From nobody Mon Oct 18 11:16:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3EFFE180531B; Mon, 18 Oct 2021 11:16: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 4HXvTd0tL6z3QTk; Mon, 18 Oct 2021 11:16: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 F1E431F0FD; Mon, 18 Oct 2021 11:16: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 19IBGqwG039501; Mon, 18 Oct 2021 11:16:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19IBGqJj039500; Mon, 18 Oct 2021 11:16:52 GMT (envelope-from git) Date: Mon, 18 Oct 2021 11:16:52 GMT Message-Id: <202110181116.19IBGqJj039500@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Yoshihiro Takahashi Subject: git: 3bfe213143c5 - stable/13 - unzip: Fix segmentation fault if a zip file contains buggy filename. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: nyan X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3bfe213143c562154e04d840380651f182df04de Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by nyan: URL: https://cgit.FreeBSD.org/src/commit/?id=3bfe213143c562154e04d840380651f182df04de commit 3bfe213143c562154e04d840380651f182df04de Author: Yoshihiro Takahashi AuthorDate: 2021-10-10 11:49:19 +0000 Commit: Yoshihiro Takahashi CommitDate: 2021-10-18 11:16:02 +0000 unzip: Fix segmentation fault if a zip file contains buggy filename. PR: 259011 Reported by: Robert Morris Submitted by: ak (cherry picked from commit 2c614481fd5248c1685e713f67d40cf2d5fba494) --- usr.bin/unzip/unzip.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/usr.bin/unzip/unzip.c b/usr.bin/unzip/unzip.c index e5ca1ff2c939..0b564b0f08ec 100644 --- a/usr.bin/unzip/unzip.c +++ b/usr.bin/unzip/unzip.c @@ -211,6 +211,9 @@ pathdup(const char *path) char *str; size_t i, len; + if (path == NULL || path[0] == '\0') + return (NULL); + len = strlen(path); while (len && path[len - 1] == '/') len--; @@ -697,7 +700,11 @@ extract(struct archive *a, struct archive_entry *e) mode_t filetype; char *p, *q; - pathname = pathdup(archive_entry_pathname(e)); + if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) { + warningx("skipping empty or unreadable filename entry"); + ac(archive_read_data_skip(a)); + return; + } filetype = archive_entry_filetype(e); /* sanity checks */ @@ -760,7 +767,11 @@ extract_stdout(struct archive *a, struct archive_entry *e) char *pathname; mode_t filetype; - pathname = pathdup(archive_entry_pathname(e)); + if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) { + warningx("skipping empty or unreadable filename entry"); + ac(archive_read_data_skip(a)); + return; + } filetype = archive_entry_filetype(e); /* I don't think this can happen in a zipfile.. */ From nobody Mon Oct 18 11:18:16 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C74081805913; Mon, 18 Oct 2021 11:18:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HXvWD56pGz3QsR; Mon, 18 Oct 2021 11:18: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 8EBA11F741; Mon, 18 Oct 2021 11:18: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 19IBIGJF039707; Mon, 18 Oct 2021 11:18:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19IBIGPX039706; Mon, 18 Oct 2021 11:18:16 GMT (envelope-from git) Date: Mon, 18 Oct 2021 11:18:16 GMT Message-Id: <202110181118.19IBIGPX039706@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Yoshihiro Takahashi Subject: git: 94c3735b74f7 - stable/12 - unzip: Fix segmentation fault if a zip file contains buggy filename. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: nyan X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 94c3735b74f796a8b271091a8ebc276021345d79 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by nyan: URL: https://cgit.FreeBSD.org/src/commit/?id=94c3735b74f796a8b271091a8ebc276021345d79 commit 94c3735b74f796a8b271091a8ebc276021345d79 Author: Yoshihiro Takahashi AuthorDate: 2021-10-10 11:49:19 +0000 Commit: Yoshihiro Takahashi CommitDate: 2021-10-18 11:17:27 +0000 unzip: Fix segmentation fault if a zip file contains buggy filename. PR: 259011 Reported by: Robert Morris Submitted by: ak (cherry picked from commit 2c614481fd5248c1685e713f67d40cf2d5fba494) --- usr.bin/unzip/unzip.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/usr.bin/unzip/unzip.c b/usr.bin/unzip/unzip.c index e5ca1ff2c939..0b564b0f08ec 100644 --- a/usr.bin/unzip/unzip.c +++ b/usr.bin/unzip/unzip.c @@ -211,6 +211,9 @@ pathdup(const char *path) char *str; size_t i, len; + if (path == NULL || path[0] == '\0') + return (NULL); + len = strlen(path); while (len && path[len - 1] == '/') len--; @@ -697,7 +700,11 @@ extract(struct archive *a, struct archive_entry *e) mode_t filetype; char *p, *q; - pathname = pathdup(archive_entry_pathname(e)); + if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) { + warningx("skipping empty or unreadable filename entry"); + ac(archive_read_data_skip(a)); + return; + } filetype = archive_entry_filetype(e); /* sanity checks */ @@ -760,7 +767,11 @@ extract_stdout(struct archive *a, struct archive_entry *e) char *pathname; mode_t filetype; - pathname = pathdup(archive_entry_pathname(e)); + if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) { + warningx("skipping empty or unreadable filename entry"); + ac(archive_read_data_skip(a)); + return; + } filetype = archive_entry_filetype(e); /* I don't think this can happen in a zipfile.. */ From nobody Mon Oct 18 13:08:46 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 094561812E78; Mon, 18 Oct 2021 13:08: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 4HXxyk6sxkz4f6f; Mon, 18 Oct 2021 13:08:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C89C020F30; Mon, 18 Oct 2021 13:08:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19ID8kAV086648; Mon, 18 Oct 2021 13:08:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19ID8kGP086647; Mon, 18 Oct 2021 13:08:46 GMT (envelope-from git) Date: Mon, 18 Oct 2021 13:08:46 GMT Message-Id: <202110181308.19ID8kGP086647@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: 116a988f99cd - stable/12 - geom_label: Add more validation for NTFS volume tasting List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 116a988f99cd9fcac1a34c17ec0aa81be70d5e4f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=116a988f99cd9fcac1a34c17ec0aa81be70d5e4f commit 116a988f99cd9fcac1a34c17ec0aa81be70d5e4f Author: Mark Johnston AuthorDate: 2021-10-04 21:48:44 +0000 Commit: Mark Johnston CommitDate: 2021-10-18 13:08:32 +0000 geom_label: Add more validation for NTFS volume tasting - Ensure that the computed MFT record size isn't negative or larger than maxphys before trying to read $Volume. - Guard against truncated records in volume metadata. - Ensure that the record length is large enough to contain the volume name. - Verify that the (UTF-16-encoded) volume name's length is a multiple of two. PR: 258833, 258914 Sponsored by: The FreeBSD Foundation (cherry picked from commit f0a08fa9f532a58f5d7a4814d6eb7ddd49f368da) --- sys/geom/label/g_label_ntfs.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/sys/geom/label/g_label_ntfs.c b/sys/geom/label/g_label_ntfs.c index 653524ab654c..bcf6a3a72b36 100644 --- a/sys/geom/label/g_label_ntfs.c +++ b/sys/geom/label/g_label_ntfs.c @@ -101,7 +101,8 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) struct ntfs_filerec *fr; struct ntfs_attr *atr; off_t voloff; - char *filerecp, *ap; + size_t recoff; + char *filerecp; int8_t mftrecsz; char vnchar; int recsize, j; @@ -117,8 +118,9 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) goto done; mftrecsz = bf->bf_mftrecsz; - recsize = (mftrecsz > 0) ? (mftrecsz * bf->bf_bps * bf->bf_spc) : (1 << -mftrecsz); - if (recsize == 0 || recsize % pp->sectorsize != 0) + recsize = (mftrecsz > 0) ? (mftrecsz * bf->bf_bps * bf->bf_spc) : + (1 << -mftrecsz); + if (recsize <= 0 || recsize > maxphys || recsize % pp->sectorsize != 0) goto done; voloff = bf->bf_mftcn * bf->bf_spc * bf->bf_bps + @@ -130,24 +132,33 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) if (filerecp == NULL) goto done; fr = (struct ntfs_filerec *)filerecp; - if (fr->fr_hdrmagic != NTFS_FILEMAGIC) goto done; - for (ap = filerecp + fr->fr_attroff; - atr = (struct ntfs_attr *)ap, atr->a_type != -1; - ap += atr->reclen) { + for (recoff = fr->fr_attroff; + recoff <= recsize - 2 * sizeof(uint32_t); + recoff += atr->reclen) { + atr = (struct ntfs_attr *)(filerecp + recoff); + if (atr->a_type == -1) + break; + if (atr->reclen < sizeof(*atr)) + break; + if (recsize - recoff < atr->reclen) + break; if (atr->a_type == NTFS_A_VOLUMENAME) { - if(atr->a_datalen >= size *2){ - label[0] = 0; - goto done; - } + if (atr->a_dataoff > atr->reclen || + atr->a_datalen > atr->reclen - atr->a_dataoff) + break; + /* - *UNICODE to ASCII. + * UNICODE to ASCII. * Should we need to use iconv(9)? */ + if (atr->a_datalen >= size * 2 || + atr->a_datalen % 2 != 0) + break; for (j = 0; j < atr->a_datalen; j++) { - vnchar = *(ap + atr->a_dataoff + j); + vnchar = ((char *)atr)[atr->a_dataoff + j]; if (j & 1) { if (vnchar) { label[0] = 0; From nobody Mon Oct 18 13:08:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3C1591812F6A; Mon, 18 Oct 2021 13:08: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 4HXxyq104Pz4fKW; Mon, 18 Oct 2021 13:08: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 F367320FDB; Mon, 18 Oct 2021 13:08: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 19ID8o8l086776; Mon, 18 Oct 2021 13:08:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19ID8oGD086775; Mon, 18 Oct 2021 13:08:50 GMT (envelope-from git) Date: Mon, 18 Oct 2021 13:08:50 GMT Message-Id: <202110181308.19ID8oGD086775@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: 41dbff735184 - stable/13 - geom_label: Add more validation for NTFS volume tasting List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 41dbff735184337b910b36a4ce963b36233916e4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=41dbff735184337b910b36a4ce963b36233916e4 commit 41dbff735184337b910b36a4ce963b36233916e4 Author: Mark Johnston AuthorDate: 2021-10-04 21:48:44 +0000 Commit: Mark Johnston CommitDate: 2021-10-18 13:07:58 +0000 geom_label: Add more validation for NTFS volume tasting - Ensure that the computed MFT record size isn't negative or larger than maxphys before trying to read $Volume. - Guard against truncated records in volume metadata. - Ensure that the record length is large enough to contain the volume name. - Verify that the (UTF-16-encoded) volume name's length is a multiple of two. PR: 258833, 258914 Sponsored by: The FreeBSD Foundation (cherry picked from commit f0a08fa9f532a58f5d7a4814d6eb7ddd49f368da) --- sys/geom/label/g_label_ntfs.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/sys/geom/label/g_label_ntfs.c b/sys/geom/label/g_label_ntfs.c index f78d4d28b967..888096164b09 100644 --- a/sys/geom/label/g_label_ntfs.c +++ b/sys/geom/label/g_label_ntfs.c @@ -99,7 +99,8 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) struct ntfs_filerec *fr; struct ntfs_attr *atr; off_t voloff; - char *filerecp, *ap; + size_t recoff; + char *filerecp; int8_t mftrecsz; char vnchar; int recsize, j; @@ -119,8 +120,9 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) goto done; mftrecsz = bf->bf_mftrecsz; - recsize = (mftrecsz > 0) ? (mftrecsz * bf->bf_bps * bf->bf_spc) : (1 << -mftrecsz); - if (recsize == 0 || recsize % pp->sectorsize != 0) + recsize = (mftrecsz > 0) ? (mftrecsz * bf->bf_bps * bf->bf_spc) : + (1 << -mftrecsz); + if (recsize <= 0 || recsize > maxphys || recsize % pp->sectorsize != 0) goto done; voloff = bf->bf_mftcn * bf->bf_spc * bf->bf_bps + @@ -132,24 +134,33 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) if (filerecp == NULL) goto done; fr = (struct ntfs_filerec *)filerecp; - if (fr->fr_hdrmagic != NTFS_FILEMAGIC) goto done; - for (ap = filerecp + fr->fr_attroff; - atr = (struct ntfs_attr *)ap, atr->a_type != -1; - ap += atr->reclen) { + for (recoff = fr->fr_attroff; + recoff <= recsize - 2 * sizeof(uint32_t); + recoff += atr->reclen) { + atr = (struct ntfs_attr *)(filerecp + recoff); + if (atr->a_type == -1) + break; + if (atr->reclen < sizeof(*atr)) + break; + if (recsize - recoff < atr->reclen) + break; if (atr->a_type == NTFS_A_VOLUMENAME) { - if(atr->a_datalen >= size *2){ - label[0] = 0; - goto done; - } + if (atr->a_dataoff > atr->reclen || + atr->a_datalen > atr->reclen - atr->a_dataoff) + break; + /* - *UNICODE to ASCII. + * UNICODE to ASCII. * Should we need to use iconv(9)? */ + if (atr->a_datalen >= size * 2 || + atr->a_datalen % 2 != 0) + break; for (j = 0; j < atr->a_datalen; j++) { - vnchar = *(ap + atr->a_dataoff + j); + vnchar = ((char *)atr)[atr->a_dataoff + j]; if (j & 1) { if (vnchar) { label[0] = 0; From nobody Mon Oct 18 13:09:28 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A0C8A1813A85; Mon, 18 Oct 2021 13:09: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 4HXxzX431zz4g8r; Mon, 18 Oct 2021 13:09: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 682D720EE2; Mon, 18 Oct 2021 13:09: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 19ID9SVh086961; Mon, 18 Oct 2021 13:09:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19ID9SYs086960; Mon, 18 Oct 2021 13:09:28 GMT (envelope-from git) Date: Mon, 18 Oct 2021 13:09:28 GMT Message-Id: <202110181309.19ID9SYs086960@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: feb3289f4977 - stable/13 - libctf: Improve check for duplicate SOU definitions in ctf_add_type() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: feb3289f497719267ae2fb95d38d6352dbac784e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=feb3289f497719267ae2fb95d38d6352dbac784e commit feb3289f497719267ae2fb95d38d6352dbac784e Author: Mark Johnston AuthorDate: 2021-10-04 16:28:22 +0000 Commit: Mark Johnston CommitDate: 2021-10-18 13:09:02 +0000 libctf: Improve check for duplicate SOU definitions in ctf_add_type() When copying a struct or union from one CTF container to another, ctf_add_type() checks whether it matches an existing type in the destination container. It does so by looking for a type with the same name and kind as the new type, and if one exists, it iterates over all members of the source type and checks whether a member with matching name and offset exists in the matched destination type. This can produce false positives, for example because member types are not compared, but this is not expected to arise in practice. If the match fails, ctf_add_type() returns an error. The procedure used for member comparison breaks down in the face of anonymous struct and union members. ctf_member_iter() visits each member in the source definition and looks up the corresponding member in the desination definition by name using ctf_member_info(), but this function will descend into anonymous members and thus fail to match. Fix the problem by introducing a custom comparison routine which does not assume member names are unique. This should also be faster for types with many members; in the previous scheme, membcmp() would perform a linear scan of the desination type's members to perform a lookup by name. The new routine steps through the members of both types in a single loop. PR: 258763 Sponsored by: The FreeBSD Foundation (cherry picked from commit 105fd928b0b5b35ab529e5f6914788dc49582901) --- cddl/contrib/opensolaris/common/ctf/ctf_create.c | 100 +++++++++++++++++------ 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/cddl/contrib/opensolaris/common/ctf/ctf_create.c b/cddl/contrib/opensolaris/common/ctf/ctf_create.c index ae4cc7f31176..3a080e71baa0 100644 --- a/cddl/contrib/opensolaris/common/ctf/ctf_create.c +++ b/cddl/contrib/opensolaris/common/ctf/ctf_create.c @@ -1196,17 +1196,6 @@ enumadd(const char *name, int value, void *arg) name, value) == CTF_ERR); } -/*ARGSUSED*/ -static int -membcmp(const char *name, ctf_id_t type, ulong_t offset, void *arg) -{ - ctf_bundle_t *ctb = arg; - ctf_membinfo_t ctm; - - return (ctf_member_info(ctb->ctb_file, ctb->ctb_type, - name, &ctm) == CTF_ERR || ctm.ctm_offset != offset); -} - static int membadd(const char *name, ctf_id_t type, ulong_t offset, void *arg) { @@ -1240,6 +1229,71 @@ membadd(const char *name, ctf_id_t type, ulong_t offset, void *arg) return (0); } +static long +soucmp(ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t *dst_fp, + ctf_id_t dst_type) +{ + const struct ctf_type *src_tp, *dst_tp; + const char *src_name, *dst_name; + ssize_t src_sz, dst_sz, src_inc, dst_inc; + uint_t kind, n; + + if ((src_type = ctf_type_resolve(src_fp, src_type)) == CTF_ERR) + return (CTF_ERR); + if ((dst_type = ctf_type_resolve(dst_fp, dst_type)) == CTF_ERR) + return (CTF_ERR); + + if ((src_tp = ctf_lookup_by_id(&src_fp, src_type)) == NULL) + return (CTF_ERR); + if ((dst_tp = ctf_lookup_by_id(&dst_fp, dst_type)) == NULL) + return (CTF_ERR); + + if ((kind = LCTF_INFO_KIND(src_fp, src_tp->ctt_info)) != + LCTF_INFO_KIND(dst_fp, dst_tp->ctt_info)) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + if ((n = LCTF_INFO_VLEN(src_fp, src_tp->ctt_info)) != + LCTF_INFO_VLEN(dst_fp, dst_tp->ctt_info)) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + + (void) ctf_get_ctt_size(src_fp, src_tp, &src_sz, &src_inc); + (void) ctf_get_ctt_size(dst_fp, dst_tp, &dst_sz, &dst_inc); + if (src_sz != dst_sz || src_inc != dst_inc) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + + if (src_sz < CTF_LSTRUCT_THRESH) { + const ctf_member_t *src_mp, *dst_mp; + + src_mp = (const ctf_member_t *)((uintptr_t)src_tp + src_inc); + dst_mp = (const ctf_member_t *)((uintptr_t)dst_tp + dst_inc); + for (; n != 0; n--, src_mp++, dst_mp++) { + if (src_mp->ctm_offset != dst_mp->ctm_offset) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + src_name = ctf_strptr(src_fp, src_mp->ctm_name); + dst_name = ctf_strptr(dst_fp, dst_mp->ctm_name); + if (strcmp(src_name, dst_name) != 0) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + } + } else { + const ctf_lmember_t *src_mp, *dst_mp; + + src_mp = (const ctf_lmember_t *)((uintptr_t)src_tp + src_inc); + dst_mp = (const ctf_lmember_t *)((uintptr_t)dst_tp + dst_inc); + for (; n != 0; n--, src_mp++, dst_mp++) { + if (src_mp->ctlm_offsethi != dst_mp->ctlm_offsethi || + src_mp->ctlm_offsetlo != dst_mp->ctlm_offsetlo) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + src_name = ctf_strptr(src_fp, src_mp->ctlm_name); + dst_name = ctf_strptr(dst_fp, dst_mp->ctlm_name); + if (strcmp(src_name, dst_name) != 0) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + } + } + + return (0); +} + /* * The ctf_add_type routine is used to copy a type from a source CTF container * to a dynamic destination container. This routine operates recursively by @@ -1460,23 +1514,15 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type) ctf_dmdef_t *dmd; int errs = 0; - /* - * Technically to match a struct or union we need to check both - * ways (src members vs. dst, dst members vs. src) but we make - * this more optimal by only checking src vs. dst and comparing - * the total size of the structure (which we must do anyway) - * which covers the possibility of dst members not in src. - * This optimization can be defeated for unions, but is so - * pathological as to render it irrelevant for our purposes. - */ if (dst_type != CTF_ERR && dst_kind != CTF_K_FORWARD) { - if (ctf_type_size(src_fp, src_type) != - ctf_type_size(dst_fp, dst_type)) - return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); - - if (ctf_member_iter(src_fp, src_type, membcmp, &dst)) - return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); - + /* + * Compare the sizes and fields of the two types. + * The field comparisons only check the names and + * offsets, so this is not perfect but is good enough + * for scenarios that we care about. + */ + if (soucmp(src_fp, src_type, dst_fp, dst_type) != 0) + return (CTF_ERR); /* errno is set for us */ break; } From nobody Mon Oct 18 13:18:55 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7AD5B17F0F84; Mon, 18 Oct 2021 13:18: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 4HXyBR2wYbz4kR2; Mon, 18 Oct 2021 13:18: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 459E72140C; Mon, 18 Oct 2021 13:18: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 19IDItZM000183; Mon, 18 Oct 2021 13:18:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19IDItLQ000182; Mon, 18 Oct 2021 13:18:55 GMT (envelope-from git) Date: Mon, 18 Oct 2021 13:18:55 GMT Message-Id: <202110181318.19IDItLQ000182@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: 35f1d655819e - stable/12 - geom_label: Fix the stable/12 build List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 35f1d655819e5d4d11ea1a11061f80e48e35f173 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=35f1d655819e5d4d11ea1a11061f80e48e35f173 commit 35f1d655819e5d4d11ea1a11061f80e48e35f173 Author: Mark Johnston AuthorDate: 2021-10-18 13:16:47 +0000 Commit: Mark Johnston CommitDate: 2021-10-18 13:16:47 +0000 geom_label: Fix the stable/12 build MAXPHYS is a constant here, use the right name. This is a direct commit to stable/12. Fixes: 116a988f99cd ("geom_label: Add more validation for NTFS volume tasting") Reported by: Jenkins --- sys/geom/label/g_label_ntfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/geom/label/g_label_ntfs.c b/sys/geom/label/g_label_ntfs.c index bcf6a3a72b36..dad55f601e16 100644 --- a/sys/geom/label/g_label_ntfs.c +++ b/sys/geom/label/g_label_ntfs.c @@ -120,7 +120,7 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size) mftrecsz = bf->bf_mftrecsz; recsize = (mftrecsz > 0) ? (mftrecsz * bf->bf_bps * bf->bf_spc) : (1 << -mftrecsz); - if (recsize <= 0 || recsize > maxphys || recsize % pp->sectorsize != 0) + if (recsize <= 0 || recsize > MAXPHYS || recsize % pp->sectorsize != 0) goto done; voloff = bf->bf_mftcn * bf->bf_spc * bf->bf_bps + From nobody Mon Oct 18 19:04:18 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6124D17F0CCF; Mon, 18 Oct 2021 19:04: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 4HY5ry2Lcjz4W1Y; Mon, 18 Oct 2021 19:04: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 319F925876; Mon, 18 Oct 2021 19:04: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 19IJ4IFd066454; Mon, 18 Oct 2021 19:04:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19IJ4Ile066453; Mon, 18 Oct 2021 19:04:18 GMT (envelope-from git) Date: Mon, 18 Oct 2021 19:04:18 GMT Message-Id: <202110181904.19IJ4Ile066453@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: cf560d6b3620 - stable/13 - acpi(4): Correct outdated sysctl List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cf560d6b3620851c4041581dbfd6eabc10bfc332 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by ygy (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=cf560d6b3620851c4041581dbfd6eabc10bfc332 commit cf560d6b3620851c4041581dbfd6eabc10bfc332 Author: Felix Johnson AuthorDate: 2021-10-13 00:42:14 +0000 Commit: Guangyuan Yang CommitDate: 2021-10-18 19:03:39 +0000 acpi(4): Correct outdated sysctl This changes the location of cx_supported sysctl to dev.cpu.N. PR: 214370 (cherry picked from commit 6882064d0ced456c89d161da4bc43c5d97bab60b) --- share/man/man4/acpi.4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man4/acpi.4 b/share/man/man4/acpi.4 index 8c221be870aa..0a865d9e7a38 100644 --- a/share/man/man4/acpi.4 +++ b/share/man/man4/acpi.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 9, 2015 +.Dd October 12, 2021 .Dt ACPI 4 .Os .Sh NAME @@ -86,7 +86,7 @@ should be set to .Li acpi if it is listed in .Va machdep.idle_available . -.It Va hw.acpi.cpu.cx_supported +.It Va dev.cpu.N.cx_supported List of supported CPU idle states and their transition latency in microseconds. Each state has a type (e.g., From nobody Mon Oct 18 19:16:34 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 20A5717F75E1; Mon, 18 Oct 2021 19:16: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 4HY67707w0z4bWl; Mon, 18 Oct 2021 19:16: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 D869F260B2; Mon, 18 Oct 2021 19:16: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 19IJGYI3079803; Mon, 18 Oct 2021 19:16:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19IJGYJP079802; Mon, 18 Oct 2021 19:16:34 GMT (envelope-from git) Date: Mon, 18 Oct 2021 19:16:34 GMT Message-Id: <202110181916.19IJGYJP079802@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: 351cad089f20 - stable/13 - bpf(4): Fix a misnamed constant List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 351cad089f204bb3a706dfefe1720736150778b0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by ygy (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=351cad089f204bb3a706dfefe1720736150778b0 commit 351cad089f204bb3a706dfefe1720736150778b0 Author: Felix Johnson AuthorDate: 2021-10-13 23:00:41 +0000 Commit: Guangyuan Yang CommitDate: 2021-10-18 19:16:01 +0000 bpf(4): Fix a misnamed constant rarpd.c was modified in r19859 to use REVARP_REQUEST instead of ARPOP_REVREQUEST. PR: 183333 Reported by: pluknet (cherry picked from commit a524aaf68341d9f83a0ef7dc21ad54728ddaaa1e) --- share/man/man4/bpf.4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man4/bpf.4 b/share/man/man4/bpf.4 index 66f4ae72918b..f285d5276376 100644 --- a/share/man/man4/bpf.4 +++ b/share/man/man4/bpf.4 @@ -49,7 +49,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 22, 2021 +.Dd October 13, 2021 .Dt BPF 4 .Os .Sh NAME @@ -1079,7 +1079,7 @@ struct bpf_insn insns[] = { BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETHERTYPE_REVARP, 0, 3), BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 20), - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, REVARP_REQUEST, 0, 1), + BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ARPOP_REVREQUEST, 0, 1), BPF_STMT(BPF_RET+BPF_K, sizeof(struct ether_arp) + sizeof(struct ether_header)), BPF_STMT(BPF_RET+BPF_K, 0), From nobody Tue Oct 19 03:36:30 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 964AD1803274; Tue, 19 Oct 2021 03:36: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 4HYKCy3c0Qz56lC; Tue, 19 Oct 2021 03:36: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 5B7CB4B63; Tue, 19 Oct 2021 03:36: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 19J3aUeq048274; Tue, 19 Oct 2021 03:36:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19J3aUcW048273; Tue, 19 Oct 2021 03:36:30 GMT (envelope-from git) Date: Tue, 19 Oct 2021 03:36:30 GMT Message-Id: <202110190336.19J3aUcW048273@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: 16f3a89d08b2 - stable/12 - nfscl: Fix a deadlock related to the NFSv4 clientID lock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 16f3a89d08b2deffccace6f605a9e9883cfbd4e2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=16f3a89d08b2deffccace6f605a9e9883cfbd4e2 commit 16f3a89d08b2deffccace6f605a9e9883cfbd4e2 Author: Rick Macklem AuthorDate: 2021-10-12 04:58:24 +0000 Commit: Rick Macklem CommitDate: 2021-10-19 03:31:47 +0000 nfscl: Fix a deadlock related to the NFSv4 clientID lock Without this patch, it is possible for a process doing an NFSv4 Open/create of a file to block to allow another process to acquire the exclusive lock on the clientID when holding a shared lock on the clientID. As such, both processes deadlock, with one wanting the exclusive lock, while the other holds the shared lock. This deadlock is unlikely to occur unless delegations are in use on the NFSv4 mount. This patch fixes the problem by not deferring to the process waiting for the exclusive lock when a shared lock (reference cnt) is already held by the process. This problem was detected during a recent NFSv4 interoperability testing event held by the IETF working group. (cherry picked from commit 120b20bdf49630cf2a7dbc5f93b9e985e1f4f198) --- sys/fs/nfs/nfs_var.h | 4 ++-- sys/fs/nfsclient/nfs_clrpcops.c | 12 ++++++------ sys/fs/nfsclient/nfs_clstate.c | 29 ++++++++++++++++------------- sys/fs/nfsclient/nfs_clvfsops.c | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 0f656601e531..5177a1c2c065 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -540,13 +540,13 @@ void nfsrpc_bindconnsess(CLIENT *, void *, struct ucred *); /* nfs_clstate.c */ int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int, struct ucred *, NFSPROC_T *, struct nfsclowner **, struct nfsclopen **, - int *, int *, int); + int *, int *, int, bool); int nfscl_getstateid(vnode_t, u_int8_t *, int, u_int32_t, int, struct ucred *, NFSPROC_T *, nfsv4stateid_t *, void **); void nfscl_ownerrelease(struct nfsmount *, struct nfsclowner *, int, int, int); void nfscl_openrelease(struct nfsmount *, struct nfsclopen *, int, int); int nfscl_getcl(struct mount *, struct ucred *, NFSPROC_T *, int, - struct nfsclclient **); + bool, struct nfsclclient **); struct nfsclclient *nfscl_findcl(struct nfsmount *); void nfscl_clientrelease(struct nfsclclient *); void nfscl_freelock(struct nfscllock *, int); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 3ff23a8b147b..3d26a1dfda88 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -365,7 +365,7 @@ else printf(" fhl=0\n"); do { dp = NULL; error = nfscl_open(vp, nfhp->nfh_fh, nfhp->nfh_len, mode, 1, - cred, p, NULL, &op, &newone, &ret, 1); + cred, p, NULL, &op, &newone, &ret, 1, true); if (error) { return (error); } @@ -1997,7 +1997,7 @@ nfsrpc_create(vnode_t dvp, char *name, int namelen, struct vattr *vap, dp = NULL; error = nfscl_open(dvp, NULL, 0, (NFSV4OPEN_ACCESSWRITE | NFSV4OPEN_ACCESSREAD), 0, cred, p, &owp, NULL, &newone, - NULL, 1); + NULL, 1, true); if (error) return (error); if (nmp->nm_clp != NULL) @@ -2283,7 +2283,7 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap, */ error = nfscl_open(dvp, nfhp->nfh_fh, nfhp->nfh_len, (NFSV4OPEN_ACCESSWRITE | NFSV4OPEN_ACCESSREAD), 0, - cred, p, NULL, &op, &newone, NULL, 0); + cred, p, NULL, &op, &newone, NULL, 0, false); if (error) goto nfsmout; op->nfso_stateid = stateid; @@ -3886,7 +3886,7 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, do { nd->nd_repstat = 0; if (op == F_GETLK) { - error = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); + error = nfscl_getcl(vnode_mount(vp), cred, p, 1, true, &clp); if (error) return (error); error = nfscl_lockt(vp, clp, off, len, fl, p, id, flags); @@ -3903,7 +3903,7 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, * We must loop around for all lockowner cases. */ callcnt = 0; - error = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); + error = nfscl_getcl(vnode_mount(vp), cred, p, 1, true, &clp); if (error) return (error); do { @@ -7537,7 +7537,7 @@ nfsrpc_createlayout(vnode_t dvp, char *name, int namelen, struct vattr *vap, */ error = nfscl_open(dvp, nfhp->nfh_fh, nfhp->nfh_len, (NFSV4OPEN_ACCESSWRITE | NFSV4OPEN_ACCESSREAD), 0, - cred, p, NULL, &op, &newone, NULL, 0); + cred, p, NULL, &op, &newone, NULL, 0, false); if (error != 0) goto nfsmout; op->nfso_stateid = stateid; diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 9965b7ca7e4f..92688fcfbe28 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -213,7 +213,7 @@ static short *nfscl_cberrmap[] = { int nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, struct ucred *cred, NFSPROC_T *p, struct nfsclowner **owpp, - struct nfsclopen **opp, int *newonep, int *retp, int lockit) + struct nfsclopen **opp, int *newonep, int *retp, int lockit, bool firstref) { struct nfsclclient *clp; struct nfsclowner *owp, *nowp; @@ -239,7 +239,7 @@ nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, if (nfhp != NULL) nop = malloc(sizeof (struct nfsclopen) + fhlen - 1, M_NFSCLOPEN, M_WAITOK); - ret = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); + ret = nfscl_getcl(vnode_mount(vp), cred, p, 1, firstref, &clp); if (ret != 0) { free(nowp, M_NFSCLOWNER); if (nop != NULL) @@ -778,7 +778,7 @@ nfscl_openrelease(struct nfsmount *nmp, struct nfsclopen *op, int error, */ int nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p, - int start_renewthread, struct nfsclclient **clpp) + int start_renewthread, bool firstref, struct nfsclclient **clpp) { struct nfsclclient *clp; struct nfsclclient *newclp = NULL; @@ -850,14 +850,16 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p, NFSCLSTATEMUTEXPTR, mp); if (igotlock == 0) { /* - * Call nfsv4_lock() with "iwantlock == 0" so that it will - * wait for a pending exclusive lock request. This gives the - * exclusive lock request priority over this shared lock - * request. + * Call nfsv4_lock() with "iwantlock == 0" on the firstref so + * that it will wait for a pending exclusive lock request. + * This gives the exclusive lock request priority over this + * shared lock request. * An exclusive lock on nfsc_lock is used mainly for server - * crash recoveries. + * crash recoveries and delegation recalls. */ - nfsv4_lock(&clp->nfsc_lock, 0, NULL, NFSCLSTATEMUTEXPTR, mp); + if (firstref) + nfsv4_lock(&clp->nfsc_lock, 0, NULL, NFSCLSTATEMUTEXPTR, + mp); nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, mp); } if (igotlock == 0 && NFSCL_FORCEDISM(mp)) { @@ -1032,7 +1034,8 @@ nfscl_getbytelock(vnode_t vp, u_int64_t off, u_int64_t len, if (recovery) clp = rclp; else - error = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); + error = nfscl_getcl(vnode_mount(vp), cred, p, 1, true, + &clp); } if (error) { free(nlp, M_NFSCLLOCKOWNER); @@ -1370,7 +1373,7 @@ nfscl_checkwritelocked(vnode_t vp, struct flock *fl, end = NFS64BITSSET; } - error = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); + error = nfscl_getcl(vnode_mount(vp), cred, p, 1, true, &clp); if (error) return (1); nfscl_filllockowner(id, own, flags); @@ -3140,7 +3143,7 @@ nfscl_getclose(vnode_t vp, struct nfsclclient **clpp) struct nfsfh *nfhp; int error, notdecr; - error = nfscl_getcl(vnode_mount(vp), NULL, NULL, 1, &clp); + error = nfscl_getcl(vnode_mount(vp), NULL, NULL, 1, true, &clp); if (error) return (error); *clpp = clp; @@ -3215,7 +3218,7 @@ nfscl_doclose(vnode_t vp, struct nfsclclient **clpp, NFSPROC_T *p) struct nfsclrecalllayout *recallp; int error; - error = nfscl_getcl(vnode_mount(vp), NULL, NULL, 1, &clp); + error = nfscl_getcl(vnode_mount(vp), NULL, NULL, 1, true, &clp); if (error) return (error); *clpp = clp; diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 1a1e1b122994..49a08e3787b4 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -1524,7 +1524,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, /* For NFSv4.1, get the clientid now. */ if (nmp->nm_minorvers > 0) { NFSCL_DEBUG(3, "at getcl\n"); - error = nfscl_getcl(mp, cred, td, 0, &clp); + error = nfscl_getcl(mp, cred, td, 0, true, &clp); NFSCL_DEBUG(3, "aft getcl=%d\n", error); if (error != 0) goto bad; From nobody Tue Oct 19 03:49:49 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 26AFE1808BBC; Tue, 19 Oct 2021 03:49: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 4HYKWL0Ky6z59NZ; Tue, 19 Oct 2021 03:49: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 E03E751A4; Tue, 19 Oct 2021 03:49: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 19J3nn51062150; Tue, 19 Oct 2021 03:49:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19J3nnGH062149; Tue, 19 Oct 2021 03:49:49 GMT (envelope-from git) Date: Tue, 19 Oct 2021 03:49:49 GMT Message-Id: <202110190349.19J3nnGH062149@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: 75d71cf8df8c - stable/12 - nfscl: Fix another deadlock related to the NFSv4 clientID lock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 75d71cf8df8c83b2b2bc3a16ef66a540a2ebac70 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=75d71cf8df8c83b2b2bc3a16ef66a540a2ebac70 commit 75d71cf8df8c83b2b2bc3a16ef66a540a2ebac70 Author: Rick Macklem AuthorDate: 2021-10-13 00:21:01 +0000 Commit: Rick Macklem CommitDate: 2021-10-19 03:46:00 +0000 nfscl: Fix another deadlock related to the NFSv4 clientID lock Without this patch, it is possible to hang the NFSv4 client, when a rename/remove is being done on a file where the client holds a delegation, if pNFS is being used. For a delegation to be returned, dirty data blocks must be flushed to the NFSv4 server. When pNFS is in use, a shared lock on the clientID must be acquired while doing a write to the DS(s). However, if rename/remove is doing the delegation return an exclusive lock will be acquired on the clientID, preventing the write to the DS(s) from acquiring a shared lock on the clientID. This patch stops rename/remove from doing a delegation return if pNFS is enabled. Since doing delegation return in the same compound as rename/remove is only an optimization, not doing so should not cause problems. This problem was detected during a recent NFSv4 interoperability testing event held by the IETF working group. (cherry picked from commit b82168e657d378ff86ea18c4f03b98aac9ee9bb3) --- sys/fs/nfsclient/nfs_clstate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 92688fcfbe28..5f35e4e708e9 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -4480,6 +4480,8 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; nmp = VFSTONFS(vnode_mount(vp)); + if (NFSHASPNFS(nmp)) + return (retcnt); np = VTONFS(vp); NFSLOCKCLSTATE(); /* @@ -4579,6 +4581,8 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, nmp = VFSTONFS(vnode_mount(fvp)); *gotfdp = 0; *gottdp = 0; + if (NFSHASPNFS(nmp)) + return (retcnt); NFSLOCKCLSTATE(); /* * Loop around waiting for: From nobody Tue Oct 19 05:27:40 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0E0551809787; Tue, 19 Oct 2021 05:27: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 4HYMhD6z0kz3ssQ; Tue, 19 Oct 2021 05:27: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 D12F866DD; Tue, 19 Oct 2021 05:27: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 19J5Reab095095; Tue, 19 Oct 2021 05:27:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19J5Re4S095094; Tue, 19 Oct 2021 05:27:40 GMT (envelope-from git) Date: Tue, 19 Oct 2021 05:27:40 GMT Message-Id: <202110190527.19J5Re4S095094@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: 17ef4736e28d - stable/13 - Fix two typos in source code comments List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 17ef4736e28d168f30105e7a27c821f7211f1f9a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=17ef4736e28d168f30105e7a27c821f7211f1f9a commit 17ef4736e28d168f30105e7a27c821f7211f1f9a Author: Gordon Bergling AuthorDate: 2021-10-16 06:09:31 +0000 Commit: Gordon Bergling CommitDate: 2021-10-19 05:27:21 +0000 Fix two typos in source code comments - s/alocated/allocated/ - s/realocated/reallocated/ (cherry picked from commit 899a3b38f5172d70360396caeebb5b694638282e) --- sys/dev/extres/clk/clk.c | 2 +- sys/dev/mlx4/mlx4_en/mlx4_en_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c index b26158922d74..b1522eb1d4c2 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -1517,7 +1517,7 @@ clk_get_by_ofw_name(device_t dev, phandle_t cnode, const char *name, clk_t *clk) /* * Get "clock-output-names" and (optional) "clock-indices" lists. - * Both lists are alocated using M_OFWPROP specifier. + * Both lists are allocated using M_OFWPROP specifier. * * Returns number of items or 0. */ diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c b/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c index 9e6f4df107bd..8e7c410d1c55 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c @@ -857,7 +857,7 @@ out: mlx4_cq_set_ci(mcq); wmb(); /* ensure HW sees CQ consumer before we post new buffers */ ring->cons = mcq->cons_index; - ring->prod += polled; /* Polled descriptors were realocated in place */ + ring->prod += polled; /* Polled descriptors were reallocated in place */ mlx4_en_update_rx_prod_db(ring); return polled; From nobody Tue Oct 19 05:35:11 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F1A04180E389; Tue, 19 Oct 2021 05: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 4HYMrv4P7Sz3wJV; Tue, 19 Oct 2021 05: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 5B70267E8; Tue, 19 Oct 2021 05: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 19J5ZB33008673; Tue, 19 Oct 2021 05: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 19J5ZBtA008672; Tue, 19 Oct 2021 05:35:11 GMT (envelope-from git) Date: Tue, 19 Oct 2021 05:35:11 GMT Message-Id: <202110190535.19J5ZBtA008672@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: 2a69f6e99655 - stable/12 - Fix two typos in source code comments List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 2a69f6e99655e0ce995baf0574ebf7005be0241d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=2a69f6e99655e0ce995baf0574ebf7005be0241d commit 2a69f6e99655e0ce995baf0574ebf7005be0241d Author: Gordon Bergling AuthorDate: 2021-10-16 06:09:31 +0000 Commit: Gordon Bergling CommitDate: 2021-10-19 05:28:08 +0000 Fix two typos in source code comments - s/alocated/allocated/ - s/realocated/reallocated/ (cherry picked from commit 899a3b38f5172d70360396caeebb5b694638282e) --- sys/dev/extres/clk/clk.c | 2 +- sys/dev/mlx4/mlx4_en/mlx4_en_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c index 172661587d00..1dec2050ddb0 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -1517,7 +1517,7 @@ clk_get_by_ofw_name(device_t dev, phandle_t cnode, const char *name, clk_t *clk) /* * Get "clock-output-names" and (optional) "clock-indices" lists. - * Both lists are alocated using M_OFWPROP specifier. + * Both lists are allocated using M_OFWPROP specifier. * * Returns number of items or 0. */ diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c b/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c index c9222e1df55c..40df00c05882 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c @@ -857,7 +857,7 @@ out: mlx4_cq_set_ci(mcq); wmb(); /* ensure HW sees CQ consumer before we post new buffers */ ring->cons = mcq->cons_index; - ring->prod += polled; /* Polled descriptors were realocated in place */ + ring->prod += polled; /* Polled descriptors were reallocated in place */ mlx4_en_update_rx_prod_db(ring); return polled; From nobody Tue Oct 19 13:19:15 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9C72A17FFD47; Tue, 19 Oct 2021 13:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HYZ8M41Dbz4fd3; Tue, 19 Oct 2021 13:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6AACE14C96; Tue, 19 Oct 2021 13:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19JDJF4O023166; Tue, 19 Oct 2021 13:19:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JDJFtk023165; Tue, 19 Oct 2021 13:19:15 GMT (envelope-from git) Date: Tue, 19 Oct 2021 13:19:15 GMT Message-Id: <202110191319.19JDJFtk023165@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mike Karels Subject: git: 3ee882bf21af - stable/13 - Change lowest address on subnet (host 0) not to broadcast by default. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: karels X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3ee882bf21afec1adca131783468e9091826521a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=3ee882bf21afec1adca131783468e9091826521a commit 3ee882bf21afec1adca131783468e9091826521a Author: Mike Karels AuthorDate: 2021-09-05 18:14:04 +0000 Commit: Mike Karels CommitDate: 2021-10-19 13:16:32 +0000 Change lowest address on subnet (host 0) not to broadcast by default. The address with a host part of all zeros was used as a broadcast long ago, but the default has been all ones since 4.3BSD and RFC1122. Until now, we would broadcast the host zero address as well as the configured address. Change to not broadcasting that address by default, but add a sysctl (net.inet.ip.broadcast_lowest) to re-enable it. Note that the correct way to use the zero address for broadcast would be to configure it as the broadcast address for the network. See https:/datatracker.ietf.org/doc/draft-schoen-intarea-lowest-address/ and the discussion in https://reviews.freebsd.org/D19316. Note, Linux now implements this. Reviewed by: rgrimes, tuexen; melifaro (previous version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D31861 (cherry picked from commit fd0765933c3ccb059ad7456e657b2e8ed22f58b0) --- sys/netinet/in.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index f9b46b414007..80ddeb5079a0 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -87,6 +87,12 @@ SYSCTL_INT(_net_inet_ip, OID_AUTO, no_same_prefix, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nosameprefix), 0, "Refuse to create same prefixes on different interfaces"); +VNET_DEFINE_STATIC(bool, broadcast_lowest); +#define V_broadcast_lowest VNET(broadcast_lowest) +SYSCTL_BOOL(_net_inet_ip, OID_AUTO, broadcast_lowest, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(broadcast_lowest), 0, + "Treat lowest address on a subnet (host 0) as broadcast"); + VNET_DECLARE(struct inpcbinfo, ripcbinfo); #define V_ripcbinfo VNET(ripcbinfo) @@ -1135,10 +1141,10 @@ in_ifaddr_broadcast(struct in_addr in, struct in_ifaddr *ia) return ((in.s_addr == ia->ia_broadaddr.sin_addr.s_addr || /* - * Check for old-style (host 0) broadcast, but + * Optionally check for old-style (host 0) broadcast, but * taking into account that RFC 3021 obsoletes it. */ - (ia->ia_subnetmask != IN_RFC3021_MASK && + (V_broadcast_lowest && ia->ia_subnetmask != IN_RFC3021_MASK && ntohl(in.s_addr) == ia->ia_subnet)) && /* * Check for an all one subnetmask. These From nobody Tue Oct 19 15:05:15 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4A5A018051F7; Tue, 19 Oct 2021 15:05: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 4HYcVh1Zfrz3h8n; Tue, 19 Oct 2021 15:05: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 06946163C1; Tue, 19 Oct 2021 15:05: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 19JF5F84069554; Tue, 19 Oct 2021 15:05:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JF5FlA069553; Tue, 19 Oct 2021 15:05:15 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:05:15 GMT Message-Id: <202110191505.19JF5FlA069553@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: 7d7168478380 - stable/13 - cam(4): Improve XPT_DEV_MATCH List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 7d7168478380f08b3a7fd58ca7cf83182fae6850 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=7d7168478380f08b3a7fd58ca7cf83182fae6850 commit 7d7168478380f08b3a7fd58ca7cf83182fae6850 Author: Alexander Motin AuthorDate: 2021-10-05 18:54:03 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 14:10:57 +0000 cam(4): Improve XPT_DEV_MATCH Remove *_MATCH_NONE enums, making no sense and so never used. Make *_MATCH_ANY enums 0 (no any match flags set), previously used by *_MATCH_NONE. Bump CAM_VERSION to 0x1a reflecting those changes and add compat shims. When traversing through buses and devices do not descend if we can already see that requested pattern does not match the bus or device. It allows to save significant amount of time on system with thousands of disks when doing limited searches. Reviewed by: imp MFC after: 2 weeks Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D32304 (cherry picked from commit 8f9be1eed11c27c66386c3d72cd6c6aef597fa0d) --- sys/cam/cam_ccb.h | 11 +++----- sys/cam/cam_compat.c | 50 ++++++++++++++++++++++++++++++++-- sys/cam/cam_compat.h | 7 +++++ sys/cam/cam_xpt.c | 76 +++++++++++++--------------------------------------- 4 files changed, 78 insertions(+), 66 deletions(-) diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h index b853e3165ba3..a0066eae3361 100644 --- a/sys/cam/cam_ccb.h +++ b/sys/cam/cam_ccb.h @@ -410,13 +410,12 @@ struct ccb_getdevlist { }; typedef enum { - PERIPH_MATCH_NONE = 0x000, + PERIPH_MATCH_ANY = 0x000, PERIPH_MATCH_PATH = 0x001, PERIPH_MATCH_TARGET = 0x002, PERIPH_MATCH_LUN = 0x004, PERIPH_MATCH_NAME = 0x008, PERIPH_MATCH_UNIT = 0x010, - PERIPH_MATCH_ANY = 0x01f } periph_pattern_flags; struct periph_match_pattern { @@ -429,13 +428,12 @@ struct periph_match_pattern { }; typedef enum { - DEV_MATCH_NONE = 0x000, + DEV_MATCH_ANY = 0x000, DEV_MATCH_PATH = 0x001, DEV_MATCH_TARGET = 0x002, DEV_MATCH_LUN = 0x004, DEV_MATCH_INQUIRY = 0x008, DEV_MATCH_DEVID = 0x010, - DEV_MATCH_ANY = 0x00f } dev_pattern_flags; struct device_id_match_pattern { @@ -455,12 +453,11 @@ struct device_match_pattern { }; typedef enum { - BUS_MATCH_NONE = 0x000, + BUS_MATCH_ANY = 0x000, BUS_MATCH_PATH = 0x001, BUS_MATCH_NAME = 0x002, BUS_MATCH_UNIT = 0x004, BUS_MATCH_BUS_ID = 0x008, - BUS_MATCH_ANY = 0x00f } bus_pattern_flags; struct bus_match_pattern { @@ -582,7 +579,7 @@ struct ccb_dev_match { /* * Definitions for the path inquiry CCB fields. */ -#define CAM_VERSION 0x19 /* Hex value for current version */ +#define CAM_VERSION 0x1a /* Hex value for current version */ typedef enum { PI_MDP_ABLE = 0x80, /* Supports MDP message */ diff --git a/sys/cam/cam_compat.c b/sys/cam/cam_compat.c index 4c89072fa389..6893402a3d9c 100644 --- a/sys/cam/cam_compat.c +++ b/sys/cam/cam_compat.c @@ -58,6 +58,8 @@ static int cam_compat_handle_0x17(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td, d_ioctl_t *cbfnp); static int cam_compat_handle_0x18(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td, d_ioctl_t *cbfnp); +static int cam_compat_handle_0x19(struct cdev *dev, u_long cmd, caddr_t addr, + int flag, struct thread *td, d_ioctl_t *cbfnp); static int cam_compat_translate_dev_match_0x18(union ccb *ccb); int @@ -108,6 +110,22 @@ cam_compat_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, cmd = CAMGETPASSTHRU; error = cam_compat_handle_0x18(dev, cmd, addr, flag, td, cbfnp); break; + case CAMIOCOMMAND_0x19: + cmd = CAMIOCOMMAND; + error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp); + break; + case CAMGETPASSTHRU_0x19: + cmd = CAMGETPASSTHRU; + error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp); + break; + case CAMIOQUEUE_0x19: + cmd = CAMIOQUEUE; + error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp); + break; + case CAMIOGET_0x19: + cmd = CAMIOGET; + error = cam_compat_handle_0x19(dev, cmd, addr, flag, td, cbfnp); + break; default: error = ENOTTY; } @@ -170,7 +188,7 @@ cam_compat_handle_0x17(struct cdev *dev, u_long cmd, caddr_t addr, int flag, bcopy(ccbb17, ccbb, CAM_0X17_DATA_LEN); } - error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td); + error = cam_compat_handle_0x19(dev, cmd, (caddr_t)ccb, flag, td, cbfnp); hdr17->pinfo = hdr->pinfo; hdr17->xpt_links = hdr->xpt_links; @@ -310,7 +328,7 @@ cam_compat_handle_0x18(struct cdev *dev, u_long cmd, caddr_t addr, int flag, bcopy(ccbb18, ccbb, CAM_0X18_DATA_LEN); } - error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td); + error = cam_compat_handle_0x19(dev, cmd, (caddr_t)ccb, flag, td, cbfnp); hdr18->pinfo = hdr->pinfo; hdr18->xpt_links = hdr->xpt_links; @@ -420,3 +438,31 @@ cam_compat_translate_dev_match_0x18(union ccb *ccb) return (0); } + +static int +cam_compat_handle_0x19(struct cdev *dev, u_long cmd, caddr_t addr, int flag, + struct thread *td, d_ioctl_t *cbfnp) +{ + union ccb *ccb = (union ccb *)addr; + struct cam_periph_map_info mapinfo; + + if (cmd == CAMIOCOMMAND && ccb->ccb_h.func_code == XPT_DEV_MATCH) { + bzero(&mapinfo, sizeof(mapinfo)); + cam_periph_mapmem(ccb, &mapinfo, maxphys); + for (int i = 0; i < ccb->cdm.num_patterns; i++) { + struct dev_match_pattern *p = &ccb->cdm.patterns[i]; + + if (p->type == DEV_MATCH_BUS && + p->pattern.bus_pattern.flags == 0x00f) + p->pattern.bus_pattern.flags = BUS_MATCH_ANY; + if (p->type == DEV_MATCH_DEVICE && + p->pattern.device_pattern.flags == 0x00f) + p->pattern.device_pattern.flags = DEV_MATCH_ANY; + if (p->type == DEV_MATCH_PERIPH && + p->pattern.periph_pattern.flags == 0x01f) + p->pattern.periph_pattern.flags = PERIPH_MATCH_ANY; + } + cam_periph_unmapmem(ccb, &mapinfo); + } + return ((cbfnp)(dev, cmd, addr, flag, td)); +} diff --git a/sys/cam/cam_compat.h b/sys/cam/cam_compat.h index dd728d86839e..9a1996d230ce 100644 --- a/sys/cam/cam_compat.h +++ b/sys/cam/cam_compat.h @@ -220,5 +220,12 @@ struct dev_match_result_0x18 { #define CAMIOCOMMAND_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 2, CAM_0X18_LEN) #define CAMGETPASSTHRU_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 3, CAM_0X18_LEN) +/* Version 0x19 compatibility */ +#define CAM_VERSION_0x19 0x19 +#define CAMIOCOMMAND_0x19 _IOWR(CAM_VERSION_0x19, 2, union ccb) +#define CAMGETPASSTHRU_0x19 _IOWR(CAM_VERSION_0x19, 3, union ccb) +#define CAMIOQUEUE_0x19 _IO(CAM_VERSION_0x19, 4) +#define CAMIOGET_0x19 _IO(CAM_VERSION_0x19, 5) + #endif #endif diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 0e38166b6ba0..678d8e0b4f3d 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -1374,6 +1374,8 @@ xptbusmatch(struct dev_match_pattern *patterns, u_int num_patterns, for (i = 0; i < num_patterns; i++) { struct bus_match_pattern *cur_pattern; + struct device_match_pattern *dp = &patterns[i].pattern.device_pattern; + struct periph_match_pattern *pp = &patterns[i].pattern.periph_pattern; /* * If the pattern in question isn't for a bus node, we @@ -1382,6 +1384,14 @@ xptbusmatch(struct dev_match_pattern *patterns, u_int num_patterns, * tree, since the user wants to match against lower-level * EDT elements. */ + if (patterns[i].type == DEV_MATCH_DEVICE && + (dp->flags & DEV_MATCH_PATH) != 0 && + dp->path_id != bus->path_id) + continue; + if (patterns[i].type == DEV_MATCH_PERIPH && + (pp->flags & PERIPH_MATCH_PATH) != 0 && + pp->path_id != bus->path_id) + continue; if (patterns[i].type != DEV_MATCH_BUS) { if ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE) retval |= DM_RET_DESCEND; @@ -1390,28 +1400,6 @@ xptbusmatch(struct dev_match_pattern *patterns, u_int num_patterns, cur_pattern = &patterns[i].pattern.bus_pattern; - /* - * If they want to match any bus node, we give them any - * device node. - */ - if (cur_pattern->flags == BUS_MATCH_ANY) { - /* set the copy flag */ - retval |= DM_RET_COPY; - - /* - * If we've already decided on an action, go ahead - * and return. - */ - if ((retval & DM_RET_ACTION_MASK) != DM_RET_NONE) - return(retval); - } - - /* - * Not sure why someone would do this... - */ - if (cur_pattern->flags == BUS_MATCH_NONE) - continue; - if (((cur_pattern->flags & BUS_MATCH_PATH) != 0) && (cur_pattern->path_id != bus->path_id)) continue; @@ -1487,11 +1475,20 @@ xptdevicematch(struct dev_match_pattern *patterns, u_int num_patterns, for (i = 0; i < num_patterns; i++) { struct device_match_pattern *cur_pattern; struct scsi_vpd_device_id *device_id_page; + struct periph_match_pattern *pp = &patterns[i].pattern.periph_pattern; /* * If the pattern in question isn't for a device node, we * aren't interested. */ + if (patterns[i].type == DEV_MATCH_PERIPH && + (pp->flags & PERIPH_MATCH_TARGET) != 0 && + pp->target_id != device->target->target_id) + continue; + if (patterns[i].type == DEV_MATCH_PERIPH && + (pp->flags & PERIPH_MATCH_LUN) != 0 && + pp->target_lun != device->lun_id) + continue; if (patterns[i].type != DEV_MATCH_DEVICE) { if ((patterns[i].type == DEV_MATCH_PERIPH) && ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE)) @@ -1506,19 +1503,6 @@ xptdevicematch(struct dev_match_pattern *patterns, u_int num_patterns, == (DEV_MATCH_INQUIRY|DEV_MATCH_DEVID)) return(DM_RET_ERROR); - /* - * If they want to match any device node, we give them any - * device node. - */ - if (cur_pattern->flags == DEV_MATCH_ANY) - goto copy_dev_node; - - /* - * Not sure why someone would do this... - */ - if (cur_pattern->flags == DEV_MATCH_NONE) - continue; - if (((cur_pattern->flags & DEV_MATCH_PATH) != 0) && (cur_pattern->path_id != device->target->bus->path_id)) continue; @@ -1548,7 +1532,6 @@ xptdevicematch(struct dev_match_pattern *patterns, u_int num_patterns, cur_pattern->data.devid_pat.id_len) != 0)) continue; -copy_dev_node: /* * If we get to this point, the user definitely wants * information on this device. So tell the caller to copy @@ -1623,27 +1606,6 @@ xptperiphmatch(struct dev_match_pattern *patterns, u_int num_patterns, cur_pattern = &patterns[i].pattern.periph_pattern; - /* - * If they want to match on anything, then we will do so. - */ - if (cur_pattern->flags == PERIPH_MATCH_ANY) { - /* set the copy flag */ - retval |= DM_RET_COPY; - - /* - * We've already set the return action to stop, - * since there are no nodes below peripherals in - * the tree. - */ - return(retval); - } - - /* - * Not sure why someone would do this... - */ - if (cur_pattern->flags == PERIPH_MATCH_NONE) - continue; - if (((cur_pattern->flags & PERIPH_MATCH_PATH) != 0) && (cur_pattern->path_id != periph->path->bus->path_id)) continue; From nobody Tue Oct 19 15:06:54 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 88DAE1805850; Tue, 19 Oct 2021 15:06: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 4HYcXZ3Pbrz3hLP; Tue, 19 Oct 2021 15:06: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 4F38E1655B; Tue, 19 Oct 2021 15:06: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 19JF6si8069783; Tue, 19 Oct 2021 15:06:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JF6s6b069782; Tue, 19 Oct 2021 15:06:54 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:06:54 GMT Message-Id: <202110191506.19JF6s6b069782@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: 7e321b97917d - stable/13 - cam(4): Limit search for disks in SES enclosure by single bus List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 7e321b97917dce5274972a6bc5eee94c6ad4cfc4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=7e321b97917dce5274972a6bc5eee94c6ad4cfc4 commit 7e321b97917dce5274972a6bc5eee94c6ad4cfc4 Author: Alexander Motin AuthorDate: 2021-10-05 19:01:16 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 15:06:52 +0000 cam(4): Limit search for disks in SES enclosure by single bus At least for SAS that we only support now disks are typically connected to the same bus as the enclosure. Limiting the search scope makes it much faster on systems with multiple buses and thousands of disks. Reviewed by: imp MFC after: 2 weeks Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D32305 (cherry picked from commit 730ea72c706ef8e025616772cfd86fd89ed3d42e) --- sys/cam/scsi/scsi_enc_ses.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c index 014fe9fcd525..d20f3dec4e52 100644 --- a/sys/cam/scsi/scsi_enc_ses.c +++ b/sys/cam/scsi/scsi_enc_ses.c @@ -374,6 +374,10 @@ typedef struct ses_softc { ses_control_reqlist_t ses_pending_requests; } ses_softc_t; +static int ses_search_globally = 0; +SYSCTL_INT(_kern_cam_enc, OID_AUTO, search_globally, CTLFLAG_RWTUN, + &ses_search_globally, 0, "Search for disks on other buses"); + /** * \brief Reset a SES iterator to just before the first element * in the configuration. @@ -890,6 +894,10 @@ ses_path_iter_devid_callback(enc_softc_t *enc, enc_element_t *elem, + devid->length; memcpy(device_pattern->data.devid_pat.id, devid, device_pattern->data.devid_pat.id_len); + if (!ses_search_globally) { + device_pattern->flags |= DEV_MATCH_PATH; + device_pattern->path_id = xpt_path_path_id(enc->periph->path); + } memset(&cdm, 0, sizeof(cdm)); if (xpt_create_path(&cdm.ccb_h.path, /*periph*/NULL, From nobody Tue Oct 19 15:12:47 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 504C718085F9; Tue, 19 Oct 2021 15:12: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 4HYcgM1smHz3kTk; Tue, 19 Oct 2021 15:12: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 2008D165B7; Tue, 19 Oct 2021 15:12: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 19JFClwS082706; Tue, 19 Oct 2021 15:12:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JFClGs082705; Tue, 19 Oct 2021 15:12:47 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:12:47 GMT Message-Id: <202110191512.19JFClGs082705@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: 5c691a9593a2 - stable/13 - ciss(4): Properly handle data underrun. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 5c691a9593a275085734dea18d4e479ab0430c09 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=5c691a9593a275085734dea18d4e479ab0430c09 commit 5c691a9593a275085734dea18d4e479ab0430c09 Author: Alexander Motin AuthorDate: 2021-09-19 17:45:51 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 15:12:32 +0000 ciss(4): Properly handle data underrun. For SCSI data underrun is a part of normal life. It should not be reported as error. This fixes MODE SENSE used by modern CAM. MFC after: 1 month (cherry picked from commit e8144a13e075ff13c1f162690c7f14dd3f0a4862) --- sys/dev/ciss/ciss.c | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index 74baf164b860..36d1225fbe4a 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -2331,13 +2331,15 @@ _ciss_report_request(struct ciss_request *cr, int *command_status, int *scsi_sta if (command_status != NULL) *command_status = ce->command_status; if (scsi_status != NULL) { - if (ce->command_status == CISS_CMD_STATUS_TARGET_STATUS) { + if (ce->command_status == CISS_CMD_STATUS_DATA_UNDERRUN) { + *scsi_status = SCSI_STATUS_OK; + } else if (ce->command_status == CISS_CMD_STATUS_TARGET_STATUS) { *scsi_status = ce->scsi_status; } else { *scsi_status = -1; } } - if (bootverbose) + if (bootverbose && ce->command_status != CISS_CMD_STATUS_DATA_UNDERRUN) ciss_printf(cr->cr_sc, "command status 0x%x (%s) scsi status 0x%x\n", ce->command_status, ciss_name_command_status(ce->command_status), ce->scsi_status); @@ -3311,28 +3313,17 @@ ciss_cam_complete(struct ciss_request *cr) * Extract status values from request. */ ciss_report_request(cr, &command_status, &scsi_status); - csio->scsi_status = scsi_status; - - /* - * Handle specific SCSI status values. - */ - switch(scsi_status) { - /* no status due to adapter error */ - case -1: - debug(0, "adapter error"); - csio->ccb_h.status |= CAM_REQ_CMP_ERR; - break; - - /* no status due to command completed OK */ - case SCSI_STATUS_OK: /* CISS_SCSI_STATUS_GOOD */ + switch(command_status) { + case CISS_CMD_STATUS_DATA_UNDERRUN: + csio->resid = ce->residual_count; + /* FALLTHROUGH */ + case CISS_CMD_STATUS_SUCCESS: + csio->scsi_status = scsi_status; debug(2, "SCSI_STATUS_OK"); csio->ccb_h.status |= CAM_REQ_CMP; break; - - /* check condition, sense data included */ - case SCSI_STATUS_CHECK_COND: /* CISS_SCSI_STATUS_CHECK_CONDITION */ - debug(0, "SCSI_STATUS_CHECK_COND sense size %d resid %d\n", - ce->sense_length, ce->residual_count); + case CISS_CMD_STATUS_TARGET_STATUS: + csio->scsi_status = scsi_status; bzero(&csio->sense_data, SSD_FULL_SIZE); bcopy(&ce->sense_info[0], &csio->sense_data, ce->sense_length); if (csio->sense_len > ce->sense_length) @@ -3341,22 +3332,11 @@ ciss_cam_complete(struct ciss_request *cr) csio->sense_resid = 0; csio->resid = ce->residual_count; csio->ccb_h.status |= CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID; -#ifdef CISS_DEBUG - { - struct scsi_sense_data *sns = (struct scsi_sense_data *)&ce->sense_info[0]; - debug(0, "sense key %x", scsi_get_sense_key(sns, csio->sense_len - - csio->sense_resid, /*show_errors*/ 1)); - } -#endif break; - - case SCSI_STATUS_BUSY: /* CISS_SCSI_STATUS_BUSY */ - debug(0, "SCSI_STATUS_BUSY"); - csio->ccb_h.status |= CAM_SCSI_BUSY; + case CISS_CMD_STATUS_DATA_OVERRUN: + csio->ccb_h.status |= CAM_DATA_RUN_ERR; break; - default: - debug(0, "unknown status 0x%x", csio->scsi_status); csio->ccb_h.status |= CAM_REQ_CMP_ERR; break; } From nobody Tue Oct 19 15:12:48 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0346418088D6; Tue, 19 Oct 2021 15:12: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 4HYcgN42VMz3kZ8; Tue, 19 Oct 2021 15:12:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A04516258; Tue, 19 Oct 2021 15:12:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19JFCmZj082735; Tue, 19 Oct 2021 15:12:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JFCmoV082734; Tue, 19 Oct 2021 15:12:48 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:12:48 GMT Message-Id: <202110191512.19JFCmoV082734@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: e61892af6fa4 - stable/13 - ciss(4): Fix typo. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: e61892af6fa41b01941234ec1c45cbb91402d9eb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=e61892af6fa41b01941234ec1c45cbb91402d9eb commit e61892af6fa41b01941234ec1c45cbb91402d9eb Author: Alexander Motin AuthorDate: 2021-09-19 18:01:40 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 15:12:33 +0000 ciss(4): Fix typo. (cherry picked from commit 5f8cb13cfb0c91a4ec1a9648a3ae245b1dff36f6) --- sys/dev/ciss/ciss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index 36d1225fbe4a..d87f32610b20 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -1283,7 +1283,7 @@ ciss_identify_adapter(struct ciss_softc *sc) "\20\1ultra2\2ultra3\10fibre1\11fibre2\n"); ciss_printf(sc, " server name '%.16s'\n", sc->ciss_cfg->server_name); ciss_printf(sc, " heartbeat 0x%x\n", sc->ciss_cfg->heartbeat); - ciss_printf(sc, " max logical logical volumes: %d\n", sc->ciss_cfg->max_logical_supported); + ciss_printf(sc, " max logical volumes: %d\n", sc->ciss_cfg->max_logical_supported); ciss_printf(sc, " max physical disks supported: %d\n", sc->ciss_cfg->max_physical_supported); ciss_printf(sc, " max physical disks per logical volume: %d\n", sc->ciss_cfg->max_physical_per_logical); ciss_printf(sc, " JBOD Support is %s\n", (sc->ciss_id->uiYetMoreControllerFlags & YMORE_CONTROLLER_FLAGS_JBOD_SUPPORTED) ? From nobody Tue Oct 19 15:16:01 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B5229180C138; Tue, 19 Oct 2021 15:16: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 4HYcl54mKxz3mgc; Tue, 19 Oct 2021 15:16: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 83C0B1678B; Tue, 19 Oct 2021 15:16: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 19JFG1XW083076; Tue, 19 Oct 2021 15:16:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JFG1xZ083075; Tue, 19 Oct 2021 15:16:01 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:16:01 GMT Message-Id: <202110191516.19JFG1xZ083075@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: 9abf1f741d54 - stable/12 - ciss(4): Properly handle data underrun. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 9abf1f741d541a4a1ab684cc417cc6660b0cba1a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=9abf1f741d541a4a1ab684cc417cc6660b0cba1a commit 9abf1f741d541a4a1ab684cc417cc6660b0cba1a Author: Alexander Motin AuthorDate: 2021-09-19 17:45:51 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 15:13:31 +0000 ciss(4): Properly handle data underrun. For SCSI data underrun is a part of normal life. It should not be reported as error. This fixes MODE SENSE used by modern CAM. MFC after: 1 month (cherry picked from commit e8144a13e075ff13c1f162690c7f14dd3f0a4862) --- sys/dev/ciss/ciss.c | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index 3cfeb90e9f06..34d3aeb6dae8 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -2336,13 +2336,15 @@ _ciss_report_request(struct ciss_request *cr, int *command_status, int *scsi_sta if (command_status != NULL) *command_status = ce->command_status; if (scsi_status != NULL) { - if (ce->command_status == CISS_CMD_STATUS_TARGET_STATUS) { + if (ce->command_status == CISS_CMD_STATUS_DATA_UNDERRUN) { + *scsi_status = SCSI_STATUS_OK; + } else if (ce->command_status == CISS_CMD_STATUS_TARGET_STATUS) { *scsi_status = ce->scsi_status; } else { *scsi_status = -1; } } - if (bootverbose) + if (bootverbose && ce->command_status != CISS_CMD_STATUS_DATA_UNDERRUN) ciss_printf(cr->cr_sc, "command status 0x%x (%s) scsi status 0x%x\n", ce->command_status, ciss_name_command_status(ce->command_status), ce->scsi_status); @@ -3318,28 +3320,17 @@ ciss_cam_complete(struct ciss_request *cr) * Extract status values from request. */ ciss_report_request(cr, &command_status, &scsi_status); - csio->scsi_status = scsi_status; - - /* - * Handle specific SCSI status values. - */ - switch(scsi_status) { - /* no status due to adapter error */ - case -1: - debug(0, "adapter error"); - csio->ccb_h.status |= CAM_REQ_CMP_ERR; - break; - - /* no status due to command completed OK */ - case SCSI_STATUS_OK: /* CISS_SCSI_STATUS_GOOD */ + switch(command_status) { + case CISS_CMD_STATUS_DATA_UNDERRUN: + csio->resid = ce->residual_count; + /* FALLTHROUGH */ + case CISS_CMD_STATUS_SUCCESS: + csio->scsi_status = scsi_status; debug(2, "SCSI_STATUS_OK"); csio->ccb_h.status |= CAM_REQ_CMP; break; - - /* check condition, sense data included */ - case SCSI_STATUS_CHECK_COND: /* CISS_SCSI_STATUS_CHECK_CONDITION */ - debug(0, "SCSI_STATUS_CHECK_COND sense size %d resid %d\n", - ce->sense_length, ce->residual_count); + case CISS_CMD_STATUS_TARGET_STATUS: + csio->scsi_status = scsi_status; bzero(&csio->sense_data, SSD_FULL_SIZE); bcopy(&ce->sense_info[0], &csio->sense_data, ce->sense_length); if (csio->sense_len > ce->sense_length) @@ -3348,22 +3339,11 @@ ciss_cam_complete(struct ciss_request *cr) csio->sense_resid = 0; csio->resid = ce->residual_count; csio->ccb_h.status |= CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID; -#ifdef CISS_DEBUG - { - struct scsi_sense_data *sns = (struct scsi_sense_data *)&ce->sense_info[0]; - debug(0, "sense key %x", scsi_get_sense_key(sns, csio->sense_len - - csio->sense_resid, /*show_errors*/ 1)); - } -#endif break; - - case SCSI_STATUS_BUSY: /* CISS_SCSI_STATUS_BUSY */ - debug(0, "SCSI_STATUS_BUSY"); - csio->ccb_h.status |= CAM_SCSI_BUSY; + case CISS_CMD_STATUS_DATA_OVERRUN: + csio->ccb_h.status |= CAM_DATA_RUN_ERR; break; - default: - debug(0, "unknown status 0x%x", csio->scsi_status); csio->ccb_h.status |= CAM_REQ_CMP_ERR; break; } From nobody Tue Oct 19 15:16:02 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F0CF8180C1B9; Tue, 19 Oct 2021 15:16: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 4HYcl66CMHz3mN9; Tue, 19 Oct 2021 15:16: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 B24DE1678C; Tue, 19 Oct 2021 15:16: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 19JFG2CM083100; Tue, 19 Oct 2021 15:16:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JFG211083099; Tue, 19 Oct 2021 15:16:02 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:16:02 GMT Message-Id: <202110191516.19JFG211083099@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: 1a34fe4c87b0 - stable/12 - ciss(4): Fix typo. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 1a34fe4c87b0707600a3c2232f767c02b2fad56a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=1a34fe4c87b0707600a3c2232f767c02b2fad56a commit 1a34fe4c87b0707600a3c2232f767c02b2fad56a Author: Alexander Motin AuthorDate: 2021-09-19 18:01:40 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 15:13:31 +0000 ciss(4): Fix typo. (cherry picked from commit 5f8cb13cfb0c91a4ec1a9648a3ae245b1dff36f6) --- sys/dev/ciss/ciss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index 34d3aeb6dae8..d20599ed7ecd 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -1284,7 +1284,7 @@ ciss_identify_adapter(struct ciss_softc *sc) "\20\1ultra2\2ultra3\10fibre1\11fibre2\n"); ciss_printf(sc, " server name '%.16s'\n", sc->ciss_cfg->server_name); ciss_printf(sc, " heartbeat 0x%x\n", sc->ciss_cfg->heartbeat); - ciss_printf(sc, " max logical logical volumes: %d\n", sc->ciss_cfg->max_logical_supported); + ciss_printf(sc, " max logical volumes: %d\n", sc->ciss_cfg->max_logical_supported); ciss_printf(sc, " max physical disks supported: %d\n", sc->ciss_cfg->max_physical_supported); ciss_printf(sc, " max physical disks per logical volume: %d\n", sc->ciss_cfg->max_physical_per_logical); ciss_printf(sc, " JBOD Support is %s\n", (sc->ciss_id->uiYetMoreControllerFlags & YMORE_CONTROLLER_FLAGS_JBOD_SUPPORTED) ? From nobody Tue Oct 19 15:21:16 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CAC87180E155; Tue, 19 Oct 2021 15:21: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 4HYcs85QCTz3nx6; Tue, 19 Oct 2021 15:21: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 9B6E816770; Tue, 19 Oct 2021 15:21: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 19JFLG7n091753; Tue, 19 Oct 2021 15:21:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JFLGeM091752; Tue, 19 Oct 2021 15:21:16 GMT (envelope-from git) Date: Tue, 19 Oct 2021 15:21:16 GMT Message-Id: <202110191521.19JFLGeM091752@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: d5c6c2eaacba - stable/12 - sbuf(9): Microoptimize sbuf_put_byte() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: d5c6c2eaacba9e4272dcc334e2f6bbfc779c5de7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=d5c6c2eaacba9e4272dcc334e2f6bbfc779c5de7 commit d5c6c2eaacba9e4272dcc334e2f6bbfc779c5de7 Author: Alexander Motin AuthorDate: 2021-10-05 18:42:47 +0000 Commit: Alexander Motin CommitDate: 2021-10-19 15:20:20 +0000 sbuf(9): Microoptimize sbuf_put_byte() This function is actively used by sbuf_vprintf(), so this simple inlining in half reduces time of kern.geom.confxml generation. MFC after: 2 weeks Sponsored by: iXsystem, Inc. (cherry picked from commit 7835b2cb4a1ae57f403739a2f1076ec7188f18c9) --- sys/kern/subr_sbuf.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index 4a046cc41787..039d96c9b739 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -464,7 +464,26 @@ static void sbuf_put_byte(struct sbuf *s, char c) { - sbuf_put_bytes(s, &c, 1); + assert_sbuf_integrity(s); + assert_sbuf_state(s, 0); + + if (__predict_false(s->s_error != 0)) + return; + if (__predict_false(SBUF_FREESPACE(s) <= 0)) { + /* + * If there is a drain, use it, otherwise extend the + * buffer. + */ + if (s->s_drain_func != NULL) + (void)sbuf_drain(s); + else if (sbuf_extend(s, 1) < 0) + s->s_error = ENOMEM; + if (s->s_error != 0) + return; + } + s->s_buf[s->s_len++] = c; + if (SBUF_ISSECTION(s)) + s->s_sect_len++; } /* @@ -607,7 +626,7 @@ static void sbuf_putc_func(int c, void *arg) { - if (c != '\0') + if (__predict_true(c != '\0')) sbuf_put_byte(arg, c); } From nobody Tue Oct 19 23:20:33 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8B5E917F761E; Tue, 19 Oct 2021 23:20: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 4HYqV930bfz4bb9; Tue, 19 Oct 2021 23:20: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 46ECC1CB4A; Tue, 19 Oct 2021 23:20: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 19JNKXLh031218; Tue, 19 Oct 2021 23:20:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JNKXd2031217; Tue, 19 Oct 2021 23:20:33 GMT (envelope-from git) Date: Tue, 19 Oct 2021 23:20:33 GMT Message-Id: <202110192320.19JNKXd2031217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: 81184e92e0d7 - stable/13 - makesyscalls.lua: Add a new syscall type: RESERVED List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 81184e92e0d73714096bd49857670e3629994ce2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=81184e92e0d73714096bd49857670e3629994ce2 commit 81184e92e0d73714096bd49857670e3629994ce2 Author: Brooks Davis AuthorDate: 2021-10-19 23:19:56 +0000 Commit: Brooks Davis CommitDate: 2021-10-19 23:19:56 +0000 makesyscalls.lua: Add a new syscall type: RESERVED RESERVED syscall number are reserved for local/vendor use. RESERVED is identical to UNIMPL except that comments are ignored. Reviewed by: kevans Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27988 (cherry picked from commit 119fa6ee8a8056aab5e4ab1719d3c563cdb4a95a) --- sys/kern/syscalls.master | 3 ++- sys/tools/makesyscalls.lua | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index d3ec771aac6f..81f016a0c073 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -11,7 +11,7 @@ ; there is no audit event for the call at this time. For the ; case where the event exists, but we don't want auditing, the ; event should be #defined to AUE_NULL in audit_kevents.h. -; type one of STD, OBSOL, UNIMPL, COMPAT, COMPAT4, COMPAT6, +; type one of STD, OBSOL, RESERVED, UNIMPL, COMPAT, COMPAT4, COMPAT6, ; COMPAT7, COMPAT11, COMPAT12, NODEF, NOARGS, NOPROTO, NOSTD ; The COMPAT* options may be combined with one or more NO* ; options separated by '|' with no spaces (e.g. COMPAT|NOARGS) @@ -32,6 +32,7 @@ ; COMPAT11 included on COMPAT_FREEBSD11 #ifdef (FreeBSD 11 compat) ; COMPAT12 included on COMPAT_FREEBSD12 #ifdef (FreeBSD 12 compat) ; OBSOL obsolete, not included in system, only specifies name +; RESERVED reserved for local or vendor use ; UNIMPL not implemented, placeholder only ; NOSTD implemented but as a lkm that can be statically ; compiled in; sysent entry will be filled with lkmressys diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index 85b76a44150c..49a9e283e646 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -148,12 +148,13 @@ local known_abi_flags = { local known_flags = { STD = 0x00000001, OBSOL = 0x00000002, - UNIMPL = 0x00000004, - NODEF = 0x00000008, - NOARGS = 0x00000010, - NOPROTO = 0x00000020, - NOSTD = 0x00000040, - NOTSTATIC = 0x00000080, + RESERVED = 0x00000004, + UNIMPL = 0x00000008, + NODEF = 0x00000010, + NOARGS = 0x00000020, + NOPROTO = 0x00000040, + NOSTD = 0x00000080, + NOTSTATIC = 0x00000100, -- Compat flags start from here. We have plenty of space. } @@ -906,6 +907,10 @@ local function handle_unimpl(sysnum, sysstart, sysend, comment) end end +local function handle_reserved(sysnum, sysstart, sysend, comment) + handle_unimpl(sysnum, sysstart, sysend, "reserved for local use") +end + process_syscall_def = function(line) local sysstart, sysend, flags, funcname, sysflags local thr_flag, syscallret @@ -950,8 +955,8 @@ process_syscall_def = function(line) flags = flags | known_flags[flag] end - if (flags & known_flags["UNIMPL"]) == 0 and sysnum == nil then - abort(1, "Range only allowed with UNIMPL: " .. line) + if (flags & get_mask({"RESERVED", "UNIMPL"})) == 0 and sysnum == nil then + abort(1, "Range only allowed with RESERVED and UNIMPL: " .. line) end if (flags & known_flags["NOTSTATIC"]) ~= 0 then @@ -1115,6 +1120,8 @@ process_syscall_def = function(line) argalias) elseif flags & known_flags["OBSOL"] ~= 0 then handle_obsol(sysnum, funcname, funcomment) + elseif flags & known_flags["RESERVED"] ~= 0 then + handle_reserved(sysnum, sysstart, sysend) elseif flags & known_flags["UNIMPL"] ~= 0 then handle_unimpl(sysnum, sysstart, sysend, funcomment) else From nobody Tue Oct 19 23:20:34 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AA35417F7683; Tue, 19 Oct 2021 23:20: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 4HYqVB3ztTz4bsQ; Tue, 19 Oct 2021 23:20: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 68EC21CBBF; Tue, 19 Oct 2021 23:20: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 19JNKYot031249; Tue, 19 Oct 2021 23:20:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JNKY8x031248; Tue, 19 Oct 2021 23:20:34 GMT (envelope-from git) Date: Tue, 19 Oct 2021 23:20:34 GMT Message-Id: <202110192320.19JNKY8x031248@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: fe388671ac85 - stable/13 - makesyscalls.lua: add a CAPENABLED flag List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fe388671ac851292f59926e96f2c86e6e46ea218 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=fe388671ac851292f59926e96f2c86e6e46ea218 commit fe388671ac851292f59926e96f2c86e6e46ea218 Author: Brooks Davis AuthorDate: 2021-10-19 23:19:56 +0000 Commit: Brooks Davis CommitDate: 2021-10-19 23:19:56 +0000 makesyscalls.lua: add a CAPENABLED flag The CAPENABLED flag indicates that the syscall can be used in capsicum capability mode. It is intended to replace capabilities.conf. Reviewed by: kevans, emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D31349 (cherry picked from commit 6945df3fff57a9606f8c8a4e3865def3a0e915e7) --- sys/kern/syscalls.master | 2 ++ sys/tools/makesyscalls.lua | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 81f016a0c073..51ff07f8deed 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -15,6 +15,7 @@ ; COMPAT7, COMPAT11, COMPAT12, NODEF, NOARGS, NOPROTO, NOSTD ; The COMPAT* options may be combined with one or more NO* ; options separated by '|' with no spaces (e.g. COMPAT|NOARGS) +; The CAPENABLED option may be ORed into a type. ; name pseudo-prototype of syscall routine ; If one of the following alts is different, then all appear: ; altname name of system call if different @@ -45,6 +46,7 @@ ; function prototype in sys/sysproto.h. Does add a ; definition to syscall.h besides adding a sysent. ; NOTSTATIC syscall is loadable +; CAPENABLED syscall is allowed in capability mode ; annotations: ; SAL 2.0 annotations are used to specify how system calls treat diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index 49a9e283e646..dba9488b11a8 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -155,6 +155,7 @@ local known_flags = { NOPROTO = 0x00000040, NOSTD = 0x00000080, NOTSTATIC = 0x00000100, + CAPENABLED = 0x00000200, -- Compat flags start from here. We have plenty of space. } @@ -1060,7 +1061,8 @@ process_syscall_def = function(line) -- If applicable; strip the ABI prefix from the name local stripped_name = strip_abi_prefix(funcname) - if config["capenabled"][funcname] ~= nil or + if flags & known_flags['CAPENABLED'] ~= 0 or + config["capenabled"][funcname] ~= nil or config["capenabled"][stripped_name] ~= nil then sysflags = "SYF_CAPENABLED" end From nobody Tue Oct 19 23:20:35 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BB5F017F75A7; Tue, 19 Oct 2021 23:20: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 4HYqVD0VDJz4blM; Tue, 19 Oct 2021 23:20: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 982611CF86; Tue, 19 Oct 2021 23:20: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 19JNKZwB031273; Tue, 19 Oct 2021 23:20:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JNKZIS031272; Tue, 19 Oct 2021 23:20:35 GMT (envelope-from git) Date: Tue, 19 Oct 2021 23:20:35 GMT Message-Id: <202110192320.19JNKZIS031272@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: 3b55b6137195 - stable/13 - selsocket: handle sopoll() errors correctly List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3b55b6137195ee116680590c1d3c4416a88fee2e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=3b55b6137195ee116680590c1d3c4416a88fee2e commit 3b55b6137195ee116680590c1d3c4416a88fee2e Author: Brooks Davis AuthorDate: 2021-10-19 23:19:57 +0000 Commit: Brooks Davis CommitDate: 2021-10-19 23:19:57 +0000 selsocket: handle sopoll() errors correctly Without this change, unmounting smbfs filesystems with an INVARIANTS kernel would panic after 10e64782ed59727e8c9fe4a5c7e17f497903c8eb. PR: 253079 Found by: markj Reviewed by: markj, jhb Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D32492 (cherry picked from commit 04c91ac48ad13ce0d1392cedbd69c2c0223d206f) --- sys/kern/sys_generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 09c60611e755..0fcb93545e86 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1709,10 +1709,10 @@ selsocket(struct socket *so, int events, struct timeval *tvp, struct thread *td) */ for (;;) { selfdalloc(td, NULL); - error = sopoll(so, events, NULL, td); - /* error here is actually the ready events. */ - if (error) - return (0); + if (sopoll(so, events, NULL, td) != 0) { + error = 0; + break; + } error = seltdwait(td, asbt, precision); if (error) break; From nobody Tue Oct 19 23:22:36 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 384A217F908B; Tue, 19 Oct 2021 23:22: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 4HYqXY0wCrz4dVr; Tue, 19 Oct 2021 23:22: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 00C7A1CE3A; Tue, 19 Oct 2021 23:22: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 19JNMaPw035625; Tue, 19 Oct 2021 23:22:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19JNMaFC035624; Tue, 19 Oct 2021 23:22:36 GMT (envelope-from git) Date: Tue, 19 Oct 2021 23:22:36 GMT Message-Id: <202110192322.19JNMaFC035624@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: 1f64f93a0921 - stable/13 - nfscl: Add a check for "has acquired a delegation" to nfscl_removedeleg() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 1f64f93a0921fad407dd4cfbbea06a831288cf78 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=1f64f93a0921fad407dd4cfbbea06a831288cf78 commit 1f64f93a0921fad407dd4cfbbea06a831288cf78 Author: Rick Macklem AuthorDate: 2021-09-27 01:37:25 +0000 Commit: Rick Macklem CommitDate: 2021-10-19 23:19:40 +0000 nfscl: Add a check for "has acquired a delegation" to nfscl_removedeleg() Commit 5e5ca4c8fc53 added a flag to a NFSv4 mount point that is set when the first delegation is acquired from the NFSv4 server. For a common case where delegations are not being issued by the NFSv4 server, the nfscl_removedeleg() code acquires the mutex lock for open/lock state, finds the delegation list empty, then just unlocks the mutex and returns. This patch adds a check of the flag to avoid the need to acquire the mutex for this common case. This change appears to be performance neutral for a small number of opens, but should reduce lock contention for a large number of opens for the common case where server is not issuing delegations. This commit should not affect the high level semantics of delegation handling. (cherry picked from commit 62c5be4ab4c8b8127185286e148638cb8cdf45f4) --- sys/fs/nfsclient/nfs_clstate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index bb2c78a72ed9..8d1c4de0ba8e 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -4606,6 +4606,12 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; nmp = VFSTONFS(vp->v_mount); + NFSLOCKMNT(nmp); + if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) { + NFSUNLOCKMNT(nmp); + return (retcnt); + } + NFSUNLOCKMNT(nmp); np = VTONFS(vp); NFSLOCKCLSTATE(); /* From nobody Wed Oct 20 00:27:23 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A655F17F4501; Wed, 20 Oct 2021 00:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HYrzH3RMYz3C4n; Wed, 20 Oct 2021 00:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 523151D9D6; Wed, 20 Oct 2021 00:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19K0RNJ3015563; Wed, 20 Oct 2021 00:27:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K0RNW9015562; Wed, 20 Oct 2021 00:27:23 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:27:23 GMT Message-Id: <202110200027.19K0RNW9015562@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: 023283c64214 - stable/13 - config: Fix typo in comment. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 023283c6421412b25e66eca4d51e353e639750aa Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=023283c6421412b25e66eca4d51e353e639750aa commit 023283c6421412b25e66eca4d51e353e639750aa Author: John Baldwin AuthorDate: 2021-02-01 21:13:36 +0000 Commit: John Baldwin CommitDate: 2021-10-19 23:53:20 +0000 config: Fix typo in comment. (cherry picked from commit bcaa6aa15383cacf5f20179be919bb8dd45cc5f4) --- usr.sbin/config/mkheaders.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index 62f81553bb5c..5dfde12c1db8 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -38,7 +38,7 @@ static const char rcsid[] = #endif /* not lint */ /* - * This used to generate a bunch of hearders files related to devices when + * This used to generate a bunch of headers files related to devices when * device counters were supported. Support for that was removed in 2005. * Since then, all we've done is to report unknown devices in this file. * It's kept its historical name, despite no longer generating headers. From nobody Wed Oct 20 00:27:24 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9F21B17F4434; Wed, 20 Oct 2021 00:27: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 4HYrzJ3xzyz3C2Y; Wed, 20 Oct 2021 00:27: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 69A791D7E3; Wed, 20 Oct 2021 00:27: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 19K0ROl8015587; Wed, 20 Oct 2021 00:27:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K0RO9S015586; Wed, 20 Oct 2021 00:27:24 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:27:24 GMT Message-Id: <202110200027.19K0RO9S015586@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: 16aa4787ca5c - stable/13 - Remove 'make update'. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 16aa4787ca5cd9de970090eebfa67502b261d6a6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=16aa4787ca5cd9de970090eebfa67502b261d6a6 commit 16aa4787ca5cd9de970090eebfa67502b261d6a6 Author: John Baldwin AuthorDate: 2021-06-11 21:56:28 +0000 Commit: John Baldwin CommitDate: 2021-10-19 23:53:24 +0000 Remove 'make update'. In the CVS days this used be a wrapper around either CVS or CVSup and used to support updating src, doc, and ports checkouts. With the move to subversion this only supported updating src and was itself a wrapper around 'svn update'. With Git, users are probably better off using appropriate Git commands directly to update without needing an explicit make target as a wrapper. Reviewed by: bcr, imp, emaste Differential Revision: https://reviews.freebsd.org/D30736 (cherry picked from commit e290182bcf3895ca659dff111bca6a077c4708b1) --- Makefile | 3 +-- Makefile.inc1 | 27 --------------------------- share/man/man5/make.conf.5 | 25 +------------------------ 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index 5929b3c6df20..67f2195cd603 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,6 @@ # kernel-toolchain - Builds the subset of world necessary to build a kernel # kernel-toolchains - Build kernel-toolchain for all universe targets. # doxygen - Build API documentation of the kernel, needs doxygen. -# update - Convenient way to update your source tree(s). # checkworld - Run test suite on installed world. # check-old - List obsolete directories/files/libraries. # check-old-dirs - List obsolete directories. @@ -155,7 +154,7 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ installkernel.debug packagekernel packageworld \ reinstallkernel reinstallkernel.debug \ installworld kernel-toolchain libraries maninstall \ - obj objlink showconfig tags toolchain update \ + obj objlink showconfig tags toolchain \ makeman sysent \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _build-tools _build-metadata _cross-tools _includes _libraries \ diff --git a/Makefile.inc1 b/Makefile.inc1 index 376d48d4fffb..66a4c4bf316b 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -11,9 +11,7 @@ # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel -# -DNO_PORTSUPDATE do not update ports in ${MAKE} update # -DNO_ROOT install without using root privilege -# -DNO_DOCUPDATE do not update doc in ${MAKE} update # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list @@ -494,17 +492,6 @@ BUILDENV_SHELL?=/bin/sh .endif .if !defined(_MKSHOWCONFIG) -.if !defined(SVN_CMD) || empty(SVN_CMD) -. for _P in /usr/bin /usr/local/bin -. for _S in svn svnlite -. if exists(${_P}/${_S}) -SVN_CMD= ${_P}/${_S} -. endif -. endfor -. endfor -.export SVN_CMD -.endif -SVNFLAGS?= -r HEAD .if !defined(VCS_REVISION) || empty(VCS_REVISION) .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD) . for _D in ${PATH:S,:, ,g} @@ -2140,20 +2127,6 @@ doxygen: .PHONY fi ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all -# -# update -# -# Update the source tree(s), by running svn/svnup to update to the -# latest copy. -# -update: .PHONY -.if defined(SVN_UPDATE) - @echo "--------------------------------------------------------------" - @echo ">>> Updating ${.CURDIR} using Subversion" - @echo "--------------------------------------------------------------" - @(cd ${.CURDIR}; ${SVN_CMD} update ${SVNFLAGS}) -.endif - # # ------------------------------------------------------------------------ # diff --git a/share/man/man5/make.conf.5 b/share/man/man5/make.conf.5 index 3dffdf7b402c..b8bb71ddc165 100644 --- a/share/man/man5/make.conf.5 +++ b/share/man/man5/make.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 20, 2020 +.Dd June 11, 2021 .Dt MAKE.CONF 5 .Os .Sh NAME @@ -229,29 +229,6 @@ Setting this variable will prevent CPU specific compiler flags from being automatically added to .Va CFLAGS during compile time. -.It Va NO_DOCUPDATE -.Pq Vt bool -Set this to not update the doc tree during -.Dq Li "make update" . -.It Va NO_PORTSUPDATE -.Pq Vt bool -Set this to not update the ports tree during -.Dq Li "make update" . -.It Va SVN_UPDATE -.Pq Vt bool -Set this to use -.Xr svn 1 -or -.Xr svnlite 1 -to update your -.Pa src -tree with -.Dq Li "make update" . -Note that you can set -.Va SVN -to the full path of a -.Xr svn 1 -binary. .El .Ss "BUILDING THE KERNEL" The following list provides a name and short description for variables From nobody Wed Oct 20 00:27:25 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AECDF17F42D2; Wed, 20 Oct 2021 00: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 4HYrzL0f99z3C50; Wed, 20 Oct 2021 00: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 8F6521DC30; Wed, 20 Oct 2021 00:27: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 19K0RPg7015611; Wed, 20 Oct 2021 00:27:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K0RP5s015610; Wed, 20 Oct 2021 00:27:25 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:27:25 GMT Message-Id: <202110200027.19K0RP5s015610@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: 59a5099ec12d - stable/13 - Document kern.log_wakeups_per_second. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 59a5099ec12d3e8032817587c28c972ed00abdae Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=59a5099ec12d3e8032817587c28c972ed00abdae commit 59a5099ec12d3e8032817587c28c972ed00abdae Author: John Baldwin AuthorDate: 2021-08-04 18:50:34 +0000 Commit: John Baldwin CommitDate: 2021-10-19 23:53:26 +0000 Document kern.log_wakeups_per_second. PR: 148680 (cherry picked from commit c51e4962a3cf2959d1f1cb9ab74ceab448583169) --- sys/kern/subr_log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 9336611d6005..e69fb49b008f 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -98,10 +98,10 @@ static struct cv log_wakeup; struct mtx msgbuf_lock; MTX_SYSINIT(msgbuf_lock, &msgbuf_lock, "msgbuf lock", MTX_DEF); -/* Times per second to check for a pending syslog wakeup. */ static int log_wakeups_per_second = 5; SYSCTL_INT(_kern, OID_AUTO, log_wakeups_per_second, CTLFLAG_RW, - &log_wakeups_per_second, 0, ""); + &log_wakeups_per_second, 0, + "How often (times per second) to check for /dev/log waiters."); /*ARGSUSED*/ static int From nobody Wed Oct 20 00:27:26 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BB4F717F444F; Wed, 20 Oct 2021 00:27: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 4HYrzM2Fk0z3C2k; Wed, 20 Oct 2021 00:27: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 A766E1DC31; Wed, 20 Oct 2021 00: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 19K0RQiX015638; Wed, 20 Oct 2021 00: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 19K0RQU8015637; Wed, 20 Oct 2021 00:27:26 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:27:26 GMT Message-Id: <202110200027.19K0RQU8015637@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: 9ecce2faf3b3 - stable/13 - Add EPOCH_TRACE to NOTES to get LINT coverage. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 9ecce2faf3b377859c8dda05a183c98ac8f00a4b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9ecce2faf3b377859c8dda05a183c98ac8f00a4b commit 9ecce2faf3b377859c8dda05a183c98ac8f00a4b Author: John Baldwin AuthorDate: 2021-09-11 20:05:44 +0000 Commit: John Baldwin CommitDate: 2021-10-19 23:53:30 +0000 Add EPOCH_TRACE to NOTES to get LINT coverage. Sponsored by: The FreeBSD Foundation (cherry picked from commit b9485d76e3ad4924032a23c82b8a30a0dce31918) --- sys/conf/NOTES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index f73b5a466366..f172b9e93d9c 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -329,6 +329,8 @@ options SLEEPQUEUE_PROFILING options TURNSTILE_PROFILING options UMTX_PROFILING +# Debugging traces for epoch(9) misuse +options EPOCH_TRACE ##################################################################### # COMPATIBILITY OPTIONS From nobody Wed Oct 20 00:27:27 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4AFC617F427C; Wed, 20 Oct 2021 00:27: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 4HYrzN0TBbz3CCw; Wed, 20 Oct 2021 00:27: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 C76381DAFD; Wed, 20 Oct 2021 00:27: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 19K0RRNd015666; Wed, 20 Oct 2021 00:27:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K0RR9x015665; Wed, 20 Oct 2021 00:27:27 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:27:27 GMT Message-Id: <202110200027.19K0RR9x015665@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: e9b5d2443f67 - stable/13 - sysdecode_enum.3: Fix a typo: SIGBTRAP -> SIGTRAP. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: e9b5d2443f67616bc323ea0a11089fd1f44eedc5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e9b5d2443f67616bc323ea0a11089fd1f44eedc5 commit e9b5d2443f67616bc323ea0a11089fd1f44eedc5 Author: John Baldwin AuthorDate: 2021-10-05 21:55:18 +0000 Commit: John Baldwin CommitDate: 2021-10-19 23:53:35 +0000 sysdecode_enum.3: Fix a typo: SIGBTRAP -> SIGTRAP. Sponsored by: DARPA (cherry picked from commit 680d70b59e0379ded0cc94e3772bc47be2163c7f) --- lib/libsysdecode/sysdecode_enum.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libsysdecode/sysdecode_enum.3 b/lib/libsysdecode/sysdecode_enum.3 index 1db625f40ff0..722d82f27f29 100644 --- a/lib/libsysdecode/sysdecode_enum.3 +++ b/lib/libsysdecode/sysdecode_enum.3 @@ -225,7 +225,7 @@ object associated with an instance of signal: .It Fn sysdecode_sigfpe_code Ta Dv SIGFPE .It Fn sysdecode_sigill_code Ta Dv SIGILL .It Fn sysdecode_sigsegv_code Ta Dv SIGSEGV -.It Fn sysdecode_sigtrap_code Ta Dv SIGBTRAP +.It Fn sysdecode_sigtrap_code Ta Dv SIGTRAP .El .Pp Other functions decode the values described below: From nobody Wed Oct 20 00:43:01 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A101B17FD0AC; Wed, 20 Oct 2021 00:43: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 4HYsKK4CPKz3Jgj; Wed, 20 Oct 2021 00:43: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 720711DF4D; Wed, 20 Oct 2021 00:43: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 19K0h1oA041966; Wed, 20 Oct 2021 00:43:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K0h1h6041965; Wed, 20 Oct 2021 00:43:01 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:43:01 GMT Message-Id: <202110200043.19K0h1h6041965@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: 5aebce3790cc - stable/13 - rtld direct exec: add -d option List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 5aebce3790cc29a02d3041b5412dc9c83905959a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5aebce3790cc29a02d3041b5412dc9c83905959a commit 5aebce3790cc29a02d3041b5412dc9c83905959a Author: Konstantin Belousov AuthorDate: 2021-10-11 22:26:54 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-20 00:42:25 +0000 rtld direct exec: add -d option (cherry picked from commit ba7f9c1b61329630af25e75cdaca261b389318c7) --- libexec/rtld-elf/rtld.1 | 6 ++++++ libexec/rtld-elf/rtld.c | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/libexec/rtld-elf/rtld.1 b/libexec/rtld-elf/rtld.1 index 8bc4cfade070..187dc105667a 100644 --- a/libexec/rtld-elf/rtld.1 +++ b/libexec/rtld-elf/rtld.1 @@ -330,6 +330,7 @@ The syntax of the direct invocation is .Bd -ragged -offset indent .Pa /libexec/ld-elf.so.1 .Op Fl b Ar exe +.Op Fl d .Op Fl f Ar fd .Op Fl p .Op Fl u @@ -352,6 +353,8 @@ If this option is specified, is only used to provide the .Va argv[0] value to the program. +.It Fl d +Turn off the emulation of the binary execute permission. .It Fl f Ar fd File descriptor .Ar fd @@ -403,6 +406,9 @@ ignores and is naturally prone to race conditions. Environments which rely on such restrictions are weak and breakable on their own. +It can be turned off with the +.Fl d +option. .Sh VERSIONING Newer .Nm diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 1a89a7b2c1de..6c304f98253a 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -140,7 +140,7 @@ static void objlist_remove(Objlist *, Obj_Entry *); static int open_binary_fd(const char *argv0, bool search_in_path, const char **binpath_res); static int parse_args(char* argv[], int argc, bool *use_pathp, int *fdp, - const char **argv0); + const char **argv0, bool *dir_ignore); static int parse_integer(const char *); static void *path_enumerate(const char *, path_enum_proc, const char *, void *); static void print_usage(const char *argv0); @@ -503,7 +503,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) #ifdef __powerpc__ int old_auxv_format = 1; #endif - bool dir_enable, direct_exec, explicit_fd, search_in_path; + bool dir_enable, dir_ignore, direct_exec, explicit_fd, search_in_path; /* * On entry, the dynamic linker itself has not been relocated yet. @@ -589,7 +589,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) dbg("opening main program in direct exec mode"); if (argc >= 2) { - rtld_argc = parse_args(argv, argc, &search_in_path, &fd, &argv0); + rtld_argc = parse_args(argv, argc, &search_in_path, &fd, + &argv0, &dir_ignore); explicit_fd = (fd != -1); binpath = NULL; if (!explicit_fd) @@ -621,7 +622,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) } else if ((st.st_mode & S_IXOTH) != 0) { dir_enable = true; } - if (!dir_enable) { + if (!dir_enable && !dir_ignore) { _rtld_error("No execute permission for binary %s", argv0); rtld_die(); @@ -5842,7 +5843,7 @@ open_binary_fd(const char *argv0, bool search_in_path, */ static int parse_args(char* argv[], int argc, bool *use_pathp, int *fdp, - const char **argv0) + const char **argv0, bool *dir_ignore) { const char *arg; char machine[64]; @@ -5854,6 +5855,7 @@ parse_args(char* argv[], int argc, bool *use_pathp, int *fdp, dbg("Parsing command-line arguments"); *use_pathp = false; *fdp = -1; + *dir_ignore = false; seen_b = seen_f = false; for (i = 1; i < argc; i++ ) { @@ -5890,6 +5892,9 @@ parse_args(char* argv[], int argc, bool *use_pathp, int *fdp, *argv0 = argv[i]; seen_b = true; break; + } else if (opt == 'd') { + *dir_ignore = true; + break; } else if (opt == 'f') { if (seen_b) { _rtld_error("Both -b and -f specified"); @@ -5988,11 +5993,12 @@ print_usage(const char *argv0) { rtld_printf( - "Usage: %s [-h] [-b ] [-f ] [-p] [--] []\n" + "Usage: %s [-h] [-b ] [-d] [-f ] [-p] [--] []\n" "\n" "Options:\n" " -h Display this help message\n" " -b Execute instead of , arg0 is \n" + " -d Ignore lack of exec permissions for the binary\n" " -f Execute instead of searching for \n" " -p Search in PATH for named binary\n" " -u Ignore LD_ environment variables\n" From nobody Wed Oct 20 00:53:41 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2669A18017E2; Wed, 20 Oct 2021 00:53: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 4HYsYf0PTyz3M7w; Wed, 20 Oct 2021 00:53: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 E22AF1DF7F; Wed, 20 Oct 2021 00:53: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 19K0rfqw055137; Wed, 20 Oct 2021 00:53:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K0rfCD055136; Wed, 20 Oct 2021 00:53:41 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:53:41 GMT Message-Id: <202110200053.19K0rfCD055136@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: f89204d6b99d - stable/13 - libc/locale: Fix races between localeconv(3) and setlocale(3) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: f89204d6b99d11aa1f67722e8c1d33b0fc4d61d7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f89204d6b99d11aa1f67722e8c1d33b0fc4d61d7 commit f89204d6b99d11aa1f67722e8c1d33b0fc4d61d7 Author: Mark Johnston AuthorDate: 2021-09-17 14:44:23 +0000 Commit: Mark Johnston CommitDate: 2021-10-20 00:53:33 +0000 libc/locale: Fix races between localeconv(3) and setlocale(3) Each locale embeds a lazily initialized lconv which is populated by localeconv(3) and localeconv_l(3). When setlocale(3) updates the global locale, the lconv needs to be (lazily) reinitialized. To signal this, we set flag variables in the locale structure. There are two problems: - The flags are set before the locale is fully updated, so a concurrent localeconv() call can observe partially initialized locale data. - No barriers ensure that localeconv() observes a fully initialized locale if a flag is set. So, move the flag update appropriately, and use acq/rel barriers to provide some synchronization. Note that this is inadequate in the face of multiple concurrent calls to setlocale(3), but this is not expected to work regardless. Thanks to Henry Hu for providing a test case demonstrating the race. PR: 258360 Sponsored by: The FreeBSD Foundation (cherry picked from commit 7eb138a9e53636366e615bdf04062fedc044bcea) --- lib/libc/locale/lmonetary.c | 4 ++-- lib/libc/locale/lnumeric.c | 4 ++-- lib/libc/locale/localeconv.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/libc/locale/lmonetary.c b/lib/libc/locale/lmonetary.c index 99800ae69922..b8b4e78c060b 100644 --- a/lib/libc/locale/lmonetary.c +++ b/lib/libc/locale/lmonetary.c @@ -107,8 +107,6 @@ monetary_load_locale_l(struct xlocale_monetary *loc, int *using_locale, &loc->buffer, "LC_MONETARY", LCMONETARY_SIZE_FULL, LCMONETARY_SIZE_MIN, (const char **)l); - if (ret != _LDP_ERROR) - *changed = 1; if (ret == _LDP_LOADED) { l->mon_grouping = __fix_locale_grouping_str(l->mon_grouping); @@ -146,6 +144,8 @@ monetary_load_locale_l(struct xlocale_monetary *loc, int *using_locale, M_ASSIGN_ICHAR(p_sign_posn); M_ASSIGN_ICHAR(n_sign_posn); } + if (ret != _LDP_ERROR) + atomic_store_rel_int(changed, 1); return (ret); } int diff --git a/lib/libc/locale/lnumeric.c b/lib/libc/locale/lnumeric.c index 046d1f1817dc..cc1daa3863e3 100644 --- a/lib/libc/locale/lnumeric.c +++ b/lib/libc/locale/lnumeric.c @@ -73,8 +73,6 @@ numeric_load_locale(struct xlocale_numeric *loc, int *using_locale, int *changed &loc->buffer, "LC_NUMERIC", LCNUMERIC_SIZE, LCNUMERIC_SIZE, (const char**)l); - if (ret != _LDP_ERROR) - *changed= 1; if (ret == _LDP_LOADED) { /* Can't be empty according to C99 */ if (*l->decimal_point == '\0') @@ -83,6 +81,8 @@ numeric_load_locale(struct xlocale_numeric *loc, int *using_locale, int *changed l->grouping = __fix_locale_grouping_str(l->grouping); } + if (ret != _LDP_ERROR) + atomic_store_rel_int(changed, 1); return (ret); } diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c index 641773944e32..130f93c178f4 100644 --- a/lib/libc/locale/localeconv.c +++ b/lib/libc/locale/localeconv.c @@ -65,7 +65,7 @@ localeconv_l(locale_t loc) FIX_LOCALE(loc); struct lconv *ret = &loc->lconv; - if (loc->monetary_locale_changed) { + if (atomic_load_acq_int(&loc->monetary_locale_changed) != 0) { /* LC_MONETARY part */ struct lc_monetary_T * mptr; @@ -94,10 +94,10 @@ localeconv_l(locale_t loc) M_ASSIGN_CHAR(int_n_sep_by_space); M_ASSIGN_CHAR(int_p_sign_posn); M_ASSIGN_CHAR(int_n_sign_posn); - loc->monetary_locale_changed = 0; + atomic_store_int(&loc->monetary_locale_changed, 0); } - if (loc->numeric_locale_changed) { + if (atomic_load_acq_int(&loc->numeric_locale_changed) != 0) { /* LC_NUMERIC part */ struct lc_numeric_T * nptr; @@ -107,7 +107,7 @@ localeconv_l(locale_t loc) N_ASSIGN_STR(decimal_point); N_ASSIGN_STR(thousands_sep); N_ASSIGN_STR(grouping); - loc->numeric_locale_changed = 0; + atomic_store_int(&loc->numeric_locale_changed, 0); } return ret; From nobody Wed Oct 20 00:53:42 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A040418012E8; Wed, 20 Oct 2021 00:53: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 4HYsYg39NQz3MNs; Wed, 20 Oct 2021 00:53: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 21C7F1E480; Wed, 20 Oct 2021 00:53: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 19K0rgEk055161; Wed, 20 Oct 2021 00:53:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K0rgMr055160; Wed, 20 Oct 2021 00:53:42 GMT (envelope-from git) Date: Wed, 20 Oct 2021 00:53:42 GMT Message-Id: <202110200053.19K0rgMr055160@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: 348fc38fd539 - stable/13 - mount: Check for !VDIR mount points before handling -o emptydir List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 348fc38fd53920cce82175f90b13765258cee027 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=348fc38fd53920cce82175f90b13765258cee027 commit 348fc38fd53920cce82175f90b13765258cee027 Author: Mark Johnston AuthorDate: 2021-10-13 00:11:02 +0000 Commit: Mark Johnston CommitDate: 2021-10-20 00:53:33 +0000 mount: Check for !VDIR mount points before handling -o emptydir To implement -o emptydir, vfs_emptydir() checks that the passed directory is empty. This should be done after checking whether the vnode is of type VDIR, though, or vfs_emptydir() may end up calling VOP_READDIR on a non-directory. Reported by: syzbot+4006732c69fb0f792b2c@syzkaller.appspotmail.com Reviewed by: kib, imp Sponsored by: The FreeBSD Foundation (cherry picked from commit 03d5820f738de130b2feb66833f18741b7f92a14) --- sys/kern/vfs_mount.c | 10 ++-------- sys/kern/vfs_subr.c | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 09c9a59d1bed..c10c24f4501b 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -946,14 +946,6 @@ vfs_domount_first( ASSERT_VOP_ELOCKED(vp, __func__); KASSERT((fsflags & MNT_UPDATE) == 0, ("MNT_UPDATE shouldn't be here")); - if ((fsflags & MNT_EMPTYDIR) != 0) { - error = vfs_emptydir(vp); - if (error != 0) { - vput(vp); - return (error); - } - } - /* * If the jail of the calling thread lacks permission for this type of * file system, or is trying to cover its own root, deny immediately. @@ -975,6 +967,8 @@ vfs_domount_first( error = vinvalbuf(vp, V_SAVE, 0, 0); if (error == 0 && vp->v_type != VDIR) error = ENOTDIR; + if (error == 0 && (fsflags & MNT_EMPTYDIR) != 0) + error = vfs_emptydir(vp); if (error == 0) { VI_LOCK(vp); if ((vp->v_iflag & VI_MOUNT) == 0 && vp->v_mountedhere == NULL) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 9d0638d1bf38..76e01d1f7816 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -6276,6 +6276,7 @@ vfs_emptydir(struct vnode *vp) eof = 0; ASSERT_VOP_LOCKED(vp, "vfs_emptydir"); + VNASSERT(vp->v_type == VDIR, vp, ("vp is not a directory")); dirent = malloc(sizeof(struct dirent), M_TEMP, M_WAITOK); iov.iov_base = dirent; From nobody Wed Oct 20 01:14:30 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 99DCA180A047; Wed, 20 Oct 2021 01:14: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 4HYt1f3yh3z3hdH; Wed, 20 Oct 2021 01:14: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 67B931E801; Wed, 20 Oct 2021 01:14: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 19K1EU3i082326; Wed, 20 Oct 2021 01:14:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K1EUpj082325; Wed, 20 Oct 2021 01:14:30 GMT (envelope-from git) Date: Wed, 20 Oct 2021 01:14:30 GMT Message-Id: <202110200114.19K1EUpj082325@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: 589daa05be6f - stable/13 - Revert "libc/locale: Fix races between localeconv(3) and setlocale(3)" List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 589daa05be6f390bed6fdeb820c47f8db114c5ec Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=589daa05be6f390bed6fdeb820c47f8db114c5ec commit 589daa05be6f390bed6fdeb820c47f8db114c5ec Author: Mark Johnston AuthorDate: 2021-10-20 01:13:12 +0000 Commit: Mark Johnston CommitDate: 2021-10-20 01:13:12 +0000 Revert "libc/locale: Fix races between localeconv(3) and setlocale(3)" This reverts commit f89204d6b99d11aa1f67722e8c1d33b0fc4d61d7. I didn't intend to push this commit yet, pending discussion on PR 258360. PR: 258360 --- lib/libc/locale/lmonetary.c | 4 ++-- lib/libc/locale/lnumeric.c | 4 ++-- lib/libc/locale/localeconv.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/libc/locale/lmonetary.c b/lib/libc/locale/lmonetary.c index b8b4e78c060b..99800ae69922 100644 --- a/lib/libc/locale/lmonetary.c +++ b/lib/libc/locale/lmonetary.c @@ -107,6 +107,8 @@ monetary_load_locale_l(struct xlocale_monetary *loc, int *using_locale, &loc->buffer, "LC_MONETARY", LCMONETARY_SIZE_FULL, LCMONETARY_SIZE_MIN, (const char **)l); + if (ret != _LDP_ERROR) + *changed = 1; if (ret == _LDP_LOADED) { l->mon_grouping = __fix_locale_grouping_str(l->mon_grouping); @@ -144,8 +146,6 @@ monetary_load_locale_l(struct xlocale_monetary *loc, int *using_locale, M_ASSIGN_ICHAR(p_sign_posn); M_ASSIGN_ICHAR(n_sign_posn); } - if (ret != _LDP_ERROR) - atomic_store_rel_int(changed, 1); return (ret); } int diff --git a/lib/libc/locale/lnumeric.c b/lib/libc/locale/lnumeric.c index cc1daa3863e3..046d1f1817dc 100644 --- a/lib/libc/locale/lnumeric.c +++ b/lib/libc/locale/lnumeric.c @@ -73,6 +73,8 @@ numeric_load_locale(struct xlocale_numeric *loc, int *using_locale, int *changed &loc->buffer, "LC_NUMERIC", LCNUMERIC_SIZE, LCNUMERIC_SIZE, (const char**)l); + if (ret != _LDP_ERROR) + *changed= 1; if (ret == _LDP_LOADED) { /* Can't be empty according to C99 */ if (*l->decimal_point == '\0') @@ -81,8 +83,6 @@ numeric_load_locale(struct xlocale_numeric *loc, int *using_locale, int *changed l->grouping = __fix_locale_grouping_str(l->grouping); } - if (ret != _LDP_ERROR) - atomic_store_rel_int(changed, 1); return (ret); } diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c index 130f93c178f4..641773944e32 100644 --- a/lib/libc/locale/localeconv.c +++ b/lib/libc/locale/localeconv.c @@ -65,7 +65,7 @@ localeconv_l(locale_t loc) FIX_LOCALE(loc); struct lconv *ret = &loc->lconv; - if (atomic_load_acq_int(&loc->monetary_locale_changed) != 0) { + if (loc->monetary_locale_changed) { /* LC_MONETARY part */ struct lc_monetary_T * mptr; @@ -94,10 +94,10 @@ localeconv_l(locale_t loc) M_ASSIGN_CHAR(int_n_sep_by_space); M_ASSIGN_CHAR(int_p_sign_posn); M_ASSIGN_CHAR(int_n_sign_posn); - atomic_store_int(&loc->monetary_locale_changed, 0); + loc->monetary_locale_changed = 0; } - if (atomic_load_acq_int(&loc->numeric_locale_changed) != 0) { + if (loc->numeric_locale_changed) { /* LC_NUMERIC part */ struct lc_numeric_T * nptr; @@ -107,7 +107,7 @@ localeconv_l(locale_t loc) N_ASSIGN_STR(decimal_point); N_ASSIGN_STR(thousands_sep); N_ASSIGN_STR(grouping); - atomic_store_int(&loc->numeric_locale_changed, 0); + loc->numeric_locale_changed = 0; } return ret; From nobody Wed Oct 20 01:42:14 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2971317FBD40; Wed, 20 Oct 2021 01:42: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 4HYtdg0ZDHz4SN5; Wed, 20 Oct 2021 01:42: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 E7C0F1E8FC; Wed, 20 Oct 2021 01:42: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 19K1gEI9022503; Wed, 20 Oct 2021 01:42:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K1gEj1022502; Wed, 20 Oct 2021 01:42:14 GMT (envelope-from git) Date: Wed, 20 Oct 2021 01:42:14 GMT Message-Id: <202110200142.19K1gEj1022502@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: 701eb03cc0dc - stable/13 - nfscl: Fix a deadlock related to the NFSv4 clientID lock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 701eb03cc0dca907de872a41407b8487c38429fc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=701eb03cc0dca907de872a41407b8487c38429fc commit 701eb03cc0dca907de872a41407b8487c38429fc Author: Rick Macklem AuthorDate: 2021-10-12 04:58:24 +0000 Commit: Rick Macklem CommitDate: 2021-10-20 01:36:56 +0000 nfscl: Fix a deadlock related to the NFSv4 clientID lock Without this patch, it is possible for a process doing an NFSv4 Open/create of a file to block to allow another process to acquire the exclusive lock on the clientID when holding a shared lock on the clientID. As such, both processes deadlock, with one wanting the exclusive lock, while the other holds the shared lock. This deadlock is unlikely to occur unless delegations are in use on the NFSv4 mount. This patch fixes the problem by not deferring to the process waiting for the exclusive lock when a shared lock (reference cnt) is already held by the process. This problem was detected during a recent NFSv4 interoperability testing event held by the IETF working group. (cherry picked from commit 120b20bdf49630cf2a7dbc5f93b9e985e1f4f198) --- sys/fs/nfs/nfs_var.h | 4 ++-- sys/fs/nfsclient/nfs_clrpcops.c | 12 ++++++------ sys/fs/nfsclient/nfs_clstate.c | 29 ++++++++++++++++------------- sys/fs/nfsclient/nfs_clvfsops.c | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 9cbaeae361a6..846ab2503981 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -569,12 +569,12 @@ void nfsrpc_bindconnsess(CLIENT *, void *, struct ucred *); /* nfs_clstate.c */ int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int, struct ucred *, NFSPROC_T *, struct nfsclowner **, struct nfsclopen **, - int *, int *, int); + int *, int *, int, bool); int nfscl_getstateid(vnode_t, u_int8_t *, int, u_int32_t, int, struct ucred *, NFSPROC_T *, nfsv4stateid_t *, void **); void nfscl_ownerrelease(struct nfsmount *, struct nfsclowner *, int, int, int); void nfscl_openrelease(struct nfsmount *, struct nfsclopen *, int, int); -int nfscl_getcl(struct mount *, struct ucred *, NFSPROC_T *, bool, +int nfscl_getcl(struct mount *, struct ucred *, NFSPROC_T *, bool, bool, struct nfsclclient **); struct nfsclclient *nfscl_findcl(struct nfsmount *); void nfscl_clientrelease(struct nfsclclient *); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 984a63484777..dbbfdb3b2976 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -390,7 +390,7 @@ else printf(" fhl=0\n"); do { dp = NULL; error = nfscl_open(vp, nfhp->nfh_fh, nfhp->nfh_len, mode, 1, - cred, p, NULL, &op, &newone, &ret, 1); + cred, p, NULL, &op, &newone, &ret, 1, true); if (error) { return (error); } @@ -2061,7 +2061,7 @@ nfsrpc_create(vnode_t dvp, char *name, int namelen, struct vattr *vap, dp = NULL; error = nfscl_open(dvp, NULL, 0, (NFSV4OPEN_ACCESSWRITE | NFSV4OPEN_ACCESSREAD), 0, cred, p, &owp, NULL, &newone, - NULL, 1); + NULL, 1, true); if (error) return (error); if (nmp->nm_clp != NULL) @@ -2347,7 +2347,7 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap, */ error = nfscl_open(dvp, nfhp->nfh_fh, nfhp->nfh_len, (NFSV4OPEN_ACCESSWRITE | NFSV4OPEN_ACCESSREAD), 0, - cred, p, NULL, &op, &newone, NULL, 0); + cred, p, NULL, &op, &newone, NULL, 0, false); if (error) goto nfsmout; op->nfso_stateid = stateid; @@ -3968,7 +3968,7 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, do { nd->nd_repstat = 0; if (op == F_GETLK) { - error = nfscl_getcl(vp->v_mount, cred, p, false, &clp); + error = nfscl_getcl(vp->v_mount, cred, p, false, true, &clp); if (error) return (error); error = nfscl_lockt(vp, clp, off, len, fl, p, id, flags); @@ -3985,7 +3985,7 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, * We must loop around for all lockowner cases. */ callcnt = 0; - error = nfscl_getcl(vp->v_mount, cred, p, false, &clp); + error = nfscl_getcl(vp->v_mount, cred, p, false, true, &clp); if (error) return (error); do { @@ -7931,7 +7931,7 @@ nfsrpc_createlayout(vnode_t dvp, char *name, int namelen, struct vattr *vap, */ error = nfscl_open(dvp, nfhp->nfh_fh, nfhp->nfh_len, (NFSV4OPEN_ACCESSWRITE | NFSV4OPEN_ACCESSREAD), 0, - cred, p, NULL, &op, &newone, NULL, 0); + cred, p, NULL, &op, &newone, NULL, 0, false); if (error != 0) goto nfsmout; op->nfso_stateid = stateid; diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 8d1c4de0ba8e..5aebd68dd9e1 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -218,7 +218,7 @@ static short *nfscl_cberrmap[] = { int nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, struct ucred *cred, NFSPROC_T *p, struct nfsclowner **owpp, - struct nfsclopen **opp, int *newonep, int *retp, int lockit) + struct nfsclopen **opp, int *newonep, int *retp, int lockit, bool firstref) { struct nfsclclient *clp; struct nfsclowner *owp, *nowp; @@ -246,7 +246,7 @@ nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, fhlen - 1, M_NFSCLOPEN, M_WAITOK); nop->nfso_hash.le_prev = NULL; } - ret = nfscl_getcl(vp->v_mount, cred, p, false, &clp); + ret = nfscl_getcl(vp->v_mount, cred, p, false, firstref, &clp); if (ret != 0) { free(nowp, M_NFSCLOWNER); if (nop != NULL) @@ -865,7 +865,7 @@ nfscl_openrelease(struct nfsmount *nmp, struct nfsclopen *op, int error, */ int nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p, - bool tryminvers, struct nfsclclient **clpp) + bool tryminvers, bool firstref, struct nfsclclient **clpp) { struct nfsclclient *clp; struct nfsclclient *newclp = NULL; @@ -934,14 +934,16 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p, NFSCLSTATEMUTEXPTR, mp); if (igotlock == 0) { /* - * Call nfsv4_lock() with "iwantlock == 0" so that it will - * wait for a pending exclusive lock request. This gives the - * exclusive lock request priority over this shared lock - * request. + * Call nfsv4_lock() with "iwantlock == 0" on the firstref so + * that it will wait for a pending exclusive lock request. + * This gives the exclusive lock request priority over this + * shared lock request. * An exclusive lock on nfsc_lock is used mainly for server - * crash recoveries. + * crash recoveries and delegation recalls. */ - nfsv4_lock(&clp->nfsc_lock, 0, NULL, NFSCLSTATEMUTEXPTR, mp); + if (firstref) + nfsv4_lock(&clp->nfsc_lock, 0, NULL, NFSCLSTATEMUTEXPTR, + mp); nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, mp); } if (igotlock == 0 && NFSCL_FORCEDISM(mp)) { @@ -1123,7 +1125,8 @@ nfscl_getbytelock(vnode_t vp, u_int64_t off, u_int64_t len, if (recovery) clp = rclp; else - error = nfscl_getcl(vp->v_mount, cred, p, false, &clp); + error = nfscl_getcl(vp->v_mount, cred, p, false, true, + &clp); } if (error) { free(nlp, M_NFSCLLOCKOWNER); @@ -1454,7 +1457,7 @@ nfscl_checkwritelocked(vnode_t vp, struct flock *fl, end = NFS64BITSSET; } - error = nfscl_getcl(vp->v_mount, cred, p, false, &clp); + error = nfscl_getcl(vp->v_mount, cred, p, false, true, &clp); if (error) return (1); nfscl_filllockowner(id, own, flags); @@ -3247,7 +3250,7 @@ nfscl_getclose(vnode_t vp, struct nfsclclient **clpp) struct nfsfh *nfhp; int error, notdecr; - error = nfscl_getcl(vp->v_mount, NULL, NULL, false, &clp); + error = nfscl_getcl(vp->v_mount, NULL, NULL, false, true, &clp); if (error) return (error); *clpp = clp; @@ -3321,7 +3324,7 @@ nfscl_doclose(vnode_t vp, struct nfsclclient **clpp, NFSPROC_T *p) struct nfsclrecalllayout *recallp; int error; - error = nfscl_getcl(vp->v_mount, NULL, NULL, false, &clp); + error = nfscl_getcl(vp->v_mount, NULL, NULL, false, true, &clp); if (error) return (error); *clpp = clp; diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index d6ec1f9a3825..57ac7f59f38d 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -1611,7 +1611,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, /* For NFSv4, get the clientid now. */ if ((argp->flags & NFSMNT_NFSV4) != 0) { NFSCL_DEBUG(3, "at getcl\n"); - error = nfscl_getcl(mp, cred, td, tryminvers, &clp); + error = nfscl_getcl(mp, cred, td, tryminvers, true, &clp); NFSCL_DEBUG(3, "aft getcl=%d\n", error); if (error != 0) goto bad; From nobody Wed Oct 20 01:43:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 691FD17FD918; Wed, 20 Oct 2021 01:43: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 4HYtgV275Gz4T2b; Wed, 20 Oct 2021 01:43: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 29B0E1EB5B; Wed, 20 Oct 2021 01:43: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 19K1ho1i022716; Wed, 20 Oct 2021 01:43:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19K1hoMx022715; Wed, 20 Oct 2021 01:43:50 GMT (envelope-from git) Date: Wed, 20 Oct 2021 01:43:50 GMT Message-Id: <202110200143.19K1hoMx022715@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: 00595201ad4d - stable/13 - nfscl: Fix another deadlock related to the NFSv4 clientID lock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 00595201ad4de48a1537d43c77445873df6028db Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=00595201ad4de48a1537d43c77445873df6028db commit 00595201ad4de48a1537d43c77445873df6028db Author: Rick Macklem AuthorDate: 2021-10-13 00:21:01 +0000 Commit: Rick Macklem CommitDate: 2021-10-20 01:40:27 +0000 nfscl: Fix another deadlock related to the NFSv4 clientID lock Without this patch, it is possible to hang the NFSv4 client, when a rename/remove is being done on a file where the client holds a delegation, if pNFS is being used. For a delegation to be returned, dirty data blocks must be flushed to the NFSv4 server. When pNFS is in use, a shared lock on the clientID must be acquired while doing a write to the DS(s). However, if rename/remove is doing the delegation return an exclusive lock will be acquired on the clientID, preventing the write to the DS(s) from acquiring a shared lock on the clientID. This patch stops rename/remove from doing a delegation return if pNFS is enabled. Since doing delegation return in the same compound as rename/remove is only an optimization, not doing so should not cause problems. This problem was detected during a recent NFSv4 interoperability testing event held by the IETF working group. (cherry picked from commit b82168e657d378ff86ea18c4f03b98aac9ee9bb3) --- sys/fs/nfsclient/nfs_clstate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 5aebd68dd9e1..276e94002d34 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -4609,6 +4609,8 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; nmp = VFSTONFS(vp->v_mount); + if (NFSHASPNFS(nmp)) + return (retcnt); NFSLOCKMNT(nmp); if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) { NFSUNLOCKMNT(nmp); @@ -4714,6 +4716,8 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, nmp = VFSTONFS(fvp->v_mount); *gotfdp = 0; *gottdp = 0; + if (NFSHASPNFS(nmp)) + return (retcnt); NFSLOCKCLSTATE(); /* * Loop around waiting for: From nobody Wed Oct 20 07:00:02 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 04EB6181410D; Wed, 20 Oct 2021 07: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 4HZ1hL6hkZz4wng; Wed, 20 Oct 2021 07:00: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 C787A22FE0; Wed, 20 Oct 2021 07:00: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 19K702S2039877; Wed, 20 Oct 2021 07: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 19K702QZ039875; Wed, 20 Oct 2021 07:00:02 GMT (envelope-from git) Date: Wed, 20 Oct 2021 07:00:02 GMT Message-Id: <202110200700.19K702QZ039875@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: dbdc8e3e3f64 - stable/13 - bhyve: Update usage and synopsis for the -k flag List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: dbdc8e3e3f64e1c4d8aadcbdbfc1a8bf3609d571 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=dbdc8e3e3f64e1c4d8aadcbdbfc1a8bf3609d571 commit dbdc8e3e3f64e1c4d8aadcbdbfc1a8bf3609d571 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-10-12 19:49:43 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-10-20 06:59:11 +0000 bhyve: Update usage and synopsis for the -k flag Let's make it clear to users that -k is for configuration files. Also, point to bhyve_config(5) in the paragraph describing the flag. Reviewed by: jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32467 (cherry picked from commit f656df586ad1aa86a2b9f076a224f746d5308613) --- usr.sbin/bhyve/bhyve.8 | 9 ++++++--- usr.sbin/bhyve/bhyverun.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8 index 79b6d9bfb240..4f5b544cfc65 100644 --- a/usr.sbin/bhyve/bhyve.8 +++ b/usr.sbin/bhyve/bhyve.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 18, 2021 +.Dd October 13, 2021 .Dt BHYVE 8 .Os .Sh NAME @@ -46,7 +46,7 @@ .Oc .Sm on .Op Fl G Ar port -.Op Fl k Ar file +.Op Fl k Ar config_file .Oo Fl l .Sm off .Ar lpcdev Op Cm \&, Ar conf @@ -155,7 +155,7 @@ 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 h Print help message and exit. -.It Fl k Ar file +.It Fl k Ar config_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 @@ -166,6 +166,9 @@ value. Blank lines and lines starting with .Sq # are ignored. +See +.Xr bhyve_config 5 +for more details. .It Fl l Cm help Print a list of supported LPC devices. .It Fl l Ar lpcdev Ns Op Cm \&, Ns Ar conf diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index d14219bbef65..e4d96d2293fa 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -224,7 +224,7 @@ usage(int code) fprintf(stderr, "Usage: %s [-AaCDeHhPSuWwxY]\n" " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n" - " %*s [-G port] [-k file] [-l lpc] [-m mem] [-o var=value]\n" + " %*s [-G port] [-k config_file] [-l lpc] [-m mem] [-o var=value]\n" " %*s [-p vcpu:hostcpu] [-r file] [-s pci] [-U uuid] vmname\n" " -A: create ACPI tables\n" " -a: local apic is in xAPIC mode (deprecated)\n" From nobody Wed Oct 20 13:33:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 258031806C44; Wed, 20 Oct 2021 13:33: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 4HZBQl0fHvz4gNF; Wed, 20 Oct 2021 13:33: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 EB1FA712; Wed, 20 Oct 2021 13:33: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 19KDXoOY070199; Wed, 20 Oct 2021 13:33:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KDXoef070198; Wed, 20 Oct 2021 13:33:50 GMT (envelope-from git) Date: Wed, 20 Oct 2021 13:33:50 GMT Message-Id: <202110201333.19KDXoef070198@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: a90b5b1104db - stable/12 - pf: Introduce pf_nvbool() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: a90b5b1104db4d50a5fb65861c6cc627c0a38dfe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a90b5b1104db4d50a5fb65861c6cc627c0a38dfe commit a90b5b1104db4d50a5fb65861c6cc627c0a38dfe Author: Kristof Provost AuthorDate: 2021-10-13 09:00:46 +0000 Commit: Kristof Provost CommitDate: 2021-10-20 07:53:23 +0000 pf: Introduce pf_nvbool() Similar to the existing functions for strings and ints, this lets us simplify some of the nvlist conversion code. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 776df104fa54bb581e1fb88ac44af4fa7fd4052b) --- sys/netpfil/pf/pf_nv.c | 14 ++++++++++++-- sys/netpfil/pf/pf_nv.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index d1eca90e0ee5..5eda6b3917f4 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -99,6 +99,17 @@ __FBSDID("$FreeBSD$"); } \ } +int +pf_nvbool(const nvlist_t *nvl, const char *name, bool *val) +{ + if (! nvlist_exists_bool(nvl, name)) + return (EINVAL); + + *val = nvlist_get_bool(nvl, name); + + return (0); +} + int pf_nvbinary(const nvlist_t *nvl, const char *name, void *data, size_t expected_size) @@ -840,8 +851,7 @@ pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, sizeof(kill->psk_ifname))); PFNV_CHK(pf_nvstring(nvl, "label", kill->psk_label, sizeof(kill->psk_label))); - if (nvlist_exists_bool(nvl, "kill_match")) - kill->psk_kill_match = nvlist_get_bool(nvl, "kill_match"); + PFNV_CHK(pf_nvbool(nvl, "kill_match", &kill->psk_kill_match)); errout: return (error); diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index f1cdc52aad6b..7ac3bc4153ee 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -70,6 +70,7 @@ PF_NV_DEF_UINT(uint16, uint16_t, UINT16_MAX); PF_NV_DEF_UINT(uint32, uint32_t, UINT32_MAX); PF_NV_DEF_UINT(uint64, uint64_t, UINT64_MAX); +int pf_nvbool(const nvlist_t *, const char *, bool *); int pf_nvbinary(const nvlist_t *, const char *, void *, size_t); int pf_nvint(const nvlist_t *, const char *, int *); int pf_nvstring(const nvlist_t *, const char *, char *, size_t); From nobody Wed Oct 20 13:33:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 772851806BDC; Wed, 20 Oct 2021 13:33: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 4HZBQm1nCnz4gc9; Wed, 20 Oct 2021 13:33: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 1C4833E3; Wed, 20 Oct 2021 13:33: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 19KDXqZB070302; Wed, 20 Oct 2021 13:33:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KDXq8M070301; Wed, 20 Oct 2021 13:33:52 GMT (envelope-from git) Date: Wed, 20 Oct 2021 13:33:52 GMT Message-Id: <202110201333.19KDXq8M070301@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: fc391b7a56d9 - stable/13 - pf: Introduce pf_nvbool() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: fc391b7a56d9b8eec3f1585397c8263923153442 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=fc391b7a56d9b8eec3f1585397c8263923153442 commit fc391b7a56d9b8eec3f1585397c8263923153442 Author: Kristof Provost AuthorDate: 2021-10-13 09:00:46 +0000 Commit: Kristof Provost CommitDate: 2021-10-20 07:51:34 +0000 pf: Introduce pf_nvbool() Similar to the existing functions for strings and ints, this lets us simplify some of the nvlist conversion code. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 776df104fa54bb581e1fb88ac44af4fa7fd4052b) --- sys/netpfil/pf/pf_nv.c | 14 ++++++++++++-- sys/netpfil/pf/pf_nv.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index d1eca90e0ee5..5eda6b3917f4 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -99,6 +99,17 @@ __FBSDID("$FreeBSD$"); } \ } +int +pf_nvbool(const nvlist_t *nvl, const char *name, bool *val) +{ + if (! nvlist_exists_bool(nvl, name)) + return (EINVAL); + + *val = nvlist_get_bool(nvl, name); + + return (0); +} + int pf_nvbinary(const nvlist_t *nvl, const char *name, void *data, size_t expected_size) @@ -840,8 +851,7 @@ pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, sizeof(kill->psk_ifname))); PFNV_CHK(pf_nvstring(nvl, "label", kill->psk_label, sizeof(kill->psk_label))); - if (nvlist_exists_bool(nvl, "kill_match")) - kill->psk_kill_match = nvlist_get_bool(nvl, "kill_match"); + PFNV_CHK(pf_nvbool(nvl, "kill_match", &kill->psk_kill_match)); errout: return (error); diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index f1cdc52aad6b..7ac3bc4153ee 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -70,6 +70,7 @@ PF_NV_DEF_UINT(uint16, uint16_t, UINT16_MAX); PF_NV_DEF_UINT(uint32, uint32_t, UINT32_MAX); PF_NV_DEF_UINT(uint64, uint64_t, UINT64_MAX); +int pf_nvbool(const nvlist_t *, const char *, bool *); int pf_nvbinary(const nvlist_t *, const char *, void *, size_t); int pf_nvint(const nvlist_t *, const char *, int *); int pf_nvstring(const nvlist_t *, const char *, char *, size_t); From nobody Wed Oct 20 13:57:45 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C68EB17F01E4; Wed, 20 Oct 2021 13:57: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 4HZByK2yFsz4nBD; Wed, 20 Oct 2021 13:57: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 3ECA3971; Wed, 20 Oct 2021 13:57: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 19KDvjMs097066; Wed, 20 Oct 2021 13:57:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KDvjsm097065; Wed, 20 Oct 2021 13:57:45 GMT (envelope-from git) Date: Wed, 20 Oct 2021 13:57:45 GMT Message-Id: <202110201357.19KDvjsm097065@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 8ec8f56ce25b - stable/13 - cxgbe(4): Separate the sw- and hw-specific parts of resource allocations List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8ec8f56ce25b0bcb95bba5ae52d284bcbd88617e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=8ec8f56ce25b0bcb95bba5ae52d284bcbd88617e commit 8ec8f56ce25b0bcb95bba5ae52d284bcbd88617e Author: Navdeep Parhar AuthorDate: 2021-04-26 21:03:06 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 13:55:38 +0000 cxgbe(4): Separate the sw- and hw-specific parts of resource allocations The driver uses both software resources (locks, callouts, memory for descriptors and for bookkeeping, sysctls, etc.) and hardware resources (VIs, DMA queues, TCAM entries, etc.) to operate the NIC. This commit splits the single *_ALLOCATED flag used to track all these resources into separate *_SW_ALLOCATED and *_HW_ALLOCATED flags. This is the simplified pseudocode that now applies to most queues (foo can be ctrlq/txq/rxq/ofld_txq/ofld_rxq): /* Idempotent */ alloc_foo { if (!SW_ALLOCATED) init_iq/init_eq/init_fl no-fail sw init alloc_iq_fl/alloc_eq/alloc_wrq may-fail sw alloc add_foo_sysctls, etc. no-fail post-alloc items if (!HW_ALLOCATED) alloc_iq_fl_hwq/alloc_eq_hwq hw resource allocation } /* Idempotent */ free_foo { if (!HW_ALLOCATED) free_iq_fl_hwq/free_eq_hwq release hw resources if (!SW_ALLOCATED) free_iq_fl/free_eq/free_wrq release sw resources } The routines that take the driver to FULL_INIT_DONE and VI_INIT_DONE and back are now all idempotent. The quiesce routines pay attention to the HW_ALLOCATED flag and will not wait on the hardware for pidx/cidx updates and other completions if this flag is not set. Sponsored by: Chelsio Communications (cherry picked from commit 43bbae19483fbde0a91e61acad8a6e71e334c8b8) --- sys/dev/cxgbe/adapter.h | 44 +- sys/dev/cxgbe/t4_filter.c | 9 +- sys/dev/cxgbe/t4_main.c | 376 +++++++---- sys/dev/cxgbe/t4_netmap.c | 11 +- sys/dev/cxgbe/t4_sched.c | 13 +- sys/dev/cxgbe/t4_sge.c | 1466 ++++++++++++++++++++++++----------------- sys/dev/cxgbe/tom/t4_cpl_io.c | 2 +- 7 files changed, 1135 insertions(+), 786 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 7f6e1ceb1550..8809a10269a1 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -231,7 +231,13 @@ struct vi_info { struct mtx tick_mtx; struct callout tick; - struct sysctl_ctx_list ctx; /* from ifconfig up to driver detach */ + struct sysctl_ctx_list ctx; + struct sysctl_oid *rxq_oid; + struct sysctl_oid *txq_oid; + struct sysctl_oid *nm_rxq_oid; + struct sysctl_oid *nm_txq_oid; + struct sysctl_oid *ofld_rxq_oid; + struct sysctl_oid *ofld_txq_oid; uint8_t hw_addr[ETHER_ADDR_LEN]; /* factory MAC address, won't change */ }; @@ -345,11 +351,12 @@ CTASSERT(sizeof(struct iq_desc) == IQ_ESIZE); enum { /* iq flags */ - IQ_ALLOCATED = (1 << 0), /* firmware resources allocated */ + IQ_SW_ALLOCATED = (1 << 0), /* sw resources allocated */ IQ_HAS_FL = (1 << 1), /* iq associated with a freelist */ IQ_RX_TIMESTAMP = (1 << 2), /* provide the SGE rx timestamp */ IQ_LRO_ENABLED = (1 << 3), /* iq is an eth rxq with LRO enabled */ IQ_ADJ_CREDIT = (1 << 4), /* hw is off by 1 credit for this iq */ + IQ_HW_ALLOCATED = (1 << 5), /* fw/hw resources allocated */ /* iq state */ IQS_DISABLED = 0, @@ -393,12 +400,13 @@ struct sge_iq { int8_t intr_pktc_idx; /* packet count threshold index */ uint8_t gen; /* generation bit */ uint8_t intr_params; /* interrupt holdoff parameters */ - uint8_t intr_next; /* XXX: holdoff for next interrupt */ + int8_t cong; /* congestion settings */ uint16_t qsize; /* size (# of entries) of the queue */ uint16_t sidx; /* index of the entry with the status page */ uint16_t cidx; /* consumer index */ uint16_t cntxt_id; /* SGE context id for the iq */ uint16_t abs_id; /* absolute SGE id for the iq */ + int16_t intr_idx; /* interrupt used by the queue */ STAILQ_ENTRY(sge_iq) link; @@ -408,13 +416,14 @@ struct sge_iq { }; enum { + /* eq type */ EQ_CTRL = 1, EQ_ETH = 2, EQ_OFLD = 3, /* eq flags */ - EQ_TYPEMASK = 0x3, /* 2 lsbits hold the type (see above) */ - EQ_ALLOCATED = (1 << 2), /* firmware resources allocated */ + EQ_SW_ALLOCATED = (1 << 0), /* sw resources allocated */ + EQ_HW_ALLOCATED = (1 << 1), /* hw/fw resources allocated */ EQ_ENABLED = (1 << 3), /* open for business */ EQ_QFLUSH = (1 << 4), /* if_qflush in progress */ }; @@ -432,10 +441,12 @@ struct sge_eq { unsigned int flags; /* MUST be first */ unsigned int cntxt_id; /* SGE context id for the eq */ unsigned int abs_id; /* absolute SGE id for the eq */ + uint8_t type; /* EQ_CTRL/EQ_ETH/EQ_OFLD */ + uint8_t doorbells; + uint8_t tx_chan; /* tx channel used by the eq */ struct mtx eq_lock; struct tx_desc *desc; /* KVA of descriptor ring */ - uint8_t doorbells; volatile uint32_t *udb; /* KVA of doorbell (lies within BAR2) */ u_int udb_qid; /* relative qid within the doorbell page */ uint16_t sidx; /* index of the entry with the status page */ @@ -443,9 +454,9 @@ struct sge_eq { uint16_t pidx; /* producer idx (desc idx) */ uint16_t equeqidx; /* EQUEQ last requested at this pidx */ uint16_t dbidx; /* pidx of the most recent doorbell */ - uint16_t iqid; /* iq that gets egr_update for the eq */ - uint8_t tx_chan; /* tx channel used by the eq */ + uint16_t iqid; /* cached iq->cntxt_id (see iq below) */ volatile u_int equiq; /* EQUIQ outstanding */ + struct sge_iq *iq; /* iq that receives egr_update for the eq */ bus_dma_tag_t desc_tag; bus_dmamap_t desc_map; @@ -922,7 +933,9 @@ struct adapter { uint16_t iscsicaps; uint16_t fcoecaps; - struct sysctl_ctx_list ctx; /* from adapter_full_init to full_uninit */ + struct sysctl_ctx_list ctx; + struct sysctl_oid *ctrlq_oid; + struct sysctl_oid *fwq_oid; struct mtx sc_lock; char lockname[16]; @@ -1201,10 +1214,8 @@ int begin_synchronized_op(struct adapter *, struct vi_info *, int, char *); void doom_vi(struct adapter *, struct vi_info *); void end_synchronized_op(struct adapter *, int); int update_mac_settings(struct ifnet *, int); -int adapter_full_init(struct adapter *); -int adapter_full_uninit(struct adapter *); -int vi_full_init(struct vi_info *); -int vi_full_uninit(struct vi_info *); +int adapter_init(struct adapter *); +int vi_init(struct vi_info *); void vi_sysctls(struct vi_info *); int rw_via_memwin(struct adapter *, int, uint32_t, uint32_t *, int, int); int alloc_atid(struct adapter *, void *); @@ -1243,11 +1254,9 @@ struct sge_nm_rxq; void cxgbe_nm_attach(struct vi_info *); void cxgbe_nm_detach(struct vi_info *); void service_nm_rxq(struct sge_nm_rxq *); -int alloc_nm_rxq(struct vi_info *, struct sge_nm_rxq *, int, int, - struct sysctl_oid *); +int alloc_nm_rxq(struct vi_info *, struct sge_nm_rxq *, int, int); int free_nm_rxq(struct vi_info *, struct sge_nm_rxq *); -int alloc_nm_txq(struct vi_info *, struct sge_nm_txq *, int, int, - struct sysctl_oid *); +int alloc_nm_txq(struct vi_info *, struct sge_nm_txq *, int, int); int free_nm_txq(struct vi_info *, struct sge_nm_txq *); #endif @@ -1266,6 +1275,7 @@ int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *, bus_addr_t *, void **); int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, void *); +void free_fl_buffers(struct adapter *, struct sge_fl *); int t4_setup_adapter_queues(struct adapter *); int t4_teardown_adapter_queues(struct adapter *); int t4_setup_vi_queues(struct vi_info *); diff --git a/sys/dev/cxgbe/t4_filter.c b/sys/dev/cxgbe/t4_filter.c index 3afab0d1d6b9..cddd2c96a620 100644 --- a/sys/dev/cxgbe/t4_filter.c +++ b/sys/dev/cxgbe/t4_filter.c @@ -960,11 +960,10 @@ set_filter(struct adapter *sc, struct t4_filter *t) rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4setf"); if (rc) return (rc); - if (!(sc->flags & FULL_INIT_DONE) && - ((rc = adapter_full_init(sc)) != 0)) { - end_synchronized_op(sc, 0); - return (rc); - } + + if (!(sc->flags & FULL_INIT_DONE) && ((rc = adapter_init(sc)) != 0)) + goto done; + if (t->fs.hash) { if (__predict_false(ti->hftid_hash_4t == NULL)) { rc = alloc_hftid_hash(&sc->tids, HASH_NOWAIT); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 5f969829c2d1..e5c11402d9ab 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -725,10 +725,15 @@ static int fixup_link_config(struct port_info *); static int apply_link_config(struct port_info *); static int cxgbe_init_synchronized(struct vi_info *); static int cxgbe_uninit_synchronized(struct vi_info *); -static void quiesce_txq(struct adapter *, struct sge_txq *); -static void quiesce_wrq(struct adapter *, struct sge_wrq *); -static void quiesce_iq(struct adapter *, struct sge_iq *); -static void quiesce_fl(struct adapter *, struct sge_fl *); +static int adapter_full_init(struct adapter *); +static void adapter_full_uninit(struct adapter *); +static int vi_full_init(struct vi_info *); +static void vi_full_uninit(struct vi_info *); +static int alloc_extra_vi(struct adapter *, struct port_info *, struct vi_info *); +static void quiesce_txq(struct sge_txq *); +static void quiesce_wrq(struct sge_wrq *); +static void quiesce_iq_fl(struct adapter *, struct sge_iq *, struct sge_fl *); +static void quiesce_vi(struct vi_info *); static int t4_alloc_irq(struct adapter *, struct irq *, int rid, driver_intr_t *, void *, char *); static int t4_free_irq(struct adapter *, struct irq *); @@ -1132,6 +1137,13 @@ t4_attach(device_t dev) refcount_init(&sc->vxlan_refcount, 0); + sc->ctrlq_oid = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "ctrlq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "control queues"); + sc->fwq_oid = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "fwq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "firmware event queue"); + rc = t4_map_bars_0_and_4(sc); if (rc != 0) goto done; /* error message displayed already */ @@ -1429,6 +1441,7 @@ t4_attach(device_t dev) for_each_vi(pi, j, vi) { vi->pi = pi; vi->adapter = sc; + vi->first_intr = -1; vi->qsize_rxq = t4_qsize_rxq; vi->qsize_txq = t4_qsize_txq; @@ -1680,9 +1693,7 @@ t4_detach_common(device_t dev) } device_delete_children(dev); - - if (sc->flags & FULL_INIT_DONE) - adapter_full_uninit(sc); + adapter_full_uninit(sc); if ((sc->flags & (IS_VF | FW_OK)) == FW_OK) t4_fw_bye(sc, sc->mbox); @@ -1797,9 +1808,32 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) { struct ifnet *ifp; struct sbuf *sb; + struct sysctl_ctx_list *ctx; + struct sysctl_oid_list *children; struct pfil_head_args pa; struct adapter *sc = vi->adapter; + ctx = device_get_sysctl_ctx(vi->dev); + children = SYSCTL_CHILDREN(device_get_sysctl_tree(vi->dev)); + vi->rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "rxq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "NIC rx queues"); + vi->txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "txq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "NIC tx queues"); +#ifdef DEV_NETMAP + vi->nm_rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "nm_rxq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "netmap rx queues"); + vi->nm_txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "nm_txq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "netmap tx queues"); +#endif +#ifdef TCP_OFFLOAD + vi->ofld_rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "ofld_rxq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "TOE rx queues"); +#endif +#if defined(TCP_OFFLOAD) || defined(RATELIMIT) + vi->ofld_txq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "ofld_txq", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "TOE/ETHOFLD tx queues"); +#endif + vi->xact_addr_filt = -1; mtx_init(&vi->tick_mtx, "vi tick", NULL, MTX_DEF); callout_init_mtx(&vi->tick, &vi->tick_mtx, 0); @@ -5536,12 +5570,10 @@ cxgbe_init_synchronized(struct vi_info *vi) if (ifp->if_drv_flags & IFF_DRV_RUNNING) return (0); /* already running */ - if (!(sc->flags & FULL_INIT_DONE) && - ((rc = adapter_full_init(sc)) != 0)) + if (!(sc->flags & FULL_INIT_DONE) && ((rc = adapter_init(sc)) != 0)) return (rc); /* error message displayed already */ - if (!(vi->flags & VI_INIT_DONE) && - ((rc = vi_full_init(vi)) != 0)) + if (!(vi->flags & VI_INIT_DONE) && ((rc = vi_init(vi)) != 0)) return (rc); /* error message displayed already */ rc = update_mac_settings(ifp, XGMAC_ALL); @@ -5836,31 +5868,36 @@ write_global_rss_key(struct adapter *sc) #endif } -int +/* + * Idempotent. + */ +static int adapter_full_init(struct adapter *sc) { int rc, i; ASSERT_SYNCHRONIZED_OP(sc); - ADAPTER_LOCK_ASSERT_NOTOWNED(sc); - KASSERT((sc->flags & FULL_INIT_DONE) == 0, - ("%s: FULL_INIT_DONE already", __func__)); + + if (!(sc->flags & ADAP_SYSCTL_CTX)) { + sysctl_ctx_init(&sc->ctx); + sc->flags |= ADAP_SYSCTL_CTX; + } /* * queues that belong to the adapter (not any particular port). */ rc = t4_setup_adapter_queues(sc); if (rc != 0) - goto done; + return (rc); for (i = 0; i < nitems(sc->tq); i++) { + if (sc->tq[i] != NULL) + continue; sc->tq[i] = taskqueue_create("t4 taskq", M_NOWAIT, taskqueue_thread_enqueue, &sc->tq[i]); if (sc->tq[i] == NULL) { - device_printf(sc->dev, - "failed to allocate task queue %d\n", i); - rc = ENOMEM; - goto done; + CH_ERR(sc, "failed to allocate task queue %d\n", i); + return (ENOMEM); } taskqueue_start_threads(&sc->tq[i], 1, PI_NET, "%s tq%d", device_get_nameunit(sc->dev), i); @@ -5875,20 +5912,41 @@ adapter_full_init(struct adapter *sc) callout_reset_sbt(&sc->ktls_tick, SBT_1MS, 0, ktls_tick, sc, C_HARDCLOCK); #endif - sc->flags |= FULL_INIT_DONE; -done: + return (0); +} + +int +adapter_init(struct adapter *sc) +{ + int rc; + + ASSERT_SYNCHRONIZED_OP(sc); + ADAPTER_LOCK_ASSERT_NOTOWNED(sc); + KASSERT((sc->flags & FULL_INIT_DONE) == 0, + ("%s: FULL_INIT_DONE already", __func__)); + + rc = adapter_full_init(sc); if (rc != 0) adapter_full_uninit(sc); + else + sc->flags |= FULL_INIT_DONE; return (rc); } -int +/* + * Idempotent. + */ +static void adapter_full_uninit(struct adapter *sc) { int i; - ADAPTER_LOCK_ASSERT_NOTOWNED(sc); + /* Do this before freeing the adapter queues. */ + if (sc->flags & ADAP_SYSCTL_CTX) { + sysctl_ctx_free(&sc->ctx); + sc->flags &= ~ADAP_SYSCTL_CTX; + } t4_teardown_adapter_queues(sc); @@ -5898,8 +5956,6 @@ adapter_full_uninit(struct adapter *sc) } sc->flags &= ~FULL_INIT_DONE; - - return (0); } #ifdef RSS @@ -5967,12 +6023,13 @@ hashen_to_hashconfig(int hashen) } #endif -int +/* + * Idempotent. + */ +static int vi_full_init(struct vi_info *vi) { struct adapter *sc = vi->adapter; - struct ifnet *ifp = vi->ifp; - uint16_t *rss; struct sge_rxq *rxq; int rc, i, j; #ifdef RSS @@ -5982,59 +6039,60 @@ vi_full_init(struct vi_info *vi) #endif ASSERT_SYNCHRONIZED_OP(sc); - KASSERT((vi->flags & VI_INIT_DONE) == 0, - ("%s: VI_INIT_DONE already", __func__)); - sysctl_ctx_init(&vi->ctx); - vi->flags |= VI_SYSCTL_CTX; + if (!(vi->flags & VI_SYSCTL_CTX)) { + sysctl_ctx_init(&vi->ctx); + vi->flags |= VI_SYSCTL_CTX; + } /* * Allocate tx/rx/fl queues for this VI. */ rc = t4_setup_vi_queues(vi); if (rc != 0) - goto done; /* error message displayed already */ + return (rc); /* * Setup RSS for this VI. Save a copy of the RSS table for later use. */ if (vi->nrxq > vi->rss_size) { - if_printf(ifp, "nrxq (%d) > hw RSS table size (%d); " + CH_ALERT(vi, "nrxq (%d) > hw RSS table size (%d); " "some queues will never receive traffic.\n", vi->nrxq, vi->rss_size); } else if (vi->rss_size % vi->nrxq) { - if_printf(ifp, "nrxq (%d), hw RSS table size (%d); " + CH_ALERT(vi, "nrxq (%d), hw RSS table size (%d); " "expect uneven traffic distribution.\n", vi->nrxq, vi->rss_size); } #ifdef RSS if (vi->nrxq != nbuckets) { - if_printf(ifp, "nrxq (%d) != kernel RSS buckets (%d);" + CH_ALERT(vi, "nrxq (%d) != kernel RSS buckets (%d);" "performance will be impacted.\n", vi->nrxq, nbuckets); } #endif - rss = malloc(vi->rss_size * sizeof (*rss), M_CXGBE, M_ZERO | M_WAITOK); + if (vi->rss == NULL) + vi->rss = malloc(vi->rss_size * sizeof (*vi->rss), M_CXGBE, + M_ZERO | M_WAITOK); for (i = 0; i < vi->rss_size;) { #ifdef RSS j = rss_get_indirection_to_bucket(i); j %= vi->nrxq; rxq = &sc->sge.rxq[vi->first_rxq + j]; - rss[i++] = rxq->iq.abs_id; + vi->rss[i++] = rxq->iq.abs_id; #else for_each_rxq(vi, j, rxq) { - rss[i++] = rxq->iq.abs_id; + vi->rss[i++] = rxq->iq.abs_id; if (i == vi->rss_size) break; } #endif } - rc = -t4_config_rss_range(sc, sc->mbox, vi->viid, 0, vi->rss_size, rss, - vi->rss_size); + rc = -t4_config_rss_range(sc, sc->mbox, vi->viid, 0, vi->rss_size, + vi->rss, vi->rss_size); if (rc != 0) { - free(rss, M_CXGBE); - if_printf(ifp, "rss_config failed: %d\n", rc); - goto done; + CH_ERR(vi, "rss_config failed: %d\n", rc); + return (rc); } #ifdef RSS @@ -6057,40 +6115,52 @@ vi_full_init(struct vi_info *vi) MPASS((extra & hashconfig) == 0); if (extra) { - if_printf(ifp, + CH_ALERT(vi, "global RSS config (0x%x) cannot be accommodated.\n", hashconfig); } if (extra & RSS_HASHTYPE_RSS_IPV4) - if_printf(ifp, "IPv4 2-tuple hashing forced on.\n"); + CH_ALERT(vi, "IPv4 2-tuple hashing forced on.\n"); if (extra & RSS_HASHTYPE_RSS_TCP_IPV4) - if_printf(ifp, "TCP/IPv4 4-tuple hashing forced on.\n"); + CH_ALERT(vi, "TCP/IPv4 4-tuple hashing forced on.\n"); if (extra & RSS_HASHTYPE_RSS_IPV6) - if_printf(ifp, "IPv6 2-tuple hashing forced on.\n"); + CH_ALERT(vi, "IPv6 2-tuple hashing forced on.\n"); if (extra & RSS_HASHTYPE_RSS_TCP_IPV6) - if_printf(ifp, "TCP/IPv6 4-tuple hashing forced on.\n"); + CH_ALERT(vi, "TCP/IPv6 4-tuple hashing forced on.\n"); if (extra & RSS_HASHTYPE_RSS_UDP_IPV4) - if_printf(ifp, "UDP/IPv4 4-tuple hashing forced on.\n"); + CH_ALERT(vi, "UDP/IPv4 4-tuple hashing forced on.\n"); if (extra & RSS_HASHTYPE_RSS_UDP_IPV6) - if_printf(ifp, "UDP/IPv6 4-tuple hashing forced on.\n"); + CH_ALERT(vi, "UDP/IPv6 4-tuple hashing forced on.\n"); #else vi->hashen = F_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN | F_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN | F_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN | F_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN | F_FW_RSS_VI_CONFIG_CMD_UDPEN; #endif - rc = -t4_config_vi_rss(sc, sc->mbox, vi->viid, vi->hashen, rss[0], 0, 0); + rc = -t4_config_vi_rss(sc, sc->mbox, vi->viid, vi->hashen, vi->rss[0], + 0, 0); if (rc != 0) { - free(rss, M_CXGBE); - if_printf(ifp, "rss hash/defaultq config failed: %d\n", rc); - goto done; + CH_ERR(vi, "rss hash/defaultq config failed: %d\n", rc); + return (rc); } - vi->rss = rss; - vi->flags |= VI_INIT_DONE; -done: + return (0); +} + +int +vi_init(struct vi_info *vi) +{ + int rc; + + ASSERT_SYNCHRONIZED_OP(vi->adapter); + KASSERT((vi->flags & VI_INIT_DONE) == 0, + ("%s: VI_INIT_DONE already", __func__)); + + rc = vi_full_init(vi); if (rc != 0) vi_full_uninit(vi); + else + vi->flags |= VI_INIT_DONE; return (rc); } @@ -6098,118 +6168,149 @@ done: /* * Idempotent. */ -int +static void vi_full_uninit(struct vi_info *vi) { - struct port_info *pi = vi->pi; - struct adapter *sc = pi->adapter; - int i; - struct sge_rxq *rxq; - struct sge_txq *txq; -#ifdef TCP_OFFLOAD - struct sge_ofld_rxq *ofld_rxq; -#endif -#if defined(TCP_OFFLOAD) || defined(RATELIMIT) - struct sge_ofld_txq *ofld_txq; -#endif if (vi->flags & VI_INIT_DONE) { - - /* Need to quiesce queues. */ - - /* XXX: Only for the first VI? */ - if (IS_MAIN_VI(vi) && !(sc->flags & IS_VF)) - quiesce_wrq(sc, &sc->sge.ctrlq[pi->port_id]); - - for_each_txq(vi, i, txq) { - quiesce_txq(sc, txq); - } - -#if defined(TCP_OFFLOAD) || defined(RATELIMIT) - for_each_ofld_txq(vi, i, ofld_txq) { - quiesce_wrq(sc, &ofld_txq->wrq); - } -#endif - - for_each_rxq(vi, i, rxq) { - quiesce_iq(sc, &rxq->iq); - quiesce_fl(sc, &rxq->fl); - } - -#ifdef TCP_OFFLOAD - for_each_ofld_rxq(vi, i, ofld_rxq) { - quiesce_iq(sc, &ofld_rxq->iq); - quiesce_fl(sc, &ofld_rxq->fl); - } -#endif + quiesce_vi(vi); free(vi->rss, M_CXGBE); free(vi->nm_rss, M_CXGBE); } + /* Do this before freeing the VI queues. */ + if (vi->flags & VI_SYSCTL_CTX) { + sysctl_ctx_free(&vi->ctx); + vi->flags &= ~VI_SYSCTL_CTX; + } + t4_teardown_vi_queues(vi); vi->flags &= ~VI_INIT_DONE; - - return (0); } static void -quiesce_txq(struct adapter *sc, struct sge_txq *txq) +quiesce_txq(struct sge_txq *txq) { struct sge_eq *eq = &txq->eq; struct sge_qstat *spg = (void *)&eq->desc[eq->sidx]; - (void) sc; /* unused */ - -#ifdef INVARIANTS - TXQ_LOCK(txq); - MPASS((eq->flags & EQ_ENABLED) == 0); - TXQ_UNLOCK(txq); -#endif + MPASS(eq->flags & EQ_SW_ALLOCATED); + MPASS(!(eq->flags & EQ_ENABLED)); /* Wait for the mp_ring to empty. */ while (!mp_ring_is_idle(txq->r)) { mp_ring_check_drainage(txq->r, 4096); pause("rquiesce", 1); } + MPASS(txq->txp.npkt == 0); - /* Then wait for the hardware to finish. */ - while (spg->cidx != htobe16(eq->pidx)) - pause("equiesce", 1); - - /* Finally, wait for the driver to reclaim all descriptors. */ - while (eq->cidx != eq->pidx) - pause("dquiesce", 1); + if (eq->flags & EQ_HW_ALLOCATED) { + /* + * Hardware is alive and working normally. Wait for it to + * finish and then wait for the driver to catch up and reclaim + * all descriptors. + */ + while (spg->cidx != htobe16(eq->pidx)) + pause("equiesce", 1); + while (eq->cidx != eq->pidx) + pause("dquiesce", 1); + } else { + /* + * Hardware is unavailable. Discard all pending tx and reclaim + * descriptors directly. + */ + TXQ_LOCK(txq); + while (eq->cidx != eq->pidx) { + struct mbuf *m, *nextpkt; + struct tx_sdesc *txsd; + + txsd = &txq->sdesc[eq->cidx]; + for (m = txsd->m; m != NULL; m = nextpkt) { + nextpkt = m->m_nextpkt; + m->m_nextpkt = NULL; + m_freem(m); + } + IDXINCR(eq->cidx, txsd->desc_used, eq->sidx); + } + spg->pidx = spg->cidx = htobe16(eq->cidx); + TXQ_UNLOCK(txq); + } } static void -quiesce_wrq(struct adapter *sc, struct sge_wrq *wrq) +quiesce_wrq(struct sge_wrq *wrq) { /* XXXTX */ } static void -quiesce_iq(struct adapter *sc, struct sge_iq *iq) +quiesce_iq_fl(struct adapter *sc, struct sge_iq *iq, struct sge_fl *fl) { - (void) sc; /* unused */ - /* Synchronize with the interrupt handler */ while (!atomic_cmpset_int(&iq->state, IQS_IDLE, IQS_DISABLED)) pause("iqfree", 1); + + if (fl != NULL) { + MPASS(iq->flags & IQ_HAS_FL); + + mtx_lock(&sc->sfl_lock); + FL_LOCK(fl); + fl->flags |= FL_DOOMED; + FL_UNLOCK(fl); + callout_stop(&sc->sfl_callout); + mtx_unlock(&sc->sfl_lock); + + KASSERT((fl->flags & FL_STARVING) == 0, + ("%s: still starving", __func__)); + + /* Release all buffers if hardware is no longer available. */ + if (!(iq->flags & IQ_HW_ALLOCATED)) + free_fl_buffers(sc, fl); + } } +/* + * Wait for all activity on all the queues of the VI to complete. It is assumed + * that no new work is being enqueued by the hardware or the driver. That part + * should be arranged before calling this function. + */ static void -quiesce_fl(struct adapter *sc, struct sge_fl *fl) +quiesce_vi(struct vi_info *vi) { - mtx_lock(&sc->sfl_lock); - FL_LOCK(fl); - fl->flags |= FL_DOOMED; - FL_UNLOCK(fl); - callout_stop(&sc->sfl_callout); - mtx_unlock(&sc->sfl_lock); + int i; + struct adapter *sc = vi->adapter; + struct sge_rxq *rxq; + struct sge_txq *txq; +#ifdef TCP_OFFLOAD + struct sge_ofld_rxq *ofld_rxq; +#endif +#if defined(TCP_OFFLOAD) || defined(RATELIMIT) + struct sge_ofld_txq *ofld_txq; +#endif + + if (!(vi->flags & VI_INIT_DONE)) + return; + + for_each_txq(vi, i, txq) { + quiesce_txq(txq); + } + +#if defined(TCP_OFFLOAD) || defined(RATELIMIT) + for_each_ofld_txq(vi, i, ofld_txq) { + quiesce_wrq(&ofld_txq->wrq); + } +#endif - KASSERT((fl->flags & FL_STARVING) == 0, - ("%s: still starving", __func__)); + for_each_rxq(vi, i, rxq) { + quiesce_iq_fl(sc, &rxq->iq, &rxq->fl); + } + +#ifdef TCP_OFFLOAD + for_each_ofld_rxq(vi, i, ofld_rxq) { + quiesce_iq_fl(sc, &ofld_rxq->iq, &ofld_rxq->fl); + } +#endif } static int @@ -11119,16 +11220,11 @@ toe_capability(struct vi_info *vi, bool enable) * and receive CPLs to/from the TOE even if the ifnet for this * port has never been UP'd administratively. */ - if (!(vi->flags & VI_INIT_DONE)) { - rc = vi_full_init(vi); - if (rc) - return (rc); - } - if (!(pi->vi[0].flags & VI_INIT_DONE)) { - rc = vi_full_init(&pi->vi[0]); - if (rc) - return (rc); - } + if (!(vi->flags & VI_INIT_DONE) && ((rc = vi_init(vi)) != 0)) + return (rc); + if (!(pi->vi[0].flags & VI_INIT_DONE) && + ((rc = vi_init(&pi->vi[0])) != 0)) + return (rc); if (isset(&sc->offload_map, pi->port_id)) { /* TOE is enabled on another VI of this port. */ @@ -11239,7 +11335,7 @@ t4_activate_uld(struct adapter *sc, int id) SLIST_FOREACH(ui, &t4_uld_list, link) { if (ui->uld_id == id) { if (!(sc->flags & FULL_INIT_DONE)) { - rc = adapter_full_init(sc); + rc = adapter_init(sc); if (rc != 0) break; } diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index 6078dd89829d..8c5b9f500661 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -125,9 +125,10 @@ static int free_nm_txq_hwq(struct vi_info *, struct sge_nm_txq *); int alloc_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int intr_idx, - int idx, struct sysctl_oid *oid) + int idx) { int rc; + struct sysctl_oid *oid; struct sysctl_oid_list *children; struct sysctl_ctx_list *ctx; char name[16]; @@ -161,7 +162,7 @@ alloc_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int intr_idx, nm_rxq->iq_cntxt_id = INVALID_NM_RXQ_CNTXT_ID; ctx = &vi->ctx; - children = SYSCTL_CHILDREN(oid); + children = SYSCTL_CHILDREN(vi->nm_rxq_oid); snprintf(name, sizeof(name), "%d", idx); oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, name, @@ -211,8 +212,7 @@ free_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq) } int -alloc_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq, int iqidx, int idx, - struct sysctl_oid *oid) +alloc_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq, int iqidx, int idx) { int rc; size_t len; @@ -220,7 +220,8 @@ alloc_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq, int iqidx, int idx, struct adapter *sc = pi->adapter; struct netmap_adapter *na = NA(vi->ifp); char name[16]; - struct sysctl_oid_list *children = SYSCTL_CHILDREN(oid); + struct sysctl_oid *oid; + struct sysctl_oid_list *children = SYSCTL_CHILDREN(vi->nm_txq_oid); len = na->num_tx_desc * EQ_ESIZE + sc->params.sge.spg_len; rc = alloc_ring(sc, len, &nm_txq->desc_tag, &nm_txq->desc_map, diff --git a/sys/dev/cxgbe/t4_sched.c b/sys/dev/cxgbe/t4_sched.c index 99a157eca08c..0cb44e1d4ffb 100644 --- a/sys/dev/cxgbe/t4_sched.c +++ b/sys/dev/cxgbe/t4_sched.c @@ -296,8 +296,8 @@ bind_txq_to_traffic_class(struct adapter *sc, struct sge_txq *txq, int idx) int rc, old_idx; uint32_t fw_mnem, fw_class; - if (!(txq->eq.flags & EQ_ALLOCATED)) - return (EAGAIN); + if (!(txq->eq.flags & EQ_HW_ALLOCATED)) + return (ENXIO); mtx_lock(&sc->tc_lock); if (txq->tc_idx == -2) { @@ -565,16 +565,13 @@ int sysctl_tc(SYSCTL_HANDLER_ARGS) { struct vi_info *vi = arg1; - struct port_info *pi; - struct adapter *sc; + struct adapter *sc = vi->adapter; struct sge_txq *txq; int qidx = arg2, rc, tc_idx; - MPASS(qidx >= 0 && qidx < vi->ntxq); - pi = vi->pi; - sc = pi->adapter; - txq = &sc->sge.txq[vi->first_txq + qidx]; + MPASS(qidx >= vi->first_txq && qidx < vi->first_txq + vi->ntxq); + txq = &sc->sge.txq[qidx]; tc_idx = txq->tc_idx; rc = sysctl_handle_int(oidp, &tc_idx, 0, req); if (rc != 0 || req->newptr == NULL) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index c09ba29213a1..2f6c7e2e7914 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -234,53 +234,66 @@ static int service_iq_fl(struct sge_iq *, int); static struct mbuf *get_fl_payload(struct adapter *, struct sge_fl *, uint32_t); static int eth_rx(struct adapter *, struct sge_rxq *, const struct iq_desc *, u_int); -static inline void init_iq(struct sge_iq *, struct adapter *, int, int, int); +static inline void init_iq(struct sge_iq *, struct adapter *, int, int, int, + int, int); static inline void init_fl(struct adapter *, struct sge_fl *, int, int, char *); static inline void init_eq(struct adapter *, struct sge_eq *, int, int, uint8_t, - uint16_t, char *); + struct sge_iq *, char *); static int alloc_iq_fl(struct vi_info *, struct sge_iq *, struct sge_fl *, - int, int); -static int free_iq_fl(struct vi_info *, struct sge_iq *, struct sge_fl *); + struct sysctl_ctx_list *, struct sysctl_oid *); +static void free_iq_fl(struct adapter *, struct sge_iq *, struct sge_fl *); static void add_iq_sysctls(struct sysctl_ctx_list *, struct sysctl_oid *, struct sge_iq *); static void add_fl_sysctls(struct adapter *, struct sysctl_ctx_list *, struct sysctl_oid *, struct sge_fl *); +static int alloc_iq_fl_hwq(struct vi_info *, struct sge_iq *, struct sge_fl *); +static int free_iq_fl_hwq(struct adapter *, struct sge_iq *, struct sge_fl *); static int alloc_fwq(struct adapter *); -static int free_fwq(struct adapter *); -static int alloc_ctrlq(struct adapter *, struct sge_wrq *, int, - struct sysctl_oid *); -static int alloc_rxq(struct vi_info *, struct sge_rxq *, int, int, - struct sysctl_oid *); -static int free_rxq(struct vi_info *, struct sge_rxq *); +static void free_fwq(struct adapter *); +static int alloc_ctrlq(struct adapter *, int); +static void free_ctrlq(struct adapter *, int); +static int alloc_rxq(struct vi_info *, struct sge_rxq *, int, int, int); +static void free_rxq(struct vi_info *, struct sge_rxq *); +static void add_rxq_sysctls(struct sysctl_ctx_list *, struct sysctl_oid *, + struct sge_rxq *); #ifdef TCP_OFFLOAD static int alloc_ofld_rxq(struct vi_info *, struct sge_ofld_rxq *, int, int, - struct sysctl_oid *); -static int free_ofld_rxq(struct vi_info *, struct sge_ofld_rxq *); + int); +static void free_ofld_rxq(struct vi_info *, struct sge_ofld_rxq *); +static void add_ofld_rxq_sysctls(struct sysctl_ctx_list *, struct sysctl_oid *, + struct sge_ofld_rxq *); #endif static int ctrl_eq_alloc(struct adapter *, struct sge_eq *); static int eth_eq_alloc(struct adapter *, struct vi_info *, struct sge_eq *); #if defined(TCP_OFFLOAD) || defined(RATELIMIT) static int ofld_eq_alloc(struct adapter *, struct vi_info *, struct sge_eq *); #endif -static int alloc_eq(struct adapter *, struct vi_info *, struct sge_eq *); -static int free_eq(struct adapter *, struct sge_eq *); -static int alloc_wrq(struct adapter *, struct vi_info *, struct sge_wrq *, +static int alloc_eq(struct adapter *, struct sge_eq *, struct sysctl_ctx_list *, struct sysctl_oid *); -static int free_wrq(struct adapter *, struct sge_wrq *); -static int alloc_txq(struct vi_info *, struct sge_txq *, int, - struct sysctl_oid *); -static int free_txq(struct vi_info *, struct sge_txq *); +static void free_eq(struct adapter *, struct sge_eq *); +static void add_eq_sysctls(struct adapter *, struct sysctl_ctx_list *, + struct sysctl_oid *, struct sge_eq *); +static int alloc_eq_hwq(struct adapter *, struct vi_info *, struct sge_eq *); +static int free_eq_hwq(struct adapter *, struct vi_info *, struct sge_eq *); +static int alloc_wrq(struct adapter *, struct vi_info *, struct sge_wrq *, + struct sysctl_ctx_list *, struct sysctl_oid *); +static void free_wrq(struct adapter *, struct sge_wrq *); +static void add_wrq_sysctls(struct sysctl_ctx_list *, struct sysctl_oid *, + struct sge_wrq *); *** 2021 LINES SKIPPED *** From nobody Wed Oct 20 14:07:00 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6325B17F6CF8; Wed, 20 Oct 2021 14:07:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HZC902D0Rz4ryb; Wed, 20 Oct 2021 14:07:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2BAA775F; Wed, 20 Oct 2021 14:07: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 19KE70Jh011418; Wed, 20 Oct 2021 14:07:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KE70p7011417; Wed, 20 Oct 2021 14:07:00 GMT (envelope-from git) Date: Wed, 20 Oct 2021 14:07:00 GMT Message-Id: <202110201407.19KE70p7011417@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 0d6f2ab194c7 - stable/13 - cxgbe(4): Add support for NIC suspend/resume and live reset. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0d6f2ab194c79443b8870bc7a82fa4b2e6954f0e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=0d6f2ab194c79443b8870bc7a82fa4b2e6954f0e commit 0d6f2ab194c79443b8870bc7a82fa4b2e6954f0e Author: Navdeep Parhar AuthorDate: 2021-04-28 04:33:10 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 13:59:41 +0000 cxgbe(4): Add support for NIC suspend/resume and live reset. Add suspend/resume callbacks to the driver and a live reset built around them. This commit covers the basic NIC and future commits will expand this functionality to other stateful parts of the chip. Suspend and resume operate on the chip (the t?nex nexus device) and affect all its ports. It is not possible to suspend/resume or reset individual ports. All these operations can be performed on a running NIC. A reset will look like a link bounce to the networking stack. Here are some ways to exercise this functionality: /* Manual suspend and resume. */ # devctl suspend t6nex0 # devctl resume t6nex0 /* Manual reset. */ # devctl reset t6nex0 /* Manual reset with driver sysctl. */ # sysctl dev.t6nex.0.reset=1 /* Automatic adapter reset on any fatal error. */ # hw.cxgbe.reset_on_fatal_err=1 Suspend disables the adapter (DMA, interrupts, and the port PHYs) and marks the hardware as unavailable to the driver. All ifnets associated with the adapter are still visible to the kernel but operations that require hardware interaction will fail with ENXIO. All ifnets report link-down while the adapter is suspended. Resume will reattach to the card, reconfigure it as before, and recreate the queues servicing the existing ifnets. The ifnets are able to send and receive traffic as soon as the link comes back up. Reset is roughly the same as a suspend and a resume with at least one of these events in between: D0->D3Hot->D0, FLR, PCIe link retrain. (cherry picked from commit 83b5cda106a2dc0c8ace1718485c2ef05c5aa62b) --- sys/dev/cxgbe/adapter.h | 52 +- sys/dev/cxgbe/t4_clip.c | 2 +- sys/dev/cxgbe/t4_filter.c | 36 +- sys/dev/cxgbe/t4_main.c | 1586 +++++++++++++++++++++++++++++++++++++-------- sys/dev/cxgbe/t4_sched.c | 13 +- sys/dev/cxgbe/t4_tracer.c | 10 + 6 files changed, 1393 insertions(+), 306 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 8809a10269a1..2f4619b1180f 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -155,6 +155,7 @@ enum { IS_VF = (1 << 7), KERN_TLS_ON = (1 << 8), /* HW is configured for KERN_TLS */ CXGBE_BUSY = (1 << 9), + HW_OFF_LIMITS = (1 << 10), /* off limits to all except reset_thread */ /* port flags */ HAS_TRACEQ = (1 << 3), @@ -945,13 +946,26 @@ struct adapter { TAILQ_HEAD(, sge_fl) sfl; struct callout sfl_callout; - struct mtx reg_lock; /* for indirect register access */ + /* + * Driver code that can run when the adapter is suspended must use this + * lock or a synchronized_op and check for HW_OFF_LIMITS before + * accessing hardware. + * + * XXX: could be changed to rwlock. wlock in suspend/resume and for + * indirect register access, rlock everywhere else. + */ + struct mtx reg_lock; struct memwin memwin[NUM_MEMWIN]; /* memory windows */ struct mtx tc_lock; struct task tc_task; + struct task reset_task; + const void *reset_thread; + int num_resets; + int incarnation; + const char *last_op; const void *last_op_thr; int last_op_flags; @@ -1041,24 +1055,34 @@ forwarding_intr_to_fwq(struct adapter *sc) return (sc->intr_count == 1); } +/* Works reliably inside a sync_op or with reg_lock held. */ +static inline bool +hw_off_limits(struct adapter *sc) +{ + return (__predict_false(sc->flags & HW_OFF_LIMITS)); +} + static inline uint32_t t4_read_reg(struct adapter *sc, uint32_t reg) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); return bus_space_read_4(sc->bt, sc->bh, reg); } static inline void t4_write_reg(struct adapter *sc, uint32_t reg, uint32_t val) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); bus_space_write_4(sc->bt, sc->bh, reg, val); } static inline uint64_t t4_read_reg64(struct adapter *sc, uint32_t reg) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); #ifdef __LP64__ return bus_space_read_8(sc->bt, sc->bh, reg); #else @@ -1071,7 +1095,8 @@ t4_read_reg64(struct adapter *sc, uint32_t reg) static inline void t4_write_reg64(struct adapter *sc, uint32_t reg, uint64_t val) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); #ifdef __LP64__ bus_space_write_8(sc->bt, sc->bh, reg, val); #else @@ -1083,14 +1108,16 @@ t4_write_reg64(struct adapter *sc, uint32_t reg, uint64_t val) static inline void t4_os_pci_read_cfg1(struct adapter *sc, int reg, uint8_t *val) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); *val = pci_read_config(sc->dev, reg, 1); } static inline void t4_os_pci_write_cfg1(struct adapter *sc, int reg, uint8_t val) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); pci_write_config(sc->dev, reg, val, 1); } @@ -1098,27 +1125,32 @@ static inline void t4_os_pci_read_cfg2(struct adapter *sc, int reg, uint16_t *val) { + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); *val = pci_read_config(sc->dev, reg, 2); } static inline void t4_os_pci_write_cfg2(struct adapter *sc, int reg, uint16_t val) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); pci_write_config(sc->dev, reg, val, 2); } static inline void t4_os_pci_read_cfg4(struct adapter *sc, int reg, uint32_t *val) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); *val = pci_read_config(sc->dev, reg, 4); } static inline void t4_os_pci_write_cfg4(struct adapter *sc, int reg, uint32_t val) { - + if (hw_off_limits(sc)) + MPASS(curthread == sc->reset_thread); pci_write_config(sc->dev, reg, val, 4); } diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c index f737c17eaaae..ad26d212315e 100644 --- a/sys/dev/cxgbe/t4_clip.c +++ b/sys/dev/cxgbe/t4_clip.c @@ -171,7 +171,7 @@ update_clip(struct adapter *sc, void *arg __unused) if (begin_synchronized_op(sc, NULL, HOLD_LOCK, "t4clip")) return; - if (mtx_initialized(&sc->clip_table_lock)) + if (mtx_initialized(&sc->clip_table_lock) && !hw_off_limits(sc)) update_clip_table(sc); end_synchronized_op(sc, LOCK_HELD); diff --git a/sys/dev/cxgbe/t4_filter.c b/sys/dev/cxgbe/t4_filter.c index cddd2c96a620..3972111b4897 100644 --- a/sys/dev/cxgbe/t4_filter.c +++ b/sys/dev/cxgbe/t4_filter.c @@ -522,6 +522,11 @@ set_filter_mode(struct adapter *sc, uint32_t mode) if (rc) return (rc); + if (hw_off_limits(sc)) { + rc = ENXIO; + goto done; + } + if (sc->tids.ftids_in_use > 0 || /* TCAM filters active */ sc->tids.hpftids_in_use > 0 || /* hi-pri TCAM filters active */ sc->tids.tids_in_use > 0) { /* TOE or hashfilters active */ @@ -568,6 +573,11 @@ set_filter_mask(struct adapter *sc, uint32_t mode) if (rc) return (rc); + if (hw_off_limits(sc)) { + rc = ENXIO; + goto done; + } + if (sc->tids.tids_in_use > 0) { /* TOE or hashfilters active */ rc = EBUSY; goto done; @@ -589,20 +599,27 @@ static inline uint64_t get_filter_hits(struct adapter *sc, uint32_t tid) { uint32_t tcb_addr; + uint64_t hits; tcb_addr = t4_read_reg(sc, A_TP_CMM_TCB_BASE) + tid * TCB_SIZE; - if (is_t4(sc)) { - uint64_t hits; + mtx_lock(&sc->reg_lock); + if (hw_off_limits(sc)) + hits = 0; + else if (is_t4(sc)) { + uint64_t t; - read_via_memwin(sc, 0, tcb_addr + 16, (uint32_t *)&hits, 8); - return (be64toh(hits)); + read_via_memwin(sc, 0, tcb_addr + 16, (uint32_t *)&t, 8); + hits = be64toh(t); } else { - uint32_t hits; + uint32_t t; - read_via_memwin(sc, 0, tcb_addr + 24, &hits, 4); - return (be32toh(hits)); + read_via_memwin(sc, 0, tcb_addr + 24, &t, 4); + hits = be32toh(t); } + mtx_unlock(&sc->reg_lock); + + return (hits); } int @@ -961,6 +978,11 @@ set_filter(struct adapter *sc, struct t4_filter *t) if (rc) return (rc); + if (hw_off_limits(sc)) { + rc = ENXIO; + goto done; + } + if (!(sc->flags & FULL_INIT_DONE) && ((rc = adapter_init(sc)) != 0)) goto done; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index e5c11402d9ab..1c22b0c8f124 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -100,12 +100,20 @@ static int t4_detach(device_t); static int t4_child_location_str(device_t, device_t, char *, size_t); static int t4_ready(device_t); static int t4_read_port_device(device_t, int, device_t *); +static int t4_suspend(device_t); +static int t4_resume(device_t); +static int t4_reset_prepare(device_t, device_t); +static int t4_reset_post(device_t, device_t); static device_method_t t4_methods[] = { DEVMETHOD(device_probe, t4_probe), DEVMETHOD(device_attach, t4_attach), DEVMETHOD(device_detach, t4_detach), + DEVMETHOD(device_suspend, t4_suspend), + DEVMETHOD(device_resume, t4_resume), DEVMETHOD(bus_child_location_str, t4_child_location_str), + DEVMETHOD(bus_reset_prepare, t4_reset_prepare), + DEVMETHOD(bus_reset_post, t4_reset_post), DEVMETHOD(t4_is_main_ready, t4_ready), DEVMETHOD(t4_read_port_device, t4_read_port_device), @@ -165,8 +173,12 @@ static device_method_t t5_methods[] = { DEVMETHOD(device_probe, t5_probe), DEVMETHOD(device_attach, t4_attach), DEVMETHOD(device_detach, t4_detach), + DEVMETHOD(device_suspend, t4_suspend), + DEVMETHOD(device_resume, t4_resume), DEVMETHOD(bus_child_location_str, t4_child_location_str), + DEVMETHOD(bus_reset_prepare, t4_reset_prepare), + DEVMETHOD(bus_reset_post, t4_reset_post), DEVMETHOD(t4_is_main_ready, t4_ready), DEVMETHOD(t4_read_port_device, t4_read_port_device), @@ -200,8 +212,12 @@ static device_method_t t6_methods[] = { DEVMETHOD(device_probe, t6_probe), DEVMETHOD(device_attach, t4_attach), DEVMETHOD(device_detach, t4_detach), + DEVMETHOD(device_suspend, t4_suspend), + DEVMETHOD(device_resume, t4_resume), DEVMETHOD(bus_child_location_str, t4_child_location_str), + DEVMETHOD(bus_reset_prepare, t4_reset_prepare), + DEVMETHOD(bus_reset_post, t4_reset_post), DEVMETHOD(t4_is_main_ready, t4_ready), DEVMETHOD(t4_read_port_device, t4_read_port_device), @@ -596,6 +612,10 @@ static int t4_panic_on_fatal_err = 0; SYSCTL_INT(_hw_cxgbe, OID_AUTO, panic_on_fatal_err, CTLFLAG_RWTUN, &t4_panic_on_fatal_err, 0, "panic on fatal errors"); +static int t4_reset_on_fatal_err = 0; +SYSCTL_INT(_hw_cxgbe, OID_AUTO, reset_on_fatal_err, CTLFLAG_RWTUN, + &t4_reset_on_fatal_err, 0, "reset adapter on fatal errors"); + static int t4_tx_vm_wr = 0; SYSCTL_INT(_hw_cxgbe, OID_AUTO, tx_vm_wr, CTLFLAG_RWTUN, &t4_tx_vm_wr, 0, "Use VM work requests to transmit packets."); @@ -794,6 +814,7 @@ static int sysctl_tx_rate(SYSCTL_HANDLER_ARGS); static int sysctl_ulprx_la(SYSCTL_HANDLER_ARGS); static int sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS); static int sysctl_cpus(SYSCTL_HANDLER_ARGS); +static int sysctl_reset(SYSCTL_HANDLER_ARGS); #ifdef TCP_OFFLOAD static int sysctl_tls(SYSCTL_HANDLER_ARGS); static int sysctl_tls_rx_ports(SYSCTL_HANDLER_ARGS); @@ -829,6 +850,7 @@ static int notify_siblings(device_t, int); static uint64_t vi_get_counter(struct ifnet *, ift_counter); static uint64_t cxgbe_get_counter(struct ifnet *, ift_counter); static void enable_vxlan_rx(struct adapter *); +static void reset_adapter(void *, int); struct { uint16_t device; @@ -1137,6 +1159,8 @@ t4_attach(device_t dev) refcount_init(&sc->vxlan_refcount, 0); + TASK_INIT(&sc->reset_task, 0, reset_adapter, sc); + sc->ctrlq_oid = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->dev), SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "ctrlq", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "control queues"); @@ -1785,6 +1809,572 @@ t4_detach_common(device_t dev) return (0); } +static inline bool +ok_to_reset(struct adapter *sc) +{ + struct tid_info *t = &sc->tids; + struct port_info *pi; + struct vi_info *vi; + int i, j; + const int caps = IFCAP_TOE | IFCAP_TXTLS | IFCAP_NETMAP | IFCAP_TXRTLMT; + + ASSERT_SYNCHRONIZED_OP(sc); + MPASS(!(sc->flags & IS_VF)); + + for_each_port(sc, i) { + pi = sc->port[i]; + for_each_vi(pi, j, vi) { + if (vi->ifp->if_capenable & caps) + return (false); + } + } + + if (atomic_load_int(&t->tids_in_use) > 0) + return (false); + if (atomic_load_int(&t->stids_in_use) > 0) + return (false); + if (atomic_load_int(&t->atids_in_use) > 0) + return (false); + if (atomic_load_int(&t->ftids_in_use) > 0) + return (false); + if (atomic_load_int(&t->hpftids_in_use) > 0) + return (false); + if (atomic_load_int(&t->etids_in_use) > 0) + return (false); + + return (true); +} + +static int +t4_suspend(device_t dev) +{ + struct adapter *sc = device_get_softc(dev); + struct port_info *pi; + struct vi_info *vi; + struct ifnet *ifp; + struct sge_rxq *rxq; + struct sge_txq *txq; + struct sge_wrq *wrq; +#ifdef TCP_OFFLOAD + struct sge_ofld_rxq *ofld_rxq; +#endif +#if defined(TCP_OFFLOAD) || defined(RATELIMIT) + struct sge_ofld_txq *ofld_txq; +#endif + int rc, i, j, k; + + CH_ALERT(sc, "suspend requested\n"); + + rc = begin_synchronized_op(sc, NULL, SLEEP_OK, "t4sus"); + if (rc != 0) + return (ENXIO); + + /* XXX: Can the kernel call suspend repeatedly without resume? */ + MPASS(!hw_off_limits(sc)); + + if (!ok_to_reset(sc)) { + /* XXX: should list what resource is preventing suspend. */ + CH_ERR(sc, "not safe to suspend.\n"); + rc = EBUSY; + goto done; + } + + /* No more DMA or interrupts. */ + t4_shutdown_adapter(sc); + + /* Quiesce all activity. */ + for_each_port(sc, i) { + pi = sc->port[i]; + pi->vxlan_tcam_entry = false; + + PORT_LOCK(pi); + if (pi->up_vis > 0) { + /* + * t4_shutdown_adapter has already shut down all the + * PHYs but it also disables interrupts and DMA so there + * won't be a link interrupt. So we update the state + * manually and inform the kernel. + */ + pi->link_cfg.link_ok = false; + t4_os_link_changed(pi); + } + PORT_UNLOCK(pi); + + for_each_vi(pi, j, vi) { + vi->xact_addr_filt = -1; + if (!(vi->flags & VI_INIT_DONE)) + continue; + + ifp = vi->ifp; + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + mtx_lock(&vi->tick_mtx); + vi->flags |= VI_SKIP_STATS; + callout_stop(&vi->tick); + mtx_unlock(&vi->tick_mtx); + callout_drain(&vi->tick); + } + + /* + * Note that the HW is not available. + */ + for_each_txq(vi, k, txq) { + TXQ_LOCK(txq); + txq->eq.flags &= ~(EQ_ENABLED | EQ_HW_ALLOCATED); + TXQ_UNLOCK(txq); + } +#if defined(TCP_OFFLOAD) || defined(RATELIMIT) + for_each_ofld_txq(vi, k, ofld_txq) { + ofld_txq->wrq.eq.flags &= ~EQ_HW_ALLOCATED; + } +#endif + for_each_rxq(vi, k, rxq) { + rxq->iq.flags &= ~IQ_HW_ALLOCATED; + } +#if defined(TCP_OFFLOAD) + for_each_ofld_rxq(vi, k, ofld_rxq) { + ofld_rxq->iq.flags &= ~IQ_HW_ALLOCATED; + } +#endif + + quiesce_vi(vi); + } + + if (sc->flags & FULL_INIT_DONE) { + /* Control queue */ + wrq = &sc->sge.ctrlq[i]; + wrq->eq.flags &= ~EQ_HW_ALLOCATED; + quiesce_wrq(wrq); + } + } + if (sc->flags & FULL_INIT_DONE) { + /* Firmware event queue */ + sc->sge.fwq.flags &= ~IQ_HW_ALLOCATED; + quiesce_iq_fl(sc, &sc->sge.fwq, NULL); + } + + /* Mark the adapter totally off limits. */ + mtx_lock(&sc->reg_lock); + sc->flags |= HW_OFF_LIMITS; + sc->flags &= ~(FW_OK | MASTER_PF); + sc->reset_thread = NULL; + mtx_unlock(&sc->reg_lock); + + sc->num_resets++; + CH_ALERT(sc, "suspend completed.\n"); +done: + end_synchronized_op(sc, 0); + return (rc); +} + +struct adapter_pre_reset_state { + u_int flags; + uint16_t nbmcaps; + uint16_t linkcaps; + uint16_t switchcaps; + uint16_t niccaps; + uint16_t toecaps; + uint16_t rdmacaps; + uint16_t cryptocaps; + uint16_t iscsicaps; + uint16_t fcoecaps; + + u_int cfcsum; + char cfg_file[32]; + + struct adapter_params params; + struct t4_virt_res vres; + struct tid_info tids; + struct sge sge; + + int rawf_base; + int nrawf; + +}; + +static void +save_caps_and_params(struct adapter *sc, struct adapter_pre_reset_state *o) +{ + + ASSERT_SYNCHRONIZED_OP(sc); + + o->flags = sc->flags; + + o->nbmcaps = sc->nbmcaps; + o->linkcaps = sc->linkcaps; + o->switchcaps = sc->switchcaps; + o->niccaps = sc->niccaps; + o->toecaps = sc->toecaps; + o->rdmacaps = sc->rdmacaps; + o->cryptocaps = sc->cryptocaps; + o->iscsicaps = sc->iscsicaps; + o->fcoecaps = sc->fcoecaps; + + o->cfcsum = sc->cfcsum; + MPASS(sizeof(o->cfg_file) == sizeof(sc->cfg_file)); + memcpy(o->cfg_file, sc->cfg_file, sizeof(o->cfg_file)); + + o->params = sc->params; + o->vres = sc->vres; + o->tids = sc->tids; + o->sge = sc->sge; + + o->rawf_base = sc->rawf_base; + o->nrawf = sc->nrawf; +} + +static int +compare_caps_and_params(struct adapter *sc, struct adapter_pre_reset_state *o) +{ + int rc = 0; + + ASSERT_SYNCHRONIZED_OP(sc); + + /* Capabilities */ +#define COMPARE_CAPS(c) do { \ + if (o->c##caps != sc->c##caps) { \ + CH_ERR(sc, "%scaps 0x%04x -> 0x%04x.\n", #c, o->c##caps, \ + sc->c##caps); \ + rc = EINVAL; \ + } \ +} while (0) + COMPARE_CAPS(nbm); + COMPARE_CAPS(link); + COMPARE_CAPS(switch); + COMPARE_CAPS(nic); + COMPARE_CAPS(toe); + COMPARE_CAPS(rdma); + COMPARE_CAPS(crypto); + COMPARE_CAPS(iscsi); + COMPARE_CAPS(fcoe); +#undef COMPARE_CAPS + + /* Firmware config file */ + if (o->cfcsum != sc->cfcsum) { + CH_ERR(sc, "config file %s (0x%x) -> %s (0x%x)\n", o->cfg_file, + o->cfcsum, sc->cfg_file, sc->cfcsum); + rc = EINVAL; + } + +#define COMPARE_PARAM(p, name) do { \ + if (o->p != sc->p) { \ + CH_ERR(sc, #name " %d -> %d\n", o->p, sc->p); \ + rc = EINVAL; \ + } \ +} while (0) + COMPARE_PARAM(sge.iq_start, iq_start); + COMPARE_PARAM(sge.eq_start, eq_start); + COMPARE_PARAM(tids.ftid_base, ftid_base); + COMPARE_PARAM(tids.ftid_end, ftid_end); + COMPARE_PARAM(tids.nftids, nftids); + COMPARE_PARAM(vres.l2t.start, l2t_start); + COMPARE_PARAM(vres.l2t.size, l2t_size); + COMPARE_PARAM(sge.iqmap_sz, iqmap_sz); + COMPARE_PARAM(sge.eqmap_sz, eqmap_sz); + COMPARE_PARAM(tids.tid_base, tid_base); + COMPARE_PARAM(tids.hpftid_base, hpftid_base); + COMPARE_PARAM(tids.hpftid_end, hpftid_end); + COMPARE_PARAM(tids.nhpftids, nhpftids); + COMPARE_PARAM(rawf_base, rawf_base); + COMPARE_PARAM(nrawf, nrawf); + COMPARE_PARAM(params.mps_bg_map, mps_bg_map); + COMPARE_PARAM(params.filter2_wr_support, filter2_wr_support); + COMPARE_PARAM(params.ulptx_memwrite_dsgl, ulptx_memwrite_dsgl); + COMPARE_PARAM(params.fr_nsmr_tpte_wr_support, fr_nsmr_tpte_wr_support); + COMPARE_PARAM(params.max_pkts_per_eth_tx_pkts_wr, max_pkts_per_eth_tx_pkts_wr); + COMPARE_PARAM(tids.ntids, ntids); + COMPARE_PARAM(tids.etid_base, etid_base); + COMPARE_PARAM(tids.etid_end, etid_end); + COMPARE_PARAM(tids.netids, netids); + COMPARE_PARAM(params.eo_wr_cred, eo_wr_cred); + COMPARE_PARAM(params.ethoffload, ethoffload); + COMPARE_PARAM(tids.natids, natids); + COMPARE_PARAM(tids.stid_base, stid_base); + COMPARE_PARAM(vres.ddp.start, ddp_start); + COMPARE_PARAM(vres.ddp.size, ddp_size); + COMPARE_PARAM(params.ofldq_wr_cred, ofldq_wr_cred); + COMPARE_PARAM(vres.stag.start, stag_start); + COMPARE_PARAM(vres.stag.size, stag_size); + COMPARE_PARAM(vres.rq.start, rq_start); + COMPARE_PARAM(vres.rq.size, rq_size); + COMPARE_PARAM(vres.pbl.start, pbl_start); + COMPARE_PARAM(vres.pbl.size, pbl_size); + COMPARE_PARAM(vres.qp.start, qp_start); + COMPARE_PARAM(vres.qp.size, qp_size); + COMPARE_PARAM(vres.cq.start, cq_start); + COMPARE_PARAM(vres.cq.size, cq_size); + COMPARE_PARAM(vres.ocq.start, ocq_start); + COMPARE_PARAM(vres.ocq.size, ocq_size); + COMPARE_PARAM(vres.srq.start, srq_start); + COMPARE_PARAM(vres.srq.size, srq_size); + COMPARE_PARAM(params.max_ordird_qp, max_ordird_qp); + COMPARE_PARAM(params.max_ird_adapter, max_ird_adapter); + COMPARE_PARAM(vres.iscsi.start, iscsi_start); + COMPARE_PARAM(vres.iscsi.size, iscsi_size); + COMPARE_PARAM(vres.key.start, key_start); + COMPARE_PARAM(vres.key.size, key_size); +#undef COMPARE_PARAM + + return (rc); +} + +static int +t4_resume(device_t dev) +{ + struct adapter *sc = device_get_softc(dev); + struct adapter_pre_reset_state *old_state = NULL; + struct port_info *pi; + struct vi_info *vi; + struct ifnet *ifp; + struct sge_txq *txq; + int rc, i, j, k; + + CH_ALERT(sc, "resume requested.\n"); + + rc = begin_synchronized_op(sc, NULL, SLEEP_OK, "t4res"); + if (rc != 0) + return (ENXIO); + MPASS(hw_off_limits(sc)); + MPASS((sc->flags & FW_OK) == 0); + MPASS((sc->flags & MASTER_PF) == 0); + MPASS(sc->reset_thread == NULL); + sc->reset_thread = curthread; + + /* Register access is expected to work by the time we're here. */ + if (t4_read_reg(sc, A_PL_WHOAMI) == 0xffffffff) { + CH_ERR(sc, "%s: can't read device registers\n", __func__); + rc = ENXIO; + goto done; + } + + /* Restore memory window. */ + setup_memwin(sc); + + /* Go no further if recovery mode has been requested. */ + if (TUNABLE_INT_FETCH("hw.cxgbe.sos", &i) && i != 0) { + CH_ALERT(sc, "recovery mode on resume.\n"); + rc = 0; + mtx_lock(&sc->reg_lock); + sc->flags &= ~HW_OFF_LIMITS; + mtx_unlock(&sc->reg_lock); + goto done; + } + + old_state = malloc(sizeof(*old_state), M_CXGBE, M_ZERO | M_WAITOK); + save_caps_and_params(sc, old_state); + + /* Reestablish contact with firmware and become the primary PF. */ + rc = contact_firmware(sc); + if (rc != 0) + goto done; /* error message displayed already */ + MPASS(sc->flags & FW_OK); + + if (sc->flags & MASTER_PF) { + rc = partition_resources(sc); + if (rc != 0) + goto done; /* error message displayed already */ + t4_intr_clear(sc); + } + + rc = get_params__post_init(sc); + if (rc != 0) + goto done; /* error message displayed already */ + + rc = set_params__post_init(sc); + if (rc != 0) + goto done; /* error message displayed already */ + + rc = compare_caps_and_params(sc, old_state); + if (rc != 0) + goto done; /* error message displayed already */ + + for_each_port(sc, i) { + pi = sc->port[i]; + MPASS(pi != NULL); + MPASS(pi->vi != NULL); + MPASS(pi->vi[0].dev == pi->dev); + + rc = -t4_port_init(sc, sc->mbox, sc->pf, 0, i); + if (rc != 0) { + CH_ERR(sc, + "failed to re-initialize port %d: %d\n", i, rc); + goto done; + } + MPASS(sc->chan_map[pi->tx_chan] == i); + + PORT_LOCK(pi); + fixup_link_config(pi); + build_medialist(pi); + PORT_UNLOCK(pi); + for_each_vi(pi, j, vi) { + if (IS_MAIN_VI(vi)) + continue; + rc = alloc_extra_vi(sc, pi, vi); + if (rc != 0) { + CH_ERR(vi, + "failed to re-allocate extra VI: %d\n", rc); + goto done; + } + } + } + + /* + * Interrupts and queues are about to be enabled and other threads will + * want to access the hardware too. It is safe to do so. Note that + * this thread is still in the middle of a synchronized_op. + */ + mtx_lock(&sc->reg_lock); + sc->flags &= ~HW_OFF_LIMITS; + mtx_unlock(&sc->reg_lock); + + if (sc->flags & FULL_INIT_DONE) { + rc = adapter_full_init(sc); + if (rc != 0) { + CH_ERR(sc, "failed to re-initialize adapter: %d\n", rc); + goto done; + } + + if (sc->vxlan_refcount > 0) + enable_vxlan_rx(sc); + + for_each_port(sc, i) { + pi = sc->port[i]; + for_each_vi(pi, j, vi) { + if (!(vi->flags & VI_INIT_DONE)) + continue; + rc = vi_full_init(vi); + if (rc != 0) { + CH_ERR(vi, "failed to re-initialize " + "interface: %d\n", rc); + goto done; + } + + ifp = vi->ifp; + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + continue; + /* + * Note that we do not setup multicast addresses + * in the first pass. This ensures that the + * unicast DMACs for all VIs on all ports get an + * MPS TCAM entry. + */ + rc = update_mac_settings(ifp, XGMAC_ALL & + ~XGMAC_MCADDRS); + if (rc != 0) { + CH_ERR(vi, "failed to re-configure MAC: %d\n", rc); + goto done; + } + rc = -t4_enable_vi(sc, sc->mbox, vi->viid, true, + true); + if (rc != 0) { + CH_ERR(vi, "failed to re-enable VI: %d\n", rc); + goto done; + } + for_each_txq(vi, k, txq) { + TXQ_LOCK(txq); + txq->eq.flags |= EQ_ENABLED; + TXQ_UNLOCK(txq); + } + mtx_lock(&vi->tick_mtx); + vi->flags &= ~VI_SKIP_STATS; + callout_schedule(&vi->tick, hz); + mtx_unlock(&vi->tick_mtx); + } + PORT_LOCK(pi); + if (pi->up_vis > 0) { + t4_update_port_info(pi); + fixup_link_config(pi); + build_medialist(pi); + apply_link_config(pi); + if (pi->link_cfg.link_ok) + t4_os_link_changed(pi); + } + PORT_UNLOCK(pi); + } + + /* Now reprogram the L2 multicast addresses. */ + for_each_port(sc, i) { + pi = sc->port[i]; + for_each_vi(pi, j, vi) { + if (!(vi->flags & VI_INIT_DONE)) + continue; + ifp = vi->ifp; + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + continue; + rc = update_mac_settings(ifp, XGMAC_MCADDRS); + if (rc != 0) { + CH_ERR(vi, "failed to re-configure MCAST MACs: %d\n", rc); + rc = 0; /* carry on */ + } + } + } + } +done: + if (rc == 0) { + sc->incarnation++; + CH_ALERT(sc, "resume completed.\n"); + } + end_synchronized_op(sc, 0); + free(old_state, M_CXGBE); + return (rc); +} + +static int +t4_reset_prepare(device_t dev, device_t child) +{ + struct adapter *sc = device_get_softc(dev); + + CH_ALERT(sc, "reset_prepare.\n"); + return (0); +} + +static int +t4_reset_post(device_t dev, device_t child) +{ + struct adapter *sc = device_get_softc(dev); + + CH_ALERT(sc, "reset_post.\n"); + return (0); +} + +static void +reset_adapter(void *arg, int pending) +{ + struct adapter *sc = arg; + int rc; + + CH_ALERT(sc, "reset requested.\n"); + + rc = begin_synchronized_op(sc, NULL, SLEEP_OK, "t4rst1"); + if (rc != 0) + return; + + if (hw_off_limits(sc)) { + CH_ERR(sc, "adapter is suspended, use resume (not reset).\n"); + rc = ENXIO; + goto done; + } + + if (!ok_to_reset(sc)) { + /* XXX: should list what resource is preventing reset. */ + CH_ERR(sc, "not safe to reset.\n"); + rc = EBUSY; + goto done; + } + +done: + end_synchronized_op(sc, 0); + if (rc != 0) + return; /* Error logged already. */ + + mtx_lock(&Giant); + rc = BUS_RESET_CHILD(device_get_parent(sc->dev), sc->dev, 0); + mtx_unlock(&Giant); + if (rc != 0) + CH_ERR(sc, "bus_reset_child failed: %d.\n", rc); + else + CH_ALERT(sc, "bus_reset_child succeeded.\n"); +} + static int cxgbe_probe(device_t dev) { @@ -2072,7 +2662,8 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data) ifp->if_mtu = mtu; if (vi->flags & VI_INIT_DONE) { t4_update_fl_bufsize(ifp); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (!hw_off_limits(sc) && + ifp->if_drv_flags & IFF_DRV_RUNNING) rc = update_mac_settings(ifp, XGMAC_MTU); } end_synchronized_op(sc, 0); @@ -2083,6 +2674,11 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data) if (rc) return (rc); + if (hw_off_limits(sc)) { + rc = ENXIO; + goto fail; + } + if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { flags = vi->if_flags; @@ -2106,7 +2702,7 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data) rc = begin_synchronized_op(sc, vi, SLEEP_OK | INTR_OK, "t4multi"); if (rc) return (rc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (!hw_off_limits(sc) && ifp->if_drv_flags & IFF_DRV_RUNNING) rc = update_mac_settings(ifp, XGMAC_MCADDRS); end_synchronized_op(sc, 0); break; @@ -2281,8 +2877,11 @@ fail: rc = begin_synchronized_op(sc, vi, SLEEP_OK | INTR_OK, "t4i2c"); if (rc) return (rc); - rc = -t4_i2c_rd(sc, sc->mbox, pi->port_id, i2c.dev_addr, - i2c.offset, i2c.len, &i2c.data[0]); + if (hw_off_limits(sc)) *** 1771 LINES SKIPPED *** From nobody Wed Oct 20 14:11:23 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BC6AB17F7B72; Wed, 20 Oct 2021 14:11: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 4HZCG350rwz4spk; Wed, 20 Oct 2021 14:11: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 8CA1DE9D; Wed, 20 Oct 2021 14:11: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 19KEBNdr024005; Wed, 20 Oct 2021 14:11:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KEBNKi024004; Wed, 20 Oct 2021 14:11:23 GMT (envelope-from git) Date: Wed, 20 Oct 2021 14:11:23 GMT Message-Id: <202110201411.19KEBNKi024004@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: fed21efcfce4 - stable/13 - cxgbe(4): Fix build warnings with NOINET kernels. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fed21efcfce40fe2cbbc99322662f200f3532505 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=fed21efcfce40fe2cbbc99322662f200f3532505 commit fed21efcfce40fe2cbbc99322662f200f3532505 Author: Navdeep Parhar AuthorDate: 2021-05-22 03:42:04 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 14:07:47 +0000 cxgbe(4): Fix build warnings with NOINET kernels. MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26334 (cherry picked from commit ffbb373c5a95c37be693330a76a093fbcf546440) --- sys/dev/cxgbe/t4_sge.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 2f6c7e2e7914..44fef6dfc633 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -333,7 +333,9 @@ static void drain_wrq_wr_list(struct adapter *, struct sge_wrq *); static int sysctl_bufsizes(SYSCTL_HANDLER_ARGS); #ifdef RATELIMIT +#if defined(INET) || defined(INET6) static inline u_int txpkt_eo_len16(u_int, u_int, u_int); +#endif static int ethofld_fw4_ack(struct sge_iq *, const struct rss_header *, struct mbuf *); #endif @@ -1497,12 +1499,14 @@ service_iq(struct sge_iq *iq, int budget) return (0); } +#if defined(INET) || defined(INET6) static inline int sort_before_lro(struct lro_ctrl *lro) { return (lro->lro_mbuf_max != 0); } +#endif static inline uint64_t last_flit_to_ns(struct adapter *sc, uint64_t lf) @@ -2311,6 +2315,7 @@ mbuf_eo_nsegs(struct mbuf *m) return (m->m_pkthdr.PH_loc.eight[1]); } +#if defined(INET) || defined(INET6) static inline void set_mbuf_eo_nsegs(struct mbuf *m, uint8_t nsegs) { @@ -2318,6 +2323,7 @@ set_mbuf_eo_nsegs(struct mbuf *m, uint8_t nsegs) M_ASSERTPKTHDR(m); m->m_pkthdr.PH_loc.eight[1] = nsegs; } +#endif static inline int mbuf_eo_len16(struct mbuf *m) @@ -2331,6 +2337,7 @@ mbuf_eo_len16(struct mbuf *m) return (n); } +#if defined(INET) || defined(INET6) static inline void set_mbuf_eo_len16(struct mbuf *m, uint8_t len16) { @@ -2338,6 +2345,7 @@ set_mbuf_eo_len16(struct mbuf *m, uint8_t len16) M_ASSERTPKTHDR(m); m->m_pkthdr.PH_loc.eight[2] = len16; } +#endif static inline int mbuf_eo_tsclk_tsoff(struct mbuf *m) @@ -2347,6 +2355,7 @@ mbuf_eo_tsclk_tsoff(struct mbuf *m) return (m->m_pkthdr.PH_loc.eight[3]); } +#if defined(INET) || defined(INET6) static inline void set_mbuf_eo_tsclk_tsoff(struct mbuf *m, uint8_t tsclk_tsoff) { @@ -2354,6 +2363,7 @@ set_mbuf_eo_tsclk_tsoff(struct mbuf *m, uint8_t tsclk_tsoff) M_ASSERTPKTHDR(m); m->m_pkthdr.PH_loc.eight[3] = tsclk_tsoff; } +#endif static inline int needs_eo(struct m_snd_tag *mst) @@ -2434,6 +2444,7 @@ needs_vxlan_tso(struct mbuf *m) (m->m_pkthdr.csum_flags & csum_flags) != CSUM_ENCAP_VXLAN); } +#if defined(INET) || defined(INET6) static inline bool needs_inner_tcp_csum(struct mbuf *m) { @@ -2443,6 +2454,7 @@ needs_inner_tcp_csum(struct mbuf *m) return (m->m_pkthdr.csum_flags & csum_flags); } +#endif static inline bool needs_l3_csum(struct mbuf *m) @@ -6393,6 +6405,7 @@ sysctl_bufsizes(SYSCTL_HANDLER_ARGS) } #ifdef RATELIMIT +#if defined(INET) || defined(INET6) /* * len16 for a txpkt WR with a GL. Includes the firmware work request header. */ @@ -6416,6 +6429,7 @@ txpkt_eo_len16(u_int nsegs, u_int immhdrs, u_int tso) done: return (howmany(n, 16)); } +#endif #define ETID_FLOWC_NPARAMS 6 #define ETID_FLOWC_LEN (roundup2((sizeof(struct fw_flowc_wr) + \ From nobody Wed Oct 20 16:01:01 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B72D5180236B; Wed, 20 Oct 2021 16:01: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 4HZFhY4WL5z4TYm; Wed, 20 Oct 2021 16:01: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 7B02826BE; Wed, 20 Oct 2021 16:01: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 19KG11uh066974; Wed, 20 Oct 2021 16:01:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KG115r066973; Wed, 20 Oct 2021 16:01:01 GMT (envelope-from git) Date: Wed, 20 Oct 2021 16:01:01 GMT Message-Id: <202110201601.19KG115r066973@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: 2f022558ce3d - stable/12 - selsocket: handle sopoll() errors correctly List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2f022558ce3d00eb53fd235dd87db780acd9bc25 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=2f022558ce3d00eb53fd235dd87db780acd9bc25 commit 2f022558ce3d00eb53fd235dd87db780acd9bc25 Author: Brooks Davis AuthorDate: 2021-10-20 16:00:38 +0000 Commit: Brooks Davis CommitDate: 2021-10-20 16:00:38 +0000 selsocket: handle sopoll() errors correctly Without this change, unmounting smbfs filesystems with an INVARIANTS kernel would panic after 10e64782ed59727e8c9fe4a5c7e17f497903c8eb. PR: 253079 Found by: markj Reviewed by: markj, jhb Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D32492 (cherry picked from commit 04c91ac48ad13ce0d1392cedbd69c2c0223d206f) --- sys/kern/sys_generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index fcdd5604583e..0840456f582f 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1596,10 +1596,10 @@ selsocket(struct socket *so, int events, struct timeval *tvp, struct thread *td) */ for (;;) { selfdalloc(td, NULL); - error = sopoll(so, events, NULL, td); - /* error here is actually the ready events. */ - if (error) - return (0); + if (sopoll(so, events, NULL, td) != 0) { + error = 0; + break; + } error = seltdwait(td, asbt, precision); if (error) break; From nobody Wed Oct 20 17:27:04 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5E592180C92E; Wed, 20 Oct 2021 17:27: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 4HZHbr2974z3GQg; Wed, 20 Oct 2021 17:27: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 29C663BAE; Wed, 20 Oct 2021 17:27: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 19KHR4k0080154; Wed, 20 Oct 2021 17:27:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHR4cL080153; Wed, 20 Oct 2021 17:27:04 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:27:04 GMT Message-Id: <202110201727.19KHR4cL080153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: ebf4e2da2c59 - stable/13 - cxgbe(4): Overhaul CLIP (Compressed Local IPv6) table management. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ebf4e2da2c598e41656a187c4bf5cd547c6c4a65 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=ebf4e2da2c598e41656a187c4bf5cd547c6c4a65 commit ebf4e2da2c598e41656a187c4bf5cd547c6c4a65 Author: Navdeep Parhar AuthorDate: 2021-05-23 21:58:29 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:05:02 +0000 cxgbe(4): Overhaul CLIP (Compressed Local IPv6) table management. - Process the list of local IPs once instead of once per adapter. Add addresses from all VNETs to the driver's list but leave hardware updates for later when the global VNET/IFADDR list locks have been released. - Add address to the hardware table synchronously when a CLIP entry is requested for an address that's not already in there. - Provide ioctls that allow userspace tools to manage addresses in the CLIP table. - Add a knob (hw.cxgbe.clip_db_auto) that controls whether local IPs are automatically added to the CLIP table or not. Sponsored by: Chelsio Communications (cherry picked from commit 24b98f288d11750f2cdfbfe360be1c92a9c2ee1d) --- sys/dev/cxgbe/adapter.h | 16 +- sys/dev/cxgbe/crypto/t4_kern_tls.c | 4 +- sys/dev/cxgbe/t4_clip.c | 842 ++++++++++++++++++++++++++++--------- sys/dev/cxgbe/t4_clip.h | 15 +- sys/dev/cxgbe/t4_ioctl.h | 10 + sys/dev/cxgbe/t4_main.c | 37 ++ sys/dev/cxgbe/tom/t4_connect.c | 4 +- sys/dev/cxgbe/tom/t4_listen.c | 18 +- sys/dev/cxgbe/tom/t4_tom.c | 2 +- 9 files changed, 735 insertions(+), 213 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 2f4619b1180f..630e9c4ac1b9 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,15 @@ MALLOC_DECLARE(M_CXGBE); #define CXGBE_UNIMPLEMENTED(s) \ panic("%s (%s, line %d) not implemented yet.", s, __FILE__, __LINE__) +/* + * Same as LIST_HEAD from queue.h. This is to avoid conflict with LinuxKPI's + * LIST_HEAD when building iw_cxgbe. + */ +#define CXGBE_LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + #ifndef SYSCTL_ADD_UQUAD #define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD #define sysctl_handle_64 sysctl_handle_quad @@ -881,9 +891,11 @@ struct adapter { struct port_info *port[MAX_NPORTS]; uint8_t chan_map[MAX_NCHAN]; /* channel -> port */ - struct mtx clip_table_lock; - TAILQ_HEAD(, clip_entry) clip_table; + CXGBE_LIST_HEAD(, clip_entry) *clip_table; + TAILQ_HEAD(, clip_entry) clip_pending; /* these need hw update. */ + u_long clip_mask; int clip_gen; + struct timeout_task clip_task; void *tom_softc; /* (struct tom_data *) */ struct tom_tunables tt; diff --git a/sys/dev/cxgbe/crypto/t4_kern_tls.c b/sys/dev/cxgbe/crypto/t4_kern_tls.c index 957d0202fa3f..99d0d33cf128 100644 --- a/sys/dev/cxgbe/crypto/t4_kern_tls.c +++ b/sys/dev/cxgbe/crypto/t4_kern_tls.c @@ -379,7 +379,7 @@ send_ktls_act_open_req(struct adapter *sc, struct vi_info *vi, isipv6 = (inp->inp_vflag & INP_IPV6) != 0; if (isipv6) { - tlsp->ce = t4_hold_lip(sc, &inp->in6p_laddr, NULL); + tlsp->ce = t4_get_clip_entry(sc, &inp->in6p_laddr, true); if (tlsp->ce == NULL) return (ENOENT); } @@ -2333,7 +2333,7 @@ cxgbe_tls_tag_free(struct m_snd_tag *mst) if (tlsp->tid >= 0) release_tid(sc, tlsp->tid, tlsp->ctrlq); if (tlsp->ce) - t4_release_lip(sc, tlsp->ce); + t4_release_clip_entry(sc, tlsp->ce); if (tlsp->tx_key_addr >= 0) free_keyid(tlsp, tlsp->tx_key_addr); diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c index ad26d212315e..18d78a9e830b 100644 --- a/sys/dev/cxgbe/t4_clip.c +++ b/sys/dev/cxgbe/t4_clip.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2012 Chelsio Communications, Inc. + * Copyright (c) 2012-2021 Chelsio Communications, Inc. * All rights reserved. * Written by: Navdeep Parhar * @@ -50,112 +50,345 @@ __FBSDID("$FreeBSD$"); #include "common/common.h" #include "t4_clip.h" +/* + * Code to deal with the Compressed Local IPv6 (CLIP) table in the ASIC. + * + * The driver maintains a global CLIP database (clip_db) of IPv6 addresses and a + * per-adapter CLIP table (sc->clip_table) with entries that point to an IPv6 in + * the clip_db. All access is protected by a single global lock (clip_db_lock). + * The correct lock order is clip lock before synchronized op. + * + * By default (hw.cxgbe.clip_db_auto=1) all local IPv6 addresses are added to + * the db. Addresses are also added on-demand when the driver allocates an + * entry for a filter, TOE tid, etc. krn_ref counts the number of times an + * address appears in the system. adp_ref counts the number of adapters that + * have that address in their CLIP table. If both are 0 then the entry is + * evicted from the db. Consumers of the CLIP table entry (filters, TOE tids) + * are tracked in ce->refcount. Driver ioctls let external consumers add/remove + * addresses from the CLIP table. + */ + #if defined(INET6) -static int add_lip(struct adapter *, struct in6_addr *); -static int delete_lip(struct adapter *, struct in6_addr *); -static struct clip_entry *search_lip(struct adapter *, struct in6_addr *); -static void update_clip(struct adapter *, void *); -static void t4_clip_task(void *, int); -static void update_clip_table(struct adapter *); +struct clip_db_entry { + LIST_ENTRY(clip_db_entry) link; /* clip_db hash linkage */ + struct in6_addr lip; + u_int krn_ref; /* # of times this IP6 appears in list of all IP6 */ + u_int adp_ref; /* # of adapters with this IP6 in their CLIP */ + u_int tmp_ref; /* Used only during refresh */ +}; + +struct clip_entry { + LIST_ENTRY(clip_entry) link; /* clip_table hash linkage */ + TAILQ_ENTRY(clip_entry) plink; /* clip_pending linkage */ + struct clip_db_entry *cde; + int16_t clip_idx; /* index in the hw table */ + bool pending; /* in clip_pending list */ + int refcount; +}; -static int in6_ifaddr_gen; static eventhandler_tag ifaddr_evhandler; -static struct timeout_task clip_task; +static struct mtx clip_db_lock; +static LIST_HEAD(, clip_db_entry) *clip_db; +static u_long clip_db_mask; +static int clip_db_gen; +static struct task clip_db_task; + +static int add_lip(struct adapter *, struct in6_addr *, int16_t *); +static int del_lip(struct adapter *, struct in6_addr *); +static void t4_clip_db_task(void *, int); +static void t4_clip_task(void *, int); +static void update_clip_db(void); +static int update_sw_clip_table(struct adapter *); +static int update_hw_clip_table(struct adapter *); +static void update_clip_table(struct adapter *, void *); +static int sysctl_clip_db(SYSCTL_HANDLER_ARGS); +static int sysctl_clip_db_auto(SYSCTL_HANDLER_ARGS); +static struct clip_db_entry *lookup_clip_db_entry(struct in6_addr *, bool); +static struct clip_entry *lookup_clip_entry(struct adapter *, struct in6_addr *, + bool); + +SYSCTL_PROC(_hw_cxgbe, OID_AUTO, clip_db, CTLTYPE_STRING | CTLFLAG_RD | + CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, 0, sysctl_clip_db, "A", + "CLIP database"); + +int t4_clip_db_auto = 1; +SYSCTL_PROC(_hw_cxgbe, OID_AUTO, clip_db_auto, CTLTYPE_INT | CTLFLAG_RWTUN | + CTLFLAG_MPSAFE, NULL, 0, sysctl_clip_db_auto, "I", + "Add local IPs to CLIP db automatically (0 = no, 1 = yes)"); + +static inline uint32_t +clip_hashfn(struct in6_addr *addr) +{ + return (fnv_32_buf(addr, sizeof(*addr), FNV1_32_INIT) & clip_db_mask); +} + +static inline struct clip_db_entry * +alloc_clip_db_entry(struct in6_addr *in6) +{ + struct clip_db_entry *cde; + + cde = malloc(sizeof(*cde), M_CXGBE, M_NOWAIT | M_ZERO); + if (__predict_true(cde != NULL)) + memcpy(&cde->lip, in6, sizeof(cde->lip)); + + return (cde); +} + +static inline struct clip_entry * +alloc_clip_entry(struct clip_db_entry *cde) +{ + struct clip_entry *ce; + + mtx_assert(&clip_db_lock, MA_OWNED); + + ce = malloc(sizeof(*ce), M_CXGBE, M_NOWAIT | M_ZERO); + if (__predict_true(ce != NULL)) { + ce->cde = cde; + cde->adp_ref++; + ce->clip_idx = -1; + } + + return (ce); +} + +/* + * Look up the IP6 address in the CLIP db. If add is set then an entry for the + * IP6 will be added to the db. + */ +static struct clip_db_entry * +lookup_clip_db_entry(struct in6_addr *in6, bool add) +{ + struct clip_db_entry *cde; + const int bucket = clip_hashfn(in6); + + mtx_assert(&clip_db_lock, MA_OWNED); + + LIST_FOREACH(cde, &clip_db[bucket], link) { + if (IN6_ARE_ADDR_EQUAL(&cde->lip, in6)) + return (cde); + } + + /* Not found. Create a new entry if requested. */ + if (add) { + cde = alloc_clip_db_entry(in6); + if (cde != NULL) + LIST_INSERT_HEAD(&clip_db[bucket], cde, link); + } + + return (cde); +} + +/* + * Look up the IP6 address in the CLIP db. If add is set then an entry for the + * IP6 will be added to the db. + */ +static struct clip_entry * +lookup_clip_entry(struct adapter *sc, struct in6_addr *in6, bool add) +{ + struct clip_db_entry *cde; + struct clip_entry *ce; + const int bucket = clip_hashfn(in6); + + mtx_assert(&clip_db_lock, MA_OWNED); + + cde = lookup_clip_db_entry(in6, add); + if (cde == NULL) + return (NULL); + + LIST_FOREACH(ce, &sc->clip_table[bucket], link) { + if (ce->cde == cde) + return (ce); + } + + /* Not found. Create a new entry if requested. */ + if (add) { + ce = alloc_clip_entry(cde); + if (ce != NULL) { + LIST_INSERT_HEAD(&sc->clip_table[bucket], ce, link); + TAILQ_INSERT_TAIL(&sc->clip_pending, ce, plink); + ce->pending = true; + } + } + + return (ce); +} static int -add_lip(struct adapter *sc, struct in6_addr *lip) +add_lip(struct adapter *sc, struct in6_addr *lip, int16_t *idx) { - struct fw_clip_cmd c; + struct fw_clip_cmd c; + int rc; ASSERT_SYNCHRONIZED_OP(sc); - mtx_assert(&sc->clip_table_lock, MA_OWNED); - memset(&c, 0, sizeof(c)); + memset(&c, 0, sizeof(c)); c.op_to_write = htonl(V_FW_CMD_OP(FW_CLIP_CMD) | F_FW_CMD_REQUEST | F_FW_CMD_WRITE); - c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_ALLOC | FW_LEN16(c)); - c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; - c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; + c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_ALLOC | FW_LEN16(c)); + c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; + c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; - return (-t4_wr_mbox_ns(sc, sc->mbox, &c, sizeof(c), &c)); + rc = -t4_wr_mbox_ns(sc, sc->mbox, &c, sizeof(c), &c); + if (rc == 0 && idx != NULL) + *idx = G_FW_CLIP_CMD_INDEX(ntohl(c.alloc_to_len16)); + return (rc); } static int -delete_lip(struct adapter *sc, struct in6_addr *lip) +del_lip(struct adapter *sc, struct in6_addr *lip) { struct fw_clip_cmd c; ASSERT_SYNCHRONIZED_OP(sc); - mtx_assert(&sc->clip_table_lock, MA_OWNED); memset(&c, 0, sizeof(c)); c.op_to_write = htonl(V_FW_CMD_OP(FW_CLIP_CMD) | F_FW_CMD_REQUEST | F_FW_CMD_READ); - c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_FREE | FW_LEN16(c)); - c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; - c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; + c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_FREE | FW_LEN16(c)); + c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; + c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; return (-t4_wr_mbox_ns(sc, sc->mbox, &c, sizeof(c), &c)); } +#endif -static struct clip_entry * -search_lip(struct adapter *sc, struct in6_addr *lip) +struct clip_entry * +t4_get_clip_entry(struct adapter *sc, struct in6_addr *in6, bool add) { +#ifdef INET6 struct clip_entry *ce; + bool schedule = false; - mtx_assert(&sc->clip_table_lock, MA_OWNED); - - TAILQ_FOREACH(ce, &sc->clip_table, link) { - if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) - return (ce); + mtx_lock(&clip_db_lock); + ce = lookup_clip_entry(sc, in6, add); + if (ce != NULL) { + MPASS(ce->cde->adp_ref > 0); + if (++ce->refcount == 1 && ce->pending && ce->clip_idx != -1) { + /* + * Valid entry that was waiting to be deleted. It is in + * use now so take it off the pending list. + */ + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + ce->pending = false; + } + if (ce->clip_idx == -1 && update_hw_clip_table(sc) != 0) + schedule = true; } + mtx_unlock(&clip_db_lock); + if (schedule) + taskqueue_enqueue_timeout(taskqueue_thread, &sc->clip_task, 0); + return (ce); +#else return (NULL); -} #endif +} -struct clip_entry * -t4_hold_lip(struct adapter *sc, struct in6_addr *lip, struct clip_entry *ce) +void +t4_hold_clip_entry(struct adapter *sc, struct clip_entry *ce) { - #ifdef INET6 - mtx_lock(&sc->clip_table_lock); - if (ce == NULL) - ce = search_lip(sc, lip); - if (ce != NULL) - ce->refcount++; - mtx_unlock(&sc->clip_table_lock); + MPASS(ce != NULL); + MPASS(ce->cde->adp_ref > 0); - return (ce); -#else - return (NULL); + mtx_lock(&clip_db_lock); + MPASS(ce->refcount > 0); /* Caller should already have a reference */ + ce->refcount++; + mtx_unlock(&clip_db_lock); #endif } +#ifdef INET6 +static void +release_clip_entry_locked(struct adapter *sc, struct clip_entry *ce) +{ + struct clip_db_entry *cde; + + mtx_assert(&clip_db_lock, MA_OWNED); + MPASS(ce->refcount > 0); + cde = ce->cde; + MPASS(cde->adp_ref > 0); + if (--ce->refcount == 0 && cde->krn_ref == 0) { + if (ce->clip_idx == -1) { + /* Was never written to the hardware. */ + MPASS(ce->pending); + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + LIST_REMOVE(ce, link); + free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + } + } else { + /* + * Valid entry is now unused, add to the pending list + * for deletion. Its refcount was 1 on entry so it + * can't already be pending. + */ + MPASS(!ce->pending); + TAILQ_INSERT_HEAD(&sc->clip_pending, ce, plink); + ce->pending = true; + } + } +} +#endif + void -t4_release_lip(struct adapter *sc, struct clip_entry *ce) +t4_release_clip_entry(struct adapter *sc, struct clip_entry *ce) { +#ifdef INET6 + MPASS(ce != NULL); + + mtx_lock(&clip_db_lock); + release_clip_entry_locked(sc, ce); + /* + * This isn't a manual release via the ioctl. No need to update the + * hw right now even if the release resulted in the entry being queued + * for deletion. + */ + mtx_unlock(&clip_db_lock); +#endif +} +int +t4_release_clip_addr(struct adapter *sc, struct in6_addr *in6) +{ + int rc = ENOTSUP; #ifdef INET6 - mtx_lock(&sc->clip_table_lock); - KASSERT(search_lip(sc, &ce->lip) == ce, - ("%s: CLIP entry %p p not in CLIP table.", __func__, ce)); - KASSERT(ce->refcount > 0, - ("%s: CLIP entry %p has refcount 0", __func__, ce)); - --ce->refcount; - mtx_unlock(&sc->clip_table_lock); + struct clip_entry *ce; + bool schedule = false; + + mtx_lock(&clip_db_lock); + ce = lookup_clip_entry(sc, in6, false); + if (ce == NULL) + rc = ENOENT; + else if (ce->refcount == 0) + rc = EIO; + else { + release_clip_entry_locked(sc, ce); + if (update_hw_clip_table(sc) != 0) + schedule = true; + rc = 0; + } + mtx_unlock(&clip_db_lock); + if (schedule) + taskqueue_enqueue_timeout(taskqueue_thread, &sc->clip_task, 0); #endif + return (rc); } #ifdef INET6 void t4_init_clip_table(struct adapter *sc) { - - mtx_init(&sc->clip_table_lock, "CLIP table lock", NULL, MTX_DEF); - TAILQ_INIT(&sc->clip_table); + TAILQ_INIT(&sc->clip_pending); + TIMEOUT_TASK_INIT(taskqueue_thread, &sc->clip_task, 0, t4_clip_task, sc); sc->clip_gen = -1; + sc->clip_table = hashinit(CLIP_HASH_SIZE, M_CXGBE, &sc->clip_mask); + /* Both the hashes must use the same bucket for the same key. */ + if (sc->clip_table != NULL) + MPASS(sc->clip_mask == clip_db_mask); /* * Don't bother forcing an update of the clip table when the * adapter is initialized. Before an interface can be used it @@ -164,194 +397,344 @@ t4_init_clip_table(struct adapter *sc) */ } +/* + * Returns true if any additions or deletions were made to the CLIP DB. + */ static void -update_clip(struct adapter *sc, void *arg __unused) +update_clip_db(void) { + VNET_ITERATOR_DECL(vnet_iter); + struct rm_priotracker in6_ifa_tracker; + struct in6_addr *in6, tin6; + struct in6_ifaddr *ia; + struct clip_db_entry *cde, *cde_tmp; + int i, addel; - if (begin_synchronized_op(sc, NULL, HOLD_LOCK, "t4clip")) - return; + VNET_LIST_RLOCK(); + IN6_IFADDR_RLOCK(&in6_ifa_tracker); + mtx_lock(&clip_db_lock); + VNET_FOREACH(vnet_iter) { + CURVNET_SET_QUIET(vnet_iter); + CK_STAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { + if (ia->ia_ifp->if_flags & IFF_LOOPBACK) + continue; + in6 = &ia->ia_addr.sin6_addr; + KASSERT(!IN6_IS_ADDR_MULTICAST(in6), + ("%s: mcast address in in6_ifaddr list", __func__)); + if (IN6_IS_ADDR_LOOPBACK(in6)) + continue; - if (mtx_initialized(&sc->clip_table_lock) && !hw_off_limits(sc)) - update_clip_table(sc); + if (IN6_IS_SCOPE_EMBED(in6)) { + tin6 = *in6; + in6 = &tin6; + in6_clearscope(in6); + } + cde = lookup_clip_db_entry(in6, true); + if (cde == NULL) + continue; + cde->tmp_ref++; + } + CURVNET_RESTORE(); + } + + addel = 0; + for (i = 0; i <= clip_db_mask; i++) { + LIST_FOREACH_SAFE(cde, &clip_db[i], link, cde_tmp) { + if (cde->krn_ref == 0 && cde->tmp_ref > 0) { + addel++; /* IP6 addr added. */ + } else if (cde->krn_ref > 0 && cde->tmp_ref == 0) { + if (cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + continue; + } + addel++; /* IP6 addr deleted. */ + } + cde->krn_ref = cde->tmp_ref; + cde->tmp_ref = 0; + } + } + if (addel > 0) + clip_db_gen++; + mtx_unlock(&clip_db_lock); + IN6_IFADDR_RUNLOCK(&in6_ifa_tracker); + VNET_LIST_RUNLOCK(); - end_synchronized_op(sc, LOCK_HELD); } +/* + * Update the CLIP db and then update the CLIP tables on all the adapters. + */ static void -t4_clip_task(void *arg, int count) +t4_clip_db_task(void *arg, int count) { - - t4_iterate(update_clip, NULL); + update_clip_db(); + t4_iterate(update_clip_table, NULL); } -static void -update_clip_table(struct adapter *sc) +/* + * Refresh the sw CLIP table for this adapter from the global CLIP db. Entries + * that need to be added or deleted from the hardware CLIP table are placed on a + * pending list but the hardware is not touched. The pending list is something + * reasonable even if this fails so it's ok to apply that to the hardware. + */ +static int +update_sw_clip_table(struct adapter *sc) { - struct rm_priotracker in6_ifa_tracker; - struct in6_ifaddr *ia; - struct in6_addr *lip, tlip; - TAILQ_HEAD(, clip_entry) stale; + struct clip_db_entry *cde; struct clip_entry *ce, *ce_temp; - struct vi_info *vi; - int rc, gen, i, j; - uintptr_t last_vnet; - - ASSERT_SYNCHRONIZED_OP(sc); + int i; + bool found; - IN6_IFADDR_RLOCK(&in6_ifa_tracker); - mtx_lock(&sc->clip_table_lock); - - gen = atomic_load_acq_int(&in6_ifaddr_gen); - if (gen == sc->clip_gen) - goto done; - - TAILQ_INIT(&stale); - TAILQ_CONCAT(&stale, &sc->clip_table, link); + mtx_assert(&clip_db_lock, MA_OWNED); /* - * last_vnet optimizes the common cases where all if_vnet = NULL (no - * VIMAGE) or all if_vnet = vnet0. + * We are about to rebuild the pending list from scratch. Deletions are + * placed before additions because that's how we want to submit them to + * the hardware. */ - last_vnet = (uintptr_t)(-1); - for_each_port(sc, i) - for_each_vi(sc->port[i], j, vi) { - if (IS_DOOMED(vi)) - continue; - - if (last_vnet == (uintptr_t)vi->ifp->if_vnet) - continue; + TAILQ_INIT(&sc->clip_pending); - /* XXX: races with if_vmove */ - CURVNET_SET(vi->ifp->if_vnet); - CK_STAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { - lip = &ia->ia_addr.sin6_addr; - - KASSERT(!IN6_IS_ADDR_MULTICAST(lip), - ("%s: mcast address in in6_ifaddr list", __func__)); - - if (IN6_IS_ADDR_LOOPBACK(lip)) + /* + * Walk the sw CLIP table first. We want to reset every entry's pending + * status as we're rebuilding the pending list. + */ + for (i = 0; i <= clip_db_mask; i++) { + LIST_FOREACH_SAFE(ce, &sc->clip_table[i], link, ce_temp) { + cde = ce->cde; + MPASS(cde->adp_ref > 0); + if (ce->refcount != 0 || cde->krn_ref != 0) { + /* + * Entry should stay in the CLIP. + */ + + if (ce->clip_idx != -1) { + ce->pending = false; + } else { + /* Was never added, carry forward. */ + MPASS(ce->pending); + TAILQ_INSERT_TAIL(&sc->clip_pending, ce, + plink); + } continue; - if (IN6_IS_SCOPE_EMBED(lip)) { - /* Remove the embedded scope */ - tlip = *lip; - lip = &tlip; - in6_clearscope(lip); } - /* - * XXX: how to weed out the link local address for the - * loopback interface? It's fe80::1 usually (always?). - */ /* - * If it's in the main list then we already know it's - * not stale. + * Entry should be removed from the CLIP. */ - TAILQ_FOREACH(ce, &sc->clip_table, link) { - if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) - goto next; - } - /* - * If it's in the stale list we should move it to the - * main list. - */ - TAILQ_FOREACH(ce, &stale, link) { - if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) { - TAILQ_REMOVE(&stale, ce, link); - TAILQ_INSERT_TAIL(&sc->clip_table, ce, - link); - goto next; + if (ce->clip_idx != -1) { + ce->pending = true; + TAILQ_INSERT_HEAD(&sc->clip_pending, ce, plink); + } else { + /* Was never added, free right now. */ + MPASS(ce->pending); + LIST_REMOVE(ce, link); + free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); } } + } + } + + for (i = 0; i <= clip_db_mask; i++) { + LIST_FOREACH(cde, &clip_db[i], link) { + if (cde->krn_ref == 0) + continue; - /* A new IP6 address; add it to the CLIP table */ - ce = malloc(sizeof(*ce), M_CXGBE, M_NOWAIT); - memcpy(&ce->lip, lip, sizeof(ce->lip)); - ce->refcount = 0; - rc = add_lip(sc, lip); - if (rc == 0) - TAILQ_INSERT_TAIL(&sc->clip_table, ce, link); - else { - char ip[INET6_ADDRSTRLEN]; - - inet_ntop(AF_INET6, &ce->lip, &ip[0], - sizeof(ip)); - if (sc->flags & KERN_TLS_ON || - sc->active_ulds != 0) { - log(LOG_ERR, - "%s: could not add %s (%d)\n", - __func__, ip, rc); + found = false; + LIST_FOREACH(ce, &sc->clip_table[i], link) { + if (ce->cde == cde) { + found = true; + break; } - free(ce, M_CXGBE); } -next: - continue; + if (found) + continue; + ce = alloc_clip_entry(cde); + if (ce == NULL) + return (ENOMEM); + LIST_INSERT_HEAD(&sc->clip_table[i], ce, link); + TAILQ_INSERT_TAIL(&sc->clip_pending, ce, plink); + ce->pending = true; } - CURVNET_RESTORE(); - last_vnet = (uintptr_t)vi->ifp->if_vnet; } - /* - * Remove stale addresses (those no longer in V_in6_ifaddrhead) that are - * no longer referenced by the driver. - */ - TAILQ_FOREACH_SAFE(ce, &stale, link, ce_temp) { - if (ce->refcount == 0) { - rc = delete_lip(sc, &ce->lip); - if (rc == 0) { - TAILQ_REMOVE(&stale, ce, link); + sc->clip_gen = clip_db_gen; + return (0); +} + +static int +update_hw_clip_table(struct adapter *sc) +{ + struct clip_db_entry *cde; + struct clip_entry *ce; + int rc; + char ip[INET6_ADDRSTRLEN]; + + mtx_assert(&clip_db_lock, MA_OWNED); + rc = begin_synchronized_op(sc, NULL, HOLD_LOCK, "t4clip"); + if (rc != 0) + return (rc); + if (hw_off_limits(sc)) + goto done; /* with rc = 0, we don't want to reschedule. */ + while (!TAILQ_EMPTY(&sc->clip_pending)) { + ce = TAILQ_FIRST(&sc->clip_pending); + MPASS(ce->pending); + cde = ce->cde; + MPASS(cde->adp_ref > 0); + + if (ce->clip_idx == -1) { + /* + * Entry was queued for addition to the HW CLIP. + */ + + if (ce->refcount == 0 && cde->krn_ref == 0) { + /* No need to add to HW CLIP. */ + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + LIST_REMOVE(ce, link); free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + } } else { - char ip[INET6_ADDRSTRLEN]; + /* Add to the HW CLIP. */ + rc = add_lip(sc, &cde->lip, &ce->clip_idx); + if (rc == FW_ENOMEM) { + /* CLIP full, no point in retrying. */ + rc = 0; + goto done; + } + if (rc != 0) { + inet_ntop(AF_INET6, &cde->lip, &ip[0], + sizeof(ip)); + CH_ERR(sc, "add_lip(%s) failed: %d\n", + ip, rc); + goto done; + } + MPASS(ce->clip_idx != -1); + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + ce->pending = false; + } + } else { + /* + * Entry was queued for deletion from the HW CLIP. + */ - inet_ntop(AF_INET6, &ce->lip, &ip[0], - sizeof(ip)); - log(LOG_ERR, "%s: could not delete %s (%d)\n", - __func__, ip, rc); + if (ce->refcount == 0 && cde->krn_ref == 0) { + /* + * Delete from the HW CLIP. Delete should never + * fail so we always log an error. But if the + * failure is that the entry wasn't found in the + * CLIP then we carry on as if it was deleted. + */ + rc = del_lip(sc, &cde->lip); + if (rc != 0) + CH_ERR(sc, "del_lip(%s) failed: %d\n", + ip, rc); + if (rc == FW_EPROTO) + rc = 0; + if (rc != 0) + goto done; + + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + LIST_REMOVE(ce, link); + free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + } + } else { + /* No need to delete from HW CLIP. */ + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + ce->pending = false; } } } - /* The ones that are still referenced need to stay in the CLIP table */ - TAILQ_CONCAT(&sc->clip_table, &stale, link); - - sc->clip_gen = gen; done: - mtx_unlock(&sc->clip_table_lock); - IN6_IFADDR_RUNLOCK(&in6_ifa_tracker); + end_synchronized_op(sc, LOCK_HELD); + return (rc); +} + +static void +update_clip_table(struct adapter *sc, void *arg __unused) +{ + bool reschedule; + + if (sc->clip_table == NULL) + return; + + reschedule = false; + mtx_lock(&clip_db_lock); + if (sc->clip_gen != clip_db_gen && update_sw_clip_table(sc) != 0) + reschedule = true; + if (!TAILQ_EMPTY(&sc->clip_pending) && update_hw_clip_table(sc) != 0) + reschedule = true; + mtx_unlock(&clip_db_lock); + if (reschedule) + taskqueue_enqueue_timeout(taskqueue_thread, &sc->clip_task, + -hz / 4); +} + +/* + * Update the CLIP table of the specified adapter. + */ +static void +t4_clip_task(void *sc, int count) +{ + update_clip_table(sc, NULL); } void t4_destroy_clip_table(struct adapter *sc) { struct clip_entry *ce, *ce_temp; - - if (mtx_initialized(&sc->clip_table_lock)) { - mtx_lock(&sc->clip_table_lock); - TAILQ_FOREACH_SAFE(ce, &sc->clip_table, link, ce_temp) { - KASSERT(ce->refcount == 0, - ("%s: CLIP entry %p still in use (%d)", __func__, - ce, ce->refcount)); - TAILQ_REMOVE(&sc->clip_table, ce, link); + int i; + + mtx_lock(&clip_db_lock); + if (sc->clip_table == NULL) + goto done; /* CLIP was never initialized. */ + for (i = 0; i <= sc->clip_mask; i++) { + LIST_FOREACH_SAFE(ce, &sc->clip_table[i], link, ce_temp) { + MPASS(ce->refcount == 0); + MPASS(ce->cde->adp_ref > 0); #if 0 - delete_lip(sc, &ce->lip); + del_lip(sc, &ce->lip); #endif + LIST_REMOVE(ce, link); + if (--ce->cde->adp_ref == 0 && ce->cde->krn_ref == 0) { + LIST_REMOVE(ce->cde, link); + free(ce->cde, M_CXGBE); + } free(ce, M_CXGBE); } - mtx_unlock(&sc->clip_table_lock); - mtx_destroy(&sc->clip_table_lock); } + hashdestroy(&sc->clip_table, M_CXGBE, sc->clip_mask); + sc->clip_table = NULL; +done: + mtx_unlock(&clip_db_lock); } static void t4_ifaddr_event(void *arg __unused, struct ifnet *ifp, struct ifaddr *ifa, int event) { + struct in6_addr *in6; + if (t4_clip_db_auto == 0) + return; /* Automatic updates not allowed. */ if (ifa->ifa_addr->sa_family != AF_INET6) return; + if (ifp->if_flags & IFF_LOOPBACK) + return; + in6 = &((struct in6_ifaddr *)ifa)->ia_addr.sin6_addr; + if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_MULTICAST(in6)) + return; - atomic_add_rel_int(&in6_ifaddr_gen, 1); - taskqueue_enqueue_timeout(taskqueue_thread, &clip_task, -hz / 4); + taskqueue_enqueue(taskqueue_thread, &clip_db_task); } *** 337 LINES SKIPPED *** From nobody Wed Oct 20 17:27:05 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B2795180C934; Wed, 20 Oct 2021 17:27: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 4HZHbs39Qdz3GVq; Wed, 20 Oct 2021 17:27: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 449A13ACA; Wed, 20 Oct 2021 17:27: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 19KHR5Wm080178; Wed, 20 Oct 2021 17:27:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHR5cP080177; Wed, 20 Oct 2021 17:27:05 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:27:05 GMT Message-Id: <202110201727.19KHR5cP080177@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: be259947759b - stable/13 - cxgbetool(8): add a 'clip' subcommand to deal with the CLIP table. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: be259947759be3c677e022ec314625812e7cb837 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=be259947759be3c677e022ec314625812e7cb837 commit be259947759be3c677e022ec314625812e7cb837 Author: Navdeep Parhar AuthorDate: 2021-05-23 23:28:31 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:12:37 +0000 cxgbetool(8): add a 'clip' subcommand to deal with the CLIP table. Sponsored by: Chelsio Communications (cherry picked from commit ac02945f7e2b5ab84fe510fc052c35350e31220d) --- usr.sbin/cxgbetool/cxgbetool.8 | 30 ++++++++++++++- usr.sbin/cxgbetool/cxgbetool.c | 84 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 110 insertions(+), 4 deletions(-) diff --git a/usr.sbin/cxgbetool/cxgbetool.8 b/usr.sbin/cxgbetool/cxgbetool.8 index 56980e42795f..02dc1a176eb0 100644 --- a/usr.sbin/cxgbetool/cxgbetool.8 +++ b/usr.sbin/cxgbetool/cxgbetool.8 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Sep 21, 2018 +.Dd May 23, 2021 .Dt CXGBETOOL 8 .Os .Sh NAME @@ -46,6 +46,10 @@ .It .Nm Ar nexus Cm clearstats Ar port_id .It +.Nm Ar nexus Cm clip Bro Cm hold | release Brc Ar ipv6-address +.It +.Nm Ar nexus Cm clip Cm list +.It .Nm Ar nexus Cm context Bro Cm ingress | egress | fl | cong Brc Ar cntxt_id .It .Nm Ar nexus Cm hashfilter mode @@ -119,6 +123,30 @@ identifies a port within this range. .Pp .Bl -item -compact .It +.Cm clip hold Ar ipv6-address +.El +Install a reference on the given +.Ar ipv6-address +in the CLIP (Compressed Local IPv6) table. +The address is added to the CLIP table if it is not present there already. +.Pp +.Bl -item -compact +.It +.Cm clip list +.El +List the contents of the CLIP table. +.Pp +.Bl -item -compact +.It +.Cm clip release Ar ipv6-address +.El +Release a reference on the given +.Ar ipv6-address +in the CLIP table. +A reference on the address must have been acquired previously. +.Pp +.Bl -item -compact +.It .Cm context ingress Ar ingress_cntxt_id .It .Cm context cong Ar ingress_cntxt_id diff --git a/usr.sbin/cxgbetool/cxgbetool.c b/usr.sbin/cxgbetool/cxgbetool.c index 139a0bd8e564..77f092123de9 100644 --- a/usr.sbin/cxgbetool/cxgbetool.c +++ b/usr.sbin/cxgbetool/cxgbetool.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -58,7 +59,8 @@ __FBSDID("$FreeBSD$"); #define max(x, y) ((x) > (y) ? (x) : (y)) static const char *progname, *nexus; -static int chip_id; /* 4 for T4, 5 for T5 */ +static int chip_id; /* 4 for T4, 5 for T5, and so on. */ +static int inst; /* instance of nexus device */ struct reg_info { const char *name; @@ -91,6 +93,8 @@ usage(FILE *fp) fprintf(fp, "Usage: %s [operation]\n", progname); fprintf(fp, "\tclearstats clear port statistics\n" + "\tclip hold|release hold/release an address\n" + "\tclip list list the CLIP table\n" "\tcontext show an SGE context\n" "\tdumpstate dump chip state\n" "\tfilter [ ] ... set a filter\n" @@ -3506,6 +3510,69 @@ load_offload_policy(int argc, const char *argv[]) return (rc); } +static int +display_clip(void) +{ + size_t clip_buf_size = 4096; + char *buf, name[32]; + int rc; + + buf = malloc(clip_buf_size); + if (buf == NULL) { + warn("%s", __func__); + return (errno); + } + + snprintf(name, sizeof(name), "dev.t%unex.%u.misc.clip", chip_id, inst); + rc = sysctlbyname(name, buf, &clip_buf_size, NULL, 0); + if (rc != 0) { + warn("sysctl %s", name); + free(buf); + return (errno); + } + + printf("%s\n", buf); + free(buf); + return (0); +} + +static int +clip_cmd(int argc, const char *argv[]) +{ + int rc, af = AF_INET6, add; + struct t4_clip_addr ca = {0}; + + if (argc == 1 && !strcmp(argv[0], "list")) { + rc = display_clip(); + return (rc); + } + + if (argc != 2) { + warnx("incorrect number of arguments."); + return (EINVAL); + } + + if (!strcmp(argv[0], "hold")) { + add = 1; + } else if (!strcmp(argv[0], "rel") || !strcmp(argv[0], "release")) { + add = 0; + } else { + warnx("first argument must be \"hold\" or \"release\""); + return (EINVAL); + } + + rc = parse_ipaddr(argv[0], argv, &af, &ca.addr[0], &ca.mask[0], 1); + if (rc != 0) + return (rc); + + if (add) + rc = doit(CHELSIO_T4_HOLD_CLIP_ADDR, &ca); + else + rc = doit(CHELSIO_T4_RELEASE_CLIP_ADDR, &ca); + + return (rc); +} + static int run_cmd(int argc, const char *argv[]) { @@ -3556,6 +3623,8 @@ run_cmd(int argc, const char *argv[]) rc = load_offload_policy(argc, argv); else if (!strcmp(cmd, "hashfilter")) rc = filter_cmd(argc, argv, 1); + else if (!strcmp(cmd, "clip")) + rc = clip_cmd(argc, argv); else { rc = EINVAL; warnx("invalid command \"%s\"", cmd); @@ -3609,6 +3678,16 @@ run_cmd_loop(void) return (rc); } +static void +parse_nexus_name(const char *s) +{ + char junk; + + if (sscanf(s, "t%unex%u%c", &chip_id, &inst, &junk) != 2) + errx(EINVAL, "invalid nexus \"%s\"", s); + nexus = s; +} + int main(int argc, const char *argv[]) { @@ -3628,8 +3707,7 @@ main(int argc, const char *argv[]) exit(EINVAL); } - nexus = argv[1]; - chip_id = nexus[1] - '0'; + parse_nexus_name(argv[1]); /* progname and nexus */ argc -= 2; From nobody Wed Oct 20 17:27:06 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 19147180C850; Wed, 20 Oct 2021 17:27: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 4HZHbt53mLz3GHl; Wed, 20 Oct 2021 17:27: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 6C0B93ACB; Wed, 20 Oct 2021 17:27: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 19KHR6lM080207; Wed, 20 Oct 2021 17:27:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHR6Ue080206; Wed, 20 Oct 2021 17:27:06 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:27:06 GMT Message-Id: <202110201727.19KHR6Ue080206@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: b58fc654a9b4 - stable/13 - cxgbe(4): Use correct argument in call to hashdestroy. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b58fc654a9b4ec60bd6ec0116fd68b4237389a12 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=b58fc654a9b4ec60bd6ec0116fd68b4237389a12 commit b58fc654a9b4ec60bd6ec0116fd68b4237389a12 Author: Navdeep Parhar AuthorDate: 2021-05-27 04:32:13 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:16:18 +0000 cxgbe(4): Use correct argument in call to hashdestroy. This fixes a panic on driver module unload. Fixes: 24b98f288d11 cxgbe(4): Overhaul CLIP (Compressed Local IPv6) table management. Sponsored by: Chelsio Communications (cherry picked from commit 740d722def71905dd74a622acce1561701ccbec6) --- sys/dev/cxgbe/t4_clip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c index 18d78a9e830b..98734d6d11ce 100644 --- a/sys/dev/cxgbe/t4_clip.c +++ b/sys/dev/cxgbe/t4_clip.c @@ -712,7 +712,7 @@ t4_destroy_clip_table(struct adapter *sc) free(ce, M_CXGBE); } } - hashdestroy(&sc->clip_table, M_CXGBE, sc->clip_mask); + hashdestroy(sc->clip_table, M_CXGBE, sc->clip_mask); sc->clip_table = NULL; done: mtx_unlock(&clip_db_lock); @@ -856,7 +856,7 @@ t4_clip_modunload(void) { EVENTHANDLER_DEREGISTER(ifaddr_event_ext, ifaddr_evhandler); taskqueue_drain(taskqueue_thread, &clip_db_task); - hashdestroy(&clip_db, M_CXGBE, clip_db_mask); + hashdestroy(clip_db, M_CXGBE, clip_db_mask); mtx_destroy(&clip_db_lock); } #endif From nobody Wed Oct 20 17:27:07 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9C35A180CA3C; Wed, 20 Oct 2021 17:27: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 4HZHbw0gfnz3GF8; Wed, 20 Oct 2021 17:27: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 907323C0E; Wed, 20 Oct 2021 17:27: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 19KHR7wM080233; Wed, 20 Oct 2021 17:27:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHR741080232; Wed, 20 Oct 2021 17:27:07 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:27:07 GMT Message-Id: <202110201727.19KHR741080232@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 29d5f2c0ee06 - stable/13 - cxgbe(4): Empty the clib_db before trying to destroy it. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 29d5f2c0ee0610c3ddbdadb9fbf0fe2621484529 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=29d5f2c0ee0610c3ddbdadb9fbf0fe2621484529 commit 29d5f2c0ee0610c3ddbdadb9fbf0fe2621484529 Author: Navdeep Parhar AuthorDate: 2021-06-04 19:01:14 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:16:58 +0000 cxgbe(4): Empty the clib_db before trying to destroy it. This fixes a panic on driver unload. Reported by: Jithesh Arakkan @ Chelsio Sponsored by: Chelsio Communications (cherry picked from commit bb877c0620347eb86f25f4382c42d58685c348d4) --- sys/dev/cxgbe/t4_clip.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c index 98734d6d11ce..5f4fbd0f07a6 100644 --- a/sys/dev/cxgbe/t4_clip.c +++ b/sys/dev/cxgbe/t4_clip.c @@ -854,8 +854,21 @@ t4_clip_modload(void) void t4_clip_modunload(void) { + struct clip_db_entry *cde; + int i; + EVENTHANDLER_DEREGISTER(ifaddr_event_ext, ifaddr_evhandler); taskqueue_drain(taskqueue_thread, &clip_db_task); + mtx_lock(&clip_db_lock); + for (i = 0; i <= clip_db_mask; i++) { + while ((cde = LIST_FIRST(&clip_db[i])) != NULL) { + MPASS(cde->tmp_ref == 0); + MPASS(cde->adp_ref == 0); + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + } + } + mtx_unlock(&clip_db_lock); hashdestroy(clip_db, M_CXGBE, clip_db_mask); mtx_destroy(&clip_db_lock); } From nobody Wed Oct 20 17:29:04 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 95640180E29D; Wed, 20 Oct 2021 17:29: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 4HZHf83Srlz3J5R; Wed, 20 Oct 2021 17:29: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 5311B3BBD; Wed, 20 Oct 2021 17:29: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 19KHT4H7080487; Wed, 20 Oct 2021 17:29:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHT4UE080486; Wed, 20 Oct 2021 17:29:04 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:29:04 GMT Message-Id: <202110201729.19KHT4UE080486@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 1b3f407f7d43 - stable/13 - cxgbe(4): Fix an incorrect assert. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1b3f407f7d437c272d0cb2d84260b5622733a110 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=1b3f407f7d437c272d0cb2d84260b5622733a110 commit 1b3f407f7d437c272d0cb2d84260b5622733a110 Author: Navdeep Parhar AuthorDate: 2021-05-27 02:18:42 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:27:28 +0000 cxgbe(4): Fix an incorrect assert. CTRL and OFLD tx queues do not have automatic tx credit flush enabled so it is okay for the cidx not to be the same as the pidx when the queue is destroyed. Reported by: Jithesh Arakkan @ Chelsio Sponsored by: Chelsio Communications (cherry picked from commit 5ef87bf8b687575bee010967e23cd2c552b43ad9) --- sys/dev/cxgbe/t4_sge.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 44fef6dfc633..9d990253d7a0 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4317,7 +4317,8 @@ static void free_eq(struct adapter *sc, struct sge_eq *eq) { MPASS(eq->flags & EQ_SW_ALLOCATED); - MPASS(eq->pidx == eq->cidx); + if (eq->type == EQ_ETH) + MPASS(eq->pidx == eq->cidx); free_ring(sc, eq->desc_tag, eq->desc_map, eq->ba, eq->desc); mtx_destroy(&eq->eq_lock); @@ -4470,6 +4471,8 @@ free_wrq(struct adapter *sc, struct sge_wrq *wrq) { free_eq(sc, &wrq->eq); MPASS(wrq->nwr_pending == 0); + MPASS(TAILQ_EMPTY(&wrq->incomplete_wrs)); + MPASS(STAILQ_EMPTY(&wrq->wr_list)); bzero(wrq, sizeof(*wrq)); } From nobody Wed Oct 20 17:39:32 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 54A711812234; Wed, 20 Oct 2021 17: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 4HZHtD1vj5z3LTc; Wed, 20 Oct 2021 17: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 2280E3CA8; Wed, 20 Oct 2021 17: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 19KHdWqW094371; Wed, 20 Oct 2021 17: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 19KHdWVO094370; Wed, 20 Oct 2021 17:39:32 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:32 GMT Message-Id: <202110201739.19KHdWVO094370@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: df667b59d76f - stable/13 - cxgb(4): Report proper TSO limits. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: df667b59d76fefc9fafa3a02ed162c58e6aa5199 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=df667b59d76fefc9fafa3a02ed162c58e6aa5199 commit df667b59d76fefc9fafa3a02ed162c58e6aa5199 Author: Navdeep Parhar AuthorDate: 2021-06-04 20:30:28 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:29:45 +0000 cxgb(4): Report proper TSO limits. Sponsored by: Chelsio Communications (cherry picked from commit f13d72fd0b743a1fd97dd31f4abf19e8814c420b) --- sys/dev/cxgb/cxgb_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index ab835b0c1853..5c0bdd569fab 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -1042,6 +1042,9 @@ cxgb_port_attach(device_t dev) ifp->if_capenable = CXGB_CAP_ENABLE; ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO | CSUM_UDP_IPV6 | CSUM_TCP_IPV6; + ifp->if_hw_tsomax = IP_MAXPACKET; + ifp->if_hw_tsomaxsegcount = 36; + ifp->if_hw_tsomaxsegsize = 65536; /* * Disable TSO on 4-port - it isn't supported by the firmware. From nobody Wed Oct 20 17:39:33 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 197CA1812166; Wed, 20 Oct 2021 17:39: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 4HZHtF559Lz3LnW; Wed, 20 Oct 2021 17:39: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 6D4B53C25; Wed, 20 Oct 2021 17:39: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 19KHdX9M094399; Wed, 20 Oct 2021 17:39:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHdXZH094398; Wed, 20 Oct 2021 17:39:33 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:33 GMT Message-Id: <202110201739.19KHdXZH094398@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 20cbc6676b87 - stable/13 - cxgbe(4): Update firmwares to 1.25.6.0. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 20cbc6676b87a00813b73676d9bcb390a41ce479 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=20cbc6676b87a00813b73676d9bcb390a41ce479 commit 20cbc6676b87a00813b73676d9bcb390a41ce479 Author: Navdeep Parhar AuthorDate: 2021-05-25 20:47:06 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:30:56 +0000 cxgbe(4): Update firmwares to 1.25.6.0. Changes since 1.25.0.0 are listed here. This list comes from the Release Notes for the "Chelsio Unified Wire v3.14.0.3 for Linux" release dated 2021-05-21. Fixes ----- BASE: - Fixed Back to back T6 100G-CR4 link coming up with NO FEC sometimes. - [T5] Try to bring up link in 1G speed if link doesn't come up on 10G. - Fixed a bug to not allow BaseR fec in 100G speed. - Fixed linkup issues on BT adapter in 1G and 100M speed. - Fixed an issue to allow driver to send VI_ENABLE multiple times (once with rx disable and then later rx enable). - Fixed rate limiting not working on class number 16 to 30. - Fixed backward compatibility issue in port type interpretation with vpd version 0x80. ETH: - Fixed a case when firmware failed to deliver NIC WR completion to host. - No rate limit support for WR ETH_TX_PKTS2 due to performance reasons. OFLD - Fixed a connection hang in SO adapters when tp_plen_max (set by driver) is more than the window size. - Added fw_filter_vnic_mode to firmware API file (t4fw_interface.h) - Use correct rx channel in coprocessor crypto completion (CPL_FW6_PLD). This was causing out of order completion to host. FOiSCSI - Fixed a crash due to unaligned access of ipv6 address. - Fixed a crash during lun reset. Enhancements ------------ ETH: - Rate limiting support added for encapsulated (vxlan, nvgre, geneve) NIC TCP packets. OFLD: - More than 128 SGLs supported in FW_RI_FR_NSMR_WR. Now, more than 16GB (upto 64GB) of PBLs can be written with single FW_RI_FR_NSMR_WR. Obtained from: Chelsio Communications Sponsored by: Chelsio Communications (cherry picked from commit e0fa04e257c1af4c793a70a124ba41e592570c14) --- sys/conf/files | 6 +++--- sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin | Bin 569856 -> 0 bytes sys/dev/cxgbe/firmware/t4fw-1.25.6.0.bin | Bin 0 -> 570368 bytes sys/dev/cxgbe/firmware/t4fw_interface.h | 23 +++++++++++++---------- sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin | Bin 673792 -> 0 bytes sys/dev/cxgbe/firmware/t5fw-1.25.6.0.bin | Bin 0 -> 675840 bytes sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin | Bin 731648 -> 0 bytes sys/dev/cxgbe/firmware/t6fw-1.25.6.0.bin | Bin 0 -> 730112 bytes sys/modules/cxgbe/t4_firmware/Makefile | 2 +- sys/modules/cxgbe/t5_firmware/Makefile | 2 +- sys/modules/cxgbe/t6_firmware/Makefile | 2 +- 11 files changed, 19 insertions(+), 16 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index 40bba75d4fbc..30f1a0940a8e 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1523,7 +1523,7 @@ t4fw.fwo optional cxgbe \ no-implicit-rule \ clean "t4fw.fwo" t4fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t4fw-1.25.0.40.bin" \ + dependency "$S/dev/cxgbe/firmware/t4fw-1.25.6.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t4fw.fw" @@ -1557,7 +1557,7 @@ t5fw.fwo optional cxgbe \ no-implicit-rule \ clean "t5fw.fwo" t5fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t5fw-1.25.0.40.bin" \ + dependency "$S/dev/cxgbe/firmware/t5fw-1.25.6.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t5fw.fw" @@ -1591,7 +1591,7 @@ t6fw.fwo optional cxgbe \ no-implicit-rule \ clean "t6fw.fwo" t6fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t6fw-1.25.0.40.bin" \ + dependency "$S/dev/cxgbe/firmware/t6fw-1.25.6.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t6fw.fw" diff --git a/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin b/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin deleted file mode 100644 index 075478fdf040..000000000000 Binary files a/sys/dev/cxgbe/firmware/t4fw-1.25.0.40.bin and /dev/null differ diff --git a/sys/dev/cxgbe/firmware/t4fw-1.25.6.0.bin b/sys/dev/cxgbe/firmware/t4fw-1.25.6.0.bin new file mode 100644 index 000000000000..45e805198f59 Binary files /dev/null and b/sys/dev/cxgbe/firmware/t4fw-1.25.6.0.bin differ diff --git a/sys/dev/cxgbe/firmware/t4fw_interface.h b/sys/dev/cxgbe/firmware/t4fw_interface.h index 30a2e1760052..0f877cb5a045 100644 --- a/sys/dev/cxgbe/firmware/t4fw_interface.h +++ b/sys/dev/cxgbe/firmware/t4fw_interface.h @@ -4839,7 +4839,9 @@ enum fw_params_param_dev { FW_PARAMS_PARAM_DEV_TCB_CACHE_FLUSH = 0x2D, FW_PARAMS_PARAM_DEV_FILTER = 0x2E, FW_PARAMS_PARAM_DEV_CLIP2_CMD = 0x2F, + FW_PARAMS_PARAM_DEV_DEV_512SGL_MR = 0x30, FW_PARAMS_PARAM_DEV_KTLS_HW = 0x31, + FW_PARAMS_PARAM_DEV_VI_ENABLE_INGRESS_AFTER_LINKUP = 0x32, }; /* @@ -4874,11 +4876,12 @@ enum fw_params_param_dev_diag { enum fw_params_param_dev_filter{ FW_PARAM_DEV_FILTER_VNIC_MODE = 0x00, FW_PARAM_DEV_FILTER_MODE_MASK = 0x01, +}; - /* VNIC modes */ - FW_VNIC_MODE_PF_VF = 0, - FW_VNIC_MODE_OUTER_VLAN = 1, - FW_VNIC_MODE_ENCAP_EN = 2, +enum fw_filter_vnic_mode { + FW_VNIC_MODE_PF_VF = 0, + FW_VNIC_MODE_OUTER_VLAN = 1, + FW_VNIC_MODE_ENCAP_EN = 2, }; enum fw_params_param_dev_ktls_hw { @@ -9989,18 +9992,18 @@ enum fw_hdr_chip { enum { T4FW_VERSION_MAJOR = 1, T4FW_VERSION_MINOR = 25, - T4FW_VERSION_MICRO = 0, - T4FW_VERSION_BUILD = 40, + T4FW_VERSION_MICRO = 6, + T4FW_VERSION_BUILD = 0, T5FW_VERSION_MAJOR = 1, T5FW_VERSION_MINOR = 25, - T5FW_VERSION_MICRO = 0, - T5FW_VERSION_BUILD = 40, + T5FW_VERSION_MICRO = 6, + T5FW_VERSION_BUILD = 0, T6FW_VERSION_MAJOR = 1, T6FW_VERSION_MINOR = 25, - T6FW_VERSION_MICRO = 0, - T6FW_VERSION_BUILD = 40, + T6FW_VERSION_MICRO = 6, + T6FW_VERSION_BUILD = 0, }; enum { diff --git a/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin b/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin deleted file mode 100644 index 1d115d65a1ba..000000000000 Binary files a/sys/dev/cxgbe/firmware/t5fw-1.25.0.40.bin and /dev/null differ diff --git a/sys/dev/cxgbe/firmware/t5fw-1.25.6.0.bin b/sys/dev/cxgbe/firmware/t5fw-1.25.6.0.bin new file mode 100644 index 000000000000..6c2d1374c87a Binary files /dev/null and b/sys/dev/cxgbe/firmware/t5fw-1.25.6.0.bin differ diff --git a/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin b/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin deleted file mode 100644 index acddb1cf8bfd..000000000000 Binary files a/sys/dev/cxgbe/firmware/t6fw-1.25.0.40.bin and /dev/null differ diff --git a/sys/dev/cxgbe/firmware/t6fw-1.25.6.0.bin b/sys/dev/cxgbe/firmware/t6fw-1.25.6.0.bin new file mode 100644 index 000000000000..1cf05565ffff Binary files /dev/null and b/sys/dev/cxgbe/firmware/t6fw-1.25.6.0.bin differ diff --git a/sys/modules/cxgbe/t4_firmware/Makefile b/sys/modules/cxgbe/t4_firmware/Makefile index f5bc4830771b..48ac2766a560 100644 --- a/sys/modules/cxgbe/t4_firmware/Makefile +++ b/sys/modules/cxgbe/t4_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T4FW_VER= 1.25.0.40 +T4FW_VER= 1.25.6.0 FIRMWS+= t4fw-${T4FW_VER}.bin:t4fw:${T4FW_VER} .include diff --git a/sys/modules/cxgbe/t5_firmware/Makefile b/sys/modules/cxgbe/t5_firmware/Makefile index 89106cb4a497..3b54df8b222b 100644 --- a/sys/modules/cxgbe/t5_firmware/Makefile +++ b/sys/modules/cxgbe/t5_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T5FW_VER= 1.25.0.40 +T5FW_VER= 1.25.6.0 FIRMWS+= t5fw-${T5FW_VER}.bin:t5fw:${T5FW_VER} .include diff --git a/sys/modules/cxgbe/t6_firmware/Makefile b/sys/modules/cxgbe/t6_firmware/Makefile index 071db2bab2dc..e7b39839b5e4 100644 --- a/sys/modules/cxgbe/t6_firmware/Makefile +++ b/sys/modules/cxgbe/t6_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T6FW_VER= 1.25.0.40 +T6FW_VER= 1.25.6.0 FIRMWS+= t6fw-${T6FW_VER}.bin:t6fw:${T6FW_VER} .include From nobody Wed Oct 20 17:39:34 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A396B1812411; Wed, 20 Oct 2021 17:39: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 4HZHtG6C9Sz3Lst; Wed, 20 Oct 2021 17:39: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 8ED5A3AF9; Wed, 20 Oct 2021 17:39: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 19KHdYO0094426; Wed, 20 Oct 2021 17:39:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHdYiY094425; Wed, 20 Oct 2021 17:39:34 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:34 GMT Message-Id: <202110201739.19KHdYiY094425@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: a27e3c20f6e4 - stable/13 - cxgbe(4): Check if the firmware supports 512 SGL per FR MR. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a27e3c20f6e4ce7b396c3f0dd1481313f6f629a7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=a27e3c20f6e4ce7b396c3f0dd1481313f6f629a7 commit a27e3c20f6e4ce7b396c3f0dd1481313f6f629a7 Author: Navdeep Parhar AuthorDate: 2021-06-01 19:14:17 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:31:35 +0000 cxgbe(4): Check if the firmware supports 512 SGL per FR MR. Firmwares >= 1.25.6.0 support 512 SGL entries in a single memory registration request. Obtained from: Chelsio Communications Sponsored by: Chelsio Communications (cherry picked from commit db15dbf8801120241b7bfb6461341f2cb421ef8e) --- sys/dev/cxgbe/common/common.h | 1 + sys/dev/cxgbe/t4_main.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index 6264a7d6ec07..b803a7106a0c 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -405,6 +405,7 @@ struct adapter_params { bool ulptx_memwrite_dsgl; /* use of T5 DSGL allowed */ bool fr_nsmr_tpte_wr_support; /* FW support for FR_NSMR_TPTE_WR */ + bool dev_512sgl_mr; /* FW support for 512 SGL per FR MR */ bool viid_smt_extn_support; /* FW returns vin, vfvld & smt index? */ unsigned int max_pkts_per_eth_tx_pkts_wr; }; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 2d33ba0ab95b..a9579ca874ec 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -5222,6 +5222,14 @@ get_params__post_init(struct adapter *sc) else sc->params.fr_nsmr_tpte_wr_support = false; + /* Support for 512 SGL entries per FR MR. */ + param[0] = FW_PARAM_DEV(DEV_512SGL_MR); + rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); + if (rc == 0) + sc->params.dev_512sgl_mr = val[0] != 0; + else + sc->params.dev_512sgl_mr = false; + param[0] = FW_PARAM_PFVF(MAX_PKTS_PER_ETH_TX_PKTS_WR); rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); if (rc == 0) From nobody Wed Oct 20 17:39:35 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 70E7A18122D0; Wed, 20 Oct 2021 17:39: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 4HZHtJ6hhJz3LZY; Wed, 20 Oct 2021 17:39: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 B45AE3EA4; Wed, 20 Oct 2021 17:39: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 19KHdZPv094450; Wed, 20 Oct 2021 17:39:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHdZf9094449; Wed, 20 Oct 2021 17:39:35 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:35 GMT Message-Id: <202110201739.19KHdZf9094449@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 0c65e339d8c7 - stable/13 - cxgbe/iw_cxgbe: Support for 512 SGL entries in one memory registration. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0c65e339d8c74020024c276f8e9532e549085725 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=0c65e339d8c74020024c276f8e9532e549085725 commit 0c65e339d8c74020024c276f8e9532e549085725 Author: Navdeep Parhar AuthorDate: 2021-06-01 19:57:53 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:32:18 +0000 cxgbe/iw_cxgbe: Support for 512 SGL entries in one memory registration. Use the correct SGL limit within iw_cxgbe, firmwares >= 1.25.6.0 support upto 512 entries per MR. Obtained from: Chelsio Communications Sponsored by: Chelsio Communications (cherry picked from commit 211972cfb816f8da8b8a4c524b44dde4638c3288) --- sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h | 8 ++++++++ sys/dev/cxgbe/iw_cxgbe/mem.c | 3 +-- sys/dev/cxgbe/iw_cxgbe/provider.c | 3 +-- sys/dev/cxgbe/iw_cxgbe/qp.c | 2 +- sys/dev/cxgbe/iw_cxgbe/t4.h | 7 ++----- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h index 1a717d6352c8..59ca38a96004 100644 --- a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h +++ b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h @@ -178,6 +178,14 @@ static inline int c4iw_num_stags(struct c4iw_rdev *rdev) return (int)(rdev->adap->vres.stag.size >> 5); } +static inline int t4_max_fr_depth(struct c4iw_rdev *rdev, bool use_dsgl) +{ + if (rdev->adap->params.ulptx_memwrite_dsgl && use_dsgl) + return rdev->adap->params.dev_512sgl_mr ? T4_MAX_FR_FW_DSGL_DEPTH : T4_MAX_FR_DSGL_DEPTH; + else + return T4_MAX_FR_IMMD_DEPTH; +} + #define C4IW_WR_TO (60*HZ) struct c4iw_wr_wait { diff --git a/sys/dev/cxgbe/iw_cxgbe/mem.c b/sys/dev/cxgbe/iw_cxgbe/mem.c index 3f016c0cc0c1..dab812d58eec 100644 --- a/sys/dev/cxgbe/iw_cxgbe/mem.c +++ b/sys/dev/cxgbe/iw_cxgbe/mem.c @@ -624,8 +624,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, rhp = php->rhp; if (mr_type != IB_MR_TYPE_MEM_REG || - max_num_sg > t4_max_fr_depth( - rhp->rdev.adap->params.ulptx_memwrite_dsgl && use_dsgl)) + max_num_sg > t4_max_fr_depth(&rhp->rdev, use_dsgl)) return ERR_PTR(-EINVAL); mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); diff --git a/sys/dev/cxgbe/iw_cxgbe/provider.c b/sys/dev/cxgbe/iw_cxgbe/provider.c index 53106073d101..02a32fa4c1fc 100644 --- a/sys/dev/cxgbe/iw_cxgbe/provider.c +++ b/sys/dev/cxgbe/iw_cxgbe/provider.c @@ -348,8 +348,7 @@ c4iw_query_device(struct ib_device *ibdev, struct ib_device_attr *props, props->max_mr = c4iw_num_stags(&dev->rdev); props->max_pd = T4_MAX_NUM_PD; props->local_ca_ack_delay = 0; - props->max_fast_reg_page_list_len = - t4_max_fr_depth(sc->params.ulptx_memwrite_dsgl && use_dsgl); + props->max_fast_reg_page_list_len = t4_max_fr_depth(&dev->rdev, use_dsgl); return (0); } diff --git a/sys/dev/cxgbe/iw_cxgbe/qp.c b/sys/dev/cxgbe/iw_cxgbe/qp.c index eb314a6034c8..c1006109762c 100644 --- a/sys/dev/cxgbe/iw_cxgbe/qp.c +++ b/sys/dev/cxgbe/iw_cxgbe/qp.c @@ -714,7 +714,7 @@ static int build_memreg(struct t4_sq *sq, union t4_wr *wqe, int pbllen = roundup(mhp->mpl_len * sizeof(u64), 32); int rem; - if (mhp->mpl_len > t4_max_fr_depth(use_dsgl && dsgl_supported)) + if (mhp->mpl_len > t4_max_fr_depth(&mhp->rhp->rdev, use_dsgl)) return -EINVAL; if (wr->mr->page_size > C4IW_MAX_PAGE_SIZE) return -EINVAL; diff --git a/sys/dev/cxgbe/iw_cxgbe/t4.h b/sys/dev/cxgbe/iw_cxgbe/t4.h index 70385b4ff6b6..88e7d6418615 100644 --- a/sys/dev/cxgbe/iw_cxgbe/t4.h +++ b/sys/dev/cxgbe/iw_cxgbe/t4.h @@ -103,11 +103,8 @@ struct t4_status_page { #define T4_MAX_FR_IMMD_DEPTH (T4_MAX_FR_IMMD / sizeof(u64)) #define T4_MAX_FR_DSGL 1024 #define T4_MAX_FR_DSGL_DEPTH (T4_MAX_FR_DSGL / sizeof(u64)) - -static inline int t4_max_fr_depth(int use_dsgl) -{ - return use_dsgl ? T4_MAX_FR_DSGL_DEPTH : T4_MAX_FR_IMMD_DEPTH; -} +#define T4_MAX_FR_FW_DSGL 4096 +#define T4_MAX_FR_FW_DSGL_DEPTH (T4_MAX_FR_FW_DSGL / sizeof(u64)) #define T4_RQ_NUM_SLOTS 2 #define T4_RQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_RQ_NUM_SLOTS) From nobody Wed Oct 20 17:39:36 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BD2E91812432; Wed, 20 Oct 2021 17:39: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 4HZHtK47cHz3Lns; Wed, 20 Oct 2021 17:39: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 DAA2B39F5; Wed, 20 Oct 2021 17:39: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 19KHdaxt094474; Wed, 20 Oct 2021 17:39:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHda6v094473; Wed, 20 Oct 2021 17:39:36 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:36 GMT Message-Id: <202110201739.19KHda6v094473@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: fa9e240fb06e - stable/13 - cxgbe(4): Get the number of usable traffic classes from the firmware. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fa9e240fb06ef28b1dccef8d2ceb54cd908cbb9f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=fa9e240fb06ef28b1dccef8d2ceb54cd908cbb9f commit fa9e240fb06ef28b1dccef8d2ceb54cd908cbb9f Author: Navdeep Parhar AuthorDate: 2021-06-22 05:07:56 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:33:02 +0000 cxgbe(4): Get the number of usable traffic classes from the firmware. Recent firmwares are able to utilize the traffic classes of tx channels that were previously unused. This effectively doubles the number of traffic classes available per port for 2 port cards. Stop using the raw per-channel value in the driver and ask the firmware for the number of usable traffic classes instead. Sponsored by: Chelsio Communications (cherry picked from commit 6beb67c7e0ad4c3f8277ed1122ef5efcde0a269c) --- sys/dev/cxgbe/common/common.h | 1 + sys/dev/cxgbe/t4_main.c | 12 ++++++++++-- sys/dev/cxgbe/t4_sched.c | 28 ++++++++++++++-------------- sys/dev/cxgbe/tom/t4_cpl_io.c | 4 ++-- sys/dev/cxgbe/tom/t4_tom.c | 11 +++++------ 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index b803a7106a0c..c132cb779204 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -408,6 +408,7 @@ struct adapter_params { bool dev_512sgl_mr; /* FW support for 512 SGL per FR MR */ bool viid_smt_extn_support; /* FW returns vin, vfvld & smt index? */ unsigned int max_pkts_per_eth_tx_pkts_wr; + uint8_t nsched_cls; /* # of usable sched classes per port */ }; #define CHELSIO_T4 0x4 diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index a9579ca874ec..09b4534b1b73 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -5237,6 +5237,14 @@ get_params__post_init(struct adapter *sc) else sc->params.max_pkts_per_eth_tx_pkts_wr = 15; + param[0] = FW_PARAM_DEV(NUM_TM_CLASS); + rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); + if (rc == 0) { + MPASS(val[0] > 0 && val[0] < 256); /* nsched_cls is 8b */ + sc->params.nsched_cls = val[0]; + } else + sc->params.nsched_cls = sc->chip_params->nsched_cls; + /* get capabilites */ bzero(&caps, sizeof(caps)); caps.op_to_write = htobe32(V_FW_CMD_OP(FW_CAPS_CONFIG_CMD) | @@ -7846,7 +7854,7 @@ cxgbe_sysctls(struct port_info *pi) SYSCTL_ADD_UINT(ctx, children2, OID_AUTO, "burstsize", CTLFLAG_RW, &pi->sched_params->burstsize, 0, "burstsize for per-flow cl-rl (0 means up to the driver)"); - for (i = 0; i < sc->chip_params->nsched_cls; i++) { + for (i = 0; i < sc->params.nsched_cls; i++) { struct tx_cl_rl_params *tc = &pi->sched_params->cl_rl[i]; snprintf(name, sizeof(name), "%d", i); @@ -11670,7 +11678,7 @@ error: if ((s->offload != 0 && s->offload != 1) || s->cong_algo < -1 || s->cong_algo > CONG_ALG_HIGHSPEED || s->sched_class < -1 || - s->sched_class >= sc->chip_params->nsched_cls) { + s->sched_class >= sc->params.nsched_cls) { rc = EINVAL; goto error; } diff --git a/sys/dev/cxgbe/t4_sched.c b/sys/dev/cxgbe/t4_sched.c index b320ff4a7c68..827add3c27ec 100644 --- a/sys/dev/cxgbe/t4_sched.c +++ b/sys/dev/cxgbe/t4_sched.c @@ -171,7 +171,7 @@ set_sched_class_params(struct adapter *sc, struct t4_sched_class_params *p, */ if (p->cl < 0) return (EINVAL); - if (!in_range(p->cl, 0, sc->chip_params->nsched_cls - 1)) + if (!in_range(p->cl, 0, sc->params.nsched_cls - 1)) return (ERANGE); } @@ -243,7 +243,7 @@ update_tx_sched(void *context, int pending) struct port_info *pi; struct tx_cl_rl_params *tc; struct adapter *sc = context; - const int n = sc->chip_params->nsched_cls; + const int n = sc->params.nsched_cls; mtx_lock(&sc->tc_lock); for_each_port(sc, i) { @@ -373,7 +373,7 @@ bind_txq_to_traffic_class(struct adapter *sc, struct sge_txq *txq, int idx) txq->tc_idx = old_idx; } done: - MPASS(txq->tc_idx >= -1 && txq->tc_idx < sc->chip_params->nsched_cls); + MPASS(txq->tc_idx >= -1 && txq->tc_idx < sc->params.nsched_cls); mtx_unlock(&sc->tc_lock); return (rc); } @@ -402,7 +402,7 @@ t4_set_sched_queue(struct adapter *sc, struct t4_sched_queue *p) MPASS(vi->ntxq > 0); if (!in_range(p->queue, 0, vi->ntxq - 1) || - !in_range(p->cl, 0, sc->chip_params->nsched_cls - 1)) + !in_range(p->cl, 0, sc->params.nsched_cls - 1)) return (EINVAL); if (p->queue < 0) { @@ -431,7 +431,7 @@ int t4_init_tx_sched(struct adapter *sc) { int i, j; - const int n = sc->chip_params->nsched_cls; + const int n = sc->params.nsched_cls; struct port_info *pi; struct tx_cl_rl_params *tc; @@ -507,7 +507,7 @@ t4_reserve_cl_rl_kbps(struct adapter *sc, int port_id, u_int maxrate, update = false; mtx_lock(&sc->tc_lock); - for (i = 0; i < sc->chip_params->nsched_cls; i++, tc++) { + for (i = 0; i < sc->params.nsched_cls; i++, tc++) { if (fa < 0 && tc->refcount == 0 && !(tc->flags & CLRL_USER)) fa = i; /* first available */ @@ -526,7 +526,7 @@ t4_reserve_cl_rl_kbps(struct adapter *sc, int port_id, u_int maxrate, } } /* Not found */ - MPASS(i == sc->chip_params->nsched_cls); + MPASS(i == sc->params.nsched_cls); if (fa != -1) { tc = &pi->sched_params->cl_rl[fa]; tc->refcount = 1; @@ -557,7 +557,7 @@ t4_release_cl_rl(struct adapter *sc, int port_id, int tc_idx) struct tx_cl_rl_params *tc; MPASS(port_id >= 0 && port_id < sc->params.nports); - MPASS(tc_idx >= 0 && tc_idx < sc->chip_params->nsched_cls); + MPASS(tc_idx >= 0 && tc_idx < sc->params.nsched_cls); mtx_lock(&sc->tc_lock); tc = &sc->port[port_id]->sched_params->cl_rl[tc_idx]; @@ -584,7 +584,7 @@ sysctl_tc(SYSCTL_HANDLER_ARGS) if (sc->flags & IS_VF) return (EPERM); - if (!in_range(tc_idx, 0, sc->chip_params->nsched_cls - 1)) + if (!in_range(tc_idx, 0, sc->params.nsched_cls - 1)) return (EINVAL); return (bind_txq_to_traffic_class(sc, txq, tc_idx)); @@ -610,7 +610,7 @@ sysctl_tc_params(SYSCTL_HANDLER_ARGS) MPASS(port_id < sc->params.nports); MPASS(sc->port[port_id] != NULL); i = arg2 & 0xffff; - MPASS(i < sc->chip_params->nsched_cls); + MPASS(i < sc->params.nsched_cls); mtx_lock(&sc->tc_lock); tc = sc->port[port_id]->sched_params->cl_rl[i]; @@ -772,7 +772,7 @@ cxgbe_rate_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params, (params->rate_limit.max_rate * 8ULL / 1000), &schedcl); if (rc != 0) return (rc); - MPASS(schedcl >= 0 && schedcl < sc->chip_params->nsched_cls); + MPASS(schedcl >= 0 && schedcl < sc->params.nsched_cls); cst = malloc(sizeof(*cst), M_CXGBE, M_ZERO | M_NOWAIT); if (cst == NULL) { @@ -823,7 +823,7 @@ cxgbe_rate_tag_modify(struct m_snd_tag *mst, struct adapter *sc = cst->adapter; /* XXX: is schedcl -1 ok here? */ - MPASS(cst->schedcl >= 0 && cst->schedcl < sc->chip_params->nsched_cls); + MPASS(cst->schedcl >= 0 && cst->schedcl < sc->params.nsched_cls); mtx_lock(&cst->lock); MPASS(cst->flags & EO_SND_TAG_REF); @@ -831,7 +831,7 @@ cxgbe_rate_tag_modify(struct m_snd_tag *mst, (params->rate_limit.max_rate * 8ULL / 1000), &schedcl); if (rc != 0) return (rc); - MPASS(schedcl >= 0 && schedcl < sc->chip_params->nsched_cls); + MPASS(schedcl >= 0 && schedcl < sc->params.nsched_cls); t4_release_cl_rl(sc, cst->port_id, cst->schedcl); cst->schedcl = schedcl; cst->max_rate = params->rate_limit.max_rate; @@ -919,7 +919,7 @@ cxgbe_ratelimit_query(struct ifnet *ifp, struct if_ratelimit_query_results *q) * the card's cclk. */ q->max_flows = sc->tids.netids; - q->number_of_rates = sc->chip_params->nsched_cls; + q->number_of_rates = sc->params.nsched_cls; q->min_segment_burst = 4; /* matches PKTSCHED_BURST in the firmware. */ #if 1 diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index b0b6b6877de6..9168547494f1 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -102,7 +102,7 @@ send_flowc_wr(struct toepcb *toep, struct tcpcb *tp) nparams++; if (toep->params.tc_idx != -1) { MPASS(toep->params.tc_idx >= 0 && - toep->params.tc_idx < sc->chip_params->nsched_cls); + toep->params.tc_idx < sc->params.nsched_cls); nparams++; } @@ -189,7 +189,7 @@ update_tx_rate_limit(struct adapter *sc, struct toepcb *toep, u_int Bps) rc = t4_reserve_cl_rl_kbps(sc, port_id, kbps, &tc_idx); if (rc != 0) return (rc); - MPASS(tc_idx >= 0 && tc_idx < sc->chip_params->nsched_cls); + MPASS(tc_idx >= 0 && tc_idx < sc->params.nsched_cls); } if (toep->params.tc_idx != tc_idx) { diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c index cccaa6b1cc0d..d4a995a5559a 100644 --- a/sys/dev/cxgbe/tom/t4_tom.c +++ b/sys/dev/cxgbe/tom/t4_tom.c @@ -167,7 +167,7 @@ init_toepcb(struct vi_info *vi, struct toepcb *toep) struct adapter *sc = pi->adapter; struct tx_cl_rl_params *tc; - if (cp->tc_idx >= 0 && cp->tc_idx < sc->chip_params->nsched_cls) { + if (cp->tc_idx >= 0 && cp->tc_idx < sc->params.nsched_cls) { tc = &pi->sched_params->cl_rl[cp->tc_idx]; mtx_lock(&sc->tc_lock); if (tc->flags & CLRL_ERR) { @@ -1153,11 +1153,10 @@ init_conn_params(struct vi_info *vi , struct offload_settings *s, } /* Tx traffic scheduling class. */ - if (s->sched_class >= 0 && - s->sched_class < sc->chip_params->nsched_cls) { - cp->tc_idx = s->sched_class; - } else - cp->tc_idx = -1; + if (s->sched_class >= 0 && s->sched_class < sc->params.nsched_cls) + cp->tc_idx = s->sched_class; + else + cp->tc_idx = -1; /* Nagle's algorithm. */ if (s->nagle >= 0) From nobody Wed Oct 20 17:39:37 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 54F6518122E3; Wed, 20 Oct 2021 17:39: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 4HZHtL40nMz3Lqb; Wed, 20 Oct 2021 17:39: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 E40903F0E; Wed, 20 Oct 2021 17:39: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 19KHdbEg094498; Wed, 20 Oct 2021 17:39:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHdbt9094497; Wed, 20 Oct 2021 17:39:37 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:37 GMT Message-Id: <202110201739.19KHdbt9094497@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: f7b50d986cb5 - stable/13 - cxgbe(4): Do not configure traffic classes automatically on attach. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f7b50d986cb5a34757b1f636d90b543b6556ed95 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=f7b50d986cb5a34757b1f636d90b543b6556ed95 commit f7b50d986cb5a34757b1f636d90b543b6556ed95 Author: Navdeep Parhar AuthorDate: 2021-06-24 20:05:57 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:35:14 +0000 cxgbe(4): Do not configure traffic classes automatically on attach. The driver used to configure all available classes with some default parameters on attach and the rest of t4_sched.c was written with the assumption that all traffic classes are always valid in the hardware. But this resulted in a lot of informational messages being logged in the firmware's circular log, crowding out other more useful messages. This change leaves the tx scheduler alone during attach to reduce the spam in the devlog. The state of every class is now tracked separately from its flags and there is support for an 'uninitialized' state. Sponsored by: Chelsio Communications (cherry picked from commit ec8004dd419d8c8acfc9025dd050f141c949d53a) --- sys/dev/cxgbe/adapter.h | 16 ++++-- sys/dev/cxgbe/t4_main.c | 4 +- sys/dev/cxgbe/t4_sched.c | 135 +++++++++++++++++++++++++++------------------ sys/dev/cxgbe/tom/t4_tom.c | 9 ++- 4 files changed, 101 insertions(+), 63 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 630e9c4ac1b9..a394e8f11017 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -258,14 +258,22 @@ struct tx_ch_rl_params { uint32_t maxrate; }; +/* CLRL state */ +enum clrl_state { + CS_UNINITIALIZED = 0, + CS_PARAMS_SET, /* sw parameters have been set. */ + CS_HW_UPDATE_REQUESTED, /* async HW update requested. */ + CS_HW_UPDATE_IN_PROGRESS, /* sync hw update in progress. */ + CS_HW_CONFIGURED /* configured in the hardware. */ +}; + +/* CLRL flags */ enum { - CLRL_USER = (1 << 0), /* allocated manually. */ - CLRL_SYNC = (1 << 1), /* sync hw update in progress. */ - CLRL_ASYNC = (1 << 2), /* async hw update requested. */ - CLRL_ERR = (1 << 3), /* last hw setup ended in error. */ + CF_USER = (1 << 0), /* was configured by driver ioctl. */ }; struct tx_cl_rl_params { + enum clrl_state state; int refcount; uint8_t flags; enum fw_sched_params_rate ratemode; /* %port REL or ABS value */ diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 09b4534b1b73..2fa54909aa5a 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -7784,7 +7784,7 @@ cxgbe_sysctls(struct port_info *pi) struct adapter *sc = pi->adapter; int i; char name[16]; - static char *tc_flags = {"\20\1USER\2SYNC\3ASYNC\4ERR"}; + static char *tc_flags = {"\20\1USER"}; ctx = device_get_sysctl_ctx(pi->dev); @@ -7861,6 +7861,8 @@ cxgbe_sysctls(struct port_info *pi) children2 = SYSCTL_CHILDREN(SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "traffic class")); + SYSCTL_ADD_UINT(ctx, children2, OID_AUTO, "state", + CTLFLAG_RD, &tc->state, 0, "current state"); SYSCTL_ADD_PROC(ctx, children2, OID_AUTO, "flags", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, tc_flags, (uintptr_t)&tc->flags, sysctl_bitfield_8b, "A", "flags"); diff --git a/sys/dev/cxgbe/t4_sched.c b/sys/dev/cxgbe/t4_sched.c index 827add3c27ec..b19e62474bbb 100644 --- a/sys/dev/cxgbe/t4_sched.c +++ b/sys/dev/cxgbe/t4_sched.c @@ -185,17 +185,19 @@ set_sched_class_params(struct adapter *sc, struct t4_sched_class_params *p, if (p->level == SCHED_CLASS_LEVEL_CL_RL) { tc = &pi->sched_params->cl_rl[p->cl]; mtx_lock(&sc->tc_lock); - if (tc->refcount > 0 || tc->flags & (CLRL_SYNC | CLRL_ASYNC)) + if (tc->refcount > 0 || tc->state == CS_HW_UPDATE_IN_PROGRESS) rc = EBUSY; else { - tc->flags |= CLRL_SYNC | CLRL_USER; + old = *tc; + + tc->flags |= CF_USER; + tc->state = CS_HW_UPDATE_IN_PROGRESS; tc->ratemode = fw_ratemode; tc->rateunit = fw_rateunit; tc->mode = fw_mode; tc->maxrate = p->maxrate; tc->pktsize = p->pktsize; rc = 0; - old= *tc; } mtx_unlock(&sc->tc_lock); if (rc != 0) @@ -207,6 +209,9 @@ set_sched_class_params(struct adapter *sc, struct t4_sched_class_params *p, if (rc != 0) { if (p->level == SCHED_CLASS_LEVEL_CL_RL) { mtx_lock(&sc->tc_lock); + MPASS(tc->refcount == 0); + MPASS(tc->flags & CF_USER); + MPASS(tc->state == CS_HW_UPDATE_IN_PROGRESS); *tc = old; mtx_unlock(&sc->tc_lock); } @@ -221,15 +226,23 @@ set_sched_class_params(struct adapter *sc, struct t4_sched_class_params *p, if (p->level == SCHED_CLASS_LEVEL_CL_RL) { mtx_lock(&sc->tc_lock); - MPASS(tc->flags & CLRL_SYNC); - MPASS(tc->flags & CLRL_USER); MPASS(tc->refcount == 0); + MPASS(tc->flags & CF_USER); + MPASS(tc->state == CS_HW_UPDATE_IN_PROGRESS); - tc->flags &= ~CLRL_SYNC; if (rc == 0) - tc->flags &= ~CLRL_ERR; - else - tc->flags |= CLRL_ERR; + tc->state = CS_HW_CONFIGURED; + else { + /* parameters failed so we don't park at params_set */ + tc->state = CS_UNINITIALIZED; + tc->flags &= ~CF_USER; + CH_ERR(pi, "failed to configure traffic class %d: %d. " + "params: mode %d, rateunit %d, ratemode %d, " + "channel %d, minrate %d, maxrate %d, pktsize %d, " + "burstsize %d\n", p->cl, rc, fw_mode, fw_rateunit, + fw_ratemode, p->channel, p->minrate, p->maxrate, + p->pktsize, 0); + } mtx_unlock(&sc->tc_lock); } @@ -251,7 +264,7 @@ update_tx_sched(void *context, int pending) tc = &pi->sched_params->cl_rl[0]; for (j = 0; j < n; j++, tc++) { MPASS(mtx_owned(&sc->tc_lock)); - if ((tc->flags & CLRL_ASYNC) == 0) + if (tc->state != CS_HW_UPDATE_REQUESTED) continue; mtx_unlock(&sc->tc_lock); @@ -267,12 +280,22 @@ update_tx_sched(void *context, int pending) end_synchronized_op(sc, 0); mtx_lock(&sc->tc_lock); - MPASS(tc->flags & CLRL_ASYNC); - tc->flags &= ~CLRL_ASYNC; - if (rc == 0) - tc->flags &= ~CLRL_ERR; + MPASS(tc->state == CS_HW_UPDATE_REQUESTED); + if (rc == 0) { + tc->state = CS_HW_CONFIGURED; + continue; + } + /* parameters failed so we try to avoid params_set */ + if (tc->refcount > 0) + tc->state = CS_PARAMS_SET; else - tc->flags |= CLRL_ERR; + tc->state = CS_UNINITIALIZED; + CH_ERR(pi, "failed to configure traffic class %d: %d. " + "params: mode %d, rateunit %d, ratemode %d, " + "channel %d, minrate %d, maxrate %d, pktsize %d, " + "burstsize %d\n", j, rc, tc->mode, tc->rateunit, + tc->ratemode, pi->tx_chan, 0, tc->maxrate, + tc->pktsize, tc->burstsize); } } mtx_unlock(&sc->tc_lock); @@ -320,7 +343,7 @@ bind_txq_to_traffic_class(struct adapter *sc, struct sge_txq *txq, int idx) * Bind to a different class at index idx. */ tc = &tc0[idx]; - if (tc->flags & CLRL_ERR) { + if (tc->state != CS_HW_CONFIGURED) { rc = ENXIO; goto done; } else { @@ -338,14 +361,15 @@ bind_txq_to_traffic_class(struct adapter *sc, struct sge_txq *txq, int idx) mtx_unlock(&sc->tc_lock); rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4btxq"); - if (rc != 0) - return (rc); - fw_mnem = (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) | - V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH) | - V_FW_PARAMS_PARAM_YZ(txq->eq.cntxt_id)); - fw_class = idx < 0 ? 0xffffffff : idx; - rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &fw_mnem, &fw_class); - end_synchronized_op(sc, 0); + if (rc == 0) { + fw_mnem = (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH) | + V_FW_PARAMS_PARAM_YZ(txq->eq.cntxt_id)); + fw_class = idx < 0 ? 0xffffffff : idx; + rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &fw_mnem, + &fw_class); + end_synchronized_op(sc, 0); + } mtx_lock(&sc->tc_lock); MPASS(txq->tc_idx == -2); @@ -430,29 +454,16 @@ t4_set_sched_queue(struct adapter *sc, struct t4_sched_queue *p) int t4_init_tx_sched(struct adapter *sc) { - int i, j; + int i; const int n = sc->params.nsched_cls; struct port_info *pi; - struct tx_cl_rl_params *tc; mtx_init(&sc->tc_lock, "tx_sched lock", NULL, MTX_DEF); TASK_INIT(&sc->tc_task, 0, update_tx_sched, sc); for_each_port(sc, i) { pi = sc->port[i]; pi->sched_params = malloc(sizeof(*pi->sched_params) + - n * sizeof(*tc), M_CXGBE, M_ZERO | M_WAITOK); - tc = &pi->sched_params->cl_rl[0]; - for (j = 0; j < n; j++, tc++) { - tc->refcount = 0; - tc->ratemode = FW_SCHED_PARAMS_RATE_ABS; - tc->rateunit = FW_SCHED_PARAMS_UNIT_BITRATE; - tc->mode = FW_SCHED_PARAMS_MODE_CLASS; - tc->maxrate = 1000 * 1000; /* 1 Gbps. Arbitrary */ - - if (t4_sched_params_cl_rl_kbps(sc, pi->tx_chan, j, - tc->mode, tc->maxrate, tc->pktsize, 1) != 0) - tc->flags = CLRL_ERR; - } + n * sizeof(struct tx_cl_rl_params), M_CXGBE, M_ZERO | M_WAITOK); } return (0); @@ -487,7 +498,7 @@ int t4_reserve_cl_rl_kbps(struct adapter *sc, int port_id, u_int maxrate, int *tc_idx) { - int rc = 0, fa = -1, i, pktsize, burstsize; + int rc = 0, fa, fa2, i, pktsize, burstsize; bool update; struct tx_cl_rl_params *tc; struct port_info *pi; @@ -506,30 +517,47 @@ t4_reserve_cl_rl_kbps(struct adapter *sc, int port_id, u_int maxrate, tc = &pi->sched_params->cl_rl[0]; update = false; + fa = fa2 = -1; mtx_lock(&sc->tc_lock); for (i = 0; i < sc->params.nsched_cls; i++, tc++) { - if (fa < 0 && tc->refcount == 0 && !(tc->flags & CLRL_USER)) - fa = i; /* first available */ - - if (tc->ratemode == FW_SCHED_PARAMS_RATE_ABS && + if (tc->state >= CS_PARAMS_SET && + tc->ratemode == FW_SCHED_PARAMS_RATE_ABS && tc->rateunit == FW_SCHED_PARAMS_UNIT_BITRATE && tc->mode == FW_SCHED_PARAMS_MODE_FLOW && tc->maxrate == maxrate && tc->pktsize == pktsize && tc->burstsize == burstsize) { tc->refcount++; *tc_idx = i; - if ((tc->flags & (CLRL_ERR | CLRL_ASYNC | CLRL_SYNC)) == - CLRL_ERR) { + if (tc->state == CS_PARAMS_SET) { + tc->state = CS_HW_UPDATE_REQUESTED; update = true; } goto done; } + + if (fa < 0 && tc->state == CS_UNINITIALIZED) { + MPASS(tc->refcount == 0); + fa = i; /* first available, never used. */ + } + if (fa2 < 0 && tc->refcount == 0 && !(tc->flags & CF_USER)) { + fa2 = i; /* first available, used previously. */ + } } /* Not found */ MPASS(i == sc->params.nsched_cls); - if (fa != -1) { + if (fa == -1) + fa = fa2; + if (fa == -1) { + *tc_idx = -1; + rc = ENOSPC; + } else { + MPASS(fa >= 0 && fa < sc->params.nsched_cls); tc = &pi->sched_params->cl_rl[fa]; + MPASS(!(tc->flags & CF_USER)); + MPASS(tc->refcount == 0); + tc->refcount = 1; + tc->state = CS_HW_UPDATE_REQUESTED; tc->ratemode = FW_SCHED_PARAMS_RATE_ABS; tc->rateunit = FW_SCHED_PARAMS_UNIT_BITRATE; tc->mode = FW_SCHED_PARAMS_MODE_FLOW; @@ -538,16 +566,11 @@ t4_reserve_cl_rl_kbps(struct adapter *sc, int port_id, u_int maxrate, tc->burstsize = burstsize; *tc_idx = fa; update = true; - } else { - *tc_idx = -1; - rc = ENOSPC; } done: mtx_unlock(&sc->tc_lock); - if (update) { - tc->flags |= CLRL_ASYNC; + if (update) t4_update_tx_sched(sc); - } return (rc); } @@ -616,6 +639,11 @@ sysctl_tc_params(SYSCTL_HANDLER_ARGS) tc = sc->port[port_id]->sched_params->cl_rl[i]; mtx_unlock(&sc->tc_lock); + if (tc.state < CS_PARAMS_SET) { + sbuf_printf(sb, "uninitialized"); + goto done; + } + switch (tc.rateunit) { case SCHED_CLASS_RATEUNIT_BITS: switch (tc.ratemode) { @@ -649,6 +677,7 @@ sysctl_tc_params(SYSCTL_HANDLER_ARGS) switch (tc.mode) { case SCHED_CLASS_MODE_CLASS: + /* Note that pktsize and burstsize are not used in this mode. */ sbuf_printf(sb, " aggregate"); break; case SCHED_CLASS_MODE_FLOW: diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c index d4a995a5559a..fe0ebfbd832b 100644 --- a/sys/dev/cxgbe/tom/t4_tom.c +++ b/sys/dev/cxgbe/tom/t4_tom.c @@ -170,11 +170,10 @@ init_toepcb(struct vi_info *vi, struct toepcb *toep) if (cp->tc_idx >= 0 && cp->tc_idx < sc->params.nsched_cls) { tc = &pi->sched_params->cl_rl[cp->tc_idx]; mtx_lock(&sc->tc_lock); - if (tc->flags & CLRL_ERR) { - log(LOG_ERR, - "%s: failed to associate traffic class %u with tid %u\n", - device_get_nameunit(vi->dev), cp->tc_idx, - toep->tid); + if (tc->state != CS_HW_CONFIGURED) { + CH_ERR(vi, "tid %d cannot be bound to traffic class %d " + "because it is not configured (its state is %d)\n", + toep->tid, cp->tc_idx, tc->state); cp->tc_idx = -1; } else { tc->refcount++; From nobody Wed Oct 20 17:39:40 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 20D1E1812783; Wed, 20 Oct 2021 17:39: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 4HZHtP0gHrz3LpG; Wed, 20 Oct 2021 17:39: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 8088E3F0F; Wed, 20 Oct 2021 17:39: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 19KHde17094552; Wed, 20 Oct 2021 17:39:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHdeT1094551; Wed, 20 Oct 2021 17:39:40 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:40 GMT Message-Id: <202110201739.19KHdeT1094551@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: bcb2da3a6212 - stable/13 - cxgbe(4): Update firmwares to 1.26.2.0. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bcb2da3a621273eeaf36342e0f786191f78ea3de Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=bcb2da3a621273eeaf36342e0f786191f78ea3de commit bcb2da3a621273eeaf36342e0f786191f78ea3de Author: Navdeep Parhar AuthorDate: 2021-09-27 23:45:56 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:36:34 +0000 cxgbe(4): Update firmwares to 1.26.2.0. The firmwares and the following changelog are from the "Chelsio Unified Wire v3.15.0.0 for Linux." Version : 1.26.2.0 Date : 09/24/2021 ==================== FIXES ----- BASE: - Added support for SFP+ RJ45 (0x1C). - Fixing backward compatibility issue with older drivers when multiple speeds are passed to firmware. OFLD: - Do not touch tp_plen_max if driver is supplying tp_plen_max. This fixes a connection reset issue in iscsi. ENHANCEMENTS ------------ BASE: - Firmware header modified to add firmware binary signature. Sponsored by: Chelsio Communications (cherry picked from commit 45d6fbaec23eee457197a14517e715c947114d99) --- sys/conf/files | 6 +++--- .../{t4fw-1.26.0.0.bin => t4fw-1.26.2.0.bin} | Bin 570368 -> 570368 bytes sys/dev/cxgbe/firmware/t4fw_interface.h | 12 ++++++++---- .../{t5fw-1.26.0.0.bin => t5fw-1.26.2.0.bin} | Bin 675840 -> 676352 bytes .../{t6fw-1.26.0.0.bin => t6fw-1.26.2.0.bin} | Bin 729088 -> 729088 bytes sys/modules/cxgbe/t4_firmware/Makefile | 2 +- sys/modules/cxgbe/t5_firmware/Makefile | 2 +- sys/modules/cxgbe/t6_firmware/Makefile | 2 +- 8 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index 889e0289dfa8..2d3ae104753d 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1523,7 +1523,7 @@ t4fw.fwo optional cxgbe \ no-implicit-rule \ clean "t4fw.fwo" t4fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t4fw-1.26.0.0.bin" \ + dependency "$S/dev/cxgbe/firmware/t4fw-1.26.2.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t4fw.fw" @@ -1557,7 +1557,7 @@ t5fw.fwo optional cxgbe \ no-implicit-rule \ clean "t5fw.fwo" t5fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t5fw-1.26.0.0.bin" \ + dependency "$S/dev/cxgbe/firmware/t5fw-1.26.2.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t5fw.fw" @@ -1591,7 +1591,7 @@ t6fw.fwo optional cxgbe \ no-implicit-rule \ clean "t6fw.fwo" t6fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t6fw-1.26.0.0.bin" \ + dependency "$S/dev/cxgbe/firmware/t6fw-1.26.2.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t6fw.fw" diff --git a/sys/dev/cxgbe/firmware/t4fw-1.26.0.0.bin b/sys/dev/cxgbe/firmware/t4fw-1.26.2.0.bin similarity index 57% rename from sys/dev/cxgbe/firmware/t4fw-1.26.0.0.bin rename to sys/dev/cxgbe/firmware/t4fw-1.26.2.0.bin index 04e96d16c57a..a8f611628dcc 100644 Binary files a/sys/dev/cxgbe/firmware/t4fw-1.26.0.0.bin and b/sys/dev/cxgbe/firmware/t4fw-1.26.2.0.bin differ diff --git a/sys/dev/cxgbe/firmware/t4fw_interface.h b/sys/dev/cxgbe/firmware/t4fw_interface.h index acb7a6481d9c..876fd61b4b21 100644 --- a/sys/dev/cxgbe/firmware/t4fw_interface.h +++ b/sys/dev/cxgbe/firmware/t4fw_interface.h @@ -9952,7 +9952,10 @@ struct fw_hdr { __u32 reserved3; __be32 magic; /* runtime or bootstrap fw */ __be32 flags; - __be32 reserved6[23]; + __be32 reserved6[4]; + __u8 reserved7[3]; + __u8 dsign_len; + __u8 dsign[72]; /* fw binary digital signature */ }; enum fw_hdr_chip { @@ -9992,17 +9995,17 @@ enum fw_hdr_chip { enum { T4FW_VERSION_MAJOR = 1, T4FW_VERSION_MINOR = 26, - T4FW_VERSION_MICRO = 0, + T4FW_VERSION_MICRO = 2, T4FW_VERSION_BUILD = 0, T5FW_VERSION_MAJOR = 1, T5FW_VERSION_MINOR = 26, - T5FW_VERSION_MICRO = 0, + T5FW_VERSION_MICRO = 2, T5FW_VERSION_BUILD = 0, T6FW_VERSION_MAJOR = 1, T6FW_VERSION_MINOR = 26, - T6FW_VERSION_MICRO = 0, + T6FW_VERSION_MICRO = 2, T6FW_VERSION_BUILD = 0, }; @@ -10052,6 +10055,7 @@ enum { enum fw_hdr_flags { FW_HDR_FLAGS_RESET_HALT = 0x00000001, + FW_HDR_FLAGS_SIGNED_FW = 0x00000002, }; /* diff --git a/sys/dev/cxgbe/firmware/t5fw-1.26.0.0.bin b/sys/dev/cxgbe/firmware/t5fw-1.26.2.0.bin similarity index 55% rename from sys/dev/cxgbe/firmware/t5fw-1.26.0.0.bin rename to sys/dev/cxgbe/firmware/t5fw-1.26.2.0.bin index f72bd502ea1f..b11d6d0bf49f 100644 Binary files a/sys/dev/cxgbe/firmware/t5fw-1.26.0.0.bin and b/sys/dev/cxgbe/firmware/t5fw-1.26.2.0.bin differ diff --git a/sys/dev/cxgbe/firmware/t6fw-1.26.0.0.bin b/sys/dev/cxgbe/firmware/t6fw-1.26.2.0.bin similarity index 61% rename from sys/dev/cxgbe/firmware/t6fw-1.26.0.0.bin rename to sys/dev/cxgbe/firmware/t6fw-1.26.2.0.bin index ee4341d5074f..f43d9953a7a4 100644 Binary files a/sys/dev/cxgbe/firmware/t6fw-1.26.0.0.bin and b/sys/dev/cxgbe/firmware/t6fw-1.26.2.0.bin differ diff --git a/sys/modules/cxgbe/t4_firmware/Makefile b/sys/modules/cxgbe/t4_firmware/Makefile index a202c5d2a6a0..e525edf96ce2 100644 --- a/sys/modules/cxgbe/t4_firmware/Makefile +++ b/sys/modules/cxgbe/t4_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T4FW_VER= 1.26.0.0 +T4FW_VER= 1.26.2.0 FIRMWS+= t4fw-${T4FW_VER}.bin:t4fw:${T4FW_VER} .include diff --git a/sys/modules/cxgbe/t5_firmware/Makefile b/sys/modules/cxgbe/t5_firmware/Makefile index 371df89f233b..74e89e4174b5 100644 --- a/sys/modules/cxgbe/t5_firmware/Makefile +++ b/sys/modules/cxgbe/t5_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T5FW_VER= 1.26.0.0 +T5FW_VER= 1.26.2.0 FIRMWS+= t5fw-${T5FW_VER}.bin:t5fw:${T5FW_VER} .include diff --git a/sys/modules/cxgbe/t6_firmware/Makefile b/sys/modules/cxgbe/t6_firmware/Makefile index 074c3991bc37..2ea01e7b776a 100644 --- a/sys/modules/cxgbe/t6_firmware/Makefile +++ b/sys/modules/cxgbe/t6_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T6FW_VER= 1.26.0.0 +T6FW_VER= 1.26.2.0 FIRMWS+= t6fw-${T6FW_VER}.bin:t6fw:${T6FW_VER} .include From nobody Wed Oct 20 17:39:39 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3E58E1812786; Wed, 20 Oct 2021 17:39: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 4HZHtN48Q6z3Llb; Wed, 20 Oct 2021 17:39: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 428D93EA5; Wed, 20 Oct 2021 17:39: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 19KHddUS094524; Wed, 20 Oct 2021 17:39:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHddHA094523; Wed, 20 Oct 2021 17:39:39 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:39:39 GMT Message-Id: <202110201739.19KHddHA094523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: c1f66d325a56 - stable/13 - cxgbe(4): Update firmwares to 1.26.0.0. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c1f66d325a56c94b8aa384073c561a88dc9e25f9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=c1f66d325a56c94b8aa384073c561a88dc9e25f9 commit c1f66d325a56c94b8aa384073c561a88dc9e25f9 Author: Navdeep Parhar AuthorDate: 2021-06-24 20:21:51 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:35:56 +0000 cxgbe(4): Update firmwares to 1.26.0.0. Changes since 1.25.6.0 are listed here. This list comes from the Release Notes for "Chelsio Unified Wire 3.14.0.4 for Linux" dated 2021-07-08. Fixes ----- BASE: - Wait 5ms before and after the i2c command that clears the mod_select. This fixes incorrect port module type read from i2c. Obtained from: Chelsio Communications Sponsored by: Chelsio Communications (cherry picked from commit 3c900106ea7aab69690945ad885b4df1095c1504) --- sys/conf/files | 6 +++--- .../{t4fw-1.25.6.0.bin => t4fw-1.26.0.0.bin} | Bin 570368 -> 570368 bytes sys/dev/cxgbe/firmware/t4fw_interface.h | 12 ++++++------ .../{t5fw-1.25.6.0.bin => t5fw-1.26.0.0.bin} | Bin 675840 -> 675840 bytes .../{t6fw-1.25.6.0.bin => t6fw-1.26.0.0.bin} | Bin 730112 -> 729088 bytes sys/modules/cxgbe/t4_firmware/Makefile | 2 +- sys/modules/cxgbe/t5_firmware/Makefile | 2 +- sys/modules/cxgbe/t6_firmware/Makefile | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index 30f1a0940a8e..889e0289dfa8 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1523,7 +1523,7 @@ t4fw.fwo optional cxgbe \ no-implicit-rule \ clean "t4fw.fwo" t4fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t4fw-1.25.6.0.bin" \ + dependency "$S/dev/cxgbe/firmware/t4fw-1.26.0.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t4fw.fw" @@ -1557,7 +1557,7 @@ t5fw.fwo optional cxgbe \ no-implicit-rule \ clean "t5fw.fwo" t5fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t5fw-1.25.6.0.bin" \ + dependency "$S/dev/cxgbe/firmware/t5fw-1.26.0.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t5fw.fw" @@ -1591,7 +1591,7 @@ t6fw.fwo optional cxgbe \ no-implicit-rule \ clean "t6fw.fwo" t6fw.fw optional cxgbe \ - dependency "$S/dev/cxgbe/firmware/t6fw-1.25.6.0.bin" \ + dependency "$S/dev/cxgbe/firmware/t6fw-1.26.0.0.bin" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t6fw.fw" diff --git a/sys/dev/cxgbe/firmware/t4fw-1.25.6.0.bin b/sys/dev/cxgbe/firmware/t4fw-1.26.0.0.bin similarity index 77% rename from sys/dev/cxgbe/firmware/t4fw-1.25.6.0.bin rename to sys/dev/cxgbe/firmware/t4fw-1.26.0.0.bin index 45e805198f59..04e96d16c57a 100644 Binary files a/sys/dev/cxgbe/firmware/t4fw-1.25.6.0.bin and b/sys/dev/cxgbe/firmware/t4fw-1.26.0.0.bin differ diff --git a/sys/dev/cxgbe/firmware/t4fw_interface.h b/sys/dev/cxgbe/firmware/t4fw_interface.h index 0f877cb5a045..acb7a6481d9c 100644 --- a/sys/dev/cxgbe/firmware/t4fw_interface.h +++ b/sys/dev/cxgbe/firmware/t4fw_interface.h @@ -9991,18 +9991,18 @@ enum fw_hdr_chip { enum { T4FW_VERSION_MAJOR = 1, - T4FW_VERSION_MINOR = 25, - T4FW_VERSION_MICRO = 6, + T4FW_VERSION_MINOR = 26, + T4FW_VERSION_MICRO = 0, T4FW_VERSION_BUILD = 0, T5FW_VERSION_MAJOR = 1, - T5FW_VERSION_MINOR = 25, - T5FW_VERSION_MICRO = 6, + T5FW_VERSION_MINOR = 26, + T5FW_VERSION_MICRO = 0, T5FW_VERSION_BUILD = 0, T6FW_VERSION_MAJOR = 1, - T6FW_VERSION_MINOR = 25, - T6FW_VERSION_MICRO = 6, + T6FW_VERSION_MINOR = 26, + T6FW_VERSION_MICRO = 0, T6FW_VERSION_BUILD = 0, }; diff --git a/sys/dev/cxgbe/firmware/t5fw-1.25.6.0.bin b/sys/dev/cxgbe/firmware/t5fw-1.26.0.0.bin similarity index 72% rename from sys/dev/cxgbe/firmware/t5fw-1.25.6.0.bin rename to sys/dev/cxgbe/firmware/t5fw-1.26.0.0.bin index 6c2d1374c87a..f72bd502ea1f 100644 Binary files a/sys/dev/cxgbe/firmware/t5fw-1.25.6.0.bin and b/sys/dev/cxgbe/firmware/t5fw-1.26.0.0.bin differ diff --git a/sys/dev/cxgbe/firmware/t6fw-1.25.6.0.bin b/sys/dev/cxgbe/firmware/t6fw-1.26.0.0.bin similarity index 61% rename from sys/dev/cxgbe/firmware/t6fw-1.25.6.0.bin rename to sys/dev/cxgbe/firmware/t6fw-1.26.0.0.bin index 1cf05565ffff..ee4341d5074f 100644 Binary files a/sys/dev/cxgbe/firmware/t6fw-1.25.6.0.bin and b/sys/dev/cxgbe/firmware/t6fw-1.26.0.0.bin differ diff --git a/sys/modules/cxgbe/t4_firmware/Makefile b/sys/modules/cxgbe/t4_firmware/Makefile index 48ac2766a560..a202c5d2a6a0 100644 --- a/sys/modules/cxgbe/t4_firmware/Makefile +++ b/sys/modules/cxgbe/t4_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T4FW_VER= 1.25.6.0 +T4FW_VER= 1.26.0.0 FIRMWS+= t4fw-${T4FW_VER}.bin:t4fw:${T4FW_VER} .include diff --git a/sys/modules/cxgbe/t5_firmware/Makefile b/sys/modules/cxgbe/t5_firmware/Makefile index 3b54df8b222b..371df89f233b 100644 --- a/sys/modules/cxgbe/t5_firmware/Makefile +++ b/sys/modules/cxgbe/t5_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T5FW_VER= 1.25.6.0 +T5FW_VER= 1.26.0.0 FIRMWS+= t5fw-${T5FW_VER}.bin:t5fw:${T5FW_VER} .include diff --git a/sys/modules/cxgbe/t6_firmware/Makefile b/sys/modules/cxgbe/t6_firmware/Makefile index e7b39839b5e4..074c3991bc37 100644 --- a/sys/modules/cxgbe/t6_firmware/Makefile +++ b/sys/modules/cxgbe/t6_firmware/Makefile @@ -17,7 +17,7 @@ FIRMWS+= ${F}:${F:C/.txt//}:1.0.0.0 .endif .endfor -T6FW_VER= 1.25.6.0 +T6FW_VER= 1.26.0.0 FIRMWS+= t6fw-${T6FW_VER}.bin:t6fw:${T6FW_VER} .include From nobody Wed Oct 20 17:47:51 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1679C181671A; Wed, 20 Oct 2021 17:47: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 4HZJ3r0716z3R7j; Wed, 20 Oct 2021 17:47: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 D811E4183; Wed, 20 Oct 2021 17:47: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 19KHlpBn007700; Wed, 20 Oct 2021 17:47:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHlp5i007699; Wed, 20 Oct 2021 17:47:51 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:47:51 GMT Message-Id: <202110201747.19KHlp5i007699@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 0ab62c8abacb - stable/13 - cxgbe(4): Skip a few more T5/T6 registers during a regdump. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0ab62c8abacb2e0d5336a247b4ba966ea48597ee Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=0ab62c8abacb2e0d5336a247b4ba966ea48597ee commit 0ab62c8abacb2e0d5336a247b4ba966ea48597ee Author: Navdeep Parhar AuthorDate: 2021-07-13 23:38:55 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:42:55 +0000 cxgbe(4): Skip a few more T5/T6 registers during a regdump. These registers have read side effects and a read at just the right (wrong?) time can trash some internal hw state. Obtained from: Chelsio Communications Sponsored by: Chelsio Communications (cherry picked from commit f13920b39b8b500a17fc276629d70828f9f2d4b1) --- sys/dev/cxgbe/common/t4_hw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index bb08c55c87b2..f06b21120061 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -1373,7 +1373,8 @@ void t4_get_regs(struct adapter *adap, u8 *buf, size_t buf_size) 0xdfc0, 0xdfe0, 0xe000, 0x1106c, 0x11074, 0x11088, - 0x1109c, 0x1117c, + 0x1109c, 0x11110, + 0x11118, 0x1117c, 0x11190, 0x11204, 0x19040, 0x1906c, 0x19078, 0x19080, @@ -2082,7 +2083,8 @@ void t4_get_regs(struct adapter *adap, u8 *buf, size_t buf_size) 0x1190, 0x1194, 0x11a0, 0x11a4, 0x11b0, 0x11c4, - 0x11fc, 0x1274, + 0x11fc, 0x123c, + 0x1254, 0x1274, 0x1280, 0x133c, 0x1800, 0x18fc, 0x3000, 0x302c, From nobody Wed Oct 20 17:47:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 825D1181671B; Wed, 20 Oct 2021 17:47: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 4HZJ3s2f75z3gxh; Wed, 20 Oct 2021 17:47: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 14E783D68; Wed, 20 Oct 2021 17: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 19KHlrF4007724; Wed, 20 Oct 2021 17: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 19KHlqur007723; Wed, 20 Oct 2021 17:47:52 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:47:52 GMT Message-Id: <202110201747.19KHlqur007723@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: d257477bd0bd - stable/13 - cxgbetool(8): Update the register definitions used to decode regdump. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d257477bd0bdf45a79626017d54366a7f4acc60d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=d257477bd0bdf45a79626017d54366a7f4acc60d commit d257477bd0bdf45a79626017d54366a7f4acc60d Author: Navdeep Parhar AuthorDate: 2021-07-14 00:51:13 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:43:21 +0000 cxgbetool(8): Update the register definitions used to decode regdump. Obtained from: Chelsio Communications Sponsored by: Chelsio Communications (cherry picked from commit 35e62b00c3342cffee042093b72a52f3f19e5263) --- usr.sbin/cxgbetool/reg_defs_t5.c | 304 +------------ usr.sbin/cxgbetool/reg_defs_t6.c | 955 +-------------------------------------- 2 files changed, 25 insertions(+), 1234 deletions(-) diff --git a/usr.sbin/cxgbetool/reg_defs_t5.c b/usr.sbin/cxgbetool/reg_defs_t5.c index ff84f00f297a..f5f64da7ebd2 100644 --- a/usr.sbin/cxgbetool/reg_defs_t5.c +++ b/usr.sbin/cxgbetool/reg_defs_t5.c @@ -1,6 +1,6 @@ /* This file is automatically generated --- changes will be lost */ -/* Generation Date : Mon Dec 7 19:40:45 IST 2015 */ -/* Directory name: t5_reg.txt, Changeset: 6934:86d3c0167c2c */ +/* Generation Date : Tue Jan 28 03:02:12 IST 2020 */ +/* Directory name: t5_reg.txt, Changeset: 6941:9063655afd44 */ __FBSDID("$FreeBSD$"); struct reg_info t5_sge_regs[] = { @@ -43607,21 +43607,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x30018, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x30028, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x30040, 0 }, { "MAC_PORT_TX_LINKB_TRANSMIT_CONFIGURATION_MODE", 0x33100, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -43748,21 +43733,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x30018, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x30028, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x30040, 0 }, { "MAC_PORT_TX_LINKC_TRANSMIT_CONFIGURATION_MODE", 0x33400, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -43889,21 +43859,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x30018, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x30028, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x30040, 0 }, { "MAC_PORT_TX_LINKD_TRANSMIT_CONFIGURATION_MODE", 0x33500, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -44030,21 +43985,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x30018, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x30028, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x30040, 0 }, { "MAC_PORT_TX_LINK_BCST_TRANSMIT_CONFIGURATION_MODE", 0x33900, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -44171,21 +44111,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x30018, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x30028, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x30040, 0 }, { "MAC_PORT_RX_LINKA_RECEIVER_CONFIGURATION_MODE", 0x33200, 0 }, { "T5_RX_LINKEN", 15, 1 }, { "T5_RX_LINKRST", 14, 1 }, @@ -47754,21 +47679,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x34000, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x34008, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x34010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x34018, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x34020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x34028, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x34030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x34038, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x34040, 0 }, { "MAC_PORT_TX_LINKB_TRANSMIT_CONFIGURATION_MODE", 0x37100, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -47895,21 +47805,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x34000, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x34008, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x34010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x34018, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x34020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x34028, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x34030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x34038, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x34040, 0 }, { "MAC_PORT_TX_LINKC_TRANSMIT_CONFIGURATION_MODE", 0x37400, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -48036,21 +47931,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x34000, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x34008, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x34010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x34018, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x34020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x34028, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x34030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x34038, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x34040, 0 }, { "MAC_PORT_TX_LINKD_TRANSMIT_CONFIGURATION_MODE", 0x37500, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -48177,21 +48057,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x34000, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x34008, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x34010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x34018, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x34020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x34028, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x34030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x34038, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x34040, 0 }, { "MAC_PORT_TX_LINK_BCST_TRANSMIT_CONFIGURATION_MODE", 0x37900, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -48318,21 +48183,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x34000, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x34008, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x34010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x34018, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x34020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x34028, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x34030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x34038, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x34040, 0 }, { "MAC_PORT_RX_LINKA_RECEIVER_CONFIGURATION_MODE", 0x37200, 0 }, { "T5_RX_LINKEN", 15, 1 }, { "T5_RX_LINKRST", 14, 1 }, @@ -51901,21 +51751,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x38000, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x38008, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x38010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x38018, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x38020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x38028, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x38030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x38038, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x38040, 0 }, { "MAC_PORT_TX_LINKB_TRANSMIT_CONFIGURATION_MODE", 0x3b100, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -52042,21 +51877,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x38000, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x38008, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x38010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x38018, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x38020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x38028, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x38030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x38038, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x38040, 0 }, { "MAC_PORT_TX_LINKC_TRANSMIT_CONFIGURATION_MODE", 0x3b400, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -52183,21 +52003,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x38000, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x38008, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x38010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x38018, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x38020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x38028, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x38030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x38038, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x38040, 0 }, { "MAC_PORT_TX_LINKD_TRANSMIT_CONFIGURATION_MODE", 0x3b500, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -52324,21 +52129,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x38000, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x38008, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x38010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x38018, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x38020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x38028, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x38030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x38038, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x38040, 0 }, { "MAC_PORT_TX_LINK_BCST_TRANSMIT_CONFIGURATION_MODE", 0x3b900, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -52465,21 +52255,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x38000, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x38008, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x38010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x38018, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x38020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x38028, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x38030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x38038, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x38040, 0 }, { "MAC_PORT_RX_LINKA_RECEIVER_CONFIGURATION_MODE", 0x3b200, 0 }, { "T5_RX_LINKEN", 15, 1 }, { "T5_RX_LINKRST", 14, 1 }, @@ -56048,21 +55823,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x3c000, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x3c008, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x3c010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x3c018, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x3c020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x3c028, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x3c030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x3c038, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x3c040, 0 }, { "MAC_PORT_TX_LINKB_TRANSMIT_CONFIGURATION_MODE", 0x3f100, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -56189,21 +55949,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x3c000, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x3c008, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x3c010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x3c018, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x3c020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x3c028, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x3c030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x3c038, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x3c040, 0 }, { "MAC_PORT_TX_LINKC_TRANSMIT_CONFIGURATION_MODE", 0x3f400, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -56330,21 +56075,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x3c000, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x3c008, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x3c010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x3c018, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x3c020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x3c028, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x3c030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x3c038, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x3c040, 0 }, { "MAC_PORT_TX_LINKD_TRANSMIT_CONFIGURATION_MODE", 0x3f500, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -56471,21 +56201,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x3c000, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x3c008, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x3c010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x3c018, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x3c020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x3c028, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x3c030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x3c038, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x3c040, 0 }, { "MAC_PORT_TX_LINK_BCST_TRANSMIT_CONFIGURATION_MODE", 0x3f900, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -56612,21 +56327,6 @@ struct reg_info t5_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED", 0x3c000, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x3c008, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED", 0x3c010, 0 }, - { "C0MAX", 8, 5 }, - { "C0MIN", 0, 5 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_INIT_EXTENDED", 0x3c018, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED", 0x3c020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_INIT_EXTENDED", 0x3c028, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED", 0x3c030, 0 }, - { "C2MAX", 8, 6 }, - { "C2MIN", 0, 6 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED", 0x3c038, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED", 0x3c040, 0 }, { "MAC_PORT_RX_LINKA_RECEIVER_CONFIGURATION_MODE", 0x3f200, 0 }, { "T5_RX_LINKEN", 15, 1 }, { "T5_RX_LINKRST", 14, 1 }, diff --git a/usr.sbin/cxgbetool/reg_defs_t6.c b/usr.sbin/cxgbetool/reg_defs_t6.c index f8a353b446de..23a3d6d44a5a 100644 --- a/usr.sbin/cxgbetool/reg_defs_t6.c +++ b/usr.sbin/cxgbetool/reg_defs_t6.c @@ -1,6 +1,6 @@ /* This file is automatically generated --- changes will be lost */ -/* Generation Date : Wed Jan 27 10:58:12 IST 2016 */ -/* Directory name: t6_reg.txt, Changeset: 4191:ce3ccd95c109 */ +/* Generation Date : Tue Jan 28 03:02:08 IST 2020 */ +/* Directory name: t6_reg.txt, Changeset: 4272:a648ba4d5c0c */ __FBSDID("$FreeBSD$"); struct reg_info t6_sge_regs[] = { @@ -760,6 +760,21 @@ struct reg_info t6_sge_regs[] = { { "SGE_PC0_RSP_BIST_ERROR_CNT", 0x11a4, 0 }, { "SGE_PC1_RSP_BIST_CMD", 0x11b0, 0 }, { "SGE_PC1_RSP_BIST_ERROR_CNT", 0x11b4, 0 }, + { "SGE_DBQ_TIMER_THRESH0", 0x11b8, 0 }, + { "TxTimeTh3", 24, 6 }, + { "TxTimeTh2", 16, 6 }, + { "TxTimeTh1", 8, 6 }, + { "TxTimeTh0", 0, 6 }, + { "SGE_DBQ_TIMER_THRESH1", 0x11bc, 0 }, + { "TxTimeTh7", 24, 6 }, + { "TxTimeTh6", 16, 6 }, + { "TxTimeTh5", 8, 6 }, + { "TxTimeTh4", 0, 6 }, + { "SGE_DBQ_TIMER_CONFIG", 0x11c0, 0 }, + { "SGE_DBQ_TIMER_DBG", 0x11c4, 0 }, + { "dbq_timer_cmd", 31, 1 }, + { "dbq_timer_index", 24, 6 }, + { "dbq_timer_qcnt", 0, 17 }, { "SGE_CTXT_CMD", 0x11fc, 0 }, { "Busy", 31, 1 }, { "Opcode", 28, 2 }, @@ -39712,6 +39727,12 @@ struct reg_info t6_le_regs[] = { { "LE_DB_DBGI_RSP_DATA", 0x19dc0, 0 }, { "LE_DB_DBGI_RSP_DATA", 0x19dc4, 0 }, { "LE_DB_DBGI_RSP_DATA", 0x19dc8, 0 }, + { "LE_DB_DBGI_RSP_DATA", 0x19dcc, 0 }, + { "LE_DB_DBGI_RSP_DATA", 0x19dd0, 0 }, + { "LE_DB_DBGI_RSP_DATA", 0x19dd4, 0 }, + { "LE_DB_DBGI_RSP_DATA", 0x19dd8, 0 }, + { "LE_DB_DBGI_RSP_DATA", 0x19ddc, 0 }, + { "LE_DB_DBGI_RSP_DATA", 0x19de0, 0 }, { "LE_DB_TCAM_TID_BASE", 0x19df0, 0 }, { "LE_DB_CLCAM_TID_BASE", 0x19df4, 0 }, { "LE_DB_HASH_TID_BASE", 0x19df8, 0 }, @@ -42611,37 +42632,6 @@ struct reg_info t6_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "C0PRESET", 8, 7 }, - { "C0INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 7 }, - { "C0MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C1_INIT_EXTENDED", 0x30018, 0 }, - { "C1PRESET", 8, 7 }, - { "C1INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C2_INIT_EXTENDED", 0x30028, 0 }, - { "C2PRESET", 8, 7 }, - { "C2INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 7 }, - { "C2MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_V2_LIMIT_EXTENDED", 0x30040, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C3_INIT_EXTENDED", 0x30048, 0 }, - { "C3PRESET", 8, 7 }, - { "C3INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C3_LIMIT_EXTENDED", 0x30050, 0 }, - { "C3MAX", 8, 7 }, - { "C3MIN", 0, 7 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C0_INIT2_EXTENDED", 0x3005c, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C1_INIT2_EXTENDED", 0x30060, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C2_INIT2_EXTENDED", 0x30068, 0 }, - { "MAC_PORT_TX_LINKA_TRANSMIT_AE_C3_INIT2_EXTENDED", 0x30070, 0 }, { "MAC_PORT_TX_LINKB_TRANSMIT_CONFIGURATION_MODE", 0x33100, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -42820,37 +42810,6 @@ struct reg_info t6_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "C0PRESET", 8, 7 }, - { "C0INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 7 }, - { "C0MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C1_INIT_EXTENDED", 0x30018, 0 }, - { "C1PRESET", 8, 7 }, - { "C1INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C2_INIT_EXTENDED", 0x30028, 0 }, - { "C2PRESET", 8, 7 }, - { "C2INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 7 }, - { "C2MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_V2_LIMIT_EXTENDED", 0x30040, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C3_INIT_EXTENDED", 0x30048, 0 }, - { "C3PRESET", 8, 7 }, - { "C3INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C3_LIMIT_EXTENDED", 0x30050, 0 }, - { "C3MAX", 8, 7 }, - { "C3MIN", 0, 7 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C0_INIT2_EXTENDED", 0x3005c, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C1_INIT2_EXTENDED", 0x30060, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C2_INIT2_EXTENDED", 0x30068, 0 }, - { "MAC_PORT_TX_LINKB_TRANSMIT_AE_C3_INIT2_EXTENDED", 0x30070, 0 }, { "MAC_PORT_TX_LINKC_TRANSMIT_CONFIGURATION_MODE", 0x33400, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -43029,37 +42988,6 @@ struct reg_info t6_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "C0PRESET", 8, 7 }, - { "C0INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 7 }, - { "C0MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C1_INIT_EXTENDED", 0x30018, 0 }, - { "C1PRESET", 8, 7 }, - { "C1INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C2_INIT_EXTENDED", 0x30028, 0 }, - { "C2PRESET", 8, 7 }, - { "C2INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 7 }, - { "C2MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_V2_LIMIT_EXTENDED", 0x30040, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C3_INIT_EXTENDED", 0x30048, 0 }, - { "C3PRESET", 8, 7 }, - { "C3INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C3_LIMIT_EXTENDED", 0x30050, 0 }, - { "C3MAX", 8, 7 }, - { "C3MIN", 0, 7 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C0_INIT2_EXTENDED", 0x3005c, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C1_INIT2_EXTENDED", 0x30060, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C2_INIT2_EXTENDED", 0x30068, 0 }, - { "MAC_PORT_TX_LINKC_TRANSMIT_AE_C3_INIT2_EXTENDED", 0x30070, 0 }, { "MAC_PORT_TX_LINKD_TRANSMIT_CONFIGURATION_MODE", 0x33500, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -43238,37 +43166,6 @@ struct reg_info t6_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "C0PRESET", 8, 7 }, - { "C0INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 7 }, - { "C0MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C1_INIT_EXTENDED", 0x30018, 0 }, - { "C1PRESET", 8, 7 }, - { "C1INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C2_INIT_EXTENDED", 0x30028, 0 }, - { "C2PRESET", 8, 7 }, - { "C2INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 7 }, - { "C2MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_V2_LIMIT_EXTENDED", 0x30040, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C3_INIT_EXTENDED", 0x30048, 0 }, - { "C3PRESET", 8, 7 }, - { "C3INIT1", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C3_LIMIT_EXTENDED", 0x30050, 0 }, - { "C3MAX", 8, 7 }, - { "C3MIN", 0, 7 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C0_INIT2_EXTENDED", 0x3005c, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C1_INIT2_EXTENDED", 0x30060, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C2_INIT2_EXTENDED", 0x30068, 0 }, - { "MAC_PORT_TX_LINKD_TRANSMIT_AE_C3_INIT2_EXTENDED", 0x30070, 0 }, { "MAC_PORT_TX_LINK_BCST_TRANSMIT_CONFIGURATION_MODE", 0x33900, 0 }, { "T5_TX_LINKEN", 15, 1 }, { "T5_TX_LINKRST", 14, 1 }, @@ -43447,37 +43344,6 @@ struct reg_info t6_mac_regs[] = { { "JTAGTS", 2, 1 }, { "TS", 1, 1 }, { "OBS", 0, 1 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_STEP_SIZE_EXTENDED", 0x30000, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_INIT_EXTENDED", 0x30008, 0 }, - { "C0PRESET", 8, 7 }, - { "C0INIT1", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C0_LIMIT_EXTENDED", 0x30010, 0 }, - { "C0MAX", 8, 7 }, - { "C0MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C1_INIT_EXTENDED", 0x30018, 0 }, - { "C1PRESET", 8, 7 }, - { "C1INIT1", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C1_LIMIT_EXTENDED", 0x30020, 0 }, - { "C1MAX", 8, 7 }, - { "C1MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C2_INIT_EXTENDED", 0x30028, 0 }, - { "C2PRESET", 8, 7 }, - { "C2INIT1", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C2_LIMIT_EXTENDED", 0x30030, 0 }, - { "C2MAX", 8, 7 }, - { "C2MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_VM_LIMIT_EXTENDED", 0x30038, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_V2_LIMIT_EXTENDED", 0x30040, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C3_INIT_EXTENDED", 0x30048, 0 }, - { "C3PRESET", 8, 7 }, - { "C3INIT1", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C3_LIMIT_EXTENDED", 0x30050, 0 }, - { "C3MAX", 8, 7 }, - { "C3MIN", 0, 7 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C0_INIT2_EXTENDED", 0x3005c, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C1_INIT2_EXTENDED", 0x30060, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C2_INIT2_EXTENDED", 0x30068, 0 }, - { "MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C3_INIT2_EXTENDED", 0x30070, 0 }, { "MAC_PORT_RX_LINKA_RECEIVER_CONFIGURATION_MODE", 0x33200, 0 }, { "T5_RX_LINKEN", 15, 1 }, { "T5_RX_LINKRST", 14, 1 }, @@ -43801,68 +43667,6 @@ struct reg_info t6_mac_regs[] = { { "FPRBSOFF", 0, 1 }, { "MAC_PORT_RX_LINKA_DFE_TAP_CONTROL", 0x332c0, 0 }, { "MAC_PORT_RX_LINKA_DFE_TAP", 0x332c4, 0 }, - { "MAC_PORT_RX_LINKA_DFE_TAP_ENABLE", 0x32a00, 0 }, - { "INDEX", 1, 15 }, - { "MAC_PORT_RX_LINKA_DFE_H1", 0x32a04, 0 }, - { "H1OSN", 13, 3 }, - { "H1OMAG", 8, 5 }, - { "H1ESN", 6, 2 }, - { "H1EMAG", 0, 6 }, - { "MAC_PORT_RX_LINKA_DFE_H2", 0x32a08, 0 }, - { "H2OSN", 13, 2 }, - { "H2OMAG", 8, 5 }, - { "H2ESN", 5, 2 }, - { "H2EMAG", 0, 5 }, - { "MAC_PORT_RX_LINKA_DFE_H3", 0x32a0c, 0 }, - { "H3OSN", 12, 2 }, - { "H3OMAG", 8, 4 }, - { "H3ESN", 4, 2 }, - { "H3EMAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H4", 0x32a10, 0 }, - { "H4SN", 4, 2 }, - { "H4MAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H5", 0x32a14, 0 }, - { "H5GS", 6, 2 }, - { "H5SN", 4, 2 }, - { "H5MAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H6_AND_H7", 0x32a18, 0 }, - { "H7GS", 14, 2 }, - { "H7SN", 12, 2 }, - { "H7MAG", 8, 4 }, - { "H6GS", 6, 2 }, - { "H6SN", 4, 2 }, - { "H6MAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H8_AND_H9", 0x32a1c, 0 }, - { "H9GS", 14, 2 }, - { "H9SN", 12, 2 }, - { "H9MAG", 8, 4 }, - { "H8GS", 6, 2 }, - { "H8SN", 4, 2 }, - { "H8MAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H10_AND_H11", 0x32a20, 0 }, - { "H11GS", 14, 2 }, - { "H11SN", 12, 2 }, - { "H11MAG", 8, 4 }, - { "H10GS", 6, 2 }, - { "H10SN", 4, 2 }, - { "H10MAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H12_13", 0x32a24, 0 }, - { "H13GS", 13, 3 }, - { "H13SN", 10, 3 }, - { "H13MAG", 8, 2 }, - { "H12GS", 6, 2 }, - { "H12SN", 4, 2 }, - { "H12MAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H14_15", 0x32a28, 0 }, - { "H15GS", 13, 3 }, - { "H15SN", 10, 3 }, - { "H15MAG", 8, 2 }, - { "H14GS", 6, 2 }, - { "H14SN", 4, 2 }, - { "H14MAG", 0, 4 }, - { "MAC_PORT_RX_LINKA_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA", 0x32a2c, 0 }, - { "H1ODELTA", 8, 5 }, - { "H1EDELTA", 0, 6 }, { "MAC_PORT_RX_LINKA_RECEIVER_INTERNAL_STATUS_2", 0x332e4, 0 }, { "STNDBYSTAT", 15, 1 }, { "CALSDONE", 14, 1 }, @@ -44245,68 +44049,6 @@ struct reg_info t6_mac_regs[] = { { "FPRBSOFF", 0, 1 }, { "MAC_PORT_RX_LINKB_DFE_TAP_CONTROL", 0x333c0, 0 }, { "MAC_PORT_RX_LINKB_DFE_TAP", 0x333c4, 0 }, - { "MAC_PORT_RX_LINKB_DFE_TAP_ENABLE", 0x32b00, 0 }, - { "INDEX", 1, 15 }, - { "MAC_PORT_RX_LINKB_DFE_H1", 0x32b04, 0 }, - { "H1OSN", 13, 3 }, - { "H1OMAG", 8, 5 }, - { "H1ESN", 6, 2 }, - { "H1EMAG", 0, 6 }, - { "MAC_PORT_RX_LINKB_DFE_H2", 0x32b08, 0 }, - { "H2OSN", 13, 2 }, - { "H2OMAG", 8, 5 }, - { "H2ESN", 5, 2 }, - { "H2EMAG", 0, 5 }, - { "MAC_PORT_RX_LINKB_DFE_H3", 0x32b0c, 0 }, - { "H3OSN", 12, 2 }, - { "H3OMAG", 8, 4 }, - { "H3ESN", 4, 2 }, - { "H3EMAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H4", 0x32b10, 0 }, - { "H4SN", 4, 2 }, - { "H4MAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H5", 0x32b14, 0 }, - { "H5GS", 6, 2 }, - { "H5SN", 4, 2 }, - { "H5MAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H6_AND_H7", 0x32b18, 0 }, - { "H7GS", 14, 2 }, - { "H7SN", 12, 2 }, - { "H7MAG", 8, 4 }, - { "H6GS", 6, 2 }, - { "H6SN", 4, 2 }, - { "H6MAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H8_AND_H9", 0x32b1c, 0 }, - { "H9GS", 14, 2 }, - { "H9SN", 12, 2 }, - { "H9MAG", 8, 4 }, - { "H8GS", 6, 2 }, - { "H8SN", 4, 2 }, - { "H8MAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H10_AND_H11", 0x32b20, 0 }, - { "H11GS", 14, 2 }, - { "H11SN", 12, 2 }, - { "H11MAG", 8, 4 }, - { "H10GS", 6, 2 }, - { "H10SN", 4, 2 }, - { "H10MAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H12_13", 0x32b24, 0 }, - { "H13GS", 13, 3 }, - { "H13SN", 10, 3 }, - { "H13MAG", 8, 2 }, - { "H12GS", 6, 2 }, - { "H12SN", 4, 2 }, - { "H12MAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H14_15", 0x32b28, 0 }, - { "H15GS", 13, 3 }, - { "H15SN", 10, 3 }, - { "H15MAG", 8, 2 }, - { "H14GS", 6, 2 }, - { "H14SN", 4, 2 }, - { "H14MAG", 0, 4 }, - { "MAC_PORT_RX_LINKB_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA", 0x32b2c, 0 }, - { "H1ODELTA", 8, 5 }, - { "H1EDELTA", 0, 6 }, { "MAC_PORT_RX_LINKB_RECEIVER_INTERNAL_STATUS_2", 0x333e4, 0 }, { "STNDBYSTAT", 15, 1 }, { "CALSDONE", 14, 1 }, @@ -44689,68 +44431,6 @@ struct reg_info t6_mac_regs[] = { { "FPRBSOFF", 0, 1 }, { "MAC_PORT_RX_LINKC_DFE_TAP_CONTROL", 0x336c0, 0 }, { "MAC_PORT_RX_LINKC_DFE_TAP", 0x336c4, 0 }, - { "MAC_PORT_RX_LINKC_DFE_TAP_ENABLE", 0x32e00, 0 }, - { "INDEX", 1, 15 }, - { "MAC_PORT_RX_LINKC_DFE_H1", 0x32e04, 0 }, - { "H1OSN", 13, 3 }, - { "H1OMAG", 8, 5 }, - { "H1ESN", 6, 2 }, - { "H1EMAG", 0, 6 }, - { "MAC_PORT_RX_LINKC_DFE_H2", 0x32e08, 0 }, - { "H2OSN", 13, 2 }, - { "H2OMAG", 8, 5 }, - { "H2ESN", 5, 2 }, - { "H2EMAG", 0, 5 }, - { "MAC_PORT_RX_LINKC_DFE_H3", 0x32e0c, 0 }, - { "H3OSN", 12, 2 }, - { "H3OMAG", 8, 4 }, - { "H3ESN", 4, 2 }, - { "H3EMAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H4", 0x32e10, 0 }, - { "H4SN", 4, 2 }, - { "H4MAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H5", 0x32e14, 0 }, - { "H5GS", 6, 2 }, - { "H5SN", 4, 2 }, - { "H5MAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H6_AND_H7", 0x32e18, 0 }, - { "H7GS", 14, 2 }, - { "H7SN", 12, 2 }, - { "H7MAG", 8, 4 }, - { "H6GS", 6, 2 }, - { "H6SN", 4, 2 }, - { "H6MAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H8_AND_H9", 0x32e1c, 0 }, - { "H9GS", 14, 2 }, - { "H9SN", 12, 2 }, - { "H9MAG", 8, 4 }, - { "H8GS", 6, 2 }, - { "H8SN", 4, 2 }, - { "H8MAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H10_AND_H11", 0x32e20, 0 }, - { "H11GS", 14, 2 }, - { "H11SN", 12, 2 }, - { "H11MAG", 8, 4 }, - { "H10GS", 6, 2 }, - { "H10SN", 4, 2 }, - { "H10MAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H12_13", 0x32e24, 0 }, - { "H13GS", 13, 3 }, - { "H13SN", 10, 3 }, - { "H13MAG", 8, 2 }, - { "H12GS", 6, 2 }, - { "H12SN", 4, 2 }, - { "H12MAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H14_15", 0x32e28, 0 }, - { "H15GS", 13, 3 }, - { "H15SN", 10, 3 }, - { "H15MAG", 8, 2 }, - { "H14GS", 6, 2 }, - { "H14SN", 4, 2 }, - { "H14MAG", 0, 4 }, - { "MAC_PORT_RX_LINKC_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA", 0x32e2c, 0 }, - { "H1ODELTA", 8, 5 }, - { "H1EDELTA", 0, 6 }, { "MAC_PORT_RX_LINKC_RECEIVER_INTERNAL_STATUS_2", 0x336e4, 0 }, { "STNDBYSTAT", 15, 1 }, { "CALSDONE", 14, 1 }, @@ -45133,68 +44813,6 @@ struct reg_info t6_mac_regs[] = { { "FPRBSOFF", 0, 1 }, { "MAC_PORT_RX_LINKD_DFE_TAP_CONTROL", 0x337c0, 0 }, { "MAC_PORT_RX_LINKD_DFE_TAP", 0x337c4, 0 }, - { "MAC_PORT_RX_LINKD_DFE_TAP_ENABLE", 0x32f00, 0 }, - { "INDEX", 1, 15 }, - { "MAC_PORT_RX_LINKD_DFE_H1", 0x32f04, 0 }, - { "H1OSN", 13, 3 }, - { "H1OMAG", 8, 5 }, - { "H1ESN", 6, 2 }, - { "H1EMAG", 0, 6 }, - { "MAC_PORT_RX_LINKD_DFE_H2", 0x32f08, 0 }, - { "H2OSN", 13, 2 }, - { "H2OMAG", 8, 5 }, - { "H2ESN", 5, 2 }, - { "H2EMAG", 0, 5 }, - { "MAC_PORT_RX_LINKD_DFE_H3", 0x32f0c, 0 }, - { "H3OSN", 12, 2 }, - { "H3OMAG", 8, 4 }, - { "H3ESN", 4, 2 }, - { "H3EMAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H4", 0x32f10, 0 }, - { "H4SN", 4, 2 }, - { "H4MAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H5", 0x32f14, 0 }, - { "H5GS", 6, 2 }, - { "H5SN", 4, 2 }, - { "H5MAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H6_AND_H7", 0x32f18, 0 }, - { "H7GS", 14, 2 }, - { "H7SN", 12, 2 }, - { "H7MAG", 8, 4 }, - { "H6GS", 6, 2 }, - { "H6SN", 4, 2 }, - { "H6MAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H8_AND_H9", 0x32f1c, 0 }, - { "H9GS", 14, 2 }, - { "H9SN", 12, 2 }, - { "H9MAG", 8, 4 }, - { "H8GS", 6, 2 }, - { "H8SN", 4, 2 }, - { "H8MAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H10_AND_H11", 0x32f20, 0 }, - { "H11GS", 14, 2 }, - { "H11SN", 12, 2 }, - { "H11MAG", 8, 4 }, - { "H10GS", 6, 2 }, - { "H10SN", 4, 2 }, - { "H10MAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H12_13", 0x32f24, 0 }, - { "H13GS", 13, 3 }, - { "H13SN", 10, 3 }, - { "H13MAG", 8, 2 }, - { "H12GS", 6, 2 }, - { "H12SN", 4, 2 }, - { "H12MAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H14_15", 0x32f28, 0 }, - { "H15GS", 13, 3 }, - { "H15SN", 10, 3 }, - { "H15MAG", 8, 2 }, - { "H14GS", 6, 2 }, - { "H14SN", 4, 2 }, - { "H14MAG", 0, 4 }, - { "MAC_PORT_RX_LINKD_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA", 0x32f2c, 0 }, - { "H1ODELTA", 8, 5 }, - { "H1EDELTA", 0, 6 }, { "MAC_PORT_RX_LINKD_RECEIVER_INTERNAL_STATUS_2", 0x337e4, 0 }, { "STNDBYSTAT", 15, 1 }, *** 605 LINES SKIPPED *** From nobody Wed Oct 20 17:50:32 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 63F6817F1A11; Wed, 20 Oct 2021 17:50: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 4HZJ6w2MRyz3jkM; Wed, 20 Oct 2021 17:50: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 31C8D3F9A; Wed, 20 Oct 2021 17:50: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 19KHoWsn016233; Wed, 20 Oct 2021 17:50:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHoW5K016232; Wed, 20 Oct 2021 17:50:32 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:50:32 GMT Message-Id: <202110201750.19KHoW5K016232@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 5561c4ffb261 - stable/13 - cxgbe(4): Initialize abs_id for ctrl and ofld queues. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5561c4ffb26128406f51a764e3956ba60e9695c2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=5561c4ffb26128406f51a764e3956ba60e9695c2 commit 5561c4ffb26128406f51a764e3956ba60e9695c2 Author: Navdeep Parhar AuthorDate: 2021-07-19 22:47:07 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:47:58 +0000 cxgbe(4): Initialize abs_id for ctrl and ofld queues. Sponsored by: Chelsio Communications (cherry picked from commit 76c890229628109e46f01c5037b773b59247a1f8) --- sys/dev/cxgbe/t4_sge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 9d990253d7a0..3134542b1b87 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4190,6 +4190,7 @@ ctrl_eq_alloc(struct adapter *sc, struct sge_eq *eq) } eq->cntxt_id = G_FW_EQ_CTRL_CMD_EQID(be32toh(c.cmpliqid_eqid)); + eq->abs_id = G_FW_EQ_CTRL_CMD_PHYSEQID(be32toh(c.physeqid_pkd)); cntxt_id = eq->cntxt_id - sc->sge.eq_start; if (cntxt_id >= sc->sge.eqmap_sz) panic("%s: eq->cntxt_id (%d) more than the max (%d)", __func__, @@ -4279,6 +4280,7 @@ ofld_eq_alloc(struct adapter *sc, struct vi_info *vi, struct sge_eq *eq) } eq->cntxt_id = G_FW_EQ_OFLD_CMD_EQID(be32toh(c.eqid_pkd)); + eq->abs_id = G_FW_EQ_OFLD_CMD_PHYSEQID(be32toh(c.physeqid_pkd)); cntxt_id = eq->cntxt_id - sc->sge.eq_start; if (cntxt_id >= sc->sge.eqmap_sz) panic("%s: eq->cntxt_id (%d) more than the max (%d)", __func__, From nobody Wed Oct 20 17:50:33 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A72F217F192C; Wed, 20 Oct 2021 17:50: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 4HZJ6x3nQTz3jdn; Wed, 20 Oct 2021 17:50: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 51101411A; Wed, 20 Oct 2021 17:50: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 19KHoXDt016257; Wed, 20 Oct 2021 17:50:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHoXGS016256; Wed, 20 Oct 2021 17:50:33 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:50:33 GMT Message-Id: <202110201750.19KHoXGS016256@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: d8034cee46f3 - stable/13 - cxgbe(4): Display HMA information in meminfo. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d8034cee46f3d547ad3fcd1e93024d27479b6e38 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=d8034cee46f3d547ad3fcd1e93024d27479b6e38 commit d8034cee46f3d547ad3fcd1e93024d27479b6e38 Author: Navdeep Parhar AuthorDate: 2021-09-07 20:39:44 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:48:22 +0000 cxgbe(4): Display HMA information in meminfo. This should have been added with initial T6 support many years ago. Sponsored by: Chelsio Communications (cherry picked from commit 83a611e09238ead5a765c0ea2c02699fe8175756) --- sys/dev/cxgbe/common/common.h | 2 +- sys/dev/cxgbe/t4_main.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index c132cb779204..07d8ab2b40f0 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -49,7 +49,7 @@ enum { T5_REGMAP_SIZE = (332 * 1024), }; -enum { MEM_EDC0, MEM_EDC1, MEM_MC, MEM_MC0 = MEM_MC, MEM_MC1 }; +enum { MEM_EDC0, MEM_EDC1, MEM_MC, MEM_MC0 = MEM_MC, MEM_MC1, MEM_HMA }; enum dev_master { MASTER_CANT, MASTER_MAY, MASTER_MUST }; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 2fa54909aa5a..853bc2b5d58a 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -9591,7 +9591,9 @@ sysctl_meminfo(SYSCTL_HANDLER_ARGS) struct sbuf *sb; int rc, i, n; uint32_t lo, hi, used, alloc; - static const char *memory[] = {"EDC0:", "EDC1:", "MC:", "MC0:", "MC1:"}; + static const char *memory[] = { + "EDC0:", "EDC1:", "MC:", "MC0:", "MC1:", "HMA:" + }; static const char *region[] = { "DBQ contexts:", "IMSG contexts:", "FLM cache:", "TCBs:", "Pstructs:", "Timers:", "Rx FL:", "Tx FL:", "Pstruct FL:", @@ -9644,19 +9646,25 @@ sysctl_meminfo(SYSCTL_HANDLER_ARGS) if (lo & F_EXT_MEM_ENABLE) { hi = t4_read_reg(sc, A_MA_EXT_MEMORY_BAR); avail[i].base = G_EXT_MEM_BASE(hi) << 20; - avail[i].limit = avail[i].base + - (G_EXT_MEM_SIZE(hi) << 20); + avail[i].limit = avail[i].base + (G_EXT_MEM_SIZE(hi) << 20); avail[i].idx = is_t5(sc) ? 3 : 2; /* Call it MC0 for T5 */ i++; } if (is_t5(sc) && lo & F_EXT_MEM1_ENABLE) { hi = t4_read_reg(sc, A_MA_EXT_MEMORY1_BAR); avail[i].base = G_EXT_MEM1_BASE(hi) << 20; - avail[i].limit = avail[i].base + - (G_EXT_MEM1_SIZE(hi) << 20); + avail[i].limit = avail[i].base + (G_EXT_MEM1_SIZE(hi) << 20); avail[i].idx = 4; i++; } + if (is_t6(sc) && lo & F_HMA_MUX) { + hi = t4_read_reg(sc, A_MA_EXT_MEMORY1_BAR); + avail[i].base = G_EXT_MEM1_BASE(hi) << 20; + avail[i].limit = avail[i].base + (G_EXT_MEM1_SIZE(hi) << 20); + avail[i].idx = 5; + i++; + } + MPASS(i <= nitems(avail)); if (!i) /* no memory available */ goto done; qsort(avail, i, sizeof(struct mem_desc), mem_desc_cmp); From nobody Wed Oct 20 17:50:34 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7CCAA17F1B01; Wed, 20 Oct 2021 17: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 4HZJ6y5jgxz3jmw; Wed, 20 Oct 2021 17:50: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 7605F3D69; Wed, 20 Oct 2021 17:50: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 19KHoYbV016493; Wed, 20 Oct 2021 17:50:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHoYXj016471; Wed, 20 Oct 2021 17:50:34 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:50:34 GMT Message-Id: <202110201750.19KHoYXj016471@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 38271e72919a - stable/13 - cxgbe(4): Fix the decode and display of the DBVFIFO region in meminfo. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 38271e72919a5ce1f38efc018eb270ab5a1c24af Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=38271e72919a5ce1f38efc018eb270ab5a1c24af commit 38271e72919a5ce1f38efc018eb270ab5a1c24af Author: Navdeep Parhar AuthorDate: 2021-09-07 23:28:11 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:48:51 +0000 cxgbe(4): Fix the decode and display of the DBVFIFO region in meminfo. Sponsored by: Chelsio Communications (cherry picked from commit 92de737996660b70376a8b72b80037f89d876056) --- sys/dev/cxgbe/t4_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 853bc2b5d58a..eebba8afcb8c 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -9719,23 +9719,24 @@ sysctl_meminfo(SYSCTL_HANDLER_ARGS) #undef ulp_region md->base = 0; - md->idx = nitems(region); - if (!is_t4(sc)) { + if (is_t4(sc)) + md->idx = nitems(region); + else { uint32_t size = 0; uint32_t sge_ctrl = t4_read_reg(sc, A_SGE_CONTROL2); uint32_t fifo_size = t4_read_reg(sc, A_SGE_DBVFIFO_SIZE); if (is_t5(sc)) { if (sge_ctrl & F_VFIFO_ENABLE) - size = G_DBVFIFO_SIZE(fifo_size); + size = fifo_size << 2; } else - size = G_T6_DBVFIFO_SIZE(fifo_size); + size = G_T6_DBVFIFO_SIZE(fifo_size) << 6; if (size) { - md->base = G_BASEADDR(t4_read_reg(sc, - A_SGE_DBVFIFO_BADDR)); - md->limit = md->base + (size << 2) - 1; - } + md->base = t4_read_reg(sc, A_SGE_DBVFIFO_BADDR); + md->limit = md->base + size - 1; + } else + md->idx = nitems(region); } md++; From nobody Wed Oct 20 17:52:31 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A5BF617F2D93; Wed, 20 Oct 2021 17:52: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 4HZJ9C4Fmbz3lGS; Wed, 20 Oct 2021 17:52: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 723463CF4; Wed, 20 Oct 2021 17:52: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 19KHqVYl020631; Wed, 20 Oct 2021 17:52:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19KHqVGE020630; Wed, 20 Oct 2021 17:52:31 GMT (envelope-from git) Date: Wed, 20 Oct 2021 17:52:31 GMT Message-Id: <202110201752.19KHqVGE020630@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: e058d44fda32 - stable/13 - cxgbe/t4_tom: Use stale L2T entry and avoid busy-waiting for resolution. Sponsored by: Chelsio Communications List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e058d44fda32582ae7445e400f7c385953435064 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=e058d44fda32582ae7445e400f7c385953435064 commit e058d44fda32582ae7445e400f7c385953435064 Author: Navdeep Parhar AuthorDate: 2021-09-09 03:46:42 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 17:50:42 +0000 cxgbe/t4_tom: Use stale L2T entry and avoid busy-waiting for resolution. Sponsored by: Chelsio Communications (cherry picked from commit 53c17de2b472c5c4982d5a020268ad3098241498) --- sys/dev/cxgbe/tom/t4_tom_l2t.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/tom/t4_tom_l2t.c b/sys/dev/cxgbe/tom/t4_tom_l2t.c index 682c99840dcd..1d094c30d25e 100644 --- a/sys/dev/cxgbe/tom/t4_tom_l2t.c +++ b/sys/dev/cxgbe/tom/t4_tom_l2t.c @@ -271,8 +271,7 @@ again: switch (e->state) { case L2T_STATE_STALE: /* entry is stale, kick off revalidation */ - if (resolve_entry(sc, e) != EWOULDBLOCK) - goto again; /* entry updated, re-examine state */ + resolve_entry(sc, e); /* Fall through */ From nobody Thu Oct 21 00:09:08 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B9B681805BAD; Thu, 21 Oct 2021 00:09: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 4HZSWm4vd6z3FNZ; Thu, 21 Oct 2021 00:09: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 849A8110EA; Thu, 21 Oct 2021 00:09: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 19L098wV015465; Thu, 21 Oct 2021 00:09:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19L098c3015464; Thu, 21 Oct 2021 00:09:08 GMT (envelope-from git) Date: Thu, 21 Oct 2021 00:09:08 GMT Message-Id: <202110210009.19L098c3015464@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: ba2a30ed753c - stable/12 - cxgbe(4): Catch up with in-flight netmap rx before destroying queues. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ba2a30ed753cafa9b1a12a1cc5ec290a780422b6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=ba2a30ed753cafa9b1a12a1cc5ec290a780422b6 commit ba2a30ed753cafa9b1a12a1cc5ec290a780422b6 Author: Navdeep Parhar AuthorDate: 2020-11-21 03:27:32 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 18:24:03 +0000 cxgbe(4): Catch up with in-flight netmap rx before destroying queues. The netmap application using the driver is responsible for replenishing the receive freelists and they may be totally depleted when the application exits. Packets in flight, if any, might block the pipeline in case there aren't enough buffers left in the freelist. Avoid this by filling up the freelists with a driver allocated buffer. Sponsored by: Chelsio Communications (cherry picked from commit b3718e2d7ebfe7fc0bb57bd0906aacc28dd755b2) --- sys/dev/cxgbe/adapter.h | 3 +++ sys/dev/cxgbe/t4_netmap.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 18dd334a391c..a1006df3e987 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -737,6 +737,9 @@ struct sge_nm_rxq { bus_dma_tag_t fl_desc_tag; bus_dmamap_t fl_desc_map; bus_addr_t fl_ba; + + void *bb; /* bit bucket for packets with nowhere to go. */ + uma_zone_t bb_zone; }; #define INVALID_NM_TXQ_CNTXT_ID ((u_int)(-1)) diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index 2bee6040b10e..3dd3f42c5636 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -586,6 +588,8 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, alloc_nm_rxq_hwq(vi, nm_rxq, tnl_cong(vi->pi, nm_cong_drop)); nm_rxq->fl_hwidx = hwidx; + nm_rxq->bb_zone = rxb->zone; + nm_rxq->bb = uma_zalloc(nm_rxq->bb_zone, M_WAITOK); slot = netmap_reset(na, NR_RX, i, 0); MPASS(slot != NULL); /* XXXNM: error check, not assert */ @@ -628,6 +632,31 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, return (cxgbe_netmap_rss(sc, vi, ifp, na)); } +static void +flush_nm_rxq(struct adapter *sc, struct vi_info *vi, struct sge_nm_rxq *nm_rxq) +{ + int i, n; + u_int fl_pidx, fl_pidx_target, hw_cidx_desc; + const uint64_t ba = pmap_kextract((vm_offset_t)nm_rxq->bb); + + hw_cidx_desc = nm_rxq->fl_cidx / 8; + if (hw_cidx_desc == 0) + fl_pidx_target = nm_rxq->fl_sidx2 - 8; + else + fl_pidx_target = (hw_cidx_desc - 1) * 8; + MPASS((fl_pidx_target & 7) == 0); + + fl_pidx = nm_rxq->fl_pidx; + MPASS((fl_pidx & 7) == 0); + for (n = 0; fl_pidx != fl_pidx_target; n++) { + for (i = 0; i < 8; i++, fl_pidx++) + nm_rxq->fl_desc[fl_pidx] = htobe64(ba | nm_rxq->fl_hwidx); + if (__predict_false(fl_pidx == nm_rxq->fl_sidx2)) + fl_pidx = 0; + } + t4_write_reg(sc, sc->sge_kdoorbell_reg, nm_rxq->fl_db_val | V_PIDX(n)); +} + static int cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, struct netmap_adapter *na) @@ -652,6 +681,23 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, if (rc != 0) return (rc); /* error message logged already. */ + /* + * First pass over the rx queues to make sure they're all caught up. + * + * The freelists could be out of buffers and we may need to arrange + * things so that any packets still in flight (after TP's cong_drop + * logic but not yet DMA'd) have somewhere to go and do not block the + * pipeline. Do this before trying to free any queue. + */ + for_each_nm_rxq(vi, i, nm_rxq) { + nm_state = atomic_load_int(&nm_rxq->nm_state); + kring = na->rx_rings[nm_rxq->nid]; + if (nm_state == NM_OFF || !nm_kring_pending_off(kring)) + continue; + MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID); + flush_nm_rxq(sc, vi, nm_rxq); + } + for_each_nm_txq(vi, i, nm_txq) { struct sge_qstat *spg = (void *)&nm_txq->desc[nm_txq->sidx]; @@ -688,6 +734,8 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, pause("nmst", 1); free_nm_rxq_hwq(vi, nm_rxq); + uma_zfree(nm_rxq->bb_zone, nm_rxq->bb); + nm_rxq->bb = NULL; /* XXX: netmap, not the driver, should do this. */ kring->rhead = kring->rcur = kring->nr_hwcur = 0; From nobody Thu Oct 21 00:09:09 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2ABF71805C1B; Thu, 21 Oct 2021 00:09: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 4HZSWn70WLz3FJB; Thu, 21 Oct 2021 00:09: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 AEE1B114D1; Thu, 21 Oct 2021 00:09: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 19L099ZF015489; Thu, 21 Oct 2021 00:09:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19L099Di015488; Thu, 21 Oct 2021 00:09:09 GMT (envelope-from git) Date: Thu, 21 Oct 2021 00:09:09 GMT Message-Id: <202110210009.19L099Di015488@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: d31b8f0dece1 - stable/12 - cxgbe(4): Revert r367917. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d31b8f0dece18bb5c301a71200d8a8c03ab84602 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=d31b8f0dece18bb5c301a71200d8a8c03ab84602 commit d31b8f0dece18bb5c301a71200d8a8c03ab84602 Author: Navdeep Parhar AuthorDate: 2020-12-02 20:54:03 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 18:26:49 +0000 cxgbe(4): Revert r367917. r367917 fixed the backpressure on the netmap rxq being stopped but that doesn't help if some other netmap rxq is starved (because it is stopping too although the driver doesn't know this yet) and blocks the pipeline. An alternate fix that works in all cases will be checked in instead. Sponsored by: Chelsio Communications (cherry picked from commit f42f3b2955e5afa770275fd76b4f754fbd67bbeb) --- sys/dev/cxgbe/adapter.h | 3 --- sys/dev/cxgbe/t4_netmap.c | 48 ----------------------------------------------- 2 files changed, 51 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index a1006df3e987..18dd334a391c 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -737,9 +737,6 @@ struct sge_nm_rxq { bus_dma_tag_t fl_desc_tag; bus_dmamap_t fl_desc_map; bus_addr_t fl_ba; - - void *bb; /* bit bucket for packets with nowhere to go. */ - uma_zone_t bb_zone; }; #define INVALID_NM_TXQ_CNTXT_ID ((u_int)(-1)) diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index 3dd3f42c5636..2bee6040b10e 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -42,8 +42,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include #include #include #include @@ -588,8 +586,6 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, alloc_nm_rxq_hwq(vi, nm_rxq, tnl_cong(vi->pi, nm_cong_drop)); nm_rxq->fl_hwidx = hwidx; - nm_rxq->bb_zone = rxb->zone; - nm_rxq->bb = uma_zalloc(nm_rxq->bb_zone, M_WAITOK); slot = netmap_reset(na, NR_RX, i, 0); MPASS(slot != NULL); /* XXXNM: error check, not assert */ @@ -632,31 +628,6 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, return (cxgbe_netmap_rss(sc, vi, ifp, na)); } -static void -flush_nm_rxq(struct adapter *sc, struct vi_info *vi, struct sge_nm_rxq *nm_rxq) -{ - int i, n; - u_int fl_pidx, fl_pidx_target, hw_cidx_desc; - const uint64_t ba = pmap_kextract((vm_offset_t)nm_rxq->bb); - - hw_cidx_desc = nm_rxq->fl_cidx / 8; - if (hw_cidx_desc == 0) - fl_pidx_target = nm_rxq->fl_sidx2 - 8; - else - fl_pidx_target = (hw_cidx_desc - 1) * 8; - MPASS((fl_pidx_target & 7) == 0); - - fl_pidx = nm_rxq->fl_pidx; - MPASS((fl_pidx & 7) == 0); - for (n = 0; fl_pidx != fl_pidx_target; n++) { - for (i = 0; i < 8; i++, fl_pidx++) - nm_rxq->fl_desc[fl_pidx] = htobe64(ba | nm_rxq->fl_hwidx); - if (__predict_false(fl_pidx == nm_rxq->fl_sidx2)) - fl_pidx = 0; - } - t4_write_reg(sc, sc->sge_kdoorbell_reg, nm_rxq->fl_db_val | V_PIDX(n)); -} - static int cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, struct netmap_adapter *na) @@ -681,23 +652,6 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, if (rc != 0) return (rc); /* error message logged already. */ - /* - * First pass over the rx queues to make sure they're all caught up. - * - * The freelists could be out of buffers and we may need to arrange - * things so that any packets still in flight (after TP's cong_drop - * logic but not yet DMA'd) have somewhere to go and do not block the - * pipeline. Do this before trying to free any queue. - */ - for_each_nm_rxq(vi, i, nm_rxq) { - nm_state = atomic_load_int(&nm_rxq->nm_state); - kring = na->rx_rings[nm_rxq->nid]; - if (nm_state == NM_OFF || !nm_kring_pending_off(kring)) - continue; - MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID); - flush_nm_rxq(sc, vi, nm_rxq); - } - for_each_nm_txq(vi, i, nm_txq) { struct sge_qstat *spg = (void *)&nm_txq->desc[nm_txq->sidx]; @@ -734,8 +688,6 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, pause("nmst", 1); free_nm_rxq_hwq(vi, nm_rxq); - uma_zfree(nm_rxq->bb_zone, nm_rxq->bb); - nm_rxq->bb = NULL; /* XXX: netmap, not the driver, should do this. */ kring->rhead = kring->rcur = kring->nr_hwcur = 0; From nobody Thu Oct 21 00:09:10 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3578318056E3; Thu, 21 Oct 2021 00:09: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 4HZSWp6Xdrz3FLZ; Thu, 21 Oct 2021 00:09: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 B5C64111C9; Thu, 21 Oct 2021 00:09: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 19L09A7t015518; Thu, 21 Oct 2021 00:09:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19L09AIY015516; Thu, 21 Oct 2021 00:09:10 GMT (envelope-from git) Date: Thu, 21 Oct 2021 00:09:10 GMT Message-Id: <202110210009.19L09AIY015516@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 1f4943c92cdd - stable/12 - cxgbe(4): Stop but don't free netmap queues when netmap is switched off. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 1f4943c92cdd783e31a7c145660e8ac961aaabbd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=1f4943c92cdd783e31a7c145660e8ac961aaabbd commit 1f4943c92cdd783e31a7c145660e8ac961aaabbd Author: Navdeep Parhar AuthorDate: 2020-12-03 08:30:29 +0000 Commit: Navdeep Parhar CommitDate: 2021-10-20 20:55:36 +0000 cxgbe(4): Stop but don't free netmap queues when netmap is switched off. It is common for freelists to be starving when a netmap application stops. Mailbox commands to free queues can hang in such a situation. Avoid that by not freeing the queues when netmap is switched off. Instead, use an alternate method to stop the queues without releasing the context ids. If netmap is enabled again later then the same queue is reinitialized for use. Move alloc_nm_rxq and txq to t4_netmap.c while here. Sponsored by: Chelsio Communications (cherry picked from commit 8eba75ed68854188c01a2058fe1f826b3428dbfa) --- sys/dev/cxgbe/adapter.h | 11 +++ sys/dev/cxgbe/common/common.h | 2 + sys/dev/cxgbe/common/t4_hw.c | 26 +++++ sys/dev/cxgbe/t4_netmap.c | 220 +++++++++++++++++++++++++++++++++++++----- sys/dev/cxgbe/t4_sge.c | 175 +-------------------------------- 5 files changed, 237 insertions(+), 197 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 18dd334a391c..358c5c6dfcf5 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -1221,6 +1221,12 @@ struct sge_nm_rxq; void cxgbe_nm_attach(struct vi_info *); void cxgbe_nm_detach(struct vi_info *); void service_nm_rxq(struct sge_nm_rxq *); +int alloc_nm_rxq(struct vi_info *, struct sge_nm_rxq *, int, int, + struct sysctl_oid *); +int free_nm_rxq(struct vi_info *, struct sge_nm_rxq *); +int alloc_nm_txq(struct vi_info *, struct sge_nm_txq *, int, int, + struct sysctl_oid *); +int free_nm_txq(struct vi_info *, struct sge_nm_txq *); #endif /* t4_sge.c */ @@ -1233,6 +1239,11 @@ int t4_create_dma_tag(struct adapter *); void t4_sge_sysctls(struct adapter *, struct sysctl_ctx_list *, struct sysctl_oid_list *); int t4_destroy_dma_tag(struct adapter *); +int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *, + bus_addr_t *, void **); +int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, + void *); +int sysctl_uint16(SYSCTL_HANDLER_ARGS); int t4_setup_adapter_queues(struct adapter *); int t4_teardown_adapter_queues(struct adapter *); int t4_setup_vi_queues(struct vi_info *); diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index 522b52f141bf..3ed9040e9581 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -840,6 +840,8 @@ int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf, int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, unsigned int vf, unsigned int iqtype, unsigned int iqid, unsigned int fl0id, unsigned int fl1id); +int t4_eth_eq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf, + unsigned int vf, unsigned int eqid); int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, unsigned int vf, unsigned int eqid); int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 6e78b5a4f762..427c0ff914c2 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -8619,6 +8619,32 @@ int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); } +/** + * t4_eth_eq_stop - stop an Ethernet egress queue + * @adap: the adapter + * @mbox: mailbox to use for the FW command + * @pf: the PF owning the queues + * @vf: the VF owning the queues + * @eqid: egress queue id + * + * Stops an Ethernet egress queue. The queue can be reinitialized or + * freed but is not otherwise functional after this call. + */ +int t4_eth_eq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf, + unsigned int vf, unsigned int eqid) +{ + struct fw_eq_eth_cmd c; + + memset(&c, 0, sizeof(c)); + c.op_to_vfn = cpu_to_be32(V_FW_CMD_OP(FW_EQ_ETH_CMD) | + F_FW_CMD_REQUEST | F_FW_CMD_EXEC | + V_FW_EQ_ETH_CMD_PFN(pf) | + V_FW_EQ_ETH_CMD_VFN(vf)); + c.alloc_to_len16 = cpu_to_be32(F_FW_EQ_ETH_CMD_EQSTOP | FW_LEN16(c)); + c.eqid_pkd = cpu_to_be32(V_FW_EQ_ETH_CMD_EQID(eqid)); + return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); +} + /** * t4_eth_eq_free - free an Ethernet egress queue * @adap: the adapter diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index 2bee6040b10e..29284d76bdda 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -120,6 +120,166 @@ static int nm_txcsum = 0; SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_txcsum, CTLFLAG_RWTUN, &nm_txcsum, 0, "Enable transmit checksum offloading."); +static int free_nm_rxq_hwq(struct vi_info *, struct sge_nm_rxq *); +static int free_nm_txq_hwq(struct vi_info *, struct sge_nm_txq *); + +int +alloc_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int intr_idx, + int idx, struct sysctl_oid *oid) +{ + int rc; + struct sysctl_oid_list *children; + struct sysctl_ctx_list *ctx; + char name[16]; + size_t len; + struct adapter *sc = vi->adapter; + struct netmap_adapter *na = NA(vi->ifp); + + MPASS(na != NULL); + + len = vi->qsize_rxq * IQ_ESIZE; + rc = alloc_ring(sc, len, &nm_rxq->iq_desc_tag, &nm_rxq->iq_desc_map, + &nm_rxq->iq_ba, (void **)&nm_rxq->iq_desc); + if (rc != 0) + return (rc); + + len = na->num_rx_desc * EQ_ESIZE + sc->params.sge.spg_len; + rc = alloc_ring(sc, len, &nm_rxq->fl_desc_tag, &nm_rxq->fl_desc_map, + &nm_rxq->fl_ba, (void **)&nm_rxq->fl_desc); + if (rc != 0) + return (rc); + + nm_rxq->vi = vi; + nm_rxq->nid = idx; + nm_rxq->iq_cidx = 0; + nm_rxq->iq_sidx = vi->qsize_rxq - sc->params.sge.spg_len / IQ_ESIZE; + nm_rxq->iq_gen = F_RSPD_GEN; + nm_rxq->fl_pidx = nm_rxq->fl_cidx = 0; + nm_rxq->fl_sidx = na->num_rx_desc; + nm_rxq->fl_sidx2 = nm_rxq->fl_sidx; /* copy for rxsync cacheline */ + nm_rxq->intr_idx = intr_idx; + nm_rxq->iq_cntxt_id = INVALID_NM_RXQ_CNTXT_ID; + + ctx = &vi->ctx; + children = SYSCTL_CHILDREN(oid); + + snprintf(name, sizeof(name), "%d", idx); + oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, name, + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "rx queue"); + children = SYSCTL_CHILDREN(oid); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "abs_id", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->iq_abs_id, + 0, sysctl_uint16, "I", "absolute id of the queue"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->iq_cntxt_id, + 0, sysctl_uint16, "I", "SGE context id of the queue"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cidx", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->iq_cidx, 0, + sysctl_uint16, "I", "consumer index"); + + children = SYSCTL_CHILDREN(oid); + oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "fl", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "freelist"); + children = SYSCTL_CHILDREN(oid); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->fl_cntxt_id, + 0, sysctl_uint16, "I", "SGE context id of the freelist"); + SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, + &nm_rxq->fl_cidx, 0, "consumer index"); + SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "pidx", CTLFLAG_RD, + &nm_rxq->fl_pidx, 0, "producer index"); + + return (rc); +} + +int +free_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq) +{ + struct adapter *sc = vi->adapter; + + if (!(vi->flags & VI_INIT_DONE)) + return (0); + + if (nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID) + free_nm_rxq_hwq(vi, nm_rxq); + MPASS(nm_rxq->iq_cntxt_id == INVALID_NM_RXQ_CNTXT_ID); + + free_ring(sc, nm_rxq->iq_desc_tag, nm_rxq->iq_desc_map, nm_rxq->iq_ba, + nm_rxq->iq_desc); + free_ring(sc, nm_rxq->fl_desc_tag, nm_rxq->fl_desc_map, nm_rxq->fl_ba, + nm_rxq->fl_desc); + + return (0); +} + +int +alloc_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq, int iqidx, int idx, + struct sysctl_oid *oid) +{ + int rc; + size_t len; + struct port_info *pi = vi->pi; + struct adapter *sc = pi->adapter; + struct netmap_adapter *na = NA(vi->ifp); + char name[16]; + struct sysctl_oid_list *children = SYSCTL_CHILDREN(oid); + + len = na->num_tx_desc * EQ_ESIZE + sc->params.sge.spg_len; + rc = alloc_ring(sc, len, &nm_txq->desc_tag, &nm_txq->desc_map, + &nm_txq->ba, (void **)&nm_txq->desc); + if (rc) + return (rc); + + nm_txq->pidx = nm_txq->cidx = 0; + nm_txq->sidx = na->num_tx_desc; + nm_txq->nid = idx; + nm_txq->iqidx = iqidx; + nm_txq->cpl_ctrl0 = htobe32(V_TXPKT_OPCODE(CPL_TX_PKT) | + V_TXPKT_INTF(pi->tx_chan) | V_TXPKT_PF(sc->pf) | + V_TXPKT_VF(vi->vin) | V_TXPKT_VF_VLD(vi->vfvld)); + if (sc->params.fw_vers >= FW_VERSION32(1, 24, 11, 0)) + nm_txq->op_pkd = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS2_WR)); + else + nm_txq->op_pkd = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS_WR)); + nm_txq->cntxt_id = INVALID_NM_TXQ_CNTXT_ID; + + snprintf(name, sizeof(name), "%d", idx); + oid = SYSCTL_ADD_NODE(&vi->ctx, children, OID_AUTO, name, + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "netmap tx queue"); + children = SYSCTL_CHILDREN(oid); + + SYSCTL_ADD_UINT(&vi->ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, + &nm_txq->cntxt_id, 0, "SGE context id of the queue"); + SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "cidx", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_txq->cidx, 0, + sysctl_uint16, "I", "consumer index"); + SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "pidx", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_txq->pidx, 0, + sysctl_uint16, "I", "producer index"); + + return (rc); +} + +int +free_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq) +{ + struct adapter *sc = vi->adapter; + + if (!(vi->flags & VI_INIT_DONE)) + return (0); + + if (nm_txq->cntxt_id != INVALID_NM_TXQ_CNTXT_ID) + free_nm_txq_hwq(vi, nm_txq); + MPASS(nm_txq->cntxt_id == INVALID_NM_TXQ_CNTXT_ID); + + free_ring(sc, nm_txq->desc_tag, nm_txq->desc_map, nm_txq->ba, + nm_txq->desc); + + return (0); +} + static int alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int cong) { @@ -141,8 +301,15 @@ alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int cong) c.op_to_vfn = htobe32(V_FW_CMD_OP(FW_IQ_CMD) | F_FW_CMD_REQUEST | F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_IQ_CMD_PFN(sc->pf) | V_FW_IQ_CMD_VFN(0)); - c.alloc_to_len16 = htobe32(F_FW_IQ_CMD_ALLOC | F_FW_IQ_CMD_IQSTART | - FW_LEN16(c)); + c.alloc_to_len16 = htobe32(F_FW_IQ_CMD_IQSTART | FW_LEN16(c)); + if (nm_rxq->iq_cntxt_id == INVALID_NM_RXQ_CNTXT_ID) + c.alloc_to_len16 |= htobe32(F_FW_IQ_CMD_ALLOC); + else { + c.iqid = htobe16(nm_rxq->iq_cntxt_id); + c.fl0id = htobe16(nm_rxq->fl_cntxt_id); + c.fl1id = htobe16(0xffff); + c.physiqid = htobe16(nm_rxq->iq_abs_id); + } MPASS(!forwarding_intr_to_fwq(sc)); KASSERT(nm_rxq->intr_idx < sc->intr_count, ("%s: invalid direct intr_idx %d", __func__, nm_rxq->intr_idx)); @@ -276,8 +443,11 @@ alloc_nm_txq_hwq(struct vi_info *vi, struct sge_nm_txq *nm_txq) c.op_to_vfn = htobe32(V_FW_CMD_OP(FW_EQ_ETH_CMD) | F_FW_CMD_REQUEST | F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_EQ_ETH_CMD_PFN(sc->pf) | V_FW_EQ_ETH_CMD_VFN(0)); - c.alloc_to_len16 = htobe32(F_FW_EQ_ETH_CMD_ALLOC | - F_FW_EQ_ETH_CMD_EQSTART | FW_LEN16(c)); + c.alloc_to_len16 = htobe32(F_FW_EQ_ETH_CMD_EQSTART | FW_LEN16(c)); + if (nm_txq->cntxt_id == INVALID_NM_TXQ_CNTXT_ID) + c.alloc_to_len16 |= htobe32(F_FW_EQ_ETH_CMD_ALLOC); + else + c.eqid_pkd = htobe32(V_FW_EQ_ETH_CMD_EQID(nm_txq->cntxt_id)); c.autoequiqe_to_viid = htobe32(F_FW_EQ_ETH_CMD_AUTOEQUIQE | F_FW_EQ_ETH_CMD_AUTOEQUEQE | V_FW_EQ_ETH_CMD_VIID(vi->viid)); c.fetchszm_to_iqid = @@ -580,8 +750,7 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, for_each_nm_rxq(vi, i, nm_rxq) { kring = na->rx_rings[nm_rxq->nid]; - if (!nm_kring_pending_on(kring) || - nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID) + if (!nm_kring_pending_on(kring)) continue; alloc_nm_rxq_hwq(vi, nm_rxq, tnl_cong(vi->pi, nm_cong_drop)); @@ -611,8 +780,7 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, for_each_nm_txq(vi, i, nm_txq) { kring = na->tx_rings[nm_txq->nid]; - if (!nm_kring_pending_on(kring) || - nm_txq->cntxt_id != INVALID_NM_TXQ_CNTXT_ID) + if (!nm_kring_pending_on(kring)) continue; alloc_nm_txq_hwq(vi, nm_txq); @@ -653,22 +821,17 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, return (rc); /* error message logged already. */ for_each_nm_txq(vi, i, nm_txq) { - struct sge_qstat *spg = (void *)&nm_txq->desc[nm_txq->sidx]; - kring = na->tx_rings[nm_txq->nid]; - if (!nm_kring_pending_off(kring) || - nm_txq->cntxt_id == INVALID_NM_TXQ_CNTXT_ID) + if (!nm_kring_pending_off(kring)) continue; + MPASS(nm_txq->cntxt_id != INVALID_NM_TXQ_CNTXT_ID); - /* Wait for hw pidx to catch up ... */ - while (be16toh(nm_txq->pidx) != spg->pidx) - pause("nmpidx", 1); - - /* ... and then for the cidx. */ - while (spg->pidx != spg->cidx) - pause("nmcidx", 1); - - free_nm_txq_hwq(vi, nm_txq); + rc = -t4_eth_eq_stop(sc, sc->mbox, sc->pf, 0, nm_txq->cntxt_id); + if (rc != 0) { + device_printf(vi->dev, + "failed to stop nm_txq[%d]: %d.\n", i, rc); + return (rc); + } /* XXX: netmap, not the driver, should do this. */ kring->rhead = kring->rcur = kring->nr_hwcur = 0; @@ -680,15 +843,22 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, kring = na->rx_rings[nm_rxq->nid]; if (nm_state != NM_OFF && !nm_kring_pending_off(kring)) nactive++; - if (nm_state == NM_OFF || !nm_kring_pending_off(kring)) + if (!nm_kring_pending_off(kring)) continue; - + MPASS(nm_state != NM_OFF); MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID); + + rc = -t4_iq_stop(sc, sc->mbox, sc->pf, 0, FW_IQ_TYPE_FL_INT_CAP, + nm_rxq->iq_cntxt_id, nm_rxq->fl_cntxt_id, 0xffff); + if (rc != 0) { + device_printf(vi->dev, + "failed to stop nm_rxq[%d]: %d.\n", i, rc); + return (rc); + } + while (!atomic_cmpset_int(&nm_rxq->nm_state, NM_ON, NM_OFF)) pause("nmst", 1); - free_nm_rxq_hwq(vi, nm_rxq); - /* XXX: netmap, not the driver, should do this. */ kring->rhead = kring->rcur = kring->nr_hwcur = 0; kring->rtail = kring->nr_hwtail = 0; diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 4489d40e9fe4..c6ff34a7c17b 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -234,10 +234,6 @@ static inline void init_iq(struct sge_iq *, struct adapter *, int, int, int); static inline void init_fl(struct adapter *, struct sge_fl *, int, int, char *); static inline void init_eq(struct adapter *, struct sge_eq *, int, int, uint8_t, uint16_t, char *); -static int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *, - bus_addr_t *, void **); -static int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, - void *); static int alloc_iq_fl(struct vi_info *, struct sge_iq *, struct sge_fl *, int, int); static int free_iq_fl(struct vi_info *, struct sge_iq *, struct sge_fl *); @@ -257,14 +253,6 @@ static int alloc_ofld_rxq(struct vi_info *, struct sge_ofld_rxq *, int, int, struct sysctl_oid *); static int free_ofld_rxq(struct vi_info *, struct sge_ofld_rxq *); #endif -#ifdef DEV_NETMAP -static int alloc_nm_rxq(struct vi_info *, struct sge_nm_rxq *, int, int, - struct sysctl_oid *); -static int free_nm_rxq(struct vi_info *, struct sge_nm_rxq *); -static int alloc_nm_txq(struct vi_info *, struct sge_nm_txq *, int, int, - struct sysctl_oid *); -static int free_nm_txq(struct vi_info *, struct sge_nm_txq *); -#endif static int ctrl_eq_alloc(struct adapter *, struct sge_eq *); static int eth_eq_alloc(struct adapter *, struct vi_info *, struct sge_eq *); #if defined(TCP_OFFLOAD) || defined(RATELIMIT) @@ -321,7 +309,6 @@ static int t4_handle_wrerr_rpl(struct adapter *, const __be64 *); static void wrq_tx_drain(void *, int); static void drain_wrq_wr_list(struct adapter *, struct sge_wrq *); -static int sysctl_uint16(SYSCTL_HANDLER_ARGS); static int sysctl_bufsizes(SYSCTL_HANDLER_ARGS); #ifdef RATELIMIT static inline u_int txpkt_eo_len16(u_int, u_int, u_int); @@ -3312,7 +3299,7 @@ init_eq(struct adapter *sc, struct sge_eq *eq, int eqtype, int qsize, strlcpy(eq->lockname, name, sizeof(eq->lockname)); } -static int +int alloc_ring(struct adapter *sc, size_t len, bus_dma_tag_t *tag, bus_dmamap_t *map, bus_addr_t *pa, void **va) { @@ -3344,7 +3331,7 @@ done: return (rc); } -static int +int free_ring(struct adapter *sc, bus_dma_tag_t tag, bus_dmamap_t map, bus_addr_t pa, void *va) { @@ -3861,162 +3848,6 @@ free_ofld_rxq(struct vi_info *vi, struct sge_ofld_rxq *ofld_rxq) } #endif -#ifdef DEV_NETMAP -static int -alloc_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int intr_idx, - int idx, struct sysctl_oid *oid) -{ - int rc; - struct sysctl_oid_list *children; - struct sysctl_ctx_list *ctx; - char name[16]; - size_t len; - struct adapter *sc = vi->adapter; - struct netmap_adapter *na = NA(vi->ifp); - - MPASS(na != NULL); - - len = vi->qsize_rxq * IQ_ESIZE; - rc = alloc_ring(sc, len, &nm_rxq->iq_desc_tag, &nm_rxq->iq_desc_map, - &nm_rxq->iq_ba, (void **)&nm_rxq->iq_desc); - if (rc != 0) - return (rc); - - len = na->num_rx_desc * EQ_ESIZE + sc->params.sge.spg_len; - rc = alloc_ring(sc, len, &nm_rxq->fl_desc_tag, &nm_rxq->fl_desc_map, - &nm_rxq->fl_ba, (void **)&nm_rxq->fl_desc); - if (rc != 0) - return (rc); - - nm_rxq->vi = vi; - nm_rxq->nid = idx; - nm_rxq->iq_cidx = 0; - nm_rxq->iq_sidx = vi->qsize_rxq - sc->params.sge.spg_len / IQ_ESIZE; - nm_rxq->iq_gen = F_RSPD_GEN; - nm_rxq->fl_pidx = nm_rxq->fl_cidx = 0; - nm_rxq->fl_sidx = na->num_rx_desc; - nm_rxq->fl_sidx2 = nm_rxq->fl_sidx; /* copy for rxsync cacheline */ - nm_rxq->intr_idx = intr_idx; - nm_rxq->iq_cntxt_id = INVALID_NM_RXQ_CNTXT_ID; - - ctx = &vi->ctx; - children = SYSCTL_CHILDREN(oid); - - snprintf(name, sizeof(name), "%d", idx); - oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, name, CTLFLAG_RD, NULL, - "rx queue"); - children = SYSCTL_CHILDREN(oid); - - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "abs_id", - CTLTYPE_INT | CTLFLAG_RD, &nm_rxq->iq_abs_id, 0, sysctl_uint16, - "I", "absolute id of the queue"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", - CTLTYPE_INT | CTLFLAG_RD, &nm_rxq->iq_cntxt_id, 0, sysctl_uint16, - "I", "SGE context id of the queue"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cidx", - CTLTYPE_INT | CTLFLAG_RD, &nm_rxq->iq_cidx, 0, sysctl_uint16, "I", - "consumer index"); - - children = SYSCTL_CHILDREN(oid); - oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "fl", CTLFLAG_RD, NULL, - "freelist"); - children = SYSCTL_CHILDREN(oid); - - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", - CTLTYPE_INT | CTLFLAG_RD, &nm_rxq->fl_cntxt_id, 0, sysctl_uint16, - "I", "SGE context id of the freelist"); - SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, - &nm_rxq->fl_cidx, 0, "consumer index"); - SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "pidx", CTLFLAG_RD, - &nm_rxq->fl_pidx, 0, "producer index"); - - return (rc); -} - - -static int -free_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq) -{ - struct adapter *sc = vi->adapter; - - if (vi->flags & VI_INIT_DONE) - MPASS(nm_rxq->iq_cntxt_id == INVALID_NM_RXQ_CNTXT_ID); - else - MPASS(nm_rxq->iq_cntxt_id == 0); - - free_ring(sc, nm_rxq->iq_desc_tag, nm_rxq->iq_desc_map, nm_rxq->iq_ba, - nm_rxq->iq_desc); - free_ring(sc, nm_rxq->fl_desc_tag, nm_rxq->fl_desc_map, nm_rxq->fl_ba, - nm_rxq->fl_desc); - - return (0); -} - -static int -alloc_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq, int iqidx, int idx, - struct sysctl_oid *oid) -{ - int rc; - size_t len; - struct port_info *pi = vi->pi; - struct adapter *sc = pi->adapter; - struct netmap_adapter *na = NA(vi->ifp); - char name[16]; - struct sysctl_oid_list *children = SYSCTL_CHILDREN(oid); - - len = na->num_tx_desc * EQ_ESIZE + sc->params.sge.spg_len; - rc = alloc_ring(sc, len, &nm_txq->desc_tag, &nm_txq->desc_map, - &nm_txq->ba, (void **)&nm_txq->desc); - if (rc) - return (rc); - - nm_txq->pidx = nm_txq->cidx = 0; - nm_txq->sidx = na->num_tx_desc; - nm_txq->nid = idx; - nm_txq->iqidx = iqidx; - nm_txq->cpl_ctrl0 = htobe32(V_TXPKT_OPCODE(CPL_TX_PKT) | - V_TXPKT_INTF(pi->tx_chan) | V_TXPKT_PF(sc->pf) | - V_TXPKT_VF(vi->vin) | V_TXPKT_VF_VLD(vi->vfvld)); - if (sc->params.fw_vers >= FW_VERSION32(1, 24, 11, 0)) - nm_txq->op_pkd = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS2_WR)); - else - nm_txq->op_pkd = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS_WR)); - nm_txq->cntxt_id = INVALID_NM_TXQ_CNTXT_ID; - - snprintf(name, sizeof(name), "%d", idx); - oid = SYSCTL_ADD_NODE(&vi->ctx, children, OID_AUTO, name, CTLFLAG_RD, - NULL, "netmap tx queue"); - children = SYSCTL_CHILDREN(oid); - - SYSCTL_ADD_UINT(&vi->ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, - &nm_txq->cntxt_id, 0, "SGE context id of the queue"); - SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "cidx", - CTLTYPE_INT | CTLFLAG_RD, &nm_txq->cidx, 0, sysctl_uint16, "I", - "consumer index"); - SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "pidx", - CTLTYPE_INT | CTLFLAG_RD, &nm_txq->pidx, 0, sysctl_uint16, "I", - "producer index"); - - return (rc); -} - -static int -free_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq) -{ - struct adapter *sc = vi->adapter; - - if (vi->flags & VI_INIT_DONE) - MPASS(nm_txq->cntxt_id == INVALID_NM_TXQ_CNTXT_ID); - else - MPASS(nm_txq->cntxt_id == 0); - - free_ring(sc, nm_txq->desc_tag, nm_txq->desc_map, nm_txq->ba, - nm_txq->desc); - - return (0); -} -#endif - /* * Returns a reasonable automatic cidx flush threshold for a given queue size. */ @@ -6029,7 +5860,7 @@ t4_handle_wrerr_rpl(struct adapter *adap, const __be64 *rpl) return (0); } -static int +int sysctl_uint16(SYSCTL_HANDLER_ARGS) { uint16_t *id = arg1; From nobody Thu Oct 21 00:45:23 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 14A111814E72; Thu, 21 Oct 2021 00: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 4HZTKb6ddYz3Qww; Thu, 21 Oct 2021 00:45: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 BD56B11C4F; Thu, 21 Oct 2021 00: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 19L0jN42068100; Thu, 21 Oct 2021 00: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 19L0jNTk068099; Thu, 21 Oct 2021 00:45:23 GMT (envelope-from git) Date: Thu, 21 Oct 2021 00:45:23 GMT Message-Id: <202110210045.19L0jNTk068099@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 27c4d9242bf0 - releng/12.3 - 12.3: create releng/12.3 branch List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.3 X-Git-Reftype: branch X-Git-Commit: 27c4d9242bf086f2038defcd458bb4b146892add Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/12.3 has been created by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=27c4d9242bf086f2038defcd458bb4b146892add commit 27c4d9242bf086f2038defcd458bb4b146892add Author: Glen Barber AuthorDate: 2021-10-21 00:44:32 +0000 Commit: Glen Barber CommitDate: 2021-10-21 00:44:32 +0000 12.3: create releng/12.3 branch Update from PRERELEASE to BETA1 switch pkg(8) configuration to use 'quarterly' Bump __FreeBSD_version Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/pkg_repos/release-dvd.conf | 2 +- sys/conf/newvers.sh | 2 +- sys/sys/param.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release/pkg_repos/release-dvd.conf b/release/pkg_repos/release-dvd.conf index 95413592b719..34997f2c7067 100644 --- a/release/pkg_repos/release-dvd.conf +++ b/release/pkg_repos/release-dvd.conf @@ -1,6 +1,6 @@ # $FreeBSD$ release: { - url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", + url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 75a68fddfaf9..1e65930884c0 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -49,7 +49,7 @@ TYPE="FreeBSD" REVISION="12.3" -BRANCH="PRERELEASE" +BRANCH="BETA1" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi diff --git a/sys/sys/param.h b/sys/sys/param.h index eea35ca6f893..bedd806b0ebd 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1202508 /* Master, propagated to newvers */ +#define __FreeBSD_version 1203000 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Thu Oct 21 00:48:26 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9F5B41817EED; Thu, 21 Oct 2021 00:48: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 4HZTP63rZBz3jxK; Thu, 21 Oct 2021 00:48: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 6191911DA2; Thu, 21 Oct 2021 00:48: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 19L0mQY3068741; Thu, 21 Oct 2021 00:48:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19L0mQG6068740; Thu, 21 Oct 2021 00:48:26 GMT (envelope-from git) Date: Thu, 21 Oct 2021 00:48:26 GMT Message-Id: <202110210048.19L0mQG6068740@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: f2900e784cb0 - stable/12 - 12.3: rename stable/12 to -STABLE List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: f2900e784cb024e55ec0f5cd6834af5fadcb9f9a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=f2900e784cb024e55ec0f5cd6834af5fadcb9f9a commit f2900e784cb024e55ec0f5cd6834af5fadcb9f9a Author: Glen Barber AuthorDate: 2021-10-21 00:48:09 +0000 Commit: Glen Barber CommitDate: 2021-10-21 00:48:09 +0000 12.3: rename stable/12 to -STABLE Bump __FreeBSD_version while here Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/newvers.sh | 2 +- sys/sys/param.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 75a68fddfaf9..751d395ad519 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -49,7 +49,7 @@ TYPE="FreeBSD" REVISION="12.3" -BRANCH="PRERELEASE" +BRANCH="STABLE" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi diff --git a/sys/sys/param.h b/sys/sys/param.h index eea35ca6f893..2bfe64db455a 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1202508 /* Master, propagated to newvers */ +#define __FreeBSD_version 1203500 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Thu Oct 21 05:39:46 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AF7CA17F9628; Thu, 21 Oct 2021 05: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 4HZbsG4c4dz4Rj0; Thu, 21 Oct 2021 05: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 7D918156EF; Thu, 21 Oct 2021 05: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 19L5dk0H054534; Thu, 21 Oct 2021 05: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 19L5dk61054533; Thu, 21 Oct 2021 05:39:46 GMT (envelope-from git) Date: Thu, 21 Oct 2021 05:39:46 GMT Message-Id: <202110210539.19L5dk61054533@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: c6d4cd2a81c8 - stable/13 - contrib/tzdata: correct DST in Fiji List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c6d4cd2a81c817bdbd68a94fb6f809ac5d960084 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=c6d4cd2a81c817bdbd68a94fb6f809ac5d960084 commit c6d4cd2a81c817bdbd68a94fb6f809ac5d960084 Author: Philip Paeps AuthorDate: 2021-10-18 06:19:42 +0000 Commit: Philip Paeps CommitDate: 2021-10-21 05:31:14 +0000 contrib/tzdata: correct DST in Fiji Direct commit to stable/13. Unfortunately, there is still no clear consensus on the tz mailing list about some of the changes introduced by tzdata 2021b and later releases. Pending consensus, only merge the recently announced DST transition date for Fiji and corrections to commentary from tzdata 2021d. This corrects future timestamps in Fiji. --- contrib/tzdata/australasia | 24 +++++++++++++++++++----- contrib/tzdata/europe | 13 ++++++++----- contrib/tzdata/northamerica | 6 +++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/contrib/tzdata/australasia b/contrib/tzdata/australasia index a2c5ee86eecf..eba0fad1c213 100644 --- a/contrib/tzdata/australasia +++ b/contrib/tzdata/australasia @@ -385,9 +385,22 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # "Minister for Employment, Parveen Bala says they had never thought of # stopping daylight saving. He says it was just to decide on when it should # start and end. Bala says it is a short period..." -# Since the end date is still in line with our ongoing predictions, assume for -# now that the later-than-usual start date is a one-time departure from the -# recent second Sunday in November pattern. +# +# From Tim Parenti (2021-10-11), per Jashneel Kumar (2021-10-11) and P Chan +# (2021-10-12): +# https://www.fiji.gov.fj/Media-Centre/Speeches/English/PM-BAINIMARAMA-S-COVID-19-ANNOUNCEMENT-10-10-21 +# https://www.fbcnews.com.fj/news/covid-19/curfew-moved-back-to-11pm/ +# In a 2021-10-10 speech concerning updated Covid-19 mitigation measures in +# Fiji, prime minister Josaia Voreqe "Frank" Bainimarama announced the +# suspension of DST for the 2021/2022 season: "Given that we are in the process +# of readjusting in the midst of so many changes, we will also put Daylight +# Savings Time on hold for this year. It will also make the reopening of +# scheduled commercial air service much smoother if we don't have to be +# concerned shifting arrival and departure times, which may look like a simple +# thing but requires some significant logistical adjustments domestically and +# internationally." +# Assume for now that DST will resume with the recent pre-2020 rules for the +# 2022/2023 season. # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 - @@ -399,10 +412,11 @@ Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 2018 - Nov Sun>=1 2:00 1:00 - -Rule Fiji 2015 max - Jan Sun>=12 3:00 0 - +Rule Fiji 2015 2021 - Jan Sun>=12 3:00 0 - Rule Fiji 2019 only - Nov Sun>=8 2:00 1:00 - Rule Fiji 2020 only - Dec 20 2:00 1:00 - -Rule Fiji 2021 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2022 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2023 max - Jan Sun>=12 3:00 0 - # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji +12/+13 diff --git a/contrib/tzdata/europe b/contrib/tzdata/europe index bba4d5648228..d91e0ce5f8f7 100644 --- a/contrib/tzdata/europe +++ b/contrib/tzdata/europe @@ -822,7 +822,7 @@ Zone Europe/Andorra 0:06:04 - LMT 1901 # Shanks & Pottenger give 02:00, the BEV 00:00. Go with the BEV, # and guess 02:00 for 1945-04-12. -# From Alois Triendl (2019-07-22): +# From Alois Treindl (2019-07-22): # In 1946 the end of DST was on Monday, 7 October 1946, at 3:00 am. # Shanks had this right. Source: Die Weltpresse, 5. Oktober 1946, page 5. @@ -1736,19 +1736,22 @@ Zone Atlantic/Reykjavik -1:28 - LMT 1908 # advanced to sixty minutes later starting at hour two on 1944-04-02; ... # Starting at hour three on the date 1944-09-17 standard time will be resumed. # -# From Alois Triendl (2019-07-02): +# From Alois Treindl (2019-07-02): # I spent 6 Euros to buy two archive copies of Il Messaggero, a Roman paper, # for 1 and 2 April 1944. The edition of 2 April has this note: "Tonight at 2 # am, put forward the clock by one hour. Remember that in the night between # today and Monday the 'ora legale' will come in force again." That makes it # clear that in Rome the change was on Monday, 3 April 1944 at 2 am. # -# From Paul Eggert (2016-10-27): +# From Paul Eggert (2021-10-05): # Go with INRiM for DST rules, except as corrected by Inglis for 1944 # for the Kingdom of Italy. This is consistent with Renzo Baldini. # Model Rome's occupation by using C-Eur rules from 1943-09-10 # to 1944-06-04; although Rome was an open city during this period, it -# was effectively controlled by Germany. +# was effectively controlled by Germany. Using C-Eur is consistent +# with Treindl's comment about Rome in April 1944, as the "Rule Italy" +# lines during German occupation do not affect Europe/Rome +# (though they do affect Europe/Malta). # # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Italy 1916 only - Jun 3 24:00 1:00 S @@ -2618,7 +2621,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # Although Shanks lists 1945-01-01 as the date for transition from # +01/+02 to +02/+03, more likely this is a placeholder. Guess that # the transition occurred at 1945-04-10 00:00, which is about when -# Königsberg surrendered to Soviet troops. (Thanks to Alois Triendl.) +# Königsberg surrendered to Soviet troops. (Thanks to Alois Treindl.) # From Paul Eggert (2016-03-18): # The 1989 transition is from USSR act No. 227 (1989-03-14). diff --git a/contrib/tzdata/northamerica b/contrib/tzdata/northamerica index ddc575976e59..75e115418a1e 100644 --- a/contrib/tzdata/northamerica +++ b/contrib/tzdata/northamerica @@ -970,7 +970,7 @@ Zone America/Indiana/Vincennes -5:50:07 - LMT 1883 Nov 18 12:09:53 -5:00 US E%sT # # Perry County, Indiana, switched from eastern to central time in April 2006. -# From Alois Triendl (2019-07-09): +# From Alois Treindl (2019-07-09): # The Indianapolis News, Friday 27 October 1967 states that Perry County # returned to CST. It went again to EST on 27 April 1969, as documented by the # Indianapolis star of Saturday 26 April. @@ -1998,7 +1998,7 @@ Zone America/Swift_Current -7:11:20 - LMT 1905 Sep # Alberta -# From Alois Triendl (2019-07-19): +# From Alois Treindl (2019-07-19): # There was no DST in Alberta in 1967... Calgary Herald, 29 April 1967. # 1969, no DST, from Edmonton Journal 18 April 1969 # @@ -2107,7 +2107,7 @@ Zone America/Edmonton -7:33:52 - LMT 1906 Sep # # From Paul Eggert (2019-07-25): # Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver. -# Alois Triendl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily +# Alois Treindl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily # Province. He also cited the 1946-09-28 Victoria Daily Times, which said # that Vancouver, Victoria, etc. "change at midnight Saturday"; for now, # guess they meant 02:00 Sunday since 02:00 was common practice in Vancouver. From nobody Thu Oct 21 05:40:00 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 32D6717F9A03; Thu, 21 Oct 2021 05:40: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 4HZbsY0nFyz4S0D; Thu, 21 Oct 2021 05:40: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 EFD30156F2; Thu, 21 Oct 2021 05:40: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 19L5e0nd055604; Thu, 21 Oct 2021 05:40:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19L5e0ZI055579; Thu, 21 Oct 2021 05:40:00 GMT (envelope-from git) Date: Thu, 21 Oct 2021 05:40:00 GMT Message-Id: <202110210540.19L5e0ZI055579@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: 74a0f31dbbd0 - stable/12 - contrib/tzdata: correct DST in Fiji List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 74a0f31dbbd0b32689d63d8c965c611bdfc4da2f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=74a0f31dbbd0b32689d63d8c965c611bdfc4da2f commit 74a0f31dbbd0b32689d63d8c965c611bdfc4da2f Author: Philip Paeps AuthorDate: 2021-10-18 06:19:42 +0000 Commit: Philip Paeps CommitDate: 2021-10-21 05:37:38 +0000 contrib/tzdata: correct DST in Fiji Direct commit to stable/12. Unfortunately, there is still no clear consensus on the tz mailing list about some of the changes introduced by tzdata 2021b and later releases. Pending consensus, only merge the recently announced DST transition date for Fiji and corrections to commentary from tzdata 2021d. This corrects future timestamps in Fiji. --- contrib/tzdata/australasia | 24 +++++++++++++++++++----- contrib/tzdata/europe | 13 ++++++++----- contrib/tzdata/northamerica | 6 +++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/contrib/tzdata/australasia b/contrib/tzdata/australasia index a2c5ee86eecf..eba0fad1c213 100644 --- a/contrib/tzdata/australasia +++ b/contrib/tzdata/australasia @@ -385,9 +385,22 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # "Minister for Employment, Parveen Bala says they had never thought of # stopping daylight saving. He says it was just to decide on when it should # start and end. Bala says it is a short period..." -# Since the end date is still in line with our ongoing predictions, assume for -# now that the later-than-usual start date is a one-time departure from the -# recent second Sunday in November pattern. +# +# From Tim Parenti (2021-10-11), per Jashneel Kumar (2021-10-11) and P Chan +# (2021-10-12): +# https://www.fiji.gov.fj/Media-Centre/Speeches/English/PM-BAINIMARAMA-S-COVID-19-ANNOUNCEMENT-10-10-21 +# https://www.fbcnews.com.fj/news/covid-19/curfew-moved-back-to-11pm/ +# In a 2021-10-10 speech concerning updated Covid-19 mitigation measures in +# Fiji, prime minister Josaia Voreqe "Frank" Bainimarama announced the +# suspension of DST for the 2021/2022 season: "Given that we are in the process +# of readjusting in the midst of so many changes, we will also put Daylight +# Savings Time on hold for this year. It will also make the reopening of +# scheduled commercial air service much smoother if we don't have to be +# concerned shifting arrival and departure times, which may look like a simple +# thing but requires some significant logistical adjustments domestically and +# internationally." +# Assume for now that DST will resume with the recent pre-2020 rules for the +# 2022/2023 season. # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 - @@ -399,10 +412,11 @@ Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 2018 - Nov Sun>=1 2:00 1:00 - -Rule Fiji 2015 max - Jan Sun>=12 3:00 0 - +Rule Fiji 2015 2021 - Jan Sun>=12 3:00 0 - Rule Fiji 2019 only - Nov Sun>=8 2:00 1:00 - Rule Fiji 2020 only - Dec 20 2:00 1:00 - -Rule Fiji 2021 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2022 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2023 max - Jan Sun>=12 3:00 0 - # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji +12/+13 diff --git a/contrib/tzdata/europe b/contrib/tzdata/europe index bba4d5648228..d91e0ce5f8f7 100644 --- a/contrib/tzdata/europe +++ b/contrib/tzdata/europe @@ -822,7 +822,7 @@ Zone Europe/Andorra 0:06:04 - LMT 1901 # Shanks & Pottenger give 02:00, the BEV 00:00. Go with the BEV, # and guess 02:00 for 1945-04-12. -# From Alois Triendl (2019-07-22): +# From Alois Treindl (2019-07-22): # In 1946 the end of DST was on Monday, 7 October 1946, at 3:00 am. # Shanks had this right. Source: Die Weltpresse, 5. Oktober 1946, page 5. @@ -1736,19 +1736,22 @@ Zone Atlantic/Reykjavik -1:28 - LMT 1908 # advanced to sixty minutes later starting at hour two on 1944-04-02; ... # Starting at hour three on the date 1944-09-17 standard time will be resumed. # -# From Alois Triendl (2019-07-02): +# From Alois Treindl (2019-07-02): # I spent 6 Euros to buy two archive copies of Il Messaggero, a Roman paper, # for 1 and 2 April 1944. The edition of 2 April has this note: "Tonight at 2 # am, put forward the clock by one hour. Remember that in the night between # today and Monday the 'ora legale' will come in force again." That makes it # clear that in Rome the change was on Monday, 3 April 1944 at 2 am. # -# From Paul Eggert (2016-10-27): +# From Paul Eggert (2021-10-05): # Go with INRiM for DST rules, except as corrected by Inglis for 1944 # for the Kingdom of Italy. This is consistent with Renzo Baldini. # Model Rome's occupation by using C-Eur rules from 1943-09-10 # to 1944-06-04; although Rome was an open city during this period, it -# was effectively controlled by Germany. +# was effectively controlled by Germany. Using C-Eur is consistent +# with Treindl's comment about Rome in April 1944, as the "Rule Italy" +# lines during German occupation do not affect Europe/Rome +# (though they do affect Europe/Malta). # # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Italy 1916 only - Jun 3 24:00 1:00 S @@ -2618,7 +2621,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # Although Shanks lists 1945-01-01 as the date for transition from # +01/+02 to +02/+03, more likely this is a placeholder. Guess that # the transition occurred at 1945-04-10 00:00, which is about when -# Königsberg surrendered to Soviet troops. (Thanks to Alois Triendl.) +# Königsberg surrendered to Soviet troops. (Thanks to Alois Treindl.) # From Paul Eggert (2016-03-18): # The 1989 transition is from USSR act No. 227 (1989-03-14). diff --git a/contrib/tzdata/northamerica b/contrib/tzdata/northamerica index ddc575976e59..75e115418a1e 100644 --- a/contrib/tzdata/northamerica +++ b/contrib/tzdata/northamerica @@ -970,7 +970,7 @@ Zone America/Indiana/Vincennes -5:50:07 - LMT 1883 Nov 18 12:09:53 -5:00 US E%sT # # Perry County, Indiana, switched from eastern to central time in April 2006. -# From Alois Triendl (2019-07-09): +# From Alois Treindl (2019-07-09): # The Indianapolis News, Friday 27 October 1967 states that Perry County # returned to CST. It went again to EST on 27 April 1969, as documented by the # Indianapolis star of Saturday 26 April. @@ -1998,7 +1998,7 @@ Zone America/Swift_Current -7:11:20 - LMT 1905 Sep # Alberta -# From Alois Triendl (2019-07-19): +# From Alois Treindl (2019-07-19): # There was no DST in Alberta in 1967... Calgary Herald, 29 April 1967. # 1969, no DST, from Edmonton Journal 18 April 1969 # @@ -2107,7 +2107,7 @@ Zone America/Edmonton -7:33:52 - LMT 1906 Sep # # From Paul Eggert (2019-07-25): # Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver. -# Alois Triendl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily +# Alois Treindl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily # Province. He also cited the 1946-09-28 Victoria Daily Times, which said # that Vancouver, Victoria, etc. "change at midnight Saturday"; for now, # guess they meant 02:00 Sunday since 02:00 was common practice in Vancouver. From nobody Thu Oct 21 05:40:18 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 520D917F9E07; Thu, 21 Oct 2021 05:40: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 4HZbst1mn7z4RyP; Thu, 21 Oct 2021 05:40: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 1E43415CCE; Thu, 21 Oct 2021 05:40: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 19L5eIKd061235; Thu, 21 Oct 2021 05:40:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19L5eIdp061227; Thu, 21 Oct 2021 05:40:18 GMT (envelope-from git) Date: Thu, 21 Oct 2021 05:40:18 GMT Message-Id: <202110210540.19L5eIdp061227@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: b7d19f92bfc6 - stable/11 - contrib/tzdata: correct DST in Fiji List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: b7d19f92bfc6c8edcfa78090f6656f2322be4fa7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/11 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=b7d19f92bfc6c8edcfa78090f6656f2322be4fa7 commit b7d19f92bfc6c8edcfa78090f6656f2322be4fa7 Author: Philip Paeps AuthorDate: 2021-10-18 06:19:42 +0000 Commit: Philip Paeps CommitDate: 2021-10-21 05:38:31 +0000 contrib/tzdata: correct DST in Fiji Direct commit to stable/11. Unfortunately, there is still no clear consensus on the tz mailing list about some of the changes introduced by tzdata 2021b and later releases. Pending consensus, only merge the recently announced DST transition date for Fiji and corrections to commentary from tzdata 2021d. This corrects future timestamps in Fiji. --- contrib/tzdata/australasia | 24 +++++++++++++++++++----- contrib/tzdata/europe | 13 ++++++++----- contrib/tzdata/northamerica | 6 +++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/contrib/tzdata/australasia b/contrib/tzdata/australasia index a2c5ee86eecf..eba0fad1c213 100644 --- a/contrib/tzdata/australasia +++ b/contrib/tzdata/australasia @@ -385,9 +385,22 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # "Minister for Employment, Parveen Bala says they had never thought of # stopping daylight saving. He says it was just to decide on when it should # start and end. Bala says it is a short period..." -# Since the end date is still in line with our ongoing predictions, assume for -# now that the later-than-usual start date is a one-time departure from the -# recent second Sunday in November pattern. +# +# From Tim Parenti (2021-10-11), per Jashneel Kumar (2021-10-11) and P Chan +# (2021-10-12): +# https://www.fiji.gov.fj/Media-Centre/Speeches/English/PM-BAINIMARAMA-S-COVID-19-ANNOUNCEMENT-10-10-21 +# https://www.fbcnews.com.fj/news/covid-19/curfew-moved-back-to-11pm/ +# In a 2021-10-10 speech concerning updated Covid-19 mitigation measures in +# Fiji, prime minister Josaia Voreqe "Frank" Bainimarama announced the +# suspension of DST for the 2021/2022 season: "Given that we are in the process +# of readjusting in the midst of so many changes, we will also put Daylight +# Savings Time on hold for this year. It will also make the reopening of +# scheduled commercial air service much smoother if we don't have to be +# concerned shifting arrival and departure times, which may look like a simple +# thing but requires some significant logistical adjustments domestically and +# internationally." +# Assume for now that DST will resume with the recent pre-2020 rules for the +# 2022/2023 season. # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 - @@ -399,10 +412,11 @@ Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 2018 - Nov Sun>=1 2:00 1:00 - -Rule Fiji 2015 max - Jan Sun>=12 3:00 0 - +Rule Fiji 2015 2021 - Jan Sun>=12 3:00 0 - Rule Fiji 2019 only - Nov Sun>=8 2:00 1:00 - Rule Fiji 2020 only - Dec 20 2:00 1:00 - -Rule Fiji 2021 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2022 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2023 max - Jan Sun>=12 3:00 0 - # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji +12/+13 diff --git a/contrib/tzdata/europe b/contrib/tzdata/europe index bba4d5648228..d91e0ce5f8f7 100644 --- a/contrib/tzdata/europe +++ b/contrib/tzdata/europe @@ -822,7 +822,7 @@ Zone Europe/Andorra 0:06:04 - LMT 1901 # Shanks & Pottenger give 02:00, the BEV 00:00. Go with the BEV, # and guess 02:00 for 1945-04-12. -# From Alois Triendl (2019-07-22): +# From Alois Treindl (2019-07-22): # In 1946 the end of DST was on Monday, 7 October 1946, at 3:00 am. # Shanks had this right. Source: Die Weltpresse, 5. Oktober 1946, page 5. @@ -1736,19 +1736,22 @@ Zone Atlantic/Reykjavik -1:28 - LMT 1908 # advanced to sixty minutes later starting at hour two on 1944-04-02; ... # Starting at hour three on the date 1944-09-17 standard time will be resumed. # -# From Alois Triendl (2019-07-02): +# From Alois Treindl (2019-07-02): # I spent 6 Euros to buy two archive copies of Il Messaggero, a Roman paper, # for 1 and 2 April 1944. The edition of 2 April has this note: "Tonight at 2 # am, put forward the clock by one hour. Remember that in the night between # today and Monday the 'ora legale' will come in force again." That makes it # clear that in Rome the change was on Monday, 3 April 1944 at 2 am. # -# From Paul Eggert (2016-10-27): +# From Paul Eggert (2021-10-05): # Go with INRiM for DST rules, except as corrected by Inglis for 1944 # for the Kingdom of Italy. This is consistent with Renzo Baldini. # Model Rome's occupation by using C-Eur rules from 1943-09-10 # to 1944-06-04; although Rome was an open city during this period, it -# was effectively controlled by Germany. +# was effectively controlled by Germany. Using C-Eur is consistent +# with Treindl's comment about Rome in April 1944, as the "Rule Italy" +# lines during German occupation do not affect Europe/Rome +# (though they do affect Europe/Malta). # # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Italy 1916 only - Jun 3 24:00 1:00 S @@ -2618,7 +2621,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # Although Shanks lists 1945-01-01 as the date for transition from # +01/+02 to +02/+03, more likely this is a placeholder. Guess that # the transition occurred at 1945-04-10 00:00, which is about when -# Königsberg surrendered to Soviet troops. (Thanks to Alois Triendl.) +# Königsberg surrendered to Soviet troops. (Thanks to Alois Treindl.) # From Paul Eggert (2016-03-18): # The 1989 transition is from USSR act No. 227 (1989-03-14). diff --git a/contrib/tzdata/northamerica b/contrib/tzdata/northamerica index ddc575976e59..75e115418a1e 100644 --- a/contrib/tzdata/northamerica +++ b/contrib/tzdata/northamerica @@ -970,7 +970,7 @@ Zone America/Indiana/Vincennes -5:50:07 - LMT 1883 Nov 18 12:09:53 -5:00 US E%sT # # Perry County, Indiana, switched from eastern to central time in April 2006. -# From Alois Triendl (2019-07-09): +# From Alois Treindl (2019-07-09): # The Indianapolis News, Friday 27 October 1967 states that Perry County # returned to CST. It went again to EST on 27 April 1969, as documented by the # Indianapolis star of Saturday 26 April. @@ -1998,7 +1998,7 @@ Zone America/Swift_Current -7:11:20 - LMT 1905 Sep # Alberta -# From Alois Triendl (2019-07-19): +# From Alois Treindl (2019-07-19): # There was no DST in Alberta in 1967... Calgary Herald, 29 April 1967. # 1969, no DST, from Edmonton Journal 18 April 1969 # @@ -2107,7 +2107,7 @@ Zone America/Edmonton -7:33:52 - LMT 1906 Sep # # From Paul Eggert (2019-07-25): # Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver. -# Alois Triendl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily +# Alois Treindl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily # Province. He also cited the 1946-09-28 Victoria Daily Times, which said # that Vancouver, Victoria, etc. "change at midnight Saturday"; for now, # guess they meant 02:00 Sunday since 02:00 was common practice in Vancouver. From nobody Thu Oct 21 17:06:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7716C18066F1; Thu, 21 Oct 2021 17:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HZv622cGnz4gw5; Thu, 21 Oct 2021 17:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38EB71EFB2; Thu, 21 Oct 2021 17:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19LH6okU080050; Thu, 21 Oct 2021 17:06:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6o2l080049; Thu, 21 Oct 2021 17:06:50 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:50 GMT Message-Id: <202110211706.19LH6o2l080049@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: ec3872a696a9 - stable/13 - Add an OCF algorithm for ChaCha20-Poly1305 AEAD. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: ec3872a696a9b931ca8366c616bf9efc2dbfe8f8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ec3872a696a9b931ca8366c616bf9efc2dbfe8f8 commit ec3872a696a9b931ca8366c616bf9efc2dbfe8f8 Author: John Baldwin AuthorDate: 2021-02-18 17:21:56 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:22 +0000 Add an OCF algorithm for ChaCha20-Poly1305 AEAD. Note that this algorithm implements the mode defined in RFC 8439. Reviewed by: cem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27836 (cherry picked from commit fc8fc743d89388c0c5b97a491428fab2b36beac8) --- share/man/man7/crypto.7 | 4 +++- sys/conf/files | 1 + sys/modules/crypto/Makefile | 1 + sys/opencrypto/crypto.c | 12 +++++----- sys/opencrypto/cryptodev.c | 11 +++++++++ sys/opencrypto/cryptodev.h | 5 +++- sys/opencrypto/xform_chacha20_poly1305.c | 41 ++++++++++++++++++++++++++++++++ sys/opencrypto/xform_enc.h | 1 + 8 files changed, 68 insertions(+), 8 deletions(-) diff --git a/share/man/man7/crypto.7 b/share/man/man7/crypto.7 index d6cae1e39819..ccc2d1fc9be3 100644 --- a/share/man/man7/crypto.7 +++ b/share/man/man7/crypto.7 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 20, 2021 +.Dd February 18, 2021 .Dt CRYPTO 7 .Os .Sh NAME @@ -161,6 +161,8 @@ The following AEAD algorithms are supported: AES Galois/Counter Mode .It Dv CRYPTO_AES_CCM_16 Ta 12 Ta 16, 24, 32 Ta 16 Ta AES Counter with CBC-MAC +.It Dv CRYPTO_CHACHA20_POLY1305 Ta 12 Ta 32 Ta 16 Ta +ChaCha20-Poly1305 .El .Sh SEE ALSO .Xr crypto 4 , diff --git a/sys/conf/files b/sys/conf/files index 2d3ae104753d..a352a0759c99 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4948,6 +4948,7 @@ opencrypto/gfmult.c optional crypto | ipsec | ipsec_support opencrypto/rmd160.c optional crypto | ipsec | ipsec_support opencrypto/xform.c optional crypto | ipsec | ipsec_support opencrypto/xform_cbc_mac.c optional crypto +opencrypto/xform_chacha20_poly1305.c optional crypto opencrypto/xform_poly1305.c optional crypto \ compile-with "${NORMAL_C} -I$S/contrib/libsodium/src/libsodium/include -I$S/crypto/libsodium" contrib/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c \ diff --git a/sys/modules/crypto/Makefile b/sys/modules/crypto/Makefile index 01ade43a0e51..89af6ab8fc61 100644 --- a/sys/modules/crypto/Makefile +++ b/sys/modules/crypto/Makefile @@ -67,6 +67,7 @@ SRCS += randombytes.c CFLAGS.randombytes.c += -I${LIBSODIUM_INC} -I${LIBSODIUM_COMPAT} SRCS += utils.c CFLAGS.utils.c += -I${LIBSODIUM_INC} -I${LIBSODIUM_COMPAT} +SRCS += xform_chacha20_poly1305.c SRCS += opt_param.h cryptodev_if.h bus_if.h device_if.h SRCS += opt_compat.h diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index 59c74c86de00..704077043bb8 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -602,6 +602,8 @@ crypto_cipher(const struct crypto_session_params *csp) return (&enc_xform_chacha20); case CRYPTO_AES_CCM_16: return (&enc_xform_ccm); + case CRYPTO_CHACHA20_POLY1305: + return (&enc_xform_chacha20_poly1305); default: return (NULL); } @@ -693,6 +695,7 @@ static enum alg_type { [CRYPTO_POLY1305] = ALG_KEYED_DIGEST, [CRYPTO_AES_CCM_CBC_MAC] = ALG_KEYED_DIGEST, [CRYPTO_AES_CCM_16] = ALG_AEAD, + [CRYPTO_CHACHA20_POLY1305] = ALG_AEAD, }; static enum alg_type @@ -837,6 +840,7 @@ check_csp(const struct crypto_session_params *csp) switch (csp->csp_cipher_alg) { case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_CCM_16: + case CRYPTO_CHACHA20_POLY1305: if (csp->csp_auth_mlen > 16) return (false); break; @@ -1310,12 +1314,8 @@ crp_sanity(struct cryptop *crp) crp->crp_op == (CRYPTO_OP_DECRYPT | CRYPTO_OP_VERIFY_DIGEST), ("invalid AEAD op %x", crp->crp_op)); - if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16) - KASSERT(crp->crp_flags & CRYPTO_F_IV_SEPARATE, - ("GCM without a separate IV")); - if (csp->csp_cipher_alg == CRYPTO_AES_CCM_16) - KASSERT(crp->crp_flags & CRYPTO_F_IV_SEPARATE, - ("CCM without a separate IV")); + KASSERT(crp->crp_flags & CRYPTO_F_IV_SEPARATE, + ("AEAD without a separate IV")); break; case CSP_MODE_ETA: KASSERT(crp->crp_op == diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 61f8f332e1ca..81c6dcd01e2a 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -428,6 +428,9 @@ cse_create(struct fcrypt *fcr, struct session2_op *sop) case CRYPTO_AES_CCM_16: txform = &enc_xform_ccm; break; + case CRYPTO_CHACHA20_POLY1305: + txform = &enc_xform_chacha20_poly1305; + break; default: CRYPTDEB("invalid cipher"); SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); @@ -586,6 +589,12 @@ cse_create(struct fcrypt *fcr, struct session2_op *sop) return (EINVAL); } csp.csp_mode = CSP_MODE_AEAD; + } else if (sop->cipher == CRYPTO_CHACHA20_POLY1305) { + if (sop->mac != 0) { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + return (EINVAL); + } + csp.csp_mode = CSP_MODE_AEAD; } else if (txform != NULL && thash != NULL) csp.csp_mode = CSP_MODE_ETA; else if (txform != NULL) @@ -679,6 +688,8 @@ cse_create(struct fcrypt *fcr, struct session2_op *sop) cse->hashsize = AES_GMAC_HASH_LEN; else if (csp.csp_cipher_alg == CRYPTO_AES_CCM_16) cse->hashsize = AES_CBC_MAC_HASH_LEN; + else if (csp.csp_cipher_alg == CRYPTO_CHACHA20_POLY1305) + cse->hashsize = POLY1305_HASH_LEN; cse->ivsize = csp.csp_ivlen; mtx_lock(&fcr->lock); diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index ecb1d929d1db..277867734841 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -124,6 +124,7 @@ #define AES_CCM_IV_LEN 12 #define AES_XTS_IV_LEN 8 #define AES_XTS_ALPHA 0x87 /* GF(2^128) generator polynomial */ +#define CHACHA20_POLY1305_IV_LEN 12 /* Min and Max Encryption Key Sizes */ #define NULL_MIN_KEY 0 @@ -136,6 +137,7 @@ #define AES_XTS_MAX_KEY (2 * AES_MAX_KEY) #define CAMELLIA_MIN_KEY 16 #define CAMELLIA_MAX_KEY 32 +#define CHACHA20_POLY1305_KEY 32 /* Maximum hash algorithm result length */ #define AALG_MAX_RESULT_LEN 64 /* Keep this updated */ @@ -184,7 +186,8 @@ #define CRYPTO_POLY1305 38 #define CRYPTO_AES_CCM_CBC_MAC 39 /* auth side */ #define CRYPTO_AES_CCM_16 40 /* cipher side */ -#define CRYPTO_ALGORITHM_MAX 40 /* Keep updated - see below */ +#define CRYPTO_CHACHA20_POLY1305 41 /* combined AEAD cipher per RFC 8439 */ +#define CRYPTO_ALGORITHM_MAX 41 /* Keep updated - see below */ #define CRYPTO_ALGO_VALID(x) ((x) >= CRYPTO_ALGORITHM_MIN && \ (x) <= CRYPTO_ALGORITHM_MAX) diff --git a/sys/opencrypto/xform_chacha20_poly1305.c b/sys/opencrypto/xform_chacha20_poly1305.c new file mode 100644 index 000000000000..e568e76cad51 --- /dev/null +++ b/sys/opencrypto/xform_chacha20_poly1305.c @@ -0,0 +1,41 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Netflix 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 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. + */ + +#include +#include + +struct enc_xform enc_xform_chacha20_poly1305 = { + .type = CRYPTO_CHACHA20_POLY1305, + .name = "ChaCha20-Poly1305", + .ctxsize = sizeof(struct chacha_ctx), + .blocksize = 1, + .native_blocksize = CHACHA_BLOCKLEN, + .ivsize = CHACHA20_POLY1305_IV_LEN, + .minkey = CHACHA20_POLY1305_KEY, + .maxkey = CHACHA20_POLY1305_KEY, +}; + diff --git a/sys/opencrypto/xform_enc.h b/sys/opencrypto/xform_enc.h index b44f1ff0c270..e8325f20917b 100644 --- a/sys/opencrypto/xform_enc.h +++ b/sys/opencrypto/xform_enc.h @@ -81,6 +81,7 @@ extern struct enc_xform enc_xform_aes_nist_gmac; extern struct enc_xform enc_xform_aes_xts; extern struct enc_xform enc_xform_camellia; extern struct enc_xform enc_xform_chacha20; +extern struct enc_xform enc_xform_chacha20_poly1305; extern struct enc_xform enc_xform_ccm; struct aes_icm_ctx { From nobody Thu Oct 21 17:06:51 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8555218067CE; Thu, 21 Oct 2021 17:06: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 4HZv6338DVz4h0C; Thu, 21 Oct 2021 17:06: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 48CAB1F20B; Thu, 21 Oct 2021 17:06: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 19LH6ppE080074; Thu, 21 Oct 2021 17:06:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6pms080073; Thu, 21 Oct 2021 17:06:51 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:51 GMT Message-Id: <202110211706.19LH6pms080073@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: d5cbcae312e7 - stable/13 - Add an implementation of CHACHA20_POLY1305 to cryptosoft. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: d5cbcae312e705fb89e2ce79c823e9d8697c6b0c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d5cbcae312e705fb89e2ce79c823e9d8697c6b0c commit d5cbcae312e705fb89e2ce79c823e9d8697c6b0c Author: John Baldwin AuthorDate: 2021-02-18 17:22:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:22 +0000 Add an implementation of CHACHA20_POLY1305 to cryptosoft. This uses the chacha20 IETF and poly1305 implementations from libsodium. A seperate auth_hash is created for the auth side whose Setkey method derives the poly1305 key from the AEAD key and nonce as described in RFC 8439. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27837 (cherry picked from commit dd2e1352b68aa33f7f6f8c19aaf88cf287013ae8) --- sys/conf/files | 3 +- sys/modules/crypto/Makefile | 9 +- sys/opencrypto/cryptosoft.c | 199 +++++++++++++++++++++++++++++++ sys/opencrypto/xform_auth.h | 1 + sys/opencrypto/xform_chacha20_poly1305.c | 128 +++++++++++++++++++- 5 files changed, 335 insertions(+), 5 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index a352a0759c99..f21c216288b1 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4948,7 +4948,8 @@ opencrypto/gfmult.c optional crypto | ipsec | ipsec_support opencrypto/rmd160.c optional crypto | ipsec | ipsec_support opencrypto/xform.c optional crypto | ipsec | ipsec_support opencrypto/xform_cbc_mac.c optional crypto -opencrypto/xform_chacha20_poly1305.c optional crypto +opencrypto/xform_chacha20_poly1305.c optional crypto \ + compile-with "${NORMAL_C} -I$S/contrib/libsodium/src/libsodium/include -I$S/crypto/libsodium" opencrypto/xform_poly1305.c optional crypto \ compile-with "${NORMAL_C} -I$S/contrib/libsodium/src/libsodium/include -I$S/crypto/libsodium" contrib/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c \ diff --git a/sys/modules/crypto/Makefile b/sys/modules/crypto/Makefile index 89af6ab8fc61..f64ea1f6fc8b 100644 --- a/sys/modules/crypto/Makefile +++ b/sys/modules/crypto/Makefile @@ -15,6 +15,8 @@ LIBSODIUM=${SRCTOP}/sys/contrib/libsodium/src/libsodium .PATH: ${SRCTOP}/sys/contrib/libb2 .PATH: ${LIBSODIUM}/crypto_onetimeauth/poly1305 .PATH: ${LIBSODIUM}/crypto_onetimeauth/poly1305/donna +.PATH: ${LIBSODIUM}/crypto_stream/chacha20 +.PATH: ${LIBSODIUM}/crypto_stream/chacha20/ref .PATH: ${LIBSODIUM}/crypto_verify/sodium .PATH: ${SRCTOP}/sys/crypto/libsodium @@ -55,8 +57,14 @@ SRCS += chacha-sw.c LIBSODIUM_INC=${LIBSODIUM}/include LIBSODIUM_COMPAT=${SRCTOP}/sys/crypto/libsodium +SRCS += xform_chacha20_poly1305.c +CFLAGS.xform_chacha20_poly1305.c+= -I${LIBSODIUM_INC} -I${LIBSODIUM_COMPAT} SRCS += xform_poly1305.c CFLAGS.xform_poly1305.c += -I${LIBSODIUM_INC} -I${LIBSODIUM_COMPAT} +SRCS += stream_chacha20.c +CFLAGS.stream_chacha20.c += -I${LIBSODIUM_INC}/sodium -I${LIBSODIUM_COMPAT} +SRCS += chacha20_ref.c +CFLAGS.chacha20_ref.c += -I${LIBSODIUM_INC}/sodium -I${LIBSODIUM_COMPAT} SRCS += onetimeauth_poly1305.c CFLAGS.onetimeauth_poly1305.c += -I${LIBSODIUM_INC}/sodium -I${LIBSODIUM_COMPAT} SRCS += poly1305_donna.c @@ -67,7 +75,6 @@ SRCS += randombytes.c CFLAGS.randombytes.c += -I${LIBSODIUM_INC} -I${LIBSODIUM_COMPAT} SRCS += utils.c CFLAGS.utils.c += -I${LIBSODIUM_INC} -I${LIBSODIUM_COMPAT} -SRCS += xform_chacha20_poly1305.c SRCS += opt_param.h cryptodev_if.h bus_if.h device_if.h SRCS += opt_compat.h diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index 60d1f60d6cc1..6ac628b9c21f 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -867,6 +867,168 @@ out: return (error); } +static int +swcr_chacha20_poly1305(struct swcr_session *ses, struct cryptop *crp) +{ + const struct crypto_session_params *csp; + uint64_t blkbuf[howmany(CHACHA20_NATIVE_BLOCK_LEN, sizeof(uint64_t))]; + u_char *blk = (u_char *)blkbuf; + u_char tag[POLY1305_HASH_LEN]; + struct crypto_buffer_cursor cc_in, cc_out; + const u_char *inblk; + u_char *outblk; + uint64_t *blkp; + union authctx ctx; + struct swcr_auth *swa; + struct swcr_encdec *swe; + struct auth_hash *axf; + struct enc_xform *exf; + int blksz, error, r, resid; + + swa = &ses->swcr_auth; + axf = swa->sw_axf; + + swe = &ses->swcr_encdec; + exf = swe->sw_exf; + blksz = exf->native_blocksize; + KASSERT(blksz <= sizeof(blkbuf), ("%s: blocksize mismatch", __func__)); + + if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) + return (EINVAL); + + csp = crypto_get_params(crp->crp_session); + + /* Generate Poly1305 key. */ + if (crp->crp_cipher_key != NULL) + axf->Setkey(&ctx, crp->crp_cipher_key, csp->csp_cipher_klen); + else + axf->Setkey(&ctx, csp->csp_cipher_key, csp->csp_cipher_klen); + axf->Reinit(&ctx, crp->crp_iv, csp->csp_ivlen); + + /* Supply MAC with AAD */ + if (crp->crp_aad != NULL) + axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); + else + crypto_apply(crp, crp->crp_aad_start, + crp->crp_aad_length, axf->Update, &ctx); + if (crp->crp_aad_length % 16 != 0) { + /* padding1 */ + memset(blk, 0, 16); + axf->Update(&ctx, blk, 16 - crp->crp_aad_length % 16); + } + + if (crp->crp_cipher_key != NULL) + exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, + csp->csp_cipher_klen); + exf->reinit(swe->sw_kschedule, crp->crp_iv); + + /* Do encryption with MAC */ + crypto_cursor_init(&cc_in, &crp->crp_buf); + crypto_cursor_advance(&cc_in, crp->crp_payload_start); + if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { + crypto_cursor_init(&cc_out, &crp->crp_obuf); + crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); + } else + cc_out = cc_in; + for (resid = crp->crp_payload_length; resid >= blksz; resid -= blksz) { + if (crypto_cursor_seglen(&cc_in) < blksz) { + crypto_cursor_copydata(&cc_in, blksz, blk); + inblk = blk; + } else { + inblk = crypto_cursor_segbase(&cc_in); + crypto_cursor_advance(&cc_in, blksz); + } + if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { + if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = blk; + else + outblk = crypto_cursor_segbase(&cc_out); + exf->encrypt(swe->sw_kschedule, inblk, outblk); + axf->Update(&ctx, outblk, blksz); + if (outblk == blk) + crypto_cursor_copyback(&cc_out, blksz, blk); + else + crypto_cursor_advance(&cc_out, blksz); + } else { + axf->Update(&ctx, inblk, blksz); + } + } + if (resid > 0) { + crypto_cursor_copydata(&cc_in, resid, blk); + if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { + exf->encrypt_last(swe->sw_kschedule, blk, blk, resid); + crypto_cursor_copyback(&cc_out, resid, blk); + } + axf->Update(&ctx, blk, resid); + if (resid % 16 != 0) { + /* padding2 */ + memset(blk, 0, 16); + axf->Update(&ctx, blk, 16 - resid % 16); + } + } + + /* lengths */ + blkp = (uint64_t *)blk; + blkp[0] = htole64(crp->crp_aad_length); + blkp[1] = htole64(crp->crp_payload_length); + axf->Update(&ctx, blk, sizeof(uint64_t) * 2); + + /* Finalize MAC */ + axf->Final(tag, &ctx); + + /* Validate tag */ + error = 0; + if (!CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { + u_char tag2[POLY1305_HASH_LEN]; + + crypto_copydata(crp, crp->crp_digest_start, swa->sw_mlen, tag2); + + r = timingsafe_bcmp(tag, tag2, swa->sw_mlen); + explicit_bzero(tag2, sizeof(tag2)); + if (r != 0) { + error = EBADMSG; + goto out; + } + + /* tag matches, decrypt data */ + crypto_cursor_init(&cc_in, &crp->crp_buf); + crypto_cursor_advance(&cc_in, crp->crp_payload_start); + for (resid = crp->crp_payload_length; resid > blksz; + resid -= blksz) { + if (crypto_cursor_seglen(&cc_in) < blksz) { + crypto_cursor_copydata(&cc_in, blksz, blk); + inblk = blk; + } else { + inblk = crypto_cursor_segbase(&cc_in); + crypto_cursor_advance(&cc_in, blksz); + } + if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = blk; + else + outblk = crypto_cursor_segbase(&cc_out); + exf->decrypt(swe->sw_kschedule, inblk, outblk); + if (outblk == blk) + crypto_cursor_copyback(&cc_out, blksz, blk); + else + crypto_cursor_advance(&cc_out, blksz); + } + if (resid > 0) { + crypto_cursor_copydata(&cc_in, resid, blk); + exf->decrypt_last(swe->sw_kschedule, blk, blk, resid); + crypto_cursor_copyback(&cc_out, resid, blk); + } + } else { + /* Inject the authentication data */ + crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, tag); + } + +out: + explicit_bzero(blkbuf, sizeof(blkbuf)); + explicit_bzero(tag, sizeof(tag)); + explicit_bzero(&ctx, sizeof(ctx)); + return (error); +} + /* * Apply a cipher and a digest to perform EtA. */ @@ -1171,6 +1333,33 @@ swcr_setup_ccm(struct swcr_session *ses, return (swcr_setup_cipher(ses, csp)); } +static int +swcr_setup_chacha20_poly1305(struct swcr_session *ses, + const struct crypto_session_params *csp) +{ + struct swcr_auth *swa; + struct auth_hash *axf; + + if (csp->csp_ivlen != CHACHA20_POLY1305_IV_LEN) + return (EINVAL); + + /* First, setup the auth side. */ + swa = &ses->swcr_auth; + axf = &auth_hash_chacha20_poly1305; + swa->sw_axf = axf; + if (csp->csp_auth_mlen < 0 || csp->csp_auth_mlen > axf->hashsize) + return (EINVAL); + if (csp->csp_auth_mlen == 0) + swa->sw_mlen = axf->hashsize; + else + swa->sw_mlen = csp->csp_auth_mlen; + + /* The auth state is regenerated for each nonce. */ + + /* Second, setup the cipher side. */ + return (swcr_setup_cipher(ses, csp)); +} + static bool swcr_auth_supported(const struct crypto_session_params *csp) { @@ -1258,6 +1447,7 @@ swcr_probesession(device_t dev, const struct crypto_session_params *csp) switch (csp->csp_cipher_alg) { case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_CCM_16: + case CRYPTO_CHACHA20_POLY1305: return (EINVAL); default: if (!swcr_cipher_supported(csp)) @@ -1273,6 +1463,7 @@ swcr_probesession(device_t dev, const struct crypto_session_params *csp) switch (csp->csp_cipher_alg) { case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_CCM_16: + case CRYPTO_CHACHA20_POLY1305: break; default: return (EINVAL); @@ -1283,6 +1474,7 @@ swcr_probesession(device_t dev, const struct crypto_session_params *csp) switch (csp->csp_cipher_alg) { case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_CCM_16: + case CRYPTO_CHACHA20_POLY1305: return (EINVAL); } switch (csp->csp_auth_alg) { @@ -1343,6 +1535,7 @@ swcr_newsession(device_t dev, crypto_session_t cses, #ifdef INVARIANTS case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_CCM_16: + case CRYPTO_CHACHA20_POLY1305: panic("bad cipher algo"); #endif default: @@ -1366,6 +1559,11 @@ swcr_newsession(device_t dev, crypto_session_t cses, if (error == 0) ses->swcr_process = swcr_ccm; break; + case CRYPTO_CHACHA20_POLY1305: + error = swcr_setup_chacha20_poly1305(ses, csp); + if (error == 0) + ses->swcr_process = swcr_chacha20_poly1305; + break; #ifdef INVARIANTS default: panic("bad aead algo"); @@ -1377,6 +1575,7 @@ swcr_newsession(device_t dev, crypto_session_t cses, switch (csp->csp_cipher_alg) { case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_CCM_16: + case CRYPTO_CHACHA20_POLY1305: panic("bad eta cipher algo"); } switch (csp->csp_auth_alg) { diff --git a/sys/opencrypto/xform_auth.h b/sys/opencrypto/xform_auth.h index dbdb278209b5..6427965671d3 100644 --- a/sys/opencrypto/xform_auth.h +++ b/sys/opencrypto/xform_auth.h @@ -84,6 +84,7 @@ extern struct auth_hash auth_hash_poly1305; extern struct auth_hash auth_hash_ccm_cbc_mac_128; extern struct auth_hash auth_hash_ccm_cbc_mac_192; extern struct auth_hash auth_hash_ccm_cbc_mac_256; +extern struct auth_hash auth_hash_chacha20_poly1305; union authctx { SHA1_CTX sha1ctx; diff --git a/sys/opencrypto/xform_chacha20_poly1305.c b/sys/opencrypto/xform_chacha20_poly1305.c index e568e76cad51..3a72c06f931b 100644 --- a/sys/opencrypto/xform_chacha20_poly1305.c +++ b/sys/opencrypto/xform_chacha20_poly1305.c @@ -25,17 +25,139 @@ * SUCH DAMAGE. */ -#include +#include #include +#include +#include + +struct chacha20_poly1305_cipher_ctx { + const void *key; + uint32_t ic; + char nonce[CHACHA20_POLY1305_IV_LEN]; +}; + +static int +chacha20_poly1305_setkey(void *vctx, const uint8_t *key, int len) +{ + struct chacha20_poly1305_cipher_ctx *ctx = vctx; + + if (len != CHACHA20_POLY1305_KEY) + return (EINVAL); + + ctx->key = key; + return (0); +} + +static void +chacha20_poly1305_reinit(void *vctx, const uint8_t *iv) +{ + struct chacha20_poly1305_cipher_ctx *ctx = vctx; + + /* Block 0 is used for the poly1305 key. */ + memcpy(ctx->nonce, iv, sizeof(ctx->nonce)); + ctx->ic = 1; +} + +static void +chacha20_poly1305_crypt(void *vctx, const uint8_t *in, uint8_t *out) +{ + struct chacha20_poly1305_cipher_ctx *ctx = vctx; + int error; + + error = crypto_stream_chacha20_ietf_xor_ic(out, in, + CHACHA20_NATIVE_BLOCK_LEN, ctx->nonce, ctx->ic, ctx->key); + KASSERT(error == 0, ("%s failed: %d", __func__, error)); + ctx->ic++; +} + +static void +chacha20_poly1305_crypt_last(void *vctx, const uint8_t *in, uint8_t *out, + size_t len) +{ + struct chacha20_poly1305_cipher_ctx *ctx = vctx; + + int error; + + error = crypto_stream_chacha20_ietf_xor_ic(out, in, len, ctx->nonce, + ctx->ic, ctx->key); + KASSERT(error == 0, ("%s failed: %d", __func__, error)); +} + struct enc_xform enc_xform_chacha20_poly1305 = { .type = CRYPTO_CHACHA20_POLY1305, .name = "ChaCha20-Poly1305", - .ctxsize = sizeof(struct chacha_ctx), + .ctxsize = sizeof(struct chacha20_poly1305_cipher_ctx), .blocksize = 1, - .native_blocksize = CHACHA_BLOCKLEN, + .native_blocksize = CHACHA20_NATIVE_BLOCK_LEN, .ivsize = CHACHA20_POLY1305_IV_LEN, .minkey = CHACHA20_POLY1305_KEY, .maxkey = CHACHA20_POLY1305_KEY, + .encrypt = chacha20_poly1305_crypt, + .decrypt = chacha20_poly1305_crypt, + .setkey = chacha20_poly1305_setkey, + .reinit = chacha20_poly1305_reinit, + .encrypt_last = chacha20_poly1305_crypt_last, + .decrypt_last = chacha20_poly1305_crypt_last, }; +struct chacha20_poly1305_auth_ctx { + struct crypto_onetimeauth_poly1305_state state; + const void *key; +}; +CTASSERT(sizeof(union authctx) >= sizeof(struct chacha20_poly1305_auth_ctx)); + +static void +chacha20_poly1305_Init(void *vctx) +{ +} + +static void +chacha20_poly1305_Setkey(void *vctx, const uint8_t *key, u_int klen) +{ + struct chacha20_poly1305_auth_ctx *ctx = vctx; + + ctx->key = key; +} + +static void +chacha20_poly1305_Reinit(void *vctx, const uint8_t *nonce, u_int noncelen) +{ + struct chacha20_poly1305_auth_ctx *ctx = vctx; + char block[CHACHA20_NATIVE_BLOCK_LEN]; + + crypto_stream_chacha20_ietf(block, sizeof(block), nonce, ctx->key); + crypto_onetimeauth_poly1305_init(&ctx->state, block); + explicit_bzero(block, sizeof(block)); +} + +static int +chacha20_poly1305_Update(void *vctx, const void *data, u_int len) +{ + struct chacha20_poly1305_auth_ctx *ctx = vctx; + + crypto_onetimeauth_poly1305_update(&ctx->state, data, len); + return (0); +} + +static void +chacha20_poly1305_Final(uint8_t *digest, void *vctx) +{ + struct chacha20_poly1305_auth_ctx *ctx = vctx; + + crypto_onetimeauth_poly1305_final(&ctx->state, digest); +} + +struct auth_hash auth_hash_chacha20_poly1305 = { + .type = CRYPTO_POLY1305, + .name = "ChaCha20-Poly1305", + .keysize = POLY1305_KEY_LEN, + .hashsize = POLY1305_HASH_LEN, + .ctxsize = sizeof(struct chacha20_poly1305_auth_ctx), + .blocksize = crypto_onetimeauth_poly1305_BYTES, + .Init = chacha20_poly1305_Init, + .Setkey = chacha20_poly1305_Setkey, + .Reinit = chacha20_poly1305_Reinit, + .Update = chacha20_poly1305_Update, + .Final = chacha20_poly1305_Final, +}; From nobody Thu Oct 21 17:06:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D7E7A1806A04; Thu, 21 Oct 2021 17:06: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 4HZv644dSvz4h5q; Thu, 21 Oct 2021 17:06: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 710D21EFB3; Thu, 21 Oct 2021 17:06: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 19LH6qrW080098; Thu, 21 Oct 2021 17:06:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6q3K080097; Thu, 21 Oct 2021 17:06:52 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:52 GMT Message-Id: <202110211706.19LH6q3K080097@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: 3a7ae9ce6dce - stable/13 - cryptocheck: Add Chacha20-Poly1305 AEAD coverage. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 3a7ae9ce6dcea8cc5beb0dc3284e1b50a60eff1e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3a7ae9ce6dcea8cc5beb0dc3284e1b50a60eff1e commit 3a7ae9ce6dcea8cc5beb0dc3284e1b50a60eff1e Author: John Baldwin AuthorDate: 2021-02-18 17:23:36 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:22 +0000 cryptocheck: Add Chacha20-Poly1305 AEAD coverage. - Make openssl_gcm_encrypt generic to AEAD ciphers (aside from CCM) and use it for Chacha20-Poly1305. - Use generic AEAD control constants instead of GCM/CCM specific names. Reviewed by: cem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27838 (cherry picked from commit 1bd9fc96d4e4a26bb0060698c07b6f13d19cd819) --- tools/tools/crypto/cryptocheck.c | 46 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c index efb68f8966ef..fc08396b45f5 100644 --- a/tools/tools/crypto/cryptocheck.c +++ b/tools/tools/crypto/cryptocheck.c @@ -120,6 +120,7 @@ * aes-ccm 128-bit AES-CCM * aes-ccm192 192-bit AES-CCM * aes-ccm256 256-bit AES-CCM + * chacha20-poly1305 Chacha20 (96 bit nonce) with Poly1305 per RFC 8439 */ #include @@ -149,6 +150,7 @@ static const struct alg { int cipher; int mac; enum { T_HASH, T_HMAC, T_GMAC, T_CIPHER, T_ETA, T_AEAD } type; + int tag_len; const EVP_CIPHER *(*evp_cipher)(void); const EVP_MD *(*evp_md)(void); } algs[] = { @@ -177,11 +179,11 @@ static const struct alg { { .name = "blake2s", .mac = CRYPTO_BLAKE2S, .type = T_HASH, .evp_md = EVP_blake2s256 }, { .name = "gmac", .mac = CRYPTO_AES_NIST_GMAC, .type = T_GMAC, - .evp_cipher = EVP_aes_128_gcm }, + .tag_len = AES_GMAC_HASH_LEN, .evp_cipher = EVP_aes_128_gcm }, { .name = "gmac192", .mac = CRYPTO_AES_NIST_GMAC, .type = T_GMAC, - .evp_cipher = EVP_aes_192_gcm }, + .tag_len = AES_GMAC_HASH_LEN, .evp_cipher = EVP_aes_192_gcm }, { .name = "gmac256", .mac = CRYPTO_AES_NIST_GMAC, .type = T_GMAC, - .evp_cipher = EVP_aes_256_gcm }, + .tag_len = AES_GMAC_HASH_LEN, .evp_cipher = EVP_aes_256_gcm }, { .name = "aes-cbc", .cipher = CRYPTO_AES_CBC, .type = T_CIPHER, .evp_cipher = EVP_aes_128_cbc }, { .name = "aes-cbc192", .cipher = CRYPTO_AES_CBC, .type = T_CIPHER, @@ -201,17 +203,22 @@ static const struct alg { { .name = "chacha20", .cipher = CRYPTO_CHACHA20, .type = T_CIPHER, .evp_cipher = EVP_chacha20 }, { .name = "aes-gcm", .cipher = CRYPTO_AES_NIST_GCM_16, .type = T_AEAD, - .evp_cipher = EVP_aes_128_gcm }, + .tag_len = AES_GMAC_HASH_LEN, .evp_cipher = EVP_aes_128_gcm }, { .name = "aes-gcm192", .cipher = CRYPTO_AES_NIST_GCM_16, - .type = T_AEAD, .evp_cipher = EVP_aes_192_gcm }, + .type = T_AEAD, .tag_len = AES_GMAC_HASH_LEN, + .evp_cipher = EVP_aes_192_gcm }, { .name = "aes-gcm256", .cipher = CRYPTO_AES_NIST_GCM_16, - .type = T_AEAD, .evp_cipher = EVP_aes_256_gcm }, + .type = T_AEAD, .tag_len = AES_GMAC_HASH_LEN, + .evp_cipher = EVP_aes_256_gcm }, { .name = "aes-ccm", .cipher = CRYPTO_AES_CCM_16, .type = T_AEAD, - .evp_cipher = EVP_aes_128_ccm }, + .evp_cipher = EVP_aes_128_ccm, .tag_len = AES_CBC_MAC_HASH_LEN }, { .name = "aes-ccm192", .cipher = CRYPTO_AES_CCM_16, .type = T_AEAD, - .evp_cipher = EVP_aes_192_ccm }, + .evp_cipher = EVP_aes_192_ccm, .tag_len = AES_CBC_MAC_HASH_LEN }, { .name = "aes-ccm256", .cipher = CRYPTO_AES_CCM_16, .type = T_AEAD, - .evp_cipher = EVP_aes_256_ccm }, + .evp_cipher = EVP_aes_256_ccm, .tag_len = AES_CBC_MAC_HASH_LEN }, + { .name = "chacha20-poly1305", .cipher = CRYPTO_CHACHA20_POLY1305, + .type = T_AEAD, .tag_len = POLY1305_HASH_LEN, + .evp_cipher = EVP_chacha20_poly1305 }, }; static bool verbose; @@ -1046,7 +1053,7 @@ openssl_gmac(const struct alg *alg, const EVP_CIPHER *cipher, const char *key, if (EVP_EncryptFinal_ex(ctx, NULL, &outl) != 1) errx(1, "OpenSSL %s (%zu) final failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); - if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, AES_GMAC_HASH_LEN, + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, alg->tag_len, tag) != 1) errx(1, "OpenSSL %s (%zu) get tag failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); @@ -1133,7 +1140,7 @@ out: } static void -openssl_gcm_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, +openssl_aead_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, const char *key, const char *iv, const char *aad, size_t aad_len, const char *input, char *output, size_t size, char *tag) { @@ -1168,7 +1175,7 @@ openssl_gcm_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, if ((size_t)total != size) errx(1, "OpenSSL %s (%zu) encrypt size mismatch: %d", alg->name, size, total); - if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, AES_GMAC_HASH_LEN, + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, alg->tag_len, tag) != 1) errx(1, "OpenSSL %s (%zu) get tag failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); @@ -1177,7 +1184,7 @@ openssl_gcm_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, #ifdef notused static bool -openssl_gcm_decrypt(const struct alg *alg, const EVP_CIPHER *cipher, +openssl_aead_decrypt(const struct alg *alg, const EVP_CIPHER *cipher, const char *key, const char *iv, const char *aad, size_t aad_len, const char *input, char *output, size_t size, char *tag) { @@ -1206,7 +1213,7 @@ openssl_gcm_decrypt(const struct alg *alg, const EVP_CIPHER *cipher, errx(1, "OpenSSL %s (%zu) decrypt update failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); total = outl; - if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, AES_GMAC_HASH_LEN, + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, alg->tag_len, tag) != 1) errx(1, "OpenSSL %s (%zu) get tag failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); @@ -1235,10 +1242,10 @@ openssl_ccm_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, if (EVP_EncryptInit_ex(ctx, cipher, NULL, NULL, NULL) != 1) errx(1, "OpenSSL %s (%zu) ctx init failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); - if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_IVLEN, iv_len, NULL) != 1) + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, iv_len, NULL) != 1) errx(1, "OpenSSL %s (%zu) setting iv length failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); - if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, AES_CBC_MAC_HASH_LEN, NULL) != 1) + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, AES_CBC_MAC_HASH_LEN, NULL) != 1) errx(1, "OpenSSL %s (%zu) setting tag length failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); if (EVP_EncryptInit_ex(ctx, NULL, NULL, (const u_char *)key, @@ -1268,7 +1275,7 @@ openssl_ccm_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, if ((size_t)total != size) errx(1, "OpenSSL %s (%zu) encrypt size mismatch: %d", alg->name, size, total); - if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_GET_TAG, AES_CBC_MAC_HASH_LEN, + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, AES_CBC_MAC_HASH_LEN, tag) != 1) errx(1, "OpenSSL %s (%zu) get tag failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); @@ -1311,7 +1318,8 @@ ocf_aead(const struct ocf_session *ses, const char *iv, size_t iv_len, return (0); } -#define AEAD_MAX_TAG_LEN MAX(AES_GMAC_HASH_LEN, AES_CBC_MAC_HASH_LEN) +#define AEAD_MAX_TAG_LEN \ + MAX(MAX(AES_GMAC_HASH_LEN, AES_CBC_MAC_HASH_LEN), POLY1305_HASH_LEN) static void run_aead_test(const struct alg *alg, size_t aad_len, size_t size) @@ -1368,7 +1376,7 @@ run_aead_test(const struct alg *alg, size_t aad_len, size_t size) openssl_ccm_encrypt(alg, cipher, key, iv, iv_len, aad, aad_len, cleartext, ciphertext, size, control_tag); else - openssl_gcm_encrypt(alg, cipher, key, iv, aad, aad_len, + openssl_aead_encrypt(alg, cipher, key, iv, aad, aad_len, cleartext, ciphertext, size, control_tag); if (!ocf_init_aead_session(alg, key, key_len, &ses)) From nobody Thu Oct 21 17:06:53 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 26FA018067D8; Thu, 21 Oct 2021 17:06: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 4HZv655f9lz4gwF; Thu, 21 Oct 2021 17:06: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 7ECE61F097; Thu, 21 Oct 2021 17:06: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 19LH6r6W080122; Thu, 21 Oct 2021 17:06:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6rlo080121; Thu, 21 Oct 2021 17:06:53 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:53 GMT Message-Id: <202110211706.19LH6rlo080121@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: c3eec459b643 - stable/13 - cryptosoft: Support per-op keys for AES-GCM and AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: c3eec459b643f08a9af479b28a0789b655207617 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c3eec459b643f08a9af479b28a0789b655207617 commit c3eec459b643f08a9af479b28a0789b655207617 Author: John Baldwin AuthorDate: 2021-02-18 17:24:35 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:23 +0000 cryptosoft: Support per-op keys for AES-GCM and AES-CCM. Reviewed by: cem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28752 (cherry picked from commit a10020cfe2830e9626ac58ae97ecd12afb3553be) --- sys/opencrypto/cryptosoft.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index 6ac628b9c21f..a09f085a1eef 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -537,6 +537,9 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) } } + if (crp->crp_cipher_key != NULL) + exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, + crypto_get_params(crp->crp_session)->csp_cipher_klen); exf->reinit(swe->sw_kschedule, iv); /* Do encryption with MAC */ @@ -755,6 +758,9 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) if (error) return (error); + if (crp->crp_cipher_key != NULL) + exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, + crypto_get_params(crp->crp_session)->csp_cipher_klen); exf->reinit(swe->sw_kschedule, iv); /* Do encryption/decryption with MAC */ From nobody Thu Oct 21 17:06:55 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 921661806875; Thu, 21 Oct 2021 17:06: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 4HZv680mKRz4h8N; Thu, 21 Oct 2021 17:06: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 C226D1ED6E; Thu, 21 Oct 2021 17:06: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 19LH6tNI080177; Thu, 21 Oct 2021 17:06:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6tYA080176; Thu, 21 Oct 2021 17:06:55 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:55 GMT Message-Id: <202110211706.19LH6tYA080176@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: 29af3bc12dd7 - stable/13 - cryptocheck: Free generated IV after each GMAC test. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 29af3bc12dd76a4a83556634e400e8f047ea679a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=29af3bc12dd76a4a83556634e400e8f047ea679a commit 29af3bc12dd76a4a83556634e400e8f047ea679a Author: John Baldwin AuthorDate: 2021-03-03 23:17:19 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:23 +0000 cryptocheck: Free generated IV after each GMAC test. Reviewed by: cem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28753 (cherry picked from commit 442a293611461834778d1b7cd2ac170fb3427dcf) --- tools/tools/crypto/cryptocheck.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c index 389d0cc9f610..bd075d24e0f5 100644 --- a/tools/tools/crypto/cryptocheck.c +++ b/tools/tools/crypto/cryptocheck.c @@ -1141,6 +1141,7 @@ run_gmac_test(const struct alg *alg, size_t size) out: free(buffer); + free(iv); free(key); } From nobody Thu Oct 21 17:06:54 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C0EBF1806B16; Thu, 21 Oct 2021 17:06: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 4HZv6756XKz4gwS; Thu, 21 Oct 2021 17:06: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 A5F9E1ED6D; Thu, 21 Oct 2021 17:06: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 19LH6spk080146; Thu, 21 Oct 2021 17:06:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6sS0080145; Thu, 21 Oct 2021 17:06:54 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:54 GMT Message-Id: <202110211706.19LH6sS0080145@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: 1ab6c8ca7eed - stable/13 - cryptocheck: Add support for the Poly1305 digest. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 1ab6c8ca7eed3d0e75959636d6855a92ebf5015b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=1ab6c8ca7eed3d0e75959636d6855a92ebf5015b commit 1ab6c8ca7eed3d0e75959636d6855a92ebf5015b Author: John Baldwin AuthorDate: 2021-03-03 23:17:00 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:23 +0000 cryptocheck: Add support for the Poly1305 digest. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28758 (cherry picked from commit 68c03734484f679bf2f15fc81359128e331db364) --- tools/tools/crypto/cryptocheck.c | 90 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c index fc08396b45f5..389d0cc9f610 100644 --- a/tools/tools/crypto/cryptocheck.c +++ b/tools/tools/crypto/cryptocheck.c @@ -98,6 +98,7 @@ * gmac 128-bit GMAC * gmac192 192-bit GMAC * gmac256 256-bit GMAC + * poly1305 * * Ciphers: * aes-cbc 128-bit AES-CBC @@ -149,10 +150,12 @@ static const struct alg { const char *name; int cipher; int mac; - enum { T_HASH, T_HMAC, T_GMAC, T_CIPHER, T_ETA, T_AEAD } type; + enum { T_HASH, T_HMAC, T_GMAC, T_DIGEST, T_CIPHER, T_ETA, T_AEAD } type; + int key_len; int tag_len; const EVP_CIPHER *(*evp_cipher)(void); const EVP_MD *(*evp_md)(void); + int pkey; } algs[] = { { .name = "sha1", .mac = CRYPTO_SHA1, .type = T_HASH, .evp_md = EVP_sha1 }, @@ -184,6 +187,8 @@ static const struct alg { .tag_len = AES_GMAC_HASH_LEN, .evp_cipher = EVP_aes_192_gcm }, { .name = "gmac256", .mac = CRYPTO_AES_NIST_GMAC, .type = T_GMAC, .tag_len = AES_GMAC_HASH_LEN, .evp_cipher = EVP_aes_256_gcm }, + { .name = "poly1305", .mac = CRYPTO_POLY1305, .type = T_DIGEST, + .key_len = POLY1305_KEY_LEN, .pkey = EVP_PKEY_POLY1305 }, { .name = "aes-cbc", .cipher = CRYPTO_AES_CBC, .type = T_CIPHER, .evp_cipher = EVP_aes_128_cbc }, { .name = "aes-cbc192", .cipher = CRYPTO_AES_CBC, .type = T_CIPHER, @@ -1061,7 +1066,7 @@ openssl_gmac(const struct alg *alg, const EVP_CIPHER *cipher, const char *key, } static bool -ocf_gmac(const struct alg *alg, const char *input, size_t size, const char *key, +ocf_mac(const struct alg *alg, const char *input, size_t size, const char *key, size_t key_len, const char *iv, char *tag, int *cridp) { struct ocf_session ses; @@ -1072,7 +1077,7 @@ ocf_gmac(const struct alg *alg, const char *input, size_t size, const char *key, sop.mackeylen = key_len; sop.mackey = key; sop.mac = alg->mac; - if (!ocf_init_session(&sop, "GMAC", alg->name, &ses)) + if (!ocf_init_session(&sop, "MAC", alg->name, &ses)) return (false); ocf_init_cop(&ses, &cop); @@ -1119,7 +1124,78 @@ run_gmac_test(const struct alg *alg, size_t size) openssl_gmac(alg, cipher, key, iv, buffer, size, control_tag); /* OCF GMAC. */ - if (!ocf_gmac(alg, buffer, size, key, key_len, iv, test_tag, &crid)) + if (!ocf_mac(alg, buffer, size, key, key_len, iv, test_tag, &crid)) + goto out; + if (memcmp(control_tag, test_tag, sizeof(control_tag)) != 0) { + printf("%s (%zu) mismatch:\n", alg->name, size); + printf("control:\n"); + hexdump(control_tag, sizeof(control_tag), NULL, 0); + printf("test (cryptodev device %s):\n", crfind(crid)); + hexdump(test_tag, sizeof(test_tag), NULL, 0); + goto out; + } + + if (verbose) + printf("%s (%zu) matched (cryptodev device %s)\n", + alg->name, size, crfind(crid)); + +out: + free(buffer); + free(key); +} + +static void +openssl_digest(const struct alg *alg, const char *key, u_int key_len, + const char *input, size_t size, char *tag, u_int tag_len) +{ + EVP_MD_CTX *mdctx; + EVP_PKEY *pkey; + size_t len; + + pkey = EVP_PKEY_new_raw_private_key(alg->pkey, NULL, key, key_len); + if (pkey == NULL) + errx(1, "OpenSSL %s (%zu) pkey new failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + mdctx = EVP_MD_CTX_new(); + if (mdctx == NULL) + errx(1, "OpenSSL %s (%zu) ctx new failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_DigestSignInit(mdctx, NULL, NULL, NULL, pkey) != 1) + errx(1, "OpenSSL %s (%zu) digest sign init failed: %s", + alg->name, size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_DigestSignUpdate(mdctx, input, size) != 1) + errx(1, "OpenSSL %s (%zu) digest update failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + len = tag_len; + if (EVP_DigestSignFinal(mdctx, tag, &len) != 1) + errx(1, "OpenSSL %s (%zu) digest final failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + EVP_MD_CTX_free(mdctx); + EVP_PKEY_free(pkey); +} + +static void +run_digest_test(const struct alg *alg, size_t size) +{ + char *key, *buffer; + u_int key_len; + int crid; + char control_tag[EVP_MAX_MD_SIZE], test_tag[EVP_MAX_MD_SIZE]; + + memset(control_tag, 0x3c, sizeof(control_tag)); + memset(test_tag, 0x3c, sizeof(test_tag)); + + key_len = alg->key_len; + + key = alloc_buffer(key_len); + buffer = alloc_buffer(size); + + /* OpenSSL Poly1305. */ + openssl_digest(alg, key, key_len, buffer, size, control_tag, + sizeof(control_tag)); + + /* OCF Poly1305. */ + if (!ocf_mac(alg, buffer, size, key, key_len, NULL, test_tag, &crid)) goto out; if (memcmp(control_tag, test_tag, sizeof(control_tag)) != 0) { printf("%s (%zu) mismatch:\n", alg->name, size); @@ -1471,6 +1547,9 @@ run_test(const struct alg *alg, size_t aad_len, size_t size) case T_GMAC: run_gmac_test(alg, size); break; + case T_DIGEST: + run_digest_test(alg, size); + break; case T_CIPHER: run_cipher_test(alg, size); break; @@ -1518,7 +1597,8 @@ run_mac_tests(void) u_int i; for (i = 0; i < nitems(algs); i++) - if (algs[i].type == T_HMAC || algs[i].type == T_GMAC) + if (algs[i].type == T_HMAC || algs[i].type == T_GMAC || + algs[i].type == T_DIGEST) run_test_sizes(&algs[i]); } From nobody Thu Oct 21 17:06:56 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4326218069BD; Thu, 21 Oct 2021 17:06: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 4HZv6939s3z4h29; Thu, 21 Oct 2021 17: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 F0E621ED6F; Thu, 21 Oct 2021 17: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 19LH6uGF080201; Thu, 21 Oct 2021 17: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 19LH6uD0080200; Thu, 21 Oct 2021 17:06:56 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:56 GMT Message-Id: <202110211706.19LH6uD0080200@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: bc6265e8cf8d - stable/13 - ossl: Add Poly1305 digest support. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: bc6265e8cf8dd4c6897b25307f89d1b7a3372e28 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bc6265e8cf8dd4c6897b25307f89d1b7a3372e28 commit bc6265e8cf8dd4c6897b25307f89d1b7a3372e28 Author: John Baldwin AuthorDate: 2021-03-03 23:17:29 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:23 +0000 ossl: Add Poly1305 digest support. Reviewed by: cem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28754 (cherry picked from commit a079e38b08f2f07c50ba915dae66d099559abdcc) --- share/man/man4/ossl.4 | 4 +- sys/conf/files | 1 + sys/conf/files.amd64 | 1 + sys/conf/files.arm64 | 2 + sys/conf/files.i386 | 1 + sys/crypto/openssl/ossl.c | 46 ++++++---- sys/crypto/openssl/ossl.h | 3 +- sys/crypto/openssl/ossl_poly1305.c | 181 +++++++++++++++++++++++++++++++++++++ sys/crypto/openssl/ossl_poly1305.h | 35 +++++++ sys/modules/ossl/Makefile | 4 + 10 files changed, 260 insertions(+), 18 deletions(-) diff --git a/share/man/man4/ossl.4 b/share/man/man4/ossl.4 index ce97a9fc0f71..9c0d7f897d53 100644 --- a/share/man/man4/ossl.4 +++ b/share/man/man4/ossl.4 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 4, 2020 +.Dd March 3, 2021 .Dt OSSL 4 .Os .Sh NAME @@ -74,6 +74,8 @@ driver includes support for the following algorithms: .Pp .Bl -bullet -compact .It +Poly1305 +.It SHA1 .It SHA1-HMAC diff --git a/sys/conf/files b/sys/conf/files index f21c216288b1..e680382210cd 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -741,6 +741,7 @@ crypto/chacha20/chacha-sw.c optional crypto | ipsec | ipsec_support crypto/des/des_ecb.c optional netsmb crypto/des/des_setkey.c optional netsmb crypto/openssl/ossl.c optional ossl +crypto/openssl/ossl_poly1305.c optional ossl crypto/openssl/ossl_sha1.c optional ossl crypto/openssl/ossl_sha256.c optional ossl crypto/openssl/ossl_sha512.c optional ossl diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 60184978fb51..f6271d0e0e92 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -139,6 +139,7 @@ cddl/dev/dtrace/amd64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/amd64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_amd64.S optional aesni crypto/des/des_enc.c optional netsmb +crypto/openssl/amd64/poly1305-x86_64.S optional ossl crypto/openssl/amd64/sha1-x86_64.S optional ossl crypto/openssl/amd64/sha256-x86_64.S optional ossl crypto/openssl/amd64/sha512-x86_64.S optional ossl diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 6e0f5658f33c..d6c9586f58f7 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -127,6 +127,8 @@ ghashv8-armx.o optional armv8crypto \ crypto/des/des_enc.c optional netsmb crypto/openssl/ossl_aarch64.c optional ossl +crypto/openssl/aarch64/poly1305-armv8.S optional ossl \ + compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}" crypto/openssl/aarch64/sha1-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}" crypto/openssl/aarch64/sha256-armv8.S optional ossl \ diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 6a0ca49c0432..5238e2bab40a 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -77,6 +77,7 @@ compat/linux/linux.c optional compat_linux compat/ndis/winx32_wrap.S optional ndisapi pci crypto/aesni/aeskeys_i386.S optional aesni crypto/des/arch/i386/des_enc.S optional netsmb +crypto/openssl/i386/poly1305-x86.S optional ossl crypto/openssl/i386/sha1-586.S optional ossl crypto/openssl/i386/sha256-586.S optional ossl crypto/openssl/i386/sha512-586.S optional ossl diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index 35f19c9fbca7..229729c27c21 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -135,6 +135,8 @@ ossl_lookup_hash(const struct crypto_session_params *csp) case CRYPTO_SHA2_512: case CRYPTO_SHA2_512_HMAC: return (&ossl_hash_sha512); + case CRYPTO_POLY1305: + return (&ossl_hash_poly1305); default: return (NULL); } @@ -159,14 +161,6 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) return (CRYPTODEV_PROBE_ACCEL_SOFTWARE); } -static void -ossl_setkey_hmac(struct ossl_session *s, const void *key, int klen) -{ - - hmac_init_ipad(s->hash.axf, key, klen, &s->hash.ictx); - hmac_init_opad(s->hash.axf, key, klen, &s->hash.octx); -} - static int ossl_newsession(device_t dev, crypto_session_t cses, const struct crypto_session_params *csp) @@ -188,8 +182,16 @@ ossl_newsession(device_t dev, crypto_session_t cses, } else { if (csp->csp_auth_key != NULL) { fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); - ossl_setkey_hmac(s, csp->csp_auth_key, - csp->csp_auth_klen); + if (axf->Setkey != NULL) { + axf->Init(&s->hash.ictx); + axf->Setkey(&s->hash.ictx, csp->csp_auth_key, + csp->csp_auth_klen); + } else { + hmac_init_ipad(axf, csp->csp_auth_key, + csp->csp_auth_klen, &s->hash.ictx); + hmac_init_opad(axf, csp->csp_auth_key, + csp->csp_auth_klen, &s->hash.octx); + } fpu_kern_leave(curthread, NULL); } } @@ -218,10 +220,18 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) fpu_entered = true; } - if (crp->crp_auth_key != NULL) - ossl_setkey_hmac(s, crp->crp_auth_key, csp->csp_auth_klen); - - ctx = s->hash.ictx; + if (crp->crp_auth_key == NULL) { + ctx = s->hash.ictx; + } else { + if (axf->Setkey != NULL) { + axf->Init(&ctx); + axf->Setkey(&ctx, crp->crp_auth_key, + csp->csp_auth_klen); + } else { + hmac_init_ipad(axf, crp->crp_auth_key, + csp->csp_auth_klen, &ctx); + } + } if (crp->crp_aad != NULL) error = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); @@ -238,8 +248,12 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) axf->Final(digest, &ctx); - if (csp->csp_auth_klen != 0) { - ctx = s->hash.octx; + if (csp->csp_auth_klen != 0 && axf->Setkey == NULL) { + if (crp->crp_auth_key == NULL) + ctx = s->hash.octx; + else + hmac_init_opad(axf, crp->crp_auth_key, + csp->csp_auth_klen, &ctx); axf->Update(&ctx, digest, axf->hashsize); axf->Final(digest, &ctx); } diff --git a/sys/crypto/openssl/ossl.h b/sys/crypto/openssl/ossl.h index 533d497f1be3..55022b10f377 100644 --- a/sys/crypto/openssl/ossl.h +++ b/sys/crypto/openssl/ossl.h @@ -38,9 +38,10 @@ void ossl_cpuid(void); /* Needs to be big enough to hold any hash context. */ struct ossl_hash_context { - uint32_t dummy[54]; + uint32_t dummy[61]; } __aligned(32); +extern struct auth_hash ossl_hash_poly1305; extern struct auth_hash ossl_hash_sha1; extern struct auth_hash ossl_hash_sha224; extern struct auth_hash ossl_hash_sha256; diff --git a/sys/crypto/openssl/ossl_poly1305.c b/sys/crypto/openssl/ossl_poly1305.c new file mode 100644 index 000000000000..8f8c5bc4b6e7 --- /dev/null +++ b/sys/crypto/openssl/ossl_poly1305.c @@ -0,0 +1,181 @@ +/* + * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include + +#include +#include + +#include +#include + +#define POLY1305_ASM + +/* From crypto/poly1305/poly1305.c */ + +/* pick 32-bit unsigned integer in little endian order */ +static unsigned int U8TOU32(const unsigned char *p) +{ + return (((unsigned int)(p[0] & 0xff)) | + ((unsigned int)(p[1] & 0xff) << 8) | + ((unsigned int)(p[2] & 0xff) << 16) | + ((unsigned int)(p[3] & 0xff) << 24)); +} + +/* + * Implementations can be classified by amount of significant bits in + * words making up the multi-precision value, or in other words radix + * or base of numerical representation, e.g. base 2^64, base 2^32, + * base 2^26. Complementary characteristic is how wide is the result of + * multiplication of pair of digits, e.g. it would take 128 bits to + * accommodate multiplication result in base 2^64 case. These are used + * interchangeably. To describe implementation that is. But interface + * is designed to isolate this so that low-level primitives implemented + * in assembly can be self-contained/self-coherent. + */ +int poly1305_init(void *ctx, const unsigned char key[16], void *func); +void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, + unsigned int padbit); +void poly1305_emit(void *ctx, unsigned char mac[16], + const unsigned int nonce[4]); + +static void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]) +{ + ctx->nonce[0] = U8TOU32(&key[16]); + ctx->nonce[1] = U8TOU32(&key[20]); + ctx->nonce[2] = U8TOU32(&key[24]); + ctx->nonce[3] = U8TOU32(&key[28]); + + /* + * Unlike reference poly1305_init assembly counterpart is expected + * to return a value: non-zero if it initializes ctx->func, and zero + * otherwise. Latter is to simplify assembly in cases when there no + * multiple code paths to switch between. + */ + if (!poly1305_init(ctx->opaque, key, &ctx->func)) { + ctx->func.blocks = poly1305_blocks; + ctx->func.emit = poly1305_emit; + } + + ctx->num = 0; + +} + +#ifdef POLY1305_ASM +/* + * This "eclipses" poly1305_blocks and poly1305_emit, but it's + * conscious choice imposed by -Wshadow compiler warnings. + */ +# define poly1305_blocks (*poly1305_blocks_p) +# define poly1305_emit (*poly1305_emit_p) +#endif + +static void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len) +{ +#ifdef POLY1305_ASM + /* + * As documented, poly1305_blocks is never called with input + * longer than single block and padbit argument set to 0. This + * property is fluently used in assembly modules to optimize + * padbit handling on loop boundary. + */ + poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks; +#endif + size_t rem, num; + + if ((num = ctx->num)) { + rem = POLY1305_BLOCK_SIZE - num; + if (len >= rem) { + memcpy(ctx->data + num, inp, rem); + poly1305_blocks(ctx->opaque, ctx->data, POLY1305_BLOCK_SIZE, 1); + inp += rem; + len -= rem; + } else { + /* Still not enough data to process a block. */ + memcpy(ctx->data + num, inp, len); + ctx->num = num + len; + return; + } + } + + rem = len % POLY1305_BLOCK_SIZE; + len -= rem; + + if (len >= POLY1305_BLOCK_SIZE) { + poly1305_blocks(ctx->opaque, inp, len, 1); + inp += len; + } + + if (rem) + memcpy(ctx->data, inp, rem); + + ctx->num = rem; +} + +static void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]) +{ +#ifdef POLY1305_ASM + poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks; + poly1305_emit_f poly1305_emit_p = ctx->func.emit; +#endif + size_t num; + + if ((num = ctx->num)) { + ctx->data[num++] = 1; /* pad bit */ + while (num < POLY1305_BLOCK_SIZE) + ctx->data[num++] = 0; + poly1305_blocks(ctx->opaque, ctx->data, POLY1305_BLOCK_SIZE, 0); + } + + poly1305_emit(ctx->opaque, mac, ctx->nonce); + + /* zero out the state */ + OPENSSL_cleanse(ctx, sizeof(*ctx)); +} + +static void +ossl_poly1305_init(void *vctx) +{ +} + +static void +ossl_poly1305_setkey(void *vctx, const uint8_t *key, u_int klen) +{ + MPASS(klen == 32); + Poly1305_Init(vctx, key); +} + +static int +ossl_poly1305_update(void *vctx, const void *buf, u_int len) +{ + Poly1305_Update(vctx, buf, len); + return (0); +} + +static void +ossl_poly1305_final(uint8_t *digest, void *vctx) +{ + Poly1305_Final(vctx, digest); +} + +struct auth_hash ossl_hash_poly1305 = { + .type = CRYPTO_POLY1305, + .name = "OpenSSL-Poly1305", + .hashsize = POLY1305_HASH_LEN, + .ctxsize = sizeof(struct poly1305_context), + .blocksize = POLY1305_BLOCK_SIZE, + .Init = ossl_poly1305_init, + .Setkey = ossl_poly1305_setkey, + .Update = ossl_poly1305_update, + .Final = ossl_poly1305_final, +}; + +_Static_assert(sizeof(struct poly1305_context) <= + sizeof(struct ossl_hash_context), "ossl_hash_context too small"); diff --git a/sys/crypto/openssl/ossl_poly1305.h b/sys/crypto/openssl/ossl_poly1305.h new file mode 100644 index 000000000000..d1b2db6d5cba --- /dev/null +++ b/sys/crypto/openssl/ossl_poly1305.h @@ -0,0 +1,35 @@ +/* + * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* From include/crypto/poly1305.h */ + +#define POLY1305_BLOCK_SIZE 16 + +typedef struct poly1305_context POLY1305; + +/* From crypto/poly1305/poly1305_local.h */ + +typedef void (*poly1305_blocks_f) (void *ctx, const unsigned char *inp, + size_t len, unsigned int padbit); +typedef void (*poly1305_emit_f) (void *ctx, unsigned char mac[16], + const unsigned int nonce[4]); + +struct poly1305_context { + double opaque[24]; /* large enough to hold internal state, declared + * 'double' to ensure at least 64-bit invariant + * alignment across all platforms and + * configurations */ + unsigned int nonce[4]; + unsigned char data[POLY1305_BLOCK_SIZE]; + size_t num; + struct { + poly1305_blocks_f blocks; + poly1305_emit_f emit; + } func; +}; diff --git a/sys/modules/ossl/Makefile b/sys/modules/ossl/Makefile index 6fe8c5a6c812..2ddebefebd1a 100644 --- a/sys/modules/ossl/Makefile +++ b/sys/modules/ossl/Makefile @@ -8,24 +8,28 @@ SRCS= bus_if.h \ cryptodev_if.h \ device_if.h \ ossl.c \ + ossl_poly1305.c \ ossl_sha1.c \ ossl_sha256.c \ ossl_sha512.c \ ${SRCS.${MACHINE_CPUARCH}} SRCS.aarch64= \ + poly1305-armv8.S \ sha1-armv8.S \ sha256-armv8.S \ sha512-armv8.S \ ossl_aarch64.c SRCS.amd64= \ + poly1305-x86_64.S \ sha1-x86_64.S \ sha256-x86_64.S \ sha512-x86_64.S \ ossl_x86.c SRCS.i386= \ + poly1305-x86.S \ sha1-586.S \ sha256-586.S \ sha512-586.S \ From nobody Thu Oct 21 17:06:58 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2B2C41806AC3; Thu, 21 Oct 2021 17:07:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HZv6B4XZZz4h3p; Thu, 21 Oct 2021 17:06: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 1B50B1EDB7; Thu, 21 Oct 2021 17:06: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 19LH6w63080225; Thu, 21 Oct 2021 17:06:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6wPG080224; Thu, 21 Oct 2021 17:06:58 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:58 GMT Message-Id: <202110211706.19LH6wPG080224@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: ee1e39b012f6 - stable/13 - The ChaCha20 counter is little endian, not big endian. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: ee1e39b012f6239539cc0293eb0495e237d033ca Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ee1e39b012f6239539cc0293eb0495e237d033ca commit ee1e39b012f6239539cc0293eb0495e237d033ca Author: John Baldwin AuthorDate: 2021-03-03 23:17:37 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:23 +0000 The ChaCha20 counter is little endian, not big endian. Reviewed by: cem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28755 (cherry picked from commit a899ce4ba4c404d342bf892b8b756b66fc65d6b5) --- share/man/man7/crypto.7 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man7/crypto.7 b/share/man/man7/crypto.7 index ccc2d1fc9be3..6e5bd83621aa 100644 --- a/share/man/man7/crypto.7 +++ b/share/man/man7/crypto.7 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 18, 2021 +.Dd March 3, 2021 .Dt CRYPTO 7 .Os .Sh NAME @@ -136,7 +136,7 @@ counter rollover. .Dv CRYPTO_CHACHA20 accepts a 16 byte IV. The first 8 bytes are used as a nonce. -The last 8 bytes are used as 64-bit big-endian block counter. +The last 8 bytes are used as a 64-bit little-endian block counter. .Ss Authenticated Encryption with Associated Data Algorithms AEAD algorithms in OCF combine a stream cipher with an authentication algorithm to provide both secrecy and authentication. From nobody Thu Oct 21 17:06:59 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4710C1806971; Thu, 21 Oct 2021 17: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 4HZv6D4q6nz4hHf; Thu, 21 Oct 2021 17:07:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D8031EFB4; Thu, 21 Oct 2021 17:06: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 19LH6xlD080249; Thu, 21 Oct 2021 17:06:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH6xp5080248; Thu, 21 Oct 2021 17:06:59 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:06:59 GMT Message-Id: <202110211706.19LH6xp5080248@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: 6ca6d4edc234 - stable/13 - ossl: Add ChaCha20 cipher support. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 6ca6d4edc234cee9e3c85b058d8b0adda0a2026f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=6ca6d4edc234cee9e3c85b058d8b0adda0a2026f commit 6ca6d4edc234cee9e3c85b058d8b0adda0a2026f Author: John Baldwin AuthorDate: 2021-03-03 23:17:43 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:24 +0000 ossl: Add ChaCha20 cipher support. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28756 (cherry picked from commit 92aecd1e6fac47ffc893f628c1fe289568bb19cb) --- share/man/man4/ossl.4 | 2 + sys/conf/files | 1 + sys/conf/files.amd64 | 1 + sys/conf/files.arm64 | 2 + sys/conf/files.i386 | 1 + sys/crypto/openssl/ossl.c | 82 ++++++++++++++++----- sys/crypto/openssl/ossl.h | 5 ++ sys/crypto/openssl/ossl_chacha.h | 42 +++++++++++ sys/crypto/openssl/ossl_chacha20.c | 141 +++++++++++++++++++++++++++++++++++++ sys/modules/ossl/Makefile | 4 ++ 10 files changed, 262 insertions(+), 19 deletions(-) diff --git a/share/man/man4/ossl.4 b/share/man/man4/ossl.4 index 9c0d7f897d53..2aa4b69eda31 100644 --- a/share/man/man4/ossl.4 +++ b/share/man/man4/ossl.4 @@ -74,6 +74,8 @@ driver includes support for the following algorithms: .Pp .Bl -bullet -compact .It +ChaCha20 +.It Poly1305 .It SHA1 diff --git a/sys/conf/files b/sys/conf/files index e680382210cd..a5f23ca09774 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -741,6 +741,7 @@ crypto/chacha20/chacha-sw.c optional crypto | ipsec | ipsec_support crypto/des/des_ecb.c optional netsmb crypto/des/des_setkey.c optional netsmb crypto/openssl/ossl.c optional ossl +crypto/openssl/ossl_chacha20.c optional ossl crypto/openssl/ossl_poly1305.c optional ossl crypto/openssl/ossl_sha1.c optional ossl crypto/openssl/ossl_sha256.c optional ossl diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index f6271d0e0e92..bf2213eec68c 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -139,6 +139,7 @@ cddl/dev/dtrace/amd64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/amd64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_amd64.S optional aesni crypto/des/des_enc.c optional netsmb +crypto/openssl/amd64/chacha-x86_64.S optional ossl crypto/openssl/amd64/poly1305-x86_64.S optional ossl crypto/openssl/amd64/sha1-x86_64.S optional ossl crypto/openssl/amd64/sha256-x86_64.S optional ossl diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index d6c9586f58f7..84fd0c7858ff 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -127,6 +127,8 @@ ghashv8-armx.o optional armv8crypto \ crypto/des/des_enc.c optional netsmb crypto/openssl/ossl_aarch64.c optional ossl +crypto/openssl/aarch64/chacha-armv8.S optional ossl \ + compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}" crypto/openssl/aarch64/poly1305-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}" crypto/openssl/aarch64/sha1-armv8.S optional ossl \ diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 5238e2bab40a..7beb3f21292c 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -77,6 +77,7 @@ compat/linux/linux.c optional compat_linux compat/ndis/winx32_wrap.S optional ndisapi pci crypto/aesni/aeskeys_i386.S optional aesni crypto/des/arch/i386/des_enc.S optional netsmb +crypto/openssl/i386/chacha-x86.S optional ossl crypto/openssl/i386/poly1305-x86.S optional ossl crypto/openssl/i386/sha1-586.S optional ossl crypto/openssl/i386/sha256-586.S optional ossl diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index 229729c27c21..0c863429939c 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "cryptodev_if.h" @@ -154,6 +155,16 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) if (ossl_lookup_hash(csp) == NULL) return (EINVAL); break; + case CSP_MODE_CIPHER: + switch (csp->csp_cipher_alg) { + case CRYPTO_CHACHA20: + if (csp->csp_cipher_klen != CHACHA_KEY_SIZE) + return (EINVAL); + break; + default: + return (EINVAL); + } + break; default: return (EINVAL); } @@ -161,15 +172,12 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) return (CRYPTODEV_PROBE_ACCEL_SOFTWARE); } -static int -ossl_newsession(device_t dev, crypto_session_t cses, +static void +ossl_newsession_hash(struct ossl_session *s, const struct crypto_session_params *csp) { - struct ossl_session *s; struct auth_hash *axf; - s = crypto_get_driver_session(cses); - axf = ossl_lookup_hash(csp); s->hash.axf = axf; if (csp->csp_auth_mlen == 0) @@ -195,31 +203,35 @@ ossl_newsession(device_t dev, crypto_session_t cses, fpu_kern_leave(curthread, NULL); } } +} + +static int +ossl_newsession(device_t dev, crypto_session_t cses, + const struct crypto_session_params *csp) +{ + struct ossl_session *s; + + s = crypto_get_driver_session(cses); + switch (csp->csp_mode) { + case CSP_MODE_DIGEST: + ossl_newsession_hash(s, csp); + break; + } + return (0); } static int -ossl_process(device_t dev, struct cryptop *crp, int hint) +ossl_process_hash(struct ossl_session *s, struct cryptop *crp, + const struct crypto_session_params *csp) { struct ossl_hash_context ctx; char digest[HASH_MAX_LEN]; - const struct crypto_session_params *csp; - struct ossl_session *s; struct auth_hash *axf; int error; - bool fpu_entered; - s = crypto_get_driver_session(crp->crp_session); - csp = crypto_get_params(crp->crp_session); axf = s->hash.axf; - if (is_fpu_kern_thread(0)) { - fpu_entered = false; - } else { - fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); - fpu_entered = true; - } - if (crp->crp_auth_key == NULL) { ctx = s->hash.ictx; } else { @@ -273,13 +285,45 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) explicit_bzero(digest, sizeof(digest)); out: + explicit_bzero(&ctx, sizeof(ctx)); + return (error); +} + +static int +ossl_process(device_t dev, struct cryptop *crp, int hint) +{ + const struct crypto_session_params *csp; + struct ossl_session *s; + int error; + bool fpu_entered; + + s = crypto_get_driver_session(crp->crp_session); + csp = crypto_get_params(crp->crp_session); + + if (is_fpu_kern_thread(0)) { + fpu_entered = false; + } else { + fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); + fpu_entered = true; + } + + switch (csp->csp_mode) { + case CSP_MODE_DIGEST: + error = ossl_process_hash(s, crp, csp); + break; + case CSP_MODE_CIPHER: + error = ossl_chacha20(crp, csp); + break; + default: + __assert_unreachable(); + } + if (fpu_entered) fpu_kern_leave(curthread, NULL); crp->crp_etype = error; crypto_done(crp); - explicit_bzero(&ctx, sizeof(ctx)); return (0); } diff --git a/sys/crypto/openssl/ossl.h b/sys/crypto/openssl/ossl.h index 55022b10f377..b7c681d0fb1d 100644 --- a/sys/crypto/openssl/ossl.h +++ b/sys/crypto/openssl/ossl.h @@ -34,6 +34,11 @@ /* Compatibility shims. */ #define OPENSSL_cleanse explicit_bzero +struct cryptop; +struct crypto_session_params; + +int ossl_chacha20(struct cryptop *crp, + const struct crypto_session_params *csp); void ossl_cpuid(void); /* Needs to be big enough to hold any hash context. */ diff --git a/sys/crypto/openssl/ossl_chacha.h b/sys/crypto/openssl/ossl_chacha.h new file mode 100644 index 000000000000..781899c6bdf6 --- /dev/null +++ b/sys/crypto/openssl/ossl_chacha.h @@ -0,0 +1,42 @@ +/* + * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* From include/crypto/chacha.h */ + +#ifndef OSSL_CRYPTO_CHACHA_H +#define OSSL_CRYPTO_CHACHA_H + +/* + * ChaCha20_ctr32 encrypts |len| bytes from |inp| with the given key and + * nonce and writes the result to |out|, which may be equal to |inp|. + * The |key| is not 32 bytes of verbatim key material though, but the + * said material collected into 8 32-bit elements array in host byte + * order. Same approach applies to nonce: the |counter| argument is + * pointer to concatenated nonce and counter values collected into 4 + * 32-bit elements. This, passing crypto material collected into 32-bit + * elements as opposite to passing verbatim byte vectors, is chosen for + * efficiency in multi-call scenarios. + */ +void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp, + size_t len, const unsigned int key[8], + const unsigned int counter[4]); +/* + * You can notice that there is no key setup procedure. Because it's + * as trivial as collecting bytes into 32-bit elements, it's reckoned + * that below macro is sufficient. + */ +#define CHACHA_U8TOU32(p) ( \ + ((unsigned int)(p)[0]) | ((unsigned int)(p)[1]<<8) | \ + ((unsigned int)(p)[2]<<16) | ((unsigned int)(p)[3]<<24) ) + +#define CHACHA_KEY_SIZE 32 +#define CHACHA_CTR_SIZE 16 +#define CHACHA_BLK_SIZE 64 + +#endif diff --git a/sys/crypto/openssl/ossl_chacha20.c b/sys/crypto/openssl/ossl_chacha20.c new file mode 100644 index 000000000000..70a0a5718dbd --- /dev/null +++ b/sys/crypto/openssl/ossl_chacha20.c @@ -0,0 +1,141 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Netflix, 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, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. + */ + +#include +#include +#include +#include + +#include + +#include +#include + +int +ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) +{ + _Alignas(8) unsigned int key[CHACHA_KEY_SIZE / 4]; + unsigned int counter[CHACHA_CTR_SIZE / 4]; + unsigned char block[CHACHA_BLK_SIZE]; + struct crypto_buffer_cursor cc_in, cc_out; + const unsigned char *in, *inseg, *cipher_key; + unsigned char *out, *outseg; + size_t resid, todo, inlen, outlen; + uint32_t next_counter; + u_int i; + + if (crp->crp_cipher_key != NULL) + cipher_key = crp->crp_cipher_key; + else + cipher_key = csp->csp_cipher_key; + for (i = 0; i < nitems(key); i++) + key[i] = CHACHA_U8TOU32(cipher_key + i * 4); + crypto_read_iv(crp, counter); + for (i = 0; i < nitems(counter); i++) + counter[i] = le32toh(counter[i]); + + resid = crp->crp_payload_length; + crypto_cursor_init(&cc_in, &crp->crp_buf); + crypto_cursor_advance(&cc_in, crp->crp_payload_start); + inseg = crypto_cursor_segbase(&cc_in); + inlen = crypto_cursor_seglen(&cc_in); + if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { + crypto_cursor_init(&cc_out, &crp->crp_obuf); + crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); + } else + cc_out = cc_in; + outseg = crypto_cursor_segbase(&cc_out); + outlen = crypto_cursor_seglen(&cc_out); + while (resid >= CHACHA_BLK_SIZE) { + if (inlen < CHACHA_BLK_SIZE) { + crypto_cursor_copydata(&cc_in, CHACHA_BLK_SIZE, block); + in = block; + inlen = CHACHA_BLK_SIZE; + } else + in = inseg; + if (outlen < CHACHA_BLK_SIZE) { + out = block; + outlen = CHACHA_BLK_SIZE; + } else + out = outseg; + + /* Figure out how many blocks we can encrypt/decrypt at once. */ + todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); + +#ifdef __LP64__ + /* ChaCha20_ctr32() assumes length is <= 4GB. */ + todo = (uint32_t)todo; +#endif + + /* Truncate if the 32-bit counter would roll over. */ + next_counter = counter[0] + todo / CHACHA_BLK_SIZE; + if (next_counter < counter[0]) { + todo -= next_counter * CHACHA_BLK_SIZE; + next_counter = 0; + } + + ChaCha20_ctr32(out, in, todo, key, counter); + + counter[0] = next_counter; + if (counter[0] == 0) + counter[1]++; + + if (out == block) { + crypto_cursor_copyback(&cc_out, CHACHA_BLK_SIZE, block); + outseg = crypto_cursor_segbase(&cc_out); + outlen = crypto_cursor_seglen(&cc_out); + } else { + crypto_cursor_advance(&cc_out, todo); + outseg += todo; + outlen -= todo; + } + if (in == block) { + inseg = crypto_cursor_segbase(&cc_in); + inlen = crypto_cursor_seglen(&cc_in); + } else { + crypto_cursor_advance(&cc_in, todo); + inseg += todo; + inlen -= todo; + } + resid -= todo; + } + + if (resid > 0) { + memset(block, 0, sizeof(block)); + crypto_cursor_copydata(&cc_in, resid, block); + ChaCha20_ctr32(block, block, CHACHA_BLK_SIZE, key, counter); + crypto_cursor_copyback(&cc_out, resid, block); + } + + explicit_bzero(block, sizeof(block)); + explicit_bzero(counter, sizeof(counter)); + explicit_bzero(key, sizeof(key)); + return (0); +} diff --git a/sys/modules/ossl/Makefile b/sys/modules/ossl/Makefile index 2ddebefebd1a..dfd82dcf6e1f 100644 --- a/sys/modules/ossl/Makefile +++ b/sys/modules/ossl/Makefile @@ -8,6 +8,7 @@ SRCS= bus_if.h \ cryptodev_if.h \ device_if.h \ ossl.c \ + ossl_chacha20.c \ ossl_poly1305.c \ ossl_sha1.c \ ossl_sha256.c \ @@ -15,6 +16,7 @@ SRCS= bus_if.h \ ${SRCS.${MACHINE_CPUARCH}} SRCS.aarch64= \ + chacha-armv8.S \ poly1305-armv8.S \ sha1-armv8.S \ sha256-armv8.S \ @@ -22,6 +24,7 @@ SRCS.aarch64= \ ossl_aarch64.c SRCS.amd64= \ + chacha-x86_64.S \ poly1305-x86_64.S \ sha1-x86_64.S \ sha256-x86_64.S \ @@ -29,6 +32,7 @@ SRCS.amd64= \ ossl_x86.c SRCS.i386= \ + chacha-x86.S \ poly1305-x86.S \ sha1-586.S \ sha256-586.S \ From nobody Thu Oct 21 17:07:00 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6A7691806AE0; Thu, 21 Oct 2021 17:07: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 4HZv6F1Gl0z4h2N; Thu, 21 Oct 2021 17:07:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60BA71F01F; Thu, 21 Oct 2021 17:07: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 19LH70d4080273; Thu, 21 Oct 2021 17:07:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH70FE080272; Thu, 21 Oct 2021 17:07:00 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:00 GMT Message-Id: <202110211707.19LH70FE080272@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: 8e89a7d1821a - stable/13 - poly1305: Don't export generic Poly1305_* symbols from xform_poly1305.c. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 8e89a7d1821a1650e2789b54c91b85ee822ec0f4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=8e89a7d1821a1650e2789b54c91b85ee822ec0f4 commit 8e89a7d1821a1650e2789b54c91b85ee822ec0f4 Author: John Baldwin AuthorDate: 2021-03-05 17:47:58 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:24 +0000 poly1305: Don't export generic Poly1305_* symbols from xform_poly1305.c. There currently isn't a need to provide a public interface to a software Poly1305 implementation beyond what is already available via libsodium's APIs and these symbols conflict with symbols shared within the ossl.ko module between ossl_poly1305.c and ossl_chacha20.c. Reported by: se, kp Fixes: 78991a93eb9d Sponsored by: Netflix (cherry picked from commit bb6e84c988d3f54eff602ed544ceaa9b9fe3e9ff) --- sys/opencrypto/xform_poly1305.c | 43 ++++++++++++----------------------------- sys/opencrypto/xform_poly1305.h | 16 --------------- 2 files changed, 12 insertions(+), 47 deletions(-) diff --git a/sys/opencrypto/xform_poly1305.c b/sys/opencrypto/xform_poly1305.c index bddbb572d682..d8ceab47deca 100644 --- a/sys/opencrypto/xform_poly1305.c +++ b/sys/opencrypto/xform_poly1305.c @@ -4,7 +4,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include @@ -16,16 +15,16 @@ CTASSERT(sizeof(union authctx) >= sizeof(struct poly1305_xform_ctx)); CTASSERT(POLY1305_KEY_LEN == crypto_onetimeauth_poly1305_KEYBYTES); CTASSERT(POLY1305_HASH_LEN == crypto_onetimeauth_poly1305_BYTES); -void -Poly1305_Init(void *polyctx) +static void +xform_Poly1305_Init(void *polyctx) { /* Nop */ } -void -Poly1305_Setkey(struct poly1305_xform_ctx *polyctx, - const uint8_t key[__min_size(POLY1305_KEY_LEN)], size_t klen) +static void +xform_Poly1305_Setkey(void *ctx, const uint8_t *key, u_int klen) { + struct poly1305_xform_ctx *polyctx = ctx; int rc; if (klen != POLY1305_KEY_LEN) @@ -36,16 +35,10 @@ Poly1305_Setkey(struct poly1305_xform_ctx *polyctx, panic("%s: Invariant violated: %d", __func__, rc); } -static void -xform_Poly1305_Setkey(void *ctx, const uint8_t *key, u_int klen) -{ - Poly1305_Setkey(ctx, key, klen); -} - -int -Poly1305_Update(struct poly1305_xform_ctx *polyctx, const void *data, - size_t len) +static int +xform_Poly1305_Update(void *ctx, const void *data, u_int len) { + struct poly1305_xform_ctx *polyctx = ctx; int rc; rc = crypto_onetimeauth_poly1305_update(&polyctx->state, data, len); @@ -54,16 +47,10 @@ Poly1305_Update(struct poly1305_xform_ctx *polyctx, const void *data, return (0); } -static int -xform_Poly1305_Update(void *ctx, const void *data, u_int len) -{ - return (Poly1305_Update(ctx, data, len)); -} - -void -Poly1305_Final(uint8_t digest[__min_size(POLY1305_HASH_LEN)], - struct poly1305_xform_ctx *polyctx) +static void +xform_Poly1305_Final(uint8_t *digest, void *ctx) { + struct poly1305_xform_ctx *polyctx = ctx; int rc; rc = crypto_onetimeauth_poly1305_final(&polyctx->state, digest); @@ -71,12 +58,6 @@ Poly1305_Final(uint8_t digest[__min_size(POLY1305_HASH_LEN)], panic("%s: Invariant violated: %d", __func__, rc); } -static void -xform_Poly1305_Final(uint8_t *digest, void *ctx) -{ - Poly1305_Final(digest, ctx); -} - struct auth_hash auth_hash_poly1305 = { .type = CRYPTO_POLY1305, .name = "Poly-1305", @@ -84,7 +65,7 @@ struct auth_hash auth_hash_poly1305 = { .hashsize = POLY1305_HASH_LEN, .ctxsize = sizeof(struct poly1305_xform_ctx), .blocksize = crypto_onetimeauth_poly1305_BYTES, - .Init = Poly1305_Init, + .Init = xform_Poly1305_Init, .Setkey = xform_Poly1305_Setkey, .Update = xform_Poly1305_Update, .Final = xform_Poly1305_Final, diff --git a/sys/opencrypto/xform_poly1305.h b/sys/opencrypto/xform_poly1305.h deleted file mode 100644 index cca1c6af9395..000000000000 --- a/sys/opencrypto/xform_poly1305.h +++ /dev/null @@ -1,16 +0,0 @@ -/* This file is in the public domain. */ -/* $FreeBSD$ */ -#pragma once - -#include - -struct poly1305_xform_ctx; - -void Poly1305_Init(void *); - -void Poly1305_Setkey(struct poly1305_xform_ctx *, - const uint8_t [__min_size(32)], size_t); - -int Poly1305_Update(struct poly1305_xform_ctx *, const void *, size_t); - -void Poly1305_Final(uint8_t [__min_size(16)], struct poly1305_xform_ctx *); From nobody Thu Oct 21 17:07:01 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8E4061806A6E; Thu, 21 Oct 2021 17:07: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 4HZv6G1cqnz4hHs; Thu, 21 Oct 2021 17:07: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 7C9F61ED70; Thu, 21 Oct 2021 17: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 19LH71CF080303; Thu, 21 Oct 2021 17: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 19LH71O8080302; Thu, 21 Oct 2021 17:07:01 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:01 GMT Message-Id: <202110211707.19LH71O8080302@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: 5131b1448c34 - stable/13 - ossl: Add support for the ChaCha20 + Poly1305 AEAD cipher from RFC 8439 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 5131b1448c342afb9e60b58183bb000c7eae2951 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5131b1448c342afb9e60b58183bb000c7eae2951 commit 5131b1448c342afb9e60b58183bb000c7eae2951 Author: John Baldwin AuthorDate: 2021-03-03 23:17:51 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:24 +0000 ossl: Add support for the ChaCha20 + Poly1305 AEAD cipher from RFC 8439 Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D28757 (cherry picked from commit 78991a93eb9dd3074a3fc19b88a7c3e34e1ec703) --- share/man/man4/ossl.4 | 2 + sys/crypto/openssl/ossl.c | 14 ++ sys/crypto/openssl/ossl.h | 4 + sys/crypto/openssl/ossl_chacha20.c | 306 +++++++++++++++++++++++++++++++++++++ sys/crypto/openssl/ossl_poly1305.c | 8 +- sys/crypto/openssl/ossl_poly1305.h | 5 + 6 files changed, 335 insertions(+), 4 deletions(-) diff --git a/share/man/man4/ossl.4 b/share/man/man4/ossl.4 index 2aa4b69eda31..5929e46e9fe3 100644 --- a/share/man/man4/ossl.4 +++ b/share/man/man4/ossl.4 @@ -76,6 +76,8 @@ driver includes support for the following algorithms: .It ChaCha20 .It +ChaCha20-Poly1305 (RFC 8439) +.It Poly1305 .It SHA1 diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index 0c863429939c..ad9b93dd960d 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -165,6 +165,14 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) return (EINVAL); } break; + case CSP_MODE_AEAD: + switch (csp->csp_cipher_alg) { + case CRYPTO_CHACHA20_POLY1305: + break; + default: + return (EINVAL); + } + break; default: return (EINVAL); } @@ -314,6 +322,12 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) case CSP_MODE_CIPHER: error = ossl_chacha20(crp, csp); break; + case CSP_MODE_AEAD: + if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) + error = ossl_chacha20_poly1305_encrypt(crp, csp); + else + error = ossl_chacha20_poly1305_decrypt(crp, csp); + break; default: __assert_unreachable(); } diff --git a/sys/crypto/openssl/ossl.h b/sys/crypto/openssl/ossl.h index b7c681d0fb1d..11793dca037a 100644 --- a/sys/crypto/openssl/ossl.h +++ b/sys/crypto/openssl/ossl.h @@ -39,6 +39,10 @@ struct crypto_session_params; int ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp); +int ossl_chacha20_poly1305_decrypt(struct cryptop *crp, + const struct crypto_session_params *csp); +int ossl_chacha20_poly1305_encrypt(struct cryptop *crp, + const struct crypto_session_params *csp); void ossl_cpuid(void); /* Needs to be big enough to hold any hash context. */ diff --git a/sys/crypto/openssl/ossl_chacha20.c b/sys/crypto/openssl/ossl_chacha20.c index 70a0a5718dbd..a2bfb52cacd6 100644 --- a/sys/crypto/openssl/ossl_chacha20.c +++ b/sys/crypto/openssl/ossl_chacha20.c @@ -37,6 +37,7 @@ #include #include +#include int ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) @@ -139,3 +140,308 @@ ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) explicit_bzero(key, sizeof(key)); return (0); } + +int +ossl_chacha20_poly1305_encrypt(struct cryptop *crp, + const struct crypto_session_params *csp) +{ + _Alignas(8) unsigned int key[CHACHA_KEY_SIZE / 4]; + unsigned int counter[CHACHA_CTR_SIZE / 4]; + _Alignas(8) unsigned char block[CHACHA_BLK_SIZE]; + unsigned char tag[POLY1305_HASH_LEN]; + POLY1305 auth_ctx; + struct crypto_buffer_cursor cc_in, cc_out; + const unsigned char *in, *inseg, *cipher_key; + unsigned char *out, *outseg; + size_t resid, todo, inlen, outlen; + uint32_t next_counter; + u_int i; + + if (crp->crp_cipher_key != NULL) + cipher_key = crp->crp_cipher_key; + else + cipher_key = csp->csp_cipher_key; + for (i = 0; i < nitems(key); i++) + key[i] = CHACHA_U8TOU32(cipher_key + i * 4); + + crypto_read_iv(crp, counter + 1); + for (i = 1; i < nitems(counter); i++) + counter[i] = le32toh(counter[i]); + + /* Block 0 is used to generate the poly1305 key. */ + counter[0] = 0; + + memset(block, 0, sizeof(block)); + ChaCha20_ctr32(block, block, sizeof(block), key, counter); + Poly1305_Init(&auth_ctx, block); + + /* MAC the AAD. */ + if (crp->crp_aad != NULL) + Poly1305_Update(&auth_ctx, crp->crp_aad, crp->crp_aad_length); + else + crypto_apply(crp, crp->crp_aad_start, crp->crp_aad_length, + ossl_poly1305_update, &auth_ctx); + if (crp->crp_aad_length % 16 != 0) { + /* padding1 */ + memset(block, 0, 16); + Poly1305_Update(&auth_ctx, block, + 16 - crp->crp_aad_length % 16); + } + + /* Encryption starts with block 1. */ + counter[0] = 1; + + /* Do encryption with MAC */ + resid = crp->crp_payload_length; + crypto_cursor_init(&cc_in, &crp->crp_buf); + crypto_cursor_advance(&cc_in, crp->crp_payload_start); + inseg = crypto_cursor_segbase(&cc_in); + inlen = crypto_cursor_seglen(&cc_in); + if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { + crypto_cursor_init(&cc_out, &crp->crp_obuf); + crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); + } else + cc_out = cc_in; + outseg = crypto_cursor_segbase(&cc_out); + outlen = crypto_cursor_seglen(&cc_out); + while (resid >= CHACHA_BLK_SIZE) { + if (inlen < CHACHA_BLK_SIZE) { + crypto_cursor_copydata(&cc_in, CHACHA_BLK_SIZE, block); + in = block; + inlen = CHACHA_BLK_SIZE; + } else + in = inseg; + if (outlen < CHACHA_BLK_SIZE) { + out = block; + outlen = CHACHA_BLK_SIZE; + } else + out = outseg; + + /* Figure out how many blocks we can encrypt/decrypt at once. */ + todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); + +#ifdef __LP64__ + /* ChaCha20_ctr32() assumes length is <= 4GB. */ + todo = (uint32_t)todo; +#endif + + /* Truncate if the 32-bit counter would roll over. */ + next_counter = counter[0] + todo / CHACHA_BLK_SIZE; + if (next_counter < counter[0]) { + todo -= next_counter * CHACHA_BLK_SIZE; + next_counter = 0; + } + + ChaCha20_ctr32(out, in, todo, key, counter); + Poly1305_Update(&auth_ctx, out, todo); + + counter[0] = next_counter; + if (counter[0] == 0) + counter[1]++; + + if (out == block) { + crypto_cursor_copyback(&cc_out, CHACHA_BLK_SIZE, block); + outseg = crypto_cursor_segbase(&cc_out); + outlen = crypto_cursor_seglen(&cc_out); + } else { + crypto_cursor_advance(&cc_out, todo); + outseg += todo; + outlen -= todo; + } + if (in == block) { + inseg = crypto_cursor_segbase(&cc_in); + inlen = crypto_cursor_seglen(&cc_in); + } else { + crypto_cursor_advance(&cc_in, todo); + inseg += todo; + inlen -= todo; + } + resid -= todo; + } + + if (resid > 0) { + memset(block, 0, sizeof(block)); + crypto_cursor_copydata(&cc_in, resid, block); + ChaCha20_ctr32(block, block, CHACHA_BLK_SIZE, key, counter); + crypto_cursor_copyback(&cc_out, resid, block); + + /* padding2 */ + todo = roundup2(resid, 16); + memset(block + resid, 0, todo - resid); + Poly1305_Update(&auth_ctx, block, todo); + } + + /* lengths */ + le64enc(block, crp->crp_aad_length); + le64enc(block + 8, crp->crp_payload_length); + Poly1305_Update(&auth_ctx, block, sizeof(uint64_t) * 2); + + Poly1305_Final(&auth_ctx, tag); + crypto_copyback(crp, crp->crp_digest_start, csp->csp_auth_mlen == 0 ? + POLY1305_HASH_LEN : csp->csp_auth_mlen, tag); + + explicit_bzero(&auth_ctx, sizeof(auth_ctx)); + explicit_bzero(tag, sizeof(tag)); + explicit_bzero(block, sizeof(block)); + explicit_bzero(counter, sizeof(counter)); + explicit_bzero(key, sizeof(key)); + return (0); +} + + +int +ossl_chacha20_poly1305_decrypt(struct cryptop *crp, + const struct crypto_session_params *csp) +{ + _Alignas(8) unsigned int key[CHACHA_KEY_SIZE / 4]; + unsigned int counter[CHACHA_CTR_SIZE / 4]; + _Alignas(8) unsigned char block[CHACHA_BLK_SIZE]; + unsigned char tag[POLY1305_HASH_LEN], tag2[POLY1305_HASH_LEN]; + struct poly1305_context auth_ctx; + struct crypto_buffer_cursor cc_in, cc_out; + const unsigned char *in, *inseg, *cipher_key; + unsigned char *out, *outseg; + size_t resid, todo, inlen, outlen; + uint32_t next_counter; + int error; + u_int i, mlen; + + if (crp->crp_cipher_key != NULL) + cipher_key = crp->crp_cipher_key; + else + cipher_key = csp->csp_cipher_key; + for (i = 0; i < nitems(key); i++) + key[i] = CHACHA_U8TOU32(cipher_key + i * 4); + + crypto_read_iv(crp, counter + 1); + for (i = 1; i < nitems(counter); i++) + counter[i] = le32toh(counter[i]); + + /* Block 0 is used to generate the poly1305 key. */ + counter[0] = 0; + + memset(block, 0, sizeof(block)); + ChaCha20_ctr32(block, block, sizeof(block), key, counter); + Poly1305_Init(&auth_ctx, block); + + /* MAC the AAD. */ + if (crp->crp_aad != NULL) + Poly1305_Update(&auth_ctx, crp->crp_aad, crp->crp_aad_length); + else + crypto_apply(crp, crp->crp_aad_start, crp->crp_aad_length, + ossl_poly1305_update, &auth_ctx); + if (crp->crp_aad_length % 16 != 0) { + /* padding1 */ + memset(block, 0, 16); + Poly1305_Update(&auth_ctx, block, + 16 - crp->crp_aad_length % 16); + } + + /* Mac the ciphertext. */ + crypto_apply(crp, crp->crp_payload_start, crp->crp_payload_length, + ossl_poly1305_update, &auth_ctx); + if (crp->crp_payload_length % 16 != 0) { + /* padding2 */ + memset(block, 0, 16); + Poly1305_Update(&auth_ctx, block, + 16 - crp->crp_payload_length % 16); + } + + /* lengths */ + le64enc(block, crp->crp_aad_length); + le64enc(block + 8, crp->crp_payload_length); + Poly1305_Update(&auth_ctx, block, sizeof(uint64_t) * 2); + + Poly1305_Final(&auth_ctx, tag); + mlen = csp->csp_auth_mlen == 0 ? POLY1305_HASH_LEN : csp->csp_auth_mlen; + crypto_copydata(crp, crp->crp_digest_start, mlen, tag2); + if (timingsafe_bcmp(tag, tag2, mlen) != 0) { + error = EBADMSG; + goto out; + } + + /* Decryption starts with block 1. */ + counter[0] = 1; + + resid = crp->crp_payload_length; + crypto_cursor_init(&cc_in, &crp->crp_buf); + crypto_cursor_advance(&cc_in, crp->crp_payload_start); + inseg = crypto_cursor_segbase(&cc_in); + inlen = crypto_cursor_seglen(&cc_in); + if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { + crypto_cursor_init(&cc_out, &crp->crp_obuf); + crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); + } else + cc_out = cc_in; + outseg = crypto_cursor_segbase(&cc_out); + outlen = crypto_cursor_seglen(&cc_out); + while (resid >= CHACHA_BLK_SIZE) { + if (inlen < CHACHA_BLK_SIZE) { + crypto_cursor_copydata(&cc_in, CHACHA_BLK_SIZE, block); + in = block; + inlen = CHACHA_BLK_SIZE; + } else + in = inseg; + if (outlen < CHACHA_BLK_SIZE) { + out = block; + outlen = CHACHA_BLK_SIZE; + } else + out = outseg; + + /* Figure out how many blocks we can encrypt/decrypt at once. */ + todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); + +#ifdef __LP64__ + /* ChaCha20_ctr32() assumes length is <= 4GB. */ + todo = (uint32_t)todo; +#endif + + /* Truncate if the 32-bit counter would roll over. */ + next_counter = counter[0] + todo / CHACHA_BLK_SIZE; + if (next_counter < counter[0]) { + todo -= next_counter * CHACHA_BLK_SIZE; + next_counter = 0; + } + + ChaCha20_ctr32(out, in, todo, key, counter); + + counter[0] = next_counter; + if (counter[0] == 0) + counter[1]++; + + if (out == block) { + crypto_cursor_copyback(&cc_out, CHACHA_BLK_SIZE, block); + outseg = crypto_cursor_segbase(&cc_out); + outlen = crypto_cursor_seglen(&cc_out); + } else { + crypto_cursor_advance(&cc_out, todo); + outseg += todo; + outlen -= todo; + } + if (in == block) { + inseg = crypto_cursor_segbase(&cc_in); + inlen = crypto_cursor_seglen(&cc_in); + } else { + crypto_cursor_advance(&cc_in, todo); + inseg += todo; + inlen -= todo; + } + resid -= todo; + } + + if (resid > 0) { + memset(block, 0, sizeof(block)); + crypto_cursor_copydata(&cc_in, resid, block); + ChaCha20_ctr32(block, block, CHACHA_BLK_SIZE, key, counter); + crypto_cursor_copyback(&cc_out, resid, block); + } + + error = 0; +out: + explicit_bzero(&auth_ctx, sizeof(auth_ctx)); + explicit_bzero(tag, sizeof(tag)); + explicit_bzero(block, sizeof(block)); + explicit_bzero(counter, sizeof(counter)); + explicit_bzero(key, sizeof(key)); + return (error); +} diff --git a/sys/crypto/openssl/ossl_poly1305.c b/sys/crypto/openssl/ossl_poly1305.c index 8f8c5bc4b6e7..9d08e84ae5bf 100644 --- a/sys/crypto/openssl/ossl_poly1305.c +++ b/sys/crypto/openssl/ossl_poly1305.c @@ -46,7 +46,7 @@ void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, void poly1305_emit(void *ctx, unsigned char mac[16], const unsigned int nonce[4]); -static void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]) +void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]) { ctx->nonce[0] = U8TOU32(&key[16]); ctx->nonce[1] = U8TOU32(&key[20]); @@ -77,7 +77,7 @@ static void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]) # define poly1305_emit (*poly1305_emit_p) #endif -static void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len) +void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len) { #ifdef POLY1305_ASM /* @@ -119,7 +119,7 @@ static void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len) ctx->num = rem; } -static void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]) +void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]) { #ifdef POLY1305_ASM poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks; @@ -152,7 +152,7 @@ ossl_poly1305_setkey(void *vctx, const uint8_t *key, u_int klen) Poly1305_Init(vctx, key); } -static int +int ossl_poly1305_update(void *vctx, const void *buf, u_int len) { Poly1305_Update(vctx, buf, len); diff --git a/sys/crypto/openssl/ossl_poly1305.h b/sys/crypto/openssl/ossl_poly1305.h index d1b2db6d5cba..d0811e0e3f06 100644 --- a/sys/crypto/openssl/ossl_poly1305.h +++ b/sys/crypto/openssl/ossl_poly1305.h @@ -33,3 +33,8 @@ struct poly1305_context { poly1305_emit_f emit; } func; }; + +int ossl_poly1305_update(void *vctx, const void *buf, u_int len); +void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]); +void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len); +void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]); From nobody Thu Oct 21 17:07:02 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BF5151806E42; Thu, 21 Oct 2021 17:07: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 4HZv6J5hnrz4h4F; Thu, 21 Oct 2021 17:07: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 9987A1F020; Thu, 21 Oct 2021 17:07: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 19LH72Qa080327; Thu, 21 Oct 2021 17:07:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH72Z2080326; Thu, 21 Oct 2021 17:07:02 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:02 GMT Message-Id: <202110211707.19LH72Z2080326@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: 06e1e115a9ae - stable/13 - Add Chacha20+Poly1035 to the list of AEAD algorithms. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 06e1e115a9ae872ff54a479f8082ada843a48c6e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=06e1e115a9ae872ff54a479f8082ada843a48c6e commit 06e1e115a9ae872ff54a479f8082ada843a48c6e Author: John Baldwin AuthorDate: 2021-03-18 20:31:39 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:24 +0000 Add Chacha20+Poly1035 to the list of AEAD algorithms. Sponsored by: Netflix (cherry picked from commit c853c53d024a3cc950854dfaade7f50303c5a022) --- share/man/man9/crypto.9 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/man/man9/crypto.9 b/share/man/man9/crypto.9 index 0ea24356e975..69fe3339a757 100644 --- a/share/man/man9/crypto.9 +++ b/share/man/man9/crypto.9 @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2020 +.Dd March 18, 2021 .Dt CRYPTO 9 .Os .Sh NAME @@ -136,9 +136,10 @@ The following encryption algorithms are supported: The following authenticated encryption with additional data (AEAD) algorithms are supported: .Pp -.Bl -tag -offset indent -width CRYPTO_AES_NIST_GCM_16 -compact +.Bl -tag -offset indent -width CRYPTO_CHACHA20_POLY1305 -compact .It Dv CRYPTO_AES_CCM_16 .It Dv CRYPTO_AES_NIST_GCM_16 +.It Dv CRYPTO_CHACHA20_POLY1305 .El .Pp The following compression algorithms are supported: From nobody Thu Oct 21 17:07:03 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BD7A61806E41; Thu, 21 Oct 2021 17:07: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 4HZv6K6MTsz4hL5; Thu, 21 Oct 2021 17:07: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 A233D1ED71; Thu, 21 Oct 2021 17:07: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 19LH73Oc080351; Thu, 21 Oct 2021 17:07:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH73hO080350; Thu, 21 Oct 2021 17:07:03 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:03 GMT Message-Id: <202110211707.19LH73hO080350@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: e3d927fac1da - stable/13 - ossl: Don't encryt/decrypt too much data for chacha20. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: e3d927fac1da765f40addb147e0bacb69a9236fb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e3d927fac1da765f40addb147e0bacb69a9236fb commit e3d927fac1da765f40addb147e0bacb69a9236fb Author: John Baldwin AuthorDate: 2021-04-01 22:42:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:24 +0000 ossl: Don't encryt/decrypt too much data for chacha20. The loops for Chacha20 and Chacha20+Poly1305 which encrypted/decrypted full blocks of data used the minimum of the input and output segment lengths to determine the size of the next chunk ('todo') to pass to Chacha20_ctr32(). However, the input and output segments could extend past the end of the ciphertext region into the tag (e.g. if a "plain" single mbuf contained an entire TLS record). If the length of the tag plus the length of the last partial block together were at least as large as a full Chacha20 block (64 bytes), then an extra block was encrypted/decrypted overlapping with the tag. Fix this by also capping the amount of data to encrypt/decrypt by the amount of remaining data in the ciphertext region ('resid'). Reported by: gallatin Reviewed by: cem, gallatin, markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29517 (cherry picked from commit d2e076c37b0963a8be89684a656c4e1640dc7a3e) --- sys/crypto/openssl/ossl_chacha20.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/crypto/openssl/ossl_chacha20.c b/sys/crypto/openssl/ossl_chacha20.c index a2bfb52cacd6..7fa1a297052e 100644 --- a/sys/crypto/openssl/ossl_chacha20.c +++ b/sys/crypto/openssl/ossl_chacha20.c @@ -88,7 +88,8 @@ ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) out = outseg; /* Figure out how many blocks we can encrypt/decrypt at once. */ - todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); + todo = rounddown(MIN(resid, MIN(inlen, outlen)), + CHACHA_BLK_SIZE); #ifdef __LP64__ /* ChaCha20_ctr32() assumes length is <= 4GB. */ @@ -218,7 +219,8 @@ ossl_chacha20_poly1305_encrypt(struct cryptop *crp, out = outseg; /* Figure out how many blocks we can encrypt/decrypt at once. */ - todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); + todo = rounddown(MIN(resid, MIN(inlen, outlen)), + CHACHA_BLK_SIZE); #ifdef __LP64__ /* ChaCha20_ctr32() assumes length is <= 4GB. */ @@ -389,7 +391,8 @@ ossl_chacha20_poly1305_decrypt(struct cryptop *crp, out = outseg; /* Figure out how many blocks we can encrypt/decrypt at once. */ - todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); + todo = rounddown(MIN(resid, MIN(inlen, outlen)), + CHACHA_BLK_SIZE); #ifdef __LP64__ /* ChaCha20_ctr32() assumes length is <= 4GB. */ From nobody Thu Oct 21 17:07:04 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D29C61806ED7; Thu, 21 Oct 2021 17:07: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 4HZv6L5ptSz4h4P; Thu, 21 Oct 2021 17:07: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 C825E1EF2C; Thu, 21 Oct 2021 17:07: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 19LH74sW080375; Thu, 21 Oct 2021 17:07:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH74MS080374; Thu, 21 Oct 2021 17:07:04 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:04 GMT Message-Id: <202110211707.19LH74MS080374@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: d8b6a6559070 - stable/13 - cryptocheck: Expand the set of sizes tested by -z. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: d8b6a6559070a4d76f8c9e0660fff2ea5a573d65 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d8b6a6559070a4d76f8c9e0660fff2ea5a573d65 commit d8b6a6559070a4d76f8c9e0660fff2ea5a573d65 Author: John Baldwin AuthorDate: 2021-04-01 22:42:30 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:24 +0000 cryptocheck: Expand the set of sizes tested by -z. Test individual sizes up to the max encryption block length as well as a few sizes that include 1 full block and a partial block before doubling the size. Reviewed by: cem, markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29518 (cherry picked from commit c86de1dab8e65bc9d11501ca51f2e152276cb94e) --- tools/tools/crypto/cryptocheck.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c index bd075d24e0f5..502ea04cd661 100644 --- a/tools/tools/crypto/cryptocheck.c +++ b/tools/tools/crypto/cryptocheck.c @@ -228,7 +228,7 @@ static const struct alg { static bool verbose; static int requested_crid; -static size_t aad_sizes[48], sizes[128]; +static size_t aad_sizes[48], sizes[EALG_MAX_BLOCK_LEN * 2]; static u_int naad_sizes, nsizes; static void @@ -1729,12 +1729,18 @@ main(int ac, char **av) if (nsizes == 0) { if (testall) { - for (i = 1; i <= 32; i++) { + for (i = 1; i <= EALG_MAX_BLOCK_LEN; i++) { sizes[nsizes] = i; nsizes++; } - base_size = 32; + for (i = EALG_MAX_BLOCK_LEN + 8; + i <= EALG_MAX_BLOCK_LEN * 2; i += 8) { + sizes[nsizes] = i; + nsizes++; + } + + base_size = EALG_MAX_BLOCK_LEN * 2; while (base_size * 2 < 240 * 1024) { base_size *= 2; assert(nsizes < nitems(sizes)); From nobody Thu Oct 21 17:07:05 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 36FF31806EDA; Thu, 21 Oct 2021 17:07: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 4HZv6M190Cz4hLK; Thu, 21 Oct 2021 17:07: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 E9F8F1EF2D; Thu, 21 Oct 2021 17:07: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 19LH754M080399; Thu, 21 Oct 2021 17:07:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH75Ha080398; Thu, 21 Oct 2021 17:07:05 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:05 GMT Message-Id: <202110211707.19LH75Ha080398@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: 11db133ecad7 - stable/13 - cryptodev: Use 'csp' in the handlers for requests. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 11db133ecad7930dd4f289815e2a1b531390f124 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=11db133ecad7930dd4f289815e2a1b531390f124 commit 11db133ecad7930dd4f289815e2a1b531390f124 Author: John Baldwin AuthorDate: 2021-10-06 21:08:46 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:25 +0000 cryptodev: Use 'csp' in the handlers for requests. - Retire cse->mode and use csp->csp_mode instead. - Use csp->csp_cipher_algorithm instead of the ivsize when checking for the fixup for the IV length for AES-XTS. Reviewed by: markj Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32103 (cherry picked from commit b4e0a27c5be5090a9db16dd0ad417543b1fb0c4a) --- sys/opencrypto/cryptodev.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 81c6dcd01e2a..9f581e68fe92 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -3,13 +3,16 @@ /*- * Copyright (c) 2001 Theo de Raadt * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2014-2021 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by John-Mark Gurney * under sponsorship of the FreeBSD Foundation and * Rubicon Communications, LLC (Netgate). * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -325,7 +328,6 @@ struct csession { struct enc_xform *txform; int hashsize; int ivsize; - int mode; void *key; void *mackey; @@ -679,7 +681,6 @@ cse_create(struct fcrypt *fcr, struct session2_op *sop) refcount_init(&cse->refs, 1); cse->key = key; cse->mackey = mackey; - cse->mode = csp.csp_mode; cse->cses = cses; cse->txform = txform; if (thash != NULL) @@ -808,6 +809,7 @@ cryptodev_cb(struct cryptop *crp) static int cryptodev_op(struct csession *cse, const struct crypt_op *cop) { + const struct crypto_session_params *csp; struct cryptop_data *cod = NULL; struct cryptop *crp = NULL; char *dst; @@ -857,7 +859,8 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) if (cse->hashsize) crp->crp_digest_start = cop->len; - switch (cse->mode) { + csp = crypto_get_params(cse->cses); + switch (csp->csp_mode) { case CSP_MODE_COMPRESS: switch (cop->op) { case COP_ENCRYPT: @@ -1023,6 +1026,7 @@ bail: static int cryptodev_aead(struct csession *cse, struct crypt_aead *caead) { + const struct crypto_session_params *csp; struct cryptop_data *cod = NULL; struct cryptop *crp = NULL; char *dst; @@ -1085,7 +1089,8 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) else crp->crp_digest_start = crp->crp_payload_start + caead->len; - switch (cse->mode) { + csp = crypto_get_params(cse->cses); + switch (csp->csp_mode) { case CSP_MODE_AEAD: case CSP_MODE_ETA: switch (caead->op) { @@ -1123,9 +1128,9 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) * Permit a 16-byte IV for AES-XTS, but only use the * first 8 bytes as a block number. */ - if (cse->mode == CSP_MODE_ETA && - caead->ivlen == AES_BLOCK_LEN && - cse->ivsize == AES_XTS_IV_LEN) + if (csp->csp_mode == CSP_MODE_ETA && + csp->csp_cipher_alg == CRYPTO_AES_XTS && + caead->ivlen == AES_BLOCK_LEN) caead->ivlen = AES_XTS_IV_LEN; if (cse->ivsize == 0) { From nobody Thu Oct 21 17:07:06 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0BB0318070A9; Thu, 21 Oct 2021 17:07: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 4HZv6P0c5Tz4hCN; Thu, 21 Oct 2021 17:07: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 16A2A1EFB5; Thu, 21 Oct 2021 17:07: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 19LH76bS080429; Thu, 21 Oct 2021 17:07:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH765L080428; Thu, 21 Oct 2021 17:07:06 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:06 GMT Message-Id: <202110211707.19LH765L080428@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: 83b3e8e05ad9 - stable/13 - ccp, ccr: Simplify drivers to assume an AES-GCM IV length of 12. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 83b3e8e05ad9bab3f6cd79cc7842c37fa5f84951 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=83b3e8e05ad9bab3f6cd79cc7842c37fa5f84951 commit 83b3e8e05ad9bab3f6cd79cc7842c37fa5f84951 Author: John Baldwin AuthorDate: 2021-10-06 21:08:46 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:25 +0000 ccp, ccr: Simplify drivers to assume an AES-GCM IV length of 12. While here, use crypto_read_iv() in a few more places in ccr(4) that I missed previously. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32104 (cherry picked from commit cb128893b92994456107d6ca722fdf6e5028eacc) --- sys/crypto/ccp/ccp_hardware.c | 5 ++--- sys/dev/cxgbe/crypto/t4_crypto.c | 36 ++++++------------------------------ 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/sys/crypto/ccp/ccp_hardware.c b/sys/crypto/ccp/ccp_hardware.c index a2ca8e1cb71a..68f46a553f3c 100644 --- a/sys/crypto/ccp/ccp_hardware.c +++ b/sys/crypto/ccp/ccp_hardware.c @@ -1356,10 +1356,9 @@ ccp_collect_iv(struct cryptop *crp, const struct crypto_session_params *csp, crypto_read_iv(crp, iv); /* - * If the input IV is 12 bytes, append an explicit counter of 1. + * Append an explicit counter of 1 for GCM. */ - if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16 && - csp->csp_ivlen == 12) + if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16) *(uint32_t *)&iv[12] = htobe32(1); if (csp->csp_cipher_alg == CRYPTO_AES_XTS && diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c index cdd14fcee2f9..a3c25eb7df47 100644 --- a/sys/dev/cxgbe/crypto/t4_crypto.c +++ b/sys/dev/cxgbe/crypto/t4_crypto.c @@ -1133,26 +1133,7 @@ ccr_gcm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) else op_type = CHCR_DECRYPT_OP; - /* - * The IV handling for GCM in OCF is a bit more complicated in - * that IPSec provides a full 16-byte IV (including the - * counter), whereas the /dev/crypto interface sometimes - * provides a full 16-byte IV (if no IV is provided in the - * ioctl) and sometimes a 12-byte IV (if the IV was explicit). - * - * When provided a 12-byte IV, assume the IV is really 16 bytes - * with a counter in the last 4 bytes initialized to 1. - * - * While iv_len is checked below, the value is currently - * always set to 12 when creating a GCM session in this driver - * due to limitations in OCF (there is no way to know what the - * IV length of a given request will be). This means that the - * driver always assumes as 12-byte IV for now. - */ - if (s->blkcipher.iv_len == 12) - iv_len = AES_BLOCK_LEN; - else - iv_len = s->blkcipher.iv_len; + iv_len = AES_BLOCK_LEN; /* * GCM requests should always provide an explicit IV. @@ -1290,9 +1271,8 @@ ccr_gcm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) crwr = wrtod(wr); memset(crwr, 0, wr_len); - memcpy(iv, crp->crp_iv, s->blkcipher.iv_len); - if (s->blkcipher.iv_len == 12) - *(uint32_t *)&iv[12] = htobe32(1); + crypto_read_iv(crp, iv); + *(uint32_t *)&iv[12] = htobe32(1); ccr_populate_wreq(sc, s, crwr, kctx_len, wr_len, imm_len, sgl_len, 0, crp); @@ -1445,15 +1425,11 @@ ccr_gcm_soft(struct ccr_session *s, struct cryptop *crp) if (error) goto out; - /* - * This assumes a 12-byte IV from the crp. See longer comment - * above in ccr_gcm() for more details. - */ if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) { error = EINVAL; goto out; } - memcpy(iv, crp->crp_iv, 12); + crypto_read_iv(crp, iv); *(uint32_t *)&iv[12] = htobe32(1); axf->Reinit(auth_ctx, iv, sizeof(iv)); @@ -1767,7 +1743,7 @@ ccr_ccm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) */ memset(iv, 0, iv_len); iv[0] = (15 - AES_CCM_IV_LEN) - 1; - memcpy(iv + 1, crp->crp_iv, AES_CCM_IV_LEN); + crypto_read_iv(crp, iv + 1); ccr_populate_wreq(sc, s, crwr, kctx_len, wr_len, imm_len, sgl_len, 0, crp); @@ -1940,7 +1916,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) error = EINVAL; goto out; } - memcpy(iv, crp->crp_iv, AES_CCM_IV_LEN); + crypto_read_iv(crp, iv); auth_ctx->aes_cbc_mac_ctx.authDataLength = crp->crp_aad_length; auth_ctx->aes_cbc_mac_ctx.cryptDataLength = crp->crp_payload_length; From nobody Thu Oct 21 17:07:08 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7E9DC1806E6E; Thu, 21 Oct 2021 17:07: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 4HZv6Q2l3Yz4hNg; Thu, 21 Oct 2021 17:07: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 2EAED1EDB8; Thu, 21 Oct 2021 17:07: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 19LH78bs080453; Thu, 21 Oct 2021 17:07:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH780s080452; Thu, 21 Oct 2021 17:07:08 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:08 GMT Message-Id: <202110211707.19LH780s080452@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: 2ba824366ca6 - stable/13 - Extend m_apply() to support unmapped mbufs. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 2ba824366ca60679c36296991582054116d2d4a7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=2ba824366ca60679c36296991582054116d2d4a7 commit 2ba824366ca60679c36296991582054116d2d4a7 Author: John Baldwin AuthorDate: 2021-05-25 23:59:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:25 +0000 Extend m_apply() to support unmapped mbufs. m_apply() invokes the callback function separately on each segment of an unmapped mbuf: the TLS header, individual pages, and the TLS trailer. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30132 (cherry picked from commit 3c7a01d773ac2d128eabb596eed7098f76966cc5) --- sys/kern/uipc_mbuf.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index f525c25d1431..8b5b83337d56 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1239,6 +1239,62 @@ m_append(struct mbuf *m0, int len, c_caddr_t cp) return (remainder == 0); } +static int +m_apply_extpg_one(struct mbuf *m, int off, int len, + int (*f)(void *, void *, u_int), void *arg) +{ + void *p; + u_int i, count, pgoff, pglen; + int rval; + + KASSERT(PMAP_HAS_DMAP, + ("m_apply_extpg_one does not support unmapped mbufs")); + off += mtod(m, vm_offset_t); + if (off < m->m_epg_hdrlen) { + count = min(m->m_epg_hdrlen - off, len); + rval = f(arg, m->m_epg_hdr + off, count); + if (rval) + return (rval); + len -= count; + off = 0; + } else + off -= m->m_epg_hdrlen; + pgoff = m->m_epg_1st_off; + for (i = 0; i < m->m_epg_npgs && len > 0; i++) { + pglen = m_epg_pagelen(m, i, pgoff); + if (off < pglen) { + count = min(pglen - off, len); + p = (void *)PHYS_TO_DMAP(m->m_epg_pa[i] + pgoff); + rval = f(arg, p, count); + if (rval) + return (rval); + len -= count; + off = 0; + } else + off -= pglen; + pgoff = 0; + } + if (len > 0) { + KASSERT(off < m->m_epg_trllen, + ("m_apply_extpg_one: offset beyond trailer")); + KASSERT(len <= m->m_epg_trllen - off, + ("m_apply_extpg_one: length beyond trailer")); + return (f(arg, m->m_epg_trail + off, len)); + } + return (0); +} + +/* Apply function f to the data in a single mbuf. */ +static int +m_apply_one(struct mbuf *m, int off, int len, + int (*f)(void *, void *, u_int), void *arg) +{ + if ((m->m_flags & M_EXTPG) != 0) + return (m_apply_extpg_one(m, off, len, f, arg)); + else + return (f(arg, mtod(m, caddr_t) + off, len)); +} + /* * Apply function f to the data in an mbuf chain starting "off" bytes from * the beginning, continuing for "len" bytes. @@ -1262,7 +1318,7 @@ m_apply(struct mbuf *m, int off, int len, while (len > 0) { KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain")); count = min(m->m_len - off, len); - rval = (*f)(arg, mtod(m, caddr_t) + off, count); + rval = m_apply_one(m, off, count, f, arg); if (rval) return (rval); len -= count; From nobody Thu Oct 21 17:07:09 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0D63518070D1; Thu, 21 Oct 2021 17:07: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 4HZv6R46Zwz4hNp; Thu, 21 Oct 2021 17:07: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 504CC1EDB9; Thu, 21 Oct 2021 17:07: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 19LH79n5080477; Thu, 21 Oct 2021 17:07:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH79pZ080476; Thu, 21 Oct 2021 17:07:09 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:09 GMT Message-Id: <202110211707.19LH79pZ080476@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: 8efc88d0d6a0 - stable/13 - Extend m_copyback() to support unmapped mbufs. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 8efc88d0d6a044e5928bec64447fcbc24b8f01b2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=8efc88d0d6a044e5928bec64447fcbc24b8f01b2 commit 8efc88d0d6a044e5928bec64447fcbc24b8f01b2 Author: John Baldwin AuthorDate: 2021-05-25 23:59:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:25 +0000 Extend m_copyback() to support unmapped mbufs. Reviewed by: gallatin, markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30133 (cherry picked from commit 3f9dac85cc8f2963026fdc2d5477acb607176a89) --- sys/kern/uipc_mbuf.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 8b5b83337d56..b141cb5f43a2 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1139,6 +1139,29 @@ m_devget(char *buf, int totlen, int off, struct ifnet *ifp, return (top); } +static void +m_copytounmapped(const struct mbuf *m, int off, int len, c_caddr_t cp) +{ + struct iovec iov; + struct uio uio; + int error; + + KASSERT(off >= 0, ("m_copytounmapped: negative off %d", off)); + KASSERT(len >= 0, ("m_copytounmapped: negative len %d", len)); + KASSERT(off < m->m_len, ("m_copytounmapped: len exceeds mbuf length")); + iov.iov_base = __DECONST(caddr_t, cp); + iov.iov_len = len; + uio.uio_resid = len; + uio.uio_iov = &iov; + uio.uio_segflg = UIO_SYSSPACE; + uio.uio_iovcnt = 1; + uio.uio_offset = 0; + uio.uio_rw = UIO_WRITE; + error = m_unmappedtouio(m, off, &uio, len); + KASSERT(error == 0, ("m_unmappedtouio failed: off %d, len %d", off, + len)); +} + /* * Copy data from a buffer back into the indicated mbuf chain, * starting "off" bytes from the beginning, extending the mbuf @@ -1172,7 +1195,10 @@ m_copyback(struct mbuf *m0, int off, int len, c_caddr_t cp) M_TRAILINGSPACE(m)); } mlen = min (m->m_len - off, len); - bcopy(cp, off + mtod(m, caddr_t), (u_int)mlen); + if ((m->m_flags & M_EXTPG) != 0) + m_copytounmapped(m, off, mlen, cp); + else + bcopy(cp, off + mtod(m, caddr_t), (u_int)mlen); cp += mlen; len -= mlen; mlen += off; @@ -1870,7 +1896,7 @@ m_uiotombuf(struct uio *uio, int how, int len, int align, int flags) } /* - * Copy data from an unmapped mbuf into a uio limited by len if set. + * Copy data to/from an unmapped mbuf into a uio limited by len if set. */ int m_unmappedtouio(const struct mbuf *m, int m_off, struct uio *uio, int len) From nobody Thu Oct 21 17:07:10 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1D88E1807132; Thu, 21 Oct 2021 17:07: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 4HZv6S163fz4hNt; Thu, 21 Oct 2021 17:07: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 71CCD1ED72; Thu, 21 Oct 2021 17:07: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 19LH7AjA080501; Thu, 21 Oct 2021 17:07:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH7Afe080500; Thu, 21 Oct 2021 17:07:10 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:10 GMT Message-Id: <202110211707.19LH7Afe080500@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: da557f2fe654 - stable/13 - Rename m_unmappedtouio() to m_unmapped_uiomove(). List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: da557f2fe654b703bb7fe3f72d225bc78d08173d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=da557f2fe654b703bb7fe3f72d225bc78d08173d commit da557f2fe654b703bb7fe3f72d225bc78d08173d Author: John Baldwin AuthorDate: 2021-05-25 23:59:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:26 +0000 Rename m_unmappedtouio() to m_unmapped_uiomove(). This function doesn't only copy data into a uio but instead is a variant of uiomove() similar to uiomove_fromphys(). Reviewed by: gallatin, markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30444 (cherry picked from commit aa341db39b6373c5e242f376a3cabe6a6b99141e) --- sys/kern/uipc_mbuf.c | 12 ++++++------ sys/kern/uipc_socket.c | 3 ++- sys/sys/mbuf.h | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index b141cb5f43a2..1a2098c7c536 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -628,8 +628,8 @@ m_copyfromunmapped(const struct mbuf *m, int off, int len, caddr_t cp) uio.uio_iovcnt = 1; uio.uio_offset = 0; uio.uio_rw = UIO_READ; - error = m_unmappedtouio(m, off, &uio, len); - KASSERT(error == 0, ("m_unmappedtouio failed: off %d, len %d", off, + error = m_unmapped_uiomove(m, off, &uio, len); + KASSERT(error == 0, ("m_unmapped_uiomove failed: off %d, len %d", off, len)); } @@ -1157,8 +1157,8 @@ m_copytounmapped(const struct mbuf *m, int off, int len, c_caddr_t cp) uio.uio_iovcnt = 1; uio.uio_offset = 0; uio.uio_rw = UIO_WRITE; - error = m_unmappedtouio(m, off, &uio, len); - KASSERT(error == 0, ("m_unmappedtouio failed: off %d, len %d", off, + error = m_unmapped_uiomove(m, off, &uio, len); + KASSERT(error == 0, ("m_unmapped_uiomove failed: off %d, len %d", off, len)); } @@ -1899,7 +1899,7 @@ m_uiotombuf(struct uio *uio, int how, int len, int align, int flags) * Copy data to/from an unmapped mbuf into a uio limited by len if set. */ int -m_unmappedtouio(const struct mbuf *m, int m_off, struct uio *uio, int len) +m_unmapped_uiomove(const struct mbuf *m, int m_off, struct uio *uio, int len) { vm_page_t pg; int error, i, off, pglen, pgoff, seglen, segoff; @@ -1970,7 +1970,7 @@ m_mbuftouio(struct uio *uio, const struct mbuf *m, int len) length = min(m->m_len, total - progress); if ((m->m_flags & M_EXTPG) != 0) - error = m_unmappedtouio(m, 0, uio, length); + error = m_unmapped_uiomove(m, 0, uio, length); else error = uiomove(mtod(m, void *), length, uio); if (error) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 0ba8387763e1..92ee7e1f97d0 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2199,7 +2199,8 @@ dontblock: SBLASTMBUFCHK(&so->so_rcv); SOCKBUF_UNLOCK(&so->so_rcv); if ((m->m_flags & M_EXTPG) != 0) - error = m_unmappedtouio(m, moff, uio, (int)len); + error = m_unmapped_uiomove(m, moff, uio, + (int)len); else error = uiomove(mtod(m, char *) + moff, (int)len, uio); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index bb6bf9f62b7a..640856016e0e 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -834,7 +834,6 @@ struct mbuf *m_getm2(struct mbuf *, int, int, short, int); struct mbuf *m_getptr(struct mbuf *, int, int *); u_int m_length(struct mbuf *, struct mbuf **); int m_mbuftouio(struct uio *, const struct mbuf *, int); -int m_unmappedtouio(const struct mbuf *, int, struct uio *, int); void m_move_pkthdr(struct mbuf *, struct mbuf *); int m_pkthdr_init(struct mbuf *, int); struct mbuf *m_prepend(struct mbuf *, int, int); @@ -844,6 +843,8 @@ struct mbuf *m_pullup(struct mbuf *, int); int m_sanity(struct mbuf *, int); struct mbuf *m_split(struct mbuf *, int, int); struct mbuf *m_uiotombuf(struct uio *, int, int, int, int); +int m_unmapped_uiomove(const struct mbuf *, int, struct uio *, + int); struct mbuf *m_unshare(struct mbuf *, int); int m_snd_tag_alloc(struct ifnet *, union if_snd_tag_alloc_params *, struct m_snd_tag **); From nobody Thu Oct 21 17:07:11 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AF1C71806FF5; Thu, 21 Oct 2021 17:07: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 4HZv6S6q7Mz4h7B; Thu, 21 Oct 2021 17:07: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 95F671EDBA; Thu, 21 Oct 2021 17:07: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 19LH7BcJ080525; Thu, 21 Oct 2021 17:07:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH7Bs1080524; Thu, 21 Oct 2021 17:07:11 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:11 GMT Message-Id: <202110211707.19LH7Bs1080524@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: 8460b90d28c0 - stable/13 - Support unmapped mbufs in crypto buffers. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 8460b90d28c027f48427eb640c038598e7ba4c56 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=8460b90d28c027f48427eb640c038598e7ba4c56 commit 8460b90d28c027f48427eb640c038598e7ba4c56 Author: John Baldwin AuthorDate: 2021-05-25 23:59:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:26 +0000 Support unmapped mbufs in crypto buffers. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30134 (cherry picked from commit 1c8f4b3c9f9e8ca5823d153d3b117246b3d18db4) --- sys/opencrypto/criov.c | 121 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 10 deletions(-) diff --git a/sys/opencrypto/criov.c b/sys/opencrypto/criov.c index b18a01faf26a..bf7965032084 100644 --- a/sys/opencrypto/criov.c +++ b/sys/opencrypto/criov.c @@ -239,6 +239,99 @@ cvm_page_copydata(vm_page_t *pages, int off, int len, caddr_t cp) } #endif /* CRYPTO_MAY_HAVE_VMPAGE */ +/* + * Given a starting page in an m_epg, determine the length of the + * current physically contiguous segment. + */ +static __inline size_t +m_epg_pages_extent(struct mbuf *m, int idx, u_int pglen) +{ + size_t len; + u_int i; + + len = pglen; + for (i = idx + 1; i < m->m_epg_npgs; i++) { + if (m->m_epg_pa[i - 1] + PAGE_SIZE != m->m_epg_pa[i]) + break; + len += m_epg_pagelen(m, i, 0); + } + return (len); +} + +static __inline void * +m_epg_segbase(struct mbuf *m, size_t offset) +{ + u_int i, pglen, pgoff; + + offset += mtod(m, vm_offset_t); + if (offset < m->m_epg_hdrlen) + return (m->m_epg_hdr + offset); + offset -= m->m_epg_hdrlen; + pgoff = m->m_epg_1st_off; + for (i = 0; i < m->m_epg_npgs; i++) { + pglen = m_epg_pagelen(m, i, pgoff); + if (offset < pglen) + return ((void *)PHYS_TO_DMAP(m->m_epg_pa[i] + pgoff + + offset)); + offset -= pglen; + pgoff = 0; + } + KASSERT(offset <= m->m_epg_trllen, ("%s: offset beyond trailer", + __func__)); + return (m->m_epg_trail + offset); +} + +static __inline size_t +m_epg_seglen(struct mbuf *m, size_t offset) +{ + u_int i, pglen, pgoff; + + offset += mtod(m, vm_offset_t); + if (offset < m->m_epg_hdrlen) + return (m->m_epg_hdrlen - offset); + offset -= m->m_epg_hdrlen; + pgoff = m->m_epg_1st_off; + for (i = 0; i < m->m_epg_npgs; i++) { + pglen = m_epg_pagelen(m, i, pgoff); + if (offset < pglen) + return (m_epg_pages_extent(m, i, pglen) - offset); + offset -= pglen; + pgoff = 0; + } + KASSERT(offset <= m->m_epg_trllen, ("%s: offset beyond trailer", + __func__)); + return (m->m_epg_trllen - offset); +} + +static __inline void * +m_epg_contiguous_subsegment(struct mbuf *m, size_t skip, size_t len) +{ + u_int i, pglen, pgoff; + + skip += mtod(m, vm_offset_t); + if (skip < m->m_epg_hdrlen) { + if (len > m->m_epg_hdrlen - skip) + return (NULL); + return (m->m_epg_hdr + skip); + } + skip -= m->m_epg_hdrlen; + pgoff = m->m_epg_1st_off; + for (i = 0; i < m->m_epg_npgs; i++) { + pglen = m_epg_pagelen(m, i, pgoff); + if (skip < pglen) { + if (len > m_epg_pages_extent(m, i, pglen) - skip) + return (NULL); + return ((void *)PHYS_TO_DMAP(m->m_epg_pa[i] + pgoff + + skip)); + } + skip -= pglen; + pgoff = 0; + } + KASSERT(skip <= m->m_epg_trllen && len <= m->m_epg_trllen - skip, + ("%s: segment beyond trailer", __func__)); + return (m->m_epg_trail + skip); +} + void crypto_cursor_init(struct crypto_buffer_cursor *cc, const struct crypto_buffer *cb) @@ -345,8 +438,8 @@ crypto_cursor_segbase(struct crypto_buffer_cursor *cc) case CRYPTO_BUF_MBUF: if (cc->cc_mbuf == NULL) return (NULL); - KASSERT((cc->cc_mbuf->m_flags & M_EXTPG) == 0, - ("%s: not supported for unmapped mbufs", __func__)); + if (cc->cc_mbuf->m_flags & M_EXTPG) + return (m_epg_segbase(cc->cc_mbuf, cc->cc_offset)); return (mtod(cc->cc_mbuf, char *) + cc->cc_offset); case CRYPTO_BUF_VMPAGE: return ((char *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( @@ -372,6 +465,8 @@ crypto_cursor_seglen(struct crypto_buffer_cursor *cc) case CRYPTO_BUF_MBUF: if (cc->cc_mbuf == NULL) return (0); + if (cc->cc_mbuf->m_flags & M_EXTPG) + return (m_epg_seglen(cc->cc_mbuf, cc->cc_offset)); return (cc->cc_mbuf->m_len - cc->cc_offset); case CRYPTO_BUF_UIO: return (cc->cc_iov->iov_len - cc->cc_offset); @@ -401,12 +496,14 @@ crypto_cursor_copyback(struct crypto_buffer_cursor *cc, int size, break; case CRYPTO_BUF_MBUF: for (;;) { - KASSERT((cc->cc_mbuf->m_flags & M_EXTPG) == 0, - ("%s: not supported for unmapped mbufs", __func__)); - dst = mtod(cc->cc_mbuf, char *) + cc->cc_offset; + /* + * This uses m_copyback() for individual + * mbufs so that cc_mbuf and cc_offset are + * updated. + */ remain = cc->cc_mbuf->m_len - cc->cc_offset; todo = MIN(remain, size); - memcpy(dst, src, todo); + m_copyback(cc->cc_mbuf, cc->cc_offset, todo, src); src += todo; if (todo < remain) { cc->cc_offset += todo; @@ -482,12 +579,14 @@ crypto_cursor_copydata(struct crypto_buffer_cursor *cc, int size, void *vdst) break; case CRYPTO_BUF_MBUF: for (;;) { - KASSERT((cc->cc_mbuf->m_flags & M_EXTPG) == 0, - ("%s: not supported for unmapped mbufs", __func__)); - src = mtod(cc->cc_mbuf, const char *) + cc->cc_offset; + /* + * This uses m_copydata() for individual + * mbufs so that cc_mbuf and cc_offset are + * updated. + */ remain = cc->cc_mbuf->m_len - cc->cc_offset; todo = MIN(remain, size); - memcpy(dst, src, todo); + m_copydata(cc->cc_mbuf, cc->cc_offset, todo, dst); dst += todo; if (todo < remain) { cc->cc_offset += todo; @@ -715,6 +814,8 @@ m_contiguous_subsegment(struct mbuf *m, size_t skip, size_t len) if (skip + len > m->m_len) return (NULL); + if (m->m_flags & M_EXTPG) + return (m_epg_contiguous_subsegment(m, skip, len)); return (mtod(m, char*) + skip); } From nobody Thu Oct 21 17:07:12 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A9735180729E; Thu, 21 Oct 2021 17:07: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 4HZv6W43Xrz4hCn; Thu, 21 Oct 2021 17:07: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 B056A1F021; Thu, 21 Oct 2021 17:07: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 19LH7C5w080553; Thu, 21 Oct 2021 17:07:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH7Cd7080552; Thu, 21 Oct 2021 17:07:12 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:12 GMT Message-Id: <202110211707.19LH7Cd7080552@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: 60b9ce724518 - stable/13 - sglist: Add sglist_append_single_mbuf(). List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 60b9ce724518e6c5a594ae3d10507e0d4771fd8b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=60b9ce724518e6c5a594ae3d10507e0d4771fd8b commit 60b9ce724518e6c5a594ae3d10507e0d4771fd8b Author: John Baldwin AuthorDate: 2021-05-25 23:59:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:26 +0000 sglist: Add sglist_append_single_mbuf(). This function appends the contents of a single mbuf to an sglist rather than an entire mbuf chain. Reviewed by: gallatin, markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30135 (cherry picked from commit 6663f8a23e7cb60d798c5ffbd9c716b62b204f2a) --- share/man/man9/Makefile | 1 + share/man/man9/sglist.9 | 12 +++++++++++- sys/kern/subr_sglist.c | 15 +++++++++++++++ sys/sys/sglist.h | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index ae5efa65bd0b..acdfa7cc6d8e 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1946,6 +1946,7 @@ MLINKS+=sglist.9 sglist_alloc.9 \ sglist.9 sglist_append_mbuf_epg.9 \ sglist.9 sglist_append_phys.9 \ sglist.9 sglist_append_sglist.9 \ + sglist.9 sglist_append_single_mbuf.9 \ sglist.9 sglist_append_uio.9 \ sglist.9 sglist_append_user.9 \ sglist.9 sglist_append_vmpages.9 \ diff --git a/share/man/man9/sglist.9 b/share/man/man9/sglist.9 index b1d781b84d63..408d23573489 100644 --- a/share/man/man9/sglist.9 +++ b/share/man/man9/sglist.9 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 24, 2020 +.Dd May 25, 2021 .Dt SGLIST 9 .Os .Sh NAME @@ -38,6 +38,7 @@ .Nm sglist_append_mbuf_epg, .Nm sglist_append_phys , .Nm sglist_append_sglist , +.Nm sglist_append_single_mbuf , .Nm sglist_append_uio , .Nm sglist_append_user , .Nm sglist_append_vmpages , @@ -74,6 +75,8 @@ .Ft int .Fn sglist_append_sglist "struct sglist *sg" "struct sglist *source" "size_t offset" "size_t len" .Ft int +.Fn sglist_append_single_mbuf "struct sglist *sg" "struct mbuf *m" +.Ft int .Fn sglist_append_uio "struct sglist *sg" "struct uio *uio" .Ft int .Fn sglist_append_user "struct sglist *sg" "void *buf" "size_t len" "struct thread *td" @@ -284,6 +287,13 @@ to the scatter/gather list .Fa sg . .Pp The +.Nm sglist_append_mbuf +function appends the physical address ranges described by a single mbuf +.Fa m +to the scatter/gather list +.Fa sg . +.Pp +The .Nm sglist_append_phys function appends a single physical address range to the scatter/gather list .Fa sg . diff --git a/sys/kern/subr_sglist.c b/sys/kern/subr_sglist.c index 71be45b4231d..7c520fda00f5 100644 --- a/sys/kern/subr_sglist.c +++ b/sys/kern/subr_sglist.c @@ -466,6 +466,21 @@ sglist_append_mbuf(struct sglist *sg, struct mbuf *m0) return (0); } +/* + * Append the segments that describe a single mbuf to a scatter/gather + * list. If there are insufficient segments, then this fails with + * EFBIG. + */ +int +sglist_append_single_mbuf(struct sglist *sg, struct mbuf *m) +{ + if ((m->m_flags & M_EXTPG) != 0) + return (sglist_append_mbuf_epg(sg, m, + mtod(m, vm_offset_t), m->m_len)); + else + return (sglist_append(sg, m->m_data, m->m_len)); +} + /* * Append the segments that describe a buffer spanning an array of VM * pages. The buffer begins at an offset of 'pgoff' in the first diff --git a/sys/sys/sglist.h b/sys/sys/sglist.h index 82a3ac6ed6ac..bf8aa482e3ce 100644 --- a/sys/sys/sglist.h +++ b/sys/sys/sglist.h @@ -94,6 +94,7 @@ int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr, size_t len); int sglist_append_sglist(struct sglist *sg, struct sglist *source, size_t offset, size_t length); +int sglist_append_single_mbuf(struct sglist *sg, struct mbuf *m); int sglist_append_uio(struct sglist *sg, struct uio *uio); int sglist_append_user(struct sglist *sg, void *buf, size_t len, struct thread *td); From nobody Thu Oct 21 17:07:13 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8A98D1807429; Thu, 21 Oct 2021 17:07: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 4HZv6X5lwlz4hJs; Thu, 21 Oct 2021 17:07: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 C83281EF2E; Thu, 21 Oct 2021 17:07: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 19LH7DtK080579; Thu, 21 Oct 2021 17:07:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH7DVf080578; Thu, 21 Oct 2021 17:07:13 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:13 GMT Message-Id: <202110211707.19LH7DVf080578@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: 58d69f4ecfee - stable/13 - crypto: Add a new type of crypto buffer for a single mbuf. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 58d69f4ecfeef7cc811c21ac1d3901c4fdc4f610 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=58d69f4ecfeef7cc811c21ac1d3901c4fdc4f610 commit 58d69f4ecfeef7cc811c21ac1d3901c4fdc4f610 Author: John Baldwin AuthorDate: 2021-05-25 23:59:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:26 +0000 crypto: Add a new type of crypto buffer for a single mbuf. This is intended for use in KTLS transmit where each TLS record is described by a single mbuf that is itself queued in the socket buffer. Using the existing CRYPTO_BUF_MBUF would result in bus_dmamap_load_crp() walking additional mbufs in the socket buffer that are not relevant, but generating a S/G list that potentially exceeds the limit of the tag (while also wasting CPU cycles). Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30136 (cherry picked from commit 883a0196b629a07e52562b4103cc0f6391083080) --- share/man/man9/crypto_buffer.9 | 11 ++++++++--- sys/crypto/ccp/ccp.c | 3 +++ sys/dev/cxgbe/crypto/t4_crypto.c | 3 +++ sys/dev/sec/sec.c | 3 +++ sys/kern/subr_bus_dma.c | 25 +++++++++++++++++++++++++ sys/mips/nlm/dev/sec/nlmsec.c | 3 +++ sys/mips/nlm/dev/sec/nlmseclib.c | 3 +++ sys/opencrypto/criov.c | 21 +++++++++++++++++++++ sys/opencrypto/crypto.c | 2 ++ sys/opencrypto/cryptodev.h | 22 +++++++++++++++++++++- sys/opencrypto/cryptosoft.c | 1 + 11 files changed, 93 insertions(+), 4 deletions(-) diff --git a/share/man/man9/crypto_buffer.9 b/share/man/man9/crypto_buffer.9 index 333fc5ec449f..df6128650cd4 100644 --- a/share/man/man9/crypto_buffer.9 +++ b/share/man/man9/crypto_buffer.9 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 24, 2020 +.Dd May 25, 2021 .Dt CRYPTO_BUFFER 9 .Os .Sh NAME @@ -195,7 +195,10 @@ An array of bytes mapped into the kernel's address space. A scatter/gather list of kernel buffers as described in .Xr uio 9 . .It Dv CRYPTO_BUF_MBUF -A network memory buffer as described in +A chain of network memory buffers as described in +.Xr mbuf 9 . +.It Dv CRYPTO_BUF_SINGLE_MBUF +A single network memory buffer as described in .Xr mbuf 9 . .It Dv CRYPTO_BUF_VMPAGE A scatter/gather list of @@ -220,7 +223,9 @@ data buffer A pointer to a .Vt struct mbuf for -.Dv CRYPTO_BUF_MBUF . +.Dv CRYPTO_BUF_MBUF +and +.Dv CRYPTO_BUF_SINGLE_MBUF . .It Fa cb_uio A pointer to a .Vt struct uio diff --git a/sys/crypto/ccp/ccp.c b/sys/crypto/ccp/ccp.c index 63967d7f8e3c..7cc38b14f3fd 100644 --- a/sys/crypto/ccp/ccp.c +++ b/sys/crypto/ccp/ccp.c @@ -101,6 +101,9 @@ ccp_populate_sglist(struct sglist *sg, struct crypto_buffer *cb) case CRYPTO_BUF_MBUF: error = sglist_append_mbuf(sg, cb->cb_mbuf); break; + case CRYPTO_BUF_SINGLE_MBUF: + error = sglist_append_single_mbuf(sg, cb->cb_mbuf); + break; case CRYPTO_BUF_UIO: error = sglist_append_uio(sg, cb->cb_uio); break; diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c index a3c25eb7df47..ea1272758eaf 100644 --- a/sys/dev/cxgbe/crypto/t4_crypto.c +++ b/sys/dev/cxgbe/crypto/t4_crypto.c @@ -271,6 +271,9 @@ ccr_populate_sglist(struct sglist *sg, struct crypto_buffer *cb) case CRYPTO_BUF_MBUF: error = sglist_append_mbuf(sg, cb->cb_mbuf); break; + case CRYPTO_BUF_SINGLE_MBUF: + error = sglist_append_single_mbuf(sg, cb->cb_mbuf); + break; case CRYPTO_BUF_UIO: error = sglist_append_uio(sg, cb->cb_uio); break; diff --git a/sys/dev/sec/sec.c b/sys/dev/sec/sec.c index fa3e20806124..f485d932727b 100644 --- a/sys/dev/sec/sec.c +++ b/sys/dev/sec/sec.c @@ -850,6 +850,9 @@ sec_desc_map_dma(struct sec_softc *sc, struct sec_dma_mem *dma_mem, case CRYPTO_BUF_MBUF: size = m_length(crp->crp_buf.cb_mbuf, NULL); break; + case CRYPTO_BUF_SINGLE_MBUF: + size = crp->crp_buf.cb_mbuf->m_len; + break; case CRYPTO_BUF_VMPAGE: size = PAGE_SIZE - crp->crp_buf.cb_vm_page_offset; break; diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c index 6248dd520511..a7ad30e77715 100644 --- a/sys/kern/subr_bus_dma.c +++ b/sys/kern/subr_bus_dma.c @@ -172,6 +172,27 @@ _bus_dmamap_load_mbuf_epg(bus_dma_tag_t dmat, bus_dmamap_t map, return (error); } +/* + * Load a single mbuf. + */ +static int +_bus_dmamap_load_single_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, + struct mbuf *m, bus_dma_segment_t *segs, int *nsegs, int flags) +{ + int error; + + error = 0; + if ((m->m_flags & M_EXTPG) != 0) + error = _bus_dmamap_load_mbuf_epg(dmat, map, m, segs, nsegs, + flags); + else + error = _bus_dmamap_load_buffer(dmat, map, m->m_data, m->m_len, + kernel_pmap, flags | BUS_DMA_LOAD_MBUF, segs, nsegs); + CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d", + __func__, dmat, flags, error, *nsegs); + return (error); +} + /* * Load an mbuf chain. */ @@ -658,6 +679,10 @@ bus_dmamap_load_crp_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, error = _bus_dmamap_load_mbuf_sg(dmat, map, cb->cb_mbuf, NULL, &nsegs, flags); break; + case CRYPTO_BUF_SINGLE_MBUF: + error = _bus_dmamap_load_single_mbuf(dmat, map, cb->cb_mbuf, + NULL, &nsegs, flags); + break; case CRYPTO_BUF_UIO: error = _bus_dmamap_load_uio(dmat, map, cb->cb_uio, &nsegs, flags); diff --git a/sys/mips/nlm/dev/sec/nlmsec.c b/sys/mips/nlm/dev/sec/nlmsec.c index c28eaf334613..d5d83ba796bd 100644 --- a/sys/mips/nlm/dev/sec/nlmsec.c +++ b/sys/mips/nlm/dev/sec/nlmsec.c @@ -468,12 +468,15 @@ xlp_get_nsegs(struct cryptop *crp, unsigned int *nsegs) switch (crp->crp_buf.cb_type) { case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: { struct mbuf *m = NULL; m = crp->crp_buf.cb_mbuf; while (m != NULL) { *nsegs += NLM_CRYPTO_NUM_SEGS_REQD(m->m_len); + if (crp->crp_buf.cb_type == CRYPTO_BUF_SINGLE_MBUF) + break; m = m->m_next; } break; diff --git a/sys/mips/nlm/dev/sec/nlmseclib.c b/sys/mips/nlm/dev/sec/nlmseclib.c index bb154b5d3d79..6e5e715c28f8 100644 --- a/sys/mips/nlm/dev/sec/nlmseclib.c +++ b/sys/mips/nlm/dev/sec/nlmseclib.c @@ -112,6 +112,7 @@ nlm_crypto_form_srcdst_segs(struct xlp_sec_command *cmd, switch (crp->crp_buf.cb_type) { case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: { struct mbuf *m = NULL; @@ -123,6 +124,8 @@ nlm_crypto_form_srcdst_segs(struct xlp_sec_command *cmd, dstseg = nlm_crypto_fill_dst_seg(cmd->paramp, dstseg, mtod(m,caddr_t), m->m_len); } + if (crp->crp_buf.cb_type == CRYPTO_BUF_SINGLE_MBUF) + break; m = m->m_next; } break; diff --git a/sys/opencrypto/criov.c b/sys/opencrypto/criov.c index bf7965032084..df053b314d41 100644 --- a/sys/opencrypto/criov.c +++ b/sys/opencrypto/criov.c @@ -344,6 +344,7 @@ crypto_cursor_init(struct crypto_buffer_cursor *cc, cc->cc_buf_len = cb->cb_buf_len; break; case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: cc->cc_mbuf = cb->cb_mbuf; break; case CRYPTO_BUF_VMPAGE: @@ -389,6 +390,10 @@ crypto_cursor_advance(struct crypto_buffer_cursor *cc, size_t amount) break; } break; + case CRYPTO_BUF_SINGLE_MBUF: + MPASS(cc->cc_mbuf->m_len >= cc->cc_offset + amount); + cc->cc_offset += amount; + break; case CRYPTO_BUF_VMPAGE: for (;;) { SDT_PROBE2(opencrypto, criov, cursor_advance, vmpage, @@ -436,6 +441,7 @@ crypto_cursor_segbase(struct crypto_buffer_cursor *cc) case CRYPTO_BUF_CONTIG: return (cc->cc_buf); case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: if (cc->cc_mbuf == NULL) return (NULL); if (cc->cc_mbuf->m_flags & M_EXTPG) @@ -463,6 +469,7 @@ crypto_cursor_seglen(struct crypto_buffer_cursor *cc) case CRYPTO_BUF_VMPAGE: return (PAGE_SIZE - cc->cc_offset); case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: if (cc->cc_mbuf == NULL) return (0); if (cc->cc_mbuf->m_flags & M_EXTPG) @@ -516,6 +523,11 @@ crypto_cursor_copyback(struct crypto_buffer_cursor *cc, int size, break; } break; + case CRYPTO_BUF_SINGLE_MBUF: + MPASS(cc->cc_mbuf->m_len >= cc->cc_offset + size); + m_copyback(cc->cc_mbuf, cc->cc_offset, size, src); + cc->cc_offset += size; + break; case CRYPTO_BUF_VMPAGE: for (;;) { dst = (char *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( @@ -599,6 +611,11 @@ crypto_cursor_copydata(struct crypto_buffer_cursor *cc, int size, void *vdst) break; } break; + case CRYPTO_BUF_SINGLE_MBUF: + MPASS(cc->cc_mbuf->m_len >= cc->cc_offset + size); + m_copydata(cc->cc_mbuf, cc->cc_offset, size, dst); + cc->cc_offset += size; + break; case CRYPTO_BUF_VMPAGE: for (;;) { src = (char *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( @@ -699,6 +716,7 @@ crypto_copyback(struct cryptop *crp, int off, int size, const void *src) cb = &crp->crp_buf; switch (cb->cb_type) { case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: m_copyback(cb->cb_mbuf, off, size, src); break; #if CRYPTO_MAY_HAVE_VMPAGE @@ -731,6 +749,7 @@ crypto_copydata(struct cryptop *crp, int off, int size, void *dst) switch (crp->crp_buf.cb_type) { case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: m_copydata(crp->crp_buf.cb_mbuf, off, size, dst); break; #if CRYPTO_MAY_HAVE_VMPAGE @@ -765,6 +784,7 @@ crypto_apply_buf(struct crypto_buffer *cb, int off, int len, switch (cb->cb_type) { case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: error = m_apply(cb->cb_mbuf, off, len, (int (*)(void *, void *, u_int))f, arg); break; @@ -843,6 +863,7 @@ crypto_buffer_contiguous_subsegment(struct crypto_buffer *cb, size_t skip, switch (cb->cb_type) { case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: return (m_contiguous_subsegment(cb->cb_mbuf, skip, len)); case CRYPTO_BUF_UIO: return (cuio_contiguous_segment(cb->cb_uio, skip, len)); diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index 704077043bb8..bcde910728e1 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -1224,6 +1224,8 @@ crypto_buffer_len(struct crypto_buffer *cb) if (cb->cb_mbuf->m_flags & M_PKTHDR) return (cb->cb_mbuf->m_pkthdr.len); return (m_length(cb->cb_mbuf, NULL)); + case CRYPTO_BUF_SINGLE_MBUF: + return (cb->cb_mbuf->m_len); case CRYPTO_BUF_VMPAGE: return (cb->cb_vm_page_len); case CRYPTO_BUF_UIO: diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index 277867734841..f60f4e63735a 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -392,7 +392,8 @@ enum crypto_buffer_type { CRYPTO_BUF_UIO, CRYPTO_BUF_MBUF, CRYPTO_BUF_VMPAGE, - CRYPTO_BUF_LAST = CRYPTO_BUF_VMPAGE + CRYPTO_BUF_SINGLE_MBUF, + CRYPTO_BUF_LAST = CRYPTO_BUF_SINGLE_MBUF }; /* @@ -524,6 +525,13 @@ _crypto_use_mbuf(struct crypto_buffer *cb, struct mbuf *m) cb->cb_type = CRYPTO_BUF_MBUF; } +static __inline void +_crypto_use_single_mbuf(struct crypto_buffer *cb, struct mbuf *m) +{ + cb->cb_mbuf = m; + cb->cb_type = CRYPTO_BUF_SINGLE_MBUF; +} + static __inline void _crypto_use_vmpage(struct crypto_buffer *cb, vm_page_t *pages, int len, int offset) @@ -553,6 +561,12 @@ crypto_use_mbuf(struct cryptop *crp, struct mbuf *m) _crypto_use_mbuf(&crp->crp_buf, m); } +static __inline void +crypto_use_single_mbuf(struct cryptop *crp, struct mbuf *m) +{ + _crypto_use_single_mbuf(&crp->crp_buf, m); +} + static __inline void crypto_use_vmpage(struct cryptop *crp, vm_page_t *pages, int len, int offset) { @@ -577,6 +591,12 @@ crypto_use_output_mbuf(struct cryptop *crp, struct mbuf *m) _crypto_use_mbuf(&crp->crp_obuf, m); } +static __inline void +crypto_use_output_single_mbuf(struct cryptop *crp, struct mbuf *m) +{ + _crypto_use_single_mbuf(&crp->crp_obuf, m); +} + static __inline void crypto_use_output_vmpage(struct cryptop *crp, vm_page_t *pages, int len, int offset) diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index a09f085a1eef..4040a014881e 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -1105,6 +1105,7 @@ swcr_compdec(struct swcr_session *ses, struct cryptop *crp) if (result < crp->crp_payload_length) { switch (crp->crp_buf.cb_type) { case CRYPTO_BUF_MBUF: + case CRYPTO_BUF_SINGLE_MBUF: adj = result - crp->crp_payload_length; m_adj(crp->crp_buf.cb_mbuf, adj); break; From nobody Thu Oct 21 17:07:14 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8E7B61807346; Thu, 21 Oct 2021 17:07: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 4HZv6Y4bNVz4hB4; Thu, 21 Oct 2021 17:07: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 E04861ED73; Thu, 21 Oct 2021 17:07: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 19LH7Ej9080603; Thu, 21 Oct 2021 17:07:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH7ELC080602; Thu, 21 Oct 2021 17:07:14 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:14 GMT Message-Id: <202110211707.19LH7ELC080602@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: a017868e2818 - stable/13 - crypto: Add crypto_cursor_segment() to fetch both base and length. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: a017868e281874261a560ba1e3069b4e14b7483e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a017868e281874261a560ba1e3069b4e14b7483e commit a017868e281874261a560ba1e3069b4e14b7483e Author: John Baldwin AuthorDate: 2021-05-25 23:59:19 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:26 +0000 crypto: Add crypto_cursor_segment() to fetch both base and length. This function combines crypto_cursor_segbase() and crypto_cursor_seglen() into a single function. This is mostly beneficial in the unmapped mbuf case where back to back calls of these two functions have to iterate over the sub-components of unmapped mbufs twice. Bump __FreeBSD_version for crypto drivers in ports. Suggested by: markj Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30445 (cherry picked from commit beb817edfe22cdea91e19a60c42caabd9404da48) --- share/man/man9/Makefile | 1 + share/man/man9/crypto_buffer.9 | 11 ++++- sys/opencrypto/criov.c | 109 ++++++++++++++--------------------------- sys/opencrypto/cryptodev.h | 1 + sys/sys/param.h | 2 +- 5 files changed, 50 insertions(+), 74 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index acdfa7cc6d8e..c180742bdb4b 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -929,6 +929,7 @@ MLINKS+=crypto_buffer.9 crypto_apply.9 \ crypto_buffer.9 crypto_cursor_copydata_noadv.9 \ crypto_buffer.9 crypto_cursor_segbase.9 \ crypto_buffer.9 crypto_cursor_seglen.9 \ + crypto_buffer.9 crypto_cursor_segment.9 \ crypto_buffer.9 CRYPTO_HAS_OUTPUT_BUFFER.9 MLINKS+=crypto_driver.9 crypto_copyback.9 \ crypto_driver.9 crypto_copydata.9 \ diff --git a/share/man/man9/crypto_buffer.9 b/share/man/man9/crypto_buffer.9 index df6128650cd4..a16206e8e607 100644 --- a/share/man/man9/crypto_buffer.9 +++ b/share/man/man9/crypto_buffer.9 @@ -94,6 +94,8 @@ .Fa "void *dst" .Fc .Ft void * +.Fn crypto_cursor_segment "struct crypto_buffer_cursor *cc" "size_t *len" +.Ft void * .Fn crypto_cursor_segbase "struct crypto_buffer_cursor *cc" .Ft size_t .Fn crypto_cursor_seglen "struct crypto_buffer_cursor *cc" @@ -293,6 +295,12 @@ is similar to except that it does not change the current position of .Fa cc . .Pp +.Fn crypto_cursor_segment +returns the start of the virtually-contiguous segment at the current position of +.Fa cc . +The length of the segment is stored in +.Fa len . +.Pp .Fn crypto_cursor_segbase and .Fn crypto_cursor_seglen @@ -307,8 +315,9 @@ return the return value from the caller-supplied callback function. .Pp .Fn crypto_buffer_contiguous_subsegment , .Fn crypto_contiguous_subsegment , -and .Fn crypto_cursor_segbase , +and +.Fn crypto_cursor_segment return a pointer to a contiguous segment or .Dv NULL . .Pp diff --git a/sys/opencrypto/criov.c b/sys/opencrypto/criov.c index df053b314d41..25702e3592fe 100644 --- a/sys/opencrypto/criov.c +++ b/sys/opencrypto/criov.c @@ -258,78 +258,44 @@ m_epg_pages_extent(struct mbuf *m, int idx, u_int pglen) return (len); } -static __inline void * -m_epg_segbase(struct mbuf *m, size_t offset) +static void * +m_epg_segment(struct mbuf *m, size_t offset, size_t *len) { u_int i, pglen, pgoff; offset += mtod(m, vm_offset_t); - if (offset < m->m_epg_hdrlen) + if (offset < m->m_epg_hdrlen) { + *len = m->m_epg_hdrlen - offset; return (m->m_epg_hdr + offset); + } offset -= m->m_epg_hdrlen; pgoff = m->m_epg_1st_off; for (i = 0; i < m->m_epg_npgs; i++) { pglen = m_epg_pagelen(m, i, pgoff); - if (offset < pglen) + if (offset < pglen) { + *len = m_epg_pages_extent(m, i, pglen) - offset; return ((void *)PHYS_TO_DMAP(m->m_epg_pa[i] + pgoff + offset)); + } offset -= pglen; pgoff = 0; } KASSERT(offset <= m->m_epg_trllen, ("%s: offset beyond trailer", __func__)); + *len = m->m_epg_trllen - offset; return (m->m_epg_trail + offset); } -static __inline size_t -m_epg_seglen(struct mbuf *m, size_t offset) -{ - u_int i, pglen, pgoff; - - offset += mtod(m, vm_offset_t); - if (offset < m->m_epg_hdrlen) - return (m->m_epg_hdrlen - offset); - offset -= m->m_epg_hdrlen; - pgoff = m->m_epg_1st_off; - for (i = 0; i < m->m_epg_npgs; i++) { - pglen = m_epg_pagelen(m, i, pgoff); - if (offset < pglen) - return (m_epg_pages_extent(m, i, pglen) - offset); - offset -= pglen; - pgoff = 0; - } - KASSERT(offset <= m->m_epg_trllen, ("%s: offset beyond trailer", - __func__)); - return (m->m_epg_trllen - offset); -} - static __inline void * m_epg_contiguous_subsegment(struct mbuf *m, size_t skip, size_t len) { - u_int i, pglen, pgoff; + void *base; + size_t seglen; - skip += mtod(m, vm_offset_t); - if (skip < m->m_epg_hdrlen) { - if (len > m->m_epg_hdrlen - skip) - return (NULL); - return (m->m_epg_hdr + skip); - } - skip -= m->m_epg_hdrlen; - pgoff = m->m_epg_1st_off; - for (i = 0; i < m->m_epg_npgs; i++) { - pglen = m_epg_pagelen(m, i, pgoff); - if (skip < pglen) { - if (len > m_epg_pages_extent(m, i, pglen) - skip) - return (NULL); - return ((void *)PHYS_TO_DMAP(m->m_epg_pa[i] + pgoff + - skip)); - } - skip -= pglen; - pgoff = 0; - } - KASSERT(skip <= m->m_epg_trllen && len <= m->m_epg_trllen - skip, - ("%s: segment beyond trailer", __func__)); - return (m->m_epg_trail + skip); + base = m_epg_segment(m, skip, &seglen); + if (len > seglen) + return (NULL); + return (base); } void @@ -435,54 +401,53 @@ crypto_cursor_advance(struct crypto_buffer_cursor *cc, size_t amount) } void * -crypto_cursor_segbase(struct crypto_buffer_cursor *cc) +crypto_cursor_segment(struct crypto_buffer_cursor *cc, size_t *len) { switch (cc->cc_type) { case CRYPTO_BUF_CONTIG: + *len = cc->cc_buf_len; return (cc->cc_buf); case CRYPTO_BUF_MBUF: case CRYPTO_BUF_SINGLE_MBUF: - if (cc->cc_mbuf == NULL) + if (cc->cc_mbuf == NULL) { + *len = 0; return (NULL); + } if (cc->cc_mbuf->m_flags & M_EXTPG) - return (m_epg_segbase(cc->cc_mbuf, cc->cc_offset)); + return (m_epg_segment(cc->cc_mbuf, cc->cc_offset, len)); + *len = cc->cc_mbuf->m_len - cc->cc_offset; return (mtod(cc->cc_mbuf, char *) + cc->cc_offset); case CRYPTO_BUF_VMPAGE: + *len = PAGE_SIZE - cc->cc_offset; return ((char *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( *cc->cc_vmpage)) + cc->cc_offset); case CRYPTO_BUF_UIO: + *len = cc->cc_iov->iov_len - cc->cc_offset; return ((char *)cc->cc_iov->iov_base + cc->cc_offset); default: #ifdef INVARIANTS panic("%s: invalid buffer type %d", __func__, cc->cc_type); #endif + *len = 0; return (NULL); } } +void * +crypto_cursor_segbase(struct crypto_buffer_cursor *cc) +{ + size_t len; + + return (crypto_cursor_segment(cc, &len)); +} + size_t crypto_cursor_seglen(struct crypto_buffer_cursor *cc) { - switch (cc->cc_type) { - case CRYPTO_BUF_CONTIG: - return (cc->cc_buf_len); - case CRYPTO_BUF_VMPAGE: - return (PAGE_SIZE - cc->cc_offset); - case CRYPTO_BUF_MBUF: - case CRYPTO_BUF_SINGLE_MBUF: - if (cc->cc_mbuf == NULL) - return (0); - if (cc->cc_mbuf->m_flags & M_EXTPG) - return (m_epg_seglen(cc->cc_mbuf, cc->cc_offset)); - return (cc->cc_mbuf->m_len - cc->cc_offset); - case CRYPTO_BUF_UIO: - return (cc->cc_iov->iov_len - cc->cc_offset); - default: -#ifdef INVARIANTS - panic("%s: invalid buffer type %d", __func__, cc->cc_type); -#endif - return (0); - } + size_t len; + + crypto_cursor_segment(cc, &len); + return (len); } void diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index f60f4e63735a..4d9b735366b8 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -726,6 +726,7 @@ size_t crypto_buffer_len(struct crypto_buffer *cb); void crypto_cursor_init(struct crypto_buffer_cursor *cc, const struct crypto_buffer *cb); void crypto_cursor_advance(struct crypto_buffer_cursor *cc, size_t amount); +void *crypto_cursor_segment(struct crypto_buffer_cursor *cc, size_t *len); void *crypto_cursor_segbase(struct crypto_buffer_cursor *cc); size_t crypto_cursor_seglen(struct crypto_buffer_cursor *cc); void crypto_cursor_copyback(struct crypto_buffer_cursor *cc, int size, diff --git a/sys/sys/param.h b/sys/sys/param.h index 799ba1a9af42..fd177d5a23a1 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300517 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300518 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Thu Oct 21 17:07:15 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0F4BB180753D; Thu, 21 Oct 2021 17: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 4HZv6b5QMxz4hPf; Thu, 21 Oct 2021 17:07: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 0F2081ED74; Thu, 21 Oct 2021 17:07: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 19LH7FNc080627; Thu, 21 Oct 2021 17:07:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH7FQP080626; Thu, 21 Oct 2021 17:07:15 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:15 GMT Message-Id: <202110211707.19LH7FQP080626@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: bb8cda12a9c9 - stable/13 - cryptosoft: Use crypto_cursor_segment(). List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: bb8cda12a9c99f31b0ae334e0037e2ea07761484 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bb8cda12a9c99f31b0ae334e0037e2ea07761484 commit bb8cda12a9c99f31b0ae334e0037e2ea07761484 Author: John Baldwin AuthorDate: 2021-05-25 23:59:19 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:51:57 +0000 cryptosoft: Use crypto_cursor_segment(). Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30446 (cherry picked from commit 86be314d09bc2857bb63d0a1e34945c63daa0008) --- sys/opencrypto/cryptosoft.c | 107 +++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 61 deletions(-) diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index 4040a014881e..9e551ba9652b 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -105,7 +105,8 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) const struct crypto_session_params *csp; struct swcr_encdec *sw; struct enc_xform *exf; - int i, blks, inlen, ivlen, outlen, resid; + size_t inlen, outlen; + int i, blks, ivlen, resid; struct crypto_buffer_cursor cc_in, cc_out; const unsigned char *inblk; unsigned char *outblk; @@ -153,15 +154,13 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) crypto_cursor_init(&cc_in, &crp->crp_buf); crypto_cursor_advance(&cc_in, crp->crp_payload_start); - inlen = crypto_cursor_seglen(&cc_in); - inblk = crypto_cursor_segbase(&cc_in); + inblk = crypto_cursor_segment(&cc_in, &inlen); if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { crypto_cursor_init(&cc_out, &crp->crp_obuf); crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); } else cc_out = cc_in; - outlen = crypto_cursor_seglen(&cc_out); - outblk = crypto_cursor_segbase(&cc_out); + outblk = crypto_cursor_segment(&cc_out, &outlen); resid = crp->crp_payload_length; encrypting = CRYPTO_OP_IS_ENCRYPT(crp->crp_op); @@ -225,8 +224,7 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) } if (inlen < blks) { - inlen = crypto_cursor_seglen(&cc_in); - inblk = crypto_cursor_segbase(&cc_in); + inblk = crypto_cursor_segment(&cc_in, &inlen); } else { crypto_cursor_advance(&cc_in, blks); inlen -= blks; @@ -235,8 +233,7 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) if (outlen < blks) { crypto_cursor_copyback(&cc_out, blks, blk); - outlen = crypto_cursor_seglen(&cc_out); - outblk = crypto_cursor_segbase(&cc_out); + outblk = crypto_cursor_segment(&cc_out, &outlen); } else { crypto_cursor_advance(&cc_out, blks); outlen -= blks; @@ -256,17 +253,14 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) __func__, exf->name)); KASSERT(resid < blks, ("%s: partial block too big", __func__)); - inlen = crypto_cursor_seglen(&cc_in); - outlen = crypto_cursor_seglen(&cc_out); + inblk = crypto_cursor_segment(&cc_in, &inlen); + outblk = crypto_cursor_segment(&cc_out, &outlen); if (inlen < resid) { crypto_cursor_copydata(&cc_in, resid, blk); inblk = blk; - } else - inblk = crypto_cursor_segbase(&cc_in); + } if (outlen < resid) outblk = blk; - else - outblk = crypto_cursor_segbase(&cc_out); if (encrypting) exf->encrypt_last(sw->sw_kschedule, inblk, outblk, resid); @@ -397,7 +391,8 @@ swcr_gmac(struct swcr_session *ses, struct cryptop *crp) struct swcr_auth *swa; struct auth_hash *axf; uint32_t *blkp; - int blksz, error, ivlen, len, resid; + size_t len; + int blksz, error, ivlen, resid; swa = &ses->swcr_auth; axf = swa->sw_axf; @@ -415,9 +410,8 @@ swcr_gmac(struct swcr_session *ses, struct cryptop *crp) crypto_cursor_init(&cc, &crp->crp_buf); crypto_cursor_advance(&cc, crp->crp_payload_start); for (resid = crp->crp_payload_length; resid >= blksz; resid -= len) { - len = crypto_cursor_seglen(&cc); + inblk = crypto_cursor_segment(&cc, &len); if (len >= blksz) { - inblk = crypto_cursor_segbase(&cc); len = rounddown(MIN(len, resid), blksz); crypto_cursor_advance(&cc, len); } else { @@ -477,7 +471,8 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) struct auth_hash *axf; struct enc_xform *exf; uint32_t *blkp; - int blksz, error, ivlen, len, r, resid; + size_t len; + int blksz, error, ivlen, r, resid; swa = &ses->swcr_auth; axf = swa->sw_axf; @@ -518,9 +513,8 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) crypto_cursor_advance(&cc_in, crp->crp_aad_start); for (resid = crp->crp_aad_length; resid >= blksz; resid -= len) { - len = crypto_cursor_seglen(&cc_in); + inblk = crypto_cursor_segment(&cc_in, &len); if (len >= blksz) { - inblk = crypto_cursor_segbase(&cc_in); len = rounddown(MIN(len, resid), blksz); crypto_cursor_advance(&cc_in, len); } else { @@ -551,18 +545,17 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) } else cc_out = cc_in; for (resid = crp->crp_payload_length; resid >= blksz; resid -= blksz) { - if (crypto_cursor_seglen(&cc_in) < blksz) { + inblk = crypto_cursor_segment(&cc_in, &len); + if (len < blksz) { crypto_cursor_copydata(&cc_in, blksz, blk); inblk = blk; } else { - inblk = crypto_cursor_segbase(&cc_in); crypto_cursor_advance(&cc_in, blksz); } if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { - if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = crypto_cursor_segment(&cc_out, &len); + if (len < blksz) outblk = blk; - else - outblk = crypto_cursor_segbase(&cc_out); exf->encrypt(swe->sw_kschedule, inblk, outblk); axf->Update(&ctx, outblk, blksz); if (outblk == blk) @@ -612,17 +605,15 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) crypto_cursor_advance(&cc_in, crp->crp_payload_start); for (resid = crp->crp_payload_length; resid > blksz; resid -= blksz) { - if (crypto_cursor_seglen(&cc_in) < blksz) { + inblk = crypto_cursor_segment(&cc_in, &len); + if (len < blksz) { crypto_cursor_copydata(&cc_in, blksz, blk); inblk = blk; - } else { - inblk = crypto_cursor_segbase(&cc_in); + } else crypto_cursor_advance(&cc_in, blksz); - } - if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = crypto_cursor_segment(&cc_out, &len); + if (len < blksz) outblk = blk; - else - outblk = crypto_cursor_segbase(&cc_out); exf->decrypt(swe->sw_kschedule, inblk, outblk); if (outblk == blk) crypto_cursor_copyback(&cc_out, blksz, blk); @@ -717,6 +708,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) struct swcr_encdec *swe; struct auth_hash *axf; struct enc_xform *exf; + size_t len; int blksz, error, ivlen, r, resid; swa = &ses->swcr_auth; @@ -772,18 +764,16 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) } else cc_out = cc_in; for (resid = crp->crp_payload_length; resid >= blksz; resid -= blksz) { - if (crypto_cursor_seglen(&cc_in) < blksz) { + inblk = crypto_cursor_segment(&cc_in, &len); + if (len < blksz) { crypto_cursor_copydata(&cc_in, blksz, blk); inblk = blk; - } else { - inblk = crypto_cursor_segbase(&cc_in); + } else crypto_cursor_advance(&cc_in, blksz); - } if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { - if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = crypto_cursor_segment(&cc_out, &len); + if (len < blksz) outblk = blk; - else - outblk = crypto_cursor_segbase(&cc_out); axf->Update(&ctx, inblk, blksz); exf->encrypt(swe->sw_kschedule, inblk, outblk); if (outblk == blk) @@ -839,17 +829,15 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) crypto_cursor_advance(&cc_in, crp->crp_payload_start); for (resid = crp->crp_payload_length; resid > blksz; resid -= blksz) { - if (crypto_cursor_seglen(&cc_in) < blksz) { + inblk = crypto_cursor_segment(&cc_in, &len); + if (len < blksz) { crypto_cursor_copydata(&cc_in, blksz, blk); inblk = blk; - } else { - inblk = crypto_cursor_segbase(&cc_in); + } else crypto_cursor_advance(&cc_in, blksz); - } - if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = crypto_cursor_segment(&cc_out, &len); + if (len < blksz) outblk = blk; - else - outblk = crypto_cursor_segbase(&cc_out); exf->decrypt(swe->sw_kschedule, inblk, outblk); if (outblk == blk) crypto_cursor_copyback(&cc_out, blksz, blk); @@ -889,6 +877,7 @@ swcr_chacha20_poly1305(struct swcr_session *ses, struct cryptop *crp) struct swcr_encdec *swe; struct auth_hash *axf; struct enc_xform *exf; + size_t len; int blksz, error, r, resid; swa = &ses->swcr_auth; @@ -937,18 +926,16 @@ swcr_chacha20_poly1305(struct swcr_session *ses, struct cryptop *crp) } else cc_out = cc_in; for (resid = crp->crp_payload_length; resid >= blksz; resid -= blksz) { - if (crypto_cursor_seglen(&cc_in) < blksz) { + inblk = crypto_cursor_segment(&cc_in, &len); + if (len < blksz) { crypto_cursor_copydata(&cc_in, blksz, blk); inblk = blk; - } else { - inblk = crypto_cursor_segbase(&cc_in); + } else crypto_cursor_advance(&cc_in, blksz); - } if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { - if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = crypto_cursor_segment(&cc_out, &len); + if (len < blksz) outblk = blk; - else - outblk = crypto_cursor_segbase(&cc_out); exf->encrypt(swe->sw_kschedule, inblk, outblk); axf->Update(&ctx, outblk, blksz); if (outblk == blk) @@ -1001,17 +988,15 @@ swcr_chacha20_poly1305(struct swcr_session *ses, struct cryptop *crp) crypto_cursor_advance(&cc_in, crp->crp_payload_start); for (resid = crp->crp_payload_length; resid > blksz; resid -= blksz) { - if (crypto_cursor_seglen(&cc_in) < blksz) { + inblk = crypto_cursor_segment(&cc_in, &len); + if (len < blksz) { crypto_cursor_copydata(&cc_in, blksz, blk); inblk = blk; - } else { - inblk = crypto_cursor_segbase(&cc_in); + } else crypto_cursor_advance(&cc_in, blksz); - } - if (crypto_cursor_seglen(&cc_out) < blksz) + outblk = crypto_cursor_segment(&cc_out, &len); + if (len < blksz) outblk = blk; - else - outblk = crypto_cursor_segbase(&cc_out); exf->decrypt(swe->sw_kschedule, inblk, outblk); if (outblk == blk) crypto_cursor_copyback(&cc_out, blksz, blk); From nobody Thu Oct 21 17:07:17 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C3FA01807465; Thu, 21 Oct 2021 17: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 4HZv6f1bd3z4hRS; Thu, 21 Oct 2021 17:07: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 30CB11EF2F; Thu, 21 Oct 2021 17:07: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 19LH7HrS080651; Thu, 21 Oct 2021 17:07:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LH7Het080650; Thu, 21 Oct 2021 17:07:17 GMT (envelope-from git) Date: Thu, 21 Oct 2021 17:07:17 GMT Message-Id: <202110211707.19LH7Het080650@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: 757d96ade64c - stable/13 - ossl: Use crypto_cursor_segment(). List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 757d96ade64c0488512147bcd07117f3b0f9c91c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=757d96ade64c0488512147bcd07117f3b0f9c91c commit 757d96ade64c0488512147bcd07117f3b0f9c91c Author: John Baldwin AuthorDate: 2021-05-25 23:59:19 +0000 Commit: John Baldwin CommitDate: 2021-10-21 15:52:13 +0000 ossl: Use crypto_cursor_segment(). Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30447 (cherry picked from commit 1c09320d5833fef8a4b6cc0091883fd47ea1eb1b) --- sys/crypto/openssl/ossl_chacha20.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/sys/crypto/openssl/ossl_chacha20.c b/sys/crypto/openssl/ossl_chacha20.c index 7fa1a297052e..a6f56aca1f8f 100644 --- a/sys/crypto/openssl/ossl_chacha20.c +++ b/sys/crypto/openssl/ossl_chacha20.c @@ -65,15 +65,13 @@ ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) resid = crp->crp_payload_length; crypto_cursor_init(&cc_in, &crp->crp_buf); crypto_cursor_advance(&cc_in, crp->crp_payload_start); - inseg = crypto_cursor_segbase(&cc_in); - inlen = crypto_cursor_seglen(&cc_in); + inseg = crypto_cursor_segment(&cc_in, &inlen); if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { crypto_cursor_init(&cc_out, &crp->crp_obuf); crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); } else cc_out = cc_in; - outseg = crypto_cursor_segbase(&cc_out); - outlen = crypto_cursor_seglen(&cc_out); + outseg = crypto_cursor_segment(&cc_out, &outlen); while (resid >= CHACHA_BLK_SIZE) { if (inlen < CHACHA_BLK_SIZE) { crypto_cursor_copydata(&cc_in, CHACHA_BLK_SIZE, block); @@ -111,16 +109,14 @@ ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) if (out == block) { crypto_cursor_copyback(&cc_out, CHACHA_BLK_SIZE, block); - outseg = crypto_cursor_segbase(&cc_out); - outlen = crypto_cursor_seglen(&cc_out); + outseg = crypto_cursor_segment(&cc_out, &outlen); } else { crypto_cursor_advance(&cc_out, todo); outseg += todo; outlen -= todo; } if (in == block) { - inseg = crypto_cursor_segbase(&cc_in); - inlen = crypto_cursor_seglen(&cc_in); + inseg = crypto_cursor_segment(&cc_in, &inlen); } else { crypto_cursor_advance(&cc_in, todo); inseg += todo; @@ -196,15 +192,13 @@ ossl_chacha20_poly1305_encrypt(struct cryptop *crp, resid = crp->crp_payload_length; crypto_cursor_init(&cc_in, &crp->crp_buf); crypto_cursor_advance(&cc_in, crp->crp_payload_start); - inseg = crypto_cursor_segbase(&cc_in); - inlen = crypto_cursor_seglen(&cc_in); + inseg = crypto_cursor_segment(&cc_in, &inlen); if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { crypto_cursor_init(&cc_out, &crp->crp_obuf); crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); } else cc_out = cc_in; - outseg = crypto_cursor_segbase(&cc_out); - outlen = crypto_cursor_seglen(&cc_out); + outseg = crypto_cursor_segment(&cc_out, &outlen); while (resid >= CHACHA_BLK_SIZE) { if (inlen < CHACHA_BLK_SIZE) { crypto_cursor_copydata(&cc_in, CHACHA_BLK_SIZE, block); @@ -243,16 +237,14 @@ ossl_chacha20_poly1305_encrypt(struct cryptop *crp, if (out == block) { crypto_cursor_copyback(&cc_out, CHACHA_BLK_SIZE, block); - outseg = crypto_cursor_segbase(&cc_out); - outlen = crypto_cursor_seglen(&cc_out); + outseg = crypto_cursor_segment(&cc_out, &outlen); } else { crypto_cursor_advance(&cc_out, todo); outseg += todo; outlen -= todo; } if (in == block) { - inseg = crypto_cursor_segbase(&cc_in); - inlen = crypto_cursor_seglen(&cc_in); + inseg = crypto_cursor_segment(&cc_in, &inlen); } else { crypto_cursor_advance(&cc_in, todo); inseg += todo; @@ -368,15 +360,13 @@ ossl_chacha20_poly1305_decrypt(struct cryptop *crp, resid = crp->crp_payload_length; crypto_cursor_init(&cc_in, &crp->crp_buf); crypto_cursor_advance(&cc_in, crp->crp_payload_start); - inseg = crypto_cursor_segbase(&cc_in); - inlen = crypto_cursor_seglen(&cc_in); + inseg = crypto_cursor_segment(&cc_in, &inlen); if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { crypto_cursor_init(&cc_out, &crp->crp_obuf); crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); } else cc_out = cc_in; - outseg = crypto_cursor_segbase(&cc_out); - outlen = crypto_cursor_seglen(&cc_out); + outseg = crypto_cursor_segment(&cc_out, &outlen); while (resid >= CHACHA_BLK_SIZE) { if (inlen < CHACHA_BLK_SIZE) { crypto_cursor_copydata(&cc_in, CHACHA_BLK_SIZE, block); @@ -414,16 +404,14 @@ ossl_chacha20_poly1305_decrypt(struct cryptop *crp, if (out == block) { crypto_cursor_copyback(&cc_out, CHACHA_BLK_SIZE, block); - outseg = crypto_cursor_segbase(&cc_out); - outlen = crypto_cursor_seglen(&cc_out); + outseg = crypto_cursor_segment(&cc_out, &outlen); } else { crypto_cursor_advance(&cc_out, todo); outseg += todo; outlen -= todo; } if (in == block) { - inseg = crypto_cursor_segbase(&cc_in); - inlen = crypto_cursor_seglen(&cc_in); + inseg = crypto_cursor_segment(&cc_in, &inlen); } else { crypto_cursor_advance(&cc_in, todo); inseg += todo; From nobody Thu Oct 21 22:04:09 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 45FF91800E5A; Thu, 21 Oct 2021 22:04: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 4Hb1j61BDJz3tV7; Thu, 21 Oct 2021 22:04: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 07D7622F19; Thu, 21 Oct 2021 22:04: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 19LM49UD079379; Thu, 21 Oct 2021 22:04:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM49bd079378; Thu, 21 Oct 2021 22:04:09 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:09 GMT Message-Id: <202110212204.19LM49bd079378@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: de705beeef63 - stable/13 - crypto: Permit variable-sized IVs for ciphers with a reinit hook. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: de705beeef63413ca56807a5df810135c7ddf925 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=de705beeef63413ca56807a5df810135c7ddf925 commit de705beeef63413ca56807a5df810135c7ddf925 Author: John Baldwin AuthorDate: 2021-10-06 21:08:46 +0000 Commit: John Baldwin CommitDate: 2021-10-21 20:47:58 +0000 crypto: Permit variable-sized IVs for ciphers with a reinit hook. Add a 'len' argument to the reinit hook in 'struct enc_xform' to permit support for AEAD ciphers such as AES-CCM and Chacha20-Poly1305 which support different nonce lengths. Reviewed by: markj Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32105 (cherry picked from commit 1833d6042c9a0116e8a1198256fd8fbc99cb11ad) (cherry picked from commit d586c978b9b4216869e589daa5bbcc33225a0e35) --- stand/libsa/geli/geliboot.c | 2 +- stand/libsa/geli/geliboot_crypto.c | 7 ++++--- stand/libsa/geli/geliboot_internal.h | 2 +- sys/crypto/chacha20/chacha-sw.c | 5 +++-- sys/dev/cxgbe/crypto/t4_crypto.c | 10 +++++++--- sys/opencrypto/cryptosoft.c | 20 +++++++++++--------- sys/opencrypto/xform_aes_icm.c | 22 ++++++++++++++-------- sys/opencrypto/xform_aes_xts.c | 9 +++++++-- sys/opencrypto/xform_chacha20_poly1305.c | 5 ++++- sys/opencrypto/xform_enc.h | 2 +- 10 files changed, 53 insertions(+), 31 deletions(-) diff --git a/stand/libsa/geli/geliboot.c b/stand/libsa/geli/geliboot.c index 954a3ec34044..56499e96b295 100644 --- a/stand/libsa/geli/geliboot.c +++ b/stand/libsa/geli/geliboot.c @@ -345,7 +345,7 @@ geli_io(struct geli_dev *gdev, geli_op_t enc, off_t offset, u_char *buf, g_eli_key_fill(&gdev->sc, &gkey, keyno); error = geliboot_crypt(gdev->sc.sc_ealgo, enc, pbuf, secsize, - gkey.gek_key, gdev->sc.sc_ekeylen, iv); + gkey.gek_key, gdev->sc.sc_ekeylen, iv, sizeof(iv)); if (error != 0) { explicit_bzero(&gkey, sizeof(gkey)); diff --git a/stand/libsa/geli/geliboot_crypto.c b/stand/libsa/geli/geliboot_crypto.c index 8478d2754d6f..fcc5d7bcd7fb 100644 --- a/stand/libsa/geli/geliboot_crypto.c +++ b/stand/libsa/geli/geliboot_crypto.c @@ -36,7 +36,7 @@ int geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, - const u_char *key, size_t keysize, u_char *iv) + const u_char *key, size_t keysize, u_char *iv, size_t ivlen) { keyInstance aeskey; cipherInstance cipher; @@ -81,7 +81,7 @@ geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, ctxp = &xtsctx; enc_xform_aes_xts.setkey(ctxp, key, xts_len / 8); - enc_xform_aes_xts.reinit(ctxp, iv); + enc_xform_aes_xts.reinit(ctxp, iv, ivlen); switch (enc) { case GELI_DECRYPT: @@ -113,7 +113,8 @@ g_eli_crypto_cipher(u_int algo, geli_op_t enc, u_char *data, size_t datasize, u_char iv[keysize]; explicit_bzero(iv, sizeof(iv)); - return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv)); + return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv, + sizeof(iv))); } int diff --git a/stand/libsa/geli/geliboot_internal.h b/stand/libsa/geli/geliboot_internal.h index 2af74466179f..2318690297f8 100644 --- a/stand/libsa/geli/geliboot_internal.h +++ b/stand/libsa/geli/geliboot_internal.h @@ -68,6 +68,6 @@ struct geli_dev { }; int geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, - const u_char *key, size_t keysize, u_char *iv); + const u_char *key, size_t keysize, u_char *iv, size_t ivlen); #endif /* _GELIBOOT_INTERNAL_H_ */ diff --git a/sys/crypto/chacha20/chacha-sw.c b/sys/crypto/chacha20/chacha-sw.c index 2c28b9a0c459..ef62e67316c0 100644 --- a/sys/crypto/chacha20/chacha-sw.c +++ b/sys/crypto/chacha20/chacha-sw.c @@ -18,9 +18,10 @@ chacha20_xform_setkey(void *ctx, const uint8_t *key, int len) } static void -chacha20_xform_reinit(void *ctx, const uint8_t *iv) +chacha20_xform_reinit(void *ctx, const uint8_t *iv, size_t ivlen) { - + KASSERT(ivlen == CHACHA_NONCELEN + CHACHA_CTRLEN, + ("%s: invalid IV length", __func__)); chacha_ivsetup(ctx, iv + 8, iv); } diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c index ea1272758eaf..9d410da6e030 100644 --- a/sys/dev/cxgbe/crypto/t4_crypto.c +++ b/sys/dev/cxgbe/crypto/t4_crypto.c @@ -1,8 +1,12 @@ /*- * Copyright (c) 2017 Chelsio Communications, Inc. + * Copyright (c) 2021 The FreeBSD Foundation * All rights reserved. * Written by: John Baldwin * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -1458,7 +1462,7 @@ ccr_gcm_soft(struct ccr_session *s, struct cryptop *crp) } } - exf->reinit(kschedule, iv); + exf->reinit(kschedule, iv, sizeof(iv)); /* Do encryption with MAC */ for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { @@ -1935,7 +1939,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) if (error) goto out; - exf->reinit(kschedule, iv); + exf->reinit(kschedule, iv, sizeof(iv)); /* Do encryption/decryption with MAC */ for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { @@ -1970,7 +1974,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) error = 0; /* Tag matches, decrypt data. */ - exf->reinit(kschedule, iv); + exf->reinit(kschedule, iv, sizeof(iv)); for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { len = imin(crp->crp_payload_length - i, diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index 9e551ba9652b..a85d7d6d3b7b 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -9,13 +9,16 @@ * supported the development of this code. * * Copyright (c) 2000, 2001 Angelos D. Keromytis - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2014-2021 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by John-Mark Gurney * under sponsorship of the FreeBSD Foundation and * Rubicon Communications, LLC (Netgate). * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Permission to use, copy, and modify this software with or without fee * is hereby granted, provided that this entire notice is included in * all source code copies of any software which is or includes a copy or @@ -106,7 +109,7 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) struct swcr_encdec *sw; struct enc_xform *exf; size_t inlen, outlen; - int i, blks, ivlen, resid; + int i, blks, resid; struct crypto_buffer_cursor cc_in, cc_out; const unsigned char *inblk; unsigned char *outblk; @@ -117,7 +120,7 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) sw = &ses->swcr_encdec; exf = sw->sw_exf; - ivlen = exf->ivsize; + csp = crypto_get_params(crp->crp_session); if (exf->native_blocksize == 0) { /* Check for non-padded data */ @@ -133,7 +136,6 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) return (EINVAL); if (crp->crp_cipher_key != NULL) { - csp = crypto_get_params(crp->crp_session); error = exf->setkey(sw->sw_kschedule, crp->crp_cipher_key, csp->csp_cipher_klen); if (error) @@ -147,7 +149,7 @@ swcr_encdec(struct swcr_session *ses, struct cryptop *crp) * xforms that provide a reinit method perform all IV * handling themselves. */ - exf->reinit(sw->sw_kschedule, iv); + exf->reinit(sw->sw_kschedule, iv, csp->csp_ivlen); } ivp = iv; @@ -534,7 +536,7 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) if (crp->crp_cipher_key != NULL) exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, crypto_get_params(crp->crp_session)->csp_cipher_klen); - exf->reinit(swe->sw_kschedule, iv); + exf->reinit(swe->sw_kschedule, iv, ivlen); /* Do encryption with MAC */ crypto_cursor_init(&cc_in, &crp->crp_buf); @@ -753,7 +755,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) if (crp->crp_cipher_key != NULL) exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, crypto_get_params(crp->crp_session)->csp_cipher_klen); - exf->reinit(swe->sw_kschedule, iv); + exf->reinit(swe->sw_kschedule, iv, ivlen); /* Do encryption/decryption with MAC */ crypto_cursor_init(&cc_in, &crp->crp_buf); @@ -824,7 +826,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) } /* tag matches, decrypt data */ - exf->reinit(swe->sw_kschedule, iv); + exf->reinit(swe->sw_kschedule, iv, ivlen); crypto_cursor_init(&cc_in, &crp->crp_buf); crypto_cursor_advance(&cc_in, crp->crp_payload_start); for (resid = crp->crp_payload_length; resid > blksz; @@ -915,7 +917,7 @@ swcr_chacha20_poly1305(struct swcr_session *ses, struct cryptop *crp) if (crp->crp_cipher_key != NULL) exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, csp->csp_cipher_klen); - exf->reinit(swe->sw_kschedule, crp->crp_iv); + exf->reinit(swe->sw_kschedule, crp->crp_iv, csp->csp_ivlen); /* Do encryption with MAC */ crypto_cursor_init(&cc_in, &crp->crp_buf); diff --git a/sys/opencrypto/xform_aes_icm.c b/sys/opencrypto/xform_aes_icm.c index 5f81f8df8a87..45da8267ca7d 100644 --- a/sys/opencrypto/xform_aes_icm.c +++ b/sys/opencrypto/xform_aes_icm.c @@ -55,9 +55,9 @@ __FBSDID("$FreeBSD$"); static int aes_icm_setkey(void *, const uint8_t *, int); static void aes_icm_crypt(void *, const uint8_t *, uint8_t *); static void aes_icm_crypt_last(void *, const uint8_t *, uint8_t *, size_t); -static void aes_icm_reinit(void *, const uint8_t *); -static void aes_gcm_reinit(void *, const uint8_t *); -static void aes_ccm_reinit(void *, const uint8_t *); +static void aes_icm_reinit(void *, const uint8_t *, size_t); +static void aes_gcm_reinit(void *, const uint8_t *, size_t); +static void aes_ccm_reinit(void *, const uint8_t *, size_t); /* Encryption instances */ struct enc_xform enc_xform_aes_icm = { @@ -114,20 +114,24 @@ struct enc_xform enc_xform_ccm = { * Encryption wrapper routines. */ static void -aes_icm_reinit(void *key, const uint8_t *iv) +aes_icm_reinit(void *key, const uint8_t *iv, size_t ivlen) { struct aes_icm_ctx *ctx; ctx = key; - bcopy(iv, ctx->ac_block, AESICM_BLOCKSIZE); + KASSERT(ivlen <= sizeof(ctx->ac_block), + ("%s: ivlen too large", __func__)); + bcopy(iv, ctx->ac_block, ivlen); } static void -aes_gcm_reinit(void *key, const uint8_t *iv) +aes_gcm_reinit(void *key, const uint8_t *iv, size_t ivlen) { struct aes_icm_ctx *ctx; - aes_icm_reinit(key, iv); + KASSERT(ivlen == AES_GCM_IV_LEN, + ("%s: invalid IV length", __func__)); + aes_icm_reinit(key, iv, ivlen); ctx = key; /* GCM starts with 2 as counter 1 is used for final xor of tag. */ @@ -136,10 +140,12 @@ aes_gcm_reinit(void *key, const uint8_t *iv) } static void -aes_ccm_reinit(void *key, const uint8_t *iv) +aes_ccm_reinit(void *key, const uint8_t *iv, size_t ivlen) { struct aes_icm_ctx *ctx; + KASSERT(ivlen == AES_CCM_IV_LEN, + ("%s: invalid IV length", __func__)); ctx = key; /* CCM has flags, then the IV, then the counter, which starts at 1 */ diff --git a/sys/opencrypto/xform_aes_xts.c b/sys/opencrypto/xform_aes_xts.c index 0b415f1d6346..d7f807752aa6 100644 --- a/sys/opencrypto/xform_aes_xts.c +++ b/sys/opencrypto/xform_aes_xts.c @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); static int aes_xts_setkey(void *, const uint8_t *, int); static void aes_xts_encrypt(void *, const uint8_t *, uint8_t *); static void aes_xts_decrypt(void *, const uint8_t *, uint8_t *); -static void aes_xts_reinit(void *, const uint8_t *); +static void aes_xts_reinit(void *, const uint8_t *, size_t); /* Encryption instances */ struct enc_xform enc_xform_aes_xts = { @@ -77,12 +77,17 @@ struct enc_xform enc_xform_aes_xts = { * Encryption wrapper routines. */ static void -aes_xts_reinit(void *key, const uint8_t *iv) +aes_xts_reinit(void *key, const uint8_t *iv, size_t ivlen) { struct aes_xts_ctx *ctx = key; uint64_t blocknum; u_int i; +#ifndef _STANDALONE + KASSERT(ivlen == sizeof(blocknum), + ("%s: invalid IV length", __func__)); +#endif + /* * Prepare tweak as E_k2(IV). IV is specified as LE representation * of a 64-bit block number which we allow to be passed in directly. diff --git a/sys/opencrypto/xform_chacha20_poly1305.c b/sys/opencrypto/xform_chacha20_poly1305.c index 3a72c06f931b..e893287145f2 100644 --- a/sys/opencrypto/xform_chacha20_poly1305.c +++ b/sys/opencrypto/xform_chacha20_poly1305.c @@ -50,10 +50,13 @@ chacha20_poly1305_setkey(void *vctx, const uint8_t *key, int len) } static void -chacha20_poly1305_reinit(void *vctx, const uint8_t *iv) +chacha20_poly1305_reinit(void *vctx, const uint8_t *iv, size_t ivlen) { struct chacha20_poly1305_cipher_ctx *ctx = vctx; + KASSERT(ivlen == sizeof(ctx->nonce), + ("%s: invalid nonce length", __func__)); + /* Block 0 is used for the poly1305 key. */ memcpy(ctx->nonce, iv, sizeof(ctx->nonce)); ctx->ic = 1; diff --git a/sys/opencrypto/xform_enc.h b/sys/opencrypto/xform_enc.h index e8325f20917b..1c800ed428fe 100644 --- a/sys/opencrypto/xform_enc.h +++ b/sys/opencrypto/xform_enc.h @@ -62,7 +62,7 @@ struct enc_xform { void (*encrypt) (void *, const uint8_t *, uint8_t *); void (*decrypt) (void *, const uint8_t *, uint8_t *); int (*setkey) (void *, const uint8_t *, int len); - void (*reinit) (void *, const uint8_t *); + void (*reinit) (void *, const uint8_t *, size_t); /* * For stream ciphers, encrypt/decrypt the final partial block From nobody Thu Oct 21 22:04:11 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8C3CA1801206; Thu, 21 Oct 2021 22:04: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 4Hb1j72R1dz3tKb; Thu, 21 Oct 2021 22:04: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 2B9EC22F9E; Thu, 21 Oct 2021 22:04: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 19LM4BlK079403; Thu, 21 Oct 2021 22:04:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4BAo079402; Thu, 21 Oct 2021 22:04:11 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:11 GMT Message-Id: <202110212204.19LM4BAo079402@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: d1d4ac2dbd70 - stable/13 - cryptosoft, ccr: Use crp_iv directly for AES-CCM and AES-GCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: d1d4ac2dbd70e6f71be236cec3e9d743e6d54692 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d1d4ac2dbd70e6f71be236cec3e9d743e6d54692 commit d1d4ac2dbd70e6f71be236cec3e9d743e6d54692 Author: John Baldwin AuthorDate: 2021-10-06 21:08:46 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:03:45 +0000 cryptosoft, ccr: Use crp_iv directly for AES-CCM and AES-GCM. Rather than copying crp_iv to a local array on the stack that is then passed to xform reinit routines, pass crp_iv directly and remove the local copy. Reviewed by: markj Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32106 (cherry picked from commit 5ae5ed5b8fd2955378ab67ba127cad8c981678ab) --- sys/dev/cxgbe/crypto/t4_crypto.c | 17 +++++------------ sys/opencrypto/cryptosoft.c | 18 +++++------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c index 9d410da6e030..33c03c3903e5 100644 --- a/sys/dev/cxgbe/crypto/t4_crypto.c +++ b/sys/dev/cxgbe/crypto/t4_crypto.c @@ -1391,7 +1391,6 @@ ccr_gcm_soft(struct ccr_session *s, struct cryptop *crp) void *auth_ctx, *kschedule; char block[GMAC_BLOCK_LEN]; char digest[GMAC_DIGEST_LEN]; - char iv[AES_BLOCK_LEN]; int error, i, len; auth_ctx = NULL; @@ -1436,10 +1435,8 @@ ccr_gcm_soft(struct ccr_session *s, struct cryptop *crp) error = EINVAL; goto out; } - crypto_read_iv(crp, iv); - *(uint32_t *)&iv[12] = htobe32(1); - axf->Reinit(auth_ctx, iv, sizeof(iv)); + axf->Reinit(auth_ctx, crp->crp_iv, AES_GCM_IV_LEN); /* MAC the AAD. */ if (crp->crp_aad != NULL) { @@ -1462,7 +1459,7 @@ ccr_gcm_soft(struct ccr_session *s, struct cryptop *crp) } } - exf->reinit(kschedule, iv, sizeof(iv)); + exf->reinit(kschedule, crp->crp_iv, AES_GCM_IV_LEN); /* Do encryption with MAC */ for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { @@ -1522,7 +1519,6 @@ out: zfree(kschedule, M_CCR); zfree(auth_ctx, M_CCR); explicit_bzero(block, sizeof(block)); - explicit_bzero(iv, sizeof(iv)); explicit_bzero(digest, sizeof(digest)); crp->crp_etype = error; crypto_done(crp); @@ -1878,7 +1874,6 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) void *kschedule; char block[CCM_CBC_BLOCK_LEN]; char digest[AES_CBC_MAC_HASH_LEN]; - char iv[AES_CCM_IV_LEN]; int error, i, len; auth_ctx = NULL; @@ -1923,11 +1918,10 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) error = EINVAL; goto out; } - crypto_read_iv(crp, iv); auth_ctx->aes_cbc_mac_ctx.authDataLength = crp->crp_aad_length; auth_ctx->aes_cbc_mac_ctx.cryptDataLength = crp->crp_payload_length; - axf->Reinit(auth_ctx, iv, sizeof(iv)); + axf->Reinit(auth_ctx, crp->crp_iv, AES_CCM_IV_LEN); /* MAC the AAD. */ if (crp->crp_aad != NULL) @@ -1939,7 +1933,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) if (error) goto out; - exf->reinit(kschedule, iv, sizeof(iv)); + exf->reinit(kschedule, crp->crp_iv, AES_CCM_IV_LEN); /* Do encryption/decryption with MAC */ for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { @@ -1974,7 +1968,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) error = 0; /* Tag matches, decrypt data. */ - exf->reinit(kschedule, iv, sizeof(iv)); + exf->reinit(kschedule, crp->crp_iv, AES_CCM_IV_LEN); for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { len = imin(crp->crp_payload_length - i, @@ -1995,7 +1989,6 @@ out: zfree(kschedule, M_CCR); zfree(auth_ctx, M_CCR); explicit_bzero(block, sizeof(block)); - explicit_bzero(iv, sizeof(iv)); explicit_bzero(digest, sizeof(digest)); crp->crp_etype = error; crypto_done(crp); diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index a85d7d6d3b7b..77df37420bf5 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -463,7 +463,6 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) uint32_t blkbuf[howmany(AES_BLOCK_LEN, sizeof(uint32_t))]; u_char *blk = (u_char *)blkbuf; u_char tag[GMAC_DIGEST_LEN]; - u_char iv[AES_BLOCK_LEN]; struct crypto_buffer_cursor cc_in, cc_out; const u_char *inblk; u_char *outblk; @@ -492,12 +491,10 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) return (EINVAL); - /* Initialize the IV */ ivlen = AES_GCM_IV_LEN; - bcopy(crp->crp_iv, iv, ivlen); /* Supply MAC with IV */ - axf->Reinit(&ctx, iv, ivlen); + axf->Reinit(&ctx, crp->crp_iv, ivlen); /* Supply MAC with AAD */ if (crp->crp_aad != NULL) { @@ -536,7 +533,7 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) if (crp->crp_cipher_key != NULL) exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, crypto_get_params(crp->crp_session)->csp_cipher_klen); - exf->reinit(swe->sw_kschedule, iv, ivlen); + exf->reinit(swe->sw_kschedule, crp->crp_iv, ivlen); /* Do encryption with MAC */ crypto_cursor_init(&cc_in, &crp->crp_buf); @@ -635,7 +632,6 @@ swcr_gcm(struct swcr_session *ses, struct cryptop *crp) out: explicit_bzero(blkbuf, sizeof(blkbuf)); explicit_bzero(tag, sizeof(tag)); - explicit_bzero(iv, sizeof(iv)); return (error); } @@ -701,7 +697,6 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) uint32_t blkbuf[howmany(AES_BLOCK_LEN, sizeof(uint32_t))]; u_char *blk = (u_char *)blkbuf; u_char tag[AES_CBC_MAC_HASH_LEN]; - u_char iv[AES_BLOCK_LEN]; struct crypto_buffer_cursor cc_in, cc_out; const u_char *inblk; u_char *outblk; @@ -729,9 +724,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) return (EINVAL); - /* Initialize the IV */ ivlen = AES_CCM_IV_LEN; - bcopy(crp->crp_iv, iv, ivlen); /* * AES CCM-CBC-MAC needs to know the length of both the auth @@ -741,7 +734,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) ctx.aes_cbc_mac_ctx.cryptDataLength = crp->crp_payload_length; /* Supply MAC with IV */ - axf->Reinit(&ctx, iv, ivlen); + axf->Reinit(&ctx, crp->crp_iv, ivlen); /* Supply MAC with AAD */ if (crp->crp_aad != NULL) @@ -755,7 +748,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) if (crp->crp_cipher_key != NULL) exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, crypto_get_params(crp->crp_session)->csp_cipher_klen); - exf->reinit(swe->sw_kschedule, iv, ivlen); + exf->reinit(swe->sw_kschedule, crp->crp_iv, ivlen); /* Do encryption/decryption with MAC */ crypto_cursor_init(&cc_in, &crp->crp_buf); @@ -826,7 +819,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) } /* tag matches, decrypt data */ - exf->reinit(swe->sw_kschedule, iv, ivlen); + exf->reinit(swe->sw_kschedule, crp->crp_iv, ivlen); crypto_cursor_init(&cc_in, &crp->crp_buf); crypto_cursor_advance(&cc_in, crp->crp_payload_start); for (resid = crp->crp_payload_length; resid > blksz; @@ -859,7 +852,6 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) out: explicit_bzero(blkbuf, sizeof(blkbuf)); explicit_bzero(tag, sizeof(tag)); - explicit_bzero(iv, sizeof(iv)); return (error); } From nobody Thu Oct 21 22:04:12 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D2D421800EE2; Thu, 21 Oct 2021 22:04: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 4Hb1j841nLz3tHX; Thu, 21 Oct 2021 22:04: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 4A149230A2; Thu, 21 Oct 2021 22:04: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 19LM4C83079429; Thu, 21 Oct 2021 22:04:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4CcP079428; Thu, 21 Oct 2021 22:04:12 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:12 GMT Message-Id: <202110212204.19LM4CcP079428@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: 38b8a2be5c48 - stable/13 - cryptodev: Permit explicit IV/nonce and MAC/tag lengths. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 38b8a2be5c48436a5db059080b97ff0f8c02ef27 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=38b8a2be5c48436a5db059080b97ff0f8c02ef27 commit 38b8a2be5c48436a5db059080b97ff0f8c02ef27 Author: John Baldwin AuthorDate: 2021-10-06 21:08:46 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:05:11 +0000 cryptodev: Permit explicit IV/nonce and MAC/tag lengths. Add 'ivlen' and 'maclen' fields to the structure used for CIOGSESSION2 to specify the explicit IV/nonce and MAC/tag lengths for crypto sessions. If these fields are zero, the default lengths are used. This permits selecting an alternate nonce length for AEAD ciphers such as AES-CCM which support multiple nonce leengths. It also supports truncated MACs as input to AEAD or ETA requests. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32107 (cherry picked from commit 16676123fc85233334983e0071cb446357abec8d) --- share/man/man4/crypto.4 | 24 ++++++++++++++++++++---- sys/opencrypto/cryptodev.c | 29 +++++++++++++++++++++++++++-- sys/opencrypto/cryptodev.h | 9 +++++++-- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/share/man/man4/crypto.4 b/share/man/man4/crypto.4 index f146b50ecd4b..83d00050af28 100644 --- a/share/man/man4/crypto.4 +++ b/share/man/man4/crypto.4 @@ -1,13 +1,16 @@ .\" $NetBSD: crypto.4,v 1.24 2014/01/27 21:23:59 pgoyette Exp $ .\" .\" Copyright (c) 2008 The NetBSD Foundation, Inc. -.\" Copyright (c) 2014 The FreeBSD Foundation +.\" Copyright (c) 2014-2021 The FreeBSD Foundation .\" All rights reserved. .\" .\" Portions of this documentation were written by John-Mark Gurney .\" under sponsorship of the FreeBSD Foundation and .\" Rubicon Communications, LLC (Netgate). .\" +.\" Portions of this documentation were written by Ararat River +.\" Consulting, LLC under sponsorship of the FreeBSD Foundation. +.\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Coyote Point Systems, Inc. .\" @@ -60,7 +63,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 24, 2020 +.Dd October 6, 2021 .Dt CRYPTO 4 .Os .Sh NAME @@ -265,14 +268,27 @@ struct session2_op { uint32_t ses; /* returns: ses # */ int crid; /* driver id + flags (rw) */ - int pad[4]; /* for future expansion */ + int ivlen; /* length of nonce/IV */ + int maclen; /* length of MAC/tag */ + int pad[2]; /* for future expansion */ }; .Ed -This request is similar to CIOGSESSION except that +This request is similar to CIOGSESSION but adds additional fields. +.Pp .Fa sessp-\*[Gt]crid requests either a specific crypto device or a class of devices (software vs hardware). +.Pp +.Fa sessp-\*[Gt]ivlen +specifies the length of the IV or nonce supplied with each request. +If this field is set to zero, the default IV or nonce length is used. +.Pp +.Fa sessp-\*[Gt]maclen +specifies the length of the MAC or authentication tag supplied or computed by +each request. +If this field is set to zero, the full MAC is used. +.Pp The .Fa sessp-\*[Gt]pad field must be initialized to zero. diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 9f581e68fe92..ffdf4c67d2f0 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -103,7 +103,9 @@ struct session2_op32 { uint32_t mackey; uint32_t ses; int crid; - int pad[4]; + int ivlen; + int maclen; + int pad[2]; }; struct crypt_op32 { @@ -172,6 +174,8 @@ session2_op_from_32(const struct session2_op32 *from, struct session2_op *to) session_op_from_32((const struct session_op32 *)from, to); CP(*from, *to, crid); + CP(*from, *to, ivlen); + CP(*from, *to, maclen); } static void @@ -662,6 +666,25 @@ cse_create(struct fcrypt *fcr, struct session2_op *sop) csp.csp_ivlen = AES_CCM_IV_LEN; } + if (sop->ivlen != 0) { + if (csp.csp_ivlen == 0) { + CRYPTDEB("does not support an IV"); + error = EINVAL; + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + goto bail; + } + csp.csp_ivlen = sop->ivlen; + } + if (sop->maclen != 0) { + if (!(thash != NULL || csp.csp_mode == CSP_MODE_AEAD)) { + CRYPTDEB("does not support a MAC"); + error = EINVAL; + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + goto bail; + } + csp.csp_auth_mlen = sop->maclen; + } + crid = sop->crid; error = checkforsoftware(&crid); if (error) { @@ -683,7 +706,9 @@ cse_create(struct fcrypt *fcr, struct session2_op *sop) cse->mackey = mackey; cse->cses = cses; cse->txform = txform; - if (thash != NULL) + if (sop->maclen != 0) + cse->hashsize = sop->maclen; + else if (thash != NULL) cse->hashsize = thash->hashsize; else if (csp.csp_cipher_alg == CRYPTO_AES_NIST_GCM_16) cse->hashsize = AES_GMAC_HASH_LEN; diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index 4d9b735366b8..046f67de418e 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -23,13 +23,16 @@ * PURPOSE. * * Copyright (c) 2001 Theo de Raadt - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2014-2021 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by John-Mark Gurney * under sponsorship of the FreeBSD Foundation and * Rubicon Communications, LLC (Netgate). * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -246,7 +249,9 @@ struct session2_op { uint32_t ses; /* returns: session # */ int crid; /* driver id + flags (rw) */ - int pad[4]; /* for future expansion */ + int ivlen; /* length of nonce/IV */ + int maclen; /* length of MAC/tag */ + int pad[2]; /* for future expansion */ }; struct crypt_op { From nobody Thu Oct 21 22:04:13 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 880AF1800E6D; Thu, 21 Oct 2021 22:04: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 4Hb1j953JGz3tKq; Thu, 21 Oct 2021 22:04: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 72C512303D; Thu, 21 Oct 2021 22:04: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 19LM4D5R079457; Thu, 21 Oct 2021 22:04:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4D16079456; Thu, 21 Oct 2021 22:04:13 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:13 GMT Message-Id: <202110212204.19LM4D16079456@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: ac648e3affe3 - stable/13 - cryptodev: Permit CIOCCRYPT for AEAD ciphers. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: ac648e3affe358fb373cf369fb2ea46daceba250 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ac648e3affe358fb373cf369fb2ea46daceba250 commit ac648e3affe358fb373cf369fb2ea46daceba250 Author: John Baldwin AuthorDate: 2021-10-06 21:08:47 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:07:11 +0000 cryptodev: Permit CIOCCRYPT for AEAD ciphers. A request without AAD for an AEAD cipher can be submitted via CIOCCRYPT rather than CIOCCRYPTAEAD. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32108 (cherry picked from commit 70dbebea124236184a66a30175ba307793971f00) --- sys/opencrypto/cryptodev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index ffdf4c67d2f0..b449c7a12d9f 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -929,6 +929,13 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) goto bail; } break; + case CSP_MODE_AEAD: + if (cse->ivsize != 0 && cop->iv == NULL) { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + error = EINVAL; + goto bail; + } + /* FALLTHROUGH */ case CSP_MODE_ETA: switch (cop->op) { case COP_ENCRYPT: From nobody Thu Oct 21 22:04:14 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 618BE180121D; Thu, 21 Oct 2021 22:04: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 4Hb1jC0KKlz3t87; Thu, 21 Oct 2021 22:04: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 98199230A3; Thu, 21 Oct 2021 22:04: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 19LM4EEb079481; Thu, 21 Oct 2021 22:04:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4ENt079480; Thu, 21 Oct 2021 22:04:14 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:14 GMT Message-Id: <202110212204.19LM4ENt079480@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: 5f9a61203779 - stable/13 - cryptodev: Allow some CIOCCRYPT operations with an empty payload. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 5f9a612037793b51c70e26846334d0e0c4232950 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5f9a612037793b51c70e26846334d0e0c4232950 commit 5f9a612037793b51c70e26846334d0e0c4232950 Author: John Baldwin AuthorDate: 2021-10-06 21:08:47 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:07:18 +0000 cryptodev: Allow some CIOCCRYPT operations with an empty payload. If an operation would generate a MAC output (e.g. for digest operation or for an AEAD or EtA operation), then an empty payload buffer is valid. Only reject requests with an empty buffer for "plain" cipher sessions. Some of the AES-CCM NIST KAT vectors use an empty payload. While here, don't advance crp_payload_start for requests that use an empty payload with an inline IV. (*) Reported by: syzbot+d4b94fbd9a44b032f428@syzkaller.appspotmail.com (*) Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32109 (cherry picked from commit a0cbcbb7917b0b8566ec0853425a73d7958ddbed) --- sys/opencrypto/cryptodev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index b449c7a12d9f..7e4cecff3980 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -846,7 +846,7 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) } if (cse->txform) { - if (cop->len == 0 || (cop->len % cse->txform->blocksize) != 0) { + if ((cop->len % cse->txform->blocksize) != 0) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); return (EINVAL); } @@ -901,6 +901,12 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) } break; case CSP_MODE_CIPHER: + if (cop->len == 0 || + (cop->iv == NULL && cop->len == cse->ivsize)) { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + error = EINVAL; + goto bail; + } switch (cop->op) { case COP_ENCRYPT: crp->crp_op = CRYPTO_OP_ENCRYPT; @@ -984,8 +990,9 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) goto bail; } crp->crp_iv_start = 0; - crp->crp_payload_start += cse->ivsize; crp->crp_payload_length -= cse->ivsize; + if (crp->crp_payload_length != 0) + crp->crp_payload_start = cse->ivsize; dst += cse->ivsize; } From nobody Thu Oct 21 22:04:16 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0B9DD180139B; Thu, 21 Oct 2021 22:04: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 4Hb1jF1Km1z3tkT; Thu, 21 Oct 2021 22:04: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 DB21D230A5; Thu, 21 Oct 2021 22:04: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 19LM4GIN079530; Thu, 21 Oct 2021 22:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4GiR079529; Thu, 21 Oct 2021 22:04:16 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:16 GMT Message-Id: <202110212204.19LM4GiR079529@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: fd464d2f78f3 - stable/13 - crypto: Support multiple nonce lengths for AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: fd464d2f78f3b3ff6cf8197b95a952c2db29ec5c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=fd464d2f78f3b3ff6cf8197b95a952c2db29ec5c commit fd464d2f78f3b3ff6cf8197b95a952c2db29ec5c Author: John Baldwin AuthorDate: 2021-10-06 21:08:47 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:07:36 +0000 crypto: Support multiple nonce lengths for AES-CCM. Permit nonces of lengths 7 through 13 in the OCF framework and the cryptosoft driver. A helper function (ccm_max_payload_length) can be used in OCF drivers to reject CCM requests which are too large for the specified nonce length. Reviewed by: sef Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32111 (cherry picked from commit ae18720d2792287c9ec658404f1a3173014d4979) --- share/man/man7/crypto.7 | 18 +++++++++----- sys/opencrypto/crypto.c | 56 ++++++++++++++++++++++++++++++++++++------ sys/opencrypto/cryptodev.h | 29 ++++++++++++++++++++++ sys/opencrypto/cryptosoft.c | 17 +++++++------ sys/opencrypto/xform_aes_icm.c | 7 +++--- 5 files changed, 102 insertions(+), 25 deletions(-) diff --git a/share/man/man7/crypto.7 b/share/man/man7/crypto.7 index 6e5bd83621aa..d75daa62adcb 100644 --- a/share/man/man7/crypto.7 +++ b/share/man/man7/crypto.7 @@ -1,9 +1,13 @@ -.\" Copyright (c) 2014 The FreeBSD Foundation +.\" Copyright (c) 2014-2021 The FreeBSD Foundation .\" All rights reserved. .\" -.\" This documentation was written by John-Mark Gurney under -.\" the sponsorship of the FreeBSD Foundation and +.\" Portions of this documentation were written by John-Mark Gurney +.\" under the sponsorship of the FreeBSD Foundation and .\" Rubicon Communications, LLC (Netgate). +.\" +.\" Portions of this documentation were written by Ararat River +.\" Consulting, LLC under sponsorship of the FreeBSD Foundation. +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -27,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 3, 2021 +.Dd October 6, 2021 .Dt CRYPTO 7 .Os .Sh NAME @@ -153,13 +157,15 @@ This nonce must be provided in via the .Dv CRYPTO_F_IV_SEPARATE flag. +Some AEAD algorithms support multiple nonce sizes. +The first size listed is the default nonce size. .Pp The following AEAD algorithms are supported: -.Bl -column "CRYPTO_AES_NIST_GCM_16" "Nonce" "16, 24, 32" "Tag" +.Bl -column "CRYPTO_AES_NIST_GCM_16" "12, 7-13" "16, 24, 32" "Tag" .It Sy Name Ta Sy Nonce Ta Sy Key Sizes Ta Sy Tag Ta Sy Description .It Dv CRYPTO_AES_NIST_GCM_16 Ta 12 Ta 16, 24, 32 Ta 16 Ta AES Galois/Counter Mode -.It Dv CRYPTO_AES_CCM_16 Ta 12 Ta 16, 24, 32 Ta 16 Ta +.It Dv CRYPTO_AES_CCM_16 Ta 12, 7-13 Ta 16, 24, 32 Ta 16 Ta AES Counter with CBC-MAC .It Dv CRYPTO_CHACHA20_POLY1305 Ta 12 Ta 32 Ta 16 Ta ChaCha20-Poly1305 diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index bcde910728e1..a3a42827d51b 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -1,5 +1,9 @@ /*- * Copyright (c) 2002-2006 Sam Leffler. All rights reserved. + * Copyright (c) 2021 The FreeBSD Foundation + * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -743,6 +747,24 @@ alg_is_aead(int alg) return (alg_type(alg) == ALG_AEAD); } +static bool +ccm_tag_length_valid(int len) +{ + /* RFC 3610 */ + switch (len) { + case 4: + case 6: + case 8: + case 10: + case 12: + case 14: + case 16: + return (true); + default: + return (false); + } +} + #define SUPPORTED_SES (CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD | CSP_F_ESN) /* Various sanity checks on crypto session parameters. */ @@ -800,8 +822,21 @@ check_csp(const struct crypto_session_params *csp) return (false); /* IV is optional for digests (e.g. GMAC). */ - if (csp->csp_ivlen >= EALG_MAX_BLOCK_LEN) - return (false); + switch (csp->csp_auth_alg) { + case CRYPTO_AES_CCM_CBC_MAC: + if (csp->csp_ivlen < 7 || csp->csp_ivlen > 13) + return (false); + break; + case CRYPTO_AES_NIST_GMAC: + if (csp->csp_ivlen != AES_GCM_IV_LEN) + return (false); + break; + default: + if (csp->csp_ivlen != 0) + return (false); + break; + } + if (!alg_is_digest(csp->csp_auth_alg)) return (false); @@ -820,6 +855,10 @@ check_csp(const struct crypto_session_params *csp) axf = crypto_auth_hash(csp); if (axf == NULL || csp->csp_auth_mlen > axf->hashsize) return (false); + + if (csp->csp_auth_alg == CRYPTO_AES_CCM_CBC_MAC && + !ccm_tag_length_valid(csp->csp_auth_mlen)) + return (false); } break; case CSP_MODE_AEAD: @@ -833,13 +872,16 @@ check_csp(const struct crypto_session_params *csp) if (csp->csp_auth_alg != 0 || csp->csp_auth_klen != 0) return (false); - /* - * XXX: Would be nice to have a better way to get this - * value. - */ switch (csp->csp_cipher_alg) { - case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_CCM_16: + if (csp->csp_auth_mlen != 0 && + !ccm_tag_length_valid(csp->csp_auth_mlen)) + return (false); + + if (csp->csp_ivlen < 7 || csp->csp_ivlen > 13) + return (false); + break; + case CRYPTO_AES_NIST_GCM_16: case CRYPTO_CHACHA20_POLY1305: if (csp->csp_auth_mlen > 16) return (false); diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index 046f67de418e..1aa11c34d8ba 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -753,5 +753,34 @@ crypto_read_iv(struct cryptop *crp, void *iv) crypto_copydata(crp, crp->crp_iv_start, csp->csp_ivlen, iv); } +static __inline size_t +ccm_max_payload_length(const struct crypto_session_params *csp) +{ + /* RFC 3160 */ + const u_int L = 15 - csp->csp_ivlen; + + switch (L) { + case 2: + return (0xffff); + case 3: + return (0xffffff); +#ifdef __LP64__ + case 4: + return (0xffffffff); + case 5: + return (0xffffffffff); + case 6: + return (0xffffffffffff); + case 7: + return (0xffffffffffffff); + default: + return (0xffffffffffffffff); +#else + default: + return (0xffffffff); +#endif + } +} + #endif /* _KERNEL */ #endif /* _CRYPTO_CRYPTO_H_ */ diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index 77df37420bf5..c86ff86613db 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -642,17 +642,19 @@ swcr_ccm_cbc_mac(struct swcr_session *ses, struct cryptop *crp) u_char tag[AES_CBC_MAC_HASH_LEN]; u_char iv[AES_BLOCK_LEN]; union authctx ctx; + const struct crypto_session_params *csp; struct swcr_auth *swa; struct auth_hash *axf; int error, ivlen; + csp = crypto_get_params(crp->crp_session); swa = &ses->swcr_auth; axf = swa->sw_axf; bcopy(swa->sw_ictx, &ctx, axf->ctxsize); /* Initialize the IV */ - ivlen = AES_CCM_IV_LEN; + ivlen = csp->csp_ivlen; crypto_read_iv(crp, iv); /* @@ -694,6 +696,7 @@ swcr_ccm_cbc_mac(struct swcr_session *ses, struct cryptop *crp) static int swcr_ccm(struct swcr_session *ses, struct cryptop *crp) { + const struct crypto_session_params *csp; uint32_t blkbuf[howmany(AES_BLOCK_LEN, sizeof(uint32_t))]; u_char *blk = (u_char *)blkbuf; u_char tag[AES_CBC_MAC_HASH_LEN]; @@ -708,6 +711,7 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) size_t len; int blksz, error, ivlen, r, resid; + csp = crypto_get_params(crp->crp_session); swa = &ses->swcr_auth; axf = swa->sw_axf; @@ -721,10 +725,13 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) KASSERT(axf->blocksize == exf->native_blocksize, ("%s: blocksize mismatch", __func__)); + if (crp->crp_payload_length > ccm_max_payload_length(csp)) + return (EMSGSIZE); + if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) return (EINVAL); - ivlen = AES_CCM_IV_LEN; + ivlen = csp->csp_ivlen; /* * AES CCM-CBC-MAC needs to know the length of both the auth @@ -1130,7 +1137,6 @@ swcr_setup_cipher(struct swcr_session *ses, swe = &ses->swcr_encdec; txf = crypto_cipher(csp); - MPASS(txf->ivsize == csp->csp_ivlen); if (txf->ctxsize != 0) { swe->sw_kschedule = malloc(txf->ctxsize, M_CRYPTO_DATA, M_NOWAIT); @@ -1282,9 +1288,6 @@ swcr_setup_ccm(struct swcr_session *ses, struct swcr_auth *swa; struct auth_hash *axf; - if (csp->csp_ivlen != AES_CCM_IV_LEN) - return (EINVAL); - /* First, setup the auth side. */ swa = &ses->swcr_auth; switch (csp->csp_cipher_klen * 8) { @@ -1392,8 +1395,6 @@ swcr_auth_supported(const struct crypto_session_params *csp) } if (csp->csp_auth_key == NULL) return (false); - if (csp->csp_ivlen != AES_CCM_IV_LEN) - return (false); break; } return (true); diff --git a/sys/opencrypto/xform_aes_icm.c b/sys/opencrypto/xform_aes_icm.c index 45da8267ca7d..4126bd755e0c 100644 --- a/sys/opencrypto/xform_aes_icm.c +++ b/sys/opencrypto/xform_aes_icm.c @@ -144,15 +144,14 @@ aes_ccm_reinit(void *key, const uint8_t *iv, size_t ivlen) { struct aes_icm_ctx *ctx; - KASSERT(ivlen == AES_CCM_IV_LEN, + KASSERT(ivlen >= 7 && ivlen <= 13, ("%s: invalid IV length", __func__)); ctx = key; /* CCM has flags, then the IV, then the counter, which starts at 1 */ bzero(ctx->ac_block, sizeof(ctx->ac_block)); - /* 3 bytes for length field; this gives a nonce of 12 bytes */ - ctx->ac_block[0] = (15 - AES_CCM_IV_LEN) - 1; - bcopy(iv, ctx->ac_block+1, AES_CCM_IV_LEN); + ctx->ac_block[0] = (15 - ivlen) - 1; + bcopy(iv, ctx->ac_block + 1, ivlen); ctx->ac_block[AESICM_BLOCKSIZE - 1] = 1; } From nobody Thu Oct 21 22:04:15 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8D55B1801437; Thu, 21 Oct 2021 22:04: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 4Hb1jD0dDkz3tL5; Thu, 21 Oct 2021 22:04: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 B54BD230A4; Thu, 21 Oct 2021 22:04: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 19LM4FvV079506; Thu, 21 Oct 2021 22:04:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4FP7079505; Thu, 21 Oct 2021 22:04:15 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:15 GMT Message-Id: <202110212204.19LM4FP7079505@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: 8581b350dda4 - stable/13 - cryptocheck: Support multiple IV sizes for AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 8581b350dda4eb8c46f92949b8def97454f63ae0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=8581b350dda4eb8c46f92949b8def97454f63ae0 commit 8581b350dda4eb8c46f92949b8def97454f63ae0 Author: John Baldwin AuthorDate: 2021-10-06 21:08:47 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:07:24 +0000 cryptocheck: Support multiple IV sizes for AES-CCM. By default, the "normal" IV size (12) is used, but it can be overriden via -I. If -I is not specified and -z is specified, issue requests for all possible IV sizes. Reviewed by: markj Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32110 (cherry picked from commit bcb0fd6accc095295765b08b02f5f3b07ea62536) --- tools/tools/crypto/cryptocheck.c | 236 ++++++++++++++++++++++++++------------- 1 file changed, 156 insertions(+), 80 deletions(-) diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c index 502ea04cd661..63c6ce1f9d28 100644 --- a/tools/tools/crypto/cryptocheck.c +++ b/tools/tools/crypto/cryptocheck.c @@ -1,8 +1,12 @@ /*- * Copyright (c) 2017 Chelsio Communications, Inc. * All rights reserved. + * Copyright (c) 2021 The FreeBSD Foundation * Written by: John Baldwin * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -65,7 +69,8 @@ * operation once in software via OpenSSL and a second time via * OpenCrypto and compares the results. * - * cryptocheck [-vz] [-A aad length] [-a algorithm] [-d dev] [size ...] + * cryptocheck [-vz] [-A aad length] [-a algorithm] [-d dev] [-I IV length] + * [size ...] * * Options: * -v Verbose. @@ -153,6 +158,7 @@ static const struct alg { enum { T_HASH, T_HMAC, T_GMAC, T_DIGEST, T_CIPHER, T_ETA, T_AEAD } type; int key_len; int tag_len; + u_int iv_sizes[8]; const EVP_CIPHER *(*evp_cipher)(void); const EVP_MD *(*evp_md)(void); int pkey; @@ -208,34 +214,41 @@ static const struct alg { { .name = "chacha20", .cipher = CRYPTO_CHACHA20, .type = T_CIPHER, .evp_cipher = EVP_chacha20 }, { .name = "aes-gcm", .cipher = CRYPTO_AES_NIST_GCM_16, .type = T_AEAD, - .tag_len = AES_GMAC_HASH_LEN, .evp_cipher = EVP_aes_128_gcm }, + .tag_len = AES_GMAC_HASH_LEN, .iv_sizes = { AES_GCM_IV_LEN }, + .evp_cipher = EVP_aes_128_gcm }, { .name = "aes-gcm192", .cipher = CRYPTO_AES_NIST_GCM_16, .type = T_AEAD, .tag_len = AES_GMAC_HASH_LEN, - .evp_cipher = EVP_aes_192_gcm }, + .iv_sizes = { AES_GCM_IV_LEN }, .evp_cipher = EVP_aes_192_gcm }, { .name = "aes-gcm256", .cipher = CRYPTO_AES_NIST_GCM_16, .type = T_AEAD, .tag_len = AES_GMAC_HASH_LEN, - .evp_cipher = EVP_aes_256_gcm }, + .iv_sizes = { AES_GCM_IV_LEN }, .evp_cipher = EVP_aes_256_gcm }, { .name = "aes-ccm", .cipher = CRYPTO_AES_CCM_16, .type = T_AEAD, - .evp_cipher = EVP_aes_128_ccm, .tag_len = AES_CBC_MAC_HASH_LEN }, + .tag_len = AES_CBC_MAC_HASH_LEN, .iv_sizes = { 12, 7, 8, 9, 10, 11, 13 }, + .evp_cipher = EVP_aes_128_ccm }, { .name = "aes-ccm192", .cipher = CRYPTO_AES_CCM_16, .type = T_AEAD, - .evp_cipher = EVP_aes_192_ccm, .tag_len = AES_CBC_MAC_HASH_LEN }, + .tag_len = AES_CBC_MAC_HASH_LEN, .iv_sizes = { 12, 7, 8, 9, 10, 11, 13 }, + .evp_cipher = EVP_aes_192_ccm }, { .name = "aes-ccm256", .cipher = CRYPTO_AES_CCM_16, .type = T_AEAD, - .evp_cipher = EVP_aes_256_ccm, .tag_len = AES_CBC_MAC_HASH_LEN }, + .tag_len = AES_CBC_MAC_HASH_LEN, .iv_sizes = { 12, 7, 8, 9, 10, 11, 13 }, + .evp_cipher = EVP_aes_256_ccm }, { .name = "chacha20-poly1305", .cipher = CRYPTO_CHACHA20_POLY1305, .type = T_AEAD, .tag_len = POLY1305_HASH_LEN, + .iv_sizes = { CHACHA20_POLY1305_IV_LEN }, .evp_cipher = EVP_chacha20_poly1305 }, }; -static bool verbose; +static bool testall, verbose; static int requested_crid; static size_t aad_sizes[48], sizes[EALG_MAX_BLOCK_LEN * 2]; static u_int naad_sizes, nsizes; +static u_int iv_size; static void usage(void) { fprintf(stderr, - "usage: cryptocheck [-z] [-a algorithm] [-d dev] [size ...]\n"); + "usage: cryptocheck [-vz] [-A aad size] [-a algorithm]\n" + " [-d dev] [-I IV size] [size ...]\n"); exit(1); } @@ -1218,8 +1231,8 @@ out: static void openssl_aead_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, - const char *key, const char *iv, const char *aad, size_t aad_len, - const char *input, char *output, size_t size, char *tag) + const char *key, const char *iv, size_t iv_len, const char *aad, + size_t aad_len, const char *input, char *output, size_t size, char *tag) { EVP_CIPHER_CTX *ctx; int outl, total; @@ -1228,7 +1241,13 @@ openssl_aead_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, if (ctx == NULL) errx(1, "OpenSSL %s (%zu) ctx new failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); - if (EVP_EncryptInit_ex(ctx, cipher, NULL, (const u_char *)key, + if (EVP_EncryptInit_ex(ctx, cipher, NULL, NULL, NULL) != 1) + errx(1, "OpenSSL %s (%zu) ctx init failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, iv_len, NULL) != 1) + errx(1, "OpenSSL %s (%zu) setting iv length failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_EncryptInit_ex(ctx, NULL, NULL, (const u_char *)key, (const u_char *)iv) != 1) errx(1, "OpenSSL %s (%zu) ctx init failed: %s", alg->name, size, ERR_error_string(ERR_get_error(), NULL)); @@ -1314,54 +1333,67 @@ openssl_ccm_encrypt(const struct alg *alg, const EVP_CIPHER *cipher, ctx = EVP_CIPHER_CTX_new(); if (ctx == NULL) - errx(1, "OpenSSL %s (%zu) ctx new failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, "OpenSSL %s/%zu (%zu, %zu) ctx new failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); if (EVP_EncryptInit_ex(ctx, cipher, NULL, NULL, NULL) != 1) - errx(1, "OpenSSL %s (%zu) ctx init failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, "OpenSSL %s/%zu (%zu, %zu) ctx init failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, iv_len, NULL) != 1) - errx(1, "OpenSSL %s (%zu) setting iv length failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, + "OpenSSL %s/%zu (%zu, %zu) setting iv length failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, AES_CBC_MAC_HASH_LEN, NULL) != 1) - errx(1, "OpenSSL %s (%zu) setting tag length failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, + "OpenSSL %s/%zu (%zu, %zu) setting tag length failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); if (EVP_EncryptInit_ex(ctx, NULL, NULL, (const u_char *)key, (const u_char *)iv) != 1) - errx(1, "OpenSSL %s (%zu) ctx init failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, "OpenSSL %s/%zu (%zu, %zu) ctx init failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); if (EVP_EncryptUpdate(ctx, NULL, &outl, NULL, size) != 1) - errx(1, "OpenSSL %s (%zu) unable to set data length: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, + "OpenSSL %s/%zu (%zu, %zu) unable to set data length: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); if (aad != NULL) { if (EVP_EncryptUpdate(ctx, NULL, &outl, (const u_char *)aad, aad_len) != 1) - errx(1, "OpenSSL %s (%zu) aad update failed: %s", - alg->name, size, + errx(1, + "OpenSSL %s/%zu (%zu, %zu) aad update failed: %s", + alg->name, iv_len, aad_len, size, ERR_error_string(ERR_get_error(), NULL)); } if (EVP_EncryptUpdate(ctx, (u_char *)output, &outl, (const u_char *)input, size) != 1) - errx(1, "OpenSSL %s (%zu) encrypt update failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, "OpenSSL %s/%zu (%zu, %zu) encrypt update failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); total = outl; if (EVP_EncryptFinal_ex(ctx, (u_char *)output + outl, &outl) != 1) - errx(1, "OpenSSL %s (%zu) encrypt final failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, "OpenSSL %s/%zu (%zu, %zu) encrypt final failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); total += outl; if ((size_t)total != size) - errx(1, "OpenSSL %s (%zu) encrypt size mismatch: %d", alg->name, - size, total); + errx(1, "OpenSSL %s/%zu (%zu, %zu) encrypt size mismatch: %d", + alg->name, iv_len, aad_len, size, total); if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, AES_CBC_MAC_HASH_LEN, tag) != 1) - errx(1, "OpenSSL %s (%zu) get tag failed: %s", alg->name, - size, ERR_error_string(ERR_get_error(), NULL)); + errx(1, "OpenSSL %s/%zu (%zu, %zu) get tag failed: %s", + alg->name, iv_len, aad_len, size, + ERR_error_string(ERR_get_error(), NULL)); EVP_CIPHER_CTX_free(ctx); } static bool ocf_init_aead_session(const struct alg *alg, const char *key, size_t key_len, - struct ocf_session *ses) + size_t iv_len, struct ocf_session *ses) { struct session2_op sop; @@ -1369,6 +1401,7 @@ ocf_init_aead_session(const struct alg *alg, const char *key, size_t key_len, sop.keylen = key_len; sop.key = key; sop.cipher = alg->cipher; + sop.ivlen = iv_len; return (ocf_init_session(&sop, "AEAD", alg->name, ses)); } @@ -1398,14 +1431,43 @@ ocf_aead(const struct ocf_session *ses, const char *iv, size_t iv_len, #define AEAD_MAX_TAG_LEN \ MAX(MAX(AES_GMAC_HASH_LEN, AES_CBC_MAC_HASH_LEN), POLY1305_HASH_LEN) +static size_t +max_ccm_buffer_length(size_t iv_len) +{ + const u_int L = 15 - iv_len; + + switch (L) { + case 2: + return (0xffff); + case 3: + return (0xffffff); +#ifdef __LP64__ + case 4: + return (0xffffffff); + case 5: + return (0xffffffffff); + case 6: + return (0xffffffffffff); + case 7: + return (0xffffffffffffff); + default: + return (0xffffffffffffffff); +#else + default: + return (0xffffffff); +#endif + } +} + static void -run_aead_test(const struct alg *alg, size_t aad_len, size_t size) +run_aead_test(const struct alg *alg, size_t aad_len, size_t size, + size_t iv_len) { struct ocf_session ses; const EVP_CIPHER *cipher; char *aad, *buffer, *cleartext, *ciphertext; char *iv, *key; - u_int iv_len, key_len; + u_int key_len; int error; char control_tag[AEAD_MAX_TAG_LEN], test_tag[AEAD_MAX_TAG_LEN]; @@ -1413,31 +1475,25 @@ run_aead_test(const struct alg *alg, size_t aad_len, size_t size) if (size % EVP_CIPHER_block_size(cipher) != 0) { if (verbose) printf( - "%s (%zu, %zu): invalid buffer size (block size %d)\n", - alg->name, aad_len, size, + "%s/%zu (%zu, %zu): invalid buffer size (block size %d)\n", + alg->name, iv_len, aad_len, size, EVP_CIPHER_block_size(cipher)); return; } - memset(control_tag, 0x3c, sizeof(control_tag)); - memset(test_tag, 0x3c, sizeof(test_tag)); - - key_len = EVP_CIPHER_key_length(cipher); - iv_len = EVP_CIPHER_iv_length(cipher); - - /* - * AES-CCM can have varying IV lengths; however, for the moment - * we only support AES_CCM_IV_LEN (12). So if the sizes are - * different, we'll fail. - */ if (EVP_CIPHER_mode(cipher) == EVP_CIPH_CCM_MODE && - iv_len != AES_CCM_IV_LEN) { + size > max_ccm_buffer_length(iv_len)) { if (verbose) - printf("OpenSSL CCM IV length (%d) != AES_CCM_IV_LEN", - iv_len); + printf("%s/%zu (%zu, %zu): invalid buffer size\n", + alg->name, iv_len, aad_len, size); return; } + memset(control_tag, 0x3c, sizeof(control_tag)); + memset(test_tag, 0x3c, sizeof(test_tag)); + + key_len = EVP_CIPHER_key_length(cipher); + key = alloc_buffer(key_len); iv = generate_iv(iv_len, alg); cleartext = alloc_buffer(size); @@ -1453,23 +1509,23 @@ run_aead_test(const struct alg *alg, size_t aad_len, size_t size) openssl_ccm_encrypt(alg, cipher, key, iv, iv_len, aad, aad_len, cleartext, ciphertext, size, control_tag); else - openssl_aead_encrypt(alg, cipher, key, iv, aad, aad_len, - cleartext, ciphertext, size, control_tag); + openssl_aead_encrypt(alg, cipher, key, iv, iv_len, aad, + aad_len, cleartext, ciphertext, size, control_tag); - if (!ocf_init_aead_session(alg, key, key_len, &ses)) + if (!ocf_init_aead_session(alg, key, key_len, iv_len, &ses)) goto out; /* OCF encrypt */ error = ocf_aead(&ses, iv, iv_len, aad, aad_len, cleartext, buffer, size, test_tag, COP_ENCRYPT); if (error != 0) { - warnc(error, "cryptodev %s (%zu, %zu) failed for device %s", - alg->name, aad_len, size, crfind(ses.crid)); + warnc(error, "cryptodev %s/%zu (%zu, %zu) failed for device %s", + alg->name, iv_len, aad_len, size, crfind(ses.crid)); goto out; } if (memcmp(ciphertext, buffer, size) != 0) { - printf("%s (%zu, %zu) encryption mismatch:\n", alg->name, - aad_len, size); + printf("%s/%zu (%zu, %zu) encryption mismatch:\n", alg->name, + iv_len, aad_len, size); printf("control:\n"); hexdump(ciphertext, size, NULL, 0); printf("test (cryptodev device %s):\n", crfind(ses.crid)); @@ -1477,8 +1533,8 @@ run_aead_test(const struct alg *alg, size_t aad_len, size_t size) goto out; } if (memcmp(control_tag, test_tag, sizeof(control_tag)) != 0) { - printf("%s (%zu, %zu) enc tag mismatch:\n", alg->name, aad_len, - size); + printf("%s/%zu (%zu, %zu) enc tag mismatch:\n", alg->name, + iv_len, aad_len, size); printf("control:\n"); hexdump(control_tag, sizeof(control_tag), NULL, 0); printf("test (cryptodev device %s):\n", crfind(ses.crid)); @@ -1490,13 +1546,13 @@ run_aead_test(const struct alg *alg, size_t aad_len, size_t size) error = ocf_aead(&ses, iv, iv_len, aad, aad_len, ciphertext, buffer, size, control_tag, COP_DECRYPT); if (error != 0) { - warnc(error, "cryptodev %s (%zu, %zu) failed for device %s", - alg->name, aad_len, size, crfind(ses.crid)); + warnc(error, "cryptodev %s/%zu (%zu, %zu) failed for device %s", + alg->name, iv_len, aad_len, size, crfind(ses.crid)); goto out; } if (memcmp(cleartext, buffer, size) != 0) { - printf("%s (%zu, %zu) decryption mismatch:\n", alg->name, - aad_len, size); + printf("%s/%zu (%zu, %zu) decryption mismatch:\n", alg->name, + iv_len, aad_len, size); printf("control:\n"); hexdump(cleartext, size, NULL, 0); printf("test (cryptodev device %s):\n", crfind(ses.crid)); @@ -1511,18 +1567,18 @@ run_aead_test(const struct alg *alg, size_t aad_len, size_t size) if (error != EBADMSG) { if (error != 0) warnc(error, - "cryptodev %s (%zu, %zu) corrupt tag failed for device %s", - alg->name, aad_len, size, crfind(ses.crid)); + "cryptodev %s/%zu (%zu, %zu) corrupt tag failed for device %s", + alg->name, iv_len, aad_len, size, crfind(ses.crid)); else warnx( - "cryptodev %s (%zu, %zu) corrupt tag didn't fail for device %s", - alg->name, aad_len, size, crfind(ses.crid)); + "cryptodev %s/%zu (%zu, %zu) corrupt tag didn't fail for device %s", + alg->name, iv_len, aad_len, size, crfind(ses.crid)); goto out; } if (verbose) - printf("%s (%zu, %zu) matched (cryptodev device %s)\n", - alg->name, aad_len, size, crfind(ses.crid)); + printf("%s/%zu (%zu, %zu) matched (cryptodev device %s)\n", + alg->name, iv_len, aad_len, size, crfind(ses.crid)); out: ocf_destroy_session(&ses); @@ -1535,7 +1591,7 @@ out: } static void -run_test(const struct alg *alg, size_t aad_len, size_t size) +run_test(const struct alg *alg, size_t aad_len, size_t size, size_t iv_len) { switch (alg->type) { @@ -1558,7 +1614,7 @@ run_test(const struct alg *alg, size_t aad_len, size_t size) run_eta_test(alg, aad_len, size); break; case T_AEAD: - run_aead_test(alg, aad_len, size); + run_aead_test(alg, aad_len, size, iv_len); break; } } @@ -1566,18 +1622,33 @@ run_test(const struct alg *alg, size_t aad_len, size_t size) static void run_test_sizes(const struct alg *alg) { - u_int i, j; + u_int i, j, k; switch (alg->type) { default: for (i = 0; i < nsizes; i++) - run_test(alg, 0, sizes[i]); + run_test(alg, 0, sizes[i], 0); break; case T_ETA: - case T_AEAD: for (i = 0; i < naad_sizes; i++) for (j = 0; j < nsizes; j++) - run_test(alg, aad_sizes[i], sizes[j]); + run_test(alg, aad_sizes[i], sizes[j], 0); + break; + case T_AEAD: + for (i = 0; i < naad_sizes; i++) { + for (j = 0; j < nsizes; j++) { + if (iv_size != 0) + run_test(alg, aad_sizes[i], sizes[j], + iv_size); + else if (testall) { + for (k = 0; alg->iv_sizes[k] != 0; k++) + run_test(alg, aad_sizes[i], + sizes[j], alg->iv_sizes[k]); + } else + run_test(alg, aad_sizes[i], sizes[j], + alg->iv_sizes[0]); + } + } break; } } @@ -1654,14 +1725,14 @@ main(int ac, char **av) char *cp; size_t base_size; u_int i; - bool testall; int ch; algname = NULL; requested_crid = CRYPTO_FLAG_HARDWARE; testall = false; verbose = false; - while ((ch = getopt(ac, av, "A:a:d:vz")) != -1) + iv_size = 0; + while ((ch = getopt(ac, av, "A:a:d:I:vz")) != -1) switch (ch) { case 'A': if (naad_sizes >= nitems(aad_sizes)) { @@ -1679,6 +1750,11 @@ main(int ac, char **av) case 'd': requested_crid = crlookup(optarg); break; + case 'I': + iv_size = strtol(optarg, &cp, 0); + if (*cp != '\0') + errx(1, "Bad IV size %s", optarg); + break; case 'v': verbose = true; break; From nobody Thu Oct 21 22:04:17 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BE97C1801469; Thu, 21 Oct 2021 22:04: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 4Hb1jG3dRFz3tf8; Thu, 21 Oct 2021 22:04: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 0502522C5E; Thu, 21 Oct 2021 22:04: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 19LM4HpN079554; Thu, 21 Oct 2021 22:04:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4HV3079553; Thu, 21 Oct 2021 22:04:17 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:17 GMT Message-Id: <202110212204.19LM4HV3079553@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: 4cce6043c7d9 - stable/13 - aesni: Support multiple nonce lengths for AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 4cce6043c7d9be191883ad3a7ed46e8e4a1709af Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4cce6043c7d9be191883ad3a7ed46e8e4a1709af commit 4cce6043c7d9be191883ad3a7ed46e8e4a1709af Author: John Baldwin AuthorDate: 2021-10-06 21:08:47 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:07:45 +0000 aesni: Support multiple nonce lengths for AES-CCM. Reviewed by: sef Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32112 (cherry picked from commit 8e6af6adfc2cc3d0ea89c20eaa5914e453c48b49) --- sys/crypto/aesni/aesni.c | 13 +++++++++---- sys/crypto/aesni/aesni_ccm.c | 32 ++++++++------------------------ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c index 4debbae12c2b..67dcef123429 100644 --- a/sys/crypto/aesni/aesni.c +++ b/sys/crypto/aesni/aesni.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 2005-2008 Pawel Jakub Dawidek * Copyright (c) 2010 Konstantin Belousov - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2014-2021 The FreeBSD Foundation * Copyright (c) 2017 Conrad Meyer * All rights reserved. * @@ -9,6 +9,9 @@ * under sponsorship of the FreeBSD Foundation and * Rubicon Communications, LLC (Netgate). * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -319,8 +322,7 @@ aesni_probesession(device_t dev, const struct crypto_session_params *csp) if (csp->csp_auth_mlen != 0 && csp->csp_auth_mlen != AES_CBC_MAC_HASH_LEN) return (EINVAL); - if (csp->csp_ivlen != AES_CCM_IV_LEN || - !sc->has_aes) + if (!sc->has_aes) return (EINVAL); break; default: @@ -639,9 +641,12 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptop *crp) csp = crypto_get_params(crp->crp_session); switch (csp->csp_cipher_alg) { + case CRYPTO_AES_CCM_16: + if (crp->crp_payload_length > ccm_max_payload_length(csp)) + return (EMSGSIZE); + /* FALLTHROUGH */ case CRYPTO_AES_ICM: case CRYPTO_AES_NIST_GCM_16: - case CRYPTO_AES_CCM_16: if ((crp->crp_flags & CRYPTO_F_IV_SEPARATE) == 0) return (EINVAL); break; diff --git a/sys/crypto/aesni/aesni_ccm.c b/sys/crypto/aesni/aesni_ccm.c index fc01e92c697f..9e2fa317b2ed 100644 --- a/sys/crypto/aesni/aesni_ccm.c +++ b/sys/crypto/aesni/aesni_ccm.c @@ -1,11 +1,15 @@ /*- - * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2014-2021 The FreeBSD Foundation * Copyright (c) 2018 iXsystems, Inc * All rights reserved. * - * This software was developed by John-Mark Gurney under - * the sponsorship of the FreeBSD Foundation and + * Portions of this software were developed by John-Mark Gurney + * under the sponsorship of the FreeBSD Foundation and * Rubicon Communications, LLC (Netgate). + * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -185,12 +189,7 @@ cbc_mac_start(const unsigned char *auth_data, size_t auth_len, * however, they're always truncated from 16 bytes, and the tag * length isn't passed in. (This could be fixed by changing the * code in aesni.c:aesni_cipher_crypt().) - * Similarly, although the nonce length is passed in, the - * OpenCrypto API that calls us doesn't have a way to set the nonce - * other than by having different crypto algorithm types. As a result, - * this is currently always called with nlen=12; this means that we - * also have a maximum message length of 16 megabytes. And similarly, - * since abytes is limited to a 32 bit value here, the AAD is + * Since abytes is limited to a 32 bit value here, the AAD is * limited to 4 gigabytes or less. */ void @@ -222,14 +221,6 @@ AES_CCM_encrypt(const unsigned char *in, unsigned char *out, */ L = sizeof(__m128i) - 1 - nlen; - /* - * Now, this shouldn't happen, but let's make sure that - * the data length isn't too big. - */ - KASSERT(nbytes <= ((1 << (8 * L)) - 1), - ("%s: nbytes is %u, but length field is %d bytes", - __FUNCTION__, nbytes, L)); - /* * Clear out the blocks */ @@ -399,13 +390,6 @@ AES_CCM_decrypt(const unsigned char *in, unsigned char *out, */ L = sizeof(__m128i) - 1 - nlen; - /* - * Now, this shouldn't happen, but let's make sure that - * the data length isn't too big. - */ - if (nbytes > ((1 << (8 * L)) - 1)) - panic("%s: nbytes is %u, but length field is %d bytes", - __FUNCTION__, nbytes, L); /* * Clear out the blocks */ From nobody Thu Oct 21 22:04:19 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 92BDF18012E0; Thu, 21 Oct 2021 22:04: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 4Hb1jH5NHqz3tcY; Thu, 21 Oct 2021 22:04: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 289722303E; Thu, 21 Oct 2021 22:04: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 19LM4JW8079578; Thu, 21 Oct 2021 22:04:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4JAj079577; Thu, 21 Oct 2021 22:04:19 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:19 GMT Message-Id: <202110212204.19LM4JAj079577@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: a5d3890803e6 - stable/13 - aesni: Handle requests with an empty payload. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: a5d3890803e6f8d6624976645ae456e754cc9d2c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a5d3890803e6f8d6624976645ae456e754cc9d2c commit a5d3890803e6f8d6624976645ae456e754cc9d2c Author: John Baldwin AuthorDate: 2021-10-06 21:08:47 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:07:56 +0000 aesni: Handle requests with an empty payload. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32113 (cherry picked from commit d718c2d3c805001db0b0ae0cc0c8a811b8a90a95) --- sys/crypto/aesni/aesni.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c index 67dcef123429..7d4dbd2c1604 100644 --- a/sys/crypto/aesni/aesni.c +++ b/sys/crypto/aesni/aesni.c @@ -700,28 +700,36 @@ aesni_cipher_crypt(struct aesni_session *ses, struct cryptop *crp, int error; bool encflag, allocated, authallocated, outallocated, outcopy; - buf = aesni_cipher_alloc(crp, crp->crp_payload_start, - crp->crp_payload_length, &allocated); - if (buf == NULL) - return (ENOMEM); + if (crp->crp_payload_length == 0) { + buf = NULL; + allocated = false; + } else { + buf = aesni_cipher_alloc(crp, crp->crp_payload_start, + crp->crp_payload_length, &allocated); + if (buf == NULL) + return (ENOMEM); + } outallocated = false; authallocated = false; authbuf = NULL; if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16 || csp->csp_cipher_alg == CRYPTO_AES_CCM_16) { - if (crp->crp_aad != NULL) + if (crp->crp_aad_length == 0) { + authbuf = NULL; + } else if (crp->crp_aad != NULL) { authbuf = crp->crp_aad; - else + } else { authbuf = aesni_cipher_alloc(crp, crp->crp_aad_start, crp->crp_aad_length, &authallocated); - if (authbuf == NULL) { - error = ENOMEM; - goto out; + if (authbuf == NULL) { + error = ENOMEM; + goto out; + } } } - if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { + if (CRYPTO_HAS_OUTPUT_BUFFER(crp) && crp->crp_payload_length > 0) { outbuf = crypto_buffer_contiguous_subsegment(&crp->crp_obuf, crp->crp_payload_output_start, crp->crp_payload_length); if (outbuf == NULL) { From nobody Thu Oct 21 22:04:21 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3E39F180178A; Thu, 21 Oct 2021 22:04: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 4Hb1jL3rkMz3thF; Thu, 21 Oct 2021 22:04: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 708A622F1A; Thu, 21 Oct 2021 22: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 19LM4L7T079632; Thu, 21 Oct 2021 22:04:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4LFg079631; Thu, 21 Oct 2021 22:04:21 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:21 GMT Message-Id: <202110212204.19LM4LFg079631@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: 082e7569cc89 - stable/13 - aesni: Support AES-CCM requests with a truncated tag. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 082e7569cc897fe28a537349691567f19e261ff1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=082e7569cc897fe28a537349691567f19e261ff1 commit 082e7569cc897fe28a537349691567f19e261ff1 Author: John Baldwin AuthorDate: 2021-10-06 21:08:48 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:08:12 +0000 aesni: Support AES-CCM requests with a truncated tag. Reviewed by: sef Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32115 (cherry picked from commit 655eb762c31044a791e8c8c6355515e7c89c07ef) --- sys/crypto/aesni/aesni.c | 18 +++++++++++------- sys/crypto/aesni/aesni.h | 8 ++++---- sys/crypto/aesni/aesni_ccm.c | 10 ++-------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c index 7d4dbd2c1604..de797abd1af5 100644 --- a/sys/crypto/aesni/aesni.c +++ b/sys/crypto/aesni/aesni.c @@ -319,9 +319,6 @@ aesni_probesession(device_t dev, const struct crypto_session_params *csp) CRYPTDEB("invalid CCM key length"); return (EINVAL); } - if (csp->csp_auth_mlen != 0 && - csp->csp_auth_mlen != AES_CBC_MAC_HASH_LEN) - return (EINVAL); if (!sc->has_aes) return (EINVAL); break; @@ -610,6 +607,11 @@ aesni_cipher_setup(struct aesni_session *ses, error = aesni_authprepare(ses, csp->csp_auth_klen); if (error != 0) return (error); + } else if (csp->csp_cipher_alg == CRYPTO_AES_CCM_16) { + if (csp->csp_auth_mlen == 0) + ses->mlen = AES_CBC_MAC_HASH_LEN; + else + ses->mlen = csp->csp_auth_mlen; } kt = is_fpu_kern_thread(0) || (csp->csp_cipher_alg == 0); @@ -809,15 +811,17 @@ aesni_cipher_crypt(struct aesni_session *ses, struct cryptop *crp, memset(tag, 0, sizeof(tag)); AES_CCM_encrypt(buf, outbuf, authbuf, iv, tag, crp->crp_payload_length, crp->crp_aad_length, - csp->csp_ivlen, ses->enc_schedule, ses->rounds); - crypto_copyback(crp, crp->crp_digest_start, sizeof(tag), + csp->csp_ivlen, ses->mlen, ses->enc_schedule, + ses->rounds); + crypto_copyback(crp, crp->crp_digest_start, ses->mlen, tag); } else { - crypto_copydata(crp, crp->crp_digest_start, sizeof(tag), + crypto_copydata(crp, crp->crp_digest_start, ses->mlen, tag); if (!AES_CCM_decrypt(buf, outbuf, authbuf, iv, tag, crp->crp_payload_length, crp->crp_aad_length, - csp->csp_ivlen, ses->enc_schedule, ses->rounds)) + csp->csp_ivlen, ses->mlen, ses->enc_schedule, + ses->rounds)) error = EBADMSG; } break; diff --git a/sys/crypto/aesni/aesni.h b/sys/crypto/aesni/aesni.h index 284bf6fba0fc..77ceec7b382a 100644 --- a/sys/crypto/aesni/aesni.h +++ b/sys/crypto/aesni/aesni.h @@ -112,12 +112,12 @@ int AES_GCM_decrypt(const unsigned char *in, unsigned char *out, /* CCM + CBC-MAC functions */ void AES_CCM_encrypt(const unsigned char *in, unsigned char *out, const unsigned char *addt, const unsigned char *ivec, - unsigned char *tag, uint32_t nbytes, uint32_t abytes, int ibytes, - const unsigned char *key, int nr); + unsigned char *tag, uint32_t nbytes, uint32_t abytes, int nlen, + int tag_length, const unsigned char *key, int nr); int AES_CCM_decrypt(const unsigned char *in, unsigned char *out, const unsigned char *addt, const unsigned char *ivec, - const unsigned char *tag, uint32_t nbytes, uint32_t abytes, int ibytes, - const unsigned char *key, int nr); + const unsigned char *tag, uint32_t nbytes, uint32_t abytes, int nlen, + int tag_length, const unsigned char *key, int nr); void aesni_cipher_setup_common(struct aesni_session *ses, const struct crypto_session_params *csp, const uint8_t *key, int keylen); diff --git a/sys/crypto/aesni/aesni_ccm.c b/sys/crypto/aesni/aesni_ccm.c index 34b61a633907..c7edaa0b9d5c 100644 --- a/sys/crypto/aesni/aesni_ccm.c +++ b/sys/crypto/aesni/aesni_ccm.c @@ -185,10 +185,6 @@ cbc_mac_start(const unsigned char *auth_data, size_t auth_len, * Implement AES CCM+CBC-MAC encryption and authentication. * * A couple of notes: - * The specification allows for a different number of tag lengths; - * however, they're always truncated from 16 bytes, and the tag - * length isn't passed in. (This could be fixed by changing the - * code in aesni.c:aesni_cipher_crypt().) * Since abytes is limited to a 32 bit value here, the AAD is * limited to 4 gigabytes or less. */ @@ -196,9 +192,8 @@ void AES_CCM_encrypt(const unsigned char *in, unsigned char *out, const unsigned char *addt, const unsigned char *nonce, unsigned char *tag, uint32_t nbytes, uint32_t abytes, int nlen, - const unsigned char *key, int nr) + int tag_length, const unsigned char *key, int nr) { - static const int tag_length = 16; /* 128 bits */ int L; int counter = 1; /* S0 has 0, S1 has 1 */ size_t copy_amt, total = 0; @@ -367,9 +362,8 @@ int AES_CCM_decrypt(const unsigned char *in, unsigned char *out, const unsigned char *addt, const unsigned char *nonce, const unsigned char *tag, uint32_t nbytes, uint32_t abytes, int nlen, - const unsigned char *key, int nr) + int tag_length, const unsigned char *key, int nr) { - static const int tag_length = 16; /* 128 bits */ int L; __m128i s0, rolling_mac, staging_block; uint8_t *byte_ptr; From nobody Thu Oct 21 22:04:20 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CAB66180137F; Thu, 21 Oct 2021 22:04: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 4Hb1jK20Jxz3tn5; Thu, 21 Oct 2021 22:04: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 51BEB22F9F; Thu, 21 Oct 2021 22:04: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 19LM4Ksv079602; Thu, 21 Oct 2021 22: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 19LM4K0E079601; Thu, 21 Oct 2021 22:04:20 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:20 GMT Message-Id: <202110212204.19LM4K0E079601@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: aacfe3bb52b7 - stable/13 - aesni: Permit AES-CCM requests with neither payload nor AAD. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: aacfe3bb52b7c489eab02d8bed49bd1b4da6f669 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=aacfe3bb52b7c489eab02d8bed49bd1b4da6f669 commit aacfe3bb52b7c489eab02d8bed49bd1b4da6f669 Author: John Baldwin AuthorDate: 2021-10-06 21:08:47 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:08:02 +0000 aesni: Permit AES-CCM requests with neither payload nor AAD. Reviewed by: sef Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32114 (cherry picked from commit c09c379c7aa7337680ff3cb73691ce12d627128b) --- sys/crypto/aesni/aesni_ccm.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sys/crypto/aesni/aesni_ccm.c b/sys/crypto/aesni/aesni_ccm.c index 9e2fa317b2ed..34b61a633907 100644 --- a/sys/crypto/aesni/aesni_ccm.c +++ b/sys/crypto/aesni/aesni_ccm.c @@ -205,9 +205,6 @@ AES_CCM_encrypt(const unsigned char *in, unsigned char *out, uint8_t *byte_ptr; __m128i s0, rolling_mac, s_x, staging_block; - if (nbytes == 0 && abytes == 0) - return; - /* NIST 800-38c section A.1 says n is [7, 13]. */ if (nlen < 7 || nlen > 13) panic("%s: bad nonce length %d", __FUNCTION__, nlen); @@ -377,8 +374,6 @@ AES_CCM_decrypt(const unsigned char *in, unsigned char *out, __m128i s0, rolling_mac, staging_block; uint8_t *byte_ptr; - if (nbytes == 0 && abytes == 0) - return (1); // No message means no decryption! if (nlen < 0 || nlen > 15) panic("%s: bad nonce length %d", __FUNCTION__, nlen); From nobody Thu Oct 21 22:04:22 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 91F381801698; Thu, 21 Oct 2021 22:04: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 4Hb1jM2qcHz3tNS; Thu, 21 Oct 2021 22:04: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 95BCD22E1E; Thu, 21 Oct 2021 22:04: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 19LM4M8i079656; Thu, 21 Oct 2021 22:04:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4M1B079655; Thu, 21 Oct 2021 22:04:22 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:22 GMT Message-Id: <202110212204.19LM4M1B079655@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: 61c8f61518c5 - stable/13 - ccr: Support multiple nonce lengths for AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 61c8f61518c5f230d76690cc57e01b6e735c760f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=61c8f61518c5f230d76690cc57e01b6e735c760f commit 61c8f61518c5f230d76690cc57e01b6e735c760f Author: John Baldwin AuthorDate: 2021-10-06 21:08:48 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:16:54 +0000 ccr: Support multiple nonce lengths for AES-CCM. Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32116 (cherry picked from commit 3e6a97b3a7bc80b1c12dd7b5208bfe99019c42b4) --- sys/dev/cxgbe/crypto/t4_crypto.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c index 33c03c3903e5..6d5f82f6857c 100644 --- a/sys/dev/cxgbe/crypto/t4_crypto.c +++ b/sys/dev/cxgbe/crypto/t4_crypto.c @@ -1528,17 +1528,18 @@ static void generate_ccm_b0(struct cryptop *crp, u_int hash_size_in_response, const char *iv, char *b0) { - u_int i, payload_len; + u_int i, payload_len, L; /* NB: L is already set in the first byte of the IV. */ memcpy(b0, iv, CCM_B0_SIZE); + L = iv[0] + 1; /* Set length of hash in bits 3 - 5. */ b0[0] |= (((hash_size_in_response - 2) / 2) << 3); /* Store the payload length as a big-endian value. */ payload_len = crp->crp_payload_length; - for (i = 0; i < iv[0]; i++) { + for (i = 0; i < L; i++) { b0[CCM_CBC_BLOCK_LEN - 1 - i] = payload_len; payload_len >>= 8; } @@ -1559,6 +1560,7 @@ static int ccr_ccm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) { char iv[CHCR_MAX_CRYPTO_IV_LEN]; + const struct crypto_session_params *csp; struct ulptx_idata *idata; struct chcr_wr *crwr; struct wrqe *wr; @@ -1571,6 +1573,8 @@ ccr_ccm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) int sgl_nsegs, sgl_len; int error; + csp = crypto_get_params(crp->crp_session); + if (s->blkcipher.key_len == 0) return (EINVAL); @@ -1581,6 +1585,10 @@ ccr_ccm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) if (crp->crp_payload_length == 0) return (EMSGSIZE); + /* The length has to fit within the length field in block 0. */ + if (crp->crp_payload_length > ccm_max_payload_length(csp)) + return (EMSGSIZE); + /* * CCM always includes block 0 in the AAD before AAD from the * request. @@ -1598,9 +1606,8 @@ ccr_ccm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) return (EINVAL); /* - * Always assume a 12 byte input nonce for now since that is - * what OCF always generates. The full IV in the work request - * is 16 bytes. + * The IV in the work request is 16 bytes and not just the + * nonce. */ iv_len = AES_BLOCK_LEN; @@ -1745,7 +1752,7 @@ ccr_ccm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) * the full IV with the counter set to 0. */ memset(iv, 0, iv_len); - iv[0] = (15 - AES_CCM_IV_LEN) - 1; + iv[0] = (15 - csp->csp_ivlen) - 1; crypto_read_iv(crp, iv + 1); ccr_populate_wreq(sc, s, crwr, kctx_len, wr_len, imm_len, sgl_len, 0, @@ -1868,6 +1875,7 @@ ccr_ccm_done(struct ccr_softc *sc, struct ccr_session *s, static void ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) { + const struct crypto_session_params *csp; struct auth_hash *axf; struct enc_xform *exf; union authctx *auth_ctx; @@ -1879,6 +1887,12 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) auth_ctx = NULL; kschedule = NULL; + csp = crypto_get_params(crp->crp_session); + if (crp->crp_payload_length > ccm_max_payload_length(csp)) { + error = EMSGSIZE; + goto out; + } + /* Initialize the MAC. */ switch (s->blkcipher.key_len) { case 16: @@ -1921,7 +1935,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) auth_ctx->aes_cbc_mac_ctx.authDataLength = crp->crp_aad_length; auth_ctx->aes_cbc_mac_ctx.cryptDataLength = crp->crp_payload_length; - axf->Reinit(auth_ctx, crp->crp_iv, AES_CCM_IV_LEN); + axf->Reinit(auth_ctx, crp->crp_iv, csp->csp_ivlen); /* MAC the AAD. */ if (crp->crp_aad != NULL) @@ -1933,7 +1947,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) if (error) goto out; - exf->reinit(kschedule, crp->crp_iv, AES_CCM_IV_LEN); + exf->reinit(kschedule, crp->crp_iv, csp->csp_ivlen); /* Do encryption/decryption with MAC */ for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { @@ -1968,7 +1982,7 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) error = 0; /* Tag matches, decrypt data. */ - exf->reinit(kschedule, crp->crp_iv, AES_CCM_IV_LEN); + exf->reinit(kschedule, crp->crp_iv, csp->csp_ivlen); for (i = 0; i < crp->crp_payload_length; i += sizeof(block)) { len = imin(crp->crp_payload_length - i, @@ -2445,8 +2459,6 @@ ccr_probesession(device_t dev, const struct crypto_session_params *csp) return (EINVAL); break; case CRYPTO_AES_CCM_16: - if (csp->csp_ivlen != AES_CCM_IV_LEN) - return (EINVAL); if (csp->csp_auth_mlen < 0 || csp->csp_auth_mlen > AES_CBC_MAC_HASH_LEN) return (EINVAL); From nobody Thu Oct 21 22:04:24 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 78BD218016BB; Thu, 21 Oct 2021 22:04: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 4Hb1jR2FPxz3tfw; Thu, 21 Oct 2021 22:04: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 EC5912303F; Thu, 21 Oct 2021 22:04: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 19LM4OEQ079704; Thu, 21 Oct 2021 22:04:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4Ohx079703; Thu, 21 Oct 2021 22:04:24 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:24 GMT Message-Id: <202110212204.19LM4Ohx079703@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: cfa1d2c9b987 - stable/13 - safexcel: Support multiple nonce lengths for AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: cfa1d2c9b9876bc97322cd4e68bf10fbd0b0b6d4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cfa1d2c9b9876bc97322cd4e68bf10fbd0b0b6d4 commit cfa1d2c9b9876bc97322cd4e68bf10fbd0b0b6d4 Author: John Baldwin AuthorDate: 2021-10-06 21:08:48 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:17:14 +0000 safexcel: Support multiple nonce lengths for AES-CCM. Reviewed by: markj Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32118 (cherry picked from commit 2ec2e4df094ba632e5e74268a8818f71903a4537) --- sys/dev/safexcel/safexcel.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/dev/safexcel/safexcel.c b/sys/dev/safexcel/safexcel.c index 71300dcb0393..9a9b0ab0cb74 100644 --- a/sys/dev/safexcel/safexcel.c +++ b/sys/dev/safexcel/safexcel.c @@ -2,6 +2,10 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2020, 2021 Rubicon Communications, LLC (Netgate) + * Copyright (c) 2021 The FreeBSD Foundation + * + * Portions of this software were developed by Ararat River + * Consulting, LLC under sponsorship of the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1689,12 +1693,14 @@ static void safexcel_instr_ccm(struct safexcel_request *req, struct safexcel_instr *instr, struct safexcel_cmd_descr *cdesc) { + const struct crypto_session_params *csp; struct cryptop *crp; struct safexcel_instr *start; uint8_t *a0, *b0, *alenp, L; int aalign, blen; crp = req->crp; + csp = crypto_get_params(crp->crp_session); start = instr; /* @@ -1703,17 +1709,17 @@ safexcel_instr_ccm(struct safexcel_request *req, struct safexcel_instr *instr, * descriptor, and B0 is inserted directly into the data stream using * instructions below. * - * OCF seems to assume a 12-byte IV, fixing L (the payload length size) - * at 3 bytes due to the layout of B0. This is fine since the driver - * has a maximum of 65535 bytes anyway. + * An explicit check for overflow of the length field is not + * needed since the maximum driver size of 65535 bytes fits in + * the smallest length field used for a 13-byte nonce. */ blen = AES_BLOCK_LEN; - L = 3; + L = 15 - csp->csp_ivlen; a0 = (uint8_t *)&cdesc->control_data.token[0]; memset(a0, 0, blen); a0[0] = L - 1; - memcpy(&a0[1], req->iv, AES_CCM_IV_LEN); + memcpy(&a0[1], req->iv, csp->csp_ivlen); /* * Insert B0 and the AAD length into the input stream. @@ -1731,7 +1737,7 @@ safexcel_instr_ccm(struct safexcel_request *req, struct safexcel_instr *instr, (L - 1) | /* payload length size */ ((CCM_CBC_MAX_DIGEST_LEN - 2) / 2) << 3 /* digest length */ | (crp->crp_aad_length > 0 ? 1 : 0) << 6 /* AAD present bit */; - memcpy(&b0[1], req->iv, AES_CCM_IV_LEN); + memcpy(&b0[1], req->iv, csp->csp_ivlen); b0[14] = crp->crp_payload_length >> 8; b0[15] = crp->crp_payload_length & 0xff; instr += blen / sizeof(*instr); @@ -2308,7 +2314,8 @@ safexcel_probesession(device_t dev, const struct crypto_session_params *csp) return (EINVAL); break; case CRYPTO_AES_CCM_16: - if (csp->csp_ivlen != AES_CCM_IV_LEN) + if (csp->csp_auth_mlen != 0 && + csp->csp_auth_mlen != AES_CBC_MAC_HASH_LEN) return (EINVAL); break; default: From nobody Thu Oct 21 22:04:23 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C8C8C180163C; Thu, 21 Oct 2021 22:04: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 4Hb1jP1mNHz3tWR; Thu, 21 Oct 2021 22:04: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 C0FFF22C5F; Thu, 21 Oct 2021 22:04: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 19LM4N10079680; Thu, 21 Oct 2021 22:04:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4Nbk079679; Thu, 21 Oct 2021 22:04:23 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:23 GMT Message-Id: <202110212204.19LM4Nbk079679@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: 12d5e71fb5c3 - stable/13 - ccr: Support AES-CCM requests with truncated tags. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 12d5e71fb5c35113ca0ead049f7285a4e6fab30f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=12d5e71fb5c35113ca0ead049f7285a4e6fab30f commit 12d5e71fb5c35113ca0ead049f7285a4e6fab30f Author: John Baldwin AuthorDate: 2021-10-06 21:08:48 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:17:09 +0000 ccr: Support AES-CCM requests with truncated tags. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32117 (cherry picked from commit e148e407df5c8b1c83bcd44da9f4837d94431d02) --- sys/dev/cxgbe/crypto/t4_crypto.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c index 6d5f82f6857c..24287638b376 100644 --- a/sys/dev/cxgbe/crypto/t4_crypto.c +++ b/sys/dev/cxgbe/crypto/t4_crypto.c @@ -1524,6 +1524,29 @@ out: crypto_done(crp); } +static int +ccr_ccm_hmac_ctrl(unsigned int authsize) +{ + switch (authsize) { + case 4: + return (SCMD_HMAC_CTRL_PL1); + case 6: + return (SCMD_HMAC_CTRL_PL2); + case 8: + return (SCMD_HMAC_CTRL_DIV2); + case 10: + return (SCMD_HMAC_CTRL_TRUNC_RFC4366); + case 12: + return (SCMD_HMAC_CTRL_IPSEC_96BIT); + case 14: + return (SCMD_HMAC_CTRL_PL3); + case 16: + return (SCMD_HMAC_CTRL_NO_TRUNC); + default: + __assert_unreachable(); + } +} + static void generate_ccm_b0(struct cryptop *crp, u_int hash_size_in_response, const char *iv, char *b0) @@ -1783,7 +1806,7 @@ ccr_ccm(struct ccr_softc *sc, struct ccr_session *s, struct cryptop *crp) V_CPL_TX_SEC_PDU_AUTHINSERT(auth_insert)); /* These two flits are actually a CPL_TLS_TX_SCMD_FMT. */ - hmac_ctrl = ccr_hmac_ctrl(AES_CBC_MAC_HASH_LEN, hash_size_in_response); + hmac_ctrl = ccr_ccm_hmac_ctrl(hash_size_in_response); crwr->sec_cpl.seqno_numivs = htobe32( V_SCMD_SEQ_NO_CTRL(0) | V_SCMD_PROTO_VERSION(SCMD_PROTO_VERSION_GENERIC) | @@ -2459,9 +2482,6 @@ ccr_probesession(device_t dev, const struct crypto_session_params *csp) return (EINVAL); break; case CRYPTO_AES_CCM_16: - if (csp->csp_auth_mlen < 0 || - csp->csp_auth_mlen > AES_CBC_MAC_HASH_LEN) - return (EINVAL); break; default: return (EINVAL); From nobody Thu Oct 21 22:04:28 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1E2051801992; Thu, 21 Oct 2021 22:04: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 4Hb1jW2ndKz3tgX; Thu, 21 Oct 2021 22:04: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 524EC22E1F; Thu, 21 Oct 2021 22:04: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 19LM4Ska079782; Thu, 21 Oct 2021 22:04:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4SRc079781; Thu, 21 Oct 2021 22:04:28 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:28 GMT Message-Id: <202110212204.19LM4SRc079781@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: dffa7f13db78 - stable/13 - crypto: Test all of the AES-CCM KAT vectors. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: dffa7f13db7855941b270caa6fc5ec72becb07bc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=dffa7f13db7855941b270caa6fc5ec72becb07bc commit dffa7f13db7855941b270caa6fc5ec72becb07bc Author: John Baldwin AuthorDate: 2021-10-06 21:08:48 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:19:24 +0000 crypto: Test all of the AES-CCM KAT vectors. Previously, only test vectors which used the default nonce and tag sizes (12 and 16, respectively) were tested. This now tests all of the vectors. This exposed some additional issues around requests with an empty payload (which wasn't supported) and an empty AAD (which falls back to CIOCCRYPT instead of CIOCCRYPTAEAD). - Make use of the 'ivlen' and 'maclen' fields for CIOGSESSION2 to test AES-CCM vectors with non-default nonce and tag lengths. - Permit requests with an empty payload. - Permit an input MAC for requests without AAD. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32121 (cherry picked from commit 668770dc7de2ec8b5f5edf71e09b8a404120f6fa) --- tests/sys/opencrypto/cryptodev.py | 54 +++++++++++++++++++++++++++----------- tests/sys/opencrypto/cryptotest.py | 41 ++++++++++++----------------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/tests/sys/opencrypto/cryptodev.py b/tests/sys/opencrypto/cryptodev.py index 83d14fc2b205..d97a731d37ba 100644 --- a/tests/sys/opencrypto/cryptodev.py +++ b/tests/sys/opencrypto/cryptodev.py @@ -79,10 +79,10 @@ class SessionOp2(dpkt.Packet): ('mackey', 'P', 0), ('ses', 'I', 0), ('crid', 'i', 0), + ('ivlen', 'i', 0), + ('maclen', 'i', 0), ('pad0', 'i', 0), ('pad1', 'i', 0), - ('pad2', 'i', 0), - ('pad3', 'i', 0), ) class CryptOp(dpkt.Packet): @@ -159,6 +159,11 @@ def array_tobytes(array_obj): return array_obj.tobytes() return array_obj.tostring() +def empty_bytes(): + if sys.version_info[0] >= 3: + return b'' + return "" + class Crypto: @staticmethod def findcrid(name): @@ -169,7 +174,8 @@ class Crypto: return _findop(crid, '')[1] def __init__(self, cipher=0, key=None, mac=0, mackey=None, - crid=CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE, maclen=None): + crid=CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE, maclen=None, + ivlen=None): self._ses = None self._maclen = maclen ses = SessionOp2() @@ -191,6 +197,10 @@ class Crypto: if not cipher and not mac: raise ValueError('one of cipher or mac MUST be specified.') ses.crid = crid + if ivlen: + ses.ivlen = ivlen + if maclen: + ses.maclen = maclen #print(ses) s = array.array('B', ses.pack_hdr()) #print(s) @@ -209,16 +219,23 @@ class Crypto: pass self._ses = None - def _doop(self, op, src, iv): + def _doop(self, op, src, iv, mac=None): cop = CryptOp() cop.ses = self._ses cop.op = op cop.flags = 0 - cop.len = len(src) - s = array.array('B', src) - cop.src = cop.dst = s.buffer_info()[0] + if src is not None: + cop.len = len(src) + s = array.array('B', src) + cop.src = cop.dst = s.buffer_info()[0] + if mac is not None: + assert len(mac) == self._maclen, \ + '%d != %d' % (len(tag), self._maclen) if self._maclen is not None: - m = array.array('B', [0] * self._maclen) + if mac is None: + m = array.array('B', [0] * self._maclen) + else: + m = array.array('B', mac) cop.mac = m.buffer_info()[0] ivbuf = array.array('B', str_to_ascii(iv)) cop.iv = ivbuf.buffer_info()[0] @@ -226,7 +243,10 @@ class Crypto: #print('cop:', cop) ioctl(_cryptodev, CIOCCRYPT, bytes(cop)) - s = array_tobytes(s) + if src is not None: + s = array_tobytes(s) + else: + s = empty_bytes() if self._maclen is not None: return s, array_tobytes(m) @@ -238,10 +258,11 @@ class Crypto: caead.op = op caead.flags = CRD_F_IV_EXPLICIT caead.flags = 0 - src = str_to_ascii(src) - caead.len = len(src) - s = array.array('B', src) - caead.src = caead.dst = s.buffer_info()[0] + if src is not None and len(src) != 0: + src = str_to_ascii(src) + caead.len = len(src) + s = array.array('B', src) + caead.src = caead.dst = s.buffer_info()[0] aad = str_to_ascii(aad) caead.aadlen = len(aad) saad = array.array('B', aad) @@ -266,7 +287,10 @@ class Crypto: ioctl(_cryptodev, CIOCCRYPTAEAD, bytes(caead)) - s = array_tobytes(s) + if src is not None: + s = array_tobytes(s) + else: + s = empty_bytes() return s, array_tobytes(tag) @@ -320,7 +344,7 @@ class Crypto: def decrypt(self, data, iv, aad=None, tag=None): if aad is None: - return self._doop(COP_DECRYPT, data, iv) + return self._doop(COP_DECRYPT, data, iv, mac=tag) else: return self._doaead(COP_DECRYPT, data, aad, iv, tag=tag) diff --git a/tests/sys/opencrypto/cryptotest.py b/tests/sys/opencrypto/cryptotest.py index 2ef423ac1505..74ce62cee33d 100644 --- a/tests/sys/opencrypto/cryptotest.py +++ b/tests/sys/opencrypto/cryptotest.py @@ -243,25 +243,26 @@ def GenTestCase(cname): def runCCMEncryptWithParser(self, parser): for data in next(parser): Nlen = int(data['Nlen']) - if Nlen != 12: - # OCF only supports 12 byte IVs - continue + Tlen = int(data['Tlen']) key = binascii.unhexlify(data['Key']) nonce = binascii.unhexlify(data['Nonce']) Alen = int(data['Alen']) + Plen = int(data['Plen']) if Alen != 0: aad = binascii.unhexlify(data['Adata']) else: aad = None - payload = binascii.unhexlify(data['Payload']) + if Plen != 0: + payload = binascii.unhexlify(data['Payload']) + else: + payload = None ct = binascii.unhexlify(data['CT']) try: c = Crypto(crid=crid, cipher=cryptodev.CRYPTO_AES_CCM_16, key=key, - mac=cryptodev.CRYPTO_AES_CCM_CBC_MAC, - mackey=key, maclen=16) + mackey=key, maclen=Tlen, ivlen=Nlen) r, tag = Crypto.encrypt(c, payload, nonce, aad) except EnvironmentError as e: @@ -280,36 +281,29 @@ def GenTestCase(cname): self.runCCMDecryptWithParser(parser) def runCCMDecryptWithParser(self, parser): - # XXX: Note that all of the current CCM - # decryption test vectors use IV and tag sizes - # that aren't supported by OCF none of the - # tests are actually ran. for data in next(parser): Nlen = int(data['Nlen']) - if Nlen != 12: - # OCF only supports 12 byte IVs - continue Tlen = int(data['Tlen']) - if Tlen != 16: - # OCF only supports 16 byte tags - continue key = binascii.unhexlify(data['Key']) nonce = binascii.unhexlify(data['Nonce']) Alen = int(data['Alen']) + Plen = int(data['Plen']) if Alen != 0: aad = binascii.unhexlify(data['Adata']) else: aad = None ct = binascii.unhexlify(data['CT']) - tag = ct[-16:] - ct = ct[:-16] + tag = ct[-Tlen:] + if Plen != 0: + payload = ct[:-Tlen] + else: + payload = None try: c = Crypto(crid=crid, cipher=cryptodev.CRYPTO_AES_CCM_16, key=key, - mac=cryptodev.CRYPTO_AES_CCM_CBC_MAC, - mackey=key, maclen=16) + mackey=key, maclen=Tlen, ivlen=Nlen) except EnvironmentError as e: if e.errno != errno.EOPNOTSUPP: raise @@ -319,12 +313,11 @@ def GenTestCase(cname): self.assertRaises(IOError, c.decrypt, payload, nonce, aad, tag) else: - r = Crypto.decrypt(c, payload, nonce, - aad, tag) + r, tag = Crypto.decrypt(c, payload, nonce, + aad, tag) payload = binascii.unhexlify(data['Payload']) - plen = int(data('Plen')) - payload = payload[:plen] + payload = payload[:Plen] self.assertEqual(r, payload, "Count " + data['Count'] + \ " Actual: " + repr(binascii.hexlify(r)) + \ From nobody Thu Oct 21 22:04:27 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3674018018D5; Thu, 21 Oct 2021 22:04: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 4Hb1jV1Ycyz3tnn; Thu, 21 Oct 2021 22:04: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 3C15322F1B; Thu, 21 Oct 2021 22:04: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 19LM4Rew079758; Thu, 21 Oct 2021 22:04:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4RID079757; Thu, 21 Oct 2021 22:04:27 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:27 GMT Message-Id: <202110212204.19LM4RID079757@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: 9039a0fae46e - stable/13 - cryptosoft: Fix support for variable tag lengths in AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 9039a0fae46e7a63c5c09890d46f987dc8320d80 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9039a0fae46e7a63c5c09890d46f987dc8320d80 commit 9039a0fae46e7a63c5c09890d46f987dc8320d80 Author: John Baldwin AuthorDate: 2021-10-06 21:08:48 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:19:04 +0000 cryptosoft: Fix support for variable tag lengths in AES-CCM. The tag length is included as one of the values in the flags byte of block 0 passed to CBC_MAC, so merely copying the first N bytes is insufficient. To avoid adding more sideband data to the CBC MAC software context, pull the generation of block 0, the AAD length, and AAD padding out of cbc_mac.c and into cryptosoft.c. This matches how GCM/GMAC are handled where the length block is constructed in cryptosoft.c and passed as an input to the Update callback. As a result, the CBC MAC Update() routine is now much simpler and simply performs the XOR-and-encrypt step on each input block. While here, avoid a copy to the staging block in the Update routine when one or more full blocks are passed as input to the Update callback. Reviewed by: sef Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32120 (cherry picked from commit 4361c4eb6e3620e68d005c1671fdbf60b1fe83c6) --- sys/dev/cxgbe/crypto/t4_crypto.c | 107 ++++++++++++++++++++------ sys/opencrypto/cbc_mac.c | 157 ++++++--------------------------------- sys/opencrypto/cbc_mac.h | 6 +- sys/opencrypto/cryptosoft.c | 124 +++++++++++++++++++++++-------- 4 files changed, 205 insertions(+), 189 deletions(-) diff --git a/sys/dev/cxgbe/crypto/t4_crypto.c b/sys/dev/cxgbe/crypto/t4_crypto.c index 24287638b376..885271d82de0 100644 --- a/sys/dev/cxgbe/crypto/t4_crypto.c +++ b/sys/dev/cxgbe/crypto/t4_crypto.c @@ -1893,8 +1893,60 @@ ccr_ccm_done(struct ccr_softc *sc, struct ccr_session *s, /* * Handle a CCM request that is not supported by the crypto engine by - * performing the operation in software. Derived from swcr_authenc(). + * performing the operation in software. Derived from swcr_ccm(). */ +static void +build_ccm_b0(const char *nonce, u_int nonce_length, u_int aad_length, + u_int data_length, u_int tag_length, uint8_t *b0) +{ + uint8_t *bp; + uint8_t flags, L; + + KASSERT(nonce_length >= 7 && nonce_length <= 13, + ("nonce_length must be between 7 and 13 bytes")); + + /* + * Need to determine the L field value. This is the number of + * bytes needed to specify the length of the message; the length + * is whatever is left in the 16 bytes after specifying flags and + * the nonce. + */ + L = 15 - nonce_length; + + flags = ((aad_length > 0) << 6) + + (((tag_length - 2) / 2) << 3) + + L - 1; + + /* + * Now we need to set up the first block, which has flags, nonce, + * and the message length. + */ + b0[0] = flags; + memcpy(b0 + 1, nonce, nonce_length); + bp = b0 + 1 + nonce_length; + + /* Need to copy L' [aka L-1] bytes of data_length */ + for (uint8_t *dst = b0 + CCM_CBC_BLOCK_LEN - 1; dst >= bp; dst--) { + *dst = data_length; + data_length >>= 8; + } +} + +/* NB: OCF only supports AAD lengths < 2^32. */ +static int +build_ccm_aad_length(u_int aad_length, uint8_t *blk) +{ + if (aad_length < ((1 << 16) - (1 << 8))) { + be16enc(blk, aad_length); + return (sizeof(uint16_t)); + } else { + blk[0] = 0xff; + blk[1] = 0xfe; + be32enc(blk + 2, aad_length); + return (2 + sizeof(uint32_t)); + } +} + static void ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) { @@ -1904,11 +1956,13 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) union authctx *auth_ctx; void *kschedule; char block[CCM_CBC_BLOCK_LEN]; - char digest[AES_CBC_MAC_HASH_LEN]; + char tag[AES_CBC_MAC_HASH_LEN]; + u_int taglen; int error, i, len; auth_ctx = NULL; kschedule = NULL; + taglen = s->ccm_mac.hash_len; csp = crypto_get_params(crp->crp_session); if (crp->crp_payload_length > ccm_max_payload_length(csp)) { @@ -1956,19 +2010,32 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) goto out; } - auth_ctx->aes_cbc_mac_ctx.authDataLength = crp->crp_aad_length; - auth_ctx->aes_cbc_mac_ctx.cryptDataLength = crp->crp_payload_length; axf->Reinit(auth_ctx, crp->crp_iv, csp->csp_ivlen); + /* Supply MAC with b0. */ + build_ccm_b0(crp->crp_iv, csp->csp_ivlen, crp->crp_aad_length, + crp->crp_payload_length, taglen, block); + axf->Update(auth_ctx, block, CCM_CBC_BLOCK_LEN); + /* MAC the AAD. */ - if (crp->crp_aad != NULL) - error = axf->Update(auth_ctx, crp->crp_aad, - crp->crp_aad_length); - else - error = crypto_apply(crp, crp->crp_aad_start, - crp->crp_aad_length, axf->Update, auth_ctx); - if (error) - goto out; + if (crp->crp_aad_length != 0) { + len = build_ccm_aad_length(crp->crp_aad_length, block); + axf->Update(auth_ctx, block, len); + if (crp->crp_aad != NULL) + axf->Update(auth_ctx, crp->crp_aad, + crp->crp_aad_length); + else + crypto_apply(crp, crp->crp_aad_start, + crp->crp_aad_length, axf->Update, auth_ctx); + + /* Pad the AAD (including length field) to a full block. */ + len = (len + crp->crp_aad_length) % CCM_CBC_BLOCK_LEN; + if (len != 0) { + len = CCM_CBC_BLOCK_LEN - len; + memset(block, 0, CCM_CBC_BLOCK_LEN); + axf->Update(auth_ctx, block, len); + } + } exf->reinit(kschedule, crp->crp_iv, csp->csp_ivlen); @@ -1989,19 +2056,17 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) } /* Finalize MAC. */ - axf->Final(digest, auth_ctx); + axf->Final(tag, auth_ctx); /* Inject or validate tag. */ if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { - crypto_copyback(crp, crp->crp_digest_start, sizeof(digest), - digest); + crypto_copyback(crp, crp->crp_digest_start, taglen, tag); error = 0; } else { - char digest2[AES_CBC_MAC_HASH_LEN]; + char tag2[AES_CBC_MAC_HASH_LEN]; - crypto_copydata(crp, crp->crp_digest_start, sizeof(digest2), - digest2); - if (timingsafe_bcmp(digest, digest2, sizeof(digest)) == 0) { + crypto_copydata(crp, crp->crp_digest_start, taglen, tag2); + if (timingsafe_bcmp(tag, tag2, taglen) == 0) { error = 0; /* Tag matches, decrypt data. */ @@ -2019,14 +2084,14 @@ ccr_ccm_soft(struct ccr_session *s, struct cryptop *crp) } } else error = EBADMSG; - explicit_bzero(digest2, sizeof(digest2)); + explicit_bzero(tag2, sizeof(tag2)); } out: zfree(kschedule, M_CCR); zfree(auth_ctx, M_CCR); explicit_bzero(block, sizeof(block)); - explicit_bzero(digest, sizeof(digest)); + explicit_bzero(tag, sizeof(tag)); crp->crp_etype = error; crypto_done(crp); } diff --git a/sys/opencrypto/cbc_mac.c b/sys/opencrypto/cbc_mac.c index 40afae5373bf..9a030cd54173 100644 --- a/sys/opencrypto/cbc_mac.c +++ b/sys/opencrypto/cbc_mac.c @@ -75,85 +75,23 @@ AES_CBC_MAC_Setkey(void *vctx, const uint8_t *key, u_int klen) /* * This is called to set the nonce, aka IV. - * Before this call, the authDataLength and cryptDataLength fields - * MUST have been set. Sadly, there's no way to return an error. * - * The CBC-MAC algorithm requires that the first block contain the - * nonce, as well as information about the sizes and lengths involved. + * Note that the caller is responsible for constructing b0 as well + * as the length and padding around the AAD and passing that data + * to _Update. */ void AES_CBC_MAC_Reinit(void *vctx, const uint8_t *nonce, u_int nonceLen) { struct aes_cbc_mac_ctx *ctx = vctx; - uint8_t b0[CCM_CBC_BLOCK_LEN]; - uint8_t *bp = b0, flags = 0; - uint8_t L = 0; - uint64_t dataLength = ctx->cryptDataLength; - - KASSERT(nonceLen >= 7 && nonceLen <= 13, - ("nonceLen must be between 7 and 13 bytes")); ctx->nonce = nonce; ctx->nonceLength = nonceLen; - - ctx->authDataCount = 0; + ctx->blockIndex = 0; - explicit_bzero(ctx->staging_block, sizeof(ctx->staging_block)); - - /* - * Need to determine the L field value. This is the number of - * bytes needed to specify the length of the message; the length - * is whatever is left in the 16 bytes after specifying flags and - * the nonce. - */ - L = 15 - nonceLen; - - flags = ((ctx->authDataLength > 0) << 6) + - (((AES_CBC_MAC_HASH_LEN - 2) / 2) << 3) + - L - 1; - /* - * Now we need to set up the first block, which has flags, nonce, - * and the message length. - */ - b0[0] = flags; - bcopy(nonce, b0 + 1, nonceLen); - bp = b0 + 1 + nonceLen; - /* Need to copy L' [aka L-1] bytes of cryptDataLength */ - for (uint8_t *dst = b0 + sizeof(b0) - 1; dst >= bp; dst--) { - *dst = dataLength; - dataLength >>= 8; - } - /* Now need to encrypt b0 */ - rijndaelEncrypt(ctx->keysched, ctx->rounds, b0, ctx->block); - /* If there is auth data, we need to set up the staging block */ - if (ctx->authDataLength) { - size_t addLength; - if (ctx->authDataLength < ((1<<16) - (1<<8))) { - uint16_t sizeVal = htobe16(ctx->authDataLength); - bcopy(&sizeVal, ctx->staging_block, sizeof(sizeVal)); - addLength = sizeof(sizeVal); - } else if (ctx->authDataLength < (1ULL<<32)) { - uint32_t sizeVal = htobe32(ctx->authDataLength); - ctx->staging_block[0] = 0xff; - ctx->staging_block[1] = 0xfe; - bcopy(&sizeVal, ctx->staging_block+2, sizeof(sizeVal)); - addLength = 2 + sizeof(sizeVal); - } else { - uint64_t sizeVal = htobe64(ctx->authDataLength); - ctx->staging_block[0] = 0xff; - ctx->staging_block[1] = 0xff; - bcopy(&sizeVal, ctx->staging_block+2, sizeof(sizeVal)); - addLength = 2 + sizeof(sizeVal); - } - ctx->blockIndex = addLength; - /* - * The length descriptor goes into the AAD buffer, so we - * need to account for it. - */ - ctx->authDataLength += addLength; - ctx->authDataCount = addLength; - } + /* XOR b0 with all 0's on first call to _Update. */ + memset(ctx->block, 0, CCM_CBC_BLOCK_LEN); } int @@ -167,85 +105,35 @@ AES_CBC_MAC_Update(void *vctx, const void *vdata, u_int length) data = vdata; /* - * This will be called in one of two phases: - * (1) Applying authentication data, or - * (2) Applying the payload data. - * - * Because CBC-MAC puts the authentication data size before the - * data, subsequent calls won't be block-size-aligned. Which - * complicates things a fair bit. - * - * The payload data doesn't have that problem. + * _Update can be called with non-aligned update lengths. Use + * the staging block when necessary. */ - - if (ctx->authDataCount < ctx->authDataLength) { - /* - * We need to process data as authentication data. - * Since we may be out of sync, we may also need - * to pad out the staging block. - */ - const uint8_t *ptr = data; - while (length > 0) { - - copy_amt = MIN(length, - sizeof(ctx->staging_block) - ctx->blockIndex); - - bcopy(ptr, ctx->staging_block + ctx->blockIndex, - copy_amt); - ptr += copy_amt; - length -= copy_amt; - ctx->authDataCount += copy_amt; - ctx->blockIndex += copy_amt; - ctx->blockIndex %= sizeof(ctx->staging_block); + while (length != 0) { + uint8_t *ptr; - if (ctx->blockIndex == 0 || - ctx->authDataCount == ctx->authDataLength) { - /* - * We're done with this block, so we - * xor staging_block with block, and then - * encrypt it. - */ - xor_and_encrypt(ctx, ctx->staging_block, ctx->block); - bzero(ctx->staging_block, sizeof(ctx->staging_block)); - ctx->blockIndex = 0; - if (ctx->authDataCount >= ctx->authDataLength) - break; - } - } /* - * We'd like to be able to check length == 0 and return - * here, but the way OCF calls us, length is always - * blksize (16, in this case). So we have to count on - * the fact that OCF calls us separately for the AAD and - * for the real data. + * If there is no partial block and the length is at + * least a full block, encrypt the full block without + * copying to the staging block. */ - return (0); - } - /* - * If we're here, then we're encoding payload data. - * This is marginally easier, except that _Update can - * be called with non-aligned update lengths. As a result, - * we still need to use the staging block. - */ - KASSERT((length + ctx->cryptDataCount) <= ctx->cryptDataLength, - ("More encryption data than allowed")); + if (ctx->blockIndex == 0 && length >= CCM_CBC_BLOCK_LEN) { + xor_and_encrypt(ctx, data, ctx->block); + length -= CCM_CBC_BLOCK_LEN; + data += CCM_CBC_BLOCK_LEN; + continue; + } - while (length) { - uint8_t *ptr; - copy_amt = MIN(sizeof(ctx->staging_block) - ctx->blockIndex, length); ptr = ctx->staging_block + ctx->blockIndex; bcopy(data, ptr, copy_amt); data += copy_amt; ctx->blockIndex += copy_amt; - ctx->cryptDataCount += copy_amt; length -= copy_amt; if (ctx->blockIndex == sizeof(ctx->staging_block)) { /* We've got a full block */ xor_and_encrypt(ctx, ctx->staging_block, ctx->block); ctx->blockIndex = 0; - bzero(ctx->staging_block, sizeof(ctx->staging_block)); } } return (0); @@ -264,11 +152,12 @@ AES_CBC_MAC_Final(uint8_t *buf, void *vctx) * left over to encrypt. */ if (ctx->blockIndex != 0) { + memset(ctx->staging_block + ctx->blockIndex, 0, + CCM_CBC_BLOCK_LEN - ctx->blockIndex); xor_and_encrypt(ctx, ctx->staging_block, ctx->block); - ctx->cryptDataCount += ctx->blockIndex; - ctx->blockIndex = 0; - explicit_bzero(ctx->staging_block, sizeof(ctx->staging_block)); } + explicit_bzero(ctx->staging_block, sizeof(ctx->staging_block)); + bzero(s0, sizeof(s0)); s0[0] = (15 - ctx->nonceLength) - 1; bcopy(ctx->nonce, s0 + 1, ctx->nonceLength); diff --git a/sys/opencrypto/cbc_mac.h b/sys/opencrypto/cbc_mac.h index 51833a212f6c..50694e5d4b44 100644 --- a/sys/opencrypto/cbc_mac.h +++ b/sys/opencrypto/cbc_mac.h @@ -46,13 +46,11 @@ * the encryption one is similar. */ struct aes_cbc_mac_ctx { - uint64_t authDataLength, authDataCount; - uint64_t cryptDataLength, cryptDataCount; - int blockIndex; uint8_t staging_block[CCM_CBC_BLOCK_LEN]; uint8_t block[CCM_CBC_BLOCK_LEN]; - const uint8_t *nonce; + int blockIndex; int nonceLength; /* This one is in bytes, not bits! */ + const uint8_t *nonce; /* AES state data */ int rounds; uint32_t keysched[4*(RIJNDAEL_MAXNR+1)]; diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index c86ff86613db..fb43a08970c7 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -636,16 +636,69 @@ out: return (error); } +static void +build_ccm_b0(const char *nonce, u_int nonce_length, u_int aad_length, + u_int data_length, u_int tag_length, uint8_t *b0) +{ + uint8_t *bp; + uint8_t flags, L; + + KASSERT(nonce_length >= 7 && nonce_length <= 13, + ("nonce_length must be between 7 and 13 bytes")); + + /* + * Need to determine the L field value. This is the number of + * bytes needed to specify the length of the message; the length + * is whatever is left in the 16 bytes after specifying flags and + * the nonce. + */ + L = 15 - nonce_length; + + flags = ((aad_length > 0) << 6) + + (((tag_length - 2) / 2) << 3) + + L - 1; + + /* + * Now we need to set up the first block, which has flags, nonce, + * and the message length. + */ + b0[0] = flags; + memcpy(b0 + 1, nonce, nonce_length); + bp = b0 + 1 + nonce_length; + + /* Need to copy L' [aka L-1] bytes of data_length */ + for (uint8_t *dst = b0 + CCM_CBC_BLOCK_LEN - 1; dst >= bp; dst--) { + *dst = data_length; + data_length >>= 8; + } +} + +/* NB: OCF only supports AAD lengths < 2^32. */ +static int +build_ccm_aad_length(u_int aad_length, uint8_t *blk) +{ + if (aad_length < ((1 << 16) - (1 << 8))) { + be16enc(blk, aad_length); + return (sizeof(uint16_t)); + } else { + blk[0] = 0xff; + blk[1] = 0xfe; + be32enc(blk + 2, aad_length); + return (2 + sizeof(uint32_t)); + } +} + static int swcr_ccm_cbc_mac(struct swcr_session *ses, struct cryptop *crp) { - u_char tag[AES_CBC_MAC_HASH_LEN]; u_char iv[AES_BLOCK_LEN]; + u_char blk[CCM_CBC_BLOCK_LEN]; + u_char tag[AES_CBC_MAC_HASH_LEN]; union authctx ctx; const struct crypto_session_params *csp; struct swcr_auth *swa; struct auth_hash *axf; - int error, ivlen; + int error, ivlen, len; csp = crypto_get_params(crp->crp_session); swa = &ses->swcr_auth; @@ -657,25 +710,24 @@ swcr_ccm_cbc_mac(struct swcr_session *ses, struct cryptop *crp) ivlen = csp->csp_ivlen; crypto_read_iv(crp, iv); - /* - * AES CCM-CBC-MAC needs to know the length of both the auth - * data and payload data before doing the auth computation. - */ - ctx.aes_cbc_mac_ctx.authDataLength = crp->crp_payload_length; - ctx.aes_cbc_mac_ctx.cryptDataLength = 0; + /* Supply MAC with IV */ + axf->Reinit(&ctx, crp->crp_iv, ivlen); - axf->Reinit(&ctx, iv, ivlen); - if (crp->crp_aad != NULL) - error = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); - else - error = crypto_apply(crp, crp->crp_payload_start, - crp->crp_payload_length, axf->Update, &ctx); - if (error) - return (error); + /* Supply MAC with b0. */ + build_ccm_b0(crp->crp_iv, ivlen, crp->crp_payload_length, 0, + swa->sw_mlen, blk); + axf->Update(&ctx, blk, CCM_CBC_BLOCK_LEN); + + len = build_ccm_aad_length(crp->crp_payload_length, blk); + axf->Update(&ctx, blk, len); + + crypto_apply(crp, crp->crp_payload_start, crp->crp_payload_length, + axf->Update, &ctx); /* Finalize MAC */ axf->Final(tag, &ctx); + error = 0; if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { u_char tag2[AES_CBC_MAC_HASH_LEN]; @@ -689,6 +741,7 @@ swcr_ccm_cbc_mac(struct swcr_session *ses, struct cryptop *crp) crypto_copyback(crp, crp->crp_digest_start, swa->sw_mlen, tag); } explicit_bzero(tag, sizeof(tag)); + explicit_bzero(blk, sizeof(blk)); explicit_bzero(iv, sizeof(iv)); return (error); } @@ -733,24 +786,35 @@ swcr_ccm(struct swcr_session *ses, struct cryptop *crp) ivlen = csp->csp_ivlen; - /* - * AES CCM-CBC-MAC needs to know the length of both the auth - * data and payload data before doing the auth computation. - */ - ctx.aes_cbc_mac_ctx.authDataLength = crp->crp_aad_length; - ctx.aes_cbc_mac_ctx.cryptDataLength = crp->crp_payload_length; - /* Supply MAC with IV */ axf->Reinit(&ctx, crp->crp_iv, ivlen); + /* Supply MAC with b0. */ + _Static_assert(sizeof(blkbuf) >= CCM_CBC_BLOCK_LEN, + "blkbuf too small for b0"); + build_ccm_b0(crp->crp_iv, ivlen, crp->crp_aad_length, + crp->crp_payload_length, swa->sw_mlen, blk); + axf->Update(&ctx, blk, CCM_CBC_BLOCK_LEN); + /* Supply MAC with AAD */ - if (crp->crp_aad != NULL) - error = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); - else - error = crypto_apply(crp, crp->crp_aad_start, - crp->crp_aad_length, axf->Update, &ctx); - if (error) - return (error); + if (crp->crp_aad_length != 0) { + len = build_ccm_aad_length(crp->crp_aad_length, blk); + axf->Update(&ctx, blk, len); + if (crp->crp_aad != NULL) + axf->Update(&ctx, crp->crp_aad, + crp->crp_aad_length); + else + crypto_apply(crp, crp->crp_aad_start, + crp->crp_aad_length, axf->Update, &ctx); + + /* Pad the AAD (including length field) to a full block. */ + len = (len + crp->crp_aad_length) % CCM_CBC_BLOCK_LEN; + if (len != 0) { + len = CCM_CBC_BLOCK_LEN - len; + memset(blk, 0, CCM_CBC_BLOCK_LEN); + axf->Update(&ctx, blk, len); + } + } if (crp->crp_cipher_key != NULL) exf->setkey(swe->sw_kschedule, crp->crp_cipher_key, From nobody Thu Oct 21 22:04:25 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BB4EF18015DA; Thu, 21 Oct 2021 22:04: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 4Hb1jS5CvBz3thv; Thu, 21 Oct 2021 22:04: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 1EE56230A6; Thu, 21 Oct 2021 22:04: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 19LM4PXU079728; Thu, 21 Oct 2021 22:04:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4P70079727; Thu, 21 Oct 2021 22:04:25 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:25 GMT Message-Id: <202110212204.19LM4P70079727@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: 4b18b3c402b4 - stable/13 - safexcel: Support truncated tags for AES-CCM. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 4b18b3c402b4db8a6a15acff3dd96e8d5be10bdb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4b18b3c402b4db8a6a15acff3dd96e8d5be10bdb commit 4b18b3c402b4db8a6a15acff3dd96e8d5be10bdb Author: John Baldwin AuthorDate: 2021-10-06 21:08:48 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:17:21 +0000 safexcel: Support truncated tags for AES-CCM. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32119 (cherry picked from commit 366ae4a000b1483390ddbf28e3dc420ebac894a0) --- sys/dev/safexcel/safexcel.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sys/dev/safexcel/safexcel.c b/sys/dev/safexcel/safexcel.c index 9a9b0ab0cb74..807040a7a1d8 100644 --- a/sys/dev/safexcel/safexcel.c +++ b/sys/dev/safexcel/safexcel.c @@ -1735,7 +1735,7 @@ safexcel_instr_ccm(struct safexcel_request *req, struct safexcel_instr *instr, memset(b0, 0, blen); b0[0] = (L - 1) | /* payload length size */ - ((CCM_CBC_MAX_DIGEST_LEN - 2) / 2) << 3 /* digest length */ | + ((req->sess->digestlen - 2) / 2) << 3 /* digest length */ | (crp->crp_aad_length > 0 ? 1 : 0) << 6 /* AAD present bit */; memcpy(&b0[1], req->iv, csp->csp_ivlen); b0[14] = crp->crp_payload_length >> 8; @@ -2314,9 +2314,6 @@ safexcel_probesession(device_t dev, const struct crypto_session_params *csp) return (EINVAL); break; case CRYPTO_AES_CCM_16: - if (csp->csp_auth_mlen != 0 && - csp->csp_auth_mlen != AES_CBC_MAC_HASH_LEN) - return (EINVAL); break; default: return (EINVAL); From nobody Thu Oct 21 22:04:29 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DE9DD18016F2; Thu, 21 Oct 2021 22:04: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 4Hb1jY134pz3tgg; Thu, 21 Oct 2021 22:04: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 680DB22CD8; Thu, 21 Oct 2021 22:04: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 19LM4TIm079806; Thu, 21 Oct 2021 22:04:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4TcE079805; Thu, 21 Oct 2021 22:04:29 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:29 GMT Message-Id: <202110212204.19LM4TcE079805@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: 64c043d2d2cf - stable/13 - crypto: Support Chacha20-Poly1305 with a nonce size of 8 bytes. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 64c043d2d2cfa44128361c9354d1fad023087be8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=64c043d2d2cfa44128361c9354d1fad023087be8 commit 64c043d2d2cfa44128361c9354d1fad023087be8 Author: John Baldwin AuthorDate: 2021-10-06 21:08:49 +0000 Commit: John Baldwin CommitDate: 2021-10-21 21:19:30 +0000 crypto: Support Chacha20-Poly1305 with a nonce size of 8 bytes. This is useful for WireGuard which uses a nonce of 8 bytes rather than the 12 bytes used for IPsec and TLS. Note that this also fixes a (should be) harmless bug in ossl(4) where the counter was incorrectly treated as a 64-bit counter instead of a 32-bit counter in terms of wrapping when using a 12 byte nonce. However, this required a single message (TLS record) longer than 64 * (2^32 - 1) bytes (about 256 GB) to trigger. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32122 (cherry picked from commit 42dcd39528c6188a259951e28bbad309234324e4) --- share/man/man7/crypto.7 | 2 +- sys/crypto/openssl/ossl_chacha20.c | 14 ++++++++------ sys/opencrypto/crypto.c | 7 ++++++- sys/opencrypto/cryptosoft.c | 3 --- sys/opencrypto/xform_chacha20_poly1305.c | 31 +++++++++++++++++++++++++------ tools/tools/crypto/cryptocheck.c | 4 ++-- 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/share/man/man7/crypto.7 b/share/man/man7/crypto.7 index d75daa62adcb..c7af22af4deb 100644 --- a/share/man/man7/crypto.7 +++ b/share/man/man7/crypto.7 @@ -167,7 +167,7 @@ The following AEAD algorithms are supported: AES Galois/Counter Mode .It Dv CRYPTO_AES_CCM_16 Ta 12, 7-13 Ta 16, 24, 32 Ta 16 Ta AES Counter with CBC-MAC -.It Dv CRYPTO_CHACHA20_POLY1305 Ta 12 Ta 32 Ta 16 Ta +.It Dv CRYPTO_CHACHA20_POLY1305 Ta 12, 8 Ta 32 Ta 16 Ta ChaCha20-Poly1305 .El .Sh SEE ALSO diff --git a/sys/crypto/openssl/ossl_chacha20.c b/sys/crypto/openssl/ossl_chacha20.c index a6f56aca1f8f..aa125121e8b4 100644 --- a/sys/crypto/openssl/ossl_chacha20.c +++ b/sys/crypto/openssl/ossl_chacha20.c @@ -161,7 +161,8 @@ ossl_chacha20_poly1305_encrypt(struct cryptop *crp, for (i = 0; i < nitems(key); i++) key[i] = CHACHA_U8TOU32(cipher_key + i * 4); - crypto_read_iv(crp, counter + 1); + memset(counter, 0, sizeof(counter)); + crypto_read_iv(crp, counter + (CHACHA_CTR_SIZE - csp->csp_ivlen) / 4); for (i = 1; i < nitems(counter); i++) counter[i] = le32toh(counter[i]); @@ -223,7 +224,7 @@ ossl_chacha20_poly1305_encrypt(struct cryptop *crp, /* Truncate if the 32-bit counter would roll over. */ next_counter = counter[0] + todo / CHACHA_BLK_SIZE; - if (next_counter < counter[0]) { + if (csp->csp_ivlen == 8 && next_counter < counter[0]) { todo -= next_counter * CHACHA_BLK_SIZE; next_counter = 0; } @@ -232,7 +233,7 @@ ossl_chacha20_poly1305_encrypt(struct cryptop *crp, Poly1305_Update(&auth_ctx, out, todo); counter[0] = next_counter; - if (counter[0] == 0) + if (csp->csp_ivlen == 8 && counter[0] == 0) counter[1]++; if (out == block) { @@ -307,7 +308,8 @@ ossl_chacha20_poly1305_decrypt(struct cryptop *crp, for (i = 0; i < nitems(key); i++) key[i] = CHACHA_U8TOU32(cipher_key + i * 4); - crypto_read_iv(crp, counter + 1); + memset(counter, 0, sizeof(counter)); + crypto_read_iv(crp, counter + (CHACHA_CTR_SIZE - csp->csp_ivlen) / 4); for (i = 1; i < nitems(counter); i++) counter[i] = le32toh(counter[i]); @@ -391,7 +393,7 @@ ossl_chacha20_poly1305_decrypt(struct cryptop *crp, /* Truncate if the 32-bit counter would roll over. */ next_counter = counter[0] + todo / CHACHA_BLK_SIZE; - if (next_counter < counter[0]) { + if (csp->csp_ivlen == 8 && next_counter < counter[0]) { todo -= next_counter * CHACHA_BLK_SIZE; next_counter = 0; } @@ -399,7 +401,7 @@ ossl_chacha20_poly1305_decrypt(struct cryptop *crp, ChaCha20_ctr32(out, in, todo, key, counter); counter[0] = next_counter; - if (counter[0] == 0) + if (csp->csp_ivlen == 8 && counter[0] == 0) counter[1]++; if (out == block) { diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index a3a42827d51b..f0fd3fe662a9 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -882,10 +882,15 @@ check_csp(const struct crypto_session_params *csp) return (false); break; case CRYPTO_AES_NIST_GCM_16: - case CRYPTO_CHACHA20_POLY1305: if (csp->csp_auth_mlen > 16) return (false); break; + case CRYPTO_CHACHA20_POLY1305: + if (csp->csp_ivlen != 8 && csp->csp_ivlen != 12) + return (false); + if (csp->csp_auth_mlen > POLY1305_HASH_LEN) + return (false); + break; } break; case CSP_MODE_ETA: diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index fb43a08970c7..567a0f4748d5 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -1393,9 +1393,6 @@ swcr_setup_chacha20_poly1305(struct swcr_session *ses, struct swcr_auth *swa; struct auth_hash *axf; - if (csp->csp_ivlen != CHACHA20_POLY1305_IV_LEN) - return (EINVAL); - /* First, setup the auth side. */ swa = &ses->swcr_auth; axf = &auth_hash_chacha20_poly1305; diff --git a/sys/opencrypto/xform_chacha20_poly1305.c b/sys/opencrypto/xform_chacha20_poly1305.c index e893287145f2..f593faa9b5ef 100644 --- a/sys/opencrypto/xform_chacha20_poly1305.c +++ b/sys/opencrypto/xform_chacha20_poly1305.c @@ -34,6 +34,7 @@ struct chacha20_poly1305_cipher_ctx { const void *key; uint32_t ic; + bool ietf; char nonce[CHACHA20_POLY1305_IV_LEN]; }; @@ -58,7 +59,8 @@ chacha20_poly1305_reinit(void *vctx, const uint8_t *iv, size_t ivlen) ("%s: invalid nonce length", __func__)); /* Block 0 is used for the poly1305 key. */ - memcpy(ctx->nonce, iv, sizeof(ctx->nonce)); + memcpy(ctx->nonce, iv, ivlen); + ctx->ietf = (ivlen == CHACHA20_POLY1305_IV_LEN); ctx->ic = 1; } @@ -68,8 +70,12 @@ chacha20_poly1305_crypt(void *vctx, const uint8_t *in, uint8_t *out) struct chacha20_poly1305_cipher_ctx *ctx = vctx; int error; - error = crypto_stream_chacha20_ietf_xor_ic(out, in, - CHACHA20_NATIVE_BLOCK_LEN, ctx->nonce, ctx->ic, ctx->key); + if (ctx->ietf) + error = crypto_stream_chacha20_ietf_xor_ic(out, in, + CHACHA20_NATIVE_BLOCK_LEN, ctx->nonce, ctx->ic, ctx->key); + else + error = crypto_stream_chacha20_xor_ic(out, in, + CHACHA20_NATIVE_BLOCK_LEN, ctx->nonce, ctx->ic, ctx->key); KASSERT(error == 0, ("%s failed: %d", __func__, error)); ctx->ic++; } @@ -82,8 +88,12 @@ chacha20_poly1305_crypt_last(void *vctx, const uint8_t *in, uint8_t *out, int error; - error = crypto_stream_chacha20_ietf_xor_ic(out, in, len, ctx->nonce, - ctx->ic, ctx->key); + if (ctx->ietf) + error = crypto_stream_chacha20_ietf_xor_ic(out, in, len, + ctx->nonce, ctx->ic, ctx->key); + else + error = crypto_stream_chacha20_xor_ic(out, in, len, ctx->nonce, + ctx->ic, ctx->key); KASSERT(error == 0, ("%s failed: %d", __func__, error)); } @@ -129,7 +139,16 @@ chacha20_poly1305_Reinit(void *vctx, const uint8_t *nonce, u_int noncelen) struct chacha20_poly1305_auth_ctx *ctx = vctx; char block[CHACHA20_NATIVE_BLOCK_LEN]; - crypto_stream_chacha20_ietf(block, sizeof(block), nonce, ctx->key); + switch (noncelen) { + case 8: + crypto_stream_chacha20(block, sizeof(block), nonce, ctx->key); + break; + case CHACHA20_POLY1305_IV_LEN: + crypto_stream_chacha20_ietf(block, sizeof(block), nonce, ctx->key); + break; + default: + __assert_unreachable(); + } crypto_onetimeauth_poly1305_init(&ctx->state, block); explicit_bzero(block, sizeof(block)); } diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c index 63c6ce1f9d28..05b761a0c87a 100644 --- a/tools/tools/crypto/cryptocheck.c +++ b/tools/tools/crypto/cryptocheck.c @@ -126,7 +126,7 @@ * aes-ccm 128-bit AES-CCM * aes-ccm192 192-bit AES-CCM * aes-ccm256 256-bit AES-CCM - * chacha20-poly1305 Chacha20 (96 bit nonce) with Poly1305 per RFC 8439 + * chacha20-poly1305 Chacha20 with Poly1305 per RFC 8439 */ #include @@ -233,7 +233,7 @@ static const struct alg { .evp_cipher = EVP_aes_256_ccm }, { .name = "chacha20-poly1305", .cipher = CRYPTO_CHACHA20_POLY1305, .type = T_AEAD, .tag_len = POLY1305_HASH_LEN, - .iv_sizes = { CHACHA20_POLY1305_IV_LEN }, + .iv_sizes = { CHACHA20_POLY1305_IV_LEN, 8 }, .evp_cipher = EVP_chacha20_poly1305 }, }; From nobody Thu Oct 21 22:04:30 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7B10E1801D05; Thu, 21 Oct 2021 22: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 4Hb1jb0xtMz3tqr; Thu, 21 Oct 2021 22:04: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 8E0BC22FA0; Thu, 21 Oct 2021 22:04: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 19LM4UHm079830; Thu, 21 Oct 2021 22:04:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LM4UgZ079829; Thu, 21 Oct 2021 22:04:30 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:04:30 GMT Message-Id: <202110212204.19LM4UgZ079829@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: fe2827f1678b - stable/13 - Bump __FreeBSD_version for OCF changes to support variable nonce lengths. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: fe2827f1678b8ff0baf62a1529b2cc121a25b090 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=fe2827f1678b8ff0baf62a1529b2cc121a25b090 commit fe2827f1678b8ff0baf62a1529b2cc121a25b090 Author: John Baldwin AuthorDate: 2021-10-06 21:09:18 +0000 Commit: John Baldwin CommitDate: 2021-10-21 22:03:38 +0000 Bump __FreeBSD_version for OCF changes to support variable nonce lengths. Sponsored by: The FreeBSD Foundation (cherry picked from commit ac847dbf73685a5df9f70bbcdefa9fdeb559071d) --- 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 fd177d5a23a1..3d47dda916af 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300518 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300519 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Thu Oct 21 22:31:32 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 030EB1813440; Thu, 21 Oct 2021 22:31: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 4Hb2Jh6hvYz4fFx; Thu, 21 Oct 2021 22:31: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 C6E1723343; Thu, 21 Oct 2021 22:31: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 19LMVWj5018758; Thu, 21 Oct 2021 22:31:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMVWff018757; Thu, 21 Oct 2021 22:31:32 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:31:32 GMT Message-Id: <202110212231.19LMVWff018757@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: fa226878a553 - stable/13 - sbuf(9): Microoptimize sbuf_put_byte() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: fa226878a5532e79acb373e1201f92e0114428e6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=fa226878a5532e79acb373e1201f92e0114428e6 commit fa226878a5532e79acb373e1201f92e0114428e6 Author: Alexander Motin AuthorDate: 2021-10-05 18:42:47 +0000 Commit: Alexander Motin CommitDate: 2021-10-21 22:24:29 +0000 sbuf(9): Microoptimize sbuf_put_byte() This function is actively used by sbuf_vprintf(), so this simple inlining in half reduces time of kern.geom.confxml generation. MFC after: 2 weeks Sponsored by: iXsystem, Inc. (cherry picked from commit 7835b2cb4a1ae57f403739a2f1076ec7188f18c9) --- sys/kern/subr_sbuf.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index b7f135e81206..6c533f36c82e 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -480,7 +480,26 @@ static void sbuf_put_byte(struct sbuf *s, char c) { - sbuf_put_bytes(s, &c, 1); + assert_sbuf_integrity(s); + assert_sbuf_state(s, 0); + + if (__predict_false(s->s_error != 0)) + return; + if (__predict_false(SBUF_FREESPACE(s) <= 0)) { + /* + * If there is a drain, use it, otherwise extend the + * buffer. + */ + if (s->s_drain_func != NULL) + (void)sbuf_drain(s); + else if (sbuf_extend(s, 1) < 0) + s->s_error = ENOMEM; + if (s->s_error != 0) + return; + } + s->s_buf[s->s_len++] = c; + if (SBUF_ISSECTION(s)) + s->s_sect_len++; } /* @@ -623,7 +642,7 @@ static void sbuf_putc_func(int c, void *arg) { - if (c != '\0') + if (__predict_true(c != '\0')) sbuf_put_byte(arg, c); } From nobody Thu Oct 21 22:31:33 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7879E1813445; Thu, 21 Oct 2021 22:31: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 4Hb2Jk1XhQz4fND; Thu, 21 Oct 2021 22:31: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 EAE0B2352E; Thu, 21 Oct 2021 22:31: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 19LMVXD0018788; Thu, 21 Oct 2021 22:31:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMVX2S018787; Thu, 21 Oct 2021 22:31:33 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:31:33 GMT Message-Id: <202110212231.19LMVX2S018787@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: 4808bab7fa6c - stable/13 - sched_ule(4): Improve long-term load balancer. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 4808bab7fa6c3ec49b49476b8326d7a0250a03fa Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=4808bab7fa6c3ec49b49476b8326d7a0250a03fa commit 4808bab7fa6c3ec49b49476b8326d7a0250a03fa Author: Alexander Motin AuthorDate: 2021-09-21 22:14:22 +0000 Commit: Alexander Motin CommitDate: 2021-10-21 22:24:35 +0000 sched_ule(4): Improve long-term load balancer. Before this change long-term load balancer was unable to migrate running threads, only ones waiting on run queues. But with growing number of CPU cores it is quite typical now for system to not have many waiting threads. But same time if due to some coincidence two long-running CPU-bound threads ended up sharing same physical CPU core, they could suffer from the SMT penalty indefinitely, and the load balancer couldn't help. Improve that by teaching the load balancer to hint running threads to migrate by marking them with TDF_NEEDRESCHED and new TDF_PICKCPU flag, making sched_pickcpu() to search for better CPU later, when it is convenient. Fix CPU search logic when balancing to limit round-robin migrations in case of almost equal load to the group of physical cores. The previous code bounced threads across all the system, that should be pretty bad for caches and NUMA affinity, while additional fairness was almost invisible, diminishing with number of cores in the group. MFC after: 1 month (cherry picked from commit e745d729be60a47b49eb19c02a6864a747fb2744) --- sys/kern/sched_ule.c | 119 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 93 insertions(+), 26 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 53d5a59a3605..e7de4a50bb93 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -196,6 +196,7 @@ _Static_assert(sizeof(struct thread) + sizeof(struct td_sched) <= #define SCHED_SLICE_MIN_DIVISOR 6 /* DEFAULT/MIN = ~16 ms. */ /* Flags kept in td_flags. */ +#define TDF_PICKCPU TDF_SCHED0 /* Thread should pick new CPU. */ #define TDF_SLICEEND TDF_SCHED2 /* Thread time slice is over. */ /* @@ -633,15 +634,16 @@ sched_random(void) } struct cpu_search { - cpuset_t *cs_mask; - u_int cs_prefer; + cpuset_t *cs_mask; /* The mask of allowed CPUs to choose from. */ + int cs_prefer; /* Prefer this CPU and groups including it. */ + int cs_running; /* The thread is now running at cs_prefer. */ int cs_pri; /* Min priority for low. */ int cs_limit; /* Max load for low, min load for high. */ }; struct cpu_search_res { - int cs_cpu; - int cs_load; + int cs_cpu; /* The best CPU found. */ + int cs_load; /* The load of cs_cpu. */ }; /* @@ -657,7 +659,7 @@ cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, { struct cpu_search_res lr; struct tdq *tdq; - int c, bload, l, load, total; + int c, bload, l, load, p, total; total = 0; bload = INT_MAX; @@ -668,6 +670,17 @@ cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, for (c = cg->cg_children - 1; c >= 0; c--) { load = cpu_search_lowest(&cg->cg_child[c], s, &lr); total += load; + + /* + * When balancing do not prefer SMT groups with load >1. + * It allows round-robin between SMT groups with equal + * load within parent group for more fair scheduling. + */ + if (__predict_false(s->cs_running) && + (cg->cg_child[c].cg_flags & CG_FLAG_THREAD) && + load >= 128 && (load & 128) != 0) + load += 128; + if (lr.cs_cpu >= 0 && (load < bload || (load == bload && lr.cs_load < r->cs_load))) { bload = load; @@ -684,20 +697,40 @@ cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, continue; tdq = TDQ_CPU(c); l = tdq->tdq_load; + if (c == s->cs_prefer) { + if (__predict_false(s->cs_running)) + l--; + p = 128; + } else + p = 0; load = l * 256; - if (c == s->cs_prefer) - load -= 128; - total += load; - if (l > s->cs_limit || tdq->tdq_lowpri <= s->cs_pri || + total += load - p; + + /* + * Check this CPU is acceptable. + * If the threads is already on the CPU, don't look on the TDQ + * priority, since it can be the priority of the thread itself. + */ + if (l > s->cs_limit || (tdq->tdq_lowpri <= s->cs_pri && + (!s->cs_running || c != s->cs_prefer)) || !CPU_ISSET(c, s->cs_mask)) continue; + + /* + * When balancing do not prefer CPUs with load > 1. + * It allows round-robin between CPUs with equal load + * within the CPU group for more fair scheduling. + */ + if (__predict_false(s->cs_running) && l > 0) + p = 0; + load -= sched_random() % 128; - if (load < bload) { - bload = load; + if (bload > load - p) { + bload = load - p; r->cs_cpu = c; + r->cs_load = load; } } - r->cs_load = bload; return (total); } @@ -736,9 +769,17 @@ cpu_search_highest(const struct cpu_group *cg, const struct cpu_search *s, l = tdq->tdq_load; load = l * 256; total += load; - if (l < s->cs_limit || !tdq->tdq_transferable || + + /* + * Check this CPU is acceptable. + * If requested minimum load is 1, then caller must know how + * to handle running threads, not counted in tdq_transferable. + */ + if (l < s->cs_limit || (tdq->tdq_transferable == 0 && + (s->cs_limit > 1 || l > 1)) || !CPU_ISSET(c, s->cs_mask)) continue; + load -= sched_random() % 256; if (load > bload) { bload = load; @@ -756,12 +797,13 @@ cpu_search_highest(const struct cpu_group *cg, const struct cpu_search *s, */ static inline int sched_lowest(const struct cpu_group *cg, cpuset_t *mask, int pri, int maxload, - int prefer) + int prefer, int running) { struct cpu_search s; struct cpu_search_res r; s.cs_prefer = prefer; + s.cs_running = running; s.cs_mask = mask; s.cs_pri = pri; s.cs_limit = maxload; @@ -788,12 +830,13 @@ static void sched_balance_group(struct cpu_group *cg) { struct tdq *tdq; + struct thread *td; cpuset_t hmask, lmask; int high, low, anylow; CPU_FILL(&hmask); for (;;) { - high = sched_highest(cg, &hmask, 2); + high = sched_highest(cg, &hmask, 1); /* Stop if there is no more CPU with transferrable threads. */ if (high == -1) break; @@ -802,10 +845,28 @@ sched_balance_group(struct cpu_group *cg) /* Stop if there is no more CPU left for low. */ if (CPU_EMPTY(&lmask)) break; - anylow = 1; tdq = TDQ_CPU(high); + if (tdq->tdq_load == 1) { + /* + * There is only one running thread. We can't move + * it from here, so tell it to pick new CPU by itself. + */ + TDQ_LOCK(tdq); + td = pcpu_find(high)->pc_curthread; + if ((td->td_flags & TDF_IDLETD) == 0 && + THREAD_CAN_MIGRATE(td)) { + td->td_flags |= TDF_NEEDRESCHED | TDF_PICKCPU; + if (high != curcpu) + ipi_cpu(high, IPI_AST); + } + TDQ_UNLOCK(tdq); + break; + } + anylow = 1; nextlow: - low = sched_lowest(cg, &lmask, -1, tdq->tdq_load - 1, high); + if (tdq->tdq_transferable == 0) + continue; + low = sched_lowest(cg, &lmask, -1, tdq->tdq_load - 1, high, 1); /* Stop if we looked well and found no less loaded CPU. */ if (anylow && low == -1) break; @@ -1227,7 +1288,7 @@ sched_pickcpu(struct thread *td, int flags) struct td_sched *ts; struct tdq *tdq; cpuset_t *mask; - int cpu, pri, self, intr; + int cpu, pri, r, self, intr; self = PCPU_GET(cpuid); ts = td_get_sched(td); @@ -1305,32 +1366,33 @@ llc: cpu = -1; mask = &td->td_cpuset->cs_mask; pri = td->td_priority; + r = TD_IS_RUNNING(td); /* * Try hard to keep interrupts within found LLC. Search the LLC for * the least loaded CPU we can run now. For NUMA systems it should * be within target domain, and it also reduces scheduling overhead. */ if (ccg != NULL && intr) { - cpu = sched_lowest(ccg, mask, pri, INT_MAX, ts->ts_cpu); + cpu = sched_lowest(ccg, mask, pri, INT_MAX, ts->ts_cpu, r); if (cpu >= 0) SCHED_STAT_INC(pickcpu_intrbind); } else /* Search the LLC for the least loaded idle CPU we can run now. */ if (ccg != NULL) { cpu = sched_lowest(ccg, mask, max(pri, PRI_MAX_TIMESHARE), - INT_MAX, ts->ts_cpu); + INT_MAX, ts->ts_cpu, r); if (cpu >= 0) SCHED_STAT_INC(pickcpu_affinity); } /* Search globally for the least loaded CPU we can run now. */ if (cpu < 0) { - cpu = sched_lowest(cpu_top, mask, pri, INT_MAX, ts->ts_cpu); + cpu = sched_lowest(cpu_top, mask, pri, INT_MAX, ts->ts_cpu, r); if (cpu >= 0) SCHED_STAT_INC(pickcpu_lowest); } /* Search globally for the least loaded CPU. */ if (cpu < 0) { - cpu = sched_lowest(cpu_top, mask, -1, INT_MAX, ts->ts_cpu); + cpu = sched_lowest(cpu_top, mask, -1, INT_MAX, ts->ts_cpu, r); if (cpu >= 0) SCHED_STAT_INC(pickcpu_lowest); } @@ -2056,7 +2118,7 @@ sched_switch(struct thread *td, int flags) struct td_sched *ts; struct mtx *mtx; int srqflag; - int cpuid, preempted; + int cpuid, pickcpu, preempted; THREAD_LOCK_ASSERT(td, MA_OWNED); @@ -2064,11 +2126,15 @@ sched_switch(struct thread *td, int flags) tdq = TDQ_SELF(); ts = td_get_sched(td); sched_pctcpu_update(ts, 1); - ts->ts_rltick = ticks; + pickcpu = (td->td_flags & TDF_PICKCPU) != 0; + if (pickcpu) + ts->ts_rltick = ticks - affinity * MAX_CACHE_LEVELS; + else + ts->ts_rltick = ticks; td->td_lastcpu = td->td_oncpu; preempted = (td->td_flags & TDF_SLICEEND) == 0 && (flags & SW_PREEMPT) != 0; - td->td_flags &= ~(TDF_NEEDRESCHED | TDF_SLICEEND); + td->td_flags &= ~(TDF_NEEDRESCHED | TDF_PICKCPU | TDF_SLICEEND); td->td_owepreempt = 0; tdq->tdq_owepreempt = 0; if (!TD_IS_IDLETHREAD(td)) @@ -2088,7 +2154,8 @@ sched_switch(struct thread *td, int flags) SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED : SRQ_OURSELF|SRQ_YIELDING; #ifdef SMP - if (THREAD_CAN_MIGRATE(td) && !THREAD_CAN_SCHED(td, ts->ts_cpu)) + if (THREAD_CAN_MIGRATE(td) && (!THREAD_CAN_SCHED(td, ts->ts_cpu) + || pickcpu)) ts->ts_cpu = sched_pickcpu(td, 0); #endif if (ts->ts_cpu == cpuid) From nobody Thu Oct 21 22:31:34 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E73E31813449; Thu, 21 Oct 2021 22:31: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 4Hb2Jl2Szwz4fKh; Thu, 21 Oct 2021 22:31: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 1D083233C2; Thu, 21 Oct 2021 22:31: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 19LMVYgl018813; Thu, 21 Oct 2021 22:31:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMVYre018812; Thu, 21 Oct 2021 22:31:34 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:31:34 GMT Message-Id: <202110212231.19LMVYre018812@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: a3d50144ccd7 - stable/13 - Fix build without SMP. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: a3d50144ccd7cdb0754efc8ff2c8b56d8abcc2d9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=a3d50144ccd7cdb0754efc8ff2c8b56d8abcc2d9 commit a3d50144ccd7cdb0754efc8ff2c8b56d8abcc2d9 Author: Alexander Motin AuthorDate: 2021-09-22 02:13:33 +0000 Commit: Alexander Motin CommitDate: 2021-10-21 22:24:35 +0000 Fix build without SMP. MFC after: 1 month (cherry picked from commit 8db1669959ceebdc60a7d402830663953bf32818) --- sys/kern/sched_ule.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index e7de4a50bb93..d92436f70db2 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -2118,7 +2118,10 @@ sched_switch(struct thread *td, int flags) struct td_sched *ts; struct mtx *mtx; int srqflag; - int cpuid, pickcpu, preempted; + int cpuid, preempted; +#ifdef SMP + int pickcpu; +#endif THREAD_LOCK_ASSERT(td, MA_OWNED); @@ -2126,11 +2129,13 @@ sched_switch(struct thread *td, int flags) tdq = TDQ_SELF(); ts = td_get_sched(td); sched_pctcpu_update(ts, 1); +#ifdef SMP pickcpu = (td->td_flags & TDF_PICKCPU) != 0; if (pickcpu) ts->ts_rltick = ticks - affinity * MAX_CACHE_LEVELS; else ts->ts_rltick = ticks; +#endif td->td_lastcpu = td->td_oncpu; preempted = (td->td_flags & TDF_SLICEEND) == 0 && (flags & SW_PREEMPT) != 0; From nobody Thu Oct 21 22:31:36 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 84C39181353E; Thu, 21 Oct 2021 22:31: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 4Hb2Jn0j0Xz4fKs; Thu, 21 Oct 2021 22:31: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 459D0233C3; Thu, 21 Oct 2021 22:31: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 19LMVaM1018837; Thu, 21 Oct 2021 22:31:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMVaFo018836; Thu, 21 Oct 2021 22:31:36 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:31:36 GMT Message-Id: <202110212231.19LMVaFo018836@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: b5919ea4e6bb - stable/13 - x86: Add NUMA nodes into CPU topology. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: b5919ea4e6bb21e22484bc1943665e1f7e3bf888 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=b5919ea4e6bb21e22484bc1943665e1f7e3bf888 commit b5919ea4e6bb21e22484bc1943665e1f7e3bf888 Author: Alexander Motin AuthorDate: 2021-09-23 17:41:02 +0000 Commit: Alexander Motin CommitDate: 2021-10-21 22:24:36 +0000 x86: Add NUMA nodes into CPU topology. Depending on hardware, NUMA nodes may match last level caches, or they may be above them (AMD Zen 2/3) or below (Intel Xeon w/ SNC). This information is provided by ACPI instead of CPUID, and it is provided for each CPU individually instead of mask widths, but this code should be able to properly handle all the above cases. This change should immediately allow idle stealing in sched_ule(4) to prefer load from NUMA-local CPUs to remote ones when the node does not match LLC. Later we may think of how to better handle it on sched_pickcpu() side. MFC after: 1 month (cherry picked from commit ef50d5fbc39fc39970eab1234222b5ac1d9ba74c) --- sys/kern/sched_ule.c | 2 ++ sys/sys/smp.h | 1 + sys/x86/x86/mp_x86.c | 82 +++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index d92436f70db2..98c1f0bca981 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -3098,6 +3098,8 @@ sysctl_kern_sched_topology_spec_internal(struct sbuf *sb, struct cpu_group *cg, sbuf_printf(sb, "THREAD group"); if ((cg->cg_flags & CG_FLAG_SMT) != 0) sbuf_printf(sb, "SMT group"); + if ((cg->cg_flags & CG_FLAG_NODE) != 0) + sbuf_printf(sb, "NUMA node"); sbuf_printf(sb, "\n"); } diff --git a/sys/sys/smp.h b/sys/sys/smp.h index cee1199015a7..1da557212ae2 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -107,6 +107,7 @@ typedef struct cpu_group *cpu_group_t; #define CG_FLAG_HTT 0x01 /* Schedule the alternate core last. */ #define CG_FLAG_SMT 0x02 /* New age htt, less crippled. */ #define CG_FLAG_THREAD (CG_FLAG_HTT | CG_FLAG_SMT) /* Any threading. */ +#define CG_FLAG_NODE 0x04 /* NUMA node. */ /* * Convenience routines for building and traversing topologies. diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index db40aab28ad5..326b6fdae77d 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_acpi.h" #ifdef __i386__ #include "opt_apic.h" #endif @@ -82,6 +83,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef DEV_ACPI +#include +#include +#endif + static MALLOC_DEFINE(M_CPUS, "cpus", "CPU items"); /* lock region used by kernel profiling */ @@ -501,13 +507,16 @@ topo_probe(void) int type; int subtype; int id_shift; - } topo_layers[MAX_CACHE_LEVELS + 4]; + } topo_layers[MAX_CACHE_LEVELS + 5]; struct topo_node *parent; struct topo_node *node; int layer; int nlayers; int node_id; int i; +#if defined(DEV_ACPI) && MAXMEMDOM > 1 + int d, domain; +#endif if (cpu_topo_probed) return; @@ -582,6 +591,31 @@ topo_probe(void) topo_layers[nlayers].id_shift = 0; nlayers++; +#if defined(DEV_ACPI) && MAXMEMDOM > 1 + if (vm_ndomains > 1) { + for (layer = 0; layer < nlayers; ++layer) { + for (i = 0; i <= max_apic_id; ++i) { + if ((i & ((1 << topo_layers[layer].id_shift) - 1)) == 0) + domain = -1; + if (!cpu_info[i].cpu_present) + continue; + d = acpi_pxm_get_cpu_locality(i); + if (domain >= 0 && domain != d) + break; + domain = d; + } + if (i > max_apic_id) + break; + } + KASSERT(layer < nlayers, ("NUMA domain smaller than PU")); + memmove(&topo_layers[layer+1], &topo_layers[layer], + sizeof(*topo_layers) * (nlayers - layer)); + topo_layers[layer].type = TOPO_TYPE_NODE; + topo_layers[layer].subtype = CG_SHARE_NONE; + nlayers++; + } +#endif + topo_init_root(&topo_root); for (i = 0; i <= max_apic_id; ++i) { if (!cpu_info[i].cpu_present) @@ -589,7 +623,12 @@ topo_probe(void) parent = &topo_root; for (layer = 0; layer < nlayers; ++layer) { - node_id = i >> topo_layers[layer].id_shift; +#if defined(DEV_ACPI) && MAXMEMDOM > 1 + if (topo_layers[layer].type == TOPO_TYPE_NODE) { + node_id = acpi_pxm_get_cpu_locality(i); + } else +#endif + node_id = i >> topo_layers[layer].id_shift; parent = topo_add_node_by_hwid(parent, node_id, topo_layers[layer].type, topo_layers[layer].subtype); @@ -598,7 +637,12 @@ topo_probe(void) parent = &topo_root; for (layer = 0; layer < nlayers; ++layer) { - node_id = boot_cpu_id >> topo_layers[layer].id_shift; +#if defined(DEV_ACPI) && MAXMEMDOM > 1 + if (topo_layers[layer].type == TOPO_TYPE_NODE) + node_id = acpi_pxm_get_cpu_locality(boot_cpu_id); + else +#endif + node_id = boot_cpu_id >> topo_layers[layer].id_shift; node = topo_find_node_by_hwid(parent, node_id, topo_layers[layer].type, topo_layers[layer].subtype); @@ -773,14 +817,18 @@ x86topo_add_sched_group(struct topo_node *root, struct cpu_group *cg_root) int i; KASSERT(root->type == TOPO_TYPE_SYSTEM || root->type == TOPO_TYPE_CACHE || - root->type == TOPO_TYPE_GROUP, + root->type == TOPO_TYPE_NODE || root->type == TOPO_TYPE_GROUP, ("x86topo_add_sched_group: bad type: %u", root->type)); CPU_COPY(&root->cpuset, &cg_root->cg_mask); cg_root->cg_count = root->cpu_count; - if (root->type == TOPO_TYPE_SYSTEM) + if (root->type == TOPO_TYPE_CACHE) + cg_root->cg_level = root->subtype; + else cg_root->cg_level = CG_SHARE_NONE; + if (root->type == TOPO_TYPE_NODE) + cg_root->cg_flags = CG_FLAG_NODE; else - cg_root->cg_level = root->subtype; + cg_root->cg_flags = 0; /* * Check how many core nodes we have under the given root node. @@ -801,7 +849,7 @@ x86topo_add_sched_group(struct topo_node *root, struct cpu_group *cg_root) if (cg_root->cg_level != CG_SHARE_NONE && root->cpu_count > 1 && ncores < 2) - cg_root->cg_flags = CG_FLAG_SMT; + cg_root->cg_flags |= CG_FLAG_SMT; /* * Find out how many cache nodes we have under the given root node. @@ -813,10 +861,18 @@ x86topo_add_sched_group(struct topo_node *root, struct cpu_group *cg_root) nchildren = 0; node = root; while (node != NULL) { - if ((node->type != TOPO_TYPE_GROUP && - node->type != TOPO_TYPE_CACHE) || - (root->type != TOPO_TYPE_SYSTEM && - CPU_CMP(&node->cpuset, &root->cpuset) == 0)) { + if (CPU_CMP(&node->cpuset, &root->cpuset) == 0) { + if (node->type == TOPO_TYPE_CACHE && + cg_root->cg_level < node->subtype) + cg_root->cg_level = node->subtype; + if (node->type == TOPO_TYPE_NODE) + cg_root->cg_flags |= CG_FLAG_NODE; + node = topo_next_node(root, node); + continue; + } + if (node->type != TOPO_TYPE_GROUP && + node->type != TOPO_TYPE_NODE && + node->type != TOPO_TYPE_CACHE) { node = topo_next_node(root, node); continue; } @@ -841,9 +897,9 @@ x86topo_add_sched_group(struct topo_node *root, struct cpu_group *cg_root) i = 0; while (node != NULL) { if ((node->type != TOPO_TYPE_GROUP && + node->type != TOPO_TYPE_NODE && node->type != TOPO_TYPE_CACHE) || - (root->type != TOPO_TYPE_SYSTEM && - CPU_CMP(&node->cpuset, &root->cpuset) == 0)) { + CPU_CMP(&node->cpuset, &root->cpuset) == 0) { node = topo_next_node(root, node); continue; } From nobody Thu Oct 21 22:31:37 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1625D18132FE; Thu, 21 Oct 2021 22:31: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 4Hb2Jp3WLKz4fJR; Thu, 21 Oct 2021 22:31: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 5AA2D2352F; Thu, 21 Oct 2021 22:31: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 19LMVbfd018861; Thu, 21 Oct 2021 22:31:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMVboT018860; Thu, 21 Oct 2021 22:31:37 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:31:37 GMT Message-Id: <202110212231.19LMVboT018860@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: 11f14b33629e - stable/13 - sched_ule(4): Fix hang with steal_thresh < 2. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 11f14b33629e552a451fdbfe653ebb0addd27700 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=11f14b33629e552a451fdbfe653ebb0addd27700 commit 11f14b33629e552a451fdbfe653ebb0addd27700 Author: Alexander Motin AuthorDate: 2021-09-26 16:03:05 +0000 Commit: Alexander Motin CommitDate: 2021-10-21 22:24:36 +0000 sched_ule(4): Fix hang with steal_thresh < 2. e745d729be60 caused infinite loop with interrupts disabled in load stealing code if steal_thresh set below 2. Such configuration should not generally be used, but appeared some people are using it to workaround some problems. To fix the problem explicitly pass to sched_highest() minimum number of transferrable threads, supported by the caller, instead of guessing. MFC after: 25 days (cherry picked from commit 08063e9f98a33980a09e3bd465926719b3437122) --- sys/kern/sched_ule.c | 70 +++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 98c1f0bca981..6f072c518934 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -638,12 +638,13 @@ struct cpu_search { int cs_prefer; /* Prefer this CPU and groups including it. */ int cs_running; /* The thread is now running at cs_prefer. */ int cs_pri; /* Min priority for low. */ - int cs_limit; /* Max load for low, min load for high. */ + int cs_load; /* Max load for low, min load for high. */ + int cs_trans; /* Min transferable load for high. */ }; struct cpu_search_res { - int cs_cpu; /* The best CPU found. */ - int cs_load; /* The load of cs_cpu. */ + int csr_cpu; /* The best CPU found. */ + int csr_load; /* The load of cs_cpu. */ }; /* @@ -663,7 +664,7 @@ cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, total = 0; bload = INT_MAX; - r->cs_cpu = -1; + r->csr_cpu = -1; /* Loop through children CPU groups if there are any. */ if (cg->cg_children > 0) { @@ -681,11 +682,11 @@ cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, load >= 128 && (load & 128) != 0) load += 128; - if (lr.cs_cpu >= 0 && (load < bload || - (load == bload && lr.cs_load < r->cs_load))) { + if (lr.csr_cpu >= 0 && (load < bload || + (load == bload && lr.csr_load < r->csr_load))) { bload = load; - r->cs_cpu = lr.cs_cpu; - r->cs_load = lr.cs_load; + r->csr_cpu = lr.csr_cpu; + r->csr_load = lr.csr_load; } } return (total); @@ -711,7 +712,7 @@ cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, * If the threads is already on the CPU, don't look on the TDQ * priority, since it can be the priority of the thread itself. */ - if (l > s->cs_limit || (tdq->tdq_lowpri <= s->cs_pri && + if (l > s->cs_load || (tdq->tdq_lowpri <= s->cs_pri && (!s->cs_running || c != s->cs_prefer)) || !CPU_ISSET(c, s->cs_mask)) continue; @@ -727,8 +728,8 @@ cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, load -= sched_random() % 128; if (bload > load - p) { bload = load - p; - r->cs_cpu = c; - r->cs_load = load; + r->csr_cpu = c; + r->csr_load = load; } } return (total); @@ -744,18 +745,18 @@ cpu_search_highest(const struct cpu_group *cg, const struct cpu_search *s, total = 0; bload = INT_MIN; - r->cs_cpu = -1; + r->csr_cpu = -1; /* Loop through children CPU groups if there are any. */ if (cg->cg_children > 0) { for (c = cg->cg_children - 1; c >= 0; c--) { load = cpu_search_highest(&cg->cg_child[c], s, &lr); total += load; - if (lr.cs_cpu >= 0 && (load > bload || - (load == bload && lr.cs_load > r->cs_load))) { + if (lr.csr_cpu >= 0 && (load > bload || + (load == bload && lr.csr_load > r->csr_load))) { bload = load; - r->cs_cpu = lr.cs_cpu; - r->cs_load = lr.cs_load; + r->csr_cpu = lr.csr_cpu; + r->csr_load = lr.csr_load; } } return (total); @@ -772,21 +773,18 @@ cpu_search_highest(const struct cpu_group *cg, const struct cpu_search *s, /* * Check this CPU is acceptable. - * If requested minimum load is 1, then caller must know how - * to handle running threads, not counted in tdq_transferable. */ - if (l < s->cs_limit || (tdq->tdq_transferable == 0 && - (s->cs_limit > 1 || l > 1)) || + if (l < s->cs_load || (tdq->tdq_transferable < s->cs_trans) || !CPU_ISSET(c, s->cs_mask)) continue; load -= sched_random() % 256; if (load > bload) { bload = load; - r->cs_cpu = c; + r->csr_cpu = c; } } - r->cs_load = bload; + r->csr_load = bload; return (total); } @@ -806,24 +804,26 @@ sched_lowest(const struct cpu_group *cg, cpuset_t *mask, int pri, int maxload, s.cs_running = running; s.cs_mask = mask; s.cs_pri = pri; - s.cs_limit = maxload; + s.cs_load = maxload; cpu_search_lowest(cg, &s, &r); - return (r.cs_cpu); + return (r.csr_cpu); } /* * Find the cpu with the highest load via the highest loaded path. */ static inline int -sched_highest(const struct cpu_group *cg, cpuset_t *mask, int minload) +sched_highest(const struct cpu_group *cg, cpuset_t *mask, int minload, + int mintrans) { struct cpu_search s; struct cpu_search_res r; s.cs_mask = mask; - s.cs_limit = minload; + s.cs_load = minload; + s.cs_trans = mintrans; cpu_search_highest(cg, &s, &r); - return (r.cs_cpu); + return (r.csr_cpu); } static void @@ -836,7 +836,7 @@ sched_balance_group(struct cpu_group *cg) CPU_FILL(&hmask); for (;;) { - high = sched_highest(cg, &hmask, 1); + high = sched_highest(cg, &hmask, 1, 0); /* Stop if there is no more CPU with transferrable threads. */ if (high == -1) break; @@ -1008,7 +1008,7 @@ tdq_idled(struct tdq *tdq) restart: switchcnt = tdq->tdq_switchcnt + tdq->tdq_oldswitchcnt; for (cg = tdq->tdq_cg, goup = 0; ; ) { - cpu = sched_highest(cg, &mask, steal_thresh); + cpu = sched_highest(cg, &mask, steal_thresh, 1); /* * We were assigned a thread but not preempted. Returning * 0 here will cause our caller to switch to it. @@ -1968,7 +1968,8 @@ tdq_trysteal(struct tdq *tdq) cpuset_t mask; int cpu, i, goup; - if (smp_started == 0 || trysteal_limit == 0 || tdq->tdq_cg == NULL) + if (smp_started == 0 || steal_idle == 0 || trysteal_limit == 0 || + tdq->tdq_cg == NULL) return; CPU_FILL(&mask); CPU_CLR(PCPU_GET(cpuid), &mask); @@ -1976,7 +1977,7 @@ tdq_trysteal(struct tdq *tdq) spinlock_enter(); TDQ_UNLOCK(tdq); for (i = 1, cg = tdq->tdq_cg, goup = 0; ; ) { - cpu = sched_highest(cg, &mask, steal_thresh); + cpu = sched_highest(cg, &mask, steal_thresh, 1); /* * If a thread was added while interrupts were disabled don't * steal one here. @@ -2019,7 +2020,9 @@ tdq_trysteal(struct tdq *tdq) steal = TDQ_CPU(cpu); /* * The data returned by sched_highest() is stale and - * the chosen CPU no longer has an eligible thread. + * the chosen CPU no longer has an eligible thread. + * At this point unconditonally exit the loop to bound + * the time spent in the critcal section. */ if (steal->tdq_load < steal_thresh || steal->tdq_transferable == 0) @@ -2028,8 +2031,7 @@ tdq_trysteal(struct tdq *tdq) * Try to lock both queues. If we are assigned a thread while * waited for the lock, switch to it now instead of stealing. * If we can't get the lock, then somebody likely got there - * first. At this point unconditonally exit the loop to - * bound the time spent in the critcal section. + * first. */ TDQ_LOCK(tdq); if (tdq->tdq_load > 0) From nobody Thu Oct 21 22:31:38 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A5D09181363C; Thu, 21 Oct 2021 22:31: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 4Hb2Jq3LD9z4fXP; Thu, 21 Oct 2021 22:31: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 70F62234EE; Thu, 21 Oct 2021 22:31: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 19LMVcD0018885; Thu, 21 Oct 2021 22:31:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMVc0d018884; Thu, 21 Oct 2021 22:31:38 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:31:38 GMT Message-Id: <202110212231.19LMVc0d018884@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: 1e7091ac7cf2 - stable/13 - sched_ule(4): Fix possible significance loss. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 1e7091ac7cf222a1fbc2b318b1b12b16fcbb5b50 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=1e7091ac7cf222a1fbc2b318b1b12b16fcbb5b50 commit 1e7091ac7cf222a1fbc2b318b1b12b16fcbb5b50 Author: Alexander Motin AuthorDate: 2021-10-02 03:47:18 +0000 Commit: Alexander Motin CommitDate: 2021-10-21 22:24:36 +0000 sched_ule(4): Fix possible significance loss. Before this change kern.sched.interact sysctl setting above 32 gave all interactive threads identical priority of PRI_MIN_INTERACT due to ((PRI_MAX_INTERACT - PRI_MIN_INTERACT + 1) / sched_interact) turning zero. Setting the sysctl lower reduced the range of used priority levels up to half, that is not great either. Change of the operations order should fix the issue, always using full range of priorities, while overflow is impossible there since both score and priority values are small. While there, make the variables unsigned as they really are. MFC after: 1 month (cherry picked from commit 1c119e173ddc7f5603a3b6cf940dc524e494a667) --- sys/kern/sched_ule.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 6f072c518934..708c19b27394 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -207,7 +207,7 @@ _Static_assert(sizeof(struct thread) + sizeof(struct td_sched) <= * sched_slice: Runtime of each thread before rescheduling. * preempt_thresh: Priority threshold for preemption and remote IPIs. */ -static int __read_mostly sched_interact = SCHED_INTERACT_THRESH; +static u_int __read_mostly sched_interact = SCHED_INTERACT_THRESH; static int __read_mostly tickincr = 8 << SCHED_TICK_SHIFT; static int __read_mostly realstathz = 127; /* reset during boot. */ static int __read_mostly sched_slice = 10; /* reset during boot. */ @@ -1616,8 +1616,7 @@ sched_interact_score(struct thread *td) static void sched_priority(struct thread *td) { - int score; - int pri; + u_int pri, score; if (PRI_BASE(td->td_pri_class) != PRI_TIMESHARE) return; @@ -1637,10 +1636,10 @@ sched_priority(struct thread *td) score = imax(0, sched_interact_score(td) + td->td_proc->p_nice); if (score < sched_interact) { pri = PRI_MIN_INTERACT; - pri += ((PRI_MAX_INTERACT - PRI_MIN_INTERACT + 1) / - sched_interact) * score; + pri += (PRI_MAX_INTERACT - PRI_MIN_INTERACT + 1) * score / + sched_interact; KASSERT(pri >= PRI_MIN_INTERACT && pri <= PRI_MAX_INTERACT, - ("sched_priority: invalid interactive priority %d score %d", + ("sched_priority: invalid interactive priority %u score %u", pri, score)); } else { pri = SCHED_PRI_MIN; @@ -1649,7 +1648,7 @@ sched_priority(struct thread *td) SCHED_PRI_RANGE - 1); pri += SCHED_PRI_NICE(td->td_proc->p_nice); KASSERT(pri >= PRI_MIN_BATCH && pri <= PRI_MAX_BATCH, - ("sched_priority: invalid priority %d: nice %d, " + ("sched_priority: invalid priority %u: nice %d, " "ticks %d ftick %d ltick %d tick pri %d", pri, td->td_proc->p_nice, td_get_sched(td)->ts_ticks, td_get_sched(td)->ts_ftick, td_get_sched(td)->ts_ltick, @@ -3174,7 +3173,7 @@ SYSCTL_PROC(_kern_sched, OID_AUTO, quantum, "Quantum for timeshare threads in microseconds"); SYSCTL_INT(_kern_sched, OID_AUTO, slice, CTLFLAG_RW, &sched_slice, 0, "Quantum for timeshare threads in stathz ticks"); -SYSCTL_INT(_kern_sched, OID_AUTO, interact, CTLFLAG_RW, &sched_interact, 0, +SYSCTL_UINT(_kern_sched, OID_AUTO, interact, CTLFLAG_RW, &sched_interact, 0, "Interactivity score threshold"); SYSCTL_INT(_kern_sched, OID_AUTO, preempt_thresh, CTLFLAG_RW, &preempt_thresh, 0, From nobody Thu Oct 21 22:44:55 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8B247181A38C; Thu, 21 Oct 2021 22:44: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 4Hb2c73ZcTz4lQH; Thu, 21 Oct 2021 22:44: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 56EAE236BF; Thu, 21 Oct 2021 22:44: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 19LMit9p033399; Thu, 21 Oct 2021 22:44:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMituh033398; Thu, 21 Oct 2021 22:44:55 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:44:55 GMT Message-Id: <202110212244.19LMituh033398@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: b7eded5ea1f1 - stable/12 - sched_ule(4): Fix possible significance loss. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: b7eded5ea1f1b051489627989c13d9e48521ed9f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=b7eded5ea1f1b051489627989c13d9e48521ed9f commit b7eded5ea1f1b051489627989c13d9e48521ed9f Author: Alexander Motin AuthorDate: 2021-10-02 03:47:18 +0000 Commit: Alexander Motin CommitDate: 2021-10-21 22:44:29 +0000 sched_ule(4): Fix possible significance loss. Before this change kern.sched.interact sysctl setting above 32 gave all interactive threads identical priority of PRI_MIN_INTERACT due to ((PRI_MAX_INTERACT - PRI_MIN_INTERACT + 1) / sched_interact) turning zero. Setting the sysctl lower reduced the range of used priority levels up to half, that is not great either. Change of the operations order should fix the issue, always using full range of priorities, while overflow is impossible there since both score and priority values are small. While there, make the variables unsigned as they really are. MFC after: 1 month (cherry picked from commit 1c119e173ddc7f5603a3b6cf940dc524e494a667) --- sys/kern/sched_ule.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 20835a0b2c5f..ed5cef8ab80a 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -206,7 +206,7 @@ _Static_assert(sizeof(struct thread) + sizeof(struct td_sched) <= * sched_slice: Runtime of each thread before rescheduling. * preempt_thresh: Priority threshold for preemption and remote IPIs. */ -static int __read_mostly sched_interact = SCHED_INTERACT_THRESH; +static u_int __read_mostly sched_interact = SCHED_INTERACT_THRESH; static int __read_mostly tickincr = 8 << SCHED_TICK_SHIFT; static int __read_mostly realstathz = 127; /* reset during boot. */ static int __read_mostly sched_slice = 10; /* reset during boot. */ @@ -1576,8 +1576,7 @@ sched_interact_score(struct thread *td) static void sched_priority(struct thread *td) { - int score; - int pri; + u_int pri, score; if (PRI_BASE(td->td_pri_class) != PRI_TIMESHARE) return; @@ -1597,10 +1596,10 @@ sched_priority(struct thread *td) score = imax(0, sched_interact_score(td) + td->td_proc->p_nice); if (score < sched_interact) { pri = PRI_MIN_INTERACT; - pri += ((PRI_MAX_INTERACT - PRI_MIN_INTERACT + 1) / - sched_interact) * score; + pri += (PRI_MAX_INTERACT - PRI_MIN_INTERACT + 1) * score / + sched_interact; KASSERT(pri >= PRI_MIN_INTERACT && pri <= PRI_MAX_INTERACT, - ("sched_priority: invalid interactive priority %d score %d", + ("sched_priority: invalid interactive priority %u score %u", pri, score)); } else { pri = SCHED_PRI_MIN; @@ -1609,7 +1608,7 @@ sched_priority(struct thread *td) SCHED_PRI_RANGE - 1); pri += SCHED_PRI_NICE(td->td_proc->p_nice); KASSERT(pri >= PRI_MIN_BATCH && pri <= PRI_MAX_BATCH, - ("sched_priority: invalid priority %d: nice %d, " + ("sched_priority: invalid priority %u: nice %d, " "ticks %d ftick %d ltick %d tick pri %d", pri, td->td_proc->p_nice, td_get_sched(td)->ts_ticks, td_get_sched(td)->ts_ftick, td_get_sched(td)->ts_ltick, @@ -3070,7 +3069,7 @@ SYSCTL_PROC(_kern_sched, OID_AUTO, quantum, CTLTYPE_INT | CTLFLAG_RW, "Quantum for timeshare threads in microseconds"); SYSCTL_INT(_kern_sched, OID_AUTO, slice, CTLFLAG_RW, &sched_slice, 0, "Quantum for timeshare threads in stathz ticks"); -SYSCTL_INT(_kern_sched, OID_AUTO, interact, CTLFLAG_RW, &sched_interact, 0, +SYSCTL_UINT(_kern_sched, OID_AUTO, interact, CTLFLAG_RW, &sched_interact, 0, "Interactivity score threshold"); SYSCTL_INT(_kern_sched, OID_AUTO, preempt_thresh, CTLFLAG_RW, &preempt_thresh, 0, From nobody Thu Oct 21 22:48:09 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 788D5181A904; Thu, 21 Oct 2021 22:48:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hb2gs30xtz4m00; Thu, 21 Oct 2021 22:48:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 470AC236C1; Thu, 21 Oct 2021 22:48:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19LMm9X5033738; Thu, 21 Oct 2021 22:48:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LMm9Pv033737; Thu, 21 Oct 2021 22:48:09 GMT (envelope-from git) Date: Thu, 21 Oct 2021 22:48:09 GMT Message-Id: <202110212248.19LMm9Pv033737@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 51a3024ee71a - releng/12.3 - 12.3: Makefile: add a newline to validate the git->svn exporter List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.3 X-Git-Reftype: branch X-Git-Commit: 51a3024ee71a1ffebed139a40a534cdb2284d888 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/12.3 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=51a3024ee71a1ffebed139a40a534cdb2284d888 commit 51a3024ee71a1ffebed139a40a534cdb2284d888 Author: Glen Barber AuthorDate: 2021-10-21 22:47:31 +0000 Commit: Glen Barber CommitDate: 2021-10-21 22:47:31 +0000 12.3: Makefile: add a newline to validate the git->svn exporter Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 21ce26f215c9..f86f483f55d6 100644 --- a/Makefile +++ b/Makefile @@ -743,3 +743,4 @@ MAKE_JOB_ERROR_TOKEN= no .endif # bmake .endif # DIRDEPS_BUILD + From nobody Thu Oct 21 23:09:11 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D158817F2EAB; Thu, 21 Oct 2021 23:09: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 4Hb3875dwBz4sHF; Thu, 21 Oct 2021 23:09: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 9E94D23C37; Thu, 21 Oct 2021 23:09: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 19LN9B3V061167; Thu, 21 Oct 2021 23:09:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19LN9B6t061166; Thu, 21 Oct 2021 23:09:11 GMT (envelope-from git) Date: Thu, 21 Oct 2021 23:09:11 GMT Message-Id: <202110212309.19LN9B6t061166@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: b9c0a61651a2 - releng/12.3 - Revert "12.3: Makefile: add a newline to validate the git->svn exporter" List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.3 X-Git-Reftype: branch X-Git-Commit: b9c0a61651a21c2c6dc546479f382c5a5831bdb5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/12.3 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=b9c0a61651a21c2c6dc546479f382c5a5831bdb5 commit b9c0a61651a21c2c6dc546479f382c5a5831bdb5 Author: Glen Barber AuthorDate: 2021-10-21 23:08:30 +0000 Commit: Glen Barber CommitDate: 2021-10-21 23:08:30 +0000 Revert "12.3: Makefile: add a newline to validate the git->svn exporter" This reverts commit 51a3024ee71a1ffebed139a40a534cdb2284d888. Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index f86f483f55d6..21ce26f215c9 100644 --- a/Makefile +++ b/Makefile @@ -743,4 +743,3 @@ MAKE_JOB_ERROR_TOKEN= no .endif # bmake .endif # DIRDEPS_BUILD - From nobody Fri Oct 22 04:00:04 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 606401805431; Fri, 22 Oct 2021 04:00: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 4Hb9bm2Hhcz3PZT; Fri, 22 Oct 2021 04:00: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 2E6F627B98; Fri, 22 Oct 2021 04:00: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 19M4043S049035; Fri, 22 Oct 2021 04:00:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19M404RC049032; Fri, 22 Oct 2021 04:00:04 GMT (envelope-from git) Date: Fri, 22 Oct 2021 04:00:04 GMT Message-Id: <202110220400.19M404RC049032@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: d8359af5b642 - stable/13 - devd(8): Note default config file search locations List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d8359af5b642c0d194aedce90ebd1415e0c483d6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by ygy (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=d8359af5b642c0d194aedce90ebd1415e0c483d6 commit d8359af5b642c0d194aedce90ebd1415e0c483d6 Author: Felix Johnson AuthorDate: 2021-10-19 04:37:40 +0000 Commit: Guangyuan Yang CommitDate: 2021-10-22 03:59:17 +0000 devd(8): Note default config file search locations PR: 197003 Reported by: Harald Schmalzbauer (cherry picked from commit bad324ace4f817206baf86ae7379c35c8199048e) --- sbin/devd/devd.8 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sbin/devd/devd.8 b/sbin/devd/devd.8 index fa05db734b88..77c8e4aac2fb 100644 --- a/sbin/devd/devd.8 +++ b/sbin/devd/devd.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 5, 2016 +.Dd October 19, 2021 .Dt DEVD 8 .Os .Sh NAME @@ -115,10 +115,16 @@ option and uses that file to drive the rest of the process. While the format of this file is described in .Xr devd.conf 5 , some basics are covered here. +.Pp In the .Ic options section, one can define multiple directories to search for config files. +The default config file specifies +.Pa /etc/devd +and +.Pa /usr/local/etc/devd +as directories to search. All files in these directories whose names match the pattern .Pa *.conf are parsed. From nobody Fri Oct 22 12:32:40 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8C5C817F7EA4; Fri, 22 Oct 2021 12:32: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 4HbNzD3RkTz4ZSj; Fri, 22 Oct 2021 12:32: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 566976CC6; Fri, 22 Oct 2021 12:32: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 19MCWeEm038450; Fri, 22 Oct 2021 12:32:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWeaT038449; Fri, 22 Oct 2021 12:32:40 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:40 GMT Message-Id: <202110221232.19MCWeaT038449@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: e089cda88b78 - stable/13 - pfctl: Remove unused variable List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: e089cda88b7885e23043b8a46f9c9add6a285443 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e089cda88b7885e23043b8a46f9c9add6a285443 commit e089cda88b7885e23043b8a46f9c9add6a285443 Author: Kristof Provost AuthorDate: 2021-09-30 15:25:45 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:32:24 +0000 pfctl: Remove unused variable MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 90dedf0fef71d3e3081015525665bf335f9c7ee3) --- sbin/pfctl/parse.y | 1 - sbin/pfctl/pfctl_parser.h | 1 - 2 files changed, 2 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index b7b934e6c2ef..7457e4346895 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -854,7 +854,6 @@ pfa_anchor : '{' /* steping into a brace anchor */ pf->asd++; pf->bn++; - pf->brace = 1; /* create a holding ruleset in the root */ snprintf(ta, PF_ANCHOR_NAME_SIZE, "_%d", pf->bn); diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 484830c61791..4e144b97567b 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -82,7 +82,6 @@ struct pfctl { int loadopt; int asd; /* anchor stack depth */ int bn; /* brace number */ - int brace; int tdirty; /* kernel dirty */ #define PFCTL_ANCHOR_STACK_DEPTH 64 struct pfctl_anchor *astack[PFCTL_ANCHOR_STACK_DEPTH]; From nobody Fri Oct 22 12:32:41 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6391617F7E31; Fri, 22 Oct 2021 12:32: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 4HbNzF5D0Fz4Z7J; Fri, 22 Oct 2021 12:32: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 7A4746B4E; Fri, 22 Oct 2021 12:32: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 19MCWfTq038483; Fri, 22 Oct 2021 12:32:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWfvn038482; Fri, 22 Oct 2021 12:32:41 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:41 GMT Message-Id: <202110221232.19MCWfvn038482@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: 00ff2b29a9ba - stable/13 - pf: remove unused field from pf_kanchor List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 00ff2b29a9ba563b6b2f324c0c9378ea286e17df Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=00ff2b29a9ba563b6b2f324c0c9378ea286e17df commit 00ff2b29a9ba563b6b2f324c0c9378ea286e17df Author: Kristof Provost AuthorDate: 2021-10-04 08:58:27 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:08 +0000 pf: remove unused field from pf_kanchor The 'match' field is only used in the userspace version of the struct (pf_anchor). MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 76c2e71c4c65a85279505005716aa43101c47bf7) --- sys/net/pfvar.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index e142976c588e..9fb231e95a2c 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1044,7 +1044,6 @@ struct pf_kanchor { char path[MAXPATHLEN]; struct pf_kruleset ruleset; int refcnt; /* anchor rules */ - int match; /* XXX: used for pfctl black magic */ }; RB_PROTOTYPE(pf_kanchor_global, pf_kanchor, entry_global, pf_anchor_compare); RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare); From nobody Fri Oct 22 12:32:42 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 683F01800020; Fri, 22 Oct 2021 12:32: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 4HbNzG6RPMz4ZZQ; Fri, 22 Oct 2021 12:32: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 93A786561; Fri, 22 Oct 2021 12:32: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 19MCWgPu038516; Fri, 22 Oct 2021 12:32:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWgBM038515; Fri, 22 Oct 2021 12:32:42 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:42 GMT Message-Id: <202110221232.19MCWgBM038515@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: 56dc7a08bff8 - stable/13 - pf: do not copy anchor_wildcard / anchor_relative from userspace List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 56dc7a08bff8e0d8edde89ab9fecc3c6a7e375e4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=56dc7a08bff8e0d8edde89ab9fecc3c6a7e375e4 commit 56dc7a08bff8e0d8edde89ab9fecc3c6a7e375e4 Author: Kristof Provost AuthorDate: 2021-10-08 13:13:21 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:18 +0000 pf: do not copy anchor_wildcard / anchor_relative from userspace We overwrite these fields again in pf_kanchor_setup() anyway. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 1c680e620bf7e53d043d10b23bdfc980e45e6455) --- sys/netpfil/pf/pf_ioctl.c | 2 -- sys/netpfil/pf/pf_nv.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 7a8d0cdda836..7b68110b0f99 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1823,8 +1823,6 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule) krule->return_ttl = rule->return_ttl; krule->tos = rule->tos; krule->set_tos = rule->set_tos; - krule->anchor_relative = rule->anchor_relative; - krule->anchor_wildcard = rule->anchor_wildcard; krule->flush = rule->flush; krule->prio = rule->prio; diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index 5eda6b3917f4..d53c6fe4b84e 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -603,8 +603,6 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule *rule) PFNV_CHK(pf_nvuint8(nvl, "return_ttl", &rule->return_ttl)); PFNV_CHK(pf_nvuint8(nvl, "tos", &rule->tos)); PFNV_CHK(pf_nvuint8(nvl, "set_tos", &rule->set_tos)); - PFNV_CHK(pf_nvuint8(nvl, "anchor_relative", &rule->anchor_relative)); - PFNV_CHK(pf_nvuint8(nvl, "anchor_wildcard", &rule->anchor_wildcard)); PFNV_CHK(pf_nvuint8(nvl, "flush", &rule->flush)); PFNV_CHK(pf_nvuint8(nvl, "prio", &rule->prio)); From nobody Fri Oct 22 12:32:44 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D967218000BA; Fri, 22 Oct 2021 12:32: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 4HbNzK4F2Zz4ZK2; Fri, 22 Oct 2021 12:32: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 E22E76BA5; Fri, 22 Oct 2021 12:32: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 19MCWitE038564; Fri, 22 Oct 2021 12:32:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWij1038563; Fri, 22 Oct 2021 12:32:44 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:44 GMT Message-Id: <202110221232.19MCWij1038563@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: 9365113e89a5 - stable/13 - pf tests: ensure that $nr expansion is correct List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 9365113e89a52ce025d4097a5986e2228234f5ca Auto-Submitted: auto-generated X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9365113e89a52ce025d4097a5986e2228234f5ca commit 9365113e89a52ce025d4097a5986e2228234f5ca Author: Kristof Provost AuthorDate: 2021-10-03 16:07:04 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:33 +0000 pf tests: ensure that $nr expansion is correct Test the $nr expansion in labels is correct, even if the optimiser reduces the rule count. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32489 (cherry picked from commit 914ec9c78dcd5d8f77552fb93d3bc15efe9c0f40) --- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/macro.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 2f9ce73f381b..246c267e7d2b 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -14,6 +14,7 @@ ATF_TESTS_SH+= altq \ get_state \ icmp \ killstate \ + macro \ map_e \ names \ nat \ diff --git a/tests/sys/netpfil/pf/macro.sh b/tests/sys/netpfil/pf/macro.sh new file mode 100644 index 000000000000..442677c9f946 --- /dev/null +++ b/tests/sys/netpfil/pf/macro.sh @@ -0,0 +1,40 @@ +. $(atf_get_srcdir)/utils.subr + +atf_test_case "nr" "cleanup" +nr_head() +{ + atf_set descr 'Test $nr expansion' + atf_set require.user root +} + +nr_body() +{ + # Ensure that when the optimiser collapses rules the macro expansion + # has the correct rule number + pft_init + + vnet_mkjail alcatraz + jexec alcatraz ifconfig lo0 inet 127.0.0.1/8 + jexec alcatraz ifconfig lo0 inet 127.0.0.2/32 alias + + pft_set_rules alcatraz \ + "pass quick on lo from lo:network to lo:network" \ + "block quick all label \"ruleNo:\$nr\"" + + no=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub("@", "", $1); print $1; }') + ruleno=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub(/"ruleNo:/, "", $7); gsub(/"/, "", $7); print $7; }') + if [ "${no}" -ne "${ruleno}" ]; + then + atf_fail "Expected ruleNo $no != $ruleno" + fi +} + +nr_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "nr" +} From nobody Fri Oct 22 12:32:43 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4866717F7EB8; Fri, 22 Oct 2021 12:32: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 4HbNzJ0N5Wz4ZV4; Fri, 22 Oct 2021 12:32: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 B83EA6D08; Fri, 22 Oct 2021 12:32: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 19MCWh5t038540; Fri, 22 Oct 2021 12:32:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWh0V038539; Fri, 22 Oct 2021 12:32:43 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:43 GMT Message-Id: <202110221232.19MCWh0V038539@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: 35237559a6a0 - stable/13 - pfctl: delay label macro expansion until after rule optimisation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 35237559a6a0ad0b16abcc6809c2e145931c5e9a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=35237559a6a0ad0b16abcc6809c2e145931c5e9a commit 35237559a6a0ad0b16abcc6809c2e145931c5e9a Author: Kristof Provost AuthorDate: 2021-10-13 14:06:47 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:25 +0000 pfctl: delay label macro expansion until after rule optimisation We used to expand the $nr macro in labels into the rule number prior to the optimisation step. This would occasionally produce incorrect rule numbers in the labels. Delay all macro expansion until after the optimisation step to ensure that we expand the correct values. MFC after: 1 week Reported by: Özkan KIRIK Differential Revision: https://reviews.freebsd.org/D32488 (cherry picked from commit 09c7f2386973f8c36978895a7600320916bc3d07) --- sbin/pfctl/parse.y | 85 +++++++++++++++++++++++------------------------------- sbin/pfctl/pfctl.c | 6 ++++ sbin/pfctl/pfctl.h | 2 ++ 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 7457e4346895..c8a310688ca7 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -330,14 +330,12 @@ int process_tabledef(char *, struct table_opts *); void expand_label_str(char *, size_t, const char *, const char *); void expand_label_if(const char *, char *, size_t, const char *); void expand_label_addr(const char *, char *, size_t, u_int8_t, - struct node_host *); + struct pf_rule_addr *); void expand_label_port(const char *, char *, size_t, - struct node_port *); + struct pf_rule_addr *); void expand_label_proto(const char *, char *, size_t, u_int8_t); -void expand_label_nr(const char *, char *, size_t); -void expand_label(char *, size_t, const char *, u_int8_t, - struct node_host *, struct node_port *, struct node_host *, - struct node_port *, u_int8_t); +void expand_label_nr(const char *, char *, size_t, + struct pfctl_rule *); void expand_rule(struct pfctl_rule *, struct node_if *, struct node_host *, struct node_proto *, struct node_os *, struct node_host *, struct node_port *, struct node_host *, @@ -4983,17 +4981,17 @@ expand_label_if(const char *name, char *label, size_t len, const char *ifname) void expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, - struct node_host *h) + struct pf_rule_addr *addr) { char tmp[64], tmp_not[66]; if (strstr(label, name) != NULL) { - switch (h->addr.type) { + switch (addr->addr.type) { case PF_ADDR_DYNIFTL: - snprintf(tmp, sizeof(tmp), "(%s)", h->addr.v.ifname); + snprintf(tmp, sizeof(tmp), "(%s)", addr->addr.v.ifname); break; case PF_ADDR_TABLE: - snprintf(tmp, sizeof(tmp), "<%s>", h->addr.v.tblname); + snprintf(tmp, sizeof(tmp), "<%s>", addr->addr.v.tblname); break; case PF_ADDR_NOROUTE: snprintf(tmp, sizeof(tmp), "no-route"); @@ -5002,18 +5000,18 @@ expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, snprintf(tmp, sizeof(tmp), "urpf-failed"); break; case PF_ADDR_ADDRMASK: - if (!af || (PF_AZERO(&h->addr.v.a.addr, af) && - PF_AZERO(&h->addr.v.a.mask, af))) + if (!af || (PF_AZERO(&addr->addr.v.a.addr, af) && + PF_AZERO(&addr->addr.v.a.mask, af))) snprintf(tmp, sizeof(tmp), "any"); else { char a[48]; int bits; - if (inet_ntop(af, &h->addr.v.a.addr, a, + if (inet_ntop(af, &addr->addr.v.a.addr, a, sizeof(a)) == NULL) snprintf(tmp, sizeof(tmp), "?"); else { - bits = unmask(&h->addr.v.a.mask, af); + bits = unmask(&addr->addr.v.a.mask, af); if ((af == AF_INET && bits < 32) || (af == AF_INET6 && bits < 128)) snprintf(tmp, sizeof(tmp), @@ -5029,7 +5027,7 @@ expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, break; } - if (h->not) { + if (addr->neg) { snprintf(tmp_not, sizeof(tmp_not), "! %s", tmp); expand_label_str(label, len, name, tmp_not); } else @@ -5039,30 +5037,30 @@ expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, void expand_label_port(const char *name, char *label, size_t len, - struct node_port *port) + struct pf_rule_addr *addr) { char a1[6], a2[6], op[13] = ""; if (strstr(label, name) != NULL) { - snprintf(a1, sizeof(a1), "%u", ntohs(port->port[0])); - snprintf(a2, sizeof(a2), "%u", ntohs(port->port[1])); - if (!port->op) + snprintf(a1, sizeof(a1), "%u", ntohs(addr->port[0])); + snprintf(a2, sizeof(a2), "%u", ntohs(addr->port[1])); + if (!addr->port_op) ; - else if (port->op == PF_OP_IRG) + else if (addr->port_op == PF_OP_IRG) snprintf(op, sizeof(op), "%s><%s", a1, a2); - else if (port->op == PF_OP_XRG) + else if (addr->port_op == PF_OP_XRG) snprintf(op, sizeof(op), "%s<>%s", a1, a2); - else if (port->op == PF_OP_EQ) + else if (addr->port_op == PF_OP_EQ) snprintf(op, sizeof(op), "%s", a1); - else if (port->op == PF_OP_NE) + else if (addr->port_op == PF_OP_NE) snprintf(op, sizeof(op), "!=%s", a1); - else if (port->op == PF_OP_LT) + else if (addr->port_op == PF_OP_LT) snprintf(op, sizeof(op), "<%s", a1); - else if (port->op == PF_OP_LE) + else if (addr->port_op == PF_OP_LE) snprintf(op, sizeof(op), "<=%s", a1); - else if (port->op == PF_OP_GT) + else if (addr->port_op == PF_OP_GT) snprintf(op, sizeof(op), ">%s", a1); - else if (port->op == PF_OP_GE) + else if (addr->port_op == PF_OP_GE) snprintf(op, sizeof(op), ">=%s", a1); expand_label_str(label, len, name, op); } @@ -5086,29 +5084,27 @@ expand_label_proto(const char *name, char *label, size_t len, u_int8_t proto) } void -expand_label_nr(const char *name, char *label, size_t len) +expand_label_nr(const char *name, char *label, size_t len, + struct pfctl_rule *r) { char n[11]; if (strstr(label, name) != NULL) { - snprintf(n, sizeof(n), "%u", pf->anchor->match); + snprintf(n, sizeof(n), "%u", r->nr); expand_label_str(label, len, name, n); } } void -expand_label(char *label, size_t len, const char *ifname, sa_family_t af, - struct node_host *src_host, struct node_port *src_port, - struct node_host *dst_host, struct node_port *dst_port, - u_int8_t proto) +expand_label(char *label, size_t len, struct pfctl_rule *r) { - expand_label_if("$if", label, len, ifname); - expand_label_addr("$srcaddr", label, len, af, src_host); - expand_label_addr("$dstaddr", label, len, af, dst_host); - expand_label_port("$srcport", label, len, src_port); - expand_label_port("$dstport", label, len, dst_port); - expand_label_proto("$proto", label, len, proto); - expand_label_nr("$nr", label, len); + expand_label_if("$if", label, len, r->ifname); + expand_label_addr("$srcaddr", label, len, r->af, &r->src); + expand_label_addr("$dstaddr", label, len, r->af, &r->dst); + expand_label_port("$srcport", label, len, &r->src); + expand_label_port("$dstport", label, len, &r->dst); + expand_label_proto("$proto", label, len, r->proto); + expand_label_nr("$nr", label, len, r); } int @@ -5442,15 +5438,6 @@ expand_rule(struct pfctl_rule *r, if (strlcpy(r->match_tagname, match_tagname, sizeof(r->match_tagname)) >= sizeof(r->match_tagname)) errx(1, "expand_rule: strlcpy"); - for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) - expand_label(r->label[i], PF_RULE_LABEL_SIZE, - r->ifname, r->af, src_host, src_port, dst_host, - dst_port, proto->proto); - expand_label(r->tagname, PF_TAG_NAME_SIZE, r->ifname, r->af, - src_host, src_port, dst_host, dst_port, proto->proto); - expand_label(r->match_tagname, PF_TAG_NAME_SIZE, r->ifname, - r->af, src_host, src_port, dst_host, dst_port, - proto->proto); error += check_netmask(src_host, r->af); error += check_netmask(dst_host, r->af); diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index d7bde0012e9b..a0eec1b09289 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1528,6 +1528,12 @@ pfctl_load_ruleset(struct pfctl *pf, char *path, struct pfctl_ruleset *rs, while ((r = TAILQ_FIRST(rs->rules[rs_num].active.ptr)) != NULL) { TAILQ_REMOVE(rs->rules[rs_num].active.ptr, r, entries); + + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + expand_label(r->label[i], PF_RULE_LABEL_SIZE, r); + expand_label(r->tagname, PF_TAG_NAME_SIZE, r); + expand_label(r->match_tagname, PF_TAG_NAME_SIZE, r); + if ((error = pfctl_load_rule(pf, path, r, depth))) goto error; if (r->anchor) { diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h index 80ef184fa90f..606eb729cd44 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -138,6 +138,8 @@ void pf_remove_if_empty_ruleset(struct pfctl_ruleset *); struct pfctl_ruleset *pf_find_ruleset(const char *); struct pfctl_ruleset *pf_find_or_create_ruleset(const char *); +void expand_label(char *, size_t, struct pfctl_rule *); + const char *pfctl_proto2name(int); #endif /* _PFCTL_H_ */ From nobody Fri Oct 22 12:32:47 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CBCF117F7EE7; Fri, 22 Oct 2021 12:32: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 4HbNzN0V8mz4ZgS; Fri, 22 Oct 2021 12:32: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 D22536B4F; Fri, 22 Oct 2021 12:32: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 19MCWl5K038758; Fri, 22 Oct 2021 12:32:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWlx2038757; Fri, 22 Oct 2021 12:32:47 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:47 GMT Message-Id: <202110221232.19MCWlx2038757@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: 006fadf8347b - stable/12 - pf: do not copy anchor_wildcard / anchor_relative from userspace List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 006fadf8347bd640b8e4c07288bb744350c56609 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=006fadf8347bd640b8e4c07288bb744350c56609 commit 006fadf8347bd640b8e4c07288bb744350c56609 Author: Kristof Provost AuthorDate: 2021-10-08 13:13:21 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:18 +0000 pf: do not copy anchor_wildcard / anchor_relative from userspace We overwrite these fields again in pf_kanchor_setup() anyway. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 1c680e620bf7e53d043d10b23bdfc980e45e6455) --- sys/netpfil/pf/pf_ioctl.c | 2 -- sys/netpfil/pf/pf_nv.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index bbafaed0c1b0..ff7e4d4235a6 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1792,8 +1792,6 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule) krule->return_ttl = rule->return_ttl; krule->tos = rule->tos; krule->set_tos = rule->set_tos; - krule->anchor_relative = rule->anchor_relative; - krule->anchor_wildcard = rule->anchor_wildcard; krule->flush = rule->flush; krule->prio = rule->prio; diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index 5eda6b3917f4..d53c6fe4b84e 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -603,8 +603,6 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule *rule) PFNV_CHK(pf_nvuint8(nvl, "return_ttl", &rule->return_ttl)); PFNV_CHK(pf_nvuint8(nvl, "tos", &rule->tos)); PFNV_CHK(pf_nvuint8(nvl, "set_tos", &rule->set_tos)); - PFNV_CHK(pf_nvuint8(nvl, "anchor_relative", &rule->anchor_relative)); - PFNV_CHK(pf_nvuint8(nvl, "anchor_wildcard", &rule->anchor_wildcard)); PFNV_CHK(pf_nvuint8(nvl, "flush", &rule->flush)); PFNV_CHK(pf_nvuint8(nvl, "prio", &rule->prio)); From nobody Fri Oct 22 12:32:45 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EE77A17F7ED1; Fri, 22 Oct 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 4HbNzL1g36z4ZgJ; Fri, 22 Oct 2021 12:32: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 886E96CC7; Fri, 22 Oct 2021 12:32: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 19MCWjWv038660; Fri, 22 Oct 2021 12:32:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWjtA038659; Fri, 22 Oct 2021 12:32:45 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:45 GMT Message-Id: <202110221232.19MCWjtA038659@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: 1b46da63eec5 - stable/12 - pfctl: Remove unused variable List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 1b46da63eec5c4cea8eecf2a7f132634903bb1e6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1b46da63eec5c4cea8eecf2a7f132634903bb1e6 commit 1b46da63eec5c4cea8eecf2a7f132634903bb1e6 Author: Kristof Provost AuthorDate: 2021-09-30 15:25:45 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:32:29 +0000 pfctl: Remove unused variable MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 90dedf0fef71d3e3081015525665bf335f9c7ee3) --- sbin/pfctl/parse.y | 1 - sbin/pfctl/pfctl_parser.h | 1 - 2 files changed, 2 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 2bfb1e651d65..5c3f4a07a98a 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -846,7 +846,6 @@ pfa_anchor : '{' /* steping into a brace anchor */ pf->asd++; pf->bn++; - pf->brace = 1; /* create a holding ruleset in the root */ snprintf(ta, PF_ANCHOR_NAME_SIZE, "_%d", pf->bn); diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 484830c61791..4e144b97567b 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -82,7 +82,6 @@ struct pfctl { int loadopt; int asd; /* anchor stack depth */ int bn; /* brace number */ - int brace; int tdirty; /* kernel dirty */ #define PFCTL_ANCHOR_STACK_DEPTH 64 struct pfctl_anchor *astack[PFCTL_ANCHOR_STACK_DEPTH]; From nobody Fri Oct 22 12:32:46 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D58C91800209; Fri, 22 Oct 2021 12:32: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 4HbNzM4x3lz4ZKB; Fri, 22 Oct 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 ACB3B6D09; Fri, 22 Oct 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 19MCWkAw038731; Fri, 22 Oct 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 19MCWkRf038730; Fri, 22 Oct 2021 12:32:46 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:46 GMT Message-Id: <202110221232.19MCWkRf038730@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: 094befb5dbd1 - stable/12 - pf: remove unused field from pf_kanchor List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 094befb5dbd111209b43d2e77c4d03df1f41bc4e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=094befb5dbd111209b43d2e77c4d03df1f41bc4e commit 094befb5dbd111209b43d2e77c4d03df1f41bc4e Author: Kristof Provost AuthorDate: 2021-10-04 08:58:27 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:08 +0000 pf: remove unused field from pf_kanchor The 'match' field is only used in the userspace version of the struct (pf_anchor). MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 76c2e71c4c65a85279505005716aa43101c47bf7) --- sys/net/pfvar.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index b6a1f779c073..6f8d79b27133 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1044,7 +1044,6 @@ struct pf_kanchor { char path[MAXPATHLEN]; struct pf_kruleset ruleset; int refcnt; /* anchor rules */ - int match; /* XXX: used for pfctl black magic */ }; RB_PROTOTYPE(pf_kanchor_global, pf_kanchor, entry_global, pf_anchor_compare); RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare); From nobody Fri Oct 22 12:32:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 41B5418003D1; Fri, 22 Oct 2021 12:32: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 4HbNzR5PGCz4ZMf; Fri, 22 Oct 2021 12:32: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 1669168FA; Fri, 22 Oct 2021 12:32: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 19MCWoMd038806; Fri, 22 Oct 2021 12:32:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWoAn038805; Fri, 22 Oct 2021 12:32:50 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:50 GMT Message-Id: <202110221232.19MCWoAn038805@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: 615433297d67 - stable/12 - pf tests: ensure that $nr expansion is correct List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 615433297d6764b0a243dfe6156a05f619d6379c Auto-Submitted: auto-generated X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=615433297d6764b0a243dfe6156a05f619d6379c commit 615433297d6764b0a243dfe6156a05f619d6379c Author: Kristof Provost AuthorDate: 2021-10-03 16:07:04 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:32 +0000 pf tests: ensure that $nr expansion is correct Test the $nr expansion in labels is correct, even if the optimiser reduces the rule count. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32489 (cherry picked from commit 914ec9c78dcd5d8f77552fb93d3bc15efe9c0f40) --- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/macro.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 3882db287f5a..5a8b5fe8de70 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -14,6 +14,7 @@ ATF_TESTS_SH+= altq \ get_state \ icmp \ killstate \ + macro \ map_e \ names \ nat \ diff --git a/tests/sys/netpfil/pf/macro.sh b/tests/sys/netpfil/pf/macro.sh new file mode 100644 index 000000000000..442677c9f946 --- /dev/null +++ b/tests/sys/netpfil/pf/macro.sh @@ -0,0 +1,40 @@ +. $(atf_get_srcdir)/utils.subr + +atf_test_case "nr" "cleanup" +nr_head() +{ + atf_set descr 'Test $nr expansion' + atf_set require.user root +} + +nr_body() +{ + # Ensure that when the optimiser collapses rules the macro expansion + # has the correct rule number + pft_init + + vnet_mkjail alcatraz + jexec alcatraz ifconfig lo0 inet 127.0.0.1/8 + jexec alcatraz ifconfig lo0 inet 127.0.0.2/32 alias + + pft_set_rules alcatraz \ + "pass quick on lo from lo:network to lo:network" \ + "block quick all label \"ruleNo:\$nr\"" + + no=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub("@", "", $1); print $1; }') + ruleno=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub(/"ruleNo:/, "", $7); gsub(/"/, "", $7); print $7; }') + if [ "${no}" -ne "${ruleno}" ]; + then + atf_fail "Expected ruleNo $no != $ruleno" + fi +} + +nr_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "nr" +} From nobody Fri Oct 22 12:32:48 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 059561800416; Fri, 22 Oct 2021 12:32: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 4HbNzP2xGLz4ZZr; Fri, 22 Oct 2021 12:32: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 EF2D86CC8; Fri, 22 Oct 2021 12:32: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 19MCWm6t038782; Fri, 22 Oct 2021 12:32:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MCWml5038781; Fri, 22 Oct 2021 12:32:48 GMT (envelope-from git) Date: Fri, 22 Oct 2021 12:32:48 GMT Message-Id: <202110221232.19MCWml5038781@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: 6358f57209e2 - stable/12 - pfctl: delay label macro expansion until after rule optimisation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 6358f57209e2d16c2f1a6a9e6df09ba8f20f6868 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6358f57209e2d16c2f1a6a9e6df09ba8f20f6868 commit 6358f57209e2d16c2f1a6a9e6df09ba8f20f6868 Author: Kristof Provost AuthorDate: 2021-10-13 14:06:47 +0000 Commit: Kristof Provost CommitDate: 2021-10-22 07:34:26 +0000 pfctl: delay label macro expansion until after rule optimisation We used to expand the $nr macro in labels into the rule number prior to the optimisation step. This would occasionally produce incorrect rule numbers in the labels. Delay all macro expansion until after the optimisation step to ensure that we expand the correct values. MFC after: 1 week Reported by: Özkan KIRIK Differential Revision: https://reviews.freebsd.org/D32488 (cherry picked from commit 09c7f2386973f8c36978895a7600320916bc3d07) --- sbin/pfctl/parse.y | 85 +++++++++++++++++++++++------------------------------- sbin/pfctl/pfctl.c | 6 ++++ sbin/pfctl/pfctl.h | 2 ++ 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 5c3f4a07a98a..2dd0e6b6ff43 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -330,14 +330,12 @@ int process_tabledef(char *, struct table_opts *); void expand_label_str(char *, size_t, const char *, const char *); void expand_label_if(const char *, char *, size_t, const char *); void expand_label_addr(const char *, char *, size_t, u_int8_t, - struct node_host *); + struct pf_rule_addr *); void expand_label_port(const char *, char *, size_t, - struct node_port *); + struct pf_rule_addr *); void expand_label_proto(const char *, char *, size_t, u_int8_t); -void expand_label_nr(const char *, char *, size_t); -void expand_label(char *, size_t, const char *, u_int8_t, - struct node_host *, struct node_port *, struct node_host *, - struct node_port *, u_int8_t); +void expand_label_nr(const char *, char *, size_t, + struct pfctl_rule *); void expand_rule(struct pfctl_rule *, struct node_if *, struct node_host *, struct node_proto *, struct node_os *, struct node_host *, struct node_port *, struct node_host *, @@ -4975,17 +4973,17 @@ expand_label_if(const char *name, char *label, size_t len, const char *ifname) void expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, - struct node_host *h) + struct pf_rule_addr *addr) { char tmp[64], tmp_not[66]; if (strstr(label, name) != NULL) { - switch (h->addr.type) { + switch (addr->addr.type) { case PF_ADDR_DYNIFTL: - snprintf(tmp, sizeof(tmp), "(%s)", h->addr.v.ifname); + snprintf(tmp, sizeof(tmp), "(%s)", addr->addr.v.ifname); break; case PF_ADDR_TABLE: - snprintf(tmp, sizeof(tmp), "<%s>", h->addr.v.tblname); + snprintf(tmp, sizeof(tmp), "<%s>", addr->addr.v.tblname); break; case PF_ADDR_NOROUTE: snprintf(tmp, sizeof(tmp), "no-route"); @@ -4994,18 +4992,18 @@ expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, snprintf(tmp, sizeof(tmp), "urpf-failed"); break; case PF_ADDR_ADDRMASK: - if (!af || (PF_AZERO(&h->addr.v.a.addr, af) && - PF_AZERO(&h->addr.v.a.mask, af))) + if (!af || (PF_AZERO(&addr->addr.v.a.addr, af) && + PF_AZERO(&addr->addr.v.a.mask, af))) snprintf(tmp, sizeof(tmp), "any"); else { char a[48]; int bits; - if (inet_ntop(af, &h->addr.v.a.addr, a, + if (inet_ntop(af, &addr->addr.v.a.addr, a, sizeof(a)) == NULL) snprintf(tmp, sizeof(tmp), "?"); else { - bits = unmask(&h->addr.v.a.mask, af); + bits = unmask(&addr->addr.v.a.mask, af); if ((af == AF_INET && bits < 32) || (af == AF_INET6 && bits < 128)) snprintf(tmp, sizeof(tmp), @@ -5021,7 +5019,7 @@ expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, break; } - if (h->not) { + if (addr->neg) { snprintf(tmp_not, sizeof(tmp_not), "! %s", tmp); expand_label_str(label, len, name, tmp_not); } else @@ -5031,30 +5029,30 @@ expand_label_addr(const char *name, char *label, size_t len, sa_family_t af, void expand_label_port(const char *name, char *label, size_t len, - struct node_port *port) + struct pf_rule_addr *addr) { char a1[6], a2[6], op[13] = ""; if (strstr(label, name) != NULL) { - snprintf(a1, sizeof(a1), "%u", ntohs(port->port[0])); - snprintf(a2, sizeof(a2), "%u", ntohs(port->port[1])); - if (!port->op) + snprintf(a1, sizeof(a1), "%u", ntohs(addr->port[0])); + snprintf(a2, sizeof(a2), "%u", ntohs(addr->port[1])); + if (!addr->port_op) ; - else if (port->op == PF_OP_IRG) + else if (addr->port_op == PF_OP_IRG) snprintf(op, sizeof(op), "%s><%s", a1, a2); - else if (port->op == PF_OP_XRG) + else if (addr->port_op == PF_OP_XRG) snprintf(op, sizeof(op), "%s<>%s", a1, a2); - else if (port->op == PF_OP_EQ) + else if (addr->port_op == PF_OP_EQ) snprintf(op, sizeof(op), "%s", a1); - else if (port->op == PF_OP_NE) + else if (addr->port_op == PF_OP_NE) snprintf(op, sizeof(op), "!=%s", a1); - else if (port->op == PF_OP_LT) + else if (addr->port_op == PF_OP_LT) snprintf(op, sizeof(op), "<%s", a1); - else if (port->op == PF_OP_LE) + else if (addr->port_op == PF_OP_LE) snprintf(op, sizeof(op), "<=%s", a1); - else if (port->op == PF_OP_GT) + else if (addr->port_op == PF_OP_GT) snprintf(op, sizeof(op), ">%s", a1); - else if (port->op == PF_OP_GE) + else if (addr->port_op == PF_OP_GE) snprintf(op, sizeof(op), ">=%s", a1); expand_label_str(label, len, name, op); } @@ -5078,29 +5076,27 @@ expand_label_proto(const char *name, char *label, size_t len, u_int8_t proto) } void -expand_label_nr(const char *name, char *label, size_t len) +expand_label_nr(const char *name, char *label, size_t len, + struct pfctl_rule *r) { char n[11]; if (strstr(label, name) != NULL) { - snprintf(n, sizeof(n), "%u", pf->anchor->match); + snprintf(n, sizeof(n), "%u", r->nr); expand_label_str(label, len, name, n); } } void -expand_label(char *label, size_t len, const char *ifname, sa_family_t af, - struct node_host *src_host, struct node_port *src_port, - struct node_host *dst_host, struct node_port *dst_port, - u_int8_t proto) +expand_label(char *label, size_t len, struct pfctl_rule *r) { - expand_label_if("$if", label, len, ifname); - expand_label_addr("$srcaddr", label, len, af, src_host); - expand_label_addr("$dstaddr", label, len, af, dst_host); - expand_label_port("$srcport", label, len, src_port); - expand_label_port("$dstport", label, len, dst_port); - expand_label_proto("$proto", label, len, proto); - expand_label_nr("$nr", label, len); + expand_label_if("$if", label, len, r->ifname); + expand_label_addr("$srcaddr", label, len, r->af, &r->src); + expand_label_addr("$dstaddr", label, len, r->af, &r->dst); + expand_label_port("$srcport", label, len, &r->src); + expand_label_port("$dstport", label, len, &r->dst); + expand_label_proto("$proto", label, len, r->proto); + expand_label_nr("$nr", label, len, r); } int @@ -5434,15 +5430,6 @@ expand_rule(struct pfctl_rule *r, if (strlcpy(r->match_tagname, match_tagname, sizeof(r->match_tagname)) >= sizeof(r->match_tagname)) errx(1, "expand_rule: strlcpy"); - for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) - expand_label(r->label[i], PF_RULE_LABEL_SIZE, - r->ifname, r->af, src_host, src_port, dst_host, - dst_port, proto->proto); - expand_label(r->tagname, PF_TAG_NAME_SIZE, r->ifname, r->af, - src_host, src_port, dst_host, dst_port, proto->proto); - expand_label(r->match_tagname, PF_TAG_NAME_SIZE, r->ifname, - r->af, src_host, src_port, dst_host, dst_port, - proto->proto); error += check_netmask(src_host, r->af); error += check_netmask(dst_host, r->af); diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index d7bde0012e9b..a0eec1b09289 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1528,6 +1528,12 @@ pfctl_load_ruleset(struct pfctl *pf, char *path, struct pfctl_ruleset *rs, while ((r = TAILQ_FIRST(rs->rules[rs_num].active.ptr)) != NULL) { TAILQ_REMOVE(rs->rules[rs_num].active.ptr, r, entries); + + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + expand_label(r->label[i], PF_RULE_LABEL_SIZE, r); + expand_label(r->tagname, PF_TAG_NAME_SIZE, r); + expand_label(r->match_tagname, PF_TAG_NAME_SIZE, r); + if ((error = pfctl_load_rule(pf, path, r, depth))) goto error; if (r->anchor) { diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h index 80ef184fa90f..606eb729cd44 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -138,6 +138,8 @@ void pf_remove_if_empty_ruleset(struct pfctl_ruleset *); struct pfctl_ruleset *pf_find_ruleset(const char *); struct pfctl_ruleset *pf_find_or_create_ruleset(const char *); +void expand_label(char *, size_t, struct pfctl_rule *); + const char *pfctl_proto2name(int); #endif /* _PFCTL_H_ */ From nobody Fri Oct 22 18:27:23 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E42E318161C8; Fri, 22 Oct 2021 18:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HbXrW5zK2z3mhH; Fri, 22 Oct 2021 18:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ACD8713B13; Fri, 22 Oct 2021 18:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19MIRNt2005897; Fri, 22 Oct 2021 18:27:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19MIRNvQ005896; Fri, 22 Oct 2021 18:27:23 GMT (envelope-from git) Date: Fri, 22 Oct 2021 18:27:23 GMT Message-Id: <202110221827.19MIRNvQ005896@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gleb Smirnoff Subject: git: fba15546837f - stable/13 - Mark sppp(4) as gone in FreeBSD 14. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fba15546837fe7285a15487a3fee93e551dc5be2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=fba15546837fe7285a15487a3fee93e551dc5be2 commit fba15546837fe7285a15487a3fee93e551dc5be2 Author: Gleb Smirnoff AuthorDate: 2021-10-22 18:27:00 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-22 18:27:00 +0000 Mark sppp(4) as gone in FreeBSD 14. --- sbin/spppcontrol/spppcontrol.8 | 10 +++++++++- share/man/man4/ng_sppp.4 | 8 +++++++- share/man/man4/sppp.4 | 8 +++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/sbin/spppcontrol/spppcontrol.8 b/sbin/spppcontrol/spppcontrol.8 index 4d948a60651a..b92ca4a883c9 100644 --- a/sbin/spppcontrol/spppcontrol.8 +++ b/sbin/spppcontrol/spppcontrol.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 30, 2001 +.Dd October 22, 2021 .Dt SPPPCONTROL 8 .Os .Sh NAME @@ -36,6 +36,14 @@ .Ar ifname .Op Ar parameter Ns Op Li = Ns Ar value .Op Ar ... +.Sh DEPRECATION NOTICE +The +.Xr sppp 4 +module and the +.Nm +utility is not present in +.Fx 14.0 +and later. .Sh DESCRIPTION The .Xr sppp 4 diff --git a/share/man/man4/ng_sppp.4 b/share/man/man4/ng_sppp.4 index 685d45f1500e..8ca493ce4008 100644 --- a/share/man/man4/ng_sppp.4 +++ b/share/man/man4/ng_sppp.4 @@ -12,7 +12,7 @@ .\" Cronyx Id: ng_sppp.4,v 1.1.2.3 2004/03/30 14:28:34 rik Exp $ .\" $FreeBSD$ .\" -.Dd February 3, 2005 +.Dd October 22, 2021 .Dt NG_SPPP 4 .Os .Sh NAME @@ -20,6 +20,12 @@ .Nd sppp netgraph node type .Sh SYNOPSIS .In netgraph/ng_sppp.h +.Sh DEPRECATION NOTICE +The +.Nm +module is not present in +.Fx 14.0 +and later. .Sh DESCRIPTION An .Nm sppp diff --git a/share/man/man4/sppp.4 b/share/man/man4/sppp.4 index 0420bb45ab80..585459b6d6c0 100644 --- a/share/man/man4/sppp.4 +++ b/share/man/man4/sppp.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 25, 2008 +.Dd October 22, 2021 .Dt SPPP 4 .Os .Sh NAME @@ -33,6 +33,12 @@ .Nd point to point protocol network layer for synchronous lines .Sh SYNOPSIS .Cd "device sppp" +.Sh DEPRECATION NOTICE +The +.Nm +module is not present in +.Fx 14.0 +and later. .Sh DESCRIPTION The .Nm From nobody Sat Oct 23 01:12:26 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AAA31180F19D; Sat, 23 Oct 2021 01:12: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 4Hbjqt4Sgpz3plH; Sat, 23 Oct 2021 01:12: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 795A2190DE; Sat, 23 Oct 2021 01:12: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 19N1CQ1w051340; Sat, 23 Oct 2021 01:12:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19N1CQEb051339; Sat, 23 Oct 2021 01:12:26 GMT (envelope-from git) Date: Sat, 23 Oct 2021 01:12:26 GMT Message-Id: <202110230112.19N1CQEb051339@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: cf12f7ba97dc - stable/13 - crt_malloc: use uintptr_t instead of long for arithmetic on addresses List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: cf12f7ba97dcb8d415414e491b5e4d68f1605190 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cf12f7ba97dcb8d415414e491b5e4d68f1605190 commit cf12f7ba97dcb8d415414e491b5e4d68f1605190 Author: Konstantin Belousov AuthorDate: 2021-10-12 21:39:07 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-22 23:32:27 +0000 crt_malloc: use uintptr_t instead of long for arithmetic on addresses (cherry picked from commit 0b72d2965d68113bce16f6cccea77257283ef0a7) --- libexec/rtld-elf/rtld_malloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/rtld_malloc.c b/libexec/rtld-elf/rtld_malloc.c index 6604aa7201f8..f22c3c727c73 100644 --- a/libexec/rtld-elf/rtld_malloc.c +++ b/libexec/rtld-elf/rtld_malloc.c @@ -259,7 +259,7 @@ morepages(int n) int offset; if (pagepool_end - pagepool_start > pagesz) { - addr = (caddr_t)roundup2((long)pagepool_start, pagesz); + addr = roundup2(pagepool_start, pagesz); if (munmap(addr, pagepool_end - addr) != 0) { #ifdef IN_RTLD rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": " @@ -269,8 +269,8 @@ morepages(int n) } } - offset = (long)pagepool_start - rounddown2((long)pagepool_start, - pagesz); + offset = (uintptr_t)pagepool_start - rounddown2( + (uintptr_t)pagepool_start, pagesz); pagepool_start = mmap(0, n * pagesz, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); From nobody Sat Oct 23 01:12:27 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 232EB180F323; Sat, 23 Oct 2021 01:12: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 4Hbjqv5sR6z3pRl; Sat, 23 Oct 2021 01:12: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 A6C2F1913C; Sat, 23 Oct 2021 01:12: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 19N1CR7R051364; Sat, 23 Oct 2021 01:12:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19N1CR6Q051363; Sat, 23 Oct 2021 01:12:27 GMT (envelope-from git) Date: Sat, 23 Oct 2021 01:12:27 GMT Message-Id: <202110230112.19N1CR6Q051363@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: e5a8b8152ade - stable/13 - crt_malloc: Be more persistent when handling mmap() failure List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: e5a8b8152ade3c658a9a180f0bd2f6ae82302948 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e5a8b8152ade3c658a9a180f0bd2f6ae82302948 commit e5a8b8152ade3c658a9a180f0bd2f6ae82302948 Author: Konstantin Belousov AuthorDate: 2021-10-11 16:13:31 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-22 23:32:27 +0000 crt_malloc: Be more persistent when handling mmap() failure PR: 259076 (cherry picked from commit 19e008e7f79ce55182d227be8513b3fa520471d8) --- libexec/rtld-elf/rtld_malloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld_malloc.c b/libexec/rtld-elf/rtld_malloc.c index f22c3c727c73..64218b5bb786 100644 --- a/libexec/rtld-elf/rtld_malloc.c +++ b/libexec/rtld-elf/rtld_malloc.c @@ -184,7 +184,9 @@ morecore(int bucket) nblks = 1; } if (amt > pagepool_end - pagepool_start) - if (morepages(amt/pagesz + NPOOLPAGES) == 0) + if (morepages(amt / pagesz + NPOOLPAGES) == 0 && + /* Retry with min required size */ + morepages(amt / pagesz) == 0) return; op = (union overhead *)pagepool_start; pagepool_start += amt; @@ -269,6 +271,8 @@ morepages(int n) } } + if (pagepool_start == MAP_FAILED) + pagepool_start = 0; offset = (uintptr_t)pagepool_start - rounddown2( (uintptr_t)pagepool_start, pagesz); From nobody Sat Oct 23 01:12:28 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CAACA180EFD1; Sat, 23 Oct 2021 01:12: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 4Hbjqx0g0lz3pg0; Sat, 23 Oct 2021 01:12: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 C98231913D; Sat, 23 Oct 2021 01:12: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 19N1CSIg051388; Sat, 23 Oct 2021 01:12:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19N1CSb7051387; Sat, 23 Oct 2021 01:12:28 GMT (envelope-from git) Date: Sat, 23 Oct 2021 01:12:28 GMT Message-Id: <202110230112.19N1CSb7051387@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: 00df149452bf - stable/13 - crt_malloc: more accurate handling of mmap(2) failure List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 00df149452bfd1b9eee9acba842bb6bc874c5ae3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=00df149452bfd1b9eee9acba842bb6bc874c5ae3 commit 00df149452bfd1b9eee9acba842bb6bc874c5ae3 Author: Konstantin Belousov AuthorDate: 2021-10-15 17:59:37 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-22 23:32:27 +0000 crt_malloc: more accurate handling of mmap(2) failure PR: 259076 (cherry picked from commit 73dddffc3175581ba99f6ced9a2e508a0e880e59) --- libexec/rtld-elf/rtld_malloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libexec/rtld-elf/rtld_malloc.c b/libexec/rtld-elf/rtld_malloc.c index 64218b5bb786..63fa6f5e2ee7 100644 --- a/libexec/rtld-elf/rtld_malloc.c +++ b/libexec/rtld-elf/rtld_malloc.c @@ -271,21 +271,21 @@ morepages(int n) } } - if (pagepool_start == MAP_FAILED) - pagepool_start = 0; offset = (uintptr_t)pagepool_start - rounddown2( (uintptr_t)pagepool_start, pagesz); - pagepool_start = mmap(0, n * pagesz, PROT_READ | PROT_WRITE, + addr = mmap(0, n * pagesz, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (pagepool_start == MAP_FAILED) { + if (addr == MAP_FAILED) { #ifdef IN_RTLD rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": morepages: " "cannot mmap anonymous memory: %s\n", rtld_strerror(errno)); #endif + pagepool_start = pagepool_end = NULL; return (0); } + pagepool_start = addr; pagepool_end = pagepool_start + n * pagesz; pagepool_start += offset; From nobody Sat Oct 23 01:12:29 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 31A33180F2BD; Sat, 23 Oct 2021 01:12: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 4Hbjqy4jzhz3pcn; Sat, 23 Oct 2021 01:12: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 E055418BE0; Sat, 23 Oct 2021 01:12: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 19N1CT49051412; Sat, 23 Oct 2021 01:12:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19N1CTgb051411; Sat, 23 Oct 2021 01:12:29 GMT (envelope-from git) Date: Sat, 23 Oct 2021 01:12:29 GMT Message-Id: <202110230112.19N1CTgb051411@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: 5fb00264be3f - stable/13 - sys: Add definitions for RELR relative relocation format List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 5fb00264be3f9e3ede49bec69baa4d3e53e02f88 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5fb00264be3f9e3ede49bec69baa4d3e53e02f88 commit 5fb00264be3f9e3ede49bec69baa4d3e53e02f88 Author: Fangrui Song AuthorDate: 2021-10-16 21:31:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-22 23:32:27 +0000 sys: Add definitions for RELR relative relocation format (cherry picked from commit 1cf06333160a9a6a4dabeba19f6d67ab55f0dac2) --- sys/sys/elf32.h | 2 ++ sys/sys/elf64.h | 2 ++ sys/sys/elf_common.h | 3 +++ sys/sys/elf_generic.h | 1 + 4 files changed, 8 insertions(+) diff --git a/sys/sys/elf32.h b/sys/sys/elf32.h index ad44b7cf970a..c328ce3b2f80 100644 --- a/sys/sys/elf32.h +++ b/sys/sys/elf32.h @@ -152,6 +152,8 @@ typedef struct { /* Macro for constructing r_info from field values. */ #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) +typedef Elf32_Word Elf32_Relr; + /* * Note entry header */ diff --git a/sys/sys/elf64.h b/sys/sys/elf64.h index 880166a3e83a..cc5c682e07da 100644 --- a/sys/sys/elf64.h +++ b/sys/sys/elf64.h @@ -166,6 +166,8 @@ typedef struct { #define ELF64_R_TYPE_INFO(data, type) \ (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type)) +typedef Elf64_Xword Elf64_Relr; + /* * Note entry header */ diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index d914ab8d4731..3243a8aca13c 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -617,6 +617,9 @@ typedef struct { #define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of pre-initialization functions. */ #define DT_MAXPOSTAGS 34 /* number of positive tags */ +#define DT_RELRSZ 35 /* Total size of ElfNN_Relr relocations. */ +#define DT_RELR 36 /* Address of ElfNN_Relr relocations. */ +#define DT_RELRENT 37 /* Size of each ElfNN_Relr relocation. */ #define DT_LOOS 0x6000000d /* First OS-specific */ #define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ #define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ diff --git a/sys/sys/elf_generic.h b/sys/sys/elf_generic.h index dcd44fe93b14..177de7339d3f 100644 --- a/sys/sys/elf_generic.h +++ b/sys/sys/elf_generic.h @@ -71,6 +71,7 @@ __ElfType(Phdr); __ElfType(Dyn); __ElfType(Rel); __ElfType(Rela); +__ElfType(Relr); __ElfType(Sym); __ElfType(Verdef); __ElfType(Verdaux); From nobody Sat Oct 23 01:12:30 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B5F80180F330; Sat, 23 Oct 2021 01:12: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 4Hbjqz21yCz3pZd; Sat, 23 Oct 2021 01:12: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 0C741191B3; Sat, 23 Oct 2021 01:12: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 19N1CUD0051442; Sat, 23 Oct 2021 01:12:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19N1CU4x051441; Sat, 23 Oct 2021 01:12:30 GMT (envelope-from git) Date: Sat, 23 Oct 2021 01:12:30 GMT Message-Id: <202110230112.19N1CU4x051441@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: c99fa2c634b3 - stable/13 - rtld: Support DT_RELR relative relocation format List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: c99fa2c634b3349cae6a6678d60352ade22abf51 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c99fa2c634b3349cae6a6678d60352ade22abf51 commit c99fa2c634b3349cae6a6678d60352ade22abf51 Author: Fangrui Song AuthorDate: 2021-10-16 21:34:37 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-22 23:32:27 +0000 rtld: Support DT_RELR relative relocation format (cherry picked from commit a7d137fcbcac7182d4fcdc97a46b10edc5c7041d) --- libexec/rtld-elf/rtld.c | 36 ++++++++++++++++++++++++++++++++++++ libexec/rtld-elf/rtld.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 6c304f98253a..d598bb044f8e 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1255,6 +1255,18 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath, assert(dynp->d_un.d_val == sizeof(Elf_Rela)); break; + case DT_RELR: + obj->relr = (const Elf_Relr *)(obj->relocbase + dynp->d_un.d_ptr); + break; + + case DT_RELRSZ: + obj->relrsize = dynp->d_un.d_val; + break; + + case DT_RELRENT: + assert(dynp->d_un.d_val == sizeof(Elf_Relr)); + break; + case DT_PLTREL: plttype = dynp->d_un.d_val; assert(dynp->d_un.d_val == DT_REL || plttype == DT_RELA); @@ -3148,6 +3160,29 @@ reloc_textrel_prot(Obj_Entry *obj, bool before) return (0); } +/* Process RELR relative relocations. */ +static void +reloc_relr(Obj_Entry *obj) +{ + const Elf_Relr *relr, *relrlim; + Elf_Addr *where; + + relrlim = (const Elf_Relr *)((const char *)obj->relr + obj->relrsize); + for (relr = obj->relr; relr < relrlim; relr++) { + Elf_Relr entry = *relr; + + if ((entry & 1) == 0) { + where = (Elf_Addr *)(obj->relocbase + entry); + *where++ += (Elf_Addr)obj->relocbase; + } else { + for (long i = 0; (entry >>= 1) != 0; i++) + if ((entry & 1) != 0) + where[i] += (Elf_Addr)obj->relocbase; + where += CHAR_BIT * sizeof(Elf_Relr) - 1; + } + } +} + /* * Relocate single object. * Returns 0 on success, or -1 on failure. @@ -3174,6 +3209,7 @@ relocate_object(Obj_Entry *obj, bool bind_now, Obj_Entry *rtldobj, /* Process the non-PLT non-IFUNC relocations. */ if (reloc_non_plt(obj, rtldobj, flags, lockstate)) return (-1); + reloc_relr(obj); /* Re-protected the text segment. */ if (obj->textrel && reloc_textrel_prot(obj, false) != 0) diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 060b83b2cdad..b216e80115bc 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -174,6 +174,8 @@ typedef struct Struct_Obj_Entry { unsigned long relsize; /* Size in bytes of relocation info */ const Elf_Rela *rela; /* Relocation entries with addend */ unsigned long relasize; /* Size in bytes of addend relocation info */ + const Elf_Relr *relr; /* RELR relocation entries */ + unsigned long relrsize; /* Size in bytes of RELR relocations */ const Elf_Rel *pltrel; /* PLT relocation entries */ unsigned long pltrelsize; /* Size in bytes of PLT relocation info */ const Elf_Rela *pltrela; /* PLT relocation entries with addend */ From nobody Sat Oct 23 01:12:32 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A795F180F2EE; Sat, 23 Oct 2021 01:12: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 4Hbjr10M5Bz3plq; Sat, 23 Oct 2021 01:12: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 2C89F190E3; Sat, 23 Oct 2021 01:12: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 19N1CWLs051466; Sat, 23 Oct 2021 01:12:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19N1CWAT051465; Sat, 23 Oct 2021 01:12:32 GMT (envelope-from git) Date: Sat, 23 Oct 2021 01:12:32 GMT Message-Id: <202110230112.19N1CWAT051465@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: a3876ab1eb87 - stable/13 - rtld-elf/paths.h: Make it usable outside rtld List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: a3876ab1eb8724f5fc4c3b5c44925603882426da Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a3876ab1eb8724f5fc4c3b5c44925603882426da commit a3876ab1eb8724f5fc4c3b5c44925603882426da Author: Konstantin Belousov AuthorDate: 2021-10-12 15:50:49 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-22 23:32:27 +0000 rtld-elf/paths.h: Make it usable outside rtld (cherry picked from commit 33dba3bb0ec2a0f0a401bed145cc0ef95f37a5c3) --- libexec/rtld-elf/arm/reloc.c | 2 +- libexec/rtld-elf/libmap.c | 2 +- libexec/rtld-elf/rtld.c | 2 +- libexec/rtld-elf/rtld_malloc.c | 2 +- libexec/rtld-elf/{paths.h => rtld_paths.h} | 18 ++++++++++++++---- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libexec/rtld-elf/arm/reloc.c b/libexec/rtld-elf/arm/reloc.c index 7779169667be..4eb3fc7e6929 100644 --- a/libexec/rtld-elf/arm/reloc.c +++ b/libexec/rtld-elf/arm/reloc.c @@ -16,7 +16,7 @@ __FBSDID("$FreeBSD$"); #include "debug.h" #include "rtld.h" -#include "paths.h" +#include "rtld_paths.h" #ifdef __ARM_FP /* diff --git a/libexec/rtld-elf/libmap.c b/libexec/rtld-elf/libmap.c index e4388d14b951..854c73f39ef7 100644 --- a/libexec/rtld-elf/libmap.c +++ b/libexec/rtld-elf/libmap.c @@ -16,7 +16,7 @@ #include "debug.h" #include "rtld.h" #include "libmap.h" -#include "paths.h" +#include "rtld_paths.h" #include "rtld_libc.h" TAILQ_HEAD(lm_list, lm); diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index d598bb044f8e..8b1f84c6901a 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$"); #include "debug.h" #include "rtld.h" #include "libmap.h" -#include "paths.h" +#include "rtld_paths.h" #include "rtld_tls.h" #include "rtld_printf.h" #include "rtld_malloc.h" diff --git a/libexec/rtld-elf/rtld_malloc.c b/libexec/rtld-elf/rtld_malloc.c index 63fa6f5e2ee7..d08254b67d9f 100644 --- a/libexec/rtld-elf/rtld_malloc.c +++ b/libexec/rtld-elf/rtld_malloc.c @@ -55,7 +55,7 @@ static char *rcsid = "$FreeBSD$"; #include #include "rtld.h" #include "rtld_printf.h" -#include "paths.h" +#include "rtld_paths.h" /* * Pre-allocate mmap'ed pages diff --git a/libexec/rtld-elf/paths.h b/libexec/rtld-elf/rtld_paths.h similarity index 88% rename from libexec/rtld-elf/paths.h rename to libexec/rtld-elf/rtld_paths.h index 75f3b1d47dd4..4ce423ce6dbb 100644 --- a/libexec/rtld-elf/paths.h +++ b/libexec/rtld-elf/rtld_paths.h @@ -26,15 +26,19 @@ * $FreeBSD$ */ -#ifndef PATHS_H -#define PATHS_H +#ifndef _RTLD_PATHS_H +#define _RTLD_PATHS_H #undef _PATH_ELF_HINTS +#ifndef _COMPAT32_BASENAME_RTLD +#define _COMPAT32_BASENAME_RTLD "ld-elf32.so.1" +#endif + #ifdef COMPAT_32BIT #define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints" #define _PATH_LIBMAP_CONF "/etc/libmap32.conf" -#define _BASENAME_RTLD "ld-elf32.so.1" +#define _BASENAME_RTLD _COMPAT32_BASENAME_RTLD #define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32" #define LD_ "LD_32_" #endif @@ -55,6 +59,10 @@ #define _PATH_RTLD "/libexec/" _BASENAME_RTLD #endif +#ifndef _COMPAT32_PATH_RTLD +#define _COMPAT32_PATH_RTLD "/libexec/" _COMPAT32_BASENAME_RTLD +#endif + #ifndef STANDARD_LIBRARY_PATH #define STANDARD_LIBRARY_PATH "/lib/casper:/lib:/usr/lib" #endif @@ -69,10 +77,12 @@ #define SOFT_STANDARD_LIBRARY_PATH "/usr/libsoft" #define LD_SOFT_ "LD_SOFT_" +#ifdef IN_RTLD extern const char *ld_elf_hints_default; extern const char *ld_path_libmap_conf; extern const char *ld_path_rtld; extern const char *ld_standard_library_path; extern const char *ld_env_prefix; +#endif -#endif /* PATHS_H */ +#endif /* _RTLD_PATHS_H */ From nobody Sat Oct 23 01:54:12 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C4131181FFEE; Sat, 23 Oct 2021 01:54: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 4Hbkm457l9z4Wkh; Sat, 23 Oct 2021 01:54: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 9023119C1F; Sat, 23 Oct 2021 01:54: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 19N1sCmR004062; Sat, 23 Oct 2021 01:54:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19N1sC39004061; Sat, 23 Oct 2021 01:54:12 GMT (envelope-from git) Date: Sat, 23 Oct 2021 01:54:12 GMT Message-Id: <202110230154.19N1sC39004061@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: 9a00da73a3dc - stable/13 - ffs: retire unused fsckpid mount option List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9a00da73a3dc15b5316e6eea805da8d2eeac4310 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=9a00da73a3dc15b5316e6eea805da8d2eeac4310 commit 9a00da73a3dc15b5316e6eea805da8d2eeac4310 Author: Robert Wing AuthorDate: 2021-10-02 23:11:40 +0000 Commit: Robert Wing CommitDate: 2021-10-23 01:37:17 +0000 ffs: retire unused fsckpid mount option The fsckpid mount option was introduced in 927a12ae16433b50 along with a couple sysctl's to support SU+J with snapshots. However, those sysctl's were never used and eventually removed in f2620e9ceb3ede02. There are no in-tree consumers of this mount option. Reviewed by: mckusick, kib Differential Revision: https://reviews.freebsd.org/D32015 (cherry picked from commit 9acea16404117f2f54475640ff036c12130707d8) --- sys/ufs/ffs/ffs_alloc.c | 3 +- sys/ufs/ffs/ffs_inode.c | 2 +- sys/ufs/ffs/ffs_vfsops.c | 117 ++--------------------------------------------- sys/ufs/ufs/ufsmount.h | 2 - 4 files changed, 6 insertions(+), 118 deletions(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 771377b7cefc..6a262a798d1b 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -3236,8 +3236,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) return (EINVAL); } ump = VFSTOUFS(mp); - if ((mp->mnt_flag & MNT_RDONLY) && - ump->um_fsckpid != td->td_proc->p_pid) { + if (mp->mnt_flag & MNT_RDONLY) { vn_finished_write(mp); fdrop(fp, td); return (EROFS); diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 6bb7521cef4c..b78f46ae4ba0 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -132,7 +132,7 @@ ffs_update(vp, waitfor) if (waitfor) ip->i_flag &= ~(IN_SIZEMOD | IN_IBLKDATA); fs = ITOFS(ip); - if (fs->fs_ronly && ITOUMP(ip)->um_fsckpid == 0) + if (fs->fs_ronly) return (0); /* * If we are updating a snapshot and another process is currently diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index d5f20690793d..fb00218f5d3a 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -147,7 +147,7 @@ static struct buf_ops ffs_ops = { */ static const char *ffs_opts[] = { "acls", "async", "noatime", "noclusterr", "noclusterw", "noexec", "export", "force", "from", "groupquota", - "multilabel", "nfsv4acls", "fsckpid", "snapshot", "nosuid", "suiddir", + "multilabel", "nfsv4acls", "snapshot", "nosuid", "suiddir", "nosymfollow", "sync", "union", "userquota", "untrusted", NULL }; static int ffs_enxio_enable = 1; @@ -374,7 +374,6 @@ ffs_mount(struct mount *mp) struct thread *td; struct ufsmount *ump = NULL; struct fs *fs; - pid_t fsckpid = 0; int error, error1, flags; uint64_t mntorflags, saved_mnt_flag; accmode_t accmode; @@ -422,31 +421,6 @@ ffs_mount(struct mount *mp) vfs_deleteopt(mp->mnt_opt, "snapshot"); } - if (vfs_getopt(mp->mnt_optnew, "fsckpid", NULL, NULL) == 0 && - vfs_scanopt(mp->mnt_optnew, "fsckpid", "%d", &fsckpid) == 1) { - /* - * Once we have set the restricted PID, do not - * persist "fsckpid" in the options list. - */ - vfs_deleteopt(mp->mnt_optnew, "fsckpid"); - vfs_deleteopt(mp->mnt_opt, "fsckpid"); - if (mp->mnt_flag & MNT_UPDATE) { - if (VFSTOUFS(mp)->um_fs->fs_ronly == 0 && - vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) == 0) { - vfs_mount_error(mp, - "Checker enable: Must be read-only"); - return (EINVAL); - } - } else if (vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) == 0) { - vfs_mount_error(mp, - "Checker enable: Must be read-only"); - return (EINVAL); - } - /* Set to -1 if we are done */ - if (fsckpid == 0) - fsckpid = -1; - } - if (vfs_getopt(mp->mnt_optnew, "nfsv4acls", NULL, NULL) == 0) { if (mntorflags & MNT_ACLS) { vfs_mount_error(mp, @@ -470,18 +444,6 @@ ffs_mount(struct mount *mp) fs = ump->um_fs; odevvp = ump->um_odevvp; devvp = ump->um_devvp; - if (fsckpid == -1 && ump->um_fsckpid > 0) { - if ((error = ffs_flushfiles(mp, WRITECLOSE, td)) != 0 || - (error = ffs_sbupdate(ump, MNT_WAIT, 0)) != 0) - return (error); - g_topology_lock(); - /* - * Return to normal read-only mode. - */ - error = g_access(ump->um_cp, 0, -1, 0); - g_topology_unlock(); - ump->um_fsckpid = 0; - } if (fs->fs_ronly == 0 && vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) { /* @@ -569,14 +531,6 @@ ffs_mount(struct mount *mp) return (error); if (fs->fs_ronly && !vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) { - /* - * If we are running a checker, do not allow upgrade. - */ - if (ump->um_fsckpid > 0) { - vfs_mount_error(mp, - "Active checker, cannot upgrade to write"); - return (EINVAL); - } /* * If upgrade to read-write by non-root, then verify * that user has necessary permissions on the device. @@ -686,39 +640,6 @@ ffs_mount(struct mount *mp) mp->mnt_flag |= MNT_NFS4ACLS; MNT_IUNLOCK(mp); } - /* - * If this is a request from fsck to clean up the filesystem, - * then allow the specified pid to proceed. - */ - if (fsckpid > 0) { - if (ump->um_fsckpid != 0) { - vfs_mount_error(mp, - "Active checker already running on %s", - fs->fs_fsmnt); - return (EINVAL); - } - KASSERT(MOUNTEDSOFTDEP(mp) == 0, - ("soft updates enabled on read-only file system")); - g_topology_lock(); - /* - * Request write access. - */ - error = g_access(ump->um_cp, 0, 1, 0); - g_topology_unlock(); - if (error) { - vfs_mount_error(mp, - "Checker activation failed on %s", - fs->fs_fsmnt); - return (error); - } - ump->um_fsckpid = fsckpid; - if (fs->fs_snapinum[0] != 0) - ffs_snapshot_mount(mp); - fs->fs_mtime = time_second; - fs->fs_fmod = 1; - fs->fs_clean = 0; - (void) ffs_sbupdate(ump, MNT_WAIT, 0); - } /* * If this is a snapshot request, take the snapshot. @@ -798,29 +719,6 @@ ffs_mount(struct mount *mp) vrele(devvp); return (error); } - if (fsckpid > 0) { - KASSERT(MOUNTEDSOFTDEP(mp) == 0, - ("soft updates enabled on read-only file system")); - ump = VFSTOUFS(mp); - fs = ump->um_fs; - g_topology_lock(); - /* - * Request write access. - */ - error = g_access(ump->um_cp, 0, 1, 0); - g_topology_unlock(); - if (error) { - printf("WARNING: %s: Checker activation " - "failed\n", fs->fs_fsmnt); - } else { - ump->um_fsckpid = fsckpid; - if (fs->fs_snapinum[0] != 0) - ffs_snapshot_mount(mp); - fs->fs_mtime = time_second; - fs->fs_clean = 0; - (void) ffs_sbupdate(ump, MNT_WAIT, 0); - } - } } MNT_ILOCK(mp); @@ -1541,7 +1439,7 @@ ffs_unmount(mp, mntflags) if (MOUNTEDSOFTDEP(mp)) softdep_unmount(mp); MPASS(ump->um_softdep == NULL); - if (fs->fs_ronly == 0 || ump->um_fsckpid > 0) { + if (fs->fs_ronly == 0) { fs->fs_clean = fs->fs_flags & (FS_UNCLEAN|FS_NEEDSFSCK) ? 0 : 1; error = ffs_sbupdate(ump, MNT_WAIT, 0); if (ffs_fsfail_cleanup(ump, error)) @@ -1561,13 +1459,6 @@ ffs_unmount(mp, mntflags) free (ump->um_trimhash, M_TRIM); } g_topology_lock(); - if (ump->um_fsckpid > 0) { - /* - * Return to normal read-only mode. - */ - error = g_access(ump->um_cp, 0, -1, 0); - ump->um_fsckpid = 0; - } g_vfs_close(ump->um_cp); g_topology_unlock(); BO_LOCK(&ump->um_odevvp->v_bufobj); @@ -1833,7 +1724,7 @@ ffs_sync(mp, waitfor) suspended = 0; td = curthread; fs = ump->um_fs; - if (fs->fs_fmod != 0 && fs->fs_ronly != 0 && ump->um_fsckpid == 0) + if (fs->fs_fmod != 0 && fs->fs_ronly != 0) panic("%s: ffs_sync: modification on read-only filesystem", fs->fs_fsmnt); if (waitfor == MNT_LAZY) { @@ -2304,7 +2195,7 @@ ffs_sbupdate(ump, waitfor, suspended) fs = ump->um_fs; if (fs->fs_ronly == 1 && (ump->um_mountp->mnt_flag & (MNT_RDONLY | MNT_UPDATE)) != - (MNT_RDONLY | MNT_UPDATE) && ump->um_fsckpid == 0) + (MNT_RDONLY | MNT_UPDATE)) panic("ffs_sbupdate: write read-only filesystem"); /* * We use the superblock's buf to serialize calls to ffs_sbupdate(). diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 0b90cae95ff5..2e7865070025 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -85,7 +85,6 @@ struct fsfail_task { * i - ufsmount interlock (UFS_LOCK / UFS_UNLOCK) * q - associated quota file is locked * r - ref to parent mount structure is held (vfs_busy / vfs_unbusy) - * u - managed by user process fsck_ufs */ struct ufsmount { struct mount *um_mountp; /* (r) filesystem vfs struct */ @@ -105,7 +104,6 @@ struct ufsmount { 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 */ struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */ From nobody Sat Oct 23 19:02:12 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 64DA01815539; Sat, 23 Oct 2021 19:02: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 4Hc9ZD2TkQz57dS; Sat, 23 Oct 2021 19:02:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3598827616; Sat, 23 Oct 2021 19:02:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19NJ2Cir075315; Sat, 23 Oct 2021 19:02:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19NJ2C7W075314; Sat, 23 Oct 2021 19:02:12 GMT (envelope-from git) Date: Sat, 23 Oct 2021 19:02:12 GMT Message-Id: <202110231902.19NJ2C7W075314@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: aba2dc46dfa5 - stable/12 - cmp: initialize limit to avoid stack garbage limits List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: aba2dc46dfa51cf9e1b1987ca4e91f703ae7e368 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=aba2dc46dfa51cf9e1b1987ca4e91f703ae7e368 commit aba2dc46dfa51cf9e1b1987ca4e91f703ae7e368 Author: Kyle Evans AuthorDate: 2021-10-21 16:30:55 +0000 Commit: Kyle Evans CommitDate: 2021-10-23 19:01:39 +0000 cmp: initialize limit to avoid stack garbage limits Pointy hat: kevans Fixes: 4e380e847460 ("cmp: add -n, --bytes to limit number of bytes [...]") Sponsored by: Klara, Inc. (cherry picked from commit f1f7f31366e5830f4f5b96c6394a0b91475744f4) --- usr.bin/cmp/cmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c index 98ae96c73375..83ea7ae7eee0 100644 --- a/usr.bin/cmp/cmp.c +++ b/usr.bin/cmp/cmp.c @@ -105,7 +105,7 @@ main(int argc, char *argv[]) bool special; const char *file1, *file2; - skip1 = skip2 = 0; + limit = skip1 = skip2 = 0; oflag = O_RDONLY; while ((ch = getopt_long(argc, argv, "+bhi:ln:sxz", long_opts, NULL)) != -1) switch (ch) { From nobody Sat Oct 23 19:02:19 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 99B7E181582C; Sat, 23 Oct 2021 19:02: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 4Hc9ZN1tv6z57nH; Sat, 23 Oct 2021 19:02: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 1621F274D9; Sat, 23 Oct 2021 19:02: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 19NJ2JSv075436; Sat, 23 Oct 2021 19:02:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19NJ2JH0075435; Sat, 23 Oct 2021 19:02:19 GMT (envelope-from git) Date: Sat, 23 Oct 2021 19:02:19 GMT Message-Id: <202110231902.19NJ2JH0075435@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: b6aec7884750 - stable/13 - cmp: initialize limit to avoid stack garbage limits List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b6aec78847501c4f7a79552651991e0842ecaec3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=b6aec78847501c4f7a79552651991e0842ecaec3 commit b6aec78847501c4f7a79552651991e0842ecaec3 Author: Kyle Evans AuthorDate: 2021-10-21 16:30:55 +0000 Commit: Kyle Evans CommitDate: 2021-10-23 19:01:00 +0000 cmp: initialize limit to avoid stack garbage limits Pointy hat: kevans Fixes: 4e380e847460 ("cmp: add -n, --bytes to limit number of bytes [...]") Sponsored by: Klara, Inc. (cherry picked from commit f1f7f31366e5830f4f5b96c6394a0b91475744f4) --- usr.bin/cmp/cmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/cmp/cmp.c b/usr.bin/cmp/cmp.c index 98ae96c73375..83ea7ae7eee0 100644 --- a/usr.bin/cmp/cmp.c +++ b/usr.bin/cmp/cmp.c @@ -105,7 +105,7 @@ main(int argc, char *argv[]) bool special; const char *file1, *file2; - skip1 = skip2 = 0; + limit = skip1 = skip2 = 0; oflag = O_RDONLY; while ((ch = getopt_long(argc, argv, "+bhi:ln:sxz", long_opts, NULL)) != -1) switch (ch) { From nobody Sun Oct 24 03:13:25 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EBED3180EA89; Sun, 24 Oct 2021 03:13: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 4HcNT16PHQz3NdM; Sun, 24 Oct 2021 03:13: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 BC45A60BE; Sun, 24 Oct 2021 03:13: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 19O3DPu5031486; Sun, 24 Oct 2021 03:13:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19O3DPpo031485; Sun, 24 Oct 2021 03:13:25 GMT (envelope-from git) Date: Sun, 24 Oct 2021 03:13:25 GMT Message-Id: <202110240313.19O3DPpo031485@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: bee91a0e8b97 - releng/12.3 - contrib/tzdata: correct DST in Fiji List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.3 X-Git-Reftype: branch X-Git-Commit: bee91a0e8b97dd9b424c6d72b25ec8591c180549 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/12.3 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=bee91a0e8b97dd9b424c6d72b25ec8591c180549 commit bee91a0e8b97dd9b424c6d72b25ec8591c180549 Author: Philip Paeps AuthorDate: 2021-10-18 06:19:42 +0000 Commit: Philip Paeps CommitDate: 2021-10-24 03:11:20 +0000 contrib/tzdata: correct DST in Fiji Direct commit to stable/12. Unfortunately, there is still no clear consensus on the tz mailing list about some of the changes introduced by tzdata 2021b and later releases. Pending consensus, only merge the recently announced DST transition date for Fiji and corrections to commentary from tzdata 2021d. This corrects future timestamps in Fiji. Approved by: re (gjb) (cherry picked from commit 74a0f31dbbd0b32689d63d8c965c611bdfc4da2f) --- contrib/tzdata/australasia | 24 +++++++++++++++++++----- contrib/tzdata/europe | 13 ++++++++----- contrib/tzdata/northamerica | 6 +++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/contrib/tzdata/australasia b/contrib/tzdata/australasia index a2c5ee86eecf..eba0fad1c213 100644 --- a/contrib/tzdata/australasia +++ b/contrib/tzdata/australasia @@ -385,9 +385,22 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # "Minister for Employment, Parveen Bala says they had never thought of # stopping daylight saving. He says it was just to decide on when it should # start and end. Bala says it is a short period..." -# Since the end date is still in line with our ongoing predictions, assume for -# now that the later-than-usual start date is a one-time departure from the -# recent second Sunday in November pattern. +# +# From Tim Parenti (2021-10-11), per Jashneel Kumar (2021-10-11) and P Chan +# (2021-10-12): +# https://www.fiji.gov.fj/Media-Centre/Speeches/English/PM-BAINIMARAMA-S-COVID-19-ANNOUNCEMENT-10-10-21 +# https://www.fbcnews.com.fj/news/covid-19/curfew-moved-back-to-11pm/ +# In a 2021-10-10 speech concerning updated Covid-19 mitigation measures in +# Fiji, prime minister Josaia Voreqe "Frank" Bainimarama announced the +# suspension of DST for the 2021/2022 season: "Given that we are in the process +# of readjusting in the midst of so many changes, we will also put Daylight +# Savings Time on hold for this year. It will also make the reopening of +# scheduled commercial air service much smoother if we don't have to be +# concerned shifting arrival and departure times, which may look like a simple +# thing but requires some significant logistical adjustments domestically and +# internationally." +# Assume for now that DST will resume with the recent pre-2020 rules for the +# 2022/2023 season. # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 - @@ -399,10 +412,11 @@ Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 2018 - Nov Sun>=1 2:00 1:00 - -Rule Fiji 2015 max - Jan Sun>=12 3:00 0 - +Rule Fiji 2015 2021 - Jan Sun>=12 3:00 0 - Rule Fiji 2019 only - Nov Sun>=8 2:00 1:00 - Rule Fiji 2020 only - Dec 20 2:00 1:00 - -Rule Fiji 2021 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2022 max - Nov Sun>=8 2:00 1:00 - +Rule Fiji 2023 max - Jan Sun>=12 3:00 0 - # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji +12/+13 diff --git a/contrib/tzdata/europe b/contrib/tzdata/europe index bba4d5648228..d91e0ce5f8f7 100644 --- a/contrib/tzdata/europe +++ b/contrib/tzdata/europe @@ -822,7 +822,7 @@ Zone Europe/Andorra 0:06:04 - LMT 1901 # Shanks & Pottenger give 02:00, the BEV 00:00. Go with the BEV, # and guess 02:00 for 1945-04-12. -# From Alois Triendl (2019-07-22): +# From Alois Treindl (2019-07-22): # In 1946 the end of DST was on Monday, 7 October 1946, at 3:00 am. # Shanks had this right. Source: Die Weltpresse, 5. Oktober 1946, page 5. @@ -1736,19 +1736,22 @@ Zone Atlantic/Reykjavik -1:28 - LMT 1908 # advanced to sixty minutes later starting at hour two on 1944-04-02; ... # Starting at hour three on the date 1944-09-17 standard time will be resumed. # -# From Alois Triendl (2019-07-02): +# From Alois Treindl (2019-07-02): # I spent 6 Euros to buy two archive copies of Il Messaggero, a Roman paper, # for 1 and 2 April 1944. The edition of 2 April has this note: "Tonight at 2 # am, put forward the clock by one hour. Remember that in the night between # today and Monday the 'ora legale' will come in force again." That makes it # clear that in Rome the change was on Monday, 3 April 1944 at 2 am. # -# From Paul Eggert (2016-10-27): +# From Paul Eggert (2021-10-05): # Go with INRiM for DST rules, except as corrected by Inglis for 1944 # for the Kingdom of Italy. This is consistent with Renzo Baldini. # Model Rome's occupation by using C-Eur rules from 1943-09-10 # to 1944-06-04; although Rome was an open city during this period, it -# was effectively controlled by Germany. +# was effectively controlled by Germany. Using C-Eur is consistent +# with Treindl's comment about Rome in April 1944, as the "Rule Italy" +# lines during German occupation do not affect Europe/Rome +# (though they do affect Europe/Malta). # # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Italy 1916 only - Jun 3 24:00 1:00 S @@ -2618,7 +2621,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # Although Shanks lists 1945-01-01 as the date for transition from # +01/+02 to +02/+03, more likely this is a placeholder. Guess that # the transition occurred at 1945-04-10 00:00, which is about when -# Königsberg surrendered to Soviet troops. (Thanks to Alois Triendl.) +# Königsberg surrendered to Soviet troops. (Thanks to Alois Treindl.) # From Paul Eggert (2016-03-18): # The 1989 transition is from USSR act No. 227 (1989-03-14). diff --git a/contrib/tzdata/northamerica b/contrib/tzdata/northamerica index ddc575976e59..75e115418a1e 100644 --- a/contrib/tzdata/northamerica +++ b/contrib/tzdata/northamerica @@ -970,7 +970,7 @@ Zone America/Indiana/Vincennes -5:50:07 - LMT 1883 Nov 18 12:09:53 -5:00 US E%sT # # Perry County, Indiana, switched from eastern to central time in April 2006. -# From Alois Triendl (2019-07-09): +# From Alois Treindl (2019-07-09): # The Indianapolis News, Friday 27 October 1967 states that Perry County # returned to CST. It went again to EST on 27 April 1969, as documented by the # Indianapolis star of Saturday 26 April. @@ -1998,7 +1998,7 @@ Zone America/Swift_Current -7:11:20 - LMT 1905 Sep # Alberta -# From Alois Triendl (2019-07-19): +# From Alois Treindl (2019-07-19): # There was no DST in Alberta in 1967... Calgary Herald, 29 April 1967. # 1969, no DST, from Edmonton Journal 18 April 1969 # @@ -2107,7 +2107,7 @@ Zone America/Edmonton -7:33:52 - LMT 1906 Sep # # From Paul Eggert (2019-07-25): # Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver. -# Alois Triendl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily +# Alois Treindl confirmed this on 07-22, citing the 1946-04-27 Vancouver Daily # Province. He also cited the 1946-09-28 Victoria Daily Times, which said # that Vancouver, Victoria, etc. "change at midnight Saturday"; for now, # guess they meant 02:00 Sunday since 02:00 was common practice in Vancouver. From nobody Sun Oct 24 04:24:56 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 533BB1827F78; Sun, 24 Oct 2021 04:24: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 4HcQ3Y1RhFz3wDD; Sun, 24 Oct 2021 04:24: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 118536DE8; Sun, 24 Oct 2021 04:24: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 19O4OuNw024697; Sun, 24 Oct 2021 04:24:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19O4OuVt024696; Sun, 24 Oct 2021 04:24:56 GMT (envelope-from git) Date: Sun, 24 Oct 2021 04:24:56 GMT Message-Id: <202110240424.19O4OuVt024696@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: 010e3bc77275 - stable/13 - Avoid lost buffers in fsck_ffs. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: 010e3bc772753e282ccbf12df3600f6d1a33d3fe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=010e3bc772753e282ccbf12df3600f6d1a33d3fe commit 010e3bc772753e282ccbf12df3600f6d1a33d3fe Author: Kirk McKusick AuthorDate: 2021-10-07 22:51:56 +0000 Commit: Kirk McKusick CommitDate: 2021-10-24 04:24:08 +0000 Avoid lost buffers in fsck_ffs. Sponsored by: Netflix (cherry picked from commit 4313e2ae44ba4e416a7ddaeaccf8ad311902f1c8) --- sbin/fsck_ffs/inode.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index ba2d5892238e..dafc99bd92da 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -264,6 +264,8 @@ ino_blkatoff(union dinode *dp, ino_t ino, ufs_lbn_t lbn, int *frags, int i; *frags = 0; + if (bpp != NULL) + *bpp = NULL; /* * Handle extattr blocks first. */ @@ -300,6 +302,8 @@ ino_blkatoff(union dinode *dp, ino_t ino, ufs_lbn_t lbn, int *frags, continue; if (lbn > 0 && lbn >= next) continue; + if (DIP(dp, di_ib[i]) == 0) + return (0); return (indir_blkatoff(DIP(dp, di_ib[i]), ino, -cur - i, lbn, bpp)); } @@ -321,8 +325,6 @@ indir_blkatoff(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t cur, ufs_lbn_t lbn, ufs_lbn_t base; int i, level; - if (blk == 0) - return (0); level = lbn_level(cur); if (level == -1) pfatal("Invalid indir lbn %jd in ino %ju\n", @@ -352,12 +354,14 @@ indir_blkatoff(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t cur, ufs_lbn_t lbn, return (0); blk = IBLK(bp, i); bp->b_index = i; - if (bpp != NULL) - *bpp = bp; - else - brelse(bp); - if (cur == lbn) + if (cur == lbn || blk == 0) { + if (bpp != NULL) + *bpp = bp; + else + brelse(bp); return (blk); + } + brelse(bp); if (level == 0) pfatal("Invalid lbn %jd at level 0 for ino %ju\n", lbn, (uintmax_t)ino); From nobody Sun Oct 24 16:34:13 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 05A30180BEE4; Sun, 24 Oct 2021 16:34: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 4HckF16lXvz4TvF; Sun, 24 Oct 2021 16:34: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 C744818A53; Sun, 24 Oct 2021 16:34: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 19OGYDit093447; Sun, 24 Oct 2021 16:34:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19OGYDc0093446; Sun, 24 Oct 2021 16:34:13 GMT (envelope-from git) Date: Sun, 24 Oct 2021 16:34:13 GMT Message-Id: <202110241634.19OGYDc0093446@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: c1c3ef8ef84b - stable/13 - timeout.1: Fix typos in examples List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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: c1c3ef8ef84b49f3a4db0fc2953db30c75235292 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c1c3ef8ef84b49f3a4db0fc2953db30c75235292 commit c1c3ef8ef84b49f3a4db0fc2953db30c75235292 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-10-21 11:06:45 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-10-24 16:33:37 +0000 timeout.1: Fix typos in examples MFC after: 3 days (cherry picked from commit 12615938c6e0bc3ca7604a8b0614ff23d9964370) --- usr.bin/timeout/timeout.1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.bin/timeout/timeout.1 b/usr.bin/timeout/timeout.1 index b9613128755e..843c6215cc80 100644 --- a/usr.bin/timeout/timeout.1 +++ b/usr.bin/timeout/timeout.1 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 7, 2020 +.Dd October 21, 2021 .Dt TIMEOUT 1 .Os .Sh NAME @@ -161,7 +161,7 @@ $ echo $? .Pp Same as above but preserving status. Exit status is 128 + signal number (15 for -.Va SIGTERM ) +.Va SIGTERM ) : .Bd -literal -offset indent $ timeout --preserve-status 2 sleep 4 $ echo $? @@ -171,7 +171,7 @@ $ echo $? Same as above but sending .Va SIGALRM (signal number 14) instead of -.Va SIGTERM +.Va SIGTERM : .Bd -literal -offset indent $ timeout --preserve-status -s SIGALRM 2 sleep 4 $ echo $? @@ -189,8 +189,8 @@ signal after 1 minute and send a .Va SIGKILL signal 5 seconds later if the process refuses to stop: .Bd -literal -offset indent -timeout -k 5s 1m fetch \\ -https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/book.html +$ timeout -k 5s 1m fetch \\ +> https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/book.html .Ed .Sh SEE ALSO .Xr kill 1 , From nobody Sun Oct 24 18:54:05 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 908BA18206A0; Sun, 24 Oct 2021 18:54: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 4HcnLP3Dzqz3hFx; Sun, 24 Oct 2021 18:54: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 4E9DC1AB4C; Sun, 24 Oct 2021 18:54: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 19OIs5rg080929; Sun, 24 Oct 2021 18:54:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19OIs5iV080928; Sun, 24 Oct 2021 18:54:05 GMT (envelope-from git) Date: Sun, 24 Oct 2021 18:54:05 GMT Message-Id: <202110241854.19OIs5iV080928@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: af818612a5d3 - stable/13 - riscv: Implement pmap_mapdev_attr List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: af818612a5d3941763b1b0c620b929df89bc6c4d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=af818612a5d3941763b1b0c620b929df89bc6c4d commit af818612a5d3941763b1b0c620b929df89bc6c4d Author: Jessica Clarke AuthorDate: 2021-10-17 14:31:35 +0000 Commit: Jessica Clarke CommitDate: 2021-10-24 18:51:10 +0000 riscv: Implement pmap_mapdev_attr This is needed for LinuxKPI's _ioremap_attr. This reuses the generic implementation introduced for aarch64, and itself requires implementing pmap_kenter, which is trivial to do given riscv currently treats all mapping attributes the same due to the Svpbmt extension not yet being ratified and in hardware. Reviewed by: markj, mhorne MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32445 (cherry picked from commit 682c00a6ce2f3870e9c698b283ee2b2a56c28c0b) --- sys/kern/subr_devmap.c | 2 +- sys/riscv/include/pmap.h | 2 ++ sys/riscv/riscv/pmap.c | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_devmap.c b/sys/kern/subr_devmap.c index 23baceb05129..1c9b192cc4c8 100644 --- a/sys/kern/subr_devmap.c +++ b/sys/kern/subr_devmap.c @@ -290,7 +290,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size) return ((void *)(va + offset)); } -#if defined(__aarch64__) +#if defined(__aarch64__) || defined(__riscv) void * pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma) { diff --git a/sys/riscv/include/pmap.h b/sys/riscv/include/pmap.h index 024bc3743f67..0ef221ed2393 100644 --- a/sys/riscv/include/pmap.h +++ b/sys/riscv/include/pmap.h @@ -145,10 +145,12 @@ void pmap_activate_boot(pmap_t); void pmap_activate_sw(struct thread *); void pmap_bootstrap(vm_offset_t, vm_paddr_t, vm_size_t); int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode); +void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode); void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t); vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kremove(vm_offset_t); void pmap_kremove_device(vm_offset_t, vm_size_t); +void *pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma); bool pmap_page_is_mapped(vm_page_t m); bool pmap_ps_enabled(pmap_t); diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index eab61032fbcb..06bb19fb5f24 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -916,7 +916,7 @@ pmap_kextract(vm_offset_t va) ***************************************************/ void -pmap_kenter_device(vm_offset_t sva, vm_size_t size, vm_paddr_t pa) +pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode __unused) { pt_entry_t entry; pt_entry_t *l3; @@ -947,6 +947,12 @@ pmap_kenter_device(vm_offset_t sva, vm_size_t size, vm_paddr_t pa) pmap_invalidate_range(kernel_pmap, sva, va); } +void +pmap_kenter_device(vm_offset_t sva, vm_size_t size, vm_paddr_t pa) +{ + pmap_kenter(sva, size, pa, VM_MEMATTR_DEVICE); +} + /* * Remove a page from the kernel pagetables. * Note: not SMP coherent. From nobody Sun Oct 24 18:54:06 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 982D8182064D; Sun, 24 Oct 2021 18:54: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 4HcnLQ3rm8z3hCn; Sun, 24 Oct 2021 18:54: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 64EF31AB97; Sun, 24 Oct 2021 18:54: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 19OIs6ih080953; Sun, 24 Oct 2021 18:54:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19OIs6eB080952; Sun, 24 Oct 2021 18:54:06 GMT (envelope-from git) Date: Sun, 24 Oct 2021 18:54:06 GMT Message-Id: <202110241854.19OIs6eB080952@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: feb3031f0ae8 - stable/13 - LinuxKPI: Implement _ioremap_attr for riscv List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: feb3031f0ae878b72b48488fe3ba13884ae58b7f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=feb3031f0ae878b72b48488fe3ba13884ae58b7f commit feb3031f0ae878b72b48488fe3ba13884ae58b7f Author: Jessica Clarke AuthorDate: 2021-10-17 14:32:20 +0000 Commit: Jessica Clarke CommitDate: 2021-10-24 18:51:12 +0000 LinuxKPI: Implement _ioremap_attr for riscv Now that riscv implements pmap_mapdev_attr we can enable the non-stub implementation for riscv, which is needed for drm-kmod to not fail at run time for drivers that need to map I/O regions. Reviewed by: hselasky, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32446 (cherry picked from commit 60d962e0410340f107d062e8f4389c0d467613a2) --- sys/compat/linuxkpi/common/include/linux/io.h | 2 +- sys/compat/linuxkpi/common/src/linux_compat.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/io.h b/sys/compat/linuxkpi/common/include/linux/io.h index 074417b892f9..e402ebed0665 100644 --- a/sys/compat/linuxkpi/common/include/linux/io.h +++ b/sys/compat/linuxkpi/common/include/linux/io.h @@ -390,7 +390,7 @@ _outb(u_char data, u_int port) } #endif -#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || defined(__aarch64__) +#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || defined(__aarch64__) || defined(__riscv) void *_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr); #else #define _ioremap_attr(...) NULL diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 247c1f54515e..a1462c6a7010 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -1822,7 +1822,7 @@ vmmap_remove(void *addr) return (vmmap); } -#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || defined(__aarch64__) +#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || defined(__aarch64__) || defined(__riscv) void * _ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr) { @@ -1845,7 +1845,7 @@ iounmap(void *addr) vmmap = vmmap_remove(addr); if (vmmap == NULL) return; -#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || defined(__aarch64__) +#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) || defined(__aarch64__) || defined(__riscv) pmap_unmapdev((vm_offset_t)addr, vmmap->vm_size); #endif kfree(vmmap); From nobody Sun Oct 24 18:54:07 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3248E182079D; Sun, 24 Oct 2021 18:54: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 4HcnLR5w7rz3hLp; Sun, 24 Oct 2021 18:54: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 912C91A832; Sun, 24 Oct 2021 18:54: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 19OIs7FV080979; Sun, 24 Oct 2021 18:54:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19OIs7ux080978; Sun, 24 Oct 2021 18:54:07 GMT (envelope-from git) Date: Sun, 24 Oct 2021 18:54:07 GMT Message-Id: <202110241854.19OIs7ux080978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: fa82e6a10305 - stable/13 - LinuxKPI: Support lazy BAR allocation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: fa82e6a103050299629e62c2289e31946734c277 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=fa82e6a103050299629e62c2289e31946734c277 commit fa82e6a103050299629e62c2289e31946734c277 Author: Jessica Clarke AuthorDate: 2021-10-17 14:32:35 +0000 Commit: Jessica Clarke CommitDate: 2021-10-24 18:51:15 +0000 LinuxKPI: Support lazy BAR allocation Linux KPIs like pci_resource_start/len assume that BARs have been allocated, but FreeBSD lazily allocates BARs if it cannot allocate the firmware-allocated BARs. Thus using the Linux KPIs must force allocation of the BARs rather than returning 0 for the start and length, which can crash drm-kmod drivers that assume the BARs are valid. This is needed for the AMDGPU driver to be able to attach on SiFive's HiFive Unmatched. Reviewed by: hselasky, jhb, mav MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32447 (cherry picked from commit 82098c8bb5b303c7c8b48e7537fadfe74b375bd3) --- sys/compat/linuxkpi/common/include/linux/pci.h | 22 +++++++++++++++------- sys/compat/linuxkpi/common/src/linux_pci.c | 25 ++++++++++++++++++++++--- sys/dev/pci/pci.c | 2 +- sys/dev/pci/pci_private.h | 4 ++++ 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 1ec7fe75388d..5b3c7c292921 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -292,19 +292,27 @@ pci_resource_type(struct pci_dev *pdev, int bar) return (SYS_RES_MEMORY); } +struct resource_list_entry *linux_pci_reserve_bar(struct pci_dev *pdev, + struct resource_list *rl, int type, int rid); + static inline struct resource_list_entry * -linux_pci_get_rle(struct pci_dev *pdev, int type, int rid) +linux_pci_get_rle(struct pci_dev *pdev, int type, int rid, bool reserve_bar) { struct pci_devinfo *dinfo; struct resource_list *rl; + struct resource_list_entry *rle; dinfo = device_get_ivars(pdev->dev.bsddev); rl = &dinfo->resources; - return resource_list_find(rl, type, rid); + rle = resource_list_find(rl, type, rid); + /* Reserve resources for this BAR if needed. */ + if (rle == NULL && reserve_bar) + rle = linux_pci_reserve_bar(pdev, rl, type, rid); + return (rle); } static inline struct resource_list_entry * -linux_pci_get_bar(struct pci_dev *pdev, int bar) +linux_pci_get_bar(struct pci_dev *pdev, int bar, bool reserve) { int type; @@ -312,7 +320,7 @@ linux_pci_get_bar(struct pci_dev *pdev, int bar) if (type < 0) return (NULL); bar = PCIR_BAR(bar); - return (linux_pci_get_rle(pdev, type, bar)); + return (linux_pci_get_rle(pdev, type, bar, reserve)); } static inline struct device * @@ -502,7 +510,7 @@ pci_release_region(struct pci_dev *pdev, int bar) struct pci_devres *dr; struct pci_mmio_region *mmio, *p; - if ((rle = linux_pci_get_bar(pdev, bar)) == NULL) + if ((rle = linux_pci_get_bar(pdev, bar, false)) == NULL) return; /* @@ -760,7 +768,7 @@ pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq) pci_release_msi(pdev->dev.bsddev); return avail; } - rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1); + rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1, false); pdev->dev.irq_start = rle->start; pdev->dev.irq_end = rle->start + avail; for (i = 0; i < nreq; i++) @@ -813,7 +821,7 @@ pci_enable_msi(struct pci_dev *pdev) if ((error = -pci_alloc_msi(pdev->dev.bsddev, &avail)) != 0) return error; - rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1); + rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1, false); pdev->dev.irq_start = rle->start; pdev->dev.irq_end = rle->start + avail; pdev->irq = rle->start; diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index b5bb87b5f2ae..c8f473205ede 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -368,7 +368,7 @@ linux_pci_attach_device(device_t dev, struct pci_driver *pdrv, PCI_GET_ID(parent, dev, PCI_ID_RID, &rid); pdev->devfn = rid; pdev->pdrv = pdrv; - rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 0); + rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 0, false); if (rle != NULL) pdev->dev.irq = rle->start; else @@ -624,6 +624,25 @@ linux_pci_register_driver(struct pci_driver *pdrv) return (_linux_pci_register_driver(pdrv, dc)); } +struct resource_list_entry * +linux_pci_reserve_bar(struct pci_dev *pdev, struct resource_list *rl, + int type, int rid) +{ + device_t dev; + struct resource *res; + + KASSERT(type == SYS_RES_IOPORT || type == SYS_RES_MEMORY, + ("trying to reserve non-BAR type %d", type)); + + dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ? + device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev; + res = pci_reserve_map(device_get_parent(dev), dev, type, &rid, 0, ~0, + 1, 1, 0); + if (res == NULL) + return (NULL); + return (resource_list_find(rl, type, rid)); +} + unsigned long pci_resource_start(struct pci_dev *pdev, int bar) { @@ -631,7 +650,7 @@ pci_resource_start(struct pci_dev *pdev, int bar) rman_res_t newstart; device_t dev; - if ((rle = linux_pci_get_bar(pdev, bar)) == NULL) + if ((rle = linux_pci_get_bar(pdev, bar, true)) == NULL) return (0); dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ? device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev; @@ -648,7 +667,7 @@ pci_resource_len(struct pci_dev *pdev, int bar) { struct resource_list_entry *rle; - if ((rle = linux_pci_get_bar(pdev, bar)) == NULL) + if ((rle = linux_pci_get_bar(pdev, bar, true)) == NULL) return (0); return (rle->count); } diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index ef138e926b6f..530526adb7b3 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -5364,7 +5364,7 @@ DB_SHOW_COMMAND(pciregs, db_pci_dump) } #endif /* DDB */ -static struct resource * +struct resource * pci_reserve_map(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int num, u_int flags) diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h index d891f592bdbd..fec5db2e4ad5 100644 --- a/sys/dev/pci/pci_private.h +++ b/sys/dev/pci/pci_private.h @@ -163,6 +163,10 @@ void pci_read_bar(device_t dev, int reg, pci_addr_t *mapp, struct pci_map *pci_add_bar(device_t dev, int reg, pci_addr_t value, pci_addr_t size); +struct resource *pci_reserve_map(device_t dev, device_t child, int type, + int *rid, rman_res_t start, rman_res_t end, + rman_res_t count, u_int num, u_int flags); + struct resource *pci_alloc_multi_resource(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_long num, u_int flags); From nobody Sun Oct 24 18:54:08 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8DED918207A4; Sun, 24 Oct 2021 18:54: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 4HcnLT0Zhtz3h5P; Sun, 24 Oct 2021 18:54: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 A998A1AA34; Sun, 24 Oct 2021 18:54: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 19OIs8Yv081006; Sun, 24 Oct 2021 18:54:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19OIs8Yp081005; Sun, 24 Oct 2021 18:54:08 GMT (envelope-from git) Date: Sun, 24 Oct 2021 18:54:08 GMT Message-Id: <202110241854.19OIs8Yp081005@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: f9f5d846b72d - stable/13 - Bump __FreeBSD_version for LinuxKPI changes List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: f9f5d846b72d767a4799daa66ae6f0ef3a9ea771 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=f9f5d846b72d767a4799daa66ae6f0ef3a9ea771 commit f9f5d846b72d767a4799daa66ae6f0ef3a9ea771 Author: Jessica Clarke AuthorDate: 2021-10-17 14:35:48 +0000 Commit: Jessica Clarke CommitDate: 2021-10-24 18:52:47 +0000 Bump __FreeBSD_version for LinuxKPI changes (cherry picked from commit 0d6516b453469ce1d92ec903c4c4df9ee08be0f9) --- 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 3d47dda916af..fa3bc1544a4a 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300519 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300520 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Sun Oct 24 21:29:53 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 93187181E0C6; Sun, 24 Oct 2021 21:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hcrp93kvNz4yZQ; Sun, 24 Oct 2021 21:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C3761CD07; Sun, 24 Oct 2021 21:29:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19OLTrlQ081681; Sun, 24 Oct 2021 21:29:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19OLTrmw081680; Sun, 24 Oct 2021 21:29:53 GMT (envelope-from git) Date: Sun, 24 Oct 2021 21:29:53 GMT Message-Id: <202110242129.19OLTrmw081680@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: 39545ce06ca8 - stable/12 - libctf: Improve check for duplicate SOU definitions in ctf_add_type() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 39545ce06ca8088aecc68b92c028b78bcae888a2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=39545ce06ca8088aecc68b92c028b78bcae888a2 commit 39545ce06ca8088aecc68b92c028b78bcae888a2 Author: Mark Johnston AuthorDate: 2021-10-04 16:28:22 +0000 Commit: Mark Johnston CommitDate: 2021-10-24 21:29:36 +0000 libctf: Improve check for duplicate SOU definitions in ctf_add_type() When copying a struct or union from one CTF container to another, ctf_add_type() checks whether it matches an existing type in the destination container. It does so by looking for a type with the same name and kind as the new type, and if one exists, it iterates over all members of the source type and checks whether a member with matching name and offset exists in the matched destination type. This can produce false positives, for example because member types are not compared, but this is not expected to arise in practice. If the match fails, ctf_add_type() returns an error. The procedure used for member comparison breaks down in the face of anonymous struct and union members. ctf_member_iter() visits each member in the source definition and looks up the corresponding member in the desination definition by name using ctf_member_info(), but this function will descend into anonymous members and thus fail to match. Fix the problem by introducing a custom comparison routine which does not assume member names are unique. This should also be faster for types with many members; in the previous scheme, membcmp() would perform a linear scan of the desination type's members to perform a lookup by name. The new routine steps through the members of both types in a single loop. PR: 258763 Sponsored by: The FreeBSD Foundation (cherry picked from commit 105fd928b0b5b35ab529e5f6914788dc49582901) --- cddl/contrib/opensolaris/common/ctf/ctf_create.c | 100 +++++++++++++++++------ 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/cddl/contrib/opensolaris/common/ctf/ctf_create.c b/cddl/contrib/opensolaris/common/ctf/ctf_create.c index a2ca81960f73..bf9b3b26b200 100644 --- a/cddl/contrib/opensolaris/common/ctf/ctf_create.c +++ b/cddl/contrib/opensolaris/common/ctf/ctf_create.c @@ -1196,17 +1196,6 @@ enumadd(const char *name, int value, void *arg) name, value) == CTF_ERR); } -/*ARGSUSED*/ -static int -membcmp(const char *name, ctf_id_t type, ulong_t offset, void *arg) -{ - ctf_bundle_t *ctb = arg; - ctf_membinfo_t ctm; - - return (ctf_member_info(ctb->ctb_file, ctb->ctb_type, - name, &ctm) == CTF_ERR || ctm.ctm_offset != offset); -} - static int membadd(const char *name, ctf_id_t type, ulong_t offset, void *arg) { @@ -1240,6 +1229,71 @@ membadd(const char *name, ctf_id_t type, ulong_t offset, void *arg) return (0); } +static long +soucmp(ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t *dst_fp, + ctf_id_t dst_type) +{ + const struct ctf_type *src_tp, *dst_tp; + const char *src_name, *dst_name; + ssize_t src_sz, dst_sz, src_inc, dst_inc; + uint_t kind, n; + + if ((src_type = ctf_type_resolve(src_fp, src_type)) == CTF_ERR) + return (CTF_ERR); + if ((dst_type = ctf_type_resolve(dst_fp, dst_type)) == CTF_ERR) + return (CTF_ERR); + + if ((src_tp = ctf_lookup_by_id(&src_fp, src_type)) == NULL) + return (CTF_ERR); + if ((dst_tp = ctf_lookup_by_id(&dst_fp, dst_type)) == NULL) + return (CTF_ERR); + + if ((kind = LCTF_INFO_KIND(src_fp, src_tp->ctt_info)) != + LCTF_INFO_KIND(dst_fp, dst_tp->ctt_info)) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + if ((n = LCTF_INFO_VLEN(src_fp, src_tp->ctt_info)) != + LCTF_INFO_VLEN(dst_fp, dst_tp->ctt_info)) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + + (void) ctf_get_ctt_size(src_fp, src_tp, &src_sz, &src_inc); + (void) ctf_get_ctt_size(dst_fp, dst_tp, &dst_sz, &dst_inc); + if (src_sz != dst_sz || src_inc != dst_inc) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + + if (src_sz < CTF_LSTRUCT_THRESH) { + const ctf_member_t *src_mp, *dst_mp; + + src_mp = (const ctf_member_t *)((uintptr_t)src_tp + src_inc); + dst_mp = (const ctf_member_t *)((uintptr_t)dst_tp + dst_inc); + for (; n != 0; n--, src_mp++, dst_mp++) { + if (src_mp->ctm_offset != dst_mp->ctm_offset) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + src_name = ctf_strptr(src_fp, src_mp->ctm_name); + dst_name = ctf_strptr(dst_fp, dst_mp->ctm_name); + if (strcmp(src_name, dst_name) != 0) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + } + } else { + const ctf_lmember_t *src_mp, *dst_mp; + + src_mp = (const ctf_lmember_t *)((uintptr_t)src_tp + src_inc); + dst_mp = (const ctf_lmember_t *)((uintptr_t)dst_tp + dst_inc); + for (; n != 0; n--, src_mp++, dst_mp++) { + if (src_mp->ctlm_offsethi != dst_mp->ctlm_offsethi || + src_mp->ctlm_offsetlo != dst_mp->ctlm_offsetlo) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + src_name = ctf_strptr(src_fp, src_mp->ctlm_name); + dst_name = ctf_strptr(dst_fp, dst_mp->ctlm_name); + if (strcmp(src_name, dst_name) != 0) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + } + } + + return (0); +} + /* * The ctf_add_type routine is used to copy a type from a source CTF container * to a dynamic destination container. This routine operates recursively by @@ -1439,23 +1493,15 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type) ctf_dmdef_t *dmd; int errs = 0; - /* - * Technically to match a struct or union we need to check both - * ways (src members vs. dst, dst members vs. src) but we make - * this more optimal by only checking src vs. dst and comparing - * the total size of the structure (which we must do anyway) - * which covers the possibility of dst members not in src. - * This optimization can be defeated for unions, but is so - * pathological as to render it irrelevant for our purposes. - */ if (dst_type != CTF_ERR && dst_kind != CTF_K_FORWARD) { - if (ctf_type_size(src_fp, src_type) != - ctf_type_size(dst_fp, dst_type)) - return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); - - if (ctf_member_iter(src_fp, src_type, membcmp, &dst)) - return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); - + /* + * Compare the sizes and fields of the two types. + * The field comparisons only check the names and + * offsets, so this is not perfect but is good enough + * for scenarios that we care about. + */ + if (soucmp(src_fp, src_type, dst_fp, dst_type) != 0) + return (CTF_ERR); /* errno is set for us */ break; }