From owner-dev-commits-src-all@freebsd.org Mon Aug 9 00:28:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F165966B02B; Mon, 9 Aug 2021 00:28: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 4GjcPG69kBz4gpf; Mon, 9 Aug 2021 00:28: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 B7F151E455; Mon, 9 Aug 2021 00:28: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 1790S29X006535; Mon, 9 Aug 2021 00:28:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1790S2fP006534; Mon, 9 Aug 2021 00:28:02 GMT (envelope-from git) Date: Mon, 9 Aug 2021 00:28:02 GMT Message-Id: <202108090028.1790S2fP006534@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: d8789cd0ae27 - main - mmc_fdt_helper: correct typo in DT property name MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d8789cd0ae278a86f92247a87d98bb54f15b5592 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 00:28:03 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=d8789cd0ae278a86f92247a87d98bb54f15b5592 commit d8789cd0ae278a86f92247a87d98bb54f15b5592 Author: Bartłomiej Grzesik AuthorDate: 2021-07-15 15:08:16 +0000 Commit: Marcin Wojtas CommitDate: 2021-08-09 00:27:41 +0000 mmc_fdt_helper: correct typo in DT property name 'no-1-8-v' is a proper name according to the DT binding documentation (https://www.kernel.org/doc/Documentation/devicetree/bindings/mmc/mmc-controller.yaml). Fixes: e63fbd7bb7a25 MFC after: 1 week Sponsored by: Semihalf --- sys/dev/mmc/mmc_fdt_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/mmc/mmc_fdt_helpers.c b/sys/dev/mmc/mmc_fdt_helpers.c index 175de28ac5fb..291a4bc72ff2 100644 --- a/sys/dev/mmc/mmc_fdt_helpers.c +++ b/sys/dev/mmc/mmc_fdt_helpers.c @@ -56,7 +56,7 @@ mmc_fdt_parse_sd_speed(phandle_t node, struct mmc_host *host) * Parse SD supported modes * All UHS-I modes requires 1.8V signaling. */ - if (OF_hasprop(node, "no1-8-v")) + if (OF_hasprop(node, "no-1-8-v")) no_18v = true; if (OF_hasprop(node, "cap-sd-highspeed")) host->caps |= MMC_CAP_HSPEED; From owner-dev-commits-src-all@freebsd.org Mon Aug 9 01:54:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C398766BBEB; Mon, 9 Aug 2021 01:54: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 4GjfKT4wS2z4lNr; Mon, 9 Aug 2021 01:54: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 9120C1FAF2; Mon, 9 Aug 2021 01:54: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 1791srOd025291; Mon, 9 Aug 2021 01:54:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1791srNj025290; Mon, 9 Aug 2021 01:54:53 GMT (envelope-from git) Date: Mon, 9 Aug 2021 01:54:53 GMT Message-Id: <202108090154.1791srNj025290@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 696fca3fd491 - main - Optimize res_find(). 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/main X-Git-Reftype: branch X-Git-Commit: 696fca3fd491972e615195f2ce94598b9c469cac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 01:54:53 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=696fca3fd491972e615195f2ce94598b9c469cac commit 696fca3fd491972e615195f2ce94598b9c469cac Author: Alexander Motin AuthorDate: 2021-08-09 01:34:33 +0000 Commit: Alexander Motin CommitDate: 2021-08-09 01:54:49 +0000 Optimize res_find(). When the device name is provided, we can simply run strncmp() for each line to quickly skip unrelated ones, that is much faster than sscanf() and only then strcmp(). MFC after: 2 weeks --- sys/kern/subr_hints.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index 3614659ebcf2..b16761d7d6fc 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -127,7 +127,7 @@ res_find(char **hintp_cookie, int *line, int *startln, const char **ret_name, int *ret_namelen, int *ret_unit, const char **ret_resname, int *ret_resnamelen, const char **ret_value) { - int fbacklvl = FBACK_MDENV, i = 0, n = 0; + int fbacklvl = FBACK_MDENV, i = 0, n = 0, namelen; char r_name[32]; int r_unit; char r_resname[32]; @@ -229,12 +229,16 @@ fallback: i = 0; } + if (name) + namelen = strlen(name); cp = hintp; while (cp) { (*line)++; if (strncmp(cp, "hint.", 5) != 0) goto nexthint; - n = sscanf(cp, "hint.%32[^.].%d.%32[^=]=%127s", r_name, &r_unit, + if (name && strncmp(cp + 5, name, namelen) != 0) + goto nexthint; + n = sscanf(cp + 5, "%32[^.].%d.%32[^=]=%127s", r_name, &r_unit, r_resname, r_value); if (n != 4) { printf("CONFIG: invalid hint '%s'\n", cp); From owner-dev-commits-src-all@freebsd.org Mon Aug 9 08:00:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F1182650315; Mon, 9 Aug 2021 08:00: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 4GjpQx6P6Sz3Qsd; Mon, 9 Aug 2021 08:00: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 C2C2A2464A; Mon, 9 Aug 2021 08:00: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 17980999012397; Mon, 9 Aug 2021 08:00:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179809oj012393; Mon, 9 Aug 2021 08:00:09 GMT (envelope-from git) Date: Mon, 9 Aug 2021 08:00:09 GMT Message-Id: <202108090800.179809oj012393@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: a8d54fc903cc - main - ipv6: Fix getsockopt() for some IPPROTO_IPV6 level socket options MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a8d54fc903cca354572ddd7a890baefd81baa7e8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 08:00:10 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=a8d54fc903cca354572ddd7a890baefd81baa7e8 commit a8d54fc903cca354572ddd7a890baefd81baa7e8 Author: Michael Tuexen AuthorDate: 2021-08-09 07:23:42 +0000 Commit: Michael Tuexen CommitDate: 2021-08-09 07:29:13 +0000 ipv6: Fix getsockopt() for some IPPROTO_IPV6 level socket options Fix getsockopt() for the IPPROTO_IPV6 level socket options with the following names: IPV6_HOPOPTS, IPV6_RTHDR, IPV6_RTHDRDSTOPTS, IPV6_DSTOPTS, and IPV6_NEXTHOP. Reviewed by: markj MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D31458 --- sys/netinet6/ip6_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 71c5c4e5a501..fedb6c6b6c78 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -2584,7 +2584,7 @@ ip6_pcbopt(int optname, u_char *buf, int len, struct ip6_pktopts **pktopt, pktopt = inp->in6p_outputopts; \ if (pktopt && pktopt->field) { \ optdatalen = min(lenexpr, sopt->sopt_valsize); \ - bcopy(&pktopt->field, optdata, optdatalen); \ + bcopy(pktopt->field, optdata, optdatalen); \ } else { \ free(optdata, M_TEMP); \ optdata = NULL; \ From owner-dev-commits-src-all@freebsd.org Mon Aug 9 08:23:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 089BF65096D; Mon, 9 Aug 2021 08:23: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 4Gjpxl6hRCz3j0R; Mon, 9 Aug 2021 08:23: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 CE36A24DA9; Mon, 9 Aug 2021 08:23: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 1798NNm7048452; Mon, 9 Aug 2021 08:23:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1798NNf2048451; Mon, 9 Aug 2021 08:23:23 GMT (envelope-from git) Date: Mon, 9 Aug 2021 08:23:23 GMT Message-Id: <202108090823.1798NNf2048451@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: e6847536a89a - stable/13 - loader: cstyle cleanup of libsa/lseek.c 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: e6847536a89a7f35a0372bb46cee6f939ed78919 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 08:23:24 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=e6847536a89a7f35a0372bb46cee6f939ed78919 commit e6847536a89a7f35a0372bb46cee6f939ed78919 Author: Toomas Soome AuthorDate: 2021-08-01 07:07:32 +0000 Commit: Toomas Soome CommitDate: 2021-08-08 13:17:13 +0000 loader: cstyle cleanup of libsa/lseek.c Clean up lseek.c, no functional changes intended. This is pre-patch for open file list rewrite. MFC after: 1 week (cherry-picked from commit bbb539b83ceced2d355893ead5987193737833fd) --- stand/libsa/lseek.c | 137 ++++++++++++++++++++++++++-------------------------- 1 file changed, 69 insertions(+), 68 deletions(-) diff --git a/stand/libsa/lseek.c b/stand/libsa/lseek.c index df2591acd76d..1a39eb31421b 100644 --- a/stand/libsa/lseek.c +++ b/stand/libsa/lseek.c @@ -32,30 +32,30 @@ * SUCH DAMAGE. * * @(#)lseek.c 8.1 (Berkeley) 6/11/93 - * + * * * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University * All Rights Reserved. * * Author: Alessandro Forin - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. */ @@ -68,74 +68,75 @@ __FBSDID("$FreeBSD$"); off_t lseek(int fd, off_t offset, int where) { - off_t bufpos, filepos, target; - struct open_file *f = &files[fd]; + off_t bufpos, filepos, target; + struct open_file *f = &files[fd]; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { - errno = EBADF; - return (-1); - } - - if (f->f_flags & F_RAW) { - /* - * On RAW devices, update internal offset. - */ - switch (where) { - case SEEK_SET: - f->f_offset = offset; - break; - case SEEK_CUR: - f->f_offset += offset; - break; - default: - errno = EOFFSET; - return (-1); + if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + errno = EBADF; + return (-1); } - return (f->f_offset); - } - /* - * If there is some unconsumed data in the readahead buffer and it - * contains the desired offset, simply adjust the buffer offset and - * length. We don't bother with SEEK_END here, since the code to - * handle it would fail in the same cases where the non-readahead - * code fails (namely, for streams which cannot seek backward and whose - * size isn't known in advance). - */ - if (f->f_ralen != 0 && where != SEEK_END) { - if ((filepos = (f->f_ops->fo_seek)(f, (off_t)0, SEEK_CUR)) == -1) - return (-1); - bufpos = filepos - f->f_ralen; - switch (where) { - case SEEK_SET: - target = offset; - break; - case SEEK_CUR: - target = bufpos + offset; - break; - default: - errno = EINVAL; - return (-1); + if (f->f_flags & F_RAW) { + /* + * On RAW devices, update internal offset. + */ + switch (where) { + case SEEK_SET: + f->f_offset = offset; + break; + case SEEK_CUR: + f->f_offset += offset; + break; + default: + errno = EOFFSET; + return (-1); + } + return (f->f_offset); } - if (bufpos <= target && target < filepos) { - f->f_raoffset += target - bufpos; - f->f_ralen -= target - bufpos; - return (target); + + /* + * If there is some unconsumed data in the readahead buffer and it + * contains the desired offset, simply adjust the buffer offset and + * length. We don't bother with SEEK_END here, since the code to + * handle it would fail in the same cases where the non-readahead + * code fails (namely, for streams which cannot seek backward and whose + * size isn't known in advance). + */ + if (f->f_ralen != 0 && where != SEEK_END) { + filepos = (f->f_ops->fo_seek)(f, 0, SEEK_CUR); + if (filepos == -1) + return (-1); + bufpos = filepos - f->f_ralen; + switch (where) { + case SEEK_SET: + target = offset; + break; + case SEEK_CUR: + target = bufpos + offset; + break; + default: + errno = EINVAL; + return (-1); + } + if (bufpos <= target && target < filepos) { + f->f_raoffset += target - bufpos; + f->f_ralen -= target - bufpos; + return (target); + } } - } - /* - * If this is a relative seek, we need to correct the offset for - * bytes that we have already read but the caller doesn't know - * about. - */ - if (where == SEEK_CUR) - offset -= f->f_ralen; + /* + * If this is a relative seek, we need to correct the offset for + * bytes that we have already read but the caller doesn't know + * about. + */ + if (where == SEEK_CUR) + offset -= f->f_ralen; - /* - * Invalidate the readahead buffer. - */ - f->f_ralen = 0; + /* + * Invalidate the readahead buffer. + */ + f->f_ralen = 0; - return (f->f_ops->fo_seek)(f, offset, where); + return (f->f_ops->fo_seek)(f, offset, where); } From owner-dev-commits-src-all@freebsd.org Mon Aug 9 08:25:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 07A0F650E0B; Mon, 9 Aug 2021 08:25: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 4Gjq0g6n95z3hxw; Mon, 9 Aug 2021 08:25: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 CCE0A24DAA; Mon, 9 Aug 2021 08:25: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 1798PtZD048737; Mon, 9 Aug 2021 08:25:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1798PtEC048736; Mon, 9 Aug 2021 08:25:55 GMT (envelope-from git) Date: Mon, 9 Aug 2021 08:25:55 GMT Message-Id: <202108090825.1798PtEC048736@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: e6639057146d - stable/13 - loader: tftp client should use server address from rootip 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: e6639057146de16e4883512a900dd9a53705f477 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 08:25:56 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=e6639057146de16e4883512a900dd9a53705f477 commit e6639057146de16e4883512a900dd9a53705f477 Author: Toomas Soome AuthorDate: 2021-08-02 12:27:38 +0000 Commit: Toomas Soome CommitDate: 2021-08-08 13:21:07 +0000 loader: tftp client should use server address from rootip servip is set from bootp bp_siaddr (if present) and rootip is set immediately from servip in tha sane bootp code. However, the common/dev_net.c does only set rootip (based on url processing etc). Therefore, we should also use rootip in tftp reader. Fixes hung tftp based boot when bp_siaddr is not provided. MFC after: 1 week (cherry-picked from commit 1b1bb6f178802a4522824e0268634a99cdbda098) --- stand/libsa/tftp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/stand/libsa/tftp.c b/stand/libsa/tftp.c index 3892f2aad86a..22e03ab58da1 100644 --- a/stand/libsa/tftp.c +++ b/stand/libsa/tftp.c @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); * Simple TFTP implementation for libsa. * Assumes: * - socket descriptor (int) at open_file->f_devdata - * - server host IP in global servip + * - server host IP in global rootip * Restrictions: * - read only * - lseek only with SEEK_SET or SEEK_CUR @@ -83,8 +83,6 @@ struct fs_ops tftp_fsops = { .fo_readdir = null_readdir }; -extern struct in_addr servip; - static int tftpport = 2000; static int is_open = 0; @@ -460,7 +458,7 @@ tftp_open(const char *path, struct open_file *f) return (EINVAL); } - io->destip = servip; + io->destip = rootip; tftpfile->off = 0; pathsize = (strlen(rootpath) + 1 + strlen(path) + 1) * sizeof(char); tftpfile->path = malloc(pathsize); From owner-dev-commits-src-all@freebsd.org Mon Aug 9 10:04:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6C9F6520E7; Mon, 9 Aug 2021 10:04: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 4Gjs9v5qTXz3q8y; Mon, 9 Aug 2021 10:04: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 AFE052639E; Mon, 9 Aug 2021 10:04: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 179A43Vw085282; Mon, 9 Aug 2021 10:04:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179A43MD085281; Mon, 9 Aug 2021 10:04:03 GMT (envelope-from git) Date: Mon, 9 Aug 2021 10:04:03 GMT Message-Id: <202108091004.179A43MD085281@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: d9d59bb1af14 - main - ipsec: Handle ICMP NEEDFRAG message. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d9d59bb1af142e7575032dd6c51fc64580de84df Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 10:04:04 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=d9d59bb1af142e7575032dd6c51fc64580de84df commit d9d59bb1af142e7575032dd6c51fc64580de84df Author: Wojciech Macek AuthorDate: 2021-08-09 10:01:46 +0000 Commit: Wojciech Macek CommitDate: 2021-08-09 10:01:46 +0000 ipsec: Handle ICMP NEEDFRAG message. It will be needed for upcoming PMTU implementation in ipsec. For now simply create/update an entry in tcp hostcache when needed. The code is based on https://people.freebsd.org/~ae/ipsec_transport_mode_ctlinput.diff Authored by: Kornel Duleba Differential revision: https://reviews.freebsd.org/D30992 Reviewed by: tuxen Sponsored by: Stormshield Obtained from: Semihalf --- sys/netinet/raw_ip.c | 6 ++++++ sys/netipsec/ipsec.c | 4 ++++ sys/netipsec/ipsec.h | 4 ++++ sys/netipsec/ipsec6.h | 1 + sys/netipsec/ipsec_input.c | 42 ++++++++++++++++++++++++++++++++++++++++++ sys/netipsec/ipsec_mod.c | 2 ++ sys/netipsec/ipsec_support.h | 6 ++++++ sys/netipsec/subr_ipsec.c | 5 +++++ 8 files changed, 70 insertions(+) diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index afbdc14e47c4..00c95c451966 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -880,6 +880,12 @@ rip_ctlinput(int cmd, struct sockaddr *sa, void *vip) ifa_free(&ia->ia_ifa); break; +#if defined(IPSEC) || defined(IPSEC_SUPPORT) + case PRC_MSGSIZE: + if (IPSEC_ENABLED(ipv4)) + IPSEC_CTLINPUT(ipv4, cmd, sa, vip); + break; +#endif } } diff --git a/sys/netipsec/ipsec.c b/sys/netipsec/ipsec.c index cd24750607ea..dcc607a5b617 100644 --- a/sys/netipsec/ipsec.c +++ b/sys/netipsec/ipsec.c @@ -112,6 +112,7 @@ VNET_PCPUSTAT_SYSUNINIT(ipsec4stat); /* DF bit on encap. 0: clear 1: set 2: copy */ VNET_DEFINE(int, ip4_ipsec_dfbit) = 0; +VNET_DEFINE(int, ip4_ipsec_min_pmtu) = 576; VNET_DEFINE(int, ip4_esp_trans_deflev) = IPSEC_LEVEL_USE; VNET_DEFINE(int, ip4_esp_net_deflev) = IPSEC_LEVEL_USE; VNET_DEFINE(int, ip4_ah_trans_deflev) = IPSEC_LEVEL_USE; @@ -196,6 +197,9 @@ SYSCTL_INT(_net_inet_ipsec, IPSECCTL_AH_CLEARTOS, ah_cleartos, SYSCTL_INT(_net_inet_ipsec, IPSECCTL_DFBIT, dfbit, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip4_ipsec_dfbit), 0, "Do not fragment bit on encap."); +SYSCTL_INT(_net_inet_ipsec, IPSECCTL_MIN_PMTU, min_pmtu, + CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip4_ipsec_min_pmtu), 0, + "Lowest acceptable PMTU value."); SYSCTL_INT(_net_inet_ipsec, IPSECCTL_ECN, ecn, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip4_ipsec_ecn), 0, "Explicit Congestion Notification handling."); diff --git a/sys/netipsec/ipsec.h b/sys/netipsec/ipsec.h index c7a44d60f082..1f5aa1a43edc 100644 --- a/sys/netipsec/ipsec.h +++ b/sys/netipsec/ipsec.h @@ -246,6 +246,7 @@ struct ipsecstat { #define IPSECCTL_ECN 11 #define IPSECCTL_DEBUG 12 #define IPSECCTL_ESP_RANDPAD 13 +#define IPSECCTL_MIN_PMTU 14 #ifdef _KERNEL #include @@ -277,6 +278,7 @@ VNET_DECLARE(int, ip4_esp_net_deflev); VNET_DECLARE(int, ip4_ah_trans_deflev); VNET_DECLARE(int, ip4_ah_net_deflev); VNET_DECLARE(int, ip4_ipsec_dfbit); +VNET_DECLARE(int, ip4_ipsec_min_pmtu); VNET_DECLARE(int, ip4_ipsec_ecn); VNET_DECLARE(int, crypto_support); VNET_DECLARE(int, async_crypto); @@ -289,6 +291,7 @@ VNET_DECLARE(int, natt_cksum_policy); #define V_ip4_ah_trans_deflev VNET(ip4_ah_trans_deflev) #define V_ip4_ah_net_deflev VNET(ip4_ah_net_deflev) #define V_ip4_ipsec_dfbit VNET(ip4_ipsec_dfbit) +#define V_ip4_ipsec_min_pmtu VNET(ip4_ipsec_min_pmtu) #define V_ip4_ipsec_ecn VNET(ip4_ipsec_ecn) #define V_crypto_support VNET(crypto_support) #define V_async_crypto VNET(async_crypto) @@ -341,6 +344,7 @@ int ipsec4_pcbctl(struct inpcb *, struct sockopt *); int ipsec4_output(struct mbuf *, struct inpcb *); int ipsec4_capability(struct mbuf *, u_int); int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int); +int ipsec4_ctlinput(int, struct sockaddr *, void *); int ipsec4_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *); int ipsec_process_done(struct mbuf *, struct secpolicy *, struct secasvar *, u_int); diff --git a/sys/netipsec/ipsec6.h b/sys/netipsec/ipsec6.h index 6d44f9891928..aaba405ce0db 100644 --- a/sys/netipsec/ipsec6.h +++ b/sys/netipsec/ipsec6.h @@ -73,6 +73,7 @@ int ipsec6_pcbctl(struct inpcb *, struct sockopt *); int ipsec6_output(struct mbuf *, struct inpcb *); int ipsec6_capability(struct mbuf *, u_int); int ipsec6_common_input_cb(struct mbuf *, struct secasvar *, int, int); +int ipsec6_ctlinput(int, struct sockaddr *, void *); int ipsec6_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *); int ip6_ipsec_filtertunnel(struct mbuf *); diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c index 48acba68a1fe..07a3ef583be8 100644 --- a/sys/netipsec/ipsec_input.c +++ b/sys/netipsec/ipsec_input.c @@ -68,7 +68,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #ifdef INET6 @@ -266,6 +268,40 @@ ipsec4_input(struct mbuf *m, int offset, int proto) return (0); } +int +ipsec4_ctlinput(int code, struct sockaddr *sa, void *v) +{ + struct in_conninfo inc; + struct secasvar *sav; + struct icmp *icp; + struct ip *ip = v; + uint32_t pmtu, spi; + + if (code != PRC_MSGSIZE || ip == NULL) + return (EINVAL); + if (sa->sa_family != AF_INET || + sa->sa_len != sizeof(struct sockaddr_in)) + return (EAFNOSUPPORT); + + icp = __containerof(ip, struct icmp, icmp_ip); + pmtu = ntohs(icp->icmp_nextmtu); + + if (pmtu < V_ip4_ipsec_min_pmtu) + return (EINVAL); + + memcpy(&spi, (caddr_t)ip + (ip->ip_hl << 2), sizeof(spi)); + sav = key_allocsa((union sockaddr_union *)sa, ip->ip_p, spi); + if (sav == NULL) + return (ENOENT); + + key_freesav(&sav); + + memset(&inc, 0, sizeof(inc)); + inc.inc_faddr = satosin(sa)->sin_addr; + tcp_hc_updatemtu(&inc, pmtu); + return (0); +} + /* * IPsec input callback for INET protocols. * This routine is called as the transform callback. @@ -482,6 +518,12 @@ ipsec6_input(struct mbuf *m, int offset, int proto) return (0); } +int +ipsec6_ctlinput(int code, struct sockaddr *sa, void *v) +{ + return (0); +} + /* * IPsec input callback, called by the transform callback. Takes care of * filtering and other sanity checks on the processed packet. diff --git a/sys/netipsec/ipsec_mod.c b/sys/netipsec/ipsec_mod.c index 06523337f9fb..90cffde21968 100644 --- a/sys/netipsec/ipsec_mod.c +++ b/sys/netipsec/ipsec_mod.c @@ -63,6 +63,7 @@ static const struct ipsec_methods ipv4_methods = { .pcbctl = ipsec4_pcbctl, .capability = ipsec4_capability, .check_policy = ipsec4_in_reject, + .ctlinput = ipsec4_ctlinput, .hdrsize = ipsec_hdrsiz_inpcb, .udp_input = udp_ipsec_input, .udp_pcbctl = udp_ipsec_pcbctl, @@ -84,6 +85,7 @@ static const struct ipsec_methods ipv6_methods = { .pcbctl = ipsec6_pcbctl, .capability = ipsec6_capability, .check_policy = ipsec6_in_reject, + .ctlinput = ipsec6_ctlinput, .hdrsize = ipsec_hdrsiz_inpcb, }; #ifndef KLD_MODULE diff --git a/sys/netipsec/ipsec_support.h b/sys/netipsec/ipsec_support.h index b72aee20a7ae..e4d0aea906f1 100644 --- a/sys/netipsec/ipsec_support.h +++ b/sys/netipsec/ipsec_support.h @@ -134,6 +134,8 @@ extern const struct ipsec_support * const ipv6_ipsec_support; (*(proto ## _ipsec_support)->methods->capability)(m, __VA_ARGS__) #define IPSEC_HDRSIZE(proto, inp) \ (*(proto ## _ipsec_support)->methods->hdrsize)(inp) +#define IPSEC_CTLINPUT(proto, code, sa, v) \ + (*(proto ## _ipsec_support)->methods->ctlinput)(code, sa, v) #define UDPENCAP_INPUT(m, ...) \ (*ipv4_ipsec_support->methods->udp_input)(m, __VA_ARGS__) @@ -162,6 +164,8 @@ int ipsec_kmod_pcbctl(struct ipsec_support * const, struct inpcb *, struct sockopt *); int ipsec_kmod_capability(struct ipsec_support * const, struct mbuf *, u_int); size_t ipsec_kmod_hdrsize(struct ipsec_support * const, struct inpcb *); +int ipsec_kmod_ctlinput(struct ipsec_support * const, int, + struct sockaddr *, void *); int ipsec_kmod_udp_input(struct ipsec_support * const, struct mbuf *, int, int); int ipsec_kmod_udp_pcbctl(struct ipsec_support * const, struct inpcb *, struct sockopt *); @@ -185,6 +189,8 @@ int ipsec_kmod_udp_pcbctl(struct ipsec_support * const, struct inpcb *, ipsec_kmod_capability(proto ## _ipsec_support, __VA_ARGS__) #define IPSEC_HDRSIZE(proto, ...) \ ipsec_kmod_hdrsize(proto ## _ipsec_support, __VA_ARGS__) +#define IPSEC_CTLINPUT(proto, ...) \ + ipsec_kmod_ctlinput(proto ## _ipsec_support, __VA_ARGS__) #endif /* IPSEC_SUPPORT */ #endif /* _KERNEL */ #endif /* _NETIPSEC_IPSEC_SUPPORT_H_ */ diff --git a/sys/netipsec/subr_ipsec.c b/sys/netipsec/subr_ipsec.c index 37b686a7e91e..13c7336154e4 100644 --- a/sys/netipsec/subr_ipsec.c +++ b/sys/netipsec/subr_ipsec.c @@ -366,6 +366,11 @@ IPSEC_KMOD_METHOD(int, ipsec_kmod_forward, sc, (m) ) +IPSEC_KMOD_METHOD(int, ipsec_kmod_ctlinput, sc, + ctlinput, METHOD_DECL(struct ipsec_support * const sc, int code, + struct sockaddr *sa, void *v), METHOD_ARGS(code, sa, v) +) + IPSEC_KMOD_METHOD(int, ipsec_kmod_output, sc, output, METHOD_DECL(struct ipsec_support * const sc, struct mbuf *m, struct inpcb *inp), METHOD_ARGS(m, inp) From owner-dev-commits-src-all@freebsd.org Mon Aug 9 10:54:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 48685652C03; Mon, 9 Aug 2021 10:54: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 4GjtJ41MrLz3sQN; Mon, 9 Aug 2021 10:54: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 155E926CA0; Mon, 9 Aug 2021 10:54: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 179AsRXv051208; Mon, 9 Aug 2021 10:54:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179AsRUF051207; Mon, 9 Aug 2021 10:54:27 GMT (envelope-from git) Date: Mon, 9 Aug 2021 10:54:27 GMT Message-Id: <202108091054.179AsRUF051207@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 1791a628a13e - main - Clean up the arm64 fork_trampoline MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1791a628a13e0d6f69bc0b52934b05f09c986507 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 10:54:28 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=1791a628a13e0d6f69bc0b52934b05f09c986507 commit 1791a628a13e0d6f69bc0b52934b05f09c986507 Author: Andrew Turner AuthorDate: 2021-08-09 10:03:57 +0000 Commit: Andrew Turner CommitDate: 2021-08-08 21:00:32 +0000 Clean up the arm64 fork_trampoline When exiting to userspace the code is similar to the restore_registers macro in exception.S. Rework it to remove most of the non-style differences. Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/swtch.S | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index ee64f89502cc..28b6acb430fd 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -213,7 +213,21 @@ ENTRY(fork_trampoline) mov fp, #0 /* Stack traceback stops here. */ bl _C_LABEL(fork_exit) - /* Restore the registers other than x0 and x1 */ + /* + * Disable interrupts to avoid + * overwriting spsr_el1 and sp_el0 by an IRQ exception. + */ + msr daifset, #10 + + /* Restore sp, lr, elr, and spsr */ + ldp x18, lr, [sp, #TF_SP] + ldp x10, x11, [sp, #TF_ELR] + msr sp_el0, x18 + msr spsr_el1, x11 + msr elr_el1, x10 + + /* Restore the CPU registers */ + ldp x0, x1, [sp, #TF_X + 0 * 8] ldp x2, x3, [sp, #TF_X + 2 * 8] ldp x4, x5, [sp, #TF_X + 4 * 8] ldp x6, x7, [sp, #TF_X + 6 * 8] @@ -222,33 +236,13 @@ ENTRY(fork_trampoline) ldp x12, x13, [sp, #TF_X + 12 * 8] ldp x14, x15, [sp, #TF_X + 14 * 8] ldp x16, x17, [sp, #TF_X + 16 * 8] - ldr x19, [sp, #TF_X + 19 * 8] + ldp x18, x19, [sp, #TF_X + 18 * 8] ldp x20, x21, [sp, #TF_X + 20 * 8] ldp x22, x23, [sp, #TF_X + 22 * 8] ldp x24, x25, [sp, #TF_X + 24 * 8] ldp x26, x27, [sp, #TF_X + 26 * 8] ldp x28, x29, [sp, #TF_X + 28 * 8] - /* - * Disable interrupts to avoid - * overwriting spsr_el1 and sp_el0 by an IRQ exception. - */ - msr daifset, #2 - - /* Restore sp and lr */ - ldp x0, x1, [sp, #TF_SP] - msr sp_el0, x0 - mov lr, x1 - - /* Restore elr and spsr */ - ldp x0, x1, [sp, #TF_ELR] - msr elr_el1, x0 - msr spsr_el1, x1 - - /* Finally x0 and x1 */ - ldp x0, x1, [sp, #TF_X + 0 * 8] - ldr x18, [sp, #TF_X + 18 * 8] - /* * No need for interrupts reenabling since PSR * will be set to the desired value anyway. From owner-dev-commits-src-all@freebsd.org Mon Aug 9 10:54:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 545CA652441; Mon, 9 Aug 2021 10:54: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 4GjtJ51zdTz3sYh; Mon, 9 Aug 2021 10:54: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 2D3CC26E8D; Mon, 9 Aug 2021 10:54: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 179AsTkW051239; Mon, 9 Aug 2021 10:54:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179AsTdE051238; Mon, 9 Aug 2021 10:54:29 GMT (envelope-from git) Date: Mon, 9 Aug 2021 10:54:29 GMT Message-Id: <202108091054.179AsTdE051238@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 337eb2ab9549 - main - Add macros for the arm64 daifset/daifclr flags MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 337eb2ab9549b230926ab52857d1ef86ba121366 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 10:54:29 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=337eb2ab9549b230926ab52857d1ef86ba121366 commit 337eb2ab9549b230926ab52857d1ef86ba121366 Author: Andrew Turner AuthorDate: 2021-08-03 13:18:07 +0000 Commit: Andrew Turner CommitDate: 2021-08-08 21:01:55 +0000 Add macros for the arm64 daifset/daifclr flags Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/exception.S | 6 +++--- sys/arm64/arm64/locore.S | 2 +- sys/arm64/arm64/swtch.S | 3 ++- sys/arm64/include/armreg.h | 9 +++++++++ sys/arm64/include/cpufunc.h | 8 ++++---- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S index 9a28a5eac022..67233daf4442 100644 --- a/sys/arm64/arm64/exception.S +++ b/sys/arm64/arm64/exception.S @@ -75,7 +75,7 @@ __FBSDID("$FreeBSD$"); ldr x0, [x18, #(PC_CURTHREAD)] bl dbg_monitor_enter - msr daifclr, #8 /* Enable the debug exception */ + msr daifclr, #DAIF_D /* Enable the debug exception */ .endif /* * For EL1, debug exceptions are conditionally unmasked in @@ -90,7 +90,7 @@ __FBSDID("$FreeBSD$"); * interrupt exception handler. For EL0 exceptions, do_ast already * did this. */ - msr daifset, #10 + msr daifset, #(DAIF_D | DAIF_INTR) .endif .if \el == 0 ldr x0, [x18, #PC_CURTHREAD] @@ -148,7 +148,7 @@ __FBSDID("$FreeBSD$"); bic x19, x19, #PSR_I 1: /* Disable interrupts */ - msr daifset, #10 + msr daifset, #(DAIF_D | DAIF_INTR) /* Read the current thread flags */ ldr x1, [x18, #PC_CURTHREAD] /* Load curthread */ diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index a7e0c87bec0e..dcc370326671 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -168,7 +168,7 @@ END(_start) */ ENTRY(mpentry) /* Disable interrupts */ - msr daifset, #2 + msr daifset, #DAIF_INTR /* Drop to EL1 */ bl drop_to_el1 diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index 28b6acb430fd..266a5343d7cb 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -34,6 +34,7 @@ #include "opt_sched.h" #include +#include __FBSDID("$FreeBSD$"); @@ -217,7 +218,7 @@ ENTRY(fork_trampoline) * Disable interrupts to avoid * overwriting spsr_el1 and sp_el0 by an IRQ exception. */ - msr daifset, #10 + msr daifset, #(DAIF_D | DAIF_INTR) /* Restore sp, lr, elr, and spsr */ ldp x18, lr, [sp, #TF_SP] diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 6a5640ec5e3d..8c7c535e4277 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -130,6 +130,15 @@ #define DAIF_I_MASKED (1 << 7) #define DAIF_F_MASKED (1 << 6) +/* DAIFSet/DAIFClear */ +#define DAIF_D (1 << 3) +#define DAIF_A (1 << 2) +#define DAIF_I (1 << 1) +#define DAIF_F (1 << 0) +#define DAIF_ALL (DAIF_D | DAIF_A | DAIF_I | DAIF_F) +#define DAIF_INTR (DAIF_I) /* All exceptions that pass */ + /* through the intr framework */ + /* DCZID_EL0 - Data Cache Zero ID register */ #define DCZID_DZP (1 << 4) /* DC ZVA prohibited if non-0 */ #define DCZID_BS_SHIFT 0 diff --git a/sys/arm64/include/cpufunc.h b/sys/arm64/include/cpufunc.h index 5400f253f9a2..7f13972e838b 100644 --- a/sys/arm64/include/cpufunc.h +++ b/sys/arm64/include/cpufunc.h @@ -106,7 +106,7 @@ dbg_disable(void) __asm __volatile( "mrs %x0, daif \n" - "msr daifset, #8 \n" + "msr daifset, #(" __XSTRING(DAIF_D) ") \n" : "=&r" (ret)); return (ret); @@ -116,7 +116,7 @@ static __inline void dbg_enable(void) { - __asm __volatile("msr daifclr, #8"); + __asm __volatile("msr daifclr, #(" __XSTRING(DAIF_D) ")"); } static __inline register_t @@ -127,7 +127,7 @@ intr_disable(void) __asm __volatile( "mrs %x0, daif \n" - "msr daifset, #2 \n" + "msr daifset, #(" __XSTRING(DAIF_INTR) ") \n" : "=&r" (ret)); return (ret); @@ -144,7 +144,7 @@ static __inline void intr_enable(void) { - __asm __volatile("msr daifclr, #2"); + __asm __volatile("msr daifclr, #(" __XSTRING(DAIF_INTR) ")"); } static __inline register_t From owner-dev-commits-src-all@freebsd.org Mon Aug 9 11:20:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B107D652F4D; Mon, 9 Aug 2021 11:20: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 4Gjtt34JvFz3tYY; Mon, 9 Aug 2021 11:20: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 7B474269EB; Mon, 9 Aug 2021 11:20: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 179BKRtt087963; Mon, 9 Aug 2021 11:20:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179BKRXm087962; Mon, 9 Aug 2021 11:20:27 GMT (envelope-from git) Date: Mon, 9 Aug 2021 11:20:27 GMT Message-Id: <202108091120.179BKRXm087962@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 267d55fa2a74 - main - Remove an unused arm64 panic string MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 267d55fa2a74a6e04eb760e4cbb07c7f66729ac9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 11:20:27 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=267d55fa2a74a6e04eb760e4cbb07c7f66729ac9 commit 267d55fa2a74a6e04eb760e4cbb07c7f66729ac9 Author: Andrew Turner AuthorDate: 2021-08-08 21:28:25 +0000 Commit: Andrew Turner CommitDate: 2021-08-08 21:28:25 +0000 Remove an unused arm64 panic string This was added early in the development of the arm64 port when cpu_switch was just a stub. It should have been removed when cpu_switch was implemented, however this didn't seem to be the case, and the '%p' was added. As this hasn't been needed in 7 years we can remove it. Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/swtch.S | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index 266a5343d7cb..5d0cf1c59465 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -203,8 +203,6 @@ ENTRY(cpu_switch) str xzr, [x4, #PCB_REGS + 18 * 8] ret -.Lcpu_switch_panic_str: - .asciz "cpu_switch: %p\0" END(cpu_switch) ENTRY(fork_trampoline) From owner-dev-commits-src-all@freebsd.org Mon Aug 9 11:45:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E27A1653221; Mon, 9 Aug 2021 11:45: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 4GjvRK64TKz3vdt; Mon, 9 Aug 2021 11:45:49 +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 B5B9727751; Mon, 9 Aug 2021 11:45:49 +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 179BjnXC019455; Mon, 9 Aug 2021 11:45:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179Bjnlp019454; Mon, 9 Aug 2021 11:45:49 GMT (envelope-from git) Date: Mon, 9 Aug 2021 11:45:49 GMT Message-Id: <202108091145.179Bjnlp019454@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 8b9f6d62f75a - main - nanobsd: Correct a typo in a comment 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/main X-Git-Reftype: branch X-Git-Commit: 8b9f6d62f75a367459997e5bb27d86d0302aedd2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 11:45:49 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=8b9f6d62f75a367459997e5bb27d86d0302aedd2 commit 8b9f6d62f75a367459997e5bb27d86d0302aedd2 Author: Gordon Bergling AuthorDate: 2021-08-09 11:45:10 +0000 Commit: Gordon Bergling CommitDate: 2021-08-09 11:45:10 +0000 nanobsd: Correct a typo in a comment - s/partion/partition/ MFC after: 3 days --- tools/tools/nanobsd/embedded/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common index 7186aa5ba4b5..f3be05ae857a 100644 --- a/tools/tools/nanobsd/embedded/common +++ b/tools/tools/nanobsd/embedded/common @@ -574,7 +574,7 @@ eval std_${NANO_ARCH} # Slice 4: FreeBSD partition (empty) # on first boot, we resize slice 3 & 4 to be 1/2 of what's # left over on the SD card after slice 1 and 2 are taken -# off the top. We also resize the 'a' partion on first boot +# off the top. We also resize the 'a' partition on first boot # to the size of the partition for the ping/pong upgrade. # This feature needs support in the rc.d bootup script. # From owner-dev-commits-src-all@freebsd.org Mon Aug 9 11:53:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 965F365378B; Mon, 9 Aug 2021 11:53: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 4Gjvck3kdJz3vqn; Mon, 9 Aug 2021 11:53: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 6835D27B00; Mon, 9 Aug 2021 11:53: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 179BrwiE032958; Mon, 9 Aug 2021 11:53:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179BrwpL032957; Mon, 9 Aug 2021 11:53:58 GMT (envelope-from git) Date: Mon, 9 Aug 2021 11:53:58 GMT Message-Id: <202108091153.179BrwpL032957@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 6bddade6114a - main - mkimg(1): Correct a typo in the usage output 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/main X-Git-Reftype: branch X-Git-Commit: 6bddade6114abacacb30ef2c28781f1af331c106 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 11:53:58 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=6bddade6114abacacb30ef2c28781f1af331c106 commit 6bddade6114abacacb30ef2c28781f1af331c106 Author: Gordon Bergling AuthorDate: 2021-08-09 11:53:30 +0000 Commit: Gordon Bergling CommitDate: 2021-08-09 11:53:30 +0000 mkimg(1): Correct a typo in the usage output - s/partion/partition/ MFC after: 5 days --- usr.bin/mkimg/mkimg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c index e5e6c036575b..71af45b5815d 100644 --- a/usr.bin/mkimg/mkimg.c +++ b/usr.bin/mkimg/mkimg.c @@ -151,7 +151,7 @@ usage(const char *why) fprintf(stderr, "\t--schemes\t- list partition schemes\n"); fprintf(stderr, "\t--version\t- show version information\n"); fputc('\n', stderr); - fprintf(stderr, "\t-a \t- mark num'th partion as active\n"); + fprintf(stderr, "\t-a \t- mark num'th partition as active\n"); fprintf(stderr, "\t-b \t- file containing boot code\n"); fprintf(stderr, "\t-c \t- minimum capacity (in bytes) of the disk\n"); fprintf(stderr, "\t-C \t- maximum capacity (in bytes) of the disk\n"); From owner-dev-commits-src-all@freebsd.org Mon Aug 9 14:00:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6EDDE654AC3; Mon, 9 Aug 2021 14:00: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 4GjyQC11Rwz4Z22; Mon, 9 Aug 2021 14:00: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 0B542150B; Mon, 9 Aug 2021 14:00: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 179E02Iq096225; Mon, 9 Aug 2021 14:00:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179E026Y096221; Mon, 9 Aug 2021 14:00:02 GMT (envelope-from git) Date: Mon, 9 Aug 2021 14:00:02 GMT Message-Id: <202108091400.179E026Y096221@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 3808ab732e6a - main - sctp: remove some set, but unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3808ab732e6a044cc101cf22027a0db2ac4ad58d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 14:00:03 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=3808ab732e6a044cc101cf22027a0db2ac4ad58d commit 3808ab732e6a044cc101cf22027a0db2ac4ad58d Author: Michael Tuexen AuthorDate: 2021-08-09 13:58:46 +0000 Commit: Michael Tuexen CommitDate: 2021-08-09 13:58:46 +0000 sctp: remove some set, but unused variables Thanks to pkasting for submitting the patch for the userland stack. MFC after: 3 days --- sys/netinet/sctp_cc_functions.c | 4 +--- sys/netinet/sctp_output.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sys/netinet/sctp_cc_functions.c b/sys/netinet/sctp_cc_functions.c index 7ad456d08d80..81b9e28f9959 100644 --- a/sys/netinet/sctp_cc_functions.c +++ b/sys/netinet/sctp_cc_functions.c @@ -685,7 +685,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, { struct sctp_nets *net; int old_cwnd; - uint32_t t_ssthresh, t_cwnd, incr; + uint32_t t_ssthresh, incr; uint64_t t_ucwnd_sbw; uint64_t t_path_mptcp; uint64_t mptcp_like_alpha; @@ -694,7 +694,6 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, /* MT FIXME: Don't compute this over and over again */ t_ssthresh = 0; - t_cwnd = 0; t_ucwnd_sbw = 0; t_path_mptcp = 0; mptcp_like_alpha = 1; @@ -704,7 +703,6 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, max_path = 0; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { t_ssthresh += net->ssthresh; - t_cwnd += net->cwnd; /* lastsa>>3; we don't need to devide ... */ srtt = net->lastsa; if (srtt > 0) { diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 5e9aff7bfba9..07635851c62d 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -12471,7 +12471,7 @@ sctp_lower_sosend(struct socket *so, { struct epoch_tracker et; ssize_t sndlen = 0, max_len, local_add_more; - int error, len; + int error; struct mbuf *top = NULL; int queue_only = 0, queue_only_for_init = 0; int free_cnt_applied = 0; @@ -13031,7 +13031,6 @@ sctp_lower_sosend(struct socket *so, */ local_add_more = sndlen; } - len = 0; if (non_blocking) { goto skip_preblock; } @@ -13232,7 +13231,6 @@ skip_preblock: } sctp_snd_sb_alloc(stcb, sndout); atomic_add_int(&sp->length, sndout); - len += sndout; if (sinfo_flags & SCTP_SACK_IMMEDIATELY) { sp->sinfo_flags |= SCTP_SACK_IMMEDIATELY; } From owner-dev-commits-src-all@freebsd.org Mon Aug 9 15:55:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C6D74656F26; Mon, 9 Aug 2021 15:55: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 4Gk0zB4zBcz4myM; Mon, 9 Aug 2021 15:55: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 932632A53; Mon, 9 Aug 2021 15:55: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 179FtIKo054743; Mon, 9 Aug 2021 15:55:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179FtIxN054742; Mon, 9 Aug 2021 15:55:18 GMT (envelope-from git) Date: Mon, 9 Aug 2021 15:55:18 GMT Message-Id: <202108091555.179FtIxN054742@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brad Davis Subject: git: fd17ea8c1849 - main - release: make pkg installs more robust MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fd17ea8c1849039c436f7192ca407db70561df03 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 15:55:18 -0000 The branch main has been updated by brd: URL: https://cgit.FreeBSD.org/src/commit/?id=fd17ea8c1849039c436f7192ca407db70561df03 commit fd17ea8c1849039c436f7192ca407db70561df03 Author: Brad Davis AuthorDate: 2021-08-09 15:47:03 +0000 Commit: Brad Davis CommitDate: 2021-08-09 15:54:08 +0000 release: make pkg installs more robust Currently pkg(8) will fail to install any package if one is missing, so make this a loop to prevent one missing package from preventing the rest from installing. Seen building an AWS AMI for aarch64 on main and ebsnvme-id is not available in the repo at the moment. Approved by: gjb MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/tools/vmimage.subr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 6e0c1ea633e2..0e7edb97854a 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -131,8 +131,10 @@ vm_extra_install_packages() { mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg bootstrap -y - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ - /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} + for p in ${ASSUME_ALWAYS_YES}; do + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ + /usr/sbin/pkg install -y ${p} + done umount_loop ${DESTDIR}/dev return 0 From owner-dev-commits-src-all@freebsd.org Mon Aug 9 16:06:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 629E66571AF; Mon, 9 Aug 2021 16:06:16 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mx.blih.net (mail.blih.net [212.83.155.74]) (using TLSv1.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 (2048 bits) client-digest SHA256) (Client CN "mx.blih.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gk1Cq5jQYz4nm4; Mon, 9 Aug 2021 16:06:15 +0000 (UTC) (envelope-from manu@bidouilliste.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1628525168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cOuKk7HjDtP83Dlev83SAVZU0IL+xTm3NFUJBnXUPqI=; b=LG4UKBbIeVpfv5N4g5slQHJ1o0VCjjRPnbfzfXETJgbKhtxpfXJmSTxwCt9JQHiHxQDArz 5U3bW9rzVStEdo7H/Qjn+Ewjr0rKZXwJP8f3Q5IHWB6jv43VLZsF+orWE7ik2BnrbhKfCx MjiseVWpP4YCbIDgJmYqIeUdeYV2c+U= Received: from skull.home.blih.net (lfbn-idf2-1-644-4.w86-247.abo.wanadoo.fr [86.247.100.4]) by mx.blih.net (OpenSMTPD) with ESMTPSA id f403319a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 9 Aug 2021 16:06:08 +0000 (UTC) Date: Mon, 9 Aug 2021 18:06:08 +0200 From: Emmanuel Vadot To: Brad Davis Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: fd17ea8c1849 - main - release: make pkg installs more robust Message-Id: <20210809180608.2e09a6d2d2c5f6ec1d586546@bidouilliste.com> In-Reply-To: <202108091555.179FtIxN054742@gitrepo.freebsd.org> References: <202108091555.179FtIxN054742@gitrepo.freebsd.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Gk1Cq5jQYz4nm4 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 16:06:16 -0000 On Mon, 9 Aug 2021 15:55:18 GMT Brad Davis wrote: > The branch main has been updated by brd: > > URL: https://cgit.FreeBSD.org/src/commit/?id=fd17ea8c1849039c436f7192ca407db70561df03 > > commit fd17ea8c1849039c436f7192ca407db70561df03 > Author: Brad Davis > AuthorDate: 2021-08-09 15:47:03 +0000 > Commit: Brad Davis > CommitDate: 2021-08-09 15:54:08 +0000 > > release: make pkg installs more robust > > Currently pkg(8) will fail to install any package if one is missing, so > make this a loop to prevent one missing package from preventing the rest > from installing. Seen building an AWS AMI for aarch64 on main and > ebsnvme-id is not available in the repo at the moment. > > Approved by: gjb > MFC after: 1 week > Sponsored by: Rubicon Communications, LLC ("Netgate") > --- > release/tools/vmimage.subr | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr > index 6e0c1ea633e2..0e7edb97854a 100644 > --- a/release/tools/vmimage.subr > +++ b/release/tools/vmimage.subr > @@ -131,8 +131,10 @@ vm_extra_install_packages() { > mount -t devfs devfs ${DESTDIR}/dev > chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ > /usr/sbin/pkg bootstrap -y > - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ > - /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} > + for p in ${ASSUME_ALWAYS_YES}; do > + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ > + /usr/sbin/pkg install -y ${p} > + done > umount_loop ${DESTDIR}/dev > > return 0 I assume that what you want is for p in ${VM_EXTRA_PACKAGES} ... -- Emmanuel Vadot From owner-dev-commits-src-all@freebsd.org Mon Aug 9 16:06:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2123E657281; Mon, 9 Aug 2021 16:06:26 +0000 (UTC) (envelope-from garga.bsd@gmail.com) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (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 4Gk1D16vGSz4njt; Mon, 9 Aug 2021 16:06:25 +0000 (UTC) (envelope-from garga.bsd@gmail.com) Received: by mail-pl1-x631.google.com with SMTP id l11so5254430plk.6; Mon, 09 Aug 2021 09:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=tsPuafF3Ii61aa2V4vYp5hGTQeND9uPPeqDjKRT4QZM=; b=tBeBZpG76oG3otiu1TSxfBoX8uOnku1Ee4rJh+OhYw5BI4DF2HT0CnMbtglTszShbK AB5EY65B1kWq3ekud7cjoNNyoz3PnyRyb14RjnpZgaxEG4ANtF4z24kwnGvkRBSDG7Bf dFwikfXQzaTzUO/tF6ayngLw+BI447ly0e/n9S2ShkZ2PJkgCeK6P7nyU/dly5m4GnsT 7gxtP0tPUqJNvXoSDK/8eQ8HbK0S7PR5JA9x9hNBLSGUmySAQzYdYbZTlBpfEaRA4S1V XF0n6g+fS+x/AeXkMo57ZaRfKa8Txkh5f0q6wS8bR++fsuyaxJy3VUKMHMfM6qkrZKb9 R6nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:references:from:organization :in-reply-to:content-transfer-encoding; bh=tsPuafF3Ii61aa2V4vYp5hGTQeND9uPPeqDjKRT4QZM=; b=Nrd5/IRdAtXy3biGeQIa3qyKoCeE8LV7khomeE2YmmpNPJZkSJ2uxVjXVDSQvFrBhh a7zDzLe5iFgnm9ct2oxyfIyyqXbUkoXPKNNJ8eYFw6TUIzuvdIx2hlX8ZeXINUeGN6GV FdQLmjW1/T4yEQ7GJAnS1pAenI+uqen6IvPIDMsiQjnczCmAViVSFnjGiTHCe16MliZj nuHSjv0RlDZhKw5tr2uauF7seelSJhqEjxopHgPN1I6x4VAVj5rMJ8GLW3mLAN81PDmJ amsQXt/hTtOCYbyHLHR3lydAPbGOcOdwglblwdpa5Koc1PvKzQ95SuFNW4KTGfO56EdW BSWw== X-Gm-Message-State: AOAM530EfrothDEPwgJTuKwk8w75mTuuz18trvQrJSmHeLQGupgP/gPW j51JKBVyX1QOBsOH02pevQ9A+t3eZIg= X-Google-Smtp-Source: ABdhPJw9diXgz946thcsEE3WyIvOPprW8Mg6Ki1Ec4B1MacFRbIXfjBgi23hQ+VP7L+vPMFMDvOuUQ== X-Received: by 2002:a17:90a:4e4e:: with SMTP id t14mr26654854pjl.8.1628525184480; Mon, 09 Aug 2021 09:06:24 -0700 (PDT) Received: from [172.21.4.113] (200-12-2-199.rev.tribenet.com.br. [200.12.2.199]) by smtp.gmail.com with UTF8SMTPSA id g23sm21625986pfk.148.2021.08.09.09.06.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Aug 2021 09:06:23 -0700 (PDT) Sender: Renato Botelho Message-ID: <7e14b7b6-5ed5-d8fa-8114-effb3c475f09@FreeBSD.org> Date: Mon, 9 Aug 2021 13:06:20 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.0 Subject: Re: git: fd17ea8c1849 - main - release: make pkg installs more robust Content-Language: en-US To: Brad Davis , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108091555.179FtIxN054742@gitrepo.freebsd.org> From: Renato Botelho Organization: FreeBSD In-Reply-To: <202108091555.179FtIxN054742@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Gk1D16vGSz4njt X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 16:06:26 -0000 On 09/08/21 12:55, Brad Davis wrote: > The branch main has been updated by brd: > > URL: https://cgit.FreeBSD.org/src/commit/?id=fd17ea8c1849039c436f7192ca407db70561df03 > > commit fd17ea8c1849039c436f7192ca407db70561df03 > Author: Brad Davis > AuthorDate: 2021-08-09 15:47:03 +0000 > Commit: Brad Davis > CommitDate: 2021-08-09 15:54:08 +0000 > > release: make pkg installs more robust > > Currently pkg(8) will fail to install any package if one is missing, so > make this a loop to prevent one missing package from preventing the rest > from installing. Seen building an AWS AMI for aarch64 on main and > ebsnvme-id is not available in the repo at the moment. > > Approved by: gjb > MFC after: 1 week > Sponsored by: Rubicon Communications, LLC ("Netgate") > --- > release/tools/vmimage.subr | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr > index 6e0c1ea633e2..0e7edb97854a 100644 > --- a/release/tools/vmimage.subr > +++ b/release/tools/vmimage.subr > @@ -131,8 +131,10 @@ vm_extra_install_packages() { > mount -t devfs devfs ${DESTDIR}/dev > chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ > /usr/sbin/pkg bootstrap -y > - chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ > - /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} > + for p in ${ASSUME_ALWAYS_YES}; do I guess you meant to use ${VM_EXTRA_PACKAGES} here, no? -- Renato Botelho From owner-dev-commits-src-all@freebsd.org Mon Aug 9 16:25:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C44736573E5; Mon, 9 Aug 2021 16:25: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 4Gk1dw51LTz4q05; Mon, 9 Aug 2021 16:25: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 947ED31E2; Mon, 9 Aug 2021 16:25: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 179GPOVm094695; Mon, 9 Aug 2021 16:25:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179GPOXQ094694; Mon, 9 Aug 2021 16:25:24 GMT (envelope-from git) Date: Mon, 9 Aug 2021 16:25:24 GMT Message-Id: <202108091625.179GPOXQ094694@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brad Davis Subject: git: be2bc82f18fb - main - release: fix copypasta MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: be2bc82f18fb544c5a62b02f6faf2e320e0e881e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 16:25:24 -0000 The branch main has been updated by brd: URL: https://cgit.FreeBSD.org/src/commit/?id=be2bc82f18fb544c5a62b02f6faf2e320e0e881e commit be2bc82f18fb544c5a62b02f6faf2e320e0e881e Author: Brad Davis AuthorDate: 2021-08-09 16:23:18 +0000 Commit: Brad Davis CommitDate: 2021-08-09 16:23:18 +0000 release: fix copypasta Approved by: gjb MFC after: 1 week X-MFC-With: fd17ea8c1849039c436f7192ca407db70561df03 Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/tools/vmimage.subr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 0e7edb97854a..c2b2e21200f1 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -131,7 +131,7 @@ vm_extra_install_packages() { mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg bootstrap -y - for p in ${ASSUME_ALWAYS_YES}; do + for p in ${VM_EXTRA_PACKAGES}; do chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg install -y ${p} done From owner-dev-commits-src-all@freebsd.org Mon Aug 9 16:37:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2905F6578E9; Mon, 9 Aug 2021 16:37:19 +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 4Gk1vg0ZkNz4qJy; Mon, 9 Aug 2021 16:37: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 EBFBA2EE7; Mon, 9 Aug 2021 16:37: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 179GbIPv008677; Mon, 9 Aug 2021 16:37:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179GbIJP008676; Mon, 9 Aug 2021 16:37:18 GMT (envelope-from git) Date: Mon, 9 Aug 2021 16:37:18 GMT Message-Id: <202108091637.179GbIJP008676@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brad Davis Subject: git: 83952a5baa33 - main - release: allow VM_EXTRA_PACKAGES to be specified in the environment MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 83952a5baa337cc257858feb4886d947ba1a60e3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 16:37:19 -0000 The branch main has been updated by brd: URL: https://cgit.FreeBSD.org/src/commit/?id=83952a5baa337cc257858feb4886d947ba1a60e3 commit 83952a5baa337cc257858feb4886d947ba1a60e3 Author: Brad Davis AuthorDate: 2021-08-09 16:31:51 +0000 Commit: Brad Davis CommitDate: 2021-08-09 16:31:51 +0000 release: allow VM_EXTRA_PACKAGES to be specified in the environment This is useful for adding extra packages to the build of an AMI. For example: env VM_EXTRA_PACKAGES="zsh" make -C release ec2ami Approved by: gjb MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/tools/azure.conf | 2 +- release/tools/ec2.conf | 4 +++- release/tools/gce.conf | 7 ++++--- release/tools/vagrant.conf | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release/tools/azure.conf b/release/tools/azure.conf index 60076984b1bd..c88651a07745 100644 --- a/release/tools/azure.conf +++ b/release/tools/azure.conf @@ -6,7 +6,7 @@ # Set to a list of packages to install. # Example: #export VM_EXTRA_PACKAGES="www/apache24" -export VM_EXTRA_PACKAGES="sysutils/azure-agent" +export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} sysutils/azure-agent" # Set to a list of third-party software to enable in rc.conf(5). # Example: diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf index 888a446659a5..2bf47b01077d 100644 --- a/release/tools/ec2.conf +++ b/release/tools/ec2.conf @@ -6,7 +6,9 @@ # Packages to install into the image we're creating. This is a deliberately # minimalist set, providing only the packages necessary to bootstrap further # package installation as specified via EC2 user-data. -export VM_EXTRA_PACKAGES="ec2-scripts firstboot-freebsd-update firstboot-pkgs isc-dhcp44-client ebsnvme-id" +export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ec2-scripts \ + firstboot-freebsd-update firstboot-pkgs isc-dhcp44-client \ + ebsnvme-id" # Include the amazon-ssm-agent package in amd64 images, since some users want # to be able to use it on systems which are not connected to the Internet. diff --git a/release/tools/gce.conf b/release/tools/gce.conf index 113784a7643e..745477f0bc8e 100644 --- a/release/tools/gce.conf +++ b/release/tools/gce.conf @@ -7,9 +7,10 @@ export VMSIZE=20g # Set to a list of packages to install. -export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs \ - google-cloud-sdk panicmail sudo sysutils/py-google-compute-engine \ - lang/python lang/python2 lang/python3" +export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} firstboot-freebsd-update \ + firstboot-pkgs \ google-cloud-sdk panicmail sudo \ + sysutils/py-google-compute-engine lang/python lang/python2 \ + lang/python3" # Set to a list of third-party software to enable in rc.conf(5). export VM_RC_LIST="ntpd sshd growfs \ diff --git a/release/tools/vagrant.conf b/release/tools/vagrant.conf index 05e7052d46c4..ebf69338b7d7 100644 --- a/release/tools/vagrant.conf +++ b/release/tools/vagrant.conf @@ -8,7 +8,8 @@ export VMSIZE=8g # Packages to install into the image we're creating. This is a deliberately # minimalist set, providing only the packages necessary to bootstrap. -export VM_EXTRA_PACKAGES="shells/bash firstboot-freebsd-update firstboot-pkgs" +export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} shells/bash \ + firstboot-freebsd-update firstboot-pkgs" # Set to a list of third-party software to enable in rc.conf(5). export VM_RC_LIST="firstboot_freebsd_update firstboot_pkgs growfs" From owner-dev-commits-src-all@freebsd.org Mon Aug 9 17:49:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F332658758; Mon, 9 Aug 2021 17:49: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 4Gk3Vt3WJQz3C2H; Mon, 9 Aug 2021 17:49: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 609D64699; Mon, 9 Aug 2021 17:49: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 179HnQog002854; Mon, 9 Aug 2021 17:49:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179HnQme002853; Mon, 9 Aug 2021 17:49:26 GMT (envelope-from git) Date: Mon, 9 Aug 2021 17:49:26 GMT Message-Id: <202108091749.179HnQme002853@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: eca9ac5a32e4 - main - vfs: Avoid a comparison with an uninitialized field in setutimes() 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/main X-Git-Reftype: branch X-Git-Commit: eca9ac5a32e432313b1c7f52f43dd11504fceef4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 17:49:26 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=eca9ac5a32e432313b1c7f52f43dd11504fceef4 commit eca9ac5a32e432313b1c7f52f43dd11504fceef4 Author: Mark Johnston AuthorDate: 2021-08-09 17:27:20 +0000 Commit: Mark Johnston CommitDate: 2021-08-09 17:27:20 +0000 vfs: Avoid a comparison with an uninitialized field in setutimes() Some filesystems, e.g., devfs, do not populate va_birthtime in their GETATTR implementations. To handle this, make sure that va_birthtime is initialized to the quasi-standard value of { VNOVAL, 0 } before calling VOP_GETATTR. Reported by: KMSAN Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31468 --- sys/kern/vfs_syscalls.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 5701932a0163..f2ed8d2a9acb 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3173,15 +3173,19 @@ setutimes(struct thread *td, struct vnode *vp, const struct timespec *ts, { struct mount *mp; struct vattr vattr; - int error, setbirthtime; + int error; + bool setbirthtime; + + setbirthtime = false; + vattr.va_birthtime.tv_sec = VNOVAL; + vattr.va_birthtime.tv_nsec = 0; if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - setbirthtime = 0; - if (numtimes < 3 && !VOP_GETATTR(vp, &vattr, td->td_ucred) && + if (numtimes < 3 && VOP_GETATTR(vp, &vattr, td->td_ucred) == 0 && timespeccmp(&ts[1], &vattr.va_birthtime, < )) - setbirthtime = 1; + setbirthtime = true; VATTR_NULL(&vattr); vattr.va_atime = ts[0]; vattr.va_mtime = ts[1]; From owner-dev-commits-src-all@freebsd.org Mon Aug 9 17:49:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B966665875B; Mon, 9 Aug 2021 17:49: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 4Gk3Vv4TWjz3C55; Mon, 9 Aug 2021 17:49: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 819A048CE; Mon, 9 Aug 2021 17:49: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 179HnRU7002883; Mon, 9 Aug 2021 17:49:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179HnR60002882; Mon, 9 Aug 2021 17:49:27 GMT (envelope-from git) Date: Mon, 9 Aug 2021 17:49:27 GMT Message-Id: <202108091749.179HnR60002882@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 8ee0826f7513 - main - in6: Enter the net epoch in in6_tmpaddrtimer() 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/main X-Git-Reftype: branch X-Git-Commit: 8ee0826f75136f6ac6443f32c582882bc31abd73 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 17:49:27 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8ee0826f75136f6ac6443f32c582882bc31abd73 commit 8ee0826f75136f6ac6443f32c582882bc31abd73 Author: Mark Johnston AuthorDate: 2021-08-09 17:14:23 +0000 Commit: Mark Johnston CommitDate: 2021-08-09 17:27:52 +0000 in6: Enter the net epoch in in6_tmpaddrtimer() We need to do so to safely traverse the ifnet list. Reviewed by: bz MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31470 --- sys/netinet6/in6_ifattach.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 02d6a2b230b4..6633a649b812 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -828,6 +828,7 @@ void in6_tmpaddrtimer(void *arg) { CURVNET_SET((struct vnet *) arg); + struct epoch_tracker et; struct nd_ifinfo *ndi; u_int8_t nullbuf[8]; struct ifnet *ifp; @@ -837,6 +838,7 @@ in6_tmpaddrtimer(void *arg) V_ip6_temp_regen_advance) * hz, in6_tmpaddrtimer, curvnet); bzero(nullbuf, sizeof(nullbuf)); + NET_EPOCH_ENTER(et); CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (ifp->if_afdata[AF_INET6] == NULL) continue; @@ -850,7 +852,7 @@ in6_tmpaddrtimer(void *arg) ndi->randomseed1, ndi->randomid); } } - + NET_EPOCH_EXIT(et); CURVNET_RESTORE(); } From owner-dev-commits-src-all@freebsd.org Mon Aug 9 17:49:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFA67658836; Mon, 9 Aug 2021 17:49: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 4Gk3Vw660Gz3BqC; Mon, 9 Aug 2021 17:49: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 B270247A4; Mon, 9 Aug 2021 17:49: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 179HnSxE002907; Mon, 9 Aug 2021 17:49:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179HnSiN002906; Mon, 9 Aug 2021 17:49:28 GMT (envelope-from git) Date: Mon, 9 Aug 2021 17:49:28 GMT Message-Id: <202108091749.179HnSiN002906@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 663428ea17e3 - main - nd6: Mark several callouts as MPSAFE 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/main X-Git-Reftype: branch X-Git-Commit: 663428ea17e3a81f4c514d2571b90a13c065b1e8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 17:49:29 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=663428ea17e3a81f4c514d2571b90a13c065b1e8 commit 663428ea17e3a81f4c514d2571b90a13c065b1e8 Author: Mark Johnston AuthorDate: 2021-08-09 17:21:43 +0000 Commit: Mark Johnston CommitDate: 2021-08-09 17:27:52 +0000 nd6: Mark several callouts as MPSAFE The use of Giant here is vestigal and does not provide any useful synchronization. Furthermore, non-MPSAFE callouts can cause the softclock threads to block waiting for long-running newbus operations to complete. Reported by: mav Reviewed by: bz MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31470 --- sys/netinet6/in6_ifattach.c | 2 +- sys/netinet6/nd6.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 6633a649b812..629509f61ac1 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -889,7 +889,7 @@ in6_ifattach_init(void *dummy) { /* Timer for regeneranation of temporary addresses randomize ID. */ - callout_init(&V_in6_tmpaddrtimer_ch, 0); + callout_init(&V_in6_tmpaddrtimer_ch, 1); callout_reset(&V_in6_tmpaddrtimer_ch, (V_ip6_temp_preferred_lifetime - V_ip6_desync_factor - V_ip6_temp_regen_advance) * hz, diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 5166186f56dc..38f03916531f 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -225,11 +225,11 @@ nd6_init(void) nd6_defrouter_init(); /* Start timers. */ - callout_init(&V_nd6_slowtimo_ch, 0); + callout_init(&V_nd6_slowtimo_ch, 1); callout_reset(&V_nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz, nd6_slowtimo, curvnet); - callout_init(&V_nd6_timer_ch, 0); + callout_init(&V_nd6_timer_ch, 1); callout_reset(&V_nd6_timer_ch, hz, nd6_timer, curvnet); nd6_dad_init(); From owner-dev-commits-src-all@freebsd.org Mon Aug 9 17:49:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2BBBB658A6D; Mon, 9 Aug 2021 17:49: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 4Gk3Vx6YT9z3BqH; Mon, 9 Aug 2021 17:49: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 C532B4913; Mon, 9 Aug 2021 17:49: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 179HnTT3002931; Mon, 9 Aug 2021 17:49:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179HnTIe002930; Mon, 9 Aug 2021 17:49:29 GMT (envelope-from git) Date: Mon, 9 Aug 2021 17:49:29 GMT Message-Id: <202108091749.179HnTIe002930@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e0cc56603518 - main - kasan.9: Note the header required for kasan_mark() 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/main X-Git-Reftype: branch X-Git-Commit: e0cc5660351834c999b64c0606c320a2ea474d01 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 17:49:30 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e0cc5660351834c999b64c0606c320a2ea474d01 commit e0cc5660351834c999b64c0606c320a2ea474d01 Author: Mark Johnston AuthorDate: 2021-08-06 01:52:49 +0000 Commit: Mark Johnston CommitDate: 2021-08-09 17:27:52 +0000 kasan.9: Note the header required for kasan_mark() Sponsored by: The FreeBSD Foundation --- share/man/man9/kasan.9 | 1 + 1 file changed, 1 insertion(+) diff --git a/share/man/man9/kasan.9 b/share/man/man9/kasan.9 index 68bcc9fdbf3a..61d8daf6c345 100644 --- a/share/man/man9/kasan.9 +++ b/share/man/man9/kasan.9 @@ -45,6 +45,7 @@ kernel configuration file: .Cd "options KASAN" .Ed .Pp +.In sys/asan.h .Ft void .Fn kasan_mark "const void *addr" "size_t size" "size_t redzsize" "uint8_t code" .Sh DESCRIPTION From owner-dev-commits-src-all@freebsd.org Mon Aug 9 17:49:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 197E46587F3; Mon, 9 Aug 2021 17:49: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 4Gk3Vy746Jz3C7P; Mon, 9 Aug 2021 17:49: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 D8932469A; Mon, 9 Aug 2021 17:49: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 179HnUll002955; Mon, 9 Aug 2021 17:49:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179HnUdn002954; Mon, 9 Aug 2021 17:49:30 GMT (envelope-from git) Date: Mon, 9 Aug 2021 17:49:30 GMT Message-Id: <202108091749.179HnUdn002954@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e54ae8258d64 - main - amd64: Fix output operand specs for the stmxcsr and vmread intrinsics 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/main X-Git-Reftype: branch X-Git-Commit: e54ae8258d6433ad2f2411dbeaa1fde6b817d5ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 17:49:31 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e54ae8258d6433ad2f2411dbeaa1fde6b817d5ef commit e54ae8258d6433ad2f2411dbeaa1fde6b817d5ef Author: Mark Johnston AuthorDate: 2021-08-09 17:28:08 +0000 Commit: Mark Johnston CommitDate: 2021-08-09 17:28:08 +0000 amd64: Fix output operand specs for the stmxcsr and vmread intrinsics This does not appear to affect code generation, at least with the default toolchain. Noticed because incorrect output specifications lead to false positives from KMSAN, as the instrumentation uses them to update shadow state for output operands. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31466 --- sys/amd64/amd64/fpu.c | 2 +- sys/amd64/vmm/intel/vmx_cpufunc.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index 20e3dd34405d..d7936b3b1922 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -79,7 +79,7 @@ __FBSDID("$FreeBSD$"); #define fxrstor(addr) __asm __volatile("fxrstor %0" : : "m" (*(addr))) #define fxsave(addr) __asm __volatile("fxsave %0" : "=m" (*(addr))) #define ldmxcsr(csr) __asm __volatile("ldmxcsr %0" : : "m" (csr)) -#define stmxcsr(addr) __asm __volatile("stmxcsr %0" : : "m" (*(addr))) +#define stmxcsr(addr) __asm __volatile("stmxcsr %0" : "=m" (*(addr))) static __inline void xrstor32(char *addr, uint64_t mask) diff --git a/sys/amd64/vmm/intel/vmx_cpufunc.h b/sys/amd64/vmm/intel/vmx_cpufunc.h index 09d6d25a18e0..05ac56290cb9 100644 --- a/sys/amd64/vmm/intel/vmx_cpufunc.h +++ b/sys/amd64/vmm/intel/vmx_cpufunc.h @@ -137,10 +137,9 @@ vmread(uint64_t r, uint64_t *addr) __asm __volatile("vmread %[r], %[addr];" VMX_SET_ERROR_CODE - : [error] "=r" (error) - : [r] "r" (r), [addr] "m" (*addr) + : [error] "=r" (error), [addr] "=m" (*addr) + : [r] "r" (r) : "memory"); - return (error); } From owner-dev-commits-src-all@freebsd.org Mon Aug 9 17:49:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A382C658841; Mon, 9 Aug 2021 17:49: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 4Gk3W02wQGz3C0Q; Mon, 9 Aug 2021 17:49: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 063214914; Mon, 9 Aug 2021 17:49: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 179HnVsX002979; Mon, 9 Aug 2021 17:49:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179HnVYC002978; Mon, 9 Aug 2021 17:49:31 GMT (envelope-from git) Date: Mon, 9 Aug 2021 17:49:31 GMT Message-Id: <202108091749.179HnVYC002978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 41335c6b7f63 - main - vmm: Make iommu ops tables const 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/main X-Git-Reftype: branch X-Git-Commit: 41335c6b7f636f9ca59d0afba5728cf90020d6b1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 17:49:32 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=41335c6b7f636f9ca59d0afba5728cf90020d6b1 commit 41335c6b7f636f9ca59d0afba5728cf90020d6b1 Author: Mark Johnston AuthorDate: 2021-08-09 17:28:27 +0000 Commit: Mark Johnston CommitDate: 2021-08-09 17:28:27 +0000 vmm: Make iommu ops tables const While here, use designated initializers and rename some AMD iommu method implementations to match the corresponding op names. No functional change intended. Reviewed by: grehan MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31462 --- sys/amd64/vmm/amd/amdvi_hw.c | 28 ++++++++++++++-------------- sys/amd64/vmm/intel/vtd.c | 24 ++++++++++++------------ sys/amd64/vmm/io/iommu.c | 2 +- sys/amd64/vmm/io/iommu.h | 4 ++-- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/sys/amd64/vmm/amd/amdvi_hw.c b/sys/amd64/vmm/amd/amdvi_hw.c index e488c5fd5f6a..57386b6bea88 100644 --- a/sys/amd64/vmm/amd/amdvi_hw.c +++ b/sys/amd64/vmm/amd/amdvi_hw.c @@ -1181,7 +1181,7 @@ amdvi_create_mapping(void *arg, vm_paddr_t gpa, vm_paddr_t hpa, } static uint64_t -amdvi_destroy_mapping(void *arg, vm_paddr_t gpa, uint64_t len) +amdvi_remove_mapping(void *arg, vm_paddr_t gpa, uint64_t len) { struct amdvi_domain *domain; @@ -1360,7 +1360,7 @@ amdvi_disable(void) } static void -amdvi_inv_tlb(void *arg) +amdvi_invalidate_tlb(void *arg) { struct amdvi_domain *domain; @@ -1369,16 +1369,16 @@ amdvi_inv_tlb(void *arg) amdvi_do_inv_domain(domain->id, false); } -struct iommu_ops iommu_ops_amd = { - amdvi_init, - amdvi_cleanup, - amdvi_enable, - amdvi_disable, - amdvi_create_domain, - amdvi_destroy_domain, - amdvi_create_mapping, - amdvi_destroy_mapping, - amdvi_add_device, - amdvi_remove_device, - amdvi_inv_tlb +const struct iommu_ops iommu_ops_amd = { + .init = amdvi_init, + .cleanup = amdvi_cleanup, + .enable = amdvi_enable, + .disable = amdvi_disable, + .create_domain = amdvi_create_domain, + .destroy_domain = amdvi_destroy_domain, + .create_mapping = amdvi_create_mapping, + .remove_mapping = amdvi_remove_mapping, + .add_device = amdvi_add_device, + .remove_device = amdvi_remove_device, + .invalidate_tlb = amdvi_invalidate_tlb }; diff --git a/sys/amd64/vmm/intel/vtd.c b/sys/amd64/vmm/intel/vtd.c index f47e2b56bdce..8f06dc823364 100644 --- a/sys/amd64/vmm/intel/vtd.c +++ b/sys/amd64/vmm/intel/vtd.c @@ -761,16 +761,16 @@ vtd_destroy_domain(void *arg) free(dom, M_VTD); } -struct iommu_ops iommu_ops_intel = { - vtd_init, - vtd_cleanup, - vtd_enable, - vtd_disable, - vtd_create_domain, - vtd_destroy_domain, - vtd_create_mapping, - vtd_remove_mapping, - vtd_add_device, - vtd_remove_device, - vtd_invalidate_tlb, +const struct iommu_ops iommu_ops_intel = { + .init = vtd_init, + .cleanup = vtd_cleanup, + .enable = vtd_enable, + .disable = vtd_disable, + .create_domain = vtd_create_domain, + .destroy_domain = vtd_destroy_domain, + .create_mapping = vtd_create_mapping, + .remove_mapping = vtd_remove_mapping, + .add_device = vtd_add_device, + .remove_device = vtd_remove_device, + .invalidate_tlb = vtd_invalidate_tlb, }; diff --git a/sys/amd64/vmm/io/iommu.c b/sys/amd64/vmm/io/iommu.c index 3fe4d299a497..6a589f153815 100644 --- a/sys/amd64/vmm/io/iommu.c +++ b/sys/amd64/vmm/io/iommu.c @@ -59,7 +59,7 @@ static int iommu_enable = 1; SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, enable, CTLFLAG_RDTUN, &iommu_enable, 0, "Enable use of I/O MMU (required for PCI passthrough)."); -static struct iommu_ops *ops; +static const struct iommu_ops *ops; static void *host_domain; static eventhandler_tag add_tag, delete_tag; diff --git a/sys/amd64/vmm/io/iommu.h b/sys/amd64/vmm/io/iommu.h index f8003a5d4552..090415b57505 100644 --- a/sys/amd64/vmm/io/iommu.h +++ b/sys/amd64/vmm/io/iommu.h @@ -60,8 +60,8 @@ struct iommu_ops { iommu_invalidate_tlb_t invalidate_tlb; }; -extern struct iommu_ops iommu_ops_intel; -extern struct iommu_ops iommu_ops_amd; +extern const struct iommu_ops iommu_ops_intel; +extern const struct iommu_ops iommu_ops_amd; void iommu_cleanup(void); void *iommu_host_domain(void); From owner-dev-commits-src-all@freebsd.org Mon Aug 9 18:39:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 036FF659617; Mon, 9 Aug 2021 18:39: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 4Gk4cy6MsJz3H41; Mon, 9 Aug 2021 18:39: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 B583F51D1; Mon, 9 Aug 2021 18:39: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 179Idkxl069145; Mon, 9 Aug 2021 18:39:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179IdkJB069144; Mon, 9 Aug 2021 18:39:46 GMT (envelope-from git) Date: Mon, 9 Aug 2021 18:39:46 GMT Message-Id: <202108091839.179IdkJB069144@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: 6f2898503a92 - stable/13 - pf: bound DIOCGETSTATES memory use 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: 6f2898503a927a44104e4ceae8ff9c765abf7ece Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 18:39:47 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6f2898503a927a44104e4ceae8ff9c765abf7ece commit 6f2898503a927a44104e4ceae8ff9c765abf7ece Author: Kristof Provost AuthorDate: 2021-08-02 07:46:33 +0000 Commit: Kristof Provost CommitDate: 2021-08-09 15:56:26 +0000 pf: bound DIOCGETSTATES memory use Similar to what we did earlier for DIOCGETSTATESV2 we only allocate enough memory for a handful of states and copy those out, bit by bit, rather than allocating memory for all states in one go. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 600745f1e2260e7ed3c2e6183b24388ff38c916c) --- sys/netpfil/pf/pf_ioctl.c | 51 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 5fd711d1c574..39931540d03d 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2840,7 +2840,9 @@ DIOCCHANGERULE_error: struct pfioc_states *ps = (struct pfioc_states *)addr; struct pf_kstate *s; struct pfsync_state *pstore, *p; - int i, nr; + int i, nr; + size_t slice_count = 16, count; + void *out; if (ps->ps_len <= 0) { nr = uma_zone_get_cur(V_pf_state_z); @@ -2848,34 +2850,59 @@ DIOCCHANGERULE_error: break; } - p = pstore = malloc(ps->ps_len, M_TEMP, M_WAITOK | M_ZERO); + out = ps->ps_states; + pstore = mallocarray(slice_count, + sizeof(struct pfsync_state), M_TEMP, M_WAITOK | M_ZERO); nr = 0; for (i = 0; i <= pf_hashmask; i++) { struct pf_idhash *ih = &V_pf_idhash[i]; +DIOCGETSTATES_retry: + p = pstore; + + if (LIST_EMPTY(&ih->states)) + continue; + PF_HASHROW_LOCK(ih); + count = 0; + LIST_FOREACH(s, &ih->states, entry) { + if (s->timeout == PFTM_UNLINKED) + continue; + count++; + } + + if (count > slice_count) { + PF_HASHROW_UNLOCK(ih); + free(pstore, M_TEMP); + slice_count = count * 2; + pstore = mallocarray(slice_count, + sizeof(struct pfsync_state), M_TEMP, + M_WAITOK | M_ZERO); + goto DIOCGETSTATES_retry; + } + + if ((nr+count) * sizeof(*p) > ps->ps_len) { + PF_HASHROW_UNLOCK(ih); + goto DIOCGETSTATES_full; + } + LIST_FOREACH(s, &ih->states, entry) { if (s->timeout == PFTM_UNLINKED) continue; - if ((nr+1) * sizeof(*p) > ps->ps_len) { - PF_HASHROW_UNLOCK(ih); - goto DIOCGETSTATES_full; - } pfsync_state_export(p, s); p++; nr++; } PF_HASHROW_UNLOCK(ih); + error = copyout(pstore, out, + sizeof(struct pfsync_state) * count); + if (error) + break; + out = ps->ps_states + nr; } DIOCGETSTATES_full: - error = copyout(pstore, ps->ps_states, - sizeof(struct pfsync_state) * nr); - if (error) { - free(pstore, M_TEMP); - break; - } ps->ps_len = sizeof(struct pfsync_state) * nr; free(pstore, M_TEMP); From owner-dev-commits-src-all@freebsd.org Mon Aug 9 18:39:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B975C6591D3; Mon, 9 Aug 2021 18:39: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 4Gk4d04wWqz3HCh; Mon, 9 Aug 2021 18:39: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 90A9351D2; Mon, 9 Aug 2021 18:39: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 179IdmMs069249; Mon, 9 Aug 2021 18:39:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179IdmaQ069248; Mon, 9 Aug 2021 18:39:48 GMT (envelope-from git) Date: Mon, 9 Aug 2021 18:39:48 GMT Message-Id: <202108091839.179IdmaQ069248@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: 42cb78bdd49c - stable/12 - pf: bound DIOCGETSTATES memory use 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: 42cb78bdd49cd9a3e834c1ba3a00c7413917c812 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 18:39:48 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=42cb78bdd49cd9a3e834c1ba3a00c7413917c812 commit 42cb78bdd49cd9a3e834c1ba3a00c7413917c812 Author: Kristof Provost AuthorDate: 2021-08-02 07:46:33 +0000 Commit: Kristof Provost CommitDate: 2021-08-09 15:57:23 +0000 pf: bound DIOCGETSTATES memory use Similar to what we did earlier for DIOCGETSTATESV2 we only allocate enough memory for a handful of states and copy those out, bit by bit, rather than allocating memory for all states in one go. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 600745f1e2260e7ed3c2e6183b24388ff38c916c) --- sys/netpfil/pf/pf_ioctl.c | 51 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 8a6286b5c21a..ea323709f6cd 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2852,7 +2852,9 @@ DIOCCHANGERULE_error: struct pfioc_states *ps = (struct pfioc_states *)addr; struct pf_kstate *s; struct pfsync_state *pstore, *p; - int i, nr; + int i, nr; + size_t slice_count = 16, count; + void *out; if (ps->ps_len <= 0) { nr = uma_zone_get_cur(V_pf_state_z); @@ -2860,35 +2862,60 @@ DIOCCHANGERULE_error: break; } - p = pstore = malloc(ps->ps_len, M_TEMP, M_WAITOK | M_ZERO); + out = ps->ps_states; + pstore = mallocarray(slice_count, + sizeof(struct pfsync_state), M_TEMP, M_WAITOK | M_ZERO); nr = 0; for (i = 0; i <= pf_hashmask; i++) { struct pf_idhash *ih = &V_pf_idhash[i]; +DIOCGETSTATES_retry: + p = pstore; + + if (LIST_EMPTY(&ih->states)) + continue; + PF_HASHROW_LOCK(ih); + count = 0; + LIST_FOREACH(s, &ih->states, entry) { + if (s->timeout == PFTM_UNLINKED) + continue; + count++; + } + + if (count > slice_count) { + PF_HASHROW_UNLOCK(ih); + free(pstore, M_TEMP); + slice_count = count * 2; + pstore = mallocarray(slice_count, + sizeof(struct pfsync_state), M_TEMP, + M_WAITOK | M_ZERO); + goto DIOCGETSTATES_retry; + } + + if ((nr+count) * sizeof(*p) > ps->ps_len) { + PF_HASHROW_UNLOCK(ih); + goto DIOCGETSTATES_full; + } + LIST_FOREACH(s, &ih->states, entry) { if (s->timeout == PFTM_UNLINKED) continue; - if ((nr+1) * sizeof(*p) > ps->ps_len) { - PF_HASHROW_UNLOCK(ih); - goto DIOCGETSTATES_full; - } pfsync_state_export(p, s); p++; nr++; } PF_HASHROW_UNLOCK(ih); + error = copyout(pstore, out, + sizeof(struct pfsync_state) * count); + if (error) + break; + out = ps->ps_states + nr; } DIOCGETSTATES_full: - error = copyout(pstore, ps->ps_states, - sizeof(struct pfsync_state) * nr); - if (error) { - free(pstore, M_TEMP); - break; - } ps->ps_len = sizeof(struct pfsync_state) * nr; free(pstore, M_TEMP); From owner-dev-commits-src-all@freebsd.org Mon Aug 9 19:04:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3B0EA65A794; Mon, 9 Aug 2021 19: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 4Gk59K0ysFz3KBv; Mon, 9 Aug 2021 19: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 094AE59AD; Mon, 9 Aug 2021 19: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 179J4Kkx009386; Mon, 9 Aug 2021 19:04:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179J4KAA009385; Mon, 9 Aug 2021 19:04:20 GMT (envelope-from git) Date: Mon, 9 Aug 2021 19:04:20 GMT Message-Id: <202108091904.179J4KAA009385@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Scott Long Subject: git: 27b8dd594d58 - main - Remove duplicate entry for arm/mv/armada38x/armada38x_rtc.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: scottl X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 27b8dd594d58dd6c004a0b0d624b9a68a7e9c849 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 19:04:21 -0000 The branch main has been updated by scottl: URL: https://cgit.FreeBSD.org/src/commit/?id=27b8dd594d58dd6c004a0b0d624b9a68a7e9c849 commit 27b8dd594d58dd6c004a0b0d624b9a68a7e9c849 Author: Scott Long AuthorDate: 2021-08-09 18:57:50 +0000 Commit: Scott Long CommitDate: 2021-08-09 18:57:50 +0000 Remove duplicate entry for arm/mv/armada38x/armada38x_rtc.c Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/files.arm64 | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 5cd1fa396171..ed3625df0c23 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -462,7 +462,6 @@ arm/mv/mv_cp110_clock.c optional SOC_MARVELL_8K fdt arm/mv/mv_cp110_icu.c optional mv_cp110_icu fdt arm/mv/mv_cp110_icu_bus.c optional mv_cp110_icu fdt arm/mv/mv_thermal.c optional SOC_MARVELL_8K mv_thermal fdt -arm/mv/armada38x/armada38x_rtc.c optional mv_rtc fdt # NVidia arm/nvidia/tegra_abpmisc.c optional fdt soc_nvidia_tegra210 From owner-dev-commits-src-all@freebsd.org Mon Aug 9 19:29:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A12AE65AAD8; Mon, 9 Aug 2021 19:29: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 4Gk5kC3wJSz3LXX; Mon, 9 Aug 2021 19:29: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 6E8665BBC; Mon, 9 Aug 2021 19:29: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 179JTNSH036197; Mon, 9 Aug 2021 19:29:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179JTNqP036196; Mon, 9 Aug 2021 19:29:23 GMT (envelope-from git) Date: Mon, 9 Aug 2021 19:29:23 GMT Message-Id: <202108091929.179JTNqP036196@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 98138bbde032 - main - riscv: Fix pmap_alloc_l2 when it should allocate a new L1 entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 98138bbde032e2040af3d158658c497fd3f63f2a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 19:29:23 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=98138bbde032e2040af3d158658c497fd3f63f2a commit 98138bbde032e2040af3d158658c497fd3f63f2a Author: Jessica Clarke AuthorDate: 2021-08-09 19:28:37 +0000 Commit: Jessica Clarke CommitDate: 2021-08-09 19:28:37 +0000 riscv: Fix pmap_alloc_l2 when it should allocate a new L1 entry The current code checks the RWX bits are 0 but does not check the V bit is non-zero, meaning not-yet-allocated L1 entries that are still zero are regarded as being allocated. This is likely due to copying the arm64 code that checks ATTR_DESC_MASK is L1_TABLE, which emcompasses both the type and the validity in a single field, and erroneously translating that to a check of just PTE_RWX being 0 to indicate non-leaf, forgetting about the V bit. This then results in the following panic: panic: Fatal page fault at 0xffffffc0005cf292: 0x00000000000050 cpuid = 1 time = 1628379581 KDB: stack backtrace: db_trace_self() at db_trace_self db_trace_self_wrapper() at db_trace_self_wrapper+0x38 kdb_backtrace() at kdb_backtrace+0x2c vpanic() at vpanic+0x148 panic() at panic+0x2a page_fault_handler() at page_fault_handler+0x1ba do_trap_supervisor() at do_trap_supervisor+0x7a cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x70 --- exception 13, tval = 0x50 pmap_enter_l2() at pmap_enter_l2+0xb2 pmap_enter_object() at pmap_enter_object+0x15e vm_map_pmap_enter() at vm_map_pmap_enter+0x228 vm_map_insert() at vm_map_insert+0x4ec vm_map_find() at vm_map_find+0x474 vm_map_find_min() at vm_map_find_min+0x52 vm_mmap_object() at vm_mmap_object+0x1ba vn_mmap() at vn_mmap+0xf8 kern_mmap() at kern_mmap+0x4c4 sys_mmap() at sys_mmap+0x38 do_trap_user() at do_trap_user+0x208 cpu_exception_handler_user() at cpu_exception_handler_user+0x72 --- exception 8, tval = 0x1dd Instead, we should just check the V bit, as on amd64, and assert that any valid L1 entries are not leaves, since an L1 leaf would render the entire range allocated and thus we should not have attempted to map that VA in the first place. Reported by: David Gilbert MFC after: 1 week Reviewed by: markj, mhorne Differential Revision: https://reviews.freebsd.org/D31460 --- sys/riscv/riscv/pmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 0bb22bd13bbe..8f76881478b9 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -1348,7 +1348,10 @@ pmap_alloc_l2(pmap_t pmap, vm_offset_t va, struct rwlock **lockp) retry: l1 = pmap_l1(pmap, va); - if (l1 != NULL && (pmap_load(l1) & PTE_RWX) == 0) { + if (l1 != NULL && (pmap_load(l1) & PTE_V) != 0) { + KASSERT((pmap_load(l1) & PTE_RWX) == 0, + ("%s: L1 entry %#lx for VA %#lx is a leaf", __func__, + pmap_load(l1), va)); /* Add a reference to the L2 page. */ l2pg = PHYS_TO_VM_PAGE(PTE_TO_PHYS(pmap_load(l1))); l2pg->ref_count++; From owner-dev-commits-src-all@freebsd.org Mon Aug 9 20:34:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D9EA065BF6A for ; Mon, 9 Aug 2021 20:34: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 4Gk79f5bmxz3Q6r; Mon, 9 Aug 2021 20:34: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 9DE3C6A41; Mon, 9 Aug 2021 20:34: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 179KYkSb029323; Mon, 9 Aug 2021 20:34:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179KYkQD029322; Mon, 9 Aug 2021 20:34:46 GMT (envelope-from git) Date: Mon, 9 Aug 2021 20:34:46 GMT Message-Id: <202108092034.179KYkQD029322@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org From: =?utf-8?Q?Stefan E=C3=9Fer?= Subject: git: 2858419a0ee2..2f57ecae4b98 - vendor/bc - vendor branch updated 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/vendor/bc X-Git-Reftype: branch X-Git-Commit: 2f57ecae4b98e76e5d675563785a7e6c59c868c4 X-Git-Oldrev: 2858419a0ee2b8f5827de72c00618bcd69ebc5fc X-Git-Newrev: 2f57ecae4b98e76e5d675563785a7e6c59c868c4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 20:34:46 -0000 The branch vendor/bc has been updated by se: URL: https://cgit.FreeBSD.org/src/log/?id=2858419a0ee2..2f57ecae4b98 3c836917985d Remove files that were checked in with wrong .gitattributes b46baf82c7ba Add back Windows only VCXProj files 2f57ecae4b98 vendor/bc: imoport release 5.0.0 From owner-dev-commits-src-all@freebsd.org Mon Aug 9 21:32:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B39A065CA27; Mon, 9 Aug 2021 21:32: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 4Gk8Sq4Qvnz3kVJ; Mon, 9 Aug 2021 21:32: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 803C4775A; Mon, 9 Aug 2021 21:32: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 179LWxRG008697; Mon, 9 Aug 2021 21:32:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 179LWxol008696; Mon, 9 Aug 2021 21:32:59 GMT (envelope-from git) Date: Mon, 9 Aug 2021 21:32:59 GMT Message-Id: <202108092132.179LWxol008696@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 015075f38348 - main - e1000: Fix lem/em UDP rx csum offload MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 015075f383489fcbedbe8aae7c1c64a3d55ca75e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 21:32:59 -0000 The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=015075f383489fcbedbe8aae7c1c64a3d55ca75e commit 015075f383489fcbedbe8aae7c1c64a3d55ca75e Author: Kevin Bowling AuthorDate: 2021-08-09 21:29:31 +0000 Commit: Kevin Bowling CommitDate: 2021-08-09 21:29:31 +0000 e1000: Fix lem/em UDP rx csum offload Rebase on igb code and unify lem/em implementations. PR: 257642 Reported by: Nick Reilly Reviewed by: karels, emaste Tested by: Nick Reilly Approved by: grehan MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31449 --- sys/dev/e1000/em_txrx.c | 67 ++++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/sys/dev/e1000/em_txrx.c b/sys/dev/e1000/em_txrx.c index 458de96a7b9d..11f6662c5b79 100644 --- a/sys/dev/e1000/em_txrx.c +++ b/sys/dev/e1000/em_txrx.c @@ -62,8 +62,7 @@ static int lem_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget); static int lem_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri); -static void lem_receive_checksum(int status, int errors, if_rxd_info_t ri); -static void em_receive_checksum(uint32_t status, if_rxd_info_t ri); +static void em_receive_checksum(uint16_t, uint8_t, if_rxd_info_t); static int em_determine_rsstype(u32 pkt_info); extern int em_intr(void *arg); @@ -646,8 +645,8 @@ lem_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) } while (!eop); /* XXX add a faster way to look this up */ - if (adapter->hw.mac.type >= e1000_82543 && !(status & E1000_RXD_STAT_IXSM)) - lem_receive_checksum(status, errors, ri); + if (adapter->hw.mac.type >= e1000_82543) + em_receive_checksum(status, errors, ri); if (status & E1000_RXD_STAT_VP) { ri->iri_vtag = le16toh(rxd->special); @@ -707,9 +706,7 @@ em_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) i++; } while (!eop); - /* XXX add a faster way to look this up */ - if (adapter->hw.mac.type >= e1000_82543) - em_receive_checksum(staterr, ri); + em_receive_checksum(staterr, staterr >> 24, ri); if (staterr & E1000_RXD_STAT_VP) { vtag = le16toh(rxd->wb.upper.vlan); @@ -734,19 +731,24 @@ em_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) * *********************************************************************/ static void -lem_receive_checksum(int status, int errors, if_rxd_info_t ri) +em_receive_checksum(uint16_t status, uint8_t errors, if_rxd_info_t ri) { - /* Did it pass? */ - if (status & E1000_RXD_STAT_IPCS && !(errors & E1000_RXD_ERR_IPE)) - ri->iri_csum_flags = (CSUM_IP_CHECKED|CSUM_IP_VALID); - - if (status & E1000_RXD_STAT_TCPCS) { - /* Did it pass? */ - if (!(errors & E1000_RXD_ERR_TCPE)) { - ri->iri_csum_flags |= - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - ri->iri_csum_data = htons(0xffff); - } + if (__predict_false(status & E1000_RXD_STAT_IXSM)) + return; + + /* If there is a layer 3 or 4 error we are done */ + if (__predict_false(errors & (E1000_RXD_ERR_IPE | E1000_RXD_ERR_TCPE))) + return; + + /* IP Checksum Good */ + if (status & E1000_RXD_STAT_IPCS) + ri->iri_csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID); + + /* Valid L4E checksum */ + if (__predict_true(status & + (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))) { + ri->iri_csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + ri->iri_csum_data = htons(0xffff); } } @@ -775,30 +777,3 @@ em_determine_rsstype(u32 pkt_info) return M_HASHTYPE_OPAQUE; } } - -static void -em_receive_checksum(uint32_t status, if_rxd_info_t ri) -{ - ri->iri_csum_flags = 0; - - /* Ignore Checksum bit is set */ - if (status & E1000_RXD_STAT_IXSM) - return; - - /* If the IP checksum exists and there is no IP Checksum error */ - if ((status & (E1000_RXD_STAT_IPCS | E1000_RXDEXT_STATERR_IPE)) == - E1000_RXD_STAT_IPCS) { - ri->iri_csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID); - } - - /* TCP or UDP checksum */ - if ((status & (E1000_RXD_STAT_TCPCS | E1000_RXDEXT_STATERR_TCPE)) == - E1000_RXD_STAT_TCPCS) { - ri->iri_csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - ri->iri_csum_data = htons(0xffff); - } - if (status & E1000_RXD_STAT_UDPCS) { - ri->iri_csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - ri->iri_csum_data = htons(0xffff); - } -} From owner-dev-commits-src-all@freebsd.org Tue Aug 10 00:49:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0D9A65F59E; Tue, 10 Aug 2021 00:49: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 4GkDqP6XJMz4dFk; Tue, 10 Aug 2021 00:49: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 C878A12612; Tue, 10 Aug 2021 00:49: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 17A0nLKo061471; Tue, 10 Aug 2021 00:49:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17A0nLin061470; Tue, 10 Aug 2021 00:49:21 GMT (envelope-from git) Date: Tue, 10 Aug 2021 00:49:21 GMT Message-Id: <202108100049.17A0nLin061470@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: fd4751b38929 - main - netipsec/keydb.h: 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/main X-Git-Reftype: branch X-Git-Commit: fd4751b3892973f3d329f6fb516da6b01be6f71f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 00:49:22 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fd4751b3892973f3d329f6fb516da6b01be6f71f commit fd4751b3892973f3d329f6fb516da6b01be6f71f Author: Konstantin Belousov AuthorDate: 2021-07-31 01:41:13 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-10 00:45:36 +0000 netipsec/keydb.h: fix typo Sponsored by: NVIDIA Networking MFC after: 3 days --- sys/netipsec/keydb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netipsec/keydb.h b/sys/netipsec/keydb.h index e3c1417a2f9a..69c1cb29db34 100644 --- a/sys/netipsec/keydb.h +++ b/sys/netipsec/keydb.h @@ -55,7 +55,7 @@ union sockaddr_union { }; #endif /* _SOCKADDR_UNION_DEFINED */ -/* Security Assocciation Index */ +/* Security Association Index */ /* NOTE: Ensure to be same address family */ struct secasindex { union sockaddr_union src; /* source address for SA */ From owner-dev-commits-src-all@freebsd.org Tue Aug 10 00:49:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 284B465F47F; Tue, 10 Aug 2021 00:49: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 4GkDqR0S4rz4dHm; Tue, 10 Aug 2021 00:49: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 EB72512479; Tue, 10 Aug 2021 00:49: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 17A0nMXW061502; Tue, 10 Aug 2021 00:49:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17A0nMJp061501; Tue, 10 Aug 2021 00:49:22 GMT (envelope-from git) Date: Tue, 10 Aug 2021 00:49:22 GMT Message-Id: <202108100049.17A0nMJp061501@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 8b000bf5bcdd - main - netipsec/key.c: Use ANSI C definition for key_random() 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/main X-Git-Reftype: branch X-Git-Commit: 8b000bf5bcddea30e66e0b4e1158e2d7b328b262 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 00:49:23 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8b000bf5bcddea30e66e0b4e1158e2d7b328b262 commit 8b000bf5bcddea30e66e0b4e1158e2d7b328b262 Author: Konstantin Belousov AuthorDate: 2021-08-03 01:24:31 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-10 00:46:24 +0000 netipsec/key.c: Use ANSI C definition for key_random() Sponsored by: NVIDIA Networking MFC after: 3 days --- sys/netipsec/key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 4ca65979d5b2..3ea3a81b90c3 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -4736,7 +4736,7 @@ key_timehandler(void *arg) } u_long -key_random() +key_random(void) { u_long value; From owner-dev-commits-src-all@freebsd.org Tue Aug 10 00:49:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ABD8065F515; Tue, 10 Aug 2021 00:49: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 4GkDqS26MSz4dL9; Tue, 10 Aug 2021 00:49: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 164351247A; Tue, 10 Aug 2021 00:49: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 17A0nOs6061526; Tue, 10 Aug 2021 00:49:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17A0nOHC061525; Tue, 10 Aug 2021 00:49:24 GMT (envelope-from git) Date: Tue, 10 Aug 2021 00:49:24 GMT Message-Id: <202108100049.17A0nOHC061525@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ba3896e16913 - main - ipsec_set_policy(3): fix sentence 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/main X-Git-Reftype: branch X-Git-Commit: ba3896e16913fd6f9f227d84038171f1fdf5496b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 00:49:24 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ba3896e16913fd6f9f227d84038171f1fdf5496b commit ba3896e16913fd6f9f227d84038171f1fdf5496b Author: Konstantin Belousov AuthorDate: 2021-08-09 10:37:41 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-10 00:46:35 +0000 ipsec_set_policy(3): fix sentence Sponsored by: NVIDIA Networking MFC after: 3 days --- lib/libipsec/ipsec_set_policy.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libipsec/ipsec_set_policy.3 b/lib/libipsec/ipsec_set_policy.3 index 1e24b63e6c04..25ef8cbe32cf 100644 --- a/lib/libipsec/ipsec_set_policy.3 +++ b/lib/libipsec/ipsec_set_policy.3 @@ -71,7 +71,7 @@ library function. .Pp The .Fn ipsec_get_policylen -function will returns the of the buffer which is needed when passing +function returns the length of the buffer which is needed when passing the specification structure to the .Xr setsockopt 2 system call. From owner-dev-commits-src-all@freebsd.org Tue Aug 10 00:49:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7148F65F518; Tue, 10 Aug 2021 00:49: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 4GkDqT2Ybcz4dLD; Tue, 10 Aug 2021 00:49: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 2F42B122D2; Tue, 10 Aug 2021 00:49: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 17A0nPYh061550; Tue, 10 Aug 2021 00:49:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17A0nPwe061549; Tue, 10 Aug 2021 00:49:25 GMT (envelope-from git) Date: Tue, 10 Aug 2021 00:49:25 GMT Message-Id: <202108100049.17A0nPwe061549@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 4a5a67fe679d - main - ip(4): Mention IP_IPSEC_POLICY ip-level socket option 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/main X-Git-Reftype: branch X-Git-Commit: 4a5a67fe679d6b29957bf87dbf2e7c08ff97bb30 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 00:49:25 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4a5a67fe679d6b29957bf87dbf2e7c08ff97bb30 commit 4a5a67fe679d6b29957bf87dbf2e7c08ff97bb30 Author: Konstantin Belousov AuthorDate: 2021-08-09 11:07:18 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-10 00:46:49 +0000 ip(4): Mention IP_IPSEC_POLICY ip-level socket option Text is literally taken from NetBSD ip(4). Sponsored by: NVIDIA Networking MFC after: 3 days --- share/man/man4/ip.4 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ip.4 b/share/man/man4/ip.4 index c53cd3d5aeda..24b06846e66f 100644 --- a/share/man/man4/ip.4 +++ b/share/man/man4/ip.4 @@ -28,7 +28,7 @@ .\" @(#)ip.4 8.2 (Berkeley) 11/30/93 .\" $FreeBSD$ .\" -.Dd May 24, 2020 +.Dd August 9, 2021 .Dt IP 4 .Os .Sh NAME @@ -109,6 +109,15 @@ int ttl = 60; /* max = 255 */ setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)); .Ed .Pp +.Dv IP_IPSEC_POLICY +controls IPSec policy for sockets. +For example, +.Bd -literal +const char *policy = "in ipsec ah/transport//require"; +char *buf = ipsec_set_policy(policy, strlen(policy)); +setsockopt(s, IPPROTO_IP, IP_IPSEC_POLICY, buf, ipsec_get_policylen(buf)); +.Ed +.Pp .Dv IP_MINTTL may be used to set the minimum acceptable TTL a packet must have when received on a socket. From owner-dev-commits-src-all@freebsd.org Tue Aug 10 13:31:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9D6866886A; Tue, 10 Aug 2021 13:31: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 4GkYkZ4TJcz4cYj; Tue, 10 Aug 2021 13:31: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 81BB81C534; Tue, 10 Aug 2021 13:31: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 17ADVIQA089459; Tue, 10 Aug 2021 13:31:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ADVITG089458; Tue, 10 Aug 2021 13:31:18 GMT (envelope-from git) Date: Tue, 10 Aug 2021 13:31:18 GMT Message-Id: <202108101331.17ADVITG089458@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 518e697f2acc - main - [skip ci] unix(4): LOCAL_PEERCRED works on SOCK_SEQPACKET, too. 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/main X-Git-Reftype: branch X-Git-Commit: 518e697f2accf3769dc986e254a4c79db7ec5a06 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 13:31:18 -0000 The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=518e697f2accf3769dc986e254a4c79db7ec5a06 commit 518e697f2accf3769dc986e254a4c79db7ec5a06 Author: Alan Somers AuthorDate: 2021-08-10 13:29:06 +0000 Commit: Alan Somers CommitDate: 2021-08-10 13:31:09 +0000 [skip ci] unix(4): LOCAL_PEERCRED works on SOCK_SEQPACKET, too. MFC after: 2 weeks Reviewed By: dchagin Differential Revision: https://reviews.freebsd.org/D31456 --- share/man/man4/unix.4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/man/man4/unix.4 b/share/man/man4/unix.4 index bfce382456ef..cae33f9e8710 100644 --- a/share/man/man4/unix.4 +++ b/share/man/man4/unix.4 @@ -28,7 +28,7 @@ .\" @(#)unix.4 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd November 9, 2020 +.Dd August 7, 2021 .Dt UNIX 4 .Os .Sh NAME @@ -348,6 +348,8 @@ Requested via .Xr getsockopt 2 on a .Dv SOCK_STREAM +or +.Dv SOCK_SEQPACKET socket returns credentials of the remote side. These will arrive in the form of a filled in .Vt xucred From owner-dev-commits-src-all@freebsd.org Tue Aug 10 14:34:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3B530669B4B; Tue, 10 Aug 2021 14:34: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 4Gkb75104xz4gWw; Tue, 10 Aug 2021 14:34: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 0AFAD1D2C0; Tue, 10 Aug 2021 14:34: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 17AEY8OC070824; Tue, 10 Aug 2021 14:34:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AEY849070823; Tue, 10 Aug 2021 14:34:08 GMT (envelope-from git) Date: Tue, 10 Aug 2021 14:34:08 GMT Message-Id: <202108101434.17AEY849070823@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Kubaj Subject: git: ecb3f90dd1c6 - main - share/man/man7/arch.7: powerpc64 support appeared in 9.0-RELEASE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pkubaj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ecb3f90dd1c61f19857898eaa40757ba6a8d7d05 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 14:34:09 -0000 The branch main has been updated by pkubaj (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=ecb3f90dd1c61f19857898eaa40757ba6a8d7d05 commit ecb3f90dd1c61f19857898eaa40757ba6a8d7d05 Author: Piotr Kubaj AuthorDate: 2021-08-10 14:33:29 +0000 Commit: Piotr Kubaj CommitDate: 2021-08-10 14:33:29 +0000 share/man/man7/arch.7: powerpc64 support appeared in 9.0-RELEASE Differential revision: https://reviews.freebsd.org/D31013 Approved by: eadler, 0mp --- share/man/man7/arch.7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man7/arch.7 b/share/man/man7/arch.7 index 45df736b8a37..a6e1987d72a9 100644 --- a/share/man/man7/arch.7 +++ b/share/man/man7/arch.7 @@ -109,7 +109,7 @@ architectures, the final release. .It pc98 Ta 2.2 Ta 11.4 .It powerpc Ta 6.0 .It powerpcspe Ta 12.0 -.It powerpc64 Ta 6.0 +.It powerpc64 Ta 9.0 .It powerpc64le Ta 13.0 .It riscv64 Ta 12.0 .It riscv64sf Ta 12.0 From owner-dev-commits-src-all@freebsd.org Tue Aug 10 15:05:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CE0B66A303; Tue, 10 Aug 2021 15:05: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 4Gkbpn1yzMz4kPr; Tue, 10 Aug 2021 15:05: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 2BC5D1DBD9; Tue, 10 Aug 2021 15:05: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 17AF5517012937; Tue, 10 Aug 2021 15:05:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AF55cj012936; Tue, 10 Aug 2021 15:05:05 GMT (envelope-from git) Date: Tue, 10 Aug 2021 15:05:05 GMT Message-Id: <202108101505.17AF55cj012936@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Kubaj Subject: git: 8f642f797a03 - main - share/man/man7/arch.7: bump date MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pkubaj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8f642f797a03dd66230f8fe5475785c62741229c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 15:05:05 -0000 The branch main has been updated by pkubaj (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=8f642f797a03dd66230f8fe5475785c62741229c commit 8f642f797a03dd66230f8fe5475785c62741229c Author: Piotr Kubaj AuthorDate: 2021-08-10 15:04:51 +0000 Commit: Piotr Kubaj CommitDate: 2021-08-10 15:04:51 +0000 share/man/man7/arch.7: bump date --- share/man/man7/arch.7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man7/arch.7 b/share/man/man7/arch.7 index a6e1987d72a9..51586f4dad30 100644 --- a/share/man/man7/arch.7 +++ b/share/man/man7/arch.7 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 22, 2020 +.Dd August 10, 2021 .Dt ARCH 7 .Os .Sh NAME From owner-dev-commits-src-all@freebsd.org Tue Aug 10 15:43:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67D6566A4CF; Tue, 10 Aug 2021 15:43: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 4Gkcfn2Jcyz4m8N; Tue, 10 Aug 2021 15:43: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 374211DF57; Tue, 10 Aug 2021 15:43: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 17AFhDgX066140; Tue, 10 Aug 2021 15:43:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AFhDaI066139; Tue, 10 Aug 2021 15:43:13 GMT (envelope-from git) Date: Tue, 10 Aug 2021 15:43:13 GMT Message-Id: <202108101543.17AFhDaI066139@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e7a13643b17c - main - build.7: Document LOCAL_MODULES and LOCAL_MODULES_DIR 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/main X-Git-Reftype: branch X-Git-Commit: e7a13643b17c3ec7357b26324986587dab810da5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 15:43:13 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e7a13643b17c3ec7357b26324986587dab810da5 commit e7a13643b17c3ec7357b26324986587dab810da5 Author: Mark Johnston AuthorDate: 2021-08-10 15:42:35 +0000 Commit: Mark Johnston CommitDate: 2021-08-10 15:43:02 +0000 build.7: Document LOCAL_MODULES and LOCAL_MODULES_DIR Reviewed by: 0mp, imp MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31461 --- share/man/man7/build.7 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/share/man/man7/build.7 b/share/man/man7/build.7 index 9d311a2f2f6c..c589fb7e0b9a 100644 --- a/share/man/man7/build.7 +++ b/share/man/man7/build.7 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 1, 2021 +.Dd August 10, 2021 .Dt BUILD 7 .Os .Sh NAME @@ -601,6 +601,19 @@ process. .Bd -literal -offset indent make PORTS_MODULES=emulators/virtualbox-ose-kmod kernel .Ed +.It Va LOCAL_MODULES +A list of external kernel modules that should be built and installed +as part of the +.Cm buildkernel +and +.Cm installkernel +process. +.It Va LOCAL_MODULES_DIR +The directory in which to search for the kernel modules specified by +.Va LOCAL_MODULES . +Each kernel module should consist of a directory containing a makefile. +Defaults to +.Pa ${LOCALBASE}/sys/modules . .It Va SRCCONF Specify a file to override the default .Pa /etc/src.conf . From owner-dev-commits-src-all@freebsd.org Tue Aug 10 16:13:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CAD9766B1A5; Tue, 10 Aug 2021 16:13:08 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GkdKJ5S12z4p00; Tue, 10 Aug 2021 16:13:08 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 377102DCEF; Tue, 10 Aug 2021 16:13:08 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: git: e7a13643b17c - main - build.7: Document LOCAL_MODULES and LOCAL_MODULES_DIR To: Mark Johnston , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108101543.17AFhDaI066139@gitrepo.freebsd.org> From: John Baldwin Message-ID: <01cadb96-b1b6-5726-25f3-4adcb060bde1@FreeBSD.org> Date: Tue, 10 Aug 2021 09:13:07 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <202108101543.17AFhDaI066139@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 16:13:08 -0000 On 8/10/21 8:43 AM, Mark Johnston wrote: > The branch main has been updated by markj: > > URL: https://cgit.FreeBSD.org/src/commit/?id=e7a13643b17c3ec7357b26324986587dab810da5 > > commit e7a13643b17c3ec7357b26324986587dab810da5 > Author: Mark Johnston > AuthorDate: 2021-08-10 15:42:35 +0000 > Commit: Mark Johnston > CommitDate: 2021-08-10 15:43:02 +0000 > > build.7: Document LOCAL_MODULES and LOCAL_MODULES_DIR > > Reviewed by: 0mp, imp > MFC after: 1 week > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D31461 > --- > share/man/man7/build.7 | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/share/man/man7/build.7 b/share/man/man7/build.7 > index 9d311a2f2f6c..c589fb7e0b9a 100644 > --- a/share/man/man7/build.7 > +++ b/share/man/man7/build.7 > @@ -24,7 +24,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd July 1, 2021 > +.Dd August 10, 2021 > .Dt BUILD 7 > .Os > .Sh NAME > @@ -601,6 +601,19 @@ process. > .Bd -literal -offset indent > make PORTS_MODULES=emulators/virtualbox-ose-kmod kernel > .Ed > +.It Va LOCAL_MODULES > +A list of external kernel modules that should be built and installed > +as part of the > +.Cm buildkernel > +and > +.Cm installkernel > +process. > +.It Va LOCAL_MODULES_DIR > +The directory in which to search for the kernel modules specified by > +.Va LOCAL_MODULES . > +Each kernel module should consist of a directory containing a makefile. > +Defaults to > +.Pa ${LOCALBASE}/sys/modules . Thanks for doing this. The only thing we might want to add is to note that LOCAL_MODULES is automatically set to all the subdirs in LOCAL_MODULES_DIR if it is not explicitly set. -- John Baldwin From owner-dev-commits-src-all@freebsd.org Tue Aug 10 19:47:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 320BA66D9AD; Tue, 10 Aug 2021 19:47: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 4Gkk560WqMz50qk; Tue, 10 Aug 2021 19:47: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 EE867217D8; Tue, 10 Aug 2021 19:47: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 17AJlr3v085230; Tue, 10 Aug 2021 19:47:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AJlr8r085229; Tue, 10 Aug 2021 19:47:53 GMT (envelope-from git) Date: Tue, 10 Aug 2021 19:47:53 GMT Message-Id: <202108101947.17AJlr8r085229@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 12e8addd320d - main - e1000: rctl/srrctl buffer size init, rfctl fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 12e8addd320df995bfb2b00f51c233541f741ae4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 19:47:54 -0000 The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=12e8addd320df995bfb2b00f51c233541f741ae4 commit 12e8addd320df995bfb2b00f51c233541f741ae4 Author: Kevin Bowling AuthorDate: 2021-08-10 19:47:22 +0000 Commit: Kevin Bowling CommitDate: 2021-08-10 19:47:22 +0000 e1000: rctl/srrctl buffer size init, rfctl fix Simplify the setup of srrctl.BSIZEPKT on igb class NICs. Improve the setup of rctl.BSIZE on lem and em class NICs. Don't try to touch rfctl on lem class NICs. Manipulate rctl.BSEX correctly on lem and em class NICs. Approved by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31457 --- sys/dev/e1000/if_em.c | 76 +++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 52d20e57519a..33d5341ed8ce 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -3170,6 +3170,7 @@ em_initialize_transmit_unit(if_ctx_t ctx) * Enable receive unit. * **********************************************************************/ +#define BSIZEPKT_ROUNDUP ((1<hw; struct em_rx_queue *que; int i; - u32 rctl, rxcsum, rfctl; + uint32_t rctl, rxcsum; INIT_DEBUGOUT("em_initialize_receive_units: begin"); @@ -3224,21 +3225,25 @@ em_initialize_receive_unit(if_ctx_t ctx) } E1000_WRITE_REG(hw, E1000_RDTR, adapter->rx_int_delay.value); - /* Use extended rx descriptor formats */ - rfctl = E1000_READ_REG(hw, E1000_RFCTL); - rfctl |= E1000_RFCTL_EXTEN; - /* - * When using MSI-X interrupts we need to throttle - * using the EITR register (82574 only) - */ - if (hw->mac.type == e1000_82574) { - for (int i = 0; i < 4; i++) - E1000_WRITE_REG(hw, E1000_EITR_82574(i), - DEFAULT_ITR); - /* Disable accelerated acknowledge */ - rfctl |= E1000_RFCTL_ACK_DIS; + if (hw->mac.type >= em_mac_min) { + uint32_t rfctl; + /* Use extended rx descriptor formats */ + rfctl = E1000_READ_REG(hw, E1000_RFCTL); + rfctl |= E1000_RFCTL_EXTEN; + + /* + * When using MSI-X interrupts we need to throttle + * using the EITR register (82574 only) + */ + if (hw->mac.type == e1000_82574) { + for (int i = 0; i < 4; i++) + E1000_WRITE_REG(hw, E1000_EITR_82574(i), + DEFAULT_ITR); + /* Disable accelerated acknowledge */ + rfctl |= E1000_RFCTL_ACK_DIS; + } + E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); } - E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); if (if_getcapenable(ifp) & IFCAP_RXCSUM && @@ -3323,24 +3328,17 @@ em_initialize_receive_unit(if_ctx_t ctx) u32 psize, srrctl = 0; if (if_getmtu(ifp) > ETHERMTU) { - /* Set maximum packet len */ - if (adapter->rx_mbuf_sz <= 4096) { - srrctl |= 4096 >> E1000_SRRCTL_BSIZEPKT_SHIFT; - rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX; - } else if (adapter->rx_mbuf_sz > 4096) { - srrctl |= 8192 >> E1000_SRRCTL_BSIZEPKT_SHIFT; - rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; - } psize = scctx->isc_max_frame_size; /* are we on a vlan? */ if (ifp->if_vlantrunk != NULL) psize += VLAN_TAG_SIZE; E1000_WRITE_REG(hw, E1000_RLPML, psize); - } else { - srrctl |= 2048 >> E1000_SRRCTL_BSIZEPKT_SHIFT; - rctl |= E1000_RCTL_SZ_2048; } + /* Set maximum packet buffer len */ + srrctl |= (adapter->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >> + E1000_SRRCTL_BSIZEPKT_SHIFT; + /* * If TX flow control is disabled and there's >1 queue defined, * enable DROP. @@ -3391,17 +3389,29 @@ em_initialize_receive_unit(if_ctx_t ctx) /* Make sure VLAN Filters are off */ rctl &= ~E1000_RCTL_VFE; + /* Set up packet buffer size, overridden by per queue srrctl on igb */ if (hw->mac.type < igb_mac_min) { - if (adapter->rx_mbuf_sz == MCLBYTES) - rctl |= E1000_RCTL_SZ_2048; - else if (adapter->rx_mbuf_sz == MJUMPAGESIZE) + if (adapter->rx_mbuf_sz > 2048 && adapter->rx_mbuf_sz <= 4096) rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX; - else if (adapter->rx_mbuf_sz > MJUMPAGESIZE) + else if (adapter->rx_mbuf_sz > 4096 && adapter->rx_mbuf_sz <= 8192) rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; + else if (adapter->rx_mbuf_sz > 8192) + rctl |= E1000_RCTL_SZ_16384 | E1000_RCTL_BSEX; + else { + rctl |= E1000_RCTL_SZ_2048; + rctl &= ~E1000_RCTL_BSEX; + } + } else + rctl |= E1000_RCTL_SZ_2048; - /* ensure we clear use DTYPE of 00 here */ - rctl &= ~0x00000C00; - } + /* + * rctl bits 11:10 are as follows + * lem: reserved + * em: DTYPE + * igb: reserved + * and should be 00 on all of the above + */ + rctl &= ~0x00000C00; /* Write out the settings */ E1000_WRITE_REG(hw, E1000_RCTL, rctl); From owner-dev-commits-src-all@freebsd.org Tue Aug 10 20:21:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C814366E202; Tue, 10 Aug 2021 20:21: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 4Gkkql5J9kz52XD; Tue, 10 Aug 2021 20:21: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 9DF9221CF8; Tue, 10 Aug 2021 20:21: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 17AKLNJK036432; Tue, 10 Aug 2021 20:21:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AKLN0X036431; Tue, 10 Aug 2021 20:21:23 GMT (envelope-from git) Date: Tue, 10 Aug 2021 20:21:23 GMT Message-Id: <202108102021.17AKLN0X036431@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: d78896e46f1d - main - pmc(3): remove Pentium-related man pages and references MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d78896e46f1d7744155919476c012400321d0dab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 20:21:23 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=d78896e46f1d7744155919476c012400321d0dab commit d78896e46f1d7744155919476c012400321d0dab Author: Mitchell Horne AuthorDate: 2021-08-10 20:19:58 +0000 Commit: Mitchell Horne CommitDate: 2021-08-10 20:19:58 +0000 pmc(3): remove Pentium-related man pages and references Support for Pentium events was removed completely in e92a1350b50e. Don't bump .Dd where we are just removing xrefs. Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31423 --- ObsoleteFiles.inc | 5 + lib/libpmc/Makefile | 3 - lib/libpmc/pmc.3 | 47 +- lib/libpmc/pmc.atom.3 | 3 - lib/libpmc/pmc.atomsilvermont.3 | 3 - lib/libpmc/pmc.core.3 | 3 - lib/libpmc/pmc.core2.3 | 3 - lib/libpmc/pmc.corei7.3 | 3 - lib/libpmc/pmc.corei7uc.3 | 3 - lib/libpmc/pmc.haswell.3 | 3 - lib/libpmc/pmc.haswelluc.3 | 3 - lib/libpmc/pmc.haswellxeon.3 | 3 - lib/libpmc/pmc.iaf.3 | 3 - lib/libpmc/pmc.ivybridge.3 | 3 - lib/libpmc/pmc.ivybridgexeon.3 | 3 - lib/libpmc/pmc.k7.3 | 3 - lib/libpmc/pmc.k8.3 | 3 - lib/libpmc/pmc.mips24k.3 | 3 - lib/libpmc/pmc.octeon.3 | 3 - lib/libpmc/pmc.p4.3 | 1223 -------------------------------------- lib/libpmc/pmc.p5.3 | 460 -------------- lib/libpmc/pmc.p6.3 | 1026 -------------------------------- lib/libpmc/pmc.sandybridge.3 | 3 - lib/libpmc/pmc.sandybridgeuc.3 | 3 - lib/libpmc/pmc.sandybridgexeon.3 | 3 - lib/libpmc/pmc.soft.3 | 3 - lib/libpmc/pmc.tsc.3 | 3 - lib/libpmc/pmc.ucf.3 | 3 - lib/libpmc/pmc.westmere.3 | 3 - lib/libpmc/pmc.westmereuc.3 | 3 - 30 files changed, 6 insertions(+), 2830 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 99db0e591090..db8441716091 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -40,6 +40,11 @@ # xargs -n1 | sort | uniq -d; # done +# 20210810: remove Pentium-related man pages and references +OLD_FILES+=usr/share/man/man3/pmc.p4.3.gz +OLD_FILES+=usr/share/man/man3/pmc.p5.3.gz +OLD_FILES+=usr/share/man/man3/pmc.p6.3.gz + # 20210805: C.UTF-8 installed to the wrong location OLD_FILES+=usr/share/C.UTF-8.LC_CTYPE diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile index 285b6c539ece..2ef0d288064c 100644 --- a/lib/libpmc/Makefile +++ b/lib/libpmc/Makefile @@ -83,9 +83,6 @@ MAN+= pmc.k7.3 MAN+= pmc.k8.3 MAN+= pmc.mips24k.3 MAN+= pmc.octeon.3 -MAN+= pmc.p4.3 -MAN+= pmc.p5.3 -MAN+= pmc.p6.3 MAN+= pmc.sandybridge.3 MAN+= pmc.sandybridgeuc.3 MAN+= pmc.sandybridgexeon.3 diff --git a/lib/libpmc/pmc.3 b/lib/libpmc/pmc.3 index c70862668980..4bf2907db129 100644 --- a/lib/libpmc/pmc.3 +++ b/lib/libpmc/pmc.3 @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 12, 2020 +.Dd August 10, 2021 .Dt PMC 3 .Os .Sh NAME @@ -161,26 +161,6 @@ and CPUs, and other CPUs conforming to version 2 of the .Tn Intel performance measurement architecture. -.It Li PMC_CPU_INTEL_P5 -.Tn Intel -.Tn "Pentium" -CPUs. -.It Li PMC_CPU_INTEL_P6 -.Tn Intel -.Tn "Pentium Pro" -CPUs. -.It Li PMC_CPU_INTEL_PII -.Tn "Intel Pentium II" -CPUs. -.It Li PMC_CPU_INTEL_PIII -.Tn "Intel Pentium III" -CPUs. -.It Li PMC_CPU_INTEL_PIV -.Tn "Intel Pentium 4" -CPUs. -.It Li PMC_CPU_INTEL_PM -.Tn "Intel Pentium M" -CPUs. .El .Ss Supported PMCs PMC supported by this library are named by the @@ -205,25 +185,6 @@ CPUs. Programmable hardware counters present in .Tn "AMD Athlon64" CPUs. -.It Li PMC_CLASS_P4 -Programmable hardware counters present in -.Tn "Intel Pentium 4" -CPUs. -.It Li PMC_CLASS_P5 -Programmable hardware counters present in -.Tn Intel -.Tn Pentium -CPUs. -.It Li PMC_CLASS_P6 -Programmable hardware counters present in -.Tn Intel -.Tn "Pentium Pro" , -.Tn "Pentium II" , -.Tn "Pentium III" , -.Tn "Celeron" , -and -.Tn "Pentium M" -CPUs. .It Li PMC_CLASS_TSC The timestamp counter on i386 and amd64 architecture CPUs. .It Li PMC_CLASS_SOFT @@ -473,9 +434,6 @@ following manual pages: .It Li PMC_CLASS_IAP Ta Xr pmc.atom 3 , Xr pmc.core 3 , Xr pmc.core2 3 .It Li PMC_CLASS_K7 Ta Xr pmc.k7 3 .It Li PMC_CLASS_K8 Ta Xr pmc.k8 3 -.It Li PMC_CLASS_P4 Ta Xr pmc.p4 3 -.It Li PMC_CLASS_P5 Ta Xr pmc.p5 3 -.It Li PMC_CLASS_P6 Ta Xr pmc.p6 3 .It Li PMC_CLASS_TSC Ta Xr pmc.tsc 3 .El .Ss Event Name Aliases @@ -535,9 +493,6 @@ API is .Xr pmc.k8 3 , .Xr pmc.mips24k 3 , .Xr pmc.octeon 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.sandybridge 3 , .Xr pmc.sandybridgeuc 3 , .Xr pmc.sandybridgexeon 3 , diff --git a/lib/libpmc/pmc.atom.3 b/lib/libpmc/pmc.atom.3 index edf81ba54a5e..a79d14c9d4c1 100644 --- a/lib/libpmc/pmc.atom.3 +++ b/lib/libpmc/pmc.atom.3 @@ -1174,9 +1174,6 @@ and the underlying hardware events used on these CPUs. .Xr pmc.iaf 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc_cpuinfo 3 , diff --git a/lib/libpmc/pmc.atomsilvermont.3 b/lib/libpmc/pmc.atomsilvermont.3 index 7ed9de461e33..dd1f66a429c7 100644 --- a/lib/libpmc/pmc.atomsilvermont.3 +++ b/lib/libpmc/pmc.atomsilvermont.3 @@ -512,9 +512,6 @@ The number of times the MSROM starts a flow of UOPS. .Xr pmc.iaf 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc_cpuinfo 3 , diff --git a/lib/libpmc/pmc.core.3 b/lib/libpmc/pmc.core.3 index 551e615dc320..8d922cf3c1af 100644 --- a/lib/libpmc/pmc.core.3 +++ b/lib/libpmc/pmc.core.3 @@ -789,9 +789,6 @@ may not count some transitions. .Xr pmc.iaf 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmclog 3 , diff --git a/lib/libpmc/pmc.core2.3 b/lib/libpmc/pmc.core2.3 index cd038fb411d9..7c7049136c2b 100644 --- a/lib/libpmc/pmc.core2.3 +++ b/lib/libpmc/pmc.core2.3 @@ -1104,9 +1104,6 @@ and the underlying hardware events used. .Xr pmc.iaf 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc_cpuinfo 3 , diff --git a/lib/libpmc/pmc.corei7.3 b/lib/libpmc/pmc.corei7.3 index e9e2a6e61784..0c405d8e6e7f 100644 --- a/lib/libpmc/pmc.corei7.3 +++ b/lib/libpmc/pmc.corei7.3 @@ -1583,9 +1583,6 @@ Counts number of segment register loads. .Xr pmc.iaf 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc.ucf 3 , diff --git a/lib/libpmc/pmc.corei7uc.3 b/lib/libpmc/pmc.corei7uc.3 index 1f49222ceda6..a102a7b6c1b3 100644 --- a/lib/libpmc/pmc.corei7uc.3 +++ b/lib/libpmc/pmc.corei7uc.3 @@ -886,9 +886,6 @@ into a power down mode. .Xr pmc.iaf 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc.ucf 3 , diff --git a/lib/libpmc/pmc.haswell.3 b/lib/libpmc/pmc.haswell.3 index c69d4b694ca2..c858c702fdf1 100644 --- a/lib/libpmc/pmc.haswell.3 +++ b/lib/libpmc/pmc.haswell.3 @@ -921,9 +921,6 @@ Dirty L2 cache lines evicted by demand. .Xr pmc.ivybridgexeon 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.sandybridge 3 , .Xr pmc.sandybridgeuc 3 , .Xr pmc.sandybridgexeon 3 , diff --git a/lib/libpmc/pmc.haswelluc.3 b/lib/libpmc/pmc.haswelluc.3 index e7b57c59d0e5..a067a75201ce 100644 --- a/lib/libpmc/pmc.haswelluc.3 +++ b/lib/libpmc/pmc.haswelluc.3 @@ -205,9 +205,6 @@ Number of requests allocated in Coherency Tracker. .Xr pmc.iaf 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.sandybridge 3 , .Xr pmc.sandybridgeuc 3 , .Xr pmc.sandybridgexeon 3 , diff --git a/lib/libpmc/pmc.haswellxeon.3 b/lib/libpmc/pmc.haswellxeon.3 index 5f9a5b20eb5c..7610775adcb3 100644 --- a/lib/libpmc/pmc.haswellxeon.3 +++ b/lib/libpmc/pmc.haswellxeon.3 @@ -935,9 +935,6 @@ Dirty L2 cache lines evicted by demand. .Xr pmc.ivybridgexeon 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.sandybridge 3 , .Xr pmc.sandybridgeuc 3 , .Xr pmc.sandybridgexeon 3 , diff --git a/lib/libpmc/pmc.iaf.3 b/lib/libpmc/pmc.iaf.3 index f80560999f46..fcfa98042aaf 100644 --- a/lib/libpmc/pmc.iaf.3 +++ b/lib/libpmc/pmc.iaf.3 @@ -128,9 +128,6 @@ CPU, use the event specifier .Xr pmc.core2 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc_cpuinfo 3 , diff --git a/lib/libpmc/pmc.ivybridge.3 b/lib/libpmc/pmc.ivybridge.3 index d86199b4d407..938d2947a844 100644 --- a/lib/libpmc/pmc.ivybridge.3 +++ b/lib/libpmc/pmc.ivybridge.3 @@ -833,9 +833,6 @@ Dirty L2 cache lines evicted by the MLC prefetcher. .Xr pmc.ivybridgexeon 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.sandybridge 3 , .Xr pmc.sandybridgeuc 3 , .Xr pmc.sandybridgexeon 3 , diff --git a/lib/libpmc/pmc.ivybridgexeon.3 b/lib/libpmc/pmc.ivybridgexeon.3 index 1bbe16039bd2..9bcf4dbd56da 100644 --- a/lib/libpmc/pmc.ivybridgexeon.3 +++ b/lib/libpmc/pmc.ivybridgexeon.3 @@ -866,9 +866,6 @@ Dirty L2 cache lines filling the L2. .Xr pmc.ivybridge 3 , .Xr pmc.k7 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.sandybridge 3 , .Xr pmc.sandybridgeuc 3 , .Xr pmc.sandybridgexeon 3 , diff --git a/lib/libpmc/pmc.k7.3 b/lib/libpmc/pmc.k7.3 index a8be8143f9ea..42933f1958fb 100644 --- a/lib/libpmc/pmc.k7.3 +++ b/lib/libpmc/pmc.k7.3 @@ -246,9 +246,6 @@ and the underlying hardware events used. .Xr pmc.core2 3 , .Xr pmc.iaf 3 , .Xr pmc.k8 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmclog 3 , diff --git a/lib/libpmc/pmc.k8.3 b/lib/libpmc/pmc.k8.3 index 45c70baa438c..cbfe617f31b1 100644 --- a/lib/libpmc/pmc.k8.3 +++ b/lib/libpmc/pmc.k8.3 @@ -779,9 +779,6 @@ and the underlying hardware events used. .Xr pmc.core2 3 , .Xr pmc.iaf 3 , .Xr pmc.k7 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmclog 3 , diff --git a/lib/libpmc/pmc.mips24k.3 b/lib/libpmc/pmc.mips24k.3 index d886d0e8c906..52761d5db751 100644 --- a/lib/libpmc/pmc.mips24k.3 +++ b/lib/libpmc/pmc.mips24k.3 @@ -389,9 +389,6 @@ and the underlying hardware events used. .Xr pmc.k7 3 , .Xr pmc.k8 3 , .Xr pmc.octeon 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc_cpuinfo 3 , diff --git a/lib/libpmc/pmc.octeon.3 b/lib/libpmc/pmc.octeon.3 index 019b448522e9..43d204f164e6 100644 --- a/lib/libpmc/pmc.octeon.3 +++ b/lib/libpmc/pmc.octeon.3 @@ -229,9 +229,6 @@ and the underlying hardware events used. .Xr pmc.k7 3 , .Xr pmc.k8 3 , .Xr pmc.mips24k 3 , -.Xr pmc.p4 3 , -.Xr pmc.p5 3 , -.Xr pmc.p6 3 , .Xr pmc.soft 3 , .Xr pmc.tsc 3 , .Xr pmc_cpuinfo 3 , diff --git a/lib/libpmc/pmc.p4.3 b/lib/libpmc/pmc.p4.3 deleted file mode 100644 index e113b72001e1..000000000000 --- a/lib/libpmc/pmc.p4.3 +++ /dev/null @@ -1,1223 +0,0 @@ -.\" Copyright (c) 2003-2008 Joseph Koshy. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd October 4, 2008 -.Dt PMC.P4 3 -.Os -.Sh NAME -.Nm pmc.p4 -.Nd measurement events for -.Tn "Intel Pentium 4" -and other -.Tn Netburst -architecture CPUs -.Sh LIBRARY -.Lb libpmc -.Sh SYNOPSIS -.In pmc.h -.Sh DESCRIPTION -Intel P4 PMCs are present in Intel -.Tn "Pentium 4" -and -.Tn Xeon -processors that use the -.Tn Netburst -CPU architecture. -.Pp -These PMCs are documented in -.Rs -.%B "IA-32 Intel(R) Architecture Software Developer's Manual" -.%T "Volume 3: System Programming Guide" -.%N "Order Number 245472-012" -.%D 2003 -.%Q "Intel Corporation" -.Re -Further information about using these PMCs may be found in -.Rs -.%B "IA-32 Intel(R) Architecture Optimization Guide" -.%D 2003 -.%N "Order Number 248966-009" -.%Q "Intel Corporation" -.Re -Some of these events are affected by processor errata described in -.Rs -.%B "Intel(R) Pentium(R) 4 Processor Specification Update" -.%N "Document Number: 249199-059" -.%D "April 2005" -.%Q "Intel Corporation" -.Re -.Ss PMC Features -Intel Pentium 4 PMCs are 40 bits wide. -Each CPU contains 18 PMCs, divided into 4 groups with 4, 4, 4 and 6 -PMCs respectively. -On processors with hyperthreading support, PMC resources are shared -between logical processors. -These PMCs support the following capabilities: -.Bl -column "PMC_CAP_INTERRUPT" "Support" -.It Em Capability Ta Em Support -.It PMC_CAP_CASCADE Ta Yes -.It PMC_CAP_EDGE Ta Yes -.It PMC_CAP_INTERRUPT Ta Yes -.It PMC_CAP_INVERT Ta Yes -.It PMC_CAP_READ Ta Yes -.It PMC_CAP_PRECISE Ta Unimplemented -.It PMC_CAP_SYSTEM Ta Yes -.It PMC_CAP_TAGGING Ta Yes -.It PMC_CAP_THRESHOLD Ta Yes -.It PMC_CAP_USER Ta Yes -.It PMC_CAP_WRITE Ta Yes -.El -.Ss Event Qualifiers -Event specifiers for Intel P4 PMCs can have the following common -qualifiers: -.Bl -tag -width indent -.It Li active= Ns Ar choice -(On P4 HTT CPUs) Filter event counting based on which logical -processors are active. -The allowed values of -.Ar choice -are: -.Pp -.Bl -tag -width indent -compact -.It Li any -Count when either logical processor is active. -.It Li both -Count when both logical processors are active. -.It Li none -Count only when neither logical processor is active. -.It Li single -Count only when one logical processor is active. -.El -.Pp -The default is -.Dq Li both . -.It Li cascade -Configure the PMC to cascade onto its partner. -See -.Sx "Cascading P4 PMCs" -below for more information. -.It Li edge -Configure the counter to count false to true transitions of the threshold -comparison output. -This qualifier only takes effect if a threshold qualifier has also been -specified. -.It Li complement -Configure the counter to increment only when the event count seen is -less than the threshold qualifier value specified. -.It Li mask= Ns Ar qualifier -Many event specifiers for Intel P4 PMCs need to be additionally -qualified using a mask qualifier. -The allowed syntax for these qualifiers is event specific and is -described along with the events. -.It Li os -Configure the PMC to count when the CPL of the processor is 0. -.It Li precise -Select precise event based sampling. -Precise sampling is supported by the hardware for a limited set of -events. -.It Li tag= Ns Ar value -Configure the PMC to tag the internal uop selected by the other -fields in this event specifier with value -.Ar value . -This feature is used when cascading PMCs. -.It Li threshold= Ns Ar value -Configure the PMC to increment only when the event counts seen are -greater than the specified threshold value -.Ar value . -.It Li usr -Configure the PMC to count when the CPL of the processor is 1, 2 or 3. -.El -.Pp -If neither of the -.Dq Li os -or -.Dq Li usr -qualifiers are specified, the default is to enable both. -.Pp -On Intel Pentium 4 processors with HTT, events are -divided into two classes: -.Pp -.Bl -tag -width indent -compact -.It "TS Events" -are those where hardware can differentiate between events -generated on one logical processor from those generated on the -other. -.It "TI Events" -are those where hardware cannot differentiate between events -generated by multiple logical processors in a package. -.El -.Pp -Only TS events are allowed for use with process-mode PMCs on -Pentium-4/HTT CPUs. -.Pp -The event specifiers supported by Intel P4 PMCs are: -.Bl -tag -width indent -.It Li p4-128bit-mmx-uop Op Li ,mask= Ns Ar flags -.Pq "TI event" -Count integer SIMD SSE2 instructions that operate on 128 bit SIMD -operands. -Qualifier -.Ar flags -can take the following value (which is also the default): -.Pp -.Bl -tag -width indent -compact -.It Li all -Count all uops operating on 128 bit SIMD integer operands in memory or -XMM register. -.El -.Pp -If an instruction contains more than one 128 bit MMX uop, then each -uop will be counted. -.It Li p4-64bit-mmx-uop Op Li ,mask= Ns Ar flags -.Pq "TI event" -Count MMX instructions that operate on 64 bit SIMD operands. -Qualifier -.Ar flags -can take the following value (which is also the default): -.Pp -.Bl -tag -width indent -compact -.It Li all -Count all uops operating on 64 bit SIMD integer operands in memory or -in MMX registers. -.El -.Pp -If an instruction contains more than one 64 bit MMX uop, then each -uop will be counted. -.It Li p4-b2b-cycles -.Pq "TI event" -Count back-to-back bus cycles. -Further documentation for this event is unavailable. -.It Li p4-bnr -.Pq "TI event" -Count bus-not-ready conditions. -Further documentation for this event is unavailable. -.It Li p4-bpu-fetch-request Op Li ,mask= Ns Ar qualifier -.Pq "TS event" -Count instruction fetch requests qualified by additional -flags specified in -.Ar qualifier . -At this point only one flag is supported: -.Pp -.Bl -tag -width indent -compact -.It Li tcmiss -Count trace cache lookup misses. -.El -.Pp -The default qualifier is also -.Dq Li mask=tcmiss . -.It Li p4-branch-retired Op Li ,mask= Ns Ar flags -.Pq "TS event" -Counts retired branches. -Qualifier -.Ar flags -is a list of the following -.Ql + -separated strings: -.Pp -.Bl -tag -width indent -compact -.It Li mmnp -Count branches not-taken and predicted. -.It Li mmnm -Count branches not-taken and mis-predicted. -.It Li mmtp -Count branches taken and predicted. -.It Li mmtm -Count branches taken and mis-predicted. -.El -.Pp -The default qualifier counts all four kinds of branches. -.It Li p4-bsq-active-entries Op Li ,mask= Ns Ar qualifier -.Pq "TS event" -Count the number of entries (clipped at 15) currently active in the -BSQ. -Qualifier -.Ar qualifier -is a -.Ql + -separated set of the following flags: -.Pp -.Bl -tag -width indent -compact -.It Li req-type0 , Li req-type1 -Forms a 2-bit number used to select the request type encoding: -.Pp -.Bl -tag -width indent -compact -.It Li 0 -reads excluding read invalidate -.It Li 1 -read invalidates -.It Li 2 -writes other than writebacks -.It Li 3 -writebacks -.El -.Pp -Bit -.Dq Li req-type1 -is the MSB for this two bit number. -.It Li req-len0 , Li req-len1 -Forms a two-bit number that specifies the request length encoding: -.Pp -.Bl -tag -width indent -compact -.It Li 0 -0 chunks -.It Li 1 -1 chunk -.It Li 3 -8 chunks -.El -.Pp -Bit -.Dq Li req-len1 -is the MSB for this two bit number. -.It Li req-io-type -Count requests that are input or output requests. -.It Li req-lock-type -Count requests that lock the bus. -.It Li req-lock-cache -Count requests that lock the cache. -.It Li req-split-type -Count requests that is a bus 8-byte chunk that is split across an -8-byte boundary. -.It Li req-dem-type -Count requests that are demand (not prefetches) if set. -Count requests that are prefetches if not set. -.It Li req-ord-type -Count requests that are ordered. -.It Li mem-type0 , Li mem-type1 , Li mem-type2 -Forms a 3-bit number that specifies a memory type encoding: -.Pp -.Bl -tag -width indent -compact -.It Li 0 -UC -.It Li 1 -USWC -.It Li 4 -WT -.It Li 5 -WP -.It Li 6 -WB -.El -.Pp -Bit -.Dq Li mem-type2 -is the MSB of this 3-bit number. -.El -.Pp -The default qualifier has all the above bits set. -.Pp -Edge triggering using the -.Dq Li edge -qualifier should not be used with this event when counting cycles. -.It Li p4-bsq-allocation Op Li ,mask= Ns Ar qualifier -.Pq "TS event" -Count allocations in the bus sequence unit according to the flags -specified in -.Ar qualifier , -which is a -.Ql + -separated set of the following flags: -.Pp -.Bl -tag -width indent -compact -.It Li req-type0 , Li req-type1 -Forms a 2-bit number used to select the request type encoding: -.Pp -.Bl -tag -width indent -compact -.It Li 0 -reads excluding read invalidate -.It Li 1 -read invalidates -.It Li 2 -writes other than writebacks -.It Li 3 -writebacks -.El -.Pp -Bit -.Dq Li req-type1 -is the MSB for this two bit number. -.It Li req-len0 , Li req-len1 -Forms a two-bit number that specifies the request length encoding: -.Pp -.Bl -tag -width indent -compact -.It Li 0 -0 chunks -.It Li 1 -1 chunk -.It Li 3 -8 chunks -.El -.Pp -Bit -.Dq Li req-len1 -is the MSB for this two bit number. -.It Li req-io-type -Count requests that are input or output requests. -.It Li req-lock-type -Count requests that lock the bus. -.It Li req-lock-cache -Count requests that lock the cache. -.It Li req-split-type -Count requests that is a bus 8-byte chunk that is split across an -8-byte boundary. -.It Li req-dem-type -Count requests that are demand (not prefetches) if set. -Count requests that are prefetches if not set. -.It Li req-ord-type -Count requests that are ordered. -.It Li mem-type0 , Li mem-type1 , Li mem-type2 -Forms a 3-bit number that specifies a memory type encoding: -.Pp -.Bl -tag -width indent -compact -.It Li 0 -UC -.It Li 1 -USWC -.It Li 4 -WT -.It Li 5 -WP -.It Li 6 -WB -.El -.Pp -Bit -.Dq Li mem-type2 -is the MSB of this 3-bit number. -.El -.Pp -The default qualifier has all the above bits set. -.Pp -This event is usually used along with the -.Dq Li edge -qualifier to avoid multiple counting. -.It Li p4-bsq-cache-reference Op Li ,mask= Ns Ar qualifier -.Pq "TS event" -Count cache references as seen by the bus unit (2nd or 3rd level -cache references). -Qualifier -.Ar qualifier -is a -.Ql + -separated list of the following keywords: -.Pp -.Bl -tag -width indent -compact -.It Li rd-2ndl-hits -Count 2nd level cache hits in the shared state. -.It Li rd-2ndl-hite -Count 2nd level cache hits in the exclusive state. -.It Li rd-2ndl-hitm -Count 2nd level cache hits in the modified state. -.It Li rd-3rdl-hits -Count 3rd level cache hits in the shared state. -.It Li rd-3rdl-hite -Count 3rd level cache hits in the exclusive state. -.It Li rd-3rdl-hitm -Count 3rd level cache hits in the modified state. -.It Li rd-2ndl-miss -Count 2nd level cache misses. -.It Li rd-3rdl-miss -Count 3rd level cache misses. -.It Li wr-2ndl-miss -Count write-back lookups from the data access cache that miss the 2nd -level cache. -.El -.Pp -The default is to count all the above events. -.It Li p4-execution-event Op Li ,mask= Ns Ar flags -.Pq "TS event" -Count the retirement of tagged uops selected through the execution -tagging mechanism. -Qualifier -.Ar flags -can contain the following strings separated by -.Ql + -characters: -.Pp -.Bl -tag -width indent -compact -.It Li nbogus0 , Li nbogus1 , Li nbogus2 , Li nbogus3 -The marked uops are not bogus. -.It Li bogus0 , Li bogus1 , Li bogus2 , Li bogus3 -The marked uops are bogus. -.El -.Pp -This event requires additional (upstream) events to be allocated to -perform the desired uop tagging. -The default is to set all the above flags. -This event can be used for precise event based sampling. -.It Li p4-front-end-event Op Li ,mask= Ns Ar flags -.Pq "TS event" -Count the retirement of tagged uops selected through the front-end -tagging mechanism. -Qualifier -.Ar flags -can contain the following strings separated by -.Ql + -characters: -.Pp -.Bl -tag -width indent -compact -.It Li nbogus -The marked uops are not bogus. -.It Li bogus -The marked uops are bogus. -.El -.Pp -This event requires additional (upstream) events to be allocated to -perform the desired uop tagging. -The default is to select both kinds of events. -This event can be used for precise event based sampling. -.It Li p4-fsb-data-activity Op Li ,mask= Ns Ar flags -.Pq "TI event" -Count each DBSY or DRDY event selected by qualifier -.Ar flags . -Qualifier -.Ar flags -is a -.Ql + -separated set of the following flags: -.Pp -.Bl -tag -width indent -compact -.It Li drdy-drv -Count when this processor is driving data onto the bus. -.It Li drdy-own -Count when this processor is reading data from the bus. -.It Li drdy-other -Count when data is on the bus but not being sampled by this processor. -.It Li dbsy-drv -Count when this processor reserves the bus for use in the next cycle -in order to drive data. -.It Li dbsy-own -Count when some agent reserves the bus for use in the next bus cycle -to drive data that this processor will sample. -.It Li dbsy-other -Count when some agent reserves the bus for use in the next bus cycle -to drive data that this processor will not sample. -.El -.Pp -Flags -.Dq Li drdy-own -and -.Dq Li drdy-other -are mutually exclusive. -Flags -.Dq Li dbsy-own -and -.Dq Li dbsy-other -are mutually exclusive. -The default value for -.Ar qualifier -is -.Dq Li drdy-drv+drdy-own+dbsy-drv+dbsy-own . -.It Li p4-global-power-events Op Li ,mask= Ns Ar flags -.Pq "TS event" -Count cycles during which the processor is not stopped. -Qualifier -.Ar flags -can take the following value (which is also the default): -.Pp -.Bl -tag -width indent -compact -.It Li running -Count cycles when the processor is active. -.El -.It Li p4-instr-retired Op Li ,mask= Ns Ar flags -.Pq "TS event" -Count instructions retired during a clock cycle. -Qualifier -.Ar flags -comprises of the following strings separated by -.Ql + -characters: -.Pp -.Bl -tag -width indent -compact -.It Li nbogusntag -Count non-bogus instructions that are not tagged. -.It Li nbogustag -Count non-bogus instructions that are tagged. -.It Li bogusntag -Count bogus instructions that are not tagged. -.It Li bogustag -Count bogus instructions that are tagged. -.El -.Pp -The default qualifier counts all the above kinds of instructions. -.It Li p4-ioq-active-entries Xo -.Op Li ,mask= Ns Ar qualifier -.Op Li ,busreqtype= Ns Ar req-type -.Xc -.Pq "TS event" -Count the number of entries (clipped at 15) in the IOQ that are -active. -The event masks are specified by qualifier -.Ar qualifier -and -.Ar req-type . -.Pp -Qualifier -.Ar qualifier -is a -.Ql + -separated set of the following flags: -.Pp -.Bl -tag -width indent -compact -.It Li all-read -Count read entries. -.It Li all-write -Count write entries. -.It Li mem-uc *** 2245 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Tue Aug 10 20:37:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B49366DF74; Tue, 10 Aug 2021 20:37: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 4GklBH0gx8z53PT; Tue, 10 Aug 2021 20:37: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 EE99821F6A; Tue, 10 Aug 2021 20:37: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 17AKbQNR052170; Tue, 10 Aug 2021 20:37:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AKbQ4P052169; Tue, 10 Aug 2021 20:37:26 GMT (envelope-from git) Date: Tue, 10 Aug 2021 20:37:26 GMT Message-Id: <202108102037.17AKbQ4P052169@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 50f16247a110 - main - ntb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags. 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/main X-Git-Reftype: branch X-Git-Commit: 50f16247a110d2ace56f1120304616f3e6ad9763 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 20:37:27 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=50f16247a110d2ace56f1120304616f3e6ad9763 commit 50f16247a110d2ace56f1120304616f3e6ad9763 Author: Alexander Motin AuthorDate: 2021-08-10 20:24:48 +0000 Commit: Alexander Motin CommitDate: 2021-08-10 20:37:21 +0000 ntb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags. Most of the sysctls just read hardware registers. They don't need any locking. MFC after: 2 weeks --- sys/dev/ntb/ntb_hw/ntb_hw_intel.c | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c index 88fc3d6a36a1..d048f6c18934 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c @@ -2521,15 +2521,15 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) globals = SYSCTL_CHILDREN(device_get_sysctl_tree(ntb->device)); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "link_status", - CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, sysctl_handle_link_status_human, "A", "Link status (human readable)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "active", - CTLFLAG_RD | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RD | CTLTYPE_UINT, ntb, 0, sysctl_handle_link_status, "IU", "Link status (1=active, 0=inactive)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "admin_up", - CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RW | CTLTYPE_UINT, ntb, 0, sysctl_handle_link_admin, "IU", "Set/get interface status (1=UP, 0=DOWN)"); @@ -2555,7 +2555,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) } SYSCTL_ADD_PROC(ctx, tree_par, OID_AUTO, "features", - CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, sysctl_handle_features, "A", "Features/errata of this NTB device"); SYSCTL_ADD_UINT(ctx, tree_par, OID_AUTO, "ntb_ctl", CTLFLAG_RD, @@ -2589,63 +2589,63 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) regpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ntbcntl", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->reg->ntb_ctl, sysctl_handle_register, "IU", "NTB Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcap", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | 0x19c, sysctl_handle_register, "IU", "NTB Link Capabilities"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcon", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | 0x1a0, sysctl_handle_register, "IU", "NTB Link Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_mask", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_mask, sysctl_handle_register, "QU", "Doorbell mask register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_bell", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_bell, sysctl_handle_register, "QU", "Doorbell register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_xlat, sysctl_handle_register, "QU", "Incoming XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "IU", "Incoming XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_xlat, sysctl_handle_register, "IU", "Incoming XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "QU", "Incoming XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_limit, sysctl_handle_register, "QU", "Incoming LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "IU", "Incoming LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_limit, sysctl_handle_register, "IU", "Incoming LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "QU", "Incoming LMT45 register"); } @@ -2657,7 +2657,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Xeon HW statistics"); statpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, statpar, OID_AUTO, "upstream_mem_miss", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | XEON_USMEMMISS_OFFSET, sysctl_handle_register, "SU", "Upstream Memory Miss"); @@ -2666,55 +2666,55 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) errpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ppd", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | NTB_PPD_OFFSET, sysctl_handle_register, "CU", "PPD"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR23SZ_OFFSET, sysctl_handle_register, "CU", "PBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR4SZ_OFFSET, sysctl_handle_register, "CU", "PBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR5SZ_OFFSET, sysctl_handle_register, "CU", "PBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR23SZ_OFFSET, sysctl_handle_register, "CU", "SBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR4SZ_OFFSET, sysctl_handle_register, "CU", "SBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR5SZ_OFFSET, sysctl_handle_register, "CU", "SBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "devsts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_DEVSTS_OFFSET, sysctl_handle_register, "SU", "DEVSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_LINK_STATUS_OFFSET, sysctl_handle_register, "SU", "LNKSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "slnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_SLINK_STATUS_OFFSET, sysctl_handle_register, "SU", "SLNKSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "uncerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_UNCERRSTS_OFFSET, sysctl_handle_register, "IU", "UNCERRSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "corerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_CORERRSTS_OFFSET, sysctl_handle_register, "IU", "CORERRSTS"); @@ -2722,75 +2722,75 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) return; SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01l", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETL, sysctl_handle_register, "IU", "Outgoing XLAT0L register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01u", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETU, sysctl_handle_register, "IU", "Outgoing XLAT0U register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_1].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_3].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | XEON_PBAR2LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_PBAR5LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar01_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar0_base, sysctl_handle_register, "QU", "Secondary BAR01 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_base, sysctl_handle_register, "QU", "Secondary BAR23 base register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "IU", "Secondary BAR4 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_base, sysctl_handle_register, "IU", "Secondary BAR5 base register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar45_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "QU", "Secondary BAR45 base register"); From owner-dev-commits-src-all@freebsd.org Tue Aug 10 20:37:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 579E366E448; Tue, 10 Aug 2021 20:37: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 4GklBJ1CXFz535N; Tue, 10 Aug 2021 20:37: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 12B662213F; Tue, 10 Aug 2021 20:37: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 17AKbRM7052195; Tue, 10 Aug 2021 20:37:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AKbRbH052194; Tue, 10 Aug 2021 20:37:27 GMT (envelope-from git) Date: Tue, 10 Aug 2021 20:37:27 GMT Message-Id: <202108102037.17AKbRbH052194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: c6902e7796bc - main - ntb_transport(4): Mark callouts MP-safe. 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/main X-Git-Reftype: branch X-Git-Commit: c6902e7796bc78df011131a2b8b024faed884b8f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 20:37:28 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c6902e7796bc78df011131a2b8b024faed884b8f commit c6902e7796bc78df011131a2b8b024faed884b8f Author: Alexander Motin AuthorDate: 2021-08-10 20:30:12 +0000 Commit: Alexander Motin CommitDate: 2021-08-10 20:37:21 +0000 ntb_transport(4): Mark callouts MP-safe. The only thing around NTB using Giant lock is NewBus, and these callouts have nothing to do with it. MFC after: 2 weeks --- sys/dev/ntb/ntb_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/ntb/ntb_transport.c b/sys/dev/ntb/ntb_transport.c index 90420db0b9aa..276fe604086e 100644 --- a/sys/dev/ntb/ntb_transport.c +++ b/sys/dev/ntb/ntb_transport.c @@ -493,8 +493,8 @@ ntb_transport_attach(device_t dev) for (i = 0; i < nt->qp_count; i++) ntb_transport_init_queue(nt, i); - callout_init(&nt->link_work, 0); - callout_init(&nt->link_watchdog, 0); + callout_init(&nt->link_work, 1); + callout_init(&nt->link_watchdog, 1); TASK_INIT(&nt->link_cleanup, 0, ntb_transport_link_cleanup_work, nt); nt->link_is_up = false; @@ -639,7 +639,7 @@ ntb_transport_init_queue(struct ntb_transport_ctx *nt, unsigned int qp_num) qp->tx_max_frame = qmin(transport_mtu, tx_size / 2); qp->tx_max_entry = tx_size / qp->tx_max_frame; - callout_init(&qp->link_work, 0); + callout_init(&qp->link_work, 1); callout_init(&qp->rx_full, 1); mtx_init(&qp->ntb_rx_q_lock, "ntb rx q", NULL, MTX_SPIN); From owner-dev-commits-src-all@freebsd.org Tue Aug 10 21:11:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4A1ED66E753; Tue, 10 Aug 2021 21:11: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 4Gklxt1QF0z55ls; Tue, 10 Aug 2021 21:11: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 18D4522D8E; Tue, 10 Aug 2021 21:11: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 17ALBkt1005222; Tue, 10 Aug 2021 21:11:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ALBj38005221; Tue, 10 Aug 2021 21:11:45 GMT (envelope-from git) Date: Tue, 10 Aug 2021 21:11:45 GMT Message-Id: <202108102111.17ALBj38005221@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 38911b3c2c7d - main - ar: provide error exit status upon failure 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/main X-Git-Reftype: branch X-Git-Commit: 38911b3c2c7dbb9a097b44856472ebbbedde71fc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 21:11:46 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=38911b3c2c7dbb9a097b44856472ebbbedde71fc commit 38911b3c2c7dbb9a097b44856472ebbbedde71fc Author: Ed Maste AuthorDate: 2021-08-03 18:30:06 +0000 Commit: Ed Maste CommitDate: 2021-08-10 21:08:10 +0000 ar: provide error exit status upon failure Previously ar and ranlib returned with exit status 0 (success) in the case of a missing file or other error. Update to use error handling similar to that added by ELF Tool Chain after that project forked FreeBSD's ar. PR: PR257599 [exp-run] Reported by: Shawn Webb, gehmehgeh (on HardenedBSD IRC) Reviewed by: markj Obtained from: elftoolchain MFC after: 2 months Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31402 --- usr.bin/ar/acplex.l | 4 ++-- usr.bin/ar/acpyacc.y | 6 ++--- usr.bin/ar/ar.c | 62 ++++++++++++++++++++++++++++------------------------ usr.bin/ar/ar.h | 20 ++++++++--------- usr.bin/ar/read.c | 36 +++++++++++++++++++----------- usr.bin/ar/write.c | 49 ++++++++++++++++++++++++----------------- 6 files changed, 100 insertions(+), 77 deletions(-) diff --git a/usr.bin/ar/acplex.l b/usr.bin/ar/acplex.l index f9b7deba0dda..8eb47e6a8d0e 100644 --- a/usr.bin/ar/acplex.l +++ b/usr.bin/ar/acplex.l @@ -33,8 +33,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#include #include "y.tab.h" @@ -72,7 +72,7 @@ SAVE|save { return (SAVE); } [-_A-Za-z0-9/:$.\\]+ { yylval.str = strdup(yytext); if (yylval.str == NULL) - errc(EX_SOFTWARE, errno, "strdup failed"); + errc(EXIT_FAILURE, errno, "strdup failed"); return (FNAME); } diff --git a/usr.bin/ar/acpyacc.y b/usr.bin/ar/acpyacc.y index 113b3818bff1..5d4eb9fb6b37 100644 --- a/usr.bin/ar/acpyacc.y +++ b/usr.bin/ar/acpyacc.y @@ -191,7 +191,7 @@ directory_cmd ; end_cmd - : END { arscp_end(EX_OK); } + : END { arscp_end(EXIT_SUCCESS); } ; extract_cmd @@ -655,9 +655,9 @@ ar_mode_script(struct bsdar *ar) interactive = isatty(fileno(stdin)); while(yyparse()) { if (!interactive) - arscp_end(1); + arscp_end(EXIT_FAILURE); } /* Script ends without END */ - arscp_end(EX_OK); + arscp_end(EXIT_SUCCESS); } diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c index 8e02471e1623..b131163342a6 100644 --- a/usr.bin/ar/ar.c +++ b/usr.bin/ar/ar.c @@ -72,7 +72,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include "ar.h" @@ -102,10 +101,11 @@ main(int argc, char **argv) struct bsdar *bsdar, bsdar_storage; char *p; size_t len; - int i, opt, Dflag, Uflag; + int exitcode, i, opt, Dflag, Uflag; bsdar = &bsdar_storage; memset(bsdar, 0, sizeof(*bsdar)); + exitcode = EXIT_SUCCESS; Dflag = 0; Uflag = 0; @@ -151,9 +151,10 @@ main(int argc, char **argv) bsdar->options |= AR_D; bsdar->options |= AR_S; while ((bsdar->filename = *argv++) != NULL) - ar_mode_s(bsdar); + if (ar_mode_s(bsdar)) + exitcode = EXIT_FAILURE; - exit(EX_OK); + exit(exitcode); } else { if (argc < 2) bsdar_usage(); @@ -161,7 +162,7 @@ main(int argc, char **argv) if (*argv[1] != '-') { len = strlen(argv[1]) + 2; if ((p = malloc(len)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, + bsdar_errc(bsdar, EXIT_FAILURE, errno, "malloc failed"); *p = '-'; (void)strlcpy(p + 1, argv[1], len - 1); @@ -262,23 +263,23 @@ main(int argc, char **argv) bsdar_usage(); if (bsdar->options & AR_A && bsdar->options & AR_B) - bsdar_errc(bsdar, EX_USAGE, 0, + bsdar_errc(bsdar, EXIT_FAILURE, 0, "only one of -a and -[bi] options allowed"); if (bsdar->options & AR_J && bsdar->options & AR_Z) - bsdar_errc(bsdar, EX_USAGE, 0, + bsdar_errc(bsdar, EXIT_FAILURE, 0, "only one of -j and -z options allowed"); if (bsdar->options & AR_S && bsdar->options & AR_SS) - bsdar_errc(bsdar, EX_USAGE, 0, + bsdar_errc(bsdar, EXIT_FAILURE, 0, "only one of -s and -S options allowed"); if (bsdar->options & (AR_A | AR_B)) { if (*argv == NULL) - bsdar_errc(bsdar, EX_USAGE, 0, + bsdar_errc(bsdar, EXIT_FAILURE, 0, "no position operand specified"); if ((bsdar->posarg = basename(*argv)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, + bsdar_errc(bsdar, EXIT_FAILURE, errno, "basename failed"); argc--; argv++; @@ -310,7 +311,7 @@ main(int argc, char **argv) if (bsdar->mode == 'M') { ar_mode_script(bsdar); - exit(EX_OK); + exit(EXIT_SUCCESS); } if ((bsdar->filename = *argv) == NULL) @@ -321,44 +322,47 @@ main(int argc, char **argv) if ((!bsdar->mode || strchr("ptx", bsdar->mode)) && bsdar->options & AR_S) { - ar_mode_s(bsdar); + exitcode = ar_mode_s(bsdar); if (!bsdar->mode) - exit(EX_OK); + exit(exitcode); } switch(bsdar->mode) { case 'd': - ar_mode_d(bsdar); + exitcode = ar_mode_d(bsdar); break; case 'm': - ar_mode_m(bsdar); + exitcode = ar_mode_m(bsdar); break; case 'p': - ar_mode_p(bsdar); + exitcode = ar_mode_p(bsdar); break; case 'q': - ar_mode_q(bsdar); + exitcode = ar_mode_q(bsdar); break; case 'r': - ar_mode_r(bsdar); + exitcode = ar_mode_r(bsdar); break; case 't': - ar_mode_t(bsdar); + exitcode = ar_mode_t(bsdar); break; case 'x': - ar_mode_x(bsdar); + exitcode = ar_mode_x(bsdar); break; default: bsdar_usage(); /* NOTREACHED */ } - for (i = 0; i < bsdar->argc; i++) - if (bsdar->argv[i] != NULL) + for (i = 0; i < bsdar->argc; i++) { + if (bsdar->argv[i] != NULL) { bsdar_warnc(bsdar, 0, "%s: not found in archive", bsdar->argv[i]); + exitcode = EXIT_FAILURE; + } + } - exit(EX_OK); + exit(exitcode); } static void @@ -366,7 +370,7 @@ set_mode(struct bsdar *bsdar, char opt) { if (bsdar->mode != '\0' && bsdar->mode != opt) - bsdar_errc(bsdar, EX_USAGE, 0, + bsdar_errc(bsdar, EXIT_FAILURE, 0, "Can't specify both -%c and -%c", opt, bsdar->mode); bsdar->mode = opt; } @@ -376,7 +380,7 @@ only_mode(struct bsdar *bsdar, const char *opt, const char *valid_modes) { if (strchr(valid_modes, bsdar->mode) == NULL) - bsdar_errc(bsdar, EX_USAGE, 0, + bsdar_errc(bsdar, EXIT_FAILURE, 0, "Option %s is not permitted in mode -%c", opt, bsdar->mode); } @@ -395,7 +399,7 @@ bsdar_usage(void) (void)fprintf(stderr, "\tar -t [-Tv] archive [file ...]\n"); (void)fprintf(stderr, "\tar -x [-CTouv] archive [file ...]\n"); (void)fprintf(stderr, "\tar -V\n"); - exit(EX_USAGE); + exit(EXIT_FAILURE); } static void @@ -404,19 +408,19 @@ ranlib_usage(void) (void)fprintf(stderr, "usage: ranlib [-DtU] archive ...\n"); (void)fprintf(stderr, "\tranlib -V\n"); - exit(EX_USAGE); + exit(EXIT_FAILURE); } static void bsdar_version(void) { (void)printf("BSD ar %s - %s\n", BSDAR_VERSION, archive_version_string()); - exit(EX_OK); + exit(EXIT_SUCCESS); } static void ranlib_version(void) { (void)printf("ranlib %s - %s\n", BSDAR_VERSION, archive_version_string()); - exit(EX_OK); + exit(EXIT_SUCCESS); } diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h index 733724748221..21b3a669a943 100644 --- a/usr.bin/ar/ar.h +++ b/usr.bin/ar/ar.h @@ -54,7 +54,7 @@ */ #define AC(CALL) do { \ if ((CALL)) \ - bsdar_errc(bsdar, EX_SOFTWARE, archive_errno(a), "%s", \ + bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s", \ archive_error_string(a)); \ } while (0) @@ -117,13 +117,13 @@ struct bsdar { void bsdar_errc(struct bsdar *, int _eval, int _code, const char *fmt, ...) __dead2; void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); -void ar_mode_d(struct bsdar *bsdar); -void ar_mode_m(struct bsdar *bsdar); -void ar_mode_p(struct bsdar *bsdar); -void ar_mode_q(struct bsdar *bsdar); -void ar_mode_r(struct bsdar *bsdar); -void ar_mode_s(struct bsdar *bsdar); -void ar_mode_t(struct bsdar *bsdar); -void ar_mode_x(struct bsdar *bsdar); -void ar_mode_A(struct bsdar *bsdar); +int ar_mode_d(struct bsdar *bsdar); +int ar_mode_m(struct bsdar *bsdar); +int ar_mode_p(struct bsdar *bsdar); +int ar_mode_q(struct bsdar *bsdar); +int ar_mode_r(struct bsdar *bsdar); +int ar_mode_s(struct bsdar *bsdar); +int ar_mode_t(struct bsdar *bsdar); +int ar_mode_x(struct bsdar *bsdar); +int ar_mode_A(struct bsdar *bsdar); void ar_mode_script(struct bsdar *ar); diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c index 7791fc155850..04130b859c32 100644 --- a/usr.bin/ar/read.c +++ b/usr.bin/ar/read.c @@ -37,38 +37,38 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#include #include "ar.h" -static void read_archive(struct bsdar *bsdar, char mode); +static int read_archive(struct bsdar *bsdar, char mode); -void +int ar_mode_p(struct bsdar *bsdar) { - read_archive(bsdar, 'p'); + return (read_archive(bsdar, 'p')); } -void +int ar_mode_t(struct bsdar *bsdar) { - read_archive(bsdar, 't'); + return (read_archive(bsdar, 't')); } -void +int ar_mode_x(struct bsdar *bsdar) { - read_archive(bsdar, 'x'); + return (read_archive(bsdar, 'x')); } /* * Handle read modes: 'x', 't' and 'p'. */ -static void +static int read_archive(struct bsdar *bsdar, char mode) { struct archive *a; @@ -85,13 +85,15 @@ read_archive(struct bsdar *bsdar, char mode) char **av; char buf[25]; char find; - int flags, r, i; + int exitcode, flags, r, i; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); + bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ)); + exitcode = EXIT_SUCCESS; + for (;;) { r = archive_read_next_header(a, &entry); if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY || @@ -120,7 +122,7 @@ read_archive(struct bsdar *bsdar, char mode) if (*av == NULL) continue; if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, + bsdar_errc(bsdar, EXIT_FAILURE, errno, "basename failed"); if (strcmp(bname, name) != 0) continue; @@ -206,11 +208,19 @@ read_archive(struct bsdar *bsdar, char mode) r = archive_read_extract(a, entry, flags); } - if (r) + if (r) { bsdar_warnc(bsdar, archive_errno(a), "%s", archive_error_string(a)); + exitcode = EXIT_FAILURE; + } } } + + if (r == ARCHIVE_FATAL) + exitcode = EXIT_FAILURE; + AC(archive_read_close(a)); AC(archive_read_free(a)); + + return (exitcode); } diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index 6ca20a372fdb..4cbdc12dcc2d 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -67,52 +67,52 @@ static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, static void prefault_buffer(const char *buf, size_t s); static void read_objs(struct bsdar *bsdar, const char *archive, int checkargv); -static void write_archive(struct bsdar *bsdar, char mode); +static int write_archive(struct bsdar *bsdar, char mode); static void write_cleanup(struct bsdar *bsdar); static void write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s); static void write_objs(struct bsdar *bsdar); -void +int ar_mode_d(struct bsdar *bsdar) { - write_archive(bsdar, 'd'); + return (write_archive(bsdar, 'd')); } -void +int ar_mode_m(struct bsdar *bsdar) { - write_archive(bsdar, 'm'); + return (write_archive(bsdar, 'm')); } -void +int ar_mode_q(struct bsdar *bsdar) { - write_archive(bsdar, 'q'); + return (write_archive(bsdar, 'q')); } -void +int ar_mode_r(struct bsdar *bsdar) { - write_archive(bsdar, 'r'); + return (write_archive(bsdar, 'r')); } -void +int ar_mode_s(struct bsdar *bsdar) { - write_archive(bsdar, 's'); + return (write_archive(bsdar, 's')); } -void +int ar_mode_A(struct bsdar *bsdar) { - write_archive(bsdar, 'A'); + return (write_archive(bsdar, 'A')); } /* @@ -378,16 +378,17 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) /* * Determine the constitution of resulting archive. */ -static void +static int write_archive(struct bsdar *bsdar, char mode) { struct ar_obj *nobj, *obj, *obj_temp, *pos; struct stat sb; const char *bname; char **av; - int i; + int exitcode, i; TAILQ_INIT(&bsdar->v_obj); + exitcode = EXIT_SUCCESS; nobj = NULL; pos = NULL; memset(&sb, 0, sizeof(sb)); @@ -400,14 +401,14 @@ write_archive(struct bsdar *bsdar, char mode) if (errno != ENOENT) { bsdar_warnc(bsdar, 0, "stat %s failed", bsdar->filename); - return; + return (EXIT_FAILURE); } /* We do not create archive in mode 'd', 'm' and 's'. */ if (mode != 'r' && mode != 'q') { bsdar_warnc(bsdar, 0, "%s: no such file", bsdar->filename); - return; + return (EXIT_FAILURE); } /* Issue a warning if -c is not specified when creating. */ @@ -491,8 +492,10 @@ write_archive(struct bsdar *bsdar, char mode) */ nobj = create_obj_from_file(bsdar, *av, obj->mtime); - if (nobj == NULL) + if (nobj == NULL) { + exitcode = EXIT_FAILURE; goto skip_obj; + } } if (bsdar->options & AR_V) @@ -526,8 +529,12 @@ new_archive: av = &bsdar->argv[i]; if (*av != NULL && (mode == 'r' || mode == 'q')) { nobj = create_obj_from_file(bsdar, *av, 0); - if (nobj != NULL) - insert_obj(bsdar, nobj, pos); + if (nobj == NULL) { + exitcode = EXIT_FAILURE; + *av = NULL; + continue; + } + insert_obj(bsdar, nobj, pos); if (bsdar->options & AR_V && nobj != NULL) (void)fprintf(stdout, "a - %s\n", *av); *av = NULL; @@ -537,6 +544,8 @@ new_archive: write_objs: write_objs(bsdar); write_cleanup(bsdar); + + return (exitcode); } /* From owner-dev-commits-src-all@freebsd.org Tue Aug 10 21:19:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9D1E266EF45; Tue, 10 Aug 2021 21:19: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 4Gkm6g2q8Lz55wx; Tue, 10 Aug 2021 21:19: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 492B922E88; Tue, 10 Aug 2021 21:19: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 17ALJNx9006730; Tue, 10 Aug 2021 21:19:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ALJNwu006729; Tue, 10 Aug 2021 21:19:23 GMT (envelope-from git) Date: Tue, 10 Aug 2021 21:19:23 GMT Message-Id: <202108102119.17ALJNwu006729@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: c7bb0f47f721 - main - nfs tls: Update for SSL_OP_ENABLE_KTLS. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c7bb0f47f721a2095ed6100bca595ba68fa5645a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 21:19:23 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c7bb0f47f721a2095ed6100bca595ba68fa5645a commit c7bb0f47f721a2095ed6100bca595ba68fa5645a Author: John Baldwin AuthorDate: 2021-08-10 21:18:43 +0000 Commit: John Baldwin CommitDate: 2021-08-10 21:18:43 +0000 nfs tls: Update for SSL_OP_ENABLE_KTLS. Upstream OpenSSL (and the KTLS backport) have switched to an opt-in option (SSL_OP_ENABLE_KTLS) in place of opt-out modes (SSL_MODE_NO_KTLS_TX and SSL_MODE_NO_KTLS_RX) for controlling kernel TLS. Reviewed by: rmacklem Sponsored by: Netflix MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31445 --- usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c | 5 +++++ usr.sbin/rpc.tlsservd/rpc.tlsservd.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c index af803f203ffd..5e66f4b4b2dd 100644 --- a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c +++ b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c @@ -573,9 +573,14 @@ rpctls_setupcl_ssl(void) SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; #else flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1_3; +#endif +#ifdef SSL_OP_ENABLE_KTLS + flags |= SSL_OP_ENABLE_KTLS; #endif SSL_CTX_set_options(ctx, flags); +#ifdef SSL_MODE_NO_KTLS_TX SSL_CTX_clear_mode(ctx, SSL_MODE_NO_KTLS_TX | SSL_MODE_NO_KTLS_RX); +#endif return (ctx); } diff --git a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c index 1c7687cad87a..71787b162acd 100644 --- a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c +++ b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c @@ -636,7 +636,12 @@ rpctls_setup_ssl(const char *certdir) SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, rpctls_verify_callback); } +#ifdef SSL_OP_ENABLE_KTLS + SSL_CTX_set_options(ctx, SSL_OP_ENABLE_KTLS); +#endif +#ifdef SSL_MODE_NO_KTLS_TX SSL_CTX_clear_mode(ctx, SSL_MODE_NO_KTLS_TX | SSL_MODE_NO_KTLS_RX); +#endif return (ctx); } From owner-dev-commits-src-all@freebsd.org Tue Aug 10 21:55:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4604266F661; Tue, 10 Aug 2021 21:55: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 4GkmwJ11qsz58Sc; Tue, 10 Aug 2021 21:55: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 0556623442; Tue, 10 Aug 2021 21:55: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 17ALtRXP060332; Tue, 10 Aug 2021 21:55:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ALtRfG060331; Tue, 10 Aug 2021 21:55:27 GMT (envelope-from git) Date: Tue, 10 Aug 2021 21:55:27 GMT Message-Id: <202108102155.17ALtRfG060331@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 5dedd2517db3 - main - devmatch: Ignore the pnp fields tagged as ignore ('#') MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5dedd2517db3ac1fc48e07c7daba684e5497d250 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 21:55:28 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5dedd2517db3ac1fc48e07c7daba684e5497d250 commit 5dedd2517db3ac1fc48e07c7daba684e5497d250 Author: Warner Losh AuthorDate: 2021-08-10 21:45:50 +0000 Commit: Warner Losh CommitDate: 2021-08-10 21:47:55 +0000 devmatch: Ignore the pnp fields tagged as ignore ('#') When matching entries, we should ignore those with a name of '#'. It's the standard way to skip elements and need to be present to have the proper offsets to the fields that are observed. No bus has a pnp attribute of '#' and that is now disallowed for future buses that are written. Sponsored by: Netflix Reviewed by: kbowling Differential Revision: https://reviews.freebsd.org/D31482 --- sbin/devmatch/devmatch.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sbin/devmatch/devmatch.c b/sbin/devmatch/devmatch.c index c1ed11f6e41f..fbb05222fa5e 100644 --- a/sbin/devmatch/devmatch.c +++ b/sbin/devmatch/devmatch.c @@ -313,6 +313,13 @@ search_hints(const char *bus, const char *dev, const char *pnpinfo) } if (bit >= 0 && ((1 << bit) & mask) == 0) break; + if (strcmp(cp + 2, "#") == 0) { + if (verbose_flag) { + printf("Ignoring %s (%c) table=%#x tomatch=%#x\n", + cp + 2, *cp, v, ival); + } + break; + } v = pnpval_as_int(cp + 2, pnpinfo); if (verbose_flag) printf("Matching %s (%c) table=%#x tomatch=%#x\n", @@ -351,6 +358,13 @@ search_hints(const char *bus, const char *dev, const char *pnpinfo) break; if (bit >= 0 && ((1 << bit) & mask) == 0) break; + if (strcmp(cp + 2, "#") == 0) { + if (verbose_flag) { + printf("Ignoring %s (%c) table=%#x tomatch=%#x\n", + cp + 2, *cp, v, ival); + } + break; + } s = pnpval_as_str(cp + 2, pnpinfo); if (verbose_flag) printf("Matching %s (%c) table=%s tomatch=%s\n", From owner-dev-commits-src-all@freebsd.org Tue Aug 10 22:41:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C81566FDBF; Tue, 10 Aug 2021 22:41: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 4Gknxs1QkHz3Cph; Tue, 10 Aug 2021 22:41: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 1997C23D6B; Tue, 10 Aug 2021 22:41: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 17AMfr3c025605; Tue, 10 Aug 2021 22:41:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AMfr63025604; Tue, 10 Aug 2021 22:41:53 GMT (envelope-from git) Date: Tue, 10 Aug 2021 22:41:53 GMT Message-Id: <202108102241.17AMfr63025604@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Scott Long Subject: git: 35547df5c786 - main - Call wakeup() with the lock held to avoid missed wakeup races. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: scottl X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 35547df5c78653b2da030f920323c0357056099f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 22:41:53 -0000 The branch main has been updated by scottl: URL: https://cgit.FreeBSD.org/src/commit/?id=35547df5c78653b2da030f920323c0357056099f commit 35547df5c78653b2da030f920323c0357056099f Author: Scott Long AuthorDate: 2021-08-10 22:36:38 +0000 Commit: Scott Long CommitDate: 2021-08-10 22:36:38 +0000 Call wakeup() with the lock held to avoid missed wakeup races. Submitted by: luiz Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/dev/sdhci/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index d075c2e05000..573e6949b57e 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -2078,8 +2078,8 @@ sdhci_generic_release_host(device_t brdev __unused, device_t reqdev) /* Deactivate led. */ WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl &= ~SDHCI_CTRL_LED); slot->bus_busy--; - SDHCI_UNLOCK(slot); wakeup(slot); + SDHCI_UNLOCK(slot); return (0); } From owner-dev-commits-src-all@freebsd.org Tue Aug 10 22:47:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 957BF670185; Tue, 10 Aug 2021 22:47: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 4Gkp413k2kz3Cxg; Tue, 10 Aug 2021 22:47: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 67C9D24183; Tue, 10 Aug 2021 22:47: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 17AMlDiF027032; Tue, 10 Aug 2021 22:47:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AMlDd5027031; Tue, 10 Aug 2021 22:47:13 GMT (envelope-from git) Date: Tue, 10 Aug 2021 22:47:13 GMT Message-Id: <202108102247.17AMlDd5027031@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Scott Long Subject: git: bd9e461cf7f7 - main - Address the reported mmc serialization issue. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: scottl X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bd9e461cf7f70f2a9b3bd566122bbf4e420d7e17 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 22:47:13 -0000 The branch main has been updated by scottl: URL: https://cgit.FreeBSD.org/src/commit/?id=bd9e461cf7f70f2a9b3bd566122bbf4e420d7e17 commit bd9e461cf7f70f2a9b3bd566122bbf4e420d7e17 Author: Scott Long AuthorDate: 2021-08-10 22:41:23 +0000 Commit: Scott Long CommitDate: 2021-08-10 22:41:23 +0000 Address the reported mmc serialization issue. Reset the mmc owner before calling the bridge release host callback. Some people are hitting the "mmc: host bridge didn't serialize us." panic as the bridge is released before the mmc owner is reset. Submitted by: luiz Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/dev/mmc/mmc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c index 29b3645beadd..74d0549ca491 100644 --- a/sys/dev/mmc/mmc.c +++ b/sys/dev/mmc/mmc.c @@ -412,7 +412,6 @@ static int mmc_release_bus(device_t busdev, device_t dev) { struct mmc_softc *sc; - int err; sc = device_get_softc(busdev); @@ -421,14 +420,9 @@ mmc_release_bus(device_t busdev, device_t dev) panic("mmc: releasing unowned bus."); if (sc->owner != dev) panic("mmc: you don't own the bus. game over."); - MMC_UNLOCK(sc); - err = MMCBR_RELEASE_HOST(device_get_parent(busdev), busdev); - if (err) - return (err); - MMC_LOCK(sc); sc->owner = NULL; MMC_UNLOCK(sc); - return (0); + return (MMCBR_RELEASE_HOST(device_get_parent(busdev), busdev)); } static uint32_t From owner-dev-commits-src-all@freebsd.org Tue Aug 10 23:11:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 285DC670783; Tue, 10 Aug 2021 23:11: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 4Gkpbd0HQqz3DfW; Tue, 10 Aug 2021 23:11: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 E6D51240E0; Tue, 10 Aug 2021 23:11: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 17ANB8cP063501; Tue, 10 Aug 2021 23:11:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ANB87E063500; Tue, 10 Aug 2021 23:11:08 GMT (envelope-from git) Date: Tue, 10 Aug 2021 23:11:08 GMT Message-Id: <202108102311.17ANB87E063500@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 9339e7c0bd56 - main - rtsx: Fix wakeup race similar to sdhci one fixed in 35547df5c786 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9339e7c0bd565506092bb0a2618ff32fb04bb2c4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 23:11:09 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9339e7c0bd565506092bb0a2618ff32fb04bb2c4 commit 9339e7c0bd565506092bb0a2618ff32fb04bb2c4 Author: Warner Losh AuthorDate: 2021-08-10 23:07:50 +0000 Commit: Warner Losh CommitDate: 2021-08-10 23:10:25 +0000 rtsx: Fix wakeup race similar to sdhci one fixed in 35547df5c786 rtsx copied code from sdhci, and has the same wakeup race bug that was fixed in 35547df5c786, so apply a similar fix here. Sponsored by: Netflix --- sys/dev/rtsx/rtsx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/rtsx/rtsx.c b/sys/dev/rtsx/rtsx.c index 4400fbef5412..cb85685c875c 100644 --- a/sys/dev/rtsx/rtsx.c +++ b/sys/dev/rtsx/rtsx.c @@ -3532,8 +3532,8 @@ rtsx_mmcbr_release_host(device_t bus, device_t child __unused) sc = device_get_softc(bus); RTSX_LOCK(sc); sc->rtsx_bus_busy--; - RTSX_UNLOCK(sc); wakeup(&sc->rtsx_bus_busy); + RTSX_UNLOCK(sc); return (0); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 00:07:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E0070671202; Wed, 11 Aug 2021 00:07: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 4GkqrW604Vz3J11; Wed, 11 Aug 2021 00:07: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 A6F9324D62; Wed, 11 Aug 2021 00:07: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 17B07NMC033959; Wed, 11 Aug 2021 00:07:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B07Nnu033958; Wed, 11 Aug 2021 00:07:23 GMT (envelope-from git) Date: Wed, 11 Aug 2021 00:07:23 GMT Message-Id: <202108110007.17B07Nnu033958@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 94feb1f1eb4c - main - ntb_hw_intel(4): Add CTLFLAG_MPSAFE flags. 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/main X-Git-Reftype: branch X-Git-Commit: 94feb1f1eb4c3527efdbd0b3f556eb3cb37c3318 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 00:07:23 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=94feb1f1eb4c3527efdbd0b3f556eb3cb37c3318 commit 94feb1f1eb4c3527efdbd0b3f556eb3cb37c3318 Author: Alexander Motin AuthorDate: 2021-08-11 00:03:12 +0000 Commit: Alexander Motin CommitDate: 2021-08-11 00:07:19 +0000 ntb_hw_intel(4): Add CTLFLAG_MPSAFE flags. I should have added those in 50f16247a1. MFC after: 2 weeks --- sys/dev/ntb/ntb_hw/ntb_hw_intel.c | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c index d048f6c18934..06206f812d3f 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c @@ -2521,15 +2521,15 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) globals = SYSCTL_CHILDREN(device_get_sysctl_tree(ntb->device)); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "link_status", - CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_link_status_human, "A", "Link status (human readable)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "active", - CTLFLAG_RD | CTLTYPE_UINT, ntb, 0, + CTLFLAG_RD | CTLTYPE_UINT | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_link_status, "IU", "Link status (1=active, 0=inactive)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "admin_up", - CTLFLAG_RW | CTLTYPE_UINT, ntb, 0, + CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_link_admin, "IU", "Set/get interface status (1=UP, 0=DOWN)"); @@ -2555,7 +2555,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) } SYSCTL_ADD_PROC(ctx, tree_par, OID_AUTO, "features", - CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_features, "A", "Features/errata of this NTB device"); SYSCTL_ADD_UINT(ctx, tree_par, OID_AUTO, "ntb_ctl", CTLFLAG_RD, @@ -2589,63 +2589,63 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) regpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ntbcntl", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->reg->ntb_ctl, sysctl_handle_register, "IU", "NTB Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcap", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | 0x19c, sysctl_handle_register, "IU", "NTB Link Capabilities"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcon", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | 0x1a0, sysctl_handle_register, "IU", "NTB Link Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_mask", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_mask, sysctl_handle_register, "QU", "Doorbell mask register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_bell", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_bell, sysctl_handle_register, "QU", "Doorbell register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_xlat, sysctl_handle_register, "QU", "Incoming XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "IU", "Incoming XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_xlat, sysctl_handle_register, "IU", "Incoming XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "QU", "Incoming XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_limit, sysctl_handle_register, "QU", "Incoming LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "IU", "Incoming LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_limit, sysctl_handle_register, "IU", "Incoming LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "QU", "Incoming LMT45 register"); } @@ -2657,7 +2657,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Xeon HW statistics"); statpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, statpar, OID_AUTO, "upstream_mem_miss", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | XEON_USMEMMISS_OFFSET, sysctl_handle_register, "SU", "Upstream Memory Miss"); @@ -2666,55 +2666,55 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) errpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ppd", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | NTB_PPD_OFFSET, sysctl_handle_register, "CU", "PPD"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR23SZ_OFFSET, sysctl_handle_register, "CU", "PBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR4SZ_OFFSET, sysctl_handle_register, "CU", "PBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR5SZ_OFFSET, sysctl_handle_register, "CU", "PBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR23SZ_OFFSET, sysctl_handle_register, "CU", "SBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR4SZ_OFFSET, sysctl_handle_register, "CU", "SBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR5SZ_OFFSET, sysctl_handle_register, "CU", "SBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "devsts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_DEVSTS_OFFSET, sysctl_handle_register, "SU", "DEVSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_LINK_STATUS_OFFSET, sysctl_handle_register, "SU", "LNKSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "slnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_SLINK_STATUS_OFFSET, sysctl_handle_register, "SU", "SLNKSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "uncerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_UNCERRSTS_OFFSET, sysctl_handle_register, "IU", "UNCERRSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "corerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_CORERRSTS_OFFSET, sysctl_handle_register, "IU", "CORERRSTS"); @@ -2722,75 +2722,75 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) return; SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01l", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETL, sysctl_handle_register, "IU", "Outgoing XLAT0L register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01u", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETU, sysctl_handle_register, "IU", "Outgoing XLAT0U register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_1].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_3].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | XEON_PBAR2LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_PBAR5LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar01_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar0_base, sysctl_handle_register, "QU", "Secondary BAR01 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_base, sysctl_handle_register, "QU", "Secondary BAR23 base register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "IU", "Secondary BAR4 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_base, sysctl_handle_register, "IU", "Secondary BAR5 base register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar45_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "QU", "Secondary BAR45 base register"); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 00:07:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F3622671015; Wed, 11 Aug 2021 00:07: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 4GkqrX6S84z3Hvy; Wed, 11 Aug 2021 00:07: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 C6F82250F1; Wed, 11 Aug 2021 00:07: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 17B07OEk033983; Wed, 11 Aug 2021 00:07:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B07OJb033982; Wed, 11 Aug 2021 00:07:24 GMT (envelope-from git) Date: Wed, 11 Aug 2021 00:07:24 GMT Message-Id: <202108110007.17B07OJb033982@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 303477d32530 - main - cam(4): Mark all sysctls as CTLFLAG_MPSAFE. 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/main X-Git-Reftype: branch X-Git-Commit: 303477d3253007bb5732deed2daea86b2cbd9aa8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 00:07:25 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=303477d3253007bb5732deed2daea86b2cbd9aa8 commit 303477d3253007bb5732deed2daea86b2cbd9aa8 Author: Alexander Motin AuthorDate: 2021-08-11 00:05:40 +0000 Commit: Alexander Motin CommitDate: 2021-08-11 00:07:19 +0000 cam(4): Mark all sysctls as CTLFLAG_MPSAFE. This code does not use Giant lock for very long time. MFC after: 2 weeks --- sys/cam/ata/ata_da.c | 6 +++--- sys/cam/cam_iosched.c | 14 +++++++------- sys/cam/ctl/ctl.c | 2 +- sys/cam/ctl/ctl_ha.c | 2 +- sys/cam/scsi/scsi_all.c | 2 +- sys/cam/scsi/scsi_cd.c | 2 +- sys/cam/scsi/scsi_da.c | 12 ++++++------ sys/cam/scsi/scsi_xpt.c | 24 ++---------------------- 8 files changed, 22 insertions(+), 42 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 7063a40fcc3c..72bbbfe8ab1f 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1494,7 +1494,7 @@ adasysctlinit(void *context, int pending) SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_method", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, softc, 0, adadeletemethodsysctl, "A", "BIO_DELETE execution method"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, @@ -1517,12 +1517,12 @@ adasysctlinit(void *context, int pending) &softc->write_cache, 0, "Enable disk write cache."); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_mode", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, adazonemodesysctl, "A", "Zone Mode"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_support", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, adazonesupsysctl, "A", "Zone Support"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index b293002fb2ca..98ae98bc1d80 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -1009,7 +1009,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "limiter", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, ios, 0, cam_iosched_limiter_sysctl, "A", "Current limiting type."); SYSCTL_ADD_INT(ctx, n, @@ -1027,7 +1027,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "latencies", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, &ios->latencies, 0, cam_iosched_sysctl_latencies, "A", "Array of power of 2 latency from 1ms to 1.024s"); @@ -1057,22 +1057,22 @@ cam_iosched_cl_sysctl_init(struct cam_iosched_softc *isc) SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "type", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, clp, 0, cam_iosched_control_type_sysctl, "A", "Control loop algorithm"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "steer_interval", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->steer_interval, 0, cam_iosched_sbintime_sysctl, "A", "How often to steer (in us)"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "lolat", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->lolat, 0, cam_iosched_sbintime_sysctl, "A", "Low water mark for Latency (in us)"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "hilat", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->hilat, 0, cam_iosched_sbintime_sysctl, "A", "Hi water mark for Latency (in us)"); SYSCTL_ADD_INT(ctx, n, @@ -1200,7 +1200,7 @@ void cam_iosched_sysctl_init(struct cam_iosched_softc *isc, "How biased towards read should we be independent of limits"); SYSCTL_ADD_PROC(ctx, n, - OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, &isc->quanta, 0, cam_iosched_quanta_sysctl, "I", "How many quanta per second do we slice the I/O up into"); diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 575c8eea5198..8ad8bcec434b 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -1978,7 +1978,7 @@ ctl_init(void) SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "ha_role", - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, ctl_ha_role_sysctl, "I", "HA role for this head"); if (softc->is_single == 0) { diff --git a/sys/cam/ctl/ctl_ha.c b/sys/cam/ctl/ctl_ha.c index 80dfc543303d..e2ecb9706f56 100644 --- a/sys/cam/ctl/ctl_ha.c +++ b/sys/cam/ctl/ctl_ha.c @@ -896,7 +896,7 @@ ctl_ha_msg_init(struct ctl_softc *ctl_softc) SYSCTL_ADD_PROC(&ctl_softc->sysctl_ctx, SYSCTL_CHILDREN(ctl_softc->sysctl_tree), OID_AUTO, "ha_peer", - CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, ctl_ha_peer_sysctl, "A", "HA peer connection method"); if (ctl_ha_msg_register(CTL_HA_CHAN_DATA, ctl_dt_event_handler) diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c index 1b60003a4ac7..5a50d5bb134b 100644 --- a/sys/cam/scsi/scsi_all.c +++ b/sys/cam/scsi/scsi_all.c @@ -9236,7 +9236,7 @@ sysctl_scsi_delay(SYSCTL_HANDLER_ARGS) return (set_scsi_delay(delay)); } SYSCTL_PROC(_kern_cam, OID_AUTO, scsi_delay, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, 0, sysctl_scsi_delay, "I", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_scsi_delay, "I", "Delay to allow devices to settle after a SCSI bus reset (ms)"); static int diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index e790b0c89d02..4babe4003050 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -538,7 +538,7 @@ cdsysctlinit(void *context, int pending) */ SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "minimum_cmd_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->minimum_command_size, 0, cdcmdsizesysctl, "I", "Minimum CDB size"); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 676bf33d0bf8..40978d68cebf 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1579,7 +1579,7 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, enable_uma_ccbs, CTLFLAG_RWTUN, &da_enable_uma_ccbs, 0, "Use UMA for CCBs"); SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, dasysctlsofttimeout, "I", "Soft I/O timeout (ms)"); TUNABLE_INT64("kern.cam.da.default_softtimeout", &da_default_softtimeout); @@ -2280,17 +2280,17 @@ dasysctlinit(void *context, int pending) */ SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_method", - CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, dadeletemethodsysctl, "A", "BIO_DELETE execution method"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_max", - CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, softc, 0, dadeletemaxsysctl, "Q", "Maximum BIO_DELETE size"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "minimum_cmd_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->minimum_cmd_size, 0, dacmdsizesysctl, "I", "Minimum CDB size"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, @@ -2308,12 +2308,12 @@ dasysctlinit(void *context, int pending) SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_mode", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, dazonemodesysctl, "A", "Zone Mode"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_support", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, dazonesupsysctl, "A", "Zone Support"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 6b77d50b25c3..46cc4c1699f1 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -79,11 +79,8 @@ struct scsi_quirk_entry { #define SCSI_QUIRK(dev) ((struct scsi_quirk_entry *)((dev)->quirk)) static int cam_srch_hi = 0; -static int sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 0, 0, - sysctl_cam_search_luns, "I", - "allow search above LUN 7 for SCSI3 and greater devices"); +SYSCTL_INT(_kern_cam, OID_AUTO, cam_srch_hi, CTLFLAG_RWTUN, + &cam_srch_hi, 0, "Search above LUN 7 for SCSI3 and greater devices"); #define CAM_SCSI2_MAXLUN 8 #define CAM_CAN_GET_SIMPLE_LUN(x, i) \ @@ -1899,23 +1896,6 @@ scsi_find_quirk(struct cam_ed *device) device->maxtags = quirk->maxtags; } -static int -sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS) -{ - int error, val; - - val = cam_srch_hi; - error = sysctl_handle_int(oidp, &val, 0, req); - if (error != 0 || req->newptr == NULL) - return (error); - if (val == 0 || val == 1) { - cam_srch_hi = val; - return (0); - } else { - return (EINVAL); - } -} - typedef struct { union ccb *request_ccb; struct ccb_pathinq *cpi; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 00:45:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1E36F671949; Wed, 11 Aug 2021 00:45: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 4Gkrhl6vBxz3Kk7; Wed, 11 Aug 2021 00:45: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 D1E3F259EC; Wed, 11 Aug 2021 00:45: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 17B0jh8r086182; Wed, 11 Aug 2021 00:45:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B0jhrA086181; Wed, 11 Aug 2021 00:45:43 GMT (envelope-from git) Date: Wed, 11 Aug 2021 00:45:43 GMT Message-Id: <202108110045.17B0jhrA086181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: c2da954203c0 - main - geom(4): Mark all sysctls as CTLFLAG_MPSAFE. 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/main X-Git-Reftype: branch X-Git-Commit: c2da954203c0feb933d3be304710e0346c9ed222 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 00:45:44 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c2da954203c0feb933d3be304710e0346c9ed222 commit c2da954203c0feb933d3be304710e0346c9ed222 Author: Alexander Motin AuthorDate: 2021-08-11 00:18:46 +0000 Commit: Alexander Motin CommitDate: 2021-08-11 00:18:46 +0000 geom(4): Mark all sysctls as CTLFLAG_MPSAFE. This code does not use Giant lock for very long time. MFC after: 2 weeks --- sys/geom/cache/g_cache.c | 4 ++-- sys/geom/geom_disk.c | 2 +- sys/geom/geom_kern.c | 6 +++--- sys/geom/journal/g_journal.c | 6 +++--- sys/geom/stripe/g_stripe.c | 16 ++-------------- sys/geom/zero/g_zero.c | 2 +- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/sys/geom/cache/g_cache.c b/sys/geom/cache/g_cache.c index 05e45e6ea452..2caae5ede0f4 100644 --- a/sys/geom/cache/g_cache.c +++ b/sys/geom/cache/g_cache.c @@ -85,11 +85,11 @@ sysctl_handle_pct(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_cache, OID_AUTO, used_lo, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &g_cache_used_lo, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, &g_cache_used_lo, 0, sysctl_handle_pct, "IU", ""); SYSCTL_PROC(_kern_geom_cache, OID_AUTO, used_hi, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &g_cache_used_hi, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, &g_cache_used_hi, 0, sysctl_handle_pct, "IU", ""); diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 83d570f7e445..2f0e72fad52d 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -745,7 +745,7 @@ g_disk_create(void *arg, int flag) "LED name"); SYSCTL_ADD_PROC(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "flags", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, dp, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dp, 0, g_disk_sysctl_flags, "A", "Report disk flags"); } pp->private = sc; diff --git a/sys/geom/geom_kern.c b/sys/geom/geom_kern.c index e06824afc9fd..4b7219591dce 100644 --- a/sys/geom/geom_kern.c +++ b/sys/geom/geom_kern.c @@ -208,17 +208,17 @@ SYSCTL_NODE(_kern, OID_AUTO, geom, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "GEOMetry management"); SYSCTL_PROC(_kern_geom, OID_AUTO, confxml, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, 0, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_geom_confxml, "", "Dump the GEOM config in XML"); SYSCTL_PROC(_kern_geom, OID_AUTO, confdot, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, 0, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_geom_confdot, "", "Dump the GEOM config in dot"); SYSCTL_PROC(_kern_geom, OID_AUTO, conftxt, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, 0, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_geom_conftxt, "", "Dump the GEOM config in txt"); diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 0b518d172b5a..7c8c60183bff 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -129,7 +129,7 @@ g_journal_record_entries_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal, OID_AUTO, record_entries, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, g_journal_record_entries_sysctl, "I", "Maximum number of entires in one journal record"); SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, @@ -163,7 +163,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0, g_journal_cache_limit_sysctl, "I", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, @@ -186,7 +186,7 @@ g_journal_cache_switch_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, switch, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, g_journal_cache_switch_sysctl, "I", "Force switch when we hit this percent of cache use"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, misses, CTLFLAG_RW, diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c index 22cc16753d9a..9b4df1b8dba6 100644 --- a/sys/geom/stripe/g_stripe.c +++ b/sys/geom/stripe/g_stripe.c @@ -77,20 +77,8 @@ static u_int g_stripe_debug = 0; SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RWTUN, &g_stripe_debug, 0, "Debug level"); static int g_stripe_fast = 0; -static int -g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) -{ - int error, fast; - - fast = g_stripe_fast; - error = sysctl_handle_int(oidp, &fast, 0, req); - if (error == 0 && req->newptr != NULL) - g_stripe_fast = fast; - return (error); -} -SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, NULL, 0, - g_sysctl_stripe_fast, "I", +SYSCTL_INT(_kern_geom_stripe, OID_AUTO, fast, + CTLFLAG_RWTUN, &g_stripe_fast, 0, "Fast, but memory-consuming, mode"); static u_long g_stripe_maxmem; SYSCTL_ULONG(_kern_geom_stripe, OID_AUTO, maxmem, diff --git a/sys/geom/zero/g_zero.c b/sys/geom/zero/g_zero.c index ef43a032d470..c533a758a236 100644 --- a/sys/geom/zero/g_zero.c +++ b/sys/geom/zero/g_zero.c @@ -49,7 +49,7 @@ static SYSCTL_NODE(_kern_geom, OID_AUTO, zero, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "GEOM_ZERO stuff"); static int g_zero_clear = 1; SYSCTL_PROC(_kern_geom_zero, OID_AUTO, clear, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &g_zero_clear, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &g_zero_clear, 0, g_zero_clear_sysctl, "I", "Clear read data buffer"); static int g_zero_byte = 0; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 00:45:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 26ACF6717DE; Wed, 11 Aug 2021 00:45: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 4Gkrhn0Fv6z3Kvw; Wed, 11 Aug 2021 00:45: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 E650E25822; Wed, 11 Aug 2021 00:45:44 +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 17B0jioi086213; Wed, 11 Aug 2021 00:45:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B0jiNZ086212; Wed, 11 Aug 2021 00:45:44 GMT (envelope-from git) Date: Wed, 11 Aug 2021 00:45:44 GMT Message-Id: <202108110045.17B0jiNZ086212@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: b776de6796fa - main - Mark some sysctls as CTLFLAG_MPSAFE. 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/main X-Git-Reftype: branch X-Git-Commit: b776de6796fa0cd1b7dfaad75402e10907d47f29 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 00:45:45 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=b776de6796fa0cd1b7dfaad75402e10907d47f29 commit b776de6796fa0cd1b7dfaad75402e10907d47f29 Author: Alexander Motin AuthorDate: 2021-08-11 00:44:27 +0000 Commit: Alexander Motin CommitDate: 2021-08-11 00:44:27 +0000 Mark some sysctls as CTLFLAG_MPSAFE. MFC after: 2 weeks --- sys/dev/ahci/ahci.c | 2 +- sys/dev/ioat/ioat.c | 6 +++--- sys/dev/isp/isp_freebsd.c | 2 +- sys/dev/mpr/mpr.c | 2 +- sys/dev/mps/mps.c | 6 +++--- sys/dev/mpt/mpt_raid.c | 12 +++--------- sys/dev/nvme/nvme_sysctl.c | 18 +++++++++--------- 7 files changed, 21 insertions(+), 27 deletions(-) diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 47a5ef455f82..4b13ae3068d5 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -922,7 +922,7 @@ ahci_ch_attach(device_t dev) ctx = device_get_sysctl_ctx(dev); tree = device_get_sysctl_tree(dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "disable_phy", - CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, ch, + CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, ch, 0, ahci_ch_disablephy_proc, "IU", "Disable PHY"); return (0); diff --git a/sys/dev/ioat/ioat.c b/sys/dev/ioat/ioat.c index 7e6a33a4285b..45a6c273822d 100644 --- a/sys/dev/ioat/ioat.c +++ b/sys/dev/ioat/ioat.c @@ -1952,7 +1952,7 @@ ioat_setup_sysctl(device_t device) "submitter processing"); SYSCTL_ADD_PROC(ctx, state, OID_AUTO, "chansts", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, ioat, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, ioat, 0, sysctl_handle_chansts, "A", "String of the channel status"); SYSCTL_ADD_U16(ctx, state, OID_AUTO, "intrdelay", CTLFLAG_RD, @@ -1965,7 +1965,7 @@ ioat_setup_sysctl(device_t device) hammer = SYSCTL_CHILDREN(tmp); SYSCTL_ADD_PROC(ctx, hammer, OID_AUTO, "force_hw_reset", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, ioat, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, ioat, 0, sysctl_handle_reset, "I", "Set to non-zero to reset the hardware"); tmp = SYSCTL_ADD_NODE(ctx, par, OID_AUTO, "stats", @@ -1992,7 +1992,7 @@ ioat_setup_sysctl(device_t device) "The raw CHANERR when the channel was last halted"); SYSCTL_ADD_PROC(ctx, statpar, OID_AUTO, "desc_per_interrupt", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, ioat, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, ioat, 0, sysctl_handle_dpi, "A", "Descriptors per interrupt"); } diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index 657d3c4446ed..d5e70e96fc44 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -191,7 +191,7 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan) "Cause a Lost Frame on a Read"); #endif SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "role", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "role", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, isp, chan, isp_role_sysctl, "I", "Current role"); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "speed", CTLFLAG_RD, &fcp->isp_gbspeed, 0, diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c index e5ed9b250ca0..796f74c2547b 100644 --- a/sys/dev/mpr/mpr.c +++ b/sys/dev/mpr/mpr.c @@ -1915,7 +1915,7 @@ mpr_setup_sysctl(struct mpr_softc *sc) SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "dump_reqs", - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_NEEDGIANT, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, sc, 0, mpr_dump_reqs, "I", "Dump Active Requests"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c index 88e5cd0516bd..b4e0142204ef 100644 --- a/sys/dev/mps/mps.c +++ b/sys/dev/mps/mps.c @@ -1762,17 +1762,17 @@ mps_setup_sysctl(struct mps_softc *sc) SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "mapping_table_dump", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, mps_mapping_dump, "A", "Mapping Table Dump"); SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "encl_table_dump", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, mps_mapping_encl_dump, "A", "Enclosure Table Dump"); SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "dump_reqs", - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_NEEDGIANT, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, sc, 0, mps_dump_reqs, "I", "Dump Active Requests"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), diff --git a/sys/dev/mpt/mpt_raid.c b/sys/dev/mpt/mpt_raid.c index 603c2b42a370..660f5a833365 100644 --- a/sys/dev/mpt/mpt_raid.c +++ b/sys/dev/mpt/mpt_raid.c @@ -1747,8 +1747,6 @@ mpt_raid_sysctl_vol_member_wce(SYSCTL_HANDLER_ARGS) u_int size; u_int i; - GIANT_REQUIRED; - mpt = (struct mpt_softc *)arg1; str = mpt_vol_mwce_strs[mpt->raid_mwce_setting]; error = SYSCTL_OUT(req, str, strlen(str) + 1); @@ -1781,8 +1779,6 @@ mpt_raid_sysctl_vol_resync_rate(SYSCTL_HANDLER_ARGS) u_int raid_resync_rate; int error; - GIANT_REQUIRED; - mpt = (struct mpt_softc *)arg1; raid_resync_rate = mpt->raid_resync_rate; @@ -1801,8 +1797,6 @@ mpt_raid_sysctl_vol_queue_depth(SYSCTL_HANDLER_ARGS) u_int raid_queue_depth; int error; - GIANT_REQUIRED; - mpt = (struct mpt_softc *)arg1; raid_queue_depth = mpt->raid_queue_depth; @@ -1821,17 +1815,17 @@ mpt_raid_sysctl_attach(struct mpt_softc *mpt) struct sysctl_oid *tree = device_get_sysctl_tree(mpt->dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "vol_member_wce", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "vol_member_wce", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, mpt, 0, mpt_raid_sysctl_vol_member_wce, "A", "volume member WCE(On,Off,On-During-Rebuild,NC)"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "vol_queue_depth", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "vol_queue_depth", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, mpt, 0, mpt_raid_sysctl_vol_queue_depth, "I", "default volume queue depth"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "vol_resync_rate", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "vol_resync_rate", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, mpt, 0, mpt_raid_sysctl_vol_resync_rate, "I", "volume resync priority (0 == NC, 1 - 255)"); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c index e1771febea9b..9ec1f14511f5 100644 --- a/sys/dev/nvme/nvme_sysctl.c +++ b/sys/dev/nvme/nvme_sysctl.c @@ -278,7 +278,7 @@ nvme_sysctl_initialize_queue(struct nvme_qpair *qpair, "Number of commands ending in failure after all retries"); SYSCTL_ADD_PROC(ctrlr_ctx, que_list, OID_AUTO, - "dump_debug", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "dump_debug", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, qpair, 0, nvme_sysctl_dump_debug, "IU", "Dump debug data"); } @@ -301,46 +301,46 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr) "Number of I/O queue pairs"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_int_coal_time, "IU", "Interrupt coalescing timeout (in microseconds)"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "int_coal_threshold", - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, ctrlr, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_int_coal_threshold, "IU", "Interrupt coalescing threshold"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "timeout_period", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "timeout_period", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_timeout_period, "IU", "Timeout period (in seconds)"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_cmds", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + "num_cmds", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_cmds, "IU", "Number of commands submitted"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "num_intr_handler_calls", - CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, ctrlr, 0, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_intr_handler_calls, "IU", "Number of times interrupt handler was invoked (will " "typically be less than number of actual interrupts " "generated due to coalescing)"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_retries", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + "num_retries", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_retries, "IU", "Number of commands retried"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_failures", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + "num_failures", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_failures, "IU", "Number of commands ending in failure after all retries"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "reset_stats", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, ctrlr, + "reset_stats", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_reset_stats, "IU", "Reset statistics to zero"); que_tree = SYSCTL_ADD_NODE(ctrlr_ctx, ctrlr_list, OID_AUTO, "adminq", From owner-dev-commits-src-all@freebsd.org Wed Aug 11 00:49:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8803A6715ED; Wed, 11 Aug 2021 00:49: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 4Gkrn23Mprz3LBN; Wed, 11 Aug 2021 00:49: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 5BA31259EE; Wed, 11 Aug 2021 00:49: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 17B0nQ7Y086560; Wed, 11 Aug 2021 00:49:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B0nQOx086559; Wed, 11 Aug 2021 00:49:26 GMT (envelope-from git) Date: Wed, 11 Aug 2021 00:49:26 GMT Message-Id: <202108110049.17B0nQOx086559@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: 50c21bf33905 - stable/13 - Do not expose to scheduler caches of single CPU. 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: 50c21bf3390556920ba8d73c50292776ce58bdaf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 00:49:26 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=50c21bf3390556920ba8d73c50292776ce58bdaf commit 50c21bf3390556920ba8d73c50292776ce58bdaf Author: Alexander Motin AuthorDate: 2021-07-28 20:15:43 +0000 Commit: Alexander Motin CommitDate: 2021-08-11 00:49:22 +0000 Do not expose to scheduler caches of single CPU. Before this change my dual-Xeon(R) Gold 6242R always reported 3 levels or topology (root, package/L3 and core/L2). But with SMT disabled core/L2 matches thread, so additional topology level only causes more traversal work. With this change SMT case is reported same as before, while non-SMT is reported with only 2 much more simple levels. MFC after: 2 weeks (cherry picked from commit 5a49f1914178c5275105f2ab0d23a98118cd585f) --- sys/x86/x86/mp_x86.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 2dcdf923c467..f1c1e45e79b8 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -828,6 +828,12 @@ x86topo_add_sched_group(struct topo_node *root, struct cpu_group *cg_root) node = topo_next_nonchild_node(root, node); } + /* + * We are not interested in nodes including only one CPU each. + */ + if (nchildren == root->cpu_count) + return; + cg_root->cg_child = smp_topo_alloc(nchildren); cg_root->cg_children = nchildren; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 00:49:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70734671A46; Wed, 11 Aug 2021 00: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 4Gkrnf2mgMz3LLp; Wed, 11 Aug 2021 00: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 4730C25A88; Wed, 11 Aug 2021 00: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 17B0nwMw086705; Wed, 11 Aug 2021 00:49:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B0nwIv086704; Wed, 11 Aug 2021 00:49:58 GMT (envelope-from git) Date: Wed, 11 Aug 2021 00:49:58 GMT Message-Id: <202108110049.17B0nwIv086704@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: 70a137b75e14 - stable/12 - Do not expose to scheduler caches of single CPU. 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: 70a137b75e149611c101cb57e0322e370f669094 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 00:49:58 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=70a137b75e149611c101cb57e0322e370f669094 commit 70a137b75e149611c101cb57e0322e370f669094 Author: Alexander Motin AuthorDate: 2021-07-28 20:15:43 +0000 Commit: Alexander Motin CommitDate: 2021-08-11 00:49:48 +0000 Do not expose to scheduler caches of single CPU. Before this change my dual-Xeon(R) Gold 6242R always reported 3 levels or topology (root, package/L3 and core/L2). But with SMT disabled core/L2 matches thread, so additional topology level only causes more traversal work. With this change SMT case is reported same as before, while non-SMT is reported with only 2 much more simple levels. MFC after: 2 weeks (cherry picked from commit 5a49f1914178c5275105f2ab0d23a98118cd585f) --- sys/x86/x86/mp_x86.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 984edb43dd22..73565360007b 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -817,6 +817,12 @@ x86topo_add_sched_group(struct topo_node *root, struct cpu_group *cg_root) node = topo_next_nonchild_node(root, node); } + /* + * We are not interested in nodes including only one CPU each. + */ + if (nchildren == root->cpu_count) + return; + cg_root->cg_child = smp_topo_alloc(nchildren); cg_root->cg_children = nchildren; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:13:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 16804672280; Wed, 11 Aug 2021 01:13:43 +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 4GksK300hTz3Mtm; Wed, 11 Aug 2021 01:13: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 D19D926113; Wed, 11 Aug 2021 01:13:42 +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 17B1Dgbm026808; Wed, 11 Aug 2021 01:13:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1DgvZ026807; Wed, 11 Aug 2021 01:13:42 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:13:42 GMT Message-Id: <202108110113.17B1DgvZ026807@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: ec95c1303332 - stable/13 - pf: Initialize arrays before copying out to userland 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: ec95c1303332ea3f157a61d696be8a1d3ec5d3b7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:13:43 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ec95c1303332ea3f157a61d696be8a1d3ec5d3b7 commit ec95c1303332ea3f157a61d696be8a1d3ec5d3b7 Author: Mark Johnston AuthorDate: 2021-07-28 14:16:25 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:11:02 +0000 pf: Initialize arrays before copying out to userland A number of pf ioctls populate an array of structures and copy it out. They have the following structures: - caller specifies the size of its output buffer - ioctl handler allocates a kernel buffer of the same size - ioctl handler populates the buffer, possibly leaving some items initialized if the caller provided more space than needed - ioctl handler copies the entire buffer out to userland Thus, if more space was provided than is required, we end up copying out uninitialized kernel memory. Simply zero the buffer at allocation time to prevent this. Reported by: KMSAN Reviewed by: kp Sponsored by: The FreeBSD Foundation (cherry picked from commit 2b82c57e399700f5134c47d86d45ef2f2bd465e2) --- sys/netpfil/pf/pf_ioctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 39931540d03d..6d2403bf213d 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -3811,7 +3811,7 @@ DIOCCHANGEADDR_error: totlen = io->pfrio_size * sizeof(struct pfr_table); pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), - M_TEMP, M_NOWAIT); + M_TEMP, M_NOWAIT | M_ZERO); if (pfrts == NULL) { error = ENOMEM; PF_RULES_RUNLOCK(); @@ -3849,7 +3849,7 @@ DIOCCHANGEADDR_error: totlen = io->pfrio_size * sizeof(struct pfr_tstats); pfrtstats = mallocarray(io->pfrio_size, - sizeof(struct pfr_tstats), M_TEMP, M_NOWAIT); + sizeof(struct pfr_tstats), M_TEMP, M_NOWAIT | M_ZERO); if (pfrtstats == NULL) { error = ENOMEM; PF_RULES_RUNLOCK(); @@ -4081,7 +4081,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_WAITOK); + M_TEMP, M_WAITOK | M_ZERO); PF_RULES_RLOCK(); error = pfr_get_addrs(&io->pfrio_table, pfras, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -4109,7 +4109,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_astats); pfrastats = mallocarray(io->pfrio_size, - sizeof(struct pfr_astats), M_TEMP, M_WAITOK); + sizeof(struct pfr_astats), M_TEMP, M_WAITOK | M_ZERO); PF_RULES_RLOCK(); error = pfr_get_astats(&io->pfrio_table, pfrastats, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -4613,7 +4613,7 @@ DIOCCHANGEADDR_error: bufsiz = io->pfiio_size * sizeof(struct pfi_kif); ifstore = mallocarray(io->pfiio_size, sizeof(struct pfi_kif), - M_TEMP, M_WAITOK); + M_TEMP, M_WAITOK | M_ZERO); PF_RULES_RLOCK(); pfi_get_ifaces(io->pfiio_name, ifstore, &io->pfiio_size); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:13:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A1E1672025; Wed, 11 Aug 2021 01:13: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 4GksK40x6wz3N4X; Wed, 11 Aug 2021 01:13: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 03A7C260B4; Wed, 11 Aug 2021 01:13:44 +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 17B1DhR3026832; Wed, 11 Aug 2021 01:13:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1DhLl026831; Wed, 11 Aug 2021 01:13:43 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:13:43 GMT Message-Id: <202108110113.17B1DhLl026831@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: 76aa36ab4853 - stable/13 - pf: Validate user string nul-termination before copying 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: 76aa36ab4853eac6e6f5d2617323872a62b80b46 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:13:44 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=76aa36ab4853eac6e6f5d2617323872a62b80b46 commit 76aa36ab4853eac6e6f5d2617323872a62b80b46 Author: Mark Johnston AuthorDate: 2021-07-28 14:16:42 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:11:41 +0000 pf: Validate user string nul-termination before copying Some pf ioctl handlers use strlcpy() to copy strings when converting from user structures to their in-kernel representations. strlcpy() ensures that the destination will be nul-terminated, but it assumes that the source is nul-terminated. In particular, it returns the full length of the source string, so if the source is not nul-terminated, strlcpy() will keep scanning until it finds a nul byte, and it may encounter an unmapped page first. Add a helper to validate user strings before copying. There are also places where we look up a ruleset using a user-provided anchor string. In some ioctl handlers we were already nul-terminating the string, avoiding the same problem, but in other places we were not. Fix those by nul-terminating as well. Aside from being consistent, anchors have a maximum length of MAXPATHLEN - 1 so calling strnlen() might not be so desirable. Reported by: syzbot+35a1549b4663e9483dd1@syzkaller.appspotmail.com Reviewed by: kp Sponsored by: The FreeBSD Foundation (cherry picked from commit 64432ad2a2c4b10d3d3411a8ca018e2a35cec97e) --- sys/netpfil/pf/pf_ioctl.c | 123 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 92 insertions(+), 31 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 6d2403bf213d..edc786d804da 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -283,6 +283,20 @@ extern u_long pf_ioctl_maxcount; goto target; \ } while (0) +/* + * Copy a user-provided string, returning an error if truncation would occur. + * Avoid scanning past "sz" bytes in the source string since there's no + * guarantee that it's nul-terminated. + */ +static int +pf_user_strcpy(char *dst, const char *src, size_t sz) +{ + if (strnlen(src, sz) == sz) + return (EINVAL); + (void)strlcpy(dst, src, sz); + return (0); +} + static void pfattach_vnet(void) { @@ -1522,14 +1536,17 @@ pf_kpooladdr_to_pooladdr(const struct pf_kpooladdr *kpool, strlcpy(pool->ifname, kpool->ifname, sizeof(pool->ifname)); } -static void +static int pf_pooladdr_to_kpooladdr(const struct pf_pooladdr *pool, struct pf_kpooladdr *kpool) { + int ret; bzero(kpool, sizeof(*kpool)); bcopy(&pool->addr, &kpool->addr, sizeof(kpool->addr)); - strlcpy(kpool->ifname, pool->ifname, sizeof(kpool->ifname)); + ret = pf_user_strcpy(kpool->ifname, pool->ifname, + sizeof(kpool->ifname)); + return (ret); } static void @@ -1694,15 +1711,30 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule) bcopy(&rule->src, &krule->src, sizeof(rule->src)); bcopy(&rule->dst, &krule->dst, sizeof(rule->dst)); - strlcpy(krule->label[0], rule->label, sizeof(rule->label)); - strlcpy(krule->ifname, rule->ifname, sizeof(rule->ifname)); - strlcpy(krule->qname, rule->qname, sizeof(rule->qname)); - strlcpy(krule->pqname, rule->pqname, sizeof(rule->pqname)); - strlcpy(krule->tagname, rule->tagname, sizeof(rule->tagname)); - strlcpy(krule->match_tagname, rule->match_tagname, + ret = pf_user_strcpy(krule->label[0], rule->label, sizeof(rule->label)); + if (ret != 0) + return (ret); + ret = pf_user_strcpy(krule->ifname, rule->ifname, sizeof(rule->ifname)); + if (ret != 0) + return (ret); + ret = pf_user_strcpy(krule->qname, rule->qname, sizeof(rule->qname)); + if (ret != 0) + return (ret); + ret = pf_user_strcpy(krule->pqname, rule->pqname, sizeof(rule->pqname)); + if (ret != 0) + return (ret); + ret = pf_user_strcpy(krule->tagname, rule->tagname, + sizeof(rule->tagname)); + if (ret != 0) + return (ret); + ret = pf_user_strcpy(krule->match_tagname, rule->match_tagname, sizeof(rule->match_tagname)); - strlcpy(krule->overload_tblname, rule->overload_tblname, + if (ret != 0) + return (ret); + ret = pf_user_strcpy(krule->overload_tblname, rule->overload_tblname, sizeof(rule->overload_tblname)); + if (ret != 0) + return (ret); ret = pf_pool_to_kpool(&rule->rpool, &krule->rpool); if (ret != 0) @@ -1916,6 +1948,8 @@ static int pf_state_kill_to_kstate_kill(const struct pfioc_state_kill *psk, struct pf_kstate_kill *kill) { + int ret; + bzero(kill, sizeof(*kill)); bcopy(&psk->psk_pfcmp, &kill->psk_pfcmp, sizeof(kill->psk_pfcmp)); @@ -1923,8 +1957,14 @@ pf_state_kill_to_kstate_kill(const struct pfioc_state_kill *psk, kill->psk_proto = psk->psk_proto; bcopy(&psk->psk_src, &kill->psk_src, sizeof(kill->psk_src)); bcopy(&psk->psk_dst, &kill->psk_dst, sizeof(kill->psk_dst)); - strlcpy(kill->psk_ifname, psk->psk_ifname, sizeof(kill->psk_ifname)); - strlcpy(kill->psk_label, psk->psk_label, sizeof(kill->psk_label)); + ret = pf_user_strcpy(kill->psk_ifname, psk->psk_ifname, + sizeof(kill->psk_ifname)); + if (ret != 0) + return (ret); + ret = pf_user_strcpy(kill->psk_label, psk->psk_label, + sizeof(kill->psk_label)); + if (ret != 0) + return (ret); return (0); } @@ -2340,8 +2380,9 @@ DIOCADDRULENV_error: struct pf_krule *tail; int rs_num; - PF_RULES_WLOCK(); pr->anchor[sizeof(pr->anchor) - 1] = 0; + + PF_RULES_WLOCK(); ruleset = pf_find_kruleset(pr->anchor); if (ruleset == NULL) { PF_RULES_WUNLOCK(); @@ -2371,8 +2412,9 @@ DIOCADDRULENV_error: struct pf_krule *rule; int rs_num; - PF_RULES_WLOCK(); pr->anchor[sizeof(pr->anchor) - 1] = 0; + + PF_RULES_WLOCK(); ruleset = pf_find_kruleset(pr->anchor); if (ruleset == NULL) { PF_RULES_WUNLOCK(); @@ -2561,6 +2603,8 @@ DIOCGETRULENV_error: u_int32_t nr = 0; int rs_num; + pcr->anchor[sizeof(pcr->anchor) - 1] = 0; + if (pcr->action < PF_CHANGE_ADD_HEAD || pcr->action > PF_CHANGE_GET_TICKET) { error = EINVAL; @@ -3028,7 +3072,7 @@ DIOCGETSTATESV2_full: break; } PF_RULES_WLOCK(); - strlcpy(V_pf_status.ifname, pi->ifname, IFNAMSIZ); + error = pf_user_strcpy(V_pf_status.ifname, pi->ifname, IFNAMSIZ); PF_RULES_WUNLOCK(); break; } @@ -3194,19 +3238,23 @@ DIOCGETSTATESV2_full: struct pf_ifspeed_v1 ps; struct ifnet *ifp; - if (psp->ifname[0] != 0) { - /* Can we completely trust user-land? */ - strlcpy(ps.ifname, psp->ifname, IFNAMSIZ); - ifp = ifunit(ps.ifname); - if (ifp != NULL) { - psp->baudrate32 = - (u_int32_t)uqmin(ifp->if_baudrate, UINT_MAX); - if (cmd == DIOCGIFSPEEDV1) - psp->baudrate = ifp->if_baudrate; - } else - error = EINVAL; - } else + if (psp->ifname[0] == '\0') { + error = EINVAL; + break; + } + + error = pf_user_strcpy(ps.ifname, psp->ifname, IFNAMSIZ); + if (error != 0) + break; + ifp = ifunit(ps.ifname); + if (ifp != NULL) { + psp->baudrate32 = + (u_int32_t)uqmin(ifp->if_baudrate, UINT_MAX); + if (cmd == DIOCGIFSPEEDV1) + psp->baudrate = ifp->if_baudrate; + } else { error = EINVAL; + } break; } @@ -3433,7 +3481,9 @@ DIOCGETSTATESV2_full: break; } pa = malloc(sizeof(*pa), M_PFRULE, M_WAITOK); - pf_pooladdr_to_kpooladdr(&pp->addr, pa); + error = pf_pooladdr_to_kpooladdr(&pp->addr, pa); + if (error != 0) + break; if (pa->ifname[0]) kif = pf_kkif_create(M_WAITOK); PF_RULES_WLOCK(); @@ -3469,8 +3519,10 @@ DIOCGETSTATESV2_full: struct pf_kpool *pool; struct pf_kpooladdr *pa; - PF_RULES_RLOCK(); + pp->anchor[sizeof(pp->anchor) - 1] = 0; pp->nr = 0; + + PF_RULES_RLOCK(); pool = pf_get_kpool(pp->anchor, pp->ticket, pp->r_action, pp->r_num, 0, 1, 0); if (pool == NULL) { @@ -3490,6 +3542,8 @@ DIOCGETSTATESV2_full: struct pf_kpooladdr *pa; u_int32_t nr = 0; + pp->anchor[sizeof(pp->anchor) - 1] = 0; + PF_RULES_RLOCK(); pool = pf_get_kpool(pp->anchor, pp->ticket, pp->r_action, pp->r_num, 0, 1, 1); @@ -3521,6 +3575,8 @@ DIOCGETSTATESV2_full: struct pf_kruleset *ruleset; struct pfi_kkif *kif = NULL; + pca->anchor[sizeof(pca->anchor) - 1] = 0; + if (pca->action < PF_CHANGE_ADD_HEAD || pca->action > PF_CHANGE_REMOVE) { error = EINVAL; @@ -3652,8 +3708,9 @@ DIOCCHANGEADDR_error: struct pf_kruleset *ruleset; struct pf_kanchor *anchor; - PF_RULES_RLOCK(); pr->path[sizeof(pr->path) - 1] = 0; + + PF_RULES_RLOCK(); if ((ruleset = pf_find_kruleset(pr->path)) == NULL) { PF_RULES_RUNLOCK(); error = ENOENT; @@ -3680,8 +3737,9 @@ DIOCCHANGEADDR_error: struct pf_kanchor *anchor; u_int32_t nr = 0; - PF_RULES_RLOCK(); pr->path[sizeof(pr->path) - 1] = 0; + + PF_RULES_RLOCK(); if ((ruleset = pf_find_kruleset(pr->path)) == NULL) { PF_RULES_RUNLOCK(); error = ENOENT; @@ -4262,6 +4320,7 @@ DIOCCHANGEADDR_error: } PF_RULES_WLOCK(); for (i = 0, ioe = ioes; i < io->size; i++, ioe++) { + ioe->anchor[sizeof(ioe->anchor) - 1] = '\0'; switch (ioe->rs_num) { #ifdef ALTQ case PF_RULESET_ALTQ: @@ -4335,6 +4394,7 @@ DIOCCHANGEADDR_error: } PF_RULES_WLOCK(); for (i = 0, ioe = ioes; i < io->size; i++, ioe++) { + ioe->anchor[sizeof(ioe->anchor) - 1] = '\0'; switch (ioe->rs_num) { #ifdef ALTQ case PF_RULESET_ALTQ: @@ -4411,6 +4471,7 @@ DIOCCHANGEADDR_error: PF_RULES_WLOCK(); /* First makes sure everything will succeed. */ for (i = 0, ioe = ioes; i < io->size; i++, ioe++) { + ioe->anchor[sizeof(ioe->anchor) - 1] = 0; switch (ioe->rs_num) { #ifdef ALTQ case PF_RULESET_ALTQ: @@ -4477,7 +4538,7 @@ DIOCCHANGEADDR_error: struct pfr_table table; bzero(&table, sizeof(table)); - strlcpy(table.pfrt_anchor, ioe->anchor, + (void)strlcpy(table.pfrt_anchor, ioe->anchor, sizeof(table.pfrt_anchor)); if ((error = pfr_ina_commit(&table, ioe->ticket, NULL, NULL, 0))) { From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:30:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B47B2672493; Wed, 11 Aug 2021 01:30: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 4Gkshy4pF8z3PJk; Wed, 11 Aug 2021 01:30: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 8CE50260D8; Wed, 11 Aug 2021 01:30: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 17B1UwGX050879; Wed, 11 Aug 2021 01:30:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1UwKA050878; Wed, 11 Aug 2021 01:30:58 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:30:58 GMT Message-Id: <202108110130.17B1UwKA050878@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 805c3af898a8 - main - build.7: Describe the default value for LOCAL_MODULES 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/main X-Git-Reftype: branch X-Git-Commit: 805c3af898a8fed6a92caa069011c0ce7fa542ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:30:58 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=805c3af898a8fed6a92caa069011c0ce7fa542ef commit 805c3af898a8fed6a92caa069011c0ce7fa542ef Author: Mark Johnston AuthorDate: 2021-08-10 17:34:57 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:18:34 +0000 build.7: Describe the default value for LOCAL_MODULES Suggested by: jhb MFC after: 1 week --- share/man/man7/build.7 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/man/man7/build.7 b/share/man/man7/build.7 index c589fb7e0b9a..7a9ef72fda65 100644 --- a/share/man/man7/build.7 +++ b/share/man/man7/build.7 @@ -608,6 +608,8 @@ as part of the and .Cm installkernel process. +Defaults to the list of sub-directories of +.Va LOCAL_MODULES_DIR . .It Va LOCAL_MODULES_DIR The directory in which to search for the kernel modules specified by .Va LOCAL_MODULES . From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:30:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0F2A6726D7; Wed, 11 Aug 2021 01:30: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 4Gkshz6Hhtz3PV0; Wed, 11 Aug 2021 01:30: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 BDAC5264ED; Wed, 11 Aug 2021 01:30: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 17B1UxZO050903; Wed, 11 Aug 2021 01:30:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1Uxvl050902; Wed, 11 Aug 2021 01:30:59 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:30:59 GMT Message-Id: <202108110130.17B1Uxvl050902@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4fd450a87df0 - main - amd64 pmap: Pre-set PG_M on 2MB KASAN shadow map entries 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/main X-Git-Reftype: branch X-Git-Commit: 4fd450a87df015fe85cadfac0e22c73e3c878d24 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:00 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4fd450a87df015fe85cadfac0e22c73e3c878d24 commit 4fd450a87df015fe85cadfac0e22c73e3c878d24 Author: Mark Johnston AuthorDate: 2021-08-10 20:23:42 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:22:07 +0000 amd64 pmap: Pre-set PG_M on 2MB KASAN shadow map entries Also remove a redundant assertion in pmap_kasan_enter(). Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31295 --- sys/amd64/amd64/pmap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index bc203990faa1..bff4f5376fda 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -11321,7 +11321,7 @@ pmap_kasan_enter(vm_offset_t va) m = pmap_kasan_enter_alloc_2m(); if (m != NULL) { *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | - X86_PG_PS | X86_PG_V | pg_nx); + X86_PG_PS | X86_PG_V | X86_PG_A | X86_PG_M | pg_nx); } else { m = pmap_kasan_enter_alloc_4k(); *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | @@ -11333,8 +11333,6 @@ pmap_kasan_enter(vm_offset_t va) pte = pmap_pde_to_pte(pde, va); if ((*pte & X86_PG_V) != 0) return; - KASSERT((*pte & X86_PG_V) == 0, - ("%s: shadow address %#lx is already mapped", __func__, va)); m = pmap_kasan_enter_alloc_4k(); *pte = (pt_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_V | X86_PG_M | X86_PG_A | pg_nx); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BCC32672615; Wed, 11 Aug 2021 01:31:01 +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 4Gksj11DwYz3PBY; Wed, 11 Aug 2021 01:31: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 E18CA26502; Wed, 11 Aug 2021 01:31: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 17B1V0Kf050933; Wed, 11 Aug 2021 01:31:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V0n8050932; Wed, 11 Aug 2021 01:31:00 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:00 GMT Message-Id: <202108110131.17B1V0n8050932@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 30d00832d773 - main - conf: Add a KMSAN kernel option 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/main X-Git-Reftype: branch X-Git-Commit: 30d00832d7733e60f5e030d335c129bfa77dd77a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:01 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=30d00832d7733e60f5e030d335c129bfa77dd77a commit 30d00832d7733e60f5e030d335c129bfa77dd77a Author: Mark Johnston AuthorDate: 2021-08-10 19:51:03 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:22:12 +0000 conf: Add a KMSAN kernel option Sponsored by: The FreeBSD Foundation --- sys/conf/kern.pre.mk | 6 ++++++ sys/conf/options | 1 + 2 files changed, 7 insertions(+) diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index 221c0aa22d9d..d9621273c57b 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -109,6 +109,12 @@ SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kcsan \ -fsanitize=thread .endif +KMSAN_ENABLED!= grep KMSAN opt_global.h || true ; echo +.if !empty(KMSAN_ENABLED) +SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kmsan \ + -fsanitize=kernel-memory +.endif + KUBSAN_ENABLED!= grep KUBSAN opt_global.h || true ; echo .if !empty(KUBSAN_ENABLED) SAN_CFLAGS+= -fsanitize=undefined diff --git a/sys/conf/options b/sys/conf/options index 774850158221..c7fbbec08a9f 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -232,6 +232,7 @@ COVERAGE opt_global.h KASAN opt_global.h KCOV KCSAN opt_global.h +KMSAN opt_global.h KUBSAN opt_global.h # POSIX kernel options From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8C8AA6725AE; Wed, 11 Aug 2021 01:31: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 4Gksj32SGlz3PBb; Wed, 11 Aug 2021 01:31: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 1D8FF26506; Wed, 11 Aug 2021 01:31: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 17B1V3fm050988; Wed, 11 Aug 2021 01:31:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V3Ul050987; Wed, 11 Aug 2021 01:31:03 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:03 GMT Message-Id: <202108110131.17B1V3Ul050987@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a422084abbda - main - Add the KMSAN runtime 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/main X-Git-Reftype: branch X-Git-Commit: a422084abbda10edc0b591021536a7c9c6d0c8b4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:03 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a422084abbda10edc0b591021536a7c9c6d0c8b4 commit a422084abbda10edc0b591021536a7c9c6d0c8b4 Author: Mark Johnston AuthorDate: 2021-08-10 19:52:36 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:53 +0000 Add the KMSAN runtime KMSAN enables the use of LLVM's MemorySanitizer in the kernel. This enables precise detection of uses of uninitialized memory. As with KASAN, this feature has substantial runtime overhead and is intended to be used as part of some automated testing regime. The runtime maintains a pair of shadow maps. One is used to track the state of memory in the kernel map at bit-granularity: a bit in the kernel map is initialized when the corresponding shadow bit is clear, and is uninitialized otherwise. The second shadow map stores information about the origin of uninitialized regions of the kernel map, simplifying debugging. KMSAN relies on being able to intercept certain functions which cannot be instrumented by the compiler. KMSAN thus implements interceptors which manually update shadow state and in some cases explicitly check for uninitialized bytes. For instance, all calls to copyout() are subject to such checks. The runtime exports several functions which can be used to verify the shadow map for a given buffer. Helpers provide the same functionality for a few structures commonly used for I/O, such as CAM CCBs, BIOs and mbufs. These are handy when debugging a KMSAN report whose proximate and root causes are far away from each other. Obtained from: NetBSD Sponsored by: The FreeBSD Foundation --- sys/amd64/include/msan.h | 84 +++ sys/conf/files | 2 + sys/kern/kern_thread.c | 14 +- sys/kern/subr_msan.c | 1619 ++++++++++++++++++++++++++++++++++++++++++++++ sys/sys/msan.h | 87 +++ sys/sys/proc.h | 2 + 6 files changed, 1801 insertions(+), 7 deletions(-) diff --git a/sys/amd64/include/msan.h b/sys/amd64/include/msan.h new file mode 100644 index 000000000000..431fd25ae915 --- /dev/null +++ b/sys/amd64/include/msan.h @@ -0,0 +1,84 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software was developed by Mark Johnston 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. + */ + +#ifndef _MACHINE_MSAN_H_ +#define _MACHINE_MSAN_H_ + +#ifdef KMSAN + +#include +#include +#include +#include + +typedef uint32_t msan_orig_t; + +/* + * Our 32-bit origin cells encode a 2-bit type and 30-bit pointer. The pointer + * is compressed by making it a positive offset relative to KERNBASE. + */ +#define KMSAN_ORIG_TYPE_SHIFT 30u +#define KMSAN_ORIG_PTR_MASK ((1u << KMSAN_ORIG_TYPE_SHIFT) - 1) + +static inline msan_orig_t +kmsan_md_orig_encode(int type, uintptr_t ptr) +{ + return ((type << KMSAN_ORIG_TYPE_SHIFT) | + ((ptr & KMSAN_ORIG_PTR_MASK))); +} + +static inline void +kmsan_md_orig_decode(msan_orig_t orig, int *type, uintptr_t *ptr) +{ + *type = orig >> KMSAN_ORIG_TYPE_SHIFT; + *ptr = (orig & KMSAN_ORIG_PTR_MASK) | KERNBASE; +} + +static inline vm_offset_t +kmsan_md_addr_to_shad(vm_offset_t addr) +{ + return (addr - VM_MIN_KERNEL_ADDRESS + KMSAN_SHAD_MIN_ADDRESS); +} + +static inline vm_offset_t +kmsan_md_addr_to_orig(vm_offset_t addr) +{ + return (addr - VM_MIN_KERNEL_ADDRESS + KMSAN_ORIG_MIN_ADDRESS); +} + +static inline bool +kmsan_md_unsupported(vm_offset_t addr) +{ + return (addr < VM_MIN_KERNEL_ADDRESS || addr >= KERNBASE); +} + +#endif /* KMSAN */ + +#endif /* !_MACHINE_MSAN_H_ */ diff --git a/sys/conf/files b/sys/conf/files index 44eda0e8bae6..a5690ec1df75 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3925,6 +3925,8 @@ kern/subr_lock.c standard kern/subr_log.c standard kern/subr_mchain.c optional libmchain kern/subr_module.c standard +kern/subr_msan.c optional kmsan \ + compile-with "${NORMAL_C:N-fsanitize*}" kern/subr_msgbuf.c standard kern/subr_param.c standard kern/subr_pcpu.c standard diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 4cfd502664bd..28a517e9b35e 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -84,11 +84,11 @@ __FBSDID("$FreeBSD$"); * structures. */ #ifdef __amd64__ -_Static_assert(offsetof(struct thread, td_flags) == 0xfc, +_Static_assert(offsetof(struct thread, td_flags) == 0x108, "struct thread KBI td_flags"); -_Static_assert(offsetof(struct thread, td_pflags) == 0x104, +_Static_assert(offsetof(struct thread, td_pflags) == 0x110, "struct thread KBI td_pflags"); -_Static_assert(offsetof(struct thread, td_frame) == 0x4a0, +_Static_assert(offsetof(struct thread, td_frame) == 0x4a8, "struct thread KBI td_frame"); _Static_assert(offsetof(struct thread, td_emuldata) == 0x6b0, "struct thread KBI td_emuldata"); @@ -104,13 +104,13 @@ _Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, "struct proc KBI p_emuldata"); #endif #ifdef __i386__ -_Static_assert(offsetof(struct thread, td_flags) == 0x98, +_Static_assert(offsetof(struct thread, td_flags) == 0x9c, "struct thread KBI td_flags"); -_Static_assert(offsetof(struct thread, td_pflags) == 0xa0, +_Static_assert(offsetof(struct thread, td_pflags) == 0xa4, "struct thread KBI td_pflags"); -_Static_assert(offsetof(struct thread, td_frame) == 0x304, +_Static_assert(offsetof(struct thread, td_frame) == 0x308, "struct thread KBI td_frame"); -_Static_assert(offsetof(struct thread, td_emuldata) == 0x348, +_Static_assert(offsetof(struct thread, td_emuldata) == 0x34c, "struct thread KBI td_emuldata"); _Static_assert(offsetof(struct proc, p_flag) == 0x6c, "struct proc KBI p_flag"); diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c new file mode 100644 index 000000000000..2b6a0d585128 --- /dev/null +++ b/sys/kern/subr_msan.c @@ -0,0 +1,1619 @@ +/* $NetBSD: subr_msan.c,v 1.14 2020/09/09 16:29:59 maxv Exp $ */ + +/* + * Copyright (c) 2019-2020 Maxime Villard, m00nbsd.net + * All rights reserved. + * Copyright (c) 2021 The FreeBSD Foundation + * + * Portions of this software were developed by Mark Johnston under sponsorship + * from the FreeBSD Foundation. + * + * This code is part of the KMSAN subsystem of the NetBSD kernel. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define SAN_RUNTIME + +#include +__FBSDID("$FreeBSD$"); +#if 0 +__KERNEL_RCSID(0, "$NetBSD: subr_msan.c,v 1.14 2020/09/09 16:29:59 maxv Exp $"); +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +void kmsan_init_arg(size_t); +void kmsan_init_ret(size_t); + +/* -------------------------------------------------------------------------- */ + +/* + * Part of the compiler ABI. + */ + +typedef struct { + uint8_t *shad; + msan_orig_t *orig; +} msan_meta_t; + +#define MSAN_PARAM_SIZE 800 +#define MSAN_RETVAL_SIZE 800 +typedef struct { + uint8_t param_shadow[MSAN_PARAM_SIZE]; + uint8_t retval_shadow[MSAN_RETVAL_SIZE]; + uint8_t va_arg_shadow[MSAN_PARAM_SIZE]; + uint8_t va_arg_origin[MSAN_PARAM_SIZE]; + uint64_t va_arg_overflow_size; + msan_orig_t param_origin[MSAN_PARAM_SIZE / sizeof(msan_orig_t)]; + msan_orig_t retval_origin; +} msan_tls_t; + +/* -------------------------------------------------------------------------- */ + +#define MSAN_NCONTEXT 4 +#define MSAN_ORIG_MASK (~0x3) + +typedef struct kmsan_td { + size_t ctx; + msan_tls_t tls[MSAN_NCONTEXT]; +} msan_td_t; + +static msan_tls_t dummy_tls; + +/* + * Use separate dummy regions for loads and stores: stores may mark the region + * as uninitialized, and that can trigger false positives. + */ +static uint8_t msan_dummy_shad[PAGE_SIZE] __aligned(PAGE_SIZE); +static uint8_t msan_dummy_write_shad[PAGE_SIZE] __aligned(PAGE_SIZE); +static uint8_t msan_dummy_orig[PAGE_SIZE] __aligned(PAGE_SIZE); +static msan_td_t msan_thread0; +static bool kmsan_enabled __read_mostly; + +static bool kmsan_reporting = false; + +/* + * Avoid clobbering any thread-local state before we panic. + */ +#define kmsan_panic(f, ...) do { \ + kmsan_enabled = false; \ + panic(f, __VA_ARGS__); \ +} while (0) + +#define REPORT(f, ...) do { \ + if (panic_on_violation) { \ + kmsan_panic(f, __VA_ARGS__); \ + } else { \ + struct stack st; \ + \ + stack_save(&st); \ + printf(f "\n", __VA_ARGS__); \ + stack_print_ddb(&st); \ + } \ +} while (0) + +FEATURE(kmsan, "Kernel memory sanitizer"); + +static SYSCTL_NODE(_debug, OID_AUTO, kmsan, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, + "KMSAN options"); + +static bool panic_on_violation = 1; +SYSCTL_BOOL(_debug_kmsan, OID_AUTO, panic_on_violation, CTLFLAG_RWTUN, + &panic_on_violation, 0, + "Panic if an invalid access is detected"); + +static MALLOC_DEFINE(M_KMSAN, "kmsan", "Kernel memory sanitizer"); + +/* -------------------------------------------------------------------------- */ + +static inline const char * +kmsan_orig_name(int type) +{ + switch (type) { + case KMSAN_TYPE_STACK: + return ("stack"); + case KMSAN_TYPE_KMEM: + return ("kmem"); + case KMSAN_TYPE_MALLOC: + return ("malloc"); + case KMSAN_TYPE_UMA: + return ("UMA"); + default: + return ("unknown"); + } +} + +static void +kmsan_report_hook(const void *addr, size_t size, size_t off, const char *hook) +{ + msan_orig_t *orig; + const char *typename; + char *var, *fn; + uintptr_t ptr; + long foff; + char buf[128]; + int type; + + if (__predict_false(panicstr != NULL || kdb_active || kmsan_reporting)) + return; + + kmsan_reporting = true; + __compiler_membar(); + + orig = (msan_orig_t *)kmsan_md_addr_to_orig((vm_offset_t)addr); + orig = (msan_orig_t *)((uintptr_t)orig & MSAN_ORIG_MASK); + + if (*orig == 0) { + REPORT("MSan: Uninitialized memory in %s, offset %zu", + hook, off); + goto out; + } + + kmsan_md_orig_decode(*orig, &type, &ptr); + typename = kmsan_orig_name(type); + + if (linker_ddb_search_symbol_name((caddr_t)ptr, buf, + sizeof(buf), &foff) == 0) { + REPORT("MSan: Uninitialized %s memory in %s, " + "offset %zu/%zu, addr %p, from %s+%#lx", + typename, hook, off, size, addr, buf, foff); + } else if (__builtin_memcmp((void *)ptr, "----", 4) == 0) { + /* + * The format of the string is: "----var@function". Parse it to + * display a nice warning. + */ + var = (char *)ptr + 4; + strlcpy(buf, var, sizeof(buf)); + var = buf; + fn = strchr(buf, '@'); + *fn++ = '\0'; + REPORT("MSan: Uninitialized %s memory in %s, offset %zu, " + "variable '%s' from %s", typename, hook, off, var, fn); + } else { + REPORT("MSan: Uninitialized %s memory in %s, " + "offset %zu/%zu, addr %p, PC %p", + typename, hook, off, size, addr, (void *)ptr); + } + +out: + __compiler_membar(); + kmsan_reporting = false; +} + +static void +kmsan_report_inline(msan_orig_t orig, unsigned long pc) +{ + const char *typename; + char *var, *fn; + uintptr_t ptr; + char buf[128]; + long foff; + int type; + + if (__predict_false(panicstr != NULL || kdb_active || kmsan_reporting)) + return; + + kmsan_reporting = true; + __compiler_membar(); + + if (orig == 0) { + REPORT("MSan: uninitialized variable in %p", (void *)pc); + goto out; + } + + kmsan_md_orig_decode(orig, &type, &ptr); + typename = kmsan_orig_name(type); + + if (linker_ddb_search_symbol_name((caddr_t)ptr, buf, + sizeof(buf), &foff) == 0) { + REPORT("MSan: Uninitialized %s memory from %s+%#lx", + typename, buf, foff); + } else if (__builtin_memcmp((void *)ptr, "----", 4) == 0) { + /* + * The format of the string is: "----var@function". Parse it to + * display a nice warning. + */ + var = (char *)ptr + 4; + strlcpy(buf, var, sizeof(buf)); + var = buf; + fn = strchr(buf, '@'); + *fn++ = '\0'; + REPORT("MSan: Uninitialized variable '%s' from %s", var, fn); + } else { + REPORT("MSan: Uninitialized %s memory, origin %x", + typename, orig); + } + +out: + __compiler_membar(); + kmsan_reporting = false; +} + +/* -------------------------------------------------------------------------- */ + +static inline msan_meta_t +kmsan_meta_get(const void *addr, size_t size, const bool write) +{ + msan_meta_t ret; + + if (__predict_false(!kmsan_enabled)) { + ret.shad = write ? msan_dummy_write_shad : msan_dummy_shad; + ret.orig = (msan_orig_t *)msan_dummy_orig; + } else if (__predict_false(kmsan_md_unsupported((vm_offset_t)addr))) { + ret.shad = write ? msan_dummy_write_shad : msan_dummy_shad; + ret.orig = (msan_orig_t *)msan_dummy_orig; + } else { + ret.shad = (void *)kmsan_md_addr_to_shad((vm_offset_t)addr); + ret.orig = + (msan_orig_t *)kmsan_md_addr_to_orig((vm_offset_t)addr); + ret.orig = (msan_orig_t *)((uintptr_t)ret.orig & + MSAN_ORIG_MASK); + } + + return (ret); +} + +static inline void +kmsan_origin_fill(const void *addr, msan_orig_t o, size_t size) +{ + msan_orig_t *orig; + size_t i; + + if (__predict_false(!kmsan_enabled)) + return; + if (__predict_false(kmsan_md_unsupported((vm_offset_t)addr))) + return; + + orig = (msan_orig_t *)kmsan_md_addr_to_orig((vm_offset_t)addr); + size += ((uintptr_t)orig & (sizeof(*orig) - 1)); + orig = (msan_orig_t *)((uintptr_t)orig & MSAN_ORIG_MASK); + + for (i = 0; i < size; i += 4) { + orig[i / 4] = o; + } +} + +static inline void +kmsan_shadow_fill(uintptr_t addr, uint8_t c, size_t size) +{ + uint8_t *shad; + + if (__predict_false(!kmsan_enabled)) + return; + if (__predict_false(kmsan_md_unsupported(addr))) + return; + + shad = (uint8_t *)kmsan_md_addr_to_shad(addr); + __builtin_memset(shad, c, size); +} + +static inline void +kmsan_meta_copy(void *dst, const void *src, size_t size) +{ + uint8_t *orig_src, *orig_dst; + uint8_t *shad_src, *shad_dst; + msan_orig_t *_src, *_dst; + size_t i; + + if (__predict_false(!kmsan_enabled)) + return; + if (__predict_false(kmsan_md_unsupported((vm_offset_t)dst))) + return; + if (__predict_false(kmsan_md_unsupported((vm_offset_t)src))) { + kmsan_shadow_fill((uintptr_t)dst, KMSAN_STATE_INITED, size); + return; + } + + shad_src = (uint8_t *)kmsan_md_addr_to_shad((vm_offset_t)src); + shad_dst = (uint8_t *)kmsan_md_addr_to_shad((vm_offset_t)dst); + __builtin_memmove(shad_dst, shad_src, size); + + orig_src = (uint8_t *)kmsan_md_addr_to_orig((vm_offset_t)src); + orig_dst = (uint8_t *)kmsan_md_addr_to_orig((vm_offset_t)dst); + for (i = 0; i < size; i++) { + _src = (msan_orig_t *)((uintptr_t)orig_src & MSAN_ORIG_MASK); + _dst = (msan_orig_t *)((uintptr_t)orig_dst & MSAN_ORIG_MASK); + *_dst = *_src; + orig_src++; + orig_dst++; + } +} + +static inline void +kmsan_shadow_check(uintptr_t addr, size_t size, const char *hook) +{ + uint8_t *shad; + size_t i; + + if (__predict_false(!kmsan_enabled)) + return; + if (__predict_false(kmsan_md_unsupported(addr))) + return; + + shad = (uint8_t *)kmsan_md_addr_to_shad(addr); + for (i = 0; i < size; i++) { + if (__predict_true(shad[i] == 0)) + continue; + kmsan_report_hook((const char *)addr + i, size, i, hook); + break; + } +} + +void +kmsan_init_arg(size_t n) +{ + msan_td_t *mtd; + uint8_t *arg; + + if (__predict_false(!kmsan_enabled)) + return; + if (__predict_false(curthread == NULL)) + return; + mtd = curthread->td_kmsan; + arg = mtd->tls[mtd->ctx].param_shadow; + __builtin_memset(arg, 0, n); +} + +void +kmsan_init_ret(size_t n) +{ + msan_td_t *mtd; + uint8_t *arg; + + if (__predict_false(!kmsan_enabled)) + return; + if (__predict_false(curthread == NULL)) + return; + mtd = curthread->td_kmsan; + arg = mtd->tls[mtd->ctx].retval_shadow; + __builtin_memset(arg, 0, n); +} + +static void +kmsan_check_arg(size_t size, const char *hook) +{ + msan_td_t *mtd; + uint8_t *arg; + size_t i; + + if (__predict_false(!kmsan_enabled)) + return; + if (__predict_false(curthread == NULL)) + return; + mtd = curthread->td_kmsan; + arg = mtd->tls[mtd->ctx].param_shadow; + + for (i = 0; i < size; i++) { + if (__predict_true(arg[i] == 0)) + continue; + kmsan_report_hook((const char *)arg + i, size, i, hook); + break; + } +} + +void +kmsan_thread_alloc(struct thread *td) +{ + msan_td_t *mtd; + + if (!kmsan_enabled) + return; + + mtd = td->td_kmsan; + if (mtd == NULL) { + /* We might be recycling a thread. */ + kmsan_init_arg(sizeof(size_t) + sizeof(struct malloc_type *) + + sizeof(int)); + mtd = malloc(sizeof(*mtd), M_KMSAN, M_WAITOK); + } + kmsan_memset(mtd, 0, sizeof(*mtd)); + mtd->ctx = 0; + + if (td->td_kstack != 0) + kmsan_mark((void *)td->td_kstack, ptoa(td->td_kstack_pages), + KMSAN_STATE_UNINIT); + + td->td_kmsan = mtd; +} + +void +kmsan_thread_free(struct thread *td) +{ + msan_td_t *mtd; + + if (!kmsan_enabled) + return; + if (__predict_false(td == curthread)) + kmsan_panic("%s: freeing KMSAN TLS for curthread", __func__); + + mtd = td->td_kmsan; + kmsan_init_arg(sizeof(void *) + sizeof(struct malloc_type *)); + free(mtd, M_KMSAN); + td->td_kmsan = NULL; +} + +void kmsan_intr_enter(void); +void kmsan_intr_leave(void); + +void +kmsan_intr_enter(void) +{ + msan_td_t *mtd; + + if (__predict_false(!kmsan_enabled)) + return; + + mtd = curthread->td_kmsan; + mtd->ctx++; + if (__predict_false(mtd->ctx >= MSAN_NCONTEXT)) + kmsan_panic("%s: mtd->ctx = %zu", __func__, mtd->ctx); +} + +void +kmsan_intr_leave(void) +{ + msan_td_t *mtd; + + if (__predict_false(!kmsan_enabled)) + return; + + mtd = curthread->td_kmsan; + if (__predict_false(mtd->ctx == 0)) + kmsan_panic("%s: mtd->ctx = %zu", __func__, mtd->ctx); + mtd->ctx--; +} + +/* -------------------------------------------------------------------------- */ + +void +kmsan_shadow_map(vm_offset_t addr, size_t size) +{ + size_t npages, i; + vm_offset_t va; + + MPASS(addr % PAGE_SIZE == 0); + MPASS(size % PAGE_SIZE == 0); + + if (!kmsan_enabled) + return; + + npages = atop(size); + + va = kmsan_md_addr_to_shad(addr); + for (i = 0; i < npages; i++) { + pmap_kmsan_enter(va + ptoa(i)); + } + + va = kmsan_md_addr_to_orig(addr); + for (i = 0; i < npages; i++) { + pmap_kmsan_enter(va + ptoa(i)); + } +} + +void +kmsan_orig(const void *addr, size_t size, int type, uintptr_t pc) +{ + msan_orig_t orig; + + orig = kmsan_md_orig_encode(type, pc); + kmsan_origin_fill(addr, orig, size); +} + +void +kmsan_mark(const void *addr, size_t size, uint8_t c) +{ + kmsan_shadow_fill((uintptr_t)addr, c, size); +} + +static void +kmsan_mark_bio(const struct bio *bp, uint8_t c) +{ + kmsan_mark(bp->bio_data, bp->bio_length, c); +} + +static void +kmsan_mark_ccb(const union ccb *ccb, uint8_t c) +{ + if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_IN) + return; + if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR) + return; + + switch (ccb->ccb_h.func_code) { + case XPT_SCSI_IO: { + const struct ccb_scsiio *scsiio; + + scsiio = &ccb->ctio; + kmsan_mark(scsiio->data_ptr, scsiio->dxfer_len, c); + break; + } + case XPT_ATA_IO: { + const struct ccb_ataio *ataio; + + ataio = &ccb->ataio; + kmsan_mark(ataio->data_ptr, ataio->dxfer_len, c); + break; + } + case XPT_NVME_IO: { + const struct ccb_nvmeio *nvmeio; + + nvmeio = &ccb->nvmeio; + kmsan_mark(nvmeio->data_ptr, nvmeio->dxfer_len, c); + break; + } + default: + kmsan_panic("%s: unhandled CCB type %d", __func__, + ccb->ccb_h.func_code); + } +} + +static void +kmsan_mark_mbuf(const struct mbuf *m, uint8_t c) +{ + do { + if ((m->m_flags & M_EXTPG) == 0) + kmsan_mark(m->m_data, m->m_len, c); + m = m->m_next; + } while (m != NULL); +} + +void +kmsan_check(const void *p, size_t sz, const char *descr) +{ + kmsan_shadow_check((uintptr_t)p, sz, descr); +} + +void +kmsan_check_bio(const struct bio *bp, const char *descr) +{ + kmsan_shadow_check((uintptr_t)bp->bio_data, bp->bio_length, descr); +} + +void +kmsan_check_ccb(const union ccb *ccb, const char *descr) +{ + if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_OUT) + return; + switch (ccb->ccb_h.func_code) { + case XPT_SCSI_IO: { + const struct ccb_scsiio *scsiio; + + scsiio = &ccb->ctio; + kmsan_check(scsiio->data_ptr, scsiio->dxfer_len, descr); + break; + } + case XPT_ATA_IO: { + const struct ccb_ataio *ataio; + + ataio = &ccb->ataio; + kmsan_check(ataio->data_ptr, ataio->dxfer_len, descr); + break; + } + case XPT_NVME_IO: { + const struct ccb_nvmeio *nvmeio; + + nvmeio = &ccb->nvmeio; + kmsan_check(nvmeio->data_ptr, nvmeio->dxfer_len, descr); + break; + } + default: + kmsan_panic("%s: unhandled CCB type %d", __func__, + ccb->ccb_h.func_code); + } +} + +void +kmsan_check_mbuf(const struct mbuf *m, const char *descr) +{ + do { + kmsan_shadow_check((uintptr_t)mtod(m, void *), m->m_len, descr); + } while ((m = m->m_next) != NULL); +} + +void +kmsan_init(void) +{ + int disabled; + + disabled = 0; + TUNABLE_INT_FETCH("debug.kmsan.disabled", &disabled); + if (disabled) + return; + + /* Initialize the TLS for curthread. */ + msan_thread0.ctx = 0; + thread0.td_kmsan = &msan_thread0; + + /* Now officially enabled. */ + kmsan_enabled = true; +} + +/* -------------------------------------------------------------------------- */ + +msan_meta_t __msan_metadata_ptr_for_load_n(void *, size_t); +msan_meta_t __msan_metadata_ptr_for_store_n(void *, size_t); + +msan_meta_t +__msan_metadata_ptr_for_load_n(void *addr, size_t size) +{ + return (kmsan_meta_get(addr, size, false)); +} + +msan_meta_t +__msan_metadata_ptr_for_store_n(void *addr, size_t size) +{ + return (kmsan_meta_get(addr, size, true)); +} + +#define MSAN_META_FUNC(size) \ + msan_meta_t __msan_metadata_ptr_for_load_##size(void *); \ + msan_meta_t __msan_metadata_ptr_for_load_##size(void *addr) \ + { \ + return (kmsan_meta_get(addr, size, false)); \ + } \ + msan_meta_t __msan_metadata_ptr_for_store_##size(void *); \ + msan_meta_t __msan_metadata_ptr_for_store_##size(void *addr) \ + { \ + return (kmsan_meta_get(addr, size, true)); \ + } + +MSAN_META_FUNC(1) +MSAN_META_FUNC(2) +MSAN_META_FUNC(4) +MSAN_META_FUNC(8) + +void __msan_instrument_asm_store(const void *, size_t); +msan_orig_t __msan_chain_origin(msan_orig_t); +void __msan_poison(const void *, size_t); +void __msan_unpoison(const void *, size_t); +void __msan_poison_alloca(const void *, uint64_t, const char *); +void __msan_unpoison_alloca(const void *, uint64_t); +void __msan_warning(msan_orig_t); +msan_tls_t *__msan_get_context_state(void); + +void +__msan_instrument_asm_store(const void *addr, size_t size) +{ + kmsan_shadow_fill((uintptr_t)addr, KMSAN_STATE_INITED, size); +} + +msan_orig_t +__msan_chain_origin(msan_orig_t origin) +{ + return (origin); +} + +void +__msan_poison(const void *addr, size_t size) +{ + kmsan_shadow_fill((uintptr_t)addr, KMSAN_STATE_UNINIT, size); +} + +void +__msan_unpoison(const void *addr, size_t size) +{ + kmsan_shadow_fill((uintptr_t)addr, KMSAN_STATE_INITED, size); +} + +void +__msan_poison_alloca(const void *addr, uint64_t size, const char *descr) +{ + msan_orig_t orig; + + orig = kmsan_md_orig_encode(KMSAN_TYPE_STACK, (uintptr_t)descr); + kmsan_origin_fill(addr, orig, size); + kmsan_shadow_fill((uintptr_t)addr, KMSAN_STATE_UNINIT, size); +} + +void +__msan_unpoison_alloca(const void *addr, uint64_t size) +{ + kmsan_shadow_fill((uintptr_t)addr, KMSAN_STATE_INITED, size); +} + +void +__msan_warning(msan_orig_t origin) +{ + if (__predict_false(!kmsan_enabled)) + return; + kmsan_report_inline(origin, KMSAN_RET_ADDR); +} + +msan_tls_t * +__msan_get_context_state(void) +{ + msan_td_t *mtd; + + /* + * When APs are started, they execute some C code before curthread is + * set. We have to handle that here. + */ + if (__predict_false(!kmsan_enabled || curthread == NULL)) + return (&dummy_tls); + mtd = curthread->td_kmsan; + return (&mtd->tls[mtd->ctx]); +} + +/* -------------------------------------------------------------------------- */ + +/* + * Function hooks. Mostly ASM functions which need KMSAN wrappers to handle + * initialized areas properly. + */ + +void * +kmsan_memcpy(void *dst, const void *src, size_t len) +{ + /* No kmsan_check_arg, because inlined. */ + kmsan_init_ret(sizeof(void *)); + if (__predict_true(len != 0)) { + kmsan_meta_copy(dst, src, len); *** 938 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3EFD6726DF; Wed, 11 Aug 2021 01:31: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 4Gksj43t94z3PbF; Wed, 11 Aug 2021 01:31: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 49D4826156; Wed, 11 Aug 2021 01:31: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 17B1V4iw051012; Wed, 11 Aug 2021 01:31:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V42f051011; Wed, 11 Aug 2021 01:31:04 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:04 GMT Message-Id: <202108110131.17B1V42f051011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 5dda15adbcf7 - main - kern: Ensure that thread-local KMSAN state is available 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/main X-Git-Reftype: branch X-Git-Commit: 5dda15adbcf7b650fb69b5259090b16c66d1cf1a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:04 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5dda15adbcf7b650fb69b5259090b16c66d1cf1a commit 5dda15adbcf7b650fb69b5259090b16c66d1cf1a Author: Mark Johnston AuthorDate: 2021-08-11 00:58:00 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:53 +0000 kern: Ensure that thread-local KMSAN state is available Sponsored by: The FreeBSD Foundation --- sys/kern/kern_fork.c | 2 ++ sys/kern/kern_thread.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 7a80f7de85d8..b71a00adb62e 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -958,6 +959,7 @@ fork1(struct thread *td, struct fork_req *fr) } proc_linkup(newproc, td2); } else { + kmsan_thread_alloc(td2); if (td2->td_kstack == 0 || td2->td_kstack_pages != pages) { if (td2->td_kstack != 0) vm_thread_dispose(td2); diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 28a517e9b35e..cb35d565974d 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -761,6 +762,7 @@ thread_alloc(int pages) return (NULL); } td->td_tid = tid; + kmsan_thread_alloc(td); cpu_thread_alloc(td); EVENTHANDLER_DIRECT_INVOKE(thread_ctor, td); return (td); @@ -797,6 +799,7 @@ thread_free_batched(struct thread *td) * Freeing handled by the caller. */ td->td_tid = -1; + kmsan_thread_free(td); uma_zfree(thread_zone, td); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 46FD767270A; Wed, 11 Aug 2021 01:31: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 4Gksj21DcFz3P7v; Wed, 11 Aug 2021 01:31: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 04BC126226; Wed, 11 Aug 2021 01:31: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 17B1V1p8050959; Wed, 11 Aug 2021 01:31:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V1F4050958; Wed, 11 Aug 2021 01:31:01 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:01 GMT Message-Id: <202108110131.17B1V1F4050958@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: f95f780ea4e1 - main - amd64: Define KVA regions for KMSAN shadow maps 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/main X-Git-Reftype: branch X-Git-Commit: f95f780ea4e163ce9a0295a699f41f0a7e1591d4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:02 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f95f780ea4e163ce9a0295a699f41f0a7e1591d4 commit f95f780ea4e163ce9a0295a699f41f0a7e1591d4 Author: Mark Johnston AuthorDate: 2021-08-10 20:25:39 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:52 +0000 amd64: Define KVA regions for KMSAN shadow maps KMSAN requires two shadow maps, each one-to-one with the kernel map. Allocate regions of the kernels PML4 page for them. Add functions to create mappings in the shadow map regions, these will be used by the KMSAN runtime. Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31295 --- sys/amd64/amd64/pmap.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ sys/amd64/include/pmap.h | 13 ++++++++ sys/amd64/include/vmparam.h | 13 ++++++-- 3 files changed, 102 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index bff4f5376fda..d7a5e16d3dd6 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -11339,6 +11339,76 @@ pmap_kasan_enter(vm_offset_t va) } #endif +#ifdef KMSAN +static vm_page_t +pmap_kmsan_enter_alloc_4k(void) +{ + vm_page_t m; + + m = vm_page_alloc(NULL, 0, VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | + VM_ALLOC_WIRED | VM_ALLOC_ZERO); + if (m == NULL) + panic("%s: no memory to grow shadow map", __func__); + if ((m->flags & PG_ZERO) == 0) + pmap_zero_page(m); + return (m); +} + +static vm_page_t +pmap_kmsan_enter_alloc_2m(void) +{ + vm_page_t m; + + m = vm_page_alloc_contig(NULL, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | + VM_ALLOC_WIRED, NPTEPG, 0, ~0ul, NBPDR, 0, VM_MEMATTR_DEFAULT); + if (m != NULL) + memset((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)), 0, NBPDR); + return (m); +} + +/* + * Grow the shadow or origin maps by at least one 4KB page at the specified + * address. Use 2MB pages when possible. + */ +void +pmap_kmsan_enter(vm_offset_t va) +{ + pdp_entry_t *pdpe; + pd_entry_t *pde; + pt_entry_t *pte; + vm_page_t m; + + mtx_assert(&kernel_map->system_mtx, MA_OWNED); + + pdpe = pmap_pdpe(kernel_pmap, va); + if ((*pdpe & X86_PG_V) == 0) { + m = pmap_kmsan_enter_alloc_4k(); + *pdpe = (pdp_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | + X86_PG_V | pg_nx); + } + pde = pmap_pdpe_to_pde(pdpe, va); + if ((*pde & X86_PG_V) == 0) { + m = pmap_kmsan_enter_alloc_2m(); + if (m != NULL) { + *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | + X86_PG_PS | X86_PG_V | X86_PG_A | X86_PG_M | pg_nx); + } else { + m = pmap_kmsan_enter_alloc_4k(); + *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | + X86_PG_V | pg_nx); + } + } + if ((*pde & X86_PG_PS) != 0) + return; + pte = pmap_pde_to_pte(pde, va); + if ((*pte & X86_PG_V) != 0) + return; + m = pmap_kmsan_enter_alloc_4k(); + *pte = (pt_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_V | + X86_PG_M | X86_PG_A | pg_nx); +} +#endif + /* * Track a range of the kernel's virtual address space that is contiguous * in various mapping attributes. @@ -11520,6 +11590,14 @@ sysctl_kmaps(SYSCTL_HANDLER_ARGS) case KASANPML4I: sbuf_printf(sb, "\nKASAN shadow map:\n"); break; +#endif +#ifdef KMSAN + case KMSANSHADPML4I: + sbuf_printf(sb, "\nKMSAN shadow map:\n"); + break; + case KMSANORIGPML4I: + sbuf_printf(sb, "\nKMSAN origin map:\n"); + break; #endif case KPML4BASE: sbuf_printf(sb, "\nKernel map:\n"); diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index 375a86f95e9f..b65668b60023 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -201,6 +201,13 @@ */ #define NKASANPML4E ((NKPML4E + 7) / 8) +/* + * Number of PML4 slots for the KMSAN shadow and origin maps. These are + * one-to-one with the kernel map. + */ +#define NKMSANSHADPML4E NKPML4E +#define NKMSANORIGPML4E NKPML4E + /* * We use the same numbering of the page table pages for 5-level and * 4-level paging structures. @@ -251,6 +258,9 @@ #define KASANPML4I (DMPML4I - NKASANPML4E) /* Below the direct map */ +#define KMSANSHADPML4I (KPML4BASE - NKMSANSHADPML4E) +#define KMSANORIGPML4I (DMPML4I - NKMSANORIGPML4E) + /* Large map: index of the first and max last pml4 entry */ #define LMSPML4I (PML4PML4I + 1) #define LMEPML4I (KASANPML4I - 1) @@ -520,6 +530,9 @@ vm_page_t pmap_page_alloc_below_4g(bool zeroed); #ifdef KASAN void pmap_kasan_enter(vm_offset_t); #endif +#ifdef KMSAN +void pmap_kmsan_enter(vm_offset_t); +#endif #endif /* _KERNEL */ diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 88fd29b80be3..61d0dea54210 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -170,9 +170,10 @@ * 0xffff804020100fff - 0xffff807fffffffff unused * 0xffff808000000000 - 0xffff847fffffffff large map (can be tuned up) * 0xffff848000000000 - 0xfffff77fffffffff unused (large map extends there) - * 0xfffff78000000000 - 0xfffff7ffffffffff 512GB KASAN shadow map + * 0xfffff60000000000 - 0xfffff7ffffffffff 2TB KMSAN origin map, optional + * 0xfffff78000000000 - 0xfffff7bfffffffff 512GB KASAN shadow map, optional * 0xfffff80000000000 - 0xfffffbffffffffff 4TB direct map - * 0xfffffc0000000000 - 0xfffffdffffffffff unused + * 0xfffffc0000000000 - 0xfffffdffffffffff 2TB KMSAN shadow map, optional * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map * * Within the kernel map: @@ -191,6 +192,14 @@ #define KASAN_MIN_ADDRESS KV4ADDR(KASANPML4I, 0, 0, 0) #define KASAN_MAX_ADDRESS KV4ADDR(KASANPML4I + NKASANPML4E, 0, 0, 0) +#define KMSAN_SHAD_MIN_ADDRESS KV4ADDR(KMSANSHADPML4I, 0, 0, 0) +#define KMSAN_SHAD_MAX_ADDRESS KV4ADDR(KMSANSHADPML4I + NKMSANSHADPML4E, \ + 0, 0, 0) + +#define KMSAN_ORIG_MIN_ADDRESS KV4ADDR(KMSANORIGPML4I, 0, 0, 0) +#define KMSAN_ORIG_MAX_ADDRESS KV4ADDR(KMSANORIGPML4I + NKMSANORIGPML4E, \ + 0, 0, 0) + #define LARGEMAP_MIN_ADDRESS KV4ADDR(LMSPML4I, 0, 0, 0) #define LARGEMAP_MAX_ADDRESS KV4ADDR(LMEPML4I + 1, 0, 0, 0) From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EBAC6672721; Wed, 11 Aug 2021 01:31: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 4Gksj54W71z3PdL; Wed, 11 Aug 2021 01:31: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 6D3012633A; Wed, 11 Aug 2021 01:31: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 17B1V5VO051036; Wed, 11 Aug 2021 01:31:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V5oi051035; Wed, 11 Aug 2021 01:31:05 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:05 GMT Message-Id: <202108110131.17B1V5oi051035@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 8978608832c2 - main - amd64: Populate the KMSAN shadow maps and integrate with the VM 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/main X-Git-Reftype: branch X-Git-Commit: 8978608832c28572bbf5adadb9cfb077e8f15255 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:06 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8978608832c28572bbf5adadb9cfb077e8f15255 commit 8978608832c28572bbf5adadb9cfb077e8f15255 Author: Mark Johnston AuthorDate: 2021-08-10 20:52:36 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:53 +0000 amd64: Populate the KMSAN shadow maps and integrate with the VM - During boot, allocate PDP pages for the shadow maps. The region above KERNBASE is currently not shadowed. - Create a dummy shadow for the vm page array. For now, this array is not protected by the shadow map to help reduce kernel memory usage. - Grow shadows when growing the kernel map. - Increase the default kernel stack size when KMSAN is enabled. As with KASAN, sanitizer instrumentation appears to create stack frames large enough that the default value is not sufficient. - Disable UMA's use of the direct map when KMSAN is configured. KMSAN cannot validate the direct map. - Disable unmapped I/O when KMSAN configured. - Lower the limit on paging buffers when KMSAN is configured. Each buffer has a static MAXPHYS-sized allocation of KVA, which in turn eats 2*MAXPHYS of space in the shadow map. Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31295 --- sys/amd64/amd64/pmap.c | 122 +++++++++++++++++++++++++++++++++++++++++++- sys/amd64/include/param.h | 2 +- sys/amd64/include/vmparam.h | 2 +- sys/kern/kern_malloc.c | 8 +-- sys/kern/vfs_bio.c | 15 ++++-- sys/vm/vm_pager.c | 9 ++++ 6 files changed, 148 insertions(+), 10 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index d7a5e16d3dd6..aae35c5d7e07 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -122,6 +122,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -161,8 +162,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include #include #ifdef SMP @@ -430,6 +431,17 @@ u_int64_t KPML5phys; /* phys addr of kernel level 5, #ifdef KASAN static uint64_t KASANPDPphys; #endif +#ifdef KMSAN +static uint64_t KMSANSHADPDPphys; +static uint64_t KMSANORIGPDPphys; + +/* + * To support systems with large amounts of memory, it is necessary to extend + * the maximum size of the direct map. This could eat into the space reserved + * for the shadow map. + */ +_Static_assert(DMPML4I + NDMPML4E <= KMSANSHADPML4I, "direct map overflow"); +#endif static pml4_entry_t *kernel_pml4; static u_int64_t DMPDphys; /* phys addr of direct mapped level 2 */ @@ -1682,13 +1694,21 @@ create_pagetables(vm_paddr_t *firstaddr) DMPDphys = allocpages(firstaddr, ndmpdp - ndm1g); dmaplimit = (vm_paddr_t)ndmpdp << PDPSHIFT; - /* Allocate pages */ + /* Allocate pages. */ KPML4phys = allocpages(firstaddr, 1); KPDPphys = allocpages(firstaddr, NKPML4E); #ifdef KASAN KASANPDPphys = allocpages(firstaddr, NKASANPML4E); KASANPDphys = allocpages(firstaddr, 1); #endif +#ifdef KMSAN + /* + * The KMSAN shadow maps are initially left unpopulated, since there is + * no need to shadow memory above KERNBASE. + */ + KMSANSHADPDPphys = allocpages(firstaddr, NKMSANSHADPML4E); + KMSANORIGPDPphys = allocpages(firstaddr, NKMSANORIGPML4E); +#endif /* * Allocate the initial number of kernel page table pages required to @@ -1826,6 +1846,20 @@ create_pagetables(vm_paddr_t *firstaddr) } #endif +#ifdef KMSAN + /* Connect the KMSAN shadow map slots up to the PML4. */ + for (i = 0; i < NKMSANSHADPML4E; i++) { + p4_p[KMSANSHADPML4I + i] = KMSANSHADPDPphys + ptoa(i); + p4_p[KMSANSHADPML4I + i] |= X86_PG_RW | X86_PG_V | pg_nx; + } + + /* Connect the KMSAN origin map slots up to the PML4. */ + for (i = 0; i < NKMSANORIGPML4E; i++) { + p4_p[KMSANORIGPML4I + i] = KMSANORIGPDPphys + ptoa(i); + p4_p[KMSANORIGPML4I + i] |= X86_PG_RW | X86_PG_V | pg_nx; + } +#endif + /* Connect the Direct Map slots up to the PML4. */ for (i = 0; i < ndmpdpphys; i++) { p4_p[DMPML4I + i] = DMPDPphys + ptoa(i); @@ -2498,6 +2532,14 @@ pmap_init(void) TUNABLE_INT_FETCH("vm.pmap.large_map_pml4_entries", &lm_ents); if (lm_ents > LMEPML4I - LMSPML4I + 1) lm_ents = LMEPML4I - LMSPML4I + 1; +#ifdef KMSAN + if (lm_ents > KMSANORIGPML4I - LMSPML4I) { + printf( + "pmap: shrinking large map for KMSAN (%d slots to %ld slots)\n", + lm_ents, KMSANORIGPML4I - LMSPML4I); + lm_ents = KMSANORIGPML4I - LMSPML4I; + } +#endif if (bootverbose) printf("pmap: large map %u PML4 slots (%lu GB)\n", lm_ents, (u_long)lm_ents * (NBPML4 / 1024 / 1024 / 1024)); @@ -4186,6 +4228,16 @@ pmap_pinit_pml4(vm_page_t pml4pg) pm_pml4[KASANPML4I + i] = (KASANPDPphys + ptoa(i)) | X86_PG_RW | X86_PG_V | pg_nx; } +#endif +#ifdef KMSAN + for (i = 0; i < NKMSANSHADPML4E; i++) { + pm_pml4[KMSANSHADPML4I + i] = (KMSANSHADPDPphys + ptoa(i)) | + X86_PG_RW | X86_PG_V | pg_nx; + } + for (i = 0; i < NKMSANORIGPML4E; i++) { + pm_pml4[KMSANORIGPML4I + i] = (KMSANORIGPDPphys + ptoa(i)) | + X86_PG_RW | X86_PG_V | pg_nx; + } #endif for (i = 0; i < ndmpdpphys; i++) { pm_pml4[DMPML4I + i] = (DMPDPphys + ptoa(i)) | X86_PG_RW | @@ -4772,6 +4824,12 @@ pmap_release(pmap_t pmap) #ifdef KASAN for (i = 0; i < NKASANPML4E; i++) /* KASAN shadow map */ pmap->pm_pmltop[KASANPML4I + i] = 0; +#endif +#ifdef KMSAN + for (i = 0; i < NKMSANSHADPML4E; i++) /* KMSAN shadow map */ + pmap->pm_pmltop[KMSANSHADPML4I + i] = 0; + for (i = 0; i < NKMSANORIGPML4E; i++) /* KMSAN shadow map */ + pmap->pm_pmltop[KMSANORIGPML4I + i] = 0; #endif for (i = 0; i < ndmpdpphys; i++)/* Direct Map */ pmap->pm_pmltop[DMPML4I + i] = 0; @@ -4814,6 +4872,60 @@ SYSCTL_PROC(_vm, OID_AUTO, kvm_free, CTLTYPE_LONG | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, kvm_free, "LU", "Amount of KVM free"); +#ifdef KMSAN +static void +pmap_kmsan_shadow_map_page_array(vm_paddr_t pdppa, vm_size_t size) +{ + pdp_entry_t *pdpe; + pd_entry_t *pde; + pt_entry_t *pte; + vm_paddr_t dummypa, dummypd, dummypt; + int i, npde, npdpg; + + npdpg = howmany(size, NBPDP); + npde = size / NBPDR; + + dummypa = vm_phys_early_alloc(-1, PAGE_SIZE); + pagezero((void *)PHYS_TO_DMAP(dummypa)); + + dummypt = vm_phys_early_alloc(-1, PAGE_SIZE); + pagezero((void *)PHYS_TO_DMAP(dummypt)); + dummypd = vm_phys_early_alloc(-1, PAGE_SIZE * npdpg); + for (i = 0; i < npdpg; i++) + pagezero((void *)PHYS_TO_DMAP(dummypd + ptoa(i))); + + pte = (pt_entry_t *)PHYS_TO_DMAP(dummypt); + for (i = 0; i < NPTEPG; i++) + pte[i] = (pt_entry_t)(dummypa | X86_PG_V | X86_PG_RW | + X86_PG_A | X86_PG_M | pg_nx); + + pde = (pd_entry_t *)PHYS_TO_DMAP(dummypd); + for (i = 0; i < npde; i++) + pde[i] = (pd_entry_t)(dummypt | X86_PG_V | X86_PG_RW | pg_nx); + + pdpe = (pdp_entry_t *)PHYS_TO_DMAP(pdppa); + for (i = 0; i < npdpg; i++) + pdpe[i] = (pdp_entry_t)(dummypd + ptoa(i) | X86_PG_V | + X86_PG_RW | pg_nx); +} + +static void +pmap_kmsan_page_array_startup(vm_offset_t start, vm_offset_t end) +{ + vm_size_t size; + + KASSERT(start % NBPDP == 0, ("unaligned page array start address")); + + /* + * The end of the page array's KVA region is 2MB aligned, see + * kmem_init(). + */ + size = round_2mpage(end) - start; + pmap_kmsan_shadow_map_page_array(KMSANSHADPDPphys, size); + pmap_kmsan_shadow_map_page_array(KMSANORIGPDPphys, size); +} +#endif + /* * Allocate physical memory for the vm_page array and map it into KVA, * attempting to back the vm_pages with domain-local memory. @@ -4854,6 +4966,10 @@ pmap_page_array_startup(long pages) pde_store(pde, newpdir); } vm_page_array = (vm_page_t)start; + +#ifdef KMSAN + pmap_kmsan_page_array_startup(start, end); +#endif } /* @@ -4892,6 +5008,8 @@ pmap_growkernel(vm_offset_t addr) addr = vm_map_max(kernel_map); if (kernel_vm_end < addr) kasan_shadow_map(kernel_vm_end, addr - kernel_vm_end); + if (kernel_vm_end < addr) + kmsan_shadow_map(kernel_vm_end, addr - kernel_vm_end); while (kernel_vm_end < addr) { pdpe = pmap_pdpe(kernel_pmap, kernel_vm_end); if ((*pdpe & X86_PG_V) == 0) { diff --git a/sys/amd64/include/param.h b/sys/amd64/include/param.h index cf1d2bd0a586..a76be23bbe91 100644 --- a/sys/amd64/include/param.h +++ b/sys/amd64/include/param.h @@ -134,7 +134,7 @@ #define IOPERM_BITMAP_SIZE (IOPAGES * PAGE_SIZE + 1) #ifndef KSTACK_PAGES -#ifdef KASAN +#if defined(KASAN) || defined(KMSAN) #define KSTACK_PAGES 6 #else #define KSTACK_PAGES 4 /* pages of kstack (with pcb) */ diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 61d0dea54210..6cb8b3f0071a 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -75,7 +75,7 @@ * of the direct mapped segment. This uses 2MB pages for reduced * TLB pressure. */ -#ifndef KASAN +#if !defined(KASAN) && !defined(KMSAN) #define UMA_MD_SMALL_ALLOC #endif diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 0c2f1689d194..b30139830a1b 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1175,13 +1175,15 @@ kmeminit(void) vm_kmem_size = round_page(vm_kmem_size); -#ifdef KASAN /* - * With KASAN enabled, dynamically allocated kernel memory is shadowed. - * Account for this when setting the UMA limit. + * With KASAN or KMSAN enabled, dynamically allocated kernel memory is + * shadowed. Account for this when setting the UMA limit. */ +#if defined(KASAN) vm_kmem_size = (vm_kmem_size * KASAN_SHADOW_SCALE) / (KASAN_SHADOW_SCALE + 1); +#elif defined(KMSAN) + vm_kmem_size /= 3; #endif #ifdef DEBUG_MEMGUARD diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 859ce3b58285..174892b374d1 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1044,13 +1044,22 @@ kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est) int tuned_nbuf; long maxbuf, maxbuf_sz, buf_sz, biotmap_sz; -#ifdef KASAN /* - * With KASAN enabled, the kernel map is shadowed. Account for this - * when sizing maps based on the amount of physical memory available. + * With KASAN or KMSAN enabled, the kernel map is shadowed. Account for + * this when sizing maps based on the amount of physical memory + * available. */ +#if defined(KASAN) physmem_est = (physmem_est * KASAN_SHADOW_SCALE) / (KASAN_SHADOW_SCALE + 1); +#elif defined(KMSAN) + physmem_est /= 3; + + /* + * KMSAN cannot reliably determine whether buffer data is initialized + * unless it is updated through a KVA mapping. + */ + unmapped_buf_allowed = 0; #endif /* diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 640e3d977e99..69f0a2dc2bbb 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -217,6 +217,15 @@ pbuf_zsecond_create(const char *name, int max) zone = uma_zsecond_create(name, pbuf_ctor, pbuf_dtor, NULL, NULL, pbuf_zone); + +#ifdef KMSAN + /* + * Shrink the size of the pbuf pools if KMSAN is enabled, otherwise the + * shadows of the large KVA allocations eat up too much memory. + */ + max /= 3; +#endif + /* * uma_prealloc() rounds up to items per slab. If we would prealloc * immediately on every pbuf_zsecond_create(), we may accumulate too From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2ADB8672417; Wed, 11 Aug 2021 01:31: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 4Gksj660f7z3PYM; Wed, 11 Aug 2021 01:31: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 925EB26157; Wed, 11 Aug 2021 01:31: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 17B1V6Qu051060; Wed, 11 Aug 2021 01:31:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V6pX051059; Wed, 11 Aug 2021 01:31:06 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:06 GMT Message-Id: <202108110131.17B1V6pX051059@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b0f71f1bc5a4 - main - amd64: Add MD bits for KMSAN 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/main X-Git-Reftype: branch X-Git-Commit: b0f71f1bc5a4b111523b73455fd012f54f7879f9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:07 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b0f71f1bc5a4b111523b73455fd012f54f7879f9 commit b0f71f1bc5a4b111523b73455fd012f54f7879f9 Author: Mark Johnston AuthorDate: 2021-08-10 21:14:47 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:53 +0000 amd64: Add MD bits for KMSAN Interrupt and exception handlers must call kmsan_intr_enter() prior to calling any C code. This is because the KMSAN runtime maintains some TLS in order to track initialization state of function parameters and return values across function calls. Then, to ensure that this state is kept consistent in the face of asynchronous kernel-mode excpeptions, the runtime uses a stack of TLS blocks, and kmsan_intr_enter() and kmsan_intr_leave() push and pop that stack, respectively. Use these functions in amd64 interrupt and exception handlers. Note that handlers for user->kernel transitions need not be annotated. Also ensure that trap frames pushed by the CPU and by handlers are marked as initialized before they are used. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31467 --- sys/amd64/amd64/apic_vector.S | 22 ++++++++++++++++++++++ sys/amd64/amd64/atpic_vector.S | 2 ++ sys/amd64/amd64/exception.S | 12 ++++++++++-- sys/amd64/amd64/machdep.c | 2 ++ sys/amd64/amd64/trap.c | 5 +++++ sys/amd64/ia32/ia32_syscall.c | 3 +++ sys/amd64/include/asmacros.h | 22 ++++++++++++++++++++++ sys/kern/kern_fork.c | 2 ++ sys/kern/subr_trap.c | 3 +++ sys/x86/isa/atpic.c | 3 ++- sys/x86/x86/local_apic.c | 6 ++++-- 11 files changed, 77 insertions(+), 5 deletions(-) diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S index 21696a93fc5f..cea9b79a0ec8 100644 --- a/sys/amd64/amd64/apic_vector.S +++ b/sys/amd64/amd64/apic_vector.S @@ -81,6 +81,7 @@ as_lapic_eoi: */ .macro ISR_VEC index, vec_name INTR_HANDLER \vec_name + KMSAN_ENTER cmpl $0,x2apic_mode je 1f movl $(MSR_APIC_ISR0 + \index),%ecx @@ -97,6 +98,7 @@ as_lapic_eoi: movl %eax, %edi /* pass the IRQ */ call lapic_handle_intr 3: + KMSAN_LEAVE jmp doreti .endm @@ -125,22 +127,28 @@ IDTVEC(spuriousint) * Local APIC periodic timer handler. */ INTR_HANDLER timerint + KMSAN_ENTER movq %rsp, %rdi call lapic_handle_timer + KMSAN_LEAVE jmp doreti /* * Local APIC CMCI handler. */ INTR_HANDLER cmcint + KMSAN_ENTER call lapic_handle_cmc + KMSAN_LEAVE jmp doreti /* * Local APIC error interrupt handler. */ INTR_HANDLER errorint + KMSAN_ENTER call lapic_handle_error + KMSAN_LEAVE jmp doreti #ifdef XENHVM @@ -149,8 +157,10 @@ IDTVEC(spuriousint) * Only used when the hypervisor supports direct vector callbacks. */ INTR_HANDLER xen_intr_upcall + KMSAN_ENTER movq %rsp, %rdi call xen_intr_handle_upcall + KMSAN_LEAVE jmp doreti #endif @@ -165,8 +175,10 @@ IDTVEC(spuriousint) * IPI handler for cache and TLB shootdown */ INTR_HANDLER invlop + KMSAN_ENTER call invlop_handler call as_lapic_eoi + KMSAN_LEAVE jmp ld_regs /* @@ -174,7 +186,9 @@ IDTVEC(spuriousint) */ INTR_HANDLER ipi_intr_bitmap_handler call as_lapic_eoi + KMSAN_ENTER call ipi_bitmap_handler + KMSAN_LEAVE jmp doreti /* @@ -182,15 +196,19 @@ IDTVEC(spuriousint) */ INTR_HANDLER cpustop call as_lapic_eoi + KMSAN_ENTER call cpustop_handler + KMSAN_LEAVE jmp doreti /* * Executed by a CPU when it receives an IPI_SUSPEND from another CPU. */ INTR_HANDLER cpususpend + KMSAN_ENTER call cpususpend_handler call as_lapic_eoi + KMSAN_LEAVE jmp doreti /* @@ -198,7 +216,9 @@ IDTVEC(spuriousint) */ INTR_HANDLER ipi_swi call as_lapic_eoi + KMSAN_ENTER call ipi_swi_handler + KMSAN_LEAVE jmp doreti /* @@ -212,8 +232,10 @@ IDTVEC(spuriousint) movq ipi_rendezvous_counts(,%rax,8), %rax incq (%rax) #endif + KMSAN_ENTER call smp_rendezvous_action call as_lapic_eoi + KMSAN_LEAVE jmp doreti /* diff --git a/sys/amd64/amd64/atpic_vector.S b/sys/amd64/amd64/atpic_vector.S index d76331a887ad..c6471999c238 100644 --- a/sys/amd64/amd64/atpic_vector.S +++ b/sys/amd64/amd64/atpic_vector.S @@ -44,9 +44,11 @@ */ .macro INTR irq_num, vec_name INTR_HANDLER \vec_name + KMSAN_ENTER movq %rsp, %rsi movl $\irq_num, %edi /* pass the IRQ */ call atpic_handle_intr + KMSAN_LEAVE jmp doreti .endm diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index 4716ca8cd7c2..d1e49faa40e7 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -282,8 +282,10 @@ alltraps_pushregs_no_rax: .globl calltrap .type calltrap,@function calltrap: - movq %rsp,%rdi + KMSAN_ENTER + movq %rsp, %rdi call trap_check + KMSAN_LEAVE jmp doreti /* Handle any pending ASTs */ /* @@ -352,8 +354,10 @@ IDTVEC(dblfault) cmpq $~0,%rax je 2f movq %rax,%cr3 -2: movq %rsp,%rdi +2: KMSAN_ENTER + movq %rsp,%rdi call dblfault_handler + KMSAN_LEAVE 3: hlt jmp 3b @@ -856,8 +860,10 @@ nmi_fromuserspace: 3: /* Note: this label is also used by ddb and gdb: */ nmi_calltrap: + KMSAN_ENTER movq %rsp,%rdi call trap + KMSAN_LEAVE #ifdef HWPMC_HOOKS /* * Capture a userspace callchain if needed. @@ -1043,8 +1049,10 @@ mchk_fromuserspace: 1: call handle_ibrs_entry /* Note: this label is also used by ddb and gdb: */ mchk_calltrap: + KMSAN_ENTER movq %rsp,%rdi call mca_intr + KMSAN_LEAVE testl %ebx,%ebx /* %ebx != 0 => return to userland */ jnz doreti_exit /* diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 8599dc2fa8f6..e49dcaa576e8 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1943,6 +1944,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) thread0.td_critnest = 0; kasan_init(); + kmsan_init(); TSEXIT(); diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index b08495f3f139..ff4bccebed5b 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -229,6 +230,7 @@ trap(struct trapframe *frame) dr6 = 0; kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); + kmsan_mark(frame, sizeof(*frame), KMSAN_STATE_INITED); VM_CNT_INC(v_trap); type = frame->tf_trapno; @@ -973,6 +975,7 @@ trap_user_dtrace(struct trapframe *frame, int (**hookp)(struct trapframe *)) void dblfault_handler(struct trapframe *frame) { + kmsan_mark(frame, sizeof(*frame), KMSAN_STATE_INITED); #ifdef KDTRACE_HOOKS if (dtrace_doubletrap_func != NULL) (*dtrace_doubletrap_func)(); @@ -1177,6 +1180,8 @@ amd64_syscall(struct thread *td, int traced) { ksiginfo_t ksi; + kmsan_mark(td->td_frame, sizeof(*td->td_frame), KMSAN_STATE_INITED); + #ifdef DIAGNOSTIC if (!TRAPF_USERMODE(td->td_frame)) { panic("syscall"); diff --git a/sys/amd64/ia32/ia32_syscall.c b/sys/amd64/ia32/ia32_syscall.c index 9294ef8ce741..4e95d056d7fa 100644 --- a/sys/amd64/ia32/ia32_syscall.c +++ b/sys/amd64/ia32/ia32_syscall.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -208,6 +209,8 @@ ia32_syscall(struct trapframe *frame) register_t orig_tf_rflags; ksiginfo_t ksi; + kmsan_mark(frame, sizeof(*frame), KMSAN_STATE_INITED); + orig_tf_rflags = frame->tf_rflags; td = curthread; td->td_frame = frame; diff --git a/sys/amd64/include/asmacros.h b/sys/amd64/include/asmacros.h index 438f4ec26f61..973a1c761c6b 100644 --- a/sys/amd64/include/asmacros.h +++ b/sys/amd64/include/asmacros.h @@ -213,6 +213,28 @@ X\vec_name: movq TF_R15(%rsp),%r15 .endm +#ifdef KMSAN +/* + * The KMSAN runtime relies on a TLS block to track initialization and origin + * state for function parameters and return values. To keep this state + * consistent in the face of asynchronous kernel-mode traps, the runtime + * maintains a stack of blocks: when handling an exception or interrupt, + * kmsan_intr_enter() pushes the new block to be used until the handler is + * complete, at which point kmsan_intr_leave() restores the previous block. + * + * Thus, KMSAN_ENTER/LEAVE hooks are required only in handlers for events that + * may have happened while in kernel-mode. In particular, they are not required + * around amd64_syscall() or ast() calls. Otherwise, kmsan_intr_enter() can be + * called unconditionally, without distinguishing between entry from user-mode + * or kernel-mode. + */ +#define KMSAN_ENTER callq kmsan_intr_enter +#define KMSAN_LEAVE callq kmsan_intr_leave +#else +#define KMSAN_ENTER +#define KMSAN_LEAVE +#endif + #endif /* LOCORE */ #ifdef __STDC__ diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index b71a00adb62e..7b8a95333868 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1057,6 +1057,8 @@ fork_exit(void (*callout)(void *, struct trapframe *), void *arg, struct thread *td; struct thread *dtd; + kmsan_mark(frame, sizeof(*frame), KMSAN_STATE_INITED); + td = curthread; p = td->td_proc; KASSERT(p->p_state == PRS_NORMAL, ("executing process is still new")); diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index d0f616d037c5..edeeded09911 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -216,6 +217,8 @@ ast(struct trapframe *framep) int flags, sig; bool resched_sigs; + kmsan_mark(framep, sizeof(*framep), KMSAN_STATE_INITED); + td = curthread; p = td->td_proc; diff --git a/sys/x86/isa/atpic.c b/sys/x86/isa/atpic.c index 28c10ee7009f..de72780c100b 100644 --- a/sys/x86/isa/atpic.c +++ b/sys/x86/isa/atpic.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -523,8 +524,8 @@ atpic_handle_intr(u_int vector, struct trapframe *frame) { struct intsrc *isrc; - /* The frame may have been written into a poisoned region. */ kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); + kmsan_mark(frame, sizeof(*frame), KMSAN_STATE_INITED); KASSERT(vector < NUM_ISA_IRQS, ("unknown int %u\n", vector)); isrc = &atintrs[vector].at_intsrc; diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 9708121e0829..04de3ae47461 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1306,8 +1307,9 @@ lapic_handle_intr(int vector, struct trapframe *frame) { struct intsrc *isrc; - /* The frame may have been written into a poisoned region. */ kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); + kmsan_mark(&vector, sizeof(vector), KMSAN_STATE_INITED); + kmsan_mark(frame, sizeof(*frame), KMSAN_STATE_INITED); isrc = intr_lookup_source(apic_idt_to_irq(PCPU_GET(apic_id), vector)); @@ -1324,8 +1326,8 @@ lapic_handle_timer(struct trapframe *frame) /* Send EOI first thing. */ lapic_eoi(); - /* The frame may have been written into a poisoned region. */ kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); + kmsan_mark(frame, sizeof(*frame), KMSAN_STATE_INITED); #if defined(SMP) && !defined(SCHED_ULE) /* From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 687B26724A1; Wed, 11 Aug 2021 01:31: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 4Gksj80Dq9z3PVv; Wed, 11 Aug 2021 01:31: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 C9A5C26228; Wed, 11 Aug 2021 01:31: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 17B1V7WZ051084; Wed, 11 Aug 2021 01:31:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V7nE051083; Wed, 11 Aug 2021 01:31:07 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:07 GMT Message-Id: <202108110131.17B1V7nE051083@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: ce2609947c2d - main - kmsan: Add a manual page 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/main X-Git-Reftype: branch X-Git-Commit: ce2609947c2d5433ed4ebb25f9a728340008ff92 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:08 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ce2609947c2d5433ed4ebb25f9a728340008ff92 commit ce2609947c2d5433ed4ebb25f9a728340008ff92 Author: Mark Johnston AuthorDate: 2021-08-10 20:55:23 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:53 +0000 kmsan: Add a manual page Sponsored by: The FreeBSD Foundation --- share/man/man9/Makefile | 8 ++ share/man/man9/kasan.9 | 1 + share/man/man9/kmsan.9 | 352 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 361 insertions(+) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index d6650a2538f7..47c642319049 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -196,6 +196,7 @@ MAN= accept_filter.9 \ kernacc.9 \ kernel_mount.9 \ khelp.9 \ + kmsan.9 \ kobj.9 \ kproc.9 \ kqueue.9 \ @@ -1320,6 +1321,13 @@ MLINKS+=khelp.9 khelp_add_hhook.9 \ khelp.9 khelp_get_osd.9 \ khelp.9 khelp_init_osd.9 \ khelp.9 khelp_remove_hhook.9 +MLINKS+=kmsan.9 KMSAN.9 \ + kmsan.9 kmsan_check.9 \ + kmsan.9 kmsan_check_bio.9 \ + kmsan.9 kmsan_check_ccb.9 \ + kmsan.9 kmsan_check_mbuf.9 \ + kmsan.9 kmsan_mark.9 \ + kmsan.9 kmsan_oirg.9 MLINKS+=kobj.9 DEFINE_CLASS.9 \ kobj.9 kobj_class_compile.9 \ kobj.9 kobj_class_compile_static.9 \ diff --git a/share/man/man9/kasan.9 b/share/man/man9/kasan.9 index 61d8daf6c345..051c3ee0dbbb 100644 --- a/share/man/man9/kasan.9 +++ b/share/man/man9/kasan.9 @@ -149,6 +149,7 @@ are equal, should be 0. .Sh SEE ALSO .Xr build 7 , +.Xr KMSAN 9 , .Xr malloc 9 , .Xr memguard 9 , .Xr redzone 9 , diff --git a/share/man/man9/kmsan.9 b/share/man/man9/kmsan.9 new file mode 100644 index 000000000000..a80ef7112451 --- /dev/null +++ b/share/man/man9/kmsan.9 @@ -0,0 +1,352 @@ +.\"- +.\" Copyright (c) 2021 The FreeBSD Foundation +.\" +.\" This documentation was written by Mark Johnston 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$ +.\" +.Dd August 10, 2021 +.Dt KMSAN 9 +.Os +.Sh NAME +.Nm KMSAN +.Nd Kernel Memory SANitizer +.Sh SYNOPSIS +The +.Pa GENERIC-KMSAN +kernel configuration can be used to compile a KMSAN-enabled kernel using +.Pa GENERIC +as a base configuration. +Alternately, to compile KMSAN into the kernel, place the following line in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "options KMSAN" +.Ed +.Pp +.In sys/msan.h +.Ft void +.Fn kmsan_mark "const void *addr" "size_t size" "uint8_t code" +.Ft void +.Fn kmsan_orig "const void *addr" "size_t size" "int type" "uintptr_t pc" +.Ft void +.Fn kmsan_check "const void *addr" "size_t size" "const char *descr" +.Ft void +.Fn kmsan_check_bio "const struct bio *" "const char *descr" +.Ft void +.Fn kmsan_check_ccb "const union ccb *" "const char *descr" +.Ft void +.Fn kmsan_check_mbuf "const struct mbuf *" "const char *descr" +.Sh DESCRIPTION +.Nm +is a subsystem which leverages compiler instrumentation to detect uses of +uninitialized memory in the kernel. +Currently it is implemented only on the amd64 platform. +.Pp +When +.Nm +is compiled into the kernel, the compiler is configured to emit function +calls preceding memory accesses. +The functions are implemented by the +.Nm +runtime component and use hidden, byte-granular shadow state to determine +whether the source operand has been initialized. +When uninitialized memory is used as a source operand in certain operations, +such as control flow expressions or memory accesses, the runtime reports +an error. +Otherwise, the shadow state is propagated to destination operand. +For example, a +variable assignment or a +.Fn memcpy +call which copies uninitialized memory will cause the destination buffer or +variable to be marked uninitialized. +.Pp +To report an error, the +.Nm +runtime will either trigger a kernel panic or print a message to the console, +depending on the value of the +.Sy debug.kmsan.panic_on_violation +sysctl. +In both cases, a stack trace and information about the origin of the +uninitialized memory is included. +.Pp +In addition to compiler-detected uses of uninitialized memory, +various kernel I/O +.Dq exit points , +such as +.Xr copyout 9 , +perform validation of the input's shadow state and will raise an error if +any uninitialized bytes are detected. +.Pp +The +.Nm +option imposes a significant performance penalty. +Kernel code typically runs two or three times slower, and each byte mapped in +the kernel map requires two bytes of shadow state. +As a result, +.Nm +should be used only for kernel testing and development. +It is not recommended to enable +.Nm +in systems with less than 8GB of physical RAM. +.Sh FUNCTIONS +The +.Fn kmsan_mark +and +.Fn kmsan_orig +functions update +.Nm +shadow state. +.Fn kmsan_mark +marks an address range as valid or invalid according to the value of the +.Va code +parameter. +The valid values for this parameter are +.Dv KMSAN_STATE_INITED +and +.Dv KMSAN_STATE_UNINIT , +which mark the range as initialized and uninitialized, respectively. +For example, when a piece of memory is freed to a kernel allocator, it will +typically have been marked initialized; before the memory is reused for a new +allocation, the allocator should mark it as uninitialized. +As another example, writes to host memory performed by devices, e.g., via DMA, +are not intercepted by the sanitizer; to avoid false positives, drivers should +mark device-written memory as initialized. +For many drivers this is handled internally by the +.Xr busdma 9 +subsystem. +.Pp +The +.Fn kmsan_orig +function updates +.Dq origin +shadow state. +In particular, it associates a given uninitialized buffer with a memory type +and code address. +This is used by the +.Nm +runtime to track the source of uninitialized memory and is only for debugging +purposes. +See +.Sx IMPLEMENTATION NOTES +for more details. +.Pp +The +.Fn kmsan_check +function and its sub-typed siblings validate the shadow state of the region(s) +of kernel memory passed as input parameters. +If any byte of the input is marked as uninitialized, the runtime will generate +a report. +These functions are useful during debugging, as they can be strategically +inserted into code paths to narrow down the source of uninitialized memory. +They are also used to perform validation in various kernel I/O paths, helping +ensure that, for example, packets transmitted over a network do not contain +uninitialized kernel memory. +.Fn kmsan_check +and related functions also take a +.Fa descr +parameter which is inserted into any reports raised by the check. +.Sh IMPLEMENTATION NOTES +.Ss Shadow Maps +The +.Nm +runtime makes use of two shadows of the kernel map. +Each address in the kernel map has a linear mapping to addresses in the +two shadows. +The first, simply called the shadow map, tracks the state of the corresponding +kernel memory. +A non-zero byte in the shadow map indicates that the corresponding byte of +kernel memory is uninitialized. +The +.Nm +instrumentation automatically propagates shadow state as the contents of kernel +memory are transformed and copied. +.Pp +The second shadow is called the origin map, and exists only to help debug +reports from the sanitizer. +To avoid false positives, +.Nm +does not raise reports for certain operations on uninitialized memory, such +as copying or arithmetic. +Thus, operations on uninitialized state which raise a report may be far removed +from the source of the bug, complicating debugging. +The origin map contains information which can help pinpoint the root cause of +a particular +.Nm +report; when generating a report, the runtime uses state from the origin map +to provide extra details. +.Pp +Unlike the shadow map, the origin map is not byte-granular, but consists of 4-byte +.Dq cells . +Each cell describes the corresponding four bytes of mapped kernel memory and +holds a type and compressed code address. +When kernel memory is allocated for some purpose, its origin is initialized +either by the compiler instrumentation or by runtime hooks in the allocator. +The type indicates the specific allocator, e.g., +.Xr uma 9 , +and the address provides the location in the kernel code where the memory was +allocated. +.Ss Assembly Code +When +.Nm +is configured, the compiler will only emit instrumentation for C code. +Files containing assembly code are left un-instrumented. +In some cases this is handled by the sanitizer runtime, which defines +wrappers for subroutines implemented in assembly. +These wrappers are referred to as interceptors and handle updating +shadow state to reflect the operations performed by the original +subroutines. +In other cases, C code which calls assembly code or is called from +assembly code may need to use +.Fn kmsan_mark +to manually update shadow state. +This is typically only necessary in machine-dependent code. +.Pp +Inline assembly is instrumented by the compiler to update shadow state +based on the output operands of the code, and thus does not usually +require any special handling to avoid false positives. +.Ss Interrupts and Exceptions +In addition to the shadow maps, the sanitizer requires some thread-local +storage (TLS) to track initialization and origin state for function +parameters and return values. +The sanitizer instrumentation will automatically fetch, update and +verify this state. +In particular, this storage block has a layout defined by the sanitizer +ABI. +.Pp +Most kernel code runs in a context where interrupts or exceptions may +redirect the CPU to begin execution of unrelated code. +To ensure that thread-local sanitizer state remains consistent, the +runtime maintains a stack of TLS blocks for each thread. +When machine-dependent interrupt and exception handlers begin execution, +they push a new entry onto the stack before calling into any C code, and +pop the stack before resuming execution of the interrupted code. +These operations are performed by the +.Fn kmsan_intr_enter +and +.Fn kmsan_intr_leave +functions in the sanitizer runtime. +.Sh EXAMPLES +The following contrived example demonstrates some of the types of bugs +that are automatically detected by +.Nm : +.Bd -literal -offset indent +int +f(size_t osz) +{ + struct { + uint32_t bar; + uint16_t baz; + /* A 2-byte hole is here. */ + } foo; + char *buf; + size_t sz; + int error; + + /* + * This will raise a report since "sz" is uninitialized + * here. If it is initialized, and "osz" was left uninitialized + * by the caller, a report would also be raised. + */ + if (sz < osz) + return (1); + + buf = malloc(32, M_TEMP, M_WAITOK); + + /* + * This will raise a report since "buf" has not been + * initialized and contains whatever data is left over from the + * previous use of that memory. + */ + for (i = 0; i < 32; i++) + if (buf[i] != '\0') + foo.bar++; + foo.baz = 0; + + /* + * This will raise a report since the pad bytes in "foo" have + * not been initialized, e.g., by memset(), and this call will + * thus copy uninitialized kernel stack memory into userspace. + */ + copyout(&foo, uaddr, sizeof(foo)); + + /* + * This line itself will not raise a report, but may trigger + * a report in the caller depending on how the return value is + * used. + */ + return (error); +} +.Ed +.Sh SEE ALSO +.Xr build 7 , +.Xr busdma 9 , +.Xr copyout 9 , +.Xr KASAN 9 , +.Xr uma 9 +.Rs +.%A Evgeniy Stepanov +.%A Konstantin Serebryany +.%T MemorySanitizer: fast detector of uninitialized memory use in C++ +.%J 2015 IEEE/ACM International Symposium on Code Generation and Optimization (CGO) +.%D 2015 +.Re +.Sh HISTORY +.Nm +was ported from +.Nx +and first appeared in +.Fx 14.0 . +.Sh BUGS +Accesses to kernel memory outside of the kernel map are ignored by the +.Nm +runtime. +In particular, memory accesses via the direct map are not validated. +When memory is copied from outside the kernel map into the kernel map, +that region of the kernel map is marked as initialized. +When +.Nm +is configured, kernel memory allocators are configured to use the kernel map, +and filesystems are configured to always map data buffers into the kernel map, +so usage of the direct map is minimized. +However, some uses of the direct map remain. +This is a conservative policy which aims to avoid false positives, but it will +mask bug in some kernel subsystems. +.Pp +On amd64, global variables and the physical page array +.Va vm_page_array +are not sanitized. +This is intentional, as it reduces memory usage by avoiding creating +shadows of large regions of the kernel map. +However, this can allow bugs to go undetected by +.Nm . +.Pp +Some kernel memory allocators provide type-stable objects, and code which uses +them frequently depends on object data being preserved across allocations. +Such allocations cannot be sanitized by +.Nm . +However, in some cases it may be possible to use +.Fn kmsan_mark +to manually annotate fields which are known to contain invalid data upon +allocation. From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C64776723DA; Wed, 11 Aug 2021 01:31: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 4Gksj92kqkz3PYV; Wed, 11 Aug 2021 01:31: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 E50682639D; Wed, 11 Aug 2021 01:31: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 17B1V8d6051114; Wed, 11 Aug 2021 01:31:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V8A9051113; Wed, 11 Aug 2021 01:31:08 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:08 GMT Message-Id: <202108110131.17B1V8A9051113@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 1263022e3922 - main - Add a GENERIC-KMSAN kernel configuration for amd64 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/main X-Git-Reftype: branch X-Git-Commit: 1263022e3922f9b73c79f7f0fe34c0dfed86fb25 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:10 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1263022e3922f9b73c79f7f0fe34c0dfed86fb25 commit 1263022e3922f9b73c79f7f0fe34c0dfed86fb25 Author: Mark Johnston AuthorDate: 2021-08-10 19:51:31 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:53 +0000 Add a GENERIC-KMSAN kernel configuration for amd64 Sponsored by: The FreeBSD Foundation --- sys/amd64/conf/GENERIC-KMSAN | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/amd64/conf/GENERIC-KMSAN b/sys/amd64/conf/GENERIC-KMSAN new file mode 100644 index 000000000000..0afbade172b4 --- /dev/null +++ b/sys/amd64/conf/GENERIC-KMSAN @@ -0,0 +1,7 @@ +# $FreeBSD$ + +include GENERIC + +ident GENERIC-KMSAN + +options KMSAN From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C37D66725BA; Wed, 11 Aug 2021 01:31: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 4GksjB2r28z3PdZ; Wed, 11 Aug 2021 01:31: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 0D8832622B; Wed, 11 Aug 2021 01:31: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 17B1V9uG051138; Wed, 11 Aug 2021 01:31:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1V9ma051137; Wed, 11 Aug 2021 01:31:09 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:09 GMT Message-Id: <202108110131.17B1V9ma051137@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 3a1802fef4b5 - main - busdma: Add an internal BUS_DMA_FORCE_MAP flag to x86 bounce_busdma 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/main X-Git-Reftype: branch X-Git-Commit: 3a1802fef4b535d22b7f0d3fa6e0bc2de5003922 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:11 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3a1802fef4b535d22b7f0d3fa6e0bc2de5003922 commit 3a1802fef4b535d22b7f0d3fa6e0bc2de5003922 Author: Mark Johnston AuthorDate: 2021-08-10 21:11:43 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:54 +0000 busdma: Add an internal BUS_DMA_FORCE_MAP flag to x86 bounce_busdma Use this flag to indicate that busdma should allocate a map structure even no bouncing is required to satisfy the tag's constraints. This will be used for KMSAN. Also fix a memory leak that can occur if the kernel fails to allocate bounce pages in bounce_bus_dmamap_create(). Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31338 --- sys/x86/x86/busdma_bounce.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c index 75fdf4143b9b..d89d4d5a17ff 100644 --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -66,6 +66,7 @@ enum { BUS_DMA_COULD_BOUNCE = 0x01, BUS_DMA_MIN_ALLOC_COMP = 0x02, BUS_DMA_KMEM_ALLOC = 0x04, + BUS_DMA_FORCE_MAP = 0x08, }; struct bounce_zone; @@ -301,7 +302,7 @@ bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) error = 0; if (dmat->segments == NULL) { - dmat->segments = (bus_dma_segment_t *)malloc_domainset( + dmat->segments = malloc_domainset( sizeof(bus_dma_segment_t) * dmat->common.nsegments, M_DEVBUF, DOMAINSET_PREF(dmat->common.domain), M_NOWAIT); if (dmat->segments == NULL) { @@ -311,6 +312,19 @@ bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) } } + if (dmat->bounce_flags & (BUS_DMA_COULD_BOUNCE | BUS_DMA_FORCE_MAP)) { + *mapp = malloc_domainset(sizeof(**mapp), M_DEVBUF, + DOMAINSET_PREF(dmat->common.domain), M_NOWAIT | M_ZERO); + if (*mapp == NULL) { + CTR3(KTR_BUSDMA, "%s: tag %p error %d", + __func__, dmat, ENOMEM); + return (ENOMEM); + } + STAILQ_INIT(&(*mapp)->bpages); + } else { + *mapp = NULL; + } + /* * Bouncing might be required if the driver asks for an active * exclusion region, a data alignment that is stricter than 1, and/or @@ -318,23 +332,11 @@ bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) */ if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) { /* Must bounce */ - if (dmat->bounce_zone == NULL) { - if ((error = alloc_bounce_zone(dmat)) != 0) - return (error); - } + if (dmat->bounce_zone == NULL && + (error = alloc_bounce_zone(dmat)) != 0) + goto out; bz = dmat->bounce_zone; - *mapp = (bus_dmamap_t)malloc_domainset(sizeof(**mapp), M_DEVBUF, - DOMAINSET_PREF(dmat->common.domain), M_NOWAIT | M_ZERO); - if (*mapp == NULL) { - CTR3(KTR_BUSDMA, "%s: tag %p error %d", - __func__, dmat, ENOMEM); - return (ENOMEM); - } - - /* Initialize the new map */ - STAILQ_INIT(&((*mapp)->bpages)); - /* * Attempt to add pages to our pool on a per-instance * basis up to a sane limit. @@ -361,11 +363,16 @@ bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) error = 0; } bz->map_count++; + } + +out: + if (error == 0) { + dmat->map_count++; } else { + free(*mapp, M_DEVBUF); *mapp = NULL; } - if (error == 0) - dmat->map_count++; + CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", __func__, dmat, dmat->common.flags, error); return (error); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CCFED6723E1; Wed, 11 Aug 2021 01:31: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 4GksjD3rrHz3Pn5; Wed, 11 Aug 2021 01:31: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 4A18726508; Wed, 11 Aug 2021 01:31: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 17B1VC1I051186; Wed, 11 Aug 2021 01:31:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1VC0L051185; Wed, 11 Aug 2021 01:31:12 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:12 GMT Message-Id: <202108110131.17B1VC0L051185@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 100949103a63 - main - uma: Add KMSAN hooks 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/main X-Git-Reftype: branch X-Git-Commit: 100949103a6340aff8a6a4caf1927374c242721c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:13 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=100949103a6340aff8a6a4caf1927374c242721c commit 100949103a6340aff8a6a4caf1927374c242721c Author: Mark Johnston AuthorDate: 2021-08-10 21:15:03 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:54 +0000 uma: Add KMSAN hooks For now, just hook the allocation path: upon allocation, items are marked as initialized (absent M_ZERO). Some zones are exempted from this when it would otherwise raise false positives. Use kmsan_orig() to update the origin map for UMA and malloc(9) allocations. This allows KMSAN to print the return address when an uninitialized UMA item is implicated in a report. For example: panic: MSan: Uninitialized UMA memory from m_getm2+0x7fe Sponsored by: The FreeBSD Foundation --- sys/kern/kern_malloc.c | 16 +++++++++++-- sys/kern/kern_mbuf.c | 10 ++++---- sys/vm/uma_core.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++--- sys/vm/vm_glue.c | 2 ++ 4 files changed, 80 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index b30139830a1b..0bdce47b37b4 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -654,8 +655,13 @@ void * indx = kmemsize[size >> KMEM_ZSHIFT]; zone = kmemzones[indx].kz_zone[mtp_get_subzone(mtp)]; va = uma_zalloc(zone, flags); - if (va != NULL) + if (va != NULL) { size = zone->uz_size; + if ((flags & M_ZERO) == 0) { + kmsan_mark(va, size, KMSAN_STATE_UNINIT); + kmsan_orig(va, size, KMSAN_TYPE_MALLOC, KMSAN_RET_ADDR); + } + } malloc_type_zone_allocated(mtp, va == NULL ? 0 : size, indx); if (__predict_false(va == NULL)) { KASSERT((flags & M_WAITOK) == 0, @@ -735,6 +741,12 @@ malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds, #ifdef KASAN if (va != NULL) kasan_mark((void *)va, osize, size, KASAN_MALLOC_REDZONE); +#endif +#ifdef KMSAN + if ((flags & M_ZERO) == 0) { + kmsan_mark(va, size, KMSAN_STATE_UNINIT); + kmsan_orig(va, size, KMSAN_TYPE_MALLOC, KMSAN_RET_ADDR); + } #endif return (va); } @@ -1232,7 +1244,7 @@ mallocinit(void *dummy) for (subzone = 0; subzone < numzones; subzone++) { kmemzones[indx].kz_zone[subzone] = uma_zcreate(name, size, -#if defined(INVARIANTS) && !defined(KASAN) +#if defined(INVARIANTS) && !defined(KASAN) && !defined(KMSAN) mtrash_ctor, mtrash_dtor, mtrash_init, mtrash_fini, #else NULL, NULL, NULL, NULL, diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index c43f086bb83f..ae4aa7d7e96a 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -683,7 +683,7 @@ mb_dtor_pack(void *mem, int size, void *arg) KASSERT(m->m_ext.ext_arg2 == NULL, ("%s: ext_arg2 != NULL", __func__)); KASSERT(m->m_ext.ext_size == MCLBYTES, ("%s: ext_size != MCLBYTES", __func__)); KASSERT(m->m_ext.ext_type == EXT_PACKET, ("%s: ext_type != EXT_PACKET", __func__)); -#ifdef INVARIANTS +#if defined(INVARIANTS) && !defined(KMSAN) trash_dtor(m->m_ext.ext_buf, MCLBYTES, arg); #endif /* @@ -742,7 +742,7 @@ mb_zinit_pack(void *mem, int size, int how) m->m_ext.ext_buf == NULL) return (ENOMEM); m->m_ext.ext_type = EXT_PACKET; /* Override. */ -#ifdef INVARIANTS +#if defined(INVARIANTS) && !defined(KMSAN) trash_init(m->m_ext.ext_buf, MCLBYTES, how); #endif return (0); @@ -758,11 +758,11 @@ mb_zfini_pack(void *mem, int size) struct mbuf *m; m = (struct mbuf *)mem; -#ifdef INVARIANTS +#if defined(INVARIANTS) && !defined(KMSAN) trash_fini(m->m_ext.ext_buf, MCLBYTES); #endif uma_zfree_arg(zone_clust, m->m_ext.ext_buf, NULL); -#ifdef INVARIANTS +#if defined(INVARIANTS) && !defined(KMSAN) trash_dtor(mem, size, NULL); #endif } @@ -784,7 +784,7 @@ mb_ctor_pack(void *mem, int size, void *arg, int how) type = args->type; MPASS((flags & M_NOFREE) == 0); -#ifdef INVARIANTS +#if defined(INVARIANTS) && !defined(KMSAN) trash_ctor(m->m_ext.ext_buf, MCLBYTES, arg, how); #endif diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 59cc960d3dd9..cdf3d482679e 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -632,6 +633,60 @@ kasan_mark_slab_invalid(uma_keg_t keg __unused, void *mem __unused) } #endif /* KASAN */ +#ifdef KMSAN +static inline void +kmsan_mark_item_uninitialized(uma_zone_t zone, void *item) +{ + void *pcpu_item; + size_t sz; + int i; + + if ((zone->uz_flags & + (UMA_ZFLAG_CACHE | UMA_ZONE_SECONDARY | UMA_ZONE_MALLOC)) != 0) { + /* + * Cache zones should not be instrumented by default, as UMA + * does not have enough information to do so correctly. + * Consumers can mark items themselves if it makes sense to do + * so. + * + * Items from secondary zones are initialized by the parent + * zone and thus cannot safely be marked by UMA. + * + * malloc zones are handled directly by malloc(9) and friends, + * since they can provide more precise origin tracking. + */ + return; + } + if (zone->uz_keg->uk_init != NULL) { + /* + * By definition, initialized items cannot be marked. The + * best we can do is mark items from these zones after they + * are freed to the keg. + */ + return; + } + + sz = zone->uz_size; + if ((zone->uz_flags & UMA_ZONE_PCPU) == 0) { + kmsan_orig(item, sz, KMSAN_TYPE_UMA, KMSAN_RET_ADDR); + kmsan_mark(item, sz, KMSAN_STATE_UNINIT); + } else { + pcpu_item = zpcpu_base_to_offset(item); + for (i = 0; i <= mp_maxid; i++) { + kmsan_orig(zpcpu_get_cpu(pcpu_item, i), sz, + KMSAN_TYPE_UMA, KMSAN_RET_ADDR); + kmsan_mark(zpcpu_get_cpu(pcpu_item, i), sz, + KMSAN_STATE_INITED); + } + } +} +#else /* !KMSAN */ +static inline void +kmsan_mark_item_uninitialized(uma_zone_t zone __unused, void *item __unused) +{ +} +#endif /* KMSAN */ + /* * Acquire the domain lock and record contention. */ @@ -2799,7 +2854,7 @@ zone_ctor(void *mem, int size, void *udata, int flags) STAILQ_INIT(&zdom->uzd_buckets); } -#if defined(INVARIANTS) && !defined(KASAN) +#if defined(INVARIANTS) && !defined(KASAN) && !defined(KMSAN) if (arg->uminit == trash_init && arg->fini == trash_fini) zone->uz_flags |= UMA_ZFLAG_TRASH | UMA_ZFLAG_CTORDTOR; #elif defined(KASAN) @@ -3227,7 +3282,7 @@ uma_zcreate(const char *name, size_t size, uma_ctor ctor, uma_dtor dtor, args.dtor = dtor; args.uminit = uminit; args.fini = fini; -#if defined(INVARIANTS) && !defined(KASAN) +#if defined(INVARIANTS) && !defined(KASAN) && !defined(KMSAN) /* * Inject procedures which check for memory use after free if we are * allowed to scramble the memory while it is not allocated. This @@ -3387,6 +3442,7 @@ item_ctor(uma_zone_t zone, int uz_flags, int size, void *udata, int flags, #endif kasan_mark_item_valid(zone, item); + kmsan_mark_item_uninitialized(zone, item); #ifdef INVARIANTS skipdbg = uma_dbg_zskip(zone, item); diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 7cfb08246f9e..5e118a7ad86e 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -387,6 +388,7 @@ vm_thread_new(struct thread *td, int pages) td->td_kstack = ks; td->td_kstack_pages = pages; kasan_mark((void *)ks, ptoa(pages), ptoa(pages), 0); + kmsan_mark((void *)ks, ptoa(pages), KMSAN_STATE_UNINIT); return (1); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 01F93672623; Wed, 11 Aug 2021 01:31: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 4GksjF4rV7z3Pks; Wed, 11 Aug 2021 01:31: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 67AB6264F3; Wed, 11 Aug 2021 01:31: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 17B1VDB2051210; Wed, 11 Aug 2021 01:31:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1VDcX051209; Wed, 11 Aug 2021 01:31:13 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:13 GMT Message-Id: <202108110131.17B1VDcX051209@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d75884df7812 - main - ck: Correct asm output operand widths in amd64 pointer intrinsics 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/main X-Git-Reftype: branch X-Git-Commit: d75884df7812d7331d4ba0a37c7d391f080a9988 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:14 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d75884df7812d7331d4ba0a37c7d391f080a9988 commit d75884df7812d7331d4ba0a37c7d391f080a9988 Author: Mark Johnston AuthorDate: 2021-08-10 21:23:49 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:54 +0000 ck: Correct asm output operand widths in amd64 pointer intrinsics This does not appear to change generated code with the default toolchain. However, KMSAN makes use of output operand specifications to instrument inline asm, and with incorrect specifications we get false positives in code that uses the CK_(S)LIST macros. This was submitted upstream: https://github.com/concurrencykit/ck/pull/175 The commit applies the same change locally to make KMSAN usable until something equivalent is merged upstream. MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/contrib/ck/include/gcc/x86_64/ck_pr.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/contrib/ck/include/gcc/x86_64/ck_pr.h b/sys/contrib/ck/include/gcc/x86_64/ck_pr.h index fb2804e8d8e5..3b80d1dc1d54 100644 --- a/sys/contrib/ck/include/gcc/x86_64/ck_pr.h +++ b/sys/contrib/ck/include/gcc/x86_64/ck_pr.h @@ -149,7 +149,7 @@ ck_pr_rfo(const void *m) return v; \ } -CK_PR_FAS(ptr, void, void *, char, "xchgq") +CK_PR_FAS(ptr, void, void *, uint64_t, "xchgq") #define CK_PR_FAS_S(S, T, I) CK_PR_FAS(S, T, T, T, I) @@ -182,7 +182,7 @@ CK_PR_FAS_S(8, uint8_t, "xchgb") return (r); \ } -CK_PR_LOAD(ptr, void, void *, char, "movq") +CK_PR_LOAD(ptr, void, void *, uint64_t, "movq") #define CK_PR_LOAD_S(S, T, I) CK_PR_LOAD(S, T, T, T, I) @@ -264,7 +264,7 @@ CK_PR_LOAD_2(8, 16, uint8_t) return; \ } -CK_PR_STORE_IMM(ptr, void, const void *, char, "movq", CK_CC_IMM_U32) +CK_PR_STORE_IMM(ptr, void, const void *, uint64_t, "movq", CK_CC_IMM_U32) #ifndef CK_PR_DISABLE_DOUBLE CK_PR_STORE(double, double, double, double, "movq") #endif @@ -298,7 +298,7 @@ CK_PR_STORE_S(8, uint8_t, "movb", CK_CC_IMM_U32) return (d); \ } -CK_PR_FAA(ptr, void, uintptr_t, char, "xaddq") +CK_PR_FAA(ptr, void, uintptr_t, uint64_t, "xaddq") #define CK_PR_FAA_S(S, T, I) CK_PR_FAA(S, T, T, T, I) @@ -347,7 +347,7 @@ CK_PR_FAA_S(8, uint8_t, "xaddb") #define CK_PR_UNARY_S(K, S, T, I) CK_PR_UNARY(K, S, T, T, I) #define CK_PR_GENERATE(K) \ - CK_PR_UNARY(K, ptr, void, char, #K "q") \ + CK_PR_UNARY(K, ptr, void, uint64_t, #K "q") \ CK_PR_UNARY_S(K, char, char, #K "b") \ CK_PR_UNARY_S(K, int, int, #K "l") \ CK_PR_UNARY_S(K, uint, unsigned int, #K "l") \ @@ -388,7 +388,7 @@ CK_PR_GENERATE(not) #define CK_PR_BINARY_S(K, S, T, I, O) CK_PR_BINARY(K, S, T, T, T, I, O) #define CK_PR_GENERATE(K) \ - CK_PR_BINARY(K, ptr, void, uintptr_t, char, #K "q", CK_CC_IMM_U32) \ + CK_PR_BINARY(K, ptr, void, uintptr_t, uint64_t, #K "q", CK_CC_IMM_U32) \ CK_PR_BINARY_S(K, char, char, #K "b", CK_CC_IMM_S32) \ CK_PR_BINARY_S(K, int, int, #K "l", CK_CC_IMM_S32) \ CK_PR_BINARY_S(K, uint, unsigned int, #K "l", CK_CC_IMM_U32) \ @@ -424,7 +424,7 @@ CK_PR_GENERATE(xor) return z; \ } -CK_PR_CAS(ptr, void, void *, char, "cmpxchgq") +CK_PR_CAS(ptr, void, void *, uint64_t, "cmpxchgq") #define CK_PR_CAS_S(S, T, I) CK_PR_CAS(S, T, T, T, I) @@ -462,7 +462,7 @@ CK_PR_CAS_S(8, uint8_t, "cmpxchgb") return z; \ } -CK_PR_CAS_O(ptr, void, void *, char, "q", "rax") +CK_PR_CAS_O(ptr, void, void *, uint64_t, "q", "rax") #define CK_PR_CAS_O_S(S, T, I, R) \ CK_PR_CAS_O(S, T, T, T, I, R) @@ -587,12 +587,12 @@ CK_PR_CAS_V(8, 16, uint8_t) #define CK_PR_BT_S(K, S, T, I) CK_PR_BT(K, S, T, T, T, I) -#define CK_PR_GENERATE(K) \ - CK_PR_BT(K, ptr, void, uint64_t, char, #K "q %2, %0") \ - CK_PR_BT_S(K, uint, unsigned int, #K "l %2, %0") \ - CK_PR_BT_S(K, int, int, #K "l %2, %0") \ - CK_PR_BT_S(K, 64, uint64_t, #K "q %2, %0") \ - CK_PR_BT_S(K, 32, uint32_t, #K "l %2, %0") \ +#define CK_PR_GENERATE(K) \ + CK_PR_BT(K, ptr, void, uint64_t, uint64_t, #K "q %2, %0") \ + CK_PR_BT_S(K, uint, unsigned int, #K "l %2, %0") \ + CK_PR_BT_S(K, int, int, #K "l %2, %0") \ + CK_PR_BT_S(K, 64, uint64_t, #K "q %2, %0") \ + CK_PR_BT_S(K, 32, uint32_t, #K "l %2, %0") \ CK_PR_BT_S(K, 16, uint16_t, #K "w %w2, %0") CK_PR_GENERATE(btc) From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:31:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 71C536725C8; Wed, 11 Aug 2021 01:31: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 4GksjC4799z3PYc; Wed, 11 Aug 2021 01:31: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 2A430263A0; Wed, 11 Aug 2021 01:31: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 17B1VBEd051162; Wed, 11 Aug 2021 01:31:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1VBQC051161; Wed, 11 Aug 2021 01:31:11 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:31:11 GMT Message-Id: <202108110131.17B1VBQC051161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 693c9516fa60 - main - busdma: Add KMSAN integration 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/main X-Git-Reftype: branch X-Git-Commit: 693c9516fa6070199d1406df3265687c5e8b184a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:31:12 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=693c9516fa6070199d1406df3265687c5e8b184a commit 693c9516fa6070199d1406df3265687c5e8b184a Author: Mark Johnston AuthorDate: 2021-08-10 21:14:15 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 01:27:54 +0000 busdma: Add KMSAN integration Sanitizer instrumentation of course cannot automatically update shadow state when devices write to host memory. KMSAN thus hooks into busdma, both to update shadow state after a device write, and to verify that the kernel does not publish uninitalized bytes to devices. To implement this, when KMSAN is configured, each dmamap embeds a memory descriptor describing the region currently loaded into the map. bus_dmamap_sync() uses the operation flags to determine whether to validate the loaded region or to mark it as initialized in the shadow map. Note that in cases where the amount of data written is less than the buffer size, the entire buffer is marked initialized even when it is not. For example, if a NIC writes a 128B packet into a 2KB buffer, the entire buffer will be marked initialized, but subsequent accesses past the first 128 bytes are likely caused by bugs. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31338 --- sys/dev/iommu/busdma_iommu.c | 23 ++++++++++++++++++++++- sys/dev/iommu/busdma_iommu.h | 3 +++ sys/kern/subr_bus_dma.c | 34 ++++++++++++++++++++++++++++++++++ sys/x86/include/bus_dma.h | 12 ++++++++++++ sys/x86/include/busdma_impl.h | 3 +++ sys/x86/x86/busdma_bounce.c | 30 +++++++++++++++++++++++++++++- 6 files changed, 103 insertions(+), 2 deletions(-) diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 07a16e87eeda..75835d7484e5 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -916,11 +917,28 @@ iommu_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map1) } static void -iommu_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, +iommu_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map1, bus_dmasync_op_t op) { + struct bus_dmamap_iommu *map; + + map = (struct bus_dmamap_iommu *)map1; + kmsan_bus_dmamap_sync(&map->kmsan_mem, op); } +#ifdef KMSAN +static void +iommu_bus_dmamap_load_kmsan(bus_dmamap_t map1, struct memdesc *mem) +{ + struct bus_dmamap_iommu *map; + + map = (struct bus_dmamap_iommu *)map1; + if (map == NULL) + return; + memcpy(&map->kmsan_mem, mem, sizeof(struct memdesc)); +} +#endif + struct bus_dma_impl bus_dma_iommu_impl = { .tag_create = iommu_bus_dma_tag_create, .tag_destroy = iommu_bus_dma_tag_destroy, @@ -937,6 +955,9 @@ struct bus_dma_impl bus_dma_iommu_impl = { .map_complete = iommu_bus_dmamap_complete, .map_unload = iommu_bus_dmamap_unload, .map_sync = iommu_bus_dmamap_sync, +#ifdef KMSAN + .load_kmsan = iommu_bus_dmamap_load_kmsan, +#endif }; static void diff --git a/sys/dev/iommu/busdma_iommu.h b/sys/dev/iommu/busdma_iommu.h index f911f26fa0f7..903562ecea85 100644 --- a/sys/dev/iommu/busdma_iommu.h +++ b/sys/dev/iommu/busdma_iommu.h @@ -54,6 +54,9 @@ struct bus_dmamap_iommu { bool locked; bool cansleep; int flags; +#ifdef KMSAN + struct memdesc kmsan_mem; +#endif }; #define BUS_DMAMAP_IOMMU_MALLOC 0x0001 diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c index a7ad30e77715..909750112a96 100644 --- a/sys/kern/subr_bus_dma.c +++ b/sys/kern/subr_bus_dma.c @@ -408,6 +408,11 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, int error; int nsegs; +#ifdef KMSAN + mem = memdesc_vaddr(buf, buflen); + _bus_dmamap_load_kmsan(dmat, map, &mem); +#endif + if ((flags & BUS_DMA_NOWAIT) == 0) { mem = memdesc_vaddr(buf, buflen); _bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg); @@ -449,6 +454,11 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, M_ASSERTPKTHDR(m0); +#ifdef KMSAN + struct memdesc mem = memdesc_mbuf(m0); + _bus_dmamap_load_kmsan(dmat, map, &mem); +#endif + flags |= BUS_DMA_NOWAIT; nsegs = -1; error = _bus_dmamap_load_mbuf_sg(dmat, map, m0, NULL, &nsegs, flags); @@ -471,6 +481,11 @@ bus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, { int error; +#ifdef KMSAN + struct memdesc mem = memdesc_mbuf(m0); + _bus_dmamap_load_kmsan(dmat, map, &mem); +#endif + flags |= BUS_DMA_NOWAIT; *nsegs = -1; error = _bus_dmamap_load_mbuf_sg(dmat, map, m0, segs, nsegs, flags); @@ -486,6 +501,11 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, struct uio *uio, bus_dma_segment_t *segs; int nsegs, error; +#ifdef KMSAN + struct memdesc mem = memdesc_uio(uio); + _bus_dmamap_load_kmsan(dmat, map, &mem); +#endif + flags |= BUS_DMA_NOWAIT; nsegs = -1; error = _bus_dmamap_load_uio(dmat, map, uio, &nsegs, flags); @@ -513,6 +533,11 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat, bus_dmamap_t map, union ccb *ccb, int error; int nsegs; +#ifdef KMSAN + mem = memdesc_ccb(ccb); + _bus_dmamap_load_kmsan(dmat, map, &mem); +#endif + ccb_h = &ccb->ccb_h; if ((ccb_h->flags & CAM_DIR_MASK) == CAM_DIR_NONE) { callback(callback_arg, NULL, 0, 0); @@ -557,6 +582,11 @@ bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, int error; int nsegs; +#ifdef KMSAN + mem = memdesc_bio(bio); + _bus_dmamap_load_kmsan(dmat, map, &mem); +#endif + if ((flags & BUS_DMA_NOWAIT) == 0) { mem = memdesc_bio(bio); _bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg); @@ -595,6 +625,10 @@ bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map, int error; int nsegs; +#ifdef KMSAN + _bus_dmamap_load_kmsan(dmat, map, mem); +#endif + if ((flags & BUS_DMA_NOWAIT) == 0) _bus_dmamap_waitok(dmat, map, mem, callback, callback_arg); diff --git a/sys/x86/include/bus_dma.h b/sys/x86/include/bus_dma.h index c7d5ce2bc268..593fd4d1ea7a 100644 --- a/sys/x86/include/bus_dma.h +++ b/sys/x86/include/bus_dma.h @@ -191,4 +191,16 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map, return (tc->impl->map_complete(dmat, map, segs, nsegs, error)); } +#ifdef KMSAN +static inline void +_bus_dmamap_load_kmsan(bus_dma_tag_t dmat, bus_dmamap_t map, + struct memdesc *mem) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->load_kmsan(map, mem)); +} +#endif + #endif /* !_X86_BUS_DMA_H_ */ diff --git a/sys/x86/include/busdma_impl.h b/sys/x86/include/busdma_impl.h index c48d98ddfe71..9ae75095821a 100644 --- a/sys/x86/include/busdma_impl.h +++ b/sys/x86/include/busdma_impl.h @@ -84,6 +84,9 @@ struct bus_dma_impl { void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map); void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op); +#ifdef KMSAN + void (*load_kmsan)(bus_dmamap_t map, struct memdesc *mem); +#endif }; void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op); diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c index d89d4d5a17ff..53ec6a3cab96 100644 --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -129,6 +130,9 @@ struct bus_dmamap { bus_dmamap_callback_t *callback; void *callback_arg; STAILQ_ENTRY(bus_dmamap) links; +#ifdef KMSAN + struct memdesc kmsan_mem; +#endif }; static STAILQ_HEAD(, bus_dmamap) bounce_map_waitinglist; @@ -203,6 +207,14 @@ bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, newtag->map_count = 0; newtag->segments = NULL; +#ifdef KMSAN + /* + * When KMSAN is configured, we need a map to store a memory descriptor + * which can be used for validation. + */ + newtag->bounce_flags |= BUS_DMA_FORCE_MAP; +#endif + if (parent != NULL && (newtag->common.filter != NULL || (parent->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0)) newtag->bounce_flags |= BUS_DMA_COULD_BOUNCE; @@ -975,7 +987,10 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t datavaddr, tempvaddr; bus_size_t datacount1, datacount2; - if (map == NULL || (bpage = STAILQ_FIRST(&map->bpages)) == NULL) + if (map == NULL) + goto out; + kmsan_bus_dmamap_sync(&map->kmsan_mem, op); + if ((bpage = STAILQ_FIRST(&map->bpages)) == NULL) goto out; /* @@ -1070,6 +1085,16 @@ out: atomic_thread_fence_rel(); } +#ifdef KMSAN +static void +bounce_bus_dmamap_load_kmsan(bus_dmamap_t map, struct memdesc *mem) +{ + if (map == NULL) + return; + memcpy(&map->kmsan_mem, mem, sizeof(map->kmsan_mem)); +} +#endif + static void init_bounce_pages(void *dummy __unused) { @@ -1351,4 +1376,7 @@ struct bus_dma_impl bus_dma_bounce_impl = { .map_complete = bounce_bus_dmamap_complete, .map_unload = bounce_bus_dmamap_unload, .map_sync = bounce_bus_dmamap_sync, +#ifdef KMSAN + .load_kmsan = bounce_bus_dmamap_load_kmsan, +#endif }; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:57:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE18B67328B; Wed, 11 Aug 2021 01:57: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 4GktJ35ZXHz3R9R; Wed, 11 Aug 2021 01:57: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 9D2F226A81; Wed, 11 Aug 2021 01:57: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 17B1vtEp079991; Wed, 11 Aug 2021 01:57:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1vtEL079990; Wed, 11 Aug 2021 01:57:55 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:57:55 GMT Message-Id: <202108110157.17B1vtEL079990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: f45271340836 - stable/13 - socket: Implement SO_RERROR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f45271340836769d53320d6dbcf63226bb4e39e3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:57:55 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=f45271340836769d53320d6dbcf63226bb4e39e3 commit f45271340836769d53320d6dbcf63226bb4e39e3 Author: Roy Marples AuthorDate: 2021-07-28 15:46:59 +0000 Commit: Kevin Bowling CommitDate: 2021-08-11 01:54:00 +0000 socket: Implement SO_RERROR SO_RERROR indicates that receive buffer overflows should be handled as errors. Historically receive buffer overflows have been ignored and programs could not tell if they missed messages or messages had been truncated because of overflows. Since programs historically do not expect to get receive overflow errors, this behavior is not the default. This is really really important for programs that use route(4) to keep in sync with the system. If we loose a message then we need to reload the full system state, otherwise the behaviour from that point is undefined and can lead to chasing bogus bug reports. Reviewed by: philip (network), kbowling (transport), gbe (manpages) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26652 (cherry picked from commit 7045b1603bdf054145dd958a4acc17b410fb62a0) --- lib/libc/sys/getsockopt.2 | 10 +++++++- sbin/route/route.c | 13 +++++++++- sys/kern/uipc_sockbuf.c | 24 +++++++++++++++++ sys/kern/uipc_socket.c | 30 ++++++++++++++++------ sys/kern/uipc_usrreq.c | 2 +- sys/net/raw_usrreq.c | 11 ++++---- .../bluetooth/socket/ng_btsocket_hci_raw.c | 1 + sys/netgraph/ng_socket.c | 2 +- sys/netinet/ip_divert.c | 2 +- sys/netinet/ip_mroute.c | 2 +- sys/netinet/raw_ip.c | 3 +-- sys/netinet/udp_usrreq.c | 2 +- sys/netinet6/icmp6.c | 6 ++--- sys/netinet6/ip6_input.c | 1 + sys/netinet6/ip6_mroute.c | 3 ++- sys/netinet6/raw_ip6.c | 2 ++ sys/netinet6/send.c | 2 +- sys/netinet6/udp6_usrreq.c | 2 +- sys/netipsec/keysock.c | 10 ++++---- sys/sys/socket.h | 1 + sys/sys/socketvar.h | 6 ++++- 21 files changed, 100 insertions(+), 35 deletions(-) diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index 1e4ed6827170..3ff971a0e5db 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -28,7 +28,7 @@ .\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95 .\" $FreeBSD$ .\" -.Dd June 3, 2020 +.Dd February 8, 2021 .Dt GETSOCKOPT 2 .Os .Sh NAME @@ -177,6 +177,7 @@ for the socket .It Dv SO_PROTOCOL Ta "get the protocol number for the socket (get only)" .It Dv SO_PROTOTYPE Ta "SunOS alias for the Linux SO_PROTOCOL (get only)" .It Dv SO_ERROR Ta "get and clear error on the socket (get only)" +.It Dv SO_RERROR Ta "enables receive error reporting" .It Dv SO_SETFIB Ta "set the associated FIB (routing table) for the socket (set only)" .El .Pp @@ -514,6 +515,13 @@ returns any pending error on the socket and clears the error status. It may be used to check for asynchronous errors on connected datagram sockets or for other asynchronous errors. +.Dv SO_RERROR +indicates that receive buffer overflows should be handled as errors. +Historically receive buffer overflows have been ignored and programs +could not tell if they missed messages or messages had been truncated +because of overflows. +Since programs historically do not expect to get receive overflow errors, +this behavior is not the default. .Pp .Dv SO_LABEL returns the MAC label of the socket. diff --git a/sbin/route/route.c b/sbin/route/route.c index 51a0c68746a6..b16fb6d17a08 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1444,9 +1444,20 @@ monitor(int argc, char *argv[]) interfaces(); exit(0); } + +#ifdef SO_RERROR + n = 1; + if (setsockopt(s, SOL_SOCKET, SO_RERROR, &n, sizeof(n)) == -1) + warn("SO_RERROR"); +#endif + for (;;) { time_t now; - n = read(s, msg, 2048); + n = read(s, msg, sizeof(msg)); + if (n == -1) { + warn("read"); + continue; + } now = time(NULL); (void)printf("\ngot message of size %d on %s", n, ctime(&now)); print_rtmsg((struct rt_msghdr *)(void *)msg, n); diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 2c0e10ee1dc2..b2202fe15192 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -436,6 +436,30 @@ socantrcvmore(struct socket *so) mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); } +void +soroverflow_locked(struct socket *so) +{ + + SOCKBUF_LOCK_ASSERT(&so->so_rcv); + + if (so->so_options & SO_RERROR) { + so->so_rerror = ENOBUFS; + sorwakeup_locked(so); + } else + SOCKBUF_UNLOCK(&so->so_rcv); + + mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); +} + +void +soroverflow(struct socket *so) +{ + + SOCKBUF_LOCK(&so->so_rcv); + soroverflow_locked(so); + mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); +} + /* * Wait for data to arrive at/drain from a socket buffer. */ diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 9f8ad921933b..9f4e2fc64e98 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1948,12 +1948,19 @@ restart: KASSERT(m != NULL || !sbavail(&so->so_rcv), ("receive: m == %p sbavail == %u", m, sbavail(&so->so_rcv))); - if (so->so_error) { + if (so->so_error || so->so_rerror) { if (m != NULL) goto dontblock; - error = so->so_error; - if ((flags & MSG_PEEK) == 0) - so->so_error = 0; + if (so->so_error) + error = so->so_error; + else + error = so->so_rerror; + if ((flags & MSG_PEEK) == 0) { + if (so->so_error) + so->so_error = 0; + else + so->so_rerror = 0; + } SOCKBUF_UNLOCK(&so->so_rcv); goto release; } @@ -2297,7 +2304,7 @@ dontblock: while (flags & MSG_WAITALL && m == NULL && uio->uio_resid > 0 && !sosendallatonce(so) && nextrecord == NULL) { SOCKBUF_LOCK_ASSERT(&so->so_rcv); - if (so->so_error || + if (so->so_error || so->so_rerror || so->so_rcv.sb_state & SBS_CANTRCVMORE) break; /* @@ -3038,6 +3045,7 @@ sosetopt(struct socket *so, struct sockopt *sopt) case SO_NOSIGPIPE: case SO_NO_DDP: case SO_NO_OFFLOAD: + case SO_RERROR: error = sooptcopyin(sopt, &optval, sizeof optval, sizeof optval); if (error) @@ -3259,6 +3267,7 @@ sogetopt(struct socket *so, struct sockopt *sopt) case SO_NOSIGPIPE: case SO_NO_DDP: case SO_NO_OFFLOAD: + case SO_RERROR: optval = so->so_options & sopt->sopt_name; integer: error = sooptcopyout(sopt, &optval, sizeof optval); @@ -3278,8 +3287,13 @@ integer: case SO_ERROR: SOCK_LOCK(so); - optval = so->so_error; - so->so_error = 0; + if (so->so_error) { + optval = so->so_error; + so->so_error = 0; + } else { + optval = so->so_rerror; + so->so_rerror = 0; + } SOCK_UNLOCK(so); goto integer; @@ -3832,7 +3846,7 @@ filt_soread(struct knote *kn, long hint) kn->kn_flags |= EV_EOF; kn->kn_fflags = so->so_error; return (1); - } else if (so->so_error) /* temporary udp error */ + } else if (so->so_error || so->so_rerror) return (1); if (kn->kn_sfflags & NOTE_LOWAT) { diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index a01171424320..3d7daac42001 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1059,7 +1059,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, m = NULL; control = NULL; } else { - SOCKBUF_UNLOCK(&so2->so_rcv); + soroverflow_locked(so2); error = ENOBUFS; } if (nam != NULL) diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index f43de7dae9ca..5d4e223e5a0a 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -100,10 +100,10 @@ raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, n = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (n) { if (sbappendaddr(&last->so_rcv, src, - n, (struct mbuf *)0) == 0) - /* should notify about lost packet */ + n, (struct mbuf *)0) == 0) { + soroverflow(last); m_freem(n); - else + } else sorwakeup(last); } } @@ -111,9 +111,10 @@ raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, } if (last) { if (sbappendaddr(&last->so_rcv, src, - m, (struct mbuf *)0) == 0) + m, (struct mbuf *)0) == 0) { + soroverflow(last); m_freem(m); - else + } else sorwakeup(last); } else m_freem(m); diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c index 5f6b98d03359..c82515f82631 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c @@ -539,6 +539,7 @@ ng_btsocket_hci_raw_data_input(struct mbuf *nam) NG_FREE_M(m); NG_FREE_M(ctl); + soroverflow(pcb->so); } } next: diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index 1c67099a4dc4..05f37579aba1 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -993,7 +993,7 @@ ngs_rcvmsg(node_p node, item_p item, hook_p lasthook) /* Send it up to the socket. */ if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)&addr, m, NULL) == 0) { - SOCKBUF_UNLOCK(&so->so_rcv); + soroverflow_locked(so); TRAP_ERROR; m_freem(m); return (ENOBUFS); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 77a4bfcd08ac..4141386a6a2d 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -295,7 +295,7 @@ divert_packet(struct mbuf *m, bool incoming) if (sbappendaddr_locked(&sa->so_rcv, (struct sockaddr *)&divsrc, m, (struct mbuf *)0) == 0) { - SOCKBUF_UNLOCK(&sa->so_rcv); + soroverflow_locked(sa); sa = NULL; /* force mbuf reclaim below */ } else sorwakeup_locked(sa); diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index b66fe8df0793..6aeea44f631c 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1199,7 +1199,7 @@ socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in *src) sorwakeup_locked(s); return 0; } - SOCKBUF_UNLOCK(&s->so_rcv); + soroverflow_locked(s); } m_freem(mm); return -1; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 996440227145..afbdc14e47c4 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -263,11 +263,10 @@ rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n, SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)ripsrc, n, opts) == 0) { - /* should notify about lost packet */ + soroverflow_locked(so); m_freem(n); if (opts) m_freem(opts); - SOCKBUF_UNLOCK(&so->so_rcv); } else sorwakeup_locked(so); } else diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 5c9dbd36a1d6..ed79ddce5109 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -379,7 +379,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off, so = inp->inp_socket; SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) { - SOCKBUF_UNLOCK(&so->so_rcv); + soroverflow(so); m_freem(n); if (opts) m_freem(opts); diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index e17f82a54951..6b8f0f7be5bb 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1974,13 +1974,11 @@ icmp6_rip6_input(struct mbuf **mp, int off) &last->inp_socket->so_rcv, (struct sockaddr *)&fromsa, n, opts) == 0) { - /* should notify about lost packet */ + soroverflow_locked(last->inp_socket); m_freem(n); if (opts) { m_freem(opts); } - SOCKBUF_UNLOCK( - &last->inp_socket->so_rcv); } else sorwakeup_locked(last->inp_socket); opts = NULL; @@ -2020,7 +2018,7 @@ icmp6_rip6_input(struct mbuf **mp, int off) m_freem(m); if (opts) m_freem(opts); - SOCKBUF_UNLOCK(&last->inp_socket->so_rcv); + soroverflow_locked(last->inp_socket); } else sorwakeup_locked(last->inp_socket); INP_RUNLOCK(last); diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 9ea578f88417..30ad9a53006a 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1575,6 +1575,7 @@ ip6_notify_pmtu(struct inpcb *inp, struct sockaddr_in6 *dst, u_int32_t mtu) so = inp->inp_socket; if (sbappendaddr(&so->so_rcv, (struct sockaddr *)dst, NULL, m_mtu) == 0) { + soroverflow(so); m_freem(m_mtu); /* XXX: should count statistics */ } else diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index d2277e41110c..503c83490940 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1038,7 +1038,8 @@ socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in6 *src) mm, (struct mbuf *)0) != 0) { sorwakeup(s); return (0); - } + } else + soroverflow(s); } m_freem(mm); return (-1); diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index a369abb04bfc..3e3df65a0e12 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -214,6 +214,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto) if (sbappendaddr(&last->inp_socket->so_rcv, (struct sockaddr *)&fromsa, n, opts) == 0) { + soroverflow(last->inp_socket); m_freem(n); if (opts) m_freem(opts); @@ -325,6 +326,7 @@ skip_2: m_adj(m, *offp); if (sbappendaddr(&last->inp_socket->so_rcv, (struct sockaddr *)&fromsa, m, opts) == 0) { + soroverflow(last->inp_socket); m_freem(m); if (opts) m_freem(opts); diff --git a/sys/netinet6/send.c b/sys/netinet6/send.c index 0a2b3c65aab4..a69afd7b5ed6 100644 --- a/sys/netinet6/send.c +++ b/sys/netinet6/send.c @@ -309,7 +309,7 @@ send_input(struct mbuf *m, struct ifnet *ifp, int direction, int msglen __unused SOCKBUF_LOCK(&V_send_so->so_rcv); if (sbappendaddr_locked(&V_send_so->so_rcv, (struct sockaddr *)&sendsrc, m, NULL) == 0) { - SOCKBUF_UNLOCK(&V_send_so->so_rcv); + soroverflow_locked(V_send_so); /* XXX stats. */ m_freem(m); } else { diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 7c573d095d77..816e3bdd2850 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -197,7 +197,7 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off, SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)&fromsa[0], n, opts) == 0) { - SOCKBUF_UNLOCK(&so->so_rcv); + soroverflow_locked(so); m_freem(n); if (opts) m_freem(opts); diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index 317eb53289cf..aa893b131a57 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -141,7 +141,6 @@ end: static int key_sendup0(struct rawcb *rp, struct mbuf *m, int promisc) { - int error; if (promisc) { struct sadb_msg *pmsg; @@ -165,11 +164,12 @@ key_sendup0(struct rawcb *rp, struct mbuf *m, int promisc) m, NULL)) { PFKEYSTAT_INC(in_nomem); m_freem(m); - error = ENOBUFS; - } else - error = 0; + soroverflow(rp->rcb_socket); + return ENOBUFS; + } + sorwakeup(rp->rcb_socket); - return error; + return 0; } /* so can be NULL if target != KEY_SENDUP_ONE */ diff --git a/sys/sys/socket.h b/sys/sys/socket.h index d9256fd7544a..2cb76f9c6d63 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -147,6 +147,7 @@ typedef __uintptr_t uintptr_t; #define SO_NO_OFFLOAD 0x00004000 /* socket cannot be offloaded */ #define SO_NO_DDP 0x00008000 /* disable direct data placement */ #define SO_REUSEPORT_LB 0x00010000 /* reuse with load balancing */ +#define SO_RERROR 0x00020000 /* keep track of receive errors */ /* * Additional options, not kept in so_options. diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index dbd9804a980d..47033fdabbfa 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -100,6 +100,7 @@ struct socket { struct protosw *so_proto; /* (a) protocol handle */ short so_timeo; /* (g) connection timeout */ u_short so_error; /* (f) error affecting connection */ + u_short so_rerror; /* (f) error affecting connection */ struct sigio *so_sigio; /* [sg] information for async I/O or out of band data (SIGURG) */ struct ucred *so_cred; /* (a) user credentials */ @@ -266,7 +267,8 @@ struct socket { /* can we read something from so? */ #define soreadabledata(so) \ - (sbavail(&(so)->so_rcv) >= (so)->so_rcv.sb_lowat || (so)->so_error) + (sbavail(&(so)->so_rcv) >= (so)->so_rcv.sb_lowat || \ + (so)->so_error || (so)->so_rerror) #define soreadable(so) \ (soreadabledata(so) || ((so)->so_rcv.sb_state & SBS_CANTRCVMORE)) @@ -480,6 +482,8 @@ void socantrcvmore(struct socket *so); void socantrcvmore_locked(struct socket *so); void socantsendmore(struct socket *so); void socantsendmore_locked(struct socket *so); +void soroverflow(struct socket *so); +void soroverflow_locked(struct socket *so); /* * Accept filter functions (duh). From owner-dev-commits-src-all@freebsd.org Wed Aug 11 01:57:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E0B5567328E; Wed, 11 Aug 2021 01:57: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 4GktJ460Q2z3R7N; Wed, 11 Aug 2021 01:57: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 B5354266CF; Wed, 11 Aug 2021 01:57: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 17B1vuSL080015; Wed, 11 Aug 2021 01:57:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B1vuNo080014; Wed, 11 Aug 2021 01:57:56 GMT (envelope-from git) Date: Wed, 11 Aug 2021 01:57:56 GMT Message-Id: <202108110157.17B1vuNo080014@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 2141aab35b70 - stable/13 - udp: Fix soroverflow SOCKBUF unlocking MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2141aab35b70b0bf29d6ff9bd39d0cf7e2bd7e11 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 01:57:57 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=2141aab35b70b0bf29d6ff9bd39d0cf7e2bd7e11 commit 2141aab35b70b0bf29d6ff9bd39d0cf7e2bd7e11 Author: Konstantin Kukushkin AuthorDate: 2021-08-01 14:41:38 +0000 Commit: Kevin Bowling CommitDate: 2021-08-11 01:54:18 +0000 udp: Fix soroverflow SOCKBUF unlocking We hold the SOCKBUF_LOCK so use soroverflow_locked here. This bug may manifest as a non-killable process stuck in [*so_rcv]. Approved by: scottl Reviewed by: Roy Marples Fixes: 7045b1603bdf MFC after: 10 days Differential Revision: https://reviews.freebsd.org/D31374 (cherry picked from commit a61c24ddb7d677337d6184ffcee34a6e902d72d7) --- sys/netinet/udp_usrreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index ed79ddce5109..76ed063391eb 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -379,7 +379,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off, so = inp->inp_socket; SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) { - soroverflow(so); + soroverflow_locked(so); m_freem(n); if (opts) m_freem(opts); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 02:18:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7FC6167358E; Wed, 11 Aug 2021 02:18: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 4Gktlv2tFhz3hWY; Wed, 11 Aug 2021 02:18: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 4748B2684A; Wed, 11 Aug 2021 02:18: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 17B2IZZu006959; Wed, 11 Aug 2021 02:18:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B2IZ1q006958; Wed, 11 Aug 2021 02:18:35 GMT (envelope-from git) Date: Wed, 11 Aug 2021 02:18:35 GMT Message-Id: <202108110218.17B2IZ1q006958@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 67f508db84b8 - main - Mark some sysctls as CTLFLAG_MPSAFE. 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/main X-Git-Reftype: branch X-Git-Commit: 67f508db84b8b789db37c60972f255574417b8ed Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 02:18:35 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=67f508db84b8b789db37c60972f255574417b8ed commit 67f508db84b8b789db37c60972f255574417b8ed Author: Alexander Motin AuthorDate: 2021-08-11 02:17:53 +0000 Commit: Alexander Motin CommitDate: 2021-08-11 02:18:26 +0000 Mark some sysctls as CTLFLAG_MPSAFE. MFC after: 2 weeks --- sys/kern/kern_intr.c | 4 ++-- sys/kern/kern_shutdown.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index afaf8466a1df..1660414a50ef 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -1612,7 +1612,7 @@ sysctl_intrnames(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_hw, OID_AUTO, intrnames, - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_intrnames, "", "Interrupt Names"); @@ -1641,7 +1641,7 @@ sysctl_intrcnt(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_hw, OID_AUTO, intrcnt, - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_intrcnt, "", "Interrupt Counts"); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index e200b6d8a4b4..fb2a69401801 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -740,7 +740,7 @@ SYSCTL_INT(_debug_kassert, OID_AUTO, suppress_in_panic, KASSERT_RWTUN, static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_debug_kassert, OID_AUTO, kassert, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_MPSAFE, NULL, 0, kassert_sysctl_kassert, "I", "set to trigger a test kassert"); @@ -1021,7 +1021,7 @@ dumpdevname_sysctl_handler(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_kern_shutdown, OID_AUTO, dumpdevname, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, &dumper_configs, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, &dumper_configs, 0, dumpdevname_sysctl_handler, "A", "Device(s) for kernel dumps"); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 02:34:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B543867335F; Wed, 11 Aug 2021 02: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 4Gkv694jQGz3j4V; Wed, 11 Aug 2021 02: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 85F1D27205; Wed, 11 Aug 2021 02: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 17B2YPBu033171; Wed, 11 Aug 2021 02: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 17B2YPHT033170; Wed, 11 Aug 2021 02:34:25 GMT (envelope-from git) Date: Wed, 11 Aug 2021 02:34:25 GMT Message-Id: <202108110234.17B2YPHT033170@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 664077e69e8f - stable/12 - socket: Implement SO_RERROR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 664077e69e8f300cd0218e3c700ee235df12fcff Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 02:34:25 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=664077e69e8f300cd0218e3c700ee235df12fcff commit 664077e69e8f300cd0218e3c700ee235df12fcff Author: Roy Marples AuthorDate: 2021-07-28 15:46:59 +0000 Commit: Kevin Bowling CommitDate: 2021-08-11 01:59:36 +0000 socket: Implement SO_RERROR SO_RERROR indicates that receive buffer overflows should be handled as errors. Historically receive buffer overflows have been ignored and programs could not tell if they missed messages or messages had been truncated because of overflows. Since programs historically do not expect to get receive overflow errors, this behavior is not the default. This is really really important for programs that use route(4) to keep in sync with the system. If we loose a message then we need to reload the full system state, otherwise the behaviour from that point is undefined and can lead to chasing bogus bug reports. Reviewed by: philip (network), kbowling (transport), gbe (manpages) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26652 (cherry picked from commit 7045b1603bdf054145dd958a4acc17b410fb62a0) --- lib/libc/sys/getsockopt.2 | 10 +++++++- sbin/route/route.c | 13 +++++++++- sys/kern/uipc_sockbuf.c | 24 +++++++++++++++++ sys/kern/uipc_socket.c | 30 ++++++++++++++++------ sys/kern/uipc_usrreq.c | 2 +- sys/net/raw_usrreq.c | 11 ++++---- .../bluetooth/socket/ng_btsocket_hci_raw.c | 1 + sys/netgraph/ng_socket.c | 2 +- sys/netinet/ip_divert.c | 2 +- sys/netinet/ip_mroute.c | 2 +- sys/netinet/raw_ip.c | 3 +-- sys/netinet/udp_usrreq.c | 2 +- sys/netinet6/icmp6.c | 6 ++--- sys/netinet6/ip6_input.c | 1 + sys/netinet6/ip6_mroute.c | 3 ++- sys/netinet6/raw_ip6.c | 2 ++ sys/netinet6/send.c | 2 +- sys/netinet6/udp6_usrreq.c | 2 +- sys/netipsec/keysock.c | 10 ++++---- sys/sys/socket.h | 1 + sys/sys/socketvar.h | 6 ++++- 21 files changed, 100 insertions(+), 35 deletions(-) diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index dcd39e07efb8..b27f663f01bd 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -28,7 +28,7 @@ .\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95 .\" $FreeBSD$ .\" -.Dd June 03, 2020 +.Dd February 8, 2021 .Dt GETSOCKOPT 2 .Os .Sh NAME @@ -177,6 +177,7 @@ for the socket .It Dv SO_PROTOCOL Ta "get the protocol number for the socket (get only)" .It Dv SO_PROTOTYPE Ta "SunOS alias for the Linux SO_PROTOCOL (get only)" .It Dv SO_ERROR Ta "get and clear error on the socket (get only)" +.It Dv SO_RERROR Ta "enables receive error reporting" .It Dv SO_SETFIB Ta "set the associated FIB (routing table) for the socket (set only)" .El .Pp @@ -513,6 +514,13 @@ returns any pending error on the socket and clears the error status. It may be used to check for asynchronous errors on connected datagram sockets or for other asynchronous errors. +.Dv SO_RERROR +indicates that receive buffer overflows should be handled as errors. +Historically receive buffer overflows have been ignored and programs +could not tell if they missed messages or messages had been truncated +because of overflows. +Since programs historically do not expect to get receive overflow errors, +this behavior is not the default. .Pp .Dv SO_LABEL returns the MAC label of the socket. diff --git a/sbin/route/route.c b/sbin/route/route.c index 9c9e4b304848..14d1fe274ad3 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1485,9 +1485,20 @@ monitor(int argc, char *argv[]) interfaces(); exit(0); } + +#ifdef SO_RERROR + n = 1; + if (setsockopt(s, SOL_SOCKET, SO_RERROR, &n, sizeof(n)) == -1) + warn("SO_RERROR"); +#endif + for (;;) { time_t now; - n = read(s, msg, 2048); + n = read(s, msg, sizeof(msg)); + if (n == -1) { + warn("read"); + continue; + } now = time(NULL); (void)printf("\ngot message of size %d on %s", n, ctime(&now)); print_rtmsg((struct rt_msghdr *)(void *)msg, n); diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 598fc05f2fcf..92b6d728fcd8 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -254,6 +254,30 @@ socantrcvmore(struct socket *so) mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); } +void +soroverflow_locked(struct socket *so) +{ + + SOCKBUF_LOCK_ASSERT(&so->so_rcv); + + if (so->so_options & SO_RERROR) { + so->so_rerror = ENOBUFS; + sorwakeup_locked(so); + } else + SOCKBUF_UNLOCK(&so->so_rcv); + + mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); +} + +void +soroverflow(struct socket *so) +{ + + SOCKBUF_LOCK(&so->so_rcv); + soroverflow_locked(so); + mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); +} + /* * Wait for data to arrive at/drain from a socket buffer. */ diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index dd028c660d2b..620d81246062 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1771,12 +1771,19 @@ restart: KASSERT(m != NULL || !sbavail(&so->so_rcv), ("receive: m == %p sbavail == %u", m, sbavail(&so->so_rcv))); - if (so->so_error) { + if (so->so_error || so->so_rerror) { if (m != NULL) goto dontblock; - error = so->so_error; - if ((flags & MSG_PEEK) == 0) - so->so_error = 0; + if (so->so_error) + error = so->so_error; + else + error = so->so_rerror; + if ((flags & MSG_PEEK) == 0) { + if (so->so_error) + so->so_error = 0; + else + so->so_rerror = 0; + } SOCKBUF_UNLOCK(&so->so_rcv); goto release; } @@ -2084,7 +2091,7 @@ dontblock: while (flags & MSG_WAITALL && m == NULL && uio->uio_resid > 0 && !sosendallatonce(so) && nextrecord == NULL) { SOCKBUF_LOCK_ASSERT(&so->so_rcv); - if (so->so_error || + if (so->so_error || so->so_rerror || so->so_rcv.sb_state & SBS_CANTRCVMORE) break; /* @@ -2805,6 +2812,7 @@ sosetopt(struct socket *so, struct sockopt *sopt) case SO_NOSIGPIPE: case SO_NO_DDP: case SO_NO_OFFLOAD: + case SO_RERROR: error = sooptcopyin(sopt, &optval, sizeof optval, sizeof optval); if (error) @@ -3026,6 +3034,7 @@ sogetopt(struct socket *so, struct sockopt *sopt) case SO_NOSIGPIPE: case SO_NO_DDP: case SO_NO_OFFLOAD: + case SO_RERROR: optval = so->so_options & sopt->sopt_name; integer: error = sooptcopyout(sopt, &optval, sizeof optval); @@ -3045,8 +3054,13 @@ integer: case SO_ERROR: SOCK_LOCK(so); - optval = so->so_error; - so->so_error = 0; + if (so->so_error) { + optval = so->so_error; + so->so_error = 0; + } else { + optval = so->so_rerror; + so->so_rerror = 0; + } SOCK_UNLOCK(so); goto integer; @@ -3595,7 +3609,7 @@ filt_soread(struct knote *kn, long hint) kn->kn_flags |= EV_EOF; kn->kn_fflags = so->so_error; return (1); - } else if (so->so_error) /* temporary udp error */ + } else if (so->so_error || so->so_rerror) return (1); if (kn->kn_sfflags & NOTE_LOWAT) { diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 25f27837d6d5..329e4346c425 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1047,7 +1047,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, m = NULL; control = NULL; } else { - SOCKBUF_UNLOCK(&so2->so_rcv); + soroverflow_locked(so2); error = ENOBUFS; } if (nam != NULL) diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index f43de7dae9ca..5d4e223e5a0a 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -100,10 +100,10 @@ raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, n = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (n) { if (sbappendaddr(&last->so_rcv, src, - n, (struct mbuf *)0) == 0) - /* should notify about lost packet */ + n, (struct mbuf *)0) == 0) { + soroverflow(last); m_freem(n); - else + } else sorwakeup(last); } } @@ -111,9 +111,10 @@ raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, } if (last) { if (sbappendaddr(&last->so_rcv, src, - m, (struct mbuf *)0) == 0) + m, (struct mbuf *)0) == 0) { + soroverflow(last); m_freem(m); - else + } else sorwakeup(last); } else m_freem(m); diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c index 9523d88af633..a78905705fd0 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c @@ -539,6 +539,7 @@ ng_btsocket_hci_raw_data_input(struct mbuf *nam) NG_FREE_M(m); NG_FREE_M(ctl); + soroverflow(pcb->so); } } next: diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index 08ee76300ae8..a10993a8fab6 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -974,7 +974,7 @@ ngs_rcvmsg(node_p node, item_p item, hook_p lasthook) /* Send it up to the socket. */ if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)&addr, m, NULL) == 0) { - SOCKBUF_UNLOCK(&so->so_rcv); + soroverflow_locked(so); TRAP_ERROR; m_freem(m); return (ENOBUFS); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 81e70177e641..54cd0f509b51 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -287,7 +287,7 @@ divert_packet(struct mbuf *m, int incoming) if (sbappendaddr_locked(&sa->so_rcv, (struct sockaddr *)&divsrc, m, (struct mbuf *)0) == 0) { - SOCKBUF_UNLOCK(&sa->so_rcv); + soroverflow_locked(sa); sa = NULL; /* force mbuf reclaim below */ } else sorwakeup_locked(sa); diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index d024cdb16772..60b18cdbd35c 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1195,7 +1195,7 @@ socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in *src) sorwakeup_locked(s); return 0; } - SOCKBUF_UNLOCK(&s->so_rcv); + soroverflow_locked(s); } m_freem(mm); return -1; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index f15a3bca3a90..84dd4d7a764c 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -261,11 +261,10 @@ rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n, SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)ripsrc, n, opts) == 0) { - /* should notify about lost packet */ + soroverflow_locked(so); m_freem(n); if (opts) m_freem(opts); - SOCKBUF_UNLOCK(&so->so_rcv); } else sorwakeup_locked(so); } else diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index c271392c225d..2a5e8fdd25c2 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -376,7 +376,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off, so = inp->inp_socket; SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) { - SOCKBUF_UNLOCK(&so->so_rcv); + soroverflow(so); m_freem(n); if (opts) m_freem(opts); diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 75e7ef7c2039..923f5dd63ddc 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1976,13 +1976,11 @@ icmp6_rip6_input(struct mbuf **mp, int off) &last->inp_socket->so_rcv, (struct sockaddr *)&fromsa, n, opts) == 0) { - /* should notify about lost packet */ + soroverflow_locked(last->inp_socket); m_freem(n); if (opts) { m_freem(opts); } - SOCKBUF_UNLOCK( - &last->inp_socket->so_rcv); } else sorwakeup_locked(last->inp_socket); opts = NULL; @@ -2023,7 +2021,7 @@ icmp6_rip6_input(struct mbuf **mp, int off) m_freem(m); if (opts) m_freem(opts); - SOCKBUF_UNLOCK(&last->inp_socket->so_rcv); + soroverflow_locked(last->inp_socket); } else sorwakeup_locked(last->inp_socket); INP_RUNLOCK(last); diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 74d275f7e66e..9ef4620565a1 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1579,6 +1579,7 @@ ip6_notify_pmtu(struct inpcb *inp, struct sockaddr_in6 *dst, u_int32_t mtu) so = inp->inp_socket; if (sbappendaddr(&so->so_rcv, (struct sockaddr *)dst, NULL, m_mtu) == 0) { + soroverflow(so); m_freem(m_mtu); /* XXX: should count statistics */ } else diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 82ca908d4553..bce491d7fa5b 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1039,7 +1039,8 @@ socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in6 *src) mm, (struct mbuf *)0) != 0) { sorwakeup(s); return (0); - } + } else + soroverflow(s); } m_freem(mm); return (-1); diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 304ee4a8899b..47e106f02651 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -212,6 +212,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto) if (sbappendaddr(&last->inp_socket->so_rcv, (struct sockaddr *)&fromsa, n, opts) == 0) { + soroverflow(last->inp_socket); m_freem(n); if (opts) m_freem(opts); @@ -324,6 +325,7 @@ skip_2: m_adj(m, *offp); if (sbappendaddr(&last->inp_socket->so_rcv, (struct sockaddr *)&fromsa, m, opts) == 0) { + soroverflow(last->inp_socket); m_freem(m); if (opts) m_freem(opts); diff --git a/sys/netinet6/send.c b/sys/netinet6/send.c index bc9880c82267..8458ef367cba 100644 --- a/sys/netinet6/send.c +++ b/sys/netinet6/send.c @@ -291,7 +291,7 @@ send_input(struct mbuf *m, struct ifnet *ifp, int direction, int msglen __unused SOCKBUF_LOCK(&V_send_so->so_rcv); if (sbappendaddr_locked(&V_send_so->so_rcv, (struct sockaddr *)&sendsrc, m, NULL) == 0) { - SOCKBUF_UNLOCK(&V_send_so->so_rcv); + soroverflow_locked(V_send_so); /* XXX stats. */ m_freem(m); } else { diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 98588e48c511..02d4359dc92f 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -191,7 +191,7 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off, SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)&fromsa[0], n, opts) == 0) { - SOCKBUF_UNLOCK(&so->so_rcv); + soroverflow_locked(so); m_freem(n); if (opts) m_freem(opts); diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index a216f085c1bc..84a65967eea2 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -141,7 +141,6 @@ end: static int key_sendup0(struct rawcb *rp, struct mbuf *m, int promisc) { - int error; if (promisc) { struct sadb_msg *pmsg; @@ -165,11 +164,12 @@ key_sendup0(struct rawcb *rp, struct mbuf *m, int promisc) m, NULL)) { PFKEYSTAT_INC(in_nomem); m_freem(m); - error = ENOBUFS; - } else - error = 0; + soroverflow(rp->rcb_socket); + return ENOBUFS; + } + sorwakeup(rp->rcb_socket); - return error; + return 0; } /* so can be NULL if target != KEY_SENDUP_ONE */ diff --git a/sys/sys/socket.h b/sys/sys/socket.h index eaad9b1bacdb..17a5099424f4 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -147,6 +147,7 @@ typedef __uintptr_t uintptr_t; #define SO_NO_OFFLOAD 0x00004000 /* socket cannot be offloaded */ #define SO_NO_DDP 0x00008000 /* disable direct data placement */ #define SO_REUSEPORT_LB 0x00010000 /* reuse with load balancing */ +#define SO_RERROR 0x00020000 /* keep track of receive errors */ /* * Additional options, not kept in so_options. diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 99d8839f8beb..99d2d554143e 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -99,6 +99,7 @@ struct socket { struct protosw *so_proto; /* (a) protocol handle */ short so_timeo; /* (g) connection timeout */ u_short so_error; /* (f) error affecting connection */ + u_short so_rerror; /* (f) error affecting connection */ struct sigio *so_sigio; /* [sg] information for async I/O or out of band data (SIGURG) */ struct ucred *so_cred; /* (a) user credentials */ @@ -258,7 +259,8 @@ struct socket { /* can we read something from so? */ #define soreadabledata(so) \ - (sbavail(&(so)->so_rcv) >= (so)->so_rcv.sb_lowat || (so)->so_error) + (sbavail(&(so)->so_rcv) >= (so)->so_rcv.sb_lowat || \ + (so)->so_error || (so)->so_rerror) #define soreadable(so) \ (soreadabledata(so) || ((so)->so_rcv.sb_state & SBS_CANTRCVMORE)) @@ -471,6 +473,8 @@ void socantrcvmore(struct socket *so); void socantrcvmore_locked(struct socket *so); void socantsendmore(struct socket *so); void socantsendmore_locked(struct socket *so); +void soroverflow(struct socket *so); +void soroverflow_locked(struct socket *so); /* * Accept filter functions (duh). From owner-dev-commits-src-all@freebsd.org Wed Aug 11 02:34:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD1C8673722; Wed, 11 Aug 2021 02: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 4Gkv6B5N3Nz3j4X; Wed, 11 Aug 2021 02: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 A07A227301; Wed, 11 Aug 2021 02: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 17B2YQ4N033195; Wed, 11 Aug 2021 02: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 17B2YQBm033194; Wed, 11 Aug 2021 02:34:26 GMT (envelope-from git) Date: Wed, 11 Aug 2021 02:34:26 GMT Message-Id: <202108110234.17B2YQBm033194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: ae51594c9794 - stable/12 - udp: Fix soroverflow SOCKBUF unlocking MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ae51594c9794275073c955ad4c6fa7ad9fcc1614 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 02:34:26 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=ae51594c9794275073c955ad4c6fa7ad9fcc1614 commit ae51594c9794275073c955ad4c6fa7ad9fcc1614 Author: Konstantin Kukushkin AuthorDate: 2021-08-01 14:41:38 +0000 Commit: Kevin Bowling CommitDate: 2021-08-11 02:00:09 +0000 udp: Fix soroverflow SOCKBUF unlocking We hold the SOCKBUF_LOCK so use soroverflow_locked here. This bug may manifest as a non-killable process stuck in [*so_rcv]. Approved by: scottl Reviewed by: Roy Marples Fixes: 7045b1603bdf MFC after: 10 days Differential Revision: https://reviews.freebsd.org/D31374 (cherry picked from commit a61c24ddb7d677337d6184ffcee34a6e902d72d7) --- sys/netinet/udp_usrreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 2a5e8fdd25c2..f57a9059a7db 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -376,7 +376,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off, so = inp->inp_socket; SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) { - soroverflow(so); + soroverflow_locked(so); m_freem(n); if (opts) m_freem(opts); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 07:54:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDA11676AB8; Wed, 11 Aug 2021 07:54: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 4Gl2C76Np0z4XSW; Wed, 11 Aug 2021 07:54: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 C3A813272; Wed, 11 Aug 2021 07:54: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 17B7sBCW059887; Wed, 11 Aug 2021 07:54:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B7sB9A059886; Wed, 11 Aug 2021 07:54:11 GMT (envelope-from git) Date: Wed, 11 Aug 2021 07:54:11 GMT Message-Id: <202108110754.17B7sB9A059886@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 809ad8170aa9 - main - ipfw(8): Fix a typo in an error message 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/main X-Git-Reftype: branch X-Git-Commit: 809ad8170aa97e570ef5e1e414b4c25e4b58044c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 07:54:12 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=809ad8170aa97e570ef5e1e414b4c25e4b58044c commit 809ad8170aa97e570ef5e1e414b4c25e4b58044c Author: Gordon Bergling AuthorDate: 2021-08-11 07:53:01 +0000 Commit: Gordon Bergling CommitDate: 2021-08-11 07:53:01 +0000 ipfw(8): Fix a typo in an error message - s/suport/support/ MFC after: 5 days --- sbin/ipfw/ipfw2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index fb1d9a4a180b..deb46fc64e00 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -4127,7 +4127,7 @@ chkarg: action->arg1 = strtoul(*av, NULL, 10); if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1) - errx(EX_DATAERR, "fibs not suported.\n"); + errx(EX_DATAERR, "fibs not supported.\n"); if (action->arg1 >= numfibs) /* Temporary */ errx(EX_DATAERR, "fib too large.\n"); /* Add high-order bit to fib to make room for tablearg*/ From owner-dev-commits-src-all@freebsd.org Wed Aug 11 07:56:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DBF2967702A; Wed, 11 Aug 2021 07:56:01 +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 4Gl2FF5rtrz4XVy; Wed, 11 Aug 2021 07:56: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 B0ED5388E; Wed, 11 Aug 2021 07:56: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 17B7u1Ax060139; Wed, 11 Aug 2021 07:56:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B7u1AS060138; Wed, 11 Aug 2021 07:56:01 GMT (envelope-from git) Date: Wed, 11 Aug 2021 07:56:01 GMT Message-Id: <202108110756.17B7u1AS060138@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 1e1fbf3b47d7 - main - iscontrol(8): Fix a typo in a struct 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/main X-Git-Reftype: branch X-Git-Commit: 1e1fbf3b47d7296896593b1e477141263b0c555f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 07:56:01 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=1e1fbf3b47d7296896593b1e477141263b0c555f commit 1e1fbf3b47d7296896593b1e477141263b0c555f Author: Gordon Bergling AuthorDate: 2021-08-11 07:55:08 +0000 Commit: Gordon Bergling CommitDate: 2021-08-11 07:55:08 +0000 iscontrol(8): Fix a typo in a struct - s/suport/support/ MFC after: 5 days --- sbin/iscontrol/login.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/iscontrol/login.c b/sbin/iscontrol/login.c index 7cb990029047..c4fbc46548e9 100644 --- a/sbin/iscontrol/login.c +++ b/sbin/iscontrol/login.c @@ -59,7 +59,7 @@ static char *status_class1[] = { "Too many connections", "Missing parameter", "Can't include in session", - "Session type not suported", + "Session type not supported", "Session does not exist", "Invalid during login", }; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 07:58:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9275C677292; Wed, 11 Aug 2021 07:58: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 4Gl2JY3jLdz4XCS; Wed, 11 Aug 2021 07:58: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 640A1390A; Wed, 11 Aug 2021 07:58: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 17B7wrQJ060429; Wed, 11 Aug 2021 07:58:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B7wrur060428; Wed, 11 Aug 2021 07:58:53 GMT (envelope-from git) Date: Wed, 11 Aug 2021 07:58:53 GMT Message-Id: <202108110758.17B7wrur060428@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Daniel Engberg Subject: git: 4f3a0cfbde03 - main - Add myself (diizzy) as ports committer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: diizzy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f3a0cfbde03db19bd2c075eadc73e0efbf93820 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 07:58:53 -0000 The branch main has been updated by diizzy (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=4f3a0cfbde03db19bd2c075eadc73e0efbf93820 commit 4f3a0cfbde03db19bd2c075eadc73e0efbf93820 Author: Daniel Engberg AuthorDate: 2021-08-11 07:56:40 +0000 Commit: Daniel Engberg CommitDate: 2021-08-11 07:58:17 +0000 Add myself (diizzy) as ports committer Section 7.1 in Committer's Guide Reviewed by: tcberner Approved by: tcberner Differential Revision: --- share/misc/committers-ports.dot | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/misc/committers-ports.dot b/share/misc/committers-ports.dot index cc600bc03fff..da65d0641dba 100644 --- a/share/misc/committers-ports.dot +++ b/share/misc/committers-ports.dot @@ -96,6 +96,7 @@ decke [label="Bernhard Froehlich\ndecke@FreeBSD.org\n2010/03/21"] delphij [label="Xin Li\ndelphij@FreeBSD.org\n2006/05/01"] demon [label="Dmitry Sivachenko\ndemon@FreeBSD.org\n2000/11/13"] dhn [label="Dennis Herrmann\ndhn@FreeBSD.org\n2009/03/03"] +diizzy [label="Daniel Engberg\ndiizzy@FreeBSD.org\n2021/07/06"] dmgk [label="Dmitri Goutnik\ndmgk@FreeBSD.org\n2019/09/15"] dryice [label="Dryice Dong Liu\ndryice@FreeBSD.org\n2006/12/25"] dteske [label="Devin Teske\ndteske@FreeBSD.org\n2018/03/01"] @@ -329,6 +330,7 @@ araujo -> pclin araujo -> pgollucci araujo -> samm +arrowd -> diizzy arrowd -> rhurlin arrowd -> vishwin @@ -550,6 +552,8 @@ kwm -> zeising lawrance -> itetcu +lbartoletti -> diizzy + leeym -> clsung ler -> leres @@ -763,6 +767,7 @@ tabthorpe -> gblach tcberner -> adridg tcberner -> arrowd +tcberner -> diizzy tcberner -> fernape tcberner -> joneum tcberner -> kai From owner-dev-commits-src-all@freebsd.org Wed Aug 11 09:46:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D34E165094E; Wed, 11 Aug 2021 09:46: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 4Gl4hq5JVhz4jFw; Wed, 11 Aug 2021 09:46: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 9C9EB5130; Wed, 11 Aug 2021 09:46: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 17B9kZJP008827; Wed, 11 Aug 2021 09:46:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17B9kZRV008826; Wed, 11 Aug 2021 09:46:35 GMT (envelope-from git) Date: Wed, 11 Aug 2021 09:46:35 GMT Message-Id: <202108110946.17B9kZRV008826@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 4a9b832a2ad7 - main - vfs: Rename ioflg to ioflag in vn_deallocate 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/main X-Git-Reftype: branch X-Git-Commit: 4a9b832a2ad7acafaa16c858ab6e517f2fd83a0c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 09:46:35 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=4a9b832a2ad7acafaa16c858ab6e517f2fd83a0c commit 4a9b832a2ad7acafaa16c858ab6e517f2fd83a0c Author: Ka Ho Ng AuthorDate: 2021-08-11 09:45:47 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-11 09:45:47 +0000 vfs: Rename ioflg to ioflag in vn_deallocate This includes a style fix around ioflag checking as well. Sponsored by: The FreeBSD Foundation Reviewed by: kib, bcr Differential Revision: https://reviews.freebsd.org/D31505 --- share/man/man9/vn_deallocate.9 | 8 ++++---- sys/kern/vfs_vnops.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9 index 415a8941ca68..60bcb9049e40 100644 --- a/share/man/man9/vn_deallocate.9 +++ b/share/man/man9/vn_deallocate.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd Jul 30, 2021 +.Dd August 11, 2021 .Dt VN_DEALLOCATE 9 .Os .Sh NAME @@ -42,7 +42,7 @@ .Fa "off_t *offset" .Fa "off_t *length" .Fa "int flags" -.Fa "int ioflg" +.Fa "int ioflag" .Fa "struct ucred *active_cred" .Fa "struct ucred *file_cred" .Fc @@ -66,7 +66,7 @@ This must be greater than 0. .It Fa flags The control flags of the operation. This should be set to 0 for now. -.It Fa ioflg +.It Fa ioflag The control flags of vnode locking. .It Fa active_cred The user credentials of the calling thread. @@ -75,7 +75,7 @@ The credentials installed on the file description pointing to the vnode or NOCRE .El .Pp The -.Fn ioflg +.Fn ioflag argument may be one or more of the following flags: .Bl -tag -width IO_RANGELOCKED .It Dv IO_NODELOCKED diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 832ade5d800e..015a13c1c385 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3447,7 +3447,7 @@ vn_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td) static int vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, - int ioflg, struct ucred *active_cred, struct ucred *file_cred) + int ioflag, struct ucred *active_cred, struct ucred *file_cred) { struct mount *mp; void *rl_cookie; @@ -3463,7 +3463,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, off = *offset; len = *length; - if ((ioflg & (IO_NODELOCKED|IO_RANGELOCKED)) == 0) + if ((ioflag & (IO_NODELOCKED | IO_RANGELOCKED)) == 0) rl_cookie = vn_rangelock_wlock(vp, off, off + len); while (len > 0 && error == 0) { /* @@ -3473,7 +3473,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, * pass. */ - if ((ioflg & IO_NODELOCKED) == 0) { + if ((ioflag & IO_NODELOCKED) == 0) { bwillwrite(); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) @@ -3488,7 +3488,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, #endif #ifdef MAC - if ((ioflg & IO_NOMACCHECK) == 0) + if ((ioflag & IO_NOMACCHECK) == 0) error = mac_vnode_check_write(active_cred, file_cred, vp); #endif @@ -3496,7 +3496,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, error = VOP_DEALLOCATE(vp, &off, &len, flags, active_cred); - if ((ioflg & IO_NODELOCKED) == 0) { + if ((ioflag & IO_NODELOCKED) == 0) { VOP_UNLOCK(vp); if (mp != NULL) { vn_finished_write(mp); @@ -3514,7 +3514,7 @@ out: int vn_deallocate(struct vnode *vp, off_t *offset, off_t *length, int flags, - int ioflg, struct ucred *active_cred, struct ucred *file_cred) + int ioflag, struct ucred *active_cred, struct ucred *file_cred) { if (*offset < 0 || *length <= 0 || *length > OFF_MAX - *offset || flags != 0) @@ -3522,7 +3522,7 @@ vn_deallocate(struct vnode *vp, off_t *offset, off_t *length, int flags, if (vp->v_type != VREG) return (ENODEV); - return (vn_deallocate_impl(vp, offset, length, flags, ioflg, + return (vn_deallocate_impl(vp, offset, length, flags, ioflag, active_cred, file_cred)); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 09:46:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 444E7650B10; Wed, 11 Aug 2021 09:46:54 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from smtp3-1.goneo.de (smtp3.goneo.de [IPv6:2001:1640:5::8:37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gl4jB11rVz4jWc; Wed, 11 Aug 2021 09:46:54 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from thor.intern.walstatt.dynvpn.de (dynamic-077-011-189-183.77.11.pool.telefonica.de [77.11.189.183]) by smtp3.goneo.de (Postfix) with ESMTPSA id B8F232040DAB; Wed, 11 Aug 2021 11:46:45 +0200 (CEST) Date: Wed, 11 Aug 2021 11:46:18 +0200 From: FreeBSD User To: Alexander Motin Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 67f508db84b8 - main - Mark some sysctls as CTLFLAG_MPSAFE. Message-ID: <20210811114645.3c4fb095@thor.intern.walstatt.dynvpn.de> In-Reply-To: <202108110218.17B2IZ1q006958@gitrepo.freebsd.org> References: <202108110218.17B2IZ1q006958@gitrepo.freebsd.org> Organization: walstatt-de.de MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Gl4jB11rVz4jWc X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 09:46:54 -0000 Am Wed, 11 Aug 2021 02:18:35 GMT Alexander Motin schrieb: > The branch main has been updated by mav: > > URL: https://cgit.FreeBSD.org/src/commit/?id=67f508db84b8b789db37c60972f255574417b8ed > > commit 67f508db84b8b789db37c60972f255574417b8ed > Author: Alexander Motin > AuthorDate: 2021-08-11 02:17:53 +0000 > Commit: Alexander Motin > CommitDate: 2021-08-11 02:18:26 +0000 > > Mark some sysctls as CTLFLAG_MPSAFE. > > MFC after: 2 weeks > --- > sys/kern/kern_intr.c | 4 ++-- > sys/kern/kern_shutdown.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c > index afaf8466a1df..1660414a50ef 100644 > --- a/sys/kern/kern_intr.c > +++ b/sys/kern/kern_intr.c > @@ -1612,7 +1612,7 @@ sysctl_intrnames(SYSCTL_HANDLER_ARGS) > } > > SYSCTL_PROC(_hw, OID_AUTO, intrnames, > - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, > + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, > sysctl_intrnames, "", > "Interrupt Names"); > > @@ -1641,7 +1641,7 @@ sysctl_intrcnt(SYSCTL_HANDLER_ARGS) > } > > SYSCTL_PROC(_hw, OID_AUTO, intrcnt, > - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, > + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, > sysctl_intrcnt, "", > "Interrupt Counts"); > > diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c > index e200b6d8a4b4..fb2a69401801 100644 > --- a/sys/kern/kern_shutdown.c > +++ b/sys/kern/kern_shutdown.c > @@ -740,7 +740,7 @@ SYSCTL_INT(_debug_kassert, OID_AUTO, suppress_in_panic, KASSERT_RWTUN, > static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS); > > SYSCTL_PROC(_debug_kassert, OID_AUTO, kassert, > - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_NEEDGIANT, NULL, 0, > + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_MPSAFE, NULL, 0, > kassert_sysctl_kassert, "I", > "set to trigger a test kassert"); > > @@ -1021,7 +1021,7 @@ dumpdevname_sysctl_handler(SYSCTL_HANDLER_ARGS) > return (error); > } > SYSCTL_PROC(_kern_shutdown, OID_AUTO, dumpdevname, > - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, &dumper_configs, 0, > + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, &dumper_configs, 0, > dumpdevname_sysctl_handler, "A", > "Device(s) for kernel dumps"); > > _______________________________________________ > dev-commits-src-main@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main > To unsubscribe, send any mail to "dev-commits-src-main-unsubscribe@freebsd.org" Hello out there, this commit is the last one working, the follwoing commits seem to break buildworld, I couldn't figure out which one, so I reply to this commit. Running CURRENT: FreeBSD 14.0-CURRENT #1 main-n248614-67f508db84b: Wed Aug 11 07:29:11 CEST 2021 amd64 I use in this case a customzied kernel config with WITH_BEARSSL (I mention this since I see a libsecure compilation problem in the log shown below) Error: [...] ===> stand/libsa32 (all) --- all_subdir_rescue --- (cd /usr/src/rescue/rescue/../../sbin/dump && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/src/amd64.amd64/lib/li bifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dump/ depend && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/src/a md64.amd64/lib/libifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dump/ itime.o main.o optr.o dumprmt.o tape.o traverse.o unctime.o cache.o) --- all_subdir_stand --- --- all_subdir_stand/libsa --- make[4]: "/usr/src/lib/libsecureboot/local.trust.mk" line 109: warning: "cd /usr/src/stand/libsa && 'ls' -1 *.pem t*.asc 2> /dev/null" returned non-zero status --- all_subdir_sbin --- --- all_subdir_sbin/clri --- ===> sbin/clri (all) --- all_subdir_stand --- --- all_subdir_stand/libsa32 --- make[4]: "/usr/src/lib/libsecureboot/local.trust.mk" line 109: warning: "cd /usr/src/stand/libsa32 && 'ls' -1 *.pem t*.asc 2> /dev/null" returned non-zero statu s --- all_subdir_sbin --- --- all_subdir_sbin/comcontrol --- ===> sbin/comcontrol (all) --- all_subdir_libexec --- --- sm_os.h --- ln -sf /usr/src/contrib/sendmail/include/sm/os/sm_os_freebsd.h sm_os.h --- .depend --- echo mail.local: /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/libc.a /usr/obj/usr/src/amd64.amd64/lib/libsm/libsm_pie.a >> .depend --- mail.local.o --- cc -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin -O2 -pipe -O2 -fno-common -I/usr/sr c/contrib/sendmail/include -I. -I/usr/local/include -DSASL=2 -DNDEBUG -fPIE -MD -MF.depend.mail.local.o -MTmail.local.o -std=gnu99 -Wno-format-zero-length -f stack-protector-strong -Wsystem-headers -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variab le -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-pac ked-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Qunused-arguments -c /usr/src/contrib/sendmail/mail.local/mail.local.c -o mail.local.o --- all_subdir_rescue --- `itime.o' is up to date. `main.o' is up to date. `optr.o' is up to date. `dumprmt.o' is up to date. `tape.o' is up to date. `traverse.o' is up to date. `unctime.o' is up to date. `cache.o' is up to date. --- dumpfs_make --- (cd /usr/src/rescue/rescue/../../sbin/dumpfs && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/src/amd64.amd64/lib/ libifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dumpfs/ depend && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/s rc/amd64.amd64/lib/libifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dumpfs/ dumpfs.o) --- all_subdir_sbin --- --- all_subdir_sbin/conscontrol --- `main.o' is up to date. `optr.o' is up to date. `dumprmt.o' is up to date. `tape.o' is up to date. `traverse.o' is up to date. `unctime.o' is up to date. `cache.o' is up to date. --- dumpfs_make --- (cd /usr/src/rescue/rescue/../../sbin/dumpfs && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/src/amd64.amd64/lib/libifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dumpfs/ depend && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/src/amd64.amd64/lib/libifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dumpfs/ dumpfs.o) --- all_subdir_sbin --- --- all_subdir_sbin/conscontrol --- ===> sbin/conscontrol (all) --- all_subdir_sbin/ddb --- ===> sbin/ddb (all) --- all_subdir_sbin/devfs --- ===> sbin/devfs (all) --- all_subdir_sbin/devmatch --- ===> sbin/devmatch (all) --- all_subdir_stand --- --- all_subdir_stand/libsa --- --- beforedepend --- --- all_subdir_stand/libsa32 --- --- beforedepend --- --- all_subdir_stand/libsa --- mkdir -p xlocale arpa; for i in a.out.h assert.h elf.h limits.h nlist.h setjmp.h stddef.h stdbool.h string.h strings.h time.h unistd.h uuid.h; do ln -sf /usr/src/include/$i $i; done; ln -sf /usr/src/sys/amd64/include/stdarg.h stdarg.h; ln -sf /usr/src/sys/sys/errno.h errno.h; ln -sf /usr/src/sys/sys/stdint.h stdint.h; ln -sf /usr/src/include/arpa/inet.h arpa/inet.h; ln -sf /usr/src/include/arpa/tftp.h arpa/tftp.h; for i in _time.h _strings.h _string.h; do [ -f xlocale/$i ] || :> xlocale/$i; done; for i in ctype.h fcntl.h signal.h stdio.h stdlib.h; do ln -sf /usr/src/stand/libsa/stand.h $i; done --- all_subdir_stand/libsa32 --- mkdir -p xlocale arpa; for i in a.out.h assert.h elf.h limits.h nlist.h setjmp.h stddef.h stdbool.h string.h strings.h time.h unistd.h uuid.h; do ln -sf /usr/src/include/$i $i; done; ln -sf /usr/src/sys/amd64/include/stdarg.h stdarg.h; ln -sf /usr/src/sys/sys/errno.h errno.h; ln -sf /usr/src/sys/sys/stdint.h stdint.h; ln -sf /usr/src/include/arpa/inet.h arpa/inet.h; ln -sf /usr/src/include/arpa/tftp.h arpa/tftp.h; for i in _time.h _strings.h _string.h; do [ -f xlocale/$i ] || :> xlocale/$i; done; for i in ctype.h fcntl.h signal.h stdio.h stdlib.h; do ln -sf /usr/src/stand/libsa/stand.h $i; done --- all_subdir_rescue --- `dumpfs.o' is up to date. --- dumpon_make --- (cd /usr/src/rescue/rescue/../../sbin/dumpon && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/src/amd64.amd64/lib/libifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dumpon/ depend && make MK_PIE=no NO_SHARED=yes -DRESCUE CRUNCH_CFLAGS=-DRESCUE CRUNCH_CFLAGS+=-I/usr/obj/usr/src/amd64.amd64/lib/libifconfig MK_AUTO_OBJ=yes DIRPRFX=rescue/rescue/dumpon/ dumpon.o) --- all_subdir_sbin --- --- all_subdir_sbin/dhclient --- ===> sbin/dhclient (all) --- all_subdir_stand --- --- libsa32_pie.a --- building pie sa32 library ar -crsD libsa32_pie.a __main.pieo abort.pieo assert.pieo bcd.pieo environment.pieo getopt.pieo gets.pieo globals.pieo hexdump.pieo pager.pieo panic.pieo printf.pieo strdup.pieo strerror.pieo random.pieo sbrk.pieo tslog.pieo twiddle.pieo zalloc.pieo zalloc_malloc.pieo strcasecmp.pieo ntoh.pieo bcmp.pieo bcopy.pieo bzero.pieo ffs.pieo fls.pieo memccpy.pieo memchr.pieo memcmp.pieo memcpy.pieo memmove.pieo memset.pieo strcat.pieo strchr.pieo strchrnul.pieo strcmp.pieo strcpy.pieo stpcpy.pieo stpncpy.pieo strcspn.pieo strlcat.pieo strlcpy.pieo strlen.pieo strncat.pieo strncmp.pieo strncpy.pieo strnlen.pieo strpbrk.pieo strrchr.pieo strsep.pieo strspn.pieo strstr.pieo strtok.pieo swab.pieo abs.pieo strtol.pieo strtoll.pieo strtoul.pieo strtoull.pieo subr_boot.pieo clzsi2.pieo ctzsi2.pieo divmoddi4.pieo divmodsi4.pieo divdi3.pieo divsi3.pieo moddi3.pieo modsi3.pieo udivmoddi4.pieo udivmodsi4.pieo udivdi3.pieo udivsi3.pieo umoddi3.pieo umodsi3.pieo ashldi3.pieo ashrdi3.pieo lshrdi3.pieo hypervisor.pieo uuid_create_nil.pieo uuid_equal.pieo uuid_from_string.pieo uuid_is_nil.pieo uuid_to_string.pieo _setjmp.pieo bzlib.pieo crctable.pieo decompress.pieo huffman.pieo randtable.pieo adler32.pieo crc32.pieo infback.pieo inffast.pieo inflate.pieo inftrees.pieo zutil.pieo lz4.pieo closeall.pieo dev.pieo ioctl.pieo nullfs.pieo stat.pieo fstat.pieo close.pieo lseek.pieo open.pieo read.pieo write.pieo readdir.pieo smbios.pieo arp.pieo ether.pieo ip.pieo inet_ntoa.pieo in_cksum.pieo net.pieo udp.pieo netif.pieo rpc.pieo bootp.pieo rarp.pieo bootparam.pieo ufs.pieo nfs.pieo cd9660.pieo tftp.pieo gzipfs.pieo bzipfs.pieo dosfs.pieo ext2fs.pieo splitfs.pieo pkgfs.pieo time.pieo ffs_subr.pieo ffs_tables.pieo explicit_bzero.pieo crc32_libkern.pieo pwgets.pieo sha256c.pieo sha512c.pieo md5c.pieo rijndael-alg-fst.pieo rijndael-api-fst.pieo rijndael-api.pieo geliboot.pieo geliboot_crypto.pieo gelidev.pieo geli_metadata.pieo g_eli_hmac.pieo g_eli_key.pieo g_eli_key_cache.pieo pkcs5v2.pieo xform_aes_xts.pieo ccopy.pieo dec32be.pieo dec64be.pieo enc32be.pieo enc64be.pieo pemdec.pieo ec_all_m31.pieo ec_c25519_m31.pieo ec_c25519_m62.pieo ec_c25519_m64.pieo ec_default.pieo ec_p256_m31.pieo ec_p256_m62.pieo ec_p256_m64.pieo ec_prime_i31.pieo ec_pubkey.pieo ec_secp256r1.pieo ec_secp384r1.pieo ec_secp521r1.pieo ecdsa_atr.pieo ecdsa_default_vrfy_asn1.pieo ecdsa_i31_bits.pieo ecdsa_i31_vrfy_asn1.pieo ecdsa_i31_vrfy_raw.pieo multihash.pieo sha1.pieo sha2big.pieo sha2small.pieo i31_add.pieo i31_bitlen.pieo i31_decmod.pieo i31_decode.pieo i31_encode.pieo i31_fmont.pieo i31_iszero.pieo i31_moddiv.pieo i31_modpow.pieo i31_modpow2.pieo i31_montmul.pieo i31_muladd.pieo i31_ninv31.pieo i31_rshift.pieo i31_sub.pieo i31_tmont.pieo i32_div32.pieo i62_modpow2.pieo rsa_default_pkcs1_vrfy.pieo rsa_i31_pkcs1_vrfy.pieo rsa_i31_pub.pieo rsa_i62_pkcs1_vrfy.pieo rsa_i62_pub.pieo rsa_pkcs1_sig_unpad.pieo asn1enc.pieo x509_decoder.pieo x509_minimal.pieo readfile.pieo brf.pieo vesigned.pieo vets.pieo xmem.pieo vector.pieo dearmor.pieo decode.pieo opgp_key.pieo opgp_sig.pieo vectx.pieo veopen.pieo vepcr.pieo verify_file.pieo efi_variables.pieo efi_init.pieo zfs.pieo nvlist.pieo skein.pieo skein_block.pieo list.pieo zstd_shim.pieo zstd.pieo --- all_subdir_sbin --- --- all_subdir_sbin/dmesg --- ===> sbin/dmesg (all) --- all_subdir_stand --- ar: warning: can't open file: ccopy.pieo: No such file or directory 1.72 real 3.57 user 1.07 sys make[1]: stopped in /usr/src -- O. Hartmann From owner-dev-commits-src-all@freebsd.org Wed Aug 11 10:21:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2C727650EC6; Wed, 11 Aug 2021 10:21: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 4Gl5TV0RfGz4lkm; Wed, 11 Aug 2021 10:21: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 D3C235A9E; Wed, 11 Aug 2021 10:21:49 +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 17BALnCV061733; Wed, 11 Aug 2021 10:21:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BALnI1061732; Wed, 11 Aug 2021 10:21:49 GMT (envelope-from git) Date: Wed, 11 Aug 2021 10:21:49 GMT Message-Id: <202108111021.17BALnI1061732@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 89c085b8993d - main - Only use byte register access in legacy virtio pci MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 89c085b8993d7d1e7b137f99fa6df94c37c3a68a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 10:21:50 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=89c085b8993d7d1e7b137f99fa6df94c37c3a68a commit 89c085b8993d7d1e7b137f99fa6df94c37c3a68a Author: Andrew Turner AuthorDate: 2021-08-05 14:36:07 +0000 Commit: Andrew Turner CommitDate: 2021-08-11 10:18:54 +0000 Only use byte register access in legacy virtio pci Some simulators don't implement arbitrary sized memory access to the virtio PCI registers. Follow Linux and use single byte accesses to read and write to these registers. Reviewed by: bryanv, emaste (previous version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31424 --- sys/dev/virtio/pci/virtio_pci_legacy.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/sys/dev/virtio/pci/virtio_pci_legacy.c b/sys/dev/virtio/pci/virtio_pci_legacy.c index 0524529d064b..a0d962058a84 100644 --- a/sys/dev/virtio/pci/virtio_pci_legacy.c +++ b/sys/dev/virtio/pci/virtio_pci_legacy.c @@ -506,22 +506,14 @@ vtpci_legacy_read_dev_config(device_t dev, bus_size_t offset, struct vtpci_legacy_softc *sc; bus_size_t off; uint8_t *d; - int size; + int i; sc = device_get_softc(dev); off = VIRTIO_PCI_LEGACY_CONFIG(sc) + offset; - for (d = dst; length > 0; d += size, off += size, length -= size) { - if (length >= 4) { - size = 4; - *(uint32_t *)d = vtpci_legacy_read_config_4(sc, off); - } else if (length >= 2) { - size = 2; - *(uint16_t *)d = vtpci_legacy_read_config_2(sc, off); - } else { - size = 1; - *d = vtpci_legacy_read_config_1(sc, off); - } + d = dst; + for (i = 0; i < length; i++) { + d[i] = vtpci_legacy_read_config_1(sc, off + i); } } @@ -532,22 +524,14 @@ vtpci_legacy_write_dev_config(device_t dev, bus_size_t offset, struct vtpci_legacy_softc *sc; bus_size_t off; uint8_t *s; - int size; + int i; sc = device_get_softc(dev); off = VIRTIO_PCI_LEGACY_CONFIG(sc) + offset; - for (s = src; length > 0; s += size, off += size, length -= size) { - if (length >= 4) { - size = 4; - vtpci_legacy_write_config_4(sc, off, *(uint32_t *)s); - } else if (length >= 2) { - size = 2; - vtpci_legacy_write_config_2(sc, off, *(uint16_t *)s); - } else { - size = 1; - vtpci_legacy_write_config_1(sc, off, *s); - } + s = src; + for (i = 0; i < length; i++) { + vtpci_legacy_write_config_1(sc, off + i, s[i]); } } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 10:21:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 616776513A7; Wed, 11 Aug 2021 10:21:51 +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 4Gl5TW0Stkz4lkq; Wed, 11 Aug 2021 10:21: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 EDFED5B6A; Wed, 11 Aug 2021 10:21: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 17BALo9t061759; Wed, 11 Aug 2021 10:21:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BALoa7061758; Wed, 11 Aug 2021 10:21:50 GMT (envelope-from git) Date: Wed, 11 Aug 2021 10:21:50 GMT Message-Id: <202108111021.17BALoa7061758@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 69d8dc20be6c - main - Use arm64 sha256 intrinsics in libmd MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 69d8dc20be6ca10cf87c98223121c4121aff42cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 10:21:51 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=69d8dc20be6ca10cf87c98223121c4121aff42cc commit 69d8dc20be6ca10cf87c98223121c4121aff42cc Author: Andrew Turner AuthorDate: 2021-07-23 09:14:03 +0000 Commit: Andrew Turner CommitDate: 2021-08-11 10:20:48 +0000 Use arm64 sha256 intrinsics in libmd Summary: When running on a CPU that supports the arm64 sha256 intrinsics use them to improve perfromance of sha256 calculations. With this changethe following improvement has been seen on an Apple M1 with FreeBS running under Parallels, with similar results on a Neoverse-N1 r3p1. x sha256.orig + sha256.arm64 +--------------------------------------------------------------------+ |++ x x| |+++ xxx| ||A |A|| +--------------------------------------------------------------------+ N Min Max Median Avg Stddev x 5 3.41 3.5 3.46 3.458 0.042661458 + 5 0.47 0.54 0.5 0.504 0.027018512 Difference at 95.0% confidence -2.954 +/- 0.0520768 -85.4251% +/- 0.826831% (Student's t, pooled s = 0.0357071) Reviewed by: cem Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31284 --- lib/libmd/Makefile | 5 +++ sys/crypto/sha2/sha256c.c | 35 ++++++++++++++- sys/crypto/sha2/sha256c_arm64.c | 97 +++++++++++++++++++++++++++++++++++++++++ sys/crypto/sha2/sha256c_impl.h | 37 ++++++++++++++++ 4 files changed, 173 insertions(+), 1 deletion(-) diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile index f90101112ba9..480796ae5029 100644 --- a/lib/libmd/Makefile +++ b/lib/libmd/Makefile @@ -129,6 +129,11 @@ skein_block.o skein_block.pico: Makefile .if exists(${MACHINE_ARCH}/sha.S) || exists(${MACHINE_ARCH}/rmd160.S) || exists(${MACHINE_ARCH}/skein_block_asm.S) ACFLAGS+= -DELF -Wa,--noexecstack .endif +.if ${MACHINE_CPUARCH} == "aarch64" +SRCS+= sha256c_arm64.c +CFLAGS+= -DARM64_SHA2 +CFLAGS.sha256c_arm64.c+= -march=armv8-a+crypto +.endif .endif # ${USE_ASM_SOURCES} != 0 md4hl.c: mdXhl.c diff --git a/sys/crypto/sha2/sha256c.c b/sys/crypto/sha2/sha256c.c index 135fb68ccc65..63805c97a4bb 100644 --- a/sys/crypto/sha2/sha256c.c +++ b/sys/crypto/sha2/sha256c.c @@ -38,6 +38,12 @@ __FBSDID("$FreeBSD$"); #include "sha224.h" #include "sha256.h" +#include "sha256c_impl.h" + +#if defined(ARM64_SHA2) +#include +#include +#endif #if BYTE_ORDER == BIG_ENDIAN @@ -132,7 +138,7 @@ static const uint32_t K[64] = { * the 512-bit input block to produce a new state. */ static void -SHA256_Transform(uint32_t * state, const unsigned char block[64]) +SHA256_Transform_c(uint32_t * state, const unsigned char block[64]) { uint32_t W[64]; uint32_t S[8]; @@ -188,6 +194,33 @@ SHA256_Transform(uint32_t * state, const unsigned char block[64]) state[i] += S[i]; } +#if defined(ARM64_SHA2) +static void +SHA256_Transform_arm64(uint32_t * state, const unsigned char block[64]) +{ + SHA256_Transform_arm64_impl(state, block, K); +} + +DEFINE_UIFUNC(static, void, SHA256_Transform, + (uint32_t * state, const unsigned char block[64])) +{ + u_long hwcap; + + if (elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)) == 0) { + if ((hwcap & HWCAP_SHA2) != 0) + return (SHA256_Transform_arm64); + } + + return (SHA256_Transform_c); +} +#else +static void +SHA256_Transform(uint32_t * state, const unsigned char block[64]) +{ + SHA256_Transform_c(state, block); +} +#endif + static unsigned char PAD[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/sys/crypto/sha2/sha256c_arm64.c b/sys/crypto/sha2/sha256c_arm64.c new file mode 100644 index 000000000000..8c0153c2b603 --- /dev/null +++ b/sys/crypto/sha2/sha256c_arm64.c @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software was developed by Andrew Turner 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include + +#include "sha256c_impl.h" + +void __hidden +SHA256_Transform_arm64_impl(uint32_t * state, const unsigned char block[64], + const uint32_t K[64]) +{ + uint32x4_t W[4]; + uint32x4_t S[2]; + uint32x4_t S_start[2]; + uint32x4_t K_tmp, S_tmp; + int i; + +#define A64_LOAD_W(x) \ + W[x] = vld1q_u32((const uint32_t *)(&block[(x) * 16])); \ + W[x] = vreinterpretq_u32_u8(vrev32q_u8(vreinterpretq_u8_u32(W[x]))) + + /* 1. Prepare the first part of the message schedule W. */ + A64_LOAD_W(0); + A64_LOAD_W(1); + A64_LOAD_W(2); + A64_LOAD_W(3); + + /* 2. Initialize working variables. */ + S[0] = vld1q_u32(&state[0]); + S[1] = vld1q_u32(&state[4]); + + S_start[0] = S[0]; + S_start[1] = S[1]; + + /* 3. Mix. */ + for (i = 0; i < 64; i += 16) { +#define A64_RNDr(i, ii) \ + K_tmp = vaddq_u32(W[i], vld1q_u32(&K[ii + i * 4])); \ + S_tmp = vsha256hq_u32(S[0], S[1], K_tmp); \ + S[1] = vsha256h2q_u32(S[1], S[0], K_tmp); \ + S[0] = S_tmp + + A64_RNDr(0, i); + A64_RNDr(1, i); + A64_RNDr(2, i); + A64_RNDr(3, i); + + if (i == 48) + break; + +#define A64_MSCH(x) \ + W[x] = vsha256su0q_u32(W[x], W[(x + 1) % 4]); \ + W[x] = vsha256su1q_u32(W[x], W[(x + 2) % 4], W[(x + 3) % 4]) + + A64_MSCH(0); + A64_MSCH(1); + A64_MSCH(2); + A64_MSCH(3); + } + + /* 4. Mix local working variables into global state */ + S[0] = vaddq_u32(S[0], S_start[0]); + S[1] = vaddq_u32(S[1], S_start[1]); + + vst1q_u32(&state[0], S[0]); + vst1q_u32(&state[4], S[1]); +} diff --git a/sys/crypto/sha2/sha256c_impl.h b/sys/crypto/sha2/sha256c_impl.h new file mode 100644 index 000000000000..ed96e6706699 --- /dev/null +++ b/sys/crypto/sha2/sha256c_impl.h @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software was developed by Andrew Turner 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. + */ + +#ifndef _SHA256_IMPL_H_ +#define _SHA256_IMPL_H_ + +#if defined(ARM64_SHA2) +void SHA256_Transform_arm64_impl(uint32_t * state, + const unsigned char block[64], const uint32_t K[64]); +#endif + +#endif /* !_SHA256_IMPL_H_ */ From owner-dev-commits-src-all@freebsd.org Wed Aug 11 10:22:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8DB6B650EFB; Wed, 11 Aug 2021 10:22:55 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from smtp2-2.goneo.de (smtp2.goneo.de [IPv6:2001:1640:5::8:33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gl5Vk2q67z4m2K; Wed, 11 Aug 2021 10:22:54 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from thor.intern.walstatt.dynvpn.de (dynamic-077-011-189-183.77.11.pool.telefonica.de [77.11.189.183]) by smtp2.goneo.de (Postfix) with ESMTPSA id B1C2A2040D99; Wed, 11 Aug 2021 12:22:47 +0200 (CEST) Date: Wed, 11 Aug 2021 12:22:20 +0200 From: FreeBSD User To: Alexander Motin Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Rbuildworld failure: ar: warning: can't open file: x509_minimal.pieo (an other .pieo files) Message-ID: <20210811122247.42b24b7e@thor.intern.walstatt.dynvpn.de> In-Reply-To: <20210811114645.3c4fb095@thor.intern.walstatt.dynvpn.de> References: <202108110218.17B2IZ1q006958@gitrepo.freebsd.org> <20210811114645.3c4fb095@thor.intern.walstatt.dynvpn.de> Organization: walstatt-de.de MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Gl5Vk2q67z4m2K X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@walstatt-de.de has no SPF policy when checking 2001:1640:5::8:33) smtp.mailfrom=freebsd@walstatt-de.de X-Spamd-Result: default: False [-2.20 / 15.00]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[walstatt-de.de]; AUTH_NA(1.00)[]; HAS_ORG_HEADER(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:25394, ipnet:2001:1640::/32, country:DE]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_IN_DNSWL_LOW(-0.10)[2001:1640:5::8:33:from] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 10:22:55 -0000 Am Wed, 11 Aug 2021 11:46:18 +0200 FreeBSD User schrieb: > Am Wed, 11 Aug 2021 02:18:35 GMT > Alexander Motin schrieb: > > > The branch main has been updated by mav: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=67f508db84b8b789db37c60972f255574417b8ed > > > > commit 67f508db84b8b789db37c60972f255574417b8ed > > Author: Alexander Motin > > AuthorDate: 2021-08-11 02:17:53 +0000 > > Commit: Alexander Motin > > CommitDate: 2021-08-11 02:18:26 +0000 > > > > Mark some sysctls as CTLFLAG_MPSAFE. > > > > MFC after: 2 weeks > > --- > > sys/kern/kern_intr.c | 4 ++-- > > sys/kern/kern_shutdown.c | 4 ++-- > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c > > index afaf8466a1df..1660414a50ef 100644 > > --- a/sys/kern/kern_intr.c > > +++ b/sys/kern/kern_intr.c > > @@ -1612,7 +1612,7 @@ sysctl_intrnames(SYSCTL_HANDLER_ARGS) > > } > > > > SYSCTL_PROC(_hw, OID_AUTO, intrnames, > > - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, > > + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, > > sysctl_intrnames, "", > > "Interrupt Names"); > > > > @@ -1641,7 +1641,7 @@ sysctl_intrcnt(SYSCTL_HANDLER_ARGS) > > } > > > > SYSCTL_PROC(_hw, OID_AUTO, intrcnt, > > - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, > > + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, > > sysctl_intrcnt, "", > > "Interrupt Counts"); > > > > diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c > > index e200b6d8a4b4..fb2a69401801 100644 > > --- a/sys/kern/kern_shutdown.c > > +++ b/sys/kern/kern_shutdown.c > > @@ -740,7 +740,7 @@ SYSCTL_INT(_debug_kassert, OID_AUTO, suppress_in_panic, KASSERT_RWTUN, > > static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS); > > > > SYSCTL_PROC(_debug_kassert, OID_AUTO, kassert, > > - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_NEEDGIANT, NULL, 0, > > + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_MPSAFE, NULL, 0, > > kassert_sysctl_kassert, "I", > > "set to trigger a test kassert"); > > > > @@ -1021,7 +1021,7 @@ dumpdevname_sysctl_handler(SYSCTL_HANDLER_ARGS) > > return (error); > > } > > SYSCTL_PROC(_kern_shutdown, OID_AUTO, dumpdevname, > > - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, &dumper_configs, 0, > > + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, &dumper_configs, 0, > > dumpdevname_sysctl_handler, "A", > > "Device(s) for kernel dumps"); > > > > _______________________________________________ > > dev-commits-src-main@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main > > To unsubscribe, send any mail to "dev-commits-src-main-unsubscribe@freebsd.org" > > Hello out there, this commit is the last one working, the follwoing commits seem to break > buildworld, I couldn't figure out which one, so I reply to this commit. > > Running CURRENT: > FreeBSD 14.0-CURRENT #1 main-n248614-67f508db84b: Wed Aug 11 07:29:11 CEST 2021 amd64 > > I use in this case a customzied kernel config with WITH_BEARSSL (I mention this since I see a > libsecure compilation problem in the log shown below) > > Error: > [...] After a fresh build from scratch the error reported in the first message seems to be a bit cloudy, but after restarting the buildworld again (without cleanup the world), I (naively) guess the error shown then (see below) covers a bit more of the source of the fault. [...] --- all_subdir_stand --- building pie sa library ar -crsD libsa_pie.a __main.pieo abort.pieo assert.pieo bcd.pieo environment.pieo getopt.pieo gets.pieo globals.pieo hexdump.pieo pager.pieo panic.pieo printf.p ieo strdup.pieo strerror.pieo random.pieo sbrk.pieo tslog.pieo twiddle.pieo zalloc.pieo zalloc_malloc.pieo strcasecmp.pieo ntoh.pieo bcmp.pieo bcopy.pieo bzero. pieo ffs.pieo fls.pieo memccpy.pieo memchr.pieo memcmp.pieo memcpy.pieo memmove.pieo memset.pieo strcat.pieo strchr.pieo strchrnul.pieo strcmp.pieo strcpy.pieo stpcpy.pieo stpncpy.pieo strcspn.pieo strlcat.pieo strlcpy.pieo strlen.pieo strncat.pieo strncmp.pieo strncpy.pieo strnlen.pieo strpbrk.pieo strrchr.pieo strsep .pieo strspn.pieo strstr.pieo strtok.pieo swab.pieo abs.pieo strtol.pieo strtoll.pieo strtoul.pieo strtoull.pieo subr_boot.pieo clzsi2.pieo ctzsi2.pieo divmoddi 4.pieo divmodsi4.pieo divdi3.pieo divsi3.pieo moddi3.pieo modsi3.pieo udivmoddi4.pieo udivmodsi4.pieo udivdi3.pieo udivsi3.pieo umoddi3.pieo umodsi3.pieo ashldi 3.pieo ashrdi3.pieo lshrdi3.pieo hypervisor.pieo uuid_create_nil.pieo uuid_equal.pieo uuid_from_string.pieo uuid_is_nil.pieo uuid_to_string.pieo _setjmp.pieo bz lib.pieo crctable.pieo decompress.pieo huffman.pieo randtable.pieo adler32.pieo crc32.pieo infback.pieo inffast.pieo inflate.pieo inftrees.pieo zutil.pieo lz4.p ieo closeall.pieo dev.pieo ioctl.pieo nullfs.pieo stat.pieo fstat.pieo close.pieo lseek.pieo open.pieo read.pieo write.pieo readdir.pieo smbios.pieo arp.pieo et her.pieo ip.pieo inet_ntoa.pieo in_cksum.pieo net.pieo udp.pieo netif.pieo rpc.pieo bootp.pieo rarp.pieo bootparam.pieo ufs.pieo nfs.pieo cd9660.pieo tftp.pieo gzipfs.pieo bzipfs.pieo dosfs.pieo ext2fs.pieo splitfs.pieo pkgfs.pieo time.pieo ffs_subr.pieo ffs_tables.pieo explicit_bzero.pieo crc32_libkern.pieo pwgets.pie o sha256c.pieo sha512c.pieo md5c.pieo rijndael-alg-fst.pieo rijndael-api-fst.pieo rijndael-api.pieo geliboot.pieo geliboot_crypto.pieo gelidev.pieo geli_metadat a.pieo g_eli_hmac.pieo g_eli_key.pieo g_eli_key_cache.pieo pkcs5v2.pieo xform_aes_xts.pieo ccopy.pieo dec32be.pieo dec64be.pieo enc32be.pieo enc64be.pieo pemdec .pieo ec_all_m31.pieo ec_c25519_m31.pieo ec_c25519_m62.pieo ec_c25519_m64.pieo ec_default.pieo ec_p256_m31.pieo ec_p256_m62.pieo ec_p256_m64.pieo ec_prime_i31.p ieo ec_pubkey.pieo ec_secp256r1.pieo ec_secp384r1.pieo ec_secp521r1.pieo ecdsa_atr.pieo ecdsa_default_vrfy_asn1.pieo ecdsa_i31_bits.pieo ecdsa_i31_vrfy_asn1.pie o ecdsa_i31_vrfy_raw.pieo multihash.pieo sha1.pieo sha2big.pieo sha2small.pieo i31_add.pieo i31_bitlen.pieo i31_decmod.pieo i31_decode.pieo i31_encode.pieo i31_ fmont.pieo i31_iszero.pieo i31_moddiv.pieo i31_modpow.pieo i31_modpow2.pieo i31_montmul.pieo i31_muladd.pieo i31_ninv31.pieo i31_rshift.pieo i31_sub.pieo i31_tm ont.pieo i32_div32.pieo i62_modpow2.pieo rsa_default_pkcs1_vrfy.pieo rsa_i31_pkcs1_vrfy.pieo rsa_i31_pub.pieo rsa_i62_pkcs1_vrfy.pieo rsa_i62_pub.pieo rsa_pkcs1 _sig_unpad.pieo asn1enc.pieo x509_decoder.pieo x509_minimal.pieo readfile.pieo brf.pieo vesigned.pieo vets.pieo xmem.pieo vector.pieo dearmor.pieo decode.pieo o pgp_key.pieo opgp_sig.pieo vectx.pieo veopen.pieo vepcr.pieo verify_file.pieo efi_variables.pieo efi_init.pieo zfs.pieo nvlist.pieo skein.pieo skein_block.pieo list.pieo zstd_shim.pieo zstd.pieo ar: warning: can't open file: ccopy.pieo: No such file or directory ar: warning: can't open file: dec32be.pieo: No such file or directory ar: warning: can't open file: dec64be.pieo: No such file or directory ar: warning: can't open file: enc32be.pieo: No such file or directory ar: warning: can't open file: enc64be.pieo: No such file or directory ar: warning: can't open file: pemdec.pieo: No such file or directory ar: warning: can't open file: ec_all_m31.pieo: No such file or directory ar: warning: can't open file: ec_c25519_m31.pieo: No such file or directory ar: warning: can't open file: ec_c25519_m62.pieo: No such file or directory ar: warning: can't open file: ec_c25519_m64.pieo: No such file or directory ar: warning: can't open file: ec_default.pieo: No such file or directory ar: warning: can't open file: ec_p256_m31.pieo: No such file or directory ar: warning: can't open file: ec_p256_m62.pieo: No such file or directory ar: warning: can't open file: ec_p256_m64.pieo: No such file or directory ar: warning: can't open file: ec_prime_i31.pieo: No such file or directory ar: warning: can't open file: ec_pubkey.pieo: No such file or directory ar: warning: can't open file: ec_secp256r1.pieo: No such file or directory ar: warning: can't open file: ec_secp384r1.pieo: No such file or directory ar: warning: can't open file: ec_secp521r1.pieo: No such file or directory ar: warning: can't open file: ecdsa_atr.pieo: No such file or directory ar: warning: can't open file: ecdsa_default_vrfy_asn1.pieo: No such file or directory ar: warning: can't open file: ecdsa_i31_bits.pieo: No such file or directory ar: warning: can't open file: ecdsa_i31_vrfy_asn1.pieo: No such file or directory ar: warning: can't open file: ecdsa_i31_vrfy_raw.pieo: No such file or directory ar: warning: can't open file: multihash.pieo: No such file or directory ar: warning: can't open file: sha1.pieo: No such file or directory ar: warning: can't open file: sha2big.pieo: No such file or directory ar: warning: can't open file: sha2small.pieo: No such file or directory ar: warning: can't open file: i31_add.pieo: No such file or directory ar: warning: can't open file: i31_bitlen.pieo: No such file or directory ar: warning: can't open file: i31_decmod.pieo: No such file or directory ar: warning: can't open file: i31_decode.pieo: No such file or directory ar: warning: can't open file: i31_encode.pieo: No such file or directory ar: warning: can't open file: i31_fmont.pieo: No such file or directory ar: warning: can't open file: i31_iszero.pieo: No such file or directory ar: warning: can't open file: i31_moddiv.pieo: No such file or directory ar: warning: can't open file: i31_modpow.pieo: No such file or directory ar: warning: can't open file: i31_modpow2.pieo: No such file or directory ar: warning: can't open file: i31_montmul.pieo: No such file or directory ar: warning: can't open file: i31_muladd.pieo: No such file or directory ar: warning: can't open file: i31_ninv31.pieo: No such file or directory ar: warning: can't open file: i31_rshift.pieo: No such file or directory ar: warning: can't open file: i31_sub.pieo: No such file or directory ar: warning: can't open file: i31_tmont.pieo: No such file or directory ar: warning: can't open file: i32_div32.pieo: No such file or directory ar: warning: can't open file: i62_modpow2.pieo: No such file or directory ar: warning: can't open file: rsa_default_pkcs1_vrfy.pieo: No such file or directory ar: warning: can't open file: rsa_i31_pkcs1_vrfy.pieo: No such file or directory ar: warning: can't open file: rsa_i31_pub.pieo: No such file or directory ar: warning: can't open file: rsa_i62_pkcs1_vrfy.pieo: No such file or directory ar: warning: can't open file: rsa_i62_pub.pieo: No such file or directory ar: warning: can't open file: rsa_pkcs1_sig_unpad.pieo: No such file or directory ar: warning: can't open file: asn1enc.pieo: No such file or directory ar: warning: can't open file: x509_decoder.pieo: No such file or directory ar: warning: can't open file: x509_minimal.pieo: No such file or directory ar: warning: can't open file: xmem.pieo: No such file or directory ar: warning: can't open file: vector.pieo: No such file or directory ar: warning: can't open file: efi_variables.pieo: No such file or directory ar: warning: can't open file: efi_init.pieo: No such file or directory --- all_subdir_lib --- --- sigreturn.2.gz --- --- all_subdir_stand --- *** [libsa_pie.a] Error code 1 make[4]: stopped in /usr/src/stand/libsa -- O. Hartmann From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D46B0653DDF; Wed, 11 Aug 2021 13:25: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 4Gl9Y75j2Gz3CQm; Wed, 11 Aug 2021 13:25: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 AB2867B4C; Wed, 11 Aug 2021 13:25: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 17BDPFBp004802; Wed, 11 Aug 2021 13:25:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BDPFfF004801; Wed, 11 Aug 2021 13:25:15 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:15 GMT Message-Id: <202108111325.17BDPFfF004801@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: 919cf790d4da - stable/12 - pf: consistently malloc rules with M_ZERO 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/12 X-Git-Reftype: branch X-Git-Commit: 919cf790d4da75f82cae2c3dfc28a5d0f8e3d115 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:15 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=919cf790d4da75f82cae2c3dfc28a5d0f8e3d115 commit 919cf790d4da75f82cae2c3dfc28a5d0f8e3d115 Author: Mateusz Guzik AuthorDate: 2021-07-23 15:01:29 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:14:32 +0000 pf: consistently malloc rules with M_ZERO Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 49a7d47235434a300cc57b205e493988fdebf79c) --- sys/netpfil/pf/pf_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index ea323709f6cd..bb71f44cad97 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2330,7 +2330,7 @@ DIOCADDRULENV_error: struct pfioc_rule *pr = (struct pfioc_rule *)addr; struct pf_krule *rule; - rule = malloc(sizeof(*rule), M_PFRULE, M_WAITOK); + rule = malloc(sizeof(*rule), M_PFRULE, M_WAITOK | M_ZERO); error = pf_rule_to_krule(&pr->rule, rule); if (error != 0) { free(rule, M_PFRULE); @@ -2583,7 +2583,7 @@ DIOCGETRULENV_error: } if (pcr->action != PF_CHANGE_REMOVE) { - newrule = malloc(sizeof(*newrule), M_PFRULE, M_WAITOK); + newrule = malloc(sizeof(*newrule), M_PFRULE, M_WAITOK | M_ZERO); error = pf_rule_to_krule(&pcr->rule, newrule); if (error != 0) { free(newrule, M_PFRULE); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C9F4F653647; Wed, 11 Aug 2021 13:25: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 4Gl9Y65Klkz3ClJ; Wed, 11 Aug 2021 13:25: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 9ADD37DE8; Wed, 11 Aug 2021 13:25: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 17BDPEAq004778; Wed, 11 Aug 2021 13:25:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BDPEsV004777; Wed, 11 Aug 2021 13:25:14 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:14 GMT Message-Id: <202108111325.17BDPEsV004777@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: 8abcdb1f59cc - stable/12 - pf: hide struct pf_kstatus behind ifdef _KERNEL 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/12 X-Git-Reftype: branch X-Git-Commit: 8abcdb1f59ccdb75df84112427eb2a7ba7e69bb7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:14 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8abcdb1f59ccdb75df84112427eb2a7ba7e69bb7 commit 8abcdb1f59ccdb75df84112427eb2a7ba7e69bb7 Author: Mateusz Guzik AuthorDate: 2021-07-23 17:34:43 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:14:22 +0000 pf: hide struct pf_kstatus behind ifdef _KERNEL Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit d9cc6ea270ea52e860e3cc730876ee4324081586) --- sys/net/pfvar.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 52fd015ba54e..eda2e9fb71c0 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1146,6 +1146,7 @@ enum pf_syncookies_mode { PF_SYNCOOKIES_MODE_MAX = PF_SYNCOOKIES_ALWAYS }; +#ifdef _KERNEL struct pf_kstatus { counter_u64_t counters[PFRES_MAX]; /* reason for passing/dropping */ counter_u64_t lcounters[LCNT_MAX]; /* limit counters */ @@ -1163,6 +1164,7 @@ struct pf_kstatus { enum pf_syncookies_mode syncookies_mode; bool syncookies_active; }; +#endif struct pf_divert { union { From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2615B653DE1; Wed, 11 Aug 2021 13:25: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 4Gl9Y905Ggz3Cnb; Wed, 11 Aug 2021 13:25: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 CFDD17D7C; Wed, 11 Aug 2021 13:25: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 17BDPGaY004826; Wed, 11 Aug 2021 13:25:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BDPGI2004825; Wed, 11 Aug 2021 13:25:16 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:16 GMT Message-Id: <202108111325.17BDPGI2004825@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: abfc083a0859 - stable/12 - pf: drop redundant 'else' in pf_normalize_* 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/12 X-Git-Reftype: branch X-Git-Commit: abfc083a085902f296cf8c56731e9fcf9af99adc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:17 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=abfc083a085902f296cf8c56731e9fcf9af99adc commit abfc083a085902f296cf8c56731e9fcf9af99adc Author: Mateusz Guzik AuthorDate: 2021-07-24 05:17:27 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:15:11 +0000 pf: drop redundant 'else' in pf_normalize_* Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 6f1fb6561236fa933835a9a67bd442053fb509e9) --- sys/netpfil/pf/pf_norm.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index ea49fb230021..8ffa690ac36f 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -1061,10 +1061,9 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - else { - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); - } + + counter_u64_add(r->packets[dir == PF_OUT], 1); + counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (hlen < (int)sizeof(struct ip)) { @@ -1204,10 +1203,9 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - else { - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); - } + + counter_u64_add(r->packets[dir == PF_OUT], 1); + counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (sizeof(struct ip6_hdr) + IPV6_MAXPACKET < m->m_pkthdr.len) @@ -1390,10 +1388,9 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, if (rm == NULL || rm->action == PF_NOSCRUB) return (PF_PASS); - else { - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); - } + + counter_u64_add(r->packets[dir == PF_OUT], 1); + counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); if (rm->rule_flag & PFRULE_REASSEMBLE_TCP) pd->flags |= PFDESC_TCP_NORM; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67C9865386D; Wed, 11 Aug 2021 13: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 4Gl9YB1Hymz3Chr; Wed, 11 Aug 2021 13:25: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 0B9E77EF4; Wed, 11 Aug 2021 13:25: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 17BDPH16004850; Wed, 11 Aug 2021 13: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 17BDPHnL004849; Wed, 11 Aug 2021 13:25:17 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:17 GMT Message-Id: <202108111325.17BDPHnL004849@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: 5bc73c369dba - stable/12 - pf: add hybrid 32- an 64- bit counters 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/12 X-Git-Reftype: branch X-Git-Commit: 5bc73c369dbae8759f5735ca5a1f940127cec2db Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:18 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=5bc73c369dbae8759f5735ca5a1f940127cec2db commit 5bc73c369dbae8759f5735ca5a1f940127cec2db Author: Mateusz Guzik AuthorDate: 2021-07-22 20:47:24 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:20:09 +0000 pf: add hybrid 32- an 64- bit counters Numerous counters got migrated from straight uint64_t to the counter(9) API. Unfortunately the implementation comes with a significiant performance hit on some platforms and cannot be easily fixed. Work around the problem by implementing a pf-specific variant. Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit defdcdd5648dc1ea789bc54bb45108fcab546a6b) --- sys/net/pfvar.h | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sys/netpfil/pf/pf.c | 28 ++++++- 2 files changed, 245 insertions(+), 1 deletion(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index eda2e9fb71c0..fd0b36c72a42 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -43,9 +43,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -64,6 +66,222 @@ #ifdef _KERNEL +#if defined(__arm__) +#define PF_WANT_32_TO_64_COUNTER +#endif + +/* + * A hybrid of 32-bit and 64-bit counters which can be used on platforms where + * counter(9) is very expensive. + * + * As 32-bit counters are expected to overflow, a periodic job sums them up to + * a saved 64-bit state. Fetching the value still walks all CPUs to get the most + * current snapshot. + */ +#ifdef PF_WANT_32_TO_64_COUNTER +struct pf_counter_u64_pcpu { + u_int32_t current; + u_int32_t snapshot; +}; + +struct pf_counter_u64 { + struct pf_counter_u64_pcpu *pfcu64_pcpu; + u_int64_t pfcu64_value; + seq_t pfcu64_seqc; +}; + +static inline int +pf_counter_u64_init(struct pf_counter_u64 *pfcu64, int flags) +{ + + pfcu64->pfcu64_value = 0; + pfcu64->pfcu64_seqc = 0; + pfcu64->pfcu64_pcpu = uma_zalloc_pcpu(pcpu_zone_64, flags | M_ZERO); + if (__predict_false(pfcu64->pfcu64_pcpu == NULL)) + return (ENOMEM); + return (0); +} + +static inline void +pf_counter_u64_deinit(struct pf_counter_u64 *pfcu64) +{ + + uma_zfree_pcpu(pcpu_zone_64, pfcu64->pfcu64_pcpu); +} + +static inline void +pf_counter_u64_critical_enter(void) +{ + + critical_enter(); +} + +static inline void +pf_counter_u64_critical_exit(void) +{ + + critical_exit(); +} + +static inline void +pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + struct pf_counter_u64_pcpu *pcpu; + u_int32_t val; + + MPASS(curthread->td_critnest > 0); + pcpu = zpcpu_get(pfcu64->pfcu64_pcpu); + val = atomic_load_int(&pcpu->current); + atomic_store_int(&pcpu->current, val + n); +} + +static inline void +pf_counter_u64_add(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + + critical_enter(); + pf_counter_u64_add_protected(pfcu64, n); + critical_exit(); +} + +static inline u_int64_t +pf_counter_u64_periodic(struct pf_counter_u64 *pfcu64) +{ + struct pf_counter_u64_pcpu *pcpu; + u_int64_t sum; + u_int32_t val; + int cpu; + + MPASS(curthread->td_critnest > 0); + seq_write_begin(&pfcu64->pfcu64_seqc); + sum = pfcu64->pfcu64_value; + CPU_FOREACH(cpu) { + pcpu = zpcpu_get_cpu(pfcu64->pfcu64_pcpu, cpu); + val = atomic_load_int(&pcpu->current); + sum += (uint32_t)(val - pcpu->snapshot); + pcpu->snapshot = val; + } + pfcu64->pfcu64_value = sum; + seq_write_end(&pfcu64->pfcu64_seqc); + return (sum); +} + +static inline u_int64_t +pf_counter_u64_fetch(struct pf_counter_u64 *pfcu64) +{ + struct pf_counter_u64_pcpu *pcpu; + u_int64_t sum; + seq_t seqc; + int cpu; + + for (;;) { + seqc = seq_load(&pfcu64->pfcu64_seqc); + sum = 0; + CPU_FOREACH(cpu) { + pcpu = zpcpu_get_cpu(pfcu64->pfcu64_pcpu, cpu); + sum += (uint32_t)(atomic_load_int(&pcpu->current) -pcpu->snapshot); + } + sum += pfcu64->pfcu64_value; + if (seq_consistent(&pfcu64->pfcu64_seqc, seqc)) + break; + } + return (sum); +} + +static inline void +pf_counter_u64_zero_protected(struct pf_counter_u64 *pfcu64) +{ + struct pf_counter_u64_pcpu *pcpu; + int cpu; + + MPASS(curthread->td_critnest > 0); + seq_write_begin(&pfcu64->pfcu64_seqc); + CPU_FOREACH(cpu) { + pcpu = zpcpu_get_cpu(pfcu64->pfcu64_pcpu, cpu); + pcpu->snapshot = atomic_load_int(&pcpu->current); + } + pfcu64->pfcu64_value = 0; + seq_write_end(&pfcu64->pfcu64_seqc); +} + +static inline void +pf_counter_u64_zero(struct pf_counter_u64 *pfcu64) +{ + + critical_enter(); + pf_counter_u64_zero_protected(pfcu64); + critical_exit(); +} +#else +struct pf_counter_u64 { + counter_u64_t counter; +}; + +static inline int +pf_counter_u64_init(struct pf_counter_u64 *pfcu64, int flags) +{ + + pfcu64->counter = counter_u64_alloc(flags); + if (__predict_false(pfcu64->counter == NULL)) + return (ENOMEM); + return (0); +} + +static inline void +pf_counter_u64_deinit(struct pf_counter_u64 *pfcu64) +{ + + counter_u64_free(pfcu64->counter); +} + +static inline void +pf_counter_u64_critical_enter(void) +{ + +} + +static inline void +pf_counter_u64_critical_exit(void) +{ + +} + +static inline void +pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + + counter_u64_add(pfcu64->counter, n); +} + +static inline void +pf_counter_u64_add(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + + pf_counter_u64_add_protected(pfcu64, n); +} + +static inline u_int64_t +pf_counter_u64_fetch(struct pf_counter_u64 *pfcu64) +{ + + return (counter_u64_fetch(pfcu64->counter)); +} + +static inline void +pf_counter_u64_zero_protected(struct pf_counter_u64 *pfcu64) +{ + + counter_u64_zero(pfcu64->counter); +} + +static inline void +pf_counter_u64_zero(struct pf_counter_u64 *pfcu64) +{ + + pf_counter_u64_zero_protected(pfcu64); +} +#endif + SYSCTL_DECL(_net_pf); MALLOC_DECLARE(M_PFHASH); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index a7b429120c9e..5edafe4b5e7a 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -155,6 +155,11 @@ VNET_DECLARE(int, pf_vnet_active); VNET_DEFINE_STATIC(uint32_t, pf_purge_idx); #define V_pf_purge_idx VNET(pf_purge_idx) +#ifdef PF_WANT_32_TO_64_COUNTER +VNET_DEFINE_STATIC(uint32_t, pf_counter_periodic_iter); +#define V_pf_counter_periodic_iter VNET(pf_counter_periodic_iter) +#endif + /* * Queue for pf_intr() sends. */ @@ -1505,6 +1510,25 @@ pf_intr(void *v) CURVNET_RESTORE(); } +#define pf_purge_thread_period (hz / 10) + +#ifdef PF_WANT_32_TO_64_COUNTER +static void +pf_counter_u64_periodic_main(void) +{ + PF_RULES_RLOCK_TRACKER; + + V_pf_counter_periodic_iter++; + + PF_RULES_RLOCK(); + pf_counter_u64_critical_enter(); + pf_counter_u64_critical_exit(); + PF_RULES_RUNLOCK(); +} +#else +#define pf_counter_u64_periodic_main() do { } while (0) +#endif + void pf_purge_thread(void *unused __unused) { @@ -1512,7 +1536,7 @@ pf_purge_thread(void *unused __unused) sx_xlock(&pf_end_lock); while (pf_end_threads == 0) { - sx_sleep(pf_purge_thread, &pf_end_lock, 0, "pftm", hz / 10); + sx_sleep(pf_purge_thread, &pf_end_lock, 0, "pftm", pf_purge_thread_period); VNET_LIST_RLOCK(); VNET_FOREACH(vnet_iter) { @@ -1525,6 +1549,8 @@ pf_purge_thread(void *unused __unused) continue; } + pf_counter_u64_periodic_main(); + /* * Process 1/interval fraction of the state * table every run. From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 55FDA6536EB; Wed, 11 Aug 2021 13:25:19 +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 4Gl9YC1gbXz3ClZ; Wed, 11 Aug 2021 13:25: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 152B37EF5; Wed, 11 Aug 2021 13:25: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 17BDPINU004881; Wed, 11 Aug 2021 13:25:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BDPIGS004880; Wed, 11 Aug 2021 13:25:18 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:18 GMT Message-Id: <202108111325.17BDPIGS004880@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: f45535b6c79d - stable/12 - pf: switch pf_status.fcounters to pf_counter_u64 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/12 X-Git-Reftype: branch X-Git-Commit: f45535b6c79d359625fb2d9cff5e46de5bd59861 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:19 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f45535b6c79d359625fb2d9cff5e46de5bd59861 commit f45535b6c79d359625fb2d9cff5e46de5bd59861 Author: Mateusz Guzik AuthorDate: 2021-07-24 05:33:52 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:21:04 +0000 pf: switch pf_status.fcounters to pf_counter_u64 Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit fc4c42ce0b5ce87901b327e25f55b4e3ab4c6cf5) --- sys/net/pfvar.h | 2 +- sys/netpfil/pf/pf.c | 26 +++++++++++++++++++++----- sys/netpfil/pf/pf_ioctl.c | 8 ++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index fd0b36c72a42..7c1e92d39470 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1368,7 +1368,7 @@ enum pf_syncookies_mode { struct pf_kstatus { counter_u64_t counters[PFRES_MAX]; /* reason for passing/dropping */ counter_u64_t lcounters[LCNT_MAX]; /* limit counters */ - counter_u64_t fcounters[FCNT_MAX]; /* state operation counters */ + struct pf_counter_u64 fcounters[FCNT_MAX]; /* state operation counters */ counter_u64_t scounters[SCNT_MAX]; /* src_node operation counters */ uint32_t states; uint32_t src_nodes; diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 5edafe4b5e7a..1ba95754bd32 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1311,7 +1311,7 @@ pf_state_insert(struct pfi_kkif *kif, struct pfi_kkif *orig_kif, /* One for keys, one for ID hash. */ refcount_init(&s->refs, 2); - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_INSERT], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_INSERT], 1); if (V_pfsync_insert_state_ptr != NULL) V_pfsync_insert_state_ptr(s); @@ -1328,7 +1328,7 @@ pf_find_state_byid(uint64_t id, uint32_t creatorid) struct pf_idhash *ih; struct pf_kstate *s; - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); ih = &V_pf_idhash[(be64toh(id) % (pf_hashmask + 1))]; @@ -1355,7 +1355,7 @@ pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir) struct pf_kstate *s; int idx; - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; @@ -1399,7 +1399,7 @@ pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more) struct pf_kstate *s, *ret = NULL; int idx, inout = 0; - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; @@ -1513,6 +1513,21 @@ pf_intr(void *v) #define pf_purge_thread_period (hz / 10) #ifdef PF_WANT_32_TO_64_COUNTER +static void +pf_status_counter_u64_periodic(void) +{ + + PF_RULES_RASSERT(); + + if ((V_pf_counter_periodic_iter % (pf_purge_thread_period * 10 * 60)) != 0) { + return; + } + + for (int i = 0; i < FCNT_MAX; i++) { + pf_counter_u64_periodic(&V_pf_status.fcounters[i]); + } +} + static void pf_counter_u64_periodic_main(void) { @@ -1522,6 +1537,7 @@ pf_counter_u64_periodic_main(void) PF_RULES_RLOCK(); pf_counter_u64_critical_enter(); + pf_status_counter_u64_periodic(); pf_counter_u64_critical_exit(); PF_RULES_RUNLOCK(); } @@ -1779,7 +1795,7 @@ pf_free_state(struct pf_kstate *cur) pf_normalize_tcp_cleanup(cur); uma_zfree(V_pf_state_z, cur); - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_REMOVALS], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_REMOVALS], 1); } /* diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index bb71f44cad97..1b2c329fdb2c 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -354,7 +354,7 @@ pfattach_vnet(void) for (int i = 0; i < LCNT_MAX; i++) V_pf_status.lcounters[i] = counter_u64_alloc(M_WAITOK); for (int i = 0; i < FCNT_MAX; i++) - V_pf_status.fcounters[i] = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&V_pf_status.fcounters[i], M_WAITOK); for (int i = 0; i < SCNT_MAX; i++) V_pf_status.scounters[i] = counter_u64_alloc(M_WAITOK); @@ -3019,7 +3019,7 @@ DIOCGETSTATESV2_full: counter_u64_fetch(V_pf_status.lcounters[i]); for (int i = 0; i < FCNT_MAX; i++) s->fcounters[i] = - counter_u64_fetch(V_pf_status.fcounters[i]); + pf_counter_u64_fetch(&V_pf_status.fcounters[i]); for (int i = 0; i < SCNT_MAX; i++) s->scounters[i] = counter_u64_fetch(V_pf_status.scounters[i]); @@ -3051,7 +3051,7 @@ DIOCGETSTATESV2_full: for (int i = 0; i < PFRES_MAX; i++) counter_u64_zero(V_pf_status.counters[i]); for (int i = 0; i < FCNT_MAX; i++) - counter_u64_zero(V_pf_status.fcounters[i]); + pf_counter_u64_zero(&V_pf_status.fcounters[i]); for (int i = 0; i < SCNT_MAX; i++) counter_u64_zero(V_pf_status.scounters[i]); for (int i = 0; i < LCNT_MAX; i++) @@ -5616,7 +5616,7 @@ pf_unload_vnet(void) for (int i = 0; i < LCNT_MAX; i++) counter_u64_free(V_pf_status.lcounters[i]); for (int i = 0; i < FCNT_MAX; i++) - counter_u64_free(V_pf_status.fcounters[i]); + pf_counter_u64_deinit(&V_pf_status.fcounters[i]); for (int i = 0; i < SCNT_MAX; i++) counter_u64_free(V_pf_status.scounters[i]); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AD036538EB; Wed, 11 Aug 2021 13:25: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 4Gl9YD2SB1z3Cpg; Wed, 11 Aug 2021 13:25: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 39A4210137; Wed, 11 Aug 2021 13:25: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 17BDPK24004905; Wed, 11 Aug 2021 13:25:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BDPKxP004904; Wed, 11 Aug 2021 13:25:20 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:20 GMT Message-Id: <202108111325.17BDPKxP004904@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: 72b14da466bb - stable/12 - pf: switch kif counters to pf_counter_u64 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/12 X-Git-Reftype: branch X-Git-Commit: 72b14da466bbb9eebf2400930abefce8de47261d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:20 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=72b14da466bbb9eebf2400930abefce8de47261d commit 72b14da466bbb9eebf2400930abefce8de47261d Author: Mateusz Guzik AuthorDate: 2021-07-23 10:29:46 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:21:48 +0000 pf: switch kif counters to pf_counter_u64 Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit d40d4b3ed788b05697541b9ae94b1960ff2cf6f6) --- sys/net/pfvar.h | 17 +++++++++++-- sys/netpfil/pf/pf.c | 51 +++++++++++++++++++++++++++++++++++--- sys/netpfil/pf/pf_if.c | 62 +++++++++++++++++++++++++++++++++++------------ sys/netpfil/pf/pf_ioctl.c | 17 +++++++++++++ 4 files changed, 126 insertions(+), 21 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 7c1e92d39470..e8cf8b1e6019 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1255,14 +1255,17 @@ struct pfi_kkif { } _pfik_glue; #define pfik_tree _pfik_glue._pfik_tree #define pfik_list _pfik_glue._pfik_list - counter_u64_t pfik_packets[2][2][2]; - counter_u64_t pfik_bytes[2][2][2]; + struct pf_counter_u64 pfik_packets[2][2][2]; + struct pf_counter_u64 pfik_bytes[2][2][2]; u_int32_t pfik_tzero; u_int pfik_flags; struct ifnet *pfik_ifp; struct ifg_group *pfik_group; u_int pfik_rulerefs; TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs; +#ifdef PF_WANT_32_TO_64_COUNTER + LIST_ENTRY(pfi_kkif) pfik_allkiflist; +#endif }; #endif @@ -1848,6 +1851,16 @@ VNET_DECLARE(struct pf_altqqueue *, pf_altq_ifs_inactive); VNET_DECLARE(struct pf_krulequeue, pf_unlinked_rules); #define V_pf_unlinked_rules VNET(pf_unlinked_rules) +#ifdef PF_WANT_32_TO_64_COUNTER +LIST_HEAD(allkiflist_head, pfi_kkif); +VNET_DECLARE(struct allkiflist_head, pf_allkiflist); +#define V_pf_allkiflist VNET(pf_allkiflist) +VNET_DECLARE(size_t, pf_allkifcount); +#define V_pf_allkifcount VNET(pf_allkifcount) +VNET_DECLARE(struct pfi_kkif *, pf_kifmarker); +#define V_pf_kifmarker VNET(pf_kifmarker) +#endif + void pf_initialize(void); void pf_mtag_initialize(void); void pf_mtag_cleanup(void); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 1ba95754bd32..3dcea7e59bd0 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1528,6 +1528,48 @@ pf_status_counter_u64_periodic(void) } } +static void +pf_kif_counter_u64_periodic(void) +{ + struct pfi_kkif *kif; + size_t r, run; + + PF_RULES_RASSERT(); + + if (__predict_false(V_pf_allkifcount == 0)) { + return; + } + + if ((V_pf_counter_periodic_iter % (pf_purge_thread_period * 10 * 300)) != 0) { + return; + } + + run = V_pf_allkifcount / 10; + if (run < 5) + run = 5; + + for (r = 0; r < run; r++) { + kif = LIST_NEXT(V_pf_kifmarker, pfik_allkiflist); + if (kif == NULL) { + LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); + LIST_INSERT_HEAD(&V_pf_allkiflist, V_pf_kifmarker, pfik_allkiflist); + break; + } + + LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); + LIST_INSERT_AFTER(kif, V_pf_kifmarker, pfik_allkiflist); + + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + for (int k = 0; k < 2; k++) { + pf_counter_u64_periodic(&kif->pfik_packets[i][j][k]); + pf_counter_u64_periodic(&kif->pfik_bytes[i][j][k]); + } + } + } + } +} + static void pf_counter_u64_periodic_main(void) { @@ -1538,6 +1580,7 @@ pf_counter_u64_periodic_main(void) PF_RULES_RLOCK(); pf_counter_u64_critical_enter(); pf_status_counter_u64_periodic(); + pf_kif_counter_u64_periodic(); pf_counter_u64_critical_exit(); PF_RULES_RUNLOCK(); } @@ -6468,9 +6511,9 @@ done: (s == NULL)); } - counter_u64_add(kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], pd.tot_len); - counter_u64_add(kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { @@ -6876,9 +6919,9 @@ done: &pd, (s == NULL)); } - counter_u64_add(kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], pd.tot_len); - counter_u64_add(kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c index 9c10be3b3b77..ff2038138068 100644 --- a/sys/netpfil/pf/pf_if.c +++ b/sys/netpfil/pf/pf_if.c @@ -69,6 +69,12 @@ VNET_DEFINE_STATIC(int, pfi_buffer_max); #define V_pfi_buffer_cnt VNET(pfi_buffer_cnt) #define V_pfi_buffer_max VNET(pfi_buffer_max) +#ifdef PF_WANT_32_TO_64_COUNTER +VNET_DEFINE(struct allkiflist_head, pf_allkiflist); +VNET_DEFINE(size_t, pf_allkifcount); +VNET_DEFINE(struct pfi_kkif *, pf_kifmarker); +#endif + eventhandler_tag pfi_attach_cookie; eventhandler_tag pfi_detach_cookie; eventhandler_tag pfi_attach_group_cookie; @@ -198,6 +204,9 @@ struct pfi_kkif* pf_kkif_create(int flags) { struct pfi_kkif *kif; +#ifdef PF_WANT_32_TO_64_COUNTER + bool wowned; +#endif kif = malloc(sizeof(*kif), PFI_MTYPE, flags | M_ZERO); if (! kif) @@ -206,13 +215,12 @@ pf_kkif_create(int flags) for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { - kif->pfik_packets[i][j][k] = - counter_u64_alloc(flags); - kif->pfik_bytes[i][j][k] = - counter_u64_alloc(flags); + if (pf_counter_u64_init(&kif->pfik_packets[i][j][k], flags) != 0) { + pf_kkif_free(kif); + return (NULL); + } - if (! kif->pfik_packets[i][j][k] || - ! kif->pfik_bytes[i][j][k]) { + if (pf_counter_u64_init(&kif->pfik_bytes[i][j][k], flags) != 0) { pf_kkif_free(kif); return (NULL); } @@ -220,20 +228,44 @@ pf_kkif_create(int flags) } } +#ifdef PF_WANT_32_TO_64_COUNTER + wowned = PF_RULES_WOWNED(); + if (!wowned) + PF_RULES_WLOCK(); + LIST_INSERT_HEAD(&V_pf_allkiflist, kif, pfik_allkiflist); + V_pf_allkifcount++; + if (!wowned) + PF_RULES_WUNLOCK(); +#endif + return (kif); } void pf_kkif_free(struct pfi_kkif *kif) { +#ifdef PF_WANT_32_TO_64_COUNTER + bool wowned; +#endif + if (! kif) return; +#ifdef PF_WANT_32_TO_64_COUNTER + wowned = PF_RULES_WOWNED(); + if (!wowned) + PF_RULES_WLOCK(); + LIST_REMOVE(kif, pfik_allkiflist); + V_pf_allkifcount--; + if (!wowned) + PF_RULES_WUNLOCK(); +#endif + for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { - counter_u64_free(kif->pfik_packets[i][j][k]); - counter_u64_free(kif->pfik_bytes[i][j][k]); + pf_counter_u64_deinit(&kif->pfik_packets[i][j][k]); + pf_counter_u64_deinit(&kif->pfik_bytes[i][j][k]); } } } @@ -248,8 +280,8 @@ pf_kkif_zero(struct pfi_kkif *kif) for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { - counter_u64_zero(kif->pfik_packets[i][j][k]); - counter_u64_zero(kif->pfik_bytes[i][j][k]); + pf_counter_u64_zero(&kif->pfik_packets[i][j][k]); + pf_counter_u64_zero(&kif->pfik_bytes[i][j][k]); } } } @@ -791,15 +823,15 @@ pfi_update_status(const char *name, struct pf_status *pfs) for (j = 0; j < 2; j++) for (k = 0; k < 2; k++) { pfs->pcounters[i][j][k] += - counter_u64_fetch(p->pfik_packets[i][j][k]); + pf_counter_u64_fetch(&p->pfik_packets[i][j][k]); pfs->bcounters[i][j] += - counter_u64_fetch(p->pfik_bytes[i][j][k]); + pf_counter_u64_fetch(&p->pfik_bytes[i][j][k]); } } } static void -pf_kkif_to_kif(const struct pfi_kkif *kkif, struct pfi_kif *kif) +pf_kkif_to_kif(struct pfi_kkif *kkif, struct pfi_kif *kif) { bzero(kif, sizeof(*kif)); @@ -808,9 +840,9 @@ pf_kkif_to_kif(const struct pfi_kkif *kkif, struct pfi_kif *kif) for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { kif->pfik_packets[i][j][k] = - counter_u64_fetch(kkif->pfik_packets[i][j][k]); + pf_counter_u64_fetch(&kkif->pfik_packets[i][j][k]); kif->pfik_bytes[i][j][k] = - counter_u64_fetch(kkif->pfik_bytes[i][j][k]); + pf_counter_u64_fetch(&kkif->pfik_bytes[i][j][k]); } } } diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 1b2c329fdb2c..e02fff4f88f6 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -319,6 +319,13 @@ pfattach_vnet(void) V_pf_default_rule.states_tot = counter_u64_alloc(M_WAITOK); V_pf_default_rule.src_nodes = counter_u64_alloc(M_WAITOK); +#ifdef PF_WANT_32_TO_64_COUNTER + V_pf_kifmarker = malloc(sizeof(*V_pf_kifmarker), PFI_MTYPE, M_WAITOK | M_ZERO); + PF_RULES_WLOCK(); + LIST_INSERT_HEAD(&V_pf_allkiflist, V_pf_kifmarker, pfik_allkiflist); + PF_RULES_WUNLOCK(); +#endif + /* initialize default timeouts */ my_timeout[PFTM_TCP_FIRST_PACKET] = PFTM_TCP_FIRST_PACKET_VAL; my_timeout[PFTM_TCP_OPENING] = PFTM_TCP_OPENING_VAL; @@ -5601,6 +5608,16 @@ pf_unload_vnet(void) #endif uma_zdestroy(V_pf_tag_z); +#ifdef PF_WANT_32_TO_64_COUNTER + PF_RULES_WLOCK(); + LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); + PF_RULES_WUNLOCK(); + free(V_pf_kifmarker, PFI_MTYPE); + + MPASS(LIST_EMPTY(&V_pf_allkiflist)); + MPASS(V_pf_allkifcount == 0); +#endif + /* Free counters last as we updated them during shutdown. */ counter_u64_free(V_pf_default_rule.evaluations); for (int i = 0; i < 2; i++) { From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AA74265387D; Wed, 11 Aug 2021 13:25: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 4Gl9YF3bmlz3CP6; Wed, 11 Aug 2021 13:25: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 5E5207DE9; Wed, 11 Aug 2021 13:25: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 17BDPL30004929; Wed, 11 Aug 2021 13:25:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BDPLNt004928; Wed, 11 Aug 2021 13:25:21 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:21 GMT Message-Id: <202108111325.17BDPLNt004928@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: 463aa33ff662 - stable/12 - pf: switch rule counters to pf_counter_u64 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/12 X-Git-Reftype: branch X-Git-Commit: 463aa33ff66280385dcc34d51233b14f33a69403 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:22 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=463aa33ff66280385dcc34d51233b14f33a69403 commit 463aa33ff66280385dcc34d51233b14f33a69403 Author: Mateusz Guzik AuthorDate: 2021-07-22 14:45:14 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:22:27 +0000 pf: switch rule counters to pf_counter_u64 Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 02cf67ccf6538b14677672640e405f7f94044dc3) --- sys/net/pfvar.h | 19 ++++++- sys/netpfil/pf/pf.c | 80 +++++++++++++++++++++------ sys/netpfil/pf/pf_ioctl.c | 137 +++++++++++++++++++++++++++++++--------------- sys/netpfil/pf/pf_lb.c | 2 +- sys/netpfil/pf/pf_norm.c | 18 +++--- sys/netpfil/pf/pf_nv.c | 8 +-- sys/netpfil/pf/pf_nv.h | 2 +- 7 files changed, 185 insertions(+), 81 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index e8cf8b1e6019..624456149162 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -583,9 +583,9 @@ struct pf_krule { TAILQ_ENTRY(pf_krule) entries; struct pf_kpool rpool; - counter_u64_t evaluations; - counter_u64_t packets[2]; - counter_u64_t bytes[2]; + struct pf_counter_u64 evaluations; + struct pf_counter_u64 packets[2]; + struct pf_counter_u64 bytes[2]; struct pfi_kkif *kif; struct pf_kanchor *anchor; @@ -659,6 +659,11 @@ struct pf_krule { struct pf_addr addr; u_int16_t port; } divert; + +#ifdef PF_WANT_32_TO_64_COUNTER + LIST_ENTRY(pf_krule) allrulelist; + bool allrulelinked; +#endif }; struct pf_ksrc_node { @@ -1859,6 +1864,14 @@ VNET_DECLARE(size_t, pf_allkifcount); #define V_pf_allkifcount VNET(pf_allkifcount) VNET_DECLARE(struct pfi_kkif *, pf_kifmarker); #define V_pf_kifmarker VNET(pf_kifmarker) + +LIST_HEAD(allrulelist_head, pf_krule); +VNET_DECLARE(struct allrulelist_head, pf_allrulelist); +#define V_pf_allrulelist VNET(pf_allrulelist) +VNET_DECLARE(size_t, pf_allrulecount); +#define V_pf_allrulecount VNET(pf_allrulecount) +VNET_DECLARE(struct pf_krule *, pf_rulemarker); +#define V_pf_rulemarker VNET(pf_rulemarker) #endif void pf_initialize(void); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 3dcea7e59bd0..0c485189ec16 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -158,6 +158,10 @@ VNET_DEFINE_STATIC(uint32_t, pf_purge_idx); #ifdef PF_WANT_32_TO_64_COUNTER VNET_DEFINE_STATIC(uint32_t, pf_counter_periodic_iter); #define V_pf_counter_periodic_iter VNET(pf_counter_periodic_iter) + +VNET_DEFINE(struct allrulelist_head, pf_allrulelist); +VNET_DEFINE(size_t, pf_allrulecount); +VNET_DEFINE(struct pf_krule *, pf_rulemarker); #endif /* @@ -1570,6 +1574,45 @@ pf_kif_counter_u64_periodic(void) } } +static void +pf_rule_counter_u64_periodic(void) +{ + struct pf_krule *rule; + size_t r, run; + + PF_RULES_RASSERT(); + + if (__predict_false(V_pf_allrulecount == 0)) { + return; + } + + if ((V_pf_counter_periodic_iter % (pf_purge_thread_period * 10 * 300)) != 0) { + return; + } + + run = V_pf_allrulecount / 10; + if (run < 5) + run = 5; + + for (r = 0; r < run; r++) { + rule = LIST_NEXT(V_pf_rulemarker, allrulelist); + if (rule == NULL) { + LIST_REMOVE(V_pf_rulemarker, allrulelist); + LIST_INSERT_HEAD(&V_pf_allrulelist, V_pf_rulemarker, allrulelist); + break; + } + + LIST_REMOVE(V_pf_rulemarker, allrulelist); + LIST_INSERT_AFTER(rule, V_pf_rulemarker, allrulelist); + + pf_counter_u64_periodic(&rule->evaluations); + for (int i = 0; i < 2; i++) { + pf_counter_u64_periodic(&rule->packets[i]); + pf_counter_u64_periodic(&rule->bytes[i]); + } + } +} + static void pf_counter_u64_periodic_main(void) { @@ -1581,6 +1624,7 @@ pf_counter_u64_periodic_main(void) pf_counter_u64_critical_enter(); pf_status_counter_u64_periodic(); pf_kif_counter_u64_periodic(); + pf_rule_counter_u64_periodic(); pf_counter_u64_critical_exit(); PF_RULES_RUNLOCK(); } @@ -3643,7 +3687,7 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, int direction, } while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != direction) @@ -3712,8 +3756,8 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, int direction, rtableid = r->rtableid; if (r->anchor == NULL) { if (r->action == PF_MATCH) { - counter_u64_add(r->packets[direction == PF_OUT], 1); - counter_u64_add(r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -4085,7 +4129,7 @@ pf_test_fragment(struct pf_krule **rm, int direction, struct pfi_kkif *kif, r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_FILTER].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != direction) @@ -4126,8 +4170,8 @@ pf_test_fragment(struct pf_krule **rm, int direction, struct pfi_kkif *kif, else { if (r->anchor == NULL) { if (r->action == PF_MATCH) { - counter_u64_add(r->packets[direction == PF_OUT], 1); - counter_u64_add(r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -6518,17 +6562,17 @@ done: if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - counter_u64_add(r->packets[dirndx], 1); - counter_u64_add(r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&r->packets[dirndx], 1); + pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - counter_u64_add(a->packets[dirndx], 1); - counter_u64_add(a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&a->packets[dirndx], 1); + pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - counter_u64_add(s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], 1); - counter_u64_add(s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { @@ -6926,17 +6970,17 @@ done: if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - counter_u64_add(r->packets[dirndx], 1); - counter_u64_add(r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&r->packets[dirndx], 1); + pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - counter_u64_add(a->packets[dirndx], 1); - counter_u64_add(a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&a->packets[dirndx], 1); + pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - counter_u64_add(s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], 1); - counter_u64_add(s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index e02fff4f88f6..81b50c237252 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -310,10 +310,10 @@ pfattach_vnet(void) V_pf_default_rule.nr = -1; V_pf_default_rule.rtableid = -1; - V_pf_default_rule.evaluations = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&V_pf_default_rule.evaluations, M_WAITOK); for (int i = 0; i < 2; i++) { - V_pf_default_rule.packets[i] = counter_u64_alloc(M_WAITOK); - V_pf_default_rule.bytes[i] = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&V_pf_default_rule.packets[i], M_WAITOK); + pf_counter_u64_init(&V_pf_default_rule.bytes[i], M_WAITOK); } V_pf_default_rule.states_cur = counter_u64_alloc(M_WAITOK); V_pf_default_rule.states_tot = counter_u64_alloc(M_WAITOK); @@ -321,8 +321,12 @@ pfattach_vnet(void) #ifdef PF_WANT_32_TO_64_COUNTER V_pf_kifmarker = malloc(sizeof(*V_pf_kifmarker), PFI_MTYPE, M_WAITOK | M_ZERO); + V_pf_rulemarker = malloc(sizeof(*V_pf_rulemarker), M_PFRULE, M_WAITOK | M_ZERO); PF_RULES_WLOCK(); LIST_INSERT_HEAD(&V_pf_allkiflist, V_pf_kifmarker, pfik_allkiflist); + LIST_INSERT_HEAD(&V_pf_allrulelist, &V_pf_default_rule, allrulelist); + V_pf_allrulecount++; + LIST_INSERT_HEAD(&V_pf_allrulelist, V_pf_rulemarker, allrulelist); PF_RULES_WUNLOCK(); #endif @@ -1116,16 +1120,16 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) while ((tail != NULL) && ! pf_krule_compare(tail, rule)) tail = TAILQ_NEXT(tail, entries); if (tail != NULL) { - counter_u64_add(rule->evaluations, - counter_u64_fetch(tail->evaluations)); - counter_u64_add(rule->packets[0], - counter_u64_fetch(tail->packets[0])); - counter_u64_add(rule->packets[1], - counter_u64_fetch(tail->packets[1])); - counter_u64_add(rule->bytes[0], - counter_u64_fetch(tail->bytes[0])); - counter_u64_add(rule->bytes[1], - counter_u64_fetch(tail->bytes[1])); + pf_counter_u64_add(&rule->evaluations, + pf_counter_u64_fetch(&tail->evaluations)); + pf_counter_u64_add(&rule->packets[0], + pf_counter_u64_fetch(&tail->packets[0])); + pf_counter_u64_add(&rule->packets[1], + pf_counter_u64_fetch(&tail->packets[1])); + pf_counter_u64_add(&rule->bytes[0], + pf_counter_u64_fetch(&tail->bytes[0])); + pf_counter_u64_add(&rule->bytes[1], + pf_counter_u64_fetch(&tail->bytes[1])); } } } @@ -1506,13 +1510,29 @@ pf_altq_get_nth_active(u_int32_t n) void pf_krule_free(struct pf_krule *rule) { +#ifdef PF_WANT_32_TO_64_COUNTER + bool wowned; +#endif + if (rule == NULL) return; - counter_u64_free(rule->evaluations); +#ifdef PF_WANT_32_TO_64_COUNTER + if (rule->allrulelinked) { + wowned = PF_RULES_WOWNED(); + if (!wowned) + PF_RULES_WLOCK(); + LIST_REMOVE(rule, allrulelist); + V_pf_allrulecount--; + if (!wowned) + PF_RULES_WUNLOCK(); + } +#endif + + pf_counter_u64_deinit(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_free(rule->packets[i]); - counter_u64_free(rule->bytes[i]); + pf_counter_u64_deinit(&rule->packets[i]); + pf_counter_u64_deinit(&rule->bytes[i]); } counter_u64_free(rule->states_cur); counter_u64_free(rule->states_tot); @@ -1574,7 +1594,7 @@ pf_pool_to_kpool(const struct pf_pool *pool, struct pf_kpool *kpool) } static void -pf_krule_to_rule(const struct pf_krule *krule, struct pf_rule *rule) +pf_krule_to_rule(struct pf_krule *krule, struct pf_rule *rule) { bzero(rule, sizeof(*rule)); @@ -1601,10 +1621,10 @@ pf_krule_to_rule(const struct pf_krule *krule, struct pf_rule *rule) pf_kpool_to_pool(&krule->rpool, &rule->rpool); - rule->evaluations = counter_u64_fetch(krule->evaluations); + rule->evaluations = pf_counter_u64_fetch(&krule->evaluations); for (int i = 0; i < 2; i++) { - rule->packets[i] = counter_u64_fetch(krule->packets[i]); - rule->bytes[i] = counter_u64_fetch(krule->bytes[i]); + rule->packets[i] = pf_counter_u64_fetch(&krule->packets[i]); + rule->bytes[i] = pf_counter_u64_fetch(&krule->bytes[i]); } /* kif, anchor, overload_tbl are not copied over. */ @@ -1958,10 +1978,10 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, if (rule->ifname[0]) kif = pf_kkif_create(M_WAITOK); - rule->evaluations = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&rule->evaluations, M_WAITOK); for (int i = 0; i < 2; i++) { - rule->packets[i] = counter_u64_alloc(M_WAITOK); - rule->bytes[i] = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&rule->packets[i], M_WAITOK); + pf_counter_u64_init(&rule->bytes[i], M_WAITOK); } rule->states_cur = counter_u64_alloc(M_WAITOK); rule->states_tot = counter_u64_alloc(M_WAITOK); @@ -1971,6 +1991,12 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, TAILQ_INIT(&rule->rpool.list); PF_RULES_WLOCK(); +#ifdef PF_WANT_32_TO_64_COUNTER + LIST_INSERT_HEAD(&V_pf_allrulelist, rule, allrulelist); + MPASS(!rule->allrulelinked); + rule->allrulelinked = true; + V_pf_allrulecount++; +#endif ruleset = pf_find_kruleset(anchor); if (ruleset == NULL) ERROUT(EINVAL); @@ -2074,10 +2100,10 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, } rule->rpool.cur = TAILQ_FIRST(&rule->rpool.list); - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } TAILQ_INSERT_TAIL(ruleset->rules[rs_num].inactive.ptr, rule, entries); @@ -2428,10 +2454,10 @@ DIOCADDRULENV_error: pf_addr_copyout(&pr->rule.dst.addr); if (pr->action == PF_GET_CLR_CNTR) { - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } counter_u64_zero(rule->states_tot); } @@ -2550,10 +2576,10 @@ DIOCADDRULENV_error: } if (clear_counter) { - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } counter_u64_zero(rule->states_tot); } @@ -2599,12 +2625,10 @@ DIOCGETRULENV_error: if (newrule->ifname[0]) kif = pf_kkif_create(M_WAITOK); - newrule->evaluations = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&newrule->evaluations, M_WAITOK); for (int i = 0; i < 2; i++) { - newrule->packets[i] = - counter_u64_alloc(M_WAITOK); - newrule->bytes[i] = - counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&newrule->packets[i], M_WAITOK); + pf_counter_u64_init(&newrule->bytes[i], M_WAITOK); } newrule->states_cur = counter_u64_alloc(M_WAITOK); newrule->states_tot = counter_u64_alloc(M_WAITOK); @@ -2617,6 +2641,14 @@ DIOCGETRULENV_error: #define ERROUT(x) { error = (x); goto DIOCCHANGERULE_error; } PF_RULES_WLOCK(); +#ifdef PF_WANT_32_TO_64_COUNTER + if (newrule != NULL) { + LIST_INSERT_HEAD(&V_pf_allrulelist, newrule, allrulelist); + newrule->allrulelinked = true; + V_pf_allrulecount++; + } +#endif + if (!(pcr->action == PF_CHANGE_REMOVE || pcr->action == PF_CHANGE_GET_TICKET) && pcr->pool_ticket != V_ticket_pabuf) @@ -3198,10 +3230,10 @@ DIOCGETSTATESV2_full: PF_RULES_WLOCK(); TAILQ_FOREACH(rule, ruleset->rules[PF_RULESET_FILTER].active.ptr, entries) { - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } } PF_RULES_WUNLOCK(); @@ -5611,18 +5643,33 @@ pf_unload_vnet(void) #ifdef PF_WANT_32_TO_64_COUNTER PF_RULES_WLOCK(); LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); - PF_RULES_WUNLOCK(); - free(V_pf_kifmarker, PFI_MTYPE); MPASS(LIST_EMPTY(&V_pf_allkiflist)); MPASS(V_pf_allkifcount == 0); + + LIST_REMOVE(&V_pf_default_rule, allrulelist); + V_pf_allrulecount--; + LIST_REMOVE(V_pf_rulemarker, allrulelist); + + /* + * There are known pf rule leaks when running the test suite. + */ +#ifdef notyet + MPASS(LIST_EMPTY(&V_pf_allrulelist)); + MPASS(V_pf_allrulecount == 0); +#endif + + PF_RULES_WUNLOCK(); + + free(V_pf_kifmarker, PFI_MTYPE); + free(V_pf_rulemarker, M_PFRULE); #endif /* Free counters last as we updated them during shutdown. */ - counter_u64_free(V_pf_default_rule.evaluations); + pf_counter_u64_deinit(&V_pf_default_rule.evaluations); for (int i = 0; i < 2; i++) { - counter_u64_free(V_pf_default_rule.packets[i]); - counter_u64_free(V_pf_default_rule.bytes[i]); + pf_counter_u64_deinit(&V_pf_default_rule.packets[i]); + pf_counter_u64_deinit(&V_pf_default_rule.bytes[i]); } counter_u64_free(V_pf_default_rule.states_cur); counter_u64_free(V_pf_default_rule.states_tot); diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c index b7079c47308a..24ff907cdc61 100644 --- a/sys/netpfil/pf/pf_lb.c +++ b/sys/netpfil/pf/pf_lb.c @@ -149,7 +149,7 @@ pf_match_translation(struct pf_pdesc *pd, struct mbuf *m, int off, dst = &r->dst; } - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != direction) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 8ffa690ac36f..19d3a268e4f8 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -1035,7 +1035,7 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != dir) @@ -1062,8 +1062,8 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (hlen < (int)sizeof(struct ip)) { @@ -1178,7 +1178,7 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != dir) @@ -1204,8 +1204,8 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (sizeof(struct ip6_hdr) + IPV6_MAXPACKET < m->m_pkthdr.len) @@ -1355,7 +1355,7 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != dir) @@ -1389,8 +1389,8 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, if (rm == NULL || rm->action == PF_NOSCRUB) return (PF_PASS); - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); if (rm->rule_flag & PFRULE_REASSEMBLE_TCP) pd->flags |= PFDESC_TCP_NORM; diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index c0a17cd876ae..d1eca90e0ee5 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -655,7 +655,7 @@ error: } nvlist_t * -pf_krule_to_nvrule(const struct pf_krule *rule) +pf_krule_to_nvrule(struct pf_krule *rule) { nvlist_t *nvl, *tmp; @@ -698,12 +698,12 @@ pf_krule_to_nvrule(const struct pf_krule *rule) nvlist_destroy(tmp); nvlist_add_number(nvl, "evaluations", - counter_u64_fetch(rule->evaluations)); + pf_counter_u64_fetch(&rule->evaluations)); for (int i = 0; i < 2; i++) { nvlist_append_number_array(nvl, "packets", - counter_u64_fetch(rule->packets[i])); + pf_counter_u64_fetch(&rule->packets[i])); nvlist_append_number_array(nvl, "bytes", - counter_u64_fetch(rule->bytes[i])); + pf_counter_u64_fetch(&rule->bytes[i])); } nvlist_add_number(nvl, "os_fingerprint", rule->os_fingerprint); diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index 2abb5a2401e2..f1cdc52aad6b 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -78,7 +78,7 @@ int pf_nvstring(const nvlist_t *, const char *, char *, size_t); int pf_check_rule_addr(const struct pf_rule_addr *); -nvlist_t *pf_krule_to_nvrule(const struct pf_krule *); +nvlist_t *pf_krule_to_nvrule(struct pf_krule *); int pf_nvrule_to_krule(const nvlist_t *, struct pf_krule *); int pf_nvstate_kill_to_kstate_kill(const nvlist_t *, struct pf_kstate_kill *); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 13:25:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB626653666; Wed, 11 Aug 2021 13:25: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 4Gl9YG451Sz3CjB; Wed, 11 Aug 2021 13:25: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 72D6310138; Wed, 11 Aug 2021 13:25: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 17BDPMaJ004953; Wed, 11 Aug 2021 13:25:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BDPMqY004952; Wed, 11 Aug 2021 13:25:22 GMT (envelope-from git) Date: Wed, 11 Aug 2021 13:25:22 GMT Message-Id: <202108111325.17BDPMqY004952@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: 2522a90dcd41 - stable/12 - pf: batch critical section for several counters 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/12 X-Git-Reftype: branch X-Git-Commit: 2522a90dcd41c9c8326525fa23876bb2acc7d51a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 13:25:23 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=2522a90dcd41c9c8326525fa23876bb2acc7d51a commit 2522a90dcd41c9c8326525fa23876bb2acc7d51a Author: Mateusz Guzik AuthorDate: 2021-07-24 07:47:40 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 12:23:20 +0000 pf: batch critical section for several counters Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 87c010e6e364e96e2c1546b3c2bbcbef1dcd422f) --- sys/netpfil/pf/pf.c | 48 +++++++++++++++++++++++++++-------------------- sys/netpfil/pf/pf_ioctl.c | 12 +++++++----- sys/netpfil/pf/pf_norm.c | 18 ++++++++++++------ 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 0c485189ec16..f1b1890f50c5 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -3756,8 +3756,10 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, int direction, rtableid = r->rtableid; if (r->anchor == NULL) { if (r->action == PF_MATCH) { - pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -4170,8 +4172,10 @@ pf_test_fragment(struct pf_krule **rm, int direction, struct pfi_kkif *kif, else { if (r->anchor == NULL) { if (r->action == PF_MATCH) { - pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -6555,24 +6559,25 @@ done: (s == NULL)); } - pf_counter_u64_add(&kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], pd.tot_len); - pf_counter_u64_add(&kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add_protected(&kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - pf_counter_u64_add(&r->packets[dirndx], 1); - pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&r->packets[dirndx], 1); + pf_counter_u64_add_protected(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - pf_counter_u64_add(&a->packets[dirndx], 1); - pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&a->packets[dirndx], 1); + pf_counter_u64_add_protected(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->packets[dirndx], 1); - pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { @@ -6610,6 +6615,7 @@ done: pd.af, pd.tot_len, dir == PF_OUT, r->action == PF_PASS, tr->dst.neg); } + pf_counter_u64_critical_exit(); switch (action) { case PF_SYNPROXY_DROP: @@ -6963,24 +6969,25 @@ done: &pd, (s == NULL)); } - pf_counter_u64_add(&kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], pd.tot_len); - pf_counter_u64_add(&kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add_protected(&kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - pf_counter_u64_add(&r->packets[dirndx], 1); - pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&r->packets[dirndx], 1); + pf_counter_u64_add_protected(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - pf_counter_u64_add(&a->packets[dirndx], 1); - pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&a->packets[dirndx], 1); + pf_counter_u64_add_protected(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->packets[dirndx], 1); - pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { @@ -7016,6 +7023,7 @@ done: pd.af, pd.tot_len, dir == PF_OUT, r->action == PF_PASS, tr->dst.neg); } + pf_counter_u64_critical_exit(); switch (action) { case PF_SYNPROXY_DROP: diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 81b50c237252..4f1786b36a30 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1120,16 +1120,18 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) while ((tail != NULL) && ! pf_krule_compare(tail, rule)) tail = TAILQ_NEXT(tail, entries); if (tail != NULL) { - pf_counter_u64_add(&rule->evaluations, + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&rule->evaluations, pf_counter_u64_fetch(&tail->evaluations)); - pf_counter_u64_add(&rule->packets[0], + pf_counter_u64_add_protected(&rule->packets[0], pf_counter_u64_fetch(&tail->packets[0])); - pf_counter_u64_add(&rule->packets[1], + pf_counter_u64_add_protected(&rule->packets[1], pf_counter_u64_fetch(&tail->packets[1])); - pf_counter_u64_add(&rule->bytes[0], + pf_counter_u64_add_protected(&rule->bytes[0], pf_counter_u64_fetch(&tail->bytes[0])); - pf_counter_u64_add(&rule->bytes[1], + pf_counter_u64_add_protected(&rule->bytes[1], pf_counter_u64_fetch(&tail->bytes[1])); + pf_counter_u64_critical_exit(); } } } diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 19d3a268e4f8..40e4b1bae2f9 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -1062,8 +1062,10 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); /* Check for illegal packets */ if (hlen < (int)sizeof(struct ip)) { @@ -1204,8 +1206,10 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); /* Check for illegal packets */ if (sizeof(struct ip6_hdr) + IPV6_MAXPACKET < m->m_pkthdr.len) @@ -1389,8 +1393,10 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, if (rm == NULL || rm->action == PF_NOSCRUB) return (PF_PASS); - pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); if (rm->rule_flag & PFRULE_REASSEMBLE_TCP) pd->flags |= PFDESC_TCP_NORM; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:17:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 28B866557E6; Wed, 11 Aug 2021 15:17: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 4GlD370MnCz3L8l; Wed, 11 Aug 2021 15:17: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 E954811C0C; Wed, 11 Aug 2021 15:17: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 17BFHs98051591; Wed, 11 Aug 2021 15:17:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFHsGw051590; Wed, 11 Aug 2021 15:17:54 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:17:54 GMT Message-Id: <202108111517.17BFHsGw051590@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 6b22840ed0e8 - main - Read the arm64 midr register earlier MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6b22840ed0e8f9ceb34465987b8469a43ebb4582 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:17:55 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=6b22840ed0e8f9ceb34465987b8469a43ebb4582 commit 6b22840ed0e8f9ceb34465987b8469a43ebb4582 Author: Andrew Turner AuthorDate: 2021-08-11 15:01:25 +0000 Commit: Andrew Turner CommitDate: 2021-08-11 15:15:55 +0000 Read the arm64 midr register earlier We use the midr_el1 register to decode which CPU type we are booting from. Read it on the secondary CPUs before waiting for the boot CPU to release us as it will need to use it before the release. Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/mp_machdep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 63715c64641c..c5dd3312fdba 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -238,6 +238,7 @@ init_secondary(uint64_t cpu) * We need this before signalling the CPU is ready to * let the boot CPU use the results. */ + pcpup->pc_midr = get_midr(); identify_cpu(cpu); /* Ensure the stores in identify_cpu have completed */ @@ -248,8 +249,6 @@ init_secondary(uint64_t cpu) while (!atomic_load_int(&aps_ready)) __asm __volatile("wfe"); - pcpup->pc_midr = get_midr(); - /* Initialize curthread */ KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); pcpup->pc_curthread = pcpup->pc_idlethread; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 65EC76556DD; Wed, 11 Aug 2021 15:22:40 +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 4GlD8c2Ld5z3LDm; Wed, 11 Aug 2021 15:22: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 38A4211569; Wed, 11 Aug 2021 15:22: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 17BFMeZC064219; Wed, 11 Aug 2021 15:22:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMeBl064218; Wed, 11 Aug 2021 15:22:40 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:40 GMT Message-Id: <202108111522.17BFMeBl064218@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: 53551e9976b9 - stable/13 - pf: hide struct pf_kstatus behind ifdef _KERNEL 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: 53551e9976b9bfcff71ca820aefc22d7a668214e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:40 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=53551e9976b9bfcff71ca820aefc22d7a668214e commit 53551e9976b9bfcff71ca820aefc22d7a668214e Author: Mateusz Guzik AuthorDate: 2021-07-23 17:34:43 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:51 +0000 pf: hide struct pf_kstatus behind ifdef _KERNEL Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit d9cc6ea270ea52e860e3cc730876ee4324081586) --- sys/net/pfvar.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index e037947a5375..55ecbecf657a 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1146,6 +1146,7 @@ enum pf_syncookies_mode { PF_SYNCOOKIES_MODE_MAX = PF_SYNCOOKIES_ALWAYS }; +#ifdef _KERNEL struct pf_kstatus { counter_u64_t counters[PFRES_MAX]; /* reason for passing/dropping */ counter_u64_t lcounters[LCNT_MAX]; /* limit counters */ @@ -1163,6 +1164,7 @@ struct pf_kstatus { enum pf_syncookies_mode syncookies_mode; bool syncookies_active; }; +#endif struct pf_divert { union { From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9D62C655870; Wed, 11 Aug 2021 15:22: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 4GlD8d3NX5z3LBV; Wed, 11 Aug 2021 15:22: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 547DA11A5E; Wed, 11 Aug 2021 15:22: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 17BFMfFP064243; Wed, 11 Aug 2021 15:22:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMfr3064242; Wed, 11 Aug 2021 15:22:41 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:41 GMT Message-Id: <202108111522.17BFMfr3064242@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: 67ed59f6a826 - stable/13 - pf: consistently malloc rules with M_ZERO 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: 67ed59f6a8261e6cbb82554c72e59ae81afb0b36 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:41 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=67ed59f6a8261e6cbb82554c72e59ae81afb0b36 commit 67ed59f6a8261e6cbb82554c72e59ae81afb0b36 Author: Mateusz Guzik AuthorDate: 2021-07-23 15:01:29 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:52 +0000 pf: consistently malloc rules with M_ZERO Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 49a7d47235434a300cc57b205e493988fdebf79c) --- sys/netpfil/pf/pf_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index edc786d804da..d3d0ede278fd 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2359,7 +2359,7 @@ DIOCADDRULENV_error: struct pfioc_rule *pr = (struct pfioc_rule *)addr; struct pf_krule *rule; - rule = malloc(sizeof(*rule), M_PFRULE, M_WAITOK); + rule = malloc(sizeof(*rule), M_PFRULE, M_WAITOK | M_ZERO); error = pf_rule_to_krule(&pr->rule, rule); if (error != 0) { free(rule, M_PFRULE); @@ -2616,7 +2616,7 @@ DIOCGETRULENV_error: } if (pcr->action != PF_CHANGE_REMOVE) { - newrule = malloc(sizeof(*newrule), M_PFRULE, M_WAITOK); + newrule = malloc(sizeof(*newrule), M_PFRULE, M_WAITOK | M_ZERO); error = pf_rule_to_krule(&pcr->rule, newrule); if (error != 0) { free(newrule, M_PFRULE); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A56B16556EF; Wed, 11 Aug 2021 15:22:42 +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 4GlD8f4JDnz3Lcp; Wed, 11 Aug 2021 15:22:42 +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 7CE2111D3D; Wed, 11 Aug 2021 15:22:42 +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 17BFMge9064267; Wed, 11 Aug 2021 15:22:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMggV064266; Wed, 11 Aug 2021 15:22:42 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:42 GMT Message-Id: <202108111522.17BFMggV064266@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: 5640fea1e373 - stable/13 - pf: drop redundant 'else' in pf_normalize_* 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: 5640fea1e37323133cc8447e050ec44012389883 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:42 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=5640fea1e37323133cc8447e050ec44012389883 commit 5640fea1e37323133cc8447e050ec44012389883 Author: Mateusz Guzik AuthorDate: 2021-07-24 05:17:27 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:53 +0000 pf: drop redundant 'else' in pf_normalize_* Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 6f1fb6561236fa933835a9a67bd442053fb509e9) --- sys/netpfil/pf/pf_norm.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 561181eb1b56..3df4e06f15b6 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -1065,10 +1065,9 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - else { - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); - } + + counter_u64_add(r->packets[dir == PF_OUT], 1); + counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (hlen < (int)sizeof(struct ip)) { @@ -1207,10 +1206,9 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - else { - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); - } + + counter_u64_add(r->packets[dir == PF_OUT], 1); + counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (sizeof(struct ip6_hdr) + IPV6_MAXPACKET < m->m_pkthdr.len) @@ -1369,10 +1367,9 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, if (rm == NULL || rm->action == PF_NOSCRUB) return (PF_PASS); - else { - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); - } + + counter_u64_add(r->packets[dir == PF_OUT], 1); + counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); if (rm->rule_flag & PFRULE_REASSEMBLE_TCP) pd->flags |= PFDESC_TCP_NORM; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 215B8656065; Wed, 11 Aug 2021 15:22: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 4GlD8g5ddZz3LMg; Wed, 11 Aug 2021 15:22: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 A1DEC11A5F; Wed, 11 Aug 2021 15:22: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 17BFMhl3064298; Wed, 11 Aug 2021 15:22:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMhuj064297; Wed, 11 Aug 2021 15:22:43 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:43 GMT Message-Id: <202108111522.17BFMhuj064297@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: fff80a6992f1 - stable/13 - pf: add hybrid 32- an 64- bit counters 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: fff80a6992f1ba13f2261b066d70a3a97d8837e4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:44 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=fff80a6992f1ba13f2261b066d70a3a97d8837e4 commit fff80a6992f1ba13f2261b066d70a3a97d8837e4 Author: Mateusz Guzik AuthorDate: 2021-07-22 20:47:24 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:53 +0000 pf: add hybrid 32- an 64- bit counters Numerous counters got migrated from straight uint64_t to the counter(9) API. Unfortunately the implementation comes with a significiant performance hit on some platforms and cannot be easily fixed. Work around the problem by implementing a pf-specific variant. Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit defdcdd5648dc1ea789bc54bb45108fcab546a6b) --- sys/net/pfvar.h | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sys/netpfil/pf/pf.c | 28 ++++++- 2 files changed, 245 insertions(+), 1 deletion(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 55ecbecf657a..e381279a113f 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -43,9 +43,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -64,6 +66,222 @@ #ifdef _KERNEL +#if defined(__arm__) +#define PF_WANT_32_TO_64_COUNTER +#endif + +/* + * A hybrid of 32-bit and 64-bit counters which can be used on platforms where + * counter(9) is very expensive. + * + * As 32-bit counters are expected to overflow, a periodic job sums them up to + * a saved 64-bit state. Fetching the value still walks all CPUs to get the most + * current snapshot. + */ +#ifdef PF_WANT_32_TO_64_COUNTER +struct pf_counter_u64_pcpu { + u_int32_t current; + u_int32_t snapshot; +}; + +struct pf_counter_u64 { + struct pf_counter_u64_pcpu *pfcu64_pcpu; + u_int64_t pfcu64_value; + seqc_t pfcu64_seqc; +}; + +static inline int +pf_counter_u64_init(struct pf_counter_u64 *pfcu64, int flags) +{ + + pfcu64->pfcu64_value = 0; + pfcu64->pfcu64_seqc = 0; + pfcu64->pfcu64_pcpu = uma_zalloc_pcpu(pcpu_zone_8, flags | M_ZERO); + if (__predict_false(pfcu64->pfcu64_pcpu == NULL)) + return (ENOMEM); + return (0); +} + +static inline void +pf_counter_u64_deinit(struct pf_counter_u64 *pfcu64) +{ + + uma_zfree_pcpu(pcpu_zone_8, pfcu64->pfcu64_pcpu); +} + +static inline void +pf_counter_u64_critical_enter(void) +{ + + critical_enter(); +} + +static inline void +pf_counter_u64_critical_exit(void) +{ + + critical_exit(); +} + +static inline void +pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + struct pf_counter_u64_pcpu *pcpu; + u_int32_t val; + + MPASS(curthread->td_critnest > 0); + pcpu = zpcpu_get(pfcu64->pfcu64_pcpu); + val = atomic_load_int(&pcpu->current); + atomic_store_int(&pcpu->current, val + n); +} + +static inline void +pf_counter_u64_add(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + + critical_enter(); + pf_counter_u64_add_protected(pfcu64, n); + critical_exit(); +} + +static inline u_int64_t +pf_counter_u64_periodic(struct pf_counter_u64 *pfcu64) +{ + struct pf_counter_u64_pcpu *pcpu; + u_int64_t sum; + u_int32_t val; + int cpu; + + MPASS(curthread->td_critnest > 0); + seqc_write_begin(&pfcu64->pfcu64_seqc); + sum = pfcu64->pfcu64_value; + CPU_FOREACH(cpu) { + pcpu = zpcpu_get_cpu(pfcu64->pfcu64_pcpu, cpu); + val = atomic_load_int(&pcpu->current); + sum += (uint32_t)(val - pcpu->snapshot); + pcpu->snapshot = val; + } + pfcu64->pfcu64_value = sum; + seqc_write_end(&pfcu64->pfcu64_seqc); + return (sum); +} + +static inline u_int64_t +pf_counter_u64_fetch(struct pf_counter_u64 *pfcu64) +{ + struct pf_counter_u64_pcpu *pcpu; + u_int64_t sum; + seqc_t seqc; + int cpu; + + for (;;) { + seqc = seqc_read(&pfcu64->pfcu64_seqc); + sum = 0; + CPU_FOREACH(cpu) { + pcpu = zpcpu_get_cpu(pfcu64->pfcu64_pcpu, cpu); + sum += (uint32_t)(atomic_load_int(&pcpu->current) -pcpu->snapshot); + } + sum += pfcu64->pfcu64_value; + if (seqc_consistent(&pfcu64->pfcu64_seqc, seqc)) + break; + } + return (sum); +} + +static inline void +pf_counter_u64_zero_protected(struct pf_counter_u64 *pfcu64) +{ + struct pf_counter_u64_pcpu *pcpu; + int cpu; + + MPASS(curthread->td_critnest > 0); + seqc_write_begin(&pfcu64->pfcu64_seqc); + CPU_FOREACH(cpu) { + pcpu = zpcpu_get_cpu(pfcu64->pfcu64_pcpu, cpu); + pcpu->snapshot = atomic_load_int(&pcpu->current); + } + pfcu64->pfcu64_value = 0; + seqc_write_end(&pfcu64->pfcu64_seqc); +} + +static inline void +pf_counter_u64_zero(struct pf_counter_u64 *pfcu64) +{ + + critical_enter(); + pf_counter_u64_zero_protected(pfcu64); + critical_exit(); +} +#else +struct pf_counter_u64 { + counter_u64_t counter; +}; + +static inline int +pf_counter_u64_init(struct pf_counter_u64 *pfcu64, int flags) +{ + + pfcu64->counter = counter_u64_alloc(flags); + if (__predict_false(pfcu64->counter == NULL)) + return (ENOMEM); + return (0); +} + +static inline void +pf_counter_u64_deinit(struct pf_counter_u64 *pfcu64) +{ + + counter_u64_free(pfcu64->counter); +} + +static inline void +pf_counter_u64_critical_enter(void) +{ + +} + +static inline void +pf_counter_u64_critical_exit(void) +{ + +} + +static inline void +pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + + counter_u64_add(pfcu64->counter, n); +} + +static inline void +pf_counter_u64_add(struct pf_counter_u64 *pfcu64, uint32_t n) +{ + + pf_counter_u64_add_protected(pfcu64, n); +} + +static inline u_int64_t +pf_counter_u64_fetch(struct pf_counter_u64 *pfcu64) +{ + + return (counter_u64_fetch(pfcu64->counter)); +} + +static inline void +pf_counter_u64_zero_protected(struct pf_counter_u64 *pfcu64) +{ + + counter_u64_zero(pfcu64->counter); +} + +static inline void +pf_counter_u64_zero(struct pf_counter_u64 *pfcu64) +{ + + pf_counter_u64_zero_protected(pfcu64); +} +#endif + SYSCTL_DECL(_net_pf); MALLOC_DECLARE(M_PFHASH); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 0db9eaed1ac4..b74491bb88d0 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -154,6 +154,11 @@ VNET_DECLARE(int, pf_vnet_active); VNET_DEFINE_STATIC(uint32_t, pf_purge_idx); #define V_pf_purge_idx VNET(pf_purge_idx) +#ifdef PF_WANT_32_TO_64_COUNTER +VNET_DEFINE_STATIC(uint32_t, pf_counter_periodic_iter); +#define V_pf_counter_periodic_iter VNET(pf_counter_periodic_iter) +#endif + /* * Queue for pf_intr() sends. */ @@ -1509,6 +1514,25 @@ pf_intr(void *v) CURVNET_RESTORE(); } +#define pf_purge_thread_period (hz / 10) + +#ifdef PF_WANT_32_TO_64_COUNTER +static void +pf_counter_u64_periodic_main(void) +{ + PF_RULES_RLOCK_TRACKER; + + V_pf_counter_periodic_iter++; + + PF_RULES_RLOCK(); + pf_counter_u64_critical_enter(); + pf_counter_u64_critical_exit(); + PF_RULES_RUNLOCK(); +} +#else +#define pf_counter_u64_periodic_main() do { } while (0) +#endif + void pf_purge_thread(void *unused __unused) { @@ -1516,7 +1540,7 @@ pf_purge_thread(void *unused __unused) sx_xlock(&pf_end_lock); while (pf_end_threads == 0) { - sx_sleep(pf_purge_thread, &pf_end_lock, 0, "pftm", hz / 10); + sx_sleep(pf_purge_thread, &pf_end_lock, 0, "pftm", pf_purge_thread_period); VNET_LIST_RLOCK(); VNET_FOREACH(vnet_iter) { @@ -1528,6 +1552,8 @@ pf_purge_thread(void *unused __unused) continue; } + pf_counter_u64_periodic_main(); + /* * Process 1/interval fraction of the state * table every run. From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 07F7C655D8B; Wed, 11 Aug 2021 15:22: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 4GlD8h6DXLz3LdG; Wed, 11 Aug 2021 15:22: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 BDA4011BE0; Wed, 11 Aug 2021 15:22:44 +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 17BFMipx064322; Wed, 11 Aug 2021 15:22:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMiUH064321; Wed, 11 Aug 2021 15:22:44 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:44 GMT Message-Id: <202108111522.17BFMiUH064321@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: b45b050a69ee - stable/13 - pf: switch pf_status.fcounters to pf_counter_u64 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: b45b050a69ee7c9bd1c1b6c546e0d0a9714688e1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:45 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b45b050a69ee7c9bd1c1b6c546e0d0a9714688e1 commit b45b050a69ee7c9bd1c1b6c546e0d0a9714688e1 Author: Mateusz Guzik AuthorDate: 2021-07-24 05:33:52 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:54 +0000 pf: switch pf_status.fcounters to pf_counter_u64 Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit fc4c42ce0b5ce87901b327e25f55b4e3ab4c6cf5) --- sys/net/pfvar.h | 2 +- sys/netpfil/pf/pf.c | 26 +++++++++++++++++++++----- sys/netpfil/pf/pf_ioctl.c | 8 ++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index e381279a113f..bf70a8a5d016 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1368,7 +1368,7 @@ enum pf_syncookies_mode { struct pf_kstatus { counter_u64_t counters[PFRES_MAX]; /* reason for passing/dropping */ counter_u64_t lcounters[LCNT_MAX]; /* limit counters */ - counter_u64_t fcounters[FCNT_MAX]; /* state operation counters */ + struct pf_counter_u64 fcounters[FCNT_MAX]; /* state operation counters */ counter_u64_t scounters[SCNT_MAX]; /* src_node operation counters */ uint32_t states; uint32_t src_nodes; diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index b74491bb88d0..5d043bdbd0e4 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1311,7 +1311,7 @@ pf_state_insert(struct pfi_kkif *kif, struct pfi_kkif *orig_kif, /* One for keys, one for ID hash. */ refcount_init(&s->refs, 2); - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_INSERT], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_INSERT], 1); if (V_pfsync_insert_state_ptr != NULL) V_pfsync_insert_state_ptr(s); @@ -1328,7 +1328,7 @@ pf_find_state_byid(uint64_t id, uint32_t creatorid) struct pf_idhash *ih; struct pf_kstate *s; - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); ih = &V_pf_idhash[(be64toh(id) % (pf_hashmask + 1))]; @@ -1355,7 +1355,7 @@ pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir) struct pf_kstate *s; int idx; - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; @@ -1399,7 +1399,7 @@ pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more) struct pf_kstate *s, *ret = NULL; int idx, inout = 0; - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; @@ -1517,6 +1517,21 @@ pf_intr(void *v) #define pf_purge_thread_period (hz / 10) #ifdef PF_WANT_32_TO_64_COUNTER +static void +pf_status_counter_u64_periodic(void) +{ + + PF_RULES_RASSERT(); + + if ((V_pf_counter_periodic_iter % (pf_purge_thread_period * 10 * 60)) != 0) { + return; + } + + for (int i = 0; i < FCNT_MAX; i++) { + pf_counter_u64_periodic(&V_pf_status.fcounters[i]); + } +} + static void pf_counter_u64_periodic_main(void) { @@ -1526,6 +1541,7 @@ pf_counter_u64_periodic_main(void) PF_RULES_RLOCK(); pf_counter_u64_critical_enter(); + pf_status_counter_u64_periodic(); pf_counter_u64_critical_exit(); PF_RULES_RUNLOCK(); } @@ -1781,7 +1797,7 @@ pf_free_state(struct pf_kstate *cur) pf_normalize_tcp_cleanup(cur); uma_zfree(V_pf_state_z, cur); - counter_u64_add(V_pf_status.fcounters[FCNT_STATE_REMOVALS], 1); + pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_REMOVALS], 1); } /* diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index d3d0ede278fd..2cce147035ae 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -368,7 +368,7 @@ pfattach_vnet(void) for (int i = 0; i < LCNT_MAX; i++) V_pf_status.lcounters[i] = counter_u64_alloc(M_WAITOK); for (int i = 0; i < FCNT_MAX; i++) - V_pf_status.fcounters[i] = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&V_pf_status.fcounters[i], M_WAITOK); for (int i = 0; i < SCNT_MAX; i++) V_pf_status.scounters[i] = counter_u64_alloc(M_WAITOK); @@ -3050,7 +3050,7 @@ DIOCGETSTATESV2_full: counter_u64_fetch(V_pf_status.lcounters[i]); for (int i = 0; i < FCNT_MAX; i++) s->fcounters[i] = - counter_u64_fetch(V_pf_status.fcounters[i]); + pf_counter_u64_fetch(&V_pf_status.fcounters[i]); for (int i = 0; i < SCNT_MAX; i++) s->scounters[i] = counter_u64_fetch(V_pf_status.scounters[i]); @@ -3082,7 +3082,7 @@ DIOCGETSTATESV2_full: for (int i = 0; i < PFRES_MAX; i++) counter_u64_zero(V_pf_status.counters[i]); for (int i = 0; i < FCNT_MAX; i++) - counter_u64_zero(V_pf_status.fcounters[i]); + pf_counter_u64_zero(&V_pf_status.fcounters[i]); for (int i = 0; i < SCNT_MAX; i++) counter_u64_zero(V_pf_status.scounters[i]); for (int i = 0; i < LCNT_MAX; i++) @@ -5618,7 +5618,7 @@ pf_unload_vnet(void) for (int i = 0; i < LCNT_MAX; i++) counter_u64_free(V_pf_status.lcounters[i]); for (int i = 0; i < FCNT_MAX; i++) - counter_u64_free(V_pf_status.fcounters[i]); + pf_counter_u64_deinit(&V_pf_status.fcounters[i]); for (int i = 0; i < SCNT_MAX; i++) counter_u64_free(V_pf_status.scounters[i]); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 437A5655E99; Wed, 11 Aug 2021 15:22: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 4GlD8k0jMtz3LMl; Wed, 11 Aug 2021 15:22: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 E674B11D3E; Wed, 11 Aug 2021 15:22: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 17BFMjfG064346; Wed, 11 Aug 2021 15:22:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMj75064345; Wed, 11 Aug 2021 15:22:45 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:45 GMT Message-Id: <202108111522.17BFMj75064345@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: 79f0e6469aad - stable/13 - pf: switch kif counters to pf_counter_u64 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: 79f0e6469aad525400e8be0deb16b4d964e7a6c1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:46 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=79f0e6469aad525400e8be0deb16b4d964e7a6c1 commit 79f0e6469aad525400e8be0deb16b4d964e7a6c1 Author: Mateusz Guzik AuthorDate: 2021-07-23 10:29:46 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:55 +0000 pf: switch kif counters to pf_counter_u64 Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit d40d4b3ed788b05697541b9ae94b1960ff2cf6f6) --- sys/net/pfvar.h | 17 +++++++++++-- sys/netpfil/pf/pf.c | 51 +++++++++++++++++++++++++++++++++++--- sys/netpfil/pf/pf_if.c | 62 +++++++++++++++++++++++++++++++++++------------ sys/netpfil/pf/pf_ioctl.c | 17 +++++++++++++ 4 files changed, 126 insertions(+), 21 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index bf70a8a5d016..7afc8b895b80 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1255,14 +1255,17 @@ struct pfi_kkif { } _pfik_glue; #define pfik_tree _pfik_glue._pfik_tree #define pfik_list _pfik_glue._pfik_list - counter_u64_t pfik_packets[2][2][2]; - counter_u64_t pfik_bytes[2][2][2]; + struct pf_counter_u64 pfik_packets[2][2][2]; + struct pf_counter_u64 pfik_bytes[2][2][2]; u_int32_t pfik_tzero; u_int pfik_flags; struct ifnet *pfik_ifp; struct ifg_group *pfik_group; u_int pfik_rulerefs; TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs; +#ifdef PF_WANT_32_TO_64_COUNTER + LIST_ENTRY(pfi_kkif) pfik_allkiflist; +#endif }; #endif @@ -1847,6 +1850,16 @@ VNET_DECLARE(struct pf_altqqueue *, pf_altq_ifs_inactive); VNET_DECLARE(struct pf_krulequeue, pf_unlinked_rules); #define V_pf_unlinked_rules VNET(pf_unlinked_rules) +#ifdef PF_WANT_32_TO_64_COUNTER +LIST_HEAD(allkiflist_head, pfi_kkif); +VNET_DECLARE(struct allkiflist_head, pf_allkiflist); +#define V_pf_allkiflist VNET(pf_allkiflist) +VNET_DECLARE(size_t, pf_allkifcount); +#define V_pf_allkifcount VNET(pf_allkifcount) +VNET_DECLARE(struct pfi_kkif *, pf_kifmarker); +#define V_pf_kifmarker VNET(pf_kifmarker) +#endif + void pf_initialize(void); void pf_mtag_initialize(void); void pf_mtag_cleanup(void); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 5d043bdbd0e4..f3d82549edff 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1532,6 +1532,48 @@ pf_status_counter_u64_periodic(void) } } +static void +pf_kif_counter_u64_periodic(void) +{ + struct pfi_kkif *kif; + size_t r, run; + + PF_RULES_RASSERT(); + + if (__predict_false(V_pf_allkifcount == 0)) { + return; + } + + if ((V_pf_counter_periodic_iter % (pf_purge_thread_period * 10 * 300)) != 0) { + return; + } + + run = V_pf_allkifcount / 10; + if (run < 5) + run = 5; + + for (r = 0; r < run; r++) { + kif = LIST_NEXT(V_pf_kifmarker, pfik_allkiflist); + if (kif == NULL) { + LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); + LIST_INSERT_HEAD(&V_pf_allkiflist, V_pf_kifmarker, pfik_allkiflist); + break; + } + + LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); + LIST_INSERT_AFTER(kif, V_pf_kifmarker, pfik_allkiflist); + + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + for (int k = 0; k < 2; k++) { + pf_counter_u64_periodic(&kif->pfik_packets[i][j][k]); + pf_counter_u64_periodic(&kif->pfik_bytes[i][j][k]); + } + } + } + } +} + static void pf_counter_u64_periodic_main(void) { @@ -1542,6 +1584,7 @@ pf_counter_u64_periodic_main(void) PF_RULES_RLOCK(); pf_counter_u64_critical_enter(); pf_status_counter_u64_periodic(); + pf_kif_counter_u64_periodic(); pf_counter_u64_critical_exit(); PF_RULES_RUNLOCK(); } @@ -6381,9 +6424,9 @@ done: (s == NULL)); } - counter_u64_add(kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], pd.tot_len); - counter_u64_add(kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { @@ -6786,9 +6829,9 @@ done: &pd, (s == NULL)); } - counter_u64_add(kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], pd.tot_len); - counter_u64_add(kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add(&kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c index 3c9b53daa28c..dcbbce08ed6c 100644 --- a/sys/netpfil/pf/pf_if.c +++ b/sys/netpfil/pf/pf_if.c @@ -69,6 +69,12 @@ VNET_DEFINE_STATIC(int, pfi_buffer_max); #define V_pfi_buffer_cnt VNET(pfi_buffer_cnt) #define V_pfi_buffer_max VNET(pfi_buffer_max) +#ifdef PF_WANT_32_TO_64_COUNTER +VNET_DEFINE(struct allkiflist_head, pf_allkiflist); +VNET_DEFINE(size_t, pf_allkifcount); +VNET_DEFINE(struct pfi_kkif *, pf_kifmarker); +#endif + eventhandler_tag pfi_attach_cookie; eventhandler_tag pfi_detach_cookie; eventhandler_tag pfi_attach_group_cookie; @@ -222,6 +228,9 @@ struct pfi_kkif* pf_kkif_create(int flags) { struct pfi_kkif *kif; +#ifdef PF_WANT_32_TO_64_COUNTER + bool wowned; +#endif kif = malloc(sizeof(*kif), PFI_MTYPE, flags | M_ZERO); if (! kif) @@ -230,13 +239,12 @@ pf_kkif_create(int flags) for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { - kif->pfik_packets[i][j][k] = - counter_u64_alloc(flags); - kif->pfik_bytes[i][j][k] = - counter_u64_alloc(flags); + if (pf_counter_u64_init(&kif->pfik_packets[i][j][k], flags) != 0) { + pf_kkif_free(kif); + return (NULL); + } - if (! kif->pfik_packets[i][j][k] || - ! kif->pfik_bytes[i][j][k]) { + if (pf_counter_u64_init(&kif->pfik_bytes[i][j][k], flags) != 0) { pf_kkif_free(kif); return (NULL); } @@ -244,20 +252,44 @@ pf_kkif_create(int flags) } } +#ifdef PF_WANT_32_TO_64_COUNTER + wowned = PF_RULES_WOWNED(); + if (!wowned) + PF_RULES_WLOCK(); + LIST_INSERT_HEAD(&V_pf_allkiflist, kif, pfik_allkiflist); + V_pf_allkifcount++; + if (!wowned) + PF_RULES_WUNLOCK(); +#endif + return (kif); } void pf_kkif_free(struct pfi_kkif *kif) { +#ifdef PF_WANT_32_TO_64_COUNTER + bool wowned; +#endif + if (! kif) return; +#ifdef PF_WANT_32_TO_64_COUNTER + wowned = PF_RULES_WOWNED(); + if (!wowned) + PF_RULES_WLOCK(); + LIST_REMOVE(kif, pfik_allkiflist); + V_pf_allkifcount--; + if (!wowned) + PF_RULES_WUNLOCK(); +#endif + for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { - counter_u64_free(kif->pfik_packets[i][j][k]); - counter_u64_free(kif->pfik_bytes[i][j][k]); + pf_counter_u64_deinit(&kif->pfik_packets[i][j][k]); + pf_counter_u64_deinit(&kif->pfik_bytes[i][j][k]); } } } @@ -272,8 +304,8 @@ pf_kkif_zero(struct pfi_kkif *kif) for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { - counter_u64_zero(kif->pfik_packets[i][j][k]); - counter_u64_zero(kif->pfik_bytes[i][j][k]); + pf_counter_u64_zero(&kif->pfik_packets[i][j][k]); + pf_counter_u64_zero(&kif->pfik_bytes[i][j][k]); } } } @@ -805,15 +837,15 @@ pfi_update_status(const char *name, struct pf_status *pfs) for (j = 0; j < 2; j++) for (k = 0; k < 2; k++) { pfs->pcounters[i][j][k] += - counter_u64_fetch(p->pfik_packets[i][j][k]); + pf_counter_u64_fetch(&p->pfik_packets[i][j][k]); pfs->bcounters[i][j] += - counter_u64_fetch(p->pfik_bytes[i][j][k]); + pf_counter_u64_fetch(&p->pfik_bytes[i][j][k]); } } } static void -pf_kkif_to_kif(const struct pfi_kkif *kkif, struct pfi_kif *kif) +pf_kkif_to_kif(struct pfi_kkif *kkif, struct pfi_kif *kif) { bzero(kif, sizeof(*kif)); @@ -822,9 +854,9 @@ pf_kkif_to_kif(const struct pfi_kkif *kkif, struct pfi_kif *kif) for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { kif->pfik_packets[i][j][k] = - counter_u64_fetch(kkif->pfik_packets[i][j][k]); + pf_counter_u64_fetch(&kkif->pfik_packets[i][j][k]); kif->pfik_bytes[i][j][k] = - counter_u64_fetch(kkif->pfik_bytes[i][j][k]); + pf_counter_u64_fetch(&kkif->pfik_bytes[i][j][k]); } } } diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 2cce147035ae..a0d877263235 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -333,6 +333,13 @@ pfattach_vnet(void) V_pf_default_rule.states_tot = counter_u64_alloc(M_WAITOK); V_pf_default_rule.src_nodes = counter_u64_alloc(M_WAITOK); +#ifdef PF_WANT_32_TO_64_COUNTER + V_pf_kifmarker = malloc(sizeof(*V_pf_kifmarker), PFI_MTYPE, M_WAITOK | M_ZERO); + PF_RULES_WLOCK(); + LIST_INSERT_HEAD(&V_pf_allkiflist, V_pf_kifmarker, pfik_allkiflist); + PF_RULES_WUNLOCK(); +#endif + /* initialize default timeouts */ my_timeout[PFTM_TCP_FIRST_PACKET] = PFTM_TCP_FIRST_PACKET_VAL; my_timeout[PFTM_TCP_OPENING] = PFTM_TCP_OPENING_VAL; @@ -5603,6 +5610,16 @@ pf_unload_vnet(void) #endif uma_zdestroy(V_pf_tag_z); +#ifdef PF_WANT_32_TO_64_COUNTER + PF_RULES_WLOCK(); + LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); + PF_RULES_WUNLOCK(); + free(V_pf_kifmarker, PFI_MTYPE); + + MPASS(LIST_EMPTY(&V_pf_allkiflist)); + MPASS(V_pf_allkifcount == 0); +#endif + /* Free counters last as we updated them during shutdown. */ counter_u64_free(V_pf_default_rule.evaluations); for (int i = 0; i < 2; i++) { From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 88D4265618A; Wed, 11 Aug 2021 15:22: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 4GlD8l2GwQz3LQf; Wed, 11 Aug 2021 15:22: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 00B77119F6; Wed, 11 Aug 2021 15:22: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 17BFMkuP064370; Wed, 11 Aug 2021 15:22:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMkbl064369; Wed, 11 Aug 2021 15:22:46 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:46 GMT Message-Id: <202108111522.17BFMkbl064369@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: c9731a3f464f - stable/13 - pf: switch rule counters to pf_counter_u64 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: c9731a3f464fd49efbd39c44e262dd069034894e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:47 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=c9731a3f464fd49efbd39c44e262dd069034894e commit c9731a3f464fd49efbd39c44e262dd069034894e Author: Mateusz Guzik AuthorDate: 2021-07-22 14:45:14 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:55 +0000 pf: switch rule counters to pf_counter_u64 Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 02cf67ccf6538b14677672640e405f7f94044dc3) --- sys/net/pfvar.h | 19 ++++++- sys/netpfil/pf/pf.c | 80 +++++++++++++++++++++------ sys/netpfil/pf/pf_ioctl.c | 137 +++++++++++++++++++++++++++++++--------------- sys/netpfil/pf/pf_lb.c | 2 +- sys/netpfil/pf/pf_norm.c | 18 +++--- sys/netpfil/pf/pf_nv.c | 8 +-- sys/netpfil/pf/pf_nv.h | 2 +- 7 files changed, 185 insertions(+), 81 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 7afc8b895b80..76e3834372e3 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -583,9 +583,9 @@ struct pf_krule { TAILQ_ENTRY(pf_krule) entries; struct pf_kpool rpool; - counter_u64_t evaluations; - counter_u64_t packets[2]; - counter_u64_t bytes[2]; + struct pf_counter_u64 evaluations; + struct pf_counter_u64 packets[2]; + struct pf_counter_u64 bytes[2]; struct pfi_kkif *kif; struct pf_kanchor *anchor; @@ -659,6 +659,11 @@ struct pf_krule { struct pf_addr addr; u_int16_t port; } divert; + +#ifdef PF_WANT_32_TO_64_COUNTER + LIST_ENTRY(pf_krule) allrulelist; + bool allrulelinked; +#endif }; struct pf_ksrc_node { @@ -1858,6 +1863,14 @@ VNET_DECLARE(size_t, pf_allkifcount); #define V_pf_allkifcount VNET(pf_allkifcount) VNET_DECLARE(struct pfi_kkif *, pf_kifmarker); #define V_pf_kifmarker VNET(pf_kifmarker) + +LIST_HEAD(allrulelist_head, pf_krule); +VNET_DECLARE(struct allrulelist_head, pf_allrulelist); +#define V_pf_allrulelist VNET(pf_allrulelist) +VNET_DECLARE(size_t, pf_allrulecount); +#define V_pf_allrulecount VNET(pf_allrulecount) +VNET_DECLARE(struct pf_krule *, pf_rulemarker); +#define V_pf_rulemarker VNET(pf_rulemarker) #endif void pf_initialize(void); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index f3d82549edff..6e154b620a80 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -157,6 +157,10 @@ VNET_DEFINE_STATIC(uint32_t, pf_purge_idx); #ifdef PF_WANT_32_TO_64_COUNTER VNET_DEFINE_STATIC(uint32_t, pf_counter_periodic_iter); #define V_pf_counter_periodic_iter VNET(pf_counter_periodic_iter) + +VNET_DEFINE(struct allrulelist_head, pf_allrulelist); +VNET_DEFINE(size_t, pf_allrulecount); +VNET_DEFINE(struct pf_krule *, pf_rulemarker); #endif /* @@ -1574,6 +1578,45 @@ pf_kif_counter_u64_periodic(void) } } +static void +pf_rule_counter_u64_periodic(void) +{ + struct pf_krule *rule; + size_t r, run; + + PF_RULES_RASSERT(); + + if (__predict_false(V_pf_allrulecount == 0)) { + return; + } + + if ((V_pf_counter_periodic_iter % (pf_purge_thread_period * 10 * 300)) != 0) { + return; + } + + run = V_pf_allrulecount / 10; + if (run < 5) + run = 5; + + for (r = 0; r < run; r++) { + rule = LIST_NEXT(V_pf_rulemarker, allrulelist); + if (rule == NULL) { + LIST_REMOVE(V_pf_rulemarker, allrulelist); + LIST_INSERT_HEAD(&V_pf_allrulelist, V_pf_rulemarker, allrulelist); + break; + } + + LIST_REMOVE(V_pf_rulemarker, allrulelist); + LIST_INSERT_AFTER(rule, V_pf_rulemarker, allrulelist); + + pf_counter_u64_periodic(&rule->evaluations); + for (int i = 0; i < 2; i++) { + pf_counter_u64_periodic(&rule->packets[i]); + pf_counter_u64_periodic(&rule->bytes[i]); + } + } +} + static void pf_counter_u64_periodic_main(void) { @@ -1585,6 +1628,7 @@ pf_counter_u64_periodic_main(void) pf_counter_u64_critical_enter(); pf_status_counter_u64_periodic(); pf_kif_counter_u64_periodic(); + pf_rule_counter_u64_periodic(); pf_counter_u64_critical_exit(); PF_RULES_RUNLOCK(); } @@ -3642,7 +3686,7 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, int direction, } while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != direction) @@ -3711,8 +3755,8 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, int direction, rtableid = r->rtableid; if (r->anchor == NULL) { if (r->action == PF_MATCH) { - counter_u64_add(r->packets[direction == PF_OUT], 1); - counter_u64_add(r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -4084,7 +4128,7 @@ pf_test_fragment(struct pf_krule **rm, int direction, struct pfi_kkif *kif, r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_FILTER].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != direction) @@ -4125,8 +4169,8 @@ pf_test_fragment(struct pf_krule **rm, int direction, struct pfi_kkif *kif, else { if (r->anchor == NULL) { if (r->action == PF_MATCH) { - counter_u64_add(r->packets[direction == PF_OUT], 1); - counter_u64_add(r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -6431,17 +6475,17 @@ done: if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - counter_u64_add(r->packets[dirndx], 1); - counter_u64_add(r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&r->packets[dirndx], 1); + pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - counter_u64_add(a->packets[dirndx], 1); - counter_u64_add(a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&a->packets[dirndx], 1); + pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - counter_u64_add(s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], 1); - counter_u64_add(s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { @@ -6836,17 +6880,17 @@ done: if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - counter_u64_add(r->packets[dirndx], 1); - counter_u64_add(r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&r->packets[dirndx], 1); + pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - counter_u64_add(a->packets[dirndx], 1); - counter_u64_add(a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add(&a->packets[dirndx], 1); + pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - counter_u64_add(s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], 1); - counter_u64_add(s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index a0d877263235..7fece0facde6 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -324,10 +324,10 @@ pfattach_vnet(void) V_pf_default_rule.nr = -1; V_pf_default_rule.rtableid = -1; - V_pf_default_rule.evaluations = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&V_pf_default_rule.evaluations, M_WAITOK); for (int i = 0; i < 2; i++) { - V_pf_default_rule.packets[i] = counter_u64_alloc(M_WAITOK); - V_pf_default_rule.bytes[i] = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&V_pf_default_rule.packets[i], M_WAITOK); + pf_counter_u64_init(&V_pf_default_rule.bytes[i], M_WAITOK); } V_pf_default_rule.states_cur = counter_u64_alloc(M_WAITOK); V_pf_default_rule.states_tot = counter_u64_alloc(M_WAITOK); @@ -335,8 +335,12 @@ pfattach_vnet(void) #ifdef PF_WANT_32_TO_64_COUNTER V_pf_kifmarker = malloc(sizeof(*V_pf_kifmarker), PFI_MTYPE, M_WAITOK | M_ZERO); + V_pf_rulemarker = malloc(sizeof(*V_pf_rulemarker), M_PFRULE, M_WAITOK | M_ZERO); PF_RULES_WLOCK(); LIST_INSERT_HEAD(&V_pf_allkiflist, V_pf_kifmarker, pfik_allkiflist); + LIST_INSERT_HEAD(&V_pf_allrulelist, &V_pf_default_rule, allrulelist); + V_pf_allrulecount++; + LIST_INSERT_HEAD(&V_pf_allrulelist, V_pf_rulemarker, allrulelist); PF_RULES_WUNLOCK(); #endif @@ -1130,16 +1134,16 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) while ((tail != NULL) && ! pf_krule_compare(tail, rule)) tail = TAILQ_NEXT(tail, entries); if (tail != NULL) { - counter_u64_add(rule->evaluations, - counter_u64_fetch(tail->evaluations)); - counter_u64_add(rule->packets[0], - counter_u64_fetch(tail->packets[0])); - counter_u64_add(rule->packets[1], - counter_u64_fetch(tail->packets[1])); - counter_u64_add(rule->bytes[0], - counter_u64_fetch(tail->bytes[0])); - counter_u64_add(rule->bytes[1], - counter_u64_fetch(tail->bytes[1])); + pf_counter_u64_add(&rule->evaluations, + pf_counter_u64_fetch(&tail->evaluations)); + pf_counter_u64_add(&rule->packets[0], + pf_counter_u64_fetch(&tail->packets[0])); + pf_counter_u64_add(&rule->packets[1], + pf_counter_u64_fetch(&tail->packets[1])); + pf_counter_u64_add(&rule->bytes[0], + pf_counter_u64_fetch(&tail->bytes[0])); + pf_counter_u64_add(&rule->bytes[1], + pf_counter_u64_fetch(&tail->bytes[1])); } } } @@ -1519,13 +1523,29 @@ pf_altq_get_nth_active(u_int32_t n) void pf_krule_free(struct pf_krule *rule) { +#ifdef PF_WANT_32_TO_64_COUNTER + bool wowned; +#endif + if (rule == NULL) return; - counter_u64_free(rule->evaluations); +#ifdef PF_WANT_32_TO_64_COUNTER + if (rule->allrulelinked) { + wowned = PF_RULES_WOWNED(); + if (!wowned) + PF_RULES_WLOCK(); + LIST_REMOVE(rule, allrulelist); + V_pf_allrulecount--; + if (!wowned) + PF_RULES_WUNLOCK(); + } +#endif + + pf_counter_u64_deinit(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_free(rule->packets[i]); - counter_u64_free(rule->bytes[i]); + pf_counter_u64_deinit(&rule->packets[i]); + pf_counter_u64_deinit(&rule->bytes[i]); } counter_u64_free(rule->states_cur); counter_u64_free(rule->states_tot); @@ -1590,7 +1610,7 @@ pf_pool_to_kpool(const struct pf_pool *pool, struct pf_kpool *kpool) } static void -pf_krule_to_rule(const struct pf_krule *krule, struct pf_rule *rule) +pf_krule_to_rule(struct pf_krule *krule, struct pf_rule *rule) { bzero(rule, sizeof(*rule)); @@ -1617,10 +1637,10 @@ pf_krule_to_rule(const struct pf_krule *krule, struct pf_rule *rule) pf_kpool_to_pool(&krule->rpool, &rule->rpool); - rule->evaluations = counter_u64_fetch(krule->evaluations); + rule->evaluations = pf_counter_u64_fetch(&krule->evaluations); for (int i = 0; i < 2; i++) { - rule->packets[i] = counter_u64_fetch(krule->packets[i]); - rule->bytes[i] = counter_u64_fetch(krule->bytes[i]); + rule->packets[i] = pf_counter_u64_fetch(&krule->packets[i]); + rule->bytes[i] = pf_counter_u64_fetch(&krule->bytes[i]); } /* kif, anchor, overload_tbl are not copied over. */ @@ -1997,10 +2017,10 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, if (rule->ifname[0]) kif = pf_kkif_create(M_WAITOK); - rule->evaluations = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&rule->evaluations, M_WAITOK); for (int i = 0; i < 2; i++) { - rule->packets[i] = counter_u64_alloc(M_WAITOK); - rule->bytes[i] = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&rule->packets[i], M_WAITOK); + pf_counter_u64_init(&rule->bytes[i], M_WAITOK); } rule->states_cur = counter_u64_alloc(M_WAITOK); rule->states_tot = counter_u64_alloc(M_WAITOK); @@ -2010,6 +2030,12 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, TAILQ_INIT(&rule->rpool.list); PF_RULES_WLOCK(); +#ifdef PF_WANT_32_TO_64_COUNTER + LIST_INSERT_HEAD(&V_pf_allrulelist, rule, allrulelist); + MPASS(!rule->allrulelinked); + rule->allrulelinked = true; + V_pf_allrulecount++; +#endif ruleset = pf_find_kruleset(anchor); if (ruleset == NULL) ERROUT(EINVAL); @@ -2113,10 +2139,10 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, } rule->rpool.cur = TAILQ_FIRST(&rule->rpool.list); - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } TAILQ_INSERT_TAIL(ruleset->rules[rs_num].inactive.ptr, rule, entries); @@ -2459,10 +2485,10 @@ DIOCADDRULENV_error: pf_addr_copyout(&pr->rule.dst.addr); if (pr->action == PF_GET_CLR_CNTR) { - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } counter_u64_zero(rule->states_tot); } @@ -2581,10 +2607,10 @@ DIOCADDRULENV_error: } if (clear_counter) { - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } counter_u64_zero(rule->states_tot); } @@ -2632,12 +2658,10 @@ DIOCGETRULENV_error: if (newrule->ifname[0]) kif = pf_kkif_create(M_WAITOK); - newrule->evaluations = counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&newrule->evaluations, M_WAITOK); for (int i = 0; i < 2; i++) { - newrule->packets[i] = - counter_u64_alloc(M_WAITOK); - newrule->bytes[i] = - counter_u64_alloc(M_WAITOK); + pf_counter_u64_init(&newrule->packets[i], M_WAITOK); + pf_counter_u64_init(&newrule->bytes[i], M_WAITOK); } newrule->states_cur = counter_u64_alloc(M_WAITOK); newrule->states_tot = counter_u64_alloc(M_WAITOK); @@ -2649,6 +2673,14 @@ DIOCGETRULENV_error: #define ERROUT(x) { error = (x); goto DIOCCHANGERULE_error; } PF_RULES_WLOCK(); +#ifdef PF_WANT_32_TO_64_COUNTER + if (newrule != NULL) { + LIST_INSERT_HEAD(&V_pf_allrulelist, newrule, allrulelist); + newrule->allrulelinked = true; + V_pf_allrulecount++; + } +#endif + if (!(pcr->action == PF_CHANGE_REMOVE || pcr->action == PF_CHANGE_GET_TICKET) && pcr->pool_ticket != V_ticket_pabuf) @@ -3229,10 +3261,10 @@ DIOCGETSTATESV2_full: PF_RULES_WLOCK(); TAILQ_FOREACH(rule, ruleset->rules[PF_RULESET_FILTER].active.ptr, entries) { - counter_u64_zero(rule->evaluations); + pf_counter_u64_zero(&rule->evaluations); for (int i = 0; i < 2; i++) { - counter_u64_zero(rule->packets[i]); - counter_u64_zero(rule->bytes[i]); + pf_counter_u64_zero(&rule->packets[i]); + pf_counter_u64_zero(&rule->bytes[i]); } } PF_RULES_WUNLOCK(); @@ -5613,18 +5645,33 @@ pf_unload_vnet(void) #ifdef PF_WANT_32_TO_64_COUNTER PF_RULES_WLOCK(); LIST_REMOVE(V_pf_kifmarker, pfik_allkiflist); - PF_RULES_WUNLOCK(); - free(V_pf_kifmarker, PFI_MTYPE); MPASS(LIST_EMPTY(&V_pf_allkiflist)); MPASS(V_pf_allkifcount == 0); + + LIST_REMOVE(&V_pf_default_rule, allrulelist); + V_pf_allrulecount--; + LIST_REMOVE(V_pf_rulemarker, allrulelist); + + /* + * There are known pf rule leaks when running the test suite. + */ +#ifdef notyet + MPASS(LIST_EMPTY(&V_pf_allrulelist)); + MPASS(V_pf_allrulecount == 0); +#endif + + PF_RULES_WUNLOCK(); + + free(V_pf_kifmarker, PFI_MTYPE); + free(V_pf_rulemarker, M_PFRULE); #endif /* Free counters last as we updated them during shutdown. */ - counter_u64_free(V_pf_default_rule.evaluations); + pf_counter_u64_deinit(&V_pf_default_rule.evaluations); for (int i = 0; i < 2; i++) { - counter_u64_free(V_pf_default_rule.packets[i]); - counter_u64_free(V_pf_default_rule.bytes[i]); + pf_counter_u64_deinit(&V_pf_default_rule.packets[i]); + pf_counter_u64_deinit(&V_pf_default_rule.bytes[i]); } counter_u64_free(V_pf_default_rule.states_cur); counter_u64_free(V_pf_default_rule.states_tot); diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c index 000ee69d9ae9..3da27c7df26d 100644 --- a/sys/netpfil/pf/pf_lb.c +++ b/sys/netpfil/pf/pf_lb.c @@ -149,7 +149,7 @@ pf_match_translation(struct pf_pdesc *pd, struct mbuf *m, int off, dst = &r->dst; } - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != direction) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 3df4e06f15b6..388e2bca77b6 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -1039,7 +1039,7 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != dir) @@ -1066,8 +1066,8 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (hlen < (int)sizeof(struct ip)) { @@ -1181,7 +1181,7 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != dir) @@ -1207,8 +1207,8 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); /* Check for illegal packets */ if (sizeof(struct ip6_hdr) + IPV6_MAXPACKET < m->m_pkthdr.len) @@ -1334,7 +1334,7 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr); while (r != NULL) { - counter_u64_add(r->evaluations, 1); + pf_counter_u64_add(&r->evaluations, 1); if (pfi_kkif_match(r->kif, kif) == r->ifnot) r = r->skip[PF_SKIP_IFP].ptr; else if (r->direction && r->direction != dir) @@ -1368,8 +1368,8 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, if (rm == NULL || rm->action == PF_NOSCRUB) return (PF_PASS); - counter_u64_add(r->packets[dir == PF_OUT], 1); - counter_u64_add(r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); if (rm->rule_flag & PFRULE_REASSEMBLE_TCP) pd->flags |= PFDESC_TCP_NORM; diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index c0a17cd876ae..d1eca90e0ee5 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -655,7 +655,7 @@ error: } nvlist_t * -pf_krule_to_nvrule(const struct pf_krule *rule) +pf_krule_to_nvrule(struct pf_krule *rule) { nvlist_t *nvl, *tmp; @@ -698,12 +698,12 @@ pf_krule_to_nvrule(const struct pf_krule *rule) nvlist_destroy(tmp); nvlist_add_number(nvl, "evaluations", - counter_u64_fetch(rule->evaluations)); + pf_counter_u64_fetch(&rule->evaluations)); for (int i = 0; i < 2; i++) { nvlist_append_number_array(nvl, "packets", - counter_u64_fetch(rule->packets[i])); + pf_counter_u64_fetch(&rule->packets[i])); nvlist_append_number_array(nvl, "bytes", - counter_u64_fetch(rule->bytes[i])); + pf_counter_u64_fetch(&rule->bytes[i])); } nvlist_add_number(nvl, "os_fingerprint", rule->os_fingerprint); diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index 2abb5a2401e2..f1cdc52aad6b 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -78,7 +78,7 @@ int pf_nvstring(const nvlist_t *, const char *, char *, size_t); int pf_check_rule_addr(const struct pf_rule_addr *); -nvlist_t *pf_krule_to_nvrule(const struct pf_krule *); +nvlist_t *pf_krule_to_nvrule(struct pf_krule *); int pf_nvrule_to_krule(const nvlist_t *, struct pf_krule *); int pf_nvstate_kill_to_kstate_kill(const nvlist_t *, struct pf_kstate_kill *); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 15:22:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5130C65618B; Wed, 11 Aug 2021 15:22: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 4GlD8m1Tgvz3LV8; Wed, 11 Aug 2021 15:22: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 13A9A118FF; Wed, 11 Aug 2021 15:22: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 17BFMms3064394; Wed, 11 Aug 2021 15:22:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BFMlbY064393; Wed, 11 Aug 2021 15:22:47 GMT (envelope-from git) Date: Wed, 11 Aug 2021 15:22:47 GMT Message-Id: <202108111522.17BFMlbY064393@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: bf60d2826768 - stable/13 - pf: batch critical section for several counters 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: bf60d2826768ca4ab125ba770b14b04d303dea2f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 15:22:48 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=bf60d2826768ca4ab125ba770b14b04d303dea2f commit bf60d2826768ca4ab125ba770b14b04d303dea2f Author: Mateusz Guzik AuthorDate: 2021-07-24 07:47:40 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-11 13:37:56 +0000 pf: batch critical section for several counters Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 87c010e6e364e96e2c1546b3c2bbcbef1dcd422f) --- sys/netpfil/pf/pf.c | 48 +++++++++++++++++++++++++++-------------------- sys/netpfil/pf/pf_ioctl.c | 12 +++++++----- sys/netpfil/pf/pf_norm.c | 18 ++++++++++++------ 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 6e154b620a80..633346eee21c 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -3755,8 +3755,10 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, int direction, rtableid = r->rtableid; if (r->anchor == NULL) { if (r->action == PF_MATCH) { - pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -4169,8 +4171,10 @@ pf_test_fragment(struct pf_krule **rm, int direction, struct pfi_kkif *kif, else { if (r->anchor == NULL) { if (r->action == PF_MATCH) { - pf_counter_u64_add(&r->packets[direction == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[direction == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[direction == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); pf_rule_to_actions(r, &pd->act); if (r->log) PFLOG_PACKET(kif, m, af, @@ -6468,24 +6472,25 @@ done: (s == NULL)); } - pf_counter_u64_add(&kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS], pd.tot_len); - pf_counter_u64_add(&kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add_protected(&kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - pf_counter_u64_add(&r->packets[dirndx], 1); - pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&r->packets[dirndx], 1); + pf_counter_u64_add_protected(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - pf_counter_u64_add(&a->packets[dirndx], 1); - pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&a->packets[dirndx], 1); + pf_counter_u64_add_protected(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->packets[dirndx], 1); - pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { @@ -6523,6 +6528,7 @@ done: pd.af, pd.tot_len, dir == PF_OUT, r->action == PF_PASS, tr->dst.neg); } + pf_counter_u64_critical_exit(); switch (action) { case PF_SYNPROXY_DROP: @@ -6873,24 +6879,25 @@ done: &pd, (s == NULL)); } - pf_counter_u64_add(&kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS], pd.tot_len); - pf_counter_u64_add(&kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], + pf_counter_u64_add_protected(&kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS], 1); if (action == PF_PASS || r->action == PF_DROP) { dirndx = (dir == PF_OUT); - pf_counter_u64_add(&r->packets[dirndx], 1); - pf_counter_u64_add(&r->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&r->packets[dirndx], 1); + pf_counter_u64_add_protected(&r->bytes[dirndx], pd.tot_len); if (a != NULL) { - pf_counter_u64_add(&a->packets[dirndx], 1); - pf_counter_u64_add(&a->bytes[dirndx], pd.tot_len); + pf_counter_u64_add_protected(&a->packets[dirndx], 1); + pf_counter_u64_add_protected(&a->bytes[dirndx], pd.tot_len); } if (s != NULL) { if (s->nat_rule.ptr != NULL) { - pf_counter_u64_add(&s->nat_rule.ptr->packets[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->packets[dirndx], 1); - pf_counter_u64_add(&s->nat_rule.ptr->bytes[dirndx], + pf_counter_u64_add_protected(&s->nat_rule.ptr->bytes[dirndx], pd.tot_len); } if (s->src_node != NULL) { @@ -6926,6 +6933,7 @@ done: pd.af, pd.tot_len, dir == PF_OUT, r->action == PF_PASS, tr->dst.neg); } + pf_counter_u64_critical_exit(); switch (action) { case PF_SYNPROXY_DROP: diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 7fece0facde6..ebb30604ebf1 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1134,16 +1134,18 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) while ((tail != NULL) && ! pf_krule_compare(tail, rule)) tail = TAILQ_NEXT(tail, entries); if (tail != NULL) { - pf_counter_u64_add(&rule->evaluations, + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&rule->evaluations, pf_counter_u64_fetch(&tail->evaluations)); - pf_counter_u64_add(&rule->packets[0], + pf_counter_u64_add_protected(&rule->packets[0], pf_counter_u64_fetch(&tail->packets[0])); - pf_counter_u64_add(&rule->packets[1], + pf_counter_u64_add_protected(&rule->packets[1], pf_counter_u64_fetch(&tail->packets[1])); - pf_counter_u64_add(&rule->bytes[0], + pf_counter_u64_add_protected(&rule->bytes[0], pf_counter_u64_fetch(&tail->bytes[0])); - pf_counter_u64_add(&rule->bytes[1], + pf_counter_u64_add_protected(&rule->bytes[1], pf_counter_u64_fetch(&tail->bytes[1])); + pf_counter_u64_critical_exit(); } } } diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 388e2bca77b6..e9674d21ec5a 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -1066,8 +1066,10 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kkif *kif, u_short *reason if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); /* Check for illegal packets */ if (hlen < (int)sizeof(struct ip)) { @@ -1207,8 +1209,10 @@ pf_normalize_ip6(struct mbuf **m0, int dir, struct pfi_kkif *kif, if (r == NULL || r->action == PF_NOSCRUB) return (PF_PASS); - pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); /* Check for illegal packets */ if (sizeof(struct ip6_hdr) + IPV6_MAXPACKET < m->m_pkthdr.len) @@ -1368,8 +1372,10 @@ pf_normalize_tcp(int dir, struct pfi_kkif *kif, struct mbuf *m, int ipoff, if (rm == NULL || rm->action == PF_NOSCRUB) return (PF_PASS); - pf_counter_u64_add(&r->packets[dir == PF_OUT], 1); - pf_counter_u64_add(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_enter(); + pf_counter_u64_add_protected(&r->packets[dir == PF_OUT], 1); + pf_counter_u64_add_protected(&r->bytes[dir == PF_OUT], pd->tot_len); + pf_counter_u64_critical_exit(); if (rm->rule_flag & PFRULE_REASSEMBLE_TCP) pd->flags |= PFDESC_TCP_NORM; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:05:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44D8C6575C2; Wed, 11 Aug 2021 17:05: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 4GlGQp1DwPz3hcb; Wed, 11 Aug 2021 17:05: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 0EEC613300; Wed, 11 Aug 2021 17:05: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 17BH55Oe098031; Wed, 11 Aug 2021 17:05:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BH559B098030; Wed, 11 Aug 2021 17:05:05 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:05:05 GMT Message-Id: <202108111705.17BH559B098030@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 879675e9a0d8 - main - stand: Add MK_PIE=no to defs.mk MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 879675e9a0d84880cad9834e2ef98e8724c5532c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:05:06 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=879675e9a0d84880cad9834e2ef98e8724c5532c commit 879675e9a0d84880cad9834e2ef98e8724c5532c Author: Warner Losh AuthorDate: 2021-08-11 16:59:28 +0000 Commit: Warner Losh CommitDate: 2021-08-11 17:03:19 +0000 stand: Add MK_PIE=no to defs.mk There's no need to build both pie and non-pie .o's for stand. There's some other build thing with MK_BEAR_SSL=yes and/or MK_LOADER_VERIEXEC=yes that causes the pie build to fail that the 'ar' stage now. Since we don't need the PIE stuff and the non-PIE stuff, disable PIE for the boot loader. Reviewed by: emaste Sponsored by: Netflix --- stand/defs.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/stand/defs.mk b/stand/defs.mk index 1e22f7b7c693..aee4636985ac 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -10,6 +10,7 @@ __BOOT_DEFS_MK__=${MFILE} MK_CTF= no MK_SSP= no MK_PROFILE= no +MK_PIE= no MAN= .if !defined(PIC) NO_PIC= From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:10:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1646D6575E6; Wed, 11 Aug 2021 17:10: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 4GlGXq72lQz3hZD; Wed, 11 Aug 2021 17:10: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 D5C58129DD; Wed, 11 Aug 2021 17:10: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 17BHAJK6006003; Wed, 11 Aug 2021 17:10:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHAJXT005996; Wed, 11 Aug 2021 17:10:19 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:10:19 GMT Message-Id: <202108111710.17BHAJXT005996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b2da1032397e - main - ncurses: Apply a tputs() fix from patch 20210403 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/main X-Git-Reftype: branch X-Git-Commit: b2da1032397e3339fbeebcd57b1f179e1d8a2e19 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:10:20 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b2da1032397e3339fbeebcd57b1f179e1d8a2e19 commit b2da1032397e3339fbeebcd57b1f179e1d8a2e19 Author: Mark Johnston AuthorDate: 2021-08-11 16:54:29 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 17:08:23 +0000 ncurses: Apply a tputs() fix from patch 20210403 From the (substantially larger) upstream commit: + call delay_output_sp to handle BSD-style padding when tputs_sp is called, whether directly or internally, to ensure that the SCREEN pointer is passed correctly (reports by Henric Jungheim, Juraj Lutter). This fixes bison segfaults observed when colourized output is enabled. Thanks to jrtc27@ for identifying the upstream fix. PR: 256731 MFC after: 3 days --- contrib/ncurses/ncurses/tinfo/lib_tputs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c index 3eb19d2d9662..4b89a19ed9dd 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c +++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -52,7 +52,7 @@ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.106 2020/11/29 00:40:08 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.107 2021/04/03 18:45:53 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */ @@ -429,7 +429,7 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx */ if (trailpad > 0 && (always_delay || normal_delay)) - delay_output(trailpad / 10); + NCURSES_SP_NAME(delay_output) (NCURSES_SP_ARGx trailpad / 10); #endif /* BSD_TPUTS */ SetOutCh(my_outch); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:10:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 163B465769F; Wed, 11 Aug 2021 17:10: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 4GlGXs06tLz3hrN; Wed, 11 Aug 2021 17:10: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 E157C13251; Wed, 11 Aug 2021 17:10: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 17BHAKYL006494; Wed, 11 Aug 2021 17:10:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHAKha006488; Wed, 11 Aug 2021 17:10:20 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:10:20 GMT Message-Id: <202108111710.17BHAKha006488@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 05eba8e068c1 - main - RELNOTES: Add entries for KASAN and KMSAN 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/main X-Git-Reftype: branch X-Git-Commit: 05eba8e068c192564075a62b70217031b2eeb3fe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:10:21 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=05eba8e068c192564075a62b70217031b2eeb3fe commit 05eba8e068c192564075a62b70217031b2eeb3fe Author: Mark Johnston AuthorDate: 2021-08-11 17:05:50 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 17:08:36 +0000 RELNOTES: Add entries for KASAN and KMSAN Sponsored by: The FreeBSD Foundation --- RELNOTES | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RELNOTES b/RELNOTES index a33128e7370f..c5d4c038cfe7 100644 --- a/RELNOTES +++ b/RELNOTES @@ -10,6 +10,14 @@ newline. Entries should be separated by a newline. Changes to this file should not be MFCed. +422084abbda: + LLVM's MemorySanitizer can now be used in amd64 kernels. See the + kmsan(9) manual page for more information. + +38da497a4dfc: + LLVM's AddressSanitizer can now be used in amd64 kernels. See the + kasan(9) manual page for more information. + f39dd6a97844,23f24377b1a9,628bd30ab5a4: One True Awk has been updated to the latest from upstream (20210727). All the FreeBSD patches, but one, have now been From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:24:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B2E7C657C5B; Wed, 11 Aug 2021 17:24: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 4GlGsL4jpPz3jj8; Wed, 11 Aug 2021 17:24: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 89E231316E; Wed, 11 Aug 2021 17:24: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 17BHOcus026087; Wed, 11 Aug 2021 17:24:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHOcaL026086; Wed, 11 Aug 2021 17:24:38 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:24:38 GMT Message-Id: <202108111724.17BHOcaL026086@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 2e50ba70742b - stable/13 - hwpmc: disable uncore class on Sandy Bridge and newer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2e50ba70742bac34f144832ceb5f6816fcc06be2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:24:38 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=2e50ba70742bac34f144832ceb5f6816fcc06be2 commit 2e50ba70742bac34f144832ceb5f6816fcc06be2 Author: Mitchell Horne AuthorDate: 2021-08-04 17:31:36 +0000 Commit: Mitchell Horne CommitDate: 2021-08-11 16:49:44 +0000 hwpmc: disable uncore class on Sandy Bridge and newer It was written for Nehalem and Westmere, with minor but incomplete updates for Sandy Bridge in 78d763a29b15. The uncore architecture changed significantly with this generation, bringing new layouts and locations for some MSRs. Misprogramming these MSRs in ucp_start_pmc() may panic the system, and this is trivially reproducible via pmcstat(8) on at least Broadwell and Haswell. Disable the class on these CPUs until it can be updated more completely and leave a TODO comment detailing some of the work required. Note that the nclasses value for Broadwell was already incorrect and doesn't need changing. The result is that any uncore events listed by pmcstat -L will no longer be allocatable, but this is already the case for newer generations of Intel CPUs. PR: 253687 Reported by: Zhenlei Huang Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31389 (cherry picked from commit 4f35e8cba232d9256ab1399b8adfb761988e5eff) --- sys/dev/hwpmc/hwpmc_intel.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_intel.c b/sys/dev/hwpmc/hwpmc_intel.c index aec037b64938..02b8fd9431d1 100644 --- a/sys/dev/hwpmc/hwpmc_intel.c +++ b/sys/dev/hwpmc/hwpmc_intel.c @@ -149,7 +149,7 @@ pmc_intel_initialize(void) break; case 0x2A: /* Per Intel document 253669-039US 05/2011. */ cputype = PMC_CPU_INTEL_SANDYBRIDGE; - nclasses = 5; + nclasses = 3; break; case 0x2D: /* Per Intel document 253669-044US 08/2012. */ cputype = PMC_CPU_INTEL_SANDYBRIDGE_XEON; @@ -195,7 +195,7 @@ pmc_intel_initialize(void) case 0x3C: /* Per Intel document 325462-045US 01/2013. */ case 0x45: /* Per Intel document 325462-045US 09/2014. */ cputype = PMC_CPU_INTEL_HASWELL; - nclasses = 5; + nclasses = 3; break; case 0x37: case 0x4A: @@ -275,10 +275,27 @@ pmc_intel_initialize(void) * Intel Corei7 and Westmere processors. */ case PMC_CPU_INTEL_COREI7: - case PMC_CPU_INTEL_HASWELL: - case PMC_CPU_INTEL_SANDYBRIDGE: case PMC_CPU_INTEL_WESTMERE: +#ifdef notyet + /* + * TODO: re-enable uncore class on these processors. + * + * The uncore unit was reworked beginning with Sandy Bridge, including + * the MSRs required to program it. In particular, we need to: + * - Parse the MSR_UNC_CBO_CONFIG MSR for number of C-box units in the + * system + * - Support reading and writing to ARB and C-box units, depending on + * the requested event + * - Create some kind of mapping between C-box <--> CPU + * + * Also TODO: support other later changes to these interfaces, to + * enable the uncore class on generations newer than Broadwell. + * Skylake+ appears to use newer addresses for the uncore MSRs. + */ + case PMC_CPU_INTEL_HASWELL: case PMC_CPU_INTEL_BROADWELL: + case PMC_CPU_INTEL_SANDYBRIDGE: +#endif error = pmc_uncore_initialize(pmc_mdep, ncpus); break; default: @@ -329,11 +346,13 @@ pmc_intel_finalize(struct pmc_mdep *md) * Uncore. */ switch (md->pmd_cputype) { - case PMC_CPU_INTEL_BROADWELL: case PMC_CPU_INTEL_COREI7: + case PMC_CPU_INTEL_WESTMERE: +#ifdef notyet case PMC_CPU_INTEL_HASWELL: + case PMC_CPU_INTEL_BROADWELL: case PMC_CPU_INTEL_SANDYBRIDGE: - case PMC_CPU_INTEL_WESTMERE: +#endif pmc_uncore_finalize(md); break; default: From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:24:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D7E3C657C64; Wed, 11 Aug 2021 17:24:39 +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 4GlGsM5hQmz3jmW; Wed, 11 Aug 2021 17:24:39 +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 AD01E13692; Wed, 11 Aug 2021 17:24:39 +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 17BHOdBl026111; Wed, 11 Aug 2021 17:24:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHOd4G026110; Wed, 11 Aug 2021 17:24:39 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:24:39 GMT Message-Id: <202108111724.17BHOd4G026110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 19cbaf34a3e4 - stable/13 - mk: format some option lists MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 19cbaf34a3e47475f72f2ba3783d9281ca57996f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:24:39 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=19cbaf34a3e47475f72f2ba3783d9281ca57996f commit 19cbaf34a3e47475f72f2ba3783d9281ca57996f Author: Mitchell Horne AuthorDate: 2021-08-04 18:17:34 +0000 Commit: Mitchell Horne CommitDate: 2021-08-11 16:53:16 +0000 mk: format some option lists Alphabetize and give each option its own line, ahead of making another change to these lists. This makes future diffs easier to read. Reviewed by: imp, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31399 (cherry picked from commit bcd2f41f7d222a942fe0a268614b46d3ec3af4c0) --- Makefile.inc1 | 48 ++++++++++++++++++++++++--------- Makefile.libcompat | 8 ++++-- targets/pseudo/bootstrap-tools/Makefile | 23 +++++++++++----- 3 files changed, 59 insertions(+), 20 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 8b417eaaac05..a03b79a5b02c 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -727,12 +727,23 @@ BSARGS= DESTDIR= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ SSP_CFLAGS= \ - MK_HTML=no NO_LINT=yes MK_MAN=no MK_MAN_UTILS=yes \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_WERROR=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no \ - MK_INCLUDES=yes + -DNO_CPU_CFLAGS \ + -DNO_LINT \ + -DNO_PIC \ + -DNO_SHARED \ + MK_CTF=no \ + MK_CLANG_EXTRAS=no \ + MK_CLANG_FORMAT=no \ + MK_CLANG_FULL=no \ + MK_HTML=no \ + MK_LLDB=no \ + MK_MAN=no \ + MK_PROFILE=no \ + MK_RETPOLINE=no \ + MK_TESTS=no \ + MK_WERROR=no \ + MK_INCLUDES=yes \ + MK_MAN_UTILS=yes BMAKE= \ ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ @@ -749,10 +760,16 @@ TMAKE= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ SSP_CFLAGS= \ + -DNO_CPU_CFLAGS \ -DNO_LINT \ - -DNO_CPU_CFLAGS MK_WERROR=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no + MK_CTF=no \ + MK_CLANG_EXTRAS=no \ + MK_CLANG_FORMAT=no \ + MK_CLANG_FULL=no \ + MK_LLDB=no \ + MK_RETPOLINE=no \ + MK_TESTS=no \ + MK_WERROR=no # cross-tools stage # TOOLS_PREFIX set in BMAKE @@ -776,9 +793,16 @@ KTMAKE= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ SSP_CFLAGS= \ - MK_HTML=no -DNO_LINT MK_MAN=no \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WERROR=no MK_CTF=no + -DNO_CPU_CFLAGS \ + -DNO_LINT \ + -DNO_PIC \ + -DNO_SHARED \ + MK_CTF=no \ + MK_HTML=no \ + MK_MAN=no \ + MK_PROFILE=no \ + MK_RETPOLINE=no \ + MK_WERROR=no # world stage WMAKEENV= ${CROSSENV} \ diff --git a/Makefile.libcompat b/Makefile.libcompat index 779bcb163cf7..7238c6faf898 100644 --- a/Makefile.libcompat +++ b/Makefile.libcompat @@ -103,8 +103,12 @@ build${libcompat}: .PHONY OBJTOP=${LIBCOMPAT_OBJTOP} \ OBJROOT='$${OBJTOP}/' \ MAKEOBJDIRPREFIX= \ - DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \ - MK_CTF=no MK_RETPOLINE=no MK_WERROR=no \ + DIRPRFX=${_dir}/ \ + -DNO_LINT \ + -DNO_CPU_CFLAGS \ + MK_CTF=no \ + MK_RETPOLINE=no \ + MK_WERROR=no \ ${_t} .endfor .endfor diff --git a/targets/pseudo/bootstrap-tools/Makefile b/targets/pseudo/bootstrap-tools/Makefile index 0023f763af83..1a7f2bd15ad0 100644 --- a/targets/pseudo/bootstrap-tools/Makefile +++ b/targets/pseudo/bootstrap-tools/Makefile @@ -40,12 +40,23 @@ BSARGS= DESTDIR= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET} \ SSP_CFLAGS= \ - MK_HTML=no NO_LINT=yes MK_MAN=no \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_WERROR=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_TESTS=no \ - MK_INCLUDES=yes + -DNO_CPU_CFLAGS \ + -DNO_LINT \ + -DNO_PIC \ + -DNO_SHARED \ + MK_CTF=no \ + MK_CLANG_EXTRAS=no \ + MK_CLANG_FORMAT=no \ + MK_CLANG_FULL=no \ + MK_HTML=no \ + MK_LLDB=no \ + MK_MAN=no \ + MK_PROFILE=no \ + MK_RETPOLINE=no \ + MK_TESTS=no \ + MK_WERROR=no \ + MK_INCLUDES=yes \ + MK_MAN_UTILS=yes # We will handle building the toolchain and cross-compiler. BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:24:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56B61657D0E; Wed, 11 Aug 2021 17:24: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 4GlGsP027Pz3jmh; Wed, 11 Aug 2021 17:24: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 D103C13359; Wed, 11 Aug 2021 17:24: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 17BHOeFs026137; Wed, 11 Aug 2021 17:24:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHOeUF026136; Wed, 11 Aug 2021 17:24:40 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:24:40 GMT Message-Id: <202108111724.17BHOeUF026136@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 952226eedb0b - stable/13 - Prefer MK_SSP=no to SSP_CFLAGS= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 952226eedb0be32b2c952fb2ae12f76a62131c00 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:24:41 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=952226eedb0be32b2c952fb2ae12f76a62131c00 commit 952226eedb0be32b2c952fb2ae12f76a62131c00 Author: Mitchell Horne AuthorDate: 2021-08-04 18:20:50 +0000 Commit: Mitchell Horne CommitDate: 2021-08-11 16:56:28 +0000 Prefer MK_SSP=no to SSP_CFLAGS= It is more idiomatic. CFLAGS is only augmented with $SSP_CFLAGS when $MK_SSP != "no". Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31401 (cherry picked from commit 61ed578ee66648eff206ee5622b66727bfb52e78) --- Makefile.inc1 | 8 ++++---- Makefile.libcompat | 3 ++- lib/csu/Makefile.inc | 3 +-- lib/libclang_rt/Makefile.inc | 2 +- stand/defs.mk | 2 -- targets/pseudo/bootstrap-tools/Makefile | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index a03b79a5b02c..cc854fbebbb1 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -726,7 +726,6 @@ BSARGS= DESTDIR= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ -DNO_PIC \ @@ -740,6 +739,7 @@ BSARGS= DESTDIR= \ MK_MAN=no \ MK_PROFILE=no \ MK_RETPOLINE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WERROR=no \ MK_INCLUDES=yes \ @@ -759,7 +759,6 @@ TMAKE= \ DESTDIR= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ MK_CTF=no \ @@ -768,6 +767,7 @@ TMAKE= \ MK_CLANG_FULL=no \ MK_LLDB=no \ MK_RETPOLINE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WERROR=no @@ -792,7 +792,6 @@ KTMAKE= \ OBJROOT='$${OBJTOP}/' \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ -DNO_PIC \ @@ -801,6 +800,7 @@ KTMAKE= \ MK_HTML=no \ MK_MAN=no \ MK_PROFILE=no \ + MK_SSP=no \ MK_RETPOLINE=no \ MK_WERROR=no @@ -2780,7 +2780,6 @@ NXBMAKEARGS+= \ -DNO_SHARED \ -DNO_CPU_CFLAGS \ -DNO_PIC \ - SSP_CFLAGS= \ MK_CASPER=no \ MK_CLANG_EXTRAS=no \ MK_CLANG_FORMAT=no \ @@ -2797,6 +2796,7 @@ NXBMAKEARGS+= \ MK_RETPOLINE=no \ MK_SENDMAIL=no \ MK_SVNLITE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WERROR=no \ MK_ZFS=no diff --git a/Makefile.libcompat b/Makefile.libcompat index 7238c6faf898..3691050b9f69 100644 --- a/Makefile.libcompat +++ b/Makefile.libcompat @@ -99,7 +99,7 @@ build${libcompat}: .PHONY ${_+_}cd ${.CURDIR}/${_dir}; \ WORLDTMP=${WORLDTMP} \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ - ${MAKE} SSP_CFLAGS= DESTDIR= \ + ${MAKE} DESTDIR= \ OBJTOP=${LIBCOMPAT_OBJTOP} \ OBJROOT='$${OBJTOP}/' \ MAKEOBJDIRPREFIX= \ @@ -108,6 +108,7 @@ build${libcompat}: .PHONY -DNO_CPU_CFLAGS \ MK_CTF=no \ MK_RETPOLINE=no \ + MK_SSP=no \ MK_WERROR=no \ ${_t} .endfor diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc index 5681ef65117a..d39722847b4e 100644 --- a/lib/csu/Makefile.inc +++ b/lib/csu/Makefile.inc @@ -1,10 +1,9 @@ # $FreeBSD$ -SSP_CFLAGS= - NO_WMISSING_VARIABLE_DECLARATIONS= .include +MK_SSP= no .if !defined(BUILDING_TESTS) diff --git a/lib/libclang_rt/Makefile.inc b/lib/libclang_rt/Makefile.inc index 946d3f4c77a7..95fa32ba1f66 100644 --- a/lib/libclang_rt/Makefile.inc +++ b/lib/libclang_rt/Makefile.inc @@ -12,10 +12,10 @@ SHLIBDIR= ${LIBDIR} NO_PIC= MK_PROFILE= no +MK_SSP= no WARNS?= 0 -SSP_CFLAGS= CFLAGS+= -DNDEBUG CFLAGS+= -DHAVE_RPC_XDR_H=0 CFLAGS+= -DSANITIZER_SUPPORTS_WEAK_HOOKS=0 diff --git a/stand/defs.mk b/stand/defs.mk index d50c89879613..901c30666835 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -129,8 +129,6 @@ LD_FLAGS+= -m elf_i386_fbsd AFLAGS+= --32 .endif -SSP_CFLAGS= - # Add in the no float / no SIMD stuff and announce we're freestanding # aarch64 and riscv don't have -msoft-float, but all others do. CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} diff --git a/targets/pseudo/bootstrap-tools/Makefile b/targets/pseudo/bootstrap-tools/Makefile index 1a7f2bd15ad0..3ac47053a388 100644 --- a/targets/pseudo/bootstrap-tools/Makefile +++ b/targets/pseudo/bootstrap-tools/Makefile @@ -39,7 +39,6 @@ BSARGS= DESTDIR= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ -DNO_PIC \ @@ -53,6 +52,7 @@ BSARGS= DESTDIR= \ MK_MAN=no \ MK_PROFILE=no \ MK_RETPOLINE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WERROR=no \ MK_INCLUDES=yes \ From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:25:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 32A76657ECC; Wed, 11 Aug 2021 17:25: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 4GlGsz0wHCz3jsZ; Wed, 11 Aug 2021 17:25: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 0825C1335A; Wed, 11 Aug 2021 17:25: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 17BHPA3k026341; Wed, 11 Aug 2021 17:25:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHPAL9026340; Wed, 11 Aug 2021 17:25:10 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:25:10 GMT Message-Id: <202108111725.17BHPAL9026340@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 88ef00584bc7 - stable/12 - hwpmc: disable uncore class on Sandy Bridge and newer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 88ef00584bc7f9f9e19546bc3ef8682d5c4d6cb6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:25:11 -0000 The branch stable/12 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=88ef00584bc7f9f9e19546bc3ef8682d5c4d6cb6 commit 88ef00584bc7f9f9e19546bc3ef8682d5c4d6cb6 Author: Mitchell Horne AuthorDate: 2021-08-04 17:31:36 +0000 Commit: Mitchell Horne CommitDate: 2021-08-11 17:07:59 +0000 hwpmc: disable uncore class on Sandy Bridge and newer It was written for Nehalem and Westmere, with minor but incomplete updates for Sandy Bridge in 78d763a29b15. The uncore architecture changed significantly with this generation, bringing new layouts and locations for some MSRs. Misprogramming these MSRs in ucp_start_pmc() may panic the system, and this is trivially reproducible via pmcstat(8) on at least Broadwell and Haswell. Disable the class on these CPUs until it can be updated more completely and leave a TODO comment detailing some of the work required. Note that the nclasses value for Broadwell was already incorrect and doesn't need changing. The result is that any uncore events listed by pmcstat -L will no longer be allocatable, but this is already the case for newer generations of Intel CPUs. PR: 253687 Reported by: Zhenlei Huang Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31389 (cherry picked from commit 4f35e8cba232d9256ab1399b8adfb761988e5eff) --- sys/dev/hwpmc/hwpmc_intel.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_intel.c b/sys/dev/hwpmc/hwpmc_intel.c index aec037b64938..02b8fd9431d1 100644 --- a/sys/dev/hwpmc/hwpmc_intel.c +++ b/sys/dev/hwpmc/hwpmc_intel.c @@ -149,7 +149,7 @@ pmc_intel_initialize(void) break; case 0x2A: /* Per Intel document 253669-039US 05/2011. */ cputype = PMC_CPU_INTEL_SANDYBRIDGE; - nclasses = 5; + nclasses = 3; break; case 0x2D: /* Per Intel document 253669-044US 08/2012. */ cputype = PMC_CPU_INTEL_SANDYBRIDGE_XEON; @@ -195,7 +195,7 @@ pmc_intel_initialize(void) case 0x3C: /* Per Intel document 325462-045US 01/2013. */ case 0x45: /* Per Intel document 325462-045US 09/2014. */ cputype = PMC_CPU_INTEL_HASWELL; - nclasses = 5; + nclasses = 3; break; case 0x37: case 0x4A: @@ -275,10 +275,27 @@ pmc_intel_initialize(void) * Intel Corei7 and Westmere processors. */ case PMC_CPU_INTEL_COREI7: - case PMC_CPU_INTEL_HASWELL: - case PMC_CPU_INTEL_SANDYBRIDGE: case PMC_CPU_INTEL_WESTMERE: +#ifdef notyet + /* + * TODO: re-enable uncore class on these processors. + * + * The uncore unit was reworked beginning with Sandy Bridge, including + * the MSRs required to program it. In particular, we need to: + * - Parse the MSR_UNC_CBO_CONFIG MSR for number of C-box units in the + * system + * - Support reading and writing to ARB and C-box units, depending on + * the requested event + * - Create some kind of mapping between C-box <--> CPU + * + * Also TODO: support other later changes to these interfaces, to + * enable the uncore class on generations newer than Broadwell. + * Skylake+ appears to use newer addresses for the uncore MSRs. + */ + case PMC_CPU_INTEL_HASWELL: case PMC_CPU_INTEL_BROADWELL: + case PMC_CPU_INTEL_SANDYBRIDGE: +#endif error = pmc_uncore_initialize(pmc_mdep, ncpus); break; default: @@ -329,11 +346,13 @@ pmc_intel_finalize(struct pmc_mdep *md) * Uncore. */ switch (md->pmd_cputype) { - case PMC_CPU_INTEL_BROADWELL: case PMC_CPU_INTEL_COREI7: + case PMC_CPU_INTEL_WESTMERE: +#ifdef notyet case PMC_CPU_INTEL_HASWELL: + case PMC_CPU_INTEL_BROADWELL: case PMC_CPU_INTEL_SANDYBRIDGE: - case PMC_CPU_INTEL_WESTMERE: +#endif pmc_uncore_finalize(md); break; default: From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:25:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67949658099; Wed, 11 Aug 2021 17:25: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 4GlGt023d0z3jqK; Wed, 11 Aug 2021 17:25: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 2D6981335B; Wed, 11 Aug 2021 17:25: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 17BHPCvA026369; Wed, 11 Aug 2021 17:25:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHPC2v026368; Wed, 11 Aug 2021 17:25:12 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:25:12 GMT Message-Id: <202108111725.17BHPC2v026368@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: db26d3ca59a9 - stable/12 - mk: format some option lists MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: db26d3ca59a90185d73d3345398d3e3efcea6862 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:25:12 -0000 The branch stable/12 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=db26d3ca59a90185d73d3345398d3e3efcea6862 commit db26d3ca59a90185d73d3345398d3e3efcea6862 Author: Mitchell Horne AuthorDate: 2021-08-04 18:17:34 +0000 Commit: Mitchell Horne CommitDate: 2021-08-11 17:15:50 +0000 mk: format some option lists Alphabetize and give each option its own line, ahead of making another change to these lists. This makes future diffs easier to read. Reviewed by: imp, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31399 (cherry picked from commit bcd2f41f7d222a942fe0a268614b46d3ec3af4c0) --- Makefile.inc1 | 45 +++++++++++++++++++++++++-------- Makefile.libcompat | 8 ++++-- targets/pseudo/bootstrap-tools/Makefile | 19 ++++++++++---- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index be0d0d2a2334..d7e05df9ae24 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -656,11 +656,21 @@ BSARGS= DESTDIR= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ SSP_CFLAGS= \ - MK_HTML=no NO_LINT=yes MK_MAN=no \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no \ + -DNO_CPU_CFLAGS \ + -DNO_LINT \ + -DNO_PIC \ + -DNO_SHARED \ + MK_CTF=no \ + MK_CLANG_EXTRAS=no \ + MK_CLANG_FORMAT=no \ + MK_CLANG_FULL=no \ + MK_HTML=no \ + MK_LLDB=no \ + MK_MAN=no \ + MK_PROFILE=no \ + MK_RETPOLINE=no \ + MK_TESTS=no \ + MK_WARNS=no \ MK_INCLUDES=yes BMAKE= \ @@ -678,10 +688,16 @@ TMAKE= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ SSP_CFLAGS= \ + -DNO_CPU_CFLAGS \ -DNO_LINT \ - -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no + MK_CTF=no \ + MK_CLANG_EXTRAS=no \ + MK_CLANG_FORMAT=no \ + MK_CLANG_FULL=no \ + MK_LLDB=no \ + MK_RETPOLINE=no \ + MK_TESTS=no \ + MK_WARNS=no # cross-tools stage # TOOLS_PREFIX set in BMAKE @@ -703,9 +719,16 @@ KTMAKE= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${OSRELDATE} \ SSP_CFLAGS= \ - MK_HTML=no -DNO_LINT MK_MAN=no \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WARNS=no MK_CTF=no + -DNO_CPU_CFLAGS \ + -DNO_LINT \ + -DNO_PIC \ + -DNO_SHARED \ + MK_CTF=no \ + MK_HTML=no \ + MK_MAN=no \ + MK_PROFILE=no \ + MK_RETPOLINE=no \ + MK_WARNS=no # world stage WMAKEENV= ${CROSSENV} \ diff --git a/Makefile.libcompat b/Makefile.libcompat index a2a6bb607fdc..4e5a8dd8ae73 100644 --- a/Makefile.libcompat +++ b/Makefile.libcompat @@ -201,8 +201,12 @@ build${libcompat}: .PHONY OBJTOP=${LIBCOMPAT_OBJTOP} \ OBJROOT='$${OBJTOP}/' \ MAKEOBJDIRPREFIX= \ - DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \ - MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \ + DIRPRFX=${_dir}/ \ + -DNO_LINT \ + -DNO_CPU_CFLAGS \ + MK_CTF=no \ + MK_RETPOLINE=no \ + MK_WARNS=no \ ${_t} .endfor .endfor diff --git a/targets/pseudo/bootstrap-tools/Makefile b/targets/pseudo/bootstrap-tools/Makefile index d860a50836b1..7ab8032157c3 100644 --- a/targets/pseudo/bootstrap-tools/Makefile +++ b/targets/pseudo/bootstrap-tools/Makefile @@ -40,11 +40,20 @@ BSARGS= DESTDIR= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET} \ SSP_CFLAGS= \ - MK_HTML=no NO_LINT=yes MK_MAN=no \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_TESTS=no \ + -DNO_CPU_CFLAGS \ + -DNO_LINT \ + -DNO_PIC \ + -DNO_SHARED \ + MK_CTF=no \ + MK_CLANG_EXTRAS=no \ + MK_CLANG_FORMAT=no \ + MK_CLANG_FULL=no \ + MK_HTML=no \ + MK_LLDB=no \ + MK_MAN=no \ + MK_PROFILE=no \ + MK_TESTS=no \ + MK_WARNS=no \ MK_INCLUDES=yes # We will handle building the toolchain and cross-compiler. From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:25:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DB8CE657D33; Wed, 11 Aug 2021 17:25: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 4GlGt14H2Tz3jnS; Wed, 11 Aug 2021 17:25: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 58D761365D; Wed, 11 Aug 2021 17:25: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 17BHPDC6026398; Wed, 11 Aug 2021 17:25:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHPDgT026397; Wed, 11 Aug 2021 17:25:13 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:25:13 GMT Message-Id: <202108111725.17BHPDgT026397@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 62bee146aa42 - stable/12 - Prefer MK_SSP=no to SSP_CFLAGS= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 62bee146aa42276264008df1d2190ca94eef26cd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:25:14 -0000 The branch stable/12 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=62bee146aa42276264008df1d2190ca94eef26cd commit 62bee146aa42276264008df1d2190ca94eef26cd Author: Mitchell Horne AuthorDate: 2021-08-04 18:20:50 +0000 Commit: Mitchell Horne CommitDate: 2021-08-11 17:20:01 +0000 Prefer MK_SSP=no to SSP_CFLAGS= It is more idiomatic. CFLAGS is only augmented with $SSP_CFLAGS when $MK_SSP != "no". Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31401 (cherry picked from commit 61ed578ee66648eff206ee5622b66727bfb52e78) --- Makefile.inc1 | 8 ++++---- Makefile.libcompat | 3 ++- lib/csu/Makefile.inc | 3 +-- lib/libclang_rt/Makefile.inc | 2 +- stand/defs.mk | 2 -- targets/pseudo/bootstrap-tools/Makefile | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index d7e05df9ae24..08574880be97 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -655,7 +655,6 @@ BSARGS= DESTDIR= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ -DNO_PIC \ @@ -669,6 +668,7 @@ BSARGS= DESTDIR= \ MK_MAN=no \ MK_PROFILE=no \ MK_RETPOLINE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WARNS=no \ MK_INCLUDES=yes @@ -687,7 +687,6 @@ TMAKE= \ DESTDIR= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ MK_CTF=no \ @@ -696,6 +695,7 @@ TMAKE= \ MK_CLANG_FULL=no \ MK_LLDB=no \ MK_RETPOLINE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WARNS=no @@ -718,7 +718,6 @@ KTMAKE= \ OBJROOT='$${OBJTOP}/' \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${OSRELDATE} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ -DNO_PIC \ @@ -727,6 +726,7 @@ KTMAKE= \ MK_HTML=no \ MK_MAN=no \ MK_PROFILE=no \ + MK_SSP=no \ MK_RETPOLINE=no \ MK_WARNS=no @@ -2499,7 +2499,6 @@ NXBMAKEARGS+= \ -DNO_SHARED \ -DNO_CPU_CFLAGS \ -DNO_PIC \ - SSP_CFLAGS= \ MK_CLANG_EXTRAS=no \ MK_CLANG_FORMAT=no \ MK_CLANG_FULL=no \ @@ -2516,6 +2515,7 @@ NXBMAKEARGS+= \ MK_RETPOLINE=no \ MK_SENDMAIL=no \ MK_SVNLITE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WARNS=no \ MK_ZFS=no diff --git a/Makefile.libcompat b/Makefile.libcompat index 4e5a8dd8ae73..89509a266af0 100644 --- a/Makefile.libcompat +++ b/Makefile.libcompat @@ -197,7 +197,7 @@ build${libcompat}: .PHONY ${_+_}cd ${.CURDIR}/${_dir}; \ WORLDTMP=${WORLDTMP} \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ - ${MAKE} SSP_CFLAGS= DESTDIR= \ + ${MAKE} DESTDIR= \ OBJTOP=${LIBCOMPAT_OBJTOP} \ OBJROOT='$${OBJTOP}/' \ MAKEOBJDIRPREFIX= \ @@ -206,6 +206,7 @@ build${libcompat}: .PHONY -DNO_CPU_CFLAGS \ MK_CTF=no \ MK_RETPOLINE=no \ + MK_SSP=no \ MK_WARNS=no \ ${_t} .endfor diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc index 93bf9672db04..5aa2132fe8c4 100644 --- a/lib/csu/Makefile.inc +++ b/lib/csu/Makefile.inc @@ -1,12 +1,11 @@ # $FreeBSD$ -SSP_CFLAGS= - SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/' NO_WMISSING_VARIABLE_DECLARATIONS= .include +MK_SSP= no .if ${MK_BSD_CRTBEGIN} != "no" && !defined(BUILDING_TESTS) diff --git a/lib/libclang_rt/Makefile.inc b/lib/libclang_rt/Makefile.inc index f2f25843dda3..07b66015acb1 100644 --- a/lib/libclang_rt/Makefile.inc +++ b/lib/libclang_rt/Makefile.inc @@ -20,10 +20,10 @@ SHLIBDIR= ${LIBDIR} NO_PIC= MK_PROFILE= no +MK_SSP= no WARNS?= 0 -SSP_CFLAGS= CFLAGS+= -DNDEBUG CFLAGS+= -DHAVE_RPC_XDR_H=0 CFLAGS+= -DSANITIZER_SUPPORTS_WEAK_HOOKS=0 diff --git a/stand/defs.mk b/stand/defs.mk index 3f440d9017f8..c81be884f3ae 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -120,8 +120,6 @@ LD_FLAGS+= -m elf_i386_fbsd AFLAGS+= --32 .endif -SSP_CFLAGS= - # Add in the no float / no SIMD stuff and announce we're freestanding # aarch64 and riscv don't have -msoft-float, but all others do. riscv # currently has no /boot/loader, but may soon. diff --git a/targets/pseudo/bootstrap-tools/Makefile b/targets/pseudo/bootstrap-tools/Makefile index 7ab8032157c3..1a973dc7fc18 100644 --- a/targets/pseudo/bootstrap-tools/Makefile +++ b/targets/pseudo/bootstrap-tools/Makefile @@ -39,7 +39,6 @@ BSARGS= DESTDIR= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET} \ - SSP_CFLAGS= \ -DNO_CPU_CFLAGS \ -DNO_LINT \ -DNO_PIC \ @@ -52,6 +51,7 @@ BSARGS= DESTDIR= \ MK_LLDB=no \ MK_MAN=no \ MK_PROFILE=no \ + MK_SSP=no \ MK_TESTS=no \ MK_WARNS=no \ MK_INCLUDES=yes From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:28:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9011E65833E; Wed, 11 Aug 2021 17:28: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 4GlGyD3dv6z3jpc; Wed, 11 Aug 2021 17:28: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 650CA132EE; Wed, 11 Aug 2021 17:28: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 17BHSqRI026985; Wed, 11 Aug 2021 17:28:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHSqaT026984; Wed, 11 Aug 2021 17:28:52 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:28:52 GMT Message-Id: <202108111728.17BHSqaT026984@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 09319f7d3f8a - main - ar: remove invalid extra param in bsdar_warnc calls 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/main X-Git-Reftype: branch X-Git-Commit: 09319f7d3f8aefe8a6b37b1c2a6d842126a2c181 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:28:52 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=09319f7d3f8aefe8a6b37b1c2a6d842126a2c181 commit 09319f7d3f8aefe8a6b37b1c2a6d842126a2c181 Author: Ed Maste AuthorDate: 2021-08-11 17:22:23 +0000 Commit: Ed Maste CommitDate: 2021-08-11 17:27:19 +0000 ar: remove invalid extra param in bsdar_warnc calls A number of warnings passed an exit status code to bsdar_warnc, but it does not take exit status (as a warning, it does not exit). MFC after: 1 week Sponsored by: The FreeBSD Foundation --- usr.bin/ar/write.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index 4cbdc12dcc2d..4177f57d064a 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -796,7 +796,7 @@ create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) return; } if (elf_getshstrndx(e, &shstrndx) == 0) { - bsdar_warnc(bsdar, EX_SOFTWARE, 0, "elf_getshstrndx failed: %s", + bsdar_warnc(bsdar, 0, "elf_getshstrndx failed: %s", elf_errmsg(-1)); elf_end(e); return; @@ -833,8 +833,8 @@ create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) scn = NULL; while ((scn = elf_nextscn(e, scn)) != NULL) { if (gelf_getshdr(scn, &shdr) != &shdr) { - bsdar_warnc(bsdar, EX_SOFTWARE, 0, - "elf_getshdr failed: %s", elf_errmsg(-1)); + bsdar_warnc(bsdar, 0, "elf_getshdr failed: %s", + elf_errmsg(-1)); continue; } if (shdr.sh_type != SHT_SYMTAB) @@ -847,7 +847,7 @@ create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) len = data->d_size / shdr.sh_entsize; for (i = 0; i < len; i++) { if (gelf_getsym(data, i, &sym) != &sym) { - bsdar_warnc(bsdar, EX_SOFTWARE, 0, + bsdar_warnc(bsdar, 0, "gelf_getsym failed: %s", elf_errmsg(-1)); continue; @@ -864,7 +864,7 @@ create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) if ((name = elf_strptr(e, tabndx, sym.st_name)) == NULL) { - bsdar_warnc(bsdar, EX_SOFTWARE, 0, + bsdar_warnc(bsdar, 0, "elf_strptr failed: %s", elf_errmsg(-1)); continue; @@ -876,7 +876,7 @@ create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) } elferr = elf_errno(); if (elferr != 0) - bsdar_warnc(bsdar, EX_SOFTWARE, 0, "elf_nextscn failed: %s", + bsdar_warnc(bsdar, 0, "elf_nextscn failed: %s", elf_errmsg(elferr)); elf_end(e); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 17:45:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C91765867B; Wed, 11 Aug 2021 17:45: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 4GlHJw2ZZFz3lGf; Wed, 11 Aug 2021 17:45: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 4180A13AF0; Wed, 11 Aug 2021 17:45: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 17BHj4cH053179; Wed, 11 Aug 2021 17:45:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BHj4VP053178; Wed, 11 Aug 2021 17:45:04 GMT (envelope-from git) Date: Wed, 11 Aug 2021 17:45:04 GMT Message-Id: <202108111745.17BHj4VP053178@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 4ccaa87f695c - main - kdb: Handle process enumeration before procinit() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4ccaa87f695c8b9eb31f2ba9ce4913a045755fe0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 17:45:04 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4ccaa87f695c8b9eb31f2ba9ce4913a045755fe0 commit 4ccaa87f695c8b9eb31f2ba9ce4913a045755fe0 Author: Mitchell Horne AuthorDate: 2021-08-11 17:40:01 +0000 Commit: Mitchell Horne CommitDate: 2021-08-11 17:44:22 +0000 kdb: Handle process enumeration before procinit() Make kdb_thr_first() and kdb_thr_next() return sane values if the allproc list and pidhashtbl haven't been initialized yet. This can happen if the debugger is entered very early on, for example with the '-d' boot flag. This allows remote gdb to attach at such a time, and fixes some ddb commands like 'show threads'. Be explicit about the static initialization of these variables. This part has no functional change. Reviewed by: markj, imp (previous version) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D31495 --- sys/kern/kern_proc.c | 5 ++--- sys/kern/subr_kdb.c | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2017f824f6ad..2649d1d3a58f 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -122,13 +122,13 @@ static void pargs_free(struct pargs *pa); /* * Other process lists */ -struct pidhashhead *pidhashtbl; +struct pidhashhead *pidhashtbl = NULL; struct sx *pidhashtbl_lock; u_long pidhash; u_long pidhashlock; struct pgrphashhead *pgrphashtbl; u_long pgrphash; -struct proclist allproc; +struct proclist allproc = LIST_HEAD_INITIALIZER(allproc); struct sx __exclusive_cache_line allproc_lock; struct sx __exclusive_cache_line proctree_lock; struct mtx __exclusive_cache_line ppeers_lock; @@ -185,7 +185,6 @@ procinit(void) sx_init(&proctree_lock, "proctree"); mtx_init(&ppeers_lock, "p_peers", NULL, MTX_DEF); mtx_init(&procid_lock, "procid", NULL, MTX_DEF); - LIST_INIT(&allproc); pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash); pidhashlock = (pidhash + 1) / 64; if (pidhashlock > 0) diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 1fabb4044eb1..4f439ff103d7 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -608,6 +608,10 @@ kdb_thr_first(void) struct thread *thr; u_int i; + /* This function may be called early. */ + if (pidhashtbl == NULL) + return (&thread0); + for (i = 0; i <= pidhash; i++) { LIST_FOREACH(p, &pidhashtbl[i], p_hash) { thr = FIRST_THREAD_IN_PROC(p); @@ -651,6 +655,8 @@ kdb_thr_next(struct thread *thr) thr = TAILQ_NEXT(thr, td_plist); if (thr != NULL) return (thr); + if (pidhashtbl == NULL) + return (NULL); hash = p->p_pid & pidhash; for (;;) { p = LIST_NEXT(p, p_hash); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 18:06:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A8BB7658DD4; Wed, 11 Aug 2021 18:06:51 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlHp23WJ6z3njg; Wed, 11 Aug 2021 18:06:50 +0000 (UTC) (envelope-from ronald-lists@klop.ws) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=klop.ws; s=mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version: Date:Message-ID:From:References:To:Subject:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=zJOzvAn4iJIVrMb1rSEezJay6LdBegSoVy9Ess0ToxE=; b=CDYDwd7vNOGhSa+hfBBl6i7TFS uzE3Fb2eeD2Pwo2L6ctzTfkaISf924xeQpqhTi0o4Pio2UFDWqXpVArIhT1O7KWCkFi9RUV70cBro O8jCfLMFNwdcwGrnmNzc8TUDsLxNOLn5OCxNsEYH7oTji2ASNsWEUi00Ta6SDnmTmwFE=; Subject: Re: git: 6c9506559080 - main - Escape any '.' characters in sysctl node names To: Alan Somers , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202107221623.16MGNZDu023290@gitrepo.freebsd.org> From: Ronald Klop Message-ID: <076f21f0-c6f5-1137-f1e6-b251e01b456a@klop.ws> Date: Wed, 11 Aug 2021 20:06:39 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <202107221623.16MGNZDu023290@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-As-Hash: 398f5522cb258ce43cb679602f8cfe8b62a256d1 X-Virus-Scanned: by clamav at smarthost1.greenhost.nl X-Spam-Level: / X-Spam-Score: -0.4 X-Spam-Status: No, score=-0.4 required=5.0 tests=ALL_TRUSTED, BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A autolearn=disabled version=3.4.2 X-Scan-Signature: a37d78a1f62179d0f8bbb55570e85dc4 X-Rspamd-Queue-Id: 4GlHp23WJ6z3njg X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=klop.ws header.s=mail header.b=CDYDwd7v; dmarc=pass (policy=none) header.from=klop.ws; spf=pass (mx1.freebsd.org: domain of ronald-lists@klop.ws designates 195.190.28.88 as permitted sender) smtp.mailfrom=ronald-lists@klop.ws X-Spamd-Result: default: False [-2.00 / 15.00]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[klop.ws:s=mail]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+ip4:195.190.28.64/27]; DKIM_TRACE(0.00)[klop.ws:+]; DMARC_POLICY_ALLOW(-0.50)[klop.ws,none]; RCVD_IN_DNSWL_NONE(0.00)[195.190.28.88:from]; NEURAL_HAM_SHORT(-1.00)[-0.999]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:47172, ipnet:195.190.28.0/24, country:NL]; MID_RHS_MATCH_FROM(0.00)[]; MAILMAN_DEST(0.00)[dev-commits-src-main,dev-commits-src-all]; RWL_MAILSPIKE_POSSIBLE(0.00)[195.190.28.88:from] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 18:06:51 -0000 On 7/22/21 6:23 PM, Alan Somers wrote: > The branch main has been updated by asomers: > > URL: https://cgit.FreeBSD.org/src/commit/?id=6c9506559080da2914749bf611225d7c0a153609 > > commit 6c9506559080da2914749bf611225d7c0a153609 > Author: Alan Somers > AuthorDate: 2021-07-21 21:11:00 +0000 > Commit: Alan Somers > CommitDate: 2021-07-22 16:22:48 +0000 > > Escape any '.' characters in sysctl node names > > ZFS creates some sysctl nodes that include a pool name, and '.' is an > allowed character in pool names. But it's the separator in the sysctl > tree, so it can't be included in a sysctl name. Replace it with "%25". > Handily, "%" is illegal in ZFS pool names, so there's no ambiguity > there. Hi, Wouldn't it be cleaner to enumerate the pools as numbers/ids and put the name of the pool in a field as the data instead of the key? Regards, Ronald. > PR: 257316 > MFC after: 3 weeks > Sponsored by: Axcient > Reviewed by: freqlabs > Differential Revision: https://reviews.freebsd.org/D31265 > --- > sys/kern/kern_sysctl.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 46 insertions(+), 2 deletions(-) > > diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c > index e46584758c9b..c472db18aac7 100644 > --- a/sys/kern/kern_sysctl.c > +++ b/sys/kern/kern_sysctl.c > @@ -122,6 +122,7 @@ static int sysctl_root(SYSCTL_HANDLER_ARGS); > /* Root list */ > struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children); > > +static char* sysctl_escape_name(const char*); > static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, > int recurse); > static int sysctl_old_kernel(struct sysctl_req *, const void *, size_t); > @@ -747,6 +748,46 @@ sysctl_remove_name(struct sysctl_oid *parent, const char *name, > return (error); > } > > +/* > + * Duplicate the provided string, escaping any illegal characters. The result > + * must be freed when no longer in use. > + * > + * The list of illegal characters is ".". > + */ > +static char* > +sysctl_escape_name(const char* orig) > +{ > + int i, s = 0, d = 0, nillegals = 0; > + char *new; > + > + /* First count the number of illegal characters */ > + for (i = 0; orig[i] != '\0'; i++) { > + if (orig[i] == '.') > + nillegals++; > + } > + > + /* Allocate storage for new string */ > + new = malloc(i + 2 * nillegals + 1, M_SYSCTLOID, M_WAITOK); > + > + /* Copy the name, escaping characters as we go */ > + while (orig[s] != '\0') { > + if (orig[s] == '.') { > + /* %25 is the hexadecimal representation of '.' */ > + new[d++] = '%'; > + new[d++] = '2'; > + new[d++] = '5'; > + s++; > + } else { > + new[d++] = orig[s++]; > + } > + } > + > + /* Finally, nul-terminate */ > + new[d] = '\0'; > + > + return (new); > +} > + > static int > sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) > { > @@ -828,14 +869,17 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, > const char *label) > { > struct sysctl_oid *oidp; > + char *escaped; > > /* You have to hook up somewhere.. */ > if (parent == NULL) > return(NULL); > + escaped = sysctl_escape_name(name); > /* Check if the node already exists, otherwise create it */ > SYSCTL_WLOCK(); > - oidp = sysctl_find_oidname(name, parent); > + oidp = sysctl_find_oidname(escaped, parent); > if (oidp != NULL) { > + free(escaped, M_SYSCTLOID); > if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { > oidp->oid_refcnt++; > /* Update the context */ > @@ -854,7 +898,7 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, > SLIST_INIT(&oidp->oid_children); > oidp->oid_number = number; > oidp->oid_refcnt = 1; > - oidp->oid_name = strdup(name, M_SYSCTLOID); > + oidp->oid_name = escaped; > oidp->oid_handler = handler; > oidp->oid_kind = CTLFLAG_DYN | kind; > oidp->oid_arg1 = arg1; > _______________________________________________ > dev-commits-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all > To unsubscribe, send any mail to "dev-commits-src-all-unsubscribe@freebsd.org" > From owner-dev-commits-src-all@freebsd.org Wed Aug 11 18:08:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 998BC658F99; Wed, 11 Aug 2021 18:08:19 +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 4GlHql3zkqz3njr; Wed, 11 Aug 2021 18:08: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 6D56A1376C; Wed, 11 Aug 2021 18:08: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 17BI8J2T080773; Wed, 11 Aug 2021 18:08:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BI8Jrw080772; Wed, 11 Aug 2021 18:08:19 GMT (envelope-from git) Date: Wed, 11 Aug 2021 18:08:19 GMT Message-Id: <202108111808.17BI8Jrw080772@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: 95c51fafa40d - main - ktls: Init reset tag task for cloned sessions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 95c51fafa40d56d0a32aff857261097acc65ec92 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 18:08:19 -0000 The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=95c51fafa40d56d0a32aff857261097acc65ec92 commit 95c51fafa40d56d0a32aff857261097acc65ec92 Author: Andrew Gallatin AuthorDate: 2021-08-11 18:06:43 +0000 Commit: Andrew Gallatin CommitDate: 2021-08-11 18:06:43 +0000 ktls: Init reset tag task for cloned sessions When cloning a ktls session (which is needed when we need to switch output NICs for a NIC TLS session), we need to also init the reset task, like we do when creating a new tls session. Reviewed by: jhb Sponsored by: Netflix --- sys/kern/uipc_ktls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c index 1cc1f2e8b8c4..79da902095b3 100644 --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -709,6 +709,7 @@ ktls_clone_session(struct ktls_session *tls) counter_u64_add(ktls_offload_active, 1); refcount_init(&tls_new->refcount, 1); + TASK_INIT(&tls_new->reset_tag_task, 0, ktls_reset_send_tag, tls_new); /* Copy fields from existing session. */ tls_new->params = tls->params; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 18:19:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85A926590C2; Wed, 11 Aug 2021 18:19:36 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (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 4GlJ4m2rFrz3qPs; Wed, 11 Aug 2021 18:19:36 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-oi1-f169.google.com with SMTP id r5so5895120oiw.7; Wed, 11 Aug 2021 11:19:36 -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:to:cc; bh=rGjydspLXymfBFafrk49R9vB+13IsQTapLE9914tGTI=; b=U00XDtEv9p99qAWZuPaGIvSqOYedlrymofRtpnlbtsPHNP7F4RqA1FOPi4xaQtel0a HifXkTLocCt7XZ5pNlH6bCqF+gH/d6Ozd/xQOfxHGuJQ+hW1fh/AnCv5kPeb3Q3WeKko 4BW6SuvaOcMdDHedzdWysCJR4xoMKpgEhnoHKsz/QuRpbveOSES3IrmhbHy2Kd74hEia 5E8G0gjscVLj+oQxlXWbAvyoC3QN82Tl0ChTIodWd//9aGSCNhHlkRFBEuk0JFO2jdxU ATptYSWP/nBMnYVS7WueouHtsfGN6o1f8XqCsEQlphtA1DixCoxxxNlPLhLML2XQPdJ/ Ekzg== X-Gm-Message-State: AOAM532JTxlk7aQiT6Madha80vu5ByknD99SU6BgrLSn9kcNfVgTz2c0 0Pdjn93J6KQZsxONsVTcUS6ftWnC3d0myQnn5pHUzCjl43k= X-Google-Smtp-Source: ABdhPJxb6WTSd2DnLnZj9oe/wIIOqLMD9M4S/HOZ60xIU0C8b3drqkmcpAiCuNgUY8eGJV4aTyAVOQzIQH1UK96G/d8= X-Received: by 2002:aca:4ed6:: with SMTP id c205mr157673oib.57.1628705969067; Wed, 11 Aug 2021 11:19:29 -0700 (PDT) MIME-Version: 1.0 References: <202107221623.16MGNZDu023290@gitrepo.freebsd.org> <076f21f0-c6f5-1137-f1e6-b251e01b456a@klop.ws> In-Reply-To: <076f21f0-c6f5-1137-f1e6-b251e01b456a@klop.ws> From: Alan Somers Date: Wed, 11 Aug 2021 12:19:18 -0600 Message-ID: Subject: Re: git: 6c9506559080 - main - Escape any '.' characters in sysctl node names To: Ronald Klop Cc: src-committers , "" , dev-commits-src-main@freebsd.org X-Rspamd-Queue-Id: 4GlJ4m2rFrz3qPs X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 18:19:36 -0000 On Wed, Aug 11, 2021 at 12:06 PM Ronald Klop wrote: > On 7/22/21 6:23 PM, Alan Somers wrote: > > The branch main has been updated by asomers: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=6c9506559080da2914749bf611225d7c0a153609 > > > > commit 6c9506559080da2914749bf611225d7c0a153609 > > Author: Alan Somers > > AuthorDate: 2021-07-21 21:11:00 +0000 > > Commit: Alan Somers > > CommitDate: 2021-07-22 16:22:48 +0000 > > > > Escape any '.' characters in sysctl node names > > > > ZFS creates some sysctl nodes that include a pool name, and '.' is > an > > allowed character in pool names. But it's the separator in the > sysctl > > tree, so it can't be included in a sysctl name. Replace it with > "%25". > > Handily, "%" is illegal in ZFS pool names, so there's no ambiguity > > there. > > > Hi, > > Wouldn't it be cleaner to enumerate the pools as numbers/ids and put the > name of the pool in a field as the data instead of the key? > > Regards, > Ronald. > In fact, the dataset name (not pool name) is already represented that way, in a field like "kstat.zfs.zroot.dataset.objset-0x11.dataset_name: zroot/ROOT". So arguably the pool name should be represented in the same way, for consistency's sake. But that's a question to take up over at https://github.com/openzfs/zfs . Either way, FreeBSD's SYSCTL_ADD_NODE shouldn't generate an unusable sysctl yet return success. -Alan From owner-dev-commits-src-all@freebsd.org Wed Aug 11 18:49:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0094A659041; Wed, 11 Aug 2021 18:49:34 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlJlL6M6kz3sBk; Wed, 11 Aug 2021 18:49:34 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 51C4FA473; Wed, 11 Aug 2021 18:49:34 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: Scott Long , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108102241.17AMfr63025604@gitrepo.freebsd.org> From: John Baldwin Subject: Re: git: 35547df5c786 - main - Call wakeup() with the lock held to avoid missed wakeup races. Message-ID: <9b1ec22c-1545-52ea-7bf9-a96140737711@FreeBSD.org> Date: Wed, 11 Aug 2021 11:49:33 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <202108102241.17AMfr63025604@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 18:49:35 -0000 On 8/10/21 3:41 PM, Scott Long wrote: > The branch main has been updated by scottl: > > URL: https://cgit.FreeBSD.org/src/commit/?id=35547df5c78653b2da030f920323c0357056099f > > commit 35547df5c78653b2da030f920323c0357056099f > Author: Scott Long > AuthorDate: 2021-08-10 22:36:38 +0000 > Commit: Scott Long > CommitDate: 2021-08-10 22:36:38 +0000 > > Call wakeup() with the lock held to avoid missed wakeup races. > > Submitted by: luiz > Sponsored by: Rubicon Communications, LLC ("Netgate") > --- > sys/dev/sdhci/sdhci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c > index d075c2e05000..573e6949b57e 100644 > --- a/sys/dev/sdhci/sdhci.c > +++ b/sys/dev/sdhci/sdhci.c > @@ -2078,8 +2078,8 @@ sdhci_generic_release_host(device_t brdev __unused, device_t reqdev) > /* Deactivate led. */ > WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl &= ~SDHCI_CTRL_LED); > slot->bus_busy--; > - SDHCI_UNLOCK(slot); > wakeup(slot); > + SDHCI_UNLOCK(slot); > return (0); > } Hmm, how does this avoid a race? The sleep is checking bus_busy under the lock and should never see a stale value and go back to sleep after the wakeup has occurred: SDHCI_LOCK(slot); while (slot->bus_busy) msleep(slot, &slot->mtx, 0, "sdhciah", 0); slot->bus_busy++; /* Activate led. */ WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl |= SDHCI_CTRL_LED); SDHCI_UNLOCK(slot); Dropping the lock before wakeup() is a tiny optimization that avoids having the second thread wakeup and immediately block on the lock before it has been released by the first thread. -- John Baldwin From owner-dev-commits-src-all@freebsd.org Wed Aug 11 20:44:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0CF665B056; Wed, 11 Aug 2021 20:44: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 4GlMJG4c23z4VnZ; Wed, 11 Aug 2021 20:44: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 86467160A0; Wed, 11 Aug 2021 20:44: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 17BKikwl092243; Wed, 11 Aug 2021 20:44:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BKikKG092242; Wed, 11 Aug 2021 20:44:46 GMT (envelope-from git) Date: Wed, 11 Aug 2021 20:44:46 GMT Message-Id: <202108112044.17BKikKG092242@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 10a8e93da158 - main - kmsan: Export kmsan_mark_mbuf() and kmsan_mark_bio() 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/main X-Git-Reftype: branch X-Git-Commit: 10a8e93da15889d40497bb666c2d753f38ac7b7f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 20:44:46 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=10a8e93da15889d40497bb666c2d753f38ac7b7f commit 10a8e93da15889d40497bb666c2d753f38ac7b7f Author: Mark Johnston AuthorDate: 2021-08-11 20:22:21 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 20:33:41 +0000 kmsan: Export kmsan_mark_mbuf() and kmsan_mark_bio() Sponsored by: The FreeBSD Foundation --- sys/kern/subr_msan.c | 4 ++-- sys/sys/msan.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c index 2b6a0d585128..81322da2be6c 100644 --- a/sys/kern/subr_msan.c +++ b/sys/kern/subr_msan.c @@ -549,7 +549,7 @@ kmsan_mark(const void *addr, size_t size, uint8_t c) kmsan_shadow_fill((uintptr_t)addr, c, size); } -static void +void kmsan_mark_bio(const struct bio *bp, uint8_t c) { kmsan_mark(bp->bio_data, bp->bio_length, c); @@ -591,7 +591,7 @@ kmsan_mark_ccb(const union ccb *ccb, uint8_t c) } } -static void +void kmsan_mark_mbuf(const struct mbuf *m, uint8_t c) { do { diff --git a/sys/sys/msan.h b/sys/sys/msan.h index 70e354323247..4baa71ec8113 100644 --- a/sys/sys/msan.h +++ b/sys/sys/msan.h @@ -62,6 +62,8 @@ void kmsan_bus_dmamap_sync(struct memdesc *, bus_dmasync_op_t); void kmsan_orig(const void *, size_t, int, uintptr_t); void kmsan_mark(const void *, size_t, uint8_t); +void kmsan_mark_bio(const struct bio *, uint8_t); +void kmsan_mark_mbuf(const struct mbuf *, uint8_t); void kmsan_check(const void *, size_t, const char *); void kmsan_check_bio(const struct bio *, const char *); @@ -77,6 +79,8 @@ void kmsan_check_mbuf(const struct mbuf *, const char *); #define kmsan_dma_load(m, b, s, o) #define kmsan_orig(p, l, c, a) #define kmsan_mark(p, l, c) +#define kmsan_mark_bio(b, c) +#define kmsan_mark_mbuf(m, c) #define kmsan_check(b, s, d) #define kmsan_check_bio(b, d) #define kmsan_check_ccb(c, d) From owner-dev-commits-src-all@freebsd.org Wed Aug 11 20:44:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE48665B1A2; Wed, 11 Aug 2021 20:44: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 4GlMJH5nkYz4Vbq; Wed, 11 Aug 2021 20:44: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 A86C01603F; Wed, 11 Aug 2021 20:44: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 17BKilg1092267; Wed, 11 Aug 2021 20:44:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BKilZL092266; Wed, 11 Aug 2021 20:44:47 GMT (envelope-from git) Date: Wed, 11 Aug 2021 20:44:47 GMT Message-Id: <202108112044.17BKilZL092266@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 645b7efd496d - main - geom_disk: Add KMSAN checks 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/main X-Git-Reftype: branch X-Git-Commit: 645b7efd496d649211056be0e2d3525ef21dc53d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 20:44:48 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=645b7efd496d649211056be0e2d3525ef21dc53d commit 645b7efd496d649211056be0e2d3525ef21dc53d Author: Mark Johnston AuthorDate: 2021-08-11 20:22:26 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 20:33:41 +0000 geom_disk: Add KMSAN checks - In g_disk_start(), verify that the data to be written is initialized according to KMSAN shadow state. - In g_disk_done(), verify that the block driver updated shadow state as expected, so as to catch sources of false positives early. Sponsored by: The FreeBSD Foundation --- sys/geom/geom_disk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 2f0e72fad52d..9877243fa36e 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -239,6 +240,9 @@ g_disk_done(struct bio *bp) bp2->bio_error = bp->bio_error; bp2->bio_completed += bp->bio_length - bp->bio_resid; + if (bp->bio_cmd == BIO_READ) + kmsan_check(bp2->bio_data, bp2->bio_completed, "g_disk_done"); + switch (bp->bio_cmd) { case BIO_ZONE: bcopy(&bp->bio_zone, &bp2->bio_zone, sizeof(bp->bio_zone)); @@ -445,6 +449,10 @@ g_disk_start(struct bio *bp) KASSERT((dp->d_flags & DISKFLAG_UNMAPPED_BIO) != 0 || (bp->bio_flags & BIO_UNMAPPED) == 0, ("unmapped bio not supported by disk %s", dp->d_name)); + + if (bp->bio_cmd == BIO_WRITE) + kmsan_check_bio(bp, "g_disk_start"); + off = 0; bp3 = NULL; bp2 = g_clone_bio(bp); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 20:44:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 89B6565B1A3; Wed, 11 Aug 2021 20:44: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 4GlMJL2jgZz4Vj6; Wed, 11 Aug 2021 20:44: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 F2F3516041; Wed, 11 Aug 2021 20:44:49 +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 17BKinBw092319; Wed, 11 Aug 2021 20:44:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BKinoG092318; Wed, 11 Aug 2021 20:44:49 GMT (envelope-from git) Date: Wed, 11 Aug 2021 20:44:49 GMT Message-Id: <202108112044.17BKinoG092318@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 710c055673b3 - main - virtio: Add KMSAN hooks for network and block devices 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/main X-Git-Reftype: branch X-Git-Commit: 710c055673b3a39ff6e5fdf0bef49437d1e0c9a3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 20:44:50 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=710c055673b3a39ff6e5fdf0bef49437d1e0c9a3 commit 710c055673b3a39ff6e5fdf0bef49437d1e0c9a3 Author: Mark Johnston AuthorDate: 2021-08-11 20:23:25 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 20:41:38 +0000 virtio: Add KMSAN hooks for network and block devices This ensures that host-written data is marked as initialized. Sponsored by: The FreeBSD Foundation --- sys/dev/virtio/block/virtio_blk.c | 3 +++ sys/dev/virtio/network/if_vtnet.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index 8a5558f4571d..e4a20bfc3031 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1151,6 +1152,8 @@ vtblk_bio_done(struct vtblk_softc *sc, struct bio *bp, int error) bp->bio_resid = bp->bio_bcount; bp->bio_error = error; bp->bio_flags |= BIO_ERROR; + } else { + kmsan_mark_bio(bp, KMSAN_STATE_INITED); } if (bp->bio_driver1 != NULL) { diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index e65914c5184f..bbda5cb90707 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -36,9 +36,10 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include +#include #include #include #include @@ -2107,6 +2108,8 @@ vtnet_rxq_eof(struct vtnet_rxq *rxq) continue; } + kmsan_mark_mbuf(m, KMSAN_STATE_INITED); + /* * Save an endian swapped version of the header prior to it * being stripped. The header is always at the start of the From owner-dev-commits-src-all@freebsd.org Wed Aug 11 20:44:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 261C165B60F; Wed, 11 Aug 2021 20:44: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 4GlMJK0KzRz4Vhy; Wed, 11 Aug 2021 20:44:49 +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 D32FD16040; Wed, 11 Aug 2021 20:44: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 17BKimxT092291; Wed, 11 Aug 2021 20:44:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BKimmt092290; Wed, 11 Aug 2021 20:44:48 GMT (envelope-from git) Date: Wed, 11 Aug 2021 20:44:48 GMT Message-Id: <202108112044.17BKimmt092290@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 24fe46128495 - main - ether: Add a KMSAN check for transmitted frames 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/main X-Git-Reftype: branch X-Git-Commit: 24fe46128495fc32b31729d9bba86dd7c5280ce3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 20:44:49 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=24fe46128495fc32b31729d9bba86dd7c5280ce3 commit 24fe46128495fc32b31729d9bba86dd7c5280ce3 Author: Mark Johnston AuthorDate: 2021-08-11 20:23:12 +0000 Commit: Mark Johnston CommitDate: 2021-08-11 20:33:41 +0000 ether: Add a KMSAN check for transmitted frames This helps ensure that outbound packet data is initialized per KMSAN. Sponsored by: The FreeBSD Foundation --- sys/net/if_ethersubr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 718de9625044..bdb5b07635b7 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -46,8 +46,9 @@ #include #include #include -#include #include +#include +#include #include #include #include @@ -502,9 +503,13 @@ ether_output_frame(struct ifnet *ifp, struct mbuf *m) #endif /* - * Queue message on interface, update output statistics if - * successful, and start output if interface not yet active. + * Queue message on interface, update output statistics if successful, + * and start output if interface not yet active. + * + * If KMSAN is enabled, use it to verify that the data does not contain + * any uninitialized bytes. */ + kmsan_check_mbuf(m, "ether_output"); return ((ifp->if_transmit)(ifp, m)); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 20:55:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E99BC65BA08; Wed, 11 Aug 2021 20:55: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 4GlMX75rgCz4WnC; Wed, 11 Aug 2021 20:55: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 AA61C1634A; Wed, 11 Aug 2021 20:55: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 17BKt3ZE006720; Wed, 11 Aug 2021 20:55:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BKt3hx006719; Wed, 11 Aug 2021 20:55:03 GMT (envelope-from git) Date: Wed, 11 Aug 2021 20:55:03 GMT Message-Id: <202108112055.17BKt3hx006719@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 96f9bd46547d - main - dumpon: fix encrypted dumps after commit 372557d8c3d MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 96f9bd46547d6dfbaf219ab449efacacb0dacccc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 20:55:04 -0000 The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=96f9bd46547d6dfbaf219ab449efacacb0dacccc commit 96f9bd46547d6dfbaf219ab449efacacb0dacccc Author: Eric van Gyzen AuthorDate: 2021-08-07 08:59:02 +0000 Commit: Eric van Gyzen CommitDate: 2021-08-11 15:54:56 +0000 dumpon: fix encrypted dumps after commit 372557d8c3d That commit moved key generation into a child process, including a memory allocation referenced by a structure. The child wrote the structure to the parent over a pipe, but did not write the referenced allocation. The parent read the structure from the child and used its pointer, which was bogus in the parent. In the child, send both chunks of data to the parent. In the parent, make a corresponding allocation and read both chunks. Fixes: 372557d8c3d37dd0c1d9be56513a436393963848 Reviewed by: bdrewery, markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D31452 --- sbin/dumpon/dumpon.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c index e83994d01314..291239c4bcc8 100644 --- a/sbin/dumpon/dumpon.c +++ b/sbin/dumpon/dumpon.c @@ -332,6 +332,10 @@ genkey(const char *pubkeyfile, struct diocskerneldump_arg *kdap) bytes = write(filedes[1], kdap, sizeof(*kdap)); if (bytes != sizeof(*kdap)) err(1, "genkey pipe write"); + bytes = write(filedes[1], kdap->kda_encryptedkey, + kdap->kda_encryptedkeysize); + if (bytes != kdap->kda_encryptedkeysize) + err(1, "genkey pipe write kda_encryptedkey"); _exit(0); } close(filedes[1]); @@ -339,6 +343,16 @@ genkey(const char *pubkeyfile, struct diocskerneldump_arg *kdap) bytes = read(filedes[0], kdap, sizeof(*kdap)); if (bytes != sizeof(*kdap)) errx(1, "genkey pipe read"); + if (kdap->kda_encryptedkeysize > KERNELDUMP_ENCKEY_MAX_SIZE) + errx(1, "Public key has to be at most %db long.", + 8 * KERNELDUMP_ENCKEY_MAX_SIZE); + kdap->kda_encryptedkey = calloc(1, kdap->kda_encryptedkeysize); + if (kdap->kda_encryptedkey == NULL) + err(1, "Unable to allocate encrypted key"); + bytes = read(filedes[0], kdap->kda_encryptedkey, + kdap->kda_encryptedkeysize); + if (bytes != kdap->kda_encryptedkeysize) + errx(1, "genkey pipe read kda_encryptedkey"); error = waitpid(pid, &status, WEXITED); if (error == -1) err(1, "waitpid"); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 20:55:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45DB065B5FB; Wed, 11 Aug 2021 20:55: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 4GlMX86Z3kz4Wt5; Wed, 11 Aug 2021 20:55: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 BEF9515F56; Wed, 11 Aug 2021 20:55: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 17BKt4Kd006746; Wed, 11 Aug 2021 20:55:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BKt4At006745; Wed, 11 Aug 2021 20:55:04 GMT (envelope-from git) Date: Wed, 11 Aug 2021 20:55:04 GMT Message-Id: <202108112055.17BKt4At006745@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 13a58148de17 - main - netdump: send key before dump, in case dump fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 13a58148de1730f851d37513913fae547e53a512 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 20:55:05 -0000 The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=13a58148de1730f851d37513913fae547e53a512 commit 13a58148de1730f851d37513913fae547e53a512 Author: Eric van Gyzen AuthorDate: 2021-08-06 15:38:51 +0000 Commit: Eric van Gyzen CommitDate: 2021-08-11 15:54:56 +0000 netdump: send key before dump, in case dump fails Previously, if an encrypted netdump failed, such as due to a timeout or network failure, the key was not saved, so a partial dump was completely useless. Send the key first, so the partial dump can be decrypted, because even a partial dump can be useful. Reviewed by: bdrewery, markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D31453 --- sys/kern/kern_shutdown.c | 20 +++++++++++------ sys/netinet/netdump/netdump_client.c | 42 ++++++++++++++++++++++++------------ sys/sys/conf.h | 5 ++--- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index fb2a69401801..3cc51fd31956 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -1488,7 +1488,7 @@ dump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh) #ifdef EKCD struct kerneldumpcrypto *kdc; #endif - void *buf, *key; + void *buf; size_t hdrsz; uint64_t extent; uint32_t keysize; @@ -1500,10 +1500,8 @@ dump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh) #ifdef EKCD kdc = di->kdcrypto; - key = kdc->kdc_dumpkey; keysize = kerneldumpcrypto_dumpkeysize(kdc); #else - key = NULL; keysize = 0; #endif @@ -1512,7 +1510,7 @@ dump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh) * of writing them out. */ if (di->dumper_hdr != NULL) - return (di->dumper_hdr(di, kdh, key, keysize)); + return (di->dumper_hdr(di, kdh)); if (hdrsz == di->blocksize) buf = kdh; @@ -1571,22 +1569,30 @@ dump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh) int dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh) { +#ifdef EKCD + struct kerneldumpcrypto *kdc; +#endif + void *key; uint64_t dumpextent, span; uint32_t keysize; int error; #ifdef EKCD - error = kerneldumpcrypto_init(di->kdcrypto); + /* Send the key before the dump so a partial dump is still usable. */ + kdc = di->kdcrypto; + error = kerneldumpcrypto_init(kdc); if (error != 0) return (error); - keysize = kerneldumpcrypto_dumpkeysize(di->kdcrypto); + keysize = kerneldumpcrypto_dumpkeysize(kdc); + key = keysize > 0 ? kdc->kdc_dumpkey : NULL; #else error = 0; keysize = 0; + key = NULL; #endif if (di->dumper_start != NULL) { - error = di->dumper_start(di); + error = di->dumper_start(di, key, keysize); } else { dumpextent = dtoh64(kdh->dumpextent); span = SIZEOF_METADATA + dumpextent + 2 * di->blocksize + diff --git a/sys/netinet/netdump/netdump_client.c b/sys/netinet/netdump/netdump_client.c index 2669ec879d75..d6fd7db364b8 100644 --- a/sys/netinet/netdump/netdump_client.c +++ b/sys/netinet/netdump/netdump_client.c @@ -95,7 +95,8 @@ static int netdump_enabled_sysctl(SYSCTL_HANDLER_ARGS); static int netdump_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr, int flags __unused, struct thread *td); static int netdump_modevent(module_t mod, int type, void *priv); -static int netdump_start(struct dumperinfo *di); +static int netdump_start(struct dumperinfo *di, void *key, + uint32_t keysize); static void netdump_unconfigure(void); /* Must be at least as big as the chunks dumpsys() gives us. */ @@ -285,7 +286,7 @@ netdump_dumper(void *priv __unused, void *virtual, * Perform any initialization needed prior to transmitting the kernel core. */ static int -netdump_start(struct dumperinfo *di) +netdump_start(struct dumperinfo *di, void *key, uint32_t keysize) { struct debugnet_conn_params dcp; struct debugnet_pcb *pcb; @@ -336,12 +337,34 @@ netdump_start(struct dumperinfo *di) printf("netdumping to %s (%6D)\n", inet_ntoa_r(nd_server, buf), debugnet_get_gw_mac(pcb), ":"); nd_conf.nd_pcb = pcb; - return (0); + + /* Send the key before the dump so a partial dump is still usable. */ + if (keysize > 0) { + if (keysize > sizeof(nd_buf)) { + printf("crypto key is too large (%u)\n", keysize); + error = EINVAL; + goto out; + } + memcpy(nd_buf, key, keysize); + error = debugnet_send(pcb, NETDUMP_EKCD_KEY, nd_buf, keysize, + NULL); + if (error != 0) { + printf("error %d sending crypto key\n", error); + goto out; + } + } + +out: + if (error != 0) { + /* As above, squash errors. */ + error = EINVAL; + netdump_cleanup(); + } + return (error); } static int -netdump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh, - void *key, uint32_t keysize) +netdump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh) { int error; @@ -351,15 +374,6 @@ netdump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh, memcpy(nd_buf, kdh, sizeof(*kdh)); error = debugnet_send(nd_conf.nd_pcb, NETDUMP_KDH, nd_buf, sizeof(*kdh), NULL); - if (error == 0 && keysize > 0) { - if (keysize > sizeof(nd_buf)) { - error = EINVAL; - goto out; - } - memcpy(nd_buf, key, keysize); - error = debugnet_send(nd_conf.nd_pcb, NETDUMP_EKCD_KEY, nd_buf, - keysize, NULL); - } out: if (error != 0) netdump_cleanup(); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 123bf91cf952..053cf6ddb016 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -133,9 +133,8 @@ typedef int dumper_t( vm_offset_t _physical, /* Physical address of virtual. */ off_t _offset, /* Byte-offset to write at. */ size_t _length); /* Number of bytes to dump. */ -typedef int dumper_start_t(struct dumperinfo *di); -typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh, - void *key, uint32_t keylen); +typedef int dumper_start_t(struct dumperinfo *di, void *key, uint32_t keysize); +typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh); #endif /* _KERNEL */ From owner-dev-commits-src-all@freebsd.org Wed Aug 11 21:13:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3C16565BBCD; Wed, 11 Aug 2021 21:13: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 4GlMxw15Cwz4XTk; Wed, 11 Aug 2021 21:13: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 0D5761688C; Wed, 11 Aug 2021 21:13: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 17BLDt3g033534; Wed, 11 Aug 2021 21:13:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BLDtTn033533; Wed, 11 Aug 2021 21:13:55 GMT (envelope-from git) Date: Wed, 11 Aug 2021 21:13:55 GMT Message-Id: <202108112113.17BLDtTn033533@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: 97cbd5e72238 - main - loader: open file list should be dynamic 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/main X-Git-Reftype: branch X-Git-Commit: 97cbd5e722389a575e820c4e03f38053308f08ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 21:13:56 -0000 The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=97cbd5e722389a575e820c4e03f38053308f08ea commit 97cbd5e722389a575e820c4e03f38053308f08ea Author: Toomas Soome AuthorDate: 2021-07-31 08:09:48 +0000 Commit: Toomas Soome CommitDate: 2021-08-10 18:54:32 +0000 loader: open file list should be dynamic Summary: Open file list is currently created as statically allocated array (64 items). Once this array is filled up, loader will not be able to operate with files. In most cases, this mechanism is good enough, but the problem appears, when we have many disks with zfs pool(s). In current loader implementation, all discovered zfs pool configurations are kept in memory and disk devices open - consuming the open file array. Rewrite the open file mechanism to use dynamically allocated list. Reviewed by: imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31364 --- stand/libsa/close.c | 33 +++++++++---- stand/libsa/closeall.c | 58 ++++++----------------- stand/libsa/fstat.c | 9 ++-- stand/libsa/ioctl.c | 22 ++++----- stand/libsa/iodesc.h | 2 + stand/libsa/lseek.c | 5 +- stand/libsa/net.h | 2 - stand/libsa/netif.c | 122 +++++++++++++++++++++++++++++++++++++++---------- stand/libsa/open.c | 66 ++++++++++++++++++++++---- stand/libsa/read.c | 5 +- stand/libsa/readdir.c | 5 +- stand/libsa/stand.h | 8 +++- stand/libsa/write.c | 5 +- 13 files changed, 227 insertions(+), 115 deletions(-) diff --git a/stand/libsa/close.c b/stand/libsa/close.c index d8f62fef6198..a177eb85eb3a 100644 --- a/stand/libsa/close.c +++ b/stand/libsa/close.c @@ -68,23 +68,38 @@ __FBSDID("$FreeBSD$"); int close(int fd) { - struct open_file *f = &files[fd]; + struct open_file *f, *last; int err1 = 0, err2 = 0; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL) { errno = EBADF; return (-1); } free(f->f_rabuf); f->f_rabuf = NULL; - if (!(f->f_flags & F_RAW) && f->f_ops) - err1 = (f->f_ops->fo_close)(f); - if (!(f->f_flags & F_NODEV) && f->f_dev) - err2 = (f->f_dev->dv_close)(f); - if (f->f_devdata != NULL) - devclose(f); - f->f_flags = 0; + if (f->f_flags != 0) { + if (!(f->f_flags & F_RAW) && f->f_ops) + err1 = (f->f_ops->fo_close)(f); + if (!(f->f_flags & F_NODEV) && f->f_dev) + err2 = (f->f_dev->dv_close)(f); + if (f->f_devdata != NULL) + devclose(f); + f->f_flags = 0; + } else { + /* Attempt to close already closed file. */ + err1 = EBADF; + } + + /* free unused entries from tail. */ + TAILQ_FOREACH_REVERSE_SAFE(last, &files, file_list, f_link, f) { + if (last->f_flags != 0) + break; + TAILQ_REMOVE(&files, last, f_link); + free(last); + } + if (err1) { errno = err1; return (-1); diff --git a/stand/libsa/closeall.c b/stand/libsa/closeall.c index 9693130ebf9b..92c6955cf5da 100644 --- a/stand/libsa/closeall.c +++ b/stand/libsa/closeall.c @@ -1,11 +1,7 @@ -/* $NetBSD: closeall.c,v 1.1 1996/01/13 22:25:36 leo Exp $ */ - /*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. + * Copyright (c) 2021 Toomas Soome * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -15,14 +11,11 @@ * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * 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 REGENTS OR CONTRIBUTORS BE LIABLE + * 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) @@ -31,33 +24,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)close.c 8.1 (Berkeley) 6/11/93 - * - * - * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Author: Alessandro Forin - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. */ #include @@ -66,11 +32,17 @@ __FBSDID("$FreeBSD$"); #include "stand.h" void -closeall() +closeall(void) { - int i; + struct open_file *f; - for (i = 0; i < SOPEN_MAX; i++) - if (files[i].f_flags != 0) - (void)close(i); + /* + * Pick up last entry and close it, this will also trigger + * the removal of this entry, and we end up with empty list. + */ + while ((f = TAILQ_LAST(&files, file_list)) != NULL) { + (void)close(f->f_id); + } + /* reset errno from close() */ + errno = 0; } diff --git a/stand/libsa/fstat.c b/stand/libsa/fstat.c index cb2df8cbf0ac..47893416e0bf 100644 --- a/stand/libsa/fstat.c +++ b/stand/libsa/fstat.c @@ -37,13 +37,12 @@ __FBSDID("$FreeBSD$"); #include "stand.h" int -fstat(fd, sb) - int fd; - struct stat *sb; +fstat(int fd, struct stat *sb) { - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL || f->f_flags == 0) { errno = EBADF; return (-1); } diff --git a/stand/libsa/ioctl.c b/stand/libsa/ioctl.c index 807b308e5e50..7363236ada0e 100644 --- a/stand/libsa/ioctl.c +++ b/stand/libsa/ioctl.c @@ -32,30 +32,30 @@ * SUCH DAMAGE. * * @(#)ioctl.c 8.1 (Berkeley) 6/11/93 - * + * * * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University * All Rights Reserved. * * Author: Alessandro Forin - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. */ @@ -66,14 +66,12 @@ __FBSDID("$FreeBSD$"); #include "stand.h" int -ioctl(fd, cmd, arg) - int fd; - u_long cmd; - char *arg; +ioctl(int fd, u_long cmd, char *arg) { - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL || f->f_flags == 0) { errno = EBADF; return (-1); } diff --git a/stand/libsa/iodesc.h b/stand/libsa/iodesc.h index 37ae044af9d9..199fbcf74e98 100644 --- a/stand/libsa/iodesc.h +++ b/stand/libsa/iodesc.h @@ -47,6 +47,8 @@ struct iodesc { u_long xid; /* transaction identification */ u_char myea[6]; /* my ethernet address */ struct netif *io_netif; + int io_id; /* descriptor id */ + TAILQ_ENTRY(iodesc) io_link; /* next entry in list */ }; #endif /* __SYS_LIBNETBOOT_IODESC_H */ diff --git a/stand/libsa/lseek.c b/stand/libsa/lseek.c index 1a39eb31421b..c4ca97b148d6 100644 --- a/stand/libsa/lseek.c +++ b/stand/libsa/lseek.c @@ -69,9 +69,10 @@ off_t lseek(int fd, off_t offset, int where) { off_t bufpos, filepos, target; - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL || f->f_flags == 0) { errno = EBADF; return (-1); } diff --git a/stand/libsa/net.h b/stand/libsa/net.h index 36b7cacc95ef..77a11c8dcab6 100644 --- a/stand/libsa/net.h +++ b/stand/libsa/net.h @@ -97,8 +97,6 @@ extern u_int intf_mtu; extern int debug; /* defined in the machdep sources */ -extern struct iodesc sockets[SOPEN_MAX]; - /* ARP/RevARP functions: */ u_char *arpwhohas(struct iodesc *, struct in_addr); void arp_reply(struct iodesc *, void *); diff --git a/stand/libsa/netif.c b/stand/libsa/netif.c index d255cc663d5a..2d32ccd9de7e 100644 --- a/stand/libsa/netif.c +++ b/stand/libsa/netif.c @@ -47,7 +47,19 @@ __FBSDID("$FreeBSD$"); #include "net.h" #include "netif.h" -struct iodesc sockets[SOPEN_MAX]; +typedef TAILQ_HEAD(socket_list, iodesc) socket_list_t; + +/* + * Open socket list. The current implementation and assumption is, + * we only remove entries from tail and we only add new entries to tail. + * This decision is to keep iodesc id management simple - we get list + * entries ordered by continiously growing io_id field. + * If we do have multiple sockets open and we do close socket not from tail, + * this entry will be marked unused. netif_open() will reuse unused entry, or + * netif_close() will free all unused tail entries. + */ +static socket_list_t sockets = TAILQ_HEAD_INITIALIZER(sockets); + #ifdef NETIF_DEBUG int netif_debug = 0; #endif @@ -63,7 +75,7 @@ netif_init(void) { struct netif_driver *drv; int d, i; - + #ifdef NETIF_DEBUG if (netif_debug) printf("netif_init: called\n"); @@ -108,7 +120,7 @@ netif_select(void *machdep_hint) for (u = 0; u < drv->netif_nifs; u++) { cur_if.nif_unit = u; unit_done = 0; - + #ifdef NETIF_DEBUG if (netif_debug) printf("\t%s%d:", drv->netif_bname, @@ -179,14 +191,14 @@ netif_attach(struct netif *nif, struct iodesc *desc, void *machdep_hint) if (netif_debug) printf("%s%d: netif_attach\n", drv->netif_bname, nif->nif_unit); #endif - desc->io_netif = nif; + desc->io_netif = nif; #ifdef PARANOID if (drv->netif_init == NULL) panic("%s%d: no netif_init support", drv->netif_bname, nif->nif_unit); #endif drv->netif_init(desc, machdep_hint); - bzero(drv->netif_ifs[nif->nif_unit].dif_stats, + bzero(drv->netif_ifs[nif->nif_unit].dif_stats, sizeof(struct netif_stats)); } @@ -261,35 +273,71 @@ netif_put(struct iodesc *desc, void *pkt, size_t len) return (rv); } +/* + * socktodesc_impl: + * + * Walk socket list and return pointer to iodesc structure. + * if id is < 0, return first unused iodesc. + */ +static struct iodesc * +socktodesc_impl(int socket) +{ + struct iodesc *s; + + TAILQ_FOREACH(s, &sockets, io_link) { + /* search by socket id */ + if (socket >= 0) { + if (s->io_id == socket) + break; + continue; + } + /* search for first unused entry */ + if (s->io_netif == NULL) + break; + } + return (s); +} + struct iodesc * socktodesc(int sock) { - if (sock >= SOPEN_MAX) { + struct iodesc *desc; + + if (sock < 0) + desc = NULL; + else + desc = socktodesc_impl(sock); + + if (desc == NULL) errno = EBADF; - return (NULL); - } - return (&sockets[sock]); + + return (desc); } int netif_open(void *machdep_hint) { - int fd; struct iodesc *s; struct netif *nif; - + /* find a free socket */ - for (fd = 0, s = sockets; fd < SOPEN_MAX; fd++, s++) - if (s->io_netif == (struct netif *)0) - goto fnd; - errno = EMFILE; - return (-1); - -fnd: - bzero(s, sizeof(*s)); + s = socktodesc_impl(-1); + if (s == NULL) { + struct iodesc *last; + + s = calloc(1, sizeof (*s)); + if (s == NULL) + return (-1); + + last = TAILQ_LAST(&sockets, socket_list); + if (last != NULL) + s->io_id = last->io_id + 1; + TAILQ_INSERT_TAIL(&sockets, s, io_link); + } + netif_init(); nif = netif_select(machdep_hint); - if (!nif) + if (!nif) panic("netboot: no interfaces left untried"); if (netif_probe(nif, machdep_hint)) { printf("netboot: couldn't probe %s%d\n", @@ -299,18 +347,42 @@ fnd: } netif_attach(nif, s, machdep_hint); - return (fd); + return (s->io_id); } int netif_close(int sock) { - if (sock >= SOPEN_MAX) { - errno = EBADF; + struct iodesc *s, *last; + int err; + + err = 0; + s = socktodesc_impl(sock); + if (s == NULL || sock < 0) { + err = EBADF; + return (-1); + } + netif_detach(s->io_netif); + bzero(&s->destip, sizeof (s->destip)); + bzero(&s->myip, sizeof (s->myip)); + s->destport = 0; + s->myport = 0; + s->xid = 0; + bzero(s->myea, sizeof (s->myea)); + s->io_netif = NULL; + + /* free unused entries from tail. */ + TAILQ_FOREACH_REVERSE_SAFE(last, &sockets, socket_list, io_link, s) { + if (last->io_netif != NULL) + break; + TAILQ_REMOVE(&sockets, last, io_link); + free(last); + } + + if (err) { + errno = err; return (-1); } - netif_detach(sockets[sock].io_netif); - sockets[sock].io_netif = (struct netif *)0; return (0); } diff --git a/stand/libsa/open.c b/stand/libsa/open.c index 9590508b0015..c62e48f0e1d8 100644 --- a/stand/libsa/open.c +++ b/stand/libsa/open.c @@ -67,17 +67,66 @@ __FBSDID("$FreeBSD$"); struct fs_ops *exclusive_file_system; -struct open_file files[SOPEN_MAX]; +/* + * Open file list. The current implementation and assumption is, + * we only remove entries from tail and we only add new entries to tail. + * This decision is to keep file id management simple - we get list + * entries ordered by continiously growing f_id field. + * If we do have multiple files open and we do close file not from tail, + * this entry will be marked unused. open() will reuse unused entry, or + * close will free all unused tail entries. + * + * Only case we expect open file list to grow long, is with zfs pools with + * many disks. + */ +file_list_t files = TAILQ_HEAD_INITIALIZER(files); + +/* + * Walk file list and return pointer to open_file structure. + * if fd is < 0, return first unused open_file. + */ +struct open_file * +fd2open_file(int fd) +{ + struct open_file *f; + + TAILQ_FOREACH(f, &files, f_link) { + if (fd >= 0) { + if (f->f_id == fd) + break; + continue; + } + + if (f->f_flags == 0) + break; + } + return (f); +} static int -o_gethandle(void) +o_gethandle(struct open_file **ptr) { - int fd; + struct open_file *f, *last; - for (fd = 0; fd < SOPEN_MAX; fd++) - if (files[fd].f_flags == 0) - return (fd); - return (-1); + /* Pick up unused entry */ + f = fd2open_file(-1); + if (f != NULL) { + *ptr = f; + return (f->f_id); + } + + /* Add new entry */ + f = calloc(1, sizeof (*f)); + if (f == NULL) + return (-1); + + last = TAILQ_LAST(&files, file_list); + if (last != NULL) + f->f_id = last->f_id + 1; + TAILQ_INSERT_TAIL(&files, f, f_link); + + *ptr = f; + return (f->f_id); } static void @@ -98,12 +147,11 @@ open(const char *fname, int mode) TSENTER(); - if ((fd = o_gethandle()) == -1) { + if ((fd = o_gethandle(&f)) == -1) { errno = EMFILE; return (-1); } - f = &files[fd]; f->f_flags = mode + 1; f->f_dev = NULL; f->f_ops = NULL; diff --git a/stand/libsa/read.c b/stand/libsa/read.c index 7ad75c387a5d..d079944bf5d0 100644 --- a/stand/libsa/read.c +++ b/stand/libsa/read.c @@ -69,12 +69,13 @@ __FBSDID("$FreeBSD$"); ssize_t read(int fd, void *dest, size_t bcount) { - struct open_file *f = &files[fd]; + struct open_file *f; size_t resid; TSENTER(); - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { + f = fd2open_file(fd); + if (f == NULL || !(f->f_flags & F_READ)) { errno = EBADF; return (-1); } diff --git a/stand/libsa/readdir.c b/stand/libsa/readdir.c index e49d93d15ed6..7757647e11e8 100644 --- a/stand/libsa/readdir.c +++ b/stand/libsa/readdir.c @@ -34,9 +34,10 @@ struct dirent * readdirfd(int fd) { static struct dirent dir; /* XXX not thread safe */ - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { + f = fd2open_file(fd); + if (f == NULL || !(f->f_flags & F_READ)) { errno = EBADF; return (NULL); } diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h index eb95afe4b169..535fee31d586 100644 --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -65,6 +65,7 @@ #include #include #include +#include /* this header intentionally exports NULL from */ #include @@ -182,11 +183,14 @@ struct open_file { char *f_rabuf; /* readahead buffer pointer */ size_t f_ralen; /* valid data in readahead buffer */ off_t f_raoffset; /* consumer offset in readahead buffer */ + int f_id; /* file number */ + TAILQ_ENTRY(open_file) f_link; /* next entry */ #define SOPEN_RASIZE 512 }; -#define SOPEN_MAX 64 -extern struct open_file files[]; +typedef TAILQ_HEAD(file_list, open_file) file_list_t; +extern file_list_t files; +extern struct open_file *fd2open_file(int); /* f_flags values */ #define F_READ 0x0001 /* file opened for reading */ diff --git a/stand/libsa/write.c b/stand/libsa/write.c index 7d054e005cda..db82d7eaf4f6 100644 --- a/stand/libsa/write.c +++ b/stand/libsa/write.c @@ -69,10 +69,11 @@ __FBSDID("$FreeBSD$"); ssize_t write(int fd, const void *dest, size_t bcount) { - struct open_file *f = &files[fd]; + struct open_file *f; size_t resid; - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) { + f = fd2open_file(fd); + if (f == NULL || !(f->f_flags & F_WRITE)) { errno = EBADF; return (-1); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 21:14:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 58BC065BE0F; Wed, 11 Aug 2021 21:14: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 4GlMy226mDz4Xh6; Wed, 11 Aug 2021 21:14: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 30C191688D; Wed, 11 Aug 2021 21:14: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 17BLE2QI033655; Wed, 11 Aug 2021 21:14:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BLE25k033654; Wed, 11 Aug 2021 21:14:02 GMT (envelope-from git) Date: Wed, 11 Aug 2021 21:14:02 GMT Message-Id: <202108112114.17BLE25k033654@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 3e4aeeb95df2 - stable/13 - m_dup: Handle unmapped mbufs as an input mbuf. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3e4aeeb95df217fdd9ec21e5a86ec61d1b2abc59 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 21:14:02 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3e4aeeb95df217fdd9ec21e5a86ec61d1b2abc59 commit 3e4aeeb95df217fdd9ec21e5a86ec61d1b2abc59 Author: John Baldwin AuthorDate: 2021-07-26 21:03:28 +0000 Commit: John Baldwin CommitDate: 2021-08-11 19:18:46 +0000 m_dup: Handle unmapped mbufs as an input mbuf. Use m_copydata() instead of a direct bcopy() when copying data out of a source mbuf into a newly-allocated mbuf. PR: 256610 Reported by: Niels Bakker Reviewed by: markj MFC after: 2 weeks (cherry picked from commit be79f30d6c3e353856d4f82227b270abc26be702) --- sys/kern/uipc_mbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index f7852bc7dd7f..f525c25d1431 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -719,7 +719,7 @@ m_dup(const struct mbuf *m, int how) while (n->m_len < nsize && m != NULL) { int chunk = min(nsize - n->m_len, m->m_len - moff); - bcopy(m->m_data + moff, n->m_data + n->m_len, chunk); + m_copydata(m, moff, chunk, n->m_data + n->m_len); moff += chunk; n->m_len += chunk; remain -= chunk; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 21:39:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0B2B65C554; Wed, 11 Aug 2021 21:39:12 +0000 (UTC) (envelope-from loos.br@gmail.com) Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) (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 4GlNW44Cfmz4Z0t; Wed, 11 Aug 2021 21:39:12 +0000 (UTC) (envelope-from loos.br@gmail.com) Received: by mail-qk1-x72e.google.com with SMTP id y130so4087767qkb.6; Wed, 11 Aug 2021 14:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IUaScHttlBA+yJIMDOi6tDzCrTFy4OQskCs+vt/dO80=; b=f/5U4YXo1yThHQ+S+L1UwhM14rWzbCtsSRl6h+XLzn/yXyDKJC5AWsTW9T4X6D2TM1 LBntozIA51YANR0qceXbP+z4bPbHIu/UxqwrBI8sH/wdvFe+nRTMIky8eTXdvctEr8s1 b+BHEptMikoG7OYFvAVKFn8pF6Jw6XQ9S9qVOGVA165CSpVnxANwzm1uZpGe1yN2Jaml 45pSsmS7GzWnScT6ISenA5Jey6glzalmCbNgQOrQd6oHbAeXFmhqFF3FBJgce2JWife1 WU9nWslKTYIrsq9Dq5i6S3JyMw9GOu0ulA0V7AJPfOWKwoXekurROQoH/si9O/Wm12pp llrQ== 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:to:cc; bh=IUaScHttlBA+yJIMDOi6tDzCrTFy4OQskCs+vt/dO80=; b=gvnxZkWxBTy0wCDMP0RiorRLtXb1CHA8nw7R3W2Zts70KGc6BY27sxA71xUOJDV9P0 1EYgW0KeSbiJiXBqn1H1qtaSC0XHfZ6T0TmdNt0q0lT3esNJskJrCoMzran/29/XZrCK zAvzqzBwTPjAuW0Rh/iBan2yOk+ydszDSjxnNEGQDNBsVjnDUYEKaftZnIUcqjzzdNvr /YRgqOewShq4KfnHa+BbSeYQW146nsZjykc3kUa7ZngCJK80Wk8dPBYz1v//iRPmENlE g6vA62tg069/IqPV+6BH96Q+nxuL0J2ON+HuQsuMsSJWDYyzALzf0Ufv92JisBtAJcgE 1gIQ== X-Gm-Message-State: AOAM532gJT/rZrYr7QKsgLxngJq/6B6qOUWelnaP/1EJSdkXz8mgmKR4 LK9iXbzW1G903KaOEgDVHeLNJy+T2N1mo4ejKcHe50fG X-Google-Smtp-Source: ABdhPJy7r87VMxE48uJjwdgoMOPsK5wPK/rk3y8l0KFGn2SV+RSJUfbo3yqeWHPEp5J06+laSpwa7UJ9Ga2gLkK5vFc= X-Received: by 2002:a05:620a:14b8:: with SMTP id x24mr1134582qkj.475.1628717945815; Wed, 11 Aug 2021 14:39:05 -0700 (PDT) MIME-Version: 1.0 References: <202108102241.17AMfr63025604@gitrepo.freebsd.org> <9b1ec22c-1545-52ea-7bf9-a96140737711@FreeBSD.org> In-Reply-To: <9b1ec22c-1545-52ea-7bf9-a96140737711@FreeBSD.org> From: Luiz Otavio O Souza Date: Wed, 11 Aug 2021 18:38:55 -0300 Message-ID: Subject: Re: git: 35547df5c786 - main - Call wakeup() with the lock held to avoid missed wakeup races. To: John Baldwin Cc: Scott Long , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4GlNW44Cfmz4Z0t X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 21:39:12 -0000 On Wed, Aug 11, 2021 at 3:49 PM John Baldwin wrote: > > On 8/10/21 3:41 PM, Scott Long wrote: > > The branch main has been updated by scottl: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=35547df5c78653b2da030f920323c0357056099f > > > > commit 35547df5c78653b2da030f920323c0357056099f > > Author: Scott Long > > AuthorDate: 2021-08-10 22:36:38 +0000 > > Commit: Scott Long > > CommitDate: 2021-08-10 22:36:38 +0000 > > > > Call wakeup() with the lock held to avoid missed wakeup races. > > > > Submitted by: luiz > > Sponsored by: Rubicon Communications, LLC ("Netgate") > > --- > > sys/dev/sdhci/sdhci.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c > > index d075c2e05000..573e6949b57e 100644 > > --- a/sys/dev/sdhci/sdhci.c > > +++ b/sys/dev/sdhci/sdhci.c > > @@ -2078,8 +2078,8 @@ sdhci_generic_release_host(device_t brdev __unused, device_t reqdev) > > /* Deactivate led. */ > > WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl &= ~SDHCI_CTRL_LED); > > slot->bus_busy--; > > - SDHCI_UNLOCK(slot); > > wakeup(slot); > > + SDHCI_UNLOCK(slot); > > return (0); > > } > > Hmm, how does this avoid a race? The sleep is checking bus_busy under > the lock and should never see a stale value and go back to sleep after > the wakeup has occurred: > > SDHCI_LOCK(slot); > while (slot->bus_busy) > msleep(slot, &slot->mtx, 0, "sdhciah", 0); > slot->bus_busy++; > /* Activate led. */ > WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl |= SDHCI_CTRL_LED); > SDHCI_UNLOCK(slot); > > Dropping the lock before wakeup() is a tiny optimization that avoids > having the second thread wakeup and immediately block on the lock before > it has been released by the first thread. > 'race' is probably wrong here. this change will prevent a second thread from taking the bus before you call wakeup() - poking all other threads unnecessarily. luiz From owner-dev-commits-src-all@freebsd.org Wed Aug 11 21:50:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AB4F65C73C; Wed, 11 Aug 2021 21:50:52 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from smtp4-2.goneo.de (smtp4-2.goneo.de [85.220.129.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlNmW6Hk6z4Zqn; Wed, 11 Aug 2021 21:50:51 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from thor.intern.walstatt.dynvpn.de (dynamic-077-011-189-183.77.11.pool.telefonica.de [77.11.189.183]) by smtp4.goneo.de (Postfix) with ESMTPSA id E3BD02040DB3; Wed, 11 Aug 2021 23:50:43 +0200 (CEST) Date: Wed, 11 Aug 2021 23:50:16 +0200 From: FreeBSD User To: Toomas Soome Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 97cbd5e72238 - main - loader: open file list should be dynamic Message-ID: <20210811235043.1650b7af@thor.intern.walstatt.dynvpn.de> In-Reply-To: <202108112113.17BLDtTn033533@gitrepo.freebsd.org> References: <202108112113.17BLDtTn033533@gitrepo.freebsd.org> Organization: walstatt-de.de MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4GlNmW6Hk6z4Zqn X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 21:50:52 -0000 Am Wed, 11 Aug 2021 21:13:55 GMT Toomas Soome schrieb: > The branch main has been updated by tsoome: > > URL: https://cgit.FreeBSD.org/src/commit/?id=97cbd5e722389a575e820c4e03f38053308f08ea > > commit 97cbd5e722389a575e820c4e03f38053308f08ea > Author: Toomas Soome > AuthorDate: 2021-07-31 08:09:48 +0000 > Commit: Toomas Soome > CommitDate: 2021-08-10 18:54:32 +0000 > > loader: open file list should be dynamic > > Summary: > Open file list is currently created as statically allocated array (64 items). > Once this array is filled up, loader will not be able to operate with files. > In most cases, this mechanism is good enough, but the problem appears, when > we have many disks with zfs pool(s). In current loader implementation, all > discovered zfs pool configurations are kept in memory and disk devices open - > consuming the open file array. Rewrite the open file mechanism to use > dynamically allocated list. > > Reviewed by: imp > MFC after: 2 weeks > Differential Revision: https://reviews.freebsd.org/D31364 > --- > stand/libsa/close.c | 33 +++++++++---- > stand/libsa/closeall.c | 58 ++++++----------------- > stand/libsa/fstat.c | 9 ++-- > stand/libsa/ioctl.c | 22 ++++----- > stand/libsa/iodesc.h | 2 + > stand/libsa/lseek.c | 5 +- > stand/libsa/net.h | 2 - > stand/libsa/netif.c | 122 +++++++++++++++++++++++++++++++++++++++---------- > stand/libsa/open.c | 66 ++++++++++++++++++++++---- > stand/libsa/read.c | 5 +- > stand/libsa/readdir.c | 5 +- > stand/libsa/stand.h | 8 +++- > stand/libsa/write.c | 5 +- > 13 files changed, 227 insertions(+), 115 deletions(-) > > diff --git a/stand/libsa/close.c b/stand/libsa/close.c > index d8f62fef6198..a177eb85eb3a 100644 > --- a/stand/libsa/close.c > +++ b/stand/libsa/close.c > @@ -68,23 +68,38 @@ __FBSDID("$FreeBSD$"); > int > close(int fd) > { > - struct open_file *f = &files[fd]; > + struct open_file *f, *last; > int err1 = 0, err2 = 0; > > - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { > + f = fd2open_file(fd); > + if (f == NULL) { > errno = EBADF; > return (-1); > } > free(f->f_rabuf); > f->f_rabuf = NULL; > > - if (!(f->f_flags & F_RAW) && f->f_ops) > - err1 = (f->f_ops->fo_close)(f); > - if (!(f->f_flags & F_NODEV) && f->f_dev) > - err2 = (f->f_dev->dv_close)(f); > - if (f->f_devdata != NULL) > - devclose(f); > - f->f_flags = 0; > + if (f->f_flags != 0) { > + if (!(f->f_flags & F_RAW) && f->f_ops) > + err1 = (f->f_ops->fo_close)(f); > + if (!(f->f_flags & F_NODEV) && f->f_dev) > + err2 = (f->f_dev->dv_close)(f); > + if (f->f_devdata != NULL) > + devclose(f); > + f->f_flags = 0; > + } else { > + /* Attempt to close already closed file. */ > + err1 = EBADF; > + } > + > + /* free unused entries from tail. */ > + TAILQ_FOREACH_REVERSE_SAFE(last, &files, file_list, f_link, f) { > + if (last->f_flags != 0) > + break; > + TAILQ_REMOVE(&files, last, f_link); > + free(last); > + } > + > if (err1) { > errno = err1; > return (-1); > diff --git a/stand/libsa/closeall.c b/stand/libsa/closeall.c > index 9693130ebf9b..92c6955cf5da 100644 > --- a/stand/libsa/closeall.c > +++ b/stand/libsa/closeall.c > @@ -1,11 +1,7 @@ > -/* $NetBSD: closeall.c,v 1.1 1996/01/13 22:25:36 leo Exp $ */ > - > /*- > - * Copyright (c) 1993 > - * The Regents of the University of California. All rights reserved. > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > * > - * This code is derived from software contributed to Berkeley by > - * The Mach Operating System project at Carnegie-Mellon University. > + * Copyright (c) 2021 Toomas Soome > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -15,14 +11,11 @@ > * 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. > - * 3. Neither the name of the University nor the names of its contributors > - * may be used to endorse or promote products derived from this software > - * without specific prior written permission. > * > - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > + * 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 REGENTS OR CONTRIBUTORS BE LIABLE > + * 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) > @@ -31,33 +24,6 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > - * @(#)close.c 8.1 (Berkeley) 6/11/93 > - * > - * > - * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University > - * All Rights Reserved. > - * > - * Author: Alessandro Forin > - * > - * Permission to use, copy, modify and distribute this software and its > - * documentation is hereby granted, provided that both the copyright > - * notice and this permission notice appear in all copies of the > - * software, derivative works or modified versions, and any portions > - * thereof, and that both notices appear in supporting documentation. > - * > - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" > - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR > - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. > - * > - * Carnegie Mellon requests users of this software to return to > - * > - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU > - * School of Computer Science > - * Carnegie Mellon University > - * Pittsburgh PA 15213-3890 > - * > - * any improvements or extensions that they make and grant Carnegie the > - * rights to redistribute these changes. > */ > > #include > @@ -66,11 +32,17 @@ __FBSDID("$FreeBSD$"); > #include "stand.h" > > void > -closeall() > +closeall(void) > { > - int i; > + struct open_file *f; > > - for (i = 0; i < SOPEN_MAX; i++) > - if (files[i].f_flags != 0) > - (void)close(i); > + /* > + * Pick up last entry and close it, this will also trigger > + * the removal of this entry, and we end up with empty list. > + */ > + while ((f = TAILQ_LAST(&files, file_list)) != NULL) { > + (void)close(f->f_id); > + } > + /* reset errno from close() */ > + errno = 0; > } > diff --git a/stand/libsa/fstat.c b/stand/libsa/fstat.c > index cb2df8cbf0ac..47893416e0bf 100644 > --- a/stand/libsa/fstat.c > +++ b/stand/libsa/fstat.c > @@ -37,13 +37,12 @@ __FBSDID("$FreeBSD$"); > #include "stand.h" > > int > -fstat(fd, sb) > - int fd; > - struct stat *sb; > +fstat(int fd, struct stat *sb) > { > - struct open_file *f = &files[fd]; > + struct open_file *f; > > - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { > + f = fd2open_file(fd); > + if (f == NULL || f->f_flags == 0) { > errno = EBADF; > return (-1); > } > diff --git a/stand/libsa/ioctl.c b/stand/libsa/ioctl.c > index 807b308e5e50..7363236ada0e 100644 > --- a/stand/libsa/ioctl.c > +++ b/stand/libsa/ioctl.c > @@ -32,30 +32,30 @@ > * SUCH DAMAGE. > * > * @(#)ioctl.c 8.1 (Berkeley) 6/11/93 > - * > + * > * > * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University > * All Rights Reserved. > * > * Author: Alessandro Forin > - * > + * > * Permission to use, copy, modify and distribute this software and its > * documentation is hereby granted, provided that both the copyright > * notice and this permission notice appear in all copies of the > * software, derivative works or modified versions, and any portions > * thereof, and that both notices appear in supporting documentation. > - * > + * > * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" > * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR > * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. > - * > + * > * Carnegie Mellon requests users of this software to return to > - * > + * > * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU > * School of Computer Science > * Carnegie Mellon University > * Pittsburgh PA 15213-3890 > - * > + * > * any improvements or extensions that they make and grant Carnegie the > * rights to redistribute these changes. > */ > @@ -66,14 +66,12 @@ __FBSDID("$FreeBSD$"); > #include "stand.h" > > int > -ioctl(fd, cmd, arg) > - int fd; > - u_long cmd; > - char *arg; > +ioctl(int fd, u_long cmd, char *arg) > { > - struct open_file *f = &files[fd]; > + struct open_file *f; > > - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { > + f = fd2open_file(fd); > + if (f == NULL || f->f_flags == 0) { > errno = EBADF; > return (-1); > } > diff --git a/stand/libsa/iodesc.h b/stand/libsa/iodesc.h > index 37ae044af9d9..199fbcf74e98 100644 > --- a/stand/libsa/iodesc.h > +++ b/stand/libsa/iodesc.h > @@ -47,6 +47,8 @@ struct iodesc { > u_long xid; /* transaction identification */ > u_char myea[6]; /* my ethernet address */ > struct netif *io_netif; > + int io_id; /* descriptor id */ > + TAILQ_ENTRY(iodesc) io_link; /* next entry in list */ > }; > > #endif /* __SYS_LIBNETBOOT_IODESC_H */ > diff --git a/stand/libsa/lseek.c b/stand/libsa/lseek.c > index 1a39eb31421b..c4ca97b148d6 100644 > --- a/stand/libsa/lseek.c > +++ b/stand/libsa/lseek.c > @@ -69,9 +69,10 @@ off_t > lseek(int fd, off_t offset, int where) > { > off_t bufpos, filepos, target; > - struct open_file *f = &files[fd]; > + struct open_file *f; > > - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { > + f = fd2open_file(fd); > + if (f == NULL || f->f_flags == 0) { > errno = EBADF; > return (-1); > } > diff --git a/stand/libsa/net.h b/stand/libsa/net.h > index 36b7cacc95ef..77a11c8dcab6 100644 > --- a/stand/libsa/net.h > +++ b/stand/libsa/net.h > @@ -97,8 +97,6 @@ extern u_int intf_mtu; > > extern int debug; /* defined in the machdep sources */ > > -extern struct iodesc sockets[SOPEN_MAX]; > - > /* ARP/RevARP functions: */ > u_char *arpwhohas(struct iodesc *, struct in_addr); > void arp_reply(struct iodesc *, void *); > diff --git a/stand/libsa/netif.c b/stand/libsa/netif.c > index d255cc663d5a..2d32ccd9de7e 100644 > --- a/stand/libsa/netif.c > +++ b/stand/libsa/netif.c > @@ -47,7 +47,19 @@ __FBSDID("$FreeBSD$"); > #include "net.h" > #include "netif.h" > > -struct iodesc sockets[SOPEN_MAX]; > +typedef TAILQ_HEAD(socket_list, iodesc) socket_list_t; > + > +/* > + * Open socket list. The current implementation and assumption is, > + * we only remove entries from tail and we only add new entries to tail. > + * This decision is to keep iodesc id management simple - we get list > + * entries ordered by continiously growing io_id field. > + * If we do have multiple sockets open and we do close socket not from tail, > + * this entry will be marked unused. netif_open() will reuse unused entry, or > + * netif_close() will free all unused tail entries. > + */ > +static socket_list_t sockets = TAILQ_HEAD_INITIALIZER(sockets); > + > #ifdef NETIF_DEBUG > int netif_debug = 0; > #endif > @@ -63,7 +75,7 @@ netif_init(void) > { > struct netif_driver *drv; > int d, i; > - > + > #ifdef NETIF_DEBUG > if (netif_debug) > printf("netif_init: called\n"); > @@ -108,7 +120,7 @@ netif_select(void *machdep_hint) > for (u = 0; u < drv->netif_nifs; u++) { > cur_if.nif_unit = u; > unit_done = 0; > - > + > #ifdef NETIF_DEBUG > if (netif_debug) > printf("\t%s%d:", drv->netif_bname, > @@ -179,14 +191,14 @@ netif_attach(struct netif *nif, struct iodesc *desc, void > *machdep_hint) if (netif_debug) > printf("%s%d: netif_attach\n", drv->netif_bname, nif->nif_unit); > #endif > - desc->io_netif = nif; > + desc->io_netif = nif; > #ifdef PARANOID > if (drv->netif_init == NULL) > panic("%s%d: no netif_init support", drv->netif_bname, > nif->nif_unit); > #endif > drv->netif_init(desc, machdep_hint); > - bzero(drv->netif_ifs[nif->nif_unit].dif_stats, > + bzero(drv->netif_ifs[nif->nif_unit].dif_stats, > sizeof(struct netif_stats)); > } > > @@ -261,35 +273,71 @@ netif_put(struct iodesc *desc, void *pkt, size_t len) > return (rv); > } > > +/* > + * socktodesc_impl: > + * > + * Walk socket list and return pointer to iodesc structure. > + * if id is < 0, return first unused iodesc. > + */ > +static struct iodesc * > +socktodesc_impl(int socket) > +{ > + struct iodesc *s; > + > + TAILQ_FOREACH(s, &sockets, io_link) { > + /* search by socket id */ > + if (socket >= 0) { > + if (s->io_id == socket) > + break; > + continue; > + } > + /* search for first unused entry */ > + if (s->io_netif == NULL) > + break; > + } > + return (s); > +} > + > struct iodesc * > socktodesc(int sock) > { > - if (sock >= SOPEN_MAX) { > + struct iodesc *desc; > + > + if (sock < 0) > + desc = NULL; > + else > + desc = socktodesc_impl(sock); > + > + if (desc == NULL) > errno = EBADF; > - return (NULL); > - } > - return (&sockets[sock]); > + > + return (desc); > } > > int > netif_open(void *machdep_hint) > { > - int fd; > struct iodesc *s; > struct netif *nif; > - > + > /* find a free socket */ > - for (fd = 0, s = sockets; fd < SOPEN_MAX; fd++, s++) > - if (s->io_netif == (struct netif *)0) > - goto fnd; > - errno = EMFILE; > - return (-1); > - > -fnd: > - bzero(s, sizeof(*s)); > + s = socktodesc_impl(-1); > + if (s == NULL) { > + struct iodesc *last; > + > + s = calloc(1, sizeof (*s)); > + if (s == NULL) > + return (-1); > + > + last = TAILQ_LAST(&sockets, socket_list); > + if (last != NULL) > + s->io_id = last->io_id + 1; > + TAILQ_INSERT_TAIL(&sockets, s, io_link); > + } > + > netif_init(); > nif = netif_select(machdep_hint); > - if (!nif) > + if (!nif) > panic("netboot: no interfaces left untried"); > if (netif_probe(nif, machdep_hint)) { > printf("netboot: couldn't probe %s%d\n", > @@ -299,18 +347,42 @@ fnd: > } > netif_attach(nif, s, machdep_hint); > > - return (fd); > + return (s->io_id); > } > > int > netif_close(int sock) > { > - if (sock >= SOPEN_MAX) { > - errno = EBADF; > + struct iodesc *s, *last; > + int err; > + > + err = 0; > + s = socktodesc_impl(sock); > + if (s == NULL || sock < 0) { > + err = EBADF; > + return (-1); > + } > + netif_detach(s->io_netif); > + bzero(&s->destip, sizeof (s->destip)); > + bzero(&s->myip, sizeof (s->myip)); > + s->destport = 0; > + s->myport = 0; > + s->xid = 0; > + bzero(s->myea, sizeof (s->myea)); > + s->io_netif = NULL; > + > + /* free unused entries from tail. */ > + TAILQ_FOREACH_REVERSE_SAFE(last, &sockets, socket_list, io_link, s) { > + if (last->io_netif != NULL) > + break; > + TAILQ_REMOVE(&sockets, last, io_link); > + free(last); > + } > + > + if (err) { > + errno = err; > return (-1); > } > - netif_detach(sockets[sock].io_netif); > - sockets[sock].io_netif = (struct netif *)0; > > return (0); > } > diff --git a/stand/libsa/open.c b/stand/libsa/open.c > index 9590508b0015..c62e48f0e1d8 100644 > --- a/stand/libsa/open.c > +++ b/stand/libsa/open.c > @@ -67,17 +67,66 @@ __FBSDID("$FreeBSD$"); > > struct fs_ops *exclusive_file_system; > > -struct open_file files[SOPEN_MAX]; > +/* > + * Open file list. The current implementation and assumption is, > + * we only remove entries from tail and we only add new entries to tail. > + * This decision is to keep file id management simple - we get list > + * entries ordered by continiously growing f_id field. > + * If we do have multiple files open and we do close file not from tail, > + * this entry will be marked unused. open() will reuse unused entry, or > + * close will free all unused tail entries. > + * > + * Only case we expect open file list to grow long, is with zfs pools with > + * many disks. > + */ > +file_list_t files = TAILQ_HEAD_INITIALIZER(files); > + > +/* > + * Walk file list and return pointer to open_file structure. > + * if fd is < 0, return first unused open_file. > + */ > +struct open_file * > +fd2open_file(int fd) > +{ > + struct open_file *f; > + > + TAILQ_FOREACH(f, &files, f_link) { > + if (fd >= 0) { > + if (f->f_id == fd) > + break; > + continue; > + } > + > + if (f->f_flags == 0) > + break; > + } > + return (f); > +} > > static int > -o_gethandle(void) > +o_gethandle(struct open_file **ptr) > { > - int fd; > + struct open_file *f, *last; > > - for (fd = 0; fd < SOPEN_MAX; fd++) > - if (files[fd].f_flags == 0) > - return (fd); > - return (-1); > + /* Pick up unused entry */ > + f = fd2open_file(-1); > + if (f != NULL) { > + *ptr = f; > + return (f->f_id); > + } > + > + /* Add new entry */ > + f = calloc(1, sizeof (*f)); > + if (f == NULL) > + return (-1); > + > + last = TAILQ_LAST(&files, file_list); > + if (last != NULL) > + f->f_id = last->f_id + 1; > + TAILQ_INSERT_TAIL(&files, f, f_link); > + > + *ptr = f; > + return (f->f_id); > } > > static void > @@ -98,12 +147,11 @@ open(const char *fname, int mode) > > TSENTER(); > > - if ((fd = o_gethandle()) == -1) { > + if ((fd = o_gethandle(&f)) == -1) { > errno = EMFILE; > return (-1); > } > > - f = &files[fd]; > f->f_flags = mode + 1; > f->f_dev = NULL; > f->f_ops = NULL; > diff --git a/stand/libsa/read.c b/stand/libsa/read.c > index 7ad75c387a5d..d079944bf5d0 100644 > --- a/stand/libsa/read.c > +++ b/stand/libsa/read.c > @@ -69,12 +69,13 @@ __FBSDID("$FreeBSD$"); > ssize_t > read(int fd, void *dest, size_t bcount) > { > - struct open_file *f = &files[fd]; > + struct open_file *f; > size_t resid; > > TSENTER(); > > - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { > + f = fd2open_file(fd); > + if (f == NULL || !(f->f_flags & F_READ)) { > errno = EBADF; > return (-1); > } > diff --git a/stand/libsa/readdir.c b/stand/libsa/readdir.c > index e49d93d15ed6..7757647e11e8 100644 > --- a/stand/libsa/readdir.c > +++ b/stand/libsa/readdir.c > @@ -34,9 +34,10 @@ struct dirent * > readdirfd(int fd) > { > static struct dirent dir; /* XXX not thread safe */ > - struct open_file *f = &files[fd]; > + struct open_file *f; > > - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { > + f = fd2open_file(fd); > + if (f == NULL || !(f->f_flags & F_READ)) { > errno = EBADF; > return (NULL); > } > diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h > index eb95afe4b169..535fee31d586 100644 > --- a/stand/libsa/stand.h > +++ b/stand/libsa/stand.h > @@ -65,6 +65,7 @@ > #include > #include > #include > +#include > > /* this header intentionally exports NULL from */ > #include > @@ -182,11 +183,14 @@ struct open_file { > char *f_rabuf; /* readahead buffer pointer */ > size_t f_ralen; /* valid data in readahead buffer */ > off_t f_raoffset; /* consumer offset in readahead buffer */ > + int f_id; /* file number */ > + TAILQ_ENTRY(open_file) f_link; /* next entry */ > #define SOPEN_RASIZE 512 > }; > > -#define SOPEN_MAX 64 > -extern struct open_file files[]; > +typedef TAILQ_HEAD(file_list, open_file) file_list_t; > +extern file_list_t files; > +extern struct open_file *fd2open_file(int); > > /* f_flags values */ > #define F_READ 0x0001 /* file opened for reading */ > diff --git a/stand/libsa/write.c b/stand/libsa/write.c > index 7d054e005cda..db82d7eaf4f6 100644 > --- a/stand/libsa/write.c > +++ b/stand/libsa/write.c > @@ -69,10 +69,11 @@ __FBSDID("$FreeBSD$"); > ssize_t > write(int fd, const void *dest, size_t bcount) > { > - struct open_file *f = &files[fd]; > + struct open_file *f; > size_t resid; > > - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) { > + f = fd2open_file(fd); > + if (f == NULL || !(f->f_flags & F_WRITE)) { > errno = EBADF; > return (-1); > } > _______________________________________________ > dev-commits-src-main@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main > To unsubscribe, send any mail to "dev-commits-src-main-unsubscribe@freebsd.org" This commit inflicts a buildworld error: [...] --- all_subdir_stand/libsa --- /usr/src/lib/libsecureboot/verify_file.c:59:22: error: use of undeclared identifier 'SOPEN_MAX' static int ve_status[SOPEN_MAX+1]; ^ /usr/src/lib/libsecureboot/verify_file.c:74:22: error: use of undeclared identifier 'SOPEN_MAX' if (fd >= 0 && fd < SOPEN_MAX) { ^ /usr/src/lib/libsecureboot/verify_file.c:78:12: error: use of undeclared identifier 'SOPEN_MAX' ve_status[SOPEN_MAX] = ves; ^ /usr/src/lib/libsecureboot/verify_file.c:98:19: error: use of undeclared identifier 'SOPEN_MAX' fd >= 0 && fd < SOPEN_MAX) ^ /usr/src/lib/libsecureboot/verify_file.c:100:20: error: use of undeclared identifier 'SOPEN_MAX' return (ve_status[SOPEN_MAX]); /* most recent */ -- O. Hartmann From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:03:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFBA665CB6F; Wed, 11 Aug 2021 22:03:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlP3068Z6z4dV7; Wed, 11 Aug 2021 22:03:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 3D48DC8BA; Wed, 11 Aug 2021 22:03:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: Luiz Otavio O Souza Cc: Scott Long , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202108102241.17AMfr63025604@gitrepo.freebsd.org> <9b1ec22c-1545-52ea-7bf9-a96140737711@FreeBSD.org> From: John Baldwin Subject: Re: git: 35547df5c786 - main - Call wakeup() with the lock held to avoid missed wakeup races. Message-ID: Date: Wed, 11 Aug 2021 15:03:19 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:03:25 -0000 On 8/11/21 2:38 PM, Luiz Otavio O Souza wrote: > On Wed, Aug 11, 2021 at 3:49 PM John Baldwin wrote: >> >> On 8/10/21 3:41 PM, Scott Long wrote: >>> The branch main has been updated by scottl: >>> >>> URL: https://cgit.FreeBSD.org/src/commit/?id=35547df5c78653b2da030f920323c0357056099f >>> >>> commit 35547df5c78653b2da030f920323c0357056099f >>> Author: Scott Long >>> AuthorDate: 2021-08-10 22:36:38 +0000 >>> Commit: Scott Long >>> CommitDate: 2021-08-10 22:36:38 +0000 >>> >>> Call wakeup() with the lock held to avoid missed wakeup races. >>> >>> Submitted by: luiz >>> Sponsored by: Rubicon Communications, LLC ("Netgate") >>> --- >>> sys/dev/sdhci/sdhci.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c >>> index d075c2e05000..573e6949b57e 100644 >>> --- a/sys/dev/sdhci/sdhci.c >>> +++ b/sys/dev/sdhci/sdhci.c >>> @@ -2078,8 +2078,8 @@ sdhci_generic_release_host(device_t brdev __unused, device_t reqdev) >>> /* Deactivate led. */ >>> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl &= ~SDHCI_CTRL_LED); >>> slot->bus_busy--; >>> - SDHCI_UNLOCK(slot); >>> wakeup(slot); >>> + SDHCI_UNLOCK(slot); >>> return (0); >>> } >> >> Hmm, how does this avoid a race? The sleep is checking bus_busy under >> the lock and should never see a stale value and go back to sleep after >> the wakeup has occurred: >> >> SDHCI_LOCK(slot); >> while (slot->bus_busy) >> msleep(slot, &slot->mtx, 0, "sdhciah", 0); >> slot->bus_busy++; >> /* Activate led. */ >> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl |= SDHCI_CTRL_LED); >> SDHCI_UNLOCK(slot); >> >> Dropping the lock before wakeup() is a tiny optimization that avoids >> having the second thread wakeup and immediately block on the lock before >> it has been released by the first thread. >> > > 'race' is probably wrong here. this change will prevent a second > thread from taking the bus before you call wakeup() - poking all other > threads unnecessarily. This change does not prevent that. The other thread and the thread that are awakened will race with each other to acquire the lock. wakeup() doesn't do any sort of explicit lock handoff to the thread being awakened and it's just as likely for a thread not yet asleep to acquire the lock as for the thread being awakened to acquire the lock. If you have observed thundering herd problems with this wakeup() then you might want to change it to wakeup_one(). -- John Baldwin From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:07:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67F3465CEB7; Wed, 11 Aug 2021 22:07:01 +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 4GlP792R5Rz4dbM; Wed, 11 Aug 2021 22:07: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 3BADF17123; Wed, 11 Aug 2021 22:07: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 17BM71Lo000325; Wed, 11 Aug 2021 22:07:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BM71rN000324; Wed, 11 Aug 2021 22:07:01 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:07:01 GMT Message-Id: <202108112207.17BM71rN000324@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: ee6dc333e1a1 - main - libsecureboot: define SOPEN_MAX 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/main X-Git-Reftype: branch X-Git-Commit: ee6dc333e1a1af08afa3d14b83e963e4cf90b77b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:07:01 -0000 The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=ee6dc333e1a1af08afa3d14b83e963e4cf90b77b commit ee6dc333e1a1af08afa3d14b83e963e4cf90b77b Author: Toomas Soome AuthorDate: 2021-08-10 19:46:40 +0000 Commit: Toomas Soome CommitDate: 2021-08-10 19:46:40 +0000 libsecureboot: define SOPEN_MAX With commit 97cbd5e722389a575e820c4e03f38053308f08ea, the SOPEN_MAX was removed from stand.h. We would need better mechanism there. --- lib/libsecureboot/verify_file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libsecureboot/verify_file.c b/lib/libsecureboot/verify_file.c index 9773b02e5a1d..22f3f06b0eda 100644 --- a/lib/libsecureboot/verify_file.c +++ b/lib/libsecureboot/verify_file.c @@ -56,6 +56,9 @@ extern char *Skip; * We sometimes need to know if input is verified or not. * The extra slot is for tracking most recently opened. */ +#ifndef SOPEN_MAX +#define SOPEN_MAX 64 +#endif static int ve_status[SOPEN_MAX+1]; static int ve_status_state; struct verify_status; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 954C665D405; Wed, 11 Aug 2021 22:14: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 4GlPHS3mHBz4fDS; Wed, 11 Aug 2021 22:14: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 64C7817502; Wed, 11 Aug 2021 22:14: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 17BMEC77013780; Wed, 11 Aug 2021 22:14:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMECJR013777; Wed, 11 Aug 2021 22:14:12 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:12 GMT Message-Id: <202108112214.17BMECJR013777@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 525024fc9cbf - stable/13 - Refactor configuration management in bhyve. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 525024fc9cbfcafe9470cdaf1d4aedec62b6fa6d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:12 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=525024fc9cbfcafe9470cdaf1d4aedec62b6fa6d commit 525024fc9cbfcafe9470cdaf1d4aedec62b6fa6d Author: John Baldwin AuthorDate: 2019-06-26 20:30:41 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:11:39 +0000 Refactor configuration management in bhyve. Replace the existing ad-hoc configuration via various global variables with a small database of key-value pairs. The database supports heirarchical keys using a MIB-like syntax to name the path to a given key. Values are always stored as strings. The API used to manage configuation values does include wrappers to handling boolean values. Other values use non-string types require parsing by consumers. The configuration values are stored in a tree using nvlists. Leaf nodes hold string values. Configuration values are permitted to reference other configuration values using '%(name)'. This permits constructing template configurations. All existing command line arguments now set configuration values. For devices, the "-s" option parses its option argument to generate a list of key-value pairs for the given device. A new '-o' command line option permits setting an individual configuration variable. The key name is always given as a full path of dot-separated components. A new '-k' command line option parses a simple configuration file. This configuration file holds a flat list of 'key=value' lines where the 'key' is the full path of a configuration variable. Lines starting with a '#' are comments. In general, bhyve starts by parsing command line options in sequence and applying those settings to configuration values. Once this is complete, bhyve then begins initializing its state based on the configuration values. This means that subsequent configuration options or files may override or supplement previously given settings. A special 'config.dump' configuration value can be set to true to help debug configuration issues. When this value is set, bhyve will print out the configuration variables as a flat list of 'key=value' lines. Most command line argments map to a single configuration variable, e.g. '-w' sets the 'x86.strictmsr' value to false. A few command line arguments have less obvious effects: - Multiple '-p' options append their values (as a comma-seperated list) to "vcpu.N.cpuset" values (where N is a decimal vcpu number). - For '-s' options, a pci... node is created. The first argument to '-s' (the device type) is used as the value of a "device" variable. Additional comma-separated arguments are then parsed into 'key=value' pairs and used to set additional variables under the device node. A PCI device emulation driver can provide its own hook to override the parsing of the additonal '-s' arguments after the device type. After the configuration phase as completed, the init_pci hook then walks the "pci..." nodes. It uses the "device" value to find the device model to use. The device model's init routine is passed a reference to its nvlist node in the configuration tree which it can query for specific variables. The result is that a lot of the string parsing is removed from the device models and centralized. In addition, adding a new variable just requires teaching the model to look for the new variable. - For '-l' options, a similar model is used where the string is parsed into values that are later read during initialization. One key note here is that the serial ports use the commonly used lowercase names from existing documentation and examples (e.g. "lpc.com1") instead of the uppercase names previously used internally in bhyve. Reviewed by: grehan MFC after: 3 months Differential Revision: https://reviews.freebsd.org/D26035 (cherry picked from commit 621b5090487de9fed1b503769702a9a2a27cc7bb) --- usr.sbin/bhyve/Makefile | 5 +- usr.sbin/bhyve/bhyve.8 | 47 ++- usr.sbin/bhyve/bhyve_config.5 | 560 ++++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/bhyverun.c | 485 ++++++++++++++++++++----------- usr.sbin/bhyve/bhyverun.h | 7 +- usr.sbin/bhyve/block_if.c | 98 ++++--- usr.sbin/bhyve/block_if.h | 4 +- usr.sbin/bhyve/config.c | 431 +++++++++++++++++++++++++++ usr.sbin/bhyve/config.h | 119 ++++++++ usr.sbin/bhyve/gdb.c | 12 + usr.sbin/bhyve/hda_codec.c | 6 +- usr.sbin/bhyve/inout.c | 6 +- usr.sbin/bhyve/inout.h | 3 +- usr.sbin/bhyve/mevent.c | 2 - usr.sbin/bhyve/mevent_test.c | 2 - usr.sbin/bhyve/net_backends.c | 106 +++---- usr.sbin/bhyve/net_backends.h | 3 +- usr.sbin/bhyve/net_utils.c | 5 +- usr.sbin/bhyve/net_utils.h | 2 +- usr.sbin/bhyve/pci_ahci.c | 283 ++++++++++-------- usr.sbin/bhyve/pci_e82545.c | 65 +---- usr.sbin/bhyve/pci_emul.c | 147 +++++++--- usr.sbin/bhyve/pci_emul.h | 7 +- usr.sbin/bhyve/pci_fbuf.c | 194 +++++++------ usr.sbin/bhyve/pci_hda.c | 95 ++---- usr.sbin/bhyve/pci_hda.h | 2 +- usr.sbin/bhyve/pci_hostbridge.c | 32 ++- usr.sbin/bhyve/pci_lpc.c | 60 ++-- usr.sbin/bhyve/pci_nvme.c | 164 +++++------ usr.sbin/bhyve/pci_passthru.c | 47 ++- usr.sbin/bhyve/pci_uart.c | 19 +- usr.sbin/bhyve/pci_virtio_9p.c | 80 +++--- usr.sbin/bhyve/pci_virtio_block.c | 15 +- usr.sbin/bhyve/pci_virtio_console.c | 131 +++++++-- usr.sbin/bhyve/pci_virtio_net.c | 97 +++---- usr.sbin/bhyve/pci_virtio_rnd.c | 2 +- usr.sbin/bhyve/pci_virtio_scsi.c | 49 ++-- usr.sbin/bhyve/pci_xhci.c | 220 +++++++++----- usr.sbin/bhyve/pctestdev.c | 9 - usr.sbin/bhyve/pctestdev.h | 1 - usr.sbin/bhyve/rtc.c | 9 +- usr.sbin/bhyve/rtc.h | 2 +- usr.sbin/bhyve/smbiostbl.c | 5 + usr.sbin/bhyve/uart_emul.c | 12 +- usr.sbin/bhyve/uart_emul.h | 2 +- usr.sbin/bhyve/usb_emul.c | 2 +- usr.sbin/bhyve/usb_emul.h | 5 +- usr.sbin/bhyve/usb_mouse.c | 5 +- 48 files changed, 2593 insertions(+), 1071 deletions(-) diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile index a4fc3deea77e..e35d528ab605 100644 --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -10,7 +10,7 @@ CFLAGS+=-I${SRCTOP}/sys PROG= bhyve PACKAGE= bhyve -MAN= bhyve.8 +MAN= bhyve.8 bhyve_config.5 BHYVE_SYSDIR?=${SRCTOP} @@ -22,6 +22,7 @@ SRCS= \ bhyverun.c \ block_if.c \ bootrom.c \ + config.c \ console.c \ ctl_util.c \ ctl_scsi_all.c \ @@ -83,7 +84,7 @@ CFLAGS.kernemu_dev.c+= -I${SRCTOP}/sys/amd64 .PATH: ${BHYVE_SYSDIR}/sys/amd64/vmm SRCS+= vmm_instruction_emul.c -LIBADD= vmmapi md pthread z util sbuf cam 9p +LIBADD= vmmapi md nv pthread z util sbuf cam 9p .if ${MK_CASPER} != "no" LIBADD+= casper diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8 index 115727a136a7..04e22302d9d7 100644 --- a/usr.sbin/bhyve/bhyve.8 +++ b/usr.sbin/bhyve/bhyve.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 18, 2021 +.Dd March 18, 2021 .Dt BHYVE 8 .Os .Sh NAME @@ -46,6 +46,7 @@ .Oc .Sm on .Op Fl G Ar port +.Op Fl k Ar file .Oo Fl l .Sm off .Cm help | Ar lpcdev Op Cm \&, Ar conf @@ -59,6 +60,7 @@ .Oc .Sm on .Oc +.Op Fl o Ar var Ns Cm = Ns Ar value .Op Fl p Ar vcpu Ns Cm \&: Ns Ar hostcpu .Op Fl r Ar file .Oo Fl s @@ -149,6 +151,17 @@ Print help message and exit. .It Fl H Yield the virtual CPU thread when a HLT instruction is detected. If this option is not specified, virtual CPUs will use 100% of a host CPU. +.It Fl k Ar file +Set configuration variables from a simple, key-value config file. +Each line of the config file is expected to consist of a config variable +name, an equals sign +.Pq Sq = , +and a value. +No spaces are permitted between the variable name, equals sign, or +value. +Blank lines and lines starting with +.Sq # +are ignored. .It Fl l Op Ar help|lpcdev Ns Op , Ns Ar conf Allow devices behind the LPC PCI-ISA bridge to be configured. The only supported devices are the TTY-class devices @@ -174,6 +187,11 @@ If no suffix is given, the value is assumed to be in megabytes. .Pp .Ar memsize defaults to 256M. +.It Fl o Ar var Ns Cm = Ns Ar value +Set the configuration variable +.Ar var +to +.Ar value . .It Fl p Ar vcpu:hostcpu Pin guest's virtual CPU .Em vcpu @@ -594,6 +612,32 @@ Alphanumeric name of the guest. This should be the same as that created by .Xr bhyveload 8 . .El +.Sh CONFIGURATION VARIABLES +.Nm +uses an internal tree of configuration variables to describe global and +per-device settings. +When +.Nm +starts, +it parses command line options (including config files) in the order given +on the command line. +Each command line option sets one or more configuration variables. +For example, +the +.Fl s +option creates a new tree node for a PCI device and sets one or more variables +under that node including the device model and device model-specific variables. +Variables may be set multiple times during this parsing stage with the final +value overriding previous values. +.Pp +Once all of the command line options have been processed, +the configuration values are frozen. +.Nm +then uses the value of configuration values to initialize device models +and global settings. +.Pp +More details on configuration variables can be found in +.Xr bhyve_config 5 . .Sh DEBUG SERVER The current debug server provides limited support for debuggers. .Ss Registers @@ -717,6 +761,7 @@ bhyve -c 2 -m 4G -w -H \\ .Xr ng_socket 4 , .Xr nmdm 4 , .Xr vmm 4 , +.Xr bhyve_config 5 , .Xr ethers 5 , .Xr bhyvectl 8 , .Xr bhyveload 8 diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 new file mode 100644 index 000000000000..4e200a779d50 --- /dev/null +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -0,0 +1,560 @@ +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2021 John H. Baldwin +.\" +.\" 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. +.\" +.Dd March 18, 2021 +.Dt BHYVE_CONFIG 5 +.Os +.Sh NAME +.Nm bhyve_config +.Nd "bhyve configuration variables" +.Sh DESCRIPTION +.Xr bhyve 8 +uses a hierarchical tree of configuration variables to describe global and +per-device settings. +Internal nodes in this tree do not have a value, +only leaf nodes have values. +This manual describes the configuration variables understood by +.Xr bhyve 8 . +If additional variables are defined, +.Xr bhyve 8 +will ignore them and will not emit errors for unknown variables. +However, these additional variables can be referenced by other +variables as described below. +.Sh VARIABLE VALUES +Configuration variable values are stored as strings. +A configuration variable value may refer to one or more other +configuration values by name. +Instances of the pattern +.Sq % Ns Pq Ar var +are replaced by the value of the configuration variable +.Va var . +To avoid unwanted expansion, +.Sq % +characters can be escaped by a leading +.Sq % . +For example, +if a configuration variable +.Va disk +uses the value +.Pa /dev/zvol/bhyve/%(name) , +then the final value of the +.Va disk +variable will be set to the path of a ZFS volume whose name matches +the name of the virtual machine on the pool +.Pa bhyve . +.Pp +Some configuration variables may be interpreted as a boolean value. +For those variables the following case-insensitive values may be used to +indicate true: +.Pp +.Bl -bullet -offset indent -compact +.It +true +.It +on +.It +yes +.It +1 +.El +.Pp +The following values may be used to indicate false: +.Pp +.Bl -bullet -offset indent -compact +.It +false +.It +off +.It +no +.It +0 +.El +.Pp +Some configuration variables may be interperted as an integer. +For those variables, +any syntax supported by +.Xr strtol 3 +may be used. +.Sh GLOBAL SETTINGS +.Ss Architecture Neutral Settings +.Bl -column "memory.guest_in_core" "integer" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va name Ta string Ta Ta +The name of the VM. +.It Va cpus Ta integer Ta 1 Ta +The total number of virtual CPUs. +.It Va cores Ta integer Ta 1 Ta +The number of virtual cores in each virtual socket. +.It Va threads Ta integer Ta 1 Ta +The number of virtual CPUs in each virtual core. +.It Va sockets Ta integer Ta 1 Ta +The number of virtual sockets. +.It Va memory.guest_in_core Ta bool Ta false Ta +Include guest memory in core file. +.It Va memory.size Ta string Ta 256M Ta +Guest physical memory size in bytes. +The value must be formatted as described in +.Xr expand_number 3 . +.It Va memory.wired Ta bool Ta false Ta +Wire guest memory. +.It Va acpi_tables Ta bool Ta false Ta +Generate ACPI tables. +.It Va destroy_on_poweroff Ta bool Ta false Ta +Destroy the VM on guest-initiated power-off. +.It Va gdb.port Ta integer Ta 0 Ta +TCP port number for the debug server. +If this is set to a non-zero value, a debug server +will listen for connections on this port. +.It Va gdb.wait Ta bool Ta false Ta +If the debug server is enabled, wait for a debugger to connect +before starting the guest. +.It Va rtc.use_localtime Ta bool Ta true Ta +The real time clock uses the local time of the host. +If this is set to false, the real time clock uses UTC. +.It Va uuid Ta string Ta Ta +The universally unique identifier (UUID) to use in the guest's +System Management BIOS System Information structure. +If an explicit value is not set, a valid UUID is generated from +the host's hostname and the VM name. +.It Va virtio_msix Ta bool Ta true Ta +Use MSI-X interrupts for PCI VirtIO devices. +If set to false, MSI interrupts are used instead. +.It Va config.dump Ta bool Ta false Ta +If this value is set to true, +then +.Xr bhyve 8 +will write all of its configuration variables to stdout and exit +after it has finished parsing command line options. +.El +.Ss x86-Specific Settings +.Bl -column "x86.vmexit_on_pause" "integer" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va x86.mptable Ta bool Ta true Ta +Generate an MPTable. +.It Va x86.x2apic Ta bool Ta false Ta +Configure guest's local APICs in x2APIC mode. +.It Va x86.strictio Ta bool Ta false Ta +Exit if a guest accesses an I/O port that is not emulated. +By default, writes are ignored and reads return all bits set. +.It Va x86.strictmsr Ta bool Ta true Ta +Inject a general protection fault if a guest accesses a Model Specific +Register (MSR) that is not emulated. +If this is false, writes are ignored and reads return zero. +.It Va x86.vmexit_on_hlt Ta bool Ta false Ta +Force a VM exit when a guest CPU executes the +.Dv HLT +instruction. +This allows idle guest CPUs to yield the host CPU. +.It Va x86.vmexit_on_pause Ta bool Ta false Ta +Force a VM exit when a guest CPU executes the +.Dv PAUSE +instruction. +.El +.Sh DEVICE SETTINGS +Device settings are stored under a device node. +The device node's name is set by the parent bus of the device. +.Ss PCI Device Settings +PCI devices are described by a device node named +.Dq pci Ns Ar bus . Ns Ar slot . Ns Ar function +where each of +.Ar bus , +.Ar slot , +and +.Ar function +are formatted as decimal values with no padding. +All PCI device nodes must contain a configuration variable named +.Dq device +which specifies the device model to use. +The following PCI device models are supported: +.Bl -tag -indent +.It Li hostbridge +Provide a simple PCI-Host bridge device. +This is usually configured at pci0:0:0 and is required by most guest +operating systems. +.It Li ahci +AHCI storage controller. +.It Li e1000 +Intel e82545 network interface. +.It Li fbuf +VGA framebuffer device attached to VNC server. +.It Li lpc +LPC PCI-ISA bridge with COM1-COM4 16550 serial ports, +a boot ROM, +and an optional debug/test device. +This device must be configured on bus 0. +.It Li hda +High Definition audio controller. +.It Li nvme +NVM Express (NVMe) controller. +.It Li passthru +PCI pass-through device. +.It Li uart +PCI 16550 serial device. +.It Li virtio-9p +VirtIO 9p (VirtFS) interface. +.It Li virtio-blk +VirtIO block storage interface. +.It Li virtio-console +VirtIO console interface. +.It Li virtio-net +VirtIO network interface. +.It Li virtio-rnd +VirtIO RNG interface. +.It Li virtio-scsi +VirtIO SCSI interface. +.It Li xhci +Extensible Host Controller Interface (XHCI) USB controller. +.El +.Ss USB Device Settings +USB controller devices contain zero or more child USB devices +attached to slots. +Each USB device stores its settings in a node named +.Dq slot. Ns Va N +under the controller's device node. +.Va N +is the number of the slot to which the USB device is attached. +Note that USB slot numbers begin at 1. +All USB device nodes must contain a configuration variable named +.Dq device +which specifies the device model to use. +The following USB device models are supported: +.Bl -tag -indent +.It Li tablet +A USB tablet device which provides precise cursor synchronization +when using VNC. +.El +.Ss Block Device Settings +Block devices use the following settings to configure their backing store. +These settings are stored in the configuration node of the respective device. +.Bl -column "sectorsize" "logical[/physical]" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It path Ta string Ta Ta +The path of the file or disk device to use as the backing store. +.It nocache Ta bool Ta false Ta +Disable caching on the backing file by opening the backing file with +.Dv O_DIRECT . +.It nodelete Ta bool Ta false Ta +Disable emulation of guest trim requests via +.Dv DIOCGDELETE +requests. +.It sync Ta bool Ta false Ta +Write changes to the backing file with synchronous writes. +.It direct Ta bool Ta false Ta +An alias for +.Va sync . +.It ro Ta bool Ta false Ta +Disable writes to the backing file. +.It sectorsize Ta Va logical Ns Op / Ns Va physical Ta Ta +Specify the logical and physical sector size of the emulated disk. +If the physical size is not specified, +it is equal to the logical size. +.El +.Ss Network Backend Settings +Network devices use the following settings to configure their backend. +The backend is responsible for passing packets between the device model +and a desired destination. +Configuring a backend requires setting the +.Va backend +variable to one of the following values: +.Bl -tag +.It tap Ns Va N +Use the named +.Xr tap 4 +interface as the backend. +.It vmnet Ns Va N +Use the named +.Xr vmnet 4 +interface as the backend. +.It netgraph +Use a +.Xr netgraph 4 +socket hook as the backend. +This backend uses the following additional variables: +.Bl -column "peerhook" "Format" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va path Ta string Ta Ta +The name of the +.Xr netgraph 4 +destination node. +.It Va peerhook Ta string Ta Ta +The name of the destination hook. +.It Va socket Ta string Ta Ta +The name of the created +.Xr ng_socket 4 +node. +.It Va hook Ta string Ta vmlink Ta +The name of the source hook on the created +.Xr ng_socket 4 +node. +.El +.It netmap: Ns Va interface +Use +.Xr netmap 4 +on a network interface as the backend. +.It vale Ns Va bridge : Ns Va port +Use a port on a +.Xr vale 4 +bridge as the backend. +.El +.Ss UART Device Settings +.Bl -column "Name" "Format" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va path Ta path Ta Ta +Backend device for the serial port. +Either the pathname of a character device or +.Dq stdio +to use standard input and output of the +.Xr bhyve 8 +process. +.El +.Ss Host Bridge Settings +.Bl -column "vendor" "integer" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va vendor Ta integer Ta 0x1275 Ta +PCI vendor ID. +.It Va device Ta integer Ta 0x1275 Ta +PCI device ID. +.El +.Ss AHCI Controller Settings +AHCI controller devices contain zero or more ports each of which +provides a storage device. +Each port stores its settings in a node named +.Dq port. Ns Va N +under the controller's device node. +The +.Va N +values are formatted as successive decimal values starting with 0. +In addition to the block device settings described above, each +port supports the following settings: +.Bl -column "model" "integer" "generated" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va type Ta string Ta Ta +The type of storage device to emulate. +Must be set to either +.Dq cd +or +.Dq hd . +.It Va nmrr Ta integer Ta 0 Ta +Nominal Media Rotation Rate, also known as RPM. +A value 1 of indicates a device with no rate such as a Solid State Disk. +.It Va ser Ta string Ta generated Ta +Serial number of up to twenty characters. +A default serial number is generated using a hash of the backing +store's pathname. +.It Va rev Ta string Ta 001 Ta +Revision number of up to eight characters. +.It Va model Ta string Ta Ta +Model number of up to forty characters. +Separate default model strings are used for +.Dq cd +and +.Dq hd +device types. +.El +.Ss e1000 Settings +In addition to the network backend settings, +Intel e82545 network interfaces support the following variables: +.Bl -column "Name" "MAC address" "generated" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va mac Ta MAC address Ta generated Ta +MAC address. +If an explicit address is not provided, +a MAC address is generated from a hash of the device's PCI address. +.El +.Ss Frame Buffer Settings +.Bl -column "password" "[IP:]port" "127.0.0.1:5900" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va wait Ta bool Ta false Ta +Wait for a remote connection before starting the VM. +.It Va rfb Ta Oo Ar IP Ns : Oc Ns Ar port Ta 127.0.0.1:5900 Ta +TCP address to listen on for remote connections. +The IP address must be given as a numeric address. +IPv6 addresses must be enclosed in square brackets and +support scoped identifiers as described in +.Xr getaddrinfo 3 . +A bare port number may be given in which case the IPv4 +localhost address is used. +.It Va vga Ta string Ta io Ta +VGA configuration. +More details are provided in +.Xr bhyve 8 . +.It Va w Ta integer Ta 1024 Ta +Frame buffer width in pixels. +.It Va h Ta integer Ta 768 Ta +Frame buffer height in pixels. +.It Va password Ta string Ta Ta +Password to use for VNC authentication. +This type of authentication is known to be cryptographically weak and is not +intended for use on untrusted networks. +.El +.Ss High Definition Audio Settings +.Bl -column "Name" "Format" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va play Ta path Ta Ta +Host playback device, +typically +.Pa /dev/dsp0 . +.It Va rec Ta path Ta Ta +Host recording device, +typically +.Pa /dev/dsp0 . +.El +.Ss LPC Device Settings +The LPC bridge stores its configuration under a top-level +.Va lpc +node rather than under the PCI LPC device's node. +The following nodes are available under +.Va lpc : +.Bl -column "pc-testdev" "Format" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va bootrom Ta path Ta Ta +Path to a boot ROM. +The contents of this file are copied into the guest's +memory ending just before the 4GB physical address. +If a boot ROM is present, a firmware interface device is +also enabled for use by the boot ROM. +.It Va com1 Ta node Ta Ta +Settings for the COM1 serial port device. +.It Va com2 Ta node Ta Ta +Settings for the COM2 serial port device. +.It Va com3 Ta node Ta Ta +Settings for the COM3 serial port device. +.It Va com4 Ta node Ta Ta +Settings for the COM4 serial port device. +.It Va pc-testdev Ta bool Ta false Ta +Enable the PC debug/test device. +.El +.Ss NVMe Controller Settings +Each NVMe controller supports a single storage device. +The device can be backed either by a memory disk described by the +.Va ram +variable, or a block device using the the block device settings described above. +In addition, each controller supports the following settings: +.Bl -column "ioslots" "Format" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va maxq Ta integer Ta 16 Ta +Maximum number of I/O submission and completion queue pairs. +.It Va qsz Ta integer Ta 2058 Ta +Number of elements in each I/O queue. +.It Va ioslots Ta integer Ta 8 Ta +Maximum number of concurrent I/O requests. +.It Va sectsz Ta integer Ta Ta +Sector size. +Can be one of 512, 4096, or 8192. +Devices backed by a memory disk use 4096 as the default. +Devices backed by a block device use the block device's sector size +as the default. +.It Va ser Ta string Ta Ta +Serial number of up to twenty characters. +A default serial number is generated using a hash of the device's PCI address. +.It Va eui64 Ta integer Ta Ta +IEEE Extended Unique Identifier. +If an EUI is not provided, a default is generated using a checksum of the +device's PCI address. +.It Va dsm Ta string Ta auto Ta +Whether or not to advertise DataSet Management support. +One of +.Dq auto , +.Dq enable , +or +.Dq disable . +The +.Dq auto +setting only advertises support if the backing store supports +resource freeing, for example via TRIM. +.It Va ram Ta integer Ta Ta +If set, allocate a memory disk as the backing store. +The value of this variable is the size of the memory disk in megabytes. +.El +.Ss PCI Passthrough Settings +.Bl -column "Name" "integer" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va bus Ta integer Ta Ta +Host PCI bus address of device to pass through. +.It Va slot Ta integer Ta Ta +Host PCI slot address of device to pass through. +.It Va func Ta integer Ta Ta +Host PCI function address of device to pass through. +.El +.Ss VirtIO 9p Settings +Each VirtIO 9p device exposes a single filesystem from a host path. +.Bl -column "sharename" "Format" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va sharename Ta string Ta Ta +The share name exposed to the guest. +.It Va path Ta path Ta Ta +The path of a directory on the host to export to the guest. +.It Va ro Ta bool Ta false Ta +If true, the guest filesystem is read-only. +.El +.Ss VirtIO Console Device Settings +Each VirtIO Console device contains one or more console ports. +Each port stores its settings in a node named +.Dq port. Ns Va N +under the controller's device node. +The +.Va N +values are formatted as successive decimal values starting with 0. +Each port supports the following settings: +.Bl -column "Name" "Format" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va name Ta string Ta Ta +The name of the port exposed to the guest. +.It Va path Ta path Ta Ta +The path of a UNIX domain socket providing the host connection for the port. +.El +.Ss VirtIO Network Interface Settings +In addition to the network backend settings, +VirtIO network interfaces support the following variables: +.Bl -column "Name" "MAC address" "generated" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va mac Ta MAC address Ta generated Ta +MAC address. +If an explicit address is not provided, +a MAC address is generated from a hash of the device's PCI address. +.It Va mtu Ta integer Ta 1500 Ta +The largest supported MTU advertised to the guest. +.El +.Ss VirtIO SCSI Settings +.Bl -column "Name" "integer" "Default" +.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va dev Ta path Ta Ta +The path of a CAM target layer (CTL) device to export: +.Pa /dev/cam/ctl Ns Oo Ar pp . Ns Ar vp Oc . +.It Va iid Ta integer Ta 0 Ta +Initiator ID to use when sending requests to the CTL port. +.El +.Sh SEE ALSO +.Xr expand_number 3 , +.Xr getaddrinfo 3 , +.Xr strtol 3 , +.Xr netgraph 4 , +.Xr netmap 4 , +.Xr ng_socket 4 , +.Xr tap 4 , +.Xr vale 4 , +.Xr vmnet 4 , +.Xr bhyve 8 diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index aafab4af8d8c..a3e6ef3c4724 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$"); #include "acpi.h" #include "atkbdc.h" #include "bootrom.h" +#include "config.h" #include "inout.h" #include "debug.h" #include "fwctl.h" @@ -183,26 +184,11 @@ static const char * const vmx_exit_reason_desc[] = { typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu); extern int vmexit_task_switch(struct vmctx *, struct vm_exit *, int *vcpu); -const char *vmname; - int guest_ncpus; uint16_t cores, maxcpus, sockets, threads; -char *guest_uuid_str; - int raw_stdio = 0; -static int gdb_port = 0; -static int guest_vmexit_on_hlt, guest_vmexit_on_pause; -static int virtio_msix = 1; -static int x2apic_mode = 0; /* default is xAPIC */ -static int destroy_on_poweroff = 0; - -static int strictio; -static int strictmsr = 1; - -static int acpi; - static char *progname; static const int BSP = 0; @@ -238,8 +224,8 @@ usage(int code) fprintf(stderr, "Usage: %s [-aehuwxACDHPSWY]\n" " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n" - " %*s [-l ]\n" - " %*s [-m mem] [-p vcpu:hostcpu] [-s ] [-U uuid] \n" + " %*s [-k ] [-l ] [-m mem] [-o =]\n" + " %*s [-p vcpu:hostcpu] [-s ] [-U uuid] []\n" " -a: local apic is in xAPIC mode (deprecated)\n" " -A: create ACPI tables\n" " -c: number of cpus and/or topology specification\n" @@ -248,13 +234,15 @@ usage(int code) " -e: exit on unhandled I/O access\n" " -h: help\n" " -H: vmexit from the guest on hlt\n" + " -k: key=value flat config file\n" " -l: LPC device configuration\n" " -m: memory size in MB\n" + " -o: set config 'var' to 'value'\n" + " -p: pin 'vcpu' to 'hostcpu'\n" + " -P: vmexit from the guest on pause\n" #ifdef BHYVE_SNAPSHOT " -r: path to checkpoint file\n" #endif - " -p: pin 'vcpu' to 'hostcpu'\n" - " -P: vmexit from the guest on pause\n" " -s: PCI slot config\n" " -S: guest memory cannot be swapped\n" " -u: RTC keeps UTC time\n" @@ -271,11 +259,8 @@ usage(int code) /* * XXX This parser is known to have the following issues: - * 1. It accepts null key=value tokens ",,". - * 2. It accepts whitespace after = and before value. - * 3. Values out of range of INT are silently wrapped. - * 4. It doesn't check non-final values. - * 5. The apparently bogus limits of UINT16_MAX are for future expansion. + * 1. It accepts null key=value tokens ",," as setting "cpus" to an + * empty string. * * The acceptance of a null specification ('-c ""') is by design to match the * manual page syntax specification, this results in a topology of 1 vCPU. @@ -283,83 +268,122 @@ usage(int code) static int topology_parse(const char *opt) { - uint64_t ncpus; - int c, chk, n, s, t, tmp; char *cp, *str; - bool ns, scts; - c = 1, n = 1, s = 1, t = 1; - ns = false, scts = false; + if (*opt == '\0') { + set_config_value("sockets", "1"); + set_config_value("cores", "1"); + set_config_value("threads", "1"); + set_config_value("cpus", "1"); + return (0); + } + str = strdup(opt); if (str == NULL) - goto out; + errx(4, "Failed to allocate memory"); while ((cp = strsep(&str, ",")) != NULL) { - if (sscanf(cp, "%i%n", &tmp, &chk) == 1) { - n = tmp; - ns = true; - } else if (sscanf(cp, "cpus=%i%n", &tmp, &chk) == 1) { - n = tmp; - ns = true; - } else if (sscanf(cp, "sockets=%i%n", &tmp, &chk) == 1) { - s = tmp; - scts = true; - } else if (sscanf(cp, "cores=%i%n", &tmp, &chk) == 1) { - c = tmp; - scts = true; - } else if (sscanf(cp, "threads=%i%n", &tmp, &chk) == 1) { - t = tmp; - scts = true; + if (strncmp(cp, "cpus=", strlen("cpus=")) == 0) + set_config_value("cpus", cp + strlen("cpus=")); + else if (strncmp(cp, "sockets=", strlen("sockets=")) == 0) + set_config_value("sockets", cp + strlen("sockets=")); + else if (strncmp(cp, "cores=", strlen("cores=")) == 0) + set_config_value("cores", cp + strlen("cores=")); + else if (strncmp(cp, "threads=", strlen("threads=")) == 0) + set_config_value("threads", cp + strlen("threads=")); #ifdef notyet /* Do not expose this until vmm.ko implements it */ - } else if (sscanf(cp, "maxcpus=%i%n", &tmp, &chk) == 1) { - m = tmp; + else if (strncmp(cp, "maxcpus=", strlen("maxcpus=")) == 0) + set_config_value("maxcpus", cp + strlen("maxcpus=")); #endif - /* Skip the empty argument case from -c "" */ - } else if (cp[0] == '\0') - continue; - else - goto out; - /* Any trailing garbage causes an error */ - if (cp[chk] != '\0') + else if (strchr(cp, '=') != NULL) goto out; + else + set_config_value("cpus", cp); } free(str); - str = NULL; - - /* - * Range check 1 <= n <= UINT16_MAX all values - */ *** 4875 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB8C165D40B; Wed, 11 Aug 2021 22:14: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 4GlPHV60BDz4f7c; Wed, 11 Aug 2021 22:14: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 A6A7D172C5; Wed, 11 Aug 2021 22:14: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 17BMEEe1013829; Wed, 11 Aug 2021 22:14:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMEEiQ013828; Wed, 11 Aug 2021 22:14:14 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:14 GMT Message-Id: <202108112214.17BMEEiQ013828@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 2b2d263d0b7a - stable/13 - bhyve: Enable virtio-scsi legacy config parsing. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2b2d263d0b7aa338af7171d308228ad9cb3acc70 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:15 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=2b2d263d0b7aa338af7171d308228ad9cb3acc70 commit 2b2d263d0b7aa338af7171d308228ad9cb3acc70 Author: John Baldwin AuthorDate: 2021-03-29 17:25:45 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:12:32 +0000 bhyve: Enable virtio-scsi legacy config parsing. The previous commit added the handler to parse the command line options for virtio-scsi devices but forgot to set the correct function pointer to point to the handler. Reported by: vangyzen Reviewed by: vangyzen Fixes: 621b5090487de9fed1b503769702a9a2a27cc7bb Differential Revision: https://reviews.freebsd.org/D29438 (cherry picked from commit 4d5460a720c59a4404eb1df1b768d2f16b2f341a) --- usr.sbin/bhyve/pci_virtio_scsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index bd688d0325ef..8314b4afce38 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -739,6 +739,7 @@ pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) struct pci_devemu pci_de_vscsi = { .pe_emu = "virtio-scsi", .pe_init = pci_vtscsi_init, + .pe_legacy_config = pci_vtscsi_legacy_config, .pe_barwrite = vi_pci_write, .pe_barread = vi_pci_read }; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B3DA65CEF7; Wed, 11 Aug 2021 22:14: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 4GlPHX0NJ2z4f9w; Wed, 11 Aug 2021 22:14: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 BEB7A17333; Wed, 11 Aug 2021 22:14: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 17BMEFIr013853; Wed, 11 Aug 2021 22:14:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMEFWI013852; Wed, 11 Aug 2021 22:14:15 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:15 GMT Message-Id: <202108112214.17BMEFWI013852@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 30519e53dbad - stable/13 - Fix typo in xhci nvlist node name, and also increment device counter. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 30519e53dbad93a4d316a1b7d779dde26806a4d6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:16 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=30519e53dbad93a4d316a1b7d779dde26806a4d6 commit 30519e53dbad93a4d316a1b7d779dde26806a4d6 Author: Peter Grehan AuthorDate: 2021-04-03 04:32:54 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:12:38 +0000 Fix typo in xhci nvlist node name, and also increment device counter. This allows the xhci tablet device to be recognized and a PCI device instantiated. Reviewed by: jhb Fixes: 621b5090487d Refactor configuration management in bhyve. MFC after: 3 months. (cherry picked from commit ab899f8937c1c7c79197baf7192b727ddc9cfe54) --- usr.sbin/bhyve/pci_xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c index dd6dfc39d014..b71d66337048 100644 --- a/usr.sbin/bhyve/pci_xhci.c +++ b/usr.sbin/bhyve/pci_xhci.c @@ -2720,7 +2720,7 @@ pci_xhci_parse_devices(struct pci_xhci_softc *sc, nvlist_t *nvl) ndevices = 0; - slots_nvl = find_relative_config_node(nvl, "slots"); + slots_nvl = find_relative_config_node(nvl, "slot"); if (slots_nvl == NULL) goto portsfinal; @@ -2806,6 +2806,7 @@ pci_xhci_parse_devices(struct pci_xhci_softc *sc, nvlist_t *nvl) dev->dev_sc = devsc; XHCI_SLOTDEV_PTR(sc, slot) = dev; + ndevices++; } portsfinal: From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A6FF265D408; Wed, 11 Aug 2021 22:14: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 4GlPHT49J7z4f9n; Wed, 11 Aug 2021 22:14: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 7682F16FE5; Wed, 11 Aug 2021 22:14: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 17BMED02013805; Wed, 11 Aug 2021 22:14:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMEDNx013804; Wed, 11 Aug 2021 22:14:13 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:13 GMT Message-Id: <202108112214.17BMEDNx013804@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: f08d1570fa76 - stable/13 - bhyve hostbridge: Rename "device" property to "devid". MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f08d1570fa760e98d82ec209a948a42dc49ab0da Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:13 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f08d1570fa760e98d82ec209a948a42dc49ab0da commit f08d1570fa760e98d82ec209a948a42dc49ab0da Author: John Baldwin AuthorDate: 2021-03-24 16:29:15 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:12:23 +0000 bhyve hostbridge: Rename "device" property to "devid". "device" is already used as the generic PCI-level name of the device model to use (e.g. "hostbridge"). The result was that parsing "hostbridge" as an integer failed and the host bridge used a device ID of 0. The EFI ROM asserts that the device ID of the hostbridge is not 0, so booting with the current EFI ROM was failing during the ROM boot. Fixes: 621b5090487de9fed1b503769702a9a2a27cc7bb (cherry picked from commit 9f40a3be3d5dbddf782c3d1eeaadcd022a4dad01) --- usr.sbin/bhyve/bhyve_config.5 | 4 ++-- usr.sbin/bhyve/pci_hostbridge.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 index 4e200a779d50..d65040513cb0 100644 --- a/usr.sbin/bhyve/bhyve_config.5 +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 18, 2021 +.Dd March 24, 2021 .Dt BHYVE_CONFIG 5 .Os .Sh NAME @@ -335,7 +335,7 @@ process. .It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description .It Va vendor Ta integer Ta 0x1275 Ta PCI vendor ID. -.It Va device Ta integer Ta 0x1275 Ta +.It Va devid Ta integer Ta 0x1275 Ta PCI device ID. .El .Ss AHCI Controller Settings diff --git a/usr.sbin/bhyve/pci_hostbridge.c b/usr.sbin/bhyve/pci_hostbridge.c index 7099474eaf92..9fce225bb1d6 100644 --- a/usr.sbin/bhyve/pci_hostbridge.c +++ b/usr.sbin/bhyve/pci_hostbridge.c @@ -48,7 +48,7 @@ pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) value = get_config_value_node(nvl, "vendor"); if (value != NULL) vendor = strtol(value, NULL, 0); - value = get_config_value_node(nvl, "device"); + value = get_config_value_node(nvl, "devid"); if (value != NULL) device = strtol(value, NULL, 0); @@ -69,7 +69,7 @@ pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts) { set_config_value_node(nvl, "vendor", "0x1022"); /* AMD */ - set_config_value_node(nvl, "device", "0x7432"); /* made up */ + set_config_value_node(nvl, "devid", "0x7432"); /* made up */ return (0); } From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4658865D07D; Wed, 11 Aug 2021 22:14: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 4GlPHY0Q0dz4f5W; Wed, 11 Aug 2021 22:14: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 E038B17503; Wed, 11 Aug 2021 22:14: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 17BMEGbH013877; Wed, 11 Aug 2021 22:14:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMEG8u013876; Wed, 11 Aug 2021 22:14:16 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:16 GMT Message-Id: <202108112214.17BMEG8u013876@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 001f3d25518c - stable/13 - bhyve: fix regression in legacy virtio-9p config parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 001f3d25518c9179136629abf5ab42cab58c9347 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:17 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=001f3d25518c9179136629abf5ab42cab58c9347 commit 001f3d25518c9179136629abf5ab42cab58c9347 Author: Roman Bogorodskiy AuthorDate: 2021-04-08 14:44:58 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:12:42 +0000 bhyve: fix regression in legacy virtio-9p config parsing Commit 621b5090487de9fed1b503769702a9a2a27cc7bb introduced a regression in legacy virtio-9p config parsing by not initializing *sharename to NULL. As a result, "sharename != NULL" check in the first iteration fails and bhyve exits with "virtio-9p: more than one share name given". Fix by adding NULL back. Approved by: grehan (cherry picked from commit f2ecc0d1b7d569b4b2c930c7450390c04778ee8a) --- usr.sbin/bhyve/pci_virtio_9p.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index 10023158f8bd..6c6dc483b7ba 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -232,7 +232,7 @@ pci_vt9p_notify(void *vsc, struct vqueue_info *vq) static int pci_vt9p_legacy_config(nvlist_t *nvl, const char *opts) { - char *sharename, *tofree, *token, *tokens; + char *sharename = NULL, *tofree, *token, *tokens; if (opts == NULL) return (0); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 643C465D587; Wed, 11 Aug 2021 22:14: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 4GlPHZ1V5cz4f3h; Wed, 11 Aug 2021 22:14: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 14736172C6; Wed, 11 Aug 2021 22:14: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 17BMEHVs013901; Wed, 11 Aug 2021 22:14:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMEH7j013900; Wed, 11 Aug 2021 22:14:17 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:17 GMT Message-Id: <202108112214.17BMEH7j013900@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 77e736186d8f - stable/13 - bhyve: Move the gdb_active check to gdb_cpu_suspend(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 77e736186d8f13246f886164c3e934a34f00af87 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:18 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=77e736186d8f13246f886164c3e934a34f00af87 commit 77e736186d8f13246f886164c3e934a34f00af87 Author: John Baldwin AuthorDate: 2021-04-12 18:43:34 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:12:47 +0000 bhyve: Move the gdb_active check to gdb_cpu_suspend(). The check needs to be in the public routine (gdb_cpu_suspend()), not in the internal routine called from various places (_gdb_cpu_suspend()). All the other callers of _gdb_cpu_suspend() already check gdb_active, and this breaks the use of snapshots when the debug server is not enabled since gdb_cpu_suspend() tries to lock an uninitialized mutex. Reported by: Darius Mihai, Elena Mihailescu Reviewed by: elenamihailescu22_gmail.com Fixes: 621b5090487de9fed1b503769702a9a2a27cc7bb Differential Revision: https://reviews.freebsd.org/D29538 (cherry picked from commit eacc27affeff17beb3791793ba54458444df7135) --- usr.sbin/bhyve/gdb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index 3bff62418840..219d192b7c9a 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -731,8 +731,6 @@ static void _gdb_cpu_suspend(int vcpu, bool report_stop) { - if (!gdb_active) - return; debug("$vCPU %d suspending\n", vcpu); CPU_SET(vcpu, &vcpus_waiting); if (report_stop && CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0) @@ -807,6 +805,8 @@ void gdb_cpu_suspend(int vcpu) { + if (!gdb_active) + return; pthread_mutex_lock(&gdb_lock); _gdb_cpu_suspend(vcpu, true); gdb_cpu_resume(vcpu); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B679665D41A; Wed, 11 Aug 2021 22:14:19 +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 4GlPHb2nhXz4ds7; Wed, 11 Aug 2021 22:14: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 33C4217498; Wed, 11 Aug 2021 22:14: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 17BMEJ2e013931; Wed, 11 Aug 2021 22:14:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMEJ9L013930; Wed, 11 Aug 2021 22:14:19 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:19 GMT Message-Id: <202108112214.17BMEJ9L013930@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 81c33f22216b - stable/13 - bhyve: Be explicit that setting config.dump will not start a VM. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 81c33f22216b8dd2bd4bffc7dcdd52d4c5d9a5ff Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:19 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=81c33f22216b8dd2bd4bffc7dcdd52d4c5d9a5ff commit 81c33f22216b8dd2bd4bffc7dcdd52d4c5d9a5ff Author: John Baldwin AuthorDate: 2021-04-20 20:33:28 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:12:57 +0000 bhyve: Be explicit that setting config.dump will not start a VM. Suggested by: rpokala Reviewed by: bcr (manpages) Differential Revision: https://reviews.freebsd.org/D29738 (cherry picked from commit e15bf05e0abcf4435a09edb8ff8d7e38d1508bb2) --- usr.sbin/bhyve/bhyve_config.5 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 index d65040513cb0..1a77b1bbacb4 100644 --- a/usr.sbin/bhyve/bhyve_config.5 +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 24, 2021 +.Dd April 20, 2021 .Dt BHYVE_CONFIG 5 .Os .Sh NAME @@ -143,11 +143,13 @@ the host's hostname and the VM name. Use MSI-X interrupts for PCI VirtIO devices. If set to false, MSI interrupts are used instead. .It Va config.dump Ta bool Ta false Ta -If this value is set to true, +If this value is set to true after +.Xr bhyve 8 +has finished parsing command line options, then .Xr bhyve 8 -will write all of its configuration variables to stdout and exit -after it has finished parsing command line options. +will write all of its configuration variables to stdout and exit. +No VM will be started. .El .Ss x86-Specific Settings .Bl -column "x86.vmexit_on_pause" "integer" "Default" From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2C24465D51D; Wed, 11 Aug 2021 22:14: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 4GlPHd4DWkz4f1Q; Wed, 11 Aug 2021 22:14: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 77FEB16FE6; Wed, 11 Aug 2021 22:14: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 17BMELZc013979; Wed, 11 Aug 2021 22:14:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMELZB013978; Wed, 11 Aug 2021 22:14:21 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:21 GMT Message-Id: <202108112214.17BMELZB013978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 704d90845ce2 - stable/13 - bhyve: Fix cli regression with NVMe ram MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 704d90845ce2364b75a97aa69bc687d2cd9e236d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:22 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=704d90845ce2364b75a97aa69bc687d2cd9e236d commit 704d90845ce2364b75a97aa69bc687d2cd9e236d Author: Chuck Tuffli AuthorDate: 2021-06-15 13:59:02 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:13:04 +0000 bhyve: Fix cli regression with NVMe ram The configuration management refactoring inadvertently removed support for a RAM-backed NVMe Namespace (i.e. -s X,nvme,ram=16384). This adds it back. Reported by: andy@omniosce.org Reviewed by: jhb, andy@omniosce.org Fixes: 621b5090487d MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30717 (cherry picked from commit 3a4ab18377c86c4588d79c4ca91fe8f4530dc90c) --- usr.sbin/bhyve/pci_nvme.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index adf49e1ff61f..9b3fece43fde 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -2800,11 +2800,32 @@ done: return (error); } +static int +pci_nvme_legacy_config(nvlist_t *nvl, const char *opts) +{ + char *cp, *ram; + + if (opts == NULL) + return (0); + + if (strncmp(opts, "ram=", 4) == 0) { + cp = strchr(opts, ','); + if (cp == NULL) { + set_config_value_node(nvl, "ram", opts + 4); + return (0); + } + ram = strndup(opts + 4, cp - opts - 4); + set_config_value_node(nvl, "ram", ram); + free(ram); + return (pci_parse_legacy_config(nvl, cp + 1)); + } else + return (blockif_legacy_config(nvl, opts)); +} struct pci_devemu pci_de_nvme = { .pe_emu = "nvme", .pe_init = pci_nvme_init, - .pe_legacy_config = blockif_legacy_config, + .pe_legacy_config = pci_nvme_legacy_config, .pe_barwrite = pci_nvme_write, .pe_barread = pci_nvme_read }; From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:14:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 95CE765CF7D; Wed, 11 Aug 2021 22:14: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 4GlPHc3bJSz4f85; Wed, 11 Aug 2021 22:14: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 53F22172C7; Wed, 11 Aug 2021 22:14: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 17BMEK7H013955; Wed, 11 Aug 2021 22:14:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BMEKmk013954; Wed, 11 Aug 2021 22:14:20 GMT (envelope-from git) Date: Wed, 11 Aug 2021 22:14:20 GMT Message-Id: <202108112214.17BMEKmk013954@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: b1a2ffd650c0 - stable/13 - bhyve: Gracefully handle virtio-scsi with no conf MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b1a2ffd650c0b85d7df97d61869d7e598b81f477 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:14:20 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b1a2ffd650c0b85d7df97d61869d7e598b81f477 commit b1a2ffd650c0b85d7df97d61869d7e598b81f477 Author: Ryan Moeller AuthorDate: 2021-04-22 16:06:08 +0000 Commit: John Baldwin CommitDate: 2021-08-11 22:13:00 +0000 bhyve: Gracefully handle virtio-scsi with no conf Fixes segfault with the command `bhyve -s 0,virtio-scsi`, which is used by some third party software to probe bhyve for virtio-scsi support. Reviewed by: jhb MFC after: 1 day Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D29926 (cherry picked from commit 89c3c32647a5099b297af2958e5a939eff0c0ce0) --- usr.sbin/bhyve/pci_virtio_scsi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index 8314b4afce38..33cf67bef12c 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -670,6 +670,9 @@ pci_vtscsi_legacy_config(nvlist_t *nvl, const char *opts) { char *cp, *devname; + if (opts == NULL) + return (0); + cp = strchr(opts, ','); if (cp == NULL) { set_config_value_node(nvl, "dev", opts); From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:31:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8326C65DC2F; Wed, 11 Aug 2021 22:31:44 +0000 (UTC) (envelope-from loos.br@gmail.com) Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) (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 4GlPgh32SYz4gW5; Wed, 11 Aug 2021 22:31:44 +0000 (UTC) (envelope-from loos.br@gmail.com) Received: by mail-qk1-x730.google.com with SMTP id w197so4294693qkb.1; Wed, 11 Aug 2021 15:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y3inyOdz+CZvfBR3bMYZj/d/IL7aDNBNpL8a76JFhwg=; b=Fgid74aCtibd1WSDOsEyDxr1jI0xcHeRMC0z48RomzVU3Kkr1DqYLLSzB1WbRCcu40 8qC6Dqh51BH/fs9BKrjjH7zEvvFWmAN+N90hO2eHb/GaFamRpll018DT+1I54e8VGmkX 5ZQbidVmISDXhnwPfFmDrymxD1obsM6Gf/yfa6x6ZkVl4kelEzjnIKXA2SCJ8s1UFnUe W0P25WWcwpQwqgCYG/WaVBck2BxQ0FeYu6ol5WSq5GNsKn0E1fM5hIAEWf6MWmePwXme qshvRbIsv9clideHoi5Gm5xn5HDDzrBRQ4UzcLkAY0VBWhQcVTWpbRI32IJrWL4as9j4 8cwA== 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:to:cc; bh=y3inyOdz+CZvfBR3bMYZj/d/IL7aDNBNpL8a76JFhwg=; b=XeNI+BvKXrjtBGGDbUTwgibB+Xl3P1ZhNL44ypjdCTx3KndEpBprfdeVsnEwHCwuOY Tf9qHSqAf5RJd+oxpFK+ctBd4MFdTLWbOJp898K1mVSwbuTAgwvYbrWv5BwVc9ScbwL2 OL4YLW8wCEMbyyCIcDmdkTyb45jgLb8/0CTRtfrj3ZqerY6CajBpl+DN8SyltxCLq+83 DbRZh23ioXsA1vnLGv8ni4apyIfCvmb9+CAdzP1z2LCMublw5l3UNTuHbIBTtAm5H52Z WIxxpcdrHyvLDJiUYenqmMA8h1dgbtPW50VntdP9H9brzwQfP4kkGBGWX39JBtMtqgcx iKZg== X-Gm-Message-State: AOAM531QoIhOnuUgyq3VY115G9mco6xiKEAgu0Tt1awQYN4scZWQWB8L YCvFJ9u6+jWxs7alf9PyOoSnUvMT9rRRKOPtIbnLbytBxFc= X-Google-Smtp-Source: ABdhPJwA1NT9HU1JY1tpR7V04HKZ32axm8HqChz9Zx7M/oxwfqsluRbFQ2lseN6ofM/dYzer9zqDAhf9LPCYEDX7gMU= X-Received: by 2002:a05:620a:49c:: with SMTP id 28mr1351290qkr.389.1628721103821; Wed, 11 Aug 2021 15:31:43 -0700 (PDT) MIME-Version: 1.0 References: <202108102241.17AMfr63025604@gitrepo.freebsd.org> <9b1ec22c-1545-52ea-7bf9-a96140737711@FreeBSD.org> In-Reply-To: From: Luiz Otavio O Souza Date: Wed, 11 Aug 2021 19:31:32 -0300 Message-ID: Subject: Re: git: 35547df5c786 - main - Call wakeup() with the lock held to avoid missed wakeup races. To: John Baldwin Cc: Scott Long , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4GlPgh32SYz4gW5 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_FROM(0.00)[]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:31:44 -0000 On Wed, Aug 11, 2021 at 7:03 PM John Baldwin wrote: > > On 8/11/21 2:38 PM, Luiz Otavio O Souza wrote: > > On Wed, Aug 11, 2021 at 3:49 PM John Baldwin wrote: > >> > >> On 8/10/21 3:41 PM, Scott Long wrote: > >>> The branch main has been updated by scottl: > >>> > >>> URL: https://cgit.FreeBSD.org/src/commit/?id=35547df5c78653b2da030f920323c0357056099f > >>> > >>> commit 35547df5c78653b2da030f920323c0357056099f > >>> Author: Scott Long > >>> AuthorDate: 2021-08-10 22:36:38 +0000 > >>> Commit: Scott Long > >>> CommitDate: 2021-08-10 22:36:38 +0000 > >>> > >>> Call wakeup() with the lock held to avoid missed wakeup races. > >>> > >>> Submitted by: luiz > >>> Sponsored by: Rubicon Communications, LLC ("Netgate") > >>> --- > >>> sys/dev/sdhci/sdhci.c | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c > >>> index d075c2e05000..573e6949b57e 100644 > >>> --- a/sys/dev/sdhci/sdhci.c > >>> +++ b/sys/dev/sdhci/sdhci.c > >>> @@ -2078,8 +2078,8 @@ sdhci_generic_release_host(device_t brdev __unused, device_t reqdev) > >>> /* Deactivate led. */ > >>> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl &= ~SDHCI_CTRL_LED); > >>> slot->bus_busy--; > >>> - SDHCI_UNLOCK(slot); > >>> wakeup(slot); > >>> + SDHCI_UNLOCK(slot); > >>> return (0); > >>> } > >> > >> Hmm, how does this avoid a race? The sleep is checking bus_busy under > >> the lock and should never see a stale value and go back to sleep after > >> the wakeup has occurred: > >> > >> SDHCI_LOCK(slot); > >> while (slot->bus_busy) > >> msleep(slot, &slot->mtx, 0, "sdhciah", 0); > >> slot->bus_busy++; > >> /* Activate led. */ > >> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl |= SDHCI_CTRL_LED); > >> SDHCI_UNLOCK(slot); > >> > >> Dropping the lock before wakeup() is a tiny optimization that avoids > >> having the second thread wakeup and immediately block on the lock before > >> it has been released by the first thread. > >> > > > > 'race' is probably wrong here. this change will prevent a second > > thread from taking the bus before you call wakeup() - poking all other > > threads unnecessarily. > > This change does not prevent that. The other thread and the thread that > are awakened will race with each other to acquire the lock. wakeup() > doesn't do any sort of explicit lock handoff to the thread being awakened > and it's just as likely for a thread not yet asleep to acquire the lock as > for the thread being awakened to acquire the lock. If you have observed > thundering herd problems with this wakeup() then you might want to change > it to wakeup_one(). correct, but to be more specific, on the first thread, after you free the bus and release the lock, a new thread can run, successfully acquire the lock and grab the bus. at this point the first thread resumes and call wakeup(). when that happens, the new thread always wins, the threads being awakened won't have a chance. luiz From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:42:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9DD1D65DE9D; Wed, 11 Aug 2021 22:42:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlPvx40kCz4h0b; Wed, 11 Aug 2021 22:42:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id E1FD4CD87; Wed, 11 Aug 2021 22:42:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: Luiz Otavio O Souza Cc: Scott Long , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202108102241.17AMfr63025604@gitrepo.freebsd.org> <9b1ec22c-1545-52ea-7bf9-a96140737711@FreeBSD.org> From: John Baldwin Subject: Re: git: 35547df5c786 - main - Call wakeup() with the lock held to avoid missed wakeup races. Message-ID: <9587664b-5c82-cbe2-fb13-6de6abb9843d@FreeBSD.org> Date: Wed, 11 Aug 2021 15:42:20 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:42:21 -0000 On 8/11/21 3:31 PM, Luiz Otavio O Souza wrote: > On Wed, Aug 11, 2021 at 7:03 PM John Baldwin wrote: >> >> On 8/11/21 2:38 PM, Luiz Otavio O Souza wrote: >>> On Wed, Aug 11, 2021 at 3:49 PM John Baldwin wrote: >>>> >>>> On 8/10/21 3:41 PM, Scott Long wrote: >>>>> The branch main has been updated by scottl: >>>>> >>>>> URL: https://cgit.FreeBSD.org/src/commit/?id=35547df5c78653b2da030f920323c0357056099f >>>>> >>>>> commit 35547df5c78653b2da030f920323c0357056099f >>>>> Author: Scott Long >>>>> AuthorDate: 2021-08-10 22:36:38 +0000 >>>>> Commit: Scott Long >>>>> CommitDate: 2021-08-10 22:36:38 +0000 >>>>> >>>>> Call wakeup() with the lock held to avoid missed wakeup races. >>>>> >>>>> Submitted by: luiz >>>>> Sponsored by: Rubicon Communications, LLC ("Netgate") >>>>> --- >>>>> sys/dev/sdhci/sdhci.c | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c >>>>> index d075c2e05000..573e6949b57e 100644 >>>>> --- a/sys/dev/sdhci/sdhci.c >>>>> +++ b/sys/dev/sdhci/sdhci.c >>>>> @@ -2078,8 +2078,8 @@ sdhci_generic_release_host(device_t brdev __unused, device_t reqdev) >>>>> /* Deactivate led. */ >>>>> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl &= ~SDHCI_CTRL_LED); >>>>> slot->bus_busy--; >>>>> - SDHCI_UNLOCK(slot); >>>>> wakeup(slot); >>>>> + SDHCI_UNLOCK(slot); >>>>> return (0); >>>>> } >>>> >>>> Hmm, how does this avoid a race? The sleep is checking bus_busy under >>>> the lock and should never see a stale value and go back to sleep after >>>> the wakeup has occurred: >>>> >>>> SDHCI_LOCK(slot); >>>> while (slot->bus_busy) >>>> msleep(slot, &slot->mtx, 0, "sdhciah", 0); >>>> slot->bus_busy++; >>>> /* Activate led. */ >>>> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl |= SDHCI_CTRL_LED); >>>> SDHCI_UNLOCK(slot); >>>> >>>> Dropping the lock before wakeup() is a tiny optimization that avoids >>>> having the second thread wakeup and immediately block on the lock before >>>> it has been released by the first thread. >>>> >>> >>> 'race' is probably wrong here. this change will prevent a second >>> thread from taking the bus before you call wakeup() - poking all other >>> threads unnecessarily. >> >> This change does not prevent that. The other thread and the thread that >> are awakened will race with each other to acquire the lock. wakeup() >> doesn't do any sort of explicit lock handoff to the thread being awakened >> and it's just as likely for a thread not yet asleep to acquire the lock as >> for the thread being awakened to acquire the lock. If you have observed >> thundering herd problems with this wakeup() then you might want to change >> it to wakeup_one(). > > correct, but to be more specific, on the first thread, after you free > the bus and release the lock, a new thread can run, successfully > acquire the lock and grab the bus. at this point the first thread > resumes and call wakeup(). when that happens, the new thread always > wins, the threads being awakened won't have a chance. Perhaps on a uniprocessor system this might be true, but otherwise your new thread is likely spinning adaptively on the lock on another CPU and grabs it as soon as it is released before the thread awakened by wakeup() is even scheduled on a CPU and given a chance to run. That is, I suspect the new thread always wins even with this change on any multiprocessor system, but it now has to wait a bit longer before it wins. Have you observed some specific behavior with traces that this change seeks to address? -- John Baldwin From owner-dev-commits-src-all@freebsd.org Wed Aug 11 22:50:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8C64465E104; Wed, 11 Aug 2021 22:50:25 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.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 mx1.freebsd.org (Postfix) with ESMTPS id 4GlQ5F2VSrz4h1Q; Wed, 11 Aug 2021 22:50:25 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 2A5873200916; Wed, 11 Aug 2021 18:50:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 11 Aug 2021 18:50:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:content-transfer-encoding:from:mime-version:subject :date:message-id:references:cc:in-reply-to:to; s=fm1; bh=bma5HVC 7MvaQRIzPhd6v4gyq1q4TO3YFqa8xq2Lsb08=; b=V1ZIeQq8BIEkYvyWVE2Z5VB 2rv5UVFMcWDCIF03y+n7SOK5vKos9RkWkzlheNNPRtza0KEDLM0myvHnQNYFy4k9 OBxV8IimNKv9TlxgTbBRnxwf8JyFLs3HGFMiGRNTjNIZ2Zip7jR3dzoVwn0r8aPc n5Lgl3cL/LmYLEGa+h28lLR2owd38NEgnWIvGB9xYJYkH6uwLF3wflljzSKGVllF R/Ov/iOOEhnEpGU+iyOGb4oskrw8RAoLcqgkAkrQwW1ibrOXWvpZo8wCxtNFOsMV awzLYEzbs/nhrmc4hTDU9jLobNH221zq8R97B3Y6b9YczBG9/vQNEOl2A3hoINw= = DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=bma5HVC7MvaQRIzPhd6v4gyq1q4TO3YFqa8xq2Lsb 08=; b=rBHlTKlxqSxCelTs/OO6OZBzPPq84zdzaU/d6WMxFAmuh2PIMfxYtyHqM GT9BLLQucYk0meoEl78rM4HFPJr7oV6A0+d74p1W5HaF+nWMbk+65neKiRjIt7Pz p6Dl3bPsrSpOt9VFG2sOUNWk4q81+TAC4z2dLHLKSu1ph0HPccWbeKPafzC6P6QB 5XRtdQnyIRad39VmZF94+mj+GrhOYpB19qrcaSpOpKyXpEWDi7Nmnxcvi19MnSoM Xc3/JkzXVgwakX+gDFAFOgGcdOOKfan/K0eX/6vHD7YvQ5mLFLABoMe3jCe+TdOB OZ8qUf5iFaz7P59k3kcESbgRVwKnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrkedvgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurheptgfghfggufffkfhfjgfvofesthhqmh dthhdtjeenucfhrhhomhepufgtohhtthcunfhonhhguceoshgtohhtthhlsehsrghmshgt ohdrohhrgheqnecuggftrfgrthhtvghrnhepfeevgfevveettdekhfduueduhefgieejtd elgeehieeuuefgueekffejtdeftdehnecuffhomhgrihhnpehfrhgvvggsshgurdhorhhg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgtoh htthhlsehsrghmshgtohdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Aug 2021 18:50:17 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Scott Long Mime-Version: 1.0 (1.0) Subject: Re: git: 35547df5c786 - main - Call wakeup() with the lock held to avoid missed wakeup races. Date: Wed, 11 Aug 2021 16:50:15 -0600 Message-Id: <8FB57A36-8D3B-4B7B-8397-6D742694DD75@samsco.org> References: <9587664b-5c82-cbe2-fb13-6de6abb9843d@FreeBSD.org> Cc: Luiz Otavio O Souza , Scott Long , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org In-Reply-To: <9587664b-5c82-cbe2-fb13-6de6abb9843d@FreeBSD.org> To: John Baldwin X-Mailer: iPhone Mail (18G82) X-Rspamd-Queue-Id: 4GlQ5F2VSrz4h1Q X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 22:50:25 -0000 > On Aug 11, 2021, at 4:42 PM, John Baldwin wrote: >=20 > =EF=BB=BFOn 8/11/21 3:31 PM, Luiz Otavio O Souza wrote: >>> On Wed, Aug 11, 2021 at 7:03 PM John Baldwin wrote: >>>=20 >>> On 8/11/21 2:38 PM, Luiz Otavio O Souza wrote: >>>> On Wed, Aug 11, 2021 at 3:49 PM John Baldwin wrote: >>>>>=20 >>>>> On 8/10/21 3:41 PM, Scott Long wrote: >>>>>> The branch main has been updated by scottl: >>>>>>=20 >>>>>> URL: https://cgit.FreeBSD.org/src/commit/?id=3D35547df5c78653b2da030f= 920323c0357056099f >>>>>>=20 >>>>>> commit 35547df5c78653b2da030f920323c0357056099f >>>>>> Author: Scott Long >>>>>> AuthorDate: 2021-08-10 22:36:38 +0000 >>>>>> Commit: Scott Long >>>>>> CommitDate: 2021-08-10 22:36:38 +0000 >>>>>>=20 >>>>>> Call wakeup() with the lock held to avoid missed wakeup races. >>>>>>=20 >>>>>> Submitted by: luiz >>>>>> Sponsored by: Rubicon Communications, LLC ("Netgate") >>>>>> --- >>>>>> sys/dev/sdhci/sdhci.c | 2 +- >>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>>>=20 >>>>>> diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c >>>>>> index d075c2e05000..573e6949b57e 100644 >>>>>> --- a/sys/dev/sdhci/sdhci.c >>>>>> +++ b/sys/dev/sdhci/sdhci.c >>>>>> @@ -2078,8 +2078,8 @@ sdhci_generic_release_host(device_t brdev __unu= sed, device_t reqdev) >>>>>> /* Deactivate led. */ >>>>>> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl &=3D ~SDHCI_CTRL_= LED); >>>>>> slot->bus_busy--; >>>>>> - SDHCI_UNLOCK(slot); >>>>>> wakeup(slot); >>>>>> + SDHCI_UNLOCK(slot); >>>>>> return (0); >>>>>> } >>>>>=20 >>>>> Hmm, how does this avoid a race? The sleep is checking bus_busy under= >>>>> the lock and should never see a stale value and go back to sleep after= >>>>> the wakeup has occurred: >>>>>=20 >>>>> SDHCI_LOCK(slot); >>>>> while (slot->bus_busy) >>>>> msleep(slot, &slot->mtx, 0, "sdhciah", 0); >>>>> slot->bus_busy++; >>>>> /* Activate led. */ >>>>> WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl |=3D SDHCI_CTRL_= LED); >>>>> SDHCI_UNLOCK(slot); >>>>>=20 >>>>> Dropping the lock before wakeup() is a tiny optimization that avoids >>>>> having the second thread wakeup and immediately block on the lock befo= re >>>>> it has been released by the first thread. >>>>>=20 >>>>=20 >>>> 'race' is probably wrong here. this change will prevent a second >>>> thread from taking the bus before you call wakeup() - poking all other >>>> threads unnecessarily. >>>=20 >>> This change does not prevent that. The other thread and the thread that= >>> are awakened will race with each other to acquire the lock. wakeup() >>> doesn't do any sort of explicit lock handoff to the thread being awakene= d >>> and it's just as likely for a thread not yet asleep to acquire the lock a= s >>> for the thread being awakened to acquire the lock. If you have observed= >>> thundering herd problems with this wakeup() then you might want to chang= e >>> it to wakeup_one(). >> correct, but to be more specific, on the first thread, after you free >> the bus and release the lock, a new thread can run, successfully >> acquire the lock and grab the bus. at this point the first thread >> resumes and call wakeup(). when that happens, the new thread always >> wins, the threads being awakened won't have a chance. >=20 > Perhaps on a uniprocessor system this might be true, but otherwise > your new thread is likely spinning adaptively on the lock on another > CPU and grabs it as soon as it is released before the thread awakened by > wakeup() is even scheduled on a CPU and given a chance to run. That is, > I suspect the new thread always wins even with this change on any > multiprocessor system, but it now has to wait a bit longer before it > wins. Have you observed some specific behavior with traces that this > change seeks to address? >=20 > --=20 > John Baldwin Thats a lousy question, John. Yes, we have, and yes, we still support unipr= ocessor systems. This isnt fast path code, and it solves a problem for us. Scott= From owner-dev-commits-src-all@freebsd.org Wed Aug 11 23:10:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4DB1D65E3A4; Wed, 11 Aug 2021 23:10:28 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [IPv6:2607:fc50:1000:7400:216:3eff:fe72:314f]) (using TLSv1.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 mx1.freebsd.org (Postfix) with ESMTPS id 4GlQXN1TQ8z4hxk; Wed, 11 Aug 2021 23:10:28 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from smtpclient.apple (unknown [IPv6:2600:380:6623:b873:44a1:fb09:3422:7da2]) by smtp.vangyzen.net (Postfix) with ESMTPSA id EA2175646A; Wed, 11 Aug 2021 18:10:20 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=vangyzen.net; s=default; t=1628723421; bh=0t4P2lxmmtaWk4R9w6FT2qc8YCgw29GZ77oCx7QLfwU=; h=From:Subject:Date:References:Cc:In-Reply-To:To; b=jJptERX5vo44mgoupwaA9659D/wYRvBvQNaGFLKSxJXnObUmbRXGp53WOMQJM+fwf esJznoVwYtsseGpDlU4ui6mBl3ztRBUOtdqsPb2VHVJqRFCaLAL+hRSb7MequE07L9 0rTx4cUe+FtpXYTYxBxm4HULVj+0gwku0LSbKyn+CLjWBJ7nNXj8aE9qD9MkWvWx4z oZiTrdRQKpJPnwEqGzt07/hlhT6fN8r+GgCEpWKHEQ5Tq0vC9P+4vxQwMAO4GdYupe ut8NWl1nxVAHsqPCHLlDa9k5qWbeI9Gt3qNvp/lDMi3WpwSdD5QcbYEhZWJ67uGmpt 9+fWJv+Z+zGbQ== Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Eric van Gyzen Mime-Version: 1.0 (1.0) Subject: Re: git: 96f9bd46547d - main - dumpon: fix encrypted dumps after commit 372557d8c3d Date: Wed, 11 Aug 2021 18:10:19 -0500 Message-Id: <00BB4788-BD96-49D3-BED5-0C515DA010B9@vangyzen.net> References: <202108112055.17BKt3hx006719@gitrepo.freebsd.org> Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org In-Reply-To: <202108112055.17BKt3hx006719@gitrepo.freebsd.org> To: Eric van Gyzen X-Mailer: iPhone Mail (18G82) X-Rspamd-Queue-Id: 4GlQXN1TQ8z4hxk X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 23:10:28 -0000 >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3D96f9bd46547d6dfbaf219ab449e= facacb0dacccc >=20 > commit 96f9bd46547d6dfbaf219ab449efacacb0dacccc > Author: Eric van Gyzen > AuthorDate: 2021-08-07 08:59:02 +0000 > Commit: Eric van Gyzen > CommitDate: 2021-08-11 15:54:56 +0000 >=20 > dumpon: fix encrypted dumps after commit 372557d8c3d I broke the build. My bad. I won=E2=80=99t be able to fix it for at least t= hree hours. Feel free to fix it before me, with my thanks. Eric= From owner-dev-commits-src-all@freebsd.org Wed Aug 11 23:13:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E286B65E8A7; Wed, 11 Aug 2021 23:13: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 4GlQbj61t6z4jQQ; Wed, 11 Aug 2021 23:13: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 B6F0E17DF9; Wed, 11 Aug 2021 23:13: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 17BNDLOX093211; Wed, 11 Aug 2021 23:13:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17BNDL1g093210; Wed, 11 Aug 2021 23:13:21 GMT (envelope-from git) Date: Wed, 11 Aug 2021 23:13:21 GMT Message-Id: <202108112313.17BNDL1g093210@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: d20e9e02db3d - main - ar: diff reduction against ELF Tool Chain 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/main X-Git-Reftype: branch X-Git-Commit: d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2021 23:13:22 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6 commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6 Author: Ed Maste AuthorDate: 2021-08-04 13:54:17 +0000 Commit: Ed Maste CommitDate: 2021-08-11 23:12:46 +0000 ar: diff reduction against ELF Tool Chain - Drop exit status from bsdar_errc. ELF Tool Chain always returns EXIT_FAILURE in bsdar_errc. - Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive directly. Obtained from: ELF Tool Chain Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31496 --- usr.bin/ar/acpyacc.y | 48 ++++++++++------------ usr.bin/ar/ar.c | 52 ++++++++---------------- usr.bin/ar/ar.h | 18 +++------ usr.bin/ar/read.c | 34 ++++------------ usr.bin/ar/util.c | 4 +- usr.bin/ar/write.c | 111 +++++++++++++++------------------------------------ 6 files changed, 85 insertions(+), 182 deletions(-) diff --git a/usr.bin/ar/acpyacc.y b/usr.bin/ar/acpyacc.y index 5d4eb9fb6b37..34156e1d2d58 100644 --- a/usr.bin/ar/acpyacc.y +++ b/usr.bin/ar/acpyacc.y @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include "ar.h" @@ -250,7 +249,7 @@ arscp_open(char *fname) int r; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); + bsdar_errc(bsdar, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, fname, DEF_BLKSZ)); if ((r = archive_read_next_header(a, &entry))) @@ -277,15 +276,15 @@ arscp_create(char *in, char *out) /* Delete previously created temporary archive, if any. */ if (tmpac) { if (unlink(tmpac) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "unlink failed"); + bsdar_errc(bsdar, errno, "unlink failed"); free(tmpac); } tmpac = strdup(TEMPLATE); if (tmpac == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); if ((ofd = mkstemp(tmpac)) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "mkstemp failed"); + bsdar_errc(bsdar, errno, "mkstemp failed"); if (in) { /* @@ -308,8 +307,7 @@ arscp_create(char *in, char *out) * (archive with only global header) */ if ((a = archive_write_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_write_new failed"); + bsdar_errc(bsdar, 0, "archive_write_new failed"); archive_write_set_format_ar_svr4(a); AC(archive_write_open_fd(a, ofd)); AC(archive_write_close(a)); @@ -350,7 +348,7 @@ arscp_copy(int ifd, int ofd) } } if (munmap(p, sb.st_size) < 0) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "munmap failed"); + bsdar_errc(bsdar, errno, "munmap failed"); if (bytes > 0) return (1); @@ -369,7 +367,7 @@ arscp_addlib(char *archive, struct list *list) return; arscp_mlist2argv(list); bsdar->addlib = archive; - ar_mode_A(bsdar); + ar_write_archive(bsdar, 'A'); arscp_free_argv(); arscp_free_mlist(list); } @@ -382,7 +380,7 @@ arscp_addmod(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_q(bsdar); + ar_write_archive(bsdar, 'q'); arscp_free_argv(); arscp_free_mlist(list); } @@ -395,7 +393,7 @@ arscp_delete(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_d(bsdar); + ar_write_archive(bsdar, 'd'); arscp_free_argv(); arscp_free_mlist(list); } @@ -408,7 +406,7 @@ arscp_extract(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_x(bsdar); + ar_read_archive(bsdar, 'x'); arscp_free_argv(); arscp_free_mlist(list); } @@ -424,7 +422,7 @@ arscp_list(void) bsdar->argv = NULL; /* Always verbose. */ bsdar->options |= AR_V; - ar_mode_t(bsdar); + ar_read_archive(bsdar, 't'); bsdar->options &= ~AR_V; } @@ -439,8 +437,7 @@ arscp_dir(char *archive, struct list *list, char *rlt) if (rlt) { out = stdout; if ((stdout = fopen(rlt, "w")) == NULL) - bsdar_errc(bsdar, EX_IOERR, errno, - "fopen %s failed", rlt); + bsdar_errc(bsdar, errno, "fopen %s failed", rlt); } bsdar->filename = archive; @@ -452,13 +449,12 @@ arscp_dir(char *archive, struct list *list, char *rlt) } if (verbose) bsdar->options |= AR_V; - ar_mode_t(bsdar); + ar_read_archive(bsdar, 't'); bsdar->options &= ~AR_V; if (rlt) { if (fclose(stdout) == EOF) - bsdar_errc(bsdar, EX_IOERR, errno, - "fclose %s failed", rlt); + bsdar_errc(bsdar, errno, "fclose %s failed", rlt); stdout = out; free(rlt); } @@ -477,7 +473,7 @@ arscp_replace(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_r(bsdar); + ar_write_archive(bsdar, 'r'); arscp_free_argv(); arscp_free_mlist(list); } @@ -490,7 +486,7 @@ arscp_save(void) if (target) { if (rename(tmpac, target) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "rename failed"); + bsdar_errc(bsdar, errno, "rename failed"); /* * mkstemp creates temp files with mode 0600, here we * set target archive mode per process umask. @@ -498,7 +494,7 @@ arscp_save(void) mask = umask(0); umask(mask); if (chmod(target, 0666 & ~mask) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "chmod failed"); + bsdar_errc(bsdar, errno, "chmod failed"); free(tmpac); free(target); tmpac = NULL; @@ -520,7 +516,7 @@ arscp_clear(void) if (target) { new_target = strdup(target); if (new_target == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); arscp_create(NULL, new_target); } } @@ -537,7 +533,7 @@ arscp_end(int eval) free(target); if (tmpac) { if (unlink(tmpac) == -1) - bsdar_errc(bsdar, EX_IOERR, errno, "unlink %s failed", + bsdar_errc(bsdar, errno, "unlink %s failed", tmpac); free(tmpac); } @@ -568,7 +564,7 @@ arscp_mlist(struct list *list, char *str) l = malloc(sizeof(*l)); if (l == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); l->str = str; l->next = list; @@ -610,12 +606,12 @@ arscp_mlist2argv(struct list *list) n = arscp_mlist_len(list); argv = malloc(n * sizeof(*argv)); if (argv == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); /* Note that module names are stored in reverse order in mlist. */ for(i = n - 1; i >= 0; i--, list = list->next) { if (list == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "invalid mlist"); + bsdar_errc(bsdar, errno, "invalid mlist"); argv[i] = list->str; } diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c index b131163342a6..3012f81cfa97 100644 --- a/usr.bin/ar/ar.c +++ b/usr.bin/ar/ar.c @@ -151,7 +151,7 @@ main(int argc, char **argv) bsdar->options |= AR_D; bsdar->options |= AR_S; while ((bsdar->filename = *argv++) != NULL) - if (ar_mode_s(bsdar)) + if (ar_read_archive(bsdar, 's')) exitcode = EXIT_FAILURE; exit(exitcode); @@ -162,8 +162,7 @@ main(int argc, char **argv) if (*argv[1] != '-') { len = strlen(argv[1]) + 2; if ((p = malloc(len)) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, errno, - "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); *p = '-'; (void)strlcpy(p + 1, argv[1], len - 1); argv[1] = p; @@ -263,24 +262,20 @@ main(int argc, char **argv) bsdar_usage(); if (bsdar->options & AR_A && bsdar->options & AR_B) - bsdar_errc(bsdar, EXIT_FAILURE, 0, + bsdar_errc(bsdar, 0, "only one of -a and -[bi] options allowed"); if (bsdar->options & AR_J && bsdar->options & AR_Z) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "only one of -j and -z options allowed"); + bsdar_errc(bsdar, 0, "only one of -j and -z options allowed"); if (bsdar->options & AR_S && bsdar->options & AR_SS) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "only one of -s and -S options allowed"); + bsdar_errc(bsdar, 0, "only one of -s and -S options allowed"); if (bsdar->options & (AR_A | AR_B)) { if (*argv == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "no position operand specified"); + bsdar_errc(bsdar, 0, "no position operand specified"); if ((bsdar->posarg = basename(*argv)) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, errno, - "basename failed"); + bsdar_errc(bsdar, errno, "basename failed"); argc--; argv++; } @@ -322,32 +317,17 @@ main(int argc, char **argv) if ((!bsdar->mode || strchr("ptx", bsdar->mode)) && bsdar->options & AR_S) { - exitcode = ar_mode_s(bsdar); + exitcode = ar_write_archive(bsdar, 's'); if (!bsdar->mode) exit(exitcode); } switch(bsdar->mode) { - case 'd': - exitcode = ar_mode_d(bsdar); + case 'd': case 'm': case 'q': case 'r': + exitcode = ar_write_archive(bsdar, bsdar->mode); break; - case 'm': - exitcode = ar_mode_m(bsdar); - break; - case 'p': - exitcode = ar_mode_p(bsdar); - break; - case 'q': - exitcode = ar_mode_q(bsdar); - break; - case 'r': - exitcode = ar_mode_r(bsdar); - break; - case 't': - exitcode = ar_mode_t(bsdar); - break; - case 'x': - exitcode = ar_mode_x(bsdar); + case 'p': case 't': case 'x': + exitcode = ar_read_archive(bsdar, bsdar->mode); break; default: bsdar_usage(); @@ -370,8 +350,8 @@ set_mode(struct bsdar *bsdar, char opt) { if (bsdar->mode != '\0' && bsdar->mode != opt) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "Can't specify both -%c and -%c", opt, bsdar->mode); + bsdar_errc(bsdar, 0, "Can't specify both -%c and -%c", + opt, bsdar->mode); bsdar->mode = opt; } @@ -380,8 +360,8 @@ only_mode(struct bsdar *bsdar, const char *opt, const char *valid_modes) { if (strchr(valid_modes, bsdar->mode) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "Option %s is not permitted in mode -%c", opt, bsdar->mode); + bsdar_errc(bsdar, 0, "Option %s is not permitted in mode -%c", + opt, bsdar->mode); } static void diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h index 21b3a669a943..bcccf93a6016 100644 --- a/usr.bin/ar/ar.h +++ b/usr.bin/ar/ar.h @@ -54,7 +54,7 @@ */ #define AC(CALL) do { \ if ((CALL)) \ - bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s", \ + bsdar_errc(bsdar, archive_errno(a), "%s", \ archive_error_string(a)); \ } while (0) @@ -114,16 +114,8 @@ struct bsdar { TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ }; -void bsdar_errc(struct bsdar *, int _eval, int _code, - const char *fmt, ...) __dead2; -void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); -int ar_mode_d(struct bsdar *bsdar); -int ar_mode_m(struct bsdar *bsdar); -int ar_mode_p(struct bsdar *bsdar); -int ar_mode_q(struct bsdar *bsdar); -int ar_mode_r(struct bsdar *bsdar); -int ar_mode_s(struct bsdar *bsdar); -int ar_mode_t(struct bsdar *bsdar); -int ar_mode_x(struct bsdar *bsdar); -int ar_mode_A(struct bsdar *bsdar); void ar_mode_script(struct bsdar *ar); +int ar_read_archive(struct bsdar *ar, int mode); +int ar_write_archive(struct bsdar *ar, int mode); +void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __dead2; +void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c index 04130b859c32..81e0bfce1b7e 100644 --- a/usr.bin/ar/read.c +++ b/usr.bin/ar/read.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -42,34 +43,11 @@ __FBSDID("$FreeBSD$"); #include "ar.h" -static int read_archive(struct bsdar *bsdar, char mode); - -int -ar_mode_p(struct bsdar *bsdar) -{ - - return (read_archive(bsdar, 'p')); -} - -int -ar_mode_t(struct bsdar *bsdar) -{ - - return (read_archive(bsdar, 't')); -} - -int -ar_mode_x(struct bsdar *bsdar) -{ - - return (read_archive(bsdar, 'x')); -} - /* * Handle read modes: 'x', 't' and 'p'. */ -static int -read_archive(struct bsdar *bsdar, char mode) +int +ar_read_archive(struct bsdar *bsdar, int mode) { struct archive *a; struct archive_entry *entry; @@ -87,8 +65,10 @@ read_archive(struct bsdar *bsdar, char mode) char find; int exitcode, flags, r, i; + assert(mode == 'p' || mode == 't' || mode == 'x'); + if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed"); + bsdar_errc(bsdar, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ)); @@ -122,7 +102,7 @@ read_archive(struct bsdar *bsdar, char mode) if (*av == NULL) continue; if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, errno, + bsdar_errc(bsdar, errno, "basename failed"); if (strcmp(bname, name) != 0) continue; diff --git a/usr.bin/ar/util.c b/usr.bin/ar/util.c index 1823c5eba84a..b130d6195e47 100644 --- a/usr.bin/ar/util.c +++ b/usr.bin/ar/util.c @@ -77,12 +77,12 @@ bsdar_verrc(struct bsdar *bsdar, int code, const char *fmt, va_list ap) } void -bsdar_errc(struct bsdar *bsdar, int eval, int code, const char *fmt, ...) +bsdar_errc(struct bsdar *bsdar, int code, const char *fmt, ...) { va_list ap; va_start(ap, fmt); bsdar_verrc(bsdar, code, fmt, ap); va_end(ap); - exit(eval); + exit(EXIT_FAILURE); } diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index 4177f57d064a..d3dd71556bb3 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -42,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include "ar.h" @@ -67,54 +67,11 @@ static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, static void prefault_buffer(const char *buf, size_t s); static void read_objs(struct bsdar *bsdar, const char *archive, int checkargv); -static int write_archive(struct bsdar *bsdar, char mode); static void write_cleanup(struct bsdar *bsdar); static void write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s); static void write_objs(struct bsdar *bsdar); -int -ar_mode_d(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'd')); -} - -int -ar_mode_m(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'm')); -} - -int -ar_mode_q(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'q')); -} - -int -ar_mode_r(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'r')); -} - -int -ar_mode_s(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 's')); -} - -int -ar_mode_A(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'A')); -} - /* * Create object from file, return created obj upon success, or NULL * when an error occurs or the member is not newer than existing @@ -133,7 +90,7 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) obj = malloc(sizeof(struct ar_obj)); if (obj == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); if ((obj->fd = open(name, O_RDONLY, 0)) < 0) { bsdar_warnc(bsdar, errno, "can't open file: %s", name); free(obj); @@ -142,17 +99,17 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) tmpname = strdup(name); if (tmpname == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); if ((bname = basename(tmpname)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "basename failed"); + bsdar_errc(bsdar, errno, "basename failed"); if (bsdar->options & AR_TR && strlen(bname) > _TRUNCATE_LEN) { if ((obj->name = malloc(_TRUNCATE_LEN + 1)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); (void)strncpy(obj->name, bname, _TRUNCATE_LEN); obj->name[_TRUNCATE_LEN] = '\0'; } else if ((obj->name = strdup(bname)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); free(tmpname); if (fstat(obj->fd, &sb) < 0) { @@ -205,14 +162,14 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) goto giveup; } if (close(obj->fd) < 0) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "close failed: %s", + bsdar_errc(bsdar, errno, "close failed: %s", obj->name); return (obj); giveup: if (close(obj->fd) < 0) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "close failed: %s", + bsdar_errc(bsdar, errno, "close failed: %s", obj->name); free(obj->name); free(obj); @@ -242,7 +199,7 @@ static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, struct ar_obj *pos) { if (obj == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "try to insert a null obj"); + bsdar_errc(bsdar, 0, "try to insert a null obj"); if (pos == NULL || obj == pos) /* @@ -285,13 +242,13 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) int i, r, find; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); + bsdar_errc(bsdar, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); for (;;) { r = archive_read_next_header(a, &entry); if (r == ARCHIVE_FATAL) - bsdar_errc(bsdar, EX_DATAERR, archive_errno(a), "%s", + bsdar_errc(bsdar, archive_errno(a), "%s", archive_error_string(a)); if (r == ARCHIVE_EOF) break; @@ -322,7 +279,7 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) if (*av == NULL) continue; if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, + bsdar_errc(bsdar, errno, "basename failed"); if (strcmp(bname, name) != 0) continue; @@ -339,8 +296,7 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) if (size > 0) { if ((buff = malloc(size)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, - "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); if (archive_read_data(a, buff, size) != (ssize_t)size) { bsdar_warnc(bsdar, archive_errno(a), "%s", archive_error_string(a)); @@ -352,10 +308,10 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) obj = malloc(sizeof(struct ar_obj)); if (obj == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); obj->maddr = buff; if ((obj->name = strdup(name)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); obj->size = size; obj->uid = archive_entry_uid(entry); obj->gid = archive_entry_gid(entry); @@ -378,8 +334,8 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) /* * Determine the constitution of resulting archive. */ -static int -write_archive(struct bsdar *bsdar, char mode) +int +ar_write_archive(struct bsdar *bsdar, int mode) { struct ar_obj *nobj, *obj, *obj_temp, *pos; struct stat sb; @@ -393,6 +349,9 @@ write_archive(struct bsdar *bsdar, char mode) pos = NULL; memset(&sb, 0, sizeof(sb)); + assert(mode == 'A' || mode == 'd' || mode == 'm' || mode == 'q' || + mode == 'r' || mode == 's'); + /* * Test if the specified archive exists, to figure out * whether we are creating one here. @@ -476,8 +435,7 @@ write_archive(struct bsdar *bsdar, char mode) TAILQ_FOREACH_SAFE(obj, &bsdar->v_obj, objs, obj_temp) { if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, - "basename failed"); + bsdar_errc(bsdar, errno, "basename failed"); if (bsdar->options & AR_TR) { if (strncmp(bname, obj->name, _TRUNCATE_LEN)) continue; @@ -605,7 +563,7 @@ write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s) while (s > 0) { written = archive_write_data(a, buf, s); if (written < 0) - bsdar_errc(bsdar, EX_SOFTWARE, archive_errno(a), "%s", + bsdar_errc(bsdar, archive_errno(a), "%s", archive_error_string(a)); buf = (const char *)buf + written; s -= written; @@ -629,7 +587,7 @@ write_objs(struct bsdar *bsdar) uint32_t nr32; if (elf_version(EV_CURRENT) == EV_NONE) - bsdar_errc(bsdar, EX_SOFTWARE, 0, + bsdar_errc(bsdar, 0, "ELF library initialization failed: %s", elf_errmsg(-1)); bsdar->rela_off = 0; @@ -695,7 +653,7 @@ write_objs(struct bsdar *bsdar) } if ((a = archive_write_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); + bsdar_errc(bsdar, 0, "archive_write_new failed"); archive_write_set_format_ar_svr4(a); @@ -710,8 +668,7 @@ write_objs(struct bsdar *bsdar) bsdar->options & AR_S) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_entry_new failed"); + bsdar_errc(bsdar, 0, "archive_entry_new failed"); if (w_sz == sizeof(uint64_t)) archive_entry_copy_pathname(entry, "/SYM64/"); else @@ -737,8 +694,7 @@ write_objs(struct bsdar *bsdar) if (bsdar->as != NULL) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_entry_new failed"); + bsdar_errc(bsdar, 0, "archive_entry_new failed"); archive_entry_copy_pathname(entry, "//"); archive_entry_set_size(entry, bsdar->as_sz); AC(archive_write_header(a, entry)); @@ -750,8 +706,7 @@ write_objs(struct bsdar *bsdar) TAILQ_FOREACH(obj, &bsdar->v_obj, objs) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_entry_new failed"); + bsdar_errc(bsdar, 0, "archive_entry_new failed"); archive_entry_copy_pathname(entry, obj->name); archive_entry_set_uid(entry, obj->uid); archive_entry_set_gid(entry, obj->gid); @@ -893,7 +848,7 @@ add_to_ar_str_table(struct bsdar *bsdar, const char *name) bsdar->as_cap = _INIT_AS_CAP; bsdar->as_sz = 0; if ((bsdar->as = malloc(bsdar->as_cap)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); } /* @@ -904,7 +859,7 @@ add_to_ar_str_table(struct bsdar *bsdar, const char *name) bsdar->as_cap *= 2; bsdar->as = realloc(bsdar->as, bsdar->as_cap); if (bsdar->as == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); + bsdar_errc(bsdar, errno, "realloc failed"); } strncpy(&bsdar->as[bsdar->as_sz], name, strlen(name)); bsdar->as_sz += strlen(name); @@ -922,14 +877,14 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) if (bsdar->s_so == NULL) { if ((bsdar->s_so = malloc(_INIT_SYMOFF_CAP)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); bsdar->s_so_cap = _INIT_SYMOFF_CAP; bsdar->s_cnt = 0; } if (bsdar->s_sn == NULL) { if ((bsdar->s_sn = malloc(_INIT_SYMNAME_CAP)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); bsdar->s_sn_cap = _INIT_SYMNAME_CAP; bsdar->s_sn_sz = 0; } @@ -938,7 +893,7 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) bsdar->s_so_cap *= 2; bsdar->s_so = realloc(bsdar->s_so, bsdar->s_so_cap); if (bsdar->s_so == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); + bsdar_errc(bsdar, errno, "realloc failed"); } bsdar->s_so[bsdar->s_cnt] = bsdar->rela_off; if ((uint64_t)bsdar->rela_off > bsdar->s_so_max) @@ -953,7 +908,7 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) bsdar->s_sn_cap *= 2; bsdar->s_sn = realloc(bsdar->s_sn, bsdar->s_sn_cap); if (bsdar->s_sn == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); + bsdar_errc(bsdar, errno, "realloc failed"); } strncpy(&bsdar->s_sn[bsdar->s_sn_sz], name, strlen(name)); bsdar->s_sn_sz += strlen(name); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 00:07:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DFDFD65F15E; Thu, 12 Aug 2021 00:07: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 4GlRp15n3pz4lVQ; Thu, 12 Aug 2021 00:07: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 AB1ED18B79; Thu, 12 Aug 2021 00:07: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 17C07Lm7059960; Thu, 12 Aug 2021 00:07:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C07L84059959; Thu, 12 Aug 2021 00:07:21 GMT (envelope-from git) Date: Thu, 12 Aug 2021 00:07:21 GMT Message-Id: <202108120007.17C07L84059959@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: 5ae48eb998ad - main - powerpc/pseries: Allow radix pmap in pseries for ISA 3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5ae48eb998ad5d41118d2df62cf28b92d6864e24 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 00:07:21 -0000 The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=5ae48eb998ad5d41118d2df62cf28b92d6864e24 commit 5ae48eb998ad5d41118d2df62cf28b92d6864e24 Author: Justin Hibbits AuthorDate: 2021-08-12 00:03:27 +0000 Commit: Justin Hibbits CommitDate: 2021-08-12 00:07:04 +0000 powerpc/pseries: Allow radix pmap in pseries for ISA 3.0 ISA 3.0 allows for nested radix translations with minimal to no involvement of the hypervisor. This should make pseries signficantly faster on POWER9 pseries instances, as fewer hypercalls are needed to manage pmap now. MFC after: 2 weeks Relnotes: yes --- sys/conf/options.powerpc | 2 +- sys/powerpc/aim/mmu_radix.c | 53 +++++++++++++++++++++++++++---------- sys/powerpc/pseries/phyp-hvcall.h | 10 +++++++ sys/powerpc/pseries/platform_chrp.c | 3 ++- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/sys/conf/options.powerpc b/sys/conf/options.powerpc index 463c2b9da8c7..5d8e91a92e56 100644 --- a/sys/conf/options.powerpc +++ b/sys/conf/options.powerpc @@ -25,7 +25,7 @@ POWERMAC opt_platform.h PS3 opt_platform.h MAMBO POWERNV opt_platform.h -PSERIES +PSERIES opt_platform.h PSIM QEMU opt_platform.h diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c index 58fca5dec471..8c3f6e2cf37a 100644 --- a/sys/powerpc/aim/mmu_radix.c +++ b/sys/powerpc/aim/mmu_radix.c @@ -25,6 +25,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "opt_platform.h" + #include __FBSDID("$FreeBSD$"); @@ -84,6 +86,9 @@ __FBSDID("$FreeBSD$"); #include #include +/* For pseries bit. */ +#include + #ifdef INVARIANTS #include #endif @@ -93,6 +98,7 @@ __FBSDID("$FreeBSD$"); #define PPC_BITLSHIFT_VAL(val, bit) ((val) << PPC_BITLSHIFT(bit)) #include "opt_ddb.h" + #ifdef DDB static void pmap_pte_walk(pml1_entry_t *l1, vm_offset_t va); #endif @@ -780,8 +786,10 @@ mmu_radix_tlbiel_flush(int scope) static void mmu_radix_tlbie_all() { - /* TODO: LPID invalidate */ - mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + if (powernv_enabled) + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + else + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_LPID); } static void @@ -2024,11 +2032,14 @@ mmu_radix_early_bootstrap(vm_offset_t start, vm_offset_t end) */ if (isa3_pid_bits == 0) isa3_pid_bits = 20; - parttab_phys = moea64_bootstrap_alloc(PARTTAB_SIZE, PARTTAB_SIZE); - validate_addr(parttab_phys, PARTTAB_SIZE); - for (int i = 0; i < PARTTAB_SIZE/PAGE_SIZE; i++) - pagezero(PHYS_TO_DMAP(parttab_phys + i * PAGE_SIZE)); + if (powernv_enabled) { + parttab_phys = + moea64_bootstrap_alloc(PARTTAB_SIZE, PARTTAB_SIZE); + validate_addr(parttab_phys, PARTTAB_SIZE); + for (int i = 0; i < PARTTAB_SIZE/PAGE_SIZE; i++) + pagezero(PHYS_TO_DMAP(parttab_phys + i * PAGE_SIZE)); + } proctab_size = 1UL << PROCTAB_SIZE_SHIFT; proctab0pa = moea64_bootstrap_alloc(proctab_size, proctab_size); validate_addr(proctab0pa, proctab_size); @@ -2181,12 +2192,20 @@ mmu_radix_proctab_init(void) htobe64(RTS_SIZE | DMAP_TO_PHYS((vm_offset_t)kernel_pmap->pm_pml1) | RADIX_PGD_INDEX_SHIFT); - mmu_radix_proctab_register(proctab0pa, PROCTAB_SIZE_SHIFT - 12); + if (powernv_enabled) { + mmu_radix_proctab_register(proctab0pa, PROCTAB_SIZE_SHIFT - 12); + __asm __volatile("ptesync" : : : "memory"); + __asm __volatile(PPC_TLBIE_5(%0,%1,2,1,1) : : + "r" (TLBIEL_INVAL_SET_LPID), "r" (0)); + __asm __volatile("eieio; tlbsync; ptesync" : : : "memory"); +#ifdef PSERIES + } else { + phyp_hcall(H_REGISTER_PROC_TBL, + PROC_TABLE_NEW | PROC_TABLE_RADIX | PROC_TABLE_GTSE, + proctab0pa, 0, PROCTAB_SIZE_SHIFT - 12); +#endif + } - __asm __volatile("ptesync" : : : "memory"); - __asm __volatile(PPC_TLBIE_5(%0,%1,2,1,1) : : - "r" (TLBIEL_INVAL_SET_LPID), "r" (0)); - __asm __volatile("eieio; tlbsync; ptesync" : : : "memory"); if (bootverbose) printf("process table %p and kernel radix PDE: %p\n", isa3_proctab, kernel_pmap->pm_pml1); @@ -2326,6 +2345,7 @@ mmu_radix_bootstrap(vm_offset_t start, vm_offset_t end) if (bootverbose) printf("%s\n", __func__); hw_direct_map = 1; + powernv_enabled = (mfmsr() & PSL_HV) ? 1 : 0; mmu_radix_early_bootstrap(start, end); if (bootverbose) printf("early bootstrap complete\n"); @@ -2340,8 +2360,10 @@ mmu_radix_bootstrap(vm_offset_t start, vm_offset_t end) mmu_radix_init_iamr(); mmu_radix_proctab_init(); mmu_radix_pid_set(kernel_pmap); - /* XXX assume CPU_FTR_HVMODE */ - mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + if (powernv_enabled) + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + else + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_LPID); mmu_radix_late_bootstrap(start, end); numa_mem_regions(&numa_pregions, &numa_pregions_sz); @@ -2368,7 +2390,10 @@ mmu_radix_cpu_bootstrap(int ap) } mmu_radix_init_iamr(); mmu_radix_pid_set(kernel_pmap); - mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + if (powernv_enabled) + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_GLOBAL); + else + mmu_radix_tlbiel_flush(TLB_INVAL_SCOPE_LPID); } static SYSCTL_NODE(_vm_pmap, OID_AUTO, l3e, CTLFLAG_RD, 0, diff --git a/sys/powerpc/pseries/phyp-hvcall.h b/sys/powerpc/pseries/phyp-hvcall.h index 90f75807e56a..face804aff08 100644 --- a/sys/powerpc/pseries/phyp-hvcall.h +++ b/sys/powerpc/pseries/phyp-hvcall.h @@ -177,6 +177,16 @@ #define H_SET_MODE_RSRC_ILE 0x4 /* PAPR 2.8 / ISA 2.07 */ #define H_SET_MODE_RSRC_DAWR1 0x5 /* ISA 3.1 Future support */ +/* H_REGISTER_PROC_TBL identifiers. */ +#define PROC_TABLE_OP_MASK 0x18 +#define PROC_TABLE_DEREG 0x10 +#define PROC_TABLE_NEW 0x18 +#define PROC_TABLE_TYPE_MASK 0x06 +#define PROC_TABLE_HPT_SLB 0x00 +#define PROC_TABLE_GTSE 0x01 +#define PROC_TABLE_HPT_PT 0x02 +#define PROC_TABLE_RADIX 0x04 + /* pSeries hypervisor opcodes. */ #define H_REMOVE 0x04 #define H_ENTER 0x08 diff --git a/sys/powerpc/pseries/platform_chrp.c b/sys/powerpc/pseries/platform_chrp.c index 202ee059c528..f095e97edaf1 100644 --- a/sys/powerpc/pseries/platform_chrp.c +++ b/sys/powerpc/pseries/platform_chrp.c @@ -154,7 +154,8 @@ chrp_attach(platform_t plat) realmaxaddr = MAX(off, realmaxaddr); } - pmap_mmu_install("mmu_phyp", BUS_PROBE_SPECIFIC); + if (!radix_mmu) + pmap_mmu_install("mmu_phyp", BUS_PROBE_SPECIFIC); cpu_idle_hook = phyp_cpu_idle; /* Set up important VPA fields */ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 01:53:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E0D85660C71; Thu, 12 Aug 2021 01:53: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 4GlV8B5v89z3CWd; Thu, 12 Aug 2021 01:53: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 B271F1A509; Thu, 12 Aug 2021 01:53: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 17C1rEPV004773; Thu, 12 Aug 2021 01:53:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C1rEAl004772; Thu, 12 Aug 2021 01:53:14 GMT (envelope-from git) Date: Thu, 12 Aug 2021 01:53:14 GMT Message-Id: <202108120153.17C1rEAl004772@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 3ad1e1c1ce20 - main - nfscl: Add a Lookup+Open RPC for NFSv4.1/4.2 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/main X-Git-Reftype: branch X-Git-Commit: 3ad1e1c1ce2042bb45a518e28c881e5bc4491117 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 01:53:14 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=3ad1e1c1ce2042bb45a518e28c881e5bc4491117 commit 3ad1e1c1ce2042bb45a518e28c881e5bc4491117 Author: Rick Macklem AuthorDate: 2021-08-12 01:49:26 +0000 Commit: Rick Macklem CommitDate: 2021-08-12 01:49:26 +0000 nfscl: Add a Lookup+Open RPC for NFSv4.1/4.2 This patch adds a Lookup+Open compound RPC to the NFSv4.1/4.2 NFS client, which can be used by nfs_lookup() so that a subsequent Open RPC is not required. It uses the cn_flags OPENREAD, OPENWRITE added by commit c18c74a87c15. This reduced the number of RPCs by about 15% for a kernel build over NFS. For now, use of Lookup+Open is only done when the "oneopenown" mount option is used. It may be possible for Lookup+Open to be used for non-oneopenown NFSv4.1/4.2 mounts, but that will require extensive further testing to determine if it works. While here, I've added the changes to the nfscommon module that are needed to implement the Deallocate NFSv4.2 operation. This avoids needing another cycle of changes to the internal KAPI between the NFS modules. This commit has changed the internal KAPI between the NFS modules and, as such, all need to be rebuilt from sources. I have not bumped __FreeBSD_version, since it was bumped a few days ago. --- sys/fs/nfs/nfs_commonsubs.c | 11 ++-- sys/fs/nfs/nfs_var.h | 4 +- sys/fs/nfs/nfsport.h | 12 +++- sys/fs/nfs/nfsproto.h | 8 ++- sys/fs/nfsclient/nfs_clrpcops.c | 140 +++++++++++++++++++++++++++++++++++++++- sys/fs/nfsclient/nfs_clstate.c | 4 +- sys/fs/nfsclient/nfs_clvnops.c | 28 ++++++-- 7 files changed, 188 insertions(+), 19 deletions(-) diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 817d89284091..20f5618c202c 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -179,7 +179,7 @@ struct nfsv4_opflag nfsv4_opflag[NFSV42_NOPS] = { { 0, 1, 1, 1, LK_EXCLUSIVE, 1, 0 }, /* Allocate */ { 2, 1, 1, 0, LK_SHARED, 1, 0 }, /* Copy */ { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Copy Notify */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Deallocate */ + { 0, 2, 1, 1, LK_EXCLUSIVE, 1, 0 }, /* Deallocate */ { 0, 1, 0, 0, LK_SHARED, 1, 0 }, /* IO Advise */ { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Layout Error */ { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 0 }, /* Layout Stats */ @@ -219,7 +219,7 @@ static struct nfsrv_lughash *nfsgroupnamehash; static int nfs_bigreply[NFSV42_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 1, 0 }; + 1, 0, 0, 1, 0, 0, 0 }; /* local functions */ static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep); @@ -303,6 +303,8 @@ static struct { { NFSV4OP_REMOVEXATTR, 2, "Rmxattr", 7, }, { NFSV4OP_LISTXATTRS, 2, "Listxattr", 9, }, { NFSV4OP_BINDCONNTOSESS, 1, "BindConSess", 11, }, + { NFSV4OP_LOOKUP, 5, "LookupOpen", 10, }, + { NFSV4OP_DEALLOCATE, 2, "Deallocate", 10, }, }; /* @@ -311,7 +313,7 @@ static struct { static int nfs_bigrequest[NFSV42_NPROCS] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }; /* @@ -434,7 +436,8 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum, struct nfsmount *nmp, * attributes, so we can load the name cache. */ if (procnum == NFSPROC_LOOKUP || - procnum == NFSPROC_LOOKUPP) + procnum == NFSPROC_LOOKUPP || + procnum == NFSPROC_LOOKUPOPEN) NFSGETATTR_ATTRBIT(&attrbits); else { NFSWCCATTR_ATTRBIT(&attrbits); diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 9cbaeae361a6..b4c21c6f7029 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -465,7 +465,7 @@ int nfsrpc_setattr(vnode_t, struct vattr *, NFSACL_T *, struct ucred *, NFSPROC_T *, struct nfsvattr *, int *, void *); int nfsrpc_lookup(vnode_t, char *, int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *, struct nfsfh **, int *, int *, - void *); + void *, uint32_t); int nfsrpc_readlink(vnode_t, struct uio *, struct ucred *, NFSPROC_T *, struct nfsvattr *, int *, void *); int nfsrpc_read(vnode_t, struct uio *, struct ucred *, NFSPROC_T *, @@ -624,6 +624,8 @@ void nfscl_reclaimnode(vnode_t); void nfscl_newnode(vnode_t); void nfscl_delegmodtime(vnode_t); void nfscl_deleggetmodtime(vnode_t, struct timespec *); +int nfscl_trydelegreturn(struct nfscldeleg *, struct ucred *, + struct nfsmount *, NFSPROC_T *); int nfscl_tryclose(struct nfsclopen *, struct ucred *, struct nfsmount *, NFSPROC_T *); void nfscl_cleanup(NFSPROC_T *); diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index cb82666ab397..64ba4d48b3f1 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -415,10 +415,16 @@ /* BindConnectionToSession, done by the krpc for a new connection. */ #define NFSPROC_BINDCONNTOSESS 65 +/* Do a Lookup+Open for "oneopenown". */ +#define NFSPROC_LOOKUPOPEN 66 + +/* Do an NFSv4.2 Deallocate. */ +#define NFSPROC_DEALLOCATE 67 + /* * Must be defined as one higher than the last NFSv4.2 Proc# above. */ -#define NFSV42_NPROCS 66 +#define NFSV42_NPROCS 68 #endif /* NFS_V3NPROCS */ @@ -447,7 +453,7 @@ struct nfsstatsv1 { uint64_t readlink_bios; uint64_t biocache_readdirs; uint64_t readdir_bios; - uint64_t rpccnt[NFSV42_NPROCS + 14]; + uint64_t rpccnt[NFSV42_NPROCS + 12]; uint64_t rpcretries; uint64_t srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15]; uint64_t reserved_0; @@ -512,7 +518,7 @@ struct nfsstatsov1 { uint64_t readlink_bios; uint64_t biocache_readdirs; uint64_t readdir_bios; - uint64_t rpccnt[NFSV42_NPROCS + 3]; + uint64_t rpccnt[NFSV42_NPROCS + 1]; uint64_t rpcretries; uint64_t srvrpccnt[NFSV42_PURENOPS + NFSV4OP_FAKENOPS]; uint64_t reserved_0; diff --git a/sys/fs/nfs/nfsproto.h b/sys/fs/nfs/nfsproto.h index 13e146154805..7ac7cdc3bacf 100644 --- a/sys/fs/nfs/nfsproto.h +++ b/sys/fs/nfs/nfsproto.h @@ -396,10 +396,16 @@ /* BindConnectionToSession, done by the krpc for a new connection. */ #define NFSPROC_BINDCONNTOSESS 65 +/* Do a Lookup+Open for "oneopenown". */ +#define NFSPROC_LOOKUPOPEN 66 + +/* Do an NFSv4.2 Deallocate. */ +#define NFSPROC_DEALLOCATE 67 + /* * Must be defined as one higher than the last NFSv4.2 Proc# above. */ -#define NFSV42_NPROCS 66 +#define NFSV42_NPROCS 68 #endif /* NFS_V3NPROCS */ diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 74803e255aae..de4030876bfe 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -1382,15 +1382,20 @@ nfsrpc_setattrrpc(vnode_t vp, struct vattr *vap, int nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred, NFSPROC_T *p, struct nfsvattr *dnap, struct nfsvattr *nap, - struct nfsfh **nfhpp, int *attrflagp, int *dattrflagp, void *stuff) + struct nfsfh **nfhpp, int *attrflagp, int *dattrflagp, void *stuff, + uint32_t openmode) { - u_int32_t *tl; + uint32_t deleg, rflags, *tl; struct nfsrv_descript nfsd, *nd = &nfsd; struct nfsmount *nmp; struct nfsnode *np; struct nfsfh *nfhp; nfsattrbit_t attrbits; - int error = 0, lookupp = 0; + int error = 0, lookupp = 0, newone, ret, retop; + uint8_t own[NFSV4CL_LOCKNAMELEN]; + struct nfsclopen *op; + struct nfscldeleg *ndp; + nfsv4stateid_t stateid; *attrflagp = 0; *dattrflagp = 0; @@ -1415,7 +1420,11 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred, if (NFSHASNFSV4(nmp) && len == 2 && name[0] == '.' && name[1] == '.') { lookupp = 1; + openmode = 0; NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, dvp); + } else if (openmode != 0) { + NFSCL_REQSTART(nd, NFSPROC_LOOKUPOPEN, dvp); + nfsm_strtom(nd, name, len); } else { NFSCL_REQSTART(nd, NFSPROC_LOOKUP, dvp); (void) nfsm_strtom(nd, name, len); @@ -1426,10 +1435,36 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred, *tl++ = txdr_unsigned(NFSV4OP_GETFH); *tl = txdr_unsigned(NFSV4OP_GETATTR); (void) nfsrv_putattrbit(nd, &attrbits); + if (openmode != 0) { + /* Test for a VREG file. */ + NFSZERO_ATTRBIT(&attrbits); + NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TYPE); + NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV4OP_VERIFY); + nfsrv_putattrbit(nd, &attrbits); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSX_UNSIGNED); + *tl = vtonfsv34_type(VREG); + + /* Attempt the Open for VREG. */ + nfscl_filllockowner(NULL, own, F_POSIX); + NFSM_BUILD(tl, uint32_t *, 6 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSV4OP_OPEN); + *tl++ = 0; /* seqid, ignored. */ + *tl++ = txdr_unsigned(openmode); + *tl++ = txdr_unsigned(NFSV4OPEN_DENYNONE); + *tl++ = 0; /* ClientID, ignored. */ + *tl = 0; + nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSV4OPEN_NOCREATE); + *tl = txdr_unsigned(NFSV4OPEN_CLAIMFH); + } } error = nfscl_request(nd, dvp, p, cred, stuff); if (error) return (error); + ndp = NULL; if (nd->nd_repstat) { /* * When an NFSv4 Lookupp returns ENOENT, it means that @@ -1453,6 +1488,33 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred, error = nfsm_loadattr(nd, dnap); if (error == 0) *dattrflagp = 1; + else + goto nfsmout; + } + /* Check Lookup operation reply status. */ + if (openmode != 0 && (nd->nd_flag & ND_NOMOREDATA) == 0) { + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + if (*++tl != 0) + goto nfsmout; + } + /* Look for GetFH reply. */ + if (openmode != 0 && (nd->nd_flag & ND_NOMOREDATA) == 0) { + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + if (*++tl != 0) + goto nfsmout; + error = nfsm_getfh(nd, nfhpp); + if (error) + goto nfsmout; + } + /* Look for Getattr reply. */ + if (openmode != 0 && (nd->nd_flag & ND_NOMOREDATA) == 0) { + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + if (*++tl != 0) + goto nfsmout; + error = nfscl_postop_attr(nd, nap, attrflagp, stuff); + if (error == 0) + /* Successfully got Lookup done. */ + nd->nd_repstat = 0; } goto nfsmout; } @@ -1470,12 +1532,84 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred, goto nfsmout; error = nfscl_postop_attr(nd, nap, attrflagp, stuff); + if (openmode != 0 && error == 0) { + NFSM_DISSECT(tl, uint32_t *, NFSX_STATEID + + 10 * NFSX_UNSIGNED); + tl += 4; /* Skip over Verify+Open status. */ + stateid.seqid = *tl++; + stateid.other[0] = *tl++; + stateid.other[1] = *tl++; + stateid.other[2] = *tl; + rflags = fxdr_unsigned(uint32_t, *(tl + 6)); + error = nfsrv_getattrbits(nd, &attrbits, NULL, NULL); + if (error != 0) + goto nfsmout; + NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED); + deleg = fxdr_unsigned(uint32_t, *tl); + if (deleg == NFSV4OPEN_DELEGATEREAD || + deleg == NFSV4OPEN_DELEGATEWRITE) { + /* + * Just need to fill in the fields used by + * nfscl_trydelegreturn(). + * Mark the mount point as acquiring + * delegations, so NFSPROC_LOOKUPOPEN will + * no longer be done. + */ + NFSLOCKMNT(nmp); + nmp->nm_privflag |= NFSMNTP_DELEGISSUED; + NFSUNLOCKMNT(nmp); + ndp = malloc(sizeof(struct nfscldeleg) + + (*nfhpp)->nfh_len, M_NFSCLDELEG, M_WAITOK); + ndp->nfsdl_fhlen = (*nfhpp)->nfh_len; + NFSBCOPY((*nfhpp)->nfh_fh, ndp->nfsdl_fh, + ndp->nfsdl_fhlen); + newnfs_copyincred(cred, &ndp->nfsdl_cred); + NFSM_DISSECT(tl, uint32_t *, NFSX_STATEID); + ndp->nfsdl_stateid.seqid = *tl++; + ndp->nfsdl_stateid.other[0] = *tl++; + ndp->nfsdl_stateid.other[1] = *tl++; + ndp->nfsdl_stateid.other[2] = *tl++; + } else if (deleg != NFSV4OPEN_DELEGATENONE) { + error = NFSERR_BADXDR; + goto nfsmout; + } + ret = nfscl_open(dvp, (*nfhpp)->nfh_fh, (*nfhpp)->nfh_len, + openmode, 0, cred, p, NULL, &op, &newone, &retop, 1); + if (ret != 0) + goto nfsmout; + if (newone != 0) { + op->nfso_stateid.seqid = stateid.seqid; + op->nfso_stateid.other[0] = stateid.other[0]; + op->nfso_stateid.other[1] = stateid.other[1]; + op->nfso_stateid.other[2] = stateid.other[2]; + op->nfso_mode = openmode; + } else { + op->nfso_stateid.seqid = stateid.seqid; + if (retop == NFSCLOPEN_DOOPEN) + op->nfso_mode |= openmode; + } + if ((rflags & NFSV4OPEN_LOCKTYPEPOSIX) != 0 || + nfscl_assumeposixlocks) + op->nfso_posixlock = 1; + else + op->nfso_posixlock = 0; + nfscl_openrelease(nmp, op, 0, 0); + if (ndp != NULL) { + /* + * Since we do not have the vnode, we + * cannot invalidate cached attributes. + * Just return the delegation. + */ + nfscl_trydelegreturn(ndp, cred, nmp, p); + } + } if ((nd->nd_flag & ND_NFSV3) && !error) error = nfscl_postop_attr(nd, dnap, dattrflagp, stuff); nfsmout: m_freem(nd->nd_mrep); if (!error && nd->nd_repstat) error = nd->nd_repstat; + free(ndp, M_NFSCLDELEG); return (error); } diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index bb2c78a72ed9..8ec5b80489f9 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -162,8 +162,6 @@ static int nfscl_recalldeleg(struct nfsclclient *, struct nfsmount *, vnode_t *); static void nfscl_freeopenowner(struct nfsclowner *, int); static void nfscl_cleandeleg(struct nfscldeleg *); -static int nfscl_trydelegreturn(struct nfscldeleg *, struct ucred *, - struct nfsmount *, NFSPROC_T *); static void nfscl_emptylockowner(struct nfscllockowner *, struct nfscllockownerfhhead *); static void nfscl_mergeflayouts(struct nfsclflayouthead *, @@ -4463,7 +4461,7 @@ nfscl_trylock(struct nfsmount *nmp, vnode_t vp, u_int8_t *fhp, * retrying while NFSERR_DELAY. Also, try system credentials, if the passed in * credentials fail. */ -static int +int nfscl_trydelegreturn(struct nfscldeleg *dp, struct ucred *cred, struct nfsmount *nmp, NFSPROC_T *p) { diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 72d9eac8e962..39340692563f 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -1164,6 +1164,7 @@ nfs_lookup(struct vop_lookup_args *ap) struct nfsvattr dnfsva, nfsva; struct vattr vattr; struct timespec nctime; + uint32_t openmode; *vpp = NULLVP; if ((flags & ISLASTCN) && (mp->mnt_flag & MNT_RDONLY) && @@ -1265,11 +1266,30 @@ nfs_lookup(struct vop_lookup_args *ap) cache_purge_negative(dvp); } + /* + * If this an NFSv4.1/4.2 mount using the "oneopenown" mount + * option, it is possible to do the Open operation in the same + * compound as Lookup, so long as delegations are not being + * issued. This saves doing a separate RPC for Open. + */ + openmode = 0; + NFSLOCKMNT(nmp); + if (NFSHASNFSV4N(nmp) && NFSHASONEOPENOWN(nmp) && + (nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0 && + (!NFSMNT_RDONLY(mp) || (flags & OPENWRITE) == 0) && + (flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN)) { + if ((flags & OPENREAD) != 0) + openmode |= NFSV4OPEN_ACCESSREAD; + if ((flags & OPENWRITE) != 0) + openmode |= NFSV4OPEN_ACCESSWRITE; + } + NFSUNLOCKMNT(nmp); + newvp = NULLVP; NFSINCRGLOBAL(nfsstatsv1.lookupcache_misses); error = nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_cred, td, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, - NULL); + NULL, openmode); if (dattrflag) (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); if (error) { @@ -1577,7 +1597,7 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, - NULL); + NULL, 0); if (nfhp) error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); @@ -1693,7 +1713,7 @@ again: (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, - NULL); + NULL, 0); if (nfhp != NULL) error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); @@ -2611,7 +2631,7 @@ nfs_lookitup(struct vnode *dvp, char *name, int len, struct ucred *cred, u_int hash; error = nfsrpc_lookup(dvp, name, len, cred, td, &dnfsva, &nfsva, - &nfhp, &attrflag, &dattrflag, NULL); + &nfhp, &attrflag, &dattrflag, NULL, 0); if (dattrflag) (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); if (npp && !error) { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 02:01:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8343E661511; Thu, 12 Aug 2021 02:01: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 4GlVKC3377z3DWQ; Thu, 12 Aug 2021 02:01: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 522F41A49E; Thu, 12 Aug 2021 02:01: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 17C213Av015191; Thu, 12 Aug 2021 02:01:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C213UE015190; Thu, 12 Aug 2021 02:01:03 GMT (envelope-from git) Date: Thu, 12 Aug 2021 02:01:03 GMT Message-Id: <202108120201.17C213UE015190@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: a3ff18e2715b - main - UPDATING: Add an entry for commit 3ad1e1c1ce20 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/main X-Git-Reftype: branch X-Git-Commit: a3ff18e2715b494016fd27941f8854d66be450bc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 02:01:03 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=a3ff18e2715b494016fd27941f8854d66be450bc commit a3ff18e2715b494016fd27941f8854d66be450bc Author: Rick Macklem AuthorDate: 2021-08-12 01:58:00 +0000 Commit: Rick Macklem CommitDate: 2021-08-12 01:58:00 +0000 UPDATING: Add an entry for commit 3ad1e1c1ce20 --- UPDATING | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UPDATING b/UPDATING index 4aaac623c61f..512f33e9b43d 100644 --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 14.x IS SLOW: world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20210811: + Commit 3ad1e1c1ce20 changed the internal KAPI between the NFS + modules. Therefore, all need to be rebuilt from sources. + 20210730: Commit b69019c14cd8 removes pf's DIOCGETSTATESNV ioctl. As of be70c7a50d32 it is no longer used by userspace, but it does mean From owner-dev-commits-src-all@freebsd.org Thu Aug 12 02:29:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6F277661554; Thu, 12 Aug 2021 02: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 4GlVy32DyKz3GrN; Thu, 12 Aug 2021 02:29: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 355951A92D; Thu, 12 Aug 2021 02:29: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 17C2TVaX044820; Thu, 12 Aug 2021 02:29:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C2TVHI044819; Thu, 12 Aug 2021 02:29:31 GMT (envelope-from git) Date: Thu, 12 Aug 2021 02:29:31 GMT Message-Id: <202108120229.17C2TVHI044819@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 080c6fdc0ce8 - main - dumpon: fix build on some architectures MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 080c6fdc0ce86c55f7cbbe1e86c026f3bc641bb1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 02:29:31 -0000 The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=080c6fdc0ce86c55f7cbbe1e86c026f3bc641bb1 commit 080c6fdc0ce86c55f7cbbe1e86c026f3bc641bb1 Author: Eric van Gyzen AuthorDate: 2021-08-12 02:27:24 +0000 Commit: Eric van Gyzen CommitDate: 2021-08-12 02:27:24 +0000 dumpon: fix build on some architectures Fix a -Wsign-compare issue on some architectures. Fixes: 96f9bd46547d6dfbaf219ab449efacacb0dacccc Pointy hat to: me MFC after: 1 week Sponsored by: Dell EMC Isilon --- sbin/dumpon/dumpon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c index 291239c4bcc8..a11f07a01200 100644 --- a/sbin/dumpon/dumpon.c +++ b/sbin/dumpon/dumpon.c @@ -334,7 +334,7 @@ genkey(const char *pubkeyfile, struct diocskerneldump_arg *kdap) err(1, "genkey pipe write"); bytes = write(filedes[1], kdap->kda_encryptedkey, kdap->kda_encryptedkeysize); - if (bytes != kdap->kda_encryptedkeysize) + if (bytes != (ssize_t)kdap->kda_encryptedkeysize) err(1, "genkey pipe write kda_encryptedkey"); _exit(0); } @@ -351,7 +351,7 @@ genkey(const char *pubkeyfile, struct diocskerneldump_arg *kdap) err(1, "Unable to allocate encrypted key"); bytes = read(filedes[0], kdap->kda_encryptedkey, kdap->kda_encryptedkeysize); - if (bytes != kdap->kda_encryptedkeysize) + if (bytes != (ssize_t)kdap->kda_encryptedkeysize) errx(1, "genkey pipe read kda_encryptedkey"); error = waitpid(pid, &status, WEXITED); if (error == -1) From owner-dev-commits-src-all@freebsd.org Thu Aug 12 06:45:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 24A9E665168; Thu, 12 Aug 2021 06:45: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 4GlcdJ0FPXz3pRZ; Thu, 12 Aug 2021 06:45: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 E4EAB1E1E4; Thu, 12 Aug 2021 06:45: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 17C6jNQZ090445; Thu, 12 Aug 2021 06:45:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C6jNT6090444; Thu, 12 Aug 2021 06:45:23 GMT (envelope-from git) Date: Thu, 12 Aug 2021 06:45:23 GMT Message-Id: <202108120645.17C6jNT6090444@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: ddf1b5ac761e - stable/13 - bhyve: virtio shares definitions between sys/dev/virtio 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: ddf1b5ac761edc6f7c9e3e0788ef4a36b50c5e6a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 06:45:24 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=ddf1b5ac761edc6f7c9e3e0788ef4a36b50c5e6a commit ddf1b5ac761edc6f7c9e3e0788ef4a36b50c5e6a Author: Ka Ho Ng AuthorDate: 2021-08-12 06:44:52 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-12 06:44:52 +0000 bhyve: virtio shares definitions between sys/dev/virtio Definitions inside usr.sbin/bhyve/virtio.h are thrown away. Definitions in sys/dev/virtio are used instead. This reduces code duplication. Sponsored by: The FreeBSD Foundation Reviewed by: grehan Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D29084 (cherry picked from commit 54ac6f721efccdba5a09aa9f38be0a1c4ef6cf14) --- sys/dev/virtio/virtio.h | 4 + sys/dev/virtio/virtio_endian.h | 3 + usr.sbin/bhyve/pci_virtio_9p.c | 2 +- usr.sbin/bhyve/pci_virtio_block.c | 2 +- usr.sbin/bhyve/pci_virtio_console.c | 2 +- usr.sbin/bhyve/pci_virtio_net.c | 2 +- usr.sbin/bhyve/pci_virtio_rnd.c | 2 +- usr.sbin/bhyve/pci_virtio_scsi.c | 2 +- usr.sbin/bhyve/virtio.c | 147 +++++++++++++++++------------------ usr.sbin/bhyve/virtio.h | 150 ++++++------------------------------ 10 files changed, 105 insertions(+), 211 deletions(-) diff --git a/sys/dev/virtio/virtio.h b/sys/dev/virtio/virtio.h index b22327351b43..8d32d5a8742f 100644 --- a/sys/dev/virtio/virtio.h +++ b/sys/dev/virtio/virtio.h @@ -35,6 +35,8 @@ #include #include +#ifdef _KERNEL + struct sbuf; struct vq_alloc_info; @@ -187,4 +189,6 @@ virtio_simple_probe(device_t dev, const struct virtio_pnp_match *match) return (BUS_PROBE_DEFAULT); } +#endif /* _KERNEL */ + #endif /* _VIRTIO_H_ */ diff --git a/sys/dev/virtio/virtio_endian.h b/sys/dev/virtio/virtio_endian.h index d0de299c7227..19d7fcc12079 100644 --- a/sys/dev/virtio/virtio_endian.h +++ b/sys/dev/virtio/virtio_endian.h @@ -32,6 +32,9 @@ #define _VIRTIO_ENDIAN_H_ #include +#ifndef _KERNEL +#include +#endif /* _KERNEL */ /* * VirtIO V1 (modern) uses little endian, while legacy VirtIO uses the guest's diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index 6c6dc483b7ba..830e13878a71 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -340,7 +340,7 @@ pci_vt9p_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_9P); pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_9P); + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_9P); pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c index 3735e0cd3124..0dc58e49594b 100644 --- a/usr.sbin/bhyve/pci_virtio_block.c +++ b/usr.sbin/bhyve/pci_virtio_block.c @@ -531,7 +531,7 @@ pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_BLOCK); pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_BLOCK); + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_BLOCK); pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); if (vi_intr_init(&sc->vbsc_vs, 1, fbsdrun_virtio_msix())) { diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 670287cb3b79..88d6c37f582e 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -712,7 +712,7 @@ pci_vtcon_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_CONSOLE); pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_SIMPLECOMM); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_CONSOLE); + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_CONSOLE); pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c index 409cf9b49654..0ea470a71b56 100644 --- a/usr.sbin/bhyve/pci_virtio_net.c +++ b/usr.sbin/bhyve/pci_virtio_net.c @@ -636,7 +636,7 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_NET); pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_NETWORK); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_NET); + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_NETWORK); pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); /* Link is always up. */ diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index e30328ffd2a7..d51301b32534 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -190,7 +190,7 @@ pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_RANDOM); pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_CRYPTO); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_ENTROPY); + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_ENTROPY); pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); if (vi_intr_init(&sc->vrsc_vs, 1, fbsdrun_virtio_msix())) diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index 33cf67bef12c..e17c3002bc54 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -728,7 +728,7 @@ pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) pci_set_cfgdata16(pi, PCIR_DEVICE, VIRTIO_DEV_SCSI); pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR); pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); - pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_SCSI); + pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_ID_SCSI); pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR); if (vi_intr_init(&sc->vss_vs, 1, fbsdrun_virtio_msix())) diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c index f3deb72b081c..078a74b759df 100644 --- a/usr.sbin/bhyve/virtio.c +++ b/usr.sbin/bhyve/virtio.c @@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -127,10 +129,10 @@ vi_set_io_bar(struct virtio_softc *vs, int barnum) size_t size; /* - * ??? should we use CFG0 if MSI-X is disabled? + * ??? should we use VIRTIO_PCI_CONFIG_OFF(0) if MSI-X is disabled? * Existing code did not... */ - size = VTCFG_R_CFG1 + vs->vs_vc->vc_cfgsize; + size = VIRTIO_PCI_CONFIG_OFF(1) + vs->vs_vc->vc_cfgsize; pci_emul_alloc_bar(vs->vs_pi, barnum, PCIBAR_IO, size); } @@ -182,12 +184,12 @@ vi_vq_init(struct virtio_softc *vs, uint32_t pfn) vq = &vs->vs_queues[vs->vs_curq]; vq->vq_pfn = pfn; phys = (uint64_t)pfn << VRING_PFN; - size = vring_size(vq->vq_qsize); + size = vring_size_aligned(vq->vq_qsize); base = paddr_guest2host(vs->vs_pi->pi_vmctx, phys, size); /* First page(s) are descriptors... */ - vq->vq_desc = (struct virtio_desc *)base; - base += vq->vq_qsize * sizeof(struct virtio_desc); + vq->vq_desc = (struct vring_desc *)base; + base += vq->vq_qsize * sizeof(struct vring_desc); /* ... immediately followed by "avail" ring (entirely uint16_t's) */ vq->vq_avail = (struct vring_avail *)base; @@ -211,15 +213,15 @@ vi_vq_init(struct virtio_softc *vs, uint32_t pfn) * descriptor. */ static inline void -_vq_record(int i, volatile struct virtio_desc *vd, struct vmctx *ctx, +_vq_record(int i, volatile struct vring_desc *vd, struct vmctx *ctx, struct iovec *iov, int n_iov, uint16_t *flags) { if (i >= n_iov) return; - iov[i].iov_base = paddr_guest2host(ctx, vd->vd_addr, vd->vd_len); - iov[i].iov_len = vd->vd_len; + iov[i].iov_base = paddr_guest2host(ctx, vd->addr, vd->len); + iov[i].iov_len = vd->len; if (flags != NULL) - flags[i] = vd->vd_flags; + flags[i] = vd->flags; } #define VQ_MAX_DESCRIPTORS 512 /* see below */ @@ -236,7 +238,7 @@ _vq_record(int i, volatile struct virtio_desc *vd, struct vmctx *ctx, * i.e., we do not count the indirect descriptors, only the "real" * ones. * - * Basically, this vets the vd_flags and vd_next field of each + * Basically, this vets the "flags" and "next" field of each * descriptor and tells you how many are involved. Since some may * be indirect, this also needs the vmctx (in the pci_devinst * at vs->vs_pi) so that it can find indirect descriptors. @@ -253,7 +255,7 @@ _vq_record(int i, volatile struct virtio_desc *vd, struct vmctx *ctx, * * If you want to verify the WRITE flag on each descriptor, pass a * non-NULL "flags" pointer to an array of "uint16_t" of the same size - * as n_iov and we'll copy each vd_flags field after unwinding any + * as n_iov and we'll copy each "flags" field after unwinding any * indirects. * * If some descriptor(s) are invalid, this prints a diagnostic message @@ -269,7 +271,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, int i; u_int ndesc, n_indir; u_int idx, next; - volatile struct virtio_desc *vdir, *vindir, *vp; + volatile struct vring_desc *vdir, *vindir, *vp; struct vmctx *ctx; struct virtio_softc *vs; const char *name; @@ -279,11 +281,11 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, /* * Note: it's the responsibility of the guest not to - * update vq->vq_avail->va_idx until all of the descriptors + * update vq->vq_avail->idx until all of the descriptors * the guest has written are valid (including all their - * vd_next fields and vd_flags). + * "next" fields and "flags"). * - * Compute (va_idx - last_avail) in integers mod 2**16. This is + * Compute (vq_avail->idx - last_avail) in integers mod 2**16. This is * the number of descriptors the device has made available * since the last time we updated vq->vq_last_avail. * @@ -291,7 +293,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, * then trim off excess bits. */ idx = vq->vq_last_avail; - ndesc = (uint16_t)((u_int)vq->vq_avail->va_idx - idx); + ndesc = (uint16_t)((u_int)vq->vq_avail->idx - idx); if (ndesc == 0) return (0); if (ndesc > vq->vq_qsize) { @@ -311,9 +313,9 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, * index, but we just abort if the count gets excessive. */ ctx = vs->vs_pi->pi_vmctx; - *pidx = next = vq->vq_avail->va_ring[idx & (vq->vq_qsize - 1)]; + *pidx = next = vq->vq_avail->ring[idx & (vq->vq_qsize - 1)]; vq->vq_last_avail++; - for (i = 0; i < VQ_MAX_DESCRIPTORS; next = vdir->vd_next) { + for (i = 0; i < VQ_MAX_DESCRIPTORS; next = vdir->next) { if (next >= vq->vq_qsize) { EPRINTLN( "%s: descriptor index %u out of range, " @@ -322,7 +324,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, return (-1); } vdir = &vq->vq_desc[next]; - if ((vdir->vd_flags & VRING_DESC_F_INDIRECT) == 0) { + if ((vdir->flags & VRING_DESC_F_INDIRECT) == 0) { _vq_record(i, vdir, ctx, iov, n_iov, flags); i++; } else if ((vs->vs_vc->vc_hv_caps & @@ -333,16 +335,16 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, name); return (-1); } else { - n_indir = vdir->vd_len / 16; - if ((vdir->vd_len & 0xf) || n_indir == 0) { + n_indir = vdir->len / 16; + if ((vdir->len & 0xf) || n_indir == 0) { EPRINTLN( "%s: invalid indir len 0x%x, " "driver confused?", - name, (u_int)vdir->vd_len); + name, (u_int)vdir->len); return (-1); } vindir = paddr_guest2host(ctx, - vdir->vd_addr, vdir->vd_len); + vdir->addr, vdir->len); /* * Indirects start at the 0th, then follow * their own embedded "next"s until those run @@ -353,7 +355,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, next = 0; for (;;) { vp = &vindir[next]; - if (vp->vd_flags & VRING_DESC_F_INDIRECT) { + if (vp->flags & VRING_DESC_F_INDIRECT) { EPRINTLN( "%s: indirect desc has INDIR flag," " driver confused?", @@ -363,9 +365,9 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, _vq_record(i, vp, ctx, iov, n_iov, flags); if (++i > VQ_MAX_DESCRIPTORS) goto loopy; - if ((vp->vd_flags & VRING_DESC_F_NEXT) == 0) + if ((vp->flags & VRING_DESC_F_NEXT) == 0) break; - next = vp->vd_next; + next = vp->next; if (next >= n_indir) { EPRINTLN( "%s: invalid next %u > %u, " @@ -375,7 +377,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, } } } - if ((vdir->vd_flags & VRING_DESC_F_NEXT) == 0) + if ((vdir->flags & VRING_DESC_F_NEXT) == 0) return (i); } loopy: @@ -402,7 +404,7 @@ void vq_relchain_prepare(struct vqueue_info *vq, uint16_t idx, uint32_t iolen) { volatile struct vring_used *vuh; - volatile struct virtio_used *vue; + volatile struct vring_used_elem *vue; uint16_t mask; /* @@ -410,16 +412,13 @@ vq_relchain_prepare(struct vqueue_info *vq, uint16_t idx, uint32_t iolen) * - mask is N-1 where N is a power of 2 so computes x % N * - vuh points to the "used" data shared with guest * - vue points to the "used" ring entry we want to update - * - * (I apologize for the two fields named vu_idx; the - * virtio spec calls the one that vue points to, "id"...) */ mask = vq->vq_qsize - 1; vuh = vq->vq_used; - vue = &vuh->vu_ring[vq->vq_next_used++ & mask]; - vue->vu_idx = idx; - vue->vu_tlen = iolen; + vue = &vuh->ring[vq->vq_next_used++ & mask]; + vue->id = idx; + vue->len = iolen; } void @@ -431,7 +430,7 @@ vq_relchain_publish(struct vqueue_info *vq) * (and even on x86 to act as a compiler barrier). */ atomic_thread_fence_rel(); - vq->vq_used->vu_idx = vq->vq_next_used; + vq->vq_used->idx = vq->vq_next_used; } /* @@ -481,12 +480,12 @@ vq_endchains(struct vqueue_info *vq, int used_all_avail) */ vs = vq->vq_vs; old_idx = vq->vq_save_used; - vq->vq_save_used = new_idx = vq->vq_used->vu_idx; + vq->vq_save_used = new_idx = vq->vq_used->idx; /* - * Use full memory barrier between vu_idx store from preceding + * Use full memory barrier between "idx" store from preceding * vq_relchain() call and the loads from VQ_USED_EVENT_IDX() or - * va_flags below. + * "flags" field below. */ atomic_thread_fence_seq_cst(); if (used_all_avail && @@ -502,7 +501,7 @@ vq_endchains(struct vqueue_info *vq, int used_all_avail) (uint16_t)(new_idx - old_idx); } else { intr = new_idx != old_idx && - !(vq->vq_avail->va_flags & VRING_AVAIL_F_NO_INTERRUPT); + !(vq->vq_avail->flags & VRING_AVAIL_F_NO_INTERRUPT); } if (intr) vq_interrupt(vs, vq); @@ -515,16 +514,16 @@ static struct config_reg { uint8_t cr_ro; /* true => reg is read only */ const char *cr_name; /* name of reg */ } config_regs[] = { - { VTCFG_R_HOSTCAP, 4, 1, "HOSTCAP" }, - { VTCFG_R_GUESTCAP, 4, 0, "GUESTCAP" }, - { VTCFG_R_PFN, 4, 0, "PFN" }, - { VTCFG_R_QNUM, 2, 1, "QNUM" }, - { VTCFG_R_QSEL, 2, 0, "QSEL" }, - { VTCFG_R_QNOTIFY, 2, 0, "QNOTIFY" }, - { VTCFG_R_STATUS, 1, 0, "STATUS" }, - { VTCFG_R_ISR, 1, 0, "ISR" }, - { VTCFG_R_CFGVEC, 2, 0, "CFGVEC" }, - { VTCFG_R_QVEC, 2, 0, "QVEC" }, + { VIRTIO_PCI_HOST_FEATURES, 4, 1, "HOST_FEATURES" }, + { VIRTIO_PCI_GUEST_FEATURES, 4, 0, "GUEST_FEATURES" }, + { VIRTIO_PCI_QUEUE_PFN, 4, 0, "QUEUE_PFN" }, + { VIRTIO_PCI_QUEUE_NUM, 2, 1, "QUEUE_NUM" }, + { VIRTIO_PCI_QUEUE_SEL, 2, 0, "QUEUE_SEL" }, + { VIRTIO_PCI_QUEUE_NOTIFY, 2, 0, "QUEUE_NOTIFY" }, + { VIRTIO_PCI_STATUS, 1, 0, "STATUS" }, + { VIRTIO_PCI_ISR, 1, 0, "ISR" }, + { VIRTIO_MSI_CONFIG_VECTOR, 2, 0, "CONFIG_VECTOR" }, + { VIRTIO_MSI_QUEUE_VECTOR, 2, 0, "QUEUE_VECTOR" }, }; static inline struct config_reg * @@ -586,10 +585,7 @@ vi_pci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, if (size != 1 && size != 2 && size != 4) goto bad; - if (pci_msix_enabled(pi)) - virtio_config_size = VTCFG_R_CFG1; - else - virtio_config_size = VTCFG_R_CFG0; + virtio_config_size = VIRTIO_PCI_CONFIG_OFF(pci_msix_enabled(pi)); if (offset >= virtio_config_size) { /* @@ -623,39 +619,39 @@ bad: } switch (offset) { - case VTCFG_R_HOSTCAP: + case VIRTIO_PCI_HOST_FEATURES: value = vc->vc_hv_caps; break; - case VTCFG_R_GUESTCAP: + case VIRTIO_PCI_GUEST_FEATURES: value = vs->vs_negotiated_caps; break; - case VTCFG_R_PFN: + case VIRTIO_PCI_QUEUE_PFN: if (vs->vs_curq < vc->vc_nvq) value = vs->vs_queues[vs->vs_curq].vq_pfn; break; - case VTCFG_R_QNUM: + case VIRTIO_PCI_QUEUE_NUM: value = vs->vs_curq < vc->vc_nvq ? vs->vs_queues[vs->vs_curq].vq_qsize : 0; break; - case VTCFG_R_QSEL: + case VIRTIO_PCI_QUEUE_SEL: value = vs->vs_curq; break; - case VTCFG_R_QNOTIFY: + case VIRTIO_PCI_QUEUE_NOTIFY: value = 0; /* XXX */ break; - case VTCFG_R_STATUS: + case VIRTIO_PCI_STATUS: value = vs->vs_status; break; - case VTCFG_R_ISR: + case VIRTIO_PCI_ISR: value = vs->vs_isr; vs->vs_isr = 0; /* a read clears this flag */ if (value) pci_lintr_deassert(pi); break; - case VTCFG_R_CFGVEC: + case VIRTIO_MSI_CONFIG_VECTOR: value = vs->vs_msix_cfg_idx; break; - case VTCFG_R_QVEC: + case VIRTIO_MSI_QUEUE_VECTOR: value = vs->vs_curq < vc->vc_nvq ? vs->vs_queues[vs->vs_curq].vq_msix_idx : VIRTIO_MSI_NO_VECTOR; @@ -706,10 +702,7 @@ vi_pci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, if (size != 1 && size != 2 && size != 4) goto bad; - if (pci_msix_enabled(pi)) - virtio_config_size = VTCFG_R_CFG1; - else - virtio_config_size = VTCFG_R_CFG0; + virtio_config_size = VIRTIO_PCI_CONFIG_OFF(pci_msix_enabled(pi)); if (offset >= virtio_config_size) { /* @@ -747,18 +740,18 @@ bad: } switch (offset) { - case VTCFG_R_GUESTCAP: + case VIRTIO_PCI_GUEST_FEATURES: vs->vs_negotiated_caps = value & vc->vc_hv_caps; if (vc->vc_apply_features) (*vc->vc_apply_features)(DEV_SOFTC(vs), vs->vs_negotiated_caps); break; - case VTCFG_R_PFN: + case VIRTIO_PCI_QUEUE_PFN: if (vs->vs_curq >= vc->vc_nvq) goto bad_qindex; vi_vq_init(vs, value); break; - case VTCFG_R_QSEL: + case VIRTIO_PCI_QUEUE_SEL: /* * Note that the guest is allowed to select an * invalid queue; we just need to return a QNUM @@ -766,7 +759,7 @@ bad: */ vs->vs_curq = value; break; - case VTCFG_R_QNOTIFY: + case VIRTIO_PCI_QUEUE_NOTIFY: if (value >= vc->vc_nvq) { EPRINTLN("%s: queue %d notify out of range", name, (int)value); @@ -782,15 +775,15 @@ bad: "%s: qnotify queue %d: missing vq/vc notify", name, (int)value); break; - case VTCFG_R_STATUS: + case VIRTIO_PCI_STATUS: vs->vs_status = value; if (value == 0) (*vc->vc_reset)(DEV_SOFTC(vs)); break; - case VTCFG_R_CFGVEC: + case VIRTIO_MSI_CONFIG_VECTOR: vs->vs_msix_cfg_idx = value; break; - case VTCFG_R_QVEC: + case VIRTIO_MSI_QUEUE_VECTOR: if (vs->vs_curq >= vc->vc_nvq) goto bad_qindex; vq = &vs->vs_queues[vs->vs_curq]; @@ -896,7 +889,7 @@ vi_pci_snapshot_queues(struct virtio_softc *vs, struct vm_snapshot_meta *meta) SNAPSHOT_VAR_OR_LEAVE(vq->vq_pfn, meta, ret, done); - addr_size = vq->vq_qsize * sizeof(struct virtio_desc); + addr_size = vq->vq_qsize * sizeof(struct vring_desc); SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(vq->vq_desc, addr_size, false, meta, ret, done); @@ -908,8 +901,8 @@ vi_pci_snapshot_queues(struct virtio_softc *vs, struct vm_snapshot_meta *meta) SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(vq->vq_used, addr_size, false, meta, ret, done); - SNAPSHOT_BUF_OR_LEAVE(vq->vq_desc, vring_size(vq->vq_qsize), - meta, ret, done); + SNAPSHOT_BUF_OR_LEAVE(vq->vq_desc, + vring_size_aligned(vq->vq_qsize), meta, ret, done); } done: diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h index b055f0c35941..c5730f71000e 100644 --- a/usr.sbin/bhyve/virtio.h +++ b/usr.sbin/bhyve/virtio.h @@ -28,11 +28,15 @@ * $FreeBSD$ */ -#ifndef _VIRTIO_H_ -#define _VIRTIO_H_ +#ifndef _BHYVE_VIRTIO_H_ +#define _BHYVE_VIRTIO_H_ #include +#include +#include +#include + /* * These are derived from several virtio specifications. * @@ -125,39 +129,6 @@ */ #define VRING_ALIGN 4096 -#define VRING_DESC_F_NEXT (1 << 0) -#define VRING_DESC_F_WRITE (1 << 1) -#define VRING_DESC_F_INDIRECT (1 << 2) - -struct virtio_desc { /* AKA vring_desc */ - uint64_t vd_addr; /* guest physical address */ - uint32_t vd_len; /* length of scatter/gather seg */ - uint16_t vd_flags; /* VRING_F_DESC_* */ - uint16_t vd_next; /* next desc if F_NEXT */ -} __packed; - -struct virtio_used { /* AKA vring_used_elem */ - uint32_t vu_idx; /* head of used descriptor chain */ - uint32_t vu_tlen; /* length written-to */ -} __packed; - -#define VRING_AVAIL_F_NO_INTERRUPT 1 - -struct vring_avail { - uint16_t va_flags; /* VRING_AVAIL_F_* */ - uint16_t va_idx; /* counts to 65535, then cycles */ - uint16_t va_ring[]; /* size N, reported in QNUM value */ -/* uint16_t va_used_event; -- after N ring entries */ -} __packed; - -#define VRING_USED_F_NO_NOTIFY 1 -struct vring_used { - uint16_t vu_flags; /* VRING_USED_F_* */ - uint16_t vu_idx; /* counts to 65535, then cycles */ - struct virtio_used vu_ring[]; /* size N */ -/* uint16_t vu_avail_event; -- after N ring entries */ -} __packed; - /* * The address of any given virtual queue is determined by a single * Page Frame Number register. The guest writes the PFN into the @@ -190,23 +161,6 @@ struct vring_used { */ #define VRING_PFN 12 -/* - * Virtio device types - * - * XXX Should really be merged with defines - */ -#define VIRTIO_TYPE_NET 1 -#define VIRTIO_TYPE_BLOCK 2 -#define VIRTIO_TYPE_CONSOLE 3 -#define VIRTIO_TYPE_ENTROPY 4 -#define VIRTIO_TYPE_BALLOON 5 -#define VIRTIO_TYPE_IOMEMORY 6 -#define VIRTIO_TYPE_RPMSG 7 -#define VIRTIO_TYPE_SCSI 8 -#define VIRTIO_TYPE_9P 9 - -/* experimental IDs start at 65535 and work down */ - /* * PCI vendor/device IDs */ @@ -218,71 +172,11 @@ struct vring_used { #define VIRTIO_DEV_SCSI 0x1008 #define VIRTIO_DEV_9P 0x1009 -/* - * PCI config space constants. - * - * If MSI-X is enabled, the ISR register is generally not used, - * and the configuration vector and queue vector appear at offsets - * 20 and 22 with the remaining configuration registers at 24. - * If MSI-X is not enabled, those two registers disappear and - * the remaining configuration registers start at offset 20. - */ -#define VTCFG_R_HOSTCAP 0 -#define VTCFG_R_GUESTCAP 4 -#define VTCFG_R_PFN 8 -#define VTCFG_R_QNUM 12 -#define VTCFG_R_QSEL 14 -#define VTCFG_R_QNOTIFY 16 -#define VTCFG_R_STATUS 18 -#define VTCFG_R_ISR 19 -#define VTCFG_R_CFGVEC 20 -#define VTCFG_R_QVEC 22 -#define VTCFG_R_CFG0 20 /* No MSI-X */ -#define VTCFG_R_CFG1 24 /* With MSI-X */ -#define VTCFG_R_MSIX 20 - -/* - * Bits in VTCFG_R_STATUS. Guests need not actually set any of these, - * but a guest writing 0 to this register means "please reset". - */ -#define VTCFG_STATUS_ACK 0x01 /* guest OS has acknowledged dev */ -#define VTCFG_STATUS_DRIVER 0x02 /* guest OS driver is loaded */ -#define VTCFG_STATUS_DRIVER_OK 0x04 /* guest OS driver ready */ -#define VTCFG_STATUS_FAILED 0x80 /* guest has given up on this dev */ - -/* - * Bits in VTCFG_R_ISR. These apply only if not using MSI-X. - * - * (We don't [yet?] ever use CONF_CHANGED.) - */ -#define VTCFG_ISR_QUEUES 0x01 /* re-scan queues */ -#define VTCFG_ISR_CONF_CHANGED 0x80 /* configuration changed */ - -#define VIRTIO_MSI_NO_VECTOR 0xFFFF - -/* - * Feature flags. - * Note: bits 0 through 23 are reserved to each device type. - */ -#define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24) -#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28) -#define VIRTIO_RING_F_EVENT_IDX (1 << 29) - /* From section 2.3, "Virtqueue Configuration", of the virtio specification */ -static inline size_t -vring_size(u_int qsz) +static inline int +vring_size_aligned(u_int qsz) { - size_t size; - - /* constant 3 below = va_flags, va_idx, va_used_event */ - size = sizeof(struct virtio_desc) * qsz + sizeof(uint16_t) * (3 + qsz); - size = roundup2(size, VRING_ALIGN); - - /* constant 3 below = vu_flags, vu_idx, vu_avail_event */ - size += sizeof(uint16_t) * 3 + sizeof(struct virtio_used) * qsz; - size = roundup2(size, VRING_ALIGN); - - return (size); + return (roundup2(vring_size(qsz, VRING_ALIGN), VRING_ALIGN)); } struct vmctx; @@ -397,23 +291,23 @@ struct vqueue_info { uint16_t vq_num; /* we're the num'th queue in the softc */ uint16_t vq_flags; /* flags (see above) */ - uint16_t vq_last_avail; /* a recent value of vq_avail->va_idx */ + uint16_t vq_last_avail; /* a recent value of vq_avail->idx */ uint16_t vq_next_used; /* index of the next used slot to be filled */ - uint16_t vq_save_used; /* saved vq_used->vu_idx; see vq_endchains */ + uint16_t vq_save_used; /* saved vq_used->idx; see vq_endchains */ uint16_t vq_msix_idx; /* MSI-X index, or VIRTIO_MSI_NO_VECTOR */ uint32_t vq_pfn; /* PFN of virt queue (not shifted!) */ - volatile struct virtio_desc *vq_desc; /* descriptor array */ + volatile struct vring_desc *vq_desc; /* descriptor array */ volatile struct vring_avail *vq_avail; /* the "avail" ring */ volatile struct vring_used *vq_used; /* the "used" ring */ }; /* as noted above, these are sort of backwards, name-wise */ #define VQ_AVAIL_EVENT_IDX(vq) \ - (*(volatile uint16_t *)&(vq)->vq_used->vu_ring[(vq)->vq_qsize]) + (*(volatile uint16_t *)&(vq)->vq_used->ring[(vq)->vq_qsize]) #define VQ_USED_EVENT_IDX(vq) \ - ((vq)->vq_avail->va_ring[(vq)->vq_qsize]) + ((vq)->vq_avail->ring[(vq)->vq_qsize]) /* * Is this ring ready for I/O? @@ -434,7 +328,7 @@ vq_has_descs(struct vqueue_info *vq) { return (vq_ring_ready(vq) && vq->vq_last_avail != - vq->vq_avail->va_idx); + vq->vq_avail->idx); } /* @@ -449,7 +343,7 @@ vq_interrupt(struct virtio_softc *vs, struct vqueue_info *vq) pci_generate_msix(vs->vs_pi, vq->vq_msix_idx); else { VS_LOCK(vs); - vs->vs_isr |= VTCFG_ISR_QUEUES; + vs->vs_isr |= VIRTIO_PCI_ISR_INTR; pci_generate_msi(vs->vs_pi, 0); pci_lintr_assert(vs->vs_pi); VS_UNLOCK(vs); @@ -460,11 +354,11 @@ static inline void vq_kick_enable(struct vqueue_info *vq) { - vq->vq_used->vu_flags &= ~VRING_USED_F_NO_NOTIFY; + vq->vq_used->flags &= ~VRING_USED_F_NO_NOTIFY; /* - * Full memory barrier to make sure the store to vu_flags - * happens before the load from va_idx, which results from - * a subsequent call to vq_has_descs(). + * Full memory barrier to make sure the store to vq_used->flags + * happens before the load from vq_avail->idx, which results from a + * subsequent call to vq_has_descs(). */ atomic_thread_fence_seq_cst(); } @@ -473,7 +367,7 @@ static inline void vq_kick_disable(struct vqueue_info *vq) { - vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY; + vq->vq_used->flags |= VRING_USED_F_NO_NOTIFY; } struct iovec; @@ -502,4 +396,4 @@ int vi_pci_snapshot(struct vm_snapshot_meta *meta); int vi_pci_pause(struct vmctx *ctx, struct pci_devinst *pi); int vi_pci_resume(struct vmctx *ctx, struct pci_devinst *pi); #endif -#endif /* _VIRTIO_H_ */ +#endif /* _BHYVE_VIRTIO_H_ */ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 06:45:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A704664EA8; Thu, 12 Aug 2021 06:45: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 4GlcdK0qXGz3pfl; Thu, 12 Aug 2021 06:45: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 00DF71E228; Thu, 12 Aug 2021 06:45: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 17C6jOLQ090476; Thu, 12 Aug 2021 06:45:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C6jOO7090475; Thu, 12 Aug 2021 06:45:24 GMT (envelope-from git) Date: Thu, 12 Aug 2021 06:45:24 GMT Message-Id: <202108120645.17C6jOO7090475@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: 3fc8a816d9a3 - stable/13 - bhyve: change vq_getchain to return iovecs in both directions 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: 3fc8a816d9a34462b473b1db3ccdd073efa91cd0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 06:45:25 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=3fc8a816d9a34462b473b1db3ccdd073efa91cd0 commit 3fc8a816d9a34462b473b1db3ccdd073efa91cd0 Author: Ka Ho Ng AuthorDate: 2021-03-30 08:43:24 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-12 06:45:01 +0000 bhyve: change vq_getchain to return iovecs in both directions The old prototype requires callers to inspect flags of each descriptors to get the starting position of host-writable iovecs. vq_getchain() is changed to return a virtio request with the number of host-readable iovecs and host-writable iovecs instead. Callers can avoid boilerplate code of getting the start offset of host-writable iovecs. Sponsored by: The FreeBSD Foundation Reviewed by: afedorov Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D29433 (cherry picked from commit b013912772ec9e135b52aaec5f70bc92a191ebdb) --- usr.sbin/bhyve/pci_virtio_9p.c | 22 +++++++--------------- usr.sbin/bhyve/pci_virtio_block.c | 25 +++++++++++++------------ usr.sbin/bhyve/pci_virtio_console.c | 20 ++++++++++---------- usr.sbin/bhyve/pci_virtio_net.c | 12 +++++++----- usr.sbin/bhyve/pci_virtio_rnd.c | 6 +++--- usr.sbin/bhyve/pci_virtio_scsi.c | 34 +++++++++++++--------------------- usr.sbin/bhyve/virtio.c | 36 +++++++++++++++++++++--------------- usr.sbin/bhyve/virtio.h | 16 ++++++++++++++-- 8 files changed, 88 insertions(+), 83 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index 830e13878a71..f96d53858225 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -197,32 +197,24 @@ pci_vt9p_notify(void *vsc, struct vqueue_info *vq) struct iovec iov[VT9P_MAX_IOV]; struct pci_vt9p_softc *sc; struct pci_vt9p_request *preq; - uint16_t idx, n, i; - uint16_t flags[VT9P_MAX_IOV]; + struct vi_req req; + uint16_t n; sc = vsc; while (vq_has_descs(vq)) { - n = vq_getchain(vq, &idx, iov, VT9P_MAX_IOV, flags); + n = vq_getchain(vq, iov, VT9P_MAX_IOV, &req); preq = calloc(1, sizeof(struct pci_vt9p_request)); preq->vsr_sc = sc; - preq->vsr_idx = idx; + preq->vsr_idx = req.idx; preq->vsr_iov = iov; preq->vsr_niov = n; - preq->vsr_respidx = 0; - - /* Count readable descriptors */ - for (i = 0; i < n; i++) { - if (flags[i] & VRING_DESC_F_WRITE) - break; - - preq->vsr_respidx++; - } + preq->vsr_respidx = req.readable; for (int i = 0; i < n; i++) { DPRINTF(("vt9p: vt9p_notify(): desc%d base=%p, " - "len=%zu, flags=0x%04x\r\n", i, iov[i].iov_base, - iov[i].iov_len, flags[i])); + "len=%zu\r\n", i, iov[i].iov_base, + iov[i].iov_len)); } l9p_connection_recv(sc->vsc_conn, iov, preq->vsr_respidx, preq); diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c index 0dc58e49594b..8a172c54eda7 100644 --- a/usr.sbin/bhyve/pci_virtio_block.c +++ b/usr.sbin/bhyve/pci_virtio_block.c @@ -308,11 +308,11 @@ pci_vtblk_proc(struct pci_vtblk_softc *sc, struct vqueue_info *vq) int err; ssize_t iolen; int writeop, type; + struct vi_req req; struct iovec iov[BLOCKIF_IOV_MAX + 2]; - uint16_t idx, flags[BLOCKIF_IOV_MAX + 2]; struct virtio_blk_discard_write_zeroes *discard; - n = vq_getchain(vq, &idx, iov, BLOCKIF_IOV_MAX + 2, flags); + n = vq_getchain(vq, iov, BLOCKIF_IOV_MAX + 2, &req); /* * The first descriptor will be the read-only fixed header, @@ -324,16 +324,16 @@ pci_vtblk_proc(struct pci_vtblk_softc *sc, struct vqueue_info *vq) */ assert(n >= 2 && n <= BLOCKIF_IOV_MAX + 2); - io = &sc->vbsc_ios[idx]; - assert((flags[0] & VRING_DESC_F_WRITE) == 0); + io = &sc->vbsc_ios[req.idx]; + assert(req.readable != 0); assert(iov[0].iov_len == sizeof(struct virtio_blk_hdr)); vbh = (struct virtio_blk_hdr *)iov[0].iov_base; memcpy(&io->io_req.br_iov, &iov[1], sizeof(struct iovec) * (n - 2)); io->io_req.br_iovcnt = n - 2; io->io_req.br_offset = vbh->vbh_sector * VTBLK_BSIZE; io->io_status = (uint8_t *)iov[--n].iov_base; + assert(req.writable != 0); assert(iov[n].iov_len == 1); - assert(flags[n] & VRING_DESC_F_WRITE); /* * XXX @@ -342,16 +342,17 @@ pci_vtblk_proc(struct pci_vtblk_softc *sc, struct vqueue_info *vq) */ type = vbh->vbh_type & ~VBH_FLAG_BARRIER; writeop = (type == VBH_OP_WRITE || type == VBH_OP_DISCARD); + /* + * - Write op implies read-only descriptor + * - Read/ident op implies write-only descriptor + * + * By taking away either the read-only fixed header or the write-only + * status iovec, the following condition should hold true. + */ + assert(n == (writeop ? req.readable : req.writable)); iolen = 0; for (i = 1; i < n; i++) { - /* - * - write op implies read-only descriptor, - * - read/ident op implies write-only descriptor, - * therefore test the inverse of the descriptor bit - * to the op. - */ - assert(((flags[i] & VRING_DESC_F_WRITE) == 0) == writeop); iolen += iov[i].iov_len; } io->io_req.br_resid = iolen; diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 88d6c37f582e..6832a3f92774 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -415,10 +415,10 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) struct pci_vtcon_port *port; struct pci_vtcon_sock *sock = (struct pci_vtcon_sock *)arg; struct vqueue_info *vq; + struct vi_req req; struct iovec iov; static char dummybuf[2048]; int len, n; - uint16_t idx; port = sock->vss_port; vq = pci_vtcon_port_to_vq(port, true); @@ -441,7 +441,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) } do { - n = vq_getchain(vq, &idx, &iov, 1, NULL); + n = vq_getchain(vq, &iov, 1, &req); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -453,7 +453,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) return; } - vq_relchain(vq, idx, len); + vq_relchain(vq, req.idx, len); } while (vq_has_descs(vq)); vq_endchains(vq, 1); @@ -572,8 +572,8 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, struct pci_vtcon_control *ctrl, const void *payload, size_t len) { struct vqueue_info *vq; + struct vi_req req; struct iovec iov; - uint16_t idx; int n; vq = pci_vtcon_port_to_vq(&sc->vsc_control_port, true); @@ -581,7 +581,7 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, if (!vq_has_descs(vq)) return; - n = vq_getchain(vq, &idx, &iov, 1, NULL); + n = vq_getchain(vq, &iov, 1, &req); assert(n == 1); @@ -590,7 +590,7 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, memcpy(iov.iov_base + sizeof(struct pci_vtcon_control), payload, len); - vq_relchain(vq, idx, sizeof(struct pci_vtcon_control) + len); + vq_relchain(vq, req.idx, sizeof(struct pci_vtcon_control) + len); vq_endchains(vq, 1); } @@ -601,14 +601,14 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_softc *sc; struct pci_vtcon_port *port; struct iovec iov[1]; - uint16_t idx, n; - uint16_t flags[8]; + struct vi_req req; + uint16_t n; sc = vsc; port = pci_vtcon_vq_to_port(sc, vq); while (vq_has_descs(vq)) { - n = vq_getchain(vq, &idx, iov, 1, flags); + n = vq_getchain(vq, iov, 1, &req); assert(n >= 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); @@ -616,7 +616,7 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) /* * Release this chain and handle more */ - vq_relchain(vq, idx, 0); + vq_relchain(vq, req.idx, 0); } vq_endchains(vq, 1); /* Generate interrupt if appropriate. */ } diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c index 0ea470a71b56..d253b081d13a 100644 --- a/usr.sbin/bhyve/pci_virtio_net.c +++ b/usr.sbin/bhyve/pci_virtio_net.c @@ -248,6 +248,7 @@ pci_vtnet_rx(struct pci_vtnet_softc *sc) struct virtio_mrg_rxbuf_info info[VTNET_MAXSEGS]; struct iovec iov[VTNET_MAXSEGS + 1]; struct vqueue_info *vq; + struct vi_req req; vq = &sc->vsc_queues[VTNET_RXQ]; @@ -288,8 +289,9 @@ pci_vtnet_rx(struct pci_vtnet_softc *sc) riov = iov; n_chains = 0; do { - int n = vq_getchain(vq, &info[n_chains].idx, riov, - VTNET_MAXSEGS - riov_len, NULL); + int n = vq_getchain(vq, riov, VTNET_MAXSEGS - riov_len, + &req); + info[n_chains].idx = req.idx; if (n == 0) { /* @@ -435,7 +437,7 @@ pci_vtnet_proctx(struct pci_vtnet_softc *sc, struct vqueue_info *vq) { struct iovec iov[VTNET_MAXSEGS + 1]; struct iovec *siov = iov; - uint16_t idx; + struct vi_req req; ssize_t len; int n; @@ -443,7 +445,7 @@ pci_vtnet_proctx(struct pci_vtnet_softc *sc, struct vqueue_info *vq) * Obtain chain of descriptors. The first descriptor also * contains the virtio-net header. */ - n = vq_getchain(vq, &idx, iov, VTNET_MAXSEGS, NULL); + n = vq_getchain(vq, iov, VTNET_MAXSEGS, &req); assert(n >= 1 && n <= VTNET_MAXSEGS); if (sc->vhdrlen != sc->be_vhdrlen) { @@ -473,7 +475,7 @@ pci_vtnet_proctx(struct pci_vtnet_softc *sc, struct vqueue_info *vq) * Return the processed chain to the guest, reporting * the number of bytes that we read. */ - vq_relchain(vq, idx, len); + vq_relchain(vq, req.idx, len); } /* Called on TX kick. */ diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index d51301b32534..1d2d6144f949 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -113,8 +113,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) { struct iovec iov; struct pci_vtrnd_softc *sc; + struct vi_req req; int len; - uint16_t idx; sc = vsc; @@ -124,7 +124,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &idx, &iov, 1, NULL); + vq_getchain(vq, &iov, 1, &req); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); @@ -136,7 +136,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) /* * Release this chain and handle more */ - vq_relchain(vq, idx, len); + vq_relchain(vq, req.idx, len); } vq_endchains(vq, 1); /* Generate interrupt if appropriate. */ } diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index e17c3002bc54..e8124b9b3441 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -558,7 +558,8 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) { struct pci_vtscsi_softc *sc; struct iovec iov[VTSCSI_MAXSEG]; - uint16_t idx, n; + struct vi_req req; + uint16_t n; void *buf = NULL; size_t bufsize; int iolen; @@ -566,7 +567,7 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) sc = vsc; while (vq_has_descs(vq)) { - n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, NULL); + n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &req); bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); buf_to_iov(buf + bufsize - iolen, iolen, iov, n, @@ -575,7 +576,7 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) /* * Release this chain and handle more */ - vq_relchain(vq, idx, iolen); + vq_relchain(vq, req.idx, iolen); } vq_endchains(vq, 1); /* Generate interrupt if appropriate. */ free(buf); @@ -595,33 +596,23 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_queue *q; struct pci_vtscsi_request *req; struct iovec iov[VTSCSI_MAXSEG]; - uint16_t flags[VTSCSI_MAXSEG]; - uint16_t idx, n, i; - int readable; + struct vi_req vireq; + uint16_t n; sc = vsc; q = &sc->vss_queues[vq->vq_num - 2]; while (vq_has_descs(vq)) { - readable = 0; - n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, flags); - - /* Count readable descriptors */ - for (i = 0; i < n; i++) { - if (flags[i] & VRING_DESC_F_WRITE) - break; - - readable++; - } + n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &vireq); req = calloc(1, sizeof(struct pci_vtscsi_request)); - req->vsr_idx = idx; + req->vsr_idx = vireq.idx; req->vsr_queue = q; - req->vsr_niov_in = readable; - req->vsr_niov_out = n - readable; + req->vsr_niov_in = vireq.readable; + req->vsr_niov_out = vireq.writable; memcpy(req->vsr_iov_in, iov, req->vsr_niov_in * sizeof(struct iovec)); - memcpy(req->vsr_iov_out, iov + readable, + memcpy(req->vsr_iov_out, iov + vireq.readable, req->vsr_niov_out * sizeof(struct iovec)); pthread_mutex_lock(&q->vsq_mtx); @@ -629,7 +620,8 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) pthread_cond_signal(&q->vsq_cv); pthread_mutex_unlock(&q->vsq_mtx); - DPRINTF(("virtio-scsi: request enqueued", idx)); + DPRINTF(("virtio-scsi: request enqueued", + vireq.idx)); } } diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c index 078a74b759df..7f0485cbb826 100644 --- a/usr.sbin/bhyve/virtio.c +++ b/usr.sbin/bhyve/virtio.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -213,15 +214,18 @@ vi_vq_init(struct virtio_softc *vs, uint32_t pfn) * descriptor. */ static inline void -_vq_record(int i, volatile struct vring_desc *vd, struct vmctx *ctx, - struct iovec *iov, int n_iov, uint16_t *flags) { +_vq_record(int i, volatile struct vring_desc *vd, + struct vmctx *ctx, struct iovec *iov, int n_iov, + struct vi_req *reqp) { if (i >= n_iov) return; iov[i].iov_base = paddr_guest2host(ctx, vd->addr, vd->len); iov[i].iov_len = vd->len; - if (flags != NULL) - flags[i] = vd->flags; + if ((vd->flags & VRING_DESC_F_WRITE) == 0) + reqp->readable++; + else + reqp->writable++; } #define VQ_MAX_DESCRIPTORS 512 /* see below */ @@ -253,11 +257,6 @@ _vq_record(int i, volatile struct vring_desc *vd, struct vmctx *ctx, * a larger iov array if needed, or supply a zero length to find * out how much space is needed). * - * If you want to verify the WRITE flag on each descriptor, pass a - * non-NULL "flags" pointer to an array of "uint16_t" of the same size - * as n_iov and we'll copy each "flags" field after unwinding any - * indirects. - * * If some descriptor(s) are invalid, this prints a diagnostic message * and returns -1. If no descriptors are ready now it simply returns 0. * @@ -265,12 +264,13 @@ _vq_record(int i, volatile struct vring_desc *vd, struct vmctx *ctx, * that vq_has_descs() does one). */ int -vq_getchain(struct vqueue_info *vq, uint16_t *pidx, - struct iovec *iov, int n_iov, uint16_t *flags) +vq_getchain(struct vqueue_info *vq, struct iovec *iov, int niov, + struct vi_req *reqp) { int i; u_int ndesc, n_indir; u_int idx, next; + struct vi_req req; volatile struct vring_desc *vdir, *vindir, *vp; struct vmctx *ctx; struct virtio_softc *vs; @@ -278,6 +278,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, vs = vq->vq_vs; name = vs->vs_vc->vc_name; + memset(&req, 0, sizeof(req)); /* * Note: it's the responsibility of the guest not to @@ -313,7 +314,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, * index, but we just abort if the count gets excessive. */ ctx = vs->vs_pi->pi_vmctx; - *pidx = next = vq->vq_avail->ring[idx & (vq->vq_qsize - 1)]; + req.idx = next = vq->vq_avail->ring[idx & (vq->vq_qsize - 1)]; vq->vq_last_avail++; for (i = 0; i < VQ_MAX_DESCRIPTORS; next = vdir->next) { if (next >= vq->vq_qsize) { @@ -325,7 +326,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, } vdir = &vq->vq_desc[next]; if ((vdir->flags & VRING_DESC_F_INDIRECT) == 0) { - _vq_record(i, vdir, ctx, iov, n_iov, flags); + _vq_record(i, vdir, ctx, iov, niov, &req); i++; } else if ((vs->vs_vc->vc_hv_caps & VIRTIO_RING_F_INDIRECT_DESC) == 0) { @@ -362,7 +363,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, name); return (-1); } - _vq_record(i, vp, ctx, iov, n_iov, flags); + _vq_record(i, vp, ctx, iov, niov, &req); if (++i > VQ_MAX_DESCRIPTORS) goto loopy; if ((vp->flags & VRING_DESC_F_NEXT) == 0) @@ -378,13 +379,18 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx, } } if ((vdir->flags & VRING_DESC_F_NEXT) == 0) - return (i); + goto done; } + loopy: EPRINTLN( "%s: descriptor loop? count > %d - driver confused?", name, i); return (-1); + +done: + *reqp = req; + return (i); } /* diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h index c5730f71000e..e03fd5f710d1 100644 --- a/usr.sbin/bhyve/virtio.h +++ b/usr.sbin/bhyve/virtio.h @@ -371,6 +371,18 @@ vq_kick_disable(struct vqueue_info *vq) } struct iovec; + +/* + * Request description returned by vq_getchain. + * + * Writable iovecs start at iov[req.readable]. + */ +struct vi_req { + int readable; /* num of readable iovecs */ + int writable; /* num of writable iovecs */ + unsigned int idx; /* ring index */ +}; + void vi_softc_linkup(struct virtio_softc *vs, struct virtio_consts *vc, void *dev_softc, struct pci_devinst *pi, struct vqueue_info *queues); @@ -378,8 +390,8 @@ int vi_intr_init(struct virtio_softc *vs, int barnum, int use_msix); void vi_reset_dev(struct virtio_softc *); void vi_set_io_bar(struct virtio_softc *, int); -int vq_getchain(struct vqueue_info *vq, uint16_t *pidx, - struct iovec *iov, int n_iov, uint16_t *flags); +int vq_getchain(struct vqueue_info *vq, struct iovec *iov, int niov, + struct vi_req *reqp); void vq_retchains(struct vqueue_info *vq, uint16_t n_chains); void vq_relchain_prepare(struct vqueue_info *vq, uint16_t idx, uint32_t iolen); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 07:24:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8EF36665911; Thu, 12 Aug 2021 07:24:19 +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 4GldVC2z7Jz3sWn; Thu, 12 Aug 2021 07:24: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 4ED351EBBB; Thu, 12 Aug 2021 07:24: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 17C7OJp1043709; Thu, 12 Aug 2021 07:24:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C7OJ8h043708; Thu, 12 Aug 2021 07:24:19 GMT (envelope-from git) Date: Thu, 12 Aug 2021 07:24:19 GMT Message-Id: <202108120724.17C7OJ8h043708@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger Pau Monn=C3=A9?= Subject: git: f4c6843ec2b9 - main - xen: use correct cache attributes for Xen specific memory regions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f4c6843ec2b9aa5eff475778fb000ed6278c5b77 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 07:24:19 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=f4c6843ec2b9aa5eff475778fb000ed6278c5b77 commit f4c6843ec2b9aa5eff475778fb000ed6278c5b77 Author: Roger Pau Monné AuthorDate: 2021-04-09 09:31:44 +0000 Commit: Roger Pau Monné CommitDate: 2021-08-12 07:18:32 +0000 xen: use correct cache attributes for Xen specific memory regions bus_activate_resource maps memory regions as uncacheable on x86, which is more strict than required for regions allocated using xenmem_alloc, so don't rely on bus_activate_resource and instead map the region using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. Sponsored by: Citrix Systems R&D --- sys/dev/xen/bus/xenpv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/xen/bus/xenpv.c b/sys/dev/xen/bus/xenpv.c index 42f2c88a2885..91004039a85e 100644 --- a/sys/dev/xen/bus/xenpv.c +++ b/sys/dev/xen/bus/xenpv.c @@ -120,10 +120,11 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size) { struct resource *res; vm_paddr_t phys_addr; + void *virt_addr; int error; res = bus_alloc_resource(child, SYS_RES_MEMORY, res_id, LOW_MEM_LIMIT, - ~0, size, RF_ACTIVE); + ~0, size, RF_ACTIVE | RF_UNMAPPED); if (res == NULL) return (NULL); @@ -134,6 +135,9 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size) bus_release_resource(child, SYS_RES_MEMORY, *res_id, res); return (NULL); } + virt_addr = pmap_mapdev_attr(phys_addr, size, VM_MEMATTR_XEN); + KASSERT(virt_addr != NULL, ("Failed to create linear mappings")); + rman_set_virtual(res, virt_addr); return (res); } @@ -142,11 +146,14 @@ static int xenpv_free_physmem(device_t dev, device_t child, int res_id, struct resource *res) { vm_paddr_t phys_addr; + vm_offset_t virt_addr; size_t size; phys_addr = rman_get_start(res); size = rman_get_size(res); + virt_addr = (vm_offset_t)rman_get_virtual(res); + pmap_unmapdev(virt_addr, size); vm_phys_fictitious_unreg_range(phys_addr, phys_addr + size); return (bus_release_resource(child, SYS_RES_MEMORY, res_id, res)); } From owner-dev-commits-src-all@freebsd.org Thu Aug 12 07:24:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9A7F8665719; Thu, 12 Aug 2021 07:24: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 4GldVD3m69z3sZ8; Thu, 12 Aug 2021 07:24: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 6A45B1EADC; Thu, 12 Aug 2021 07:24: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 17C7OKKj043737; Thu, 12 Aug 2021 07:24:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C7OK0X043736; Thu, 12 Aug 2021 07:24:20 GMT (envelope-from git) Date: Thu, 12 Aug 2021 07:24:20 GMT Message-Id: <202108120724.17C7OK0X043736@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger Pau Monn=C3=A9?= Subject: git: 5e4279a8f35a - main - loader: fix multiboot loading on UEFI MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5e4279a8f35aa4b46debf728d3f743d64f15aaf8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 07:24:20 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=5e4279a8f35aa4b46debf728d3f743d64f15aaf8 commit 5e4279a8f35aa4b46debf728d3f743d64f15aaf8 Author: Roger Pau Monné AuthorDate: 2021-08-11 14:55:10 +0000 Commit: Roger Pau Monné CommitDate: 2021-08-12 07:18:33 +0000 loader: fix multiboot loading on UEFI The Xen kernel has no symbol tables, so calling lookup_symbol against it triggers the following Divide by Zero fault: Loading Xen kernel... /boot/xen data=0x2809c8+0x149638 | !!!! X64 Exception Type - 00(#DE - Divide Error) CPU Apic ID - 00000000 !!!! Fix lookup_symbol to prevent the #DE fault from happening if the symbol table is not loaded and also fix loadfile_raw to mark multiboot kernels as relocatable, since the only multiboot kernel supported is Xen and was already unconditionally booted as relocatable. Fixes: f75caed644a5 ('amd64 UEFI loader: stop copying staging area to 2M physical') Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D31507 --- stand/common/load_elf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 9ae91036dbb4..c163b50c9737 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -447,7 +447,7 @@ __elfN(loadfile_raw)(char *filename, uint64_t dest, *result = (struct preloaded_file *)fp; err = 0; #ifdef __amd64__ - fp->f_kernphys_relocatable = is_kernphys_relocatable(&ef); + fp->f_kernphys_relocatable = multiboot || is_kernphys_relocatable(&ef); #endif goto out; @@ -1253,6 +1253,11 @@ __elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp, char *strp; unsigned long hash; + if (ef->nbuckets == 0) { + printf(__elfN(bad_symtable)); + return ENOENT; + } + hash = elf_hash(name); COPYOUT(&ef->buckets[hash % ef->nbuckets], &symnum, sizeof(symnum)); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 07:56:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CB0E666129; Thu, 12 Aug 2021 07:56:43 +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 4GlfCb1wLTz3tX4; Thu, 12 Aug 2021 07:56: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 29E291EEDC; Thu, 12 Aug 2021 07:56: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 17C7uhgF083486; Thu, 12 Aug 2021 07:56:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C7uhtG083485; Thu, 12 Aug 2021 07:56:43 GMT (envelope-from git) Date: Thu, 12 Aug 2021 07:56:43 GMT Message-Id: <202108120756.17C7uhtG083485@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 179bc5729dd7 - main - vmm: Fix wrong assert in ivhd_dev_add_entry 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/main X-Git-Reftype: branch X-Git-Commit: 179bc5729dd72e0f4252c0dce72454c76782f935 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 07:56:43 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=179bc5729dd72e0f4252c0dce72454c76782f935 commit 179bc5729dd72e0f4252c0dce72454c76782f935 Author: Ka Ho Ng AuthorDate: 2021-08-12 07:54:40 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-12 07:56:16 +0000 vmm: Fix wrong assert in ivhd_dev_add_entry The correct condition is to check the number of ivhd entries fit into the array. Reported by: bz Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D31514 --- sys/amd64/vmm/amd/ivrs_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/amd64/vmm/amd/ivrs_drv.c b/sys/amd64/vmm/amd/ivrs_drv.c index 68c31788e29d..a0b332e297b1 100644 --- a/sys/amd64/vmm/amd/ivrs_drv.c +++ b/sys/amd64/vmm/amd/ivrs_drv.c @@ -184,7 +184,7 @@ ivhd_dev_add_entry(struct amdvi_softc *softc, uint32_t start_id, { struct ivhd_dev_cfg *dev_cfg; - KASSERT(softc->dev_cfg_cap <= softc->dev_cfg_cnt, + KASSERT(softc->dev_cfg_cap >= softc->dev_cfg_cnt, ("Impossible case: number of dev_cfg exceeding capacity")); if (softc->dev_cfg_cap == softc->dev_cfg_cnt) { if (softc->dev_cfg_cap == 0) From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:03:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2112566617F; Thu, 12 Aug 2021 08:03:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlfM00B0dz3vV5; Thu, 12 Aug 2021 08:03:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:470:7a58:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id C2A37211A0; Thu, 12 Aug 2021 08:03:07 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (unknown [IPv6:2001:470:7a58:0:28ab:4f5b:fc9e:e5fa]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id E532750DDA; Thu, 12 Aug 2021 10:03:05 +0200 (CEST) From: Dimitry Andric Message-Id: <3ED3B825-9D07-41E4-8053-043330232FA6@FreeBSD.org> Content-Type: multipart/signed; boundary="Apple-Mail=_B3B00E4E-7A5A-4705-B6A8-3EAAEB1EAFB0"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Rbuildworld failure: ar: warning: can't open file: x509_minimal.pieo (an other .pieo files) Date: Thu, 12 Aug 2021 10:02:50 +0200 In-Reply-To: <20210811122247.42b24b7e@thor.intern.walstatt.dynvpn.de> Cc: Alexander Motin , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" To: FreeBSD User References: <202108110218.17B2IZ1q006958@gitrepo.freebsd.org> <20210811114645.3c4fb095@thor.intern.walstatt.dynvpn.de> <20210811122247.42b24b7e@thor.intern.walstatt.dynvpn.de> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:03:08 -0000 --Apple-Mail=_B3B00E4E-7A5A-4705-B6A8-3EAAEB1EAFB0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 11 Aug 2021, at 12:22, FreeBSD User wrote: >=20 > Am Wed, 11 Aug 2021 11:46:18 +0200 > FreeBSD User schrieb: >> Am Wed, 11 Aug 2021 02:18:35 GMT >> Alexander Motin schrieb: ... > After a fresh build from scratch the error reported in the first = message seems to be a bit > cloudy, but after restarting the buildworld again (without cleanup the = world), I (naively) > guess the error shown then (see below) covers a bit more of the source = of the fault. ... > zstd_shim.pieo zstd.pieo ar: warning: can't open file: ccopy.pieo: No = such file or directory > ar: warning: can't open file: dec32be.pieo: No such file or directory = ar: warning: can't open > file: dec64be.pieo: No such file or directory ar: warning: can't open = file: enc32be.pieo: No > such file or directory ar: warning: can't open file: enc64be.pieo: No = such file or directory > ar: warning: can't open file: pemdec.pieo: No such file or directory = ar: warning: can't open > file: ec_all_m31.pieo: No such file or directory ar: warning: can't = open file: This is because ar started returning failures for missing object files. It should now be fixed by Warner's commit = https://cgit.freebsd.org/src/commit/?id=3D879675e9a0d84880cad9834e2ef98e87= 24c5532c ("stand: Add MK_PIE=3Dno to defs.mk"). -Dimitry --Apple-Mail=_B3B00E4E-7A5A-4705-B6A8-3EAAEB1EAFB0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYRTVqgAKCRCwXqMKLiCW o4aGAKDrJV0PunrGiXi9dMjoa8Vpw75dXACgmwhsuq1abzTL1WjoPu5H0Y4Yp1M= =PEa8 -----END PGP SIGNATURE----- --Apple-Mail=_B3B00E4E-7A5A-4705-B6A8-3EAAEB1EAFB0-- From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:36:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 68B4C6665EA; Thu, 12 Aug 2021 08:36: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 4Glg5Z2GnSz4RPC; Thu, 12 Aug 2021 08:36: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 35AD21F947; Thu, 12 Aug 2021 08:36: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 17C8aYiV037209; Thu, 12 Aug 2021 08:36:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8aYAh037208; Thu, 12 Aug 2021 08:36:34 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:36:34 GMT Message-Id: <202108120836.17C8aYAh037208@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 6e31bed646c2 - main - linux(4): Fix futex copyrights. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6e31bed646c2f67cbcfd4bb2ce38aadd15868dcc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:36:34 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6e31bed646c2f67cbcfd4bb2ce38aadd15868dcc commit 6e31bed646c2f67cbcfd4bb2ce38aadd15868dcc Author: Dmitry Chagin AuthorDate: 2021-08-12 08:36:24 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:36:24 +0000 linux(4): Fix futex copyrights. As no more NetBSD code in futexes exists replace NetBSD copyrights by standard FreeBSD 2 clause license. Add Roman Divacky's copyrights as an author of the robust futexes. Differential revision: https://reviews.freebsd.org/D31347 MFC after: 2 weeks --- sys/compat/linux/linux_futex.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index edd2e369f0cf..e85d7792841b 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -1,11 +1,8 @@ -/* $NetBSD: linux_futex.c,v 1.7 2006/07/24 19:01:49 manu Exp $ */ - /*- - * SPDX-License-Identifier: BSD-4-Clause + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2005 Emmanuel Dreyfus - * All rights reserved. - * Copyright (c) 2009-2016 Dmitry Chagin + * Copyright (c) 2009-2021 Dmitry Chagin + * Copyright (c) 2008 Roman Divacky * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -15,31 +12,22 @@ * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Emmanuel Dreyfus - * 4. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. * - * THIS SOFTWARE IS PROVIDED BY THE 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. + * 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. */ #include __FBSDID("$FreeBSD$"); -#if 0 -__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.7 2006/07/24 19:01:49 manu Exp $"); -#endif #include "opt_compat.h" From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:41:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDA226669E8; Thu, 12 Aug 2021 08:41: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 4GlgCc6S7gz4RhG; Thu, 12 Aug 2021 08:41: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 C56161FB32; Thu, 12 Aug 2021 08:41: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 17C8fmgc049008; Thu, 12 Aug 2021 08:41:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8fmRI049007; Thu, 12 Aug 2021 08:41:48 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:41:48 GMT Message-Id: <202108120841.17C8fmRI049007@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 13d79be9950d - main - linux(4): Implement faccessat2 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 13d79be9950dd820628906dcad4f4f1365b307b9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:41:49 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=13d79be9950dd820628906dcad4f4f1365b307b9 commit 13d79be9950dd820628906dcad4f4f1365b307b9 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:40:42 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:40:42 +0000 linux(4): Implement faccessat2 system call. It's used by bash on arm64 with glibc-2.32. Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D31345 MFC after: 2 weeks --- sys/amd64/linux/syscalls.master | 7 +++++- sys/amd64/linux32/syscalls.master | 7 +++++- sys/arm64/linux/syscalls.master | 7 +++++- sys/compat/linux/linux_file.c | 45 +++++++++++++++++++++++++++++++++------ sys/i386/linux/syscalls.master | 7 +++++- 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/sys/amd64/linux/syscalls.master b/sys/amd64/linux/syscalls.master index 4762a2ccc6a5..b9b88a036e61 100644 --- a/sys/amd64/linux/syscalls.master +++ b/sys/amd64/linux/syscalls.master @@ -2094,7 +2094,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index be6c150eebfa..60f227142f01 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2496,7 +2496,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void); diff --git a/sys/arm64/linux/syscalls.master b/sys/arm64/linux/syscalls.master index ca45e33d4190..7b4ebbb2c2e9 100644 --- a/sys/arm64/linux/syscalls.master +++ b/sys/arm64/linux/syscalls.master @@ -1743,7 +1743,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 013c435756fb..a1146c6a195a 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); static int linux_common_open(struct thread *, int, const char *, int, int, enum uio_seg); +static int linux_do_accessat(struct thread *t, int, const char *, int, int); static int linux_getdents_error(struct thread *, int, int); static struct bsd_to_linux_bitmap seal_bitmap[] = { @@ -675,28 +676,58 @@ linux_access(struct thread *td, struct linux_access_args *args) } #endif -int -linux_faccessat(struct thread *td, struct linux_faccessat_args *args) +static int +linux_do_accessat(struct thread *td, int ldfd, const char *filename, + int amode, int flags) { char *path; int error, dfd; /* Linux convention. */ - if (args->amode & ~(F_OK | X_OK | W_OK | R_OK)) + if (amode & ~(F_OK | X_OK | W_OK | R_OK)) return (EINVAL); - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; + dfd = (ldfd == LINUX_AT_FDCWD) ? AT_FDCWD : ldfd; if (!LUSECONVPATH(td)) { - error = kern_accessat(td, dfd, args->filename, UIO_USERSPACE, 0, args->amode); + error = kern_accessat(td, dfd, filename, UIO_USERSPACE, flags, amode); } else { - LCONVPATHEXIST_AT(td, args->filename, &path, dfd); - error = kern_accessat(td, dfd, path, UIO_SYSSPACE, 0, args->amode); + LCONVPATHEXIST_AT(td, filename, &path, dfd); + error = kern_accessat(td, dfd, path, UIO_SYSSPACE, flags, amode); LFREEPATH(path); } return (error); } +int +linux_faccessat(struct thread *td, struct linux_faccessat_args *args) +{ + + return (linux_do_accessat(td, args->dfd, args->filename, args->amode, + 0)); +} + +int +linux_faccessat2(struct thread *td, struct linux_faccessat2_args *args) +{ + int flags, unsupported; + + /* XXX. AT_SYMLINK_NOFOLLOW is not supported by kern_accessat */ + unsupported = args->flags & ~(LINUX_AT_EACCESS | LINUX_AT_EMPTY_PATH); + if (unsupported != 0) { + linux_msg(td, "faccessat2 unsupported flag 0x%x", unsupported); + return (EINVAL); + } + + flags = (args->flags & LINUX_AT_EACCESS) == 0 ? 0 : + AT_EACCESS; + flags |= (args->flags & LINUX_AT_EMPTY_PATH) == 0 ? 0 : + AT_EMPTY_PATH; + return (linux_do_accessat(td, args->dfd, args->filename, args->amode, + flags)); +} + + #ifdef LINUX_LEGACY_SYSCALLS int linux_unlink(struct thread *td, struct linux_unlink_args *args) diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index acbe5628e7ce..3a70c1352b44 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2514,7 +2514,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:41:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38B92666CF3; Thu, 12 Aug 2021 08:41: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 4GlgCf0WhTz4RhL; Thu, 12 Aug 2021 08:41: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 E2E2E1FBA8; Thu, 12 Aug 2021 08:41:49 +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 17C8fnup049032; Thu, 12 Aug 2021 08:41:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8fnp5049031; Thu, 12 Aug 2021 08:41:49 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:41:49 GMT Message-Id: <202108120841.17C8fnp5049031@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: bee191e46fc2 - main - linux(4): Regen for faccessat2 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bee191e46fc261b64fcaf440952d74a94cf4a273 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:41:50 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=bee191e46fc261b64fcaf440952d74a94cf4a273 commit bee191e46fc261b64fcaf440952d74a94cf4a273 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:41:35 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:41:35 +0000 linux(4): Regen for faccessat2 system call. MFC after: 2 weeks --- sys/amd64/linux/linux_proto.h | 5 ++++- sys/amd64/linux/linux_sysent.c | 2 +- sys/amd64/linux/linux_systrace_args.c | 26 +++++++++++++++++++++++++- sys/amd64/linux32/linux32_proto.h | 5 ++++- sys/amd64/linux32/linux32_sysent.c | 2 +- sys/amd64/linux32/linux32_systrace_args.c | 26 +++++++++++++++++++++++++- sys/arm64/linux/linux_proto.h | 5 ++++- sys/arm64/linux/linux_sysent.c | 2 +- sys/arm64/linux/linux_systrace_args.c | 26 +++++++++++++++++++++++++- sys/i386/linux/linux_proto.h | 5 ++++- sys/i386/linux/linux_sysent.c | 2 +- sys/i386/linux/linux_systrace_args.c | 26 +++++++++++++++++++++++++- 12 files changed, 120 insertions(+), 12 deletions(-) diff --git a/sys/amd64/linux/linux_proto.h b/sys/amd64/linux/linux_proto.h index f5eb73718c24..10f460cc0f7b 100644 --- a/sys/amd64/linux/linux_proto.h +++ b/sys/amd64/linux/linux_proto.h @@ -1370,7 +1370,10 @@ struct linux_pidfd_getfd_args { register_t dummy; }; struct linux_faccessat2_args { - register_t dummy; + char dfd_l_[PADL_(l_int)]; l_int dfd; char dfd_r_[PADR_(l_int)]; + char filename_l_[PADL_(const char *)]; const char * filename; char filename_r_[PADR_(const char *)]; + char amode_l_[PADL_(l_int)]; l_int amode; char amode_r_[PADR_(l_int)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_process_madvise_args { register_t dummy; diff --git a/sys/amd64/linux/linux_sysent.c b/sys/amd64/linux/linux_sysent.c index 96e74e821c43..cca061243a2f 100644 --- a/sys/amd64/linux/linux_sysent.c +++ b/sys/amd64/linux/linux_sysent.c @@ -456,7 +456,7 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ + { .sy_narg = AS(linux_faccessat2_args), .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_process_madvise, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 440 = linux_process_madvise */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_epoll_pwait2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 441 = linux_epoll_pwait2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_mount_setattr, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 442 = linux_mount_setattr */ diff --git a/sys/amd64/linux/linux_systrace_args.c b/sys/amd64/linux/linux_systrace_args.c index 7d89ffbf2a23..ba0776542a29 100644 --- a/sys/amd64/linux/linux_systrace_args.c +++ b/sys/amd64/linux/linux_systrace_args.c @@ -2697,7 +2697,12 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_faccessat2 */ case 439: { - *n_args = 0; + struct linux_faccessat2_args *p = params; + iarg[0] = p->dfd; /* l_int */ + uarg[1] = (intptr_t)p->filename; /* const char * */ + iarg[2] = p->amode; /* l_int */ + iarg[3] = p->flags; /* l_int */ + *n_args = 4; break; } /* linux_process_madvise */ @@ -7019,6 +7024,22 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_faccessat2 */ case 439: + switch (ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "l_int"; + break; + case 3: + p = "l_int"; + break; + default: + break; + }; break; /* linux_process_madvise */ case 440: @@ -8499,6 +8520,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 438: /* linux_faccessat2 */ case 439: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_process_madvise */ case 440: /* linux_epoll_pwait2 */ diff --git a/sys/amd64/linux32/linux32_proto.h b/sys/amd64/linux32/linux32_proto.h index 41724a5d24b6..49adaaacc876 100644 --- a/sys/amd64/linux32/linux32_proto.h +++ b/sys/amd64/linux32/linux32_proto.h @@ -1658,7 +1658,10 @@ struct linux_pidfd_getfd_args { register_t dummy; }; struct linux_faccessat2_args { - register_t dummy; + char dfd_l_[PADL_(l_int)]; l_int dfd; char dfd_r_[PADR_(l_int)]; + char filename_l_[PADL_(const char *)]; const char * filename; char filename_r_[PADR_(const char *)]; + char amode_l_[PADL_(l_int)]; l_int amode; char amode_r_[PADR_(l_int)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_process_madvise_args { register_t dummy; diff --git a/sys/amd64/linux32/linux32_sysent.c b/sys/amd64/linux32/linux32_sysent.c index 536088b02c95..cf4ccc56990c 100644 --- a/sys/amd64/linux32/linux32_sysent.c +++ b/sys/amd64/linux32/linux32_sysent.c @@ -456,7 +456,7 @@ struct sysent linux32_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ + { .sy_narg = AS(linux_faccessat2_args), .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_process_madvise, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 440 = linux_process_madvise */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_epoll_pwait2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 441 = linux_epoll_pwait2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_mount_setattr, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 442 = linux_mount_setattr */ diff --git a/sys/amd64/linux32/linux32_systrace_args.c b/sys/amd64/linux32/linux32_systrace_args.c index 93476fc84a37..a1186b6a29d7 100644 --- a/sys/amd64/linux32/linux32_systrace_args.c +++ b/sys/amd64/linux32/linux32_systrace_args.c @@ -3186,7 +3186,12 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_faccessat2 */ case 439: { - *n_args = 0; + struct linux_faccessat2_args *p = params; + iarg[0] = p->dfd; /* l_int */ + uarg[1] = (intptr_t)p->filename; /* const char * */ + iarg[2] = p->amode; /* l_int */ + iarg[3] = p->flags; /* l_int */ + *n_args = 4; break; } /* linux_process_madvise */ @@ -8292,6 +8297,22 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_faccessat2 */ case 439: + switch (ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "l_int"; + break; + case 3: + p = "l_int"; + break; + default: + break; + }; break; /* linux_process_madvise */ case 440: @@ -10041,6 +10062,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 438: /* linux_faccessat2 */ case 439: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_process_madvise */ case 440: /* linux_epoll_pwait2 */ diff --git a/sys/arm64/linux/linux_proto.h b/sys/arm64/linux/linux_proto.h index 47d4c812364f..37296827d312 100644 --- a/sys/arm64/linux/linux_proto.h +++ b/sys/arm64/linux/linux_proto.h @@ -1180,7 +1180,10 @@ struct linux_pidfd_getfd_args { register_t dummy; }; struct linux_faccessat2_args { - register_t dummy; + char dfd_l_[PADL_(l_int)]; l_int dfd; char dfd_r_[PADR_(l_int)]; + char filename_l_[PADL_(const char *)]; const char * filename; char filename_r_[PADR_(const char *)]; + char amode_l_[PADL_(l_int)]; l_int amode; char amode_r_[PADR_(l_int)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_process_madvise_args { register_t dummy; diff --git a/sys/arm64/linux/linux_sysent.c b/sys/arm64/linux/linux_sysent.c index 2943071d4e1f..a11c9b80cb11 100644 --- a/sys/arm64/linux/linux_sysent.c +++ b/sys/arm64/linux/linux_sysent.c @@ -456,7 +456,7 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ + { .sy_narg = AS(linux_faccessat2_args), .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_process_madvise, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 440 = linux_process_madvise */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_epoll_pwait2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 441 = linux_epoll_pwait2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_mount_setattr, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 442 = linux_mount_setattr */ diff --git a/sys/arm64/linux/linux_systrace_args.c b/sys/arm64/linux/linux_systrace_args.c index 929b70270045..f3838d2c52f9 100644 --- a/sys/arm64/linux/linux_systrace_args.c +++ b/sys/arm64/linux/linux_systrace_args.c @@ -2319,7 +2319,12 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_faccessat2 */ case 439: { - *n_args = 0; + struct linux_faccessat2_args *p = params; + iarg[0] = p->dfd; /* l_int */ + uarg[1] = (intptr_t)p->filename; /* const char * */ + iarg[2] = p->amode; /* l_int */ + iarg[3] = p->flags; /* l_int */ + *n_args = 4; break; } /* linux_process_madvise */ @@ -6094,6 +6099,22 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_faccessat2 */ case 439: + switch (ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "l_int"; + break; + case 3: + p = "l_int"; + break; + default: + break; + }; break; /* linux_process_madvise */ case 440: @@ -7359,6 +7380,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 438: /* linux_faccessat2 */ case 439: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_process_madvise */ case 440: /* linux_epoll_pwait2 */ diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index c66f509ca57c..cdda5da13870 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -1651,7 +1651,10 @@ struct linux_pidfd_getfd_args { register_t dummy; }; struct linux_faccessat2_args { - register_t dummy; + char dfd_l_[PADL_(l_int)]; l_int dfd; char dfd_r_[PADR_(l_int)]; + char filename_l_[PADL_(const char *)]; const char * filename; char filename_r_[PADR_(const char *)]; + char amode_l_[PADL_(l_int)]; l_int amode; char amode_r_[PADR_(l_int)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_process_madvise_args { register_t dummy; diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index 7b94d2047071..5c592cd2c141 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -456,7 +456,7 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ + { .sy_narg = AS(linux_faccessat2_args), .sy_call = (sy_call_t *)linux_faccessat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 439 = linux_faccessat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_process_madvise, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 440 = linux_process_madvise */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_epoll_pwait2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 441 = linux_epoll_pwait2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_mount_setattr, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 442 = linux_mount_setattr */ diff --git a/sys/i386/linux/linux_systrace_args.c b/sys/i386/linux/linux_systrace_args.c index bbab41700a93..4e8d180751a3 100644 --- a/sys/i386/linux/linux_systrace_args.c +++ b/sys/i386/linux/linux_systrace_args.c @@ -3225,7 +3225,12 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_faccessat2 */ case 439: { - *n_args = 0; + struct linux_faccessat2_args *p = params; + iarg[0] = p->dfd; /* l_int */ + uarg[1] = (intptr_t)p->filename; /* const char * */ + iarg[2] = p->amode; /* l_int */ + iarg[3] = p->flags; /* l_int */ + *n_args = 4; break; } /* linux_process_madvise */ @@ -8369,6 +8374,22 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_faccessat2 */ case 439: + switch (ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "l_int"; + break; + case 3: + p = "l_int"; + break; + default: + break; + }; break; /* linux_process_madvise */ case 440: @@ -10147,6 +10168,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 438: /* linux_faccessat2 */ case 439: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_process_madvise */ case 440: /* linux_epoll_pwait2 */ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:43:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FB58666DD2; Thu, 12 Aug 2021 08:43: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 4GlgFF0pF7z4RsL; Thu, 12 Aug 2021 08:43: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 03DB01FCEB; Thu, 12 Aug 2021 08:43: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 17C8hCqX050107; Thu, 12 Aug 2021 08:43:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8hCx2050106; Thu, 12 Aug 2021 08:43:12 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:43:12 GMT Message-Id: <202108120843.17C8hCx2050106@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: fc37be246021 - main - linux(4): Plug in aarch64 fcntl flags. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc37be246021ee9b7110c9f506141c2bf0bc9fb0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:43:13 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=fc37be246021ee9b7110c9f506141c2bf0bc9fb0 commit fc37be246021ee9b7110c9f506141c2bf0bc9fb0 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:42:50 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:42:50 +0000 linux(4): Plug in aarch64 fcntl flags. Fixes opendir() libc function. Differential Revision: https://reviews.freebsd.org/D31357 MFC after: 2 weeks --- sys/arm64/linux/linux.h | 5 +++++ sys/compat/linux/linux_file.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/sys/arm64/linux/linux.h b/sys/arm64/linux/linux.h index 7ea169b962b4..b5273498a5aa 100644 --- a/sys/arm64/linux/linux.h +++ b/sys/arm64/linux/linux.h @@ -117,6 +117,11 @@ struct l_timespec { l_long tv_nsec; }; +#define LINUX_O_DIRECTORY 000040000 /* Must be a directory */ +#define LINUX_O_NOFOLLOW 000100000 /* Do not follow links */ +#define LINUX_O_DIRECT 000200000 /* Direct disk access hint */ +#define LINUX_O_LARGEFILE 000400000 + struct l_newstat { l_dev_t st_dev; l_ino_t st_ino; diff --git a/sys/compat/linux/linux_file.h b/sys/compat/linux/linux_file.h index ab137ba6b9c3..e6a5bf0ce8a6 100644 --- a/sys/compat/linux/linux_file.h +++ b/sys/compat/linux/linux_file.h @@ -78,10 +78,18 @@ #define LINUX_O_NDELAY LINUX_O_NONBLOCK #define LINUX_O_SYNC 000010000 #define LINUX_O_ASYNC 000020000 +#ifndef LINUX_O_DIRECT #define LINUX_O_DIRECT 000040000 /* Direct disk access hint */ +#endif +#ifndef LINUX_O_LARGEFILE #define LINUX_O_LARGEFILE 000100000 +#endif +#ifndef LINUX_O_DIRECTORY #define LINUX_O_DIRECTORY 000200000 /* Must be a directory */ +#endif +#ifndef LINUX_O_NOFOLLOW #define LINUX_O_NOFOLLOW 000400000 /* Do not follow links */ +#endif #define LINUX_O_NOATIME 001000000 #define LINUX_O_CLOEXEC 002000000 #define LINUX_O_PATH 010000000 From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:45:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9F587666E6A; Thu, 12 Aug 2021 08:45: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 4GlgJJ3xBXz4RwZ; Thu, 12 Aug 2021 08:45: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 64E8A1FEAA; Thu, 12 Aug 2021 08:45: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 17C8jqFa050426; Thu, 12 Aug 2021 08:45:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8jqal050425; Thu, 12 Aug 2021 08:45:52 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:45:52 GMT Message-Id: <202108120845.17C8jqal050425@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: de8374df28cc - main - fork: Allow ABI to specify fork return values for child. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: de8374df28cc23ce0d893fd96d1ad0a861414154 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:45:52 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=de8374df28cc23ce0d893fd96d1ad0a861414154 commit de8374df28cc23ce0d893fd96d1ad0a861414154 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:45:25 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:45:25 +0000 fork: Allow ABI to specify fork return values for child. At least Linux x86 ABI's does not use carry bit and expects that the dx register is preserved. For this add a new sv_set_fork_retval hook and call it from cpu_fork(). Add a short comment about touching dx in x86_set_fork_retval(), for more details see phab comments from kib@ and imp@. Reviewed by: kib Differential revision: https://reviews.freebsd.org/D31472 MFC after: 2 weeks --- sys/amd64/amd64/elf_machdep.c | 2 ++ sys/amd64/amd64/vm_machdep.c | 15 ++++++++++++--- sys/amd64/cloudabi32/cloudabi32_sysvec.c | 2 ++ sys/amd64/cloudabi64/cloudabi64_sysvec.c | 2 ++ sys/amd64/linux/linux_sysvec.c | 10 ++++++++++ sys/amd64/linux32/linux32_sysvec.c | 10 ++++++++++ sys/compat/ia32/ia32_sysvec.c | 1 + sys/i386/cloudabi32/cloudabi32_sysvec.c | 2 ++ sys/i386/i386/elf_machdep.c | 1 + sys/i386/i386/vm_machdep.c | 15 ++++++++++++--- sys/i386/linux/linux_sysvec.c | 11 +++++++++++ sys/kern/imgact_aout.c | 2 ++ sys/kern/init_main.c | 7 +++++++ sys/sys/sysent.h | 2 ++ sys/x86/include/x86_var.h | 1 + 15 files changed, 77 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c index 80f7d1d8cefa..6535d4bd2446 100644 --- a/sys/amd64/amd64/elf_machdep.c +++ b/sys/amd64/amd64/elf_machdep.c @@ -87,6 +87,7 @@ struct sysentvec elf64_freebsd_sysvec_la48 = { .sv_stackgap = elf64_stackgap, .sv_onexec_old = exec_onexec_old, .sv_onexit = exit_onexit, + .sv_set_fork_retval = x86_set_fork_retval, }; struct sysentvec elf64_freebsd_sysvec_la57 = { @@ -127,6 +128,7 @@ struct sysentvec elf64_freebsd_sysvec_la57 = { .sv_stackgap = elf64_stackgap, .sv_onexec_old = exec_onexec_old, .sv_onexit = exit_onexit, + .sv_set_fork_retval= x86_set_fork_retval, }; static void diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 7d65269410e0..4567e6e0eb5d 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -245,9 +245,8 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) td2->td_frame = (struct trapframe *)td2->td_md.md_stack_base - 1; bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); - td2->td_frame->tf_rax = 0; /* Child returns zero */ - td2->td_frame->tf_rflags &= ~PSL_C; /* success */ - td2->td_frame->tf_rdx = 1; + /* Set child return values. */ + p2->p_sysent->sv_set_fork_retval(td2); /* * If the parent process has the trap bit set (i.e. a debugger @@ -300,6 +299,16 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) */ } +void +x86_set_fork_retval(struct thread *td) +{ + struct trapframe *frame = td->td_frame; + + frame->tf_rax = 0; /* Child returns zero */ + frame->tf_rflags &= ~PSL_C; /* success */ + frame->tf_rdx = 1; /* System V emulation */ +} + /* * Intercept the return address from a freshly forked process that has NOT * been scheduled yet. diff --git a/sys/amd64/cloudabi32/cloudabi32_sysvec.c b/sys/amd64/cloudabi32/cloudabi32_sysvec.c index 26924ed5a980..5bb4803ac715 100644 --- a/sys/amd64/cloudabi32/cloudabi32_sysvec.c +++ b/sys/amd64/cloudabi32/cloudabi32_sysvec.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -225,6 +226,7 @@ static struct sysentvec cloudabi32_elf_sysvec = { .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, .sv_syscallnames = cloudabi32_syscallnames, .sv_schedtail = cloudabi32_schedtail, + .sv_set_fork_retval = x86_set_fork_retval, }; INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); diff --git a/sys/amd64/cloudabi64/cloudabi64_sysvec.c b/sys/amd64/cloudabi64/cloudabi64_sysvec.c index c08d912e84d4..82c971212087 100644 --- a/sys/amd64/cloudabi64/cloudabi64_sysvec.c +++ b/sys/amd64/cloudabi64/cloudabi64_sysvec.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -212,6 +213,7 @@ static struct sysentvec cloudabi64_elf_sysvec = { .sv_fetch_syscall_args = cloudabi64_fetch_syscall_args, .sv_syscallnames = cloudabi64_syscallnames, .sv_schedtail = cloudabi64_schedtail, + .sv_set_fork_retval = x86_set_fork_retval, }; INIT_SYSENTVEC(elf_sysvec, &cloudabi64_elf_sysvec); diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 75fb21c7d037..558dfb4e0ac0 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -125,6 +125,7 @@ static void linux_exec_setregs(struct thread *td, struct image_params *imgp, static void linux_exec_sysvec_init(void *param); static int linux_on_exec_vmspace(struct proc *p, struct image_params *imgp); +static void linux_set_fork_retval(struct thread *td); static int linux_vsyscall(struct thread *td); #define LINUX_T_UNKNOWN 255 @@ -269,6 +270,14 @@ linux_set_syscall_retval(struct thread *td, int error) set_pcb_flags(td->td_pcb, PCB_FULL_IRET); } +static void +linux_set_fork_retval(struct thread *td) +{ + struct trapframe *frame = td->td_frame; + + frame->tf_rax = 0; +} + static int linux_copyout_auxargs(struct image_params *imgp, uintptr_t base) { @@ -790,6 +799,7 @@ struct sysentvec elf_linux_sysvec = { .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, + .sv_set_fork_retval = linux_set_fork_retval, }; static int diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 901c79fcdda8..2ec420b3024a 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -128,6 +128,7 @@ static bool linux32_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(const void *param); static void linux_vdso_deinstall(const void *param); static void linux_vdso_reloc(char *mapping, Elf_Addr offset); +static void linux32_set_fork_retval(struct thread *td); static void linux32_set_syscall_retval(struct thread *td, int error); #define LINUX_T_UNKNOWN 255 @@ -703,6 +704,14 @@ linux32_set_syscall_retval(struct thread *td, int error) } } +static void +linux32_set_fork_retval(struct thread *td) +{ + struct trapframe *frame = td->td_frame; + + frame->tf_rax = 0; +} + /* * Clear registers on exec * XXX copied from ia32_signal.c. @@ -956,6 +965,7 @@ struct sysentvec elf_linux_sysvec = { .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, + .sv_set_fork_retval = linux32_set_fork_retval, }; static int diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index df8a36a34810..969f5645a0f4 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -133,6 +133,7 @@ struct sysentvec ia32_freebsd_sysvec = { .sv_stackgap = elf32_stackgap, .sv_onexec_old = exec_onexec_old, .sv_onexit = exit_onexit, + .sv_set_fork_retval = x86_set_fork_retval, }; INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec); diff --git a/sys/i386/cloudabi32/cloudabi32_sysvec.c b/sys/i386/cloudabi32/cloudabi32_sysvec.c index e0a50f6697a9..773b5803c873 100644 --- a/sys/i386/cloudabi32/cloudabi32_sysvec.c +++ b/sys/i386/cloudabi32/cloudabi32_sysvec.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -195,6 +196,7 @@ static struct sysentvec cloudabi32_elf_sysvec = { .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, .sv_syscallnames = cloudabi32_syscallnames, .sv_schedtail = cloudabi32_schedtail, + .sv_set_fork_retval = x86_set_fork_retval, }; INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c index 5858c8382e33..3754b36d9e33 100644 --- a/sys/i386/i386/elf_machdep.c +++ b/sys/i386/i386/elf_machdep.c @@ -88,6 +88,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_trap = NULL, .sv_onexec_old = exec_onexec_old, .sv_onexit = exit_onexit, + .sv_set_fork_retval = x86_set_fork_retval, }; INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec); diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 57377575b9bf..5cdcdee96347 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -258,9 +258,8 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) VM86_STACK_SPACE) - 1; bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); - td2->td_frame->tf_eax = 0; /* Child returns zero */ - td2->td_frame->tf_eflags &= ~PSL_C; /* success */ - td2->td_frame->tf_edx = 1; + /* Set child return values. */ + p2->p_sysent->sv_set_fork_retval(td2); /* * If the parent process has the trap bit set (i.e. a debugger @@ -302,6 +301,16 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) */ } +void +x86_set_fork_retval(struct thread *td) +{ + struct trapframe * frame = td->td_frame; + + frame->tf_eax = 0; /* Child returns zero */ + frame->tf_eflags &= ~PSL_C; /* success */ + frame->tf_edx = 1; /* System V emulation */ +} + /* * Intercept the return address from a freshly forked process that has NOT * been scheduled yet. diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 9261364e7a24..02d69de4d8f8 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -108,6 +108,7 @@ static int linux_on_exec_vmspace(struct proc *p, struct image_params *imgp); static int linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base); +static void linux_set_fork_retval(struct thread *td); static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(const void *param); static void linux_vdso_deinstall(const void *param); @@ -803,6 +804,14 @@ linux_set_syscall_retval(struct thread *td, int error) } } +static void +linux_set_fork_retval(struct thread *td) +{ + struct trapframe *frame = td->td_frame; + + frame->tf_eax = 0; +} + /* * exec_setregs may initialize some registers differently than Linux * does, thus potentially confusing Linux binaries. If necessary, we @@ -856,6 +865,7 @@ struct sysentvec linux_sysvec = { .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, + .sv_set_fork_retval = linux_set_fork_retval, }; INIT_SYSENTVEC(aout_sysvec, &linux_sysvec); @@ -898,6 +908,7 @@ struct sysentvec elf_linux_sysvec = { .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, + .sv_set_fork_retval = linux_set_fork_retval, }; static int diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index 9e7455e14e1d..7d7ba51efd84 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -103,6 +103,7 @@ struct sysentvec aout_sysvec = { .sv_trap = NULL, .sv_onexec_old = exec_onexec_old, .sv_onexit = exit_onexit, + .sv_set_fork_retval = x86_set_fork_retval, }; #elif defined(__amd64__) @@ -141,6 +142,7 @@ struct sysentvec aout_sysvec = { .sv_syscallnames = freebsd32_syscallnames, .sv_onexec_old = exec_onexec_old, .sv_onexit = exit_onexit, + .sv_set_fork_retval = x86_set_fork_retval, }; #else #error "Port me" diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 86cc2494272f..fde07dcbf46d 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -402,6 +402,12 @@ null_set_syscall_retval(struct thread *td __unused, int error __unused) panic("null_set_syscall_retval"); } +static void +null_set_fork_retval(struct thread *td __unused) +{ + +} + struct sysentvec null_sysvec = { .sv_size = 0, .sv_table = NULL, @@ -430,6 +436,7 @@ struct sysentvec null_sysvec = { .sv_schedtail = NULL, .sv_thread_detach = NULL, .sv_trap = NULL, + .sv_set_fork_retval = null_set_fork_retval, }; /* diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index 1b43e9692153..e51a66f93f29 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -156,6 +156,8 @@ struct sysentvec { void (*sv_ontdexit)(struct thread *td); int (*sv_setid_allowed)(struct thread *td, struct image_params *imgp); + void (*sv_set_fork_retval)(struct thread *); + /* Only used on x86 */ }; #define SV_ILP32 0x000100 /* 32-bit executable. */ diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index 0fdff68638cf..ec268503634b 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -153,6 +153,7 @@ int pti_get_default(void); int user_dbreg_trap(register_t dr6); int minidumpsys(struct dumperinfo *); struct pcb *get_pcb_td(struct thread *td); +void x86_set_fork_retval(struct thread *td); /* * MSR ops for x86_msr_op() From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:47:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70D4F66738A; Thu, 12 Aug 2021 08:47: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 4GlgLf15MFz4RxN; Thu, 12 Aug 2021 08:47: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 DBE8E1FF74; Thu, 12 Aug 2021 08:47: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 17C8lrDG050675; Thu, 12 Aug 2021 08:47:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8lrNM050674; Thu, 12 Aug 2021 08:47:53 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:47:53 GMT Message-Id: <202108120847.17C8lrNM050674@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: f1c450492f81 - main - linux(4): Change clone syscall definition to match Linux actual one. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f1c450492f81cda4bddd46dc71ea4c92907567ac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:47:54 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f1c450492f81cda4bddd46dc71ea4c92907567ac commit f1c450492f81cda4bddd46dc71ea4c92907567ac Author: Dmitry Chagin AuthorDate: 2021-08-12 08:46:36 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:46:36 +0000 linux(4): Change clone syscall definition to match Linux actual one. Differential revision: https://reviews.freebsd.org/D31473 MFC after: 2 weeks --- sys/amd64/linux/syscalls.master | 8 ++++---- sys/amd64/linux32/syscalls.master | 10 +++++----- sys/arm/linux/syscalls.master | 10 +++++----- sys/arm64/linux/syscalls.master | 8 ++++---- sys/compat/linux/linux_fork.c | 10 +++++----- sys/i386/linux/syscalls.master | 10 +++++----- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/sys/amd64/linux/syscalls.master b/sys/amd64/linux/syscalls.master index b9b88a036e61..cdf663ce2e06 100644 --- a/sys/amd64/linux/syscalls.master +++ b/sys/amd64/linux/syscalls.master @@ -422,10 +422,10 @@ 56 AUE_RFORK STD { int linux_clone( l_ulong flags, - void *stack, - void *parent_tidptr, - void *child_tidptr, - void *tls + l_ulong stack, + l_int *parent_tidptr, + l_int *child_tidptr, + l_ulong tls ); } 57 AUE_FORK STD { diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index 60f227142f01..ff7ab7f98ca8 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -642,11 +642,11 @@ } 120 AUE_RFORK STD { int linux_clone( - l_int flags, - void *stack, - void *parent_tidptr, - void *tls, - void *child_tidptr + l_ulong flags, + l_ulong stack, + l_int *parent_tidptr, + l_ulong tls, + l_int *child_tidptr ); } 121 AUE_SYSCTL STD { diff --git a/sys/arm/linux/syscalls.master b/sys/arm/linux/syscalls.master index 46cf988c3dfe..3221aaa6bd6d 100644 --- a/sys/arm/linux/syscalls.master +++ b/sys/arm/linux/syscalls.master @@ -508,11 +508,11 @@ } 120 AUE_RFORK STD { int linux_clone( - l_int flags, - void *stack, - void *parent_tidptr, - void *tls, - void * child_tidptr + l_ulong flags, + l_ulong stack, + l_int *parent_tidptr, + l_ulong tls, + l_int *child_tidptr ); } 121 AUE_SYSCTL STD { diff --git a/sys/arm64/linux/syscalls.master b/sys/arm64/linux/syscalls.master index 7b4ebbb2c2e9..6e163cc3360d 100644 --- a/sys/arm64/linux/syscalls.master +++ b/sys/arm64/linux/syscalls.master @@ -1316,10 +1316,10 @@ 220 AUE_RFORK STD { int linux_clone( l_ulong flags, - void *stack, - void *parent_tidptr, - void *tls, - void *child_tidptr + l_ulong stack, + l_int *parent_tidptr, + l_ulong tls, + l_int *child_tidptr ); } 221 AUE_EXECVE STD { diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index bc7704795127..955e9e512bd1 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -205,10 +205,10 @@ linux_clone_proc(struct thread *td, struct linux_clone_args *args) * stack. This is what normal fork() does, so we just keep tf_rsp arg * intact. */ - linux_set_upcall(td2, PTROUT(args->stack)); + linux_set_upcall(td2, args->stack); if (args->flags & LINUX_CLONE_SETTLS) - linux_set_cloned_tls(td2, args->tls); + linux_set_cloned_tls(td2, PTRIN(args->tls)); /* * If CLONE_PARENT is set, then the parent of the new process will be @@ -253,7 +253,7 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) return (EINVAL); /* Threads should be created with own stack */ - if (args->stack == NULL) + if (PTRIN(args->stack) == NULL) return (EINVAL); p = td->td_proc; @@ -290,7 +290,7 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) KASSERT(em != NULL, ("clone_thread: emuldata not found.\n")); if (args->flags & LINUX_CLONE_SETTLS) - linux_set_cloned_tls(newtd, args->tls); + linux_set_cloned_tls(newtd, PTRIN(args->tls)); if (args->flags & LINUX_CLONE_CHILD_SETTID) em->child_set_tid = args->child_tidptr; @@ -304,7 +304,7 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) cpu_thread_clean(newtd); - linux_set_upcall(newtd, PTROUT(args->stack)); + linux_set_upcall(newtd, args->stack); PROC_LOCK(p); p->p_flag |= P_HADTHREADS; diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index 3a70c1352b44..aecb852e21c7 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -659,11 +659,11 @@ } 120 AUE_RFORK STD { int linux_clone( - l_int flags, - void *stack, - void *parent_tidptr, - void *tls, - void *child_tidptr + l_ulong flags, + l_ulong stack, + l_int *parent_tidptr, + l_ulong tls, + l_int *child_tidptr ); } 121 AUE_SYSCTL STD { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:47:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5BF6B66719C; Thu, 12 Aug 2021 08:47: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 4GlgLg1Qnfz4Rth; Thu, 12 Aug 2021 08:47: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 154141FE3C; Thu, 12 Aug 2021 08:47: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 17C8lsXu050699; Thu, 12 Aug 2021 08:47:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8lsKg050698; Thu, 12 Aug 2021 08:47:54 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:47:54 GMT Message-Id: <202108120847.17C8lsKg050698@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 0c08f34f4ddf - main - linux(4): Regen for clone syscall. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0c08f34f4ddff9847bd57f262270687ea1220a6a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:47:55 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=0c08f34f4ddff9847bd57f262270687ea1220a6a commit 0c08f34f4ddff9847bd57f262270687ea1220a6a Author: Dmitry Chagin AuthorDate: 2021-08-12 08:47:31 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:47:31 +0000 linux(4): Regen for clone syscall. MFC after: 2 weeks --- sys/amd64/linux/linux_proto.h | 8 ++++---- sys/amd64/linux/linux_systrace_args.c | 16 ++++++++-------- sys/amd64/linux32/linux32_proto.h | 10 +++++----- sys/amd64/linux32/linux32_systrace_args.c | 20 ++++++++++---------- sys/arm/linux/linux_proto.h | 10 +++++----- sys/arm/linux/linux_systrace_args.c | 20 ++++++++++---------- sys/arm64/linux/linux_proto.h | 8 ++++---- sys/arm64/linux/linux_systrace_args.c | 16 ++++++++-------- sys/i386/linux/linux_proto.h | 10 +++++----- sys/i386/linux/linux_systrace_args.c | 20 ++++++++++---------- 10 files changed, 69 insertions(+), 69 deletions(-) diff --git a/sys/amd64/linux/linux_proto.h b/sys/amd64/linux/linux_proto.h index 10f460cc0f7b..5ebf28723c64 100644 --- a/sys/amd64/linux/linux_proto.h +++ b/sys/amd64/linux/linux_proto.h @@ -275,10 +275,10 @@ struct linux_getsockopt_args { }; struct linux_clone_args { char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)]; - char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void *)]; - char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char parent_tidptr_r_[PADR_(void *)]; - char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char child_tidptr_r_[PADR_(void *)]; - char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)]; + char stack_l_[PADL_(l_ulong)]; l_ulong stack; char stack_r_[PADR_(l_ulong)]; + char parent_tidptr_l_[PADL_(l_int *)]; l_int * parent_tidptr; char parent_tidptr_r_[PADR_(l_int *)]; + char child_tidptr_l_[PADL_(l_int *)]; l_int * child_tidptr; char child_tidptr_r_[PADR_(l_int *)]; + char tls_l_[PADL_(l_ulong)]; l_ulong tls; char tls_r_[PADR_(l_ulong)]; }; struct linux_fork_args { register_t dummy; diff --git a/sys/amd64/linux/linux_systrace_args.c b/sys/amd64/linux/linux_systrace_args.c index ba0776542a29..3101b8672ce2 100644 --- a/sys/amd64/linux/linux_systrace_args.c +++ b/sys/amd64/linux/linux_systrace_args.c @@ -509,10 +509,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 56: { struct linux_clone_args *p = params; iarg[0] = p->flags; /* l_ulong */ - uarg[1] = (intptr_t)p->stack; /* void * */ - uarg[2] = (intptr_t)p->parent_tidptr; /* void * */ - uarg[3] = (intptr_t)p->child_tidptr; /* void * */ - uarg[4] = (intptr_t)p->tls; /* void * */ + iarg[1] = p->stack; /* l_ulong */ + uarg[2] = (intptr_t)p->parent_tidptr; /* l_int * */ + uarg[3] = (intptr_t)p->child_tidptr; /* l_int * */ + iarg[4] = p->tls; /* l_ulong */ *n_args = 5; break; } @@ -3598,16 +3598,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) p = "l_ulong"; break; case 1: - p = "userland void *"; + p = "l_ulong"; break; case 2: - p = "userland void *"; + p = "userland l_int *"; break; case 3: - p = "userland void *"; + p = "userland l_int *"; break; case 4: - p = "userland void *"; + p = "l_ulong"; break; default: break; diff --git a/sys/amd64/linux32/linux32_proto.h b/sys/amd64/linux32/linux32_proto.h index 49adaaacc876..07e673a862ad 100644 --- a/sys/amd64/linux32/linux32_proto.h +++ b/sys/amd64/linux32/linux32_proto.h @@ -377,11 +377,11 @@ struct linux_sigreturn_args { char sfp_l_[PADL_(struct l_sigframe *)]; struct l_sigframe * sfp; char sfp_r_[PADR_(struct l_sigframe *)]; }; struct linux_clone_args { - char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; - char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void *)]; - char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char parent_tidptr_r_[PADR_(void *)]; - char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)]; - char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char child_tidptr_r_[PADR_(void *)]; + char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)]; + char stack_l_[PADL_(l_ulong)]; l_ulong stack; char stack_r_[PADR_(l_ulong)]; + char parent_tidptr_l_[PADL_(l_int *)]; l_int * parent_tidptr; char parent_tidptr_r_[PADR_(l_int *)]; + char tls_l_[PADL_(l_ulong)]; l_ulong tls; char tls_r_[PADR_(l_ulong)]; + char child_tidptr_l_[PADL_(l_int *)]; l_int * child_tidptr; char child_tidptr_r_[PADR_(l_int *)]; }; struct linux_setdomainname_args { char name_l_[PADL_(char *)]; char * name; char name_r_[PADR_(char *)]; diff --git a/sys/amd64/linux32/linux32_systrace_args.c b/sys/amd64/linux32/linux32_systrace_args.c index a1186b6a29d7..79605a335aaf 100644 --- a/sys/amd64/linux32/linux32_systrace_args.c +++ b/sys/amd64/linux32/linux32_systrace_args.c @@ -808,11 +808,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_clone */ case 120: { struct linux_clone_args *p = params; - iarg[0] = p->flags; /* l_int */ - uarg[1] = (intptr_t)p->stack; /* void * */ - uarg[2] = (intptr_t)p->parent_tidptr; /* void * */ - uarg[3] = (intptr_t)p->tls; /* void * */ - uarg[4] = (intptr_t)p->child_tidptr; /* void * */ + iarg[0] = p->flags; /* l_ulong */ + iarg[1] = p->stack; /* l_ulong */ + uarg[2] = (intptr_t)p->parent_tidptr; /* l_int * */ + iarg[3] = p->tls; /* l_ulong */ + uarg[4] = (intptr_t)p->child_tidptr; /* l_int * */ *n_args = 5; break; } @@ -4431,19 +4431,19 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 120: switch (ndx) { case 0: - p = "l_int"; + p = "l_ulong"; break; case 1: - p = "userland void *"; + p = "l_ulong"; break; case 2: - p = "userland void *"; + p = "userland l_int *"; break; case 3: - p = "userland void *"; + p = "l_ulong"; break; case 4: - p = "userland void *"; + p = "userland l_int *"; break; default: break; diff --git a/sys/arm/linux/linux_proto.h b/sys/arm/linux/linux_proto.h index 131fa227e8f8..07245d6db4f3 100644 --- a/sys/arm/linux/linux_proto.h +++ b/sys/arm/linux/linux_proto.h @@ -292,11 +292,11 @@ struct linux_sigreturn_args { char sfp_l_[PADL_(struct l_sigframe *)]; struct l_sigframe * sfp; char sfp_r_[PADR_(struct l_sigframe *)]; }; struct linux_clone_args { - char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; - char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void *)]; - char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char parent_tidptr_r_[PADR_(void *)]; - char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)]; - char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char child_tidptr_r_[PADR_(void *)]; + char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)]; + char stack_l_[PADL_(l_ulong)]; l_ulong stack; char stack_r_[PADR_(l_ulong)]; + char parent_tidptr_l_[PADL_(l_int *)]; l_int * parent_tidptr; char parent_tidptr_r_[PADR_(l_int *)]; + char tls_l_[PADL_(l_ulong)]; l_ulong tls; char tls_r_[PADR_(l_ulong)]; + char child_tidptr_l_[PADL_(l_int *)]; l_int * child_tidptr; char child_tidptr_r_[PADR_(l_int *)]; }; struct linux_setdomainname_args { char name_l_[PADL_(char *)]; char * name; char name_r_[PADR_(char *)]; diff --git a/sys/arm/linux/linux_systrace_args.c b/sys/arm/linux/linux_systrace_args.c index f35bb0c6b906..16591890ea9a 100644 --- a/sys/arm/linux/linux_systrace_args.c +++ b/sys/arm/linux/linux_systrace_args.c @@ -651,11 +651,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_clone */ case 120: { struct linux_clone_args *p = params; - iarg[0] = p->flags; /* l_int */ - uarg[1] = (intptr_t)p->stack; /* void * */ - uarg[2] = (intptr_t)p->parent_tidptr; /* void * */ - uarg[3] = (intptr_t)p->tls; /* void * */ - uarg[4] = (intptr_t)p->child_tidptr; /* void * */ + iarg[0] = p->flags; /* l_ulong */ + iarg[1] = p->stack; /* l_ulong */ + uarg[2] = (intptr_t)p->parent_tidptr; /* l_int * */ + iarg[3] = p->tls; /* l_ulong */ + uarg[4] = (intptr_t)p->child_tidptr; /* l_int * */ *n_args = 5; break; } @@ -3477,19 +3477,19 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 120: switch (ndx) { case 0: - p = "l_int"; + p = "l_ulong"; break; case 1: - p = "userland void *"; + p = "l_ulong"; break; case 2: - p = "userland void *"; + p = "userland l_int *"; break; case 3: - p = "userland void *"; + p = "l_ulong"; break; case 4: - p = "userland void *"; + p = "userland l_int *"; break; default: break; diff --git a/sys/arm64/linux/linux_proto.h b/sys/arm64/linux/linux_proto.h index 37296827d312..83237b046f85 100644 --- a/sys/arm64/linux/linux_proto.h +++ b/sys/arm64/linux/linux_proto.h @@ -861,10 +861,10 @@ struct linux_keyctl_args { }; struct linux_clone_args { char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)]; - char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void *)]; - char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char parent_tidptr_r_[PADR_(void *)]; - char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)]; - char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char child_tidptr_r_[PADR_(void *)]; + char stack_l_[PADL_(l_ulong)]; l_ulong stack; char stack_r_[PADR_(l_ulong)]; + char parent_tidptr_l_[PADL_(l_int *)]; l_int * parent_tidptr; char parent_tidptr_r_[PADR_(l_int *)]; + char tls_l_[PADL_(l_ulong)]; l_ulong tls; char tls_r_[PADR_(l_ulong)]; + char child_tidptr_l_[PADL_(l_int *)]; l_int * child_tidptr; char child_tidptr_r_[PADR_(l_int *)]; }; struct linux_execve_args { char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; diff --git a/sys/arm64/linux/linux_systrace_args.c b/sys/arm64/linux/linux_systrace_args.c index f3838d2c52f9..6c0eeb5ae0f4 100644 --- a/sys/arm64/linux/linux_systrace_args.c +++ b/sys/arm64/linux/linux_systrace_args.c @@ -1746,10 +1746,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 220: { struct linux_clone_args *p = params; iarg[0] = p->flags; /* l_ulong */ - uarg[1] = (intptr_t)p->stack; /* void * */ - uarg[2] = (intptr_t)p->parent_tidptr; /* void * */ - uarg[3] = (intptr_t)p->tls; /* void * */ - uarg[4] = (intptr_t)p->child_tidptr; /* void * */ + iarg[1] = p->stack; /* l_ulong */ + uarg[2] = (intptr_t)p->parent_tidptr; /* l_int * */ + iarg[3] = p->tls; /* l_ulong */ + uarg[4] = (intptr_t)p->child_tidptr; /* l_int * */ *n_args = 5; break; } @@ -5222,16 +5222,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) p = "l_ulong"; break; case 1: - p = "userland void *"; + p = "l_ulong"; break; case 2: - p = "userland void *"; + p = "userland l_int *"; break; case 3: - p = "userland void *"; + p = "l_ulong"; break; case 4: - p = "userland void *"; + p = "userland l_int *"; break; default: break; diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index cdda5da13870..24b912757e61 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -380,11 +380,11 @@ struct linux_sigreturn_args { char sfp_l_[PADL_(struct l_sigframe *)]; struct l_sigframe * sfp; char sfp_r_[PADR_(struct l_sigframe *)]; }; struct linux_clone_args { - char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; - char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void *)]; - char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char parent_tidptr_r_[PADR_(void *)]; - char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)]; - char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char child_tidptr_r_[PADR_(void *)]; + char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)]; + char stack_l_[PADL_(l_ulong)]; l_ulong stack; char stack_r_[PADR_(l_ulong)]; + char parent_tidptr_l_[PADL_(l_int *)]; l_int * parent_tidptr; char parent_tidptr_r_[PADR_(l_int *)]; + char tls_l_[PADL_(l_ulong)]; l_ulong tls; char tls_r_[PADR_(l_ulong)]; + char child_tidptr_l_[PADL_(l_int *)]; l_int * child_tidptr; char child_tidptr_r_[PADR_(l_int *)]; }; struct linux_setdomainname_args { char name_l_[PADL_(char *)]; char * name; char name_r_[PADR_(char *)]; diff --git a/sys/i386/linux/linux_systrace_args.c b/sys/i386/linux/linux_systrace_args.c index 4e8d180751a3..0752304d5872 100644 --- a/sys/i386/linux/linux_systrace_args.c +++ b/sys/i386/linux/linux_systrace_args.c @@ -837,11 +837,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_clone */ case 120: { struct linux_clone_args *p = params; - iarg[0] = p->flags; /* l_int */ - uarg[1] = (intptr_t)p->stack; /* void * */ - uarg[2] = (intptr_t)p->parent_tidptr; /* void * */ - uarg[3] = (intptr_t)p->tls; /* void * */ - uarg[4] = (intptr_t)p->child_tidptr; /* void * */ + iarg[0] = p->flags; /* l_ulong */ + iarg[1] = p->stack; /* l_ulong */ + uarg[2] = (intptr_t)p->parent_tidptr; /* l_int * */ + iarg[3] = p->tls; /* l_ulong */ + uarg[4] = (intptr_t)p->child_tidptr; /* l_int * */ *n_args = 5; break; } @@ -4512,19 +4512,19 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 120: switch (ndx) { case 0: - p = "l_int"; + p = "l_ulong"; break; case 1: - p = "userland void *"; + p = "l_ulong"; break; case 2: - p = "userland void *"; + p = "userland l_int *"; break; case 3: - p = "userland void *"; + p = "l_ulong"; break; case 4: - p = "userland void *"; + p = "userland l_int *"; break; default: break; From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:50:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B178466733E; Thu, 12 Aug 2021 08:50: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 4GlgPm4f6nz4SLb; Thu, 12 Aug 2021 08:50: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 882AB1FF81; Thu, 12 Aug 2021 08:50: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 17C8oaPi061577; Thu, 12 Aug 2021 08:50:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8oa3R061576; Thu, 12 Aug 2021 08:50:36 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:50:36 GMT Message-Id: <202108120850.17C8oa3R061576@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 0a4b664ae858 - main - linux(4): Add struct clone_args for future clone3 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a4b664ae8582b7596858317b53d84eb4f8bbf9a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:50:36 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=0a4b664ae8582b7596858317b53d84eb4f8bbf9a commit 0a4b664ae8582b7596858317b53d84eb4f8bbf9a Author: Dmitry Chagin AuthorDate: 2021-08-12 08:49:01 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:49:01 +0000 linux(4): Add struct clone_args for future clone3 system call. In preparation for clone3 system call add struct clone_args and use it in clone implementation. Move all of clone related bits to the newly created linux_fork.h header. Differential revision: https://reviews.freebsd.org/D31474 MFC after: 2 weeks --- sys/amd64/linux/linux_machdep.c | 1 + sys/amd64/linux/linux_sysvec.c | 1 + sys/amd64/linux32/linux32_machdep.c | 1 + sys/amd64/linux32/linux32_sysvec.c | 1 + sys/arm64/linux/linux_machdep.c | 1 + sys/arm64/linux/linux_sysvec.c | 1 + sys/compat/linux/linux.h | 2 + sys/compat/linux/linux_emul.c | 10 ++-- sys/compat/linux/linux_emul.h | 3 +- sys/compat/linux/linux_fork.c | 53 ++++++++++++--------- sys/compat/linux/linux_fork.h | 92 +++++++++++++++++++++++++++++++++++++ sys/compat/linux/linux_misc.h | 27 ----------- sys/i386/linux/linux_machdep.c | 1 + sys/i386/linux/linux_sysvec.c | 1 + 14 files changed, 140 insertions(+), 55 deletions(-) diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c index 5de27a7ee7d3..dc6b6140f60c 100644 --- a/sys/amd64/linux/linux_machdep.c +++ b/sys/amd64/linux/linux_machdep.c @@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 558dfb4e0ac0..78739ae6d25c 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index 7ad05ec0de32..3a32d1eadb37 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 2ec420b3024a..f45413cca1c8 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c index bbd87eae28c4..9ccda3c3d299 100644 --- a/sys/arm64/linux/linux_machdep.c +++ b/sys/arm64/linux/linux_machdep.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c index 3625155111f2..d576ef48aa44 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/compat/linux/linux.h b/sys/compat/linux/linux.h index cd123622d14a..e75fbe773e61 100644 --- a/sys/compat/linux/linux.h +++ b/sys/compat/linux/linux.h @@ -265,4 +265,6 @@ struct l_statx { uint64_t __spare2[13]; }; +#define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff)) + #endif /* _LINUX_MI_H_ */ diff --git a/sys/compat/linux/linux_emul.c b/sys/compat/linux/linux_emul.c index fbfe9080cac7..86688d50c8a8 100644 --- a/sys/compat/linux/linux_emul.c +++ b/sys/compat/linux/linux_emul.c @@ -139,7 +139,7 @@ linux_set_default_stacksize(struct thread *td, struct proc *p) } void -linux_proc_init(struct thread *td, struct thread *newtd, int flags) +linux_proc_init(struct thread *td, struct thread *newtd, bool init_thread) { struct linux_emuldata *em; struct linux_pemuldata *pem; @@ -150,7 +150,7 @@ linux_proc_init(struct thread *td, struct thread *newtd, int flags) /* non-exec call */ em = malloc(sizeof(*em), M_TEMP, M_WAITOK | M_ZERO); - if (flags & LINUX_CLONE_THREAD) { + if (init_thread) { LINUX_CTR1(proc_init, "thread newtd(%d)", newtd->td_tid); @@ -312,12 +312,12 @@ linux_on_exec(struct proc *p, struct image_params *imgp) * before exec. Update emuldata to reflect * single-threaded cleaned state after exec. */ - linux_proc_init(td, NULL, 0); + linux_proc_init(td, NULL, false); } else { /* * We are switching the process to Linux emulator. */ - linux_proc_init(td, td, 0); + linux_proc_init(td, td, false); /* * Create a transient td_emuldata for all suspended @@ -328,7 +328,7 @@ linux_on_exec(struct proc *p, struct image_params *imgp) FOREACH_THREAD_IN_PROC(td->td_proc, othertd) { if (othertd == td) continue; - linux_proc_init(td, othertd, LINUX_CLONE_THREAD); + linux_proc_init(td, othertd, true); } } #if defined(__amd64__) diff --git a/sys/compat/linux/linux_emul.h b/sys/compat/linux/linux_emul.h index ed5332b2c96c..70646cc93847 100644 --- a/sys/compat/linux/linux_emul.h +++ b/sys/compat/linux/linux_emul.h @@ -55,12 +55,11 @@ struct linux_emuldata { struct linux_emuldata *em_find(struct thread *); int linux_exec_imgact_try(struct image_params *); -void linux_proc_init(struct thread *, struct thread *, int); +void linux_proc_init(struct thread *, struct thread *, bool); void linux_on_exit(struct proc *); void linux_schedtail(struct thread *); void linux_on_exec(struct proc *, struct image_params *); void linux_thread_dtor(struct thread *); -void linux_thread_detach(struct thread *); int linux_common_execve(struct thread *, struct image_args *); void linux32_prepare_notes(struct thread *, struct note_info_list *, size_t *); void linux64_prepare_notes(struct thread *, struct note_info_list *, size_t *); diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index 955e9e512bd1..97f5b7d89de4 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -60,7 +60,9 @@ __FBSDID("$FreeBSD$"); #include #include #endif +#include #include +#include #include #include #include @@ -82,7 +84,7 @@ linux_fork(struct thread *td, struct linux_fork_args *args) td2 = FIRST_THREAD_IN_PROC(p2); - linux_proc_init(td, td2, 0); + linux_proc_init(td, td2, false); td->td_retval[0] = p2->p_pid; @@ -112,7 +114,7 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args) td2 = FIRST_THREAD_IN_PROC(p2); - linux_proc_init(td, td2, 0); + linux_proc_init(td, td2, false); td->td_retval[0] = p2->p_pid; @@ -128,7 +130,7 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args) #endif static int -linux_clone_proc(struct thread *td, struct linux_clone_args *args) +linux_clone_proc(struct thread *td, struct l_clone_args *args) { struct fork_req fr; int error, ff = RFPROC | RFSTOPPED, f2; @@ -138,11 +140,12 @@ linux_clone_proc(struct thread *td, struct linux_clone_args *args) struct linux_emuldata *em; f2 = 0; - exit_signal = args->flags & 0x000000ff; - if (LINUX_SIG_VALID(exit_signal)) { - exit_signal = linux_to_bsd_signal(exit_signal); - } else if (exit_signal != 0) + if (LINUX_SIG_VALID(args->exit_signal)) { + exit_signal = linux_to_bsd_signal(args->exit_signal); + } else if (args->exit_signal != 0) return (EINVAL); + else + exit_signal = 0; if (args->flags & LINUX_CLONE_VM) ff |= RFMEM; @@ -158,7 +161,7 @@ linux_clone_proc(struct thread *td, struct linux_clone_args *args) } if (args->flags & LINUX_CLONE_PARENT_SETTID) - if (args->parent_tidptr == NULL) + if (args->parent_tid == NULL) return (EINVAL); if (args->flags & LINUX_CLONE_VFORK) @@ -175,23 +178,23 @@ linux_clone_proc(struct thread *td, struct linux_clone_args *args) td2 = FIRST_THREAD_IN_PROC(p2); /* create the emuldata */ - linux_proc_init(td, td2, args->flags); + linux_proc_init(td, td2, false); em = em_find(td2); KASSERT(em != NULL, ("clone_proc: emuldata not found.\n")); if (args->flags & LINUX_CLONE_CHILD_SETTID) - em->child_set_tid = args->child_tidptr; + em->child_set_tid = args->child_tid; else em->child_set_tid = NULL; if (args->flags & LINUX_CLONE_CHILD_CLEARTID) - em->child_clear_tid = args->child_tidptr; + em->child_clear_tid = args->child_tid; else em->child_clear_tid = NULL; if (args->flags & LINUX_CLONE_PARENT_SETTID) { - error = copyout(&p2->p_pid, args->parent_tidptr, + error = copyout(&p2->p_pid, args->parent_tid, sizeof(p2->p_pid)); if (error) linux_msg(td, "copyout p_pid failed!"); @@ -235,7 +238,7 @@ linux_clone_proc(struct thread *td, struct linux_clone_args *args) } static int -linux_clone_thread(struct thread *td, struct linux_clone_args *args) +linux_clone_thread(struct thread *td, struct l_clone_args *args) { struct linux_emuldata *em; struct thread *newtd; @@ -244,12 +247,12 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) LINUX_CTR4(clone_thread, "thread(%d) flags %x ptid %p ctid %p", td->td_tid, (unsigned)args->flags, - args->parent_tidptr, args->child_tidptr); + args->parent_tid, args->child_tid); if ((args->flags & LINUX_CLONE_PARENT) != 0) return (EINVAL); if (args->flags & LINUX_CLONE_PARENT_SETTID) - if (args->parent_tidptr == NULL) + if (args->parent_tid == NULL) return (EINVAL); /* Threads should be created with own stack */ @@ -284,7 +287,7 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) thread_cow_get(newtd, td); /* create the emuldata */ - linux_proc_init(td, newtd, args->flags); + linux_proc_init(td, newtd, true); em = em_find(newtd); KASSERT(em != NULL, ("clone_thread: emuldata not found.\n")); @@ -293,12 +296,12 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) linux_set_cloned_tls(newtd, PTRIN(args->tls)); if (args->flags & LINUX_CLONE_CHILD_SETTID) - em->child_set_tid = args->child_tidptr; + em->child_set_tid = args->child_tid; else em->child_set_tid = NULL; if (args->flags & LINUX_CLONE_CHILD_CLEARTID) - em->child_clear_tid = args->child_tidptr; + em->child_clear_tid = args->child_tid; else em->child_clear_tid = NULL; @@ -328,7 +331,7 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) td->td_tid, newtd->td_tid); if (args->flags & LINUX_CLONE_PARENT_SETTID) { - error = copyout(&newtd->td_tid, args->parent_tidptr, + error = copyout(&newtd->td_tid, args->parent_tid, sizeof(newtd->td_tid)); if (error) linux_msg(td, "clone_thread: copyout td_tid failed!"); @@ -359,11 +362,19 @@ fail: int linux_clone(struct thread *td, struct linux_clone_args *args) { + struct l_clone_args ca = { + .flags = (lower_32_bits(args->flags) & ~LINUX_CSIGNAL), + .child_tid = args->child_tidptr, + .parent_tid = args->parent_tidptr, + .exit_signal = (lower_32_bits(args->flags) & LINUX_CSIGNAL), + .stack = args->stack, + .tls = args->tls, + }; if (args->flags & LINUX_CLONE_THREAD) - return (linux_clone_thread(td, args)); + return (linux_clone_thread(td, &ca)); else - return (linux_clone_proc(td, args)); + return (linux_clone_proc(td, &ca)); } int diff --git a/sys/compat/linux/linux_fork.h b/sys/compat/linux/linux_fork.h new file mode 100644 index 000000000000..04dfb8ac8a70 --- /dev/null +++ b/sys/compat/linux/linux_fork.h @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 2021 Dmitry Chagin + * + * 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$ + */ + +#ifndef _LINUX_FORK_H_ +#define _LINUX_FORK_H_ + +#define LINUX_CLONE_VM 0x00000100 +#define LINUX_CLONE_FS 0x00000200 +#define LINUX_CLONE_FILES 0x00000400 +#define LINUX_CLONE_SIGHAND 0x00000800 +#define LINUX_CLONE_PID 0x00001000 /* No longer exist in Linux */ +#define LINUX_CLONE_PTRACE 0x00002000 +#define LINUX_CLONE_VFORK 0x00004000 +#define LINUX_CLONE_PARENT 0x00008000 +#define LINUX_CLONE_THREAD 0x00010000 +#define LINUX_CLONE_NEWNS 0x00020000 /* New mount NS */ +#define LINUX_CLONE_SYSVSEM 0x00040000 +#define LINUX_CLONE_SETTLS 0x00080000 +#define LINUX_CLONE_PARENT_SETTID 0x00100000 +#define LINUX_CLONE_CHILD_CLEARTID 0x00200000 +#define LINUX_CLONE_DETACHED 0x00400000 /* Unused */ +#define LINUX_CLONE_UNTRACED 0x00800000 +#define LINUX_CLONE_CHILD_SETTID 0x01000000 +#define LINUX_CLONE_NEWCGROUP 0x02000000 /* New cgroup NS */ +#define LINUX_CLONE_NEWUTS 0x04000000 +#define LINUX_CLONE_NEWIPC 0x08000000 +#define LINUX_CLONE_NEWUSER 0x10000000 +#define LINUX_CLONE_NEWPID 0x20000000 +#define LINUX_CLONE_NEWNET 0x40000000 +#define LINUX_CLONE_IO 0x80000000 + +#define LINUX_CSIGNAL 0x000000ff + +/* + * User-space clone3 args layout. + */ +struct l_user_clone_args { + uint64_t flags; + uint64_t pidfd; + uint64_t child_tid; + uint64_t parent_tid; + uint64_t exit_signal; + uint64_t stack; + uint64_t stack_size; + uint64_t tls; + uint64_t set_tid; + uint64_t set_tid_size; + uint64_t cgroup; +}; + +/* + * Kernel clone3 args layout. + */ +struct l_clone_args { + uint64_t flags; + l_int *child_tid; + l_int *parent_tid; + l_int exit_signal; + l_ulong stack; + l_ulong stack_size; + l_ulong tls; +}; + +int linux_set_upcall(struct thread *, register_t); +int linux_set_cloned_tls(struct thread *, void *); +void linux_thread_detach(struct thread *); + +#endif /* _LINUX_FORK_H_ */ diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index dc17ed430014..80f6b8a58e81 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -98,31 +98,6 @@ #define __LINUX_NPXCW__ 0x37f #endif -#define LINUX_CLONE_VM 0x00000100 -#define LINUX_CLONE_FS 0x00000200 -#define LINUX_CLONE_FILES 0x00000400 -#define LINUX_CLONE_SIGHAND 0x00000800 -#define LINUX_CLONE_PID 0x00001000 /* No longer exist in Linux */ -#define LINUX_CLONE_PTRACE 0x00002000 -#define LINUX_CLONE_VFORK 0x00004000 -#define LINUX_CLONE_PARENT 0x00008000 -#define LINUX_CLONE_THREAD 0x00010000 -#define LINUX_CLONE_NEWNS 0x00020000 /* New mount NS */ -#define LINUX_CLONE_SYSVSEM 0x00040000 -#define LINUX_CLONE_SETTLS 0x00080000 -#define LINUX_CLONE_PARENT_SETTID 0x00100000 -#define LINUX_CLONE_CHILD_CLEARTID 0x00200000 -#define LINUX_CLONE_DETACHED 0x00400000 /* Unused */ -#define LINUX_CLONE_UNTRACED 0x00800000 -#define LINUX_CLONE_CHILD_SETTID 0x01000000 -#define LINUX_CLONE_NEWCGROUP 0x02000000 /* New cgroup NS */ -#define LINUX_CLONE_NEWUTS 0x04000000 -#define LINUX_CLONE_NEWIPC 0x08000000 -#define LINUX_CLONE_NEWUSER 0x10000000 -#define LINUX_CLONE_NEWPID 0x20000000 -#define LINUX_CLONE_NEWNET 0x40000000 -#define LINUX_CLONE_IO 0x80000000 - /* Scheduling policies */ #define LINUX_SCHED_OTHER 0 #define LINUX_SCHED_FIFO 1 @@ -180,8 +155,6 @@ extern int stclohz; int linux_ptrace_status(struct thread *td, int pid, int status); #endif void linux_to_bsd_waitopts(int options, int *bsdopts); -int linux_set_upcall(struct thread *td, register_t stack); -int linux_set_cloned_tls(struct thread *td, void *desc); struct thread *linux_tdfind(struct thread *, lwpid_t, pid_t); #endif /* _LINUX_MISC_H_ */ diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index 1a51b7954063..c81bf1b4e2e5 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 02d69de4d8f8..d692679c3ec6 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:50:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D66C76674B9; Thu, 12 Aug 2021 08:50: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 4GlgPn5c6Fz4SLl; Thu, 12 Aug 2021 08:50:37 +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 A8D3B1FBCD; Thu, 12 Aug 2021 08:50:37 +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 17C8obtM061601; Thu, 12 Aug 2021 08:50:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8obLG061600; Thu, 12 Aug 2021 08:50:37 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:50:37 GMT Message-Id: <202108120850.17C8obLG061600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 17913b0b6b70 - main - linux(4): Implement clone3 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 17913b0b6b707568d63559255820f3212cd31cdf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:50:38 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=17913b0b6b707568d63559255820f3212cd31cdf commit 17913b0b6b707568d63559255820f3212cd31cdf Author: Dmitry Chagin AuthorDate: 2021-08-12 08:49:36 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:49:36 +0000 linux(4): Implement clone3 system call. clone3 system call is used by glibc-2.34. Differential revision: https://reviews.freebsd.org/D31475 MFC after: 2 weeks --- sys/amd64/linux/syscalls.master | 5 ++- sys/amd64/linux32/syscalls.master | 5 ++- sys/arm64/linux/syscalls.master | 5 ++- sys/compat/linux/linux_fork.c | 80 +++++++++++++++++++++++++++++++++++++++ sys/compat/linux/linux_fork.h | 9 +++++ sys/compat/linux/linux_misc.h | 2 + sys/i386/linux/syscalls.master | 5 ++- 7 files changed, 107 insertions(+), 4 deletions(-) diff --git a/sys/amd64/linux/syscalls.master b/sys/amd64/linux/syscalls.master index cdf663ce2e06..d3ebedbfed01 100644 --- a/sys/amd64/linux/syscalls.master +++ b/sys/amd64/linux/syscalls.master @@ -2082,7 +2082,10 @@ int linux_pidfd_open(void); } 435 AUE_NULL STD { - int linux_clone3(void); + int linux_clone3( + struct l_user_clone_args *uargs, + l_size_t usize + ); } 436 AUE_NULL STD { int linux_close_range(void); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index ff7ab7f98ca8..9d55fb1ade48 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2484,7 +2484,10 @@ int linux_pidfd_open(void); } 435 AUE_NULL STD { - int linux_clone3(void); + int linux_clone3( + struct l_user_clone_args *uargs, + l_size_t usize + ); } 436 AUE_NULL STD { int linux_close_range(void); diff --git a/sys/arm64/linux/syscalls.master b/sys/arm64/linux/syscalls.master index 6e163cc3360d..a6bb14a5ed63 100644 --- a/sys/arm64/linux/syscalls.master +++ b/sys/arm64/linux/syscalls.master @@ -1731,7 +1731,10 @@ int linux_pidfd_open(void); } 435 AUE_NULL STD { - int linux_clone3(void); + int linux_clone3( + struct l_user_clone_args *uargs, + l_size_t usize + ); } 436 AUE_NULL STD { int linux_close_range(void); diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index 97f5b7d89de4..db3e9e1ea27b 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -377,6 +377,86 @@ linux_clone(struct thread *td, struct linux_clone_args *args) return (linux_clone_proc(td, &ca)); } + +static int +linux_clone3_args_valid(struct l_user_clone_args *uca) +{ + + /* Verify that no unknown flags are passed along. */ + if ((uca->flags & ~(LINUX_CLONE_LEGACY_FLAGS | + LINUX_CLONE_CLEAR_SIGHAND | LINUX_CLONE_INTO_CGROUP)) != 0) + return (EINVAL); + if ((uca->flags & (LINUX_CLONE_DETACHED | LINUX_CSIGNAL)) != 0) + return (EINVAL); + + if ((uca->flags & (LINUX_CLONE_SIGHAND | LINUX_CLONE_CLEAR_SIGHAND)) == + (LINUX_CLONE_SIGHAND | LINUX_CLONE_CLEAR_SIGHAND)) + return (EINVAL); + if ((uca->flags & (LINUX_CLONE_THREAD | LINUX_CLONE_PARENT)) != 0 && + uca->exit_signal != 0) + return (EINVAL); + + /* We don't support set_tid, only validate input. */ + if (uca->set_tid_size > LINUX_MAX_PID_NS_LEVEL) + return (EINVAL); + if (uca->set_tid == 0 && uca->set_tid_size > 0) + return (EINVAL); + if (uca->set_tid != 0 && uca->set_tid_size == 0) + return (EINVAL); + + if (uca->stack == 0 && uca->stack_size > 0) + return (EINVAL); + if (uca->stack != 0 && uca->stack_size == 0) + return (EINVAL); + + return (0); +} + +int +linux_clone3(struct thread *td, struct linux_clone3_args *args) +{ + struct l_user_clone_args *uca; + struct l_clone_args *ca; + size_t size; + int error; + + if (args->usize > PAGE_SIZE) + return (E2BIG); + if (args->usize < LINUX_CLONE_ARGS_SIZE_VER0) + return (EINVAL); + + /* + * usize can be less than size of struct clone_args, to avoid using + * of uninitialized data of struct clone_args, allocate at least + * sizeof(struct clone_args) storage and zero it. + */ + size = max(args->usize, sizeof(*uca)); + uca = malloc(size, M_LINUX, M_WAITOK | M_ZERO); + error = copyin(args->uargs, uca, args->usize); + if (error != 0) + goto out; + error = linux_clone3_args_valid(uca); + if (error != 0) + goto out; + ca = malloc(sizeof(*ca), M_LINUX, M_WAITOK | M_ZERO); + ca->flags = uca->flags; + ca->child_tid = PTRIN(uca->child_tid); + ca->parent_tid = PTRIN(uca->parent_tid); + ca->exit_signal = uca->exit_signal; + ca->stack = uca->stack + uca->stack_size; + ca->stack_size = uca->stack_size; + ca->tls = uca->tls; + + if ((ca->flags & LINUX_CLONE_THREAD) != 0) + error = linux_clone_thread(td, ca); + else + error = linux_clone_proc(td, ca); + free(ca, M_LINUX); +out: + free(uca, M_LINUX); + return (error); +} + int linux_exit(struct thread *td, struct linux_exit_args *args) { diff --git a/sys/compat/linux/linux_fork.h b/sys/compat/linux/linux_fork.h index 04dfb8ac8a70..fa7b39544450 100644 --- a/sys/compat/linux/linux_fork.h +++ b/sys/compat/linux/linux_fork.h @@ -53,6 +53,13 @@ #define LINUX_CLONE_NEWNET 0x40000000 #define LINUX_CLONE_IO 0x80000000 +/* Flags for the clone3() syscall. */ +#define LINUX_CLONE_CLEAR_SIGHAND 0x100000000ULL +#define LINUX_CLONE_INTO_CGROUP 0x200000000ULL +#define LINUX_CLONE_NEWTIME 0x00000080 + +#define LINUX_CLONE_LEGACY_FLAGS 0xffffffffULL + #define LINUX_CSIGNAL 0x000000ff /* @@ -85,6 +92,8 @@ struct l_clone_args { l_ulong tls; }; +#define LINUX_CLONE_ARGS_SIZE_VER0 64 + int linux_set_upcall(struct thread *, register_t); int linux_set_cloned_tls(struct thread *, void *); void linux_thread_detach(struct thread *); diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index 80f6b8a58e81..ceb140d3da75 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -33,6 +33,8 @@ #include +#define LINUX_MAX_PID_NS_LEVEL 32 + /* bits per mask */ #define LINUX_NFDBITS sizeof(l_fd_mask) * 8 diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index aecb852e21c7..27bbca9e65e7 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2502,7 +2502,10 @@ int linux_pidfd_open(void); } 435 AUE_NULL STD { - int linux_clone3(void); + int linux_clone3( + struct l_user_clone_args *uargs, + l_size_t usize + ); } 436 AUE_NULL STD { int linux_close_range(void); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:50:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 39E086673D4; Thu, 12 Aug 2021 08:50:39 +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 4GlgPq0RPNz4SR8; Thu, 12 Aug 2021 08:50:39 +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 DA25C1FF84; Thu, 12 Aug 2021 08:50: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 17C8ocka061625; Thu, 12 Aug 2021 08:50:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8ocwe061624; Thu, 12 Aug 2021 08:50:38 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:50:38 GMT Message-Id: <202108120850.17C8ocwe061624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: b356030e6706 - main - linux(4): Regen for clone3 system call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b356030e670686df1300edf851e146c5d274e4f8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:50:39 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=b356030e670686df1300edf851e146c5d274e4f8 commit b356030e670686df1300edf851e146c5d274e4f8 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:50:22 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:50:22 +0000 linux(4): Regen for clone3 system call. MFC after: 2 weeks --- sys/amd64/linux/linux_proto.h | 3 ++- sys/amd64/linux/linux_sysent.c | 2 +- sys/amd64/linux/linux_systrace_args.c | 18 +++++++++++++++++- sys/amd64/linux32/linux32_proto.h | 3 ++- sys/amd64/linux32/linux32_sysent.c | 2 +- sys/amd64/linux32/linux32_systrace_args.c | 18 +++++++++++++++++- sys/arm64/linux/linux_proto.h | 3 ++- sys/arm64/linux/linux_sysent.c | 2 +- sys/arm64/linux/linux_systrace_args.c | 18 +++++++++++++++++- sys/i386/linux/linux_proto.h | 3 ++- sys/i386/linux/linux_sysent.c | 2 +- sys/i386/linux/linux_systrace_args.c | 18 +++++++++++++++++- 12 files changed, 80 insertions(+), 12 deletions(-) diff --git a/sys/amd64/linux/linux_proto.h b/sys/amd64/linux/linux_proto.h index 5ebf28723c64..e609d3deeb31 100644 --- a/sys/amd64/linux/linux_proto.h +++ b/sys/amd64/linux/linux_proto.h @@ -1358,7 +1358,8 @@ struct linux_pidfd_open_args { register_t dummy; }; struct linux_clone3_args { - register_t dummy; + char uargs_l_[PADL_(struct l_user_clone_args *)]; struct l_user_clone_args * uargs; char uargs_r_[PADR_(struct l_user_clone_args *)]; + char usize_l_[PADL_(l_size_t)]; l_size_t usize; char usize_r_[PADR_(l_size_t)]; }; struct linux_close_range_args { register_t dummy; diff --git a/sys/amd64/linux/linux_sysent.c b/sys/amd64/linux/linux_sysent.c index cca061243a2f..c866076fa9d3 100644 --- a/sys/amd64/linux/linux_sysent.c +++ b/sys/amd64/linux/linux_sysent.c @@ -452,7 +452,7 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fsmount, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 432 = linux_fsmount */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fspick, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 433 = linux_fspick */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_open, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 434 = linux_pidfd_open */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ + { .sy_narg = AS(linux_clone3_args), .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ diff --git a/sys/amd64/linux/linux_systrace_args.c b/sys/amd64/linux/linux_systrace_args.c index 3101b8672ce2..9db01b6b7440 100644 --- a/sys/amd64/linux/linux_systrace_args.c +++ b/sys/amd64/linux/linux_systrace_args.c @@ -2677,7 +2677,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_clone3 */ case 435: { - *n_args = 0; + struct linux_clone3_args *p = params; + uarg[0] = (intptr_t)p->uargs; /* struct l_user_clone_args * */ + iarg[1] = p->usize; /* l_size_t */ + *n_args = 2; break; } /* linux_close_range */ @@ -7012,6 +7015,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_clone3 */ case 435: + switch (ndx) { + case 0: + p = "userland struct l_user_clone_args *"; + break; + case 1: + p = "l_size_t"; + break; + default: + break; + }; break; /* linux_close_range */ case 436: @@ -8512,6 +8525,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 434: /* linux_clone3 */ case 435: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_close_range */ case 436: /* linux_openat2 */ diff --git a/sys/amd64/linux32/linux32_proto.h b/sys/amd64/linux32/linux32_proto.h index 07e673a862ad..819ec994d0c9 100644 --- a/sys/amd64/linux32/linux32_proto.h +++ b/sys/amd64/linux32/linux32_proto.h @@ -1646,7 +1646,8 @@ struct linux_pidfd_open_args { register_t dummy; }; struct linux_clone3_args { - register_t dummy; + char uargs_l_[PADL_(struct l_user_clone_args *)]; struct l_user_clone_args * uargs; char uargs_r_[PADR_(struct l_user_clone_args *)]; + char usize_l_[PADL_(l_size_t)]; l_size_t usize; char usize_r_[PADR_(l_size_t)]; }; struct linux_close_range_args { register_t dummy; diff --git a/sys/amd64/linux32/linux32_sysent.c b/sys/amd64/linux32/linux32_sysent.c index cf4ccc56990c..46b74d6a8139 100644 --- a/sys/amd64/linux32/linux32_sysent.c +++ b/sys/amd64/linux32/linux32_sysent.c @@ -452,7 +452,7 @@ struct sysent linux32_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fsmount, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 432 = linux_fsmount */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fspick, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 433 = linux_fspick */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_open, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 434 = linux_pidfd_open */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ + { .sy_narg = AS(linux_clone3_args), .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ diff --git a/sys/amd64/linux32/linux32_systrace_args.c b/sys/amd64/linux32/linux32_systrace_args.c index 79605a335aaf..8ff6242542f3 100644 --- a/sys/amd64/linux32/linux32_systrace_args.c +++ b/sys/amd64/linux32/linux32_systrace_args.c @@ -3166,7 +3166,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_clone3 */ case 435: { - *n_args = 0; + struct linux_clone3_args *p = params; + uarg[0] = (intptr_t)p->uargs; /* struct l_user_clone_args * */ + iarg[1] = p->usize; /* l_size_t */ + *n_args = 2; break; } /* linux_close_range */ @@ -8285,6 +8288,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_clone3 */ case 435: + switch (ndx) { + case 0: + p = "userland struct l_user_clone_args *"; + break; + case 1: + p = "l_size_t"; + break; + default: + break; + }; break; /* linux_close_range */ case 436: @@ -10054,6 +10067,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 434: /* linux_clone3 */ case 435: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_close_range */ case 436: /* linux_openat2 */ diff --git a/sys/arm64/linux/linux_proto.h b/sys/arm64/linux/linux_proto.h index 83237b046f85..6b12f819c87c 100644 --- a/sys/arm64/linux/linux_proto.h +++ b/sys/arm64/linux/linux_proto.h @@ -1168,7 +1168,8 @@ struct linux_pidfd_open_args { register_t dummy; }; struct linux_clone3_args { - register_t dummy; + char uargs_l_[PADL_(struct l_user_clone_args *)]; struct l_user_clone_args * uargs; char uargs_r_[PADR_(struct l_user_clone_args *)]; + char usize_l_[PADL_(l_size_t)]; l_size_t usize; char usize_r_[PADR_(l_size_t)]; }; struct linux_close_range_args { register_t dummy; diff --git a/sys/arm64/linux/linux_sysent.c b/sys/arm64/linux/linux_sysent.c index a11c9b80cb11..5228faa77b8c 100644 --- a/sys/arm64/linux/linux_sysent.c +++ b/sys/arm64/linux/linux_sysent.c @@ -452,7 +452,7 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fsmount, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 432 = linux_fsmount */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fspick, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 433 = linux_fspick */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_open, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 434 = linux_pidfd_open */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ + { .sy_narg = AS(linux_clone3_args), .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ diff --git a/sys/arm64/linux/linux_systrace_args.c b/sys/arm64/linux/linux_systrace_args.c index 6c0eeb5ae0f4..42f37dbff137 100644 --- a/sys/arm64/linux/linux_systrace_args.c +++ b/sys/arm64/linux/linux_systrace_args.c @@ -2299,7 +2299,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_clone3 */ case 435: { - *n_args = 0; + struct linux_clone3_args *p = params; + uarg[0] = (intptr_t)p->uargs; /* struct l_user_clone_args * */ + iarg[1] = p->usize; /* l_size_t */ + *n_args = 2; break; } /* linux_close_range */ @@ -6087,6 +6090,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_clone3 */ case 435: + switch (ndx) { + case 0: + p = "userland struct l_user_clone_args *"; + break; + case 1: + p = "l_size_t"; + break; + default: + break; + }; break; /* linux_close_range */ case 436: @@ -7372,6 +7385,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 434: /* linux_clone3 */ case 435: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_close_range */ case 436: /* linux_openat2 */ diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index 24b912757e61..d6e87072a89a 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -1639,7 +1639,8 @@ struct linux_pidfd_open_args { register_t dummy; }; struct linux_clone3_args { - register_t dummy; + char uargs_l_[PADL_(struct l_user_clone_args *)]; struct l_user_clone_args * uargs; char uargs_r_[PADR_(struct l_user_clone_args *)]; + char usize_l_[PADL_(l_size_t)]; l_size_t usize; char usize_r_[PADR_(l_size_t)]; }; struct linux_close_range_args { register_t dummy; diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index 5c592cd2c141..4435ef97a831 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -452,7 +452,7 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fsmount, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 432 = linux_fsmount */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fspick, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 433 = linux_fspick */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_open, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 434 = linux_pidfd_open */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ + { .sy_narg = AS(linux_clone3_args), .sy_call = (sy_call_t *)linux_clone3, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 435 = linux_clone3 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_close_range, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 436 = linux_close_range */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_openat2, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 437 = linux_openat2 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_pidfd_getfd, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 438 = linux_pidfd_getfd */ diff --git a/sys/i386/linux/linux_systrace_args.c b/sys/i386/linux/linux_systrace_args.c index 0752304d5872..baee524e5a6d 100644 --- a/sys/i386/linux/linux_systrace_args.c +++ b/sys/i386/linux/linux_systrace_args.c @@ -3205,7 +3205,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_clone3 */ case 435: { - *n_args = 0; + struct linux_clone3_args *p = params; + uarg[0] = (intptr_t)p->uargs; /* struct l_user_clone_args * */ + iarg[1] = p->usize; /* l_size_t */ + *n_args = 2; break; } /* linux_close_range */ @@ -8362,6 +8365,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_clone3 */ case 435: + switch (ndx) { + case 0: + p = "userland struct l_user_clone_args *"; + break; + case 1: + p = "l_size_t"; + break; + default: + break; + }; break; /* linux_close_range */ case 436: @@ -10160,6 +10173,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 434: /* linux_clone3 */ case 435: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_close_range */ case 436: /* linux_openat2 */ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:53:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D4D51667984; Thu, 12 Aug 2021 08:53: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 4GlgSt5gXjz4SQJ; Thu, 12 Aug 2021 08:53: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 AAAEB1FEE2; Thu, 12 Aug 2021 08:53: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 17C8rIqF063528; Thu, 12 Aug 2021 08:53:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8rIGX063527; Thu, 12 Aug 2021 08:53:18 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:53:18 GMT Message-Id: <202108120853.17C8rIGX063527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 29b25b13c777 - main - Sort the arm64 cpu_implementers list by name MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 29b25b13c777a682e33edc9e2d05e87339b03cc3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:53:18 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=29b25b13c777a682e33edc9e2d05e87339b03cc3 commit 29b25b13c777a682e33edc9e2d05e87339b03cc3 Author: Andrew Turner AuthorDate: 2021-08-11 15:29:09 +0000 Commit: Andrew Turner CommitDate: 2021-08-12 08:53:06 +0000 Sort the arm64 cpu_implementers list by name We perform a linear search, so make it easier to add new entries in the correct place. Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/identcpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c index 37330a8f0e3f..581e16ee82f6 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -220,17 +220,17 @@ static const struct cpu_parts cpu_parts_none[] = { * Implementers table. */ const struct cpu_implementers cpu_implementers[] = { + { CPU_IMPL_APM, "APM", cpu_parts_apm }, { CPU_IMPL_ARM, "ARM", cpu_parts_arm }, { CPU_IMPL_BROADCOM, "Broadcom", cpu_parts_none }, { CPU_IMPL_CAVIUM, "Cavium", cpu_parts_cavium }, { CPU_IMPL_DEC, "DEC", cpu_parts_none }, - { CPU_IMPL_INFINEON, "IFX", cpu_parts_none }, { CPU_IMPL_FREESCALE, "Freescale", cpu_parts_none }, + { CPU_IMPL_INFINEON, "IFX", cpu_parts_none }, + { CPU_IMPL_INTEL, "Intel", cpu_parts_none }, + { CPU_IMPL_MARVELL, "Marvell", cpu_parts_none }, { CPU_IMPL_NVIDIA, "NVIDIA", cpu_parts_none }, - { CPU_IMPL_APM, "APM", cpu_parts_apm }, { CPU_IMPL_QUALCOMM, "Qualcomm", cpu_parts_none }, - { CPU_IMPL_MARVELL, "Marvell", cpu_parts_none }, - { CPU_IMPL_INTEL, "Intel", cpu_parts_none }, CPU_IMPLEMENTER_NONE, }; From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:53:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2899E667908; Thu, 12 Aug 2021 08:53: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 4GlgSv6Z58z4Sft; Thu, 12 Aug 2021 08:53: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 CAC3D1FEE3; Thu, 12 Aug 2021 08:53: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 17C8rJUk063557; Thu, 12 Aug 2021 08:53:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8rJn4063556; Thu, 12 Aug 2021 08:53:19 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:53:19 GMT Message-Id: <202108120853.17C8rJn4063556@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: a7fcda1b8c21 - main - Add the Apple arm64 implementer ID MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a7fcda1b8c21a47ac8cdd2e7cfae298d67467e3b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:53:20 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=a7fcda1b8c21a47ac8cdd2e7cfae298d67467e3b commit a7fcda1b8c21a47ac8cdd2e7cfae298d67467e3b Author: Andrew Turner AuthorDate: 2021-08-11 15:30:44 +0000 Commit: Andrew Turner CommitDate: 2021-08-12 08:53:06 +0000 Add the Apple arm64 implementer ID Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/identcpu.c | 1 + sys/arm64/include/cpu.h | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c index 581e16ee82f6..dabfe6f99d3a 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -220,6 +220,7 @@ static const struct cpu_parts cpu_parts_none[] = { * Implementers table. */ const struct cpu_implementers cpu_implementers[] = { + { CPU_IMPL_APPLE, "Apple", cpu_parts_none }, { CPU_IMPL_APM, "APM", cpu_parts_apm }, { CPU_IMPL_ARM, "ARM", cpu_parts_arm }, { CPU_IMPL_BROADCOM, "Broadcom", cpu_parts_none }, diff --git a/sys/arm64/include/cpu.h b/sys/arm64/include/cpu.h index d58cf6f113c6..0b1aa2d93b03 100644 --- a/sys/arm64/include/cpu.h +++ b/sys/arm64/include/cpu.h @@ -77,6 +77,7 @@ #define CPU_IMPL_APM 0x50 #define CPU_IMPL_QUALCOMM 0x51 #define CPU_IMPL_MARVELL 0x56 +#define CPU_IMPL_APPLE 0x61 #define CPU_IMPL_INTEL 0x69 /* ARM Part numbers */ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:53:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 773FB66746D; Thu, 12 Aug 2021 08:53: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 4GlgSx2LRsz4Sfy; Thu, 12 Aug 2021 08:53: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 F3C562010F; Thu, 12 Aug 2021 08:53: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 17C8rKS7063582; Thu, 12 Aug 2021 08:53:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8rKkD063581; Thu, 12 Aug 2021 08:53:20 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:53:20 GMT Message-Id: <202108120853.17C8rKkD063581@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 17b6ee961382 - main - Enable arm64 SError exceptions in the kernel MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 17b6ee96138220a164d632f0be69d3df77bdd61a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:53:21 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=17b6ee96138220a164d632f0be69d3df77bdd61a commit 17b6ee96138220a164d632f0be69d3df77bdd61a Author: Andrew Turner AuthorDate: 2021-08-09 16:30:44 +0000 Commit: Andrew Turner CommitDate: 2021-08-12 08:53:06 +0000 Enable arm64 SError exceptions in the kernel These are needed to signal to the kernel when a Reliability, Availability, and Serviceability (RAS) exception has triggered. Reviewed by: mhorne Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31477 --- sys/arm64/arm64/exception.S | 24 ++++++++++++++---------- sys/arm64/arm64/machdep.c | 6 ++++++ sys/arm64/arm64/vm_machdep.c | 4 ++-- sys/arm64/include/armreg.h | 8 ++------ sys/arm64/include/cpufunc.h | 7 +++++++ 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S index 67233daf4442..413b9523eb06 100644 --- a/sys/arm64/arm64/exception.S +++ b/sys/arm64/arm64/exception.S @@ -75,23 +75,25 @@ __FBSDID("$FreeBSD$"); ldr x0, [x18, #(PC_CURTHREAD)] bl dbg_monitor_enter - msr daifclr, #DAIF_D /* Enable the debug exception */ -.endif + + /* Unmask debug and SError exceptions */ + msr daifclr, #(DAIF_D | DAIF_A) +.else /* + * Unmask debug and SError exceptions. * For EL1, debug exceptions are conditionally unmasked in * do_el1h_sync(). */ + msr daifclr, #(DAIF_A) +.endif .endm .macro restore_registers el -.if \el == 1 /* - * Disable interrupts and debug exceptions, x18 may change in the - * interrupt exception handler. For EL0 exceptions, do_ast already - * did this. + * Mask all exceptions, x18 may change in the interrupt exception + * handler. */ - msr daifset, #(DAIF_D | DAIF_INTR) -.endif + msr daifset, #(DAIF_ALL) .if \el == 0 ldr x0, [x18, #PC_CURTHREAD] mov x1, sp @@ -147,8 +149,10 @@ __FBSDID("$FreeBSD$"); /* Make sure the IRQs are enabled before calling ast() */ bic x19, x19, #PSR_I 1: - /* Disable interrupts */ - msr daifset, #(DAIF_D | DAIF_INTR) + /* + * Mask interrupts while checking the ast pending flag + */ + msr daifset, #(DAIF_INTR) /* Read the current thread flags */ ldr x1, [x18, #PC_CURTHREAD] /* Load curthread */ diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index be9bddf23062..bce3baf8e1ec 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -931,6 +931,12 @@ init_proc0(vm_offset_t kstack) thread0.td_pcb->pcb_vfpcpu = UINT_MAX; thread0.td_frame = &proc0_tf; pcpup->pc_curpcb = thread0.td_pcb; + + /* + * Unmask SError exceptions. They are used to signal a RAS failure, + * or other hardware error. + */ + serror_enable(); } typedef struct { diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c index a7b02e98959f..bf7641074317 100644 --- a/sys/arm64/arm64/vm_machdep.c +++ b/sys/arm64/arm64/vm_machdep.c @@ -112,7 +112,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) /* Setup to release spin count in fork_exit(). */ td2->td_md.md_spinlock_count = 1; - td2->td_md.md_saved_daif = td1->td_md.md_saved_daif & ~DAIF_I_MASKED; + td2->td_md.md_saved_daif = PSR_DAIF_DEFAULT; } void @@ -186,7 +186,7 @@ cpu_copy_thread(struct thread *td, struct thread *td0) /* Setup to release spin count in fork_exit(). */ td->td_md.md_spinlock_count = 1; - td->td_md.md_saved_daif = td0->td_md.md_saved_daif & ~DAIF_I_MASKED; + td->td_md.md_saved_daif = PSR_DAIF_DEFAULT; } /* diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 8c7c535e4277..bc6d34cb3c1a 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -124,12 +124,6 @@ #define CTR_ILINE_VAL(reg) ((reg) & CTR_ILINE_MASK) #define CTR_ILINE_SIZE(reg) (4 << (CTR_ILINE_VAL(reg) >> CTR_ILINE_SHIFT)) -/* DAIF - Interrupt Mask Bits */ -#define DAIF_D_MASKED (1 << 9) -#define DAIF_A_MASKED (1 << 8) -#define DAIF_I_MASKED (1 << 7) -#define DAIF_F_MASKED (1 << 6) - /* DAIFSet/DAIFClear */ #define DAIF_D (1 << 3) #define DAIF_A (1 << 2) @@ -1078,6 +1072,8 @@ #define PSR_A 0x00000100 #define PSR_D 0x00000200 #define PSR_DAIF (PSR_D | PSR_A | PSR_I | PSR_F) +/* The default DAIF mask. These bits are valid in spsr_el1 and daif */ +#define PSR_DAIF_DEFAULT (PSR_F) #define PSR_IL 0x00100000 #define PSR_SS 0x00200000 #define PSR_V 0x10000000 diff --git a/sys/arm64/include/cpufunc.h b/sys/arm64/include/cpufunc.h index 7f13972e838b..94af62380de3 100644 --- a/sys/arm64/include/cpufunc.h +++ b/sys/arm64/include/cpufunc.h @@ -147,6 +147,13 @@ intr_enable(void) __asm __volatile("msr daifclr, #(" __XSTRING(DAIF_INTR) ")"); } +static __inline void +serror_enable(void) +{ + + __asm __volatile("msr daifclr, #(" __XSTRING(DAIF_A) ")"); +} + static __inline register_t get_midr(void) { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:56:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 193D466786B; Thu, 12 Aug 2021 08:56: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 4GlgX20GGRz4T5B; Thu, 12 Aug 2021 08:56: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 E3F1D2020C; Thu, 12 Aug 2021 08:56: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 17C8u1bN064021; Thu, 12 Aug 2021 08:56:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8u1ga064020; Thu, 12 Aug 2021 08:56:01 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:56:01 GMT Message-Id: <202108120856.17C8u1ga064020@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: a796845d6de0 - main - linux(4): Add CLONE_PIDFD option bit. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a796845d6de083971eef2d2a33ccc74fcd609ec7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:56:02 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=a796845d6de083971eef2d2a33ccc74fcd609ec7 commit a796845d6de083971eef2d2a33ccc74fcd609ec7 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:55:24 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:55:24 +0000 linux(4): Add CLONE_PIDFD option bit. Differential revision: https://reviews.freebsd.org/D31478 MFC after: 2 weeks --- sys/compat/linux/linux_fork.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_fork.h b/sys/compat/linux/linux_fork.h index fa7b39544450..bdc201bce57e 100644 --- a/sys/compat/linux/linux_fork.h +++ b/sys/compat/linux/linux_fork.h @@ -32,7 +32,7 @@ #define LINUX_CLONE_FS 0x00000200 #define LINUX_CLONE_FILES 0x00000400 #define LINUX_CLONE_SIGHAND 0x00000800 -#define LINUX_CLONE_PID 0x00001000 /* No longer exist in Linux */ +#define LINUX_CLONE_PIDFD 0x00001000 /* since Linux 5.2 */ #define LINUX_CLONE_PTRACE 0x00002000 #define LINUX_CLONE_VFORK 0x00004000 #define LINUX_CLONE_PARENT 0x00008000 From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:56:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4AAC5667B14; Thu, 12 Aug 2021 08:56: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 4GlgX316Q7z4T5G; Thu, 12 Aug 2021 08:56: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 0EEE51FEEB; Thu, 12 Aug 2021 08:56: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 17C8u2MG064048; Thu, 12 Aug 2021 08:56:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8u25I064047; Thu, 12 Aug 2021 08:56:02 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:56:02 GMT Message-Id: <202108120856.17C8u25I064047@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: c5fc9fe7f36a - main - linux(4): Implement CLONE_CLEAR_SIGHAND option bit. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c5fc9fe7f36a742e567173b2e3d65252140013d1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:56:03 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c5fc9fe7f36a742e567173b2e3d65252140013d1 commit c5fc9fe7f36a742e567173b2e3d65252140013d1 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:55:35 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:55:35 +0000 linux(4): Implement CLONE_CLEAR_SIGHAND option bit. CLONE_CLEAR_SIGHAND is designed to reset all signal handlers of the child not set to SIG_IGN to SIG_DFL. Reviewed by: kib Differential revision: https://reviews.freebsd.org/D31481 MFC after: 2 weeks --- sys/compat/linux/linux_fork.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index db3e9e1ea27b..77dd8446c588 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -151,6 +151,8 @@ linux_clone_proc(struct thread *td, struct l_clone_args *args) ff |= RFMEM; if (args->flags & LINUX_CLONE_SIGHAND) ff |= RFSIGSHARE; + if ((args->flags & LINUX_CLONE_CLEAR_SIGHAND) != 0) + f2 |= FR2_DROPSIG_CAUGHT; if (args->flags & LINUX_CLONE_FILES) { if (!(args->flags & LINUX_CLONE_FS)) f2 |= FR2_SHARE_PATHS; From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:56:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A8426667C01; Thu, 12 Aug 2021 08: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 4GlgX42K9mz4T9r; Thu, 12 Aug 2021 08: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 2CA8D1FFC7; Thu, 12 Aug 2021 08: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 17C8u4wl064072; Thu, 12 Aug 2021 08: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 17C8u49T064071; Thu, 12 Aug 2021 08:56:04 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:56:04 GMT Message-Id: <202108120856.17C8u49T064071@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 0d77f6c0c350 - main - linux(4): Add LINUX_RATELIMIT_MSG macro for future use. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0d77f6c0c350ae41acc0653a236a76d981773021 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:56:05 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=0d77f6c0c350ae41acc0653a236a76d981773021 commit 0d77f6c0c350ae41acc0653a236a76d981773021 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:55:55 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:55:55 +0000 linux(4): Add LINUX_RATELIMIT_MSG macro for future use. Differential Revision: https://reviews.freebsd.org/D31488 MFC after: 2 weeks --- sys/compat/linux/linux_util.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h index 26ec8a3d4847..994efa88100f 100644 --- a/sys/compat/linux/linux_util.h +++ b/sys/compat/linux/linux_util.h @@ -165,6 +165,18 @@ void linux_free_get_char_devices(char *string); } \ } while (0) +#define LINUX_RATELIMIT_MSG(_message) \ + do { \ + static int seen = 0; \ + \ + if (seen == 0) { \ + linux_msg(curthread, _message); \ + \ + if (linux_debug < 3) \ + seen = 1; \ + } \ + } while (0) + #define LINUX_RATELIMIT_MSG_OPT1(_message, _opt1) \ do { \ static int seen = 0; \ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:57:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B31C667F07; Thu, 12 Aug 2021 08:57: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 4GlgYg0Gt2z4THN; Thu, 12 Aug 2021 08:57: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 E6FD01FEF3; Thu, 12 Aug 2021 08:57: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 17C8vQCu064293; Thu, 12 Aug 2021 08:57:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8vQcY064292; Thu, 12 Aug 2021 08:57:26 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:57:26 GMT Message-Id: <202108120857.17C8vQcY064292@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 4385147547d9 - main - linux(4): Return ENOSYS for unsupported clone3 option bits. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4385147547d9f2f8b93f08012c0a18aa6d895403 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:57:27 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=4385147547d9f2f8b93f08012c0a18aa6d895403 commit 4385147547d9f2f8b93f08012c0a18aa6d895403 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:56:36 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:56:36 +0000 linux(4): Return ENOSYS for unsupported clone3 option bits. Differential Revision: https://reviews.freebsd.org/D31483 MFC after: 2 weeks --- sys/compat/linux/linux_fork.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index 77dd8446c588..ba169ff98923 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -411,6 +412,20 @@ linux_clone3_args_valid(struct l_user_clone_args *uca) if (uca->stack != 0 && uca->stack_size == 0) return (EINVAL); + /* Verify that no unsupported flags are passed along. */ + if ((uca->flags & LINUX_CLONE_NEWTIME) != 0) { + LINUX_RATELIMIT_MSG("unsupported clone3 option CLONE_NEWTIME"); + return (ENOSYS); + } + if ((uca->flags & LINUX_CLONE_INTO_CGROUP) != 0) { + LINUX_RATELIMIT_MSG("unsupported clone3 option CLONE_INTO_CGROUP"); + return (ENOSYS); + } + if (uca->set_tid != 0 || uca->set_tid_size != 0) { + LINUX_RATELIMIT_MSG("unsupported clone3 set_tid"); + return (ENOSYS); + } + return (0); } From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:57:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 46A48667F0F; Thu, 12 Aug 2021 08:57: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 4GlgYh1M8Xz4TFG; Thu, 12 Aug 2021 08:57: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 1725B20194; Thu, 12 Aug 2021 08:57: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 17C8vRTT064318; Thu, 12 Aug 2021 08:57:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8vRMU064317; Thu, 12 Aug 2021 08:57:27 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:57:27 GMT Message-Id: <202108120857.17C8vRMU064317@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: c2cc5345b88e - main - linux(4): Verify that higher 32bits of exit_signal in clone3 are unset. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c2cc5345b88e98efb85ebc7318b8f92a8455345e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:57:28 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c2cc5345b88e98efb85ebc7318b8f92a8455345e commit c2cc5345b88e98efb85ebc7318b8f92a8455345e Author: Dmitry Chagin AuthorDate: 2021-08-12 08:56:51 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:56:51 +0000 linux(4): Verify that higher 32bits of exit_signal in clone3 are unset. MFC after: 2 weeks --- sys/compat/linux/linux_fork.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index ba169ff98923..72e753db60d4 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -412,6 +412,10 @@ linux_clone3_args_valid(struct l_user_clone_args *uca) if (uca->stack != 0 && uca->stack_size == 0) return (EINVAL); + /* Verify that higher 32bits of exit_signal are unset. */ + if ((uca->exit_signal & ~(uint64_t)LINUX_CSIGNAL) != 0) + return (EINVAL); + /* Verify that no unsupported flags are passed along. */ if ((uca->flags & LINUX_CLONE_NEWTIME) != 0) { LINUX_RATELIMIT_MSG("unsupported clone3 option CLONE_NEWTIME"); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:57:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 88E81667C43; Thu, 12 Aug 2021 08:57: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 4GlgYj2d5rz4THT; Thu, 12 Aug 2021 08:57: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 3952720213; Thu, 12 Aug 2021 08:57: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 17C8vTQs064347; Thu, 12 Aug 2021 08:57:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8vTZe064345; Thu, 12 Aug 2021 08:57:29 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:57:29 GMT Message-Id: <202108120857.17C8vTZe064345@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 1af0780b5f20 - main - linux(4): Move ff variable initialization from declaration. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1af0780b5f20aaa2603bba221ff78ca22dd44bd2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:57:29 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=1af0780b5f20aaa2603bba221ff78ca22dd44bd2 commit 1af0780b5f20aaa2603bba221ff78ca22dd44bd2 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:57:16 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:57:16 +0000 linux(4): Move ff variable initialization from declaration. Modern style(9) allows variables initialization where they are declared, but in this case initialization obfuscate the code. MFC after: 2 weeks --- sys/compat/linux/linux_fork.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index 72e753db60d4..f722e3c08482 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -134,13 +134,14 @@ static int linux_clone_proc(struct thread *td, struct l_clone_args *args) { struct fork_req fr; - int error, ff = RFPROC | RFSTOPPED, f2; + int error, ff, f2; struct proc *p2; struct thread *td2; int exit_signal; struct linux_emuldata *em; f2 = 0; + ff = RFPROC | RFSTOPPED; if (LINUX_SIG_VALID(args->exit_signal)) { exit_signal = linux_to_bsd_signal(args->exit_signal); } else if (args->exit_signal != 0) From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:58:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8A52566805A; Thu, 12 Aug 2021 08:58:40 +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 4Glgb43TdRz4TT1; Thu, 12 Aug 2021 08:58: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 5FBA9200FD; Thu, 12 Aug 2021 08:58: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 17C8wewQ064860; Thu, 12 Aug 2021 08:58:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8wedh064859; Thu, 12 Aug 2021 08:58:40 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:58:40 GMT Message-Id: <202108120858.17C8wedh064859@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 71854d9b2b09 - main - fork: Remove the unnecessary spaces. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71854d9b2b0953b624ffcb268f41b84c9370981b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:58:40 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=71854d9b2b0953b624ffcb268f41b84c9370981b commit 71854d9b2b0953b624ffcb268f41b84c9370981b Author: Dmitry Chagin AuthorDate: 2021-08-12 08:58:17 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:58:17 +0000 fork: Remove the unnecessary spaces. MFC after: 2 weeks --- sys/kern/kern_fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 7b8a95333868..1135f91e0510 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -745,7 +745,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * if ((p1->p_ptevents & PTRACE_FORK) != 0) { sx_xlock(&proctree_lock); PROC_LOCK(p2); - + /* * p1->p_ptevents & p1->p_pptr are protected by both * process and proctree locks for modifications, From owner-dev-commits-src-all@freebsd.org Thu Aug 12 08:58:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 06FF5667EF6; Thu, 12 Aug 2021 08:58:42 +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 4Glgb55WVJz4TM2; Thu, 12 Aug 2021 08:58: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 8A75F1FADB; Thu, 12 Aug 2021 08:58: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 17C8wfkx064884; Thu, 12 Aug 2021 08:58:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C8wfGg064883; Thu, 12 Aug 2021 08:58:41 GMT (envelope-from git) Date: Thu, 12 Aug 2021 08:58:41 GMT Message-Id: <202108120858.17C8wfGg064883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: bed2ac27a14d - main - linux(4): Remove the unnecessary spaces. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bed2ac27a14d39df713f004ea46cbe77fa853f86 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 08:58:42 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=bed2ac27a14d39df713f004ea46cbe77fa853f86 commit bed2ac27a14d39df713f004ea46cbe77fa853f86 Author: Dmitry Chagin AuthorDate: 2021-08-12 08:58:33 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 08:58:33 +0000 linux(4): Remove the unnecessary spaces. MFC after: 2 weeks --- sys/amd64/linux/linux_sysvec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 78739ae6d25c..6f3f78639588 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -236,7 +236,7 @@ linux_set_syscall_retval(struct thread *td, int error) switch (error) { case 0: frame->tf_rax = td->td_retval[0]; - frame->tf_r10 = frame->tf_rcx; + frame->tf_r10 = frame->tf_rcx; break; case ERESTART: @@ -249,7 +249,7 @@ linux_set_syscall_retval(struct thread *td, int error) frame->tf_rip -= frame->tf_err; frame->tf_r10 = frame->tf_rcx; break; - + case EJUSTRETURN: break; From owner-dev-commits-src-all@freebsd.org Thu Aug 12 09:28:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0DA7B668653; Thu, 12 Aug 2021 09:28:51 +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 4GlhFt6ycpz4WBV; Thu, 12 Aug 2021 09:28: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 D799E20469; Thu, 12 Aug 2021 09:28: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 17C9SoaW005331; Thu, 12 Aug 2021 09:28:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C9SoTL005330; Thu, 12 Aug 2021 09:28:50 GMT (envelope-from git) Date: Thu, 12 Aug 2021 09:28:50 GMT Message-Id: <202108120928.17C9SoTL005330@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: 5d5a6216645a - main - loader: cstyle cleanup of userboot/devicename.c 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/main X-Git-Reftype: branch X-Git-Commit: 5d5a6216645a6aefa8665c79bb761b754d74c067 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 09:28:51 -0000 The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=5d5a6216645a6aefa8665c79bb761b754d74c067 commit 5d5a6216645a6aefa8665c79bb761b754d74c067 Author: Toomas Soome AuthorDate: 2021-08-11 07:07:28 +0000 Commit: Toomas Soome CommitDate: 2021-08-11 07:13:46 +0000 loader: cstyle cleanup of userboot/devicename.c No functional changes intended. MFC after: 1 week --- stand/userboot/userboot/devicename.c | 260 ++++++++++++++++++----------------- 1 file changed, 132 insertions(+), 128 deletions(-) diff --git a/stand/userboot/userboot/devicename.c b/stand/userboot/userboot/devicename.c index 5c50b84384d2..8819af5ef127 100644 --- a/stand/userboot/userboot/devicename.c +++ b/stand/userboot/userboot/devicename.c @@ -38,9 +38,10 @@ __FBSDID("$FreeBSD$"); #include "libzfs.h" #endif -static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **path); +static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec, + const char **path); -/* +/* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, * use that. If not, use the default device. @@ -48,27 +49,27 @@ static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec, con int userboot_getdev(void **vdev, const char *devspec, const char **path) { - struct disk_devdesc **dev = (struct disk_devdesc **)vdev; - int rv; - - /* - * If it looks like this is just a path and no - * device, go with the current device. - */ - if ((devspec == NULL) || - (devspec[0] == '/') || - (strchr(devspec, ':') == NULL)) { - - if (((rv = userboot_parsedev(dev, getenv("currdev"), NULL)) == 0) && - (path != NULL)) - *path = devspec; - return(rv); - } - - /* - * Try to parse the device name off the beginning of the devspec - */ - return(userboot_parsedev(dev, devspec, path)); + struct disk_devdesc **dev = (struct disk_devdesc **)vdev; + int rv; + + /* + * If it looks like this is just a path and no + * device, go with the current device. + */ + if ((devspec == NULL) || + (devspec[0] == '/') || + (strchr(devspec, ':') == NULL)) { + + rv = userboot_parsedev(dev, getenv("currdev"), NULL); + if (rv == 0 && path != NULL) + *path = devspec; + return (rv); + } + + /* + * Try to parse the device name off the beginning of the devspec + */ + return (userboot_parsedev(dev, devspec, path)); } /* @@ -83,126 +84,129 @@ userboot_getdev(void **vdev, const char *devspec, const char **path) * For disk-type devices, the syntax is: * * disk[s][]: - * + * */ static int -userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **path) +userboot_parsedev(struct disk_devdesc **dev, const char *devspec, + const char **path) { - struct disk_devdesc *idev; - struct devsw *dv; - int i, unit, err; - const char *cp; - const char *np; - - /* minimum length check */ - if (strlen(devspec) < 2) - return(EINVAL); - - /* look for a device that matches */ - for (i = 0, dv = NULL; devsw[i] != NULL; i++) { - if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) { - dv = devsw[i]; - break; - } - } - if (dv == NULL) - return(ENOENT); - idev = malloc(sizeof(struct disk_devdesc)); - err = 0; - np = (devspec + strlen(dv->dv_name)); - - switch(dv->dv_type) { - case DEVT_NONE: /* XXX what to do here? Do we care? */ - break; - - case DEVT_DISK: - err = disk_parsedev(idev, np, path); - if (err != 0) - goto fail; - break; - - case DEVT_CD: - case DEVT_NET: - unit = 0; - - if (*np && (*np != ':')) { - unit = strtol(np, (char **)&cp, 0); /* get unit number if present */ - if (cp == np) { - err = EUNIT; - goto fail; - } - } else { - cp = np; - } - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; + struct disk_devdesc *idev; + struct devsw *dv; + int i, unit, err; + const char *cp; + const char *np; + + /* minimum length check */ + if (strlen(devspec) < 2) + return (EINVAL); + + /* look for a device that matches */ + for (i = 0, dv = NULL; devsw[i] != NULL; i++) { + if (strncmp(devspec, devsw[i]->dv_name, + strlen(devsw[i]->dv_name)) == 0) { + dv = devsw[i]; + break; + } } - - idev->dd.d_unit = unit; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - - case DEVT_ZFS: + if (dv == NULL) + return (ENOENT); + idev = malloc(sizeof(struct disk_devdesc)); + err = 0; + np = (devspec + strlen(dv->dv_name)); + + switch (dv->dv_type) { + case DEVT_NONE: /* XXX what to do here? Do we care? */ + break; + + case DEVT_DISK: + err = disk_parsedev(idev, np, path); + if (err != 0) + goto fail; + break; + + case DEVT_CD: + case DEVT_NET: + unit = 0; + + if (*np && (*np != ':')) { + /* get unit number if present */ + unit = strtol(np, (char **)&cp, 0); + if (cp == np) { + err = EUNIT; + goto fail; + } + } else { + cp = np; + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; + } + + idev->dd.d_unit = unit; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + case DEVT_ZFS: #if defined(USERBOOT_ZFS_SUPPORT) - err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); - if (err != 0) - goto fail; - break; + err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); + if (err != 0) + goto fail; + break; #else - /* FALLTHROUGH */ + /* FALLTHROUGH */ #endif - default: - err = EINVAL; - goto fail; - } - idev->dd.d_dev = dv; - if (dev == NULL) { + default: + err = EINVAL; + goto fail; + } + idev->dd.d_dev = dv; + if (dev == NULL) { + free(idev); + } else { + *dev = idev; + } + return (0); + +fail: free(idev); - } else { - *dev = idev; - } - return(0); - - fail: - free(idev); - return(err); + return (err); } char * userboot_fmtdev(void *vdev) { - struct devdesc *dev = (struct devdesc *)vdev; - static char buf[128]; /* XXX device length constant? */ + struct devdesc *dev = (struct devdesc *)vdev; + static char buf[128]; /* XXX device length constant? */ - switch(dev->d_dev->dv_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; + switch(dev->d_dev->dv_type) { + case DEVT_NONE: + strcpy(buf, "(no device)"); + break; - case DEVT_CD: - sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); - break; + case DEVT_CD: + sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); + break; - case DEVT_DISK: - return (disk_fmtdev(vdev)); + case DEVT_DISK: + return (disk_fmtdev(vdev)); - case DEVT_NET: - sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); - break; + case DEVT_NET: + sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); + break; - case DEVT_ZFS: + case DEVT_ZFS: #if defined(USERBOOT_ZFS_SUPPORT) - return (zfs_fmtdev(vdev)); + return (zfs_fmtdev(vdev)); #else - sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); + sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); #endif - break; - } - return(buf); + break; + } + return (buf); } @@ -212,12 +216,12 @@ userboot_fmtdev(void *vdev) int userboot_setcurrdev(struct env_var *ev, int flags, const void *value) { - struct disk_devdesc *ncurr; - int rv; - - if ((rv = userboot_parsedev(&ncurr, value, NULL)) != 0) - return(rv); - free(ncurr); - env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); - return(0); + struct disk_devdesc *ncurr; + int rv; + + if ((rv = userboot_parsedev(&ncurr, value, NULL)) != 0) + return (rv); + free(ncurr); + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + return (0); } From owner-dev-commits-src-all@freebsd.org Thu Aug 12 09:36:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8763668854; Thu, 12 Aug 2021 09:36: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 4GlhQS4qqSz4XG9; Thu, 12 Aug 2021 09:36: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 7FB97208A3; Thu, 12 Aug 2021 09:36: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 17C9aGLm018166; Thu, 12 Aug 2021 09:36:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17C9aGhF018165; Thu, 12 Aug 2021 09:36:16 GMT (envelope-from git) Date: Thu, 12 Aug 2021 09:36:16 GMT Message-Id: <202108120936.17C9aGhF018165@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: c15384f89631 - main - vfs: Add get_write_ioflag helper to calculate ioflag 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/main X-Git-Reftype: branch X-Git-Commit: c15384f8963191a238cb4a33382b4d394f1ac0b4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 09:36:16 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=c15384f8963191a238cb4a33382b4d394f1ac0b4 commit c15384f8963191a238cb4a33382b4d394f1ac0b4 Author: Ka Ho Ng AuthorDate: 2021-08-12 09:35:34 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-12 09:35:34 +0000 vfs: Add get_write_ioflag helper to calculate ioflag Converted vn_write to use this helper. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31513 --- sys/kern/vfs_vnops.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 015a13c1c385..5572c324469b 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -920,6 +920,35 @@ get_advice(struct file *fp, struct uio *uio) return (ret); } +static int +get_write_ioflag(struct file *fp) +{ + int ioflag; + struct mount *mp; + struct vnode *vp; + + ioflag = 0; + vp = fp->f_vnode; + mp = atomic_load_ptr(&vp->v_mount); + + if ((fp->f_flag & O_DIRECT) != 0) + ioflag |= IO_DIRECT; + + if ((fp->f_flag & O_FSYNC) != 0 || + (mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS) != 0)) + ioflag |= IO_SYNC; + + /* + * For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE() + * or VOP_DEALLOCATE() implementations that don't understand IO_DATASYNC + * fall back to full O_SYNC behavior. + */ + if ((fp->f_flag & O_DSYNC) != 0) + ioflag |= IO_SYNC | IO_DATASYNC; + + return (ioflag); +} + int vn_read_from_obj(struct vnode *vp, struct uio *uio) { @@ -1119,25 +1148,12 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, if (vp->v_type == VREG) bwillwrite(); ioflag = IO_UNIT; - if (vp->v_type == VREG && (fp->f_flag & O_APPEND)) + if (vp->v_type == VREG && (fp->f_flag & O_APPEND) != 0) ioflag |= IO_APPEND; - if (fp->f_flag & FNONBLOCK) + if ((fp->f_flag & FNONBLOCK) != 0) ioflag |= IO_NDELAY; - if (fp->f_flag & O_DIRECT) - ioflag |= IO_DIRECT; + ioflag |= get_write_ioflag(fp); - mp = atomic_load_ptr(&vp->v_mount); - if ((fp->f_flag & O_FSYNC) || - (mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS))) - ioflag |= IO_SYNC; - - /* - * For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE() - * implementations that don't understand IO_DATASYNC fall back to full - * O_SYNC behavior. - */ - if (fp->f_flag & O_DSYNC) - ioflag |= IO_SYNC | IO_DATASYNC; mp = NULL; need_finished_write = false; if (vp->v_type != VCHR) { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 10:47:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 349A6669848; Thu, 12 Aug 2021 10:47: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 4Glk070bSfz4cl4; Thu, 12 Aug 2021 10:47: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 ECDFB21893; Thu, 12 Aug 2021 10:47: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 17CAl2CP010902; Thu, 12 Aug 2021 10:47:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CAl2c6010901; Thu, 12 Aug 2021 10:47:02 GMT (envelope-from git) Date: Thu, 12 Aug 2021 10:47:02 GMT Message-Id: <202108121047.17CAl2c6010901@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Li-Wen Hsu Subject: git: 2a9b4076dc5e - main - Merge common parts of i386 and amd64's ieeefp.h into x86/x86_ieeefp.h MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: lwhsu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2a9b4076dc5ea42273ae5ddca84b5396dc1f69fc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 10:47:03 -0000 The branch main has been updated by lwhsu: URL: https://cgit.FreeBSD.org/src/commit/?id=2a9b4076dc5ea42273ae5ddca84b5396dc1f69fc commit 2a9b4076dc5ea42273ae5ddca84b5396dc1f69fc Author: NagaChaitanya Vellanki AuthorDate: 2021-08-12 10:45:22 +0000 Commit: Li-Wen Hsu CommitDate: 2021-08-12 10:45:22 +0000 Merge common parts of i386 and amd64's ieeefp.h into x86/x86_ieeefp.h MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D26292 --- sys/amd64/include/ieeefp.h | 104 ++--------------------------- sys/i386/include/ieeefp.h | 105 +----------------------------- sys/x86/include/x86_ieeefp.h | 152 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 203 deletions(-) diff --git a/sys/amd64/include/ieeefp.h b/sys/amd64/include/ieeefp.h index b2423eb00ed3..96ee7e9040d8 100644 --- a/sys/amd64/include/ieeefp.h +++ b/sys/amd64/include/ieeefp.h @@ -40,61 +40,14 @@ #ifndef _MACHINE_IEEEFP_H_ #define _MACHINE_IEEEFP_H_ -/* - * Deprecated historical FPU control interface - * - * IEEE floating point type, constant and function definitions. - * XXX: {FP,SSE}*FLD and {FP,SSE}*OFF are undocumented pollution. - */ - -#ifndef _SYS_CDEFS_H_ -#error this file needs sys/cdefs.h as a prerequisite -#endif - -/* - * Rounding modes. - */ -typedef enum { - FP_RN=0, /* round to nearest */ - FP_RM, /* round down towards minus infinity */ - FP_RP, /* round up towards plus infinity */ - FP_RZ /* truncate */ -} fp_rnd_t; +/* Deprecated historical FPU control interface */ -/* - * Precision (i.e., rounding precision) modes. - */ -typedef enum { - FP_PS=0, /* 24 bit (single-precision) */ - FP_PRS, /* reserved */ - FP_PD, /* 53 bit (double-precision) */ - FP_PE /* 64 bit (extended-precision) */ -} fp_prec_t; - -#define fp_except_t int - -/* - * Exception bit masks. - */ -#define FP_X_INV 0x01 /* invalid operation */ -#define FP_X_DNML 0x02 /* denormal */ -#define FP_X_DZ 0x04 /* zero divide */ -#define FP_X_OFL 0x08 /* overflow */ -#define FP_X_UFL 0x10 /* underflow */ -#define FP_X_IMP 0x20 /* (im)precision */ -#define FP_X_STK 0x40 /* stack fault */ - -/* - * FPU control word bit-field masks. - */ -#define FP_MSKS_FLD 0x3f /* exception masks field */ -#define FP_PRC_FLD 0x300 /* precision control field */ -#define FP_RND_FLD 0xc00 /* rounding control field */ +#include /* - * FPU status word bit-field masks. + * IEEE floating point type, constant and function definitions. + * XXX: {FP,SSE}*FLD and {FP,SSE}*OFF are undocumented pollution. */ -#define FP_STKY_FLD 0x3f /* sticky flags field */ /* * SSE mxcsr register bit-field masks. @@ -105,18 +58,6 @@ typedef enum { #define SSE_RND_FLD 0x6000 /* rounding control */ #define SSE_FZ_FLD 0x8000 /* flush to zero on underflow */ -/* - * FPU control word bit-field offsets (shift counts). - */ -#define FP_MSKS_OFF 0 /* exception masks offset */ -#define FP_PRC_OFF 8 /* precision control offset */ -#define FP_RND_OFF 10 /* rounding control offset */ - -/* - * FPU status word bit-field offsets (shift counts). - */ -#define FP_STKY_OFF 0 /* sticky flags offset */ - /* * SSE mxcsr register bit-field offsets (shift counts). */ @@ -128,43 +69,6 @@ typedef enum { #ifdef __GNUCLIKE_ASM -#define __fldcw(addr) __asm __volatile("fldcw %0" : : "m" (*(addr))) -#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr))) -#define __fnclex() __asm __volatile("fnclex") -#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr))) -#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr))) -#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr))) -#define __ldmxcsr(addr) __asm __volatile("ldmxcsr %0" : : "m" (*(addr))) -#define __stmxcsr(addr) __asm __volatile("stmxcsr %0" : "=m" (*(addr))) - -/* - * Load the control word. Be careful not to trap if there is a currently - * unmasked exception (ones that will become freshly unmasked are not a - * problem). This case must be handled by a save/restore of the - * environment or even of the full x87 state. Accessing the environment - * is very inefficient, so only do it when necessary. - */ -static __inline void -__fnldcw(unsigned short _cw, unsigned short _newcw) -{ - struct { - unsigned _cw; - unsigned _other[6]; - } _env; - unsigned short _sw; - - if ((_cw & FP_MSKS_FLD) != FP_MSKS_FLD) { - __fnstsw(&_sw); - if (((_sw & ~_cw) & FP_STKY_FLD) != 0) { - __fnstenv(&_env); - _env._cw = _newcw; - __fldenv(&_env); - return; - } - } - __fldcw(&_newcw); -} - /* * General notes about conflicting SSE vs FP status bits. * This code assumes that software will not fiddle with the control diff --git a/sys/i386/include/ieeefp.h b/sys/i386/include/ieeefp.h index 0ab8fe9259dd..1d92014e9209 100644 --- a/sys/i386/include/ieeefp.h +++ b/sys/i386/include/ieeefp.h @@ -40,113 +40,12 @@ #ifndef _MACHINE_IEEEFP_H_ #define _MACHINE_IEEEFP_H_ -/* - * Deprecated historical FPU control interface - * - * IEEE floating point type, constant and function definitions. - * XXX: FP*FLD and FP*OFF are undocumented pollution. - */ - -#ifndef _SYS_CDEFS_H_ -#error this file needs sys/cdefs.h as a prerequisite -#endif - -/* - * Rounding modes. - */ -typedef enum { - FP_RN=0, /* round to nearest */ - FP_RM, /* round down towards minus infinity */ - FP_RP, /* round up towards plus infinity */ - FP_RZ /* truncate */ -} fp_rnd_t; - -/* - * Precision (i.e., rounding precision) modes. - */ -typedef enum { - FP_PS=0, /* 24 bit (single-precision) */ - FP_PRS, /* reserved */ - FP_PD, /* 53 bit (double-precision) */ - FP_PE /* 64 bit (extended-precision) */ -} fp_prec_t; +/* Deprecated historical FPU control interface */ -#define fp_except_t int - -/* - * Exception bit masks. - */ -#define FP_X_INV 0x01 /* invalid operation */ -#define FP_X_DNML 0x02 /* denormal */ -#define FP_X_DZ 0x04 /* zero divide */ -#define FP_X_OFL 0x08 /* overflow */ -#define FP_X_UFL 0x10 /* underflow */ -#define FP_X_IMP 0x20 /* (im)precision */ -#define FP_X_STK 0x40 /* stack fault */ - -/* - * FPU control word bit-field masks. - */ -#define FP_MSKS_FLD 0x3f /* exception masks field */ -#define FP_PRC_FLD 0x300 /* precision control field */ -#define FP_RND_FLD 0xc00 /* rounding control field */ - -/* - * FPU status word bit-field masks. - */ -#define FP_STKY_FLD 0x3f /* sticky flags field */ - -/* - * FPU control word bit-field offsets (shift counts). - */ -#define FP_MSKS_OFF 0 /* exception masks offset */ -#define FP_PRC_OFF 8 /* precision control offset */ -#define FP_RND_OFF 10 /* rounding control offset */ - -/* - * FPU status word bit-field offsets (shift counts). - */ -#define FP_STKY_OFF 0 /* sticky flags offset */ +#include #ifdef __GNUCLIKE_ASM -#define __fldcw(addr) __asm __volatile("fldcw %0" : : "m" (*(addr))) -#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr))) -#define __fnclex() __asm __volatile("fnclex") -#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr))) -#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr))) -#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr))) -#define __ldmxcsr(addr) __asm __volatile("ldmxcsr %0" : : "m" (*(addr))) -#define __stmxcsr(addr) __asm __volatile("stmxcsr %0" : "=m" (*(addr))) - -/* - * Load the control word. Be careful not to trap if there is a currently - * unmasked exception (ones that will become freshly unmasked are not a - * problem). This case must be handled by a save/restore of the - * environment or even of the full x87 state. Accessing the environment - * is very inefficient, so only do it when necessary. - */ -static __inline void -__fnldcw(unsigned short _cw, unsigned short _newcw) -{ - struct { - unsigned _cw; - unsigned _other[6]; - } _env; - unsigned short _sw; - - if ((_cw & FP_MSKS_FLD) != FP_MSKS_FLD) { - __fnstsw(&_sw); - if (((_sw & ~_cw) & FP_STKY_FLD) != 0) { - __fnstenv(&_env); - _env._cw = _newcw; - __fldenv(&_env); - return; - } - } - __fldcw(&_newcw); -} - static __inline fp_rnd_t fpgetround(void) { diff --git a/sys/x86/include/x86_ieeefp.h b/sys/x86/include/x86_ieeefp.h new file mode 100644 index 000000000000..6412a7dfac1d --- /dev/null +++ b/sys/x86/include/x86_ieeefp.h @@ -0,0 +1,152 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 2003 Peter Wemm. + * Copyright (c) 1990 Andrew Moore, Talke Studio + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93 + * $FreeBSD$ + */ + +#ifndef _X86_X86_IEEEFP_H_ +#define _X86_X86_IEEEFP_H_ + +/* Deprecated historical FPU control interface */ + +/* + * IEEE floating point type, constant and function definitions. + * XXX: {FP,SSE}*FLD and {FP,SSE}*OFF are undocumented pollution. + */ + +#ifndef _SYS_CDEFS_H_ +#error this file needs sys/cdefs.h as a prerequisite +#endif + +/* + * Rounding modes. + */ +typedef enum { + FP_RN=0, /* round to nearest */ + FP_RM, /* round down towards minus infinity */ + FP_RP, /* round up towards plus infinity */ + FP_RZ /* truncate */ +} fp_rnd_t; + +/* + * Precision (i.e., rounding precision) modes. + */ +typedef enum { + FP_PS=0, /* 24 bit (single-precision) */ + FP_PRS, /* reserved */ + FP_PD, /* 53 bit (double-precision) */ + FP_PE /* 64 bit (extended-precision) */ +} fp_prec_t; + +#define fp_except_t int + +/* + * Exception bit masks. + */ +#define FP_X_INV 0x01 /* invalid operation */ +#define FP_X_DNML 0x02 /* denormal */ +#define FP_X_DZ 0x04 /* zero divide */ +#define FP_X_OFL 0x08 /* overflow */ +#define FP_X_UFL 0x10 /* underflow */ +#define FP_X_IMP 0x20 /* (im)precision */ +#define FP_X_STK 0x40 /* stack fault */ + +/* + * FPU control word bit-field masks. + */ +#define FP_MSKS_FLD 0x3f /* exception masks field */ +#define FP_PRC_FLD 0x300 /* precision control field */ +#define FP_RND_FLD 0xc00 /* rounding control field */ + +/* + * FPU status word bit-field masks. + */ +#define FP_STKY_FLD 0x3f /* sticky flags field */ + +/* + * FPU control word bit-field offsets (shift counts). + */ +#define FP_MSKS_OFF 0 /* exception masks offset */ +#define FP_PRC_OFF 8 /* precision control offset */ +#define FP_RND_OFF 10 /* rounding control offset */ + +/* + * FPU status word bit-field offsets (shift counts). + */ +#define FP_STKY_OFF 0 /* sticky flags offset */ + +#ifdef __GNUCLIKE_ASM + +#define __fldcw(addr) __asm __volatile("fldcw %0" : : "m" (*(addr))) +#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr))) +#define __fnclex() __asm __volatile("fnclex") +#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr))) +#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr))) +#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr))) +#define __ldmxcsr(addr) __asm __volatile("ldmxcsr %0" : : "m" (*(addr))) +#define __stmxcsr(addr) __asm __volatile("stmxcsr %0" : "=m" (*(addr))) + +/* + * Load the control word. Be careful not to trap if there is a currently + * unmasked exception (ones that will become freshly unmasked are not a + * problem). This case must be handled by a save/restore of the + * environment or even of the full x87 state. Accessing the environment + * is very inefficient, so only do it when necessary. + */ +static __inline void +__fnldcw(unsigned short _cw, unsigned short _newcw) +{ + struct { + unsigned _cw; + unsigned _other[6]; + } _env; + unsigned short _sw; + + if ((_cw & FP_MSKS_FLD) != FP_MSKS_FLD) { + __fnstsw(&_sw); + if (((_sw & ~_cw) & FP_STKY_FLD) != 0) { + __fnstenv(&_env); + _env._cw = _newcw; + __fldenv(&_env); + return; + } + } + __fldcw(&_newcw); +} + +#endif /* __GNUCLIKE_ASM */ + +#endif/* _X86_X86_IEEEFP_H_ */ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:26:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EAFE566AD9D; Thu, 12 Aug 2021 12:26: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 4GlmBS5ZMVz4hWd; Thu, 12 Aug 2021 12:26: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 A305E22CA1; Thu, 12 Aug 2021 12:26: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 17CCQ8IF044114; Thu, 12 Aug 2021 12:26:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCQ8Cd044113; Thu, 12 Aug 2021 12:26:08 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:26:08 GMT Message-Id: <202108121226.17CCQ8Cd044113@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: b844fc25c844 - stable/13 - nanobsd: Correct a typo in a comment 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: b844fc25c844cac3e86a26e81426a357f0f9a42c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:26:09 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=b844fc25c844cac3e86a26e81426a357f0f9a42c commit b844fc25c844cac3e86a26e81426a357f0f9a42c Author: Gordon Bergling AuthorDate: 2021-08-09 11:45:10 +0000 Commit: Gordon Bergling CommitDate: 2021-08-12 12:25:50 +0000 nanobsd: Correct a typo in a comment - s/partion/partition/ (cherry picked from commit 8b9f6d62f75a367459997e5bb27d86d0302aedd2) --- tools/tools/nanobsd/embedded/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common index 7186aa5ba4b5..f3be05ae857a 100644 --- a/tools/tools/nanobsd/embedded/common +++ b/tools/tools/nanobsd/embedded/common @@ -574,7 +574,7 @@ eval std_${NANO_ARCH} # Slice 4: FreeBSD partition (empty) # on first boot, we resize slice 3 & 4 to be 1/2 of what's # left over on the SD card after slice 1 and 2 are taken -# off the top. We also resize the 'a' partion on first boot +# off the top. We also resize the 'a' partition on first boot # to the size of the partition for the ping/pong upgrade. # This feature needs support in the rc.d bootup script. # From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:28:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9299366B113; Thu, 12 Aug 2021 12:28: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 4GlmF23VGHz4hqr; Thu, 12 Aug 2021 12:28: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 60D4B22968; Thu, 12 Aug 2021 12:28: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 17CCSM0j044483; Thu, 12 Aug 2021 12:28:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCSMn9044482; Thu, 12 Aug 2021 12:28:22 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:28:22 GMT Message-Id: <202108121228.17CCSMn9044482@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: 844e8b71f2fe - stable/12 - nanobsd: Correct a typo in a comment 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/12 X-Git-Reftype: branch X-Git-Commit: 844e8b71f2fe96d98d1aae7c1d63a0c7c431749e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:28:22 -0000 The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=844e8b71f2fe96d98d1aae7c1d63a0c7c431749e commit 844e8b71f2fe96d98d1aae7c1d63a0c7c431749e Author: Gordon Bergling AuthorDate: 2021-08-09 11:45:10 +0000 Commit: Gordon Bergling CommitDate: 2021-08-12 12:28:06 +0000 nanobsd: Correct a typo in a comment - s/partion/partition/ (cherry picked from commit 8b9f6d62f75a367459997e5bb27d86d0302aedd2) --- tools/tools/nanobsd/embedded/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common index 47a13f4cd43e..a944ba0b5119 100644 --- a/tools/tools/nanobsd/embedded/common +++ b/tools/tools/nanobsd/embedded/common @@ -588,7 +588,7 @@ eval std_${NANO_ARCH} # Slice 4: FreeBSD partition (empty) # on first boot, we resize slice 3 & 4 to be 1/2 of what's # left over on the SD card after slice 1 and 2 are taken -# off the top. We also resize the 'a' partion on first boot +# off the top. We also resize the 'a' partition on first boot # to the size of the partition for the ping/pong upgrade. # This feature needs support in the rc.d bootup script. # From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9777066B13B; Thu, 12 Aug 2021 12:39: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 4GlmTm3cZqz4jCW; Thu, 12 Aug 2021 12:39: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 6044422D2A; Thu, 12 Aug 2021 12:39: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 17CCdO1c058888; Thu, 12 Aug 2021 12:39:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdOo1058887; Thu, 12 Aug 2021 12:39:24 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:24 GMT Message-Id: <202108121239.17CCdOo1058887@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: a9c0baa1d063 - stable/13 - fork.2: Add a simple use pattern 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: a9c0baa1d063b219e9ff71076bfb05231e58acf4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:24 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a9c0baa1d063b219e9ff71076bfb05231e58acf4 commit a9c0baa1d063b219e9ff71076bfb05231e58acf4 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-04-17 21:10:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 fork.2: Add a simple use pattern (cherry picked from commit c4207d867c201a726aa3157e09262f72166c89c4) --- lib/libc/sys/fork.2 | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index 3e55530827c5..d43ade6a483e 100644 --- a/lib/libc/sys/fork.2 +++ b/lib/libc/sys/fork.2 @@ -28,7 +28,7 @@ .\" @(#)fork.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd December 1, 2017 +.Dd April 17, 2021 .Dt FORK 2 .Os .Sh NAME @@ -99,6 +99,42 @@ to the parent process, no child process is created, and the global variable .Va errno is set to indicate the error. +.Sh EXAMPLES +The following example shows a common pattern of how +.Fn fork +is used in practice. +.Bd -literal -offset indent +#include +#include +#include +#include + +int +main(void) +{ + pid_t pid; + + switch (pid = fork()) { + case -1: + err(1, "Failed to fork"); + case 0: + printf("Hello from child process!\en"); + exit(0); + default: + break; + } + + printf("Hello from parent process (child's PID: %d)!\en", pid); + + return (0); +} +.Ed +.Pp +The output of such a program is along the lines of: +.Bd -literal -offset indent +Hello from parent (child's PID: 27804)! +Hello from child process! +.Ed .Sh ERRORS The .Fn fork From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5DF666AC64; Thu, 12 Aug 2021 12:39: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 4GlmTn41CMz4j5j; Thu, 12 Aug 2021 12:39: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 6FD7A22CC0; Thu, 12 Aug 2021 12:39: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 17CCdPbH058914; Thu, 12 Aug 2021 12:39:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdPUD058913; Thu, 12 Aug 2021 12:39:25 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:25 GMT Message-Id: <202108121239.17CCdPUD058913@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: 3248a03c1a13 - stable/13 - fork.2: Fix a typo in an example 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: 3248a03c1a135bf8633d34be19902b54583a331f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:25 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3248a03c1a135bf8633d34be19902b54583a331f commit 3248a03c1a135bf8633d34be19902b54583a331f Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-04-20 08:24:21 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 fork.2: Fix a typo in an example (cherry picked from commit ca904beafd925719af998a86cd67a9c787f44255) --- lib/libc/sys/fork.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index d43ade6a483e..9ea0a6afb96f 100644 --- a/lib/libc/sys/fork.2 +++ b/lib/libc/sys/fork.2 @@ -28,7 +28,7 @@ .\" @(#)fork.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 17, 2021 +.Dd April 20, 2021 .Dt FORK 2 .Os .Sh NAME @@ -132,7 +132,7 @@ main(void) .Pp The output of such a program is along the lines of: .Bd -literal -offset indent -Hello from parent (child's PID: 27804)! +Hello from parent process (child's PID: 27804)! Hello from child process! .Ed .Sh ERRORS From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CAB0966B300; Thu, 12 Aug 2021 12:39: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 4GlmTp58Kmz4hvs; Thu, 12 Aug 2021 12:39: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 94E4B230F4; Thu, 12 Aug 2021 12:39: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 17CCdQCK058946; Thu, 12 Aug 2021 12:39:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdQtN058945; Thu, 12 Aug 2021 12:39:26 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:26 GMT Message-Id: <202108121239.17CCdQtN058945@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: 8c51479a6e90 - 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: 8c51479a6e903855c4b4073b6827eb7694f824f4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:26 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8c51479a6e903855c4b4073b6827eb7694f824f4 commit 8c51479a6e903855c4b4073b6827eb7694f824f4 Author: Konstantin Belousov AuthorDate: 2021-08-02 21:05:11 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 Style (cherry picked from commit 2d319ebe5c08f3454c4e76564b88fb921f008185) --- lib/libc/include/compat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/include/compat.h b/lib/libc/include/compat.h index 72823366c33a..ccb92c0fd930 100644 --- a/lib/libc/include/compat.h +++ b/lib/libc/include/compat.h @@ -37,7 +37,7 @@ #ifndef __LIBC_COMPAT_H__ #define __LIBC_COMPAT_H__ -#define __sym_compat(sym,impl,verid) \ +#define __sym_compat(sym, impl, verid) \ .symver impl, sym@verid #ifndef NO_COMPAT7 @@ -74,7 +74,7 @@ __sym_compat(kevent, freebsd11_kevent, FBSD_1.0); #define __weak_reference(sym,alias) \ .weak alias;.equ alias,sym -__weak_reference(__sys_fcntl,__fcntl_compat) +__weak_reference(__sys_fcntl, __fcntl_compat) #undef __weak_reference From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DBB9E66AF33; Thu, 12 Aug 2021 12:39: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 4GlmTq5ngLz4jFc; Thu, 12 Aug 2021 12:39: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 AEC4F22F97; Thu, 12 Aug 2021 12:39: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 17CCdRNQ058971; Thu, 12 Aug 2021 12:39:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdRU7058970; Thu, 12 Aug 2021 12:39:27 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:27 GMT Message-Id: <202108121239.17CCdRU7058970@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: 1c54a109d71e - stable/13 - Add _Fork() 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: 1c54a109d71ee768929e96fecbda27e44a173aa7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:28 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1c54a109d71ee768929e96fecbda27e44a173aa7 commit 1c54a109d71ee768929e96fecbda27e44a173aa7 Author: Konstantin Belousov AuthorDate: 2021-08-02 09:50:32 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 Add _Fork() (cherry picked from commit 49ad342cc10cba14b3a40ba26cf8bb2150e2925a) --- include/unistd.h | 1 + lib/libc/sys/Makefile.inc | 1 + lib/libc/sys/Symbol.map | 4 +++ lib/libc/sys/_Fork.c | 45 +++++++++++++++++++++++++++ lib/libc/sys/fork.2 | 78 ++++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 125 insertions(+), 4 deletions(-) diff --git a/include/unistd.h b/include/unistd.h index 9fa9bebbc4c0..5f358ad72d9a 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -586,6 +586,7 @@ int undelete(const char *); int unwhiteout(const char *); void *valloc(size_t); /* obsoleted by malloc() */ int funlinkat(int, const char *, int, int); +pid_t _Fork(void); #ifndef _OPTRESET_DECLARED #define _OPTRESET_DECLARED diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 82d16fb81b6b..d0fd7bda74f5 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -49,6 +49,7 @@ SRCS+= closefrom.c SRCS+= pipe.c SRCS+= shm_open.c SRCS+= vadvise.c +SRCS+= _Fork.c SRCS+= compat-stub.c diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 0044c06fd639..80bb2c236191 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -417,6 +417,10 @@ FBSD_1.6 { shm_rename; }; +FBSD_1.7 { + _Fork; +}; + FBSDprivate_1.0 { ___acl_aclcheck_fd; __sys___acl_aclcheck_fd; diff --git a/lib/libc/sys/_Fork.c b/lib/libc/sys/_Fork.c new file mode 100644 index 000000000000..a7aaf82429bb --- /dev/null +++ b/lib/libc/sys/_Fork.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include "libc_private.h" + +#pragma weak _Fork +pid_t +_Fork(void) +{ + return (__sys_fork()); +} diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index 9ea0a6afb96f..bf934d166b03 100644 --- a/lib/libc/sys/fork.2 +++ b/lib/libc/sys/fork.2 @@ -28,7 +28,7 @@ .\" @(#)fork.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 20, 2021 +.Dd August 2, 2021 .Dt FORK 2 .Os .Sh NAME @@ -40,10 +40,12 @@ .In unistd.h .Ft pid_t .Fn fork void +.Ft pid_t +.Fn _Fork void .Sh DESCRIPTION The .Fn fork -system call causes creation of a new process. +function causes creation of a new process. The new process (child process) is an exact copy of the calling process (parent process) except for the following: .Bl -bullet -offset indent @@ -77,6 +79,15 @@ are set to 0; see All interval timers are cleared; see .Xr setitimer 2 . .It +The robust mutexes list (see +.Xr pthread_mutexattr_setrobust 3 ) +is cleared for the child. +.It +The atfork handlers established with the +.Xr pthread_atfork 3 +function are called as appropriate before fork in the parent process, +and after the child is created, in parent and child. +.It The child process has only one thread, corresponding to the calling thread in the parent process. If the process has more than one thread, @@ -87,11 +98,58 @@ and therefore only async-signal-safe functions are guaranteed to work in the child process until a call to .Xr execve 2 or a similar function. +The +.Fx +implementation of +.Fn fork +provides a usable +.Xr malloc 3 , +and +.Xr rtld 1 +services in the child process. .El +.Pp +The +.Fn fork +function is not async-signal safe and creates a cancellation point +in the parent process. +It cannot be safely used from signal handlers, and the atfork handlers +established by +.Xr pthread_atfork 3 +do not need to be async-signal safe either. +.Pp +The +.Fn _Fork +function creates a new process, similarly to +.Fn fork , +but it is async-signal safe. +.Fn _Fork +does not call atfork handlers, and does not create a cancellation point. +It can be used safely from signal handlers, but then no userspace +services ( +.Xr malloc 3 +or +.Xr rtld 1 ) +are available in the child if forked from multi-threaded parent. +In particular, if using dynamic linking, all dynamic symbols used by the +child after +.Fn _Fork +must be pre-resolved. +Note: resolving can be done globally by specifying the +.Ev LD_BIND_NOW +environment variable to the dynamic linker, or per-binary by passing the +.Fl z Ar now +option to the static linker +.Xr ld 1 , +or by using each symbol before the +.Fn _Fork +call to force the binding. .Sh RETURN VALUES Upon successful completion, .Fn fork -returns a value +and +.Fn _Fork +return a value of 0 to the child process and returns the process ID of the child process to the parent process. Otherwise, a value of -1 is returned @@ -176,9 +234,21 @@ There is insufficient swap space for the new process. .Xr setrlimit 2 , .Xr sigaction 2 , .Xr vfork 2 , -.Xr wait 2 +.Xr wait 2 , +.Xr pthread_atfork 3 .Sh HISTORY The .Fn fork function appeared in .At v1 . +.Pp +The +.Fn _Fork +function was defined by Austin Group together with the removal +of a requirement that the +.Fn fork +implementation must be async-signal safe. +The +.Fn _Fork +function appeared in +.Fx 14.0 . From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A450F66AF39; Thu, 12 Aug 2021 12:39: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 4GlmTt1HwDz4j5x; Thu, 12 Aug 2021 12:39: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 027D622F79; Thu, 12 Aug 2021 12:39: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 17CCdTPg059021; Thu, 12 Aug 2021 12:39:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdTqm059020; Thu, 12 Aug 2021 12:39:29 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:29 GMT Message-Id: <202108121239.17CCdTqm059020@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: 5d7b612949c1 - stable/13 - fork(2): comment about doubtful use of stdio and exit(3) in example 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: 5d7b612949c1c7f8a284d69e6db48a6c65cd16d3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:30 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5d7b612949c1c7f8a284d69e6db48a6c65cd16d3 commit 5d7b612949c1c7f8a284d69e6db48a6c65cd16d3 Author: Konstantin Belousov AuthorDate: 2021-08-05 16:03:03 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 fork(2): comment about doubtful use of stdio and exit(3) in example (cherry picked from commit 2a51e8823a60180feb534176bc41d5d10e2a01b1) --- lib/libc/sys/fork.2 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index d841b0bc38e1..dbde8f5275aa 100644 --- a/lib/libc/sys/fork.2 +++ b/lib/libc/sys/fork.2 @@ -28,7 +28,7 @@ .\" @(#)fork.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd August 2, 2021 +.Dd August 5, 2021 .Dt FORK 2 .Os .Sh NAME @@ -172,11 +172,28 @@ main(void) { pid_t pid; + /* + * If child is expected to use stdio(3), state of + * the reused io streams must be synchronized between + * parent and child, to avoid double output and other + * possible issues. + */ + fflush(stdout); + switch (pid = fork()) { case -1: err(1, "Failed to fork"); case 0: printf("Hello from child process!\en"); + + /* + * Since we wrote into stdout, child needs to use + * exit(3) and not _exit(2). This causes handlers + * registered with atexit(3) to be called twice, + * once in parent, and once in the child. If such + * behavior is undesirable, consider + * terminating child with _exit(2) or _Exit(3). + */ exit(0); default: break; From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 88A2C66B161; Thu, 12 Aug 2021 12:39: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 4GlmTv2DCLz4jCx; Thu, 12 Aug 2021 12:39: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 24EF422F99; Thu, 12 Aug 2021 12:39: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 17CCdV52059047; Thu, 12 Aug 2021 12:39:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdVGN059046; Thu, 12 Aug 2021 12:39:31 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:31 GMT Message-Id: <202108121239.17CCdVGN059046@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: c4bb20a5ec87 - stable/13 - _Exit(3): document implementation 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: c4bb20a5ec876fb44e152c5773b7104e4c753dec Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:31 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c4bb20a5ec876fb44e152c5773b7104e4c753dec commit c4bb20a5ec876fb44e152c5773b7104e4c753dec Author: Konstantin Belousov AuthorDate: 2021-08-05 16:04:44 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 _Exit(3): document implementation (cherry picked from commit ee62fb2e1e14eab35d4e4e92535bcac9fc91eeb8) --- lib/libc/stdlib/exit.3 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3 index 9c2b79b72956..ff7a67ffcb85 100644 --- a/lib/libc/stdlib/exit.3 +++ b/lib/libc/stdlib/exit.3 @@ -32,7 +32,7 @@ .\" @(#)exit.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd March 22, 2020 +.Dd August 5, 2021 .Dt EXIT 3 .Os .Sh NAME @@ -58,17 +58,17 @@ Before termination, performs the following functions in the order listed: .Bl -enum -offset indent .It -Call the functions registered with the +Call all functions registered with the +.Xr __cxa_atexit 3 +function +(which are typically destructors from the loaded dynamic objects), +and the functions registered with the .Xr atexit 3 function, in the reverse order of their registration. .It Flush all open output streams. .It Close all open streams. -.It -Unlink all files created with the -.Xr tmpfile 3 -function. .El .Pp The @@ -76,6 +76,14 @@ The function terminates without calling the functions registered with the .Xr atexit 3 function, and may or may not perform the other actions listed. +The +.Fx +implementation of the +.Fn _Exit +function does not call destructors registered with +.Xr __cxa_atexit 3, +does not flush buffers, and does not close streams. +.Pp Both functions make the low-order eight bits of the .Fa status argument available to a parent process which has called a From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5C5C66AF3B; Thu, 12 Aug 2021 12:39: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 4GlmTw3bTQz4j4C; Thu, 12 Aug 2021 12:39: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 4DE1F22F7A; Thu, 12 Aug 2021 12:39: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 17CCdWR8059074; Thu, 12 Aug 2021 12:39:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdW4W059073; Thu, 12 Aug 2021 12:39:32 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:32 GMT Message-Id: <202108121239.17CCdW4W059073@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: c7b5abde5389 - stable/13 - Add vn_lktype_write() 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: c7b5abde53899c381ed6773b61e1ad940a44792f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:32 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c7b5abde53899c381ed6773b61e1ad940a44792f commit c7b5abde53899c381ed6773b61e1ad940a44792f Author: Konstantin Belousov AuthorDate: 2021-08-04 02:34:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 Add vn_lktype_write() (cherry picked from commit 0ef5eee9d94162ac3cefa0bd8aedf1bfa6f87192) --- sys/cam/ctl/ctl_backend_block.c | 20 +++++--------------- sys/kern/vfs_syscalls.c | 10 ++-------- sys/kern/vfs_vnops.c | 34 ++++++++++++++-------------------- sys/sys/vnode.h | 1 + sys/vm/vm_pageout.c | 6 ++---- 5 files changed, 24 insertions(+), 47 deletions(-) diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index 4ffaf0912915..83ea6b43dac3 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -588,7 +588,7 @@ ctl_be_block_flush_file(struct ctl_be_block_lun *be_lun, { union ctl_io *io = beio->io; struct mount *mountpoint; - int error, lock_flags; + int error; DPRINTF("entered\n"); @@ -597,12 +597,8 @@ ctl_be_block_flush_file(struct ctl_be_block_lun *be_lun, (void) vn_start_write(be_lun->vn, &mountpoint, V_WAIT); - if (MNT_SHARED_WRITES(mountpoint) || - ((mountpoint == NULL) && MNT_SHARED_WRITES(be_lun->vn->v_mount))) - lock_flags = LK_SHARED; - else - lock_flags = LK_EXCLUSIVE; - vn_lock(be_lun->vn, lock_flags | LK_RETRY); + vn_lock(be_lun->vn, vn_lktype_write(mountpoint, be_lun->vn) | + LK_RETRY); error = VOP_FSYNC(be_lun->vn, beio->io_arg ? MNT_NOWAIT : MNT_WAIT, curthread); VOP_UNLOCK(be_lun->vn); @@ -722,16 +718,10 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, } } else { struct mount *mountpoint; - int lock_flags; (void)vn_start_write(be_lun->vn, &mountpoint, V_WAIT); - - if (MNT_SHARED_WRITES(mountpoint) || ((mountpoint == NULL) - && MNT_SHARED_WRITES(be_lun->vn->v_mount))) - lock_flags = LK_SHARED; - else - lock_flags = LK_EXCLUSIVE; - vn_lock(be_lun->vn, lock_flags | LK_RETRY); + vn_lock(be_lun->vn, vn_lktype_write(mountpoint, + be_lun->vn) | LK_RETRY); /* * UFS pays attention to IO_DIRECT for writes. The write diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 7f2f3480a5af..80bcc0cb4d41 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3505,7 +3505,7 @@ kern_fsync(struct thread *td, int fd, bool fullsync) struct vnode *vp; struct mount *mp; struct file *fp; - int error, lock_flags; + int error; AUDIT_ARG_FD(fd); error = getvnode(td, fd, &cap_fsync_rights, &fp); @@ -3520,13 +3520,7 @@ retry: error = vn_start_write(vp, &mp, V_WAIT | PCATCH); if (error != 0) goto drop; - if (MNT_SHARED_WRITES(mp) || - ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { - lock_flags = LK_SHARED; - } else { - lock_flags = LK_EXCLUSIVE; - } - vn_lock(vp, lock_flags | LK_RETRY); + vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY); AUDIT_ARG_VNODE1(vp); if (vp->v_object != NULL) { VM_OBJECT_WLOCK(vp->v_object); diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index fc5118e8aa24..b7e53add5a35 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -653,11 +653,7 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset, (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto out; - if (MNT_SHARED_WRITES(mp) || - ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) - lock_flags = LK_SHARED; - else - lock_flags = LK_EXCLUSIVE; + lock_flags = vn_lktype_write(mp, vp); } else lock_flags = LK_SHARED; vn_lock(vp, lock_flags | LK_RETRY); @@ -1106,7 +1102,7 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct vnode *vp; struct mount *mp; off_t orig_offset; - int error, ioflag, lock_flags; + int error, ioflag; int advice; bool need_finished_write; @@ -1147,14 +1143,7 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, advice = get_advice(fp, uio); - if (MNT_SHARED_WRITES(mp) || - (mp == NULL && MNT_SHARED_WRITES(vp->v_mount))) { - lock_flags = LK_SHARED; - } else { - lock_flags = LK_EXCLUSIVE; - } - - vn_lock(vp, lock_flags | LK_RETRY); + vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY); switch (advice) { case POSIX_FADV_NORMAL: case POSIX_FADV_SEQUENTIAL: @@ -3060,7 +3049,7 @@ vn_write_outvp(struct vnode *outvp, char *dat, off_t outoff, off_t xfer, { struct mount *mp; off_t dataoff, holeoff, xfer2; - int error, lckf; + int error; /* * Loop around doing writes of blksize until write has been completed. @@ -3099,11 +3088,7 @@ vn_write_outvp(struct vnode *outvp, char *dat, off_t outoff, off_t xfer, VOP_UNLOCK(outvp); } } else { - if (MNT_SHARED_WRITES(mp)) - lckf = LK_SHARED; - else - lckf = LK_EXCLUSIVE; - error = vn_lock(outvp, lckf); + error = vn_lock(outvp, vn_lktype_write(mp, outvp)); if (error == 0) { error = vn_rdwr(UIO_WRITE, outvp, dat, xfer2, outoff, UIO_SYSSPACE, IO_NODELOCKED, @@ -3532,3 +3517,12 @@ vn_lock_pair(struct vnode *vp1, bool vp1_locked, struct vnode *vp2, if (vp2 != NULL) ASSERT_VOP_ELOCKED(vp2, "vp2 ret"); } + +int +vn_lktype_write(struct mount *mp, struct vnode *vp) +{ + if (MNT_SHARED_WRITES(mp) || + (mp == NULL && MNT_SHARED_WRITES(vp->v_mount))) + return (LK_SHARED); + return (LK_EXCLUSIVE); +} diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 8b14aac36df0..8336fd859781 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1087,6 +1087,7 @@ int vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, void vn_fsid(struct vnode *vp, struct vattr *va); int vn_dir_check_exec(struct vnode *vp, struct componentname *cnp); +int vn_lktype_write(struct mount *mp, struct vnode *vp); #define VOP_UNLOCK_FLAGS(vp, flags) ({ \ struct vnode *_vp = (vp); \ diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 216e76359631..9a0b295569e2 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -606,7 +606,7 @@ vm_pageout_clean(vm_page_t m, int *numpagedout) struct mount *mp; vm_object_t object; vm_pindex_t pindex; - int error, lockmode; + int error; object = m->object; VM_OBJECT_ASSERT_WLOCKED(object); @@ -640,9 +640,7 @@ vm_pageout_clean(vm_page_t m, int *numpagedout) vm_object_reference_locked(object); pindex = m->pindex; VM_OBJECT_WUNLOCK(object); - lockmode = MNT_SHARED_WRITES(vp->v_mount) ? - LK_SHARED : LK_EXCLUSIVE; - if (vget(vp, lockmode | LK_TIMELOCK)) { + if (vget(vp, vn_lktype_write(NULL, vp) | LK_TIMELOCK) != 0) { vp = NULL; error = EDEADLK; goto unlock_mp; From owner-dev-commits-src-all@freebsd.org Thu Aug 12 12:39:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 274F566B151; Thu, 12 Aug 2021 12:39: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 4GlmTs04hcz4jH0; Thu, 12 Aug 2021 12:39: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 DB58822F98; Thu, 12 Aug 2021 12:39: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 17CCdSTQ058995; Thu, 12 Aug 2021 12:39:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CCdSi4058994; Thu, 12 Aug 2021 12:39:28 GMT (envelope-from git) Date: Thu, 12 Aug 2021 12:39:28 GMT Message-Id: <202108121239.17CCdSi4058994@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: f59374b69a95 - stable/13 - fork.2: correct minor typo in manpage. 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: f59374b69a95452aafc22a9b2881fd6ff23208ee Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:39:29 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f59374b69a95452aafc22a9b2881fd6ff23208ee commit f59374b69a95452aafc22a9b2881fd6ff23208ee Author: Ceri Davies AuthorDate: 2021-08-05 18:36:33 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-12 12:37:54 +0000 fork.2: correct minor typo in manpage. (cherry picked from commit 383dbdb2ebffabf8c0efadd8928f8ef3e45ab9e5) --- lib/libc/sys/fork.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index bf934d166b03..d841b0bc38e1 100644 --- a/lib/libc/sys/fork.2 +++ b/lib/libc/sys/fork.2 @@ -150,7 +150,7 @@ Upon successful completion, and .Fn _Fork return a value -of 0 to the child process and returns the process ID of the child +of 0 to the child process and return the process ID of the child process to the parent process. Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global From owner-dev-commits-src-all@freebsd.org Thu Aug 12 13:07:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AB1E666BF98; Thu, 12 Aug 2021 13:07:39 +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 4Gln6M3sg1z4l3l; Thu, 12 Aug 2021 13:07:39 +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 6C2D723643; Thu, 12 Aug 2021 13:07:39 +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 17CD7dM2099834; Thu, 12 Aug 2021 13:07:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CD7d13099833; Thu, 12 Aug 2021 13:07:39 GMT (envelope-from git) Date: Thu, 12 Aug 2021 13:07:39 GMT Message-Id: <202108121307.17CD7d13099833@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: aecd31a8a3b0 - main - linux(4): Remove clone3 and faccessat2 from dummy. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aecd31a8a3b09af874120bc7b4aa6fa51db98f94 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 13:07:39 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=aecd31a8a3b09af874120bc7b4aa6fa51db98f94 commit aecd31a8a3b09af874120bc7b4aa6fa51db98f94 Author: Dmitry Chagin AuthorDate: 2021-08-12 13:07:21 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-12 13:07:21 +0000 linux(4): Remove clone3 and faccessat2 from dummy. MFC after: 2 weeks --- sys/compat/linux/linux_dummy.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/compat/linux/linux_dummy.c b/sys/compat/linux/linux_dummy.c index fbec69f4ac31..91a56616fc10 100644 --- a/sys/compat/linux/linux_dummy.c +++ b/sys/compat/linux/linux_dummy.c @@ -138,11 +138,9 @@ DUMMY(fsconfig); DUMMY(fsmount); DUMMY(fspick); DUMMY(pidfd_open); -DUMMY(clone3); DUMMY(close_range); DUMMY(openat2); DUMMY(pidfd_getfd); -DUMMY(faccessat2); DUMMY(process_madvise); DUMMY(epoll_pwait2); DUMMY(mount_setattr); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 13:39:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A269066C787; Thu, 12 Aug 2021 13:39: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 4GlnqQ3qjXz4mw6; Thu, 12 Aug 2021 13:39: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 675D123B41; Thu, 12 Aug 2021 13:39: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 17CDdkn0039467; Thu, 12 Aug 2021 13:39:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CDdk78039466; Thu, 12 Aug 2021 13:39:46 GMT (envelope-from git) Date: Thu, 12 Aug 2021 13:39:46 GMT Message-Id: <202108121339.17CDdk78039466@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 4b4850aefe3f - main - hms(4): Fix a typo in sysctl description 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/main X-Git-Reftype: branch X-Git-Commit: 4b4850aefe3ff9d9c29c7ed8bd8907bbd6142e86 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 13:39:46 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=4b4850aefe3ff9d9c29c7ed8bd8907bbd6142e86 commit 4b4850aefe3ff9d9c29c7ed8bd8907bbd6142e86 Author: Gordon Bergling AuthorDate: 2021-08-12 13:37:47 +0000 Commit: Gordon Bergling CommitDate: 2021-08-12 13:37:47 +0000 hms(4): Fix a typo in sysctl description - s/threshhold/threshold/ MFC after: 3 days --- sys/dev/hid/hms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/hid/hms.c b/sys/dev/hid/hms.c index 94267b3fcd52..014354c3acc3 100644 --- a/sys/dev/hid/hms.c +++ b/sys/dev/hid/hms.c @@ -271,7 +271,7 @@ hms_attach(device_t dev) SYSCTL_ADD_U32(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "drift_thresh", CTLFLAG_RW, &sc->drift_thresh, 0, - "drift detection threshhold"); + "drift detection threshold"); } #endif From owner-dev-commits-src-all@freebsd.org Thu Aug 12 13:49:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A56D166C1FC; Thu, 12 Aug 2021 13:49:51 +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 4Glp333mZ4z4nMQ; Thu, 12 Aug 2021 13:49: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 6943E23BD5; Thu, 12 Aug 2021 13:49: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 17CDnp7f052496; Thu, 12 Aug 2021 13:49:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CDnp0n052495; Thu, 12 Aug 2021 13:49:51 GMT (envelope-from git) Date: Thu, 12 Aug 2021 13:49:51 GMT Message-Id: <202108121349.17CDnp0n052495@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: b8adacf39a5a - stable/13 - amd64: Set GS.base before calling init_secondary() on APs 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: b8adacf39a5a968dabb36390bc51388553fb6ca9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 13:49:51 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b8adacf39a5a968dabb36390bc51388553fb6ca9 commit b8adacf39a5a968dabb36390bc51388553fb6ca9 Author: Mark Johnston AuthorDate: 2021-07-29 14:22:37 +0000 Commit: Mark Johnston CommitDate: 2021-08-12 13:43:21 +0000 amd64: Set GS.base before calling init_secondary() on APs KMSAN instrumentation requires thread-local storage to track initialization state for function parameters and return values. This buffer is accessed as part of each function prologue. It is provided by the KMSAN runtime, which looks up a pointer in the current thread's structure. When KMSAN is configured, init_secondary() is instrumented, but this means that GS.base must be initialized first, otherwise the runtime cannot safely access curthread. Work around this by loading GS.base before calling init_secondary(), so that the runtime can at least check curthread == NULL and return a pointer to some dummy storage. Note that init_secondary() still must reload GS.base after calling lgdt(), which loads a selector into %gs, which in turn clears the base register. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 4b136ef259cefedc9b6404afc09138aeb8acbd91) --- sys/amd64/amd64/mp_machdep.c | 8 ++++---- sys/amd64/amd64/mpboot.S | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 74f1af919b66..41c082ff40e9 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -103,6 +103,7 @@ char *doublefault_stack; char *mce_stack; char *nmi_stack; char *dbg_stack; +void *bootpcpu; extern u_int mptramp_la57; @@ -273,10 +274,8 @@ init_secondary(void) /* Update microcode before doing anything else. */ ucode_load_ap(cpu); - /* Get per-cpu data and save */ - pc = &__pcpu[cpu]; - - /* prime data page for it to use */ + /* Initialize the PCPU area. */ + pc = bootpcpu; pcpu_init(pc, cpu, sizeof(struct pcpu)); dpcpu_init(dpcpu, cpu); pc->pc_apic_id = cpu_apic_ids[cpu]; @@ -495,6 +494,7 @@ native_start_all_aps(void) dpcpu = (void *)kmem_malloc_domainset(DOMAINSET_PREF(domain), DPCPU_SIZE, M_WAITOK | M_ZERO); + bootpcpu = &__pcpu[cpu]; bootSTK = (char *)bootstacks[cpu] + kstack_pages * PAGE_SIZE - 8; bootAP = cpu; diff --git a/sys/amd64/amd64/mpboot.S b/sys/amd64/amd64/mpboot.S index e525102b5d3d..afdcffa573a4 100644 --- a/sys/amd64/amd64/mpboot.S +++ b/sys/amd64/amd64/mpboot.S @@ -270,4 +270,21 @@ entry_64: 2: movq KPML5phys, %rax 3: movq %rax, %cr3 movq bootSTK, %rsp + + /* + * Initialize the segment register used for the PCPU area. The PCPU + * area will be initialized by init_secondary(), but it should be + * accessible before that to support sanitizer instrumentation which + * accesses per-CPU variables. + * + * Note that GS.base is loaded again in init_secondary(). This is not + * redundant: lgdt() loads a selector into %gs and this has the side + * effect of clearing GS.base. + */ + movl $MSR_GSBASE, %ecx + movq bootpcpu, %rax + movq %rax, %rdx + shrq $32, %rdx + wrmsr + jmp init_secondary From owner-dev-commits-src-all@freebsd.org Thu Aug 12 13:49:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C56D366C81C; Thu, 12 Aug 2021 13:49: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 4Glp344ry0z4n8f; Thu, 12 Aug 2021 13:49: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 8BB2223B7D; Thu, 12 Aug 2021 13:49: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 17CDnqIm052520; Thu, 12 Aug 2021 13:49:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CDnq8U052519; Thu, 12 Aug 2021 13:49:52 GMT (envelope-from git) Date: Thu, 12 Aug 2021 13:49:52 GMT Message-Id: <202108121349.17CDnq8U052519@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: 7f39284c271b - stable/13 - amd64: Set MSR_KGSBASE to 0 during AP startup 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: 7f39284c271b6c5801b6af9a9f0e46805528b244 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 13:49:52 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7f39284c271b6c5801b6af9a9f0e46805528b244 commit 7f39284c271b6c5801b6af9a9f0e46805528b244 Author: Mark Johnston AuthorDate: 2021-07-29 14:14:05 +0000 Commit: Mark Johnston CommitDate: 2021-08-12 13:43:31 +0000 amd64: Set MSR_KGSBASE to 0 during AP startup There is no reason to initialize it to anything else, and this matches initialization of the BSP. No functional change intended. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit e1537450838134daaf584d1f17e661673b2c4c76) --- sys/amd64/amd64/mp_machdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 41c082ff40e9..d1064262891f 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -337,8 +337,8 @@ init_secondary(void) lgdt(&ap_gdt); /* does magic intra-segment return */ wrmsr(MSR_FSBASE, 0); /* User value */ - wrmsr(MSR_GSBASE, (u_int64_t)pc); - wrmsr(MSR_KGSBASE, (u_int64_t)pc); /* XXX User value while we're in the kernel */ + wrmsr(MSR_GSBASE, (uint64_t)pc); + wrmsr(MSR_KGSBASE, 0); /* User value */ fix_cpuid(); lidt(&r_idt); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 13:49:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5323B66C247; Thu, 12 Aug 2021 13: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 4Glp360lMwz4n8j; Thu, 12 Aug 2021 13: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 B053423B7E; Thu, 12 Aug 2021 13:49: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 17CDnr6C052546; Thu, 12 Aug 2021 13:49:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CDnrFO052545; Thu, 12 Aug 2021 13:49:53 GMT (envelope-from git) Date: Thu, 12 Aug 2021 13:49:53 GMT Message-Id: <202108121349.17CDnrFO052545@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: f53932dfc411 - stable/13 - link_elf_obj: Invoke fini callbacks 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: f53932dfc411fbab6f8d8fbca8727a97cc5b92a9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 13:49:54 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f53932dfc411fbab6f8d8fbca8727a97cc5b92a9 commit f53932dfc411fbab6f8d8fbca8727a97cc5b92a9 Author: Mark Johnston AuthorDate: 2021-07-29 13:46:25 +0000 Commit: Mark Johnston CommitDate: 2021-08-12 13:43:41 +0000 link_elf_obj: Invoke fini callbacks This is required for KASAN: when a module is unloaded, poisoned regions (e.g., pad areas between global variables) are left as such, so if they are reused as KLDs are loaded, false positives can arise. Reported by: pho, Jenkins Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 9e575fadf491152fb3445d4837d49a9cb87dd6e2) --- sys/kern/kern_linker.c | 2 ++ sys/kern/link_elf_obj.c | 32 +++++++++++++++++++++++++++++--- sys/sys/linker.h | 6 ++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index dbbf240a2f56..cb5d587bfbbc 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -613,6 +613,8 @@ linker_make_file(const char *pathname, linker_class_t lc) return (NULL); lf->ctors_addr = 0; lf->ctors_size = 0; + lf->dtors_addr = 0; + lf->dtors_size = 0; lf->refs = 1; lf->userrefs = 0; lf->flags = 0; diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index 65b997b513e3..91852939e5e8 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -544,6 +544,17 @@ link_elf_link_preload(linker_class_t cls, const char *filename, lf->ctors_addr = ef->progtab[pb].addr; lf->ctors_size = shdr[i].sh_size; } + } else if ((ef->progtab[pb].name != NULL && + strcmp(ef->progtab[pb].name, ".dtors") == 0) || + shdr[i].sh_type == SHT_FINI_ARRAY) { + if (lf->dtors_addr != 0) { + printf( + "%s: multiple dtor sections in %s\n", + __func__, filename); + } else { + lf->dtors_addr = ef->progtab[pb].addr; + lf->dtors_size = shdr[i].sh_size; + } } /* Update all symbol values with the offset. */ @@ -612,7 +623,7 @@ out: } static void -link_elf_invoke_ctors(caddr_t addr, size_t size) +link_elf_invoke_cbs(caddr_t addr, size_t size) { void (**ctor)(void); size_t i, cnt; @@ -653,7 +664,7 @@ link_elf_link_preload_finish(linker_file_t lf) /* Apply protections now that relocation processing is complete. */ link_elf_protect(ef); - link_elf_invoke_ctors(lf->ctors_addr, lf->ctors_size); + link_elf_invoke_cbs(lf->ctors_addr, lf->ctors_size); return (0); } @@ -1012,6 +1023,19 @@ link_elf_load_file(linker_class_t cls, const char *filename, lf->ctors_size = shdr[i].sh_size; } + } else if (!strcmp(ef->progtab[pb].name, + ".dtors") || + shdr[i].sh_type == SHT_FINI_ARRAY) { + if (lf->dtors_addr != 0) { + printf( + "%s: multiple dtor sections in %s\n", + __func__, filename); + } else { + lf->dtors_addr = + (caddr_t)mapbase; + lf->dtors_size = + shdr[i].sh_size; + } } } else if (shdr[i].sh_type == SHT_PROGBITS) ef->progtab[pb].name = "<>"; @@ -1196,7 +1220,7 @@ link_elf_load_file(linker_class_t cls, const char *filename, #endif link_elf_protect(ef); - link_elf_invoke_ctors(lf->ctors_addr, lf->ctors_size); + link_elf_invoke_cbs(lf->ctors_addr, lf->ctors_size); *result = lf; out: @@ -1216,6 +1240,8 @@ link_elf_unload_file(linker_file_t file) elf_file_t ef = (elf_file_t) file; u_int i; + link_elf_invoke_cbs(file->dtors_addr, file->dtors_size); + /* Notify MD code that a module is being unloaded. */ elf_cpu_unload_file(file); diff --git a/sys/sys/linker.h b/sys/sys/linker.h index 6423a3989a02..35c8449382cf 100644 --- a/sys/sys/linker.h +++ b/sys/sys/linker.h @@ -82,8 +82,10 @@ struct linker_file { int id; /* unique id */ caddr_t address; /* load address */ size_t size; /* size of file */ - caddr_t ctors_addr; /* address of .ctors */ - size_t ctors_size; /* size of .ctors */ + caddr_t ctors_addr; /* address of .ctors/.init_array */ + size_t ctors_size; /* size of .ctors/.init_array */ + caddr_t dtors_addr; /* address of .dtors/.fini_array */ + size_t dtors_size; /* size of .dtors/.fini_array */ int ndeps; /* number of dependencies */ linker_file_t* deps; /* list of dependencies */ STAILQ_HEAD(, common_symbol) common; /* list of common symbols */ From owner-dev-commits-src-all@freebsd.org Thu Aug 12 14:14:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3AE0366D1CC; Thu, 12 Aug 2021 14:14: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 4GlpZy142Zz4r1y; Thu, 12 Aug 2021 14:14: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 0DB1B244B8; Thu, 12 Aug 2021 14:14: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 17CEE1S9092303; Thu, 12 Aug 2021 14:14:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CEE1dR092302; Thu, 12 Aug 2021 14:14:01 GMT (envelope-from git) Date: Thu, 12 Aug 2021 14:14:01 GMT Message-Id: <202108121414.17CEE1dR092302@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Cy Schubert Subject: git: ce92f5a91b16 - main - wpa: Add wpa_cli action file event MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ce92f5a91b161c85e0a7e37cc754e3c28074281a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 14:14:02 -0000 The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=ce92f5a91b161c85e0a7e37cc754e3c28074281a commit ce92f5a91b161c85e0a7e37cc754e3c28074281a Author: Cy Schubert AuthorDate: 2021-08-12 13:38:21 +0000 Commit: Cy Schubert CommitDate: 2021-08-12 14:13:25 +0000 wpa: Add wpa_cli action file event Yan Zhong at FreeBSD Foundation is working on a wireless network configuratior for an experimental FreeBSD installer. The new installer requires an event to detect when connecting to a network fails due to a bad password. When this happens a WPA-EVENT-TEMP-DISABLED event is triggered. This patch passes the event to an action file provided by the new experimental installer. Submitted by: Yang Zhong Reviewed by: assumed to be reviewed by emaste (and cy) MFC after: 1 week --- contrib/wpa/wpa_supplicant/wpa_cli.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/wpa/wpa_supplicant/wpa_cli.c b/contrib/wpa/wpa_supplicant/wpa_cli.c index 43ac427203ec..9ad2e3ef2144 100644 --- a/contrib/wpa/wpa_supplicant/wpa_cli.c +++ b/contrib/wpa/wpa_supplicant/wpa_cli.c @@ -3977,6 +3977,8 @@ static void wpa_cli_action_process(const char *msg) wpa_cli_connected = 0; wpa_cli_exec(action_file, ifname, "DISCONNECTED"); } + } else if (str_starts(pos, WPA_EVENT_TEMP_DISABLED)) { + wpa_cli_exec(action_file, ifname, pos); } else if (str_starts(pos, WPA_EVENT_CHANNEL_SWITCH_STARTED)) { wpa_cli_exec(action_file, ctrl_ifname, pos); } else if (str_starts(pos, AP_EVENT_ENABLED)) { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 15:06:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1FBD966DAA1; Thu, 12 Aug 2021 15:06: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 4GlqlT08hgz4tcd; Thu, 12 Aug 2021 15:06: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 E255024E1B; Thu, 12 Aug 2021 15:06: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 17CF6SFi059056; Thu, 12 Aug 2021 15:06:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CF6S6U059055; Thu, 12 Aug 2021 15:06:28 GMT (envelope-from git) Date: Thu, 12 Aug 2021 15:06:28 GMT Message-Id: <202108121506.17CF6S6U059055@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: a638dc4ebc8e - main - vfs: Add ioflag to VOP_DEALLOCATE(9) 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/main X-Git-Reftype: branch X-Git-Commit: a638dc4ebc8eaa90a87ee053b7104ee4511f4491 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 15:06:29 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=a638dc4ebc8eaa90a87ee053b7104ee4511f4491 commit a638dc4ebc8eaa90a87ee053b7104ee4511f4491 Author: Ka Ho Ng AuthorDate: 2021-08-12 14:58:52 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-12 15:03:49 +0000 vfs: Add ioflag to VOP_DEALLOCATE(9) The addition of ioflag allows callers passing IO_SYNC/IO_DATASYNC/IO_DIRECT down to the file system implementation. The vop_stddeallocate fallback implementation is updated to pass the ioflag to the file system implementation. vn_deallocate(9) internally is also changed to pass ioflag to the VOP_DEALLOCATE call. Sponsored by: The FreeBSD Foundation Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D31500 --- share/man/man9/VOP_DEALLOCATE.9 | 5 ++++- share/man/man9/vn_deallocate.9 | 9 +++++++-- sys/kern/vfs_default.c | 6 +++--- sys/kern/vfs_vnops.c | 7 +++++-- sys/kern/vnode_if.src | 1 + 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9 index 1c7f80cfbc6c..dbfe048f2235 100644 --- a/share/man/man9/VOP_DEALLOCATE.9 +++ b/share/man/man9/VOP_DEALLOCATE.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 11, 2021 +.Dd August 11, 2021 .Dt VOP_DEALLOCATE 9 .Os .Sh NAME @@ -42,6 +42,7 @@ .Fa "off_t *offset" .Fa "off_t *len" .Fa "int flags" +.Fa "int ioflag" .Fa "struct ucred *cred" .Fc .Sh DESCRIPTION @@ -61,6 +62,8 @@ The length of the range to deallocate storage in the file. .It Fa flags The flags of this call. This should be set to 0 for now. +.It Fa ioflag +Directives and hints to be given to the file system. .It Fa cred The credentials of the caller. .El diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9 index 60bcb9049e40..29edcd57ff5d 100644 --- a/share/man/man9/vn_deallocate.9 +++ b/share/man/man9/vn_deallocate.9 @@ -67,7 +67,7 @@ This must be greater than 0. The control flags of the operation. This should be set to 0 for now. .It Fa ioflag -The control flags of vnode locking. +Directives and hints to be given to the file system. .It Fa active_cred The user credentials of the calling thread. .It Fa file_cred @@ -76,7 +76,8 @@ The credentials installed on the file description pointing to the vnode or NOCRE .Pp The .Fn ioflag -argument may be one or more of the following flags: +argument gives directives and hints to the file system. +It may include one or more of the following flags: .Bl -tag -width IO_RANGELOCKED .It Dv IO_NODELOCKED The vnode was locked before the call. @@ -84,6 +85,10 @@ The vnode was locked before the call. Rangelock was owned around the call. .It Dv IO_NOMACCHECK Skip MAC checking in the call. +.It Dv IO_SYNC +Do I/O synchronously. +.It Dv IO_DIRECT +Attempt to bypass buffer cache. .El .Pp .Fa *offset diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index c42d5a795935..d9328cd39b00 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1074,7 +1074,7 @@ vop_stdallocate(struct vop_allocate_args *ap) static int vp_zerofill(struct vnode *vp, struct vattr *vap, off_t *offsetp, off_t *lenp, - struct ucred *cred) + int ioflag, struct ucred *cred) { int iosize; int error = 0; @@ -1110,7 +1110,7 @@ vp_zerofill(struct vnode *vp, struct vattr *vap, off_t *offsetp, off_t *lenp, auio.uio_rw = UIO_WRITE; auio.uio_td = td; - error = VOP_WRITE(vp, &auio, 0, cred); + error = VOP_WRITE(vp, &auio, ioflag, cred); if (error != 0) { len -= xfersize - auio.uio_resid; offset += xfersize - auio.uio_resid; @@ -1175,7 +1175,7 @@ vop_stddeallocate(struct vop_deallocate_args *ap) /* Fill zeroes */ xfersize = rem = omin(noff - offset, len); - error = vp_zerofill(vp, &va, &offset, &rem, cred); + error = vp_zerofill(vp, &va, &offset, &rem, ap->a_ioflag, cred); if (error) { len -= xfersize - rem; goto out; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 5572c324469b..3fce590519a8 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3509,7 +3509,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, vp); #endif if (error == 0) - error = VOP_DEALLOCATE(vp, &off, &len, flags, + error = VOP_DEALLOCATE(vp, &off, &len, flags, ioflag, active_cred); if ((ioflag & IO_NODELOCKED) == 0) { @@ -3548,6 +3548,7 @@ vn_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, { int error; struct vnode *vp; + int ioflag; vp = fp->f_vnode; @@ -3557,9 +3558,11 @@ vn_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, if (vp->v_type != VREG) return (ENODEV); + ioflag = get_write_ioflag(fp); + switch (cmd) { case SPACECTL_DEALLOC: - error = vn_deallocate_impl(vp, offset, length, flags, 0, + error = vn_deallocate_impl(vp, offset, length, flags, ioflag, active_cred, fp->f_cred); break; default: diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 97ac1cff6705..ff57d1c9a28e 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -808,6 +808,7 @@ vop_deallocate { INOUT off_t *offset; INOUT off_t *len; IN int flags; + IN int ioflag; IN struct ucred *cred; }; From owner-dev-commits-src-all@freebsd.org Thu Aug 12 15:06:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 402AF66DB2D; Thu, 12 Aug 2021 15:06: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 4GlqlV1907z4tRC; Thu, 12 Aug 2021 15:06: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 0921C24BF9; Thu, 12 Aug 2021 15:06: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 17CF6TSL059080; Thu, 12 Aug 2021 15:06:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CF6TXt059079; Thu, 12 Aug 2021 15:06:29 GMT (envelope-from git) Date: Thu, 12 Aug 2021 15:06:29 GMT Message-Id: <202108121506.17CF6TXt059079@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 454bc887f250 - main - uipc_shm: Implements fspacectl(2) support 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/main X-Git-Reftype: branch X-Git-Commit: 454bc887f250ce0bceaabd0ec624d077269d3220 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 15:06:30 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=454bc887f250ce0bceaabd0ec624d077269d3220 commit 454bc887f250ce0bceaabd0ec624d077269d3220 Author: Ka Ho Ng AuthorDate: 2021-08-12 15:01:02 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-12 15:04:18 +0000 uipc_shm: Implements fspacectl(2) support This implements fspacectl(2) support on shared memory objects. The semantic of SPACECTL_DEALLOC is equivalent to clearing the backing store and free the pages within the affected range. If the call succeeds, subsequent reads on the affected range return all zero. tests/sys/posixshm/posixshm_tests.c is expanded to include a fspacectl(2) functional test. Sponsored by: The FreeBSD Foundation Reviewed by: kevans, kib Differential Revision: https://reviews.freebsd.org/D31490 --- sys/kern/uipc_shm.c | 197 ++++++++++++++++++++++++++++-------- tests/sys/posixshm/posixshm_test.c | 199 +++++++++++++++++++++++++++++++++++++ 2 files changed, 354 insertions(+), 42 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 58c9f8cec239..16d1e22a898b 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -131,6 +131,8 @@ static int shm_dotruncate_locked(struct shmfd *shmfd, off_t length, void *rl_cookie); static int shm_copyin_path(struct thread *td, const char *userpath_in, char **path_out); +static int shm_deallocate(struct shmfd *shmfd, off_t *offset, + off_t *length, int flags); static fo_rdwr_t shm_read; static fo_rdwr_t shm_write; @@ -146,6 +148,7 @@ static fo_mmap_t shm_mmap; static fo_get_seals_t shm_get_seals; static fo_add_seals_t shm_add_seals; static fo_fallocate_t shm_fallocate; +static fo_fspacectl_t shm_fspacectl; /* File descriptor operations. */ struct fileops shm_ops = { @@ -166,6 +169,7 @@ struct fileops shm_ops = { .fo_get_seals = shm_get_seals, .fo_add_seals = shm_add_seals, .fo_fallocate = shm_fallocate, + .fo_fspacectl = shm_fspacectl, .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE, }; @@ -626,14 +630,64 @@ out: return (error); } +static int +shm_partial_page_invalidate(vm_object_t object, vm_pindex_t idx, int base, + int end) +{ + vm_page_t m; + int rv; + + VM_OBJECT_ASSERT_WLOCKED(object); + KASSERT(base >= 0, ("%s: base %d", __func__, base)); + KASSERT(end - base <= PAGE_SIZE, ("%s: base %d end %d", __func__, base, + end)); + +retry: + m = vm_page_grab(object, idx, VM_ALLOC_NOCREAT); + if (m != NULL) { + MPASS(vm_page_all_valid(m)); + } else if (vm_pager_has_page(object, idx, NULL, NULL)) { + m = vm_page_alloc(object, idx, + VM_ALLOC_NORMAL | VM_ALLOC_WAITFAIL); + if (m == NULL) + goto retry; + vm_object_pip_add(object, 1); + VM_OBJECT_WUNLOCK(object); + rv = vm_pager_get_pages(object, &m, 1, NULL, NULL); + VM_OBJECT_WLOCK(object); + vm_object_pip_wakeup(object); + if (rv == VM_PAGER_OK) { + /* + * Since the page was not resident, and therefore not + * recently accessed, immediately enqueue it for + * asynchronous laundering. The current operation is + * not regarded as an access. + */ + vm_page_launder(m); + } else { + vm_page_free(m); + VM_OBJECT_WUNLOCK(object); + return (EIO); + } + } + if (m != NULL) { + pmap_zero_page_area(m, base, end - base); + KASSERT(vm_page_all_valid(m), ("%s: page %p is invalid", + __func__, m)); + vm_page_set_dirty(m); + vm_page_xunbusy(m); + } + + return (0); +} + static int shm_dotruncate_locked(struct shmfd *shmfd, off_t length, void *rl_cookie) { vm_object_t object; - vm_page_t m; - vm_pindex_t idx, nobjsize; + vm_pindex_t nobjsize; vm_ooffset_t delta; - int base, rv; + int base, error; KASSERT(length >= 0, ("shm_dotruncate: length < 0")); object = shmfd->shm_object; @@ -660,45 +714,10 @@ shm_dotruncate_locked(struct shmfd *shmfd, off_t length, void *rl_cookie) */ base = length & PAGE_MASK; if (base != 0) { - idx = OFF_TO_IDX(length); -retry: - m = vm_page_grab(object, idx, VM_ALLOC_NOCREAT); - if (m != NULL) { - MPASS(vm_page_all_valid(m)); - } else if (vm_pager_has_page(object, idx, NULL, NULL)) { - m = vm_page_alloc(object, idx, - VM_ALLOC_NORMAL | VM_ALLOC_WAITFAIL); - if (m == NULL) - goto retry; - vm_object_pip_add(object, 1); - VM_OBJECT_WUNLOCK(object); - rv = vm_pager_get_pages(object, &m, 1, NULL, - NULL); - VM_OBJECT_WLOCK(object); - vm_object_pip_wakeup(object); - if (rv == VM_PAGER_OK) { - /* - * Since the page was not resident, - * and therefore not recently - * accessed, immediately enqueue it - * for asynchronous laundering. The - * current operation is not regarded - * as an access. - */ - vm_page_launder(m); - } else { - vm_page_free(m); - VM_OBJECT_WUNLOCK(object); - return (EIO); - } - } - if (m != NULL) { - pmap_zero_page_area(m, base, PAGE_SIZE - base); - KASSERT(vm_page_all_valid(m), - ("shm_dotruncate: page %p is invalid", m)); - vm_page_set_dirty(m); - vm_page_xunbusy(m); - } + error = shm_partial_page_invalidate(object, + OFF_TO_IDX(length), base, PAGE_SIZE); + if (error) + return (error); } delta = IDX_TO_OFF(object->size - nobjsize); @@ -1874,6 +1893,100 @@ shm_get_seals(struct file *fp, int *seals) return (0); } +static int +shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) +{ + vm_object_t object; + vm_pindex_t pistart, pi, piend; + vm_ooffset_t off, len; + int startofs, endofs, end; + int error; + + off = *offset; + len = *length; + KASSERT(off + len <= (vm_ooffset_t)OFF_MAX, ("off + len overflows")); + object = shmfd->shm_object; + startofs = off & PAGE_MASK; + endofs = (off + len) & PAGE_MASK; + pistart = OFF_TO_IDX(off); + piend = OFF_TO_IDX(off + len); + pi = OFF_TO_IDX(off + PAGE_MASK); + error = 0; + + VM_OBJECT_WLOCK(object); + + if (startofs != 0) { + end = pistart != piend ? PAGE_SIZE : endofs; + error = shm_partial_page_invalidate(object, pistart, startofs, + end); + if (error) + goto out; + off += end - startofs; + len -= end - startofs; + } + + if (pi < piend) { + vm_object_page_remove(object, pi, piend, 0); + off += IDX_TO_OFF(piend - pi); + len -= IDX_TO_OFF(piend - pi); + } + + if (endofs != 0 && pistart != piend) { + error = shm_partial_page_invalidate(object, piend, 0, endofs); + if (error) + goto out; + off += endofs; + len -= endofs; + } + +out: + VM_OBJECT_WUNLOCK(shmfd->shm_object); + *offset = off; + *length = len; + return (error); +} + +static int +shm_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, + struct ucred *active_cred, struct thread *td) +{ + void *rl_cookie; + struct shmfd *shmfd; + off_t off, len; + int error; + + /* This assumes that the caller already checked for overflow. */ + error = EINVAL; + shmfd = fp->f_data; + off = *offset; + len = *length; + + if (cmd != SPACECTL_DEALLOC || off < 0 || len <= 0 || + len > OFF_MAX - off || flags != 0) + return (EINVAL); + + rl_cookie = rangelock_wlock(&shmfd->shm_rl, off, off + len, + &shmfd->shm_mtx); + switch (cmd) { + case SPACECTL_DEALLOC: + if ((shmfd->shm_seals & F_SEAL_WRITE) != 0) { + error = EPERM; + break; + } + error = shm_deallocate(shmfd, &off, &len, flags); + if (error != 0) + break; + *offset = off; + *length = len; + break; + default: + __assert_unreachable(); + } + rangelock_unlock(&shmfd->shm_rl, rl_cookie, &shmfd->shm_mtx); + return (error); +} + + static int shm_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td) { diff --git a/tests/sys/posixshm/posixshm_test.c b/tests/sys/posixshm/posixshm_test.c index d1c1b14aef65..eddb1d2d8250 100644 --- a/tests/sys/posixshm/posixshm_test.c +++ b/tests/sys/posixshm/posixshm_test.c @@ -2,6 +2,11 @@ * Copyright (c) 2006 Robert N. M. Watson * All rights reserved. * + * Copyright (c) 2021 The FreeBSD Foundation + * + * 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: @@ -173,6 +178,126 @@ verify_object(const char *path, char expected_value) close(fd); } +static off_t shm_max_pages = 32; +static const char byte_to_fill = 0x5f; + +static int +shm_fill(int fd, off_t offset, off_t len) +{ + int error; + size_t blen; + char *buf; + error = 0; + buf = malloc(PAGE_SIZE); + if (buf == NULL) + return (1); + + while (len > 0) { + blen = len < (off_t)PAGE_SIZE ? len : PAGE_SIZE; + memset(buf, byte_to_fill, blen); + if (pwrite(fd, buf, blen, offset) != (ssize_t)blen) { + error = 1; + break; + } + len -= blen; + offset += blen; + } + + free(buf); + return (error); +} + +static int +check_content_dealloc(int fd, off_t hole_start, off_t hole_len, off_t shm_sz) +{ + int error; + size_t blen; + off_t offset, resid; + struct stat statbuf; + char *buf, *sblk; + + error = 0; + buf = malloc(PAGE_SIZE * 2); + if (buf == NULL) + return (1); + sblk = buf + PAGE_SIZE; + + memset(sblk, 0, PAGE_SIZE); + + if ((uint64_t)hole_start + hole_len > (uint64_t)shm_sz) + hole_len = shm_sz - hole_start; + + /* + * Check hole is zeroed. + */ + offset = hole_start; + resid = hole_len; + while (resid > 0) { + blen = resid < (off_t)PAGE_SIZE ? resid : PAGE_SIZE; + if (pread(fd, buf, blen, offset) != (ssize_t)blen) { + error = 1; + break; + } + if (memcmp(buf, sblk, blen) != 0) { + error = 1; + break; + } + resid -= blen; + offset += blen; + } + + memset(sblk, byte_to_fill, PAGE_SIZE); + + /* + * Check file region before hole is zeroed. + */ + offset = 0; + resid = hole_start; + while (resid > 0) { + blen = resid < (off_t)PAGE_SIZE ? resid : PAGE_SIZE; + if (pread(fd, buf, blen, offset) != (ssize_t)blen) { + error = 1; + break; + } + if (memcmp(buf, sblk, blen) != 0) { + error = 1; + break; + } + resid -= blen; + offset += blen; + } + + /* + * Check file region after hole is zeroed. + */ + offset = hole_start + hole_len; + resid = shm_sz - offset; + while (resid > 0) { + blen = resid < (off_t)PAGE_SIZE ? resid : PAGE_SIZE; + if (pread(fd, buf, blen, offset) != (ssize_t)blen) { + error = 1; + break; + } + if (memcmp(buf, sblk, blen) != 0) { + error = 1; + break; + } + resid -= blen; + offset += blen; + } + + /* + * Check file size matches with expected file size. + */ + if (fstat(fd, &statbuf) == -1) + error = -1; + if (statbuf.st_size != shm_sz) + error = -1; + + free(buf); + return (error); +} + ATF_TC_WITHOUT_HEAD(remap_object); ATF_TC_BODY(remap_object, tc) { @@ -958,6 +1083,79 @@ ATF_TC_BODY(fallocate, tc) close(fd); } +ATF_TC_WITHOUT_HEAD(fspacectl); +ATF_TC_BODY(fspacectl, tc) +{ + struct spacectl_range range; + off_t offset, length, shm_sz; + int fd, error; + + shm_sz = shm_max_pages << PAGE_SHIFT; + + fd = shm_open("/testtest", O_RDWR|O_CREAT, 0666); + ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno:%d", errno); + ATF_REQUIRE_MSG((error = posix_fallocate(fd, 0, shm_sz)) == 0, + "posix_fallocate failed; error=%d", error); + + /* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) */ + ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); + range.r_offset = offset = PAGE_SIZE; + range.r_len = length = ((shm_max_pages - 1) << PAGE_SHIFT) - + range.r_offset; + ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, + "Aligned fspacectl failed; errno=%d", errno); + ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, + "Aligned fspacectl content checking failed", errno); + + /* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) */ + ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); + range.r_offset = offset = 1 << (PAGE_SHIFT - 1); + range.r_len = length = ((shm_max_pages - 1) << PAGE_SHIFT) + + (1 << (PAGE_SHIFT - 1)) - offset; + ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, + "Unaligned fspacectl failed; errno=%d", errno); + ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, + "Unaligned fspacectl content checking failed", errno); + + /* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) to OFF_MAX */ + ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); + range.r_offset = offset = PAGE_SHIFT; + range.r_len = length = OFF_MAX - offset; + ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, + "Aligned fspacectl to OFF_MAX failed; errno=%d", errno); + ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, + "Aligned fspacectl to OFF_MAX content checking failed", errno); + + /* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) to OFF_MAX */ + ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); + range.r_offset = offset = 1 << (PAGE_SHIFT - 1); + range.r_len = length = OFF_MAX - offset; + ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, + "Unaligned fspacectl to OFF_MAX failed; errno=%d", errno); + ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, + "Unaligned fspacectl to OFF_MAX content checking failed", errno); + + /* Aligned fspacectl(fd, SPACECTL_DEALLOC, ...) past shm_sz */ + ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); + range.r_offset = offset = PAGE_SIZE; + range.r_len = length = ((shm_max_pages + 1) << PAGE_SHIFT) - offset; + ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, + "Aligned fspacectl past shm_sz failed; errno=%d", errno); + ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, + "Aligned fspacectl past shm_sz content checking failed", errno); + + /* Unaligned fspacectl(fd, SPACECTL_DEALLOC, ...) past shm_sz */ + ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0); + range.r_offset = offset = 1 << (PAGE_SHIFT - 1); + range.r_len = length = ((shm_max_pages + 1) << PAGE_SHIFT) - offset; + ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0, + "Unaligned fspacectl past shm_sz failed; errno=%d", errno); + ATF_CHECK_MSG(check_content_dealloc(fd, offset, length, shm_sz) == 0, + "Unaligned fspacectl past shm_sz content checking failed", errno); + + ATF_REQUIRE(close(fd) == 0); +} + static int shm_open_large(int psind, int policy, size_t sz) { @@ -1704,6 +1902,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, cloexec); ATF_TP_ADD_TC(tp, mode); ATF_TP_ADD_TC(tp, fallocate); + ATF_TP_ADD_TC(tp, fspacectl); ATF_TP_ADD_TC(tp, largepage_basic); ATF_TP_ADD_TC(tp, largepage_config); ATF_TP_ADD_TC(tp, largepage_mmap); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 15:06:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75EE566D2E8; Thu, 12 Aug 2021 15:06: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 4GlqlW2f4sz4syj; Thu, 12 Aug 2021 15:06: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 3A9D724CB4; Thu, 12 Aug 2021 15:06: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 17CF6VFt059104; Thu, 12 Aug 2021 15:06:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CF6Vxs059103; Thu, 12 Aug 2021 15:06:31 GMT (envelope-from git) Date: Thu, 12 Aug 2021 15:06:31 GMT Message-Id: <202108121506.17CF6Vxs059103@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 95941b963606 - main - param.h: Bump __FreeBSD_version to 1400030 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/main X-Git-Reftype: branch X-Git-Commit: 95941b963606f6e03282cd6f866f3166dcedfa5b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 15:06:31 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=95941b963606f6e03282cd6f866f3166dcedfa5b commit 95941b963606f6e03282cd6f866f3166dcedfa5b Author: Ka Ho Ng AuthorDate: 2021-08-12 14:59:41 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-12 15:05:26 +0000 param.h: Bump __FreeBSD_version to 1400030 Commit a638dc4ebc8e expands VOP_DEALLOCATE(9)'s parameters list. File system modules and modules calling VOP_DEALLOCATE(9) need to be rebuilt. Commit 454bc887f250 introduces fspacectl(2) SPACECTL_DEALLOC support for POSIX shared memory. Sponsored by: The FreeBSD Foundation --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 8864063e3d9b..5ab48dce2a74 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400029 +#define __FreeBSD_version 1400030 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-all@freebsd.org Thu Aug 12 15:20:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2C5266DD79; Thu, 12 Aug 2021 15:20:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Glr455gtsz4vDX; Thu, 12 Aug 2021 15:20:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 234D725085; Thu, 12 Aug 2021 15:20:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: git: f4c6843ec2b9 - main - xen: use correct cache attributes for Xen specific memory regions To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108120724.17C7OJ8h043708@gitrepo.freebsd.org> From: John Baldwin Message-ID: Date: Thu, 12 Aug 2021 08:20:51 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <202108120724.17C7OJ8h043708@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 15:20:53 -0000 On 8/12/21 12:24 AM, Roger Pau Monné wrote: > The branch main has been updated by royger: > > URL: https://cgit.FreeBSD.org/src/commit/?id=f4c6843ec2b9aa5eff475778fb000ed6278c5b77 > > commit f4c6843ec2b9aa5eff475778fb000ed6278c5b77 > Author: Roger Pau Monné > AuthorDate: 2021-04-09 09:31:44 +0000 > Commit: Roger Pau Monné > CommitDate: 2021-08-12 07:18:32 +0000 > > xen: use correct cache attributes for Xen specific memory regions > > bus_activate_resource maps memory regions as uncacheable on x86, which > is more strict than required for regions allocated using xenmem_alloc, > so don't rely on bus_activate_resource and instead map the region > using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. > > Sponsored by: Citrix Systems R&D It would probably be cleaner to use bus_map_resource() for this instead. It would mean you would have to use a structure that writes to as the argument to bus_read/write_* instead of using the resource directly. -- John Baldwin From owner-dev-commits-src-all@freebsd.org Thu Aug 12 15:53:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F316166E705; Thu, 12 Aug 2021 15:53:45 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Glrp155YKz3CqM; Thu, 12 Aug 2021 15:53:45 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from localhost (unknown [93.176.191.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: royger) by smtp.freebsd.org (Postfix) with ESMTPSA id 3D7E02503B; Thu, 12 Aug 2021 15:53:45 +0000 (UTC) (envelope-from royger@FreeBSD.org) Date: Thu, 12 Aug 2021 17:53:35 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: John Baldwin Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: f4c6843ec2b9 - main - xen: use correct cache attributes for Xen specific memory regions Message-ID: References: <202108120724.17C7OJ8h043708@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 15:53:46 -0000 On Thu, Aug 12, 2021 at 08:20:51AM -0700, John Baldwin wrote: > On 8/12/21 12:24 AM, Roger Pau Monné wrote: > > The branch main has been updated by royger: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=f4c6843ec2b9aa5eff475778fb000ed6278c5b77 > > > > commit f4c6843ec2b9aa5eff475778fb000ed6278c5b77 > > Author: Roger Pau Monné > > AuthorDate: 2021-04-09 09:31:44 +0000 > > Commit: Roger Pau Monné > > CommitDate: 2021-08-12 07:18:32 +0000 > > > > xen: use correct cache attributes for Xen specific memory regions > > bus_activate_resource maps memory regions as uncacheable on x86, which > > is more strict than required for regions allocated using xenmem_alloc, > > so don't rely on bus_activate_resource and instead map the region > > using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. > > Sponsored by: Citrix Systems R&D > > It would probably be cleaner to use bus_map_resource() for this instead. It > would mean you would have to use a structure that writes to as the argument > to bus_read/write_* instead of using the resource directly. Those regions are usually handled to other subsystems of the kernel. They are mostly used to map memory from other domains and then perform IO on their behalf (like blkback and netback do), so it's not really possible to assert that all users of the regions would use bus_read/write_* to access them. I could however switch to using bus_map_resource if I can pass the desired memory cache attribute and get a linear address back. It looks like resource_map_request parameter allows to select the cache attribute. Thanks, Roger. From owner-dev-commits-src-all@freebsd.org Thu Aug 12 16:06:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E72F466E9C3; Thu, 12 Aug 2021 16:06: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 4Gls4R65Lrz3DDr; Thu, 12 Aug 2021 16:06: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 B8B7025A74; Thu, 12 Aug 2021 16:06: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 17CG6FK8038817; Thu, 12 Aug 2021 16:06:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CG6FWj038816; Thu, 12 Aug 2021 16:06:15 GMT (envelope-from git) Date: Thu, 12 Aug 2021 16:06:15 GMT Message-Id: <202108121606.17CG6FWj038816@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 2eb0e53a6b5e - main - cxgbei: Wait for the final CPL to be received in icl_cxgbei_conn_close. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2eb0e53a6b5ec1a72be70e966d4e562e1a8d4e88 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 16:06:16 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=2eb0e53a6b5ec1a72be70e966d4e562e1a8d4e88 commit 2eb0e53a6b5ec1a72be70e966d4e562e1a8d4e88 Author: John Baldwin AuthorDate: 2021-08-12 15:48:14 +0000 Commit: John Baldwin CommitDate: 2021-08-12 15:48:35 +0000 cxgbei: Wait for the final CPL to be received in icl_cxgbei_conn_close. A socket in the FIN_WAIT_1 state is marked disconnected by do_close_con_rpl() even though there might still receive data pending. This is because the socket at that point has set SBS_CANTRCVMORE which causes the protocol layer to discard any data received before the FIN. However, icl_cxgbei_conn_close needs to wait until all the data has been discarded. Replace the wait for SS_ISDISCONNECTED with instead waiting for final_cpl_received() to be called. Reported by: Jithesh Arakkan @ Chelsio Sponsored by: Chelsio Communications --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 28 +++++++++++++++++++++------- sys/dev/cxgbe/tom/t4_tom.c | 12 +++++++++++- sys/dev/cxgbe/tom/t4_tom.h | 1 + 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index a57d26ae21b8..5526388915f7 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -947,6 +947,18 @@ icl_cxgbei_conn_close(struct icl_conn *ic) icl_cxgbei_pdu_done(ip, ENOTCONN); } SOCKBUF_UNLOCK(sb); + + /* + * Grab a reference to use when waiting for the final + * CPL to be received. If toep->inp is NULL, then + * final_cpl_received() has already been called (e.g. + * due to the peer sending a RST). + */ + if (toep->inp != NULL) { + toep = hold_toepcb(toep); + toep->flags |= TPF_WAITING_FOR_FINAL; + } else + toep = NULL; } INP_WUNLOCK(inp); @@ -959,7 +971,6 @@ icl_cxgbei_conn_close(struct icl_conn *ic) * queues were purged instead of delivered reliably but soabort isn't * really general purpose and wouldn't do the right thing here. */ - soref(so); soclose(so); /* @@ -969,12 +980,15 @@ icl_cxgbei_conn_close(struct icl_conn *ic) * Callers assume that it is safe to free buffers for tasks * and transfers after this function returns. */ - SOCK_LOCK(so); - while ((so->so_state & SS_ISDISCONNECTED) == 0) - mtx_sleep(&so->so_timeo, SOCK_MTX(so), PSOCK, "conclo2", 0); - CURVNET_SET(so->so_vnet); - sorele(so); - CURVNET_RESTORE(); + if (toep != NULL) { + struct mtx *lock = mtx_pool_find(mtxpool_sleep, toep); + + mtx_lock(lock); + while ((toep->flags & TPF_WAITING_FOR_FINAL) != 0) + mtx_sleep(toep, lock, PSOCK, "conclo2", 0); + mtx_unlock(lock); + free_toepcb(toep); + } } static void diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c index 1d065ade77c4..a444f0c9d690 100644 --- a/sys/dev/cxgbe/tom/t4_tom.c +++ b/sys/dev/cxgbe/tom/t4_tom.c @@ -1008,6 +1008,7 @@ void final_cpl_received(struct toepcb *toep) { struct inpcb *inp = toep->inp; + bool need_wakeup; KASSERT(inp != NULL, ("%s: inp is NULL", __func__)); INP_WLOCK_ASSERT(inp); @@ -1022,7 +1023,8 @@ final_cpl_received(struct toepcb *toep) else if (ulp_mode(toep) == ULP_MODE_TLS) tls_detach(toep); toep->inp = NULL; - toep->flags &= ~TPF_CPL_PENDING; + need_wakeup = (toep->flags & TPF_WAITING_FOR_FINAL) != 0; + toep->flags &= ~(TPF_CPL_PENDING | TPF_WAITING_FOR_FINAL); mbufq_drain(&toep->ulp_pduq); mbufq_drain(&toep->ulp_pdu_reclaimq); @@ -1031,6 +1033,14 @@ final_cpl_received(struct toepcb *toep) if (!in_pcbrele_wlocked(inp)) INP_WUNLOCK(inp); + + if (need_wakeup) { + struct mtx *lock = mtx_pool_find(mtxpool_sleep, toep); + + mtx_lock(lock); + wakeup(toep); + mtx_unlock(lock); + } } void diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index 10d9cfe87960..dc462d4b4a66 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -76,6 +76,7 @@ enum { TPF_INITIALIZED = (1 << 12), /* init_toepcb has been called */ TPF_TLS_RECEIVE = (1 << 13), /* should receive TLS records */ TPF_TLS_ESTABLISHED = (1 << 14), /* TLS handshake timer initialized */ + TPF_WAITING_FOR_FINAL = (1<< 15), /* waiting for wakeup on final CPL */ }; enum { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 16:44:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75B5B66EFDF; Thu, 12 Aug 2021 16:44:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Glsw22dF1z3H5Y; Thu, 12 Aug 2021 16:44:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id C84BE25984; Thu, 12 Aug 2021 16:44:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: git: f4c6843ec2b9 - main - xen: use correct cache attributes for Xen specific memory regions To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108120724.17C7OJ8h043708@gitrepo.freebsd.org> From: John Baldwin Message-ID: <32e784a3-9c96-9818-8fc3-a5ad85643f2c@FreeBSD.org> Date: Thu, 12 Aug 2021 09:43:57 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 16:44:02 -0000 On 8/12/21 8:53 AM, Roger Pau Monné wrote: > On Thu, Aug 12, 2021 at 08:20:51AM -0700, John Baldwin wrote: >> On 8/12/21 12:24 AM, Roger Pau Monné wrote: >>> The branch main has been updated by royger: >>> >>> URL: https://cgit.FreeBSD.org/src/commit/?id=f4c6843ec2b9aa5eff475778fb000ed6278c5b77 >>> >>> commit f4c6843ec2b9aa5eff475778fb000ed6278c5b77 >>> Author: Roger Pau Monné >>> AuthorDate: 2021-04-09 09:31:44 +0000 >>> Commit: Roger Pau Monné >>> CommitDate: 2021-08-12 07:18:32 +0000 >>> >>> xen: use correct cache attributes for Xen specific memory regions >>> bus_activate_resource maps memory regions as uncacheable on x86, which >>> is more strict than required for regions allocated using xenmem_alloc, >>> so don't rely on bus_activate_resource and instead map the region >>> using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. >>> Sponsored by: Citrix Systems R&D >> >> It would probably be cleaner to use bus_map_resource() for this instead. It >> would mean you would have to use a structure that writes to as the argument >> to bus_read/write_* instead of using the resource directly. > > Those regions are usually handled to other subsystems of the kernel. > They are mostly used to map memory from other domains and then perform > IO on their behalf (like blkback and netback do), so it's not really > possible to assert that all users of the regions would use > bus_read/write_* to access them. > > I could however switch to using bus_map_resource if I can pass the > desired memory cache attribute and get a linear address back. It looks > like resource_map_request parameter allows to select the cache > attribute. Yes, one of the use case for bus_map_resource is to permit passing a non-default memory attribute. (It also permits mapping sub-ranges, but that isn't applicable in this case.) The 'r_vaddr' in the resource_map is the equivalent of rman_get_addr. It'd be a little cleaner (and perhaps friendly to future changes in this area) if your clients used the 'r_vaddr' from the resource_map directly instead of using rman_set_virtual() on the original resource. (At some point I would like to have each 'struct resource' keep a list of all the mappings created from it and to forcefully invalidate/free any existing mappings that still remain when a 'struct resource' is freed. I imagine as part of that I might end up with some assertions about the embedded resource fields in the 'struct resource' being self-consistent). -- John Baldwin From owner-dev-commits-src-all@freebsd.org Thu Aug 12 17:01:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7ECC166F59A; Thu, 12 Aug 2021 17:01:46 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GltJV37npz3J7T; Thu, 12 Aug 2021 17:01:46 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from localhost (unknown [93.176.191.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: royger) by smtp.freebsd.org (Postfix) with ESMTPSA id 0076D25B11; Thu, 12 Aug 2021 17:01:45 +0000 (UTC) (envelope-from royger@FreeBSD.org) Date: Thu, 12 Aug 2021 19:01:43 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: John Baldwin Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: f4c6843ec2b9 - main - xen: use correct cache attributes for Xen specific memory regions Message-ID: References: <202108120724.17C7OJ8h043708@gitrepo.freebsd.org> <32e784a3-9c96-9818-8fc3-a5ad85643f2c@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <32e784a3-9c96-9818-8fc3-a5ad85643f2c@FreeBSD.org> X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 17:01:46 -0000 On Thu, Aug 12, 2021 at 09:43:57AM -0700, John Baldwin wrote: > On 8/12/21 8:53 AM, Roger Pau Monné wrote: > > On Thu, Aug 12, 2021 at 08:20:51AM -0700, John Baldwin wrote: > > > On 8/12/21 12:24 AM, Roger Pau Monné wrote: > > > > The branch main has been updated by royger: > > > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=f4c6843ec2b9aa5eff475778fb000ed6278c5b77 > > > > > > > > commit f4c6843ec2b9aa5eff475778fb000ed6278c5b77 > > > > Author: Roger Pau Monné > > > > AuthorDate: 2021-04-09 09:31:44 +0000 > > > > Commit: Roger Pau Monné > > > > CommitDate: 2021-08-12 07:18:32 +0000 > > > > > > > > xen: use correct cache attributes for Xen specific memory regions > > > > bus_activate_resource maps memory regions as uncacheable on x86, which > > > > is more strict than required for regions allocated using xenmem_alloc, > > > > so don't rely on bus_activate_resource and instead map the region > > > > using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. > > > > Sponsored by: Citrix Systems R&D > > > > > > It would probably be cleaner to use bus_map_resource() for this instead. It > > > would mean you would have to use a structure that writes to as the argument > > > to bus_read/write_* instead of using the resource directly. > > > > Those regions are usually handled to other subsystems of the kernel. > > They are mostly used to map memory from other domains and then perform > > IO on their behalf (like blkback and netback do), so it's not really > > possible to assert that all users of the regions would use > > bus_read/write_* to access them. > > > > I could however switch to using bus_map_resource if I can pass the > > desired memory cache attribute and get a linear address back. It looks > > like resource_map_request parameter allows to select the cache > > attribute. > > Yes, one of the use case for bus_map_resource is to permit passing a > non-default memory attribute. (It also permits mapping sub-ranges, but > that isn't applicable in this case.) The 'r_vaddr' in the resource_map > is the equivalent of rman_get_addr. It'd be a little cleaner (and > perhaps friendly to future changes in this area) if your clients used > the 'r_vaddr' from the resource_map directly instead of using > rman_set_virtual() on the original resource. (At some point I would like > to have each 'struct resource' keep a list of all the mappings created > from it and to forcefully invalidate/free any existing mappings that > still remain when a 'struct resource' is freed. I imagine as part of > that I might end up with some assertions about the embedded resource > fields in the 'struct resource' being self-consistent). Does the following diff seem better: diff --git a/sys/dev/xen/bus/xenpv.c b/sys/dev/xen/bus/xenpv.c index 91004039a85e..748ead7f2f41 100644 --- a/sys/dev/xen/bus/xenpv.c +++ b/sys/dev/xen/bus/xenpv.c @@ -120,7 +120,8 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size) { struct resource *res; vm_paddr_t phys_addr; - void *virt_addr; + struct resource_map_request margs; + struct resource_map map; int error; res = bus_alloc_resource(child, SYS_RES_MEMORY, res_id, LOW_MEM_LIMIT, @@ -135,9 +136,16 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size) bus_release_resource(child, SYS_RES_MEMORY, *res_id, res); return (NULL); } - virt_addr = pmap_mapdev_attr(phys_addr, size, VM_MEMATTR_XEN); - KASSERT(virt_addr != NULL, ("Failed to create linear mappings")); - rman_set_virtual(res, virt_addr); + + resource_init_map_request(&margs); + margs.memattr = VM_MEMATTR_XEN; + error = bus_map_resource(child, SYS_RES_MEMORY, res, &margs, &map); + if (error != 0) { + vm_phys_fictitious_unreg_range(phys_addr, phys_addr + size); + bus_release_resource(child, SYS_RES_MEMORY, *res_id, res); + return (NULL); + } + rman_set_mapping(res, &map); return (res); } @@ -146,14 +154,14 @@ static int xenpv_free_physmem(device_t dev, device_t child, int res_id, struct resource *res) { vm_paddr_t phys_addr; - vm_offset_t virt_addr; + struct resource_map map; size_t size; phys_addr = rman_get_start(res); size = rman_get_size(res); - virt_addr = (vm_offset_t)rman_get_virtual(res); + rman_get_mapping(res, &map); - pmap_unmapdev(virt_addr, size); + bus_unmap_resource(child, SYS_RES_MEMORY, res, &map); vm_phys_fictitious_unreg_range(phys_addr, phys_addr + size); return (bus_release_resource(child, SYS_RES_MEMORY, res_id, res)); } I also wonder if rman_set_mapping should clear the RF_UNMAPPED flag from the resource? Or the content of the flags field is opaque from rman PoV and it should be the caller of rman_set_mapping the one to clear the flag? (xenpv_alloc_physmem in the code above) It's kind of pointless to copy the bus_unmap_resource logic in xenpv_free_physmem when it could be done by bus_release_resource if the RF_UNMAPPED flag was cleared. Thanks, Roger. From owner-dev-commits-src-all@freebsd.org Thu Aug 12 17:02:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1DF5966F801; Thu, 12 Aug 2021 17:02: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 4GltKK0Pgsz3JN2; Thu, 12 Aug 2021 17:02: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 DFE4526B05; Thu, 12 Aug 2021 17:02: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 17CH2SUE017741; Thu, 12 Aug 2021 17:02:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CH2SxC017740; Thu, 12 Aug 2021 17:02:28 GMT (envelope-from git) Date: Thu, 12 Aug 2021 17:02:28 GMT Message-Id: <202108121702.17CH2SxC017740@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 909459c2eda4 - stable/13 - bhyve: Register new kevents synchronously. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 909459c2eda4a6bc45e1fe5ff3da992e9614392b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 17:02:29 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=909459c2eda4a6bc45e1fe5ff3da992e9614392b commit 909459c2eda4a6bc45e1fe5ff3da992e9614392b Author: John Baldwin AuthorDate: 2021-06-12 00:58:54 +0000 Commit: John Baldwin CommitDate: 2021-08-12 15:56:13 +0000 bhyve: Register new kevents synchronously. Change mevent_add*() to synchronously add the new kevent. This permits reporting event registration failures to the caller and avoids failing the registration of other, unrelated events queued up in the same batch. Reviewed by: grehan, markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30502 (cherry picked from commit e8424e2947dd8a0e1d3f08295432941b5c5aafb9) --- usr.sbin/bhyve/mevent.c | 96 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/usr.sbin/bhyve/mevent.c b/usr.sbin/bhyve/mevent.c index 2e9059837011..a394b7c5d69f 100644 --- a/usr.sbin/bhyve/mevent.c +++ b/usr.sbin/bhyve/mevent.c @@ -64,8 +64,10 @@ __FBSDID("$FreeBSD$"); #define MEVENT_MAX 64 static pthread_t mevent_tid; +static pthread_once_t mevent_once = PTHREAD_ONCE_INIT; static int mevent_timid = 43; static int mevent_pipefd[2]; +static int mfd; static pthread_mutex_t mevent_lmutex = PTHREAD_MUTEX_INITIALIZER; struct mevent { @@ -124,6 +126,26 @@ mevent_notify(void) } } +static void +mevent_init(void) +{ +#ifndef WITHOUT_CAPSICUM + cap_rights_t rights; +#endif + + mfd = kqueue(); + assert(mfd > 0); + +#ifndef WITHOUT_CAPSICUM + cap_rights_init(&rights, CAP_KQUEUE); + if (caph_rights_limit(mfd, &rights) == -1) + errx(EX_OSERR, "Unable to apply rights for sandbox"); +#endif + + LIST_INIT(&change_head); + LIST_INIT(&global_head); +} + static int mevent_kq_filter(struct mevent *mevp) { @@ -159,8 +181,24 @@ mevent_kq_fflags(struct mevent *mevp) return (0); } +static void +mevent_populate(struct mevent *mevp, struct kevent *kev) +{ + if (mevp->me_type == EVF_TIMER) { + kev->ident = mevp->me_timid; + kev->data = mevp->me_msecs; + } else { + kev->ident = mevp->me_fd; + kev->data = 0; + } + kev->filter = mevent_kq_filter(mevp); + kev->flags = mevent_kq_flags(mevp); + kev->fflags = mevent_kq_fflags(mevp); + kev->udata = mevp; +} + static int -mevent_build(int mfd, struct kevent *kev) +mevent_build(struct kevent *kev) { struct mevent *mevp, *tmpp; int i; @@ -177,17 +215,8 @@ mevent_build(int mfd, struct kevent *kev) */ close(mevp->me_fd); } else { - if (mevp->me_type == EVF_TIMER) { - kev[i].ident = mevp->me_timid; - kev[i].data = mevp->me_msecs; - } else { - kev[i].ident = mevp->me_fd; - kev[i].data = 0; - } - kev[i].filter = mevent_kq_filter(mevp); - kev[i].flags = mevent_kq_flags(mevp); - kev[i].fflags = mevent_kq_fflags(mevp); - kev[i].udata = mevp; + assert((mevp->me_state & EV_ADD) == 0); + mevent_populate(mevp, &kev[i]); i++; } @@ -197,12 +226,6 @@ mevent_build(int mfd, struct kevent *kev) if (mevp->me_state & EV_DELETE) { free(mevp); } else { - /* - * We need to add the event only once, so we can - * reset the EV_ADD bit after it has been propagated - * to the kevent() arguments the first time. - */ - mevp->me_state &= ~EV_ADD; LIST_INSERT_HEAD(&global_head, mevp, me_list); } @@ -234,7 +257,9 @@ mevent_add_state(int tfd, enum ev_type type, void (*func)(int, enum ev_type, void *), void *param, int state) { + struct kevent kev; struct mevent *lp, *mevp; + int ret; if (tfd < 0 || func == NULL) { return (NULL); @@ -242,6 +267,8 @@ mevent_add_state(int tfd, enum ev_type type, mevp = NULL; + pthread_once(&mevent_once, mevent_init); + mevent_qlock(); /* @@ -262,7 +289,7 @@ mevent_add_state(int tfd, enum ev_type type, } /* - * Allocate an entry, populate it, and add it to the change list. + * Allocate an entry and populate it. */ mevp = calloc(1, sizeof(struct mevent)); if (mevp == NULL) { @@ -277,11 +304,22 @@ mevent_add_state(int tfd, enum ev_type type, mevp->me_type = type; mevp->me_func = func; mevp->me_param = param; - - LIST_INSERT_HEAD(&change_head, mevp, me_list); - mevp->me_cq = 1; mevp->me_state = state; - mevent_notify(); + + /* + * Try to add the event. If this fails, report the failure to + * the caller. + */ + mevent_populate(mevp, &kev); + ret = kevent(mfd, &kev, 1, NULL, 0, NULL); + if (ret == -1) { + free(mevp); + mevp = NULL; + goto exit; + } + + mevp->me_state &= ~EV_ADD; + LIST_INSERT_HEAD(&global_head, mevp, me_list); exit: mevent_qunlock(); @@ -415,7 +453,6 @@ mevent_dispatch(void) struct kevent changelist[MEVENT_MAX]; struct kevent eventlist[MEVENT_MAX]; struct mevent *pipev; - int mfd; int numev; int ret; #ifndef WITHOUT_CAPSICUM @@ -425,14 +462,7 @@ mevent_dispatch(void) mevent_tid = pthread_self(); mevent_set_name(); - mfd = kqueue(); - assert(mfd > 0); - -#ifndef WITHOUT_CAPSICUM - cap_rights_init(&rights, CAP_KQUEUE); - if (caph_rights_limit(mfd, &rights) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); -#endif + pthread_once(&mevent_once, mevent_init); /* * Open the pipe that will be used for other threads to force @@ -466,7 +496,7 @@ mevent_dispatch(void) * to eliminate the extra syscall. Currently better for * debug. */ - numev = mevent_build(mfd, changelist); + numev = mevent_build(changelist); if (numev) { ret = kevent(mfd, changelist, numev, NULL, 0, NULL); if (ret == -1) { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 17:02:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 53F8566F1E4; Thu, 12 Aug 2021 17:02: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 4GltKL16Y9z3JN7; Thu, 12 Aug 2021 17:02: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 0AA3626B81; Thu, 12 Aug 2021 17:02: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 17CH2TQ3017772; Thu, 12 Aug 2021 17:02:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CH2TVH017771; Thu, 12 Aug 2021 17:02:29 GMT (envelope-from git) Date: Thu, 12 Aug 2021 17:02:29 GMT Message-Id: <202108121702.17CH2TVH017771@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: d7e2c1479ccf - stable/13 - bhyve: Add support for EVFILT_VNODE mevents. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d7e2c1479ccf5bbbe7d80c203e05300353d24e52 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 17:02:30 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d7e2c1479ccf5bbbe7d80c203e05300353d24e52 commit d7e2c1479ccf5bbbe7d80c203e05300353d24e52 Author: John Baldwin AuthorDate: 2021-06-12 00:59:13 +0000 Commit: John Baldwin CommitDate: 2021-08-12 15:56:18 +0000 bhyve: Add support for EVFILT_VNODE mevents. This allows registering an event to watch for changes to a file's attributes. This is a bit imperfect as it would be nice to have a way to determine if an fd can use EVFILT_VNODE successfully. mevent's current structure does not permit that and a failure to register a single kevent impacts several other kevents. Reviewed by: grehan, markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30503 (cherry picked from commit 67d60dcce62c08250dceedaf761cb48bc74c75a4) --- usr.sbin/bhyve/mevent.c | 33 ++++++++++++++++++++++++++++----- usr.sbin/bhyve/mevent.h | 9 ++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bhyve/mevent.c b/usr.sbin/bhyve/mevent.c index a394b7c5d69f..0c5351cd31a9 100644 --- a/usr.sbin/bhyve/mevent.c +++ b/usr.sbin/bhyve/mevent.c @@ -80,6 +80,7 @@ struct mevent { int me_cq; int me_state; /* Desired kevent flags. */ int me_closefd; + int me_fflags; LIST_ENTRY(mevent) me_list; }; @@ -165,6 +166,9 @@ mevent_kq_filter(struct mevent *mevp) if (mevp->me_type == EVF_SIGNAL) retval = EVFILT_SIGNAL; + if (mevp->me_type == EVF_VNODE) + retval = EVFILT_VNODE; + return (retval); } @@ -177,8 +181,18 @@ mevent_kq_flags(struct mevent *mevp) static int mevent_kq_fflags(struct mevent *mevp) { - /* XXX nothing yet, perhaps EV_EOF for reads ? */ - return (0); + int retval; + + retval = 0; + + switch (mevp->me_type) { + case EVF_VNODE: + if ((mevp->me_fflags & EVFF_ATTRIB) != 0) + retval |= NOTE_ATTRIB; + break; + } + + return (retval); } static void @@ -255,7 +269,7 @@ mevent_handle(struct kevent *kev, int numev) static struct mevent * mevent_add_state(int tfd, enum ev_type type, void (*func)(int, enum ev_type, void *), void *param, - int state) + int state, int fflags) { struct kevent kev; struct mevent *lp, *mevp; @@ -305,6 +319,7 @@ mevent_add_state(int tfd, enum ev_type type, mevp->me_func = func; mevp->me_param = param; mevp->me_state = state; + mevp->me_fflags = fflags; /* * Try to add the event. If this fails, report the failure to @@ -332,7 +347,15 @@ mevent_add(int tfd, enum ev_type type, void (*func)(int, enum ev_type, void *), void *param) { - return (mevent_add_state(tfd, type, func, param, EV_ADD)); + return (mevent_add_state(tfd, type, func, param, EV_ADD, 0)); +} + +struct mevent * +mevent_add_flags(int tfd, enum ev_type type, int fflags, + void (*func)(int, enum ev_type, void *), void *param) +{ + + return (mevent_add_state(tfd, type, func, param, EV_ADD, fflags)); } struct mevent * @@ -340,7 +363,7 @@ mevent_add_disabled(int tfd, enum ev_type type, void (*func)(int, enum ev_type, void *), void *param) { - return (mevent_add_state(tfd, type, func, param, EV_ADD | EV_DISABLE)); + return (mevent_add_state(tfd, type, func, param, EV_ADD | EV_DISABLE, 0)); } static int diff --git a/usr.sbin/bhyve/mevent.h b/usr.sbin/bhyve/mevent.h index 503ec415a3b5..a26293867a09 100644 --- a/usr.sbin/bhyve/mevent.h +++ b/usr.sbin/bhyve/mevent.h @@ -35,14 +35,21 @@ enum ev_type { EVF_READ, EVF_WRITE, EVF_TIMER, - EVF_SIGNAL + EVF_SIGNAL, + EVF_VNODE, }; +/* Filter flags for EVF_VNODE */ +#define EVFF_ATTRIB 0x0001 + struct mevent; struct mevent *mevent_add(int fd, enum ev_type type, void (*func)(int, enum ev_type, void *), void *param); +struct mevent *mevent_add_flags(int fd, enum ev_type type, int fflags, + void (*func)(int, enum ev_type, void *), + void *param); struct mevent *mevent_add_disabled(int fd, enum ev_type type, void (*func)(int, enum ev_type, void *), void *param); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 17:02:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B522366F1E6; Thu, 12 Aug 2021 17:02: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 4GltKM1zmhz3JQb; Thu, 12 Aug 2021 17:02: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 1C8CE26ACF; Thu, 12 Aug 2021 17:02: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 17CH2V0w018339; Thu, 12 Aug 2021 17:02:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CH2Urj018332; Thu, 12 Aug 2021 17:02:30 GMT (envelope-from git) Date: Thu, 12 Aug 2021 17:02:30 GMT Message-Id: <202108121702.17CH2Urj018332@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 0f01337e3af4 - stable/13 - bhyve: Add support for handling disk resize events to block_if. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0f01337e3af4c013f3ef81401a56d420fa4de997 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 17:02:31 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=0f01337e3af4c013f3ef81401a56d420fa4de997 commit 0f01337e3af4c013f3ef81401a56d420fa4de997 Author: John Baldwin AuthorDate: 2021-06-12 00:59:25 +0000 Commit: John Baldwin CommitDate: 2021-08-12 15:56:23 +0000 bhyve: Add support for handling disk resize events to block_if. Allow clients of blockif to register a resize callback handler. When a callback is registered, register an EVFILT_VNODE kevent watching the backing store for a change in the file's attributes. If the size has changed when the kevent fires, invoke the clients' callback. Currently resize detection is limited to backing stores that support EVFILT_VNODE kevents such as regular files. Reviewed by: grehan, markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30504 (cherry picked from commit 8794846a91c5429c612ba939c61ebf8f1ff1a628) --- usr.sbin/bhyve/block_if.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++- usr.sbin/bhyve/block_if.h | 5 ++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c index ae09bc71d622..98c0f9f5f38b 100644 --- a/usr.sbin/bhyve/block_if.c +++ b/usr.sbin/bhyve/block_if.c @@ -115,6 +115,9 @@ struct blockif_ctxt { pthread_cond_t bc_cond; pthread_cond_t bc_paused_cond; pthread_cond_t bc_work_done_cond; + blockif_resize_cb *bc_resize_cb; + void *bc_resize_cb_arg; + struct mevent *bc_resize_event; /* Request elements and free/pending/busy queues */ TAILQ_HEAD(, blockif_elem) bc_freeq; @@ -532,7 +535,7 @@ blockif_open(nvlist_t *nvl, const char *ident) #ifndef WITHOUT_CAPSICUM cap_rights_init(&rights, CAP_FSYNC, CAP_IOCTL, CAP_READ, CAP_SEEK, - CAP_WRITE); + CAP_WRITE, CAP_FSTAT, CAP_EVENT); if (ro) cap_rights_clear(&rights, CAP_FSYNC, CAP_WRITE); @@ -643,6 +646,62 @@ err: return (NULL); } +static void +blockif_resized(int fd, enum ev_type type, void *arg) +{ + struct blockif_ctxt *bc; + struct stat sb; + + if (fstat(fd, &sb) != 0) + return; + + bc = arg; + pthread_mutex_lock(&bc->bc_mtx); + if (sb.st_size != bc->bc_size) { + bc->bc_size = sb.st_size; + bc->bc_resize_cb(bc, bc->bc_resize_cb_arg, bc->bc_size); + } + pthread_mutex_unlock(&bc->bc_mtx); +} + +int +blockif_register_resize_callback(struct blockif_ctxt *bc, blockif_resize_cb *cb, + void *cb_arg) +{ + struct stat sb; + int err; + + if (cb == NULL) + return (EINVAL); + + pthread_mutex_lock(&bc->bc_mtx); + if (bc->bc_resize_cb != NULL) { + err = EBUSY; + goto out; + } + + assert(bc->bc_closing == 0); + + if (fstat(bc->bc_fd, &sb) != 0) { + err = errno; + goto out; + } + + bc->bc_resize_event = mevent_add_flags(bc->bc_fd, EVF_VNODE, + EVFF_ATTRIB, blockif_resized, bc); + if (bc->bc_resize_event == NULL) { + err = ENXIO; + goto out; + } + + bc->bc_resize_cb = cb; + bc->bc_resize_cb_arg = cb_arg; +out: + pthread_mutex_unlock(&bc->bc_mtx); + + return (err); +} + static int blockif_request(struct blockif_ctxt *bc, struct blockif_req *breq, enum blockop op) @@ -796,6 +855,8 @@ blockif_close(struct blockif_ctxt *bc) */ pthread_mutex_lock(&bc->bc_mtx); bc->bc_closing = 1; + if (bc->bc_resize_event != NULL) + mevent_disable(bc->bc_resize_event); pthread_mutex_unlock(&bc->bc_mtx); pthread_cond_broadcast(&bc->bc_cond); for (i = 0; i < BLOCKIF_NUMTHR; i++) diff --git a/usr.sbin/bhyve/block_if.h b/usr.sbin/bhyve/block_if.h index 87ae4d169969..0407ff43cf94 100644 --- a/usr.sbin/bhyve/block_if.h +++ b/usr.sbin/bhyve/block_if.h @@ -63,8 +63,13 @@ struct blockif_req { }; struct blockif_ctxt; + +typedef void blockif_resize_cb(struct blockif_ctxt *, void *, size_t); + int blockif_legacy_config(nvlist_t *nvl, const char *opts); struct blockif_ctxt *blockif_open(nvlist_t *nvl, const char *ident); +int blockif_register_resize_callback(struct blockif_ctxt *bc, + blockif_resize_cb *cb, void *cb_arg); off_t blockif_size(struct blockif_ctxt *bc); void blockif_chs(struct blockif_ctxt *bc, uint16_t *c, uint8_t *h, uint8_t *s); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 17:02:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6CB8D66F805; Thu, 12 Aug 2021 17:02: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 4GltKN2HSBz3JQh; Thu, 12 Aug 2021 17:02: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 358A226AD0; Thu, 12 Aug 2021 17:02: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 17CH2WMF018542; Thu, 12 Aug 2021 17:02:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CH2WWN018541; Thu, 12 Aug 2021 17:02:32 GMT (envelope-from git) Date: Thu, 12 Aug 2021 17:02:32 GMT Message-Id: <202108121702.17CH2WWN018541@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: e8b442c74c90 - stable/13 - bhyve: Split out a lower-level helper for VirtIO interrupts. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e8b442c74c903dfd020a83ebba7d1b3c2c281aba Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 17:02:32 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e8b442c74c903dfd020a83ebba7d1b3c2c281aba commit e8b442c74c903dfd020a83ebba7d1b3c2c281aba Author: John Baldwin AuthorDate: 2021-06-12 00:59:35 +0000 Commit: John Baldwin CommitDate: 2021-08-12 17:01:25 +0000 bhyve: Split out a lower-level helper for VirtIO interrupts. This allows device models to assert VirtIO interrupts for reasons other than publishing changes to a VirtIO ring such as configuration changes. Reviewed by: grehan, markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30505 (cherry picked from commit c06676bee3d228ac18c5ed3604304e932eb84c1e) --- usr.sbin/bhyve/virtio.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h index e03fd5f710d1..5b2cf6fe2cc8 100644 --- a/usr.sbin/bhyve/virtio.h +++ b/usr.sbin/bhyve/virtio.h @@ -332,24 +332,35 @@ vq_has_descs(struct vqueue_info *vq) } /* - * Deliver an interrupt to guest on the given virtual queue - * (if possible, or a generic MSI interrupt if not using MSI-X). + * Deliver an interrupt to the guest for a specific MSI-X queue or + * event. */ static inline void -vq_interrupt(struct virtio_softc *vs, struct vqueue_info *vq) +vi_interrupt(struct virtio_softc *vs, uint8_t isr, uint16_t msix_idx) { if (pci_msix_enabled(vs->vs_pi)) - pci_generate_msix(vs->vs_pi, vq->vq_msix_idx); + pci_generate_msix(vs->vs_pi, msix_idx); else { VS_LOCK(vs); - vs->vs_isr |= VIRTIO_PCI_ISR_INTR; + vs->vs_isr |= isr; pci_generate_msi(vs->vs_pi, 0); pci_lintr_assert(vs->vs_pi); VS_UNLOCK(vs); } } +/* + * Deliver an interrupt to the guest on the given virtual queue (if + * possible, or a generic MSI interrupt if not using MSI-X). + */ +static inline void +vq_interrupt(struct virtio_softc *vs, struct vqueue_info *vq) +{ + + vi_interrupt(vs, VIRTIO_PCI_ISR_INTR, vq->vq_msix_idx); +} + static inline void vq_kick_enable(struct vqueue_info *vq) { From owner-dev-commits-src-all@freebsd.org Thu Aug 12 17:02:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A850966F886; Thu, 12 Aug 2021 17:02: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 4GltKP3zlqz3JNf; Thu, 12 Aug 2021 17:02: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 5F75D2692A; Thu, 12 Aug 2021 17:02: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 17CH2XIL018566; Thu, 12 Aug 2021 17:02:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CH2Xmr018565; Thu, 12 Aug 2021 17:02:33 GMT (envelope-from git) Date: Thu, 12 Aug 2021 17:02:33 GMT Message-Id: <202108121702.17CH2Xmr018565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 86139cc75a55 - stable/13 - bhyve vtblk: Inform guests of disk resize events. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 86139cc75a5506bde6a4b180c024294e470d5cb6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 17:02:33 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=86139cc75a5506bde6a4b180c024294e470d5cb6 commit 86139cc75a5506bde6a4b180c024294e470d5cb6 Author: John Baldwin AuthorDate: 2021-06-12 00:59:46 +0000 Commit: John Baldwin CommitDate: 2021-08-12 17:01:34 +0000 bhyve vtblk: Inform guests of disk resize events. Register a resize callback with the blockif interface. When the callback fires, update the size of the disk and notify the guest via a configuration change interrupt. Reviewed by: grehan, markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30506 (cherry picked from commit 2349cda44fea17c089b026e743ec8f03199019eb) --- usr.sbin/bhyve/pci_virtio_block.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c index 8a172c54eda7..3718b2d7eff0 100644 --- a/usr.sbin/bhyve/pci_virtio_block.c +++ b/usr.sbin/bhyve/pci_virtio_block.c @@ -3,7 +3,7 @@ * * Copyright (c) 2011 NetApp, Inc. * All rights reserved. - * Copyright 2020 Joyent, Inc. + * Copyright 2020-2021 Joyent, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -436,6 +436,18 @@ pci_vtblk_notify(void *vsc, struct vqueue_info *vq) pci_vtblk_proc(sc, vq); } +static void +pci_vtblk_resized(struct blockif_ctxt *bctxt, void *arg, size_t new_size) +{ + struct pci_vtblk_softc *sc; + + sc = arg; + + sc->vbsc_cfg.vbc_capacity = new_size / VTBLK_BSIZE; /* 512-byte units */ + vi_interrupt(&sc->vbsc_vs, VIRTIO_PCI_ISR_CONFIG, + sc->vbsc_vs.vs_msix_cfg_idx); +} + static int pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) { @@ -541,6 +553,7 @@ pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) return (1); } vi_set_io_bar(&sc->vbsc_vs, 0); + blockif_register_resize_callback(sc->bc, pci_vtblk_resized, sc); return (0); } From owner-dev-commits-src-all@freebsd.org Thu Aug 12 17:29:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8567166FE6D; Thu, 12 Aug 2021 17:29:36 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta001.cacentral1.a.cloudfilter.net (omta001.cacentral1.a.cloudfilter.net [3.97.99.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gltwc213cz3LRM; Thu, 12 Aug 2021 17:29:36 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id EBYmmixH7FRDpEEWNmgQ9A; Thu, 12 Aug 2021 17:29:35 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id EEWLmaP2VM8olEEWMmf8LB; Thu, 12 Aug 2021 17:29:35 +0000 X-Authority-Analysis: v=2.4 cv=Ua6U9IeN c=1 sm=1 tr=0 ts=61155a7f a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=kj9zAlcOel0A:10 a=MhDmnRu9jo8A:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=Dk8YGwJLn-YpwTmex9IA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 7048151F; Thu, 12 Aug 2021 10:29:32 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 17CHTWfb033244; Thu, 12 Aug 2021 10:29:32 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202108121729.17CHTWfb033244@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Ed Maste cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: d20e9e02db3d - main - ar: diff reduction against ELF Tool Chain In-reply-to: <202108112313.17BNDL1g093210@gitrepo.freebsd.org> References: <202108112313.17BNDL1g093210@gitrepo.freebsd.org> Comments: In-reply-to Ed Maste message dated "Wed, 11 Aug 2021 23:13:21 +0000." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 12 Aug 2021 10:29:32 -0700 X-CMAE-Envelope: MS4xfJAglP3KywsO72c8cOy/Y3MeArYoPhdCj/h40dNV820yOcyRq2Sw9FWBA2OkQPVkcbyMAkRWeGPYcunmy8EP0628M1NWID84XI9A32X4JVrwoye76eM/ 3WiNfehnd6AjnKD04hWJDqAXxzTI7pVycvM3lY1tDiVNWjmQaNtbz0r+ATEei6j7HJ8xc7RbvPjBqx6FI4CgA+xUmrSXNArxGFnAa6zOWMC+SBAcGsVj/sZd hwCzYa3vgYOdCoz6ZKfKxkpvE9arn3izrtfGDJXpFFJZju5GCaRaHCy+NV1S441wa2xBzm4xl78QZC9l0jfBYF+zztgN6ppC5lgDNHbdrNM= X-Rspamd-Queue-Id: 4Gltwc213cz3LRM X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 17:29:36 -0000 In message <202108112313.17BNDL1g093210@gitrepo.freebsd.org>, Ed Maste writes: > The branch main has been updated by emaste: > > URL: https://cgit.FreeBSD.org/src/commit/?id=d20e9e02db3dde383c3de1ce8cec3a8c > 35b3eee6 > > commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6 > Author: Ed Maste > AuthorDate: 2021-08-04 13:54:17 +0000 > Commit: Ed Maste > CommitDate: 2021-08-11 23:12:46 +0000 > > ar: diff reduction against ELF Tool Chain > > - Drop exit status from bsdar_errc. ELF Tool Chain always returns > EXIT_FAILURE in bsdar_errc. > > - Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive > directly. > > Obtained from: ELF Tool Chain > Reviewed by: markj > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D31496 > --- > usr.bin/ar/acpyacc.y | 48 ++++++++++------------ > usr.bin/ar/ar.c | 52 ++++++++---------------- > usr.bin/ar/ar.h | 18 +++------ > usr.bin/ar/read.c | 34 ++++------------ > usr.bin/ar/util.c | 4 +- > usr.bin/ar/write.c | 111 +++++++++++++++---------------------------------- > -- > 6 files changed, 85 insertions(+), 182 deletions(-) > [...] > diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h > index 21b3a669a943..bcccf93a6016 100644 > --- a/usr.bin/ar/ar.h > +++ b/usr.bin/ar/ar.h > @@ -54,7 +54,7 @@ > */ > #define AC(CALL) do { > \ > if ((CALL)) \ > - bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s", \ > + bsdar_errc(bsdar, archive_errno(a), "%s", \ > archive_error_string(a)); \ > } while (0) > > @@ -114,16 +114,8 @@ struct bsdar { > TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ > }; > > -void bsdar_errc(struct bsdar *, int _eval, int _code, > - const char *fmt, ...) __dead2; > -void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); > -int ar_mode_d(struct bsdar *bsdar); > -int ar_mode_m(struct bsdar *bsdar); > -int ar_mode_p(struct bsdar *bsdar); > -int ar_mode_q(struct bsdar *bsdar); > -int ar_mode_r(struct bsdar *bsdar); > -int ar_mode_s(struct bsdar *bsdar); > -int ar_mode_t(struct bsdar *bsdar); > -int ar_mode_x(struct bsdar *bsdar); > -int ar_mode_A(struct bsdar *bsdar); > void ar_mode_script(struct bsdar *ar); > +int ar_read_archive(struct bsdar *ar, int mode); > +int ar_write_archive(struct bsdar *ar, int mode); > +void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __dead2; > +void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); > diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c > index 04130b859c32..81e0bfce1b7e 100644 > --- a/usr.bin/ar/read.c > +++ b/usr.bin/ar/read.c > @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -42,34 +43,11 @@ __FBSDID("$FreeBSD$"); > > #include "ar.h" > > -static int read_archive(struct bsdar *bsdar, char mode); > - > -int > -ar_mode_p(struct bsdar *bsdar) > -{ > - > - return (read_archive(bsdar, 'p')); > -} > - > -int > -ar_mode_t(struct bsdar *bsdar) > -{ > - > - return (read_archive(bsdar, 't')); > -} > - > -int > -ar_mode_x(struct bsdar *bsdar) > -{ > - > - return (read_archive(bsdar, 'x')); > -} > - > /* > * Handle read modes: 'x', 't' and 'p'. > */ > -static int > -read_archive(struct bsdar *bsdar, char mode) > +int > +ar_read_archive(struct bsdar *bsdar, int mode) > { > struct archive *a; > struct archive_entry *entry; > @@ -87,8 +65,10 @@ read_archive(struct bsdar *bsdar, char mode) > char find; > int exitcode, flags, r, i; > > + assert(mode == 'p' || mode == 't' || mode == 'x'); This is causing port build failures: ar -cq libutil.a allwhite.o inctest.o letter.o triedump.o triepdmp.o trieplk.o trierset.o upcmp8.o upstrcmp.o wchar.o conutil.o error.o exit.o itoa.o lower.o malloc.o openchk.o trie.o triecnt.o upper.o whitesp.o ranlib libutil.a Assertion failed: (mode == 'p' || mode == 't' || mode == 'x'), function ar_read_archive, file /usr/local/poudriere/jails/main-amd64/usr/src/usr.bin/ ar/read.c, line 68. *** Signal 6 Notice at line 154 of ar.c that ar_read_archive() is called with mode='s'. This certainly triggers the assertion. The assertion may also trigger by the call to ar_read_archive() at line 330 of ar.c where mode is set to bsdar->mode. > + > if ((a = archive_read_new()) == NULL) > - bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed"); > + bsdar_errc(bsdar, 0, "archive_read_new failed"); > archive_read_support_format_ar(a); > AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ)); > > @@ -122,7 +102,7 @@ read_archive(struct bsdar *bsdar, char mode) > if (*av == NULL) > continue; > if ((bname = basename(*av)) == NULL) > - bsdar_errc(bsdar, EXIT_FAILURE, errno, > + bsdar_errc(bsdar, errno, > "basename failed"); > if (strcmp(bname, name) != 0) > continue; [...] -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-dev-commits-src-all@freebsd.org Thu Aug 12 18:27:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A4455670DAF; Thu, 12 Aug 2021 18:27: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 4GlwCL4CFYz3PHV; Thu, 12 Aug 2021 18:27: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 748F227677; Thu, 12 Aug 2021 18:27: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 17CIRQ51025988; Thu, 12 Aug 2021 18:27:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CIRQ1P025987; Thu, 12 Aug 2021 18:27:26 GMT (envelope-from git) Date: Thu, 12 Aug 2021 18:27:26 GMT Message-Id: <202108121827.17CIRQ1P025987@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: c5bf58add0d5 - main - Revert "ar: diff reduction against ELF Tool Chain" 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/main X-Git-Reftype: branch X-Git-Commit: c5bf58add0d523fc6e6546f3fc10d0c8b972e8e7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 18:27:26 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=c5bf58add0d523fc6e6546f3fc10d0c8b972e8e7 commit c5bf58add0d523fc6e6546f3fc10d0c8b972e8e7 Author: Ed Maste AuthorDate: 2021-08-12 18:26:37 +0000 Commit: Ed Maste CommitDate: 2021-08-12 18:26:37 +0000 Revert "ar: diff reduction against ELF Tool Chain" This reverts commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6. It caused port build failures. Reported by: cy --- usr.bin/ar/acpyacc.y | 48 ++++++++++++---------- usr.bin/ar/ar.c | 52 ++++++++++++++++-------- usr.bin/ar/ar.h | 18 ++++++--- usr.bin/ar/read.c | 34 ++++++++++++---- usr.bin/ar/util.c | 4 +- usr.bin/ar/write.c | 111 ++++++++++++++++++++++++++++++++++++--------------- 6 files changed, 182 insertions(+), 85 deletions(-) diff --git a/usr.bin/ar/acpyacc.y b/usr.bin/ar/acpyacc.y index 34156e1d2d58..5d4eb9fb6b37 100644 --- a/usr.bin/ar/acpyacc.y +++ b/usr.bin/ar/acpyacc.y @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "ar.h" @@ -249,7 +250,7 @@ arscp_open(char *fname) int r; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, 0, "archive_read_new failed"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, fname, DEF_BLKSZ)); if ((r = archive_read_next_header(a, &entry))) @@ -276,15 +277,15 @@ arscp_create(char *in, char *out) /* Delete previously created temporary archive, if any. */ if (tmpac) { if (unlink(tmpac) < 0) - bsdar_errc(bsdar, errno, "unlink failed"); + bsdar_errc(bsdar, EX_IOERR, errno, "unlink failed"); free(tmpac); } tmpac = strdup(TEMPLATE); if (tmpac == NULL) - bsdar_errc(bsdar, errno, "strdup failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); if ((ofd = mkstemp(tmpac)) < 0) - bsdar_errc(bsdar, errno, "mkstemp failed"); + bsdar_errc(bsdar, EX_IOERR, errno, "mkstemp failed"); if (in) { /* @@ -307,7 +308,8 @@ arscp_create(char *in, char *out) * (archive with only global header) */ if ((a = archive_write_new()) == NULL) - bsdar_errc(bsdar, 0, "archive_write_new failed"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, + "archive_write_new failed"); archive_write_set_format_ar_svr4(a); AC(archive_write_open_fd(a, ofd)); AC(archive_write_close(a)); @@ -348,7 +350,7 @@ arscp_copy(int ifd, int ofd) } } if (munmap(p, sb.st_size) < 0) - bsdar_errc(bsdar, errno, "munmap failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "munmap failed"); if (bytes > 0) return (1); @@ -367,7 +369,7 @@ arscp_addlib(char *archive, struct list *list) return; arscp_mlist2argv(list); bsdar->addlib = archive; - ar_write_archive(bsdar, 'A'); + ar_mode_A(bsdar); arscp_free_argv(); arscp_free_mlist(list); } @@ -380,7 +382,7 @@ arscp_addmod(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_write_archive(bsdar, 'q'); + ar_mode_q(bsdar); arscp_free_argv(); arscp_free_mlist(list); } @@ -393,7 +395,7 @@ arscp_delete(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_write_archive(bsdar, 'd'); + ar_mode_d(bsdar); arscp_free_argv(); arscp_free_mlist(list); } @@ -406,7 +408,7 @@ arscp_extract(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_read_archive(bsdar, 'x'); + ar_mode_x(bsdar); arscp_free_argv(); arscp_free_mlist(list); } @@ -422,7 +424,7 @@ arscp_list(void) bsdar->argv = NULL; /* Always verbose. */ bsdar->options |= AR_V; - ar_read_archive(bsdar, 't'); + ar_mode_t(bsdar); bsdar->options &= ~AR_V; } @@ -437,7 +439,8 @@ arscp_dir(char *archive, struct list *list, char *rlt) if (rlt) { out = stdout; if ((stdout = fopen(rlt, "w")) == NULL) - bsdar_errc(bsdar, errno, "fopen %s failed", rlt); + bsdar_errc(bsdar, EX_IOERR, errno, + "fopen %s failed", rlt); } bsdar->filename = archive; @@ -449,12 +452,13 @@ arscp_dir(char *archive, struct list *list, char *rlt) } if (verbose) bsdar->options |= AR_V; - ar_read_archive(bsdar, 't'); + ar_mode_t(bsdar); bsdar->options &= ~AR_V; if (rlt) { if (fclose(stdout) == EOF) - bsdar_errc(bsdar, errno, "fclose %s failed", rlt); + bsdar_errc(bsdar, EX_IOERR, errno, + "fclose %s failed", rlt); stdout = out; free(rlt); } @@ -473,7 +477,7 @@ arscp_replace(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_write_archive(bsdar, 'r'); + ar_mode_r(bsdar); arscp_free_argv(); arscp_free_mlist(list); } @@ -486,7 +490,7 @@ arscp_save(void) if (target) { if (rename(tmpac, target) < 0) - bsdar_errc(bsdar, errno, "rename failed"); + bsdar_errc(bsdar, EX_IOERR, errno, "rename failed"); /* * mkstemp creates temp files with mode 0600, here we * set target archive mode per process umask. @@ -494,7 +498,7 @@ arscp_save(void) mask = umask(0); umask(mask); if (chmod(target, 0666 & ~mask) < 0) - bsdar_errc(bsdar, errno, "chmod failed"); + bsdar_errc(bsdar, EX_IOERR, errno, "chmod failed"); free(tmpac); free(target); tmpac = NULL; @@ -516,7 +520,7 @@ arscp_clear(void) if (target) { new_target = strdup(target); if (new_target == NULL) - bsdar_errc(bsdar, errno, "strdup failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); arscp_create(NULL, new_target); } } @@ -533,7 +537,7 @@ arscp_end(int eval) free(target); if (tmpac) { if (unlink(tmpac) == -1) - bsdar_errc(bsdar, errno, "unlink %s failed", + bsdar_errc(bsdar, EX_IOERR, errno, "unlink %s failed", tmpac); free(tmpac); } @@ -564,7 +568,7 @@ arscp_mlist(struct list *list, char *str) l = malloc(sizeof(*l)); if (l == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); l->str = str; l->next = list; @@ -606,12 +610,12 @@ arscp_mlist2argv(struct list *list) n = arscp_mlist_len(list); argv = malloc(n * sizeof(*argv)); if (argv == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); /* Note that module names are stored in reverse order in mlist. */ for(i = n - 1; i >= 0; i--, list = list->next) { if (list == NULL) - bsdar_errc(bsdar, errno, "invalid mlist"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "invalid mlist"); argv[i] = list->str; } diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c index 3012f81cfa97..b131163342a6 100644 --- a/usr.bin/ar/ar.c +++ b/usr.bin/ar/ar.c @@ -151,7 +151,7 @@ main(int argc, char **argv) bsdar->options |= AR_D; bsdar->options |= AR_S; while ((bsdar->filename = *argv++) != NULL) - if (ar_read_archive(bsdar, 's')) + if (ar_mode_s(bsdar)) exitcode = EXIT_FAILURE; exit(exitcode); @@ -162,7 +162,8 @@ main(int argc, char **argv) if (*argv[1] != '-') { len = strlen(argv[1]) + 2; if ((p = malloc(len)) == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EXIT_FAILURE, errno, + "malloc failed"); *p = '-'; (void)strlcpy(p + 1, argv[1], len - 1); argv[1] = p; @@ -262,20 +263,24 @@ main(int argc, char **argv) bsdar_usage(); if (bsdar->options & AR_A && bsdar->options & AR_B) - bsdar_errc(bsdar, 0, + bsdar_errc(bsdar, EXIT_FAILURE, 0, "only one of -a and -[bi] options allowed"); if (bsdar->options & AR_J && bsdar->options & AR_Z) - bsdar_errc(bsdar, 0, "only one of -j and -z options allowed"); + bsdar_errc(bsdar, EXIT_FAILURE, 0, + "only one of -j and -z options allowed"); if (bsdar->options & AR_S && bsdar->options & AR_SS) - bsdar_errc(bsdar, 0, "only one of -s and -S options allowed"); + bsdar_errc(bsdar, EXIT_FAILURE, 0, + "only one of -s and -S options allowed"); if (bsdar->options & (AR_A | AR_B)) { if (*argv == NULL) - bsdar_errc(bsdar, 0, "no position operand specified"); + bsdar_errc(bsdar, EXIT_FAILURE, 0, + "no position operand specified"); if ((bsdar->posarg = basename(*argv)) == NULL) - bsdar_errc(bsdar, errno, "basename failed"); + bsdar_errc(bsdar, EXIT_FAILURE, errno, + "basename failed"); argc--; argv++; } @@ -317,17 +322,32 @@ main(int argc, char **argv) if ((!bsdar->mode || strchr("ptx", bsdar->mode)) && bsdar->options & AR_S) { - exitcode = ar_write_archive(bsdar, 's'); + exitcode = ar_mode_s(bsdar); if (!bsdar->mode) exit(exitcode); } switch(bsdar->mode) { - case 'd': case 'm': case 'q': case 'r': - exitcode = ar_write_archive(bsdar, bsdar->mode); + case 'd': + exitcode = ar_mode_d(bsdar); break; - case 'p': case 't': case 'x': - exitcode = ar_read_archive(bsdar, bsdar->mode); + case 'm': + exitcode = ar_mode_m(bsdar); + break; + case 'p': + exitcode = ar_mode_p(bsdar); + break; + case 'q': + exitcode = ar_mode_q(bsdar); + break; + case 'r': + exitcode = ar_mode_r(bsdar); + break; + case 't': + exitcode = ar_mode_t(bsdar); + break; + case 'x': + exitcode = ar_mode_x(bsdar); break; default: bsdar_usage(); @@ -350,8 +370,8 @@ set_mode(struct bsdar *bsdar, char opt) { if (bsdar->mode != '\0' && bsdar->mode != opt) - bsdar_errc(bsdar, 0, "Can't specify both -%c and -%c", - opt, bsdar->mode); + bsdar_errc(bsdar, EXIT_FAILURE, 0, + "Can't specify both -%c and -%c", opt, bsdar->mode); bsdar->mode = opt; } @@ -360,8 +380,8 @@ only_mode(struct bsdar *bsdar, const char *opt, const char *valid_modes) { if (strchr(valid_modes, bsdar->mode) == NULL) - bsdar_errc(bsdar, 0, "Option %s is not permitted in mode -%c", - opt, bsdar->mode); + bsdar_errc(bsdar, EXIT_FAILURE, 0, + "Option %s is not permitted in mode -%c", opt, bsdar->mode); } static void diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h index bcccf93a6016..21b3a669a943 100644 --- a/usr.bin/ar/ar.h +++ b/usr.bin/ar/ar.h @@ -54,7 +54,7 @@ */ #define AC(CALL) do { \ if ((CALL)) \ - bsdar_errc(bsdar, archive_errno(a), "%s", \ + bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s", \ archive_error_string(a)); \ } while (0) @@ -114,8 +114,16 @@ struct bsdar { TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ }; -void ar_mode_script(struct bsdar *ar); -int ar_read_archive(struct bsdar *ar, int mode); -int ar_write_archive(struct bsdar *ar, int mode); -void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __dead2; +void bsdar_errc(struct bsdar *, int _eval, int _code, + const char *fmt, ...) __dead2; void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); +int ar_mode_d(struct bsdar *bsdar); +int ar_mode_m(struct bsdar *bsdar); +int ar_mode_p(struct bsdar *bsdar); +int ar_mode_q(struct bsdar *bsdar); +int ar_mode_r(struct bsdar *bsdar); +int ar_mode_s(struct bsdar *bsdar); +int ar_mode_t(struct bsdar *bsdar); +int ar_mode_x(struct bsdar *bsdar); +int ar_mode_A(struct bsdar *bsdar); +void ar_mode_script(struct bsdar *ar); diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c index 81e0bfce1b7e..04130b859c32 100644 --- a/usr.bin/ar/read.c +++ b/usr.bin/ar/read.c @@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -43,11 +42,34 @@ __FBSDID("$FreeBSD$"); #include "ar.h" +static int read_archive(struct bsdar *bsdar, char mode); + +int +ar_mode_p(struct bsdar *bsdar) +{ + + return (read_archive(bsdar, 'p')); +} + +int +ar_mode_t(struct bsdar *bsdar) +{ + + return (read_archive(bsdar, 't')); +} + +int +ar_mode_x(struct bsdar *bsdar) +{ + + return (read_archive(bsdar, 'x')); +} + /* * Handle read modes: 'x', 't' and 'p'. */ -int -ar_read_archive(struct bsdar *bsdar, int mode) +static int +read_archive(struct bsdar *bsdar, char mode) { struct archive *a; struct archive_entry *entry; @@ -65,10 +87,8 @@ ar_read_archive(struct bsdar *bsdar, int mode) char find; int exitcode, flags, r, i; - assert(mode == 'p' || mode == 't' || mode == 'x'); - if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, 0, "archive_read_new failed"); + bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ)); @@ -102,7 +122,7 @@ ar_read_archive(struct bsdar *bsdar, int mode) if (*av == NULL) continue; if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, errno, + bsdar_errc(bsdar, EXIT_FAILURE, errno, "basename failed"); if (strcmp(bname, name) != 0) continue; diff --git a/usr.bin/ar/util.c b/usr.bin/ar/util.c index b130d6195e47..1823c5eba84a 100644 --- a/usr.bin/ar/util.c +++ b/usr.bin/ar/util.c @@ -77,12 +77,12 @@ bsdar_verrc(struct bsdar *bsdar, int code, const char *fmt, va_list ap) } void -bsdar_errc(struct bsdar *bsdar, int code, const char *fmt, ...) +bsdar_errc(struct bsdar *bsdar, int eval, int code, const char *fmt, ...) { va_list ap; va_start(ap, fmt); bsdar_verrc(bsdar, code, fmt, ap); va_end(ap); - exit(EXIT_FAILURE); + exit(eval); } diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index d3dd71556bb3..4177f57d064a 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -43,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "ar.h" @@ -67,11 +67,54 @@ static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, static void prefault_buffer(const char *buf, size_t s); static void read_objs(struct bsdar *bsdar, const char *archive, int checkargv); +static int write_archive(struct bsdar *bsdar, char mode); static void write_cleanup(struct bsdar *bsdar); static void write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s); static void write_objs(struct bsdar *bsdar); +int +ar_mode_d(struct bsdar *bsdar) +{ + + return (write_archive(bsdar, 'd')); +} + +int +ar_mode_m(struct bsdar *bsdar) +{ + + return (write_archive(bsdar, 'm')); +} + +int +ar_mode_q(struct bsdar *bsdar) +{ + + return (write_archive(bsdar, 'q')); +} + +int +ar_mode_r(struct bsdar *bsdar) +{ + + return (write_archive(bsdar, 'r')); +} + +int +ar_mode_s(struct bsdar *bsdar) +{ + + return (write_archive(bsdar, 's')); +} + +int +ar_mode_A(struct bsdar *bsdar) +{ + + return (write_archive(bsdar, 'A')); +} + /* * Create object from file, return created obj upon success, or NULL * when an error occurs or the member is not newer than existing @@ -90,7 +133,7 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) obj = malloc(sizeof(struct ar_obj)); if (obj == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); if ((obj->fd = open(name, O_RDONLY, 0)) < 0) { bsdar_warnc(bsdar, errno, "can't open file: %s", name); free(obj); @@ -99,17 +142,17 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) tmpname = strdup(name); if (tmpname == NULL) - bsdar_errc(bsdar, errno, "strdup failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); if ((bname = basename(tmpname)) == NULL) - bsdar_errc(bsdar, errno, "basename failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "basename failed"); if (bsdar->options & AR_TR && strlen(bname) > _TRUNCATE_LEN) { if ((obj->name = malloc(_TRUNCATE_LEN + 1)) == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); (void)strncpy(obj->name, bname, _TRUNCATE_LEN); obj->name[_TRUNCATE_LEN] = '\0'; } else if ((obj->name = strdup(bname)) == NULL) - bsdar_errc(bsdar, errno, "strdup failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); free(tmpname); if (fstat(obj->fd, &sb) < 0) { @@ -162,14 +205,14 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) goto giveup; } if (close(obj->fd) < 0) - bsdar_errc(bsdar, errno, "close failed: %s", + bsdar_errc(bsdar, EX_SOFTWARE, errno, "close failed: %s", obj->name); return (obj); giveup: if (close(obj->fd) < 0) - bsdar_errc(bsdar, errno, "close failed: %s", + bsdar_errc(bsdar, EX_SOFTWARE, errno, "close failed: %s", obj->name); free(obj->name); free(obj); @@ -199,7 +242,7 @@ static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, struct ar_obj *pos) { if (obj == NULL) - bsdar_errc(bsdar, 0, "try to insert a null obj"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, "try to insert a null obj"); if (pos == NULL || obj == pos) /* @@ -242,13 +285,13 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) int i, r, find; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, 0, "archive_read_new failed"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); for (;;) { r = archive_read_next_header(a, &entry); if (r == ARCHIVE_FATAL) - bsdar_errc(bsdar, archive_errno(a), "%s", + bsdar_errc(bsdar, EX_DATAERR, archive_errno(a), "%s", archive_error_string(a)); if (r == ARCHIVE_EOF) break; @@ -279,7 +322,7 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) if (*av == NULL) continue; if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, errno, + bsdar_errc(bsdar, EX_SOFTWARE, errno, "basename failed"); if (strcmp(bname, name) != 0) continue; @@ -296,7 +339,8 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) if (size > 0) { if ((buff = malloc(size)) == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, + "malloc failed"); if (archive_read_data(a, buff, size) != (ssize_t)size) { bsdar_warnc(bsdar, archive_errno(a), "%s", archive_error_string(a)); @@ -308,10 +352,10 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) obj = malloc(sizeof(struct ar_obj)); if (obj == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); obj->maddr = buff; if ((obj->name = strdup(name)) == NULL) - bsdar_errc(bsdar, errno, "strdup failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); obj->size = size; obj->uid = archive_entry_uid(entry); obj->gid = archive_entry_gid(entry); @@ -334,8 +378,8 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) /* * Determine the constitution of resulting archive. */ -int -ar_write_archive(struct bsdar *bsdar, int mode) +static int +write_archive(struct bsdar *bsdar, char mode) { struct ar_obj *nobj, *obj, *obj_temp, *pos; struct stat sb; @@ -349,9 +393,6 @@ ar_write_archive(struct bsdar *bsdar, int mode) pos = NULL; memset(&sb, 0, sizeof(sb)); - assert(mode == 'A' || mode == 'd' || mode == 'm' || mode == 'q' || - mode == 'r' || mode == 's'); - /* * Test if the specified archive exists, to figure out * whether we are creating one here. @@ -435,7 +476,8 @@ ar_write_archive(struct bsdar *bsdar, int mode) TAILQ_FOREACH_SAFE(obj, &bsdar->v_obj, objs, obj_temp) { if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, errno, "basename failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, + "basename failed"); if (bsdar->options & AR_TR) { if (strncmp(bname, obj->name, _TRUNCATE_LEN)) continue; @@ -563,7 +605,7 @@ write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s) while (s > 0) { written = archive_write_data(a, buf, s); if (written < 0) - bsdar_errc(bsdar, archive_errno(a), "%s", + bsdar_errc(bsdar, EX_SOFTWARE, archive_errno(a), "%s", archive_error_string(a)); buf = (const char *)buf + written; s -= written; @@ -587,7 +629,7 @@ write_objs(struct bsdar *bsdar) uint32_t nr32; if (elf_version(EV_CURRENT) == EV_NONE) - bsdar_errc(bsdar, 0, + bsdar_errc(bsdar, EX_SOFTWARE, 0, "ELF library initialization failed: %s", elf_errmsg(-1)); bsdar->rela_off = 0; @@ -653,7 +695,7 @@ write_objs(struct bsdar *bsdar) } if ((a = archive_write_new()) == NULL) - bsdar_errc(bsdar, 0, "archive_write_new failed"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); archive_write_set_format_ar_svr4(a); @@ -668,7 +710,8 @@ write_objs(struct bsdar *bsdar) bsdar->options & AR_S) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, 0, "archive_entry_new failed"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, + "archive_entry_new failed"); if (w_sz == sizeof(uint64_t)) archive_entry_copy_pathname(entry, "/SYM64/"); else @@ -694,7 +737,8 @@ write_objs(struct bsdar *bsdar) if (bsdar->as != NULL) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, 0, "archive_entry_new failed"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, + "archive_entry_new failed"); archive_entry_copy_pathname(entry, "//"); archive_entry_set_size(entry, bsdar->as_sz); AC(archive_write_header(a, entry)); @@ -706,7 +750,8 @@ write_objs(struct bsdar *bsdar) TAILQ_FOREACH(obj, &bsdar->v_obj, objs) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, 0, "archive_entry_new failed"); + bsdar_errc(bsdar, EX_SOFTWARE, 0, + "archive_entry_new failed"); archive_entry_copy_pathname(entry, obj->name); archive_entry_set_uid(entry, obj->uid); archive_entry_set_gid(entry, obj->gid); @@ -848,7 +893,7 @@ add_to_ar_str_table(struct bsdar *bsdar, const char *name) bsdar->as_cap = _INIT_AS_CAP; bsdar->as_sz = 0; if ((bsdar->as = malloc(bsdar->as_cap)) == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); } /* @@ -859,7 +904,7 @@ add_to_ar_str_table(struct bsdar *bsdar, const char *name) bsdar->as_cap *= 2; bsdar->as = realloc(bsdar->as, bsdar->as_cap); if (bsdar->as == NULL) - bsdar_errc(bsdar, errno, "realloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); } strncpy(&bsdar->as[bsdar->as_sz], name, strlen(name)); bsdar->as_sz += strlen(name); @@ -877,14 +922,14 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) if (bsdar->s_so == NULL) { if ((bsdar->s_so = malloc(_INIT_SYMOFF_CAP)) == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); bsdar->s_so_cap = _INIT_SYMOFF_CAP; bsdar->s_cnt = 0; } if (bsdar->s_sn == NULL) { if ((bsdar->s_sn = malloc(_INIT_SYMNAME_CAP)) == NULL) - bsdar_errc(bsdar, errno, "malloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); bsdar->s_sn_cap = _INIT_SYMNAME_CAP; bsdar->s_sn_sz = 0; } @@ -893,7 +938,7 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) bsdar->s_so_cap *= 2; bsdar->s_so = realloc(bsdar->s_so, bsdar->s_so_cap); if (bsdar->s_so == NULL) - bsdar_errc(bsdar, errno, "realloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); } bsdar->s_so[bsdar->s_cnt] = bsdar->rela_off; if ((uint64_t)bsdar->rela_off > bsdar->s_so_max) @@ -908,7 +953,7 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) bsdar->s_sn_cap *= 2; bsdar->s_sn = realloc(bsdar->s_sn, bsdar->s_sn_cap); if (bsdar->s_sn == NULL) - bsdar_errc(bsdar, errno, "realloc failed"); + bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); } strncpy(&bsdar->s_sn[bsdar->s_sn_sz], name, strlen(name)); bsdar->s_sn_sz += strlen(name); From owner-dev-commits-src-all@freebsd.org Thu Aug 12 18:29:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B10D8670DCC; Thu, 12 Aug 2021 18:29:11 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta001.cacentral1.a.cloudfilter.net (omta001.cacentral1.a.cloudfilter.net [3.97.99.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GlwFL66Hmz3PKN; Thu, 12 Aug 2021 18:29:10 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from shw-obgw-4003a.ext.cloudfilter.net ([10.228.9.183]) by cmsmtp with ESMTP id E97XmiqcRFRDpEFS2mgk6u; Thu, 12 Aug 2021 18:29:10 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id EFS0mHG7UqeviEFS1mcAoa; Thu, 12 Aug 2021 18:29:10 +0000 X-Authority-Analysis: v=2.4 cv=B4F8bMhM c=1 sm=1 tr=0 ts=61156876 a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=kj9zAlcOel0A:10 a=MhDmnRu9jo8A:10 a=VxmjJ2MpAAAA:8 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=JRNxp-b1r3qJcsVWaVUA:9 a=CjuIK1q_8ugA:10 a=GZNcuLsopXQA:10 a=7gXAzLPJhVmCkEl4_tsf:22 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 137F767A; Thu, 12 Aug 2021 11:29:08 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 17CIT71Q034598; Thu, 12 Aug 2021 11:29:07 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202108121829.17CIT71Q034598@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Ed Maste cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: d20e9e02db3d - main - ar: diff reduction against ELF Tool Chain In-reply-to: <202108121729.17CHTWfb033244@slippy.cwsent.com> References: <202108112313.17BNDL1g093210@gitrepo.freebsd.org> <202108121729.17CHTWfb033244@slippy.cwsent.com> Comments: In-reply-to Cy Schubert message dated "Thu, 12 Aug 2021 10:29:32 -0700." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 12 Aug 2021 11:29:07 -0700 X-CMAE-Envelope: MS4xfGsg9eGshybo1y8vrOB3IstCDJvKj50ObJ1o+T3M725IwK3H9JVZPE9rEngKkoagFgJtH7/JcKb+lGz3EPb6wFBu3LQ/VJUl4HpOTJrfmZdfWBKAkKMo KXqCPYF+cfkMDb9dy7dHGBB0XiBdeoqPoi3LP8oJP9oerxULhjGPy/XDB6bqxky5JEo+xnZLPYzNlfuh7bYI2wtVneu0e8Y/cwiWMYAxYAuLAcYYhzuMPvvq p2LubKFinTV8DVQdlFv065JyZJVZYXWJ2MFFW15k2ioSX9oTGoSVEKSisoDjb1x5yQ6OcKItDHbzuArxMX7NMKH+rmlOQV5+8o2TMZQm16Q= X-Rspamd-Queue-Id: 4GlwFL66Hmz3PKN X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of cy.schubert@cschubert.com has no SPF policy when checking 3.97.99.32) smtp.mailfrom=cy.schubert@cschubert.com X-Spamd-Result: default: False [-0.48 / 15.00]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; MV_CASE(0.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[cschubert.com: no valid DMARC record]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; AUTH_NA(1.00)[]; NEURAL_HAM_MEDIUM(-0.89)[-0.888]; RWL_MAILSPIKE_VERYGOOD(0.00)[3.97.99.32:from]; NEURAL_HAM_SHORT(-0.99)[-0.987]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US]; RCVD_TLS_LAST(0.00)[]; MAILMAN_DEST(0.00)[dev-commits-src-main,dev-commits-src-all]; RECEIVED_SPAMHAUS_PBL(0.00)[70.66.148.124:received] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 18:29:11 -0000 In message <202108121729.17CHTWfb033244@slippy.cwsent.com>, Cy Schubert writes: > In message <202108112313.17BNDL1g093210@gitrepo.freebsd.org>, Ed Maste > writes: > > The branch main has been updated by emaste: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=d20e9e02db3dde383c3de1ce8cec3a > 8c > > 35b3eee6 > > > > commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6 > > Author: Ed Maste > > AuthorDate: 2021-08-04 13:54:17 +0000 > > Commit: Ed Maste > > CommitDate: 2021-08-11 23:12:46 +0000 > > > > ar: diff reduction against ELF Tool Chain > > > > - Drop exit status from bsdar_errc. ELF Tool Chain always returns > > EXIT_FAILURE in bsdar_errc. > > > > - Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive > > directly. > > > > Obtained from: ELF Tool Chain > > Reviewed by: markj > > Sponsored by: The FreeBSD Foundation > > Differential Revision: https://reviews.freebsd.org/D31496 > > --- > > usr.bin/ar/acpyacc.y | 48 ++++++++++------------ > > usr.bin/ar/ar.c | 52 ++++++++---------------- > > usr.bin/ar/ar.h | 18 +++------ > > usr.bin/ar/read.c | 34 ++++------------ > > usr.bin/ar/util.c | 4 +- > > usr.bin/ar/write.c | 111 +++++++++++++++-------------------------------- > -- > > -- > > 6 files changed, 85 insertions(+), 182 deletions(-) > > > [...] > > diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h > > index 21b3a669a943..bcccf93a6016 100644 > > --- a/usr.bin/ar/ar.h > > +++ b/usr.bin/ar/ar.h > > @@ -54,7 +54,7 @@ > > */ > > #define AC(CALL) do { > > \ > > if ((CALL)) \ > > - bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s", \ > > + bsdar_errc(bsdar, archive_errno(a), "%s", \ > > archive_error_string(a)); \ > > } while (0) > > > > @@ -114,16 +114,8 @@ struct bsdar { > > TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ > > }; > > > > -void bsdar_errc(struct bsdar *, int _eval, int _code, > > - const char *fmt, ...) __dead2; > > -void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); > > -int ar_mode_d(struct bsdar *bsdar); > > -int ar_mode_m(struct bsdar *bsdar); > > -int ar_mode_p(struct bsdar *bsdar); > > -int ar_mode_q(struct bsdar *bsdar); > > -int ar_mode_r(struct bsdar *bsdar); > > -int ar_mode_s(struct bsdar *bsdar); > > -int ar_mode_t(struct bsdar *bsdar); > > -int ar_mode_x(struct bsdar *bsdar); > > -int ar_mode_A(struct bsdar *bsdar); > > void ar_mode_script(struct bsdar *ar); > > +int ar_read_archive(struct bsdar *ar, int mode); > > +int ar_write_archive(struct bsdar *ar, int mode); > > +void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __d > ead2; > > +void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); > > diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c > > index 04130b859c32..81e0bfce1b7e 100644 > > --- a/usr.bin/ar/read.c > > +++ b/usr.bin/ar/read.c > > @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -42,34 +43,11 @@ __FBSDID("$FreeBSD$"); > > > > #include "ar.h" > > > > -static int read_archive(struct bsdar *bsdar, char mode); > > - > > -int > > -ar_mode_p(struct bsdar *bsdar) > > -{ > > - > > - return (read_archive(bsdar, 'p')); > > -} > > - > > -int > > -ar_mode_t(struct bsdar *bsdar) > > -{ > > - > > - return (read_archive(bsdar, 't')); > > -} > > - > > -int > > -ar_mode_x(struct bsdar *bsdar) > > -{ > > - > > - return (read_archive(bsdar, 'x')); > > -} > > - > > /* > > * Handle read modes: 'x', 't' and 'p'. > > */ > > -static int > > -read_archive(struct bsdar *bsdar, char mode) > > +int > > +ar_read_archive(struct bsdar *bsdar, int mode) > > { > > struct archive *a; > > struct archive_entry *entry; > > @@ -87,8 +65,10 @@ read_archive(struct bsdar *bsdar, char mode) > > char find; > > int exitcode, flags, r, i; > > > > + assert(mode == 'p' || mode == 't' || mode == 'x'); > > This is causing port build failures: > > ar -cq libutil.a allwhite.o inctest.o letter.o triedump.o triepdmp.o > trieplk.o trierset.o upcmp8.o upstrcmp.o wchar.o conutil.o error.o exit.o > itoa.o lower.o malloc.o openchk.o trie.o triecnt.o upper.o whitesp.o > ranlib libutil.a > Assertion failed: (mode == 'p' || mode == 't' || mode == 'x'), function > ar_read_archive, file /usr/local/poudriere/jails/main-amd64/usr/src/usr.bin/ > ar/read.c, line 68. > *** Signal 6 > > Notice at line 154 of ar.c that ar_read_archive() is called with mode='s'. > This certainly triggers the assertion. The assertion may also trigger by > the call to ar_read_archive() at line 330 of ar.c where mode is set to > bsdar->mode. It appears that upstream doesn't call ar_read_archive() at line 154 of ar.c. This would explain why they have the assertion they do in ar_read_archive(). There is only one call to ar_read_archive() at line 350 which corresponds to our line 330 of ar.c. > > > + > > if ((a = archive_read_new()) == NULL) > > - bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed"); > > + bsdar_errc(bsdar, 0, "archive_read_new failed"); > > archive_read_support_format_ar(a); > > AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ)); > > > > @@ -122,7 +102,7 @@ read_archive(struct bsdar *bsdar, char mode) > > if (*av == NULL) > > continue; > > if ((bname = basename(*av)) == NULL) > > - bsdar_errc(bsdar, EXIT_FAILURE, errno, > > + bsdar_errc(bsdar, errno, > > "basename failed"); > > if (strcmp(bname, name) != 0) > > continue; > [...] -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-dev-commits-src-all@freebsd.org Thu Aug 12 18:29:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D803C670C6E; Thu, 12 Aug 2021 18:29:12 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 4GlwFM2sGHz3PWt; Thu, 12 Aug 2021 18:29:11 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-il1-f172.google.com with SMTP id z2so8084935iln.0; Thu, 12 Aug 2021 11:29:11 -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:to:cc; bh=Aar/wqnVYwL4GHRXLrOi0xYklfkK7FOZ7WTYueHeAoM=; b=M49wHANbkNOsLD1+hijN9Poi07GfAIdLVDvk3NRb7coFybwwv06Z/2Ocj4kJAhkQjL JfGxZaix460WqLW7+Cv3wkuSTTzeVRkMMVgaGU50WjHhriTv6pngiH8YsuyjZtndLm1I azjCc6IcwX6DvY4uXl/3Ng9/fEhxbAK8kNO2NogVHRXBaew5G64HEv2ZqkdDvwgN/bh1 plqYjUFeQzLDlRJe5F8LQ//neOfTze6VqfjTHfQ2HfiWl/YWsyADLeVFrZyEf1Cbv+8w 1tcbv1Oc8UApyt8jHRjKs58TdUx5TWGCiwDLzJOQ00t+2BjQRBt24AUU4HQqZoiyTckZ aeeQ== X-Gm-Message-State: AOAM531/xUHqOh4BWe46RseJFrTjTpbF5KymCI/qGCgLOZ/WZBaS+o6+ EhyD/Jt4JGoODFjDkpEbRi74MktmpOrCZKN2ARtI0LKA X-Google-Smtp-Source: ABdhPJwR0OPgBpW3WXtXEWqebFCXt6YLcPqUSp/uThTTeY6MzTWPQBBYlPUhaNRvU8uVysgLWNs2ioIHzhZJUCuIiIU= X-Received: by 2002:a92:2e12:: with SMTP id v18mr3995052ile.100.1628792950732; Thu, 12 Aug 2021 11:29:10 -0700 (PDT) MIME-Version: 1.0 References: <202108112313.17BNDL1g093210@gitrepo.freebsd.org> <202108121729.17CHTWfb033244@slippy.cwsent.com> In-Reply-To: <202108121729.17CHTWfb033244@slippy.cwsent.com> From: Ed Maste Date: Thu, 12 Aug 2021 14:28:54 -0400 Message-ID: Subject: Re: git: d20e9e02db3d - main - ar: diff reduction against ELF Tool Chain To: Cy Schubert Cc: src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4GlwFM2sGHz3PWt X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of carpeddiem@gmail.com designates 209.85.166.172 as permitted sender) smtp.mailfrom=carpeddiem@gmail.com X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FREEFALL_USER(0.00)[carpeddiem]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; RCVD_TLS_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; TO_DN_SOME(0.00)[]; NEURAL_SPAM_MEDIUM(0.31)[0.308]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.40)[-0.403]; RCVD_IN_DNSWL_NONE(0.00)[209.85.166.172:from]; FORGED_SENDER(0.30)[emaste@freebsd.org,carpeddiem@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.166.172:from]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[emaste@freebsd.org,carpeddiem@gmail.com]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 18:29:13 -0000 On Thu, 12 Aug 2021 at 13:29, Cy Schubert wrote: > > In message <202108112313.17BNDL1g093210@gitrepo.freebsd.org>, Ed Maste > writes: > > The branch main has been updated by emaste: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=d20e9e02db3dde383c3de1ce8cec3a8c > > 35b3eee6 > > > > commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6 > > Author: Ed Maste > > AuthorDate: 2021-08-04 13:54:17 +0000 > > Commit: Ed Maste > > CommitDate: 2021-08-11 23:12:46 +0000 > > > > ar: diff reduction against ELF Tool Chain > > This is causing port build failures: Sorry about that, this change was intended to have no functional impact, so I have reverted for now. From owner-dev-commits-src-all@freebsd.org Thu Aug 12 21:46:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D306067334B; Thu, 12 Aug 2021 21:46:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gm0cy5c36z3tT5; Thu, 12 Aug 2021 21:46:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 215EF275F6; Thu, 12 Aug 2021 21:46:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108120724.17C7OJ8h043708@gitrepo.freebsd.org> <32e784a3-9c96-9818-8fc3-a5ad85643f2c@FreeBSD.org> From: John Baldwin Subject: Re: git: f4c6843ec2b9 - main - xen: use correct cache attributes for Xen specific memory regions Message-ID: <11d56b94-7fb9-740d-93b0-fab3c3dad6a7@FreeBSD.org> Date: Thu, 12 Aug 2021 14:46:21 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 21:46:26 -0000 On 8/12/21 10:01 AM, Roger Pau Monné wrote: > On Thu, Aug 12, 2021 at 09:43:57AM -0700, John Baldwin wrote: >> On 8/12/21 8:53 AM, Roger Pau Monné wrote: >>> On Thu, Aug 12, 2021 at 08:20:51AM -0700, John Baldwin wrote: >>>> On 8/12/21 12:24 AM, Roger Pau Monné wrote: >>>>> The branch main has been updated by royger: >>>>> >>>>> URL: https://cgit.FreeBSD.org/src/commit/?id=f4c6843ec2b9aa5eff475778fb000ed6278c5b77 >>>>> >>>>> commit f4c6843ec2b9aa5eff475778fb000ed6278c5b77 >>>>> Author: Roger Pau Monné >>>>> AuthorDate: 2021-04-09 09:31:44 +0000 >>>>> Commit: Roger Pau Monné >>>>> CommitDate: 2021-08-12 07:18:32 +0000 >>>>> >>>>> xen: use correct cache attributes for Xen specific memory regions >>>>> bus_activate_resource maps memory regions as uncacheable on x86, which >>>>> is more strict than required for regions allocated using xenmem_alloc, >>>>> so don't rely on bus_activate_resource and instead map the region >>>>> using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. >>>>> Sponsored by: Citrix Systems R&D >>>> >>>> It would probably be cleaner to use bus_map_resource() for this instead. It >>>> would mean you would have to use a structure that writes to as the argument >>>> to bus_read/write_* instead of using the resource directly. >>> >>> Those regions are usually handled to other subsystems of the kernel. >>> They are mostly used to map memory from other domains and then perform >>> IO on their behalf (like blkback and netback do), so it's not really >>> possible to assert that all users of the regions would use >>> bus_read/write_* to access them. >>> >>> I could however switch to using bus_map_resource if I can pass the >>> desired memory cache attribute and get a linear address back. It looks >>> like resource_map_request parameter allows to select the cache >>> attribute. >> >> Yes, one of the use case for bus_map_resource is to permit passing a >> non-default memory attribute. (It also permits mapping sub-ranges, but >> that isn't applicable in this case.) The 'r_vaddr' in the resource_map >> is the equivalent of rman_get_addr. It'd be a little cleaner (and >> perhaps friendly to future changes in this area) if your clients used >> the 'r_vaddr' from the resource_map directly instead of using >> rman_set_virtual() on the original resource. (At some point I would like >> to have each 'struct resource' keep a list of all the mappings created >> from it and to forcefully invalidate/free any existing mappings that >> still remain when a 'struct resource' is freed. I imagine as part of >> that I might end up with some assertions about the embedded resource >> fields in the 'struct resource' being self-consistent). > > Does the following diff seem better: > > diff --git a/sys/dev/xen/bus/xenpv.c b/sys/dev/xen/bus/xenpv.c > index 91004039a85e..748ead7f2f41 100644 > --- a/sys/dev/xen/bus/xenpv.c > +++ b/sys/dev/xen/bus/xenpv.c > @@ -120,7 +120,8 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size) > { > struct resource *res; > vm_paddr_t phys_addr; > - void *virt_addr; > + struct resource_map_request margs; > + struct resource_map map; > int error; > > res = bus_alloc_resource(child, SYS_RES_MEMORY, res_id, LOW_MEM_LIMIT, > @@ -135,9 +136,16 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size) > bus_release_resource(child, SYS_RES_MEMORY, *res_id, res); > return (NULL); > } > - virt_addr = pmap_mapdev_attr(phys_addr, size, VM_MEMATTR_XEN); > - KASSERT(virt_addr != NULL, ("Failed to create linear mappings")); > - rman_set_virtual(res, virt_addr); > + > + resource_init_map_request(&margs); > + margs.memattr = VM_MEMATTR_XEN; > + error = bus_map_resource(child, SYS_RES_MEMORY, res, &margs, &map); > + if (error != 0) { > + vm_phys_fictitious_unreg_range(phys_addr, phys_addr + size); > + bus_release_resource(child, SYS_RES_MEMORY, *res_id, res); > + return (NULL); > + } > + rman_set_mapping(res, &map); > > return (res); > } > @@ -146,14 +154,14 @@ static int > xenpv_free_physmem(device_t dev, device_t child, int res_id, struct resource *res) > { > vm_paddr_t phys_addr; > - vm_offset_t virt_addr; > + struct resource_map map; > size_t size; > > phys_addr = rman_get_start(res); > size = rman_get_size(res); > - virt_addr = (vm_offset_t)rman_get_virtual(res); > + rman_get_mapping(res, &map); > > - pmap_unmapdev(virt_addr, size); > + bus_unmap_resource(child, SYS_RES_MEMORY, res, &map); > vm_phys_fictitious_unreg_range(phys_addr, phys_addr + size); > return (bus_release_resource(child, SYS_RES_MEMORY, res_id, res)); > } > > I also wonder if rman_set_mapping should clear the RF_UNMAPPED flag > from the resource? Or the content of the flags field is opaque from > rman PoV and it should be the caller of rman_set_mapping the one to > clear the flag? (xenpv_alloc_physmem in the code above) > > It's kind of pointless to copy the bus_unmap_resource logic in > xenpv_free_physmem when it could be done by bus_release_resource if > the RF_UNMAPPED flag was cleared. Huh, I hadn't really imagined that use case, but it would be nice to not have to touch the release path and optimize this case when you aren't doing a subset mapping. I would be fine with changing rman_set_mapping to clear the flag. In fact, arguably it would be cleaner (but maybe just one more one-line change?) to have new resources always have RF_UNMAPPED set even if it wasn't passed into the rman_reserve_bounds() (you would do it in the case where you allocate a resource before the RF_SHAREABLE loop) and then only clear it if rman_set_mapping() is called. -- John Baldwin From owner-dev-commits-src-all@freebsd.org Thu Aug 12 22:56:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9048E673D70; Thu, 12 Aug 2021 22: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 4Gm29K37FVz4RwM; Thu, 12 Aug 2021 22: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 4FDBA2B0AF; Thu, 12 Aug 2021 22: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 17CMu5gm084608; Thu, 12 Aug 2021 22: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 17CMu5Gr084607; Thu, 12 Aug 2021 22:56:05 GMT (envelope-from git) Date: Thu, 12 Aug 2021 22:56:05 GMT Message-Id: <202108122256.17CMu5Gr084607@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: cef65082ae12 - main - bsd.compiler.mk: Fix cross-building from non-FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cef65082ae12aabaac176a61ffc49f37c97a58c3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 22:56:05 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=cef65082ae12aabaac176a61ffc49f37c97a58c3 commit cef65082ae12aabaac176a61ffc49f37c97a58c3 Author: Jessica Clarke AuthorDate: 2021-08-12 22:45:09 +0000 Commit: Jessica Clarke CommitDate: 2021-08-12 22:45:09 +0000 bsd.compiler.mk: Fix cross-building from non-FreeBSD On non-FreeBSD, the various MACHINE variables for the host when bootstrapping can be missing or not match FreeBSD's naming, causing bsd.endian.mk to be unable to infer the endianness. Work around this by assuming it's unsupported. Note that we can't check BOOTSTRAPPING here as Makefile.inc1 includes bsd.compiler.mk before that is set, and so we are unable to catch errors during buildworld itself when cross-building and bsd.endian.mk failed, but such errors should also show up when building on FreeBSD. Fixes: 47363e99d3d3 ("Enable compressed debug on little-endian targets") --- share/mk/bsd.compiler.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index 757361a566dd..c58eb114f4b8 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -239,8 +239,14 @@ ${X_}COMPILER_FEATURES+= retpoline init-all # PR257638 lld fails with BE compressed debug. Fixed in main but external tool # chains will initially not have the fix. For now limit the feature to LE # targets. +# When compiling bootstrap tools on non-FreeBSD, the various MACHINE variables +# for the host can be missing or not match FreeBSD's naming (e.g. Linux/amd64 +# reports as MACHINE=x86_64 MACHINE_ARCH=x86_64), causing TARGET_ENDIANNESS to +# be undefined; be conservative and default to off until we turn this on by +# default everywhere. .include -.if ${TARGET_ENDIANNESS} == "1234" +.if (${.MAKE.OS} == "FreeBSD" || defined(TARGET_ENDIANNESS)) && \ + ${TARGET_ENDIANNESS} == "1234" ${X_}COMPILER_FEATURES+= compressed-debug .endif .endif From owner-dev-commits-src-all@freebsd.org Thu Aug 12 22:56:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93580673FCA; Thu, 12 Aug 2021 22:56: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 4Gm29L3kbwz4RL9; Thu, 12 Aug 2021 22:56: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 68F332B2BC; Thu, 12 Aug 2021 22: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 17CMu6ql084632; Thu, 12 Aug 2021 22: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 17CMu6GN084631; Thu, 12 Aug 2021 22:56:06 GMT (envelope-from git) Date: Thu, 12 Aug 2021 22:56:06 GMT Message-Id: <202108122256.17CMu6GN084631@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 8a1895a3fa6f - main - tools/build/cross-build: Fix building libllvmminimal on Linux MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a1895a3fa6f634e9f459b6b62321a61c7941bdc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 22:56:06 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=8a1895a3fa6f634e9f459b6b62321a61c7941bdc commit 8a1895a3fa6f634e9f459b6b62321a61c7941bdc Author: Jessica Clarke AuthorDate: 2021-08-12 22:50:48 +0000 Commit: Jessica Clarke CommitDate: 2021-08-12 22:50:48 +0000 tools/build/cross-build: Fix building libllvmminimal on Linux There is a __used member in glibc's posix_spawn_file_actions_t in spawn.h, so we must temporarily undefine __used when including it, otherwise Support/Unix/Program.inc fails to build. This is based on similar handling for __unused in other headers. Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week --- .../include/linux/__used_workaround_end.h | 43 ++++++++++++++++++++ .../include/linux/__used_workaround_start.h | 43 ++++++++++++++++++++ tools/build/cross-build/include/linux/spawn.h | 47 ++++++++++++++++++++++ 3 files changed, 133 insertions(+) diff --git a/tools/build/cross-build/include/linux/__used_workaround_end.h b/tools/build/cross-build/include/linux/__used_workaround_end.h new file mode 100644 index 000000000000..99cc6c16ac26 --- /dev/null +++ b/tools/build/cross-build/include/linux/__used_workaround_end.h @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2018-2020 Alex Richardson + * Copyright 2021 Jessica Clarke + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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$ + */ +/* Used to workaround system headers with struct members called __used */ +#ifdef __used_undefd +#undef __used_undefd +#define __used __attribute__((used)) +#endif diff --git a/tools/build/cross-build/include/linux/__used_workaround_start.h b/tools/build/cross-build/include/linux/__used_workaround_start.h new file mode 100644 index 000000000000..ee290ce30169 --- /dev/null +++ b/tools/build/cross-build/include/linux/__used_workaround_start.h @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2018-2020 Alex Richardson + * Copyright 2021 Jessica Clarke + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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$ + */ +/* Used to workaround system headers with struct members called __used */ +#ifdef __used +#undef __used +#define __used_undefd +#endif diff --git a/tools/build/cross-build/include/linux/spawn.h b/tools/build/cross-build/include/linux/spawn.h new file mode 100644 index 000000000000..873add3275af --- /dev/null +++ b/tools/build/cross-build/include/linux/spawn.h @@ -0,0 +1,47 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2018-2021 Alex Richardson + * Copyright 2021 Jessica Clarke + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * This work was supported by Innovate UK project 105694, "Digital Security by + * Design (DSbD) Technology Platform Prototype". + * + * 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$ + */ +#pragma once + +/* posix_spawn_file_actions_t contains a member __used */ +#include "__used_workaround_start.h" +#include_next +#include "__used_workaround_end.h" From owner-dev-commits-src-all@freebsd.org Thu Aug 12 22:56:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1CDA2673FD1; Thu, 12 Aug 2021 22:56: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 4Gm29M55ZFz4RnQ; Thu, 12 Aug 2021 22: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 8B2A32B240; Thu, 12 Aug 2021 22:56: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 17CMu7qV084660; Thu, 12 Aug 2021 22:56:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CMu7bP084659; Thu, 12 Aug 2021 22:56:07 GMT (envelope-from git) Date: Thu, 12 Aug 2021 22:56:07 GMT Message-Id: <202108122256.17CMu7bP084659@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 5ff5d1177bc6 - main - clang: Fix inverted condition in llvm.build.mk MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5ff5d1177bc66f1c2a0a6ee4d0ffa128d32e1dad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 22:56:08 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=5ff5d1177bc66f1c2a0a6ee4d0ffa128d32e1dad commit 5ff5d1177bc66f1c2a0a6ee4d0ffa128d32e1dad Author: Jessica Clarke AuthorDate: 2021-08-12 22:53:30 +0000 Commit: Jessica Clarke CommitDate: 2021-08-12 22:53:30 +0000 clang: Fix inverted condition in llvm.build.mk Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week --- lib/clang/llvm.build.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk index 3a712cde1703..5aff7081fb76 100644 --- a/lib/clang/llvm.build.mk +++ b/lib/clang/llvm.build.mk @@ -111,10 +111,10 @@ CXXSTD?= c++14 CXXFLAGS+= -fno-exceptions CXXFLAGS+= -fno-rtti .if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING) +CXXFLAGS.clang+= -stdlib=libc++ +.else # Building on macOS/Linux needs the real sysctl() not the bootstrap tools stub. CFLAGS+= -DBOOTSTRAPPING_WANT_NATIVE_SYSCTL -.else -CXXFLAGS.clang+= -stdlib=libc++ .endif .if defined(BOOTSTRAPPING) && ${.MAKE.OS} == "Linux" LIBADD+= dl From owner-dev-commits-src-all@freebsd.org Thu Aug 12 23:51:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85B6467481D; Thu, 12 Aug 2021 23:51:43 +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 4Gm3PW39RVz4Tph; Thu, 12 Aug 2021 23:51: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 54FA82C18D; Thu, 12 Aug 2021 23:51: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 17CNphoc063269; Thu, 12 Aug 2021 23:51:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17CNphPb063268; Thu, 12 Aug 2021 23:51:43 GMT (envelope-from git) Date: Thu, 12 Aug 2021 23:51:43 GMT Message-Id: <202108122351.17CNphPb063268@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 06afb53bcd7b - main - nfsd: Fix sanity check for NFSv4.2 Allocate operations 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/main X-Git-Reftype: branch X-Git-Commit: 06afb53bcd7b6a928bc90acb820383302ea8be9e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 23:51:43 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=06afb53bcd7b6a928bc90acb820383302ea8be9e commit 06afb53bcd7b6a928bc90acb820383302ea8be9e Author: Rick Macklem AuthorDate: 2021-08-12 23:48:28 +0000 Commit: Rick Macklem CommitDate: 2021-08-12 23:48:28 +0000 nfsd: Fix sanity check for NFSv4.2 Allocate operations The NFSv4.2 Allocate operation sanity checks the aa_offset and aa_length arguments. Since they are assigned to variables of type off_t (signed) it was possible for them to be negative. It was also possible for aa_offset+aa_length to exceed OFF_MAX when stored in lo_end, which is uint64_t. This patch adds checks for these cases to the sanity check. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31511 --- sys/fs/nfsserver/nfs_nfsdserv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 0ba3472b4ff9..12181d04f1fa 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -5347,12 +5347,18 @@ nfsrvd_allocate(struct nfsrv_descript *nd, __unused int isdgram, off = fxdr_hyper(tl); tl += 2; lop->lo_first = off; len = fxdr_hyper(tl); - lop->lo_end = off + len; + lop->lo_end = lop->lo_first + len; /* - * Paranoia, just in case it wraps around, which shouldn't - * ever happen anyhow. + * Sanity check the offset and length. + * off and len are off_t (signed int64_t) whereas + * lo_first and lo_end are uint64_t and, as such, + * if off >= 0 && len > 0, lo_end cannot overflow + * unless off_t is changed to something other than + * int64_t. Check lo_end < lo_first in case that + * is someday the case. */ - if (nd->nd_repstat == 0 && (lop->lo_end < lop->lo_first || len <= 0)) + if (nd->nd_repstat == 0 && (len <= 0 || off < 0 || lop->lo_end > + OFF_MAX || lop->lo_end < lop->lo_first)) nd->nd_repstat = NFSERR_INVAL; if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG) From owner-dev-commits-src-all@freebsd.org Fri Aug 13 01:18:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 048E367578A; Fri, 13 Aug 2021 01:18: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 4Gm5Kr6R7Vz4Z3V; Fri, 13 Aug 2021 01:18: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 B63612CFB1; Fri, 13 Aug 2021 01:18: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 17D1IeP7071220; Fri, 13 Aug 2021 01:18:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D1IeOP071219; Fri, 13 Aug 2021 01:18:40 GMT (envelope-from git) Date: Fri, 13 Aug 2021 01:18:40 GMT Message-Id: <202108130118.17D1IeOP071219@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: b41b86b65f10 - stable/13 - ipmi(4): Add more watchdog error checks. 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: b41b86b65f10ccaa8cce8cc11a030ad464b654c0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 01:18:41 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=b41b86b65f10ccaa8cce8cc11a030ad464b654c0 commit b41b86b65f10ccaa8cce8cc11a030ad464b654c0 Author: Alexander Motin AuthorDate: 2021-07-30 03:39:04 +0000 Commit: Alexander Motin CommitDate: 2021-08-13 01:18:31 +0000 ipmi(4): Add more watchdog error checks. Add request submission status checks before checking req->ir_compcode, otherwise it may be zero just because of initialization. Add checks for req->ir_compcode errors in ipmi_reset_watchdog() and ipmi_set_watchdog(). In first case explicitly check for 0x80, which means timer was not previously set, that I found happening after BMC cold reset. This change makes watchdog timer to recover instead of permanently ignoring reset errors after BMC reset or upgraded. MFC after: 2 weeks Sponsored by: iXsystems, Inc. (cherry picked from commit 9d3b47abbba74830661e90206cc0f692b159c432) --- sys/dev/ipmi/ipmi.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sys/dev/ipmi/ipmi.c b/sys/dev/ipmi/ipmi.c index 25077500d835..cd2a289b25cb 100644 --- a/sys/dev/ipmi/ipmi.c +++ b/sys/dev/ipmi/ipmi.c @@ -638,8 +638,15 @@ ipmi_reset_watchdog(struct ipmi_softc *sc) IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_RESET_WDOG, 0, 0); error = ipmi_submit_driver_request(sc, req, 0); - if (error) + if (error) { device_printf(sc->ipmi_dev, "Failed to reset watchdog\n"); + } else if (req->ir_compcode == 0x80) { + error = ENOENT; + } else if (req->ir_compcode != 0) { + device_printf(sc->ipmi_dev, "Watchdog reset returned 0x%x\n", + req->ir_compcode); + error = EINVAL; + } return (error); } @@ -671,8 +678,13 @@ ipmi_set_watchdog(struct ipmi_softc *sc, unsigned int sec) req->ir_request[5] = 0; } error = ipmi_submit_driver_request(sc, req, 0); - if (error) + if (error) { device_printf(sc->ipmi_dev, "Failed to set watchdog\n"); + } else if (req->ir_compcode != 0) { + device_printf(sc->ipmi_dev, "Watchdog set returned 0x%x\n", + req->ir_compcode); + error = EINVAL; + } return (error); } @@ -886,9 +898,9 @@ ipmi_startup(void *arg) IPMI_GET_CHANNEL_INFO, 1, 0); req->ir_request[0] = i; - ipmi_submit_driver_request(sc, req, 0); + error = ipmi_submit_driver_request(sc, req, 0); - if (req->ir_compcode != 0) + if (error != 0 || req->ir_compcode != 0) break; } device_printf(dev, "Number of channels %d\n", i); @@ -901,9 +913,9 @@ ipmi_startup(void *arg) IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_WDOG, 0, 0); - ipmi_submit_driver_request(sc, req, 0); + error = ipmi_submit_driver_request(sc, req, 0); - if (req->ir_compcode == 0x00) { + if (error == 0 && req->ir_compcode == 0x00) { device_printf(dev, "Attached watchdog\n"); /* register the watchdog event handler */ sc->ipmi_watchdog_tag = EVENTHANDLER_REGISTER( From owner-dev-commits-src-all@freebsd.org Fri Aug 13 01:19:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 12AF1675942; Fri, 13 Aug 2021 01:19: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 4Gm5Ld6ng3z4Yyg; Fri, 13 Aug 2021 01:19: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 D1D2E2CE63; Fri, 13 Aug 2021 01:19: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 17D1JLfB071401; Fri, 13 Aug 2021 01:19:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D1JLSl071400; Fri, 13 Aug 2021 01:19:21 GMT (envelope-from git) Date: Fri, 13 Aug 2021 01:19:21 GMT Message-Id: <202108130119.17D1JLSl071400@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: 8e6bcb7f56f1 - stable/12 - ipmi(4): Add more watchdog error checks. 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: 8e6bcb7f56f12ca2d237b4684223ebb5c5d9092c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 01:19:22 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=8e6bcb7f56f12ca2d237b4684223ebb5c5d9092c commit 8e6bcb7f56f12ca2d237b4684223ebb5c5d9092c Author: Alexander Motin AuthorDate: 2021-07-30 03:39:04 +0000 Commit: Alexander Motin CommitDate: 2021-08-13 01:19:13 +0000 ipmi(4): Add more watchdog error checks. Add request submission status checks before checking req->ir_compcode, otherwise it may be zero just because of initialization. Add checks for req->ir_compcode errors in ipmi_reset_watchdog() and ipmi_set_watchdog(). In first case explicitly check for 0x80, which means timer was not previously set, that I found happening after BMC cold reset. This change makes watchdog timer to recover instead of permanently ignoring reset errors after BMC reset or upgraded. MFC after: 2 weeks Sponsored by: iXsystems, Inc. (cherry picked from commit 9d3b47abbba74830661e90206cc0f692b159c432) --- sys/dev/ipmi/ipmi.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sys/dev/ipmi/ipmi.c b/sys/dev/ipmi/ipmi.c index edbe1741e0f7..d48a7d10c289 100644 --- a/sys/dev/ipmi/ipmi.c +++ b/sys/dev/ipmi/ipmi.c @@ -635,8 +635,15 @@ ipmi_reset_watchdog(struct ipmi_softc *sc) IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_RESET_WDOG, 0, 0); error = ipmi_submit_driver_request(sc, req, 0); - if (error) + if (error) { device_printf(sc->ipmi_dev, "Failed to reset watchdog\n"); + } else if (req->ir_compcode == 0x80) { + error = ENOENT; + } else if (req->ir_compcode != 0) { + device_printf(sc->ipmi_dev, "Watchdog reset returned 0x%x\n", + req->ir_compcode); + error = EINVAL; + } return (error); } @@ -668,8 +675,13 @@ ipmi_set_watchdog(struct ipmi_softc *sc, unsigned int sec) req->ir_request[5] = 0; } error = ipmi_submit_driver_request(sc, req, 0); - if (error) + if (error) { device_printf(sc->ipmi_dev, "Failed to set watchdog\n"); + } else if (req->ir_compcode != 0) { + device_printf(sc->ipmi_dev, "Watchdog set returned 0x%x\n", + req->ir_compcode); + error = EINVAL; + } return (error); } @@ -883,9 +895,9 @@ ipmi_startup(void *arg) IPMI_GET_CHANNEL_INFO, 1, 0); req->ir_request[0] = i; - ipmi_submit_driver_request(sc, req, 0); + error = ipmi_submit_driver_request(sc, req, 0); - if (req->ir_compcode != 0) + if (error != 0 || req->ir_compcode != 0) break; } device_printf(dev, "Number of channels %d\n", i); @@ -898,9 +910,9 @@ ipmi_startup(void *arg) IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_WDOG, 0, 0); - ipmi_submit_driver_request(sc, req, 0); + error = ipmi_submit_driver_request(sc, req, 0); - if (req->ir_compcode == 0x00) { + if (error == 0 && req->ir_compcode == 0x00) { device_printf(dev, "Attached watchdog\n"); /* register the watchdog event handler */ sc->ipmi_watchdog_tag = EVENTHANDLER_REGISTER( From owner-dev-commits-src-all@freebsd.org Fri Aug 13 01:48:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2C27F675B3D; Fri, 13 Aug 2021 01: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 4Gm60J0Rgkz4bJ7; Fri, 13 Aug 2021 01: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 E84AC2D6C1; Fri, 13 Aug 2021 01: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 17D1mV6M012249; Fri, 13 Aug 2021 01: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 17D1mV4Z012248; Fri, 13 Aug 2021 01:48:31 GMT (envelope-from git) Date: Fri, 13 Aug 2021 01:48:31 GMT Message-Id: <202108130148.17D1mV4Z012248@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: 7eb023696a7d - stable/13 - coretemp(4): Switch to smp_rendezvous_cpus(). 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: 7eb023696a7db1d66a811756b81e0cc7d617cc23 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 01:48:32 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=7eb023696a7db1d66a811756b81e0cc7d617cc23 commit 7eb023696a7db1d66a811756b81e0cc7d617cc23 Author: Alexander Motin AuthorDate: 2021-07-30 03:16:22 +0000 Commit: Alexander Motin CommitDate: 2021-08-13 01:48:17 +0000 coretemp(4): Switch to smp_rendezvous_cpus(). Use of smp_rendezvous_cpus() instead of sched_bind() allows to not block indefinitely if target CPU is running some thread with higher priority, while all we need is single rdmsr/wrmsr instruction call. I guess it should also be much cheaper than full thread migration. MFC after: 2 weeks Sponsored by: iXsystems, Inc. (cherry picked from commit 74f80bc1af2ffd56ec290f610c80e46f768731a0) --- sys/dev/coretemp/coretemp.c | 59 ++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c index 884ed6309f0e..53a2434254f6 100644 --- a/sys/dev/coretemp/coretemp.c +++ b/sys/dev/coretemp/coretemp.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* for curthread */ -#include +#include #include #include @@ -310,14 +310,32 @@ coretemp_detach(device_t dev) return (0); } +struct coretemp_args { + u_int msr; + uint64_t val; +}; + +static void +coretemp_rdmsr(void *arg) +{ + struct coretemp_args *args = arg; + + args->val = rdmsr(args->msr); +} + +static void +coretemp_wrmsr(void *arg) +{ + struct coretemp_args *args = arg; + + wrmsr(args->msr, args->val); +} + static uint64_t coretemp_get_thermal_msr(int cpu) { - uint64_t msr; - - thread_lock(curthread); - sched_bind(curthread, cpu); - thread_unlock(curthread); + struct coretemp_args args; + cpuset_t cpus; /* * The digital temperature reading is located at bit 16 @@ -329,27 +347,24 @@ coretemp_get_thermal_msr(int cpu) * The temperature is computed by subtracting the temperature * reading by Tj(max). */ - msr = rdmsr(MSR_THERM_STATUS); - - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); - - return (msr); + args.msr = MSR_THERM_STATUS; + CPU_SETOF(cpu, &cpus); + smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_rdmsr, + smp_no_rendezvous_barrier, &args); + return (args.val); } static void coretemp_clear_thermal_msr(int cpu) { - thread_lock(curthread); - sched_bind(curthread, cpu); - thread_unlock(curthread); - - wrmsr(MSR_THERM_STATUS, 0); - - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); + struct coretemp_args args; + cpuset_t cpus; + + args.msr = MSR_THERM_STATUS; + args.val = 0; + CPU_SETOF(cpu, &cpus); + smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_wrmsr, + smp_no_rendezvous_barrier, &args); } static int From owner-dev-commits-src-all@freebsd.org Fri Aug 13 01:56:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78683675EC1; Fri, 13 Aug 2021 01:56: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 4Gm68z2psMz4bb4; Fri, 13 Aug 2021 01:56: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 3A8002D9D3; Fri, 13 Aug 2021 01:56: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 17D1u333025218; Fri, 13 Aug 2021 01:56:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D1u3tj025217; Fri, 13 Aug 2021 01:56:03 GMT (envelope-from git) Date: Fri, 13 Aug 2021 01:56:03 GMT Message-Id: <202108130156.17D1u3tj025217@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: 6004eaaf0fc4 - stable/12 - coretemp(4): Switch to smp_rendezvous_cpus(). 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: 6004eaaf0fc4f0e7af1cfec335f78e372937d4c4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 01:56:03 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=6004eaaf0fc4f0e7af1cfec335f78e372937d4c4 commit 6004eaaf0fc4f0e7af1cfec335f78e372937d4c4 Author: Alexander Motin AuthorDate: 2021-07-30 03:16:22 +0000 Commit: Alexander Motin CommitDate: 2021-08-13 01:55:55 +0000 coretemp(4): Switch to smp_rendezvous_cpus(). Use of smp_rendezvous_cpus() instead of sched_bind() allows to not block indefinitely if target CPU is running some thread with higher priority, while all we need is single rdmsr/wrmsr instruction call. I guess it should also be much cheaper than full thread migration. MFC after: 2 weeks Sponsored by: iXsystems, Inc. (cherry picked from commit 74f80bc1af2ffd56ec290f610c80e46f768731a0) --- sys/dev/coretemp/coretemp.c | 59 ++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c index 8b9fc3b82350..b4f3fb7700f5 100644 --- a/sys/dev/coretemp/coretemp.c +++ b/sys/dev/coretemp/coretemp.c @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* for curthread */ -#include +#include #include #include @@ -308,14 +308,32 @@ coretemp_detach(device_t dev) return (0); } +struct coretemp_args { + u_int msr; + uint64_t val; +}; + +static void +coretemp_rdmsr(void *arg) +{ + struct coretemp_args *args = arg; + + args->val = rdmsr(args->msr); +} + +static void +coretemp_wrmsr(void *arg) +{ + struct coretemp_args *args = arg; + + wrmsr(args->msr, args->val); +} + static uint64_t coretemp_get_thermal_msr(int cpu) { - uint64_t msr; - - thread_lock(curthread); - sched_bind(curthread, cpu); - thread_unlock(curthread); + struct coretemp_args args; + cpuset_t cpus; /* * The digital temperature reading is located at bit 16 @@ -327,27 +345,24 @@ coretemp_get_thermal_msr(int cpu) * The temperature is computed by subtracting the temperature * reading by Tj(max). */ - msr = rdmsr(MSR_THERM_STATUS); - - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); - - return (msr); + args.msr = MSR_THERM_STATUS; + CPU_SETOF(cpu, &cpus); + smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_rdmsr, + smp_no_rendezvous_barrier, &args); + return (args.val); } static void coretemp_clear_thermal_msr(int cpu) { - thread_lock(curthread); - sched_bind(curthread, cpu); - thread_unlock(curthread); - - wrmsr(MSR_THERM_STATUS, 0); - - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); + struct coretemp_args args; + cpuset_t cpus; + + args.msr = MSR_THERM_STATUS; + args.val = 0; + CPU_SETOF(cpu, &cpus); + smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_wrmsr, + smp_no_rendezvous_barrier, &args); } static int From owner-dev-commits-src-all@freebsd.org Fri Aug 13 07:23:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 25F26651942; Fri, 13 Aug 2021 07:23: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 4GmFQp0XZxz4vsN; Fri, 13 Aug 2021 07:23: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 EEEFE1BCF; Fri, 13 Aug 2021 07:23: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 17D7NTES066263; Fri, 13 Aug 2021 07:23:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D7NTuB066262; Fri, 13 Aug 2021 07:23:29 GMT (envelope-from git) Date: Fri, 13 Aug 2021 07:23:29 GMT Message-Id: <202108130723.17D7NTuB066262@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 6b66194bcb7e - main - ipsec: Check PMTU before sending a frame. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6b66194bcb7e43ef40b11005618544081c6e30ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 07:23:30 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=6b66194bcb7e43ef40b11005618544081c6e30ea commit 6b66194bcb7e43ef40b11005618544081c6e30ea Author: Kornel Duleba AuthorDate: 2021-08-13 07:20:46 +0000 Commit: Wojciech Macek CommitDate: 2021-08-13 07:22:24 +0000 ipsec: Check PMTU before sending a frame. If an encapsulated frame is going to have DF bit set check its desitnitions' PMTU and if it won't fit drop it and: Generate ICMP 3/4 message if the packet was to be forwarded. Return EMSGSIZE error otherwise. Obtained from: Semihalf Sponsored by: Stormshield Differential revision: https://reviews.freebsd.org/D30993 --- sys/netipsec/ipsec.c | 2 +- sys/netipsec/ipsec.h | 2 ++ sys/netipsec/ipsec_output.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/sys/netipsec/ipsec.c b/sys/netipsec/ipsec.c index dcc607a5b617..07eb67641f7b 100644 --- a/sys/netipsec/ipsec.c +++ b/sys/netipsec/ipsec.c @@ -1093,7 +1093,7 @@ ipsec_in_reject(struct secpolicy *sp, struct inpcb *inp, const struct mbuf *m) * Compute the byte size to be occupied by IPsec header. * In case it is tunnelled, it includes the size of outer IP header. */ -static size_t +size_t ipsec_hdrsiz_internal(struct secpolicy *sp) { size_t size; diff --git a/sys/netipsec/ipsec.h b/sys/netipsec/ipsec.h index 1f5aa1a43edc..85360f9b737c 100644 --- a/sys/netipsec/ipsec.h +++ b/sys/netipsec/ipsec.h @@ -332,6 +332,7 @@ int ipsec_chkreplay(uint32_t, uint32_t *, struct secasvar *); int ipsec_updatereplay(uint32_t, struct secasvar *); int ipsec_updateid(struct secasvar *, crypto_session_t *, crypto_session_t *); int ipsec_initialized(void); +size_t ipsec_hdrsiz_internal(struct secpolicy *); void ipsec_setspidx_inpcb(struct inpcb *, struct secpolicyindex *, u_int); @@ -345,6 +346,7 @@ int ipsec4_output(struct mbuf *, struct inpcb *); int ipsec4_capability(struct mbuf *, u_int); int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int); int ipsec4_ctlinput(int, struct sockaddr *, void *); +int ipsec4_check_pmtu(struct mbuf *, struct secpolicy *, int); int ipsec4_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *); int ipsec_process_done(struct mbuf *, struct secpolicy *, struct secasvar *, u_int); diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c index 86f06fd10947..a817b67fd93e 100644 --- a/sys/netipsec/ipsec_output.c +++ b/sys/netipsec/ipsec_output.c @@ -61,6 +61,8 @@ #ifdef INET6 #include #endif +#include +#include #include #ifdef INET6 @@ -292,6 +294,83 @@ ipsec4_process_packet(struct mbuf *m, struct secpolicy *sp, return (ipsec4_perform_request(m, sp, inp, 0)); } +int +ipsec4_check_pmtu(struct mbuf *m, struct secpolicy *sp, int forwarding) +{ + union sockaddr_union *dst; + struct in_conninfo inc; + struct secasvar *sav; + struct ip *ip; + size_t hlen, pmtu; + uint32_t idx; + int error; + + + /* Don't check PMTU if the frame won't have DF bit set. */ + if (!V_ip4_ipsec_dfbit) + return (0); + if (V_ip4_ipsec_dfbit == 1) + goto setdf; + + /* V_ip4_ipsec_dfbit > 1 - we will copy it from inner header. */ + ip = mtod(m, struct ip *); + if (!(ip->ip_off & htons(IP_DF))) + return (0); + +setdf: + idx = sp->tcount - 1; + sav = ipsec4_allocsa(m, sp, &idx, &error); + if (sav == NULL) { + key_freesp(&sp); + if (error != EJUSTRETURN) + m_freem(m); + + return (error); + } + + dst = &sav->sah->saidx.dst; + + /* Final header is not ipv4. */ + if (dst->sa.sa_family != AF_INET) { + key_freesav(&sav); + return (0); + } + + memset(&inc, 0, sizeof(inc)); + inc.inc_faddr = satosin(&dst->sa)->sin_addr; + key_freesav(&sav); + pmtu = tcp_hc_getmtu(&inc); + /* No entry in hostcache. */ + if (pmtu == 0) + return (0); + + hlen = ipsec_hdrsiz_internal(sp); + if (m_length(m, NULL) + hlen > pmtu) { + /* + * If we're forwarding generate ICMP message here, + * so that it contains pmtu and not link mtu. + * Set error to EINPROGRESS, in order for the frame + * to be dropped silently. + */ + if (forwarding) { + if (pmtu > hlen) + icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG, + 0, pmtu - hlen); + else + m_freem(m); + + key_freesp(&sp); + return (EINPROGRESS); /* Pretend that we consumed it. */ + } else { + m_freem(m); + key_freesp(&sp); + return (EMSGSIZE); + } + } + + return (0); +} + static int ipsec4_common_output(struct mbuf *m, struct inpcb *inp, int forwarding) { @@ -349,6 +428,14 @@ ipsec4_common_output(struct mbuf *m, struct inpcb *inp, int forwarding) #endif } /* NB: callee frees mbuf and releases reference to SP */ + error = ipsec4_check_pmtu(m, sp, forwarding); + if (error != 0) { + if (error == EJUSTRETURN) + return (0); + + return (error); + } + error = ipsec4_process_packet(m, sp, inp); if (error == EJUSTRETURN) { /* From owner-dev-commits-src-all@freebsd.org Fri Aug 13 07:32:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 37E6965185D; Fri, 13 Aug 2021 07:32: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 4GmFd50y0lz3C4R; Fri, 13 Aug 2021 07:32: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 097A92311; Fri, 13 Aug 2021 07:32: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 17D7WOSI079105; Fri, 13 Aug 2021 07:32:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D7WObD079104; Fri, 13 Aug 2021 07:32:24 GMT (envelope-from git) Date: Fri, 13 Aug 2021 07:32:24 GMT Message-Id: <202108130732.17D7WObD079104@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: 40ec2323e689 - stable/13 - Fix panic in IPv6 multicast code. 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: 40ec2323e689e2b9bcede8e2f217b689e64f621f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 07:32:25 -0000 The branch stable/13 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=40ec2323e689e2b9bcede8e2f217b689e64f621f commit 40ec2323e689e2b9bcede8e2f217b689e64f621f Author: Andrey V. Elsukov AuthorDate: 2021-08-05 08:51:46 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-08-13 07:31:11 +0000 Fix panic in IPv6 multicast code. Add check that ifp supports IPv6 multicasts in in6_getmulti. This fixes panic when user application tries to join into multicast group on an interface that doesn't support IPv6 multicasts, like IFT_PFLOG interfaces. PR: 257302 Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D31420 (cherry picked from commit d477a7feed177d0ad5c12bc6e2cce804d427ed38) --- sys/netinet6/in6_mcast.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index 0744a1178fc7..7326befc6d01 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -374,9 +374,18 @@ in6_getmulti(struct ifnet *ifp, const struct in6_addr *group, IN6_MULTI_LIST_LOCK(); IF_ADDR_WLOCK(ifp); NET_EPOCH_ENTER(et); - inm = in6m_lookup_locked(ifp, group); + /* + * Does ifp support IPv6 multicasts? + */ + if (ifp->if_afdata[AF_INET6] == NULL) + error = ENODEV; + else + inm = in6m_lookup_locked(ifp, group); NET_EPOCH_EXIT(et); + if (error != 0) + goto out_locked; + if (inm != NULL) { /* * If we already joined this group, just bump the From owner-dev-commits-src-all@freebsd.org Fri Aug 13 07:36:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38165651870; Fri, 13 Aug 2021 07:36: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 4GmFk10bzzz3CV3; Fri, 13 Aug 2021 07:36: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 EBBED2137; Fri, 13 Aug 2021 07:36: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 17D7aeks079557; Fri, 13 Aug 2021 07:36:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D7aeX7079556; Fri, 13 Aug 2021 07:36:40 GMT (envelope-from git) Date: Fri, 13 Aug 2021 07:36:40 GMT Message-Id: <202108130736.17D7aeX7079556@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: a16771de4c1e - main - ipsec: Return error code if no matching SA was found MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a16771de4c1e01b52318edfab315d0ba2dce0c65 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 07:36:41 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=a16771de4c1e01b52318edfab315d0ba2dce0c65 commit a16771de4c1e01b52318edfab315d0ba2dce0c65 Author: Kornel Duleba AuthorDate: 2021-08-13 07:35:08 +0000 Commit: Wojciech Macek CommitDate: 2021-08-13 07:35:08 +0000 ipsec: Return error code if no matching SA was found If we matched SP to a packet, but no associated SA was found ipsec4_allocsa will return NULL while setting error=0. This resulted in use after free and potential kernel panic. Return EINPROGRESS if the case described above instead. Obtained from: Semihalf Sponsored by: Stormshield Differential revision: https://reviews.freebsd.org/D30994 --- sys/netipsec/ipsec_output.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c index a817b67fd93e..2f8cc12c526b 100644 --- a/sys/netipsec/ipsec_output.c +++ b/sys/netipsec/ipsec_output.c @@ -322,6 +322,12 @@ setdf: sav = ipsec4_allocsa(m, sp, &idx, &error); if (sav == NULL) { key_freesp(&sp); + /* + * No matching SA was found and SADB_ACQUIRE message was generated. + * Since we have matched a SP to this packet drop it silently. + */ + if (error == 0) + error = EINPROGRESS; if (error != EJUSTRETURN) m_freem(m); From owner-dev-commits-src-all@freebsd.org Fri Aug 13 07:39:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3DAA76521F7; Fri, 13 Aug 2021 07:39:01 +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 4GmFmj0lL0z3Cgj; Fri, 13 Aug 2021 07:39: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 024FE22A5; Fri, 13 Aug 2021 07:39: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 17D7d0F1079827; Fri, 13 Aug 2021 07:39:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D7d0BH079826; Fri, 13 Aug 2021 07:39:00 GMT (envelope-from git) Date: Fri, 13 Aug 2021 07:39:00 GMT Message-Id: <202108130739.17D7d0BH079826@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: 6144be57c0ab - stable/12 - Fix panic in IPv6 multicast code. 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: 6144be57c0ab08ddeb1a729f698f0997fe142b96 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 07:39:01 -0000 The branch stable/12 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=6144be57c0ab08ddeb1a729f698f0997fe142b96 commit 6144be57c0ab08ddeb1a729f698f0997fe142b96 Author: Andrey V. Elsukov AuthorDate: 2021-08-05 08:51:46 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-08-13 07:37:39 +0000 Fix panic in IPv6 multicast code. Add check that ifp supports IPv6 multicasts in in6_getmulti. This fixes panic when user application tries to join into multicast group on an interface that doesn't support IPv6 multicasts, like IFT_PFLOG interfaces. PR: 257302 Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D31420 (cherry picked from commit d477a7feed177d0ad5c12bc6e2cce804d427ed38) --- sys/netinet6/in6_mcast.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index bd202e76c6b6..46ed091a193e 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -372,9 +372,18 @@ in6_getmulti(struct ifnet *ifp, const struct in6_addr *group, IN6_MULTI_LIST_LOCK(); IF_ADDR_WLOCK(ifp); NET_EPOCH_ENTER_ET(et); - inm = in6m_lookup_locked(ifp, group); + /* + * Does ifp support IPv6 multicasts? + */ + if (ifp->if_afdata[AF_INET6] == NULL) + error = ENODEV; + else + inm = in6m_lookup_locked(ifp, group); NET_EPOCH_EXIT_ET(et); + if (error != 0) + goto out_locked; + if (inm != NULL) { /* * If we already joined this group, just bump the From owner-dev-commits-src-all@freebsd.org Fri Aug 13 08:36:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8FBA8652C75; Fri, 13 Aug 2021 08:36: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 4GmH3Y3Ntgz3HNN; Fri, 13 Aug 2021 08:36: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 5C3CB2C60; Fri, 13 Aug 2021 08:36: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 17D8avuU058863; Fri, 13 Aug 2021 08:36:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D8avq4058862; Fri, 13 Aug 2021 08:36:57 GMT (envelope-from git) Date: Fri, 13 Aug 2021 08:36:57 GMT Message-Id: <202108130836.17D8avq4058862@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: d4da692862f1 - main - linux(4): Improve comment. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d4da692862f195b8e98cbaeadbd97eb003cda92a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 08:36:57 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=d4da692862f195b8e98cbaeadbd97eb003cda92a commit d4da692862f195b8e98cbaeadbd97eb003cda92a Author: Dmitry Chagin AuthorDate: 2021-08-13 08:36:42 +0000 Commit: Dmitry Chagin CommitDate: 2021-08-13 08:36:42 +0000 linux(4): Improve comment. Reported by: pfg MFC after: 2 weeks --- sys/compat/linux/linux_futex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index e85d7792841b..a194e0ac7962 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -306,7 +306,7 @@ linux_futex(struct thread *td, struct linux_futex_args *args) * * And since commit * https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ed19993b5b0d05d62cc883571519a67dae481a14 - * glibc does not uses it. + * glibc does not use them. */ case LINUX_FUTEX_WAIT_REQUEUE_PI: /* not yet implemented */ From owner-dev-commits-src-all@freebsd.org Fri Aug 13 09:07:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9A1F6529FB; Fri, 13 Aug 2021 09:07: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 4GmHkj4PGQz3Kc4; Fri, 13 Aug 2021 09:07: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 7F33F3722; Fri, 13 Aug 2021 09:07: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 17D97Pw3099604; Fri, 13 Aug 2021 09:07:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D97Pk2099603; Fri, 13 Aug 2021 09:07:25 GMT (envelope-from git) Date: Fri, 13 Aug 2021 09:07:25 GMT Message-Id: <202108130907.17D97Pk2099603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: f61cb12aac8d - main - mroute: fix locking issues MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f61cb12aac8df8179ac9cbd075272aed6524a505 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 09:07:25 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=f61cb12aac8df8179ac9cbd075272aed6524a505 commit f61cb12aac8df8179ac9cbd075272aed6524a505 Author: Wojciech Macek AuthorDate: 2021-08-11 07:04:20 +0000 Commit: Wojciech Macek CommitDate: 2021-08-13 09:06:17 +0000 mroute: fix locking issues In some cases the code may fall into deadlock. Avoid calling epoch_wait when W-lock is taken. Sponsored by: Stormshield Obtained from: Semihalf --- sys/netinet/ip_mroute.c | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index b614f74cf7d3..efb34af60d9c 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #define _PIM_VT 1 +#include #include #include #include @@ -100,6 +101,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -727,7 +729,7 @@ ip_mrouter_init(struct socket *so, int version) curvnet); V_ip_mrouter = so; - ip_mrouter_cnt++; + atomic_add_int(&ip_mrouter_cnt, 1); /* This is a mutex required by buf_ring init, but not used internally */ mtx_init(&V_buf_ring_mtx, "mroute buf_ring mtx", NULL, MTX_DEF); @@ -750,22 +752,20 @@ X_ip_mrouter_done(void) vifi_t vifi; struct bw_upcall *bu; - MRW_WLOCK(); - - if (V_ip_mrouter == NULL) { - MRW_WUNLOCK(); + if (V_ip_mrouter == NULL) return EINVAL; - } /* * Detach/disable hooks to the reset of the system. */ V_ip_mrouter = NULL; - ip_mrouter_cnt--; + atomic_subtract_int(&ip_mrouter_cnt, 1); V_mrt_api_config = 0; MROUTER_WAIT(); + MRW_WLOCK(); + upcall_thread_shutdown = 1; mtx_lock(&V_upcall_thread_mtx); cv_signal(&V_upcall_thread_cv); @@ -896,25 +896,17 @@ add_vif(struct vifctl *vifcp) struct ifnet *ifp; int error; - MRW_WLOCK(); - if (vifcp->vifc_vifi >= MAXVIFS) { - MRW_WUNLOCK(); + + if (vifcp->vifc_vifi >= MAXVIFS) return EINVAL; - } /* rate limiting is no longer supported by this code */ if (vifcp->vifc_rate_limit != 0) { log(LOG_ERR, "rate limiting is no longer supported\n"); - MRW_WUNLOCK(); return EINVAL; } - if (!in_nullhost(vifp->v_lcl_addr)) { - MRW_WUNLOCK(); - return EADDRINUSE; - } - if (in_nullhost(vifcp->vifc_lcl_addr)) { - MRW_WUNLOCK(); + + if (in_nullhost(vifcp->vifc_lcl_addr)) return EADDRNOTAVAIL; - } /* Find the interface with an address in AF_INET family */ if (vifcp->vifc_flags & VIFF_REGISTER) { @@ -932,7 +924,6 @@ add_vif(struct vifctl *vifcp) ifa = ifa_ifwithaddr((struct sockaddr *)&sin); if (ifa == NULL) { NET_EPOCH_EXIT(et); - MRW_WUNLOCK(); return EADDRNOTAVAIL; } ifp = ifa->ifa_ifp; @@ -942,7 +933,6 @@ add_vif(struct vifctl *vifcp) if ((vifcp->vifc_flags & VIFF_TUNNEL) != 0) { CTR1(KTR_IPMF, "%s: tunnels are no longer supported", __func__); - MRW_WUNLOCK(); return EOPNOTSUPP; } else if (vifcp->vifc_flags & VIFF_REGISTER) { ifp = V_multicast_register_if = if_alloc(IFT_LOOP); @@ -952,17 +942,24 @@ add_vif(struct vifctl *vifcp) V_reg_vif_num = vifcp->vifc_vifi; } } else { /* Make sure the interface supports multicast */ - if ((ifp->if_flags & IFF_MULTICAST) == 0) { - MRW_WUNLOCK(); + if ((ifp->if_flags & IFF_MULTICAST) == 0) return EOPNOTSUPP; - } /* Enable promiscuous reception of all IP multicasts from the if */ error = if_allmulti(ifp, 1); - if (error) { - MRW_WUNLOCK(); + if (error) return error; - } + } + + MRW_WLOCK(); + + if (!in_nullhost(vifp->v_lcl_addr)) { + if (ifp) + V_multicast_register_if = NULL; + MRW_WUNLOCK(); + if (ifp) + if_free(ifp); + return EADDRINUSE; } vifp->v_flags = vifcp->vifc_flags; @@ -1014,8 +1011,11 @@ del_vif_locked(vifi_t vifi) if (vifp->v_flags & VIFF_REGISTER) { V_reg_vif_num = VIFI_INVALID; - if_free(V_multicast_register_if); - V_multicast_register_if = NULL; + if (vifp->v_ifp) { + if (vifp->v_ifp == V_multicast_register_if) + V_multicast_register_if = NULL; + if_free(vifp->v_ifp); + } } mtx_destroy(&vifp->v_spin); From owner-dev-commits-src-all@freebsd.org Fri Aug 13 09:35:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A791A653959; Fri, 13 Aug 2021 09:35: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 4GmJLk4JQ0z3LcB; Fri, 13 Aug 2021 09:35: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 77DB63CA7; Fri, 13 Aug 2021 09:35: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 17D9ZAEu039065; Fri, 13 Aug 2021 09:35:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D9ZAt3039064; Fri, 13 Aug 2021 09:35:10 GMT (envelope-from git) Date: Fri, 13 Aug 2021 09:35:10 GMT Message-Id: <202108130935.17D9ZAt3039064@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: 95b63f103bfd - stable/13 - netipsec/keydb.h: 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: 95b63f103bfd29505678f095c263278e45f09592 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 09:35:10 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=95b63f103bfd29505678f095c263278e45f09592 commit 95b63f103bfd29505678f095c263278e45f09592 Author: Konstantin Belousov AuthorDate: 2021-07-31 01:41:13 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 09:34:42 +0000 netipsec/keydb.h: fix typo (cherry picked from commit fd4751b3892973f3d329f6fb516da6b01be6f71f) --- sys/netipsec/keydb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netipsec/keydb.h b/sys/netipsec/keydb.h index e3c1417a2f9a..69c1cb29db34 100644 --- a/sys/netipsec/keydb.h +++ b/sys/netipsec/keydb.h @@ -55,7 +55,7 @@ union sockaddr_union { }; #endif /* _SOCKADDR_UNION_DEFINED */ -/* Security Assocciation Index */ +/* Security Association Index */ /* NOTE: Ensure to be same address family */ struct secasindex { union sockaddr_union src; /* source address for SA */ From owner-dev-commits-src-all@freebsd.org Fri Aug 13 09:35:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE764653A32; Fri, 13 Aug 2021 09:35: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 4GmJLl4gRjz3M2W; Fri, 13 Aug 2021 09:35: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 843103CA8; Fri, 13 Aug 2021 09:35: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 17D9ZBkx039089; Fri, 13 Aug 2021 09:35:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D9ZBkI039088; Fri, 13 Aug 2021 09:35:11 GMT (envelope-from git) Date: Fri, 13 Aug 2021 09:35:11 GMT Message-Id: <202108130935.17D9ZBkI039088@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: 3a8f4c41fb17 - stable/13 - netipsec/key.c: Use ANSI C definition for key_random() 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: 3a8f4c41fb1751e83af7ef45d1f2f1e3969669ac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 09:35:11 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3a8f4c41fb1751e83af7ef45d1f2f1e3969669ac commit 3a8f4c41fb1751e83af7ef45d1f2f1e3969669ac Author: Konstantin Belousov AuthorDate: 2021-08-03 01:24:31 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 09:34:42 +0000 netipsec/key.c: Use ANSI C definition for key_random() (cherry picked from commit 8b000bf5bcddea30e66e0b4e1158e2d7b328b262) --- sys/netipsec/key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 86dc9ea41024..71eaac7f8fa3 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -4739,7 +4739,7 @@ key_timehandler(void *arg) } u_long -key_random() +key_random(void) { u_long value; From owner-dev-commits-src-all@freebsd.org Fri Aug 13 09:35:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0281265400B; Fri, 13 Aug 2021 09:35: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 4GmJLm6Ckcz3M0C; Fri, 13 Aug 2021 09:35: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 AAF9437DE; Fri, 13 Aug 2021 09:35: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 17D9ZC2f039113; Fri, 13 Aug 2021 09:35:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D9ZCO5039112; Fri, 13 Aug 2021 09:35:12 GMT (envelope-from git) Date: Fri, 13 Aug 2021 09:35:12 GMT Message-Id: <202108130935.17D9ZCO5039112@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: 0896bbff7ff3 - stable/13 - ip(4): Mention IP_IPSEC_POLICY ip-level socket option 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: 0896bbff7ff3799688574a0393791277d770cc6c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 09:35:13 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0896bbff7ff3799688574a0393791277d770cc6c commit 0896bbff7ff3799688574a0393791277d770cc6c Author: Konstantin Belousov AuthorDate: 2021-08-09 11:07:18 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 09:34:42 +0000 ip(4): Mention IP_IPSEC_POLICY ip-level socket option (cherry picked from commit 4a5a67fe679d6b29957bf87dbf2e7c08ff97bb30) --- share/man/man4/ip.4 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ip.4 b/share/man/man4/ip.4 index c53cd3d5aeda..24b06846e66f 100644 --- a/share/man/man4/ip.4 +++ b/share/man/man4/ip.4 @@ -28,7 +28,7 @@ .\" @(#)ip.4 8.2 (Berkeley) 11/30/93 .\" $FreeBSD$ .\" -.Dd May 24, 2020 +.Dd August 9, 2021 .Dt IP 4 .Os .Sh NAME @@ -109,6 +109,15 @@ int ttl = 60; /* max = 255 */ setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)); .Ed .Pp +.Dv IP_IPSEC_POLICY +controls IPSec policy for sockets. +For example, +.Bd -literal +const char *policy = "in ipsec ah/transport//require"; +char *buf = ipsec_set_policy(policy, strlen(policy)); +setsockopt(s, IPPROTO_IP, IP_IPSEC_POLICY, buf, ipsec_get_policylen(buf)); +.Ed +.Pp .Dv IP_MINTTL may be used to set the minimum acceptable TTL a packet must have when received on a socket. From owner-dev-commits-src-all@freebsd.org Fri Aug 13 09:35:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 065A1653A37; Fri, 13 Aug 2021 09:35: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 4GmJLn6ZlHz3LnJ; Fri, 13 Aug 2021 09:35: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 CAA0E3C32; Fri, 13 Aug 2021 09:35: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 17D9ZDgO039139; Fri, 13 Aug 2021 09:35:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D9ZD20039138; Fri, 13 Aug 2021 09:35:13 GMT (envelope-from git) Date: Fri, 13 Aug 2021 09:35:13 GMT Message-Id: <202108130935.17D9ZD20039138@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: c24e3f5d44b7 - stable/13 - ipsec_set_policy(3): fix sentence 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: c24e3f5d44b7a88690913655de20cb4e26b01af6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 09:35:14 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c24e3f5d44b7a88690913655de20cb4e26b01af6 commit c24e3f5d44b7a88690913655de20cb4e26b01af6 Author: Konstantin Belousov AuthorDate: 2021-08-09 10:37:41 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 09:34:42 +0000 ipsec_set_policy(3): fix sentence (cherry picked from commit ba3896e16913fd6f9f227d84038171f1fdf5496b) --- lib/libipsec/ipsec_set_policy.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libipsec/ipsec_set_policy.3 b/lib/libipsec/ipsec_set_policy.3 index 1e24b63e6c04..25ef8cbe32cf 100644 --- a/lib/libipsec/ipsec_set_policy.3 +++ b/lib/libipsec/ipsec_set_policy.3 @@ -71,7 +71,7 @@ library function. .Pp The .Fn ipsec_get_policylen -function will returns the of the buffer which is needed when passing +function returns the length of the buffer which is needed when passing the specification structure to the .Xr setsockopt 2 system call. From owner-dev-commits-src-all@freebsd.org Fri Aug 13 09:52:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C4DBD6540ED; Fri, 13 Aug 2021 09:52:51 +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 4GmJl752vxz3Mgc; Fri, 13 Aug 2021 09:52: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 9517843B1; Fri, 13 Aug 2021 09:52: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 17D9qpuZ065389; Fri, 13 Aug 2021 09:52:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D9qoMs065388; Fri, 13 Aug 2021 09:52:50 GMT (envelope-from git) Date: Fri, 13 Aug 2021 09:52:50 GMT Message-Id: <202108130952.17D9qoMs065388@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Stefan E=C3=9Fer?= Subject: git: 44d4804d1945 - main - =?utf-8?Q?usr.bin/gh=C3=A4-bc, contrib/bc: update to version 5.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/main X-Git-Reftype: branch X-Git-Commit: 44d4804d1945435745518cd09eb8ae6ab22ecef4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 09:52:51 -0000 The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=44d4804d1945435745518cd09eb8ae6ab22ecef4 commit 44d4804d1945435745518cd09eb8ae6ab22ecef4 Author: Stefan Eßer AuthorDate: 2021-08-10 08:42:54 +0000 Commit: Stefan Eßer CommitDate: 2021-08-13 09:28:06 +0000 usr.bin/ghä-bc, contrib/bc: update to version 5.0.0 Merge commit 2f57ecae4b98e76e5d675563785a7e6c59c868c4 This is a new major release with a number of changes and extensions: - Limited the number of temporary numbers and made the space for them static so that allocating more space for them cannot fail. - Allowed integers with non-zero scale to be used with power, places, and shift operators. - Added greatest common divisor and least common multiple to lib2.bc. - Made bc and dc UTF-8 capable. - Added the ability for users to have bc and dc quit on SIGINT. - Added the ability for users to disable prompt and TTY mode by environment variables. - Added the ability for users to redefine keywords. - Added dc's modular exponentiation and divmod to bc. - Added the ability to assign strings to variables and array elements and pass them to functions in bc. - Added dc's asciify command and stream printing to bc. - Added bitwise and, or, xor, left shift, right shift, reverse, left rotate, right rotate, and mod functions to lib2.bc. - Added the functions s2u(x) and s2un(x,n), to lib2.bc. MFC after: 1 week --- contrib/bc/.gitattributes | 2 +- contrib/bc/.gitignore | 8 +- contrib/bc/LICENSE.md | 14 +- contrib/bc/Makefile.in | 217 +- contrib/bc/NEWS.md | 61 +- contrib/bc/README.md | 50 +- contrib/bc/RELEASE.md | 54 - contrib/bc/bc.vcxproj | 80 +- contrib/bc/bcl.vcxproj | 24 +- contrib/bc/benchmarks/bc/add.bc | 21 + .../fuzzing/bc.dict => benchmarks/bc/arrays.bc} | 44 +- contrib/bc/benchmarks/bc/arrays_and_constants.bc | 35 + contrib/bc/benchmarks/bc/bitfuncs.bc | 18 + .../{tests/diff.sh => benchmarks/bc/constants.bc} | 30 +- contrib/bc/benchmarks/bc/divide.bc | 26 + contrib/bc/benchmarks/bc/functions.bc | 34 + contrib/bc/benchmarks/bc/irand_long.bc | 9 + contrib/bc/benchmarks/bc/irand_short.bc | 5 + contrib/bc/benchmarks/bc/lib.bc | 7 + contrib/bc/benchmarks/bc/multiply.bc | 23 + contrib/bc/benchmarks/bc/postfix_incdec.bc | 7 + contrib/bc/benchmarks/bc/power.bc | 2 + contrib/bc/benchmarks/bc/strings.bc | 36 + contrib/bc/benchmarks/bc/subtract.bc | 22 + contrib/bc/benchmarks/dc/modexp.dc | 42 + contrib/bc/configure | 1322 +---- contrib/bc/configure.sh | 383 +- contrib/bc/gen/bc_help.txt | 52 + contrib/bc/gen/dc_help.txt | 30 + contrib/bc/gen/lib.bc | 2 +- contrib/bc/gen/lib2.bc | 247 +- contrib/bc/gen/strgen.c | 112 +- contrib/bc/gen/strgen.sh | 3 + contrib/bc/include/args.h | 11 +- contrib/bc/include/bc.h | 302 +- contrib/bc/include/bcl.h | 139 +- contrib/bc/include/dc.h | 42 +- contrib/bc/include/file.h | 88 + contrib/bc/include/history.h | 106 +- contrib/bc/include/lang.h | 432 +- contrib/bc/include/lex.h | 362 +- contrib/bc/include/library.h | 90 +- contrib/bc/include/num.h | 646 ++- contrib/bc/include/opt.h | 61 + contrib/bc/include/parse.h | 182 +- contrib/bc/include/program.h | 812 ++- contrib/bc/include/rand.h | 326 +- contrib/bc/include/read.h | 42 +- contrib/bc/include/status.h | 642 ++- contrib/bc/include/vector.h | 378 +- contrib/bc/include/version.h | 5 +- contrib/bc/include/vm.h | 680 ++- contrib/bc/locales/de_DE.ISO8859-1.msg | 13 +- contrib/bc/locales/de_DE.UTF-8.msg | 13 +- contrib/bc/locales/en_US.msg | 13 +- contrib/bc/locales/es_ES.ISO8859-1.msg | 13 +- contrib/bc/locales/es_ES.UTF-8.msg | 13 +- contrib/bc/locales/fr_FR.ISO8859-1.msg | 13 +- contrib/bc/locales/fr_FR.UTF-8.msg | 13 +- contrib/bc/locales/ja_JP.UTF-8.msg | 32 +- contrib/bc/locales/ja_JP.eucJP.msg | 32 +- contrib/bc/locales/nl_NL.ISO8859-1.msg | 22 +- contrib/bc/locales/nl_NL.UTF-8.msg | 22 +- contrib/bc/locales/pl_PL.ISO8859-2.msg | 22 +- contrib/bc/locales/pl_PL.UTF-8.msg | 22 +- contrib/bc/locales/pt_PT.ISO8859-1.msg | 13 +- contrib/bc/locales/pt_PT.UTF-8.msg | 13 +- contrib/bc/locales/ru_RU.CP1251.msg | 22 +- contrib/bc/locales/ru_RU.CP866.msg | 22 +- contrib/bc/locales/ru_RU.ISO8859-5.msg | 22 +- contrib/bc/locales/ru_RU.KOI8-R.msg | 15 +- contrib/bc/locales/ru_RU.UTF-8.msg | 22 +- contrib/bc/locales/zh_CN.GB18030.msg | 17 +- contrib/bc/locales/zh_CN.GB2312.msg | 17 +- contrib/bc/locales/zh_CN.GBK.msg | 17 +- contrib/bc/locales/zh_CN.UTF-8.msg | 15 +- contrib/bc/locales/zh_CN.eucCN.msg | 17 +- contrib/bc/manpage.sh | 131 - contrib/bc/manuals/algorithms.md | 162 +- contrib/bc/manuals/bc.1.md.in | 1840 ------- contrib/bc/manuals/bc/A.1 | 2575 ++++++---- contrib/bc/manuals/bc/A.1.md | 663 ++- contrib/bc/manuals/bc/E.1 | 1287 +++-- contrib/bc/manuals/bc/E.1.md | 324 +- contrib/bc/manuals/bc/EH.1 | 1258 +++-- contrib/bc/manuals/bc/EH.1.md | 296 +- contrib/bc/manuals/bc/EHN.1 | 1258 +++-- contrib/bc/manuals/bc/EHN.1.md | 296 +- contrib/bc/manuals/bc/EHNP.1 | 1375 ----- contrib/bc/manuals/bc/EHNP.1.md | 1069 ---- contrib/bc/manuals/bc/EHP.1 | 1382 ----- contrib/bc/manuals/bc/EHP.1.md | 1077 ---- contrib/bc/manuals/bc/EN.1 | 1287 +++-- contrib/bc/manuals/bc/EN.1.md | 324 +- contrib/bc/manuals/bc/ENP.1 | 1393 ----- contrib/bc/manuals/bc/ENP.1.md | 1085 ---- contrib/bc/manuals/bc/EP.1 | 1400 ----- contrib/bc/manuals/bc/EP.1.md | 1093 ---- contrib/bc/manuals/bc/H.1 | 2548 +++++---- contrib/bc/manuals/bc/H.1.md | 640 ++- contrib/bc/manuals/bc/HN.1 | 2548 +++++---- contrib/bc/manuals/bc/HN.1.md | 640 ++- contrib/bc/manuals/bc/HNP.1 | 2223 -------- contrib/bc/manuals/bc/HNP.1.md | 1679 ------ contrib/bc/manuals/bc/HP.1 | 2230 -------- contrib/bc/manuals/bc/HP.1.md | 1687 ------ contrib/bc/manuals/bc/N.1 | 2575 ++++++---- contrib/bc/manuals/bc/N.1.md | 663 ++- contrib/bc/manuals/bc/NP.1 | 2243 -------- contrib/bc/manuals/bc/NP.1.md | 1696 ------ contrib/bc/manuals/bc/P.1 | 2250 -------- contrib/bc/manuals/bc/P.1.md | 1704 ------ contrib/bc/manuals/bcl.3 | 1757 +++---- contrib/bc/manuals/bcl.3.md | 253 +- contrib/bc/manuals/benchmarks.md | 673 --- contrib/bc/manuals/build.md | 207 +- contrib/bc/manuals/dc.1.md.in | 1289 ----- contrib/bc/manuals/dc/A.1 | 1606 +++--- contrib/bc/manuals/dc/A.1.md | 237 +- contrib/bc/manuals/dc/E.1 | 1418 +++-- contrib/bc/manuals/dc/E.1.md | 237 +- contrib/bc/manuals/dc/EH.1 | 1387 +++-- contrib/bc/manuals/dc/EH.1.md | 213 +- contrib/bc/manuals/dc/EHN.1 | 1387 +++-- contrib/bc/manuals/dc/EHN.1.md | 211 +- contrib/bc/manuals/dc/EHNP.1 | 1307 ----- contrib/bc/manuals/dc/EHNP.1.md | 1023 ---- contrib/bc/manuals/dc/EHP.1 | 1311 ----- contrib/bc/manuals/dc/EHP.1.md | 1028 ---- contrib/bc/manuals/dc/EN.1 | 1416 +++-- contrib/bc/manuals/dc/EN.1.md | 235 +- contrib/bc/manuals/dc/ENP.1 | 1322 ----- contrib/bc/manuals/dc/ENP.1.md | 1036 ---- contrib/bc/manuals/dc/EP.1 | 1326 ----- contrib/bc/manuals/dc/EP.1.md | 1041 ---- contrib/bc/manuals/dc/H.1 | 1575 +++--- contrib/bc/manuals/dc/H.1.md | 213 +- contrib/bc/manuals/dc/HN.1 | 1575 +++--- contrib/bc/manuals/dc/HN.1.md | 211 +- contrib/bc/manuals/dc/HNP.1 | 1536 ------ contrib/bc/manuals/dc/HNP.1.md | 1190 ----- contrib/bc/manuals/dc/HP.1 | 1540 ------ contrib/bc/manuals/dc/HP.1.md | 1195 ----- contrib/bc/manuals/dc/N.1 | 1604 +++--- contrib/bc/manuals/dc/N.1.md | 235 +- contrib/bc/manuals/dc/NP.1 | 1551 ------ contrib/bc/manuals/dc/NP.1.md | 1203 ----- contrib/bc/manuals/dc/P.1 | 1555 ------ contrib/bc/manuals/dc/P.1.md | 1208 ----- contrib/bc/manuals/development.md | 4950 ++++++++++++++++++ contrib/bc/manuals/header.txt | 27 - contrib/bc/manuals/header_bc.txt | 1 - contrib/bc/manuals/header_bcl.txt | 1 - contrib/bc/manuals/header_dc.txt | 1 - contrib/bc/manuals/release.md | 72 + contrib/bc/{tests => scripts}/afl.py | 77 +- contrib/bc/scripts/alloc.sh | 84 + contrib/bc/scripts/benchmark.sh | 159 + contrib/bc/scripts/bitgen.c | 101 + contrib/bc/{ => scripts}/exec-install.sh | 6 +- contrib/bc/{ => scripts}/functions.sh | 68 +- contrib/bc/scripts/fuzz_prep.sh | 81 + contrib/bc/{ => scripts}/karatsuba.py | 29 +- contrib/bc/{ => scripts}/link.sh | 5 +- contrib/bc/{ => scripts}/locale_install.sh | 53 +- contrib/bc/{ => scripts}/locale_uninstall.sh | 1 + contrib/bc/scripts/manpage.sh | 175 + contrib/bc/scripts/ministat.c | 670 +++ contrib/bc/scripts/package.sh | 173 + contrib/bc/{tests => scripts}/radamsa.sh | 29 +- contrib/bc/{tests => scripts}/radamsa.txt | 0 contrib/bc/{tests => scripts}/randmath.py | 145 +- contrib/bc/{ => scripts}/release.sh | 290 +- contrib/bc/scripts/release_settings.txt | 16 + contrib/bc/{ => scripts}/safe-install.sh | 0 contrib/bc/scripts/test_settings.sh | 77 + contrib/bc/scripts/test_settings.txt | 93 + contrib/bc/src/args.c | 118 +- contrib/bc/src/bc.c | 11 +- contrib/bc/src/bc_lex.c | 84 +- contrib/bc/src/bc_parse.c | 866 +++- contrib/bc/src/data.c | 447 +- contrib/bc/src/dc.c | 11 +- contrib/bc/src/dc_lex.c | 91 +- contrib/bc/src/dc_parse.c | 93 +- contrib/bc/src/file.c | 63 +- contrib/bc/src/history.c | 648 ++- contrib/bc/src/lang.c | 131 +- contrib/bc/src/lex.c | 123 +- contrib/bc/src/library.c | 172 +- contrib/bc/src/main.c | 13 +- contrib/bc/src/num.c | 1583 ++++-- contrib/bc/src/opt.c | 129 +- contrib/bc/src/parse.c | 83 +- contrib/bc/src/program.c | 1925 +++++-- contrib/bc/src/rand.c | 185 +- contrib/bc/src/read.c | 87 +- contrib/bc/src/vector.c | 302 +- contrib/bc/src/vm.c | 695 ++- contrib/bc/tests/all.sh | 26 +- contrib/bc/tests/bc/all.txt | 9 +- contrib/bc/tests/bc/bitfuncs.txt | 5400 ++++++++++++++++++++ contrib/bc/tests/bc/bitfuncs_results.txt | 5400 ++++++++++++++++++++ contrib/bc/tests/bc/decimal.txt | 4 + contrib/bc/tests/bc/decimal_results.txt | 9 +- contrib/bc/tests/bc/divmod.txt | 64 + contrib/bc/tests/bc/divmod_results.txt | 126 + contrib/bc/tests/bc/errors.txt | 48 +- contrib/bc/tests/bc/errors/25.txt | 4 + contrib/bc/tests/bc/errors/26.txt | Bin 0 -> 317 bytes contrib/bc/tests/bc/errors/27.txt | 1 + contrib/bc/tests/bc/errors/28.txt | 2 + contrib/bc/tests/bc/errors/29.txt | 20 + contrib/bc/tests/bc/errors/30.txt | 3 + contrib/bc/tests/bc/errors/31.txt | 3 + contrib/bc/tests/bc/errors/32.txt | Bin 0 -> 1701 bytes contrib/bc/tests/bc/lib2.txt | 7 + contrib/bc/tests/bc/lib2_results.txt | 7 + contrib/bc/tests/bc/modexp.txt | 103 + contrib/bc/tests/bc/modexp_results.txt | 103 + contrib/bc/tests/bc/pi_results.txt | 3 +- contrib/bc/tests/bc/posix_errors.txt | 1 + contrib/bc/tests/bc/power.txt | 43 + contrib/bc/tests/bc/power_results.txt | 72 + contrib/bc/tests/bc/recursive_arrays.txt | 353 ++ contrib/bc/tests/bc/recursive_arrays_results.txt | 1 + contrib/bc/tests/bc/scripts/add.bc | 2 +- contrib/bc/tests/bc/scripts/all.txt | 9 +- contrib/bc/tests/bc/scripts/array.bc | 0 contrib/bc/tests/bc/scripts/atan.bc | 0 contrib/bc/tests/bc/scripts/bessel.bc | 0 contrib/bc/tests/bc/scripts/divide.bc | 1 + contrib/bc/tests/bc/scripts/globals.bc | 0 contrib/bc/tests/bc/scripts/multiply.bc | 1 + contrib/bc/tests/bc/scripts/parse.bc | 0 contrib/bc/tests/bc/scripts/print.bc | 0 contrib/bc/tests/bc/scripts/references.bc | 0 contrib/bc/tests/bc/scripts/screen.bc | 0 contrib/bc/tests/bc/scripts/strings2.bc | 7 + contrib/bc/tests/bc/scripts/subtract.bc | 2 +- contrib/bc/tests/bc/strings.txt | 61 + contrib/bc/tests/bc/strings_results.txt | 45 + contrib/bc/tests/bc/timeconst.sh | 22 +- contrib/bc/tests/bc/vars_results.txt | 3 +- contrib/bc/tests/bcl.c | 56 +- contrib/bc/tests/dc/all.txt | 2 + contrib/bc/tests/dc/decimal.txt | 5 + contrib/bc/tests/dc/decimal_results.txt | 11 +- contrib/bc/tests/dc/errors.txt | 4 + .../{fuzzing/dc_inputs/17.txt => dc/errors/32.txt} | 2 +- contrib/bc/tests/dc/errors/33.txt | Bin 0 -> 329 bytes .../{fuzzing/dc_inputs/26.txt => dc/errors/34.txt} | 104 +- contrib/bc/tests/dc/exec_stack_len.txt | 6 + contrib/bc/tests/dc/exec_stack_len_results.txt | 8 + contrib/bc/tests/dc/length.txt | 2 + contrib/bc/tests/dc/length_results.txt | 2 + contrib/bc/tests/dc/scientific.txt | 4 + contrib/bc/tests/dc/scientific_results.txt | 4 + contrib/bc/tests/dc/scripts/array.dc | 0 contrib/bc/tests/dc/scripts/asciify.dc | 0 contrib/bc/tests/dc/scripts/easter.sh | 4 +- contrib/bc/tests/dc/scripts/else.dc | 0 contrib/bc/tests/dc/scripts/factorial.dc | 0 contrib/bc/tests/dc/scripts/loop.dc | 0 contrib/bc/tests/dc/scripts/prime.dc | 0 contrib/bc/tests/dc/scripts/quit.dc | 0 contrib/bc/tests/dc/scripts/stream.dc | 2 +- contrib/bc/tests/dc/scripts/stream.txt | Bin 0 -> 130834 bytes contrib/bc/tests/dc/scripts/weird.dc | 0 contrib/bc/tests/dc/stack_len.txt | 15 + contrib/bc/tests/dc/stack_len_results.txt | 10 + contrib/bc/tests/dc/strings.txt | 1 + contrib/bc/tests/dc/strings_results.txt | 1 + contrib/bc/tests/errors.sh | 54 +- contrib/bc/tests/extra_required.txt | 1 + contrib/bc/tests/fuzzing/bc_afl.yaml | 125 + contrib/bc/tests/fuzzing/bc_afl_continue.yaml | 122 + contrib/bc/tests/fuzzing/bc_inputs1/abs.txt | 7 - contrib/bc/tests/fuzzing/bc_inputs1/add.txt | 146 - contrib/bc/tests/fuzzing/bc_inputs1/arctangent.txt | 26 - contrib/bc/tests/fuzzing/bc_inputs1/array.bc | 60 - contrib/bc/tests/fuzzing/bc_inputs1/arrays.txt | 10 - .../bc/tests/fuzzing/bc_inputs1/assignments.txt | 122 - contrib/bc/tests/fuzzing/bc_inputs1/basic.txt | 7 - contrib/bc/tests/fuzzing/bc_inputs1/boolean.txt | 184 - contrib/bc/tests/fuzzing/bc_inputs1/cosine.txt | 44 - contrib/bc/tests/fuzzing/bc_inputs1/decimal.txt | 35 - contrib/bc/tests/fuzzing/bc_inputs1/divide.txt | 31 - .../bc/tests/fuzzing/bc_inputs1/engineering.txt | 19 - contrib/bc/tests/fuzzing/bc_inputs1/exponent.txt | 22 - contrib/bc/tests/fuzzing/bc_inputs1/functions.bc | 7 - contrib/bc/tests/fuzzing/bc_inputs1/functions.txt | 13 - contrib/bc/tests/fuzzing/bc_inputs1/globals.txt | 21 - contrib/bc/tests/fuzzing/bc_inputs1/len.bc | 48 - contrib/bc/tests/fuzzing/bc_inputs1/length.txt | 59 - contrib/bc/tests/fuzzing/bc_inputs1/lib10.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib11.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib12.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs1/lib2.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs1/lib3.txt | 6 - contrib/bc/tests/fuzzing/bc_inputs1/lib4.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs1/lib5.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs1/lib6.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs1/lib7.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs1/lib8.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs1/strings.txt | 14 + contrib/bc/tests/fuzzing/bc_inputs2/lib13.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib15.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib19.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib20.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib21.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib22.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib23.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib24.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/log.txt | 22 - contrib/bc/tests/fuzzing/bc_inputs2/misc.txt | 13 - contrib/bc/tests/fuzzing/bc_inputs2/misc1.txt | 76 - contrib/bc/tests/fuzzing/bc_inputs2/misc2.txt | 110 - contrib/bc/tests/fuzzing/bc_inputs2/misc3.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs2/modulus.txt | 69 - contrib/bc/tests/fuzzing/bc_inputs2/multiply.txt | 40 - contrib/bc/tests/fuzzing/bc_inputs2/pi.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs2/places.txt | 19 - contrib/bc/tests/fuzzing/bc_inputs2/power.txt | 44 - contrib/bc/tests/fuzzing/bc_inputs2/print2.txt | 194 - contrib/bc/tests/fuzzing/bc_inputs2/references.bc | 408 -- contrib/bc/tests/fuzzing/bc_inputs2/scale.txt | 57 - contrib/bc/tests/fuzzing/bc_inputs2/scientific.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs2/shift.txt | 281 - contrib/bc/tests/fuzzing/bc_inputs2/sine.txt | 207 - contrib/bc/tests/fuzzing/bc_inputs3/01.txt | 339 -- contrib/bc/tests/fuzzing/bc_inputs3/02.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/03.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/04.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/05.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/06.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/07.txt | 8 - contrib/bc/tests/fuzzing/bc_inputs3/08.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/09.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/10.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/11.txt | 99 - contrib/bc/tests/fuzzing/bc_inputs3/12.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/13.txt | 56 - contrib/bc/tests/fuzzing/bc_inputs3/14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/15.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/17.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/18.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/19.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs3/20.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs3/21.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs3/22.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/23.txt | Bin 1024 -> 0 bytes contrib/bc/tests/fuzzing/bc_inputs3/24.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs3/sqrt.txt | 14 - contrib/bc/tests/fuzzing/bc_inputs3/strings.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs3/subtract.txt | 153 - contrib/bc/tests/fuzzing/bc_inputs3/trunc.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs3/void.txt | 20 - contrib/bc/tests/fuzzing/dc_inputs/01.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/02.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/03.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/04.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/05.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/06.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/07.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/08.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/09.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/10.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/11.txt | 4 - contrib/bc/tests/fuzzing/dc_inputs/12.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/13.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/14.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/15.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/16.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/18.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/19.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/20.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/21.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/22.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/23.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/24.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/25.txt | 6 - contrib/bc/tests/fuzzing/dc_inputs/27.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/28.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/29.txt | 13 - contrib/bc/tests/fuzzing/dc_inputs/30.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/31.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/abs.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/add.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/array.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/boolean.txt | 80 - contrib/bc/tests/fuzzing/dc_inputs/decimal.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/divide.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/divmod.txt | 64 - contrib/bc/tests/fuzzing/dc_inputs/else.dc | 4 - contrib/bc/tests/fuzzing/dc_inputs/engineering.txt | 19 - contrib/bc/tests/fuzzing/dc_inputs/loop.dc | 3 - contrib/bc/tests/fuzzing/dc_inputs/misc.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/modexp.txt | 103 - contrib/bc/tests/fuzzing/dc_inputs/modulus.txt | 70 - contrib/bc/tests/fuzzing/dc_inputs/multiply.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/places.txt | 14 - contrib/bc/tests/fuzzing/dc_inputs/power.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/quit.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/scientific.txt | 51 - contrib/bc/tests/fuzzing/dc_inputs/shift.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/sqrt.txt | 14 - contrib/bc/tests/fuzzing/dc_inputs/stack_len.txt | 1 + contrib/bc/tests/fuzzing/dc_inputs/stdin.txt | 205 - contrib/bc/tests/fuzzing/dc_inputs/stream.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/strings.txt | 50 - contrib/bc/tests/fuzzing/dc_inputs/subtract.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/trunc.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/vars.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/weird.dc | 2 - contrib/bc/tests/history.py | 1087 ++++ contrib/bc/tests/history.sh | 92 + contrib/bc/tests/other.sh | 90 +- contrib/bc/tests/read.sh | 21 +- contrib/bc/tests/script.sed | 9 + contrib/bc/tests/script.sh | 18 +- contrib/bc/tests/scripts.sh | 2 + contrib/bc/tests/stdin.sh | 15 +- contrib/bc/tests/test.sh | 13 +- usr.bin/gh-bc/Makefile | 20 +- usr.bin/gh-bc/tests/Makefile | 4 +- 429 files changed, 54578 insertions(+), 73081 deletions(-) diff --git a/contrib/bc/.gitattributes b/contrib/bc/.gitattributes index 22d6e60bce68..1e2c56dde215 100644 --- a/contrib/bc/.gitattributes +++ b/contrib/bc/.gitattributes @@ -1,3 +1,3 @@ *.vcxproj eol=crlf *.vcxproj.filters eol=crlf -*.sln eol= crlf +*.sln eol=crlf diff --git a/contrib/bc/.gitignore b/contrib/bc/.gitignore index b131d5813764..31e43aa61efc 100644 --- a/contrib/bc/.gitignore +++ b/contrib/bc/.gitignore @@ -51,11 +51,17 @@ print_results.txt bessel.txt bessel_results.txt prime.txt -stream.txt +strings2.txt +strings2_results.txt tests/bc/scripts/add.txt tests/bc/scripts/divide.txt tests/bc/scripts/multiply.txt tests/bc/scripts/subtract.txt +tests/bc/scripts/strings2.txt +benchmarks/bc/*.txt +benchmarks/dc/*.txt +scripts/ministat +scripts/bitgen perf.data perf.data.old *.gcda diff --git a/contrib/bc/LICENSE.md b/contrib/bc/LICENSE.md index 269e131cc81d..8ab2e6069881 100644 --- a/contrib/bc/LICENSE.md +++ b/contrib/bc/LICENSE.md @@ -79,9 +79,9 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -## `safe-install.sh` +## `scripts/safe-install.sh` -The file `safe-install.sh` is under the following copyright and license: +The file `scripts/safe-install.sh` is under the following copyright and license: Copyright (c) 2021 Rich Felker @@ -101,3 +101,13 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +## `scripts/ministat.c` + +The file `scripts/ministat.c` is under the following license: + +"THE BEER-WARE LICENSE" (Revision 42): + + wrote this file. As long as you retain this notice you +can do whatever you want with this stuff. If we meet some day, and you think +this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in index 2b50476a79fe..c3a41854fe9e 100644 --- a/contrib/bc/Makefile.in +++ b/contrib/bc/Makefile.in @@ -134,39 +134,64 @@ BC_ENABLE_HISTORY = %%HISTORY%% BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%% BC_ENABLE_NLS = %%NLS%% -BC_ENABLE_PROMPT = %%PROMPT%% BC_LONG_BIT = %%LONG_BIT%% BC_ENABLE_AFL = %%FUZZ%% BC_ENABLE_MEMCHECK = %%MEMCHECK%% +BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%% +BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%% +DC_DEFAULT_SIGINT_RESET = %%DC_DEFAULT_SIGINT_RESET%% +BC_DEFAULT_TTY_MODE = %%BC_DEFAULT_TTY_MODE%% +DC_DEFAULT_TTY_MODE = %%DC_DEFAULT_TTY_MODE%% +BC_DEFAULT_PROMPT = %%BC_DEFAULT_PROMPT%% +DC_DEFAULT_PROMPT = %%DC_DEFAULT_PROMPT%% + RM = rm MKDIR = mkdir -INSTALL = ./exec-install.sh -SAFE_INSTALL = ./safe-install.sh -LINK = ./link.sh -MANPAGE = ./manpage.sh -KARATSUBA = ./karatsuba.py -LOCALE_INSTALL = ./locale_install.sh -LOCALE_UNINSTALL = ./locale_uninstall.sh +SCRIPTS = ./scripts + +MINISTAT = ministat +MINISTAT_EXEC = $(SCRIPTS)/$(MINISTAT) + +BITFUNCGEN = bitfuncgen +BITFUNCGEN_EXEC = $(SCRIPTS)/$(BITFUNCGEN) + +INSTALL = $(SCRIPTS)/exec-install.sh +SAFE_INSTALL = $(SCRIPTS)/safe-install.sh +LINK = $(SCRIPTS)/link.sh +MANPAGE = $(SCRIPTS)/manpage.sh +KARATSUBA = $(SCRIPTS)/karatsuba.py +LOCALE_INSTALL = $(SCRIPTS)/locale_install.sh +LOCALE_UNINSTALL = $(SCRIPTS)/locale_uninstall.sh VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all -TEST_STARS = "***********************************************************************" +TEST_STARS = *********************************************************************** BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%% +BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER) +BC_DEFS1 = -DBC_DEFAULT_SIGINT_RESET=$(BC_DEFAULT_SIGINT_RESET) +BC_DEFS2 = -DBC_DEFAULT_TTY_MODE=$(BC_DEFAULT_TTY_MODE) +BC_DEFS3 = -DBC_DEFAULT_PROMPT=$(BC_DEFAULT_PROMPT) +BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3) +DC_DEFS1 = -DDC_DEFAULT_SIGINT_RESET=$(DC_DEFAULT_SIGINT_RESET) +DC_DEFS2 = -DDC_DEFAULT_TTY_MODE=$(DC_DEFAULT_TTY_MODE) +DC_DEFS3 = -DDC_DEFAULT_PROMPT=$(DC_DEFAULT_PROMPT) +DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) + CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED) 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 +CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 %%BSD%% CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN) -CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT) +CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH) CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY) CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL) -CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%% +CFLAGS = $(CPPFLAGS) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%% LDFLAGS = %%LDFLAGS%% HOSTCFLAGS = %%HOSTCFLAGS%% @@ -219,6 +244,12 @@ $(BIN): headers: %%HEADERS%% +$(MINISTAT): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(MINISTAT_EXEC) scripts/ministat.c + +$(BITFUNCGEN): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(BITFUNCGEN_EXEC) scripts/bitfuncgen.c + help: @printf 'available targets:\n' @printf '\n' @@ -249,16 +280,25 @@ help: @printf ' valgrind_dc runs the dc test suite, if dc has been built,\n' @printf ' through valgrind\n' -run_all_tests: +run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests history_all_tests + +bc_all_tests: %%BC_ALL_TESTS%% + +timeconst_all_tests: %%TIMECONST_ALL_TESTS%% + +dc_all_tests: %%DC_ALL_TESTS%% +history_all_tests: + %%HISTORY_TESTS%% + check: test test: %%TESTS%% -test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_stdin test_bc_read test_bc_errors test_bc_other +test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other @printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n' test_bc_tests:%%BC_TESTS%% @@ -275,12 +315,12 @@ test_bc_errors: @sh tests/errors.sh bc %%BC_TEST_EXEC%% test_bc_other: - @sh tests/other.sh bc %%BC_TEST_EXEC%% + @sh tests/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%% test_bc_header: @printf '$(TEST_STARS)\n\nRunning bc tests...\n\n' -test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_stdin test_dc_read test_dc_errors test_dc_other +test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other @printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n' test_dc_tests:%%DC_TESTS%% @@ -297,7 +337,7 @@ test_dc_errors: @sh tests/errors.sh dc %%DC_TEST_EXEC%% test_dc_other: - @sh tests/other.sh dc %%DC_TEST_EXEC%% + @sh tests/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%% test_dc_header: @printf '$(TEST_STARS)\n\nRunning dc tests...\n\n' @@ -305,6 +345,122 @@ test_dc_header: timeconst: %%TIMECONST%% +test_history: test_history_header test_bc_history test_dc_history + @printf '\nAll history tests passed.\n\n$(TEST_STARS)\n' + +test_bc_history:%%BC_HISTORY_TEST_PREREQS%% + +test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21 + +test_bc_history_skip: + @printf 'No bc history tests to run\n' + +test_bc_history0: + @sh tests/history.sh bc 0 %%BC_TEST_EXEC%% + +test_bc_history1: + @sh tests/history.sh bc 1 %%BC_TEST_EXEC%% + +test_bc_history2: + @sh tests/history.sh bc 2 %%BC_TEST_EXEC%% + +test_bc_history3: + @sh tests/history.sh bc 3 %%BC_TEST_EXEC%% + +test_bc_history4: + @sh tests/history.sh bc 4 %%BC_TEST_EXEC%% + +test_bc_history5: + @sh tests/history.sh bc 5 %%BC_TEST_EXEC%% + +test_bc_history6: + @sh tests/history.sh bc 6 %%BC_TEST_EXEC%% + +test_bc_history7: + @sh tests/history.sh bc 7 %%BC_TEST_EXEC%% + +test_bc_history8: + @sh tests/history.sh bc 8 %%BC_TEST_EXEC%% + +test_bc_history9: + @sh tests/history.sh bc 9 %%BC_TEST_EXEC%% + +test_bc_history10: + @sh tests/history.sh bc 10 %%BC_TEST_EXEC%% + +test_bc_history11: + @sh tests/history.sh bc 11 %%BC_TEST_EXEC%% + +test_bc_history12: + @sh tests/history.sh bc 12 %%BC_TEST_EXEC%% + +test_bc_history13: + @sh tests/history.sh bc 13 %%BC_TEST_EXEC%% + +test_bc_history14: + @sh tests/history.sh bc 14 %%BC_TEST_EXEC%% + +test_bc_history15: + @sh tests/history.sh bc 15 %%BC_TEST_EXEC%% + +test_bc_history16: + @sh tests/history.sh bc 16 %%BC_TEST_EXEC%% + +test_bc_history17: + @sh tests/history.sh bc 17 %%BC_TEST_EXEC%% + +test_bc_history18: + @sh tests/history.sh bc 18 %%BC_TEST_EXEC%% + +test_bc_history19: + @sh tests/history.sh bc 19 %%BC_TEST_EXEC%% + +test_bc_history20: + @sh tests/history.sh bc 20 %%BC_TEST_EXEC%% + +test_bc_history21: + @sh tests/history.sh bc 21 %%BC_TEST_EXEC%% + +test_dc_history:%%DC_HISTORY_TEST_PREREQS%% + +test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 + +test_dc_history_skip: + @printf 'No dc history tests to run\n' + +test_dc_history0: + @sh tests/history.sh dc 0 %%DC_TEST_EXEC%% + +test_dc_history1: + @sh tests/history.sh dc 1 %%DC_TEST_EXEC%% + +test_dc_history2: + @sh tests/history.sh dc 2 %%DC_TEST_EXEC%% + +test_dc_history3: + @sh tests/history.sh dc 3 %%DC_TEST_EXEC%% + +test_dc_history4: + @sh tests/history.sh dc 4 %%DC_TEST_EXEC%% + +test_dc_history5: + @sh tests/history.sh dc 5 %%DC_TEST_EXEC%% + +test_dc_history6: + @sh tests/history.sh dc 6 %%DC_TEST_EXEC%% + +test_dc_history7: + @sh tests/history.sh dc 7 %%DC_TEST_EXEC%% + +test_dc_history8: + @sh tests/history.sh dc 8 %%DC_TEST_EXEC%% + +test_dc_history9: + @sh tests/history.sh dc 9 %%DC_TEST_EXEC%% + +test_history_header: + @printf '$(TEST_STARS)\n\nRunning history tests...\n\n' + library_test: $(LIBBC) $(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST) @@ -322,12 +478,6 @@ coverage_output: coverage:%%COVERAGE_PREREQS%% -libcname: - @printf '%s' "$(BC_LIB_C)" - -extra_math: - @printf '%s' "$(BC_ENABLE_EXTRA_MATH)" - manpages: $(MANPAGE) bc $(MANPAGE) dc @@ -348,15 +498,19 @@ clean:%%CLEAN_PREREQS%% @$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O) @$(RM) -f $(BC_HELP_C) $(BC_HELP_O) @$(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 +clean_benchmarks: + @printf 'Cleaning benchmarks...\n' + @$(RM) -f $(MINISTAT_EXEC) + @$(RM) -f benchmarks/bc/*.txt + @$(RM) -f benchmarks/dc/*.txt + +clean_config: clean clean_benchmarks @printf 'Cleaning config...\n' @$(RM) -f Makefile - @$(RM) -f $(BC_MD) $(DC_MD) - @$(RM) -f $(BC_MANPAGE) $(DC_MANPAGE) + @$(RM) -f $(BC_MD) $(BC_MANPAGE) + @$(RM) -f $(DC_MD) $(DC_MANPAGE) clean_coverage: @printf 'Cleaning coverage files...\n' @@ -376,9 +530,12 @@ clean_coverage: clean_tests: clean clean_config clean_coverage @printf 'Cleaning test files...\n' + @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) + @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) @$(RM) -f tests/bc/parse.txt tests/bc/parse_results.txt @$(RM) -f tests/bc/print.txt tests/bc/print_results.txt @$(RM) -f tests/bc/bessel.txt tests/bc/bessel_results.txt + @$(RM) -f tests/bc/strings2.txt tests/bc/strings2_results.txt @$(RM) -f tests/bc/scripts/bessel.txt @$(RM) -f tests/bc/scripts/parse.txt @$(RM) -f tests/bc/scripts/print.txt @@ -386,13 +543,15 @@ clean_tests: clean clean_config clean_coverage @$(RM) -f tests/bc/scripts/divide.txt @$(RM) -f tests/bc/scripts/multiply.txt @$(RM) -f tests/bc/scripts/subtract.txt - @$(RM) -f tests/dc/scripts/prime.txt tests/dc/scripts/stream.txt + @$(RM) -f tests/bc/scripts/strings2.txt + @$(RM) -f tests/dc/scripts/prime.txt @$(RM) -f .log_*.txt @$(RM) -f .math.txt .results.txt .ops.txt @$(RM) -f .test.txt @$(RM) -f tags .gdbbreakpoints .gdb_history .gdbsetup @$(RM) -f cscope.* @$(RM) -f bc.old + @$(RM) -f $(BITFUNCGEN_EXEC) install_locales: %%INSTALL_LOCALES%% diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index c78bddd27e76..3b1477cafb26 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,55 @@ # News +## 5.0.0 + +This is a major production release with several changes: + +* Added support for OpenBSD's `pledge()` and `unveil()`. +* Fixed print bug where a backslash newline combo was printed even if only one + digit was left, something I blindly copied from GNU `bc`, like a fool. +* Fixed bugs in the manuals. +* Fixed a possible multiplication overflow in power. +* Temporary numbers are garbage collected if allocation fails, and the + allocation is retried. This is to make `bc` and `dc` more resilient to running + out of memory. +* Limited the number of temporary numbers and made the space for them static so + that allocating more space for them cannot fail. +* Allowed integers with non-zero `scale` to be used with power, places, and + shift operators. +* Added greatest common divisor and least common multiple to `lib2.bc`. +* Added `SIGQUIT` handling to history. +* Added a command to `dc` (`y`) to get the length of register stacks. +* Fixed multi-digit bugs in `lib2.bc`. +* Removed the no prompt build option. +* Created settings that builders can set defaults for and users can set their + preferences for. This includes the `bc` banner, resetting on `SIGINT`, TTY + mode, and prompt. +* Added history support to Windows. +* Fixed bugs with the handling of register names in `dc`. +* Fixed bugs with multi-line comments and strings in both calculators. +* Added a new error type and message for `dc` when register stacks don't have + enough items. +* Optimized string allocation. +* Made `bc` and `dc` UTF-8 capable. +* Fixed a bug with `void` functions. +* Fixed a misspelled symbol in `bcl`. This is technically a breaking change, + which requires this to be `5.0.0`. +* Added the ability for users to get the copyright banner back. +* Added the ability for users to have `bc` and `dc` quit on `SIGINT`. +* Added the ability for users to disable prompt and TTY mode by environment + variables. +* Added the ability for users to redefine keywords. This is another reason this + is `5.0.0`. +* Added `dc`'s modular exponentiation and divmod to `bc`. +* Added the ability to assign strings to variables and array elements and pass + them to functions in `bc`. +* Added `dc`'s asciify command and stream printing to `bc`. +* Added a command to `dc` (`Y`) to get the length of an array. +* Added a command to `dc` (`,`) to get the depth of the execution stack. +* Added bitwise and, or, xor, left shift, right shift, reverse, left rotate, + right rotate, and mod functions to `lib2.bc`. +* Added the functions `s2u(x)` and `s2un(x,n)`, to `lib2.bc`. + ## 4.0.2 This is a production release that fixes two bugs: @@ -310,8 +360,8 @@ running tests during install. **If `bc` segfaults while running arg tests when updating, it is because the global locale files have not been replaced. Make sure to either prevent the test suite from running on update or remove the old locale files before updating.** (Removing the locale files can be done with -`make uninstall` or by running the `locale_uninstall.sh` script.) Once this is -done, `bc` should install without problems.* +`make uninstall` or by running the [`locale_uninstall.sh`][22] script.) Once +this is done, `bc` should install without problems.* *Second, **the option to build without signal support has been removed**. See below for the reasons why.* @@ -396,7 +446,7 @@ diameter of the universe in Planck lengths. (For 32-bit, these numbers are either 32 integer digits or 12 integer digits and 20 fractional digits. These are also quite big, and going much bigger on a -32-bit system seems a little pointless since 12 digits in just under a trillion +32-bit system seems a little pointless since 12 digits is just under a trillion and 20 fractional digits is still enough for about any use since `10^-20` light years is just under a millimeter.) @@ -1084,7 +1134,7 @@ not thoroughly tested. [1]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 [2]: https://pkg.musl.cc/bc/ [3]: http://lcamtuf.coredump.cx/afl/ -[4]: ./karatsuba.py +[4]: ./scripts/karatsuba.py [5]: ./README.md [6]: ./configure.sh [7]: https://github.com/rain-1/linenoise-mob @@ -1092,7 +1142,7 @@ not thoroughly tested. [9]: ./manuals/bc/A.1.md [10]: ./manuals/dc/A.1.md [11]: https://scan.coverity.com/projects/gavinhoward-bc -[12]: ./locale_install.sh +[12]: ./scripts/locale_install.sh [13]: ./manuals/build.md [14]: https://github.com/stesser [15]: https://github.com/bugcrazy @@ -1102,3 +1152,4 @@ not thoroughly tested. [19]: ./manuals/benchmarks.md [20]: https://github.com/apjanke/ronn-ng [21]: https://pandoc.org/ +[22]: ./scripts/locale_uninstall.sh diff --git a/contrib/bc/README.md b/contrib/bc/README.md index f0dcecf15bde..c46d66b7e3ea 100644 --- a/contrib/bc/README.md +++ b/contrib/bc/README.md @@ -1,7 +1,5 @@ # `bc` -[![Coverity Scan Build Status][17]][18] - ***WARNING: This project has moved to [https://git.yzena.com/][20] for [these reasons][21], though GitHub will remain a mirror.*** @@ -23,6 +21,8 @@ This `bc` also provides `bc`'s math as a library with C bindings, called `bcl`. For more information, see the full manual for `bcl`. +## License + *** 154626 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Fri Aug 13 09:58:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1774A654245; Fri, 13 Aug 2021 09:58: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 4GmJtB6zVkz3Mdw; Fri, 13 Aug 2021 09:58: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 D35F94432; Fri, 13 Aug 2021 09:58: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 17D9wwc3065962; Fri, 13 Aug 2021 09:58:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17D9wwB6065961; Fri, 13 Aug 2021 09:58:58 GMT (envelope-from git) Date: Fri, 13 Aug 2021 09:58:58 GMT Message-Id: <202108130958.17D9wwB6065961@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: c9f833abf1d7 - main - rtld: Round down relro_size 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/main X-Git-Reftype: branch X-Git-Commit: c9f833abf1d76ea194b82caafa06a0627790ad97 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 09:58:59 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c9f833abf1d76ea194b82caafa06a0627790ad97 commit c9f833abf1d76ea194b82caafa06a0627790ad97 Author: Konstantin Belousov AuthorDate: 2021-08-12 02:45:15 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 09:58:53 +0000 rtld: Round down relro_size lld rounds up p_memsz(PT_GNU_RELRO) to satisfy common-page-size. If the page size is smaller than common-page-size, rounding up relro_size may incorrectly make some RW pages read-only. GNU ld, gold, and ld.lld ensures p_vaddr+p_memsz is a multiple of common-page-size. While max-page-size >= system the page size, common-page-size can be smaller than the system page size. Submitted by: MaskRay MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31498 --- libexec/rtld-elf/map_object.c | 3 ++- libexec/rtld-elf/rtld.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 273e477fbda5..b725fe93b8f6 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -325,7 +325,8 @@ map_object(int fd, const char *path, const struct stat *sb) } obj->stack_flags = stack_flags; obj->relro_page = obj->relocbase + trunc_page(relro_page); - obj->relro_size = round_page(relro_size); + obj->relro_size = trunc_page(relro_page + relro_size) - + trunc_page(relro_page); if (note_start < note_end) digest_notes(obj, note_start, note_end); if (note_map != NULL) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index f60872f12c52..eaad89339d07 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1557,7 +1557,8 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path) case PT_GNU_RELRO: obj->relro_page = obj->relocbase + trunc_page(ph->p_vaddr); - obj->relro_size = round_page(ph->p_memsz); + obj->relro_size = trunc_page(ph->p_vaddr + ph->p_memsz) - + trunc_page(ph->p_vaddr); break; case PT_NOTE: From owner-dev-commits-src-all@freebsd.org Fri Aug 13 11:16:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4CDE0654979; Fri, 13 Aug 2021 11:16:19 +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 4GmLbR1QZzz3hLR; Fri, 13 Aug 2021 11:16: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 18F535332; Fri, 13 Aug 2021 11:16: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 17DBGJ1I074066; Fri, 13 Aug 2021 11:16:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DBGI5Q074065; Fri, 13 Aug 2021 11:16:18 GMT (envelope-from git) Date: Fri, 13 Aug 2021 11:16:18 GMT Message-Id: <202108131116.17DBGI5Q074065@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 4920e38fecc3 - main - ipsec: fix race condition in key.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4920e38fecc3d0274b03ae7151153e9d6b9eb526 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 11:16:19 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=4920e38fecc3d0274b03ae7151153e9d6b9eb526 commit 4920e38fecc3d0274b03ae7151153e9d6b9eb526 Author: Wojciech Macek AuthorDate: 2021-08-13 10:52:38 +0000 Commit: Wojciech Macek CommitDate: 2021-08-13 10:52:38 +0000 ipsec: fix race condition in key.c Small patch that fixes a race condition in sys/netipsec/key.c Obtained from: Stormshield Differential revision: https://reviews.freebsd.org/D31271 --- sys/netipsec/key.c | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 3ea3a81b90c3..72c598586d8e 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -616,6 +616,7 @@ static struct callout key_timer; #endif static void key_unlink(struct secpolicy *); +static void key_detach(struct secpolicy *); static struct secpolicy *key_do_allocsp(struct secpolicyindex *spidx, u_int dir); static struct secpolicy *key_getsp(struct secpolicyindex *); static struct secpolicy *key_getspbyid(u_int32_t); @@ -1200,18 +1201,26 @@ key_freesp(struct secpolicy **spp) static void key_unlink(struct secpolicy *sp) { + SPTREE_WLOCK(); + key_detach(sp); + SPTREE_WUNLOCK(); + if (SPDCACHE_ENABLED()) + spdcache_clear(); + key_freesp(&sp); +} +static void +key_detach(struct secpolicy *sp) +{ IPSEC_ASSERT(sp->spidx.dir == IPSEC_DIR_INBOUND || sp->spidx.dir == IPSEC_DIR_OUTBOUND, ("invalid direction %u", sp->spidx.dir)); - SPTREE_UNLOCK_ASSERT(); + SPTREE_WLOCK_ASSERT(); KEYDBG(KEY_STAMP, printf("%s: SP(%p)\n", __func__, sp)); - SPTREE_WLOCK(); if (sp->state != IPSEC_SPSTATE_ALIVE) { /* SP is already unlinked */ - SPTREE_WUNLOCK(); return; } sp->state = IPSEC_SPSTATE_DEAD; @@ -1219,10 +1228,6 @@ key_unlink(struct secpolicy *sp) V_spd_size--; LIST_REMOVE(sp, idhash); V_sp_genid++; - SPTREE_WUNLOCK(); - if (SPDCACHE_ENABLED()) - spdcache_clear(); - key_freesp(&sp); } /* @@ -1941,7 +1946,7 @@ key_spdadd(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) struct sadb_address *src0, *dst0; struct sadb_x_policy *xpl0, *xpl; struct sadb_lifetime *lft = NULL; - struct secpolicy *newsp; + struct secpolicy *newsp, *oldsp; int error; IPSEC_ASSERT(so != NULL, ("null socket")); @@ -2019,15 +2024,13 @@ key_spdadd(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) src0->sadb_address_proto, &spidx); /* Checking there is SP already or not. */ - newsp = key_getsp(&spidx); - if (newsp != NULL) { + oldsp = key_getsp(&spidx); + if (oldsp != NULL) { if (mhp->msg->sadb_msg_type == SADB_X_SPDUPDATE) { KEYDBG(KEY_STAMP, printf("%s: unlink SP(%p) for SPDUPDATE\n", - __func__, newsp)); - KEYDBG(KEY_DATA, kdebug_secpolicy(newsp)); - key_unlink(newsp); - key_freesp(&newsp); + __func__, oldsp)); + KEYDBG(KEY_DATA, kdebug_secpolicy(oldsp)); } else { key_freesp(&newsp); ipseclog((LOG_DEBUG, @@ -2038,6 +2041,10 @@ key_spdadd(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) /* allocate new SP entry */ if ((newsp = key_msg2sp(xpl0, PFKEY_EXTLEN(xpl0), &error)) == NULL) { + if (oldsp != NULL) { + key_unlink(oldsp); + key_freesp(&oldsp); /* second for our reference */ + } return key_senderror(so, m, error); } @@ -2046,18 +2053,32 @@ key_spdadd(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) newsp->validtime = lft ? lft->sadb_lifetime_usetime : 0; bcopy(&spidx, &newsp->spidx, sizeof(spidx)); - /* XXXAE: there is race between key_getsp() and key_insertsp() */ SPTREE_WLOCK(); if ((newsp->id = key_getnewspid()) == 0) { + if (oldsp != NULL) + key_detach(oldsp); SPTREE_WUNLOCK(); + if (oldsp != NULL) { + key_freesp(&oldsp); /* first for key_detach */ + IPSEC_ASSERT(oldsp != NULL, ("null oldsp: refcount bug")); + key_freesp(&oldsp); /* second for our reference */ + if (SPDCACHE_ENABLED()) /* refresh cache because of key_detach */ + spdcache_clear(); + } key_freesp(&newsp); return key_senderror(so, m, ENOBUFS); } + if (oldsp != NULL) + key_detach(oldsp); key_insertsp(newsp); SPTREE_WUNLOCK(); + if (oldsp != NULL) { + key_freesp(&oldsp); /* first for key_detach */ + IPSEC_ASSERT(oldsp != NULL, ("null oldsp: refcount bug")); + key_freesp(&oldsp); /* second for our reference */ + } if (SPDCACHE_ENABLED()) spdcache_clear(); - KEYDBG(KEY_STAMP, printf("%s: SP(%p)\n", __func__, newsp)); KEYDBG(KEY_DATA, kdebug_secpolicy(newsp)); From owner-dev-commits-src-all@freebsd.org Fri Aug 13 13:58:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 331D6657874; Fri, 13 Aug 2021 13:58: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 4GmQC500z0z3r6S; Fri, 13 Aug 2021 13:58: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 D7C3A770C; Fri, 13 Aug 2021 13:58: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 17DDwusw088195; Fri, 13 Aug 2021 13:58:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DDwuex088194; Fri, 13 Aug 2021 13:58:56 GMT (envelope-from git) Date: Fri, 13 Aug 2021 13:58:56 GMT Message-Id: <202108131358.17DDwuex088194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e0e3ded78a5d - main - ng_bridge: Use M_NOWAIT when allocating memory in the newhook routine 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/main X-Git-Reftype: branch X-Git-Commit: e0e3ded78a5d0859f3520c541726b815897ba7b0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 13:58:57 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e0e3ded78a5d0859f3520c541726b815897ba7b0 commit e0e3ded78a5d0859f3520c541726b815897ba7b0 Author: Mark Johnston AuthorDate: 2021-08-13 13:49:43 +0000 Commit: Mark Johnston CommitDate: 2021-08-13 13:49:43 +0000 ng_bridge: Use M_NOWAIT when allocating memory in the newhook routine newhook can be invoked by ngthread, which runs in a network epoch section and is thus not permitted to perform M_WAITOK allocations. Reported by: Jenkins Reviewed by: donner, afedorov MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31486 --- sys/netgraph/ng_bridge.c | 84 ++++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 03d5125972d0..12cc619241b6 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -154,6 +154,7 @@ static ng_rcvdata_t ng_bridge_rcvdata; static ng_disconnect_t ng_bridge_disconnect; /* Other internal functions */ +static void ng_bridge_free_link(link_p link); static struct ng_bridge_host *ng_bridge_get(priv_cp priv, const u_char *addr); static int ng_bridge_put(priv_p priv, const u_char *addr, link_p link); static void ng_bridge_rehash(priv_p priv); @@ -395,28 +396,36 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) if(NG_PEER_NODE(hook) == node) return (ELOOP); - link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_WAITOK | M_ZERO); - - link->stats.recvOctets = counter_u64_alloc(M_WAITOK); - link->stats.recvPackets = counter_u64_alloc(M_WAITOK); - link->stats.recvMulticasts = counter_u64_alloc(M_WAITOK); - link->stats.recvBroadcasts = counter_u64_alloc(M_WAITOK); - link->stats.recvUnknown = counter_u64_alloc(M_WAITOK); - link->stats.recvRunts = counter_u64_alloc(M_WAITOK); - link->stats.recvInvalid = counter_u64_alloc(M_WAITOK); - link->stats.xmitOctets = counter_u64_alloc(M_WAITOK); - link->stats.xmitPackets = counter_u64_alloc(M_WAITOK); - link->stats.xmitMulticasts = counter_u64_alloc(M_WAITOK); - link->stats.xmitBroadcasts = counter_u64_alloc(M_WAITOK); - link->stats.loopDrops = counter_u64_alloc(M_WAITOK); - link->stats.memoryFailures = counter_u64_alloc(M_WAITOK); + link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_NOWAIT | M_ZERO); + if (link == NULL) + return (ENOMEM); + +#define NG_BRIDGE_COUNTER_ALLOC(f) do { \ + link->stats.f = counter_u64_alloc(M_NOWAIT); \ + if (link->stats.f == NULL) \ + goto nomem; \ +} while (0) + NG_BRIDGE_COUNTER_ALLOC(recvOctets); + NG_BRIDGE_COUNTER_ALLOC(recvPackets); + NG_BRIDGE_COUNTER_ALLOC(recvMulticasts); + NG_BRIDGE_COUNTER_ALLOC(recvBroadcasts); + NG_BRIDGE_COUNTER_ALLOC(recvUnknown); + NG_BRIDGE_COUNTER_ALLOC(recvRunts); + NG_BRIDGE_COUNTER_ALLOC(recvInvalid); + NG_BRIDGE_COUNTER_ALLOC(xmitOctets); + NG_BRIDGE_COUNTER_ALLOC(xmitPackets); + NG_BRIDGE_COUNTER_ALLOC(xmitMulticasts); + NG_BRIDGE_COUNTER_ALLOC(xmitBroadcasts); + NG_BRIDGE_COUNTER_ALLOC(loopDrops); + NG_BRIDGE_COUNTER_ALLOC(memoryFailures); +#undef NG_BRIDGE_COUNTER_ALLOC link->hook = hook; if (isUplink) { link->learnMac = 0; link->sendUnknown = 1; if (priv->numLinks == 0) /* if the first link is an uplink */ - priv->sendUnknown = 0; /* switch to restrictive mode */ + priv->sendUnknown = 0; /* switch to restrictive mode */ } else { link->learnMac = 1; link->sendUnknown = priv->sendUnknown; @@ -425,12 +434,17 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) NG_HOOK_SET_PRIVATE(hook, link); priv->numLinks++; return (0); + +nomem: + ng_bridge_free_link(link); + return (ENOMEM); } /* * Receive a control message */ -static void ng_bridge_clear_link_stats(struct ng_bridge_link_kernel_stats * p) +static void +ng_bridge_clear_link_stats(struct ng_bridge_link_kernel_stats *p) { counter_u64_zero(p->recvOctets); counter_u64_zero(p->recvPackets); @@ -446,7 +460,26 @@ static void ng_bridge_clear_link_stats(struct ng_bridge_link_kernel_stats * p) counter_u64_zero(p->loopDrops); p->loopDetects = 0; counter_u64_zero(p->memoryFailures); -}; +} + +static void +ng_bridge_free_link(link_p link) +{ + counter_u64_free(link->stats.recvOctets); + counter_u64_free(link->stats.recvPackets); + counter_u64_free(link->stats.recvMulticasts); + counter_u64_free(link->stats.recvBroadcasts); + counter_u64_free(link->stats.recvUnknown); + counter_u64_free(link->stats.recvRunts); + counter_u64_free(link->stats.recvInvalid); + counter_u64_free(link->stats.xmitOctets); + counter_u64_free(link->stats.xmitPackets); + counter_u64_free(link->stats.xmitMulticasts); + counter_u64_free(link->stats.xmitBroadcasts); + counter_u64_free(link->stats.loopDrops); + counter_u64_free(link->stats.memoryFailures); + free(link, M_NETGRAPH_BRIDGE); +} static int ng_bridge_reset_link(hook_p hook, void *arg __unused) @@ -915,20 +948,7 @@ ng_bridge_disconnect(hook_p hook) ng_bridge_remove_hosts(priv, link); /* Free associated link information */ - counter_u64_free(link->stats.recvOctets); - counter_u64_free(link->stats.recvPackets); - counter_u64_free(link->stats.recvMulticasts); - counter_u64_free(link->stats.recvBroadcasts); - counter_u64_free(link->stats.recvUnknown); - counter_u64_free(link->stats.recvRunts); - counter_u64_free(link->stats.recvInvalid); - counter_u64_free(link->stats.xmitOctets); - counter_u64_free(link->stats.xmitPackets); - counter_u64_free(link->stats.xmitMulticasts); - counter_u64_free(link->stats.xmitBroadcasts); - counter_u64_free(link->stats.loopDrops); - counter_u64_free(link->stats.memoryFailures); - free(link, M_NETGRAPH_BRIDGE); + ng_bridge_free_link(link); priv->numLinks--; /* If no more hooks, go away */ From owner-dev-commits-src-all@freebsd.org Fri Aug 13 13:58:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C7C1657875; Fri, 13 Aug 2021 13:58: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 4GmQC60HgTz3rF6; Fri, 13 Aug 2021 13:58: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 E6F3D73E7; Fri, 13 Aug 2021 13:58: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 17DDwv9o088220; Fri, 13 Aug 2021 13:58:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DDwvY2088219; Fri, 13 Aug 2021 13:58:57 GMT (envelope-from git) Date: Fri, 13 Aug 2021 13:58:57 GMT Message-Id: <202108131358.17DDwvY2088219@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 3d69515cfea2 - main - arc4random: Avoid KMSAN false positives from pre-seeding results 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/main X-Git-Reftype: branch X-Git-Commit: 3d69515cfea2781b318ebe1c6e6018d817cde358 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 13:58:58 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3d69515cfea2781b318ebe1c6e6018d817cde358 commit 3d69515cfea2781b318ebe1c6e6018d817cde358 Author: Mark Johnston AuthorDate: 2021-08-13 13:52:05 +0000 Commit: Mark Johnston CommitDate: 2021-08-13 13:58:42 +0000 arc4random: Avoid KMSAN false positives from pre-seeding results If code calls arc4random(), and our RNG is not yet seeded and random_bypass_before_seeding is true, we'll compute a key using the SHA256 hash of some hopefully hard-to-predict data, including the contents of an uninitialized stack buffer (which is also the output buffer). When KMSAN is enabled, this use of uninitialized state propagtes through to the arc4random() output, resulting in false positives. To address this, lie to KMSAN and explicitly mark the buffer as initialized. Reviewed by: cem (previous version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31510 --- sys/libkern/arc4random.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/libkern/arc4random.c b/sys/libkern/arc4random.c index a4bee71c0efd..fd362dd83608 100644 --- a/sys/libkern/arc4random.c +++ b/sys/libkern/arc4random.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -106,6 +107,14 @@ chacha20_randomstir(struct chacha20_s *chacha20) "enabled.\n"); } + /* + * "key" is intentionally left uninitialized here, so with KMSAN + * enabled the arc4random() return value may be marked + * uninitialized, leading to spurious reports. Lie to KMSAN to + * avoid this situation. + */ + kmsan_mark(key, sizeof(key), KMSAN_STATE_INITED); + /* Last ditch effort to inject something in a bad condition. */ cc = get_cyclecount(); SHA256_Init(&ctx); From owner-dev-commits-src-all@freebsd.org Fri Aug 13 14:40:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93A6D6584E8; Fri, 13 Aug 2021 14:40: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 4GmR6Z3XpPz3tn8; Fri, 13 Aug 2021 14:40: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 5DF0A7FA5; Fri, 13 Aug 2021 14:40: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 17DEe6gc044678; Fri, 13 Aug 2021 14:40:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DEe6Bq044675; Fri, 13 Aug 2021 14:40:06 GMT (envelope-from git) Date: Fri, 13 Aug 2021 14:40:06 GMT Message-Id: <202108131440.17DEe6Bq044675@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 086f09087713 - main - ar: diff reduction against ELF Tool Chain 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/main X-Git-Reftype: branch X-Git-Commit: 086f09087713e3af0a28d296a2372071b72211ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 14:40:06 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=086f09087713e3af0a28d296a2372071b72211ef commit 086f09087713e3af0a28d296a2372071b72211ef Author: Ed Maste AuthorDate: 2021-08-12 19:37:25 +0000 Commit: Ed Maste CommitDate: 2021-08-13 14:39:44 +0000 ar: diff reduction against ELF Tool Chain Drop exit status from bsdar_errc. ELF Tool Chain always returns EXIT_FAILURE in bsdar_errc. Recommit of one part of d20e9e02db3d / review D31496. Obtained from: ELF Tool Chain Sponsored by: The FreeBSD Foundation --- usr.bin/ar/acpyacc.y | 34 +++++++++++++--------------- usr.bin/ar/ar.c | 25 +++++++++------------ usr.bin/ar/ar.h | 5 ++--- usr.bin/ar/read.c | 4 ++-- usr.bin/ar/util.c | 4 ++-- usr.bin/ar/write.c | 62 ++++++++++++++++++++++++---------------------------- 6 files changed, 59 insertions(+), 75 deletions(-) diff --git a/usr.bin/ar/acpyacc.y b/usr.bin/ar/acpyacc.y index 5d4eb9fb6b37..f6bfbd7957b5 100644 --- a/usr.bin/ar/acpyacc.y +++ b/usr.bin/ar/acpyacc.y @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include "ar.h" @@ -250,7 +249,7 @@ arscp_open(char *fname) int r; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); + bsdar_errc(bsdar, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, fname, DEF_BLKSZ)); if ((r = archive_read_next_header(a, &entry))) @@ -277,15 +276,15 @@ arscp_create(char *in, char *out) /* Delete previously created temporary archive, if any. */ if (tmpac) { if (unlink(tmpac) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "unlink failed"); + bsdar_errc(bsdar, errno, "unlink failed"); free(tmpac); } tmpac = strdup(TEMPLATE); if (tmpac == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); if ((ofd = mkstemp(tmpac)) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "mkstemp failed"); + bsdar_errc(bsdar, errno, "mkstemp failed"); if (in) { /* @@ -308,8 +307,7 @@ arscp_create(char *in, char *out) * (archive with only global header) */ if ((a = archive_write_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_write_new failed"); + bsdar_errc(bsdar, 0, "archive_write_new failed"); archive_write_set_format_ar_svr4(a); AC(archive_write_open_fd(a, ofd)); AC(archive_write_close(a)); @@ -350,7 +348,7 @@ arscp_copy(int ifd, int ofd) } } if (munmap(p, sb.st_size) < 0) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "munmap failed"); + bsdar_errc(bsdar, errno, "munmap failed"); if (bytes > 0) return (1); @@ -439,8 +437,7 @@ arscp_dir(char *archive, struct list *list, char *rlt) if (rlt) { out = stdout; if ((stdout = fopen(rlt, "w")) == NULL) - bsdar_errc(bsdar, EX_IOERR, errno, - "fopen %s failed", rlt); + bsdar_errc(bsdar, errno, "fopen %s failed", rlt); } bsdar->filename = archive; @@ -457,8 +454,7 @@ arscp_dir(char *archive, struct list *list, char *rlt) if (rlt) { if (fclose(stdout) == EOF) - bsdar_errc(bsdar, EX_IOERR, errno, - "fclose %s failed", rlt); + bsdar_errc(bsdar, errno, "fclose %s failed", rlt); stdout = out; free(rlt); } @@ -490,7 +486,7 @@ arscp_save(void) if (target) { if (rename(tmpac, target) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "rename failed"); + bsdar_errc(bsdar, errno, "rename failed"); /* * mkstemp creates temp files with mode 0600, here we * set target archive mode per process umask. @@ -498,7 +494,7 @@ arscp_save(void) mask = umask(0); umask(mask); if (chmod(target, 0666 & ~mask) < 0) - bsdar_errc(bsdar, EX_IOERR, errno, "chmod failed"); + bsdar_errc(bsdar, errno, "chmod failed"); free(tmpac); free(target); tmpac = NULL; @@ -520,7 +516,7 @@ arscp_clear(void) if (target) { new_target = strdup(target); if (new_target == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); arscp_create(NULL, new_target); } } @@ -537,7 +533,7 @@ arscp_end(int eval) free(target); if (tmpac) { if (unlink(tmpac) == -1) - bsdar_errc(bsdar, EX_IOERR, errno, "unlink %s failed", + bsdar_errc(bsdar, errno, "unlink %s failed", tmpac); free(tmpac); } @@ -568,7 +564,7 @@ arscp_mlist(struct list *list, char *str) l = malloc(sizeof(*l)); if (l == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); l->str = str; l->next = list; @@ -610,12 +606,12 @@ arscp_mlist2argv(struct list *list) n = arscp_mlist_len(list); argv = malloc(n * sizeof(*argv)); if (argv == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); /* Note that module names are stored in reverse order in mlist. */ for(i = n - 1; i >= 0; i--, list = list->next) { if (list == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "invalid mlist"); + bsdar_errc(bsdar, errno, "invalid mlist"); argv[i] = list->str; } diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c index b131163342a6..aceb4d7f8487 100644 --- a/usr.bin/ar/ar.c +++ b/usr.bin/ar/ar.c @@ -162,8 +162,7 @@ main(int argc, char **argv) if (*argv[1] != '-') { len = strlen(argv[1]) + 2; if ((p = malloc(len)) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, errno, - "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); *p = '-'; (void)strlcpy(p + 1, argv[1], len - 1); argv[1] = p; @@ -263,24 +262,20 @@ main(int argc, char **argv) bsdar_usage(); if (bsdar->options & AR_A && bsdar->options & AR_B) - bsdar_errc(bsdar, EXIT_FAILURE, 0, + bsdar_errc(bsdar, 0, "only one of -a and -[bi] options allowed"); if (bsdar->options & AR_J && bsdar->options & AR_Z) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "only one of -j and -z options allowed"); + bsdar_errc(bsdar, 0, "only one of -j and -z options allowed"); if (bsdar->options & AR_S && bsdar->options & AR_SS) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "only one of -s and -S options allowed"); + bsdar_errc(bsdar, 0, "only one of -s and -S options allowed"); if (bsdar->options & (AR_A | AR_B)) { if (*argv == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "no position operand specified"); + bsdar_errc(bsdar, 0, "no position operand specified"); if ((bsdar->posarg = basename(*argv)) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, errno, - "basename failed"); + bsdar_errc(bsdar, errno, "basename failed"); argc--; argv++; } @@ -370,8 +365,8 @@ set_mode(struct bsdar *bsdar, char opt) { if (bsdar->mode != '\0' && bsdar->mode != opt) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "Can't specify both -%c and -%c", opt, bsdar->mode); + bsdar_errc(bsdar, 0, "Can't specify both -%c and -%c", opt, + bsdar->mode); bsdar->mode = opt; } @@ -380,8 +375,8 @@ only_mode(struct bsdar *bsdar, const char *opt, const char *valid_modes) { if (strchr(valid_modes, bsdar->mode) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, 0, - "Option %s is not permitted in mode -%c", opt, bsdar->mode); + bsdar_errc(bsdar, 0, "Option %s is not permitted in mode -%c", + opt, bsdar->mode); } static void diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h index 21b3a669a943..321680fed804 100644 --- a/usr.bin/ar/ar.h +++ b/usr.bin/ar/ar.h @@ -54,7 +54,7 @@ */ #define AC(CALL) do { \ if ((CALL)) \ - bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s", \ + bsdar_errc(bsdar, archive_errno(a), "%s", \ archive_error_string(a)); \ } while (0) @@ -114,8 +114,7 @@ struct bsdar { TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ }; -void bsdar_errc(struct bsdar *, int _eval, int _code, - const char *fmt, ...) __dead2; +void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __dead2; void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); int ar_mode_d(struct bsdar *bsdar); int ar_mode_m(struct bsdar *bsdar); diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c index 04130b859c32..15044ab57a93 100644 --- a/usr.bin/ar/read.c +++ b/usr.bin/ar/read.c @@ -88,7 +88,7 @@ read_archive(struct bsdar *bsdar, char mode) int exitcode, flags, r, i; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed"); + bsdar_errc(bsdar, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ)); @@ -122,7 +122,7 @@ read_archive(struct bsdar *bsdar, char mode) if (*av == NULL) continue; if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, EXIT_FAILURE, errno, + bsdar_errc(bsdar, errno, "basename failed"); if (strcmp(bname, name) != 0) continue; diff --git a/usr.bin/ar/util.c b/usr.bin/ar/util.c index 1823c5eba84a..b130d6195e47 100644 --- a/usr.bin/ar/util.c +++ b/usr.bin/ar/util.c @@ -77,12 +77,12 @@ bsdar_verrc(struct bsdar *bsdar, int code, const char *fmt, va_list ap) } void -bsdar_errc(struct bsdar *bsdar, int eval, int code, const char *fmt, ...) +bsdar_errc(struct bsdar *bsdar, int code, const char *fmt, ...) { va_list ap; va_start(ap, fmt); bsdar_verrc(bsdar, code, fmt, ap); va_end(ap); - exit(eval); + exit(EXIT_FAILURE); } diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index 4177f57d064a..3c4b20e305da 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include "ar.h" @@ -133,7 +132,7 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) obj = malloc(sizeof(struct ar_obj)); if (obj == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); if ((obj->fd = open(name, O_RDONLY, 0)) < 0) { bsdar_warnc(bsdar, errno, "can't open file: %s", name); free(obj); @@ -142,17 +141,17 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) tmpname = strdup(name); if (tmpname == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); if ((bname = basename(tmpname)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "basename failed"); + bsdar_errc(bsdar, errno, "basename failed"); if (bsdar->options & AR_TR && strlen(bname) > _TRUNCATE_LEN) { if ((obj->name = malloc(_TRUNCATE_LEN + 1)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); (void)strncpy(obj->name, bname, _TRUNCATE_LEN); obj->name[_TRUNCATE_LEN] = '\0'; } else if ((obj->name = strdup(bname)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); free(tmpname); if (fstat(obj->fd, &sb) < 0) { @@ -205,14 +204,14 @@ create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) goto giveup; } if (close(obj->fd) < 0) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "close failed: %s", + bsdar_errc(bsdar, errno, "close failed: %s", obj->name); return (obj); giveup: if (close(obj->fd) < 0) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "close failed: %s", + bsdar_errc(bsdar, errno, "close failed: %s", obj->name); free(obj->name); free(obj); @@ -242,7 +241,7 @@ static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, struct ar_obj *pos) { if (obj == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "try to insert a null obj"); + bsdar_errc(bsdar, 0, "try to insert a null obj"); if (pos == NULL || obj == pos) /* @@ -285,13 +284,13 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) int i, r, find; if ((a = archive_read_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); + bsdar_errc(bsdar, 0, "archive_read_new failed"); archive_read_support_format_ar(a); AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); for (;;) { r = archive_read_next_header(a, &entry); if (r == ARCHIVE_FATAL) - bsdar_errc(bsdar, EX_DATAERR, archive_errno(a), "%s", + bsdar_errc(bsdar, archive_errno(a), "%s", archive_error_string(a)); if (r == ARCHIVE_EOF) break; @@ -322,7 +321,7 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) if (*av == NULL) continue; if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, + bsdar_errc(bsdar, errno, "basename failed"); if (strcmp(bname, name) != 0) continue; @@ -339,8 +338,7 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) if (size > 0) { if ((buff = malloc(size)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, - "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); if (archive_read_data(a, buff, size) != (ssize_t)size) { bsdar_warnc(bsdar, archive_errno(a), "%s", archive_error_string(a)); @@ -352,10 +350,10 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) obj = malloc(sizeof(struct ar_obj)); if (obj == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); obj->maddr = buff; if ((obj->name = strdup(name)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "strdup failed"); + bsdar_errc(bsdar, errno, "strdup failed"); obj->size = size; obj->uid = archive_entry_uid(entry); obj->gid = archive_entry_gid(entry); @@ -476,8 +474,7 @@ write_archive(struct bsdar *bsdar, char mode) TAILQ_FOREACH_SAFE(obj, &bsdar->v_obj, objs, obj_temp) { if ((bname = basename(*av)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, - "basename failed"); + bsdar_errc(bsdar, errno, "basename failed"); if (bsdar->options & AR_TR) { if (strncmp(bname, obj->name, _TRUNCATE_LEN)) continue; @@ -605,7 +602,7 @@ write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s) while (s > 0) { written = archive_write_data(a, buf, s); if (written < 0) - bsdar_errc(bsdar, EX_SOFTWARE, archive_errno(a), "%s", + bsdar_errc(bsdar, archive_errno(a), "%s", archive_error_string(a)); buf = (const char *)buf + written; s -= written; @@ -629,8 +626,8 @@ write_objs(struct bsdar *bsdar) uint32_t nr32; if (elf_version(EV_CURRENT) == EV_NONE) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "ELF library initialization failed: %s", elf_errmsg(-1)); + bsdar_errc(bsdar, 0, "ELF library initialization failed: %s", + elf_errmsg(-1)); bsdar->rela_off = 0; @@ -695,7 +692,7 @@ write_objs(struct bsdar *bsdar) } if ((a = archive_write_new()) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); + bsdar_errc(bsdar, 0, "archive_write_new failed"); archive_write_set_format_ar_svr4(a); @@ -710,8 +707,7 @@ write_objs(struct bsdar *bsdar) bsdar->options & AR_S) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_entry_new failed"); + bsdar_errc(bsdar, 0, "archive_entry_new failed"); if (w_sz == sizeof(uint64_t)) archive_entry_copy_pathname(entry, "/SYM64/"); else @@ -737,8 +733,7 @@ write_objs(struct bsdar *bsdar) if (bsdar->as != NULL) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_entry_new failed"); + bsdar_errc(bsdar, 0, "archive_entry_new failed"); archive_entry_copy_pathname(entry, "//"); archive_entry_set_size(entry, bsdar->as_sz); AC(archive_write_header(a, entry)); @@ -750,8 +745,7 @@ write_objs(struct bsdar *bsdar) TAILQ_FOREACH(obj, &bsdar->v_obj, objs) { entry = archive_entry_new(); if (entry == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, 0, - "archive_entry_new failed"); + bsdar_errc(bsdar, 0, "archive_entry_new failed"); archive_entry_copy_pathname(entry, obj->name); archive_entry_set_uid(entry, obj->uid); archive_entry_set_gid(entry, obj->gid); @@ -893,7 +887,7 @@ add_to_ar_str_table(struct bsdar *bsdar, const char *name) bsdar->as_cap = _INIT_AS_CAP; bsdar->as_sz = 0; if ((bsdar->as = malloc(bsdar->as_cap)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); } /* @@ -904,7 +898,7 @@ add_to_ar_str_table(struct bsdar *bsdar, const char *name) bsdar->as_cap *= 2; bsdar->as = realloc(bsdar->as, bsdar->as_cap); if (bsdar->as == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); + bsdar_errc(bsdar, errno, "realloc failed"); } strncpy(&bsdar->as[bsdar->as_sz], name, strlen(name)); bsdar->as_sz += strlen(name); @@ -922,14 +916,14 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) if (bsdar->s_so == NULL) { if ((bsdar->s_so = malloc(_INIT_SYMOFF_CAP)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); bsdar->s_so_cap = _INIT_SYMOFF_CAP; bsdar->s_cnt = 0; } if (bsdar->s_sn == NULL) { if ((bsdar->s_sn = malloc(_INIT_SYMNAME_CAP)) == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "malloc failed"); + bsdar_errc(bsdar, errno, "malloc failed"); bsdar->s_sn_cap = _INIT_SYMNAME_CAP; bsdar->s_sn_sz = 0; } @@ -938,7 +932,7 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) bsdar->s_so_cap *= 2; bsdar->s_so = realloc(bsdar->s_so, bsdar->s_so_cap); if (bsdar->s_so == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); + bsdar_errc(bsdar, errno, "realloc failed"); } bsdar->s_so[bsdar->s_cnt] = bsdar->rela_off; if ((uint64_t)bsdar->rela_off > bsdar->s_so_max) @@ -953,7 +947,7 @@ add_to_ar_sym_table(struct bsdar *bsdar, const char *name) bsdar->s_sn_cap *= 2; bsdar->s_sn = realloc(bsdar->s_sn, bsdar->s_sn_cap); if (bsdar->s_sn == NULL) - bsdar_errc(bsdar, EX_SOFTWARE, errno, "realloc failed"); + bsdar_errc(bsdar, errno, "realloc failed"); } strncpy(&bsdar->s_sn[bsdar->s_sn_sz], name, strlen(name)); bsdar->s_sn_sz += strlen(name); From owner-dev-commits-src-all@freebsd.org Fri Aug 13 14:53:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B46DD658D82; Fri, 13 Aug 2021 14:53: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 4GmRQ14SbWz3vTR; Fri, 13 Aug 2021 14:53: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 81C817F65; Fri, 13 Aug 2021 14:53: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 17DErTqa068162; Fri, 13 Aug 2021 14:53:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DErTBp068161; Fri, 13 Aug 2021 14:53:29 GMT (envelope-from git) Date: Fri, 13 Aug 2021 14:53:29 GMT Message-Id: <202108131453.17DErTBp068161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 2e2212b4f55f - main - Style: wrap the long line, definition of ufs_checkpath() 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/main X-Git-Reftype: branch X-Git-Commit: 2e2212b4f55f307ed814cbe1ea633c32faea4a9c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 14:53:29 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2e2212b4f55f307ed814cbe1ea633c32faea4a9c commit 2e2212b4f55f307ed814cbe1ea633c32faea4a9c Author: Konstantin Belousov AuthorDate: 2021-08-01 17:56:33 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 14:52:20 +0000 Style: wrap the long line, definition of ufs_checkpath() Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/ufs/ufs/ufs_lookup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index b7bf4eb6c86c..ac3a8ee641a0 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1439,7 +1439,8 @@ ufs_dir_dd_ino(struct vnode *vp, struct ucred *cred, ino_t *dd_ino, * Check if source directory is in the path of the target directory. */ int -ufs_checkpath(ino_t source_ino, ino_t parent_ino, struct inode *target, struct ucred *cred, ino_t *wait_ino) +ufs_checkpath(ino_t source_ino, ino_t parent_ino, struct inode *target, + struct ucred *cred, ino_t *wait_ino) { struct mount *mp; struct vnode *tvp, *vp, *vp1; From owner-dev-commits-src-all@freebsd.org Fri Aug 13 14:53:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EC37665893C; Fri, 13 Aug 2021 14:53: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 4GmRQ25lD4z3vCq; Fri, 13 Aug 2021 14:53: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 A4EBA10508; Fri, 13 Aug 2021 14:53: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 17DErUMP068186; Fri, 13 Aug 2021 14:53:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DErUan068185; Fri, 13 Aug 2021 14:53:30 GMT (envelope-from git) Date: Fri, 13 Aug 2021 14:53:30 GMT Message-Id: <202108131453.17DErUan068185@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 8df4bc48c89a - main - ufs rename: ensure that the result of ufs_checkpath() is stable 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/main X-Git-Reftype: branch X-Git-Commit: 8df4bc48c89a1302078282f22139a8368dc06971 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 14:53:31 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8df4bc48c89a1302078282f22139a8368dc06971 commit 8df4bc48c89a1302078282f22139a8368dc06971 Author: Konstantin Belousov AuthorDate: 2021-08-06 01:03:19 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 14:52:26 +0000 ufs rename: ensure that the result of ufs_checkpath() is stable ufs_rename() calls ufs_checkpath() to ensure that the target directory is not a child of the source. If not, rename would create a loop. For instance: source->X1->X2->target and if source moved under target, we get corrupted filesystem. Suppose that we initially have source->X1 .... and X2->target where X1 is not on path from root to X2. Then ufs_checkpath() accepts the inodes, but there is nothing preventing parallel rename of X2 to become under X1, after checkpath finished. Ensure stability of ufs_checkpath() result by taking a per-mount sx in ufs_rename right before ufs_checkpath() and till the end. Reviewed by: chs, mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/ufs/ffs/ffs_vfsops.c | 5 ++++- sys/ufs/ufs/ufs_lookup.c | 2 ++ sys/ufs/ufs/ufs_vnops.c | 12 ++++++++++-- sys/ufs/ufs/ufsmount.h | 3 +++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 2ff71cc3e4d1..aad7b4f2decd 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1151,6 +1151,7 @@ ffs_mountfs(odevvp, mp, td) else ump->um_check_blkno = NULL; mtx_init(UFS_MTX(ump), "FFS", "FFS Lock", MTX_DEF); + sx_init(&ump->um_checkpath_lock, "uchpth"); ffs_oldfscompat_read(fs, ump, fs->fs_sblockloc); fs->fs_ronly = ronly; fs->fs_active = NULL; @@ -1318,8 +1319,9 @@ out: g_vfs_close(cp); g_topology_unlock(); } - if (ump) { + if (ump != NULL) { mtx_destroy(UFS_MTX(ump)); + sx_destroy(&ump->um_checkpath_lock); if (mp->mnt_gjprovider != NULL) { free(mp->mnt_gjprovider, M_UFSMNT); mp->mnt_gjprovider = NULL; @@ -1545,6 +1547,7 @@ ffs_unmount(mp, mntflags) vrele(ump->um_odevvp); dev_rel(ump->um_dev); mtx_destroy(UFS_MTX(ump)); + sx_destroy(&ump->um_checkpath_lock); if (mp->mnt_gjprovider != NULL) { free(mp->mnt_gjprovider, M_UFSMNT); mp->mnt_gjprovider = NULL; diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index ac3a8ee641a0..fc78c017e2c6 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1450,6 +1450,8 @@ ufs_checkpath(ino_t source_ino, ino_t parent_ino, struct inode *target, vp = tvp = ITOV(target); mp = vp->v_mount; *wait_ino = 0; + sx_assert(&VFSTOUFS(mp)->um_checkpath_lock, SA_XLOCKED); + if (target->i_number == source_ino) return (EEXIST); if (target->i_number == parent_ino) diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 2dfc2e24f772..00ec8f41f432 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1249,9 +1249,9 @@ ufs_rename(ap) struct mount *mp; ino_t ino; seqc_t fdvp_s, fvp_s, tdvp_s, tvp_s; - bool want_seqc_end; + bool checkpath_locked, want_seqc_end; - want_seqc_end = false; + checkpath_locked = want_seqc_end = false; #ifdef INVARIANTS if ((tcnp->cn_flags & HASBUF) == 0 || @@ -1453,6 +1453,9 @@ relock: error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); if (error) goto unlockout; + + sx_xlock(&VFSTOUFS(mp)->um_checkpath_lock); + checkpath_locked = true; error = ufs_checkpath(ino, fdp->i_number, tdp, tcnp->cn_cred, &ino); /* @@ -1460,6 +1463,8 @@ relock: * everything else and VGET before restarting. */ if (ino) { + sx_xunlock(&VFSTOUFS(mp)->um_checkpath_lock); + checkpath_locked = false; VOP_UNLOCK(fdvp); VOP_UNLOCK(fvp); VOP_UNLOCK(tdvp); @@ -1690,6 +1695,9 @@ unlockout: vn_seqc_write_end(fdvp); } + if (checkpath_locked) + sx_xunlock(&VFSTOUFS(mp)->um_checkpath_lock); + vput(fdvp); vput(fvp); diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index f2951d74d44c..da9a22127125 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -70,6 +70,7 @@ LIST_HEAD(trimlist_hashhead, ffs_blkfree_trim_params); #include #include +#include /* * This structure describes the UFS specific mount structure data. @@ -99,6 +100,8 @@ struct ufsmount { uint64_t um_maxsymlinklen; /* (c) max size of short symlink */ struct mtx um_lock; /* (c) Protects ufsmount & fs */ + struct sx um_checkpath_lock; /* (c) Protects ufs_checkpath() + result */ pid_t um_fsckpid; /* (u) PID can do fsck sysctl */ struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */ struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */ From owner-dev-commits-src-all@freebsd.org Fri Aug 13 15:18:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 16957658DBB; Fri, 13 Aug 2021 15:18: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 4GmRyh05xcz3wQX; Fri, 13 Aug 2021 15:18: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 D59EE107E5; Fri, 13 Aug 2021 15:18: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 17DFIJX1096320; Fri, 13 Aug 2021 15:18:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DFIJlo096319; Fri, 13 Aug 2021 15:18:19 GMT (envelope-from git) Date: Fri, 13 Aug 2021 15:18:19 GMT Message-Id: <202108131518.17DFIJlo096319@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 57aaefdceccd - main - ar: diff reduction against ELF Tool Chain 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/main X-Git-Reftype: branch X-Git-Commit: 57aaefdceccdd590f81af4b274c7a3ee61ae62f1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 15:18:20 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=57aaefdceccdd590f81af4b274c7a3ee61ae62f1 commit 57aaefdceccdd590f81af4b274c7a3ee61ae62f1 Author: Ed Maste AuthorDate: 2021-08-13 15:17:24 +0000 Commit: Ed Maste CommitDate: 2021-08-13 15:17:46 +0000 ar: diff reduction against ELF Tool Chain Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive directly. (This was originally committed in d20e9e02db3d but reverted due to a regression, now fixed with an update from cy@.) Obtained from: ELF Tool Chain Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31496 --- usr.bin/ar/acpyacc.y | 14 +++++++------- usr.bin/ar/ar.c | 27 ++++++--------------------- usr.bin/ar/ar.h | 14 ++++---------- usr.bin/ar/read.c | 30 +++++------------------------- usr.bin/ar/write.c | 51 ++++++--------------------------------------------- 5 files changed, 28 insertions(+), 108 deletions(-) diff --git a/usr.bin/ar/acpyacc.y b/usr.bin/ar/acpyacc.y index f6bfbd7957b5..34156e1d2d58 100644 --- a/usr.bin/ar/acpyacc.y +++ b/usr.bin/ar/acpyacc.y @@ -367,7 +367,7 @@ arscp_addlib(char *archive, struct list *list) return; arscp_mlist2argv(list); bsdar->addlib = archive; - ar_mode_A(bsdar); + ar_write_archive(bsdar, 'A'); arscp_free_argv(); arscp_free_mlist(list); } @@ -380,7 +380,7 @@ arscp_addmod(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_q(bsdar); + ar_write_archive(bsdar, 'q'); arscp_free_argv(); arscp_free_mlist(list); } @@ -393,7 +393,7 @@ arscp_delete(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_d(bsdar); + ar_write_archive(bsdar, 'd'); arscp_free_argv(); arscp_free_mlist(list); } @@ -406,7 +406,7 @@ arscp_extract(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_x(bsdar); + ar_read_archive(bsdar, 'x'); arscp_free_argv(); arscp_free_mlist(list); } @@ -422,7 +422,7 @@ arscp_list(void) bsdar->argv = NULL; /* Always verbose. */ bsdar->options |= AR_V; - ar_mode_t(bsdar); + ar_read_archive(bsdar, 't'); bsdar->options &= ~AR_V; } @@ -449,7 +449,7 @@ arscp_dir(char *archive, struct list *list, char *rlt) } if (verbose) bsdar->options |= AR_V; - ar_mode_t(bsdar); + ar_read_archive(bsdar, 't'); bsdar->options &= ~AR_V; if (rlt) { @@ -473,7 +473,7 @@ arscp_replace(struct list *list) if (!arscp_target_exist()) return; arscp_mlist2argv(list); - ar_mode_r(bsdar); + ar_write_archive(bsdar, 'r'); arscp_free_argv(); arscp_free_mlist(list); } diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c index aceb4d7f8487..fdfebb8eb459 100644 --- a/usr.bin/ar/ar.c +++ b/usr.bin/ar/ar.c @@ -151,7 +151,7 @@ main(int argc, char **argv) bsdar->options |= AR_D; bsdar->options |= AR_S; while ((bsdar->filename = *argv++) != NULL) - if (ar_mode_s(bsdar)) + if (ar_write_archive(bsdar, 's')) exitcode = EXIT_FAILURE; exit(exitcode); @@ -317,32 +317,17 @@ main(int argc, char **argv) if ((!bsdar->mode || strchr("ptx", bsdar->mode)) && bsdar->options & AR_S) { - exitcode = ar_mode_s(bsdar); + exitcode = ar_write_archive(bsdar, 's'); if (!bsdar->mode) exit(exitcode); } switch(bsdar->mode) { - case 'd': - exitcode = ar_mode_d(bsdar); + case 'd': case 'm': case 'q': case 'r': + exitcode = ar_write_archive(bsdar, bsdar->mode); break; - case 'm': - exitcode = ar_mode_m(bsdar); - break; - case 'p': - exitcode = ar_mode_p(bsdar); - break; - case 'q': - exitcode = ar_mode_q(bsdar); - break; - case 'r': - exitcode = ar_mode_r(bsdar); - break; - case 't': - exitcode = ar_mode_t(bsdar); - break; - case 'x': - exitcode = ar_mode_x(bsdar); + case 'p': case 't': case 'x': + exitcode = ar_read_archive(bsdar, bsdar->mode); break; default: bsdar_usage(); diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h index 321680fed804..c8705e20eb45 100644 --- a/usr.bin/ar/ar.h +++ b/usr.bin/ar/ar.h @@ -115,14 +115,8 @@ struct bsdar { }; void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __dead2; -void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); -int ar_mode_d(struct bsdar *bsdar); -int ar_mode_m(struct bsdar *bsdar); -int ar_mode_p(struct bsdar *bsdar); -int ar_mode_q(struct bsdar *bsdar); -int ar_mode_r(struct bsdar *bsdar); -int ar_mode_s(struct bsdar *bsdar); -int ar_mode_t(struct bsdar *bsdar); -int ar_mode_x(struct bsdar *bsdar); -int ar_mode_A(struct bsdar *bsdar); void ar_mode_script(struct bsdar *ar); +int ar_read_archive(struct bsdar *ar, int mode); +int ar_write_archive(struct bsdar *ar, int mode); +void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __dead2; +void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c index 15044ab57a93..81e0bfce1b7e 100644 --- a/usr.bin/ar/read.c +++ b/usr.bin/ar/read.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -42,34 +43,11 @@ __FBSDID("$FreeBSD$"); #include "ar.h" -static int read_archive(struct bsdar *bsdar, char mode); - -int -ar_mode_p(struct bsdar *bsdar) -{ - - return (read_archive(bsdar, 'p')); -} - -int -ar_mode_t(struct bsdar *bsdar) -{ - - return (read_archive(bsdar, 't')); -} - -int -ar_mode_x(struct bsdar *bsdar) -{ - - return (read_archive(bsdar, 'x')); -} - /* * Handle read modes: 'x', 't' and 'p'. */ -static int -read_archive(struct bsdar *bsdar, char mode) +int +ar_read_archive(struct bsdar *bsdar, int mode) { struct archive *a; struct archive_entry *entry; @@ -87,6 +65,8 @@ read_archive(struct bsdar *bsdar, char mode) char find; int exitcode, flags, r, i; + assert(mode == 'p' || mode == 't' || mode == 'x'); + if ((a = archive_read_new()) == NULL) bsdar_errc(bsdar, 0, "archive_read_new failed"); archive_read_support_format_ar(a); diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index 3c4b20e305da..1b9ff18b155b 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -66,54 +67,11 @@ static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, static void prefault_buffer(const char *buf, size_t s); static void read_objs(struct bsdar *bsdar, const char *archive, int checkargv); -static int write_archive(struct bsdar *bsdar, char mode); static void write_cleanup(struct bsdar *bsdar); static void write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s); static void write_objs(struct bsdar *bsdar); -int -ar_mode_d(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'd')); -} - -int -ar_mode_m(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'm')); -} - -int -ar_mode_q(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'q')); -} - -int -ar_mode_r(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'r')); -} - -int -ar_mode_s(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 's')); -} - -int -ar_mode_A(struct bsdar *bsdar) -{ - - return (write_archive(bsdar, 'A')); -} - /* * Create object from file, return created obj upon success, or NULL * when an error occurs or the member is not newer than existing @@ -376,8 +334,8 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv) /* * Determine the constitution of resulting archive. */ -static int -write_archive(struct bsdar *bsdar, char mode) +int +ar_write_archive(struct bsdar *bsdar, int mode) { struct ar_obj *nobj, *obj, *obj_temp, *pos; struct stat sb; @@ -391,6 +349,9 @@ write_archive(struct bsdar *bsdar, char mode) pos = NULL; memset(&sb, 0, sizeof(sb)); + assert(mode == 'A' || mode == 'd' || mode == 'm' || mode == 'q' || + mode == 'r' || mode == 's'); + /* * Test if the specified archive exists, to figure out * whether we are creating one here. From owner-dev-commits-src-all@freebsd.org Fri Aug 13 20:36:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 81D6465EDED; Fri, 13 Aug 2021 20:36: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 4Gmb1Q37kjz4k7r; Fri, 13 Aug 2021 20:36: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 5474A1493A; Fri, 13 Aug 2021 20:36: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 17DKaA07021213; Fri, 13 Aug 2021 20:36:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DKaAsr021212; Fri, 13 Aug 2021 20:36:10 GMT (envelope-from git) Date: Fri, 13 Aug 2021 20:36:10 GMT Message-Id: <202108132036.17DKaAsr021212@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: 654e91791ba3 - stable/13 - Clean up orphaned indirdep dependency structures after disk failure. 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: 654e91791ba3230bf26954d3ac1af6848702e4e6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 20:36:10 -0000 The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=654e91791ba3230bf26954d3ac1af6848702e4e6 commit 654e91791ba3230bf26954d3ac1af6848702e4e6 Author: Kirk McKusick AuthorDate: 2021-07-29 23:11:58 +0000 Commit: Kirk McKusick CommitDate: 2021-08-13 17:37:26 +0000 Clean up orphaned indirdep dependency structures after disk failure. (cherry picked from commit 412b5e40a721430adba1b4abae210641f733f976) (cherry picked from commit a91716efeb684c50289c0e1136f5432f880dc873) --- sys/ufs/ffs/ffs_softdep.c | 54 +++++++++++++++++++++++++++++++++++++++++------ sys/ufs/ffs/softdep.h | 4 +--- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 446fc69a6a32..c53ba7c70d2f 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1233,9 +1233,7 @@ workitem_free(item, type) ump->um_fs->fs_fsmnt, TYPENAME(item->wk_type))); atomic_subtract_long(&dep_current[item->wk_type], 1); ump->softdep_curdeps[item->wk_type] -= 1; -#ifdef INVARIANTS LIST_REMOVE(item, wk_all); -#endif free(item, DtoM(type)); } @@ -1262,9 +1260,7 @@ workitem_alloc(item, type, mp) ump->softdep_curdeps[type] += 1; ump->softdep_deps++; ump->softdep_accdeps++; -#ifdef INVARIANTS LIST_INSERT_HEAD(&ump->softdep_alldeps[type], item, wk_all); -#endif FREE_LOCK(ump); } @@ -1293,6 +1289,8 @@ workitem_reassign(item, newtype) dep_total[newtype]++; FREE_GBLLOCK(&lk); item->wk_type = newtype; + LIST_REMOVE(item, wk_all); + LIST_INSERT_HEAD(&ump->softdep_alldeps[newtype], item, wk_all); } /* @@ -2710,10 +2708,8 @@ softdep_mount(devvp, mp, fs, cred) ump->indir_hash_size = i - 1; for (i = 0; i <= ump->indir_hash_size; i++) TAILQ_INIT(&ump->indir_hashtbl[i]); -#ifdef INVARIANTS for (i = 0; i <= D_LAST; i++) LIST_INIT(&ump->softdep_alldeps[i]); -#endif ACQUIRE_GBLLOCK(&lk); TAILQ_INSERT_TAIL(&softdepmounts, sdp, sd_next); FREE_GBLLOCK(&lk); @@ -14765,9 +14761,12 @@ softdep_check_suspend(struct mount *mp, int secondary_writes, int secondary_accwrites) { + struct buf *bp; struct bufobj *bo; struct ufsmount *ump; struct inodedep *inodedep; + struct indirdep *indirdep; + struct worklist *wk, *nextwk; int error, unlinked; bo = &devvp->v_bufobj; @@ -14843,9 +14842,52 @@ softdep_check_suspend(struct mount *mp, } } + /* + * XXX Check for orphaned indirdep dependency structures. + * + * During forcible unmount after a disk failure there is a + * bug that causes one or more indirdep dependency structures + * to fail to be deallocated. We check for them here and clean + * them up so that the unmount can succeed. + */ + if ((ump->um_flags & UM_FSFAIL_CLEANUP) != 0 && ump->softdep_deps > 0 && + ump->softdep_deps == ump->softdep_curdeps[D_INDIRDEP]) { + LIST_FOREACH_SAFE(wk, &ump->softdep_alldeps[D_INDIRDEP], + wk_all, nextwk) { + indirdep = WK_INDIRDEP(wk); + if ((indirdep->ir_state & (GOINGAWAY | DEPCOMPLETE)) != + (GOINGAWAY | DEPCOMPLETE) || + !TAILQ_EMPTY(&indirdep->ir_trunc) || + !LIST_EMPTY(&indirdep->ir_completehd) || + !LIST_EMPTY(&indirdep->ir_writehd) || + !LIST_EMPTY(&indirdep->ir_donehd) || + !LIST_EMPTY(&indirdep->ir_deplisthd) || + indirdep->ir_saveddata != NULL || + indirdep->ir_savebp == NULL) { + printf("%s: skipping orphaned indirdep %p\n", + __FUNCTION__, indirdep); + continue; + } + printf("%s: freeing orphaned indirdep %p\n", + __FUNCTION__, indirdep); + bp = indirdep->ir_savebp; + indirdep->ir_savebp = NULL; + free_indirdep(indirdep); + FREE_LOCK(ump); + brelse(bp); + while (!TRY_ACQUIRE_LOCK(ump)) { + BO_UNLOCK(bo); + ACQUIRE_LOCK(ump); + FREE_LOCK(ump); + BO_LOCK(bo); + } + } + } + /* * Reasons for needing more work before suspend: * - Dirty buffers on devvp. + * - Dependency structures still exist * - Softdep activity occurred after start of vnode sync loop * - Secondary writes occurred after start of vnode sync loop */ diff --git a/sys/ufs/ffs/softdep.h b/sys/ufs/ffs/softdep.h index 3493aadafc98..41728be3ec0f 100644 --- a/sys/ufs/ffs/softdep.h +++ b/sys/ufs/ffs/softdep.h @@ -213,10 +213,10 @@ struct worklist { struct mount *wk_mp; /* Mount we live in */ unsigned int wk_type:8, /* type of request */ wk_state:24; /* state flags */ + LIST_ENTRY(worklist) wk_all; /* list of deps of this type */ #ifdef INVARIANTS const char *wk_func; /* func where added / removed */ int wk_line; /* line where added / removed */ - LIST_ENTRY(worklist) wk_all; /* list of deps of this type */ #endif }; #define WK_DATA(wk) ((void *)(wk)) @@ -1075,9 +1075,7 @@ struct mount_softdeps { TAILQ_ENTRY(mount_softdeps) sd_next; /* List of softdep filesystem */ struct ufsmount *sd_ump; /* our ufsmount structure */ u_long sd_curdeps[D_LAST + 1]; /* count of current deps */ -#ifdef INVARIANTS struct workhead sd_alldeps[D_LAST + 1];/* Lists of all deps */ -#endif }; /* * Flags for communicating with the syncer thread. From owner-dev-commits-src-all@freebsd.org Fri Aug 13 20:59:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9BB2965F134; Fri, 13 Aug 2021 20:59: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 4GmbWr3n5Dz4kxn; Fri, 13 Aug 2021 20:59: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 69FFF14E53; Fri, 13 Aug 2021 20:59: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 17DKx4GG047400; Fri, 13 Aug 2021 20:59:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DKx4dF047399; Fri, 13 Aug 2021 20:59:04 GMT (envelope-from git) Date: Fri, 13 Aug 2021 20:59:04 GMT Message-Id: <202108132059.17DKx4dF047399@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 866c80747261 - main - ar: remove duplicate function declaration in header 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/main X-Git-Reftype: branch X-Git-Commit: 866c807472619371adcb2a0409a9287748a52654 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 20:59:04 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=866c807472619371adcb2a0409a9287748a52654 commit 866c807472619371adcb2a0409a9287748a52654 Author: Ed Maste AuthorDate: 2021-08-13 19:36:13 +0000 Commit: Ed Maste CommitDate: 2021-08-13 20:58:18 +0000 ar: remove duplicate function declaration in header Sponsored by: The FreeBSD Foundation --- usr.bin/ar/ar.h | 1 - 1 file changed, 1 deletion(-) diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h index c8705e20eb45..bcccf93a6016 100644 --- a/usr.bin/ar/ar.h +++ b/usr.bin/ar/ar.h @@ -114,7 +114,6 @@ struct bsdar { TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ }; -void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __dead2; void ar_mode_script(struct bsdar *ar); int ar_read_archive(struct bsdar *ar, int mode); int ar_write_archive(struct bsdar *ar, int mode); From owner-dev-commits-src-all@freebsd.org Fri Aug 13 20:59:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B5FFE65F3E2; Fri, 13 Aug 2021 20:59: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 4GmbWs4j9lz4kV6; Fri, 13 Aug 2021 20:59: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 8A3C414DDC; Fri, 13 Aug 2021 20:59: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 17DKx58K047430; Fri, 13 Aug 2021 20:59:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DKx5n2047429; Fri, 13 Aug 2021 20:59:05 GMT (envelope-from git) Date: Fri, 13 Aug 2021 20:59:05 GMT Message-Id: <202108132059.17DKx5n2047429@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 6b25b4a73fbe - main - mgb: update Microchip URLs 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/main X-Git-Reftype: branch X-Git-Commit: 6b25b4a73fbe56e15d094895b4c7acdb424ee80d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 20:59:05 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=6b25b4a73fbe56e15d094895b4c7acdb424ee80d commit 6b25b4a73fbe56e15d094895b4c7acdb424ee80d Author: Ed Maste AuthorDate: 2021-08-13 20:57:04 +0000 Commit: Ed Maste CommitDate: 2021-08-13 20:58:25 +0000 mgb: update Microchip URLs Sponsored by: The FreeBSD Foundation --- sys/dev/mgb/if_mgb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/mgb/if_mgb.c b/sys/dev/mgb/if_mgb.c index 3f7a9d1a9dbb..e1381dbc307d 100644 --- a/sys/dev/mgb/if_mgb.c +++ b/sys/dev/mgb/if_mgb.c @@ -34,9 +34,9 @@ __FBSDID("$FreeBSD$"); * Microchip LAN7430/LAN7431 PCIe to Gigabit Ethernet Controller driver. * * Product information: - * LAN7430 https://www.microchip.com/wwwproducts/en/LAN7430 + * LAN7430 https://www.microchip.com/en-us/product/LAN7430 * - Integrated IEEE 802.3 compliant PHY - * LAN7431 https://www.microchip.com/wwwproducts/en/LAN7431 + * LAN7431 https://www.microchip.com/en-us/product/LAN7431 * - RGMII Interface * * This driver uses the iflib interface and the default 'ukphy' PHY driver. From owner-dev-commits-src-all@freebsd.org Fri Aug 13 21:18:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6D81965EEFC; Fri, 13 Aug 2021 21:18: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 4GmbyM2NJCz4mDT; Fri, 13 Aug 2021 21:18: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 39C04153A9; Fri, 13 Aug 2021 21:18: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 17DLIZWn075235; Fri, 13 Aug 2021 21:18:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17DLIZCd075234; Fri, 13 Aug 2021 21:18:35 GMT (envelope-from git) Date: Fri, 13 Aug 2021 21:18:35 GMT Message-Id: <202108132118.17DLIZCd075234@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9446d9e88fd7 - main - fstatat(2): handle non-vnode file descriptors for AT_EMPTY_PATH 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/main X-Git-Reftype: branch X-Git-Commit: 9446d9e88fd7b203fa50c015f29b636db5b1d52b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 21:18:35 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9446d9e88fd7b203fa50c015f29b636db5b1d52b commit 9446d9e88fd7b203fa50c015f29b636db5b1d52b Author: Konstantin Belousov AuthorDate: 2021-08-13 17:40:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-13 21:17:18 +0000 fstatat(2): handle non-vnode file descriptors for AT_EMPTY_PATH Set NIRES_EMPTYPATH earlies, to have use of EMPTYPATH recorded even if we are going to return error. When namei_setup() refused to accept dirfd, which is not of the vnode type, and indicated by ENOTDIR error return, fall back to kern_fstat(dirfd). Reported by: dchagin Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31530 --- sys/kern/vfs_lookup.c | 2 +- sys/kern/vfs_syscalls.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index e0b98c9f5661..a827c87538b8 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -489,6 +489,7 @@ namei_emptypath(struct nameidata *ndp) MPASS((cnp->cn_flags & EMPTYPATH) != 0); MPASS((cnp->cn_flags & (LOCKPARENT | WANTPARENT)) == 0); + ndp->ni_resflags |= NIRES_EMPTYPATH; error = namei_setup(ndp, &dp, &pwd); if (error != 0) { namei_cleanup_cnp(cnp); @@ -501,7 +502,6 @@ namei_emptypath(struct nameidata *ndp) ndp->ni_vp = dp; namei_cleanup_cnp(cnp); pwd_drop(pwd); - ndp->ni_resflags |= NIRES_EMPTYPATH; NDVALIDATE(ndp); if ((cnp->cn_flags & LOCKLEAF) != 0) { VOP_LOCK(dp, (cnp->cn_flags & LOCKSHARED) != 0 ? diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index f2ed8d2a9acb..bd496db50e99 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2438,8 +2438,12 @@ kern_statat(struct thread *td, int flag, int fd, const char *path, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH) | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg, path, fd, &cap_fstat_rights, td); - if ((error = namei(&nd)) != 0) + if ((error = namei(&nd)) != 0) { + if (error == ENOTDIR && + (nd.ni_resflags & NIRES_EMPTYPATH) != 0) + error = kern_fstat(td, fd, sbp); return (error); + } error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED, td); if (error == 0) { if (__predict_false(hook != NULL)) From owner-dev-commits-src-all@freebsd.org Sat Aug 14 00:01:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5C382662507; Sat, 14 Aug 2021 00:01:51 +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 4GmgZl2Cb5z3CWX; Sat, 14 Aug 2021 00:01: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 341471771E; Sat, 14 Aug 2021 00:01: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 17E01ptO099333; Sat, 14 Aug 2021 00:01:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E01pZi099332; Sat, 14 Aug 2021 00:01:51 GMT (envelope-from git) Date: Sat, 14 Aug 2021 00:01:51 GMT Message-Id: <202108140001.17E01pZi099332@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 825fb07c5598 - main - aio: revert the workaround for bug 251828 in the tests 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/main X-Git-Reftype: branch X-Git-Commit: 825fb07c55986971b1a20e40a73c12eb0ff432e0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 00:01:51 -0000 The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=825fb07c55986971b1a20e40a73c12eb0ff432e0 commit 825fb07c55986971b1a20e40a73c12eb0ff432e0 Author: Alan Somers AuthorDate: 2021-08-13 22:59:10 +0000 Commit: Alan Somers CommitDate: 2021-08-14 00:01:18 +0000 aio: revert the workaround for bug 251828 in the tests This bug is no longer reproducible in 14.0-CURRENT and 13.0-RELEASE Do not MFC to stable/12 ! PR: 251828 Reported by: markj Reviewed by: markj MFC after: 2 weeks Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D31535 --- tests/sys/aio/aio_test.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c index 6681a13653b4..35bd5dc1264b 100644 --- a/tests/sys/aio/aio_test.c +++ b/tests/sys/aio/aio_test.c @@ -924,13 +924,6 @@ aio_zvol_setup(void) ZVOL_SIZE " %s", zvol_name); ATF_REQUIRE_EQ_MSG(0, system(cmd), "zfs create failed: %s", strerror(errno)); - /* - * XXX Due to bug 251828, we need an extra "zfs set" here - * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251828 - */ - snprintf(cmd, sizeof(cmd), "zfs set volmode=dev %s", zvol_name); - ATF_REQUIRE_EQ_MSG(0, system(cmd), - "zfs set failed: %s", strerror(errno)); snprintf(devname, sizeof(devname), "/dev/zvol/%s", zvol_name); do { From owner-dev-commits-src-all@freebsd.org Sat Aug 14 01:13:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 87B90663591; Sat, 14 Aug 2021 01:13: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 4Gmj9D3JCZz3Ksn; Sat, 14 Aug 2021 01:13: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 3B4C518914; Sat, 14 Aug 2021 01:13: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 17E1DKLj094834; Sat, 14 Aug 2021 01:13:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E1DKgO094833; Sat, 14 Aug 2021 01:13:20 GMT (envelope-from git) Date: Sat, 14 Aug 2021 01:13:20 GMT Message-Id: <202108140113.17E1DKgO094833@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: 9c15ec46bfb6 - stable/13 - ncurses: Apply a tputs() fix from patch 20210403 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: 9c15ec46bfb6558c42a668afeef1a4418dcd970d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 01:13:20 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9c15ec46bfb6558c42a668afeef1a4418dcd970d commit 9c15ec46bfb6558c42a668afeef1a4418dcd970d Author: Mark Johnston AuthorDate: 2021-08-11 16:54:29 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 01:13:16 +0000 ncurses: Apply a tputs() fix from patch 20210403 From the (substantially larger) upstream commit: + call delay_output_sp to handle BSD-style padding when tputs_sp is called, whether directly or internally, to ensure that the SCREEN pointer is passed correctly (reports by Henric Jungheim, Juraj Lutter). This fixes bison segfaults observed when colourized output is enabled. Thanks to jrtc27@ for identifying the upstream fix. PR: 256731 MFC after: 3 days (cherry picked from commit b2da1032397e3339fbeebcd57b1f179e1d8a2e19) --- contrib/ncurses/ncurses/tinfo/lib_tputs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c index bfde26efd980..7da8803905e4 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c +++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -52,7 +52,7 @@ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.103 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.107 2021/04/03 18:45:53 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */ @@ -419,7 +419,7 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx */ if (trailpad > 0 && (always_delay || normal_delay)) - delay_output(trailpad / 10); + NCURSES_SP_NAME(delay_output) (NCURSES_SP_ARGx trailpad / 10); #endif /* BSD_TPUTS */ SetOutCh(my_outch); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 06:28:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6EE24665B6D; Sat, 14 Aug 2021 06:28: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 4Gmr9J26t0z4qSx; Sat, 14 Aug 2021 06:28: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 312231D6F2; Sat, 14 Aug 2021 06:28: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 17E6SqZb007982; Sat, 14 Aug 2021 06:28:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E6SqZ7007981; Sat, 14 Aug 2021 06:28:52 GMT (envelope-from git) Date: Sat, 14 Aug 2021 06:28:52 GMT Message-Id: <202108140628.17E6SqZ7007981@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: 375a52cc3cfe - stable/13 - mkimg(1): Correct a typo in the usage output 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: 375a52cc3cfee15a66dbe857b8381112b129af98 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 06:28:52 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=375a52cc3cfee15a66dbe857b8381112b129af98 commit 375a52cc3cfee15a66dbe857b8381112b129af98 Author: Gordon Bergling AuthorDate: 2021-08-09 11:53:30 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 06:28:00 +0000 mkimg(1): Correct a typo in the usage output - s/partion/partition/ (cherry picked from commit 6bddade6114abacacb30ef2c28781f1af331c106) --- usr.bin/mkimg/mkimg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c index e5e6c036575b..71af45b5815d 100644 --- a/usr.bin/mkimg/mkimg.c +++ b/usr.bin/mkimg/mkimg.c @@ -151,7 +151,7 @@ usage(const char *why) fprintf(stderr, "\t--schemes\t- list partition schemes\n"); fprintf(stderr, "\t--version\t- show version information\n"); fputc('\n', stderr); - fprintf(stderr, "\t-a \t- mark num'th partion as active\n"); + fprintf(stderr, "\t-a \t- mark num'th partition as active\n"); fprintf(stderr, "\t-b \t- file containing boot code\n"); fprintf(stderr, "\t-c \t- minimum capacity (in bytes) of the disk\n"); fprintf(stderr, "\t-C \t- maximum capacity (in bytes) of the disk\n"); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 06:29:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 14775666AC4; Sat, 14 Aug 2021 06:29: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 4Gmr9t04Lhz4qJC; Sat, 14 Aug 2021 06:29: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 DED651CF57; Sat, 14 Aug 2021 06:29: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 17E6TL1Q008127; Sat, 14 Aug 2021 06:29:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E6TLai008126; Sat, 14 Aug 2021 06:29:21 GMT (envelope-from git) Date: Sat, 14 Aug 2021 06:29:21 GMT Message-Id: <202108140629.17E6TLai008126@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: 53b0a143509c - stable/12 - mkimg(1): Correct a typo in the usage output 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/12 X-Git-Reftype: branch X-Git-Commit: 53b0a143509cfaa88a3fe621063966158367f498 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 06:29:22 -0000 The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=53b0a143509cfaa88a3fe621063966158367f498 commit 53b0a143509cfaa88a3fe621063966158367f498 Author: Gordon Bergling AuthorDate: 2021-08-09 11:53:30 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 06:29:07 +0000 mkimg(1): Correct a typo in the usage output - s/partion/partition/ (cherry picked from commit 6bddade6114abacacb30ef2c28781f1af331c106) --- usr.bin/mkimg/mkimg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c index c5a85aa7c33d..8967e538df42 100644 --- a/usr.bin/mkimg/mkimg.c +++ b/usr.bin/mkimg/mkimg.c @@ -151,7 +151,7 @@ usage(const char *why) fprintf(stderr, "\t--schemes\t- list partition schemes\n"); fprintf(stderr, "\t--version\t- show version information\n"); fputc('\n', stderr); - fprintf(stderr, "\t-a \t- mark num'th partion as active\n"); + fprintf(stderr, "\t-a \t- mark num'th partition as active\n"); fprintf(stderr, "\t-b \t- file containing boot code\n"); fprintf(stderr, "\t-c \t- minimum capacity (in bytes) of the disk\n"); fprintf(stderr, "\t-C \t- maximum capacity (in bytes) of the disk\n"); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 06:57:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7CF166726C; Sat, 14 Aug 2021 06:57: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 4Gmrp54Nq6z4rP2; Sat, 14 Aug 2021 06:57: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 7EBDF1DCB4; Sat, 14 Aug 2021 06:57: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 17E6vHDt048606; Sat, 14 Aug 2021 06:57:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E6vHBT048605; Sat, 14 Aug 2021 06:57:17 GMT (envelope-from git) Date: Sat, 14 Aug 2021 06:57:17 GMT Message-Id: <202108140657.17E6vHBT048605@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 17db4b52fb41 - main - Fix some common typos in source code comments 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/main X-Git-Reftype: branch X-Git-Commit: 17db4b52fb41aeabeb945c68c1b5edd4db4eac31 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 06:57:17 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=17db4b52fb41aeabeb945c68c1b5edd4db4eac31 commit 17db4b52fb41aeabeb945c68c1b5edd4db4eac31 Author: Gordon Bergling AuthorDate: 2021-08-14 06:55:58 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 06:55:58 +0000 Fix some common typos in source code comments - s/struture/structure/ - s/structre/structure/ MFC after: 5 days --- sys/dev/bce/if_bce.c | 4 ++-- sys/dev/drm2/drm_platform.c | 2 +- sys/dev/isci/scil/intel_ata.h | 2 +- sys/dev/isci/scil/sci_overview.h | 2 +- sys/dev/liquidio/base/lio_device.h | 2 +- sys/dev/pms/RefTisa/sallsdk/api/sa.h | 2 +- sys/dev/pms/RefTisa/sallsdk/spc/sallist.h | 2 +- sys/dev/pms/RefTisa/tisa/sassata/common/tdinit.c | 2 +- sys/dev/pms/freebsd/driver/common/lxcommon.h | 2 +- sys/sys/jail.h | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index d6c5a2bf091f..869d8f9fc40e 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -3163,7 +3163,7 @@ bce_init_media(struct bce_softc *sc) /****************************************************************************/ /* Free any DMA memory owned by the driver. */ /* */ -/* Scans through each data structre that requires DMA memory and frees */ +/* Scans through each data structure that requires DMA memory and frees */ /* the memory if allocated. */ /* */ /* Returns: */ @@ -5553,7 +5553,7 @@ bce_init_tx_chain(struct bce_softc *sc) DBRUN(sc->tx_full_count = 0); /* - * The NetXtreme II supports a linked-list structre called + * The NetXtreme II supports a linked-list structure called * a Buffer Descriptor Chain (or BD chain). A BD chain * consists of a series of 1 or more chain pages, each of which * consists of a fixed number of BD entries. diff --git a/sys/dev/drm2/drm_platform.c b/sys/dev/drm2/drm_platform.c index a8972b44f5f1..17f3367719e2 100644 --- a/sys/dev/drm2/drm_platform.c +++ b/sys/dev/drm2/drm_platform.c @@ -107,7 +107,7 @@ static struct drm_bus drm_platform_bus = { /** * Register. * - * \param platdev - Platform device struture + * \param platdev - Platform device structure * \return zero on success or a negative number on failure. * * Attempt to gets inter module "drm" information. If we are first diff --git a/sys/dev/isci/scil/intel_ata.h b/sys/dev/isci/scil/intel_ata.h index 86f584b35d61..e213d0efcb06 100644 --- a/sys/dev/isci/scil/intel_ata.h +++ b/sys/dev/isci/scil/intel_ata.h @@ -244,7 +244,7 @@ * * The following constants define bit masks utilized to determine if a * feature is supported/enabled or if a bit is simply set inside of the - * IDENTIFY DEVICE data structre. + * IDENTIFY DEVICE data structure. */ /*@{*/ #define ATA_IDENTIFY_REMOVABLE_MEDIA_ENABLE 0x0080 diff --git a/sys/dev/isci/scil/sci_overview.h b/sys/dev/isci/scil/sci_overview.h index 3cde341efb1f..cba4f8351fbd 100644 --- a/sys/dev/isci/scil/sci_overview.h +++ b/sys/dev/isci/scil/sci_overview.h @@ -216,7 +216,7 @@ associate one object to another. An SCI object can be made to have an association to another SCI object. Additionally, an SCI object can be made to have an association to a non-SCI based object. For example, an SCI Framework library can have it's association set to an operating system -specific adapter/device driver structre. +specific adapter/device driver structure. Simply put, the association that an object has is a handle (i.e. a void pointer) to a user structure. This enables the user of the SCI object to diff --git a/sys/dev/liquidio/base/lio_device.h b/sys/dev/liquidio/base/lio_device.h index d5ba3361b2fc..de07f604fd9c 100644 --- a/sys/dev/liquidio/base/lio_device.h +++ b/sys/dev/liquidio/base/lio_device.h @@ -799,7 +799,7 @@ void *lio_get_config_info(struct octeon_device *oct, uint16_t card_type); /* * Gets the octeon device configuration - * @return - pointer to the octeon configuration struture + * @return - pointer to the octeon configuration structure */ struct lio_config *lio_get_conf(struct octeon_device *oct); diff --git a/sys/dev/pms/RefTisa/sallsdk/api/sa.h b/sys/dev/pms/RefTisa/sallsdk/api/sa.h index e13db5390f4e..e702dd4fb23a 100644 --- a/sys/dev/pms/RefTisa/sallsdk/api/sa.h +++ b/sys/dev/pms/RefTisa/sallsdk/api/sa.h @@ -1660,7 +1660,7 @@ typedef struct agsaContext_s void *sdkData; /**< Pointer-sized value used internally by the LL Layer */ } agsaContext_t; -/** \brief hold points to global data strutures used by the LL and OS Layers +/** \brief hold points to global data structures used by the LL and OS Layers * * The agsaRoot_t data structure is used to hold pointer-sized values for * internal use by the LL and OS Layers. It is intended that the diff --git a/sys/dev/pms/RefTisa/sallsdk/spc/sallist.h b/sys/dev/pms/RefTisa/sallsdk/spc/sallist.h index 0203a64f6f65..8ed9fb325445 100644 --- a/sys/dev/pms/RefTisa/sallsdk/spc/sallist.h +++ b/sys/dev/pms/RefTisa/sallsdk/spc/sallist.h @@ -40,7 +40,7 @@ /** \brief Structure of Link Data * * link data, need to be included at the start (offset 0) - * of any strutures that are to be stored in the link list + * of any structures that are to be stored in the link list * */ typedef struct _SALINK diff --git a/sys/dev/pms/RefTisa/tisa/sassata/common/tdinit.c b/sys/dev/pms/RefTisa/tisa/sassata/common/tdinit.c index 89ac376caaff..eeaac814d1c2 100644 --- a/sys/dev/pms/RefTisa/tisa/sassata/common/tdinit.c +++ b/sys/dev/pms/RefTisa/tisa/sassata/common/tdinit.c @@ -2496,7 +2496,7 @@ tdsaSharedMemCalculate( #endif #ifdef TD_DISCOVER - /* adding expander data strutures */ + /* adding expander data structures */ tdSharedMem->tdSharedCachedMem1.singleElementLength += sizeof(tdsaExpander_t) * MaxTargets; #endif diff --git a/sys/dev/pms/freebsd/driver/common/lxcommon.h b/sys/dev/pms/freebsd/driver/common/lxcommon.h index bbe33cf1fef7..5968ecba8021 100644 --- a/sys/dev/pms/freebsd/driver/common/lxcommon.h +++ b/sys/dev/pms/freebsd/driver/common/lxcommon.h @@ -614,7 +614,7 @@ bit8 *data; //buffer /* ** link data, need to be included at the start (offset 0) -** of any strutures that are to be stored in the link list +** of any structures that are to be stored in the link list */ typedef struct _LINK_NODE { diff --git a/sys/sys/jail.h b/sys/sys/jail.h index 76ed377e3f06..b0183d404352 100644 --- a/sys/sys/jail.h +++ b/sys/sys/jail.h @@ -149,7 +149,7 @@ struct prison_racct; /* * This structure describes a prison. It is pointed to by all struct * ucreds's of the inmates. pr_ref keeps track of them and is used to - * delete the struture when the last inmate is dead. + * delete the structure when the last inmate is dead. * * Lock key: * (a) allprison_lock From owner-dev-commits-src-all@freebsd.org Sat Aug 14 07:06:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 35B1A6673A2; Sat, 14 Aug 2021 07:06: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 4Gms1F0fCXz4s1b; Sat, 14 Aug 2021 07:06: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 EE0F91DC43; Sat, 14 Aug 2021 07:06: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 17E76uhb062673; Sat, 14 Aug 2021 07:06:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E76ulM062672; Sat, 14 Aug 2021 07:06:56 GMT (envelope-from git) Date: Sat, 14 Aug 2021 07:06:56 GMT Message-Id: <202108140706.17E76ulM062672@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: fa7a635f7ee2 - main - Fix a few typos in source code comments 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/main X-Git-Reftype: branch X-Git-Commit: fa7a635f7ee277960eb37b9102a3aef76b36b825 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 07:06:57 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=fa7a635f7ee277960eb37b9102a3aef76b36b825 commit fa7a635f7ee277960eb37b9102a3aef76b36b825 Author: Gordon Bergling AuthorDate: 2021-08-14 07:06:09 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 07:06:09 +0000 Fix a few typos in source code comments - s/becase/because/ MFC after: 5 days --- stand/i386/libfirewire/dconsole.c | 2 +- sys/vm/vm_pageout.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/i386/libfirewire/dconsole.c b/stand/i386/libfirewire/dconsole.c index 1528fafdf787..338ed26aa417 100644 --- a/stand/i386/libfirewire/dconsole.c +++ b/stand/i386/libfirewire/dconsole.c @@ -47,7 +47,7 @@ static int dcons_started = 0; static struct dcons_softc sc[DCONS_NPORT]; uint32_t dcons_paddr; -/* The buffer must be allocated in BSS becase: +/* The buffer must be allocated in BSS because: * - The dcons driver in the kernel is initialized before VM/pmap is * initialized, so that the buffer must be allocate in the region * that is mapped at the very early boot state. diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 9a0b295569e2..ff0c90843037 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -539,7 +539,7 @@ vm_pageout_flush(vm_page_t *mc, int count, int flags, int mreq, int *prunlen, * the PQ_UNSWAPPABLE holding queue. This is an * optimization that prevents the page daemon from * wasting CPU cycles on pages that cannot be reclaimed - * becase no swap device is configured. + * because no swap device is configured. * * Otherwise, reactivate the page so that it doesn't * clog the laundry and inactive queues. (We will try From owner-dev-commits-src-all@freebsd.org Sat Aug 14 07:40:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18FA066744E; Sat, 14 Aug 2021 07:40: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 4GmslV6yLwz4t90; Sat, 14 Aug 2021 07:40: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 D67B21E1AC; Sat, 14 Aug 2021 07:40: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 17E7e6US007001; Sat, 14 Aug 2021 07:40:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E7e6wg006996; Sat, 14 Aug 2021 07:40:06 GMT (envelope-from git) Date: Sat, 14 Aug 2021 07:40:06 GMT Message-Id: <202108140740.17E7e6wg006996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 34f620f1d0cf - main - Fix a few typos in source code comments 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/main X-Git-Reftype: branch X-Git-Commit: 34f620f1d0cfa67f5987452ac3fdd8c113b6b099 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 07:40:07 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=34f620f1d0cfa67f5987452ac3fdd8c113b6b099 commit 34f620f1d0cfa67f5987452ac3fdd8c113b6b099 Author: Gordon Bergling AuthorDate: 2021-08-14 07:39:17 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 07:39:17 +0000 Fix a few typos in source code comments - s/posbile/possible/ MFC after: 5 days --- sys/cam/scsi/scsi_all.c | 2 +- sys/netgraph/ng_base.c | 2 +- tools/regression/netinet/ipsockopt/ipsockopt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c index 5a50d5bb134b..729a2a06e616 100644 --- a/sys/cam/scsi/scsi_all.c +++ b/sys/cam/scsi/scsi_all.c @@ -9150,7 +9150,7 @@ scsi_devid_match(uint8_t *lhs, size_t lhs_len, uint8_t *rhs, size_t rhs_len) rhs_end = rhs + rhs_len; /* - * rhs_last and lhs_last are the last posible position of a valid + * rhs_last and lhs_last are the last possible position of a valid * descriptor assuming it had a zero length identifier. We use * these variables to insure we can safely dereference the length * field in our loop termination tests. diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index ae179cf13a45..ba60acb53502 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -3454,7 +3454,7 @@ ngthread(void *arg) /* * XXX - * It's posible that a debugging NG_NODE_REF may need + * It's possible that a debugging NG_NODE_REF may need * to be outside the mutex zone */ static void diff --git a/tools/regression/netinet/ipsockopt/ipsockopt.c b/tools/regression/netinet/ipsockopt/ipsockopt.c index d03ddf652f42..16805b9e6412 100644 --- a/tools/regression/netinet/ipsockopt/ipsockopt.c +++ b/tools/regression/netinet/ipsockopt/ipsockopt.c @@ -163,7 +163,7 @@ test_ip_options(int sock, const char *socktypename) "returned %d bytes of data", socktypename, len); /* - * One posible failure mode is that the call succeeds but neglects to + * One possible failure mode is that the call succeeds but neglects to * copy out the data. */ if (test_options[0] == TEST_MAGIC) From owner-dev-commits-src-all@freebsd.org Sat Aug 14 08:09:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BDE47667DFE; Sat, 14 Aug 2021 08:09:40 +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 4GmtPc3Q2Pz4vbr; Sat, 14 Aug 2021 08:09: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 58F6A1EC0A; Sat, 14 Aug 2021 08:09: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 17E89e3q044576; Sat, 14 Aug 2021 08:09:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17E89eZU044575; Sat, 14 Aug 2021 08:09:40 GMT (envelope-from git) Date: Sat, 14 Aug 2021 08:09:40 GMT Message-Id: <202108140809.17E89eZU044575@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 288e553623d3 - main - Fix a few typos in source code comments 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/main X-Git-Reftype: branch X-Git-Commit: 288e553623d3f8ac33baaabc93a4f030689755d2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 08:09:40 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=288e553623d3f8ac33baaabc93a4f030689755d2 commit 288e553623d3f8ac33baaabc93a4f030689755d2 Author: Gordon Bergling AuthorDate: 2021-08-14 08:08:49 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 08:08:49 +0000 Fix a few typos in source code comments - s/procesing/processing/ MFC after: 5 days --- sys/dev/ce/ceddk.c | 4 ++-- usr.bin/indent/lexi.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/ce/ceddk.c b/sys/dev/ce/ceddk.c index cca95c891964..569476040a93 100644 --- a/sys/dev/ce/ceddk.c +++ b/sys/dev/ce/ceddk.c @@ -245,7 +245,7 @@ static void TAU32_CALLBACK_TYPE ce_on_receive c->error (c, CE_OVERRUN); } else { CE_DDK_DEBUG (b, c, ("Another receive error: %x\n", error)); - /* Do some procesing */ + /* Do some processing */ } CE_ASSERT (!req->pInternal); @@ -297,7 +297,7 @@ static void TAU32_CALLBACK_TYPE ce_on_transmit } else { CE_DDK_DEBUG (c->board, c, ("Another transmit error: %x\n", error)); - /* Do some procesing */ + /* Do some processing */ } CE_ENQUEUE (c->tx_queue, req); diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index 1a5938689e26..83178a72b4f6 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -354,7 +354,7 @@ lexi(struct parser_state *state) * then following sign is unary */ state->last_u_d = true; /* will make "int a -1" work */ return (ident); /* the ident is not in the list */ - } /* end of procesing for alpanum character */ + } /* end of processing for alpanum character */ /* Scan a non-alphanumeric token */ From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3C7B0669ED9; Sat, 14 Aug 2021 10:22: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 4GmxLh0wKtz3LVw; Sat, 14 Aug 2021 10:22: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 08040204F3; Sat, 14 Aug 2021 10:22: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 17EAMJ4h029610; Sat, 14 Aug 2021 10:22:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMJDp029609; Sat, 14 Aug 2021 10:22:19 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:19 GMT Message-Id: <202108141022.17EAMJDp029609@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: 88156d89fbc5 - stable/13 - simplify journal_mount: move the out label after success block 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: 88156d89fbc5f0fd43aeb58eafbf16aec833c77d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:20 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=88156d89fbc5f0fd43aeb58eafbf16aec833c77d commit 88156d89fbc5f0fd43aeb58eafbf16aec833c77d Author: Konstantin Belousov AuthorDate: 2021-03-04 18:55:33 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 simplify journal_mount: move the out label after success block (cherry picked from commit 25aac48d2ce322355e7890a1de0f045a15d1cc09) --- sys/ufs/ffs/ffs_softdep.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index c53ba7c70d2f..e03f88029340 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -3013,26 +3013,26 @@ journal_mount(mp, fs, cred) jblocks->jb_low = jblocks->jb_free / 3; /* Reserve 33%. */ jblocks->jb_min = jblocks->jb_free / 10; /* Suspend at 10%. */ ump->softdep_jblocks = jblocks; -out: - if (error == 0) { - MNT_ILOCK(mp); - mp->mnt_flag |= MNT_SUJ; - mp->mnt_flag &= ~MNT_SOFTDEP; - MNT_IUNLOCK(mp); - /* - * Only validate the journal contents if the - * filesystem is clean, otherwise we write the logs - * but they'll never be used. If the filesystem was - * still dirty when we mounted it the journal is - * invalid and a new journal can only be valid if it - * starts from a clean mount. - */ - if (fs->fs_clean) { - DIP_SET(ip, i_modrev, fs->fs_mtime); - ip->i_flags |= IN_MODIFIED; - ffs_update(vp, 1); - } + + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_SUJ; + mp->mnt_flag &= ~MNT_SOFTDEP; + MNT_IUNLOCK(mp); + + /* + * Only validate the journal contents if the + * filesystem is clean, otherwise we write the logs + * but they'll never be used. If the filesystem was + * still dirty when we mounted it the journal is + * invalid and a new journal can only be valid if it + * starts from a clean mount. + */ + if (fs->fs_clean) { + DIP_SET(ip, i_modrev, fs->fs_mtime); + ip->i_flags |= IN_MODIFIED; + ffs_update(vp, 1); } +out: vput(vp); return (error); } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 79E1E66A11C; Sat, 14 Aug 2021 10:22: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 4GmxLj2c1dz3LSw; Sat, 14 Aug 2021 10:22: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 3633A20652; Sat, 14 Aug 2021 10:22: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 17EAML8G029634; Sat, 14 Aug 2021 10:22:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMLel029633; Sat, 14 Aug 2021 10:22:21 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:21 GMT Message-Id: <202108141022.17EAMLel029633@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: cac4051570d9 - stable/13 - Add FFSV_FORCEINODEDEP flag for ffs_vgetf() 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: cac4051570d9feb18a05084f327b86b53114acac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:21 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cac4051570d9feb18a05084f327b86b53114acac commit cac4051570d9feb18a05084f327b86b53114acac Author: Konstantin Belousov AuthorDate: 2021-03-03 17:40:56 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 Add FFSV_FORCEINODEDEP flag for ffs_vgetf() (cherry picked from commit fd97fa64638d810b415af7afcc86634c9709ad12) --- sys/ufs/ffs/ffs_extern.h | 1 + sys/ufs/ffs/ffs_softdep.c | 13 +++++++------ sys/ufs/ffs/ffs_vfsops.c | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index 0365cb76601e..c0ceeee09e89 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -127,6 +127,7 @@ int ffs_breadz(struct ufsmount *, struct vnode *, daddr_t, daddr_t, int, #define FFSV_FORCEINSMQ 0x0001 #define FFSV_REPLACE 0x0002 #define FFSV_REPLACE_DOOMED 0x0004 +#define FFSV_FORCEINODEDEP 0x0008 /* * Flags to ffs_reload diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index e03f88029340..37db84f06fd0 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1470,7 +1470,7 @@ get_parent_vp(struct vnode *vp, struct mount *mp, ino_t inum, struct buf *bp, ASSERT_VOP_ELOCKED(vp, "child vnode must be locked"); for (bplocked = true, pvp = NULL;;) { error = ffs_vgetf(mp, inum, LK_EXCLUSIVE | LK_NOWAIT, &pvp, - FFSV_FORCEINSMQ); + FFSV_FORCEINSMQ | FFSV_FORCEINODEDEP); if (error == 0) { /* * Since we could have unlocked vp, the inode @@ -1511,7 +1511,7 @@ get_parent_vp(struct vnode *vp, struct mount *mp, ino_t inum, struct buf *bp, VOP_UNLOCK(vp); error = ffs_vgetf(mp, inum, LK_EXCLUSIVE, &pvp, - FFSV_FORCEINSMQ); + FFSV_FORCEINSMQ | FFSV_FORCEINODEDEP); if (error != 0) { MPASS(error != ERELOOKUP); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); @@ -8413,7 +8413,7 @@ handle_complete_freeblocks(freeblks, flags) */ if (spare && freeblks->fb_len != 0) { if (ffs_vgetf(freeblks->fb_list.wk_mp, freeblks->fb_inum, - flags, &vp, FFSV_FORCEINSMQ) != 0) + flags, &vp, FFSV_FORCEINSMQ | FFSV_FORCEINODEDEP) != 0) return (EBUSY); ip = VTOI(vp); if (ip->i_mode == 0) { @@ -10203,7 +10203,8 @@ handle_workitem_remove(dirrem, flags) mp = dirrem->dm_list.wk_mp; ump = VFSTOUFS(mp); flags |= LK_EXCLUSIVE; - if (ffs_vgetf(mp, oldinum, flags, &vp, FFSV_FORCEINSMQ) != 0) + if (ffs_vgetf(mp, oldinum, flags, &vp, FFSV_FORCEINSMQ | + FFSV_FORCEINODEDEP) != 0) return (EBUSY); ip = VTOI(vp); MPASS(ip->i_mode != 0); @@ -14295,7 +14296,7 @@ clear_remove(mp) if (error != 0) goto finish_write; error = ffs_vgetf(mp, ino, LK_EXCLUSIVE, &vp, - FFSV_FORCEINSMQ); + FFSV_FORCEINSMQ | FFSV_FORCEINODEDEP); vfs_unbusy(mp); if (error != 0) { softdep_error("clear_remove: vget", error); @@ -14375,7 +14376,7 @@ clear_inodedeps(mp) return; } if ((error = ffs_vgetf(mp, ino, LK_EXCLUSIVE, &vp, - FFSV_FORCEINSMQ)) != 0) { + FFSV_FORCEINSMQ | FFSV_FORCEINODEDEP)) != 0) { softdep_error("clear_inodedeps: vget", error); vfs_unbusy(mp); vn_finished_write(mp); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index c8073874a85f..0e8a13b87eec 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2073,7 +2073,8 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) *vpp = NULL; return (error); } - if (DOINGSOFTDEP(vp)) + if (DOINGSOFTDEP(vp) && (!fs->fs_ronly || + (ffs_flags & FFSV_FORCEINODEDEP) != 0)) softdep_load_inodeblock(ip); else ip->i_effnlink = ip->i_nlink; From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A2CA5669E41; Sat, 14 Aug 2021 10:22: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 4GmxLk3GTxz3LQy; Sat, 14 Aug 2021 10:22: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 57C7E205D9; Sat, 14 Aug 2021 10:22: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 17EAMMGN029658; Sat, 14 Aug 2021 10:22:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMMSe029657; Sat, 14 Aug 2021 10:22:22 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:22 GMT Message-Id: <202108141022.17EAMMSe029657@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: 8475c8db9962 - stable/13 - ffs_extern.h: Add comments for ffs_vgetf() flags 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: 8475c8db9962fc0facb5b6e14d293010b55fb9b2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:22 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8475c8db9962fc0facb5b6e14d293010b55fb9b2 commit 8475c8db9962fc0facb5b6e14d293010b55fb9b2 Author: Konstantin Belousov AuthorDate: 2021-03-11 07:02:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 ffs_extern.h: Add comments for ffs_vgetf() flags (cherry picked from commit a285d3edacf602e555a918119d787d94f342fe90) --- sys/ufs/ffs/ffs_extern.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index c0ceeee09e89..2ea828861b42 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -124,10 +124,12 @@ int ffs_breadz(struct ufsmount *, struct vnode *, daddr_t, daddr_t, int, /* * Flags to ffs_vgetf */ -#define FFSV_FORCEINSMQ 0x0001 -#define FFSV_REPLACE 0x0002 -#define FFSV_REPLACE_DOOMED 0x0004 -#define FFSV_FORCEINODEDEP 0x0008 +#define FFSV_FORCEINSMQ 0x0001 /* Force insertion into mount list */ +#define FFSV_REPLACE 0x0002 /* Replace existing vnode */ +#define FFSV_REPLACE_DOOMED 0x0004 /* Replace existing vnode if it is + doomed */ +#define FFSV_FORCEINODEDEP 0x0008 /* Force allocation of inodedep, ignore + MNT_SOFTDEP */ /* * Flags to ffs_reload From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1F35B66A11D; Sat, 14 Aug 2021 10:22: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 4GmxLm5cP4z3LTB; Sat, 14 Aug 2021 10:22: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 9BA9A20568; Sat, 14 Aug 2021 10:22: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 17EAMOOb029706; Sat, 14 Aug 2021 10:22:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMOuM029705; Sat, 14 Aug 2021 10:22:24 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:24 GMT Message-Id: <202108141022.17EAMOuM029705@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: 41a1ede01c1c - stable/13 - Rework MOUNTED/DOING SOFTDEP/SUJ macros 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: 41a1ede01c1ca519c7b1ca5c8b209cfd8bd4acec Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:25 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=41a1ede01c1ca519c7b1ca5c8b209cfd8bd4acec commit 41a1ede01c1ca519c7b1ca5c8b209cfd8bd4acec Author: Konstantin Belousov AuthorDate: 2021-03-03 17:43:17 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 Rework MOUNTED/DOING SOFTDEP/SUJ macros (cherry picked from commit 7f682bdcabdaf95ded6a69994344ddbc84fd36db) --- sys/ufs/ffs/ffs_softdep.c | 1 - sys/ufs/ufs/inode.h | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 4f69dc853e4b..a110f8b58701 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -3021,7 +3021,6 @@ journal_mount(mp, fs, cred) MNT_ILOCK(mp); mp->mnt_flag |= MNT_SUJ; - mp->mnt_flag &= ~MNT_SOFTDEP; MNT_IUNLOCK(mp); /* diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 4515dcbed401..2ff619b4eac0 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -261,11 +261,11 @@ struct indir { #define ITOV(ip) ((ip)->i_vnode) /* Determine if soft dependencies are being done */ -#define DOINGSOFTDEP(vp) \ - (((vp)->v_mount->mnt_flag & (MNT_SOFTDEP | MNT_SUJ)) != 0) -#define MOUNTEDSOFTDEP(mp) (((mp)->mnt_flag & (MNT_SOFTDEP | MNT_SUJ)) != 0) -#define DOINGSUJ(vp) (((vp)->v_mount->mnt_flag & MNT_SUJ) != 0) -#define MOUNTEDSUJ(mp) (((mp)->mnt_flag & MNT_SUJ) != 0) +#define MOUNTEDSOFTDEP(mp) (((mp)->mnt_flag & MNT_SOFTDEP) != 0) +#define DOINGSOFTDEP(vp) MOUNTEDSOFTDEP((vp)->v_mount) +#define MOUNTEDSUJ(mp) (((mp)->mnt_flag & (MNT_SOFTDEP | MNT_SUJ)) == \ + (MNT_SOFTDEP | MNT_SUJ)) +#define DOINGSUJ(vp) MOUNTEDSUJ((vp)->v_mount) /* This overlays the fid structure (see mount.h). */ struct ufid { From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF73666A180; Sat, 14 Aug 2021 10:22: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 4GmxLl4m1Nz3LbH; Sat, 14 Aug 2021 10:22: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 827C620374; Sat, 14 Aug 2021 10:22: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 17EAMNrx029682; Sat, 14 Aug 2021 10:22:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMNGP029681; Sat, 14 Aug 2021 10:22:23 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:23 GMT Message-Id: <202108141022.17EAMNGP029681@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: 12eeb8eed34f - stable/13 - ffs softdep: clear ump->um_softdep on softdep_unmount() 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: 12eeb8eed34fbd8321ee0c525305c8cb13978f63 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:23 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=12eeb8eed34fbd8321ee0c525305c8cb13978f63 commit 12eeb8eed34fbd8321ee0c525305c8cb13978f63 Author: Konstantin Belousov AuthorDate: 2021-03-03 17:42:24 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 ffs softdep: clear ump->um_softdep on softdep_unmount() (cherry picked from commit 81cdb19e04e57a934e8a5dd76e5c7e0afcba1acb) --- sys/ufs/ffs/ffs_softdep.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 37db84f06fd0..4f69dc853e4b 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -2773,13 +2773,11 @@ softdep_unmount(mp) struct mount *mp; { struct ufsmount *ump; -#ifdef INVARIANTS - int i; -#endif + struct mount_softdeps *ums; - KASSERT(MOUNTEDSOFTDEP(mp) != 0, - ("softdep_unmount called on non-softdep filesystem")); ump = VFSTOUFS(mp); + KASSERT(ump->um_softdep != NULL, + ("softdep_unmount called on non-softdep filesystem")); MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_SOFTDEP; if (MOUNTEDSUJ(mp) == 0) { @@ -2802,30 +2800,37 @@ softdep_unmount(mp) KASSERT((ump->softdep_flags & FLUSH_EXIT) == 0, ("Thread shutdown failed")); } + /* - * Free up our resources. + * We are no longer have softdep structure attached to ump. */ + ums = ump->um_softdep; ACQUIRE_GBLLOCK(&lk); - TAILQ_REMOVE(&softdepmounts, ump->um_softdep, sd_next); + TAILQ_REMOVE(&softdepmounts, ums, sd_next); FREE_GBLLOCK(&lk); - rw_destroy(LOCK_PTR(ump)); - hashdestroy(ump->pagedep_hashtbl, M_PAGEDEP, ump->pagedep_hash_size); - hashdestroy(ump->inodedep_hashtbl, M_INODEDEP, ump->inodedep_hash_size); - hashdestroy(ump->newblk_hashtbl, M_NEWBLK, ump->newblk_hash_size); - hashdestroy(ump->bmsafemap_hashtbl, M_BMSAFEMAP, - ump->bmsafemap_hash_size); - free(ump->indir_hashtbl, M_FREEWORK); + ump->um_softdep = NULL; + + /* + * Free up our resources. + */ + rw_destroy(&ums->sd_fslock); + hashdestroy(ums->sd_pdhash, M_PAGEDEP, ums->sd_pdhashsize); + hashdestroy(ums->sd_idhash, M_INODEDEP, ums->sd_idhashsize); + hashdestroy(ums->sd_newblkhash, M_NEWBLK, ums->sd_newblkhashsize); + hashdestroy(ums->sd_bmhash, M_BMSAFEMAP, ums->sd_bmhashsize); + free(ums->sd_indirhash, M_FREEWORK); #ifdef INVARIANTS - for (i = 0; i <= D_LAST; i++) { - KASSERT(ump->softdep_curdeps[i] == 0, + for (int i = 0; i <= D_LAST; i++) { + KASSERT(ums->sd_curdeps[i] == 0, ("Unmount %s: Dep type %s != 0 (%ld)", ump->um_fs->fs_fsmnt, - TYPENAME(i), ump->softdep_curdeps[i])); - KASSERT(LIST_EMPTY(&ump->softdep_alldeps[i]), - ("Unmount %s: Dep type %s not empty (%p)", ump->um_fs->fs_fsmnt, - TYPENAME(i), LIST_FIRST(&ump->softdep_alldeps[i]))); + TYPENAME(i), ums->sd_curdeps[i])); + KASSERT(LIST_EMPTY(&ums->sd_alldeps[i]), + ("Unmount %s: Dep type %s not empty (%p)", + ump->um_fs->fs_fsmnt, + TYPENAME(i), LIST_FIRST(&ums->sd_alldeps[i]))); } #endif - free(ump->um_softdep, M_MOUNTDATA); + free(ums, M_MOUNTDATA); } static struct jblocks * From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54F1D669E47; Sat, 14 Aug 2021 10:22: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 4GmxLn6Ln2z3LWL; Sat, 14 Aug 2021 10:22: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 BFFB620654; Sat, 14 Aug 2021 10:22: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 17EAMPKg029737; Sat, 14 Aug 2021 10:22:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMPlZ029736; Sat, 14 Aug 2021 10:22:25 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:25 GMT Message-Id: <202108141022.17EAMPlZ029736@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: a71498a29844 - stable/13 - ffs: clear MNT_SOFTDEP earlier when remounting rw to ro 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: a71498a29844e2cf055bdb7b1daad12ffe0c1fc0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:26 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a71498a29844e2cf055bdb7b1daad12ffe0c1fc0 commit a71498a29844e2cf055bdb7b1daad12ffe0c1fc0 Author: Konstantin Belousov AuthorDate: 2021-02-28 18:55:35 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 ffs: clear MNT_SOFTDEP earlier when remounting rw to ro (cherry picked from commit 7c7a6681fab2c0453085d30424f479c0f766904d) --- sys/ufs/ffs/ffs_softdep.c | 21 ++++++++++++--------- sys/ufs/ffs/ffs_vfsops.c | 28 +++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index a110f8b58701..3fd5476df17d 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1791,10 +1791,10 @@ softdep_process_worklist(mp, full) long starttime; KASSERT(mp != NULL, ("softdep_process_worklist: NULL mp")); - if (MOUNTEDSOFTDEP(mp) == 0) + ump = VFSTOUFS(mp); + if (ump->um_softdep == NULL) return (0); matchcnt = 0; - ump = VFSTOUFS(mp); ACQUIRE_LOCK(ump); starttime = time_second; softdep_process_journal(mp, NULL, full ? MNT_WAIT : 0); @@ -2133,6 +2133,8 @@ softdep_waitidle(struct mount *mp, int flags __unused) int error, i; ump = VFSTOUFS(mp); + KASSERT(ump->um_softdep != NULL, + ("softdep_waitidle called on non-softdep filesystem")); devvp = ump->um_devvp; td = curthread; error = 0; @@ -2170,14 +2172,15 @@ softdep_flushfiles(oldmnt, flags, td) int flags; struct thread *td; { -#ifdef QUOTA struct ufsmount *ump; +#ifdef QUOTA int i; #endif int error, early, depcount, loopcnt, retry_flush_count, retry; int morework; - KASSERT(MOUNTEDSOFTDEP(oldmnt) != 0, + ump = VFSTOUFS(oldmnt); + KASSERT(ump->um_softdep != NULL, ("softdep_flushfiles called on non-softdep filesystem")); loopcnt = 10; retry_flush_count = 3; @@ -2221,7 +2224,6 @@ retry_flush: MNT_ILOCK(oldmnt); morework = oldmnt->mnt_nvnodelistsize > 0; #ifdef QUOTA - ump = VFSTOUFS(oldmnt); UFS_LOCK(ump); for (i = 0; i < MAXQUOTAS; i++) { if (ump->um_quotas[i] != NULLVP) @@ -2780,7 +2782,7 @@ softdep_unmount(mp) ("softdep_unmount called on non-softdep filesystem")); MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_SOFTDEP; - if (MOUNTEDSUJ(mp) == 0) { + if ((mp->mnt_flag & MNT_SUJ) == 0) { MNT_IUNLOCK(mp); } else { mp->mnt_flag &= ~MNT_SUJ; @@ -3730,12 +3732,12 @@ softdep_process_journal(mp, needwk, flags) int off; int devbsize; - if (MOUNTEDSUJ(mp) == 0) + ump = VFSTOUFS(mp); + if (ump->um_softdep == NULL || ump->um_softdep->sd_jblocks == NULL) return; shouldflush = softdep_flushcache; bio = NULL; jseg = NULL; - ump = VFSTOUFS(mp); LOCK_OWNED(ump); fs = ump->um_fs; jblocks = ump->softdep_jblocks; @@ -14227,7 +14229,8 @@ check_clear_deps(mp) * causes deferred work to be done sooner. */ ump = VFSTOUFS(mp); - suj_susp = MOUNTEDSUJ(mp) && ump->softdep_jblocks->jb_suspended; + suj_susp = ump->um_softdep->sd_jblocks != NULL && + ump->softdep_jblocks->jb_suspended; if (req_clear_remove || req_clear_inodedeps || suj_susp) { FREE_LOCK(ump); softdep_send_speedup(ump, 0, BIO_SPEEDUP_TRIM | BIO_SPEEDUP_WRITE); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 0e8a13b87eec..28b8175a42dd 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -380,6 +380,7 @@ ffs_mount(struct mount *mp) accmode_t accmode; struct nameidata ndp; char *fspec; + bool mounted_softdep; td = curthread; if (vfs_filteropt(mp->mnt_optnew, ffs_opts)) @@ -491,6 +492,16 @@ ffs_mount(struct mount *mp) error = vfs_write_suspend_umnt(mp); if (error != 0) return (error); + + fs->fs_ronly = 1; + if (MOUNTEDSOFTDEP(mp)) { + MNT_ILOCK(mp); + mp->mnt_flag &= ~MNT_SOFTDEP; + MNT_IUNLOCK(mp); + mounted_softdep = true; + } else + mounted_softdep = false; + /* * Check for and optionally get rid of files open * for writing. @@ -498,15 +509,22 @@ ffs_mount(struct mount *mp) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - if (MOUNTEDSOFTDEP(mp)) { + if (mounted_softdep) { error = softdep_flushfiles(mp, flags, td); } else { error = ffs_flushfiles(mp, flags, td); } if (error) { + fs->fs_ronly = 0; + if (mounted_softdep) { + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_SOFTDEP; + MNT_IUNLOCK(mp); + } vfs_write_resume(mp, 0); return (error); } + if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) { printf("WARNING: %s Update error: blocks %jd " @@ -521,10 +539,15 @@ ffs_mount(struct mount *mp) if ((error = ffs_sbupdate(ump, MNT_WAIT, 0)) != 0) { fs->fs_ronly = 0; fs->fs_clean = 0; + if (mounted_softdep) { + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_SOFTDEP; + MNT_IUNLOCK(mp); + } vfs_write_resume(mp, 0); return (error); } - if (MOUNTEDSOFTDEP(mp)) + if (mounted_softdep) softdep_unmount(mp); g_topology_lock(); /* @@ -532,7 +555,6 @@ ffs_mount(struct mount *mp) */ g_access(ump->um_cp, 0, -1, -1); g_topology_unlock(); - fs->fs_ronly = 1; MNT_ILOCK(mp); mp->mnt_flag |= MNT_RDONLY; MNT_IUNLOCK(mp); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5F511669E4C; Sat, 14 Aug 2021 10:22: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 4GmxLq10qVz3LnJ; Sat, 14 Aug 2021 10:22: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 E1CD0206CC; Sat, 14 Aug 2021 10:22: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 17EAMQ4e029761; Sat, 14 Aug 2021 10:22:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMQZj029760; Sat, 14 Aug 2021 10:22:26 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:26 GMT Message-Id: <202108141022.17EAMQZj029760@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: a326a8f616e9 - stable/13 - softdep_flush(): do not access ump after we acked FLUSH_EXIT and unlocked SU lock 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: a326a8f616e9fc0b7ec4024e555261485fc1b1e1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:27 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a326a8f616e9fc0b7ec4024e555261485fc1b1e1 commit a326a8f616e9fc0b7ec4024e555261485fc1b1e1 Author: Konstantin Belousov AuthorDate: 2021-02-28 22:45:04 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 softdep_flush(): do not access ump after we acked FLUSH_EXIT and unlocked SU lock (cherry picked from commit fabbc3d879cce5c37df25707107a0fcb64267346) --- sys/ufs/ffs/ffs_softdep.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 3fd5476df17d..fbb5c0cbc727 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1568,6 +1568,7 @@ softdep_flush(addr) struct mount *mp; struct thread *td; struct ufsmount *ump; + int cleanups; td = curthread; td->td_pflags |= TDP_NORUNNINGBUF; @@ -1602,10 +1603,14 @@ softdep_flush(addr) continue; } ump->softdep_flags &= ~FLUSH_EXIT; + cleanups = ump->um_softdep->sd_cleanups; FREE_LOCK(ump); wakeup(&ump->softdep_flags); - if (print_threads) - printf("Stop thread %s: searchfailed %d, did cleanups %d\n", td->td_name, searchfailed, ump->um_softdep->sd_cleanups); + if (print_threads) { + printf("Stop thread %s: searchfailed %d, " + "did cleanups %d\n", + td->td_name, searchfailed, cleanups); + } atomic_subtract_int(&stat_flush_threads, 1); kthread_exit(); panic("kthread_exit failed\n"); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 635E566A194; Sat, 14 Aug 2021 10:22: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 4GmxLr1YlMz3LWb; Sat, 14 Aug 2021 10:22: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 1A02320656; Sat, 14 Aug 2021 10:22: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 17EAMRYA029785; Sat, 14 Aug 2021 10:22:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMRX6029784; Sat, 14 Aug 2021 10:22:27 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:27 GMT Message-Id: <202108141022.17EAMRX6029784@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: f59d0c7c58f1 - stable/13 - softdep_unmount: handle spurious wakeups 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: f59d0c7c58f1b0ee32675be915dfc9eac7d0044d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:28 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f59d0c7c58f1b0ee32675be915dfc9eac7d0044d commit f59d0c7c58f1b0ee32675be915dfc9eac7d0044d Author: Konstantin Belousov AuthorDate: 2021-02-28 22:46:21 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 softdep_unmount: handle spurious wakeups (cherry picked from commit d7e5e374167fe98e998b80691824750f44bb050d) --- sys/ufs/ffs/ffs_softdep.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index fbb5c0cbc727..c904336af2e4 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -2802,10 +2802,13 @@ softdep_unmount(mp) ACQUIRE_LOCK(ump); ump->softdep_flags |= FLUSH_EXIT; wakeup(&ump->softdep_flushtd); - msleep(&ump->softdep_flags, LOCK_PTR(ump), PVM | PDROP, - "sdwait", 0); + while ((ump->softdep_flags & FLUSH_EXIT) != 0) { + msleep(&ump->softdep_flags, LOCK_PTR(ump), PVM, + "sdwait", 0); + } KASSERT((ump->softdep_flags & FLUSH_EXIT) == 0, ("Thread shutdown failed")); + FREE_LOCK(ump); } /* From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE23466A0A7; Sat, 14 Aug 2021 10:22: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 4GmxLt3yHlz3LZ4; Sat, 14 Aug 2021 10:22: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 5847C20658; Sat, 14 Aug 2021 10:22: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 17EAMUPX029833; Sat, 14 Aug 2021 10:22:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMUDW029832; Sat, 14 Aug 2021 10:22:30 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:30 GMT Message-Id: <202108141022.17EAMUDW029832@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: f14006ee899f - stable/13 - Assert that um_softdep is NULL on free(ump), i.e. softdep_unmount() was called 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: f14006ee899f3bc44056d98f4fc915b8976c2302 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:31 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f14006ee899f3bc44056d98f4fc915b8976c2302 commit f14006ee899f3bc44056d98f4fc915b8976c2302 Author: Konstantin Belousov AuthorDate: 2021-03-03 19:40:34 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 Assert that um_softdep is NULL on free(ump), i.e. softdep_unmount() was called (cherry picked from commit 2af934cc15bd8e7daa2daeb806321d0daddf3b7a) --- sys/ufs/ffs/ffs_vfsops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index d321e98e8347..85c7929550fb 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1355,6 +1355,7 @@ out: free(mp->mnt_gjprovider, M_UFSMNT); mp->mnt_gjprovider = NULL; } + MPASS(ump->um_softdep == NULL); free(ump, M_UFSMNT); mp->mnt_data = NULL; } @@ -1537,6 +1538,7 @@ ffs_unmount(mp, mntflags) UFS_UNLOCK(ump); if (MOUNTEDSOFTDEP(mp)) softdep_unmount(mp); + MPASS(ump->um_softdep == NULL); if (fs->fs_ronly == 0 || ump->um_fsckpid > 0) { fs->fs_clean = fs->fs_flags & (FS_UNCLEAN|FS_NEEDSFSCK) ? 0 : 1; error = ffs_sbupdate(ump, MNT_WAIT, 0); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B761466A0A9; Sat, 14 Aug 2021 10:22: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 4GmxLv6XwJz3Lt5; Sat, 14 Aug 2021 10:22: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 7E2372056C; Sat, 14 Aug 2021 10:22: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 17EAMVb7029865; Sat, 14 Aug 2021 10:22:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMVlm029864; Sat, 14 Aug 2021 10:22:31 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:31 GMT Message-Id: <202108141022.17EAMVlm029864@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: 22d33453e141 - stable/13 - FFS: assign fully initialized struct mount_softdeps to um_softdep 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: 22d33453e14119e898cbf4de3aee93533451e2ae Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:32 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=22d33453e14119e898cbf4de3aee93533451e2ae commit 22d33453e14119e898cbf4de3aee93533451e2ae Author: Konstantin Belousov AuthorDate: 2021-03-03 22:02:30 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:59 +0000 FFS: assign fully initialized struct mount_softdeps to um_softdep (cherry picked from commit 7a8d4b4da69af966bff4892acb2fd101a95a4848) --- sys/ufs/ffs/ffs_softdep.c | 68 ++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index c904336af2e4..54f7d0d559fc 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -2678,48 +2678,50 @@ softdep_mount(devvp, mp, fs, cred) u_int cyl, i; int error; + ump = VFSTOUFS(mp); + sdp = malloc(sizeof(struct mount_softdeps), M_MOUNTDATA, M_WAITOK | M_ZERO); - MNT_ILOCK(mp); - mp->mnt_flag = (mp->mnt_flag & ~MNT_ASYNC) | MNT_SOFTDEP; - if ((mp->mnt_kern_flag & MNTK_SOFTDEP) == 0) { - mp->mnt_kern_flag = (mp->mnt_kern_flag & ~MNTK_ASYNC) | - MNTK_SOFTDEP | MNTK_NOASYNC; - } - ump = VFSTOUFS(mp); - ump->um_softdep = sdp; - MNT_IUNLOCK(mp); - rw_init(LOCK_PTR(ump), "per-fs softdep"); + rw_init(&sdp->sd_fslock, "SUrw"); sdp->sd_ump = ump; - LIST_INIT(&ump->softdep_workitem_pending); - LIST_INIT(&ump->softdep_journal_pending); - TAILQ_INIT(&ump->softdep_unlinked); - LIST_INIT(&ump->softdep_dirtycg); - ump->softdep_worklist_tail = NULL; - ump->softdep_on_worklist = 0; - ump->softdep_deps = 0; - LIST_INIT(&ump->softdep_mkdirlisthd); - ump->pagedep_hashtbl = hashinit(desiredvnodes / 5, M_PAGEDEP, - &ump->pagedep_hash_size); - ump->pagedep_nextclean = 0; - ump->inodedep_hashtbl = hashinit(desiredvnodes, M_INODEDEP, - &ump->inodedep_hash_size); - ump->inodedep_nextclean = 0; - ump->newblk_hashtbl = hashinit(max_softdeps / 2, M_NEWBLK, - &ump->newblk_hash_size); - ump->bmsafemap_hashtbl = hashinit(1024, M_BMSAFEMAP, - &ump->bmsafemap_hash_size); + LIST_INIT(&sdp->sd_workitem_pending); + LIST_INIT(&sdp->sd_journal_pending); + TAILQ_INIT(&sdp->sd_unlinked); + LIST_INIT(&sdp->sd_dirtycg); + sdp->sd_worklist_tail = NULL; + sdp->sd_on_worklist = 0; + sdp->sd_deps = 0; + LIST_INIT(&sdp->sd_mkdirlisthd); + sdp->sd_pdhash = hashinit(desiredvnodes / 5, M_PAGEDEP, + &sdp->sd_pdhashsize); + sdp->sd_pdnextclean = 0; + sdp->sd_idhash = hashinit(desiredvnodes, M_INODEDEP, + &sdp->sd_idhashsize); + sdp->sd_idnextclean = 0; + sdp->sd_newblkhash = hashinit(max_softdeps / 2, M_NEWBLK, + &sdp->sd_newblkhashsize); + sdp->sd_bmhash = hashinit(1024, M_BMSAFEMAP, &sdp->sd_bmhashsize); i = 1 << (ffs(desiredvnodes / 10) - 1); - ump->indir_hashtbl = malloc(i * sizeof(struct indir_hashhead), + sdp->sd_indirhash = malloc(i * sizeof(struct indir_hashhead), M_FREEWORK, M_WAITOK); - ump->indir_hash_size = i - 1; - for (i = 0; i <= ump->indir_hash_size; i++) - TAILQ_INIT(&ump->indir_hashtbl[i]); + sdp->sd_indirhashsize = i - 1; + for (i = 0; i <= sdp->sd_indirhashsize; i++) + TAILQ_INIT(&sdp->sd_indirhash[i]); for (i = 0; i <= D_LAST; i++) - LIST_INIT(&ump->softdep_alldeps[i]); + LIST_INIT(&sdp->sd_alldeps[i]); ACQUIRE_GBLLOCK(&lk); TAILQ_INSERT_TAIL(&softdepmounts, sdp, sd_next); FREE_GBLLOCK(&lk); + + ump->um_softdep = sdp; + MNT_ILOCK(mp); + mp->mnt_flag = (mp->mnt_flag & ~MNT_ASYNC) | MNT_SOFTDEP; + if ((mp->mnt_kern_flag & MNTK_SOFTDEP) == 0) { + mp->mnt_kern_flag = (mp->mnt_kern_flag & ~MNTK_ASYNC) | + MNTK_SOFTDEP | MNTK_NOASYNC; + } + MNT_IUNLOCK(mp); + if ((fs->fs_flags & FS_SUJ) && (error = journal_mount(mp, fs, cred)) != 0) { printf("Failed to start journal: %d\n", error); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2EC0566A12D; Sat, 14 Aug 2021 10:22: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 4GmxLw6Kpcz3LWq; Sat, 14 Aug 2021 10:22: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 A0E71206D0; Sat, 14 Aug 2021 10:22: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 17EAMWMs029889; Sat, 14 Aug 2021 10:22:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMWsQ029888; Sat, 14 Aug 2021 10:22:32 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:32 GMT Message-Id: <202108141022.17EAMWsQ029888@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: 494aba874922 - stable/13 - softdep_unmount: assert that no dandling dependencies are left 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: 494aba874922e7a0367548e264306f89a268c407 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:33 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=494aba874922e7a0367548e264306f89a268c407 commit 494aba874922e7a0367548e264306f89a268c407 Author: Konstantin Belousov AuthorDate: 2021-03-06 09:52:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:59 +0000 softdep_unmount: assert that no dandling dependencies are left (cherry picked from commit 0b3948e73b749b0fefc3f9d4fc61f356542bb9b9) --- sys/ufs/ffs/ffs_softdep.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 54f7d0d559fc..27d1cc8b0537 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -2822,6 +2822,13 @@ softdep_unmount(mp) FREE_GBLLOCK(&lk); ump->um_softdep = NULL; + KASSERT(ums->sd_on_journal == 0, + ("ump %p ums %p on_journal %d", ump, ums, ums->sd_on_journal)); + KASSERT(ums->sd_on_worklist == 0, + ("ump %p ums %p on_worklist %d", ump, ums, ums->sd_on_worklist)); + KASSERT(ums->sd_deps == 0, + ("ump %p ums %p deps %d", ump, ums, ums->sd_deps)); + /* * Free up our resources. */ From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C3EDB66A21D; Sat, 14 Aug 2021 10:22: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 4GmxLy1hy1z3Lny; Sat, 14 Aug 2021 10:22: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 C28E4208EB; Sat, 14 Aug 2021 10:22: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 17EAMXR9029913; Sat, 14 Aug 2021 10:22:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMXrX029912; Sat, 14 Aug 2021 10:22:33 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:33 GMT Message-Id: <202108141022.17EAMXrX029912@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: a14a142c6e32 - stable/13 - vlrureclaim: only skip vnode with resident pages if it own the pages 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: a14a142c6e32926b2d751356fb1f5ea4f3ddfa0c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:35 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a14a142c6e32926b2d751356fb1f5ea4f3ddfa0c commit a14a142c6e32926b2d751356fb1f5ea4f3ddfa0c Author: Konstantin Belousov AuthorDate: 2021-03-06 21:09:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:59 +0000 vlrureclaim: only skip vnode with resident pages if it own the pages (cherry picked from commit 44691b33cc99d0e17262368b6e0f64e531994a23) --- sys/kern/vfs_subr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index bd4413edcb40..d67936447216 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1169,7 +1169,7 @@ restart: VI_LOCK(vp); if (vp->v_usecount > 0 || (!reclaim_nc_src && !LIST_EMPTY(&vp->v_cache_src)) || - (vp->v_object != NULL && + (vp->v_object != NULL && vp->v_object->handle == vp && vp->v_object->resident_page_count > trigger)) { VOP_UNLOCK(vp); vdropl(vp); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6565E669E64; Sat, 14 Aug 2021 10:22: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 4GmxLz1K3mz3LX0; Sat, 14 Aug 2021 10:22: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 EDF332056E; Sat, 14 Aug 2021 10:22: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 17EAMYqx029937; Sat, 14 Aug 2021 10:22:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EAMY67029936; Sat, 14 Aug 2021 10:22:34 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:34 GMT Message-Id: <202108141022.17EAMY67029936@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: 94cb19f46114 - stable/13 - null_vput_pair(): release use reference on dvp earlier 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: 94cb19f46114950586fc363b518550c171849291 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:35 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=94cb19f46114950586fc363b518550c171849291 commit 94cb19f46114950586fc363b518550c171849291 Author: Konstantin Belousov AuthorDate: 2021-03-07 21:08:38 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:59 +0000 null_vput_pair(): release use reference on dvp earlier (cherry picked from commit 16dea8341024b8ee8be619c27d4e63bd81bd9b6c) --- sys/fs/nullfs/null_vnops.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 6a6df55a0bef..e3a320a22bfa 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -1084,33 +1084,50 @@ null_vput_pair(struct vop_vput_pair_args *ap) vpp = ap->a_vpp; vp = NULL; lvp = NULL; - if (vpp != NULL) { + mp = NULL; + if (vpp != NULL) vp = *vpp; - if (vp != NULL) { + if (vp != NULL) { + lvp = NULLVPTOLOWERVP(vp); + vref(lvp); + if (!ap->a_unlock_vp) { vhold(vp); + vhold(lvp); mp = vp->v_mount; - lvp = NULLVPTOLOWERVP(vp); - if (ap->a_unlock_vp) - vref(lvp); + vfs_ref(mp); } } - res = VOP_VPUT_PAIR(ldvp, &lvp, ap->a_unlock_vp); + res = VOP_VPUT_PAIR(ldvp, lvp != NULL ? &lvp : NULL, true); + if (vp != NULL && ap->a_unlock_vp) + vrele(vp); + vrele(dvp); - /* lvp might have been unlocked and vp reclaimed */ - if (vp != NULL) { - if (!ap->a_unlock_vp && vp->v_vnlock != lvp->v_vnlock) { + if (vp == NULL || ap->a_unlock_vp) + return (res); + + /* lvp has been unlocked and vp might be reclaimed */ + VOP_LOCK(vp, LK_EXCLUSIVE | LK_RETRY); + if (vp->v_data == NULL && vfs_busy(mp, MBF_NOWAIT) == 0) { + vput(vp); + vget(lvp, LK_EXCLUSIVE | LK_RETRY); + if (VN_IS_DOOMED(lvp)) { + vput(lvp); + vget(vp, LK_EXCLUSIVE | LK_RETRY); + } else { error = null_nodeget(mp, lvp, &vp1); if (error == 0) { - vput(vp); *vpp = vp1; + } else { + vget(vp, LK_EXCLUSIVE | LK_RETRY); } } - if (ap->a_unlock_vp) - vrele(vp); - vdrop(vp); + vfs_unbusy(mp); } - vrele(dvp); + vdrop(lvp); + vdrop(vp); + vfs_rel(mp); + return (res); } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 10:22:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9B7E9669E53; Sat, 14 Aug 2021 10: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 4GmxLs2wCKz3Lql; Sat, 14 Aug 2021 10: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 36253206CD; Sat, 14 Aug 2021 10: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 17EAMTAQ029809; Sat, 14 Aug 2021 10: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 17EAMTOq029808; Sat, 14 Aug 2021 10:22:29 GMT (envelope-from git) Date: Sat, 14 Aug 2021 10:22:29 GMT Message-Id: <202108141022.17EAMTOq029808@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: 1b957df8f8f2 - stable/13 - ffs_mount: when remounting ro->rw and sbupdate failed, cleanup softdeps 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: 1b957df8f8f2a24fdbc95690d9c1f615194bcc64 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:22:29 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1b957df8f8f2a24fdbc95690d9c1f615194bcc64 commit 1b957df8f8f2a24fdbc95690d9c1f615194bcc64 Author: Konstantin Belousov AuthorDate: 2021-03-03 18:02:13 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 10:21:58 +0000 ffs_mount: when remounting ro->rw and sbupdate failed, cleanup softdeps (cherry picked from commit f776c54cee81b4297b59ffe87a0f154e3924ee7f) --- sys/ufs/ffs/ffs_vfsops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 28b8175a42dd..d321e98e8347 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -645,6 +645,8 @@ ffs_mount(struct mount *mp) fs->fs_clean = 0; if ((error = ffs_sbupdate(ump, MNT_WAIT, 0)) != 0) { fs->fs_ronly = 1; + if ((fs->fs_flags & FS_DOSOFTDEP) != 0) + softdep_unmount(mp); MNT_ILOCK(mp); mp->mnt_flag |= saved_mnt_flag; MNT_IUNLOCK(mp); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 11:32:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 41E3266B363; Sat, 14 Aug 2021 11:32: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 4GmyvS1JMYz3R29; Sat, 14 Aug 2021 11:32: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 158FB2153E; Sat, 14 Aug 2021 11:32: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 17EBWJX8020857; Sat, 14 Aug 2021 11:32:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EBWJB1020856; Sat, 14 Aug 2021 11:32:19 GMT (envelope-from git) Date: Sat, 14 Aug 2021 11:32:19 GMT Message-Id: <202108141132.17EBWJB1020856@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 86b74b736818 - main - Fix a common typo in a comment 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/main X-Git-Reftype: branch X-Git-Commit: 86b74b736818a0b025ef520f8a4f570f48741666 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 11:32:20 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=86b74b736818a0b025ef520f8a4f570f48741666 commit 86b74b736818a0b025ef520f8a4f570f48741666 Author: Gordon Bergling AuthorDate: 2021-08-14 11:29:51 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 11:31:51 +0000 Fix a common typo in a comment - s/enrty/entry/ MFC after: 5 days --- sys/dev/bxe/bxe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index a8aa0a89aae1..9145f11e5bf1 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -17179,7 +17179,7 @@ bxe_init_hw_common(struct bxe_softc *sc) * stay set) * f. If this is VNIC 3 of a port then also init * first_timers_ilt_entry to zero and last_timers_ilt_entry - * to the last enrty in the ILT. + * to the last enrtry in the ILT. * * Notes: * Currently the PF error in the PGLC is non recoverable. From owner-dev-commits-src-all@freebsd.org Sat Aug 14 11:41:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A45EE66B52E; Sat, 14 Aug 2021 11:41: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 4Gmz5l3gK4z3RJ2; Sat, 14 Aug 2021 11:41: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 661F9213EA; Sat, 14 Aug 2021 11:41: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 17EBfFaf033513; Sat, 14 Aug 2021 11:41:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EBfFIg033512; Sat, 14 Aug 2021 11:41:15 GMT (envelope-from git) Date: Sat, 14 Aug 2021 11:41:15 GMT Message-Id: <202108141141.17EBfFIg033512@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b42df9dafb80 - main - Add test for fstatat(pipefd, AT_EMPTY_PATH) 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/main X-Git-Reftype: branch X-Git-Commit: b42df9dafb8038169e23f9225f3f1588ded8d27e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 11:41:15 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b42df9dafb8038169e23f9225f3f1588ded8d27e commit b42df9dafb8038169e23f9225f3f1588ded8d27e Author: Konstantin Belousov AuthorDate: 2021-08-14 10:33:18 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 11:41:01 +0000 Add test for fstatat(pipefd, AT_EMPTY_PATH) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- tests/sys/file/path_test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/sys/file/path_test.c b/tests/sys/file/path_test.c index e1f5240374c4..50a77f16736c 100644 --- a/tests/sys/file/path_test.c +++ b/tests/sys/file/path_test.c @@ -63,6 +63,25 @@ #define CHECKED_CLOSE(fd) \ ATF_REQUIRE_MSG(close(fd) == 0, FMT_ERR("close")) +/* + * Verify fstatat(AT_EMPTY_PATH) on non-regular dirfd. + * Verify that fstatat(AT_EMPTY_PATH) on NULL path returns EFAULT. + */ +ATF_TC_WITHOUT_HEAD(path_pipe_fstatat); +ATF_TC_BODY(path_pipe_fstatat, tc) +{ + struct stat sb; + int fd[2]; + + ATF_REQUIRE_MSG(pipe(fd) == 0, FMT_ERR("pipe")); + ATF_REQUIRE_MSG(fstatat(fd[0], "", &sb, AT_EMPTY_PATH) == 0, + FMT_ERR("fstatat pipe")); + ATF_REQUIRE_ERRNO(EFAULT, fstatat(fd[0], NULL, &sb, + AT_EMPTY_PATH) == -1); + CHECKED_CLOSE(fd[0]); + CHECKED_CLOSE(fd[1]); +} + /* Create a temporary regular file containing some data. */ static void mktfile(char path[PATH_MAX], const char *template) @@ -873,6 +892,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, path_lock); ATF_TP_ADD_TC(tp, path_rights); ATF_TP_ADD_TC(tp, path_unix); + ATF_TP_ADD_TC(tp, path_pipe_fstatat); return (atf_no_error()); } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:09:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3129D66BD28; Sat, 14 Aug 2021 12:09: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 4GmzkL0f4Jz3jDn; Sat, 14 Aug 2021 12:09: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 F281421C64; Sat, 14 Aug 2021 12:09: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 17EC9TEg065182; Sat, 14 Aug 2021 12:09:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EC9TEF065181; Sat, 14 Aug 2021 12:09:29 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:09:29 GMT Message-Id: <202108141209.17EC9TEF065181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 1da11b8ac347 - main - Fix a common typo in source code comments 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/main X-Git-Reftype: branch X-Git-Commit: 1da11b8ac3474817f38330e272f50553f2ef21a4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:09:30 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=1da11b8ac3474817f38330e272f50553f2ef21a4 commit 1da11b8ac3474817f38330e272f50553f2ef21a4 Author: Gordon Bergling AuthorDate: 2021-08-14 12:08:46 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 12:08:46 +0000 Fix a common typo in source code comments - s/definitons/definitions/ MFC after: 5 days --- sys/cam/scsi/scsi_da.c | 2 +- sys/mips/include/cpuregs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 40978d68cebf..31aeb59d9438 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -4486,7 +4486,7 @@ dazonedone(struct cam_periph *periph, union ccb *ccb) /* * NOTE: we're mapping the values here directly * from the SCSI/ATA bit definitions to the bio.h - * definitons. There is also a warning in + * definitions. There is also a warning in * disk_zone.h, but the impact is that if * additional values are added in the SCSI/ATA * specs these will be visible to consumers of diff --git a/sys/mips/include/cpuregs.h b/sys/mips/include/cpuregs.h index c61724564a59..2b5a0ce554dc 100644 --- a/sys/mips/include/cpuregs.h +++ b/sys/mips/include/cpuregs.h @@ -222,7 +222,7 @@ #define MIPS_SR_INT_MASK 0x0000ff00 /* - * R4000 status register bit definitons, + * R4000 status register bit definitions, * where different from r2000/r3000. */ #define MIPS_SR_XX 0x80000000 From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:18:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2232D66C095; Sat, 14 Aug 2021 12:18:39 +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 4Gmzwv0QHbz3jgN; Sat, 14 Aug 2021 12:18:39 +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 EA7E822184; Sat, 14 Aug 2021 12:18: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 17ECIc5H078197; Sat, 14 Aug 2021 12:18:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECIcEC078196; Sat, 14 Aug 2021 12:18:38 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:18:38 GMT Message-Id: <202108141218.17ECIcEC078196@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: a1581cd73594 - main - Fix a common typo in source code comments 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/main X-Git-Reftype: branch X-Git-Commit: a1581cd73594bbbde638859c31226c2c21be1ab3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:18:39 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a1581cd73594bbbde638859c31226c2c21be1ab3 commit a1581cd73594bbbde638859c31226c2c21be1ab3 Author: Gordon Bergling AuthorDate: 2021-08-14 12:17:48 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 12:17:48 +0000 Fix a common typo in source code comments - s/aligment/alignment/ MFC after: 5 days --- lib/libc/gen/tls.c | 4 ++-- share/man/man9/rman.9 | 4 ++-- sys/arm/allwinner/if_emac.c | 2 +- sys/dev/sound/pci/hda/hdaa.c | 2 +- sys/dev/usb/controller/uhci.c | 2 +- sys/dev/usb/usb_busdma.c | 2 +- sys/i386/i386/locore.s | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 69b87aea52bf..98915ef4ddf7 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -249,9 +249,9 @@ __libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused) * * where: * extra_size is tcbsize - TLS_TCB_SIZE - * post_size is used to adjust TCB to TLS aligment for first version of TLS + * post_size is used to adjust TCB to TLS alignment for first version of TLS * layout and is always 0 for second version. - * pre_size is used to adjust TCB aligment for first version and to adjust + * pre_size is used to adjust TCB alignment for first version and to adjust * TLS alignment for second version. * */ diff --git a/share/man/man9/rman.9 b/share/man/man9/rman.9 index 3faea2a014fc..a5a8c34cde90 100644 --- a/share/man/man9/rman.9 +++ b/share/man/man9/rman.9 @@ -275,7 +275,7 @@ The caller can specify the and .Fa end of an acceptable range, -as well as a boundary restriction and required aligment, +as well as a boundary restriction and required alignment, and the code will attempt to find a free segment which fits. The .Fa start @@ -288,7 +288,7 @@ Therefore, must be \[<=] .Fa end for any allocation to happen. -The aligment requirement +The alignment requirement .Pq if any is specified in .Fa flags . diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index 73e7e889916a..5110ce2f9fb4 100644 --- a/sys/arm/allwinner/if_emac.c +++ b/sys/arm/allwinner/if_emac.c @@ -409,7 +409,7 @@ emac_rxeof(struct emac_softc *sc, int count) m->m_len = m->m_pkthdr.len = len - ETHER_CRC_LEN; /* - * Emac controller needs strict aligment, so to avoid + * Emac controller needs strict alignment, so to avoid * copying over an entire frame to align, we allocate * a new mbuf and copy ethernet header + IP header to * the new mbuf. The new mbuf is prepended into the diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c index 621361c5fa70..82c309996d75 100644 --- a/sys/dev/sound/pci/hda/hdaa.c +++ b/sys/dev/sound/pci/hda/hdaa.c @@ -2191,7 +2191,7 @@ hdaa_channel_getptr(kobj_t obj, void *data) hdaa_unlock(devinfo); /* - * Round to available space and force 128 bytes aligment. + * Round to available space and force 128 bytes alignment. */ ptr %= ch->blksz * ch->blkcnt; ptr &= HDA_BLK_ALIGN; diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c index 41caa1610989..4c72118d9900 100644 --- a/sys/dev/usb/controller/uhci.c +++ b/sys/dev/usb/controller/uhci.c @@ -2869,7 +2869,7 @@ uhci_xfer_setup(struct usb_setup_params *parm) * We don't allow alignments of * less than 8 bytes: * - * NOTE: Allocating using an aligment + * NOTE: Allocating using an alignment * of 1 byte has special meaning! */ if (n < 3) { diff --git a/sys/dev/usb/usb_busdma.c b/sys/dev/usb/usb_busdma.c index 26fddaef65b2..4806903fa83a 100644 --- a/sys/dev/usb/usb_busdma.c +++ b/sys/dev/usb/usb_busdma.c @@ -546,7 +546,7 @@ usb_pc_alloc_mem(struct usb_page_cache *pc, struct usb_page *pg, /* * XXX BUS-DMA workaround - FIXME later: * - * We assume that that the aligment at this point of + * We assume that that the alignment at this point of * the code is greater than or equal to the size and * less than two times the size, so that if we double * the size, the size will be greater than the diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index 24c583dec554..6dffc4f97fdd 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -340,7 +340,7 @@ ENTRY(identify_cpu) testl %eax,%eax jnz try486 - /* NexGen CPU does not have aligment check flag. */ + /* NexGen CPU does not have alignment check flag. */ pushfl movl $0x5555, %eax xorl %edx, %edx From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:32:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EE25266C4DE; Sat, 14 Aug 2021 12:32: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 4Gn0FB66VCz3kdY; Sat, 14 Aug 2021 12:32: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 BA3582216D; Sat, 14 Aug 2021 12:32: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 17ECWkxH004551; Sat, 14 Aug 2021 12:32:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECWkMk004550; Sat, 14 Aug 2021 12:32:46 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:32:46 GMT Message-Id: <202108141232.17ECWkMk004550@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 646f3a36c8df - main - Fix a typo that was introduced while fixing a typo 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/main X-Git-Reftype: branch X-Git-Commit: 646f3a36c8df0e54e71332038ede594965daac6e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:32:47 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=646f3a36c8df0e54e71332038ede594965daac6e commit 646f3a36c8df0e54e71332038ede594965daac6e Author: Gordon Bergling AuthorDate: 2021-08-14 12:30:59 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 12:30:59 +0000 Fix a typo that was introduced while fixing a typo - s/enrtry/entry/ MFC after: 5 days --- sys/dev/bxe/bxe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index 9145f11e5bf1..bf6904b26b55 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -17179,7 +17179,7 @@ bxe_init_hw_common(struct bxe_softc *sc) * stay set) * f. If this is VNIC 3 of a port then also init * first_timers_ilt_entry to zero and last_timers_ilt_entry - * to the last enrtry in the ILT. + * to the last entry in the ILT. * * Notes: * Currently the PF error in the PGLC is non recoverable. From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:49:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C335866C374; Sat, 14 Aug 2021 12:49: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 4Gn0cc57s0z3lWq; Sat, 14 Aug 2021 12:49: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 98A9122554; Sat, 14 Aug 2021 12:49: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 17ECnaIh018032; Sat, 14 Aug 2021 12:49:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECna1f018031; Sat, 14 Aug 2021 12:49:36 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:49:36 GMT Message-Id: <202108141249.17ECna1f018031@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 0d71cea832f4 - main - md5(1): Fix a typo in the manual page 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/main X-Git-Reftype: branch X-Git-Commit: 0d71cea832f4b6e1db9d28d3ca393682d577b43e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:49:36 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=0d71cea832f4b6e1db9d28d3ca393682d577b43e commit 0d71cea832f4b6e1db9d28d3ca393682d577b43e Author: Gordon Bergling AuthorDate: 2021-08-14 12:48:39 +0000 Commit: Gordon Bergling CommitDate: 2021-08-14 12:48:39 +0000 md5(1): Fix a typo in the manual page - s/compatibilty/compatibility/ MFC after: 5 days --- sbin/md5/md5.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index 2b1da85c080f..ddda24196d9e 100644 --- a/sbin/md5/md5.1 +++ b/sbin/md5/md5.1 @@ -164,7 +164,7 @@ d80bf36c332dc0fdc479366ec3fa44cd /etc/rc.conf .Pd The .Nm -sum -variants put 2 blank characters between hash and file name for full compatibilty +variants put 2 blank characters between hash and file name for full compatibility with the coreutils versions of these commands. .Ed .Pp From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:57:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6225666C8CE; Sat, 14 Aug 2021 12:57: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 4Gn0ng1xPrz3lsV; Sat, 14 Aug 2021 12:57: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 2AB09224CD; Sat, 14 Aug 2021 12:57: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 17ECvRnK030846; Sat, 14 Aug 2021 12:57:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECvRie030845; Sat, 14 Aug 2021 12:57:27 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:57:27 GMT Message-Id: <202108141257.17ECvRie030845@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: ed698ef1e152 - stable/13 - Apply upstream lld fix for compressed input sections on BE targets MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ed698ef1e1523b3bd25405f5dc82bbeb44f79805 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:57:27 -0000 The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=ed698ef1e1523b3bd25405f5dc82bbeb44f79805 commit ed698ef1e1523b3bd25405f5dc82bbeb44f79805 Author: Dimitry Andric AuthorDate: 2021-08-07 11:14:11 +0000 Commit: Dimitry Andric CommitDate: 2021-08-14 12:52:55 +0000 Apply upstream lld fix for compressed input sections on BE targets Merge commit c6ebc651b6fa from llvm git (by Simon Atanasyan): [LLD] Support compressed input sections on big-endian targets This patch enables compressed input sections on big-endian targets by checking the target endianness and selecting an appropriate `Chdr` structure. Fixes PR51369 Differential Revision: https://reviews.llvm.org/D107635 Reported by: emaste (cherry picked from commit d69d07569ee2404705ff4c4abb45dc0b884eeb35) Follow-up to d69d07569ee2 by bumping lld local version This makes it easier to detect that lld's support for compressed input sections on BE targets is fixed. (cherry picked from commit cd38d9cf26db9264f709c52469f0f4e9684d62bb) --- contrib/llvm-project/lld/ELF/InputSection.cpp | 47 ++++++++++++--------------- contrib/llvm-project/lld/ELF/InputSection.h | 1 + lib/clang/include/VCSVersion.inc | 2 +- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/contrib/llvm-project/lld/ELF/InputSection.cpp b/contrib/llvm-project/lld/ELF/InputSection.cpp index 6f16fc7abc48..f9cad7f975a7 100644 --- a/contrib/llvm-project/lld/ELF/InputSection.cpp +++ b/contrib/llvm-project/lld/ELF/InputSection.cpp @@ -88,7 +88,22 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags, if (!zlib::isAvailable()) error(toString(file) + ": contains a compressed section, " + "but zlib is not available"); - parseCompressedHeader(); + switch (config->ekind) { + case ELF32LEKind: + parseCompressedHeader(); + break; + case ELF32BEKind: + parseCompressedHeader(); + break; + case ELF64LEKind: + parseCompressedHeader(); + break; + case ELF64BEKind: + parseCompressedHeader(); + break; + default: + llvm_unreachable("unknown ELFT"); + } } } @@ -210,10 +225,7 @@ OutputSection *SectionBase::getOutputSection() { // When a section is compressed, `rawData` consists with a header followed // by zlib-compressed data. This function parses a header to initialize // `uncompressedSize` member and remove the header from `rawData`. -void InputSectionBase::parseCompressedHeader() { - using Chdr64 = typename ELF64LE::Chdr; - using Chdr32 = typename ELF32LE::Chdr; - +template void InputSectionBase::parseCompressedHeader() { // Old-style header if (name.startswith(".zdebug")) { if (!toStringRef(rawData).startswith("ZLIB")) { @@ -239,32 +251,13 @@ void InputSectionBase::parseCompressedHeader() { assert(flags & SHF_COMPRESSED); flags &= ~(uint64_t)SHF_COMPRESSED; - // New-style 64-bit header - if (config->is64) { - if (rawData.size() < sizeof(Chdr64)) { - error(toString(this) + ": corrupted compressed section"); - return; - } - - auto *hdr = reinterpret_cast(rawData.data()); - if (hdr->ch_type != ELFCOMPRESS_ZLIB) { - error(toString(this) + ": unsupported compression type"); - return; - } - - uncompressedSize = hdr->ch_size; - alignment = std::max(hdr->ch_addralign, 1); - rawData = rawData.slice(sizeof(*hdr)); - return; - } - - // New-style 32-bit header - if (rawData.size() < sizeof(Chdr32)) { + // New-style header + if (rawData.size() < sizeof(typename ELFT::Chdr)) { error(toString(this) + ": corrupted compressed section"); return; } - auto *hdr = reinterpret_cast(rawData.data()); + auto *hdr = reinterpret_cast(rawData.data()); if (hdr->ch_type != ELFCOMPRESS_ZLIB) { error(toString(this) + ": unsupported compression type"); return; diff --git a/contrib/llvm-project/lld/ELF/InputSection.h b/contrib/llvm-project/lld/ELF/InputSection.h index 5b91c1c90bd2..c914d0b42155 100644 --- a/contrib/llvm-project/lld/ELF/InputSection.h +++ b/contrib/llvm-project/lld/ELF/InputSection.h @@ -238,6 +238,7 @@ public: } protected: + template void parseCompressedHeader(); void uncompress() const; diff --git a/lib/clang/include/VCSVersion.inc b/lib/clang/include/VCSVersion.inc index cb7736e7d7de..8c1798de59ee 100644 --- a/lib/clang/include/VCSVersion.inc +++ b/lib/clang/include/VCSVersion.inc @@ -7,7 +7,7 @@ #define CLANG_REPOSITORY "git@github.com:llvm/llvm-project.git" // - -#define LLD_REVISION "llvmorg-12.0.1-0-gfed41342a82f-1400001" +#define LLD_REVISION "llvmorg-12.0.1-0-gfed41342a82f-1400002" #define LLD_REPOSITORY "FreeBSD" #define LLDB_REVISION "llvmorg-12.0.1-0-gfed41342a82f" From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:58:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78D2A66CA71; Sat, 14 Aug 2021 12:58: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 4Gn0pV2slMz3m5r; Sat, 14 Aug 2021 12:58: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 4AC4522982; Sat, 14 Aug 2021 12:58: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 17ECwAT9031080; Sat, 14 Aug 2021 12:58:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECwAIJ031079; Sat, 14 Aug 2021 12:58:10 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:58:10 GMT Message-Id: <202108141258.17ECwAIJ031079@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 908e277230ef - main - x86: cpufunc: Add rdtscp_aux() 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/main X-Git-Reftype: branch X-Git-Commit: 908e277230ef1a80589f85687f5b422b0e863e79 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:58:10 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=908e277230ef1a80589f85687f5b422b0e863e79 commit 908e277230ef1a80589f85687f5b422b0e863e79 Author: Adam Fenn AuthorDate: 2021-07-26 19:59:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 12:57:53 +0000 x86: cpufunc: Add rdtscp_aux() Add a variant of 'rdtscp()' that retains and returns the 'IA32_TSC_AUX' value read by 'rdtscp'. Sponsored By: Juniper Networks, Inc. Sponsored By: Klara, Inc. Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D31415 --- sys/amd64/include/cpufunc.h | 9 +++++++++ sys/i386/include/cpufunc.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 8ef298e1d7d5..49975e826fb9 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -364,6 +364,15 @@ rdtscp(void) return (low | ((uint64_t)high << 32)); } +static __inline uint64_t +rdtscp_aux(uint32_t *aux) +{ + uint32_t low, high; + + __asm __volatile("rdtscp" : "=a" (low), "=d" (high), "=c" (*aux)); + return (low | ((uint64_t)high << 32)); +} + static __inline uint32_t rdtsc32(void) { diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index 9646590a6a40..7b99978facc3 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -403,6 +403,15 @@ rdtscp(void) return (rv); } +static __inline uint64_t +rdtscp_aux(uint32_t *aux) +{ + uint64_t rv; + + __asm __volatile("rdtscp" : "=A" (rv), "=c" (*aux)); + return (rv); +} + static __inline uint32_t rdtsc32(void) { From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:58:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F180666CA9E; Sat, 14 Aug 2021 12:58: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 4Gn0pW3tzhz3lk8; Sat, 14 Aug 2021 12:58: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 6D48B22983; Sat, 14 Aug 2021 12:58: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 17ECwBFM031111; Sat, 14 Aug 2021 12:58:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECwBK7031110; Sat, 14 Aug 2021 12:58:11 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:58:11 GMT Message-Id: <202108141258.17ECwBK7031110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 652ae7b11485 - main - x86: cpufunc: Add rdtsc_ordered() 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/main X-Git-Reftype: branch X-Git-Commit: 652ae7b11485d9f991ea66a56aa79d4dd9cd1103 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:58:12 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=652ae7b11485d9f991ea66a56aa79d4dd9cd1103 commit 652ae7b11485d9f991ea66a56aa79d4dd9cd1103 Author: Adam Fenn AuthorDate: 2021-07-28 17:12:00 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 12:57:53 +0000 x86: cpufunc: Add rdtsc_ordered() Add a variant of 'rdtsc()' that performs the ordered version of 'rdtsc' appropriate for the invoking x86 variant. Also, expose the 'lfence'-ed and 'mfence'-ed 'rdtsc()' variants needed by 'rdtsc_ordered()' for general use. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31416 --- sys/amd64/include/cpufunc.h | 14 ++++++++++++++ sys/i386/include/cpufunc.h | 14 ++++++++++++++ sys/x86/include/x86_var.h | 1 + sys/x86/x86/cpu_machdep.c | 16 ++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 49975e826fb9..bca74d8ead67 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -355,6 +355,20 @@ rdtsc(void) return (low | ((uint64_t)high << 32)); } +static __inline uint64_t +rdtsc_ordered_lfence(void) +{ + lfence(); + return (rdtsc()); +} + +static __inline uint64_t +rdtsc_ordered_mfence(void) +{ + mfence(); + return (rdtsc()); +} + static __inline uint64_t rdtscp(void) { diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index 7b99978facc3..79cdd3004b77 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -394,6 +394,20 @@ rdtsc(void) return (rv); } +static __inline uint64_t +rdtsc_ordered_lfence(void) +{ + lfence(); + return (rdtsc()); +} + +static __inline uint64_t +rdtsc_ordered_mfence(void) +{ + mfence(); + return (rdtsc()); +} + static __inline uint64_t rdtscp(void) { diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index ec268503634b..d695822ddb7f 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -154,6 +154,7 @@ int user_dbreg_trap(register_t dr6); int minidumpsys(struct dumperinfo *); struct pcb *get_pcb_td(struct thread *td); void x86_set_fork_retval(struct thread *td); +uint64_t rdtsc_ordered(void); /* * MSR ops for x86_msr_op() diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c index bfc1a697cde0..1924342c8e83 100644 --- a/sys/x86/x86/cpu_machdep.c +++ b/sys/x86/x86/cpu_machdep.c @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -88,6 +89,7 @@ __FBSDID("$FreeBSD$"); #include #endif #include +#include #include #include @@ -1508,3 +1510,17 @@ acpi_get_fadt_bootflags(uint16_t *flagsp) return (false); #endif } + +DEFINE_IFUNC(, uint64_t, rdtsc_ordered, (void)) +{ + bool cpu_is_amd = cpu_vendor_id == CPU_VENDOR_AMD || + cpu_vendor_id == CPU_VENDOR_HYGON; + + if ((amd_feature & AMDID_RDTSCP) != 0) + return (rdtscp); + else if ((cpu_feature & CPUID_SSE2) != 0) + return (cpu_is_amd ? rdtsc_ordered_mfence : + rdtsc_ordered_lfence); + else + return (rdtsc); +} From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:58:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE8AF66CA7A; Sat, 14 Aug 2021 12:58: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 4Gn0pX4xHXz3m1h; Sat, 14 Aug 2021 12:58: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 9098E227CC; Sat, 14 Aug 2021 12:58: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 17ECwCCK031135; Sat, 14 Aug 2021 12:58:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECwCJG031134; Sat, 14 Aug 2021 12:58:12 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:58:12 GMT Message-Id: <202108141258.17ECwCJG031134@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 346f5a0c483b - main - x86: files: Make sys/x86/x86/pvclock.c optional 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/main X-Git-Reftype: branch X-Git-Commit: 346f5a0c483b7c159efd7c8faf4a18f3e3f77158 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:58:13 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=346f5a0c483b7c159efd7c8faf4a18f3e3f77158 commit 346f5a0c483b7c159efd7c8faf4a18f3e3f77158 Author: Adam Fenn AuthorDate: 2021-08-04 15:10:43 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 12:57:54 +0000 x86: files: Make sys/x86/x86/pvclock.c optional Make inclusion of `sys/x86/x86/pvclock.c` contingent on that of its dependents. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D31417 --- sys/conf/files.x86 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 index b5bde6b87975..d1fc234c4182 100644 --- a/sys/conf/files.x86 +++ b/sys/conf/files.x86 @@ -318,7 +318,7 @@ x86/x86/x86_mem.c optional mem x86/x86/mp_x86.c optional smp x86/x86/mp_watchdog.c optional mp_watchdog smp x86/x86/nexus.c standard -x86/x86/pvclock.c standard +x86/x86/pvclock.c optional xenhvm x86/x86/stack_machdep.c optional ddb | stack x86/x86/tsc.c standard x86/x86/ucode.c standard From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:58:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4DE3B66C7E8; Sat, 14 Aug 2021 12:58: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 4Gn0pY6QFzz3lgq; Sat, 14 Aug 2021 12:58: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 AE959220F2; Sat, 14 Aug 2021 12:58: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 17ECwDbt031159; Sat, 14 Aug 2021 12:58:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECwDRc031158; Sat, 14 Aug 2021 12:58:13 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:58:13 GMT Message-Id: <202108141258.17ECwDRc031158@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0b3382b863f3 - main - pvclock: Add 'struct pvclock' API 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/main X-Git-Reftype: branch X-Git-Commit: 0b3382b863f3195d88b99f94d5af7fe4a7b9726a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:58:14 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0b3382b863f3195d88b99f94d5af7fe4a7b9726a commit 0b3382b863f3195d88b99f94d5af7fe4a7b9726a Author: Adam Fenn AuthorDate: 2021-08-07 20:01:46 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 12:57:54 +0000 pvclock: Add 'struct pvclock' API Consolidate more hypervisor-agnostic functionality behind a new 'struct pvclock' API. This should also make it easier to subsequently add hypervisor-agnostic vDSO timekeeping support. Also, perform some clean-up: - Remove 'pvclock_get_last_cycles()'; do not allow external access to 'pvclock_last_systime' since this is not necessary. - Consolidate/simplify wall and system time reading codepaths. - Ensure correct ordering within wall and system time reading codepaths via 'atomic(9)' and 'rdtsc_ordered()' rather than via 'rmb()'. - Remove some extra newlines. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31418 --- sys/x86/include/pvclock.h | 27 ++++++- sys/x86/x86/pvclock.c | 194 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 160 insertions(+), 61 deletions(-) diff --git a/sys/x86/include/pvclock.h b/sys/x86/include/pvclock.h index 402ffed810ca..399017039dd0 100644 --- a/sys/x86/include/pvclock.h +++ b/sys/x86/include/pvclock.h @@ -29,6 +29,9 @@ #ifndef X86_PVCLOCK #define X86_PVCLOCK +#include +#include + struct pvclock_vcpu_time_info { uint32_t version; uint32_t pad0; @@ -43,17 +46,39 @@ struct pvclock_vcpu_time_info { #define PVCLOCK_FLAG_TSC_STABLE 0x01 #define PVCLOCK_FLAG_GUEST_PASUED 0x02 +typedef struct pvclock_wall_clock *pvclock_get_wallclock_t(void *arg); + struct pvclock_wall_clock { uint32_t version; uint32_t sec; uint32_t nsec; }; +struct pvclock { + /* Public; initialized by the caller of 'pvclock_init()': */ + pvclock_get_wallclock_t *get_wallclock; + void *get_wallclock_arg; + struct pvclock_vcpu_time_info *timeinfos; + bool stable_flag_supported; + + /* Private; initialized by the 'pvclock' API: */ + struct timecounter tc; +}; + +/* + * NOTE: 'pvclock_get_timecount()' and 'pvclock_get_wallclock()' are purely + * transitional; they should be removed after 'dev/xen/timer/timer.c' has been + * migrated to the 'struct pvclock' API. + */ void pvclock_resume(void); -uint64_t pvclock_get_last_cycles(void); uint64_t pvclock_tsc_freq(struct pvclock_vcpu_time_info *ti); uint64_t pvclock_get_timecount(struct pvclock_vcpu_time_info *ti); void pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts); +void pvclock_init(struct pvclock *pvc, device_t dev, + const char *tc_name, int tc_quality, u_int tc_flags); +void pvclock_gettime(struct pvclock *pvc, struct timespec *ts); +int pvclock_destroy(struct pvclock *pvc); + #endif diff --git a/sys/x86/x86/pvclock.c b/sys/x86/x86/pvclock.c index c1e6f83b33bf..e0ad65d906b8 100644 --- a/sys/x86/x86/pvclock.c +++ b/sys/x86/x86/pvclock.c @@ -31,31 +31,34 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include -#include -#include #include +#include #include /* - * Last time; this guarantees a monotonically increasing clock for when - * a stable TSC is not provided. + * Last system time. This is used to guarantee a monotonically non-decreasing + * clock for the kernel codepath and approximate the same for the vDSO codepath. + * In theory, this should be unnecessary absent hypervisor bug(s) and/or what + * should be rare cases where TSC jitter may still be visible despite the + * hypervisor's best efforts. */ -static volatile uint64_t pvclock_last_cycles; +static volatile uint64_t pvclock_last_systime; + +static uint64_t pvclock_getsystime(struct pvclock *pvc); +static void pvclock_read_time_info( + struct pvclock_vcpu_time_info *ti, uint64_t *ns, uint8_t *flags); +static void pvclock_read_wall_clock(struct pvclock_wall_clock *wc, + struct timespec *ts); +static u_int pvclock_tc_get_timecount(struct timecounter *tc); void pvclock_resume(void) { - - atomic_store_rel_64(&pvclock_last_cycles, 0); -} - -uint64_t -pvclock_get_last_cycles(void) -{ - - return (atomic_load_acq_64(&pvclock_last_cycles)); + atomic_store_rel_64(&pvclock_last_systime, 0); } uint64_t @@ -64,12 +67,10 @@ pvclock_tsc_freq(struct pvclock_vcpu_time_info *ti) uint64_t freq; freq = (1000000000ULL << 32) / ti->tsc_to_system_mul; - if (ti->tsc_shift < 0) freq <<= -ti->tsc_shift; else freq >>= ti->tsc_shift; - return (freq); } @@ -86,7 +87,6 @@ pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) delta >>= -shift; else delta <<= shift; - #if defined(__i386__) { uint32_t tmp1, tmp2; @@ -122,82 +122,156 @@ pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) #else #error "pvclock: unsupported x86 architecture?" #endif - return (product); } -static uint64_t -pvclock_get_nsec_offset(struct pvclock_vcpu_time_info *ti) -{ - uint64_t delta; - - delta = rdtsc() - ti->tsc_timestamp; - - return (pvclock_scale_delta(delta, ti->tsc_to_system_mul, - ti->tsc_shift)); -} - static void pvclock_read_time_info(struct pvclock_vcpu_time_info *ti, - uint64_t *cycles, uint8_t *flags) + uint64_t *ns, uint8_t *flags) { + uint64_t delta; uint32_t version; do { - version = ti->version; - rmb(); - *cycles = ti->system_time + pvclock_get_nsec_offset(ti); + version = atomic_load_acq_32(&ti->version); + delta = rdtsc_ordered() - ti->tsc_timestamp; + *ns = ti->system_time + pvclock_scale_delta(delta, + ti->tsc_to_system_mul, ti->tsc_shift); *flags = ti->flags; - rmb(); + atomic_thread_fence_acq(); } while ((ti->version & 1) != 0 || ti->version != version); } static void -pvclock_read_wall_clock(struct pvclock_wall_clock *wc, uint32_t *sec, - uint32_t *nsec) +pvclock_read_wall_clock(struct pvclock_wall_clock *wc, struct timespec *ts) { uint32_t version; do { - version = wc->version; - rmb(); - *sec = wc->sec; - *nsec = wc->nsec; - rmb(); + version = atomic_load_acq_32(&wc->version); + ts->tv_sec = wc->sec; + ts->tv_nsec = wc->nsec; + atomic_thread_fence_acq(); } while ((wc->version & 1) != 0 || wc->version != version); } +static uint64_t +pvclock_getsystime(struct pvclock *pvc) +{ + uint64_t now, last, ret; + uint8_t flags; + + critical_enter(); + pvclock_read_time_info(&pvc->timeinfos[curcpu], &now, &flags); + ret = now; + if ((flags & PVCLOCK_FLAG_TSC_STABLE) == 0) { + last = atomic_load_acq_64(&pvclock_last_systime); + do { + if (last > now) { + ret = last; + break; + } + } while (!atomic_fcmpset_rel_64(&pvclock_last_systime, &last, + now)); + } + critical_exit(); + return (ret); +} + +/* + * NOTE: Transitional-only; this should be removed after 'dev/xen/timer/timer.c' + * has been migrated to the 'struct pvclock' API. + */ uint64_t pvclock_get_timecount(struct pvclock_vcpu_time_info *ti) { - uint64_t now, last; + uint64_t now, last, ret; uint8_t flags; pvclock_read_time_info(ti, &now, &flags); + ret = now; + if ((flags & PVCLOCK_FLAG_TSC_STABLE) == 0) { + last = atomic_load_acq_64(&pvclock_last_systime); + do { + if (last > now) { + ret = last; + break; + } + } while (!atomic_fcmpset_rel_64(&pvclock_last_systime, &last, + now)); + } + return (ret); +} - if (flags & PVCLOCK_FLAG_TSC_STABLE) - return (now); +/* + * NOTE: Transitional-only; this should be removed after 'dev/xen/timer/timer.c' + * has been migrated to the 'struct pvclock' API. + */ +void +pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts) +{ + pvclock_read_wall_clock(wc, ts); +} - /* - * Enforce a monotonically increasing clock time across all VCPUs. - * If our time is too old, use the last time and return. Otherwise, - * try to update the last time. - */ - do { - last = atomic_load_acq_64(&pvclock_last_cycles); - if (last > now) - return (last); - } while (!atomic_cmpset_64(&pvclock_last_cycles, last, now)); +static u_int +pvclock_tc_get_timecount(struct timecounter *tc) +{ + struct pvclock *pvc = tc->tc_priv; - return (now); + return (pvclock_getsystime(pvc) & UINT_MAX); } void -pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts) +pvclock_gettime(struct pvclock *pvc, struct timespec *ts) { - uint32_t sec, nsec; + struct timespec system_ts; + uint64_t system_ns; + + pvclock_read_wall_clock(pvc->get_wallclock(pvc->get_wallclock_arg), ts); + system_ns = pvclock_getsystime(pvc); + system_ts.tv_sec = system_ns / 1000000000ULL; + system_ts.tv_nsec = system_ns % 1000000000ULL; + timespecadd(ts, &system_ts, ts); +} - pvclock_read_wall_clock(wc, &sec, &nsec); - ts->tv_sec = sec; - ts->tv_nsec = nsec; +void +pvclock_init(struct pvclock *pvc, device_t dev, const char *tc_name, + int tc_quality, u_int tc_flags) +{ + KASSERT(((uintptr_t)pvc->timeinfos & PAGE_MASK) == 0, + ("Specified time info page(s) address is not page-aligned.")); + + /* Set up timecounter and timecounter-supporting members: */ + pvc->tc.tc_get_timecount = pvclock_tc_get_timecount; + pvc->tc.tc_poll_pps = NULL; + pvc->tc.tc_counter_mask = ~0U; + pvc->tc.tc_frequency = 1000000000ULL; + pvc->tc.tc_name = tc_name; + pvc->tc.tc_quality = tc_quality; + pvc->tc.tc_flags = tc_flags; + pvc->tc.tc_priv = pvc; + pvc->tc.tc_fill_vdso_timehands = NULL; +#ifdef COMPAT_FREEBSD32 + pvc->tc.tc_fill_vdso_timehands32 = NULL; +#endif + + /* Register timecounter: */ + tc_init(&pvc->tc); + + /* + * Register wallclock: + * The RTC registration API expects a resolution in microseconds; + * pvclock's 1ns resolution is rounded up to 1us. + */ + clock_register(dev, 1); +} + +int +pvclock_destroy(struct pvclock *pvc) +{ + /* + * Not currently possible since there is no teardown counterpart of + * 'tc_init()'. + */ + return (EBUSY); } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:58:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C709966C924; Sat, 14 Aug 2021 12:58: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 4Gn0pc11Xpz3m6D; Sat, 14 Aug 2021 12:58: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 F071D22984; Sat, 14 Aug 2021 12:58: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 17ECwF5J031207; Sat, 14 Aug 2021 12:58:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECwFSA031206; Sat, 14 Aug 2021 12:58:15 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:58:15 GMT Message-Id: <202108141258.17ECwFSA031206@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d4b2d3035a23 - main - pvclock: Add vDSO support 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/main X-Git-Reftype: branch X-Git-Commit: d4b2d3035a23d5dc468d41151487a8299bf45cdc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:58:16 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d4b2d3035a23d5dc468d41151487a8299bf45cdc commit d4b2d3035a23d5dc468d41151487a8299bf45cdc Author: Adam Fenn AuthorDate: 2021-08-07 20:10:04 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 12:57:54 +0000 pvclock: Add vDSO support Add vDSO support for timekeeping devices that support the KVM/XEN paravirtual clock API. Also, expose, in the userspace-accessible '', definitions that will be needed by 'libc' to support 'VDSO_TH_ALGO_X86_PVCLK'. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31418 --- sys/dev/acpica/acpi_hpet.c | 4 + sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c | 2 + sys/x86/include/pvclock.h | 62 +++++++++++ sys/x86/include/vdso.h | 5 +- sys/x86/x86/pvclock.c | 165 +++++++++++++++++++--------- sys/x86/x86/tsc.c | 4 + 6 files changed, 188 insertions(+), 54 deletions(-) diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index 9f92521437fd..0f0a16f336f2 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -156,6 +156,8 @@ hpet_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) vdso_th->th_algo = VDSO_TH_ALGO_X86_HPET; vdso_th->th_x86_shift = 0; vdso_th->th_x86_hpet_idx = device_get_unit(sc->dev); + vdso_th->th_x86_pvc_last_systime = 0; + vdso_th->th_x86_pvc_stable_mask = 0; bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); return (sc->mmap_allow != 0); } @@ -171,6 +173,8 @@ hpet_vdso_timehands32(struct vdso_timehands32 *vdso_th32, vdso_th32->th_algo = VDSO_TH_ALGO_X86_HPET; vdso_th32->th_x86_shift = 0; vdso_th32->th_x86_hpet_idx = device_get_unit(sc->dev); + vdso_th32->th_x86_pvc_last_systime = 0; + vdso_th32->th_x86_pvc_stable_mask = 0; bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res)); return (sc->mmap_allow != 0); } diff --git a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c index c08098138805..11d549dc18d2 100644 --- a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c +++ b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c @@ -128,6 +128,8 @@ hyperv_tsc_vdso_timehands(struct vdso_timehands *vdso_th, vdso_th->th_algo = VDSO_TH_ALGO_X86_HVTSC; vdso_th->th_x86_shift = 0; vdso_th->th_x86_hpet_idx = 0; + vdso_th->th_x86_pvc_last_systime = 0; + vdso_th->th_x86_pvc_stable_mask = 0; bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); return (1); } diff --git a/sys/x86/include/pvclock.h b/sys/x86/include/pvclock.h index 399017039dd0..023acdb80d9c 100644 --- a/sys/x86/include/pvclock.h +++ b/sys/x86/include/pvclock.h @@ -30,7 +30,12 @@ #define X86_PVCLOCK #include + +#ifdef _KERNEL #include +#endif /* _KERNEL */ + +#define PVCLOCK_CDEVNAME "pvclock" struct pvclock_vcpu_time_info { uint32_t version; @@ -46,6 +51,59 @@ struct pvclock_vcpu_time_info { #define PVCLOCK_FLAG_TSC_STABLE 0x01 #define PVCLOCK_FLAG_GUEST_PASUED 0x02 +/* + * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction, + * yielding a 64-bit result. + */ +static inline uint64_t +pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) +{ + uint64_t product; + + if (shift < 0) + delta >>= -shift; + else + delta <<= shift; +#if defined(__i386__) + { + uint32_t tmp1, tmp2; + + /** + * For i386, the formula looks like: + * + * lower = (mul_frac * (delta & UINT_MAX)) >> 32 + * upper = mul_frac * (delta >> 32) + * product = lower + upper + */ + __asm__ ( + "mul %5 ; " + "mov %4,%%eax ; " + "mov %%edx,%4 ; " + "mul %5 ; " + "xor %5,%5 ; " + "add %4,%%eax ; " + "adc %5,%%edx ; " + : "=A" (product), "=r" (tmp1), "=r" (tmp2) + : "a" ((uint32_t)delta), "1" ((uint32_t)(delta >> 32)), + "2" (mul_frac) ); + } +#elif defined(__amd64__) + { + unsigned long tmp; + + __asm__ ( + "mulq %[mul_frac] ; shrd $32, %[hi], %[lo]" + : [lo]"=a" (product), [hi]"=d" (tmp) + : "0" (delta), [mul_frac]"rm"((uint64_t)mul_frac)); + } +#else +#error "pvclock: unsupported x86 architecture?" +#endif + return (product); +} + +#ifdef _KERNEL + typedef struct pvclock_wall_clock *pvclock_get_wallclock_t(void *arg); struct pvclock_wall_clock { @@ -62,7 +120,9 @@ struct pvclock { bool stable_flag_supported; /* Private; initialized by the 'pvclock' API: */ + bool vdso_force_unstable; struct timecounter tc; + struct cdev *cdev; }; /* @@ -81,4 +141,6 @@ void pvclock_init(struct pvclock *pvc, device_t dev, void pvclock_gettime(struct pvclock *pvc, struct timespec *ts); int pvclock_destroy(struct pvclock *pvc); +#endif /* _KERNEL */ + #endif diff --git a/sys/x86/include/vdso.h b/sys/x86/include/vdso.h index 97972c660dde..ace63cbe9f62 100644 --- a/sys/x86/include/vdso.h +++ b/sys/x86/include/vdso.h @@ -37,11 +37,14 @@ #define VDSO_TIMEHANDS_MD \ uint32_t th_x86_shift; \ uint32_t th_x86_hpet_idx; \ - uint32_t th_res[6]; + uint64_t th_x86_pvc_last_systime;\ + uint8_t th_x86_pvc_stable_mask; \ + uint8_t th_res[15]; #define VDSO_TH_ALGO_X86_TSC VDSO_TH_ALGO_1 #define VDSO_TH_ALGO_X86_HPET VDSO_TH_ALGO_2 #define VDSO_TH_ALGO_X86_HVTSC VDSO_TH_ALGO_3 /* Hyper-V ref. TSC */ +#define VDSO_TH_ALGO_X86_PVCLK VDSO_TH_ALGO_4 /* KVM/XEN paravirtual clock */ #ifdef _KERNEL #ifdef COMPAT_FREEBSD32 diff --git a/sys/x86/x86/pvclock.c b/sys/x86/x86/pvclock.c index e0ad65d906b8..cc2377bdbcf0 100644 --- a/sys/x86/x86/pvclock.c +++ b/sys/x86/x86/pvclock.c @@ -31,11 +31,22 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include +#include #include +#include #include +#include +#include +#include + +#include +#include #include +#include #include #include @@ -54,6 +65,22 @@ static void pvclock_read_time_info( static void pvclock_read_wall_clock(struct pvclock_wall_clock *wc, struct timespec *ts); static u_int pvclock_tc_get_timecount(struct timecounter *tc); +static uint32_t pvclock_tc_vdso_timehands( + struct vdso_timehands *vdso_th, struct timecounter *tc); +#ifdef COMPAT_FREEBSD32 +static uint32_t pvclock_tc_vdso_timehands32( + struct vdso_timehands32 *vdso_th, struct timecounter *tc); +#endif + +static d_open_t pvclock_cdev_open; +static d_mmap_t pvclock_cdev_mmap; + +static struct cdevsw pvclock_cdev_cdevsw = { + .d_version = D_VERSION, + .d_name = PVCLOCK_CDEVNAME, + .d_open = pvclock_cdev_open, + .d_mmap = pvclock_cdev_mmap, +}; void pvclock_resume(void) @@ -74,57 +101,6 @@ pvclock_tsc_freq(struct pvclock_vcpu_time_info *ti) return (freq); } -/* - * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction, - * yielding a 64-bit result. - */ -static inline uint64_t -pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) -{ - uint64_t product; - - if (shift < 0) - delta >>= -shift; - else - delta <<= shift; -#if defined(__i386__) - { - uint32_t tmp1, tmp2; - - /** - * For i386, the formula looks like: - * - * lower = (mul_frac * (delta & UINT_MAX)) >> 32 - * upper = mul_frac * (delta >> 32) - * product = lower + upper - */ - __asm__ ( - "mul %5 ; " - "mov %4,%%eax ; " - "mov %%edx,%4 ; " - "mul %5 ; " - "xor %5,%5 ; " - "add %4,%%eax ; " - "adc %5,%%edx ; " - : "=A" (product), "=r" (tmp1), "=r" (tmp2) - : "a" ((uint32_t)delta), "1" ((uint32_t)(delta >> 32)), - "2" (mul_frac) ); - } -#elif defined(__amd64__) - { - unsigned long tmp; - - __asm__ ( - "mulq %[mul_frac] ; shrd $32, %[hi], %[lo]" - : [lo]"=a" (product), [hi]"=d" (tmp) - : "0" (delta), [mul_frac]"rm"((uint64_t)mul_frac)); - } -#else -#error "pvclock: unsupported x86 architecture?" -#endif - return (product); -} - static void pvclock_read_time_info(struct pvclock_vcpu_time_info *ti, uint64_t *ns, uint8_t *flags) @@ -213,6 +189,27 @@ pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts) pvclock_read_wall_clock(wc, ts); } +static int +pvclock_cdev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) +{ + if (oflags & FWRITE) + return (EPERM); + return (0); +} + +static int +pvclock_cdev_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, + int nprot, vm_memattr_t *memattr) +{ + if (offset >= mp_ncpus * sizeof(struct pvclock_vcpu_time_info)) + return (EINVAL); + if (PROT_EXTRACT(nprot) != PROT_READ) + return (EACCES); + *paddr = vtophys((uintptr_t)dev->si_drv1 + offset); + *memattr = VM_MEMATTR_DEFAULT; + return (0); +} + static u_int pvclock_tc_get_timecount(struct timecounter *tc) { @@ -221,6 +218,42 @@ pvclock_tc_get_timecount(struct timecounter *tc) return (pvclock_getsystime(pvc) & UINT_MAX); } +static uint32_t +pvclock_tc_vdso_timehands(struct vdso_timehands *vdso_th, + struct timecounter *tc) +{ + struct pvclock *pvc = tc->tc_priv; + + vdso_th->th_algo = VDSO_TH_ALGO_X86_PVCLK; + vdso_th->th_x86_shift = 0; + vdso_th->th_x86_hpet_idx = 0; + vdso_th->th_x86_pvc_last_systime = + atomic_load_acq_64(&pvclock_last_systime); + vdso_th->th_x86_pvc_stable_mask = !pvc->vdso_force_unstable && + pvc->stable_flag_supported ? PVCLOCK_FLAG_TSC_STABLE : 0; + bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); + return (pvc->cdev != NULL && amd_feature & AMDID_RDTSCP); +} + +#ifdef COMPAT_FREEBSD32 +static uint32_t +pvclock_tc_vdso_timehands32(struct vdso_timehands32 *vdso_th, + struct timecounter *tc) +{ + struct pvclock *pvc = tc->tc_priv; + + vdso_th->th_algo = VDSO_TH_ALGO_X86_PVCLK; + vdso_th->th_x86_shift = 0; + vdso_th->th_x86_hpet_idx = 0; + vdso_th->th_x86_pvc_last_systime = + atomic_load_acq_64(&pvclock_last_systime); + vdso_th->th_x86_pvc_stable_mask = !pvc->vdso_force_unstable && + pvc->stable_flag_supported ? PVCLOCK_FLAG_TSC_STABLE : 0; + bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); + return (pvc->cdev != NULL && amd_feature & AMDID_RDTSCP); +} +#endif + void pvclock_gettime(struct pvclock *pvc, struct timespec *ts) { @@ -238,9 +271,19 @@ void pvclock_init(struct pvclock *pvc, device_t dev, const char *tc_name, int tc_quality, u_int tc_flags) { + struct make_dev_args mda; + int err; + KASSERT(((uintptr_t)pvc->timeinfos & PAGE_MASK) == 0, ("Specified time info page(s) address is not page-aligned.")); + /* Set up vDSO stable-flag suppression test facility: */ + pvc->vdso_force_unstable = false; + SYSCTL_ADD_BOOL(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, + "vdso_force_unstable", CTLFLAG_RW, &pvc->vdso_force_unstable, 0, + "Forcibly deassert stable flag in vDSO codepath"); + /* Set up timecounter and timecounter-supporting members: */ pvc->tc.tc_get_timecount = pvclock_tc_get_timecount; pvc->tc.tc_poll_pps = NULL; @@ -250,11 +293,27 @@ pvclock_init(struct pvclock *pvc, device_t dev, const char *tc_name, pvc->tc.tc_quality = tc_quality; pvc->tc.tc_flags = tc_flags; pvc->tc.tc_priv = pvc; - pvc->tc.tc_fill_vdso_timehands = NULL; + pvc->tc.tc_fill_vdso_timehands = pvclock_tc_vdso_timehands; #ifdef COMPAT_FREEBSD32 - pvc->tc.tc_fill_vdso_timehands32 = NULL; + pvc->tc.tc_fill_vdso_timehands32 = pvclock_tc_vdso_timehands32; #endif + /* Set up cdev for userspace mmapping of vCPU 0 time info page: */ + make_dev_args_init(&mda); + mda.mda_devsw = &pvclock_cdev_cdevsw; + mda.mda_uid = UID_ROOT; + mda.mda_gid = GID_WHEEL; + mda.mda_mode = 0444; + mda.mda_si_drv1 = pvc->timeinfos; + err = make_dev_s(&mda, &pvc->cdev, PVCLOCK_CDEVNAME); + if (err != 0) { + device_printf(dev, "Could not create /dev/%s, error %d. Fast " + "time of day will be unavailable for this timecounter.\n", + PVCLOCK_CDEVNAME, err); + KASSERT(pvc->cdev == NULL, + ("Failed make_dev_s() unexpectedly inited cdev.")); + } + /* Register timecounter: */ tc_init(&pvc->tc); diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 5ffbb64229e9..0ebcea895cd3 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -870,6 +870,8 @@ x86_tsc_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) vdso_th->th_algo = VDSO_TH_ALGO_X86_TSC; vdso_th->th_x86_shift = (int)(intptr_t)tc->tc_priv; vdso_th->th_x86_hpet_idx = 0xffffffff; + vdso_th->th_x86_pvc_last_systime = 0; + vdso_th->th_x86_pvc_stable_mask = 0; bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); return (1); } @@ -883,6 +885,8 @@ x86_tsc_vdso_timehands32(struct vdso_timehands32 *vdso_th32, vdso_th32->th_algo = VDSO_TH_ALGO_X86_TSC; vdso_th32->th_x86_shift = (int)(intptr_t)tc->tc_priv; vdso_th32->th_x86_hpet_idx = 0xffffffff; + vdso_th32->th_x86_pvc_last_systime = 0; + vdso_th32->th_x86_pvc_stable_mask = 0; bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res)); return (1); } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:58:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 484C666C7EE; Sat, 14 Aug 2021 12:58: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 4Gn0pb0JjCz3lw8; Sat, 14 Aug 2021 12:58: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 C8DC322761; Sat, 14 Aug 2021 12:58: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 17ECwESN031183; Sat, 14 Aug 2021 12:58:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECwEWF031182; Sat, 14 Aug 2021 12:58:14 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:58:14 GMT Message-Id: <202108141258.17ECwEWF031182@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 6c69c6bb4c7f - main - kvm_clock: KVM paravirtual clock support 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/main X-Git-Reftype: branch X-Git-Commit: 6c69c6bb4c7ffde48b130df707799d4eca21ca9f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:58:15 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6c69c6bb4c7ffde48b130df707799d4eca21ca9f commit 6c69c6bb4c7ffde48b130df707799d4eca21ca9f Author: Adam Fenn AuthorDate: 2021-08-04 15:42:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 12:57:54 +0000 kvm_clock: KVM paravirtual clock support Add support for the KVM paravirtual clock device. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D29733 --- sys/amd64/conf/GENERIC | 3 + sys/amd64/conf/MINIMAL | 3 + sys/amd64/conf/NOTES | 3 + sys/conf/files.x86 | 3 +- sys/dev/kvm_clock/kvm_clock.c | 240 ++++++++++++++++++++++++++++++++++++++++++ sys/i386/conf/GENERIC | 3 + sys/i386/conf/MINIMAL | 3 + sys/i386/conf/NOTES | 3 + sys/x86/include/kvm.h | 80 ++++++++++++++ 9 files changed, 340 insertions(+), 1 deletion(-) diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index f7b41919575d..78b5e0e299f6 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -376,6 +376,9 @@ device virtio_blk # VirtIO Block device device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # HyperV drivers and enhancement support device hyperv # HyperV drivers diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL index 14f91e6c8eaf..f724cbd2e3f1 100644 --- a/sys/amd64/conf/MINIMAL +++ b/sys/amd64/conf/MINIMAL @@ -131,6 +131,9 @@ device ether # Ethernet support # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # Xen HVM Guest Optimizations # NOTE: XENHVM depends on xenpci and xentimer. # They must be added or removed together. diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index 501ceaedb222..c1db8ef7512f 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -498,6 +498,9 @@ device virtio_balloon # VirtIO Memory Balloon device device virtio_random # VirtIO Entropy device device virtio_console # VirtIO Console device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # Microsoft Hyper-V enhancement support device hyperv # HyperV drivers diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 index d1fc234c4182..d0cda2da8580 100644 --- a/sys/conf/files.x86 +++ b/sys/conf/files.x86 @@ -263,6 +263,7 @@ dev/isci/scil/scif_sas_task_request_state_handlers.c optional isci dev/isci/scil/scif_sas_task_request_states.c optional isci dev/isci/scil/scif_sas_timer.c optional isci dev/itwd/itwd.c optional itwd +dev/kvm_clock/kvm_clock.c optional kvm_clock dev/qat/qat.c optional qat dev/qat/qat_ae.c optional qat dev/qat/qat_c2xxx.c optional qat @@ -318,7 +319,7 @@ x86/x86/x86_mem.c optional mem x86/x86/mp_x86.c optional smp x86/x86/mp_watchdog.c optional mp_watchdog smp x86/x86/nexus.c standard -x86/x86/pvclock.c optional xenhvm +x86/x86/pvclock.c optional kvm_clock | xenhvm x86/x86/stack_machdep.c optional ddb | stack x86/x86/tsc.c standard x86/x86/ucode.c standard diff --git a/sys/dev/kvm_clock/kvm_clock.c b/sys/dev/kvm_clock/kvm_clock.c new file mode 100644 index 000000000000..1a76432e417d --- /dev/null +++ b/sys/dev/kvm_clock/kvm_clock.c @@ -0,0 +1,240 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2014 Bryan Venteicher + * Copyright (c) 2021 Mathieu Chouquet-Stringer + * Copyright (c) 2021 Juniper Networks, Inc. + * Copyright (c) 2021 Klara, Inc. + * + * 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. + */ + +/* + * Linux KVM paravirtual clock support + * + * References: + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "clock_if.h" + +#define KVM_CLOCK_DEVNAME "kvmclock" +/* + * Note: Chosen to be (1) above HPET's value (always 950), (2) above the TSC's + * default value of 800, and (3) below the TSC's value when it supports the + * "Invariant TSC" feature and is believed to be synchronized across all CPUs. + */ +#define KVM_CLOCK_TC_QUALITY 975 + +struct kvm_clock_softc { + struct pvclock pvc; + struct pvclock_wall_clock wc; + struct pvclock_vcpu_time_info *timeinfos; + u_int msr_tc; + u_int msr_wc; +}; + +static devclass_t kvm_clock_devclass; + +static struct pvclock_wall_clock *kvm_clock_get_wallclock(void *arg); +static void kvm_clock_system_time_enable(struct kvm_clock_softc *sc); +static void kvm_clock_system_time_enable_pcpu(void *arg); + +static struct pvclock_wall_clock * +kvm_clock_get_wallclock(void *arg) +{ + struct kvm_clock_softc *sc = arg; + + wrmsr(sc->msr_wc, vtophys(&sc->wc)); + return (&sc->wc); +} + +static void +kvm_clock_system_time_enable(struct kvm_clock_softc *sc) +{ + smp_rendezvous(NULL, kvm_clock_system_time_enable_pcpu, NULL, sc); +} + +static void +kvm_clock_system_time_enable_pcpu(void *arg) +{ + struct kvm_clock_softc *sc = arg; + + /* + * See [2]; the lsb of this MSR is the system time enable bit. + */ + wrmsr(sc->msr_tc, vtophys(&(sc->timeinfos)[curcpu]) | 1); +} + +static void +kvm_clock_identify(driver_t *driver, device_t parent) +{ + u_int regs[4]; + + kvm_cpuid_get_features(regs); + if ((regs[0] & + (KVM_FEATURE_CLOCKSOURCE2 | KVM_FEATURE_CLOCKSOURCE)) == 0) + return; + if (device_find_child(parent, KVM_CLOCK_DEVNAME, -1)) + return; + BUS_ADD_CHILD(parent, 0, KVM_CLOCK_DEVNAME, 0); +} + +static int +kvm_clock_probe(device_t dev) +{ + device_set_desc(dev, "KVM paravirtual clock"); + return (BUS_PROBE_DEFAULT); +} + +static int +kvm_clock_attach(device_t dev) +{ + u_int regs[4]; + struct kvm_clock_softc *sc = device_get_softc(dev); + bool stable_flag_supported; + + /* Process KVM "features" CPUID leaf content: */ + kvm_cpuid_get_features(regs); + if ((regs[0] & KVM_FEATURE_CLOCKSOURCE2) != 0) { + sc->msr_tc = KVM_MSR_SYSTEM_TIME_NEW; + sc->msr_wc = KVM_MSR_WALL_CLOCK_NEW; + } else { + KASSERT((regs[0] & KVM_FEATURE_CLOCKSOURCE) != 0, + ("Clocksource feature flags disappeared since " + "kvm_clock_identify: regs[0] %#0x.", regs[0])); + sc->msr_tc = KVM_MSR_SYSTEM_TIME; + sc->msr_wc = KVM_MSR_WALL_CLOCK; + } + stable_flag_supported = + (regs[0] & KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) != 0; + + /* Set up 'struct pvclock_vcpu_time_info' page(s): */ + sc->timeinfos = (struct pvclock_vcpu_time_info *)kmem_malloc(mp_ncpus * + sizeof(struct pvclock_vcpu_time_info), M_WAITOK | M_ZERO); + kvm_clock_system_time_enable(sc); + + /* + * Init pvclock; register KVM clock wall clock, register KVM clock + * timecounter, and set up the requisite infrastructure for vDSO access + * to this timecounter. + * Regarding 'tc_flags': Since the KVM MSR documentation does not + * specifically discuss suspend/resume scenarios, conservatively + * leave 'TC_FLAGS_SUSPEND_SAFE' cleared and assume that the system + * time must be re-inited in such cases. + */ + sc->pvc.get_wallclock = kvm_clock_get_wallclock; + sc->pvc.get_wallclock_arg = sc; + sc->pvc.timeinfos = sc->timeinfos; + sc->pvc.stable_flag_supported = stable_flag_supported; + pvclock_init(&sc->pvc, dev, KVM_CLOCK_DEVNAME, KVM_CLOCK_TC_QUALITY, 0); + return (0); +} + +static int +kvm_clock_detach(device_t dev) +{ + struct kvm_clock_softc *sc = device_get_softc(dev); + + return (pvclock_destroy(&sc->pvc)); +} + +static int +kvm_clock_suspend(device_t dev) +{ + return (0); +} + +static int +kvm_clock_resume(device_t dev) +{ + /* + * See note in 'kvm_clock_attach()' regarding 'TC_FLAGS_SUSPEND_SAFE'; + * conservatively assume that the system time must be re-inited in + * suspend/resume scenarios. + */ + kvm_clock_system_time_enable(device_get_softc(dev)); + pvclock_resume(); + inittodr(time_second); + return (0); +} + +static int +kvm_clock_gettime(device_t dev, struct timespec *ts) +{ + struct kvm_clock_softc *sc = device_get_softc(dev); + + pvclock_gettime(&sc->pvc, ts); + return (0); +} + +static int +kvm_clock_settime(device_t dev, struct timespec *ts) +{ + /* + * Even though it is not possible to set the KVM clock's wall clock, to + * avoid the possibility of periodic benign error messages from + * 'settime_task_func()', report success rather than, e.g., 'ENODEV'. + */ + return (0); +} + +static device_method_t kvm_clock_methods[] = { + DEVMETHOD(device_identify, kvm_clock_identify), + DEVMETHOD(device_probe, kvm_clock_probe), + DEVMETHOD(device_attach, kvm_clock_attach), + DEVMETHOD(device_detach, kvm_clock_detach), + DEVMETHOD(device_suspend, kvm_clock_suspend), + DEVMETHOD(device_resume, kvm_clock_resume), + /* clock interface */ + DEVMETHOD(clock_gettime, kvm_clock_gettime), + DEVMETHOD(clock_settime, kvm_clock_settime), + + DEVMETHOD_END +}; + +static driver_t kvm_clock_driver = { + KVM_CLOCK_DEVNAME, + kvm_clock_methods, + sizeof(struct kvm_clock_softc), +}; + +DRIVER_MODULE(kvm_clock, nexus, kvm_clock_driver, kvm_clock_devclass, 0, 0); diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index 86c062effd81..5447c452c4f7 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -337,6 +337,9 @@ device virtio_blk # VirtIO Block device device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # HyperV drivers and enhancement support # NOTE: HYPERV depends on hyperv. They must be added or removed together. options HYPERV # Kernel support for HyperV drivers diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL index 37b8e074ac65..9d735dbb0580 100644 --- a/sys/i386/conf/MINIMAL +++ b/sys/i386/conf/MINIMAL @@ -145,6 +145,9 @@ device gif # IPv6 and IPv4 tunneling # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # Xen HVM Guest Optimizations # NOTE: XENHVM depends on xenpci. They must be added or removed together. options XENHVM # Xen HVM kernel infrastructure diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index df9ff4fb3aed..27cebf0c48a0 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -719,6 +719,9 @@ device virtio_balloon # VirtIO Memory Balloon device device virtio_random # VirtIO Entropy device device virtio_console # VirtIO Console device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + options HYPERV device hyperv # HyperV drivers diff --git a/sys/x86/include/kvm.h b/sys/x86/include/kvm.h new file mode 100644 index 000000000000..beec6447d7d6 --- /dev/null +++ b/sys/x86/include/kvm.h @@ -0,0 +1,80 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2014 Bryan Venteicher + * Copyright (c) 2021 Mathieu Chouquet-Stringer + * Copyright (c) 2021 Juniper Networks, Inc. + * Copyright (c) 2021 Klara, Inc. + * + * 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$ + */ + +/* + * Linux KVM paravirtualization: common definitions + * + * References: + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html + */ + +#ifndef _X86_KVM_H_ +#define _X86_KVM_H_ + +#include +#include + +#include + +#define KVM_CPUID_SIGNATURE 0x40000000 +#define KVM_CPUID_FEATURES_LEAF 0x40000001 + +#define KVM_FEATURE_CLOCKSOURCE 0x00000001 +#define KVM_FEATURE_CLOCKSOURCE2 0x00000008 +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 0x01000000 + +/* Deprecated: for the CLOCKSOURCE feature. */ +#define KVM_MSR_WALL_CLOCK 0x11 +#define KVM_MSR_SYSTEM_TIME 0x12 + +#define KVM_MSR_WALL_CLOCK_NEW 0x4b564d00 +#define KVM_MSR_SYSTEM_TIME_NEW 0x4b564d01 + +static inline bool +kvm_cpuid_features_leaf_supported(void) +{ + return (vm_guest == VM_GUEST_KVM && + KVM_CPUID_FEATURES_LEAF > hv_base && + KVM_CPUID_FEATURES_LEAF <= hv_high); +} + +static inline void +kvm_cpuid_get_features(u_int *regs) +{ + if (!kvm_cpuid_features_leaf_supported()) + regs[0] = regs[1] = regs[2] = regs[3] = 0; + else + do_cpuid(KVM_CPUID_FEATURES_LEAF, regs); +} + +#endif /* !_X86_KVM_H_ */ From owner-dev-commits-src-all@freebsd.org Sat Aug 14 12:58:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70C2166CB06; Sat, 14 Aug 2021 12:58: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 4Gn0pd1rQWz3m21; Sat, 14 Aug 2021 12:58: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 1305B227CD; Sat, 14 Aug 2021 12:58: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 17ECwHxK031237; Sat, 14 Aug 2021 12:58:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ECwHUE031236; Sat, 14 Aug 2021 12:58:17 GMT (envelope-from git) Date: Sat, 14 Aug 2021 12:58:17 GMT Message-Id: <202108141258.17ECwHUE031236@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a3d932dfef5e - main - libc: vDSO timekeeping: Add pvclock support 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/main X-Git-Reftype: branch X-Git-Commit: a3d932dfef5edc9d1c947b02fb93a64d63a291cb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 12:58:17 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a3d932dfef5edc9d1c947b02fb93a64d63a291cb commit a3d932dfef5edc9d1c947b02fb93a64d63a291cb Author: Adam Fenn AuthorDate: 2021-08-07 20:11:29 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-14 12:57:54 +0000 libc: vDSO timekeeping: Add pvclock support Add support for 'VDSO_TH_ALGO_X86_PVCLK'; add vDSO-based timekeeping for devices that support the KVM/XEN paravirtual clock API. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31418 --- lib/libc/x86/sys/__vdso_gettc.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c index ab10943c811b..5cc847e31c0e 100644 --- a/lib/libc/x86/sys/__vdso_gettc.c +++ b/lib/libc/x86/sys/__vdso_gettc.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include #include +#include #include #include #ifdef WANT_HYPERV @@ -312,6 +313,61 @@ __vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int *tc) #endif /* WANT_HYPERV */ +static struct pvclock_vcpu_time_info *pvclock_timeinfos; + +static int +__vdso_pvclock_gettc(const struct vdso_timehands *th, u_int *tc) +{ + uint64_t delta, ns, tsc; + struct pvclock_vcpu_time_info *ti; + uint32_t cpuid_ti, cpuid_tsc, version; + bool stable; + + do { + ti = &pvclock_timeinfos[0]; + version = atomic_load_acq_32(&ti->version); + stable = (ti->flags & th->th_x86_pvc_stable_mask) != 0; + if (stable) { + tsc = rdtscp(); + } else { + (void)rdtscp_aux(&cpuid_ti); + ti = &pvclock_timeinfos[cpuid_ti]; + version = atomic_load_acq_32(&ti->version); + tsc = rdtscp_aux(&cpuid_tsc); + } + delta = tsc - ti->tsc_timestamp; + ns = ti->system_time + pvclock_scale_delta(delta, + ti->tsc_to_system_mul, ti->tsc_shift); + atomic_thread_fence_acq(); + } while ((ti->version & 1) != 0 || ti->version != version || + (!stable && cpuid_ti != cpuid_tsc)); + *tc = MAX(ns, th->th_x86_pvc_last_systime); + return (0); +} + +static void +__vdso_init_pvclock_timeinfos(void) +{ + struct pvclock_vcpu_time_info *timeinfos; + size_t len; + int fd, ncpus; + unsigned int mode; + + timeinfos = MAP_FAILED; + if (_elf_aux_info(AT_NCPUS, &ncpus, sizeof(ncpus)) != 0 || + (cap_getmode(&mode) == 0 && mode != 0) || + (fd = _open("/dev/" PVCLOCK_CDEVNAME, O_RDONLY | O_CLOEXEC)) < 0) + goto leave; + len = ncpus * sizeof(*pvclock_timeinfos); + timeinfos = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); + _close(fd); +leave: + if (atomic_cmpset_rel_ptr( + (volatile uintptr_t *)&pvclock_timeinfos, (uintptr_t)NULL, + (uintptr_t)timeinfos) == 0 && timeinfos != MAP_FAILED) + (void)munmap((void *)timeinfos, len); +} + #pragma weak __vdso_gettc int __vdso_gettc(const struct vdso_timehands *th, u_int *tc) @@ -347,6 +403,12 @@ __vdso_gettc(const struct vdso_timehands *th, u_int *tc) return (ENOSYS); return (__vdso_hyperv_tsc(hyperv_ref_tsc, tc)); #endif + case VDSO_TH_ALGO_X86_PVCLK: + if (pvclock_timeinfos == NULL) + __vdso_init_pvclock_timeinfos(); + if (pvclock_timeinfos == MAP_FAILED) + return (ENOSYS); + return (__vdso_pvclock_gettc(th, tc)); default: return (ENOSYS); } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 13:03:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9383966CF8C; Sat, 14 Aug 2021 13:03: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 4Gn0x43hyqz3mbV; Sat, 14 Aug 2021 13:03: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 673CA224F6; Sat, 14 Aug 2021 13:03: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 17ED3qKY045374; Sat, 14 Aug 2021 13:03:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ED3qUK045373; Sat, 14 Aug 2021 13:03:52 GMT (envelope-from git) Date: Sat, 14 Aug 2021 13:03:52 GMT Message-Id: <202108141303.17ED3qUK045373@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 6b364a92fd79 - stable/13 - Add ElfW() macro for compatibility with Linux MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6b364a92fd790717fe7ea589df62dc1a653137dc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 13:03:52 -0000 The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=6b364a92fd790717fe7ea589df62dc1a653137dc commit 6b364a92fd790717fe7ea589df62dc1a653137dc Author: Dimitry Andric AuthorDate: 2021-08-05 18:57:22 +0000 Commit: Dimitry Andric CommitDate: 2021-08-14 12:57:58 +0000 Add ElfW() macro for compatibility with Linux Some Linux software using ELF headers assumes the existence of an ElfW(type) macro, which concatenates 'Elf', the default ELF word size, and the given type. This is identical to our __ElfN(x) macro in . Add the macro for compatibility, with a comment that we prefer the __ElfN() macro for FreeBSD. Reviewed by: emaste, kib Differential Revision: https://reviews.freebsd.org/D31427 MFC after: 1 week (cherry picked from commit 34e7e4b6a059eee5e4e3e34de5b9d5f0d6e589f9) --- sys/sys/elf_generic.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/sys/elf_generic.h b/sys/sys/elf_generic.h index 301ee52cf7a1..dcd44fe93b14 100644 --- a/sys/sys/elf_generic.h +++ b/sys/sys/elf_generic.h @@ -57,6 +57,9 @@ #define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) #define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) +/* Define ElfW for compatibility with Linux, prefer __ElfN() in FreeBSD code */ +#define ElfW(x) __ElfN(x) + __ElfType(Addr); __ElfType(Half); __ElfType(Off); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 13:04:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED91166CF1E; Sat, 14 Aug 2021 13:04: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 4Gn0xw6Qljz3mW9; Sat, 14 Aug 2021 13:04: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 C4CB622C87; Sat, 14 Aug 2021 13:04: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 17ED4ani045537; Sat, 14 Aug 2021 13:04:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ED4ad8045536; Sat, 14 Aug 2021 13:04:36 GMT (envelope-from git) Date: Sat, 14 Aug 2021 13:04:36 GMT Message-Id: <202108141304.17ED4ad8045536@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: b58a13b94c99 - stable/12 - Add ElfW() macro for compatibility with Linux MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b58a13b94c99a5c505bc24ca705111585d1b6759 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 13:04:37 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=b58a13b94c99a5c505bc24ca705111585d1b6759 commit b58a13b94c99a5c505bc24ca705111585d1b6759 Author: Dimitry Andric AuthorDate: 2021-08-05 18:57:22 +0000 Commit: Dimitry Andric CommitDate: 2021-08-14 13:00:28 +0000 Add ElfW() macro for compatibility with Linux Some Linux software using ELF headers assumes the existence of an ElfW(type) macro, which concatenates 'Elf', the default ELF word size, and the given type. This is identical to our __ElfN(x) macro in . Add the macro for compatibility, with a comment that we prefer the __ElfN() macro for FreeBSD. Reviewed by: emaste, kib Differential Revision: https://reviews.freebsd.org/D31427 MFC after: 1 week (cherry picked from commit 34e7e4b6a059eee5e4e3e34de5b9d5f0d6e589f9) --- sys/sys/elf_generic.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/sys/elf_generic.h b/sys/sys/elf_generic.h index 301ee52cf7a1..dcd44fe93b14 100644 --- a/sys/sys/elf_generic.h +++ b/sys/sys/elf_generic.h @@ -57,6 +57,9 @@ #define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) #define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) +/* Define ElfW for compatibility with Linux, prefer __ElfN() in FreeBSD code */ +#define ElfW(x) __ElfN(x) + __ElfType(Addr); __ElfType(Half); __ElfType(Off); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 13:04:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 63F2B66D062; Sat, 14 Aug 2021 13:04: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 4Gn0yJ2Shqz3ml8; Sat, 14 Aug 2021 13:04: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 3CB04225D3; Sat, 14 Aug 2021 13:04: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 17ED4ucF045670; Sat, 14 Aug 2021 13:04:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ED4uAD045669; Sat, 14 Aug 2021 13:04:56 GMT (envelope-from git) Date: Sat, 14 Aug 2021 13:04:56 GMT Message-Id: <202108141304.17ED4uAD045669@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 2b53701772f0 - stable/11 - Add ElfW() macro for compatibility with Linux MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 2b53701772f00a0bfa1783f5e82a9a497f335f2a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 13:04:56 -0000 The branch stable/11 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=2b53701772f00a0bfa1783f5e82a9a497f335f2a commit 2b53701772f00a0bfa1783f5e82a9a497f335f2a Author: Dimitry Andric AuthorDate: 2021-08-05 18:57:22 +0000 Commit: Dimitry Andric CommitDate: 2021-08-14 13:03:26 +0000 Add ElfW() macro for compatibility with Linux Some Linux software using ELF headers assumes the existence of an ElfW(type) macro, which concatenates 'Elf', the default ELF word size, and the given type. This is identical to our __ElfN(x) macro in . Add the macro for compatibility, with a comment that we prefer the __ElfN() macro for FreeBSD. Reviewed by: emaste, kib Differential Revision: https://reviews.freebsd.org/D31427 MFC after: 1 week (cherry picked from commit 34e7e4b6a059eee5e4e3e34de5b9d5f0d6e589f9) --- sys/sys/elf_generic.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/sys/elf_generic.h b/sys/sys/elf_generic.h index 5ff5242efcb2..34f4f47e064d 100644 --- a/sys/sys/elf_generic.h +++ b/sys/sys/elf_generic.h @@ -55,6 +55,9 @@ #define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) #define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) +/* Define ElfW for compatibility with Linux, prefer __ElfN() in FreeBSD code */ +#define ElfW(x) __ElfN(x) + __ElfType(Addr); __ElfType(Half); __ElfType(Off); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:00:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EA6A66E0AF; Sat, 14 Aug 2021 15:00: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 4Gn3X82kP5z3sZg; Sat, 14 Aug 2021 15:00: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 4518424400; Sat, 14 Aug 2021 15:00: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 17EF0uK8001555; Sat, 14 Aug 2021 15:00:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EF0uHu001539; Sat, 14 Aug 2021 15:00:56 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:00:56 GMT Message-Id: <202108141500.17EF0uHu001539@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 7e14be0b0717 - main - pci: Add an ioctl to perform I/O to BARs 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/main X-Git-Reftype: branch X-Git-Commit: 7e14be0b0717105f4b3b8c62df82a1e883d8ebb6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 15:00:56 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7e14be0b0717105f4b3b8c62df82a1e883d8ebb6 commit 7e14be0b0717105f4b3b8c62df82a1e883d8ebb6 Author: Mark Johnston AuthorDate: 2021-08-14 14:41:43 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 14:59:03 +0000 pci: Add an ioctl to perform I/O to BARs This is useful for bhyve, which otherwise has to use /dev/io to handle accesses to I/O port BARs when PCI passthrough is in use. Reviewed by: imp, kib Discussed with: jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31307 --- share/man/man4/pci.4 | 36 +++++++++++++++++- sys/dev/pci/pci_user.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ sys/sys/pciio.h | 12 ++++++ 3 files changed, 147 insertions(+), 1 deletion(-) diff --git a/share/man/man4/pci.4 b/share/man/man4/pci.4 index 28a456d18179..3c2c08afe466 100644 --- a/share/man/man4/pci.4 +++ b/share/man/man4/pci.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 27, 2021 +.Dd August 13, 2021 .Dt PCI 4 .Os .Sh NAME @@ -430,6 +430,40 @@ even on reads. of mapping. Currently attempt to mmap an inactive BAR results in error. .El +.It PCIOCBARIO +This +.Xr ioctl 2 +command allows users to read from and write to BARs. +The I/O request parameters are passed in a +.Va struct pci_bar_ioreq +structure, which has the following fields: +.Bl -tag +.It Vt struct pcisel pbi_sel +Describes the device to operate on. +.It Vt int pbi_op +The operation to perform. +Currently supported values are +.Dv PCIBARIO_READ +and +.Dv PCIBARIO_WRITE . +.It Vt uint32_t pbi_bar +The index of the BAR on which to operate. +.It Vt uint32_t pbi_offset +The offset into the BAR at which to operate. +.It Vt uint32_t pbi_width +The size, in bytes, of the I/O operation. +1-byte, 2-byte, 4-byte and 8-byte perations are supported. +.It Vt uint32_t pbi_value +For reads, the value is returned in this field. +For writes, the caller specifies the value to be written in this field. +.Pp +Note that this operation maps and unmaps the corresponding resource and +so is relatively expensive for memory BARs. +The +.Va PCIOCBARMMAP +.Xr ioctl 2 +can be used to create a persistent userspace mapping for such BARs instead. +.El .El .Sh LOADER TUNABLES Tunables can be set at the diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index e1813b67c05c..7ebd9b66138c 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -923,6 +923,92 @@ out: return (error); } +static int +pci_bar_io(device_t pcidev, struct pci_bar_ioreq *pbi) +{ + struct pci_map *pm; + struct resource *res; + uint32_t offset, width; + int bar, error, type; + + if (pbi->pbi_op != PCIBARIO_READ && + pbi->pbi_op != PCIBARIO_WRITE) + return (EINVAL); + + bar = PCIR_BAR(pbi->pbi_bar); + pm = pci_find_bar(pcidev, bar); + if (pm == NULL) + return (EINVAL); + + offset = pbi->pbi_offset; + width = pbi->pbi_width; + + if (offset + width < offset || + ((pci_addr_t)1 << pm->pm_size) < offset + width) + return (EINVAL); + + type = PCI_BAR_MEM(pm->pm_value) ? SYS_RES_MEMORY : SYS_RES_IOPORT; + + /* + * This will fail if a driver has allocated the resource. This could be + * worked around by detecting that case and using bus_map_resource() to + * populate the handle, but so far this is not needed. + */ + res = bus_alloc_resource_any(pcidev, type, &bar, RF_ACTIVE); + if (res == NULL) + return (ENOENT); + + error = 0; + switch (pbi->pbi_op) { + case PCIBARIO_READ: + switch (pbi->pbi_width) { + case 1: + pbi->pbi_value = bus_read_1(res, offset); + break; + case 2: + pbi->pbi_value = bus_read_2(res, offset); + break; + case 4: + pbi->pbi_value = bus_read_4(res, offset); + break; +#ifndef __i386__ + case 8: + pbi->pbi_value = bus_read_8(res, offset); + break; +#endif + default: + error = EINVAL; + break; + } + break; + case PCIBARIO_WRITE: + switch (pbi->pbi_width) { + case 1: + bus_write_1(res, offset, pbi->pbi_value); + break; + case 2: + bus_write_2(res, offset, pbi->pbi_value); + break; + case 4: + bus_write_4(res, offset, pbi->pbi_value); + break; +#ifndef __i386__ + case 8: + bus_write_8(res, offset, pbi->pbi_value); + break; +#endif + default: + error = EINVAL; + break; + } + break; + } + + bus_release_resource(pcidev, type, bar, res); + + return (error); +} + static int pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) { @@ -932,6 +1018,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t struct pci_conf_io *cio = NULL; struct pci_devinfo *dinfo; struct pci_io *io; + struct pci_bar_ioreq *pbi; struct pci_bar_io *bio; struct pci_list_vpd_io *lvio; struct pci_match_conf *pattern_buf; @@ -1307,6 +1394,19 @@ getconfexit: error = pcidev == NULL ? ENODEV : pci_bar_mmap(pcidev, pbm); break; + case PCIOCBARIO: + pbi = (struct pci_bar_ioreq *)data; + + pcidev = pci_find_dbsf(pbi->pbi_sel.pc_domain, + pbi->pbi_sel.pc_bus, pbi->pbi_sel.pc_dev, + pbi->pbi_sel.pc_func); + if (pcidev == NULL) { + error = ENODEV; + break; + } + error = pci_bar_io(pcidev, pbi); + break; + default: error = ENOTTY; break; diff --git a/sys/sys/pciio.h b/sys/sys/pciio.h index 50e9116d63d4..16635a884ca3 100644 --- a/sys/sys/pciio.h +++ b/sys/sys/pciio.h @@ -151,6 +151,17 @@ struct pci_bar_mmap { int pbm_memattr; }; +struct pci_bar_ioreq { + struct pcisel pbi_sel; /* device to operate on */ +#define PCIBARIO_READ 0x1 +#define PCIBARIO_WRITE 0x2 + int pbi_op; + uint32_t pbi_bar; + uint32_t pbi_offset; + uint32_t pbi_width; + uint32_t pbi_value; +}; + #define PCIIO_BAR_MMAP_FIXED 0x01 #define PCIIO_BAR_MMAP_EXCL 0x02 #define PCIIO_BAR_MMAP_RW 0x04 @@ -163,5 +174,6 @@ struct pci_bar_mmap { #define PCIOCGETBAR _IOWR('p', 6, struct pci_bar_io) #define PCIOCLISTVPD _IOWR('p', 7, struct pci_list_vpd_io) #define PCIOCBARMMAP _IOWR('p', 8, struct pci_bar_mmap) +#define PCIOCBARIO _IOWR('p', 9, struct pci_bar_ioreq) #endif /* !_SYS_PCIIO_H_ */ From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:00:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DFF7866E0B8; Sat, 14 Aug 2021 15:00: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 4Gn3X93MCxz3sZh; Sat, 14 Aug 2021 15:00: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 5B89624383; Sat, 14 Aug 2021 15:00: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 17EF0vp8002229; Sat, 14 Aug 2021 15:00:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EF0vAo002228; Sat, 14 Aug 2021 15:00:57 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:00:57 GMT Message-Id: <202108141500.17EF0vAo002228@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 42375556e5b2 - main - bhyve: Use pci(4) to access I/O port BARs 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/main X-Git-Reftype: branch X-Git-Commit: 42375556e5b2e68746d999b43d124040b6affb91 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 15:00:58 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=42375556e5b2e68746d999b43d124040b6affb91 commit 42375556e5b2e68746d999b43d124040b6affb91 Author: Mark Johnston AuthorDate: 2021-08-14 14:42:34 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 14:59:04 +0000 bhyve: Use pci(4) to access I/O port BARs This removes the dependency on /dev/io. PR: 251046 Reviewed by: jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31308 --- usr.sbin/bhyve/pci_passthru.c | 65 ++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index 9028369217d4..2c6a2ebd8dd9 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -69,10 +69,6 @@ __FBSDID("$FreeBSD$"); #define _PATH_DEVPCI "/dev/pci" #endif -#ifndef _PATH_DEVIO -#define _PATH_DEVIO "/dev/io" -#endif - #ifndef _PATH_MEM #define _PATH_MEM "/dev/mem" #endif @@ -83,7 +79,6 @@ __FBSDID("$FreeBSD$"); #define MSIX_CAPLEN 12 static int pcifd = -1; -static int iofd = -1; static int memfd = -1; struct passthru_softc { @@ -649,8 +644,8 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) const char *value; #ifndef WITHOUT_CAPSICUM cap_rights_t rights; - cap_ioctl_t pci_ioctls[] = { PCIOCREAD, PCIOCWRITE, PCIOCGETBAR }; - cap_ioctl_t io_ioctls[] = { IODEV_PIO }; + cap_ioctl_t pci_ioctls[] = + { PCIOCREAD, PCIOCWRITE, PCIOCGETBAR, PCIOCBARIO }; #endif sc = NULL; @@ -681,21 +676,6 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) errx(EX_OSERR, "Unable to apply rights for sandbox"); #endif - if (iofd < 0) { - iofd = open(_PATH_DEVIO, O_RDWR, 0); - if (iofd < 0) { - warn("failed to open %s", _PATH_DEVIO); - return (error); - } - } - -#ifndef WITHOUT_CAPSICUM - if (caph_rights_limit(iofd, &rights) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); - if (caph_ioctls_limit(iofd, io_ioctls, nitems(io_ioctls)) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); -#endif - if (memfd < 0) { memfd = open(_PATH_MEM, O_RDWR, 0); if (memfd < 0) { @@ -910,7 +890,7 @@ passthru_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size, uint64_t value) { struct passthru_softc *sc; - struct iodev_pio_req pio; + struct pci_bar_ioreq pio; sc = pi->pi_arg; @@ -918,13 +898,18 @@ passthru_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, msix_table_write(ctx, vcpu, sc, offset, size, value); } else { assert(pi->pi_bar[baridx].type == PCIBAR_IO); - bzero(&pio, sizeof(struct iodev_pio_req)); - pio.access = IODEV_PIO_WRITE; - pio.port = sc->psc_bar[baridx].addr + offset; - pio.width = size; - pio.val = value; - - (void)ioctl(iofd, IODEV_PIO, &pio); + assert(size == 1 || size == 2 || size == 4); + assert(offset <= UINT32_MAX && offset + size <= UINT32_MAX); + + bzero(&pio, sizeof(pio)); + pio.pbi_sel = sc->psc_sel; + pio.pbi_op = PCIBARIO_WRITE; + pio.pbi_bar = baridx; + pio.pbi_offset = (uint32_t)offset; + pio.pbi_width = size; + pio.pbi_value = (uint32_t)value; + + (void)ioctl(pcifd, PCIOCBARIO, &pio); } } @@ -933,7 +918,7 @@ passthru_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size) { struct passthru_softc *sc; - struct iodev_pio_req pio; + struct pci_bar_ioreq pio; uint64_t val; sc = pi->pi_arg; @@ -942,15 +927,19 @@ passthru_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, val = msix_table_read(sc, offset, size); } else { assert(pi->pi_bar[baridx].type == PCIBAR_IO); - bzero(&pio, sizeof(struct iodev_pio_req)); - pio.access = IODEV_PIO_READ; - pio.port = sc->psc_bar[baridx].addr + offset; - pio.width = size; - pio.val = 0; + assert(size == 1 || size == 2 || size == 4); + assert(offset <= UINT32_MAX && offset + size <= UINT32_MAX); + + bzero(&pio, sizeof(pio)); + pio.pbi_sel = sc->psc_sel; + pio.pbi_op = PCIBARIO_READ; + pio.pbi_bar = baridx; + pio.pbi_offset = (uint32_t)offset; + pio.pbi_width = size; - (void)ioctl(iofd, IODEV_PIO, &pio); + (void)ioctl(pcifd, PCIOCBARIO, &pio); - val = pio.val; + val = pio.pbi_value; } return (val); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:22:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34C5066E92B; Sat, 14 Aug 2021 15:22: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 4Gn40x0zKNz3wPT; Sat, 14 Aug 2021 15:22: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 0ABE5247F0; Sat, 14 Aug 2021 15:22: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 17EFMOAZ029564; Sat, 14 Aug 2021 15:22:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EFMOxm029563; Sat, 14 Aug 2021 15:22:24 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:22:24 GMT Message-Id: <202108141522.17EFMOxm029563@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: bfa812f5407b - main - rtsold: auto-probe point to point interfaces 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/main X-Git-Reftype: branch X-Git-Commit: bfa812f5407bddac2bcced290a09bd3e686e354a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 15:22:25 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=bfa812f5407bddac2bcced290a09bd3e686e354a commit bfa812f5407bddac2bcced290a09bd3e686e354a Author: Franco Fitchner AuthorDate: 2021-08-14 15:08:07 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 15:14:24 +0000 rtsold: auto-probe point to point interfaces rtsold works fine for point to point interfaces in manual mode but will not auto-probe them. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31517 --- usr.sbin/rtsold/rtsold.8 | 4 ++-- usr.sbin/rtsold/rtsold.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8 index e30a07f3a3fe..273a2b4f0dd8 100644 --- a/usr.sbin/rtsold/rtsold.8 +++ b/usr.sbin/rtsold/rtsold.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 19, 2020 +.Dd August 14, 2021 .Dt RTSOLD 8 .Os .\" @@ -167,7 +167,7 @@ The options are as follows: .It Fl a Autoprobe outgoing interfaces. .Nm -will try to find any non-loopback, non-point-to-point, IPv6-capable interfaces +will try to find any non-loopback, IPv6-capable interfaces and send router solicitation messages on all of them. .It Fl d Enable debugging. diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index c1594ec7420a..592321f59aca 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -843,8 +843,6 @@ autoifprobe(void) for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if ((ifa->ifa_flags & IFF_UP) == 0) continue; - if ((ifa->ifa_flags & IFF_POINTOPOINT) != 0) - continue; if ((ifa->ifa_flags & IFF_LOOPBACK) != 0) continue; if ((ifa->ifa_flags & IFF_MULTICAST) == 0) From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:22:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 978C266EA13; Sat, 14 Aug 2021 15:22: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 4Gn40y2sFmz3wPV; Sat, 14 Aug 2021 15:22: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 2DD2E24A04; Sat, 14 Aug 2021 15:22: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 17EFMQ5s029588; Sat, 14 Aug 2021 15:22:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EFMQ9F029587; Sat, 14 Aug 2021 15:22:26 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:22:26 GMT Message-Id: <202108141522.17EFMQ9F029587@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 02508a3d4e17 - main - rtsold: pass sending router address to other and managed script 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/main X-Git-Reftype: branch X-Git-Commit: 02508a3d4e178b431fe5dda354a56d883f976c02 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 15:22:26 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=02508a3d4e178b431fe5dda354a56d883f976c02 commit 02508a3d4e178b431fe5dda354a56d883f976c02 Author: Franco Fitchner AuthorDate: 2021-08-14 15:10:21 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 15:14:24 +0000 rtsold: pass sending router address to other and managed script Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31518 --- usr.sbin/rtsold/rtsol.c | 8 ++++++-- usr.sbin/rtsold/rtsold.8 | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c index 76756bfd8393..646dd092cb0c 100644 --- a/usr.sbin/rtsold/rtsol.c +++ b/usr.sbin/rtsold/rtsol.c @@ -79,8 +79,8 @@ static int ra_opt_rdnss_dispatch(struct ifinfo *, struct rainfo *, struct script_msg_head_t *, struct script_msg_head_t *); static char *make_rsid(const char *, const char *, struct rainfo *); -#define _ARGS_MANAGED managedconf_script, ifi->ifname -#define _ARGS_OTHER otherconf_script, ifi->ifname +#define _ARGS_MANAGED managedconf_script, ifi->ifname, rasender +#define _ARGS_OTHER otherconf_script, ifi->ifname, rasender #define _ARGS_RESADD resolvconf_script, "-a", rsid #define _ARGS_RESDEL resolvconf_script, "-d", rsid @@ -301,6 +301,8 @@ rtsol_input(int sock) */ if (((nd_ra->nd_ra_flags_reserved) & ND_RA_FLAG_MANAGED) && !ifi->managedconfig) { + const char *rasender = inet_ntop(AF_INET6, &from.sin6_addr, + ntopbuf, sizeof(ntopbuf)); warnmsg(LOG_DEBUG, __func__, "ManagedConfigFlag on %s is turned on", ifi->ifname); ifi->managedconfig = 1; @@ -317,6 +319,8 @@ rtsol_input(int sock) */ if (((nd_ra->nd_ra_flags_reserved) & ND_RA_FLAG_OTHER) && !ifi->otherconfig) { + const char *rasender = inet_ntop(AF_INET6, &from.sin6_addr, + ntopbuf, sizeof(ntopbuf)); warnmsg(LOG_DEBUG, __func__, "OtherConfigFlag on %s is turned on", ifi->ifname); ifi->otherconfig = 1; diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8 index 273a2b4f0dd8..84e4d3013ef4 100644 --- a/usr.sbin/rtsold/rtsold.8 +++ b/usr.sbin/rtsold/rtsold.8 @@ -219,7 +219,8 @@ When the flag changes from FALSE to TRUE, .Nm will invoke .Ar script-name -with a single argument of the receiving interface name, +with a first argument of the receiving interface name +and a second argument of the sending router address, expecting the script will then start a protocol for the managed configuration. .Ar script-name @@ -233,7 +234,8 @@ When the flag changes from FALSE to TRUE, .Nm will invoke .Ar script-name -with a single argument of the receiving interface name, +with a first argument of the receiving interface name +and a second argument of the sending router address, expecting the script will then start a protocol for the other configuration. The script will not be run if the Managed Configuration flag in the From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:22:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 072EB66E83F; Sat, 14 Aug 2021 15:22: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 4Gn40z3kGGz4Qtm; Sat, 14 Aug 2021 15:22: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 51C7524A05; Sat, 14 Aug 2021 15:22: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 17EFMRV8029614; Sat, 14 Aug 2021 15:22:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EFMR7d029613; Sat, 14 Aug 2021 15:22:27 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:22:27 GMT Message-Id: <202108141522.17EFMR7d029613@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 7e11889959a6 - main - tail: Fix -f with stdin 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/main X-Git-Reftype: branch X-Git-Commit: 7e11889959a6c92f05e1c1949deb73295ce60bac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 15:22:28 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7e11889959a6c92f05e1c1949deb73295ce60bac commit 7e11889959a6c92f05e1c1949deb73295ce60bac Author: Mark Johnston AuthorDate: 2021-07-08 21:40:59 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 15:19:32 +0000 tail: Fix -f with stdin Based on a patch from swills@. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31113 --- usr.bin/tail/extern.h | 2 +- usr.bin/tail/tail.c | 43 ++++++++++++++++++++----------------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h index 65ddb519dc61..3d8c12629682 100644 --- a/usr.bin/tail/extern.h +++ b/usr.bin/tail/extern.h @@ -56,7 +56,7 @@ struct mapinfo { struct file_info { FILE *fp; - char *file_name; + const char *file_name; struct stat st; }; diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c index b52043c5e580..874557f105ec 100644 --- a/usr.bin/tail/tail.c +++ b/usr.bin/tail/tail.c @@ -67,8 +67,6 @@ static const char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93"; int Fflag, fflag, qflag, rflag, rval, no_files; fileargs_t *fa; -static file_info_t *files; - static void obsolete(char **); static void usage(void); @@ -88,8 +86,8 @@ main(int argc, char *argv[]) FILE *fp; off_t off; enum STYLE style; - int i, ch, first; - file_info_t *file; + int ch, first; + file_info_t file, *filep, *files; char *p; cap_rights_t rights; @@ -206,30 +204,24 @@ main(int argc, char *argv[]) } if (*argv && fflag) { - files = (struct file_info *) malloc(no_files * - sizeof(struct file_info)); - if (!files) + files = malloc(no_files * sizeof(struct file_info)); + if (files == NULL) err(1, "Couldn't malloc space for file descriptors."); - for (file = files; (fn = *argv++); file++) { - file->file_name = strdup(fn); - if (! file->file_name) - errx(1, "Couldn't malloc space for file name."); - file->fp = fileargs_fopen(fa, file->file_name, "r"); - if (file->fp == NULL || - fstat(fileno(file->fp), &file->st)) { - if (file->fp != NULL) { - fclose(file->fp); - file->fp = NULL; + for (filep = files; (fn = *argv++); filep++) { + filep->file_name = fn; + filep->fp = fileargs_fopen(fa, filep->file_name, "r"); + if (filep->fp == NULL || + fstat(fileno(filep->fp), &filep->st)) { + if (filep->fp != NULL) { + fclose(filep->fp); + filep->fp = NULL; } if (!Fflag || errno != ENOENT) - ierr(file->file_name); + ierr(filep->file_name); } } follow(files, style, off); - for (i = 0, file = files; i < no_files; i++, file++) { - free(file->file_name); - } free(files); } else if (*argv) { for (first = 1; (fn = *argv++);) { @@ -266,10 +258,15 @@ main(int argc, char *argv[]) fflag = 0; /* POSIX.2 requires this. */ } - if (rflag) + if (rflag) { reverse(stdin, fn, style, off, &sb); - else + } else if (fflag) { + file.file_name = fn; + file.fp = stdin; + follow(&file, style, off); + } else { forward(stdin, fn, style, off, &sb); + } } fileargs_free(fa); exit(rval); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:22:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6180766EAA8; Sat, 14 Aug 2021 15: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 4Gn4104G7Hz3wQq; Sat, 14 Aug 2021 15:22: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 712B524991; Sat, 14 Aug 2021 15:22: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 17EFMSA4029643; Sat, 14 Aug 2021 15:22:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EFMSpt029642; Sat, 14 Aug 2021 15:22:28 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:22:28 GMT Message-Id: <202108141522.17EFMSpt029642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 58b1a126b98f - main - tail: Add regression tests for -f and -F 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/main X-Git-Reftype: branch X-Git-Commit: 58b1a126b98f9d64f30246c90d6c049fd78dda6b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 15:22:29 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=58b1a126b98f9d64f30246c90d6c049fd78dda6b commit 58b1a126b98f9d64f30246c90d6c049fd78dda6b Author: Mark Johnston AuthorDate: 2021-07-05 15:01:41 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 15:19:42 +0000 tail: Add regression tests for -f and -F MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31055 --- usr.bin/tail/tests/tail_test.sh | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/usr.bin/tail/tests/tail_test.sh b/usr.bin/tail/tests/tail_test.sh index 9eecf460d1e5..66d435f2cd02 100755 --- a/usr.bin/tail/tests/tail_test.sh +++ b/usr.bin/tail/tests/tail_test.sh @@ -272,6 +272,85 @@ broken_pipe_body() -x '(tail -n 856 ints; echo exit code: $? >&2) | sleep 2' } +atf_test_case stdin +stdin_head() +{ + atf_set "descr" "Check basic operations on standard input" +} +stdin_body() +{ + seq 1 5 > infile + seq 1 5 > expectfile + seq 5 1 > expectfile_r + + tail < infile > outfile + tail -r < infile > outfile_r + + atf_check cmp expectfile outfile + atf_check cmp expectfile_r outfile_r +} + +atf_test_case follow +follow_head() +{ + atf_set "descr" "Basic regression test for -f" +} +follow_body() +{ + local pid + + seq 1 5 > expectfile + seq 1 3 > infile + tail -f infile > outfile & + pid=$! + sleep 0.1 + seq 4 5 >> infile + sleep 0.1 + atf_check cmp expectfile outfile + atf_check kill $pid +} + +atf_test_case follow_stdin +follow_stdin_head() +{ + atf_set "descr" "Verify that -f works with files piped to standard input" +} +follow_stdin_body() +{ + local pid + + seq 1 5 > expectfile + seq 1 3 > infile + tail -f < infile > outfile & + pid=$! + sleep 0.1 + seq 4 5 >> infile + sleep 0.1 + atf_check cmp expectfile outfile + atf_check kill $pid +} + +atf_test_case follow_rename +follow_rename_head() +{ + atf_set "descr" "Verify that -F works" +} +follow_rename_body() +{ + local pid + + seq 1 5 > expectfile + seq 1 3 > infile + tail -F infile > outfile & + pid=$! + seq 4 5 > infile_new + atf_check mv infile infile_old + atf_check mv infile_new infile + # tail -F polls for a new file every 1s. + sleep 2 + atf_check cmp expectfile outfile + atf_check kill $pid +} atf_init_test_cases() { @@ -289,4 +368,8 @@ atf_init_test_cases() atf_add_test_case longfile_rc145782_longlines atf_add_test_case longfile_rn2500 atf_add_test_case broken_pipe + atf_add_test_case stdin + atf_add_test_case follow + atf_add_test_case follow_stdin + atf_add_test_case follow_rename } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 15:54:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 96F3A66EEBF; Sat, 14 Aug 2021 15:54: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 4Gn4k93kMNz4SG4; Sat, 14 Aug 2021 15:54: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 6755C24F36; Sat, 14 Aug 2021 15:54: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 17EFsfCH071588; Sat, 14 Aug 2021 15:54:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EFsf21071587; Sat, 14 Aug 2021 15:54:41 GMT (envelope-from git) Date: Sat, 14 Aug 2021 15:54:41 GMT Message-Id: <202108141554.17EFsf21071587@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 20d728b55917 - main - rpc: Make function tables const 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/main X-Git-Reftype: branch X-Git-Commit: 20d728b559178577869e50c7e3c1bf0ad24a750c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 15:54:41 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=20d728b559178577869e50c7e3c1bf0ad24a750c commit 20d728b559178577869e50c7e3c1bf0ad24a750c Author: Mark Johnston AuthorDate: 2021-07-09 14:56:13 +0000 Commit: Mark Johnston CommitDate: 2021-08-14 15:26:12 +0000 rpc: Make function tables const No functional change intended. MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/rpc/auth.h | 2 +- sys/rpc/auth_none.c | 2 +- sys/rpc/auth_unix.c | 2 +- sys/rpc/clnt.h | 2 +- sys/rpc/clnt_bck.c | 2 +- sys/rpc/clnt_dg.c | 2 +- sys/rpc/clnt_rc.c | 2 +- sys/rpc/clnt_vc.c | 2 +- sys/rpc/rpcsec_gss/rpcsec_gss.c | 2 +- sys/rpc/rpcsec_gss/svc_rpcsec_gss.c | 8 ++++---- sys/rpc/rpcsec_tls/auth_tls.c | 2 +- sys/rpc/svc.h | 2 +- sys/rpc/svc_auth.c | 10 +++++----- sys/rpc/svc_dg.c | 2 +- sys/rpc/svc_vc.c | 6 +++--- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/sys/rpc/auth.h b/sys/rpc/auth.h index fd56b33da52e..5444f6180c5e 100644 --- a/sys/rpc/auth.h +++ b/sys/rpc/auth.h @@ -189,7 +189,7 @@ typedef struct __auth { struct opaque_auth ah_cred; struct opaque_auth ah_verf; union des_block ah_key; - struct auth_ops { + const struct auth_ops { void (*ah_nextverf) (struct __auth *); /* nextverf & serialize */ int (*ah_marshal) (struct __auth *, uint32_t, XDR *, diff --git a/sys/rpc/auth_none.c b/sys/rpc/auth_none.c index 236b4aa166ae..91597114c069 100644 --- a/sys/rpc/auth_none.c +++ b/sys/rpc/auth_none.c @@ -70,7 +70,7 @@ static bool_t authnone_validate (AUTH *, uint32_t, struct opaque_auth *, static bool_t authnone_refresh (AUTH *, void *); static void authnone_destroy (AUTH *); -static struct auth_ops authnone_ops = { +static const struct auth_ops authnone_ops = { .ah_nextverf = authnone_verf, .ah_marshal = authnone_marshal, .ah_validate = authnone_validate, diff --git a/sys/rpc/auth_unix.c b/sys/rpc/auth_unix.c index 4a3df5f70e3a..be0a241baa36 100644 --- a/sys/rpc/auth_unix.c +++ b/sys/rpc/auth_unix.c @@ -76,7 +76,7 @@ static bool_t authunix_refresh (AUTH *, void *); static void authunix_destroy (AUTH *); static void marshal_new_auth (AUTH *); -static struct auth_ops authunix_ops = { +static const struct auth_ops authunix_ops = { .ah_nextverf = authunix_nextverf, .ah_marshal = authunix_marshal, .ah_validate = authunix_validate, diff --git a/sys/rpc/clnt.h b/sys/rpc/clnt.h index 6f8f898ca918..a968c8f930fc 100644 --- a/sys/rpc/clnt.h +++ b/sys/rpc/clnt.h @@ -132,7 +132,7 @@ typedef struct __rpc_client { #ifdef _KERNEL volatile u_int cl_refs; /* reference count */ AUTH *cl_auth; /* authenticator */ - struct clnt_ops { + const struct clnt_ops { /* call remote procedure */ enum clnt_stat (*cl_call)(struct __rpc_client *, struct rpc_callextra *, rpcproc_t, diff --git a/sys/rpc/clnt_bck.c b/sys/rpc/clnt_bck.c index 2414171bad37..514905bf1cc2 100644 --- a/sys/rpc/clnt_bck.c +++ b/sys/rpc/clnt_bck.c @@ -101,7 +101,7 @@ static bool_t clnt_bck_control(CLIENT *, u_int, void *); static void clnt_bck_close(CLIENT *); static void clnt_bck_destroy(CLIENT *); -static struct clnt_ops clnt_bck_ops = { +static const struct clnt_ops clnt_bck_ops = { .cl_abort = clnt_bck_abort, .cl_geterr = clnt_bck_geterr, .cl_freeres = clnt_bck_freeres, diff --git a/sys/rpc/clnt_dg.c b/sys/rpc/clnt_dg.c index 3a3662a02a39..63a26cc0b9ac 100644 --- a/sys/rpc/clnt_dg.c +++ b/sys/rpc/clnt_dg.c @@ -84,7 +84,7 @@ static void clnt_dg_close(CLIENT *); static void clnt_dg_destroy(CLIENT *); static int clnt_dg_soupcall(struct socket *so, void *arg, int waitflag); -static struct clnt_ops clnt_dg_ops = { +static const struct clnt_ops clnt_dg_ops = { .cl_call = clnt_dg_call, .cl_abort = clnt_dg_abort, .cl_geterr = clnt_dg_geterr, diff --git a/sys/rpc/clnt_rc.c b/sys/rpc/clnt_rc.c index ae3b2985a891..aa69356b8cd2 100644 --- a/sys/rpc/clnt_rc.c +++ b/sys/rpc/clnt_rc.c @@ -59,7 +59,7 @@ static bool_t clnt_reconnect_control(CLIENT *, u_int, void *); static void clnt_reconnect_close(CLIENT *); static void clnt_reconnect_destroy(CLIENT *); -static struct clnt_ops clnt_reconnect_ops = { +static const struct clnt_ops clnt_reconnect_ops = { .cl_call = clnt_reconnect_call, .cl_abort = clnt_reconnect_abort, .cl_geterr = clnt_reconnect_geterr, diff --git a/sys/rpc/clnt_vc.c b/sys/rpc/clnt_vc.c index 92c216e227d1..7d22c670b017 100644 --- a/sys/rpc/clnt_vc.c +++ b/sys/rpc/clnt_vc.c @@ -104,7 +104,7 @@ static bool_t time_not_ok(struct timeval *); static int clnt_vc_soupcall(struct socket *so, void *arg, int waitflag); static void clnt_vc_dotlsupcall(void *data); -static struct clnt_ops clnt_vc_ops = { +static const struct clnt_ops clnt_vc_ops = { .cl_call = clnt_vc_call, .cl_abort = clnt_vc_abort, .cl_geterr = clnt_vc_geterr, diff --git a/sys/rpc/rpcsec_gss/rpcsec_gss.c b/sys/rpc/rpcsec_gss/rpcsec_gss.c index b384a8347ef5..32121be21091 100644 --- a/sys/rpc/rpcsec_gss/rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/rpcsec_gss.c @@ -97,7 +97,7 @@ static bool_t rpc_gss_validate(AUTH *, uint32_t, struct opaque_auth *, static void rpc_gss_destroy(AUTH *); static void rpc_gss_destroy_context(AUTH *, bool_t); -static struct auth_ops rpc_gss_ops = { +static const struct auth_ops rpc_gss_ops = { .ah_nextverf = rpc_gss_nextverf, .ah_marshal = rpc_gss_marshal, .ah_validate = rpc_gss_validate, diff --git a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c index 36ab8c5bcf87..c9a09438d907 100644 --- a/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c +++ b/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c @@ -90,10 +90,10 @@ static void svc_rpc_gss_release(SVCAUTH *); static enum auth_stat svc_rpc_gss(struct svc_req *, struct rpc_msg *); static int rpc_gss_svc_getcred(struct svc_req *, struct ucred **, int *); -static struct svc_auth_ops svc_auth_gss_ops = { - svc_rpc_gss_wrap, - svc_rpc_gss_unwrap, - svc_rpc_gss_release, +static const struct svc_auth_ops svc_auth_gss_ops = { + .svc_ah_wrap = svc_rpc_gss_wrap, + .svc_ah_unwrap = svc_rpc_gss_unwrap, + .svc_ah_release = svc_rpc_gss_release, }; struct sx svc_rpc_gss_lock; diff --git a/sys/rpc/rpcsec_tls/auth_tls.c b/sys/rpc/rpcsec_tls/auth_tls.c index bd23784f5ebf..9afde553283e 100644 --- a/sys/rpc/rpcsec_tls/auth_tls.c +++ b/sys/rpc/rpcsec_tls/auth_tls.c @@ -70,7 +70,7 @@ static bool_t authtls_validate (AUTH *, uint32_t, struct opaque_auth *, static bool_t authtls_refresh (AUTH *, void *); static void authtls_destroy (AUTH *); -static struct auth_ops authtls_ops = { +static const struct auth_ops authtls_ops = { .ah_nextverf = authtls_verf, .ah_marshal = authtls_marshal, .ah_validate = authtls_validate, diff --git a/sys/rpc/svc.h b/sys/rpc/svc.h index 8a94d7058972..d92fa6953891 100644 --- a/sys/rpc/svc.h +++ b/sys/rpc/svc.h @@ -212,7 +212,7 @@ typedef struct __rpc_svcxprt { * Interface to server-side authentication flavors. */ typedef struct __rpc_svcauth { - struct svc_auth_ops { + const struct svc_auth_ops { #ifdef _KERNEL int (*svc_ah_wrap)(struct __rpc_svcauth *, struct mbuf **); int (*svc_ah_unwrap)(struct __rpc_svcauth *, struct mbuf **); diff --git a/sys/rpc/svc_auth.c b/sys/rpc/svc_auth.c index 0c5a68688d48..75d1f21d3484 100644 --- a/sys/rpc/svc_auth.c +++ b/sys/rpc/svc_auth.c @@ -60,7 +60,7 @@ static enum auth_stat (*_svcauth_rpcsec_gss)(struct svc_req *, static int (*_svcauth_rpcsec_gss_getcred)(struct svc_req *, struct ucred **, int *); -static struct svc_auth_ops svc_auth_null_ops; +static const struct svc_auth_ops svc_auth_null_ops; /* * The call rpc message, msg has been obtained from the wire. The msg contains @@ -145,10 +145,10 @@ svcauth_null_release(SVCAUTH *auth) } -static struct svc_auth_ops svc_auth_null_ops = { - svcauth_null_wrap, - svcauth_null_unwrap, - svcauth_null_release, +static const struct svc_auth_ops svc_auth_null_ops = { + .svc_ah_wrap = svcauth_null_wrap, + .svc_ah_unwrap = svcauth_null_unwrap, + .svc_ah_release = svcauth_null_release, }; /*ARGSUSED*/ diff --git a/sys/rpc/svc_dg.c b/sys/rpc/svc_dg.c index 2bdd0700c044..db1928655618 100644 --- a/sys/rpc/svc_dg.c +++ b/sys/rpc/svc_dg.c @@ -73,7 +73,7 @@ static void svc_dg_destroy(SVCXPRT *); static bool_t svc_dg_control(SVCXPRT *, const u_int, void *); static int svc_dg_soupcall(struct socket *so, void *arg, int waitflag); -static struct xp_ops svc_dg_ops = { +static const struct xp_ops svc_dg_ops = { .xp_recv = svc_dg_recv, .xp_stat = svc_dg_stat, .xp_reply = svc_dg_reply, diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c index 234feba5c8bd..d81c0b01d84d 100644 --- a/sys/rpc/svc_vc.c +++ b/sys/rpc/svc_vc.c @@ -105,7 +105,7 @@ static int svc_vc_accept(struct socket *head, struct socket **sop); static int svc_vc_soupcall(struct socket *so, void *arg, int waitflag); static int svc_vc_rendezvous_soupcall(struct socket *, void *, int); -static struct xp_ops svc_vc_rendezvous_ops = { +static const struct xp_ops svc_vc_rendezvous_ops = { .xp_recv = svc_vc_rendezvous_recv, .xp_stat = svc_vc_rendezvous_stat, .xp_reply = (bool_t (*)(SVCXPRT *, struct rpc_msg *, @@ -114,7 +114,7 @@ static struct xp_ops svc_vc_rendezvous_ops = { .xp_control = svc_vc_rendezvous_control }; -static struct xp_ops svc_vc_ops = { +static const struct xp_ops svc_vc_ops = { .xp_recv = svc_vc_recv, .xp_stat = svc_vc_stat, .xp_ack = svc_vc_ack, @@ -123,7 +123,7 @@ static struct xp_ops svc_vc_ops = { .xp_control = svc_vc_control }; -static struct xp_ops svc_vc_backchannel_ops = { +static const struct xp_ops svc_vc_backchannel_ops = { .xp_recv = svc_vc_backchannel_recv, .xp_stat = svc_vc_backchannel_stat, .xp_reply = svc_vc_backchannel_reply, From owner-dev-commits-src-all@freebsd.org Sat Aug 14 16:52:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F0E865010C; Sat, 14 Aug 2021 16:52:01 +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 4Gn60K1Bvcz4WKK; Sat, 14 Aug 2021 16:52: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 1160925AB6; Sat, 14 Aug 2021 16:52: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 17EGq02p049011; Sat, 14 Aug 2021 16:52:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EGq0hh049010; Sat, 14 Aug 2021 16:52:00 GMT (envelope-from git) Date: Sat, 14 Aug 2021 16:52:00 GMT Message-Id: <202108141652.17EGq0hh049010@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: d2b95af1c27e - main - ip_reass: drop the volatile keyword from nfrags and mark with __exclusive_cache_line 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/main X-Git-Reftype: branch X-Git-Commit: d2b95af1c27ed51d72bef5d9f3d89860edc4fd40 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 16:52:01 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=d2b95af1c27ed51d72bef5d9f3d89860edc4fd40 commit d2b95af1c27ed51d72bef5d9f3d89860edc4fd40 Author: Mateusz Guzik AuthorDate: 2021-08-13 09:29:57 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-14 16:49:30 +0000 ip_reass: drop the volatile keyword from nfrags and mark with __exclusive_cache_line The keyword adds nothing as all operations on the var are performed through atomic_* Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31526 --- sys/netinet/ip_reass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/ip_reass.c b/sys/netinet/ip_reass.c index f5cc6ad68125..8a071345677a 100644 --- a/sys/netinet/ip_reass.c +++ b/sys/netinet/ip_reass.c @@ -137,12 +137,12 @@ ipq_drop(struct ipqbucket *bucket, struct ipq *fp) #define IP_MAXFRAGPACKETS (imin(IP_MAXFRAGS, IPREASS_NHASH * 50)) static int maxfrags; -static volatile u_int nfrags; +static u_int __exclusive_cache_line nfrags; SYSCTL_INT(_net_inet_ip, OID_AUTO, maxfrags, CTLFLAG_RW, &maxfrags, 0, "Maximum number of IPv4 fragments allowed across all reassembly queues"); SYSCTL_UINT(_net_inet_ip, OID_AUTO, curfrags, CTLFLAG_RD, - __DEVOLATILE(u_int *, &nfrags), 0, + &nfrags, 0, "Current number of IPv4 fragments across all reassembly queues"); VNET_DEFINE_STATIC(uma_zone_t, ipq_zone); From owner-dev-commits-src-all@freebsd.org Sat Aug 14 16:52:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54C4D66F875; Sat, 14 Aug 2021 16:52: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 4Gn60L1rYwz4WNZ; Sat, 14 Aug 2021 16:52: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 22D4E25979; Sat, 14 Aug 2021 16:52: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 17EGq2DB049037; Sat, 14 Aug 2021 16:52:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EGq2sc049035; Sat, 14 Aug 2021 16:52:02 GMT (envelope-from git) Date: Sat, 14 Aug 2021 16:52:02 GMT Message-Id: <202108141652.17EGq2sc049035@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 3be3cbe06d61 - main - ip_reass: do less work in ipreass_slowtimo if possible 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/main X-Git-Reftype: branch X-Git-Commit: 3be3cbe06d6107486d67d8eb80480d34d084c39c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 16:52:02 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=3be3cbe06d6107486d67d8eb80480d34d084c39c commit 3be3cbe06d6107486d67d8eb80480d34d084c39c Author: Mateusz Guzik AuthorDate: 2021-08-13 09:32:16 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-14 16:50:12 +0000 ip_reass: do less work in ipreass_slowtimo if possible ipreass_slowtimo avoidably uses CPU on otherwise idle boxes Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31526 --- sys/netinet/ip_reass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/netinet/ip_reass.c b/sys/netinet/ip_reass.c index 8a071345677a..db32e6a312f2 100644 --- a/sys/netinet/ip_reass.c +++ b/sys/netinet/ip_reass.c @@ -593,11 +593,16 @@ ipreass_slowtimo(void) { struct ipq *fp, *tmp; + if (atomic_load_int(&nfrags) == 0) + return; + for (int i = 0; i < IPREASS_NHASH; i++) { + if (TAILQ_EMPTY(&V_ipq[i].head)) + continue; IPQ_LOCK(i); TAILQ_FOREACH_SAFE(fp, &V_ipq[i].head, ipq_list, tmp) if (--fp->ipq_ttl == 0) - ipq_timeout(&V_ipq[i], fp); + ipq_timeout(&V_ipq[i], fp); IPQ_UNLOCK(i); } } From owner-dev-commits-src-all@freebsd.org Sat Aug 14 16:52:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A637466FDA5; Sat, 14 Aug 2021 16:52: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 4Gn60M3fCDz4WTH; Sat, 14 Aug 2021 16:52: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 5A2FE25B25; Sat, 14 Aug 2021 16:52: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 17EGq3R1049066; Sat, 14 Aug 2021 16:52:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EGq3iV049065; Sat, 14 Aug 2021 16:52:03 GMT (envelope-from git) Date: Sat, 14 Aug 2021 16:52:03 GMT Message-Id: <202108141652.17EGq3iV049065@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: c17ae18080b4 - main - frag6: drop the volatile keyword from frag6_nfrags and mark with __exclusive_cache_line 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/main X-Git-Reftype: branch X-Git-Commit: c17ae18080b4412435aa2fb91cd6e81dd6cd180b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 16:52:03 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=c17ae18080b4412435aa2fb91cd6e81dd6cd180b commit c17ae18080b4412435aa2fb91cd6e81dd6cd180b Author: Mateusz Guzik AuthorDate: 2021-08-13 11:28:39 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-14 16:50:29 +0000 frag6: drop the volatile keyword from frag6_nfrags and mark with __exclusive_cache_line The keyword adds nothing as all operations on the var are performed through atomic_* Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31528 --- sys/netinet6/frag6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index 1903b01e03d4..ec35e98d25ec 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -116,7 +116,7 @@ VNET_DEFINE_STATIC(bool, frag6_on); /* System wide (global) maximum and count of packets in reassembly queues. */ static int ip6_maxfrags; -static volatile u_int frag6_nfrags = 0; +static u_int __exclusive_cache_line frag6_nfrags; /* Maximum and current packets in per-VNET reassembly queue. */ VNET_DEFINE_STATIC(int, ip6_maxfragpackets); @@ -164,7 +164,7 @@ VNET_DEFINE_STATIC(uint32_t, ip6qb_hashseed); SYSCTL_DECL(_net_inet6_ip6); SYSCTL_UINT(_net_inet6_ip6, OID_AUTO, frag6_nfrags, - CTLFLAG_RD, __DEVOLATILE(u_int *, &frag6_nfrags), 0, + CTLFLAG_RD, &frag6_nfrags, 0, "Global number of IPv6 fragments across all reassembly queues."); static void From owner-dev-commits-src-all@freebsd.org Sat Aug 14 16:52:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2860566FCFB; Sat, 14 Aug 2021 16:52: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 4Gn60N4cx4z4WNq; Sat, 14 Aug 2021 16:52: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 6FBDE25B26; Sat, 14 Aug 2021 16:52: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 17EGq4Fs049090; Sat, 14 Aug 2021 16:52:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17EGq44O049089; Sat, 14 Aug 2021 16:52:04 GMT (envelope-from git) Date: Sat, 14 Aug 2021 16:52:04 GMT Message-Id: <202108141652.17EGq44O049089@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 8afe9481cfa3 - main - frag6: do less work in frag6_slowtimo if possible 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/main X-Git-Reftype: branch X-Git-Commit: 8afe9481cfa382337b8a885f358fe888bddf5982 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 16:52:05 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8afe9481cfa382337b8a885f358fe888bddf5982 commit 8afe9481cfa382337b8a885f358fe888bddf5982 Author: Mateusz Guzik AuthorDate: 2021-08-13 11:32:03 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-14 16:51:00 +0000 frag6: do less work in frag6_slowtimo if possible frag6_slowtimo avoidably uses CPU on otherwise idle boxes Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31528 --- sys/netinet6/frag6.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index ec35e98d25ec..222bd157fddd 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -891,10 +891,15 @@ frag6_slowtimo(void) struct ip6q *q6, *q6tmp; uint32_t bucket; + if (atomic_load_int(&frag6_nfrags) == 0) + return; + VNET_LIST_RLOCK_NOSLEEP(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) { + if (V_ip6qb[bucket].count == 0) + continue; IP6QB_LOCK(bucket); head = IP6QB_HEAD(bucket); TAILQ_FOREACH_SAFE(q6, head, ip6q_tq, q6tmp) From owner-dev-commits-src-all@freebsd.org Sun Aug 15 05:56:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 64D8B65A82A; Sun, 15 Aug 2021 05:56: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 4GnRPJ70HPz4c6T; Sun, 15 Aug 2021 05:56: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 D8FFB10EBB; Sun, 15 Aug 2021 05:56: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 17F5uK9B090790; Sun, 15 Aug 2021 05:56:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17F5uKqj090789; Sun, 15 Aug 2021 05:56:20 GMT (envelope-from git) Date: Sun, 15 Aug 2021 05:56:20 GMT Message-Id: <202108150556.17F5uKqj090789@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: 64085efb677f - stable/13 - hms(4): Fix a typo in sysctl description 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: 64085efb677fbfcf76235a1a9dcb497819e2b72f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 05:56:21 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=64085efb677fbfcf76235a1a9dcb497819e2b72f commit 64085efb677fbfcf76235a1a9dcb497819e2b72f Author: Gordon Bergling AuthorDate: 2021-08-12 13:37:47 +0000 Commit: Gordon Bergling CommitDate: 2021-08-15 05:56:02 +0000 hms(4): Fix a typo in sysctl description - s/threshhold/threshold/ (cherry picked from commit 4b4850aefe3ff9d9c29c7ed8bd8907bbd6142e86) --- sys/dev/hid/hms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/hid/hms.c b/sys/dev/hid/hms.c index 94267b3fcd52..014354c3acc3 100644 --- a/sys/dev/hid/hms.c +++ b/sys/dev/hid/hms.c @@ -271,7 +271,7 @@ hms_attach(device_t dev) SYSCTL_ADD_U32(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "drift_thresh", CTLFLAG_RW, &sc->drift_thresh, 0, - "drift detection threshhold"); + "drift detection threshold"); } #endif From owner-dev-commits-src-all@freebsd.org Sun Aug 15 09:12:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4351D65D5BE; Sun, 15 Aug 2021 09:12: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 4GnWl617x8z4mRw; Sun, 15 Aug 2021 09:12: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 0FE24139B9; Sun, 15 Aug 2021 09:12: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 17F9C24H058552; Sun, 15 Aug 2021 09:12:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17F9C1Ye058492; Sun, 15 Aug 2021 09:12:01 GMT (envelope-from git) Date: Sun, 15 Aug 2021 09:12:01 GMT Message-Id: <202108150912.17F9C1Ye058492@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Peter Grehan Subject: git: d7388d33b4dd - stable/13 - MFC 517904de5cca: igc(4): Introduce new driver for the Intel I225 Ethernet controller. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: grehan X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d7388d33b4ddffb8900b511ae767875916dd5126 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 09:12:02 -0000 The branch stable/13 has been updated by grehan: URL: https://cgit.FreeBSD.org/src/commit/?id=d7388d33b4ddffb8900b511ae767875916dd5126 commit d7388d33b4ddffb8900b511ae767875916dd5126 Author: Peter Grehan AuthorDate: 2021-07-12 04:50:15 +0000 Commit: Peter Grehan CommitDate: 2021-08-15 10:33:54 +0000 MFC 517904de5cca: igc(4): Introduce new driver for the Intel I225 Ethernet controller. This controller supports 2.5G/1G/100MB/10MB speeds, and allows tx/rx checksum offload, TSO, LRO, and multi-queue operation. The driver was derived from code contributed by Intel, and modified by Netgate to fit into the iflib framework. Thanks to Mike Karels for testing and feedback on the driver. Reviewed by: bcr (manpages), kbowling, scottl, erj Relnotes: yes Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30668 (cherry picked from commit 517904de5ccac643589c71ac0d2751797f89e4f9) --- share/man/man4/Makefile | 2 + share/man/man4/igc.4 | 167 +++ sys/amd64/conf/GENERIC | 1 + sys/amd64/conf/NOTES | 2 + sys/conf/files | 8 + sys/dev/igc/if_igc.c | 2984 +++++++++++++++++++++++++++++++++++++++++++++ sys/dev/igc/if_igc.h | 430 +++++++ sys/dev/igc/igc_api.c | 735 +++++++++++ sys/dev/igc/igc_api.h | 58 + sys/dev/igc/igc_base.c | 188 +++ sys/dev/igc/igc_base.h | 131 ++ sys/dev/igc/igc_defines.h | 1347 ++++++++++++++++++++ sys/dev/igc/igc_hw.h | 548 +++++++++ sys/dev/igc/igc_i225.c | 1232 +++++++++++++++++++ sys/dev/igc/igc_i225.h | 112 ++ sys/dev/igc/igc_mac.c | 1050 ++++++++++++++++ sys/dev/igc/igc_mac.h | 48 + sys/dev/igc/igc_nvm.c | 721 +++++++++++ sys/dev/igc/igc_nvm.h | 32 + sys/dev/igc/igc_osdep.h | 133 ++ sys/dev/igc/igc_phy.c | 1109 +++++++++++++++++ sys/dev/igc/igc_phy.h | 134 ++ sys/dev/igc/igc_regs.h | 424 +++++++ sys/dev/igc/igc_txrx.c | 580 +++++++++ sys/i386/conf/GENERIC | 1 + sys/i386/conf/NOTES | 2 + sys/modules/Makefile | 2 + sys/modules/igc/Makefile | 11 + 28 files changed, 12192 insertions(+) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 1e5df4bb2eec..c912abccae6e 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -225,6 +225,7 @@ MAN= aac.4 \ iicmux.4 \ iicsmb.4 \ iir.4 \ + ${_igc.4} \ ${_imcsmb.4} \ inet.4 \ inet6.4 \ @@ -820,6 +821,7 @@ _if_nfe.4= if_nfe.4 _if_urtw.4= if_urtw.4 _if_vmx.4= if_vmx.4 _if_wpi.4= if_wpi.4 +_igc.4= igc.4 _imcsmb.4= imcsmb.4 _ipmi.4= ipmi.4 _io.4= io.4 diff --git a/share/man/man4/igc.4 b/share/man/man4/igc.4 new file mode 100644 index 000000000000..bb79fbe5a8fa --- /dev/null +++ b/share/man/man4/igc.4 @@ -0,0 +1,167 @@ +.\"- +.\" Copyright 2021 Intel Corp +.\" Copyright 2021 Rubicon Communications, LLC (Netgate) +.\" SPDX-License-Identifier: BSD-3-Clause +.\" +.\" $FreeBSD$ +.\" +.Dd May 10, 2021 +.Dt IGC +.Os +.Sh NAME +.Nm igc +.Nd "Intel Ethernet Controller I225 driver" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device iflib" +.Cd "device igc" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_igc_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for any PCI Express adapter or LOM (LAN +On Motherboard) based on the Intel I225 Multi Gigabit Controller. +The driver supports Transmit/Receive checksum offload, Jumbo Frames, +MSI/MSI-X, TSO, and RSS. +.Pp +Support for Jumbo Frames is provided via the interface MTU setting. +Selecting an MTU larger than 1500 bytes with the +.Xr ifconfig 8 +utility +configures the adapter to receive and transmit Jumbo Frames. +The maximum MTU size for Jumbo Frames is 9216 bytes. +.Pp +This driver version supports VLAN hardware insertion / extraction, and +VLAN checksum offload. +For information on enabling VLANs, see +.Xr ifconfig 8 . +The +.Nm +driver supports the following media types: +.Bl -tag -width ".Cm 10baseT/UTP" +.It Cm autoselect +Enables auto-negotiation for speed and duplex. +.It Cm 10baseT/UTP +Sets 10Mbps operation. +Use the +.Cm mediaopt +option to select +.Cm half-duplex +mode. +.It Cm 100baseTX +Sets 100Mbps operation. +Use the +.Cm mediaopt +option to select +.Cm half-duplex +mode. +.It Cm 1000baseT +Sets 1000Mbps operation. +Only +.Cm full-duplex +mode is supported at this speed. +.It Cm 2500baseT +Sets 2500Mbps operation. +Only +.Cm full-duplex +mode is supported at this speed. +.El +.Pp +.Sh HARDWARE +The +.Nm +driver supports the following models: +.Pp +.Bl -bullet -compact +.It +I225-LM +.It +I225-V +.It +I225-IT +.It +I225-K +.El +.Sh LOADER TUNABLES +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Xr loader.conf 5 . +.Bl -tag -width indent +.It Va hw.igc.igc_disable_crc_stripping +Disable or enable hardware stripping of CRC field. +This is mostly useful on BMC/IPMI shared interfaces where stripping the +CRC causes remote access over IPMI to fail. +Default 0 (enabled). +.It Va hw.igc.rx_int_delay +This value delays the generation of receive interrupts in units +of 1.024 microseconds. +The default value is 0, since adapters may hang with this feature being +enabled. +.It Va hw.igc.rx_abs_int_delay +If hw.igc.rx_int_delay is non-zero, this tunable limits the +maximum delay in which a receive interrupt is generated. +.It Va hw.igc.tx_int_delay +This value delays the generation of transmit interrupts in units +of 1.024 microseconds. +The default value is 64. +.It Va hw.igc.tx_abs_int_delay +If hw.igc.tx_int_delay is non-zero, this tunable limits the +maximum delay in which a transmit interrupt is generated. +.It Va hw.igc.sbp +Show bad packets when in promiscuous mode. +Default is false. +.It Va hw.igc.rx_process_limit +Maximum number of received packets to process at a time. +Default is 100. +A value of -1 means unlimited. +.It Va hw.igc.eee_setting +Disable or enable Energy Efficient Ethernet. +Default 1 (disabled). +.It Va hw.igc.max_interrupt_rate +Maximum device interrupts per second. +The default is 8000. +.El +.Sh DIAGNOSTICS +.Bl -diag +.It "igc%d: Hardware Initialization Failed" +A fatal initialization error has occurred. +.It "igc%d: Unable to allocate bus resource: memory" +A fatal initialization error has occurred. +.It "igc%d: Invalid MAC address" +The MAC address programmed into the EEPROM is either empty or a multicast/broadcast +address. +.El +.Sh SEE ALSO +.Xr altq 4 , +.Xr arp 4 , +.Xr iflib 4 , +.Xr netintro 4 , +.Xr ng_ether 4 , +.Xr vlan 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 14.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +was originally written by +.An Intel Corporation +and converted to the +.Xr iflib 4 +framework by +.An Netgate . diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index f16247e68137..f9e578a56902 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -234,6 +234,7 @@ device puc # Multi I/O cards and multi-channel UARTs # PCI/PCI-X/PCIe Ethernet NICs that use iflib infrastructure device iflib device em # Intel PRO/1000 Gigabit Ethernet Family +device igc # Intel I225 2.5G Ethernet device ix # Intel PRO/10GbE PCIE PF Ethernet device ixv # Intel PRO/10GbE PCIE VF Ethernet device ixl # Intel 700 Series Physical Function diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index 1b949fc24c8e..a3cb84698748 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -294,6 +294,7 @@ device cpufreq # adapters. # ice: Intel 800 Series Physical Function # Requires the ice_ddp module for full functionality +# igc: Intel I225 2.5Gb Ethernet adapter # ipw: Intel PRO/Wireless 2100 IEEE 802.11 adapter # Requires the ipw firmware module # iwi: Intel PRO/Wireless 2200BG/2225BG/2915ABG IEEE 802.11 adapters @@ -314,6 +315,7 @@ device bxe # Broadcom NetXtreme II BCM5771X/BCM578XX 10GbE options ED_3C503 options ED_HPP options ED_SIC +device igc # Intel I225 2.5G Ethernet device ipw # Intel 2100 wireless NICs. device iwi # Intel 2200BG/2225BG/2915ABG wireless NICs. device iwn # Intel 4965/1000/5000/6000 wireless NICs. diff --git a/sys/conf/files b/sys/conf/files index b0f313bb39de..5f6ec9a5c546 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1888,6 +1888,14 @@ dev/iicbus/gpio/tca6416.c optional tca6416 fdt dev/iir/iir.c optional iir dev/iir/iir_ctrl.c optional iir dev/iir/iir_pci.c optional iir pci +dev/igc/if_igc.c optional igc iflib pci +dev/igc/igc_api.c optional igc iflib pci +dev/igc/igc_base.c optional igc iflib pci +dev/igc/igc_i225.c optional igc iflib pci +dev/igc/igc_mac.c optional igc iflib pci +dev/igc/igc_nvm.c optional igc iflib pci +dev/igc/igc_phy.c optional igc iflib pci +dev/igc/igc_txrx.c optional igc iflib pci dev/intpm/intpm.c optional intpm pci # XXX Work around clang warning, until maintainer approves fix. dev/ips/ips.c optional ips \ diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c new file mode 100644 index 000000000000..6d94a7c223c7 --- /dev/null +++ b/sys/dev/igc/if_igc.c @@ -0,0 +1,2984 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2016 Nicole Graziano + * All rights reserved. + * Copyright (c) 2021 Rubicon Communications, LLC (Netgate) + * + * 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "if_igc.h" +#include +#include + +#ifdef RSS +#include +#include +#endif + +/********************************************************************* + * PCI Device ID Table + * + * Used by probe to select devices to load on + * Last entry must be all 0s + * + * { Vendor ID, Device ID, String } + *********************************************************************/ + +static pci_vendor_info_t igc_vendor_info_array[] = +{ + /* Intel(R) PRO/1000 Network Connection - igc */ + PVID(0x8086, IGC_DEV_ID_I225_LM, "Intel(R) Ethernet Controller I225-LM"), + PVID(0x8086, IGC_DEV_ID_I225_V, "Intel(R) Ethernet Controller I225-V"), + PVID(0x8086, IGC_DEV_ID_I225_K, "Intel(R) Ethernet Controller I225-K"), + PVID(0x8086, IGC_DEV_ID_I225_I, "Intel(R) Ethernet Controller I225-I"), + PVID(0x8086, IGC_DEV_ID_I220_V, "Intel(R) Ethernet Controller I220-V"), + PVID(0x8086, IGC_DEV_ID_I225_K2, "Intel(R) Ethernet Controller I225-K(2)"), + PVID(0x8086, IGC_DEV_ID_I225_LMVP, "Intel(R) Ethernet Controller I225-LMvP(2)"), + PVID(0x8086, IGC_DEV_ID_I226_K, "Intel(R) Ethernet Controller I226-K"), + PVID(0x8086, IGC_DEV_ID_I225_IT, "Intel(R) Ethernet Controller I225-IT(2)"), + PVID(0x8086, IGC_DEV_ID_I226_LM, "Intel(R) Ethernet Controller I226-LM"), + PVID(0x8086, IGC_DEV_ID_I226_V, "Intel(R) Ethernet Controller I226-V"), + PVID(0x8086, IGC_DEV_ID_I226_IT, "Intel(R) Ethernet Controller I226-IT"), + PVID(0x8086, IGC_DEV_ID_I221_V, "Intel(R) Ethernet Controller I221-V"), + PVID(0x8086, IGC_DEV_ID_I226_BLANK_NVM, "Intel(R) Ethernet Controller I226(blankNVM)"), + PVID(0x8086, IGC_DEV_ID_I225_BLANK_NVM, "Intel(R) Ethernet Controller I225(blankNVM)"), + /* required last entry */ + PVID_END +}; + +/********************************************************************* + * Function prototypes + *********************************************************************/ +static void *igc_register(device_t dev); +static int igc_if_attach_pre(if_ctx_t ctx); +static int igc_if_attach_post(if_ctx_t ctx); +static int igc_if_detach(if_ctx_t ctx); +static int igc_if_shutdown(if_ctx_t ctx); +static int igc_if_suspend(if_ctx_t ctx); +static int igc_if_resume(if_ctx_t ctx); + +static int igc_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int ntxqs, int ntxqsets); +static int igc_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxqs, int nrxqsets); +static void igc_if_queues_free(if_ctx_t ctx); + +static uint64_t igc_if_get_counter(if_ctx_t, ift_counter); +static void igc_if_init(if_ctx_t ctx); +static void igc_if_stop(if_ctx_t ctx); +static void igc_if_media_status(if_ctx_t, struct ifmediareq *); +static int igc_if_media_change(if_ctx_t ctx); +static int igc_if_mtu_set(if_ctx_t ctx, uint32_t mtu); +static void igc_if_timer(if_ctx_t ctx, uint16_t qid); +static void igc_if_vlan_register(if_ctx_t ctx, u16 vtag); +static void igc_if_vlan_unregister(if_ctx_t ctx, u16 vtag); +static void igc_if_watchdog_reset(if_ctx_t ctx); +static bool igc_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event); + +static void igc_identify_hardware(if_ctx_t ctx); +static int igc_allocate_pci_resources(if_ctx_t ctx); +static void igc_free_pci_resources(if_ctx_t ctx); +static void igc_reset(if_ctx_t ctx); +static int igc_setup_interface(if_ctx_t ctx); +static int igc_setup_msix(if_ctx_t ctx); + +static void igc_initialize_transmit_unit(if_ctx_t ctx); +static void igc_initialize_receive_unit(if_ctx_t ctx); + +static void igc_if_intr_enable(if_ctx_t ctx); +static void igc_if_intr_disable(if_ctx_t ctx); +static int igc_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid); +static int igc_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid); +static void igc_if_multi_set(if_ctx_t ctx); +static void igc_if_update_admin_status(if_ctx_t ctx); +static void igc_if_debug(if_ctx_t ctx); +static void igc_update_stats_counters(struct igc_adapter *); +static void igc_add_hw_stats(struct igc_adapter *adapter); +static int igc_if_set_promisc(if_ctx_t ctx, int flags); +static void igc_setup_vlan_hw_support(struct igc_adapter *); +static int igc_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); +static void igc_print_nvm_info(struct igc_adapter *); +static int igc_sysctl_debug_info(SYSCTL_HANDLER_ARGS); +static int igc_get_rs(SYSCTL_HANDLER_ARGS); +static void igc_print_debug_info(struct igc_adapter *); +static int igc_is_valid_ether_addr(u8 *); +static int igc_sysctl_int_delay(SYSCTL_HANDLER_ARGS); +static void igc_add_int_delay_sysctl(struct igc_adapter *, const char *, + const char *, struct igc_int_delay_info *, int, int); +/* Management and WOL Support */ +static void igc_get_hw_control(struct igc_adapter *); +static void igc_release_hw_control(struct igc_adapter *); +static void igc_get_wakeup(if_ctx_t ctx); +static void igc_enable_wakeup(if_ctx_t ctx); + +int igc_intr(void *arg); + +/* MSI-X handlers */ +static int igc_if_msix_intr_assign(if_ctx_t, int); +static int igc_msix_link(void *); +static void igc_handle_link(void *context); + +static int igc_set_flowcntl(SYSCTL_HANDLER_ARGS); +static int igc_sysctl_eee(SYSCTL_HANDLER_ARGS); + +static int igc_get_regs(SYSCTL_HANDLER_ARGS); + +static void igc_configure_queues(struct igc_adapter *adapter); + + +/********************************************************************* + * FreeBSD Device Interface Entry Points + *********************************************************************/ +static device_method_t igc_methods[] = { + /* Device interface */ + DEVMETHOD(device_register, igc_register), + DEVMETHOD(device_probe, iflib_device_probe), + DEVMETHOD(device_attach, iflib_device_attach), + DEVMETHOD(device_detach, iflib_device_detach), + DEVMETHOD(device_shutdown, iflib_device_shutdown), + DEVMETHOD(device_suspend, iflib_device_suspend), + DEVMETHOD(device_resume, iflib_device_resume), + DEVMETHOD_END +}; + +static driver_t igc_driver = { + "igc", igc_methods, sizeof(struct igc_adapter), +}; + +static devclass_t igc_devclass; +DRIVER_MODULE(igc, pci, igc_driver, igc_devclass, 0, 0); + +MODULE_DEPEND(igc, pci, 1, 1, 1); +MODULE_DEPEND(igc, ether, 1, 1, 1); +MODULE_DEPEND(igc, iflib, 1, 1, 1); + +IFLIB_PNP_INFO(pci, igc, igc_vendor_info_array); + +static device_method_t igc_if_methods[] = { + DEVMETHOD(ifdi_attach_pre, igc_if_attach_pre), + DEVMETHOD(ifdi_attach_post, igc_if_attach_post), + DEVMETHOD(ifdi_detach, igc_if_detach), + DEVMETHOD(ifdi_shutdown, igc_if_shutdown), + DEVMETHOD(ifdi_suspend, igc_if_suspend), + DEVMETHOD(ifdi_resume, igc_if_resume), + DEVMETHOD(ifdi_init, igc_if_init), + DEVMETHOD(ifdi_stop, igc_if_stop), + DEVMETHOD(ifdi_msix_intr_assign, igc_if_msix_intr_assign), + DEVMETHOD(ifdi_intr_enable, igc_if_intr_enable), + DEVMETHOD(ifdi_intr_disable, igc_if_intr_disable), + DEVMETHOD(ifdi_tx_queues_alloc, igc_if_tx_queues_alloc), + DEVMETHOD(ifdi_rx_queues_alloc, igc_if_rx_queues_alloc), + DEVMETHOD(ifdi_queues_free, igc_if_queues_free), + DEVMETHOD(ifdi_update_admin_status, igc_if_update_admin_status), + DEVMETHOD(ifdi_multi_set, igc_if_multi_set), + DEVMETHOD(ifdi_media_status, igc_if_media_status), + DEVMETHOD(ifdi_media_change, igc_if_media_change), + DEVMETHOD(ifdi_mtu_set, igc_if_mtu_set), + DEVMETHOD(ifdi_promisc_set, igc_if_set_promisc), + DEVMETHOD(ifdi_timer, igc_if_timer), + DEVMETHOD(ifdi_watchdog_reset, igc_if_watchdog_reset), + DEVMETHOD(ifdi_vlan_register, igc_if_vlan_register), + DEVMETHOD(ifdi_vlan_unregister, igc_if_vlan_unregister), + DEVMETHOD(ifdi_get_counter, igc_if_get_counter), + DEVMETHOD(ifdi_rx_queue_intr_enable, igc_if_rx_queue_intr_enable), + DEVMETHOD(ifdi_tx_queue_intr_enable, igc_if_tx_queue_intr_enable), + DEVMETHOD(ifdi_debug, igc_if_debug), + DEVMETHOD(ifdi_needs_restart, igc_if_needs_restart), + DEVMETHOD_END +}; + +static driver_t igc_if_driver = { + "igc_if", igc_if_methods, sizeof(struct igc_adapter) +}; + +/********************************************************************* + * Tunable default values. + *********************************************************************/ + +#define IGC_TICKS_TO_USECS(ticks) ((1024 * (ticks) + 500) / 1000) +#define IGC_USECS_TO_TICKS(usecs) ((1000 * (usecs) + 512) / 1024) + +#define MAX_INTS_PER_SEC 8000 +#define DEFAULT_ITR (1000000000/(MAX_INTS_PER_SEC * 256)) + +/* Allow common code without TSO */ +#ifndef CSUM_TSO +#define CSUM_TSO 0 +#endif + +static SYSCTL_NODE(_hw, OID_AUTO, igc, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, + "igc driver parameters"); + +static int igc_disable_crc_stripping = 0; +SYSCTL_INT(_hw_igc, OID_AUTO, disable_crc_stripping, CTLFLAG_RDTUN, + &igc_disable_crc_stripping, 0, "Disable CRC Stripping"); + +static int igc_tx_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_TIDV_VAL); +static int igc_rx_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_RDTR_VAL); +SYSCTL_INT(_hw_igc, OID_AUTO, tx_int_delay, CTLFLAG_RDTUN, &igc_tx_int_delay_dflt, + 0, "Default transmit interrupt delay in usecs"); +SYSCTL_INT(_hw_igc, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &igc_rx_int_delay_dflt, + 0, "Default receive interrupt delay in usecs"); + +static int igc_tx_abs_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_TADV_VAL); +static int igc_rx_abs_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_RADV_VAL); +SYSCTL_INT(_hw_igc, OID_AUTO, tx_abs_int_delay, CTLFLAG_RDTUN, + &igc_tx_abs_int_delay_dflt, 0, + "Default transmit interrupt delay limit in usecs"); +SYSCTL_INT(_hw_igc, OID_AUTO, rx_abs_int_delay, CTLFLAG_RDTUN, + &igc_rx_abs_int_delay_dflt, 0, + "Default receive interrupt delay limit in usecs"); + +static int igc_smart_pwr_down = false; +SYSCTL_INT(_hw_igc, OID_AUTO, smart_pwr_down, CTLFLAG_RDTUN, &igc_smart_pwr_down, + 0, "Set to true to leave smart power down enabled on newer adapters"); + +/* Controls whether promiscuous also shows bad packets */ +static int igc_debug_sbp = true; +SYSCTL_INT(_hw_igc, OID_AUTO, sbp, CTLFLAG_RDTUN, &igc_debug_sbp, 0, + "Show bad packets in promiscuous mode"); + +/* How many packets rxeof tries to clean at a time */ +static int igc_rx_process_limit = 100; +SYSCTL_INT(_hw_igc, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, + &igc_rx_process_limit, 0, + "Maximum number of received packets to process " + "at a time, -1 means unlimited"); + +/* Energy efficient ethernet - default to OFF */ +static int igc_eee_setting = 1; +SYSCTL_INT(_hw_igc, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &igc_eee_setting, 0, + "Enable Energy Efficient Ethernet"); + +/* +** Tuneable Interrupt rate +*/ +static int igc_max_interrupt_rate = 8000; +SYSCTL_INT(_hw_igc, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, + &igc_max_interrupt_rate, 0, "Maximum interrupts per second"); + +extern struct if_txrx igc_txrx; + +static struct if_shared_ctx igc_sctx_init = { + .isc_magic = IFLIB_MAGIC, + .isc_q_align = PAGE_SIZE, + .isc_tx_maxsize = IGC_TSO_SIZE + sizeof(struct ether_vlan_header), + .isc_tx_maxsegsize = PAGE_SIZE, + .isc_tso_maxsize = IGC_TSO_SIZE + sizeof(struct ether_vlan_header), + .isc_tso_maxsegsize = IGC_TSO_SEG_SIZE, + .isc_rx_maxsize = MAX_JUMBO_FRAME_SIZE, + .isc_rx_nsegments = 1, + .isc_rx_maxsegsize = MJUM9BYTES, + .isc_nfl = 1, + .isc_nrxqs = 1, + .isc_ntxqs = 1, + .isc_admin_intrcnt = 1, + .isc_vendor_info = igc_vendor_info_array, + .isc_driver_version = "1", + .isc_driver = &igc_if_driver, + .isc_flags = IFLIB_NEED_SCRATCH | IFLIB_TSO_INIT_IP | IFLIB_NEED_ZERO_CSUM, + + .isc_nrxd_min = {IGC_MIN_RXD}, + .isc_ntxd_min = {IGC_MIN_TXD}, + .isc_nrxd_max = {IGC_MAX_RXD}, + .isc_ntxd_max = {IGC_MAX_TXD}, + .isc_nrxd_default = {IGC_DEFAULT_RXD}, + .isc_ntxd_default = {IGC_DEFAULT_TXD}, +}; + +/***************************************************************** + * + * Dump Registers + * + ****************************************************************/ +#define IGC_REGS_LEN 739 + +static int igc_get_regs(SYSCTL_HANDLER_ARGS) +{ + struct igc_adapter *adapter = (struct igc_adapter *)arg1; + struct igc_hw *hw = &adapter->hw; + struct sbuf *sb; + u32 *regs_buff; + int rc; + + regs_buff = malloc(sizeof(u32) * IGC_REGS_LEN, M_DEVBUF, M_WAITOK); + memset(regs_buff, 0, IGC_REGS_LEN * sizeof(u32)); + + rc = sysctl_wire_old_buffer(req, 0); + MPASS(rc == 0); + if (rc != 0) { + free(regs_buff, M_DEVBUF); + return (rc); + } + + sb = sbuf_new_for_sysctl(NULL, NULL, 32*400, req); + MPASS(sb != NULL); + if (sb == NULL) { + free(regs_buff, M_DEVBUF); + return (ENOMEM); + } + + /* General Registers */ + regs_buff[0] = IGC_READ_REG(hw, IGC_CTRL); + regs_buff[1] = IGC_READ_REG(hw, IGC_STATUS); + regs_buff[2] = IGC_READ_REG(hw, IGC_CTRL_EXT); + regs_buff[3] = IGC_READ_REG(hw, IGC_ICR); + regs_buff[4] = IGC_READ_REG(hw, IGC_RCTL); + regs_buff[5] = IGC_READ_REG(hw, IGC_RDLEN(0)); + regs_buff[6] = IGC_READ_REG(hw, IGC_RDH(0)); + regs_buff[7] = IGC_READ_REG(hw, IGC_RDT(0)); + regs_buff[8] = IGC_READ_REG(hw, IGC_RXDCTL(0)); + regs_buff[9] = IGC_READ_REG(hw, IGC_RDBAL(0)); + regs_buff[10] = IGC_READ_REG(hw, IGC_RDBAH(0)); + regs_buff[11] = IGC_READ_REG(hw, IGC_TCTL); + regs_buff[12] = IGC_READ_REG(hw, IGC_TDBAL(0)); + regs_buff[13] = IGC_READ_REG(hw, IGC_TDBAH(0)); + regs_buff[14] = IGC_READ_REG(hw, IGC_TDLEN(0)); + regs_buff[15] = IGC_READ_REG(hw, IGC_TDH(0)); + regs_buff[16] = IGC_READ_REG(hw, IGC_TDT(0)); + regs_buff[17] = IGC_READ_REG(hw, IGC_TXDCTL(0)); + + sbuf_printf(sb, "General Registers\n"); + sbuf_printf(sb, "\tCTRL\t %08x\n", regs_buff[0]); + sbuf_printf(sb, "\tSTATUS\t %08x\n", regs_buff[1]); + sbuf_printf(sb, "\tCTRL_EXIT\t %08x\n\n", regs_buff[2]); + + sbuf_printf(sb, "Interrupt Registers\n"); + sbuf_printf(sb, "\tICR\t %08x\n\n", regs_buff[3]); + + sbuf_printf(sb, "RX Registers\n"); + sbuf_printf(sb, "\tRCTL\t %08x\n", regs_buff[4]); + sbuf_printf(sb, "\tRDLEN\t %08x\n", regs_buff[5]); + sbuf_printf(sb, "\tRDH\t %08x\n", regs_buff[6]); + sbuf_printf(sb, "\tRDT\t %08x\n", regs_buff[7]); + sbuf_printf(sb, "\tRXDCTL\t %08x\n", regs_buff[8]); + sbuf_printf(sb, "\tRDBAL\t %08x\n", regs_buff[9]); + sbuf_printf(sb, "\tRDBAH\t %08x\n\n", regs_buff[10]); + + sbuf_printf(sb, "TX Registers\n"); + sbuf_printf(sb, "\tTCTL\t %08x\n", regs_buff[11]); + sbuf_printf(sb, "\tTDBAL\t %08x\n", regs_buff[12]); + sbuf_printf(sb, "\tTDBAH\t %08x\n", regs_buff[13]); + sbuf_printf(sb, "\tTDLEN\t %08x\n", regs_buff[14]); + sbuf_printf(sb, "\tTDH\t %08x\n", regs_buff[15]); + sbuf_printf(sb, "\tTDT\t %08x\n", regs_buff[16]); + sbuf_printf(sb, "\tTXDCTL\t %08x\n", regs_buff[17]); + sbuf_printf(sb, "\tTDFH\t %08x\n", regs_buff[18]); + sbuf_printf(sb, "\tTDFT\t %08x\n", regs_buff[19]); + sbuf_printf(sb, "\tTDFHS\t %08x\n", regs_buff[20]); + sbuf_printf(sb, "\tTDFPC\t %08x\n\n", regs_buff[21]); + + free(regs_buff, M_DEVBUF); + +#ifdef DUMP_DESCS + { + if_softc_ctx_t scctx = adapter->shared; + struct rx_ring *rxr = &rx_que->rxr; + struct tx_ring *txr = &tx_que->txr; + int ntxd = scctx->isc_ntxd[0]; + int nrxd = scctx->isc_nrxd[0]; + int j; + + for (j = 0; j < nrxd; j++) { + u32 staterr = le32toh(rxr->rx_base[j].wb.upper.status_error); + u32 length = le32toh(rxr->rx_base[j].wb.upper.length); + sbuf_printf(sb, "\tReceive Descriptor Address %d: %08" PRIx64 " Error:%d Length:%d\n", j, rxr->rx_base[j].read.buffer_addr, staterr, length); + } + + for (j = 0; j < min(ntxd, 256); j++) { + unsigned int *ptr = (unsigned int *)&txr->tx_base[j]; + + sbuf_printf(sb, "\tTXD[%03d] [0]: %08x [1]: %08x [2]: %08x [3]: %08x eop: %d DD=%d\n", + j, ptr[0], ptr[1], ptr[2], ptr[3], buf->eop, + buf->eop != -1 ? txr->tx_base[buf->eop].upper.fields.status & IGC_TXD_STAT_DD : 0); + + } + } +#endif + + rc = sbuf_finish(sb); + sbuf_delete(sb); + return(rc); +} + +static void * +igc_register(device_t dev) +{ + return (&igc_sctx_init); +} + +static int +igc_set_num_queues(if_ctx_t ctx) +{ + int maxqueues; + + maxqueues = 4; + + return (maxqueues); +} + +#define IGC_CAPS \ + IFCAP_HWCSUM | IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING | \ + IFCAP_VLAN_HWCSUM | IFCAP_WOL | IFCAP_VLAN_HWFILTER | IFCAP_TSO4 | \ + IFCAP_LRO | IFCAP_VLAN_HWTSO | IFCAP_JUMBO_MTU | IFCAP_HWCSUM_IPV6 |\ + IFCAP_TSO6 + +/********************************************************************* + * Device initialization routine + * + * The attach entry point is called when the driver is being loaded. + * This routine identifies the type of hardware, allocates all resources + * and initializes the hardware. + * + * return 0 on success, positive on failure + *********************************************************************/ +static int +igc_if_attach_pre(if_ctx_t ctx) +{ + struct igc_adapter *adapter; + if_softc_ctx_t scctx; + device_t dev; + struct igc_hw *hw; + int error = 0; + + INIT_DEBUGOUT("igc_if_attach_pre: begin"); + dev = iflib_get_dev(ctx); + adapter = iflib_get_softc(ctx); + + adapter->ctx = adapter->osdep.ctx = ctx; + adapter->dev = adapter->osdep.dev = dev; + scctx = adapter->shared = iflib_get_softc_ctx(ctx); + adapter->media = iflib_get_media(ctx); + hw = &adapter->hw; + + adapter->tx_process_limit = scctx->isc_ntxd[0]; + + /* SYSCTL stuff */ + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "nvm", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + adapter, 0, igc_sysctl_nvm_info, "I", "NVM Information"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "debug", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + adapter, 0, igc_sysctl_debug_info, "I", "Debug Information"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "fc", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + adapter, 0, igc_set_flowcntl, "I", "Flow Control"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "reg_dump", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, adapter, 0, + igc_get_regs, "A", "Dump Registers"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "rs_dump", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, adapter, 0, + igc_get_rs, "I", "Dump RS indexes"); + + /* Determine hardware and mac info */ + igc_identify_hardware(ctx); + + scctx->isc_tx_nsegments = IGC_MAX_SCATTER; + scctx->isc_nrxqsets_max = scctx->isc_ntxqsets_max = igc_set_num_queues(ctx); + if (bootverbose) + device_printf(dev, "attach_pre capping queues at %d\n", + scctx->isc_ntxqsets_max); + + scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0] * sizeof(union igc_adv_tx_desc), IGC_DBA_ALIGN); + scctx->isc_rxqsizes[0] = roundup2(scctx->isc_nrxd[0] * sizeof(union igc_adv_rx_desc), IGC_DBA_ALIGN); + scctx->isc_txd_size[0] = sizeof(union igc_adv_tx_desc); + scctx->isc_rxd_size[0] = sizeof(union igc_adv_rx_desc); + scctx->isc_txrx = &igc_txrx; + scctx->isc_tx_tso_segments_max = IGC_MAX_SCATTER; + scctx->isc_tx_tso_size_max = IGC_TSO_SIZE; + scctx->isc_tx_tso_segsize_max = IGC_TSO_SEG_SIZE; + scctx->isc_capabilities = scctx->isc_capenable = IGC_CAPS; + scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP | CSUM_TSO | + CSUM_IP6_TCP | CSUM_IP6_UDP | CSUM_SCTP | CSUM_IP6_SCTP; + + /* + ** Some new devices, as with ixgbe, now may + ** use a different BAR, so we need to keep + ** track of which is used. + */ + scctx->isc_msix_bar = PCIR_BAR(IGC_MSIX_BAR); + if (pci_read_config(dev, scctx->isc_msix_bar, 4) == 0) + scctx->isc_msix_bar += 4; + + /* Setup PCI resources */ + if (igc_allocate_pci_resources(ctx)) { + device_printf(dev, "Allocation of PCI resources failed\n"); + error = ENXIO; + goto err_pci; + } + + /* Do Shared Code initialization */ + error = igc_setup_init_funcs(hw, true); + if (error) { + device_printf(dev, "Setup of Shared code failed, error %d\n", + error); + error = ENXIO; + goto err_pci; + } + + igc_setup_msix(ctx); + igc_get_bus_info(hw); + + /* Set up some sysctls for the tunable interrupt delays */ + igc_add_int_delay_sysctl(adapter, "rx_int_delay", + "receive interrupt delay in usecs", &adapter->rx_int_delay, + IGC_REGISTER(hw, IGC_RDTR), igc_rx_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "tx_int_delay", + "transmit interrupt delay in usecs", &adapter->tx_int_delay, + IGC_REGISTER(hw, IGC_TIDV), igc_tx_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "rx_abs_int_delay", + "receive interrupt delay limit in usecs", + &adapter->rx_abs_int_delay, + IGC_REGISTER(hw, IGC_RADV), + igc_rx_abs_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "tx_abs_int_delay", + "transmit interrupt delay limit in usecs", + &adapter->tx_abs_int_delay, + IGC_REGISTER(hw, IGC_TADV), + igc_tx_abs_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "itr", + "interrupt delay limit in usecs/4", + &adapter->tx_itr, + IGC_REGISTER(hw, IGC_ITR), + DEFAULT_ITR); + + hw->mac.autoneg = DO_AUTO_NEG; + hw->phy.autoneg_wait_to_complete = false; + hw->phy.autoneg_advertised = AUTONEG_ADV_DEFAULT; + + /* Copper options */ + if (hw->phy.media_type == igc_media_type_copper) { + hw->phy.mdix = AUTO_ALL_MODES; + } + + /* + * Set the frame limits assuming + * standard ethernet sized frames. + */ + scctx->isc_max_frame_size = adapter->hw.mac.max_frame_size = + ETHERMTU + ETHER_HDR_LEN + ETHERNET_FCS_SIZE; + + /* Allocate multicast array memory. */ + adapter->mta = malloc(sizeof(u8) * ETHER_ADDR_LEN * + MAX_NUM_MULTICAST_ADDRESSES, M_DEVBUF, M_NOWAIT); + if (adapter->mta == NULL) { + device_printf(dev, "Can not allocate multicast setup array\n"); + error = ENOMEM; + goto err_late; + } + + /* Check SOL/IDER usage */ + if (igc_check_reset_block(hw)) + device_printf(dev, "PHY reset is blocked" + " due to SOL/IDER session.\n"); + + /* Sysctl for setting Energy Efficient Ethernet */ + adapter->hw.dev_spec._i225.eee_disable = igc_eee_setting; + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "eee_control", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + adapter, 0, igc_sysctl_eee, "I", + "Disable Energy Efficient Ethernet"); + + /* + ** Start from a known state, this is + ** important in reading the nvm and + ** mac from that. + */ + igc_reset_hw(hw); + + /* Make sure we have a good EEPROM before we read from it */ + if (igc_validate_nvm_checksum(hw) < 0) { + /* + ** Some PCI-E parts fail the first check due to + ** the link being in sleep state, call it again, + ** if it fails a second time its a real issue. + */ + if (igc_validate_nvm_checksum(hw) < 0) { + device_printf(dev, + "The EEPROM Checksum Is Not Valid\n"); + error = EIO; + goto err_late; + } + } + + /* Copy the permanent MAC address out of the EEPROM */ + if (igc_read_mac_addr(hw) < 0) { + device_printf(dev, "EEPROM read error while reading MAC" + " address\n"); + error = EIO; + goto err_late; + } + + if (!igc_is_valid_ether_addr(hw->mac.addr)) { + device_printf(dev, "Invalid MAC address\n"); + error = EIO; + goto err_late; + } + + /* + * Get Wake-on-Lan and Management info for later use + */ + igc_get_wakeup(ctx); + + /* Enable only WOL MAGIC by default */ + scctx->isc_capenable &= ~IFCAP_WOL; + if (adapter->wol != 0) + scctx->isc_capenable |= IFCAP_WOL_MAGIC; + + iflib_set_mac(ctx, hw->mac.addr); + + return (0); + +err_late: + igc_release_hw_control(adapter); +err_pci: + igc_free_pci_resources(ctx); + free(adapter->mta, M_DEVBUF); + + return (error); +} + +static int +igc_if_attach_post(if_ctx_t ctx) +{ + struct igc_adapter *adapter = iflib_get_softc(ctx); + struct igc_hw *hw = &adapter->hw; *** 11493 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Sun Aug 15 19:25:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6B02E664D3D; Sun, 15 Aug 2021 19:25: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 4GnnMK2MPJz3vQv; Sun, 15 Aug 2021 19:25:49 +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 392D31BD02; Sun, 15 Aug 2021 19:25:49 +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 17FJPnBu072505; Sun, 15 Aug 2021 19:25:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FJPn5Q072504; Sun, 15 Aug 2021 19:25:49 GMT (envelope-from git) Date: Sun, 15 Aug 2021 19:25:49 GMT Message-Id: <202108151925.17FJPn5Q072504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 2257c7810cc5 - stable/13 - igc: sync igc_txrx with igb(4) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2257c7810cc5be6cc294e695471fa588c60870b9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 19:25:49 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=2257c7810cc5be6cc294e695471fa588c60870b9 commit 2257c7810cc5be6cc294e695471fa588c60870b9 Author: Kevin Bowling AuthorDate: 2021-07-31 15:00:16 +0000 Commit: Kevin Bowling CommitDate: 2021-08-15 19:25:16 +0000 igc: sync igc_txrx with igb(4) Reviewed by: grehan MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31227 (cherry picked from commit d02e436353d292e6fd50f70ea80507095543764e) --- sys/dev/igc/igc_txrx.c | 92 +++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/sys/dev/igc/igc_txrx.c b/sys/dev/igc/igc_txrx.c index 2636aa77069a..ee4d5a5c0c6b 100644 --- a/sys/dev/igc/igc_txrx.c +++ b/sys/dev/igc/igc_txrx.c @@ -52,16 +52,20 @@ static int igc_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear); static void igc_isc_rxd_refill(void *arg, if_rxd_update_t iru); -static void igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx); -static int igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget); +static void igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, + qidx_t pidx); +static int igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, + qidx_t budget); static int igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri); -static int igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status); -static int igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status); +static int igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, + uint32_t *cmd_type_len, uint32_t *olinfo_status); +static int igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, + uint32_t *cmd_type_len, uint32_t *olinfo_status); -static void igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype); -static int igc_determine_rsstype(u16 pkt_info); +static void igc_rx_checksum(uint32_t staterr, if_rxd_info_t ri, uint32_t ptype); +static int igc_determine_rsstype(uint16_t pkt_info); extern void igc_if_enable_intr(if_ctx_t ctx); extern int igc_intr(void *arg); @@ -119,12 +123,13 @@ igc_dump_rs(struct igc_adapter *adapter) * **********************************************************************/ static int -igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status) +igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, uint32_t *cmd_type_len, + uint32_t *olinfo_status) { struct igc_adv_tx_context_desc *TXD; - u32 type_tucmd_mlhl = 0, vlan_macip_lens = 0; - u32 mss_l4len_idx = 0; - u32 paylen; + uint32_t type_tucmd_mlhl = 0, vlan_macip_lens = 0; + uint32_t mss_l4len_idx = 0; + uint32_t paylen; switch(pi->ipi_etype) { case ETHERTYPE_IPV6: @@ -179,11 +184,12 @@ igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *oli * **********************************************************************/ static int -igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status) +igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, uint32_t *cmd_type_len, + uint32_t *olinfo_status) { struct igc_adv_tx_context_desc *TXD; - u32 vlan_macip_lens, type_tucmd_mlhl; - u32 mss_l4len_idx; + uint32_t vlan_macip_lens, type_tucmd_mlhl; + uint32_t mss_l4len_idx; mss_l4len_idx = vlan_macip_lens = type_tucmd_mlhl = 0; /* First check if TSO is to be used */ @@ -242,7 +248,7 @@ igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 * type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_L4T_SCTP; *olinfo_status |= IGC_TXD_POPTS_TXSM << 8; } - break; + break; default: break; } @@ -267,7 +273,7 @@ igc_isc_txd_encap(void *arg, if_pkt_info_t pi) bus_dma_segment_t *segs = pi->ipi_segs; union igc_adv_tx_desc *txd = NULL; int i, j, pidx_last; - u32 olinfo_status, cmd_type_len, txd_flags; + uint32_t olinfo_status, cmd_type_len, txd_flags; qidx_t ntxd; pidx_last = olinfo_status = 0; @@ -422,7 +428,7 @@ igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget) struct igc_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; union igc_adv_rx_desc *rxd; - u32 staterr = 0; + uint32_t staterr = 0; int cnt, i; for (cnt = 0, i = idx; cnt < scctx->isc_nrxd[0] && cnt <= budget;) { @@ -453,16 +459,15 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) if_softc_ctx_t scctx = adapter->shared; struct igc_rx_queue *que = &adapter->rx_queues[ri->iri_qsidx]; struct rx_ring *rxr = &que->rxr; - struct ifnet *ifp = iflib_get_ifp(adapter->ctx); union igc_adv_rx_desc *rxd; - u16 pkt_info, len; - u16 vtag = 0; - u32 ptype; - u32 staterr = 0; + uint16_t pkt_info, len, vtag; + uint32_t ptype, staterr; + int i, cidx; bool eop; - int i = 0; - int cidx = ri->iri_cidx; + + staterr = i = vtag = 0; + cidx = ri->iri_cidx; do { rxd = (union igc_adv_rx_desc *)&rxr->rx_base[cidx]; @@ -507,14 +512,15 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) rxr->rx_packets++; - if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) + if ((scctx->isc_capenable & IFCAP_RXCSUM) != 0) igc_rx_checksum(staterr, ri, ptype); - if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 && + if ((scctx->isc_capenable & IFCAP_VLAN_HWTAGGING) != 0 && (staterr & IGC_RXD_STAT_VP) != 0) { ri->iri_vtag = vtag; ri->iri_flags |= M_VLANTAG; } + ri->iri_flowid = le32toh(rxd->wb.lower.hi_dword.rss); ri->iri_rsstype = igc_determine_rsstype(pkt_info); @@ -531,26 +537,34 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) * *********************************************************************/ static void -igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype) +igc_rx_checksum(uint32_t staterr, if_rxd_info_t ri, uint32_t ptype) { - u16 status = (u16)staterr; - u8 errors = (u8) (staterr >> 24); + uint16_t status = (uint16_t)staterr; + uint8_t errors = (uint8_t)(staterr >> 24); - /* Ignore Checksum bit is set */ - if (status & IGC_RXD_STAT_IXSM) { - ri->iri_csum_flags = 0; + if (__predict_false(status & IGC_RXD_STAT_IXSM)) return; - } - if (status & (IGC_RXD_STAT_TCPCS | IGC_RXD_STAT_UDPCS)) { - u64 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - /* Did it pass? */ - if (!(errors & IGC_RXD_ERR_TCPE)) { - ri->iri_csum_flags |= type; + /* If there is a layer 3 or 4 error we are done */ + if (__predict_false(errors & (IGC_RXD_ERR_IPE | IGC_RXD_ERR_TCPE))) + return; + + /* IP Checksum Good */ + if (status & IGC_RXD_STAT_IPCS) + ri->iri_csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID); + + /* Valid L4E checksum */ + if (__predict_true(status & + (IGC_RXD_STAT_TCPCS | IGC_RXD_STAT_UDPCS))) { + /* SCTP header present */ + if (__predict_false((ptype & IGC_RXDADV_PKTTYPE_ETQF) == 0 && + (ptype & IGC_RXDADV_PKTTYPE_SCTP) != 0)) { + ri->iri_csum_flags |= CSUM_SCTP_VALID; + } else { + ri->iri_csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; ri->iri_csum_data = htons(0xffff); } } - return; } /******************************************************************** @@ -559,7 +573,7 @@ igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype) * ******************************************************************/ static int -igc_determine_rsstype(u16 pkt_info) +igc_determine_rsstype(uint16_t pkt_info) { switch (pkt_info & IGC_RXDADV_RSSTYPE_MASK) { case IGC_RXDADV_RSSTYPE_IPV4_TCP: From owner-dev-commits-src-all@freebsd.org Sun Aug 15 21:03:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6DA42666706; Sun, 15 Aug 2021 21:03: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 4GnqWm2TQbz4bCx; Sun, 15 Aug 2021 21:03: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 2B99F1CDE9; Sun, 15 Aug 2021 21:03: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 17FL3GoA006032; Sun, 15 Aug 2021 21:03:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FL3GnW006031; Sun, 15 Aug 2021 21:03:16 GMT (envelope-from git) Date: Sun, 15 Aug 2021 21:03:16 GMT Message-Id: <202108152103.17FL3GnW006031@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 5a1da25da26b - stable/13 - grep: Fix an incorrect description of the -C flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5a1da25da26ba462ea86f64c007530cfa873c5ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 21:03:16 -0000 The branch stable/13 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5a1da25da26ba462ea86f64c007530cfa873c5ea commit 5a1da25da26ba462ea86f64c007530cfa873c5ea Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-02-05 18:38:09 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-08-15 21:01:01 +0000 grep: Fix an incorrect description of the -C flag It seems that the number of lines is no longer an optional parameter to the -C flag. Document it accordingly both in the manual page and the usage message. Reviewed by: yuripv Approved by: yuripv MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28509 (cherry picked from commit be6b8b7a3a18acb3b044e144d946392fca05e5d0) --- usr.bin/grep/grep.1 | 21 +++++++++------------ usr.bin/grep/grep.c | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/usr.bin/grep/grep.1 b/usr.bin/grep/grep.1 index 338af7e6d454..5f314d0dff7c 100644 --- a/usr.bin/grep/grep.1 +++ b/usr.bin/grep/grep.1 @@ -30,7 +30,7 @@ .\" .\" @(#)grep.1 8.3 (Berkeley) 4/18/94 .\" -.Dd February 4, 2021 +.Dd April 17, 2021 .Dt GREP 1 .Os .Sh NAME @@ -45,13 +45,13 @@ .Op Fl abcdDEFGHhIiLlmnOopqRSsUVvwxz .Op Fl A Ar num .Op Fl B Ar num -.Op Fl C Ns Op Ar num +.Op Fl C Ar num .Op Fl e Ar pattern .Op Fl f Ar file .Op Fl Fl binary-files= Ns Ar value .Op Fl Fl color Ns Op Cm = Ns Ar when .Op Fl Fl colour Ns Op Cm = Ns Ar when -.Op Fl Fl context Ns Op Cm = Ns Ar num +.Op Fl Fl context= Ns Ar num .Op Fl Fl label .Op Fl Fl line-buffered .Op Fl Fl null @@ -123,18 +123,15 @@ options. .It Fl b , Fl Fl byte-offset The offset in bytes of a matched pattern is displayed in front of the respective matched line. -.It Fl C Ns Oo Ar num Oc , Fl Fl context Ns Oo = Ns Ar num Oc +.It Fl C Ar num , Fl Fl context= Ns Ar num Print .Ar num lines of leading and trailing context surrounding each match. -The default value of -.Ar num -is -.Dq 2 -and is equivalent to -.Dq Fl A Ar 2 Fl B Ar 2 . -Note: -no whitespace may be given between the option and its argument. +See also the +.Fl A +and +.Fl B +options. .It Fl c , Fl Fl count Only a count of selected lines is written to standard output. .It Fl Fl colour= Ns Oo Ar when Oc , Fl Fl color= Ns Oo Ar when Oc diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 166d3451774a..6fbd6bee8ace 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -57,9 +57,9 @@ const char *errstr[] = { "", /* 1*/ "(standard input)", /* 2*/ "unknown %s option", -/* 3*/ "usage: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A num] [-B num] [-C[num]]\n", +/* 3*/ "usage: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A num] [-B num] [-C num]\n", /* 4*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n", -/* 5*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n", +/* 5*/ "\t[--context=num] [--directories=action] [--label] [--line-buffered]\n", /* 6*/ "\t[--null] [pattern] [file ...]\n", /* 7*/ "Binary file %s matches\n", /* 8*/ "%s (BSD grep, GNU compatible) %s\n", From owner-dev-commits-src-all@freebsd.org Sun Aug 15 21:03:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 624816665F8; Sun, 15 Aug 2021 21:03: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 4GnqWn3Hq3z4bBt; Sun, 15 Aug 2021 21:03: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 4DC561CFD5; Sun, 15 Aug 2021 21:03: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 17FL3HQp006056; Sun, 15 Aug 2021 21:03:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FL3Had006055; Sun, 15 Aug 2021 21:03:17 GMT (envelope-from git) Date: Sun, 15 Aug 2021 21:03:17 GMT Message-Id: <202108152103.17FL3Had006055@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: c8faaf378709 - stable/13 - ports.7: Document DEBUG_FLAGS and the process of debugging ports MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c8faaf378709f4ce4661da7ca73ee88e1cc63d54 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 21:03:18 -0000 The branch stable/13 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c8faaf378709f4ce4661da7ca73ee88e1cc63d54 commit c8faaf378709f4ce4661da7ca73ee88e1cc63d54 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-04-17 20:51:54 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-08-15 21:02:08 +0000 ports.7: Document DEBUG_FLAGS and the process of debugging ports Loosely based on https://wiki.freebsd.org/BenWoods/DebuggingPorts. Reviewed by: crees MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27296 (cherry picked from commit d25f7d324a9d0c33655876b920ba590918d16f4c) --- share/man/man7/ports.7 | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/share/man/man7/ports.7 b/share/man/man7/ports.7 index 1c3cce31d2f0..797fed0d3ec6 100644 --- a/share/man/man7/ports.7 +++ b/share/man/man7/ports.7 @@ -558,6 +558,13 @@ If set, debugging symbols are installed for ports binaries. .It Va WITH_DEBUG_PORTS A list of origins for which to set .Va WITH_DEBUG . +.It Va DEBUG_FLAGS +.Pq Default: Ql -g +Additional +.Va CFLAGS +to set when +.Va WITH_DEBUG +is set. .It Va WITH_CCACHE_BUILD .Pq Vt bool If set, enables the use of @@ -643,6 +650,58 @@ DISABLE_MAKE_JOBS= yes TRYBROKEN= yes \&.endif .Ed +.It Sy Example 6\&: No Debugging Ports +By default ports are built and packaged without debugging support (e.g., +debugging symbols are stripped from binaries, optimization flags are used for +compiling, verbose logging is disabled). +Whether ports are built with debugging symbols can be controlled by the +settings in +.Xr make.conf 5 , +e.g., +.Bd -literal -offset 2n +# Enable debugging for all ports. +WITH_DEBUG= yes +# Enable debugging for selected ports. +WITH_DEBUG_PORTS= mail/dovecot security/krb5 +.Ed +.Pp +It is also possible to use the debug variables on the command line: +.Bd -literal -offset 2n +.Li # Ic make -DWITH_DEBUG DEBUG_FLAGS="-g -O0" build +.Ed +.Pp +See the +.Sx MAKE VARIABLES +section to learn more about the debug variables. +.Pp +To understand the details of what happens when the debug variables are set it +is best to consult the files located at +.Pa ${PORTSDIR}/Mk/* +.Po Pa bsd.port.mk +in particular +.Pc . +.Pp +If debugging is enabled for a specific port, the ports framework will: +.Bl -bullet +.It +Add +.Va DEBUG_FLAGS +(defaults to +.Ql -g ) +to +.Va CFLAGS . +.It +Try to prevent the binaries from being stripped (including checking the install +target to replace +.Ql install-strip +with +.Ql install ) . +Whether a binary has been stripped can be checked with +.Xr file 1 . +.It +Try to enable other debugging features like debug build type or verbose logging. +However, this is port-specific and the ports framework might not be aware of +each supported debugging feature a given piece of software has to offer). .El .Sh SEE ALSO .Xr make 1 , From owner-dev-commits-src-all@freebsd.org Sun Aug 15 21:15:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 25257666C0E; Sun, 15 Aug 2021 21:15: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 4GnqpK0QlJz4f6H; Sun, 15 Aug 2021 21:15: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 EB99B1D40C; Sun, 15 Aug 2021 21:15: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 17FLFqY6020273; Sun, 15 Aug 2021 21:15:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FLFqZe020272; Sun, 15 Aug 2021 21:15:52 GMT (envelope-from git) Date: Sun, 15 Aug 2021 21:15:52 GMT Message-Id: <202108152115.17FLFqZe020272@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 90146cfa3180 - stable/12 - grep: Fix an incorrect description of the -C flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 90146cfa3180ee6f8e183f3fb31cdde2e4fc6417 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 21:15:53 -0000 The branch stable/12 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=90146cfa3180ee6f8e183f3fb31cdde2e4fc6417 commit 90146cfa3180ee6f8e183f3fb31cdde2e4fc6417 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-02-05 18:38:09 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-08-15 21:08:29 +0000 grep: Fix an incorrect description of the -C flag It seems that the number of lines is no longer an optional parameter to the -C flag. Document it accordingly both in the manual page and the usage message. Reviewed by: yuripv Approved by: yuripv MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28509 (cherry picked from commit be6b8b7a3a18acb3b044e144d946392fca05e5d0) --- usr.bin/grep/grep.1 | 21 +++++++++------------ usr.bin/grep/grep.c | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/usr.bin/grep/grep.1 b/usr.bin/grep/grep.1 index 9aac1cc6ca92..af3aec95cb19 100644 --- a/usr.bin/grep/grep.1 +++ b/usr.bin/grep/grep.1 @@ -30,7 +30,7 @@ .\" .\" @(#)grep.1 8.3 (Berkeley) 4/18/94 .\" -.Dd February 11, 2021 +.Dd April 17, 2021 .Dt GREP 1 .Os .Sh NAME @@ -45,13 +45,13 @@ .Op Fl abcdDEFGHhIiLlmnOopqRSsUVvwxz .Op Fl A Ar num .Op Fl B Ar num -.Op Fl C Ns Op Ar num +.Op Fl C Ar num .Op Fl e Ar pattern .Op Fl f Ar file .Op Fl Fl binary-files= Ns Ar value .Op Fl Fl color Ns Op Cm = Ns Ar when .Op Fl Fl colour Ns Op Cm = Ns Ar when -.Op Fl Fl context Ns Op Cm = Ns Ar num +.Op Fl Fl context= Ns Ar num .Op Fl Fl label .Op Fl Fl line-buffered .Op Fl Fl null @@ -123,18 +123,15 @@ options. .It Fl b , Fl Fl byte-offset The offset in bytes of a matched pattern is displayed in front of the respective matched line. -.It Fl C Ns Oo Ar num Oc , Fl Fl context Ns Oo = Ns Ar num Oc +.It Fl C Ar num , Fl Fl context= Ns Ar num Print .Ar num lines of leading and trailing context surrounding each match. -The default value of -.Ar num -is -.Dq 2 -and is equivalent to -.Dq Fl A Ar 2 Fl B Ar 2 . -Note: -no whitespace may be given between the option and its argument. +See also the +.Fl A +and +.Fl B +options. .It Fl c , Fl Fl count Only a count of selected lines is written to standard output. .It Fl Fl colour= Ns Oo Ar when Oc , Fl Fl color= Ns Oo Ar when Oc diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index a9c67c268b47..b9dc97661fd6 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -57,9 +57,9 @@ const char *errstr[] = { "", /* 1*/ "(standard input)", /* 2*/ "unknown %s option", -/* 3*/ "usage: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A num] [-B num] [-C[num]]\n", +/* 3*/ "usage: %s [-abcDEFGHhIiLlmnOoPqRSsUVvwxz] [-A num] [-B num] [-C num]\n", /* 4*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n", -/* 5*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n", +/* 5*/ "\t[--context=num] [--directories=action] [--label] [--line-buffered]\n", /* 6*/ "\t[--null] [pattern] [file ...]\n", /* 7*/ "Binary file %s matches\n", /* 8*/ "%s (BSD grep) %s\n", From owner-dev-commits-src-all@freebsd.org Sun Aug 15 21:19:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D6148666AB7; Sun, 15 Aug 2021 21:19:42 +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 4Gnqtk5YVRz4dpM; Sun, 15 Aug 2021 21:19:42 +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 A313F1D2EA; Sun, 15 Aug 2021 21:19:42 +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 17FLJg1G020745; Sun, 15 Aug 2021 21:19:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FLJgnv020744; Sun, 15 Aug 2021 21:19:42 GMT (envelope-from git) Date: Sun, 15 Aug 2021 21:19:42 GMT Message-Id: <202108152119.17FLJgnv020744@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 5cdee2441ed9 - stable/13 - getprogname.3: Add an example MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5cdee2441ed9cffca7462c88205e70bba61a4d6b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 21:19:42 -0000 The branch stable/13 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5cdee2441ed9cffca7462c88205e70bba61a4d6b commit 5cdee2441ed9cffca7462c88205e70bba61a4d6b Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-04-17 21:26:54 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-08-15 21:19:09 +0000 getprogname.3: Add an example It shows the difference between getprogname() and argv[0]. Reviewed by: yuripv Approved by: yuripv (src) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27204 (cherry picked from commit 1ffdcdadf61423dd02ddad82fc4f3f6c39090c8c) --- lib/libc/gen/getprogname.3 | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/libc/gen/getprogname.3 b/lib/libc/gen/getprogname.3 index 53d39a60526b..f43a7b8c6b69 100644 --- a/lib/libc/gen/getprogname.3 +++ b/lib/libc/gen/getprogname.3 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 1, 2001 +.Dd April 18, 2021 .Dt GETPROGNAME 3 .Os .Sh NAME @@ -84,6 +84,32 @@ Calling .Fn setprogname allows the aforementioned library to learn the program name without modifications to the start-up code. +.Sh EXAMPLES +The following example presents a simple program, which shows the difference +between +.Fn getprogname +and +.Va "argv[0]" . +.Bd -literal -offset indent +#include +#include + +int +main(int argc, char** argv) +{ + printf("getprogname(): %s\en", getprogname()); + printf("argv[0]: %s\en", argv[0]); + return (0); +} +.Ed +.Pp +When compiled and executed (e.g., with +.Ql ./a.out ) +the output of the program is going to look like this: +.Bd -literal -offset indent +getprogname(): a.out +argv[0]: ./a.out +.Ed .Sh SEE ALSO .Xr err 3 , .Xr setproctitle 3 From owner-dev-commits-src-all@freebsd.org Sun Aug 15 21:20:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7DE57666AC6; Sun, 15 Aug 2021 21:20: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 4GnqvT1vNSz4f7f; Sun, 15 Aug 2021 21:20: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 2A4D71D3B2; Sun, 15 Aug 2021 21:20: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 17FLKLgV028661; Sun, 15 Aug 2021 21:20:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FLKLTs028655; Sun, 15 Aug 2021 21:20:21 GMT (envelope-from git) Date: Sun, 15 Aug 2021 21:20:21 GMT Message-Id: <202108152120.17FLKLTs028655@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 2e34e54d4bf5 - stable/12 - getprogname.3: Add an example MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2e34e54d4bf50258cbda4f14deb4863cf8fcbf65 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 21:20:21 -0000 The branch stable/12 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=2e34e54d4bf50258cbda4f14deb4863cf8fcbf65 commit 2e34e54d4bf50258cbda4f14deb4863cf8fcbf65 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-04-17 21:26:54 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-08-15 21:20:07 +0000 getprogname.3: Add an example It shows the difference between getprogname() and argv[0]. Reviewed by: yuripv Approved by: yuripv (src) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27204 (cherry picked from commit 1ffdcdadf61423dd02ddad82fc4f3f6c39090c8c) --- lib/libc/gen/getprogname.3 | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/libc/gen/getprogname.3 b/lib/libc/gen/getprogname.3 index 53d39a60526b..f43a7b8c6b69 100644 --- a/lib/libc/gen/getprogname.3 +++ b/lib/libc/gen/getprogname.3 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 1, 2001 +.Dd April 18, 2021 .Dt GETPROGNAME 3 .Os .Sh NAME @@ -84,6 +84,32 @@ Calling .Fn setprogname allows the aforementioned library to learn the program name without modifications to the start-up code. +.Sh EXAMPLES +The following example presents a simple program, which shows the difference +between +.Fn getprogname +and +.Va "argv[0]" . +.Bd -literal -offset indent +#include +#include + +int +main(int argc, char** argv) +{ + printf("getprogname(): %s\en", getprogname()); + printf("argv[0]: %s\en", argv[0]); + return (0); +} +.Ed +.Pp +When compiled and executed (e.g., with +.Ql ./a.out ) +the output of the program is going to look like this: +.Bd -literal -offset indent +getprogname(): a.out +argv[0]: ./a.out +.Ed .Sh SEE ALSO .Xr err 3 , .Xr setproctitle 3 From owner-dev-commits-src-all@freebsd.org Sun Aug 15 22:24:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 65EEA667253; Sun, 15 Aug 2021 22:24:01 +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 4GnsJx2Ph0z4jq1; Sun, 15 Aug 2021 22:24: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 3A3E01E409; Sun, 15 Aug 2021 22:24: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 17FMO1To013612; Sun, 15 Aug 2021 22:24:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FMO1wg013611; Sun, 15 Aug 2021 22:24:01 GMT (envelope-from git) Date: Sun, 15 Aug 2021 22:24:01 GMT Message-Id: <202108152224.17FMO1wg013611@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 4a77a9b64910 - main - routing: Use process fib instead of fib 0 when conducting tests. 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/main X-Git-Reftype: branch X-Git-Commit: 4a77a9b6491093b9a8bb786a861ed74ddf156e8e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 22:24:01 -0000 The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=4a77a9b6491093b9a8bb786a861ed74ddf156e8e commit 4a77a9b6491093b9a8bb786a861ed74ddf156e8e Author: Alexander V. Chernikov AuthorDate: 2021-08-15 22:05:41 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-08-15 22:10:14 +0000 routing: Use process fib instead of fib 0 when conducting tests. * Allow to do validation/performance tests by using process fib instead of default fib 0. * Print all validation errors instead of just the first one. MFC after: 1 week --- sys/tests/fib_lookup/fib_lookup.c | 63 ++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/sys/tests/fib_lookup/fib_lookup.c b/sys/tests/fib_lookup/fib_lookup.c index 927664166fdd..55d2f3d4a4df 100644 --- a/sys/tests/fib_lookup/fib_lookup.c +++ b/sys/tests/fib_lookup/fib_lookup.c @@ -159,7 +159,7 @@ SYSCTL_PROC(_net_route_test, OID_AUTO, add_inet6_addr, add_inet6_addr_sysctl_handler, "A", "Set"); static uint64_t -run_test_inet_one_pass() +run_test_inet_one_pass(uint32_t fibnum) { /* Assume epoch */ int sz = V_inet_list_size; @@ -169,7 +169,7 @@ run_test_inet_one_pass() for (int pass = 0; pass < tries; pass++) { for (int i = 0; i < sz; i++) { - fib4_lookup(RT_DEFAULT_FIB, a[i], 0, NHR_NONE, 0); + fib4_lookup(fibnum, a[i], 0, NHR_NONE, 0); count++; } } @@ -199,11 +199,12 @@ run_test_inet(SYSCTL_HANDLER_ARGS) struct timespec ts_pre, ts_post; int64_t pass_diff, total_diff = 0; uint64_t pass_packets, total_packets = 0; + uint32_t fibnum = curthread->td_proc->p_fibnum; for (int pass = 0; pass < count / CHUNK_SIZE; pass++) { NET_EPOCH_ENTER(et); nanouptime(&ts_pre); - pass_packets = run_test_inet_one_pass(); + pass_packets = run_test_inet_one_pass(fibnum); nanouptime(&ts_post); NET_EPOCH_EXIT(et); @@ -223,7 +224,7 @@ SYSCTL_PROC(_net_route_test, OID_AUTO, run_inet, 0, 0, run_test_inet, "I", "Execute fib4_lookup test"); static uint64_t -run_test_inet6_one_pass() +run_test_inet6_one_pass(uint32_t fibnum) { /* Assume epoch */ int sz = V_inet6_list_size; @@ -233,7 +234,7 @@ run_test_inet6_one_pass() for (int pass = 0; pass < tries; pass++) { for (int i = 0; i < sz; i++) { - fib6_lookup(RT_DEFAULT_FIB, &a[i], 0, NHR_NONE, 0); + fib6_lookup(fibnum, &a[i], 0, NHR_NONE, 0); count++; } } @@ -263,11 +264,12 @@ run_test_inet6(SYSCTL_HANDLER_ARGS) struct timespec ts_pre, ts_post; int64_t pass_diff, total_diff = 0; uint64_t pass_packets, total_packets = 0; + uint32_t fibnum = curthread->td_proc->p_fibnum; for (int pass = 0; pass < count / CHUNK_SIZE; pass++) { NET_EPOCH_ENTER(et); nanouptime(&ts_pre); - pass_packets = run_test_inet6_one_pass(); + pass_packets = run_test_inet6_one_pass(fibnum); nanouptime(&ts_post); NET_EPOCH_EXIT(et); @@ -325,7 +327,7 @@ cmp_dst(uint32_t fibnum, struct in_addr a) /* Random lookups: correctness verification */ static uint64_t -run_test_inet_one_pass_random() +run_test_inet_one_pass_random(uint32_t fibnum) { /* Assume epoch */ struct in_addr a[64]; @@ -335,7 +337,7 @@ run_test_inet_one_pass_random() for (int pass = 0; pass < CHUNK_SIZE / sz; pass++) { arc4random_buf(a, sizeof(a)); for (int i = 0; i < sz; i++) { - if (!cmp_dst(RT_DEFAULT_FIB, a[i])) + if (!cmp_dst(fibnum, a[i])) return (0); count++; } @@ -362,11 +364,12 @@ run_test_inet_random(SYSCTL_HANDLER_ARGS) struct timespec ts_pre, ts_post; int64_t pass_diff, total_diff = 1; uint64_t pass_packets, total_packets = 0; + uint32_t fibnum = curthread->td_proc->p_fibnum; for (int pass = 0; pass < count / CHUNK_SIZE; pass++) { NET_EPOCH_ENTER(et); nanouptime(&ts_pre); - pass_packets = run_test_inet_one_pass_random(); + pass_packets = run_test_inet_one_pass_random(fibnum); nanouptime(&ts_post); NET_EPOCH_EXIT(et); @@ -396,8 +399,9 @@ SYSCTL_PROC(_net_route_test, OID_AUTO, run_inet_random, struct inet_array { uint32_t alloc_items; uint32_t num_items; - struct in_addr *arr; + uint32_t rnh_prefixes; int error; + struct in_addr *arr; }; /* @@ -412,9 +416,11 @@ add_prefix(struct rtentry *rt, void *_data) int plen; uint32_t scopeid, haddr; + pa->rnh_prefixes++; + if (pa->num_items + 5 >= pa->alloc_items) { if (pa->error == 0) - pa->error = EINVAL; + pa->error = ENOSPC; return (0); } @@ -442,13 +448,18 @@ prepare_list(uint32_t fibnum, struct inet_array *pa) rh = rt_tables_get_rnh(fibnum, AF_INET); - uint32_t num_prefixes = (rh->rnh_prefixes + 10) * 5; + uint32_t num_prefixes = rh->rnh_prefixes; bzero(pa, sizeof(struct inet_array)); - pa->alloc_items = num_prefixes; - pa->arr = mallocarray(num_prefixes, sizeof(struct in_addr), + pa->alloc_items = (num_prefixes + 10) * 5; + pa->arr = mallocarray(pa->alloc_items, sizeof(struct in_addr), M_TEMP, M_ZERO | M_WAITOK); - rib_walk(RT_DEFAULT_FIB, AF_INET, false, add_prefix, pa); + rib_walk(fibnum, AF_INET, false, add_prefix, pa); + + if (pa->error != 0) { + printf("prefixes: old: %u, current: %u, walked: %u, allocated: %u\n", + num_prefixes, rh->rnh_prefixes, pa->rnh_prefixes, pa->alloc_items); + } return (pa->error == 0); } @@ -467,20 +478,21 @@ run_test_inet_scan(SYSCTL_HANDLER_ARGS) return (0); struct inet_array pa = {}; + uint32_t fibnum = curthread->td_proc->p_fibnum; - if (!prepare_list(RT_DEFAULT_FIB, &pa)) + if (!prepare_list(fibnum, &pa)) return (pa.error); struct timespec ts_pre, ts_post; int64_t total_diff = 1; uint64_t total_packets = 0; + int failure_count = 0; NET_EPOCH_ENTER(et); nanouptime(&ts_pre); for (int i = 0; i < pa.num_items; i++) { - if (!cmp_dst(RT_DEFAULT_FIB, pa.arr[i])) { - error = EINVAL; - break; + if (!cmp_dst(fibnum, pa.arr[i])) { + failure_count++; } total_packets++; } @@ -491,8 +503,10 @@ run_test_inet_scan(SYSCTL_HANDLER_ARGS) free(pa.arr, M_TEMP); /* Signal error to userland */ - if (error != 0) - return (error); + if (failure_count > 0) { + printf("[RT ERROR] total failures: %d\n", failure_count); + return (EINVAL); + } total_diff = (ts_post.tv_sec - ts_pre.tv_sec) * 1000000000 + (ts_post.tv_nsec - ts_pre.tv_nsec); @@ -540,7 +554,7 @@ rnd_lps(SYSCTL_HANDLER_ARGS) struct timespec ts_pre, ts_post; struct nhop_object *nh_fib; uint64_t total_diff, lps; - uint32_t *keys; + uint32_t *keys, fibnum; uint32_t t, p; uintptr_t acc = 0; int i, pos, count = 0; @@ -552,6 +566,7 @@ rnd_lps(SYSCTL_HANDLER_ARGS) return (error); if (count <= 0) return (0); + fibnum = curthread->td_proc->p_fibnum; keys = malloc(sizeof(*keys) * count, M_TEMP, M_NOWAIT); if (keys == NULL) @@ -564,7 +579,7 @@ rnd_lps(SYSCTL_HANDLER_ARGS) wa.lim = count; printf("Reducing keys to announced address space...\n"); do { - rib_walk(RT_DEFAULT_FIB, AF_INET, false, reduce_keys, + rib_walk(fibnum, AF_INET, false, reduce_keys, &wa); } while (wa.pos < wa.lim); printf("Reshuffling keys...\n"); @@ -593,7 +608,7 @@ rnd_lps(SYSCTL_HANDLER_ARGS) nanouptime(&ts_pre); for (i = 0, pos = 0; i < count; i++) { key.s_addr = keys[pos++] ^ ((acc >> 10) & 0xff); - nh_fib = fib4_lookup(RT_DEFAULT_FIB, key, 0, NHR_NONE, 0); + nh_fib = fib4_lookup(fibnum, key, 0, NHR_NONE, 0); if (seq) { if (nh_fib != NULL) { acc += (uintptr_t) nh_fib + 123; From owner-dev-commits-src-all@freebsd.org Sun Aug 15 23:46:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5D23A668874; Sun, 15 Aug 2021 23:46: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 4Gnv7c283Wz4rQ3; Sun, 15 Aug 2021 23:46: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 2E6151F0D0; Sun, 15 Aug 2021 23:46: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 17FNk4Ev019329; Sun, 15 Aug 2021 23:46:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FNk4FS019328; Sun, 15 Aug 2021 23:46:04 GMT (envelope-from git) Date: Sun, 15 Aug 2021 23:46:04 GMT Message-Id: <202108152346.17FNk4FS019328@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: a54cdded3d65 - stable/13 - nfscl: Cache an open stateid for the "oneopenown" mount option 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: a54cdded3d6570997b8216df003767d663856533 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 23:46:04 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=a54cdded3d6570997b8216df003767d663856533 commit a54cdded3d6570997b8216df003767d663856533 Author: Rick Macklem AuthorDate: 2021-07-28 22:48:27 +0000 Commit: Rick Macklem CommitDate: 2021-08-15 23:41:18 +0000 nfscl: Cache an open stateid for the "oneopenown" mount option For NFSv4.1/4.2, if the "oneopenown" mount option is used, there is, at most, only one open stateid for each NFS vnode. When an open stateid for a file is acquired, set a pointer to the open structure in the NFS vnode. This pointer can be used to acquire the open stateid without searching the open linked list when the following is true: - No delegations have been issued for the file. Since delegations can outlive an NFS vnode for a file, use the global NFSMNTP_DELEGISSUED flag on the mount to determine this. - No lock stateid has been issued for the file. To determine this, a new NFS vnode flag called NMIGHTBELOCKED is set when a lock stateid is issued, which can then be tested. When this open structure pointer can be used, it avoids the need to acquire the NFSCLSTATELOCK() and searching the open structure list for an open. The NFSCLSTATELOCK() can be highly contended when there are a lot of opens issued for the NFSv4.1/4.2 mount. This patch only affects NFSv4.1/4.2 mounts when the "oneopenown" mount option is used. (cherry picked from commit efea1bc1fd93831c29fa7594d67094e0c125fb88) --- sys/fs/nfsclient/nfs_clnode.c | 11 ++++++++--- sys/fs/nfsclient/nfs_clrpcops.c | 8 +++++++- sys/fs/nfsclient/nfs_clstate.c | 36 ++++++++++++++++++++++++++++++++++++ sys/fs/nfsclient/nfs_clvnops.c | 17 +++++++++++++++++ sys/fs/nfsclient/nfsnode.h | 2 ++ 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c index 1c0e855ff5a9..9718c2c36a3c 100644 --- a/sys/fs/nfsclient/nfs_clnode.c +++ b/sys/fs/nfsclient/nfs_clnode.c @@ -243,7 +243,11 @@ ncl_inactive(struct vop_inactive_args *ap) boolean_t retv; td = curthread; + np = VTONFS(vp); if (NFS_ISV4(vp) && vp->v_type == VREG) { + NFSLOCKNODE(np); + np->n_openstateid = NULL; + NFSUNLOCKNODE(np); /* * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4 * Close operations are delayed until now. Any dirty @@ -263,7 +267,6 @@ ncl_inactive(struct vop_inactive_args *ap) } } - np = VTONFS(vp); NFSLOCKNODE(np); ncl_releasesillyrename(vp, td); @@ -303,9 +306,10 @@ ncl_reclaim(struct vop_reclaim_args *ap) NFSLOCKNODE(np); ncl_releasesillyrename(vp, td); - NFSUNLOCKNODE(np); if (NFS_ISV4(vp) && vp->v_type == VREG) { + np->n_openstateid = NULL; + NFSUNLOCKNODE(np); /* * We can now safely close any remaining NFSv4 Opens for * this file. Most opens will have already been closed by @@ -325,7 +329,8 @@ ncl_reclaim(struct vop_reclaim_args *ap) nfscl_delegreturnvp(vp, td); } else MNT_IUNLOCK(mp); - } + } else + NFSUNLOCKNODE(np); vfs_hash_remove(vp); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 6093f7c0adeb..2f6226e38415 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -457,8 +457,14 @@ else printf(" fhl=0\n"); * If error is non-zero, don't increment it, since the Open * hasn't succeeded yet. */ - if (!error) + if (!error) { op->nfso_opencnt++; + if (NFSHASNFSV4N(nmp) && NFSHASONEOPENOWN(nmp)) { + NFSLOCKNODE(np); + np->n_openstateid = op; + NFSUNLOCKNODE(np); + } + } nfscl_openrelease(nmp, op, error, newone); if (error == NFSERR_GRACE || error == NFSERR_STALECLIENTID || error == NFSERR_STALEDONTRECOVER || error == NFSERR_DELAY || diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 406dcc9d9b80..b90b500cc7a9 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -547,6 +547,34 @@ nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode, return (EISDIR); np = VTONFS(vp); nmp = VFSTONFS(vp->v_mount); + + /* + * For "oneopenown" mounts, first check for a cached open in the + * NFS vnode, that can be used as a stateid. This can only be + * done if no delegations have been issued to the mount and no + * byte range file locking has been done for the file. + */ + if (NFSHASNFSV4N(nmp) && NFSHASONEOPENOWN(nmp) && fords == 0) { + NFSLOCKMNT(nmp); + NFSLOCKNODE(np); + if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0 && + (np->n_flag & NMIGHTBELOCKED) == 0 && + np->n_openstateid != NULL) { + stateidp->seqid = 0; + stateidp->other[0] = + np->n_openstateid->nfso_stateid.other[0]; + stateidp->other[1] = + np->n_openstateid->nfso_stateid.other[1]; + stateidp->other[2] = + np->n_openstateid->nfso_stateid.other[2]; + NFSUNLOCKNODE(np); + NFSUNLOCKMNT(nmp); + return (0); + } + NFSUNLOCKNODE(np); + NFSUNLOCKMNT(nmp); + } + NFSLOCKCLSTATE(); clp = nfscl_findcl(nmp); if (clp == NULL) { @@ -4301,9 +4329,17 @@ nfscl_relock(vnode_t vp, struct nfsclclient *clp, struct nfsmount *nmp, { struct nfscllockowner *nlp; struct nfsfh *nfhp; + struct nfsnode *np; u_int64_t off, len; int error, newone, donelocally; + if (NFSHASNFSV4N(nmp) && NFSHASONEOPENOWN(nmp)) { + np = VTONFS(vp); + NFSLOCKNODE(np); + np->n_flag |= NMIGHTBELOCKED; + NFSUNLOCKNODE(np); + } + off = lop->nfslo_first; len = lop->nfslo_end - lop->nfslo_first; error = nfscl_getbytelock(vp, off, len, lop->nfslo_type, cred, p, diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 2311ea099042..72d9eac8e962 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3166,6 +3166,7 @@ nfs_advlock(struct vop_advlock_args *ap) struct vattr va; int ret, error; u_quad_t size; + struct nfsmount *nmp; error = NFSVOPLOCK(vp, LK_SHARED); if (error != 0) @@ -3195,6 +3196,22 @@ nfs_advlock(struct vop_advlock_args *ap) ap->a_flags)) (void) ncl_flush(vp, MNT_WAIT, td, 1, 0); + /* + * Mark NFS node as might have acquired a lock. + * This is separate from NHASBEENLOCKED, because it must + * be done before the nfsrpc_advlock() call, which might + * add a nfscllock structure to the client state. + * It is used to check for the case where a nfscllock + * state structure cannot exist for the file. + * Only done for "oneopenown" NFSv4.1/4.2 mounts. + */ + nmp = VFSTONFS(vp->v_mount); + if (NFSHASNFSV4N(nmp) && NFSHASONEOPENOWN(nmp)) { + NFSLOCKNODE(np); + np->n_flag |= NMIGHTBELOCKED; + NFSUNLOCKNODE(np); + } + /* * Loop around doing the lock op, while a blocking lock * must wait for the lock op to succeed. diff --git a/sys/fs/nfsclient/nfsnode.h b/sys/fs/nfsclient/nfsnode.h index 66a2de31551a..b34e362a8522 100644 --- a/sys/fs/nfsclient/nfsnode.h +++ b/sys/fs/nfsclient/nfsnode.h @@ -128,6 +128,7 @@ struct nfsnode { u_int64_t n_change; /* old Change attribute */ struct nfsv4node *n_v4; /* extra V4 stuff */ struct ucred *n_writecred; /* Cred. for putpages */ + struct nfsclopen *n_openstateid; /* Cached open stateid */ }; #define n_atim n_un1.nf_atim @@ -164,6 +165,7 @@ struct nfsnode { #define NHASBEENLOCKED 0x00080000 /* Has been file locked. */ #define NDSCOMMIT 0x00100000 /* Commit is done via the DS. */ #define NVNSETSZSKIP 0x00200000 /* Skipped vnode_pager_setsize() */ +#define NMIGHTBELOCKED 0x00400000 /* Might be file locked. */ /* * Convert between nfsnode pointers and vnode pointers From owner-dev-commits-src-all@freebsd.org Sun Aug 15 23:50:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C98D66877B; Sun, 15 Aug 2021 23:50: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 4GnvDq2YwZz4rYY; Sun, 15 Aug 2021 23:50: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 403521F413; Sun, 15 Aug 2021 23:50: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 17FNoZ1W027918; Sun, 15 Aug 2021 23:50:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17FNoZLh027917; Sun, 15 Aug 2021 23:50:35 GMT (envelope-from git) Date: Sun, 15 Aug 2021 23:50:35 GMT Message-Id: <202108152350.17FNoZLh027917@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: 181044a10169 - stable/13 - nfscl: Set correct lockowner for "oneopenown" mount option 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: 181044a10169fc0c7568131a2a7f355340428f87 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2021 23:50:35 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=181044a10169fc0c7568131a2a7f355340428f87 commit 181044a10169fc0c7568131a2a7f355340428f87 Author: Rick Macklem AuthorDate: 2021-07-28 22:23:05 +0000 Commit: Rick Macklem CommitDate: 2021-08-15 23:47:20 +0000 nfscl: Set correct lockowner for "oneopenown" mount option For NFSv4.1/4.2, the client may use either an open, lock or delegation stateid as the stateid argument for an I/O operation. RFC 5661 defines an order of preference of delegation, then lock and finally open stateid for the argument, although NFSv4.1/4.2 servers are expected to handle any stateid type. For the "oneopenown" mount option, the lock owner was not being correctly generated and, as such, the I/O operation would use an open stateid, even when a lock stateid existed. Although this did not and should not affect an NFSv4.1/4.2 server's behaviour, this patch makes the behaviour for "oneopenown" the same as when the mount option is not specified. Found during inspection of packet captures. No failure during testing against NFSv4.1/4.2 servers of the unpatched code occurred. (cherry picked from commit 54ff3b3986741b9cd06ce20b90c96711cbe146d0) --- sys/fs/nfsclient/nfs_clstate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index b90b500cc7a9..bb2c78a72ed9 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -528,7 +528,7 @@ nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode, struct nfscldeleg *dp; struct nfsnode *np; struct nfsmount *nmp; - u_int8_t own[NFSV4CL_LOCKNAMELEN]; + u_int8_t own[NFSV4CL_LOCKNAMELEN], lockown[NFSV4CL_LOCKNAMELEN]; int error; bool done; @@ -631,9 +631,10 @@ nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode, nfscl_filllockowner(NULL, own, F_POSIX); else nfscl_filllockowner(p->td_proc, own, F_POSIX); + nfscl_filllockowner(p->td_proc, lockown, F_POSIX); lp = NULL; error = nfscl_getopen(NULL, clp->nfsc_openhash, nfhp, fhlen, - own, own, mode, &lp, &op); + own, lockown, mode, &lp, &op); if (error == 0 && lp != NULL && fords == 0) { /* Don't return a lock stateid for a DS. */ if (NFSHASNFSV4N(nmp))