From owner-dev-commits-src-all@freebsd.org Mon Aug 23 00:40:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 35C48660056 for ; Mon, 23 Aug 2021 00:40: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 4GtD1L0W2fz3Q1D; Mon, 23 Aug 2021 00:40: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 E50ED21EF; Mon, 23 Aug 2021 00:40: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 17N0eb9E071062; Mon, 23 Aug 2021 00:40:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N0ebFF071061; Mon, 23 Aug 2021 00:40:37 GMT (envelope-from git) Date: Mon, 23 Aug 2021 00:40:37 GMT Message-Id: <202108230040.17N0ebFF071061@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org From: Martin Matuska Subject: git: 8be2bb3d35e2..9aa547618472 - vendor/libarchive - vendor branch updated MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/vendor/libarchive X-Git-Reftype: branch X-Git-Commit: 9aa5476184726da9d9159568c9b15e29451b5778 X-Git-Oldrev: 8be2bb3d35e232080b4e39244020e650bbe31562 X-Git-Newrev: 9aa5476184726da9d9159568c9b15e29451b5778 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 00:40:38 -0000 The branch vendor/libarchive has been updated by mm: URL: https://cgit.FreeBSD.org/src/log/?id=8be2bb3d35e2..9aa547618472 9aa547618472 Update vendor/libarchive/dist to libarchive/libarchive@1b2c437b9 From owner-dev-commits-src-all@freebsd.org Mon Aug 23 00:43:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 25914660899; Mon, 23 Aug 2021 00:43: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 4GtD4C0WQ9z3RCD; Mon, 23 Aug 2021 00:43: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 ED8DF2A0E; Mon, 23 Aug 2021 00:43: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 17N0h6X7075938; Mon, 23 Aug 2021 00:43:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N0h65e075937; Mon, 23 Aug 2021 00:43:06 GMT (envelope-from git) Date: Mon, 23 Aug 2021 00:43:06 GMT Message-Id: <202108230043.17N0h65e075937@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: 48edac83b3b5 - stable/13 - sigtimedwait: Use a unique wait channel for sleeping 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: 48edac83b3b577c2864f8ea4f8bb9962c834eaf8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 00:43:07 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=48edac83b3b577c2864f8ea4f8bb9962c834eaf8 commit 48edac83b3b577c2864f8ea4f8bb9962c834eaf8 Author: Mark Johnston AuthorDate: 2021-08-16 17:15:25 +0000 Commit: Mark Johnston CommitDate: 2021-08-23 00:42:56 +0000 sigtimedwait: Use a unique wait channel for sleeping When a sigtimedwait(2) caller goes to sleep, it uses a wait channel of p->p_sigacts with the proc lock as the interlock. However, p_sigacts can be shared between processes if a child is created with rfork(RFSIGSHARE | RFPROC). Thus we can end up with two threads sleeping on the same wait channel using different locks, which is not permitted. Fix the problem simply by using a process-unique wait channel, following the example of sigsuspend. The actual wait channel value is irrelevant here, sleeping threads are awoken using sleepq_abort(). Reported by: syzbot+8c417afabadb50bb8827@syzkaller.appspotmail.com Reported by: syzbot+1d89fc2a9ef92ef64fa8@syzkaller.appspotmail.com Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit c4feb1ab0ae0c0e779af372e4c5f3b9e0d3e1388) --- sys/kern/kern_sig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 4f6f424fb05d..d61812ad3043 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1341,7 +1341,8 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, ksiginfo_t *ksi, break; } - error = msleep(ps, &p->p_mtx, PPAUSE|PCATCH, "sigwait", timo); + error = msleep(&p->p_sigacts, &p->p_mtx, PPAUSE | PCATCH, + "sigwait", timo); /* The syscalls can not be restarted. */ if (error == ERESTART) From owner-dev-commits-src-all@freebsd.org Mon Aug 23 00:43:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 90FC8660B96; Mon, 23 Aug 2021 00:43: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 4GtD4Y3hB4z3h7C; Mon, 23 Aug 2021 00:43: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 6759A2A8F; Mon, 23 Aug 2021 00:43: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 17N0hPrG076071; Mon, 23 Aug 2021 00:43:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N0hPmN076070; Mon, 23 Aug 2021 00:43:25 GMT (envelope-from git) Date: Mon, 23 Aug 2021 00:43:25 GMT Message-Id: <202108230043.17N0hPmN076070@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: 75a60b265825 - stable/12 - sigtimedwait: Use a unique wait channel for sleeping 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: 75a60b2658254c974767a5407b9efbadd76ef017 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 00:43:25 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=75a60b2658254c974767a5407b9efbadd76ef017 commit 75a60b2658254c974767a5407b9efbadd76ef017 Author: Mark Johnston AuthorDate: 2021-08-16 17:15:25 +0000 Commit: Mark Johnston CommitDate: 2021-08-23 00:43:16 +0000 sigtimedwait: Use a unique wait channel for sleeping When a sigtimedwait(2) caller goes to sleep, it uses a wait channel of p->p_sigacts with the proc lock as the interlock. However, p_sigacts can be shared between processes if a child is created with rfork(RFSIGSHARE | RFPROC). Thus we can end up with two threads sleeping on the same wait channel using different locks, which is not permitted. Fix the problem simply by using a process-unique wait channel, following the example of sigsuspend. The actual wait channel value is irrelevant here, sleeping threads are awoken using sleepq_abort(). Reported by: syzbot+8c417afabadb50bb8827@syzkaller.appspotmail.com Reported by: syzbot+1d89fc2a9ef92ef64fa8@syzkaller.appspotmail.com Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit c4feb1ab0ae0c0e779af372e4c5f3b9e0d3e1388) --- sys/kern/kern_sig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 07102f6de5a5..917584a12b4b 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1317,7 +1317,8 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, ksiginfo_t *ksi, break; } - error = msleep(ps, &p->p_mtx, PPAUSE|PCATCH, "sigwait", timo); + error = msleep(&p->p_sigacts, &p->p_mtx, PPAUSE | PCATCH, + "sigwait", timo); if (timeout != NULL) { if (error == ERESTART) { From owner-dev-commits-src-all@freebsd.org Mon Aug 23 01:15:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F1A51660B47; Mon, 23 Aug 2021 01:15: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 4GtDnz6Z7Wz3qNv; Mon, 23 Aug 2021 01:15: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 C52842F43; Mon, 23 Aug 2021 01:15: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 17N1Fpqi016091; Mon, 23 Aug 2021 01:15:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N1FpaL016090; Mon, 23 Aug 2021 01:15:51 GMT (envelope-from git) Date: Mon, 23 Aug 2021 01:15:51 GMT Message-Id: <202108230115.17N1FpaL016090@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: 0477149e585f - stable/13 - Optimize res_find(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0477149e585f142ca9e6732d198da470a0c346f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 01:15:52 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=0477149e585f142ca9e6732d198da470a0c346f3 commit 0477149e585f142ca9e6732d198da470a0c346f3 Author: Alexander Motin AuthorDate: 2021-08-09 01:34:33 +0000 Commit: Alexander Motin CommitDate: 2021-08-23 01:15:47 +0000 Optimize res_find(). When the device name is provided, we can simply run strncmp() for each line to quickly skip unrelated ones, that is much faster than sscanf() and only then strcmp(). MFC after: 2 weeks (cherry picked from commit 696fca3fd491972e615195f2ce94598b9c469cac) --- sys/kern/subr_hints.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index 3614659ebcf2..b16761d7d6fc 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -127,7 +127,7 @@ res_find(char **hintp_cookie, int *line, int *startln, const char **ret_name, int *ret_namelen, int *ret_unit, const char **ret_resname, int *ret_resnamelen, const char **ret_value) { - int fbacklvl = FBACK_MDENV, i = 0, n = 0; + int fbacklvl = FBACK_MDENV, i = 0, n = 0, namelen; char r_name[32]; int r_unit; char r_resname[32]; @@ -229,12 +229,16 @@ fallback: i = 0; } + if (name) + namelen = strlen(name); cp = hintp; while (cp) { (*line)++; if (strncmp(cp, "hint.", 5) != 0) goto nexthint; - n = sscanf(cp, "hint.%32[^.].%d.%32[^=]=%127s", r_name, &r_unit, + if (name && strncmp(cp + 5, name, namelen) != 0) + goto nexthint; + n = sscanf(cp + 5, "%32[^.].%d.%32[^=]=%127s", r_name, &r_unit, r_resname, r_value); if (n != 4) { printf("CONFIG: invalid hint '%s'\n", cp); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 01:16:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85623660FE2; Mon, 23 Aug 2021 01:16: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 4GtDpP33b7z3qKs; Mon, 23 Aug 2021 01:16: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 50AAA2EBA; Mon, 23 Aug 2021 01:16: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 17N1GD6u016230; Mon, 23 Aug 2021 01:16:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N1GDbX016229; Mon, 23 Aug 2021 01:16:13 GMT (envelope-from git) Date: Mon, 23 Aug 2021 01:16:13 GMT Message-Id: <202108230116.17N1GDbX016229@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: 44e27939b465 - stable/12 - Optimize res_find(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 44e27939b4653a8a3afa51cb83abbe53f6c25065 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 01:16:13 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=44e27939b4653a8a3afa51cb83abbe53f6c25065 commit 44e27939b4653a8a3afa51cb83abbe53f6c25065 Author: Alexander Motin AuthorDate: 2021-08-09 01:34:33 +0000 Commit: Alexander Motin CommitDate: 2021-08-23 01:16:09 +0000 Optimize res_find(). When the device name is provided, we can simply run strncmp() for each line to quickly skip unrelated ones, that is much faster than sscanf() and only then strcmp(). MFC after: 2 weeks (cherry picked from commit 696fca3fd491972e615195f2ce94598b9c469cac) --- sys/kern/subr_hints.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c index ba30e23d9f8a..507c99eee51f 100644 --- a/sys/kern/subr_hints.c +++ b/sys/kern/subr_hints.c @@ -126,7 +126,7 @@ res_find(char **hintp_cookie, int *line, int *startln, const char **ret_name, int *ret_namelen, int *ret_unit, const char **ret_resname, int *ret_resnamelen, const char **ret_value) { - int fbacklvl = FBACK_MDENV, i = 0, n = 0; + int fbacklvl = FBACK_MDENV, i = 0, n = 0, namelen; char r_name[32]; int r_unit; char r_resname[32]; @@ -229,12 +229,16 @@ fallback: i = 0; } + if (name) + namelen = strlen(name); cp = hintp; while (cp) { (*line)++; if (strncmp(cp, "hint.", 5) != 0) goto nexthint; - n = sscanf(cp, "hint.%32[^.].%d.%32[^=]=%127s", r_name, &r_unit, + if (name && strncmp(cp + 5, name, namelen) != 0) + goto nexthint; + n = sscanf(cp + 5, "%32[^.].%d.%32[^=]=%127s", r_name, &r_unit, r_resname, r_value); if (n != 4) { printf("CONFIG: invalid hint '%s'\n", cp); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 01:32:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B42436615DF; Mon, 23 Aug 2021 01:32: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 4GtF9H4hfRz3v4Z; Mon, 23 Aug 2021 01:32: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 8914533AB; Mon, 23 Aug 2021 01:32: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 17N1WZs8042496; Mon, 23 Aug 2021 01:32:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N1WZrs042495; Mon, 23 Aug 2021 01:32:35 GMT (envelope-from git) Date: Mon, 23 Aug 2021 01:32:35 GMT Message-Id: <202108230132.17N1WZrs042495@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Martin Matuska Subject: git: ddce862ad859 - main - libarchive: import changes from upstream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ddce862ad8594542e1fa1af9ffae7264e12ffd27 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 01:32:35 -0000 The branch main has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=ddce862ad8594542e1fa1af9ffae7264e12ffd27 commit ddce862ad8594542e1fa1af9ffae7264e12ffd27 Merge: 62e1a437f328 9aa547618472 Author: Martin Matuska AuthorDate: 2021-08-23 00:54:15 +0000 Commit: Martin Matuska CommitDate: 2021-08-23 01:07:36 +0000 libarchive: import changes from upstream Libarchive 3.5.2 New features: PR #1502: Support for PWB and v7 binary cpio formats PR #1509: Support of deflate algorithm in symbolic link decompression for ZIP archives Important bugfixes: IS #1044: fix extraction of hardlinks to symlinks PR #1480: Fix truncation of size values during 7zip archive extraction on 32bit architectures PR #1504: fix rar header skiming PR #1514: ZIP excessive disk read - fix location of central directory PR #1520: fix double-free in CAB reader PR #1521: Fixed leak of rar before ending with error PR #1530: Handle short writes from archive_write_callback PR #1532: 7zip: Use compression settings from file also for file header IS #1566: do not follow symlinks when processing the fixup list MFC after: 2 weeks Relnotes: yes contrib/libarchive/NEWS | 2 + contrib/libarchive/README.md | 3 + contrib/libarchive/cat/bsdcat_platform.h | 2 +- contrib/libarchive/cpio/bsdcpio.1 | 7 + contrib/libarchive/cpio/cmdline.c | 4 +- contrib/libarchive/cpio/cpio.c | 23 +- contrib/libarchive/cpio/cpio.h | 1 + contrib/libarchive/cpio/test/test_basic.c | 2 + contrib/libarchive/libarchive/archive.h | 8 +- .../libarchive/archive_disk_acl_freebsd.c | 20 +- contrib/libarchive/libarchive/archive_entry.h | 2 +- contrib/libarchive/libarchive/archive_pathmatch.c | 4 + contrib/libarchive/libarchive/archive_private.h | 7 + contrib/libarchive/libarchive/archive_random.c | 8 +- .../libarchive/archive_read_disk_posix.c | 66 ++- .../libarchive/libarchive/archive_read_extract2.c | 2 +- .../libarchive/archive_read_set_options.3 | 9 + .../libarchive/archive_read_support_filter_rpm.c | 2 +- .../libarchive/archive_read_support_filter_uu.c | 2 +- .../libarchive/archive_read_support_format_7zip.c | 14 +- .../libarchive/archive_read_support_format_cab.c | 1 - .../libarchive/archive_read_support_format_cpio.c | 18 + .../libarchive/archive_read_support_format_mtree.c | 8 +- .../libarchive/archive_read_support_format_rar.c | 14 +- .../libarchive/archive_read_support_format_rar5.c | 1 + .../libarchive/archive_read_support_format_tar.c | 6 +- .../libarchive/archive_read_support_format_zip.c | 154 ++---- .../libarchive/archive_version_details.c | 2 +- contrib/libarchive/libarchive/archive_write.c | 23 +- .../libarchive/archive_write_disk_posix.c | 63 ++- .../libarchive/libarchive/archive_write_format.3 | 18 +- .../libarchive/archive_write_set_format.c | 4 +- .../libarchive/archive_write_set_format_7zip.c | 7 +- .../libarchive/archive_write_set_format_by_name.c | 4 +- .../libarchive/archive_write_set_format_cpio.c | 494 +---------------- .../archive_write_set_format_cpio_binary.c | 610 +++++++++++++++++++++ .../libarchive/archive_write_set_format_cpio_odc.c | 500 +++++++++++++++++ .../archive_write_set_format_filter_by_ext.c | 2 +- .../libarchive/archive_write_set_options.3 | 14 +- contrib/libarchive/libarchive/cpio.5 | 200 ++++--- contrib/libarchive/libarchive/libarchive-formats.5 | 37 +- contrib/libarchive/libarchive/libarchive.3 | 2 +- .../libarchive/test/test_archive_pathmatch.c | 4 + .../libarchive/libarchive/test/test_compat_lzma.c | 2 +- .../test/test_read_disk_directory_traversals.c | 13 +- .../libarchive/test/test_read_format_zip.c | 27 + .../test/test_read_format_zip_7z_deflate.zip.uu | 361 ++++++++++++ .../libarchive/libarchive/test/test_short_writes.c | 216 ++++++++ .../libarchive/libarchive/test/test_sparse_basic.c | 4 +- .../libarchive/test/test_write_disk_appledouble.c | 8 +- .../libarchive/test/test_write_disk_fixup.c | 81 +++ .../libarchive/test/test_write_disk_hardlink.c | 49 +- .../test/test_write_disk_hfs_compression.c | 8 +- .../libarchive/test/test_write_disk_mac_metadata.c | 8 +- .../test/test_write_disk_no_hfs_compression.c | 8 +- .../libarchive/test/test_write_format_cpio.c | 16 +- .../libarchive/test/test_write_format_cpio_empty.c | 2 +- .../libarchive/test/test_write_format_cpio_odc.c | 2 +- .../test/test_write_format_zip_compression_store.c | 2 +- .../test/test_write_format_zip_empty_zip64.c | 2 +- .../libarchive/test/test_write_format_zip_file.c | 2 +- .../test/test_write_format_zip_file_zip64.c | 2 +- .../libarchive/test/test_write_read_format_zip.c | 2 +- contrib/libarchive/libarchive/xxhash.c | 6 +- .../libarchive/tar/test/test_option_safe_writes.c | 2 +- contrib/libarchive/test_utils/test_main.c | 4 +- lib/libarchive/Makefile | 2 + lib/libarchive/config_freebsd.h | 1 + lib/libarchive/tests/Makefile | 3 + 69 files changed, 2401 insertions(+), 806 deletions(-) diff --cc contrib/libarchive/README.md index 56cd723daa47,000000000000..d5ef70c2191d mode 100644,000000..100644 --- a/contrib/libarchive/README.md +++ b/contrib/libarchive/README.md @@@ -1,224 -1,0 +1,227 @@@ +# Welcome to libarchive! + +The libarchive project develops a portable, efficient C library that +can read and write streaming archives in a variety of formats. It +also includes implementations of the common `tar`, `cpio`, and `zcat` +command-line tools that use the libarchive library. + +## Questions? Issues? + +* http://www.libarchive.org is the home for ongoing + libarchive development, including documentation, + and links to the libarchive mailing lists. +* To report an issue, use the issue tracker at + https://github.com/libarchive/libarchive/issues +* To submit an enhancement to libarchive, please + submit a pull request via GitHub: https://github.com/libarchive/libarchive/pulls + +## Contents of the Distribution + +This distribution bundle includes the following major components: + +* **libarchive**: a library for reading and writing streaming archives +* **tar**: the 'bsdtar' program is a full-featured 'tar' implementation built on libarchive +* **cpio**: the 'bsdcpio' program is a different interface to essentially the same functionality +* **cat**: the 'bsdcat' program is a simple replacement tool for zcat, bzcat, xzcat, and such +* **examples**: Some small example programs that you may find useful. +* **examples/minitar**: a compact sample demonstrating use of libarchive. +* **contrib**: Various items sent to me by third parties; please contact the authors with any questions. + +The top-level directory contains the following information files: + +* **NEWS** - highlights of recent changes +* **COPYING** - what you can do with this +* **INSTALL** - installation instructions +* **README** - this file +* **CMakeLists.txt** - input for "cmake" build tool, see INSTALL +* **configure** - configuration script, see INSTALL for details. If your copy of the source lacks a `configure` script, you can try to construct it by running the script in `build/autogen.sh` (or use `cmake`). + +The following files in the top-level directory are used by the 'configure' script: +* `Makefile.am`, `aclocal.m4`, `configure.ac` - used to build this distribution, only needed by maintainers +* `Makefile.in`, `config.h.in` - templates used by configure script + +## Documentation + +In addition to the informational articles and documentation +in the online [libarchive Wiki](https://github.com/libarchive/libarchive/wiki), +the distribution also includes a number of manual pages: + + * bsdtar.1 explains the use of the bsdtar program + * bsdcpio.1 explains the use of the bsdcpio program + * bsdcat.1 explains the use of the bsdcat program + * libarchive.3 gives an overview of the library as a whole + * archive_read.3, archive_write.3, archive_write_disk.3, and + archive_read_disk.3 provide detailed calling sequences for the read + and write APIs + * archive_entry.3 details the "struct archive_entry" utility class + * archive_internals.3 provides some insight into libarchive's + internal structure and operation. + * libarchive-formats.5 documents the file formats supported by the library + * cpio.5, mtree.5, and tar.5 provide detailed information about these + popular archive formats, including hard-to-find details about + modern cpio and tar variants. + +The manual pages above are provided in the 'doc' directory in +a number of different formats. + +You should also read the copious comments in `archive.h` and the +source code for the sample programs for more details. Please let us +know about any errors or omissions you find. + +## Supported Formats + +Currently, the library automatically detects and reads the following formats: + * Old V7 tar archives + * POSIX ustar + * GNU tar format (including GNU long filenames, long link names, and sparse files) + * Solaris 9 extended tar format (including ACLs) + * POSIX pax interchange format + * POSIX octet-oriented cpio + * SVR4 ASCII cpio + * Binary cpio (big-endian or little-endian) ++ * PWB binary cpio + * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions) + * ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives) + * ZIPX archives (with support for bzip2, ppmd8, lzma and xz compressed entries) + * GNU and BSD 'ar' archives + * 'mtree' format + * 7-Zip archives + * Microsoft CAB format + * LHA and LZH archives + * RAR and RAR 5.0 archives (with some limitations due to RAR's proprietary status) + * XAR archives + +The library also detects and handles any of the following before evaluating the archive: + * uuencoded files + * files with RPM wrapper + * gzip compression + * bzip2 compression + * compress/LZW compression + * lzma, lzip, and xz compression + * lz4 compression + * lzop compression + * zstandard compression + +The library can create archives in any of the following formats: + * POSIX ustar + * POSIX pax interchange format + * "restricted" pax format, which will create ustar archives except for + entries that require pax extensions (for long filenames, ACLs, etc). + * Old GNU tar format + * Old V7 tar format + * POSIX octet-oriented cpio + * SVR4 "newc" cpio ++ * Binary cpio (little-endian) ++ * PWB binary cpio + * shar archives + * ZIP archives (with uncompressed or "deflate" compressed entries) + * GNU and BSD 'ar' archives + * 'mtree' format + * ISO9660 format + * 7-Zip archives + * XAR archives + +When creating archives, the result can be filtered with any of the following: + * uuencode + * gzip compression + * bzip2 compression + * compress/LZW compression + * lzma, lzip, and xz compression + * lz4 compression + * lzop compression + * zstandard compression + +## Notes about the Library Design + +The following notes address many of the most common +questions we are asked about libarchive: + +* This is a heavily stream-oriented system. That means that + it is optimized to read or write the archive in a single + pass from beginning to end. For example, this allows + libarchive to process archives too large to store on disk + by processing them on-the-fly as they are read from or + written to a network or tape drive. This also makes + libarchive useful for tools that need to produce + archives on-the-fly (such as webservers that provide + archived contents of a users account). + +* In-place modification and random access to the contents + of an archive are not directly supported. For some formats, + this is not an issue: For example, tar.gz archives are not + designed for random access. In some other cases, libarchive + can re-open an archive and scan it from the beginning quickly + enough to provide the needed abilities even without true + random access. Of course, some applications do require true + random access; those applications should consider alternatives + to libarchive. + +* The library is designed to be extended with new compression and + archive formats. The only requirement is that the format be + readable or writable as a stream and that each archive entry be + independent. There are articles on the libarchive Wiki explaining + how to extend libarchive. + +* On read, compression and format are always detected automatically. + +* The same API is used for all formats; it should be very + easy for software using libarchive to transparently handle + any of libarchive's archiving formats. + +* Libarchive's automatic support for decompression can be used + without archiving by explicitly selecting the "raw" and "empty" + formats. + +* I've attempted to minimize static link pollution. If you don't + explicitly invoke a particular feature (such as support for a + particular compression or format), it won't get pulled in to + statically-linked programs. In particular, if you don't explicitly + enable a particular compression or decompression support, you won't + need to link against the corresponding compression or decompression + libraries. This also reduces the size of statically-linked + binaries in environments where that matters. + +* The library is generally _thread safe_ depending on the platform: + it does not define any global variables of its own. However, some + platforms do not provide fully thread-safe versions of key C library + functions. On those platforms, libarchive will use the non-thread-safe + functions. Patches to improve this are of great interest to us. + +* In particular, libarchive's modules to read or write a directory + tree do use `chdir()` to optimize the directory traversals. This + can cause problems for programs that expect to do disk access from + multiple threads. Of course, those modules are completely + optional and you can use the rest of libarchive without them. + +* The library is _not_ thread aware, however. It does no locking + or thread management of any kind. If you create a libarchive + object and need to access it from multiple threads, you will + need to provide your own locking. + +* On read, the library accepts whatever blocks you hand it. + Your read callback is free to pass the library a byte at a time + or mmap the entire archive and give it to the library at once. + On write, the library always produces correctly-blocked output. + +* The object-style approach allows you to have multiple archive streams + open at once. bsdtar uses this in its "@archive" extension. + +* The archive itself is read/written using callback functions. + You can read an archive directly from an in-memory buffer or + write it to a socket, if you wish. There are some utility + functions to provide easy-to-use "open file," etc, capabilities. + +* The read/write APIs are designed to allow individual entries + to be read or written to any data source: You can create + a block of data in memory and add it to a tar archive without + first writing a temporary file. You can also read an entry from + an archive and write the data directly to a socket. If you want + to read/write entries to disk, there are convenience functions to + make this especially easy. + +* Note: The "pax interchange format" is a POSIX standard extended tar + format that should be used when the older _ustar_ format is not + appropriate. It has many advantages over other tar formats + (including the legacy GNU tar format) and is widely supported by + current tar implementations. + diff --cc contrib/libarchive/cpio/cpio.c index 3d5a6a837407,000000000000..847c92d31449 mode 100644,000000..100644 --- a/contrib/libarchive/cpio/cpio.c +++ b/contrib/libarchive/cpio/cpio.c @@@ -1,1506 -1,0 +1,1517 @@@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "cpio_platform.h" +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#ifdef HAVE_SYS_MKDEV_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_GRP_H +#include +#endif +#ifdef HAVE_LOCALE_H +#include +#endif +#ifdef HAVE_PWD_H +#include +#endif +#ifdef HAVE_SIGNAL_H +#include +#endif +#ifdef HAVE_STDARG_H +#include +#endif +#ifdef HAVE_STDINT_H +#include +#endif +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_TIME_H +#include +#endif + +#include "cpio.h" +#include "err.h" +#include "line_reader.h" +#include "passphrase.h" + +/* Fixed size of uname/gname caches. */ +#define name_cache_size 101 + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +struct name_cache { + int probes; + int hits; + size_t size; + struct { + id_t id; + char *name; + } cache[name_cache_size]; +}; + +static int extract_data(struct archive *, struct archive *); +const char * cpio_i64toa(int64_t); +static const char *cpio_rename(const char *name); +static int entry_to_archive(struct cpio *, struct archive_entry *); +static int file_to_archive(struct cpio *, const char *); +static void free_cache(struct name_cache *cache); +static void list_item_verbose(struct cpio *, struct archive_entry *); +static void long_help(void) __LA_DEAD; +static const char *lookup_gname(struct cpio *, gid_t gid); +static int lookup_gname_helper(struct cpio *, + const char **name, id_t gid); +static const char *lookup_uname(struct cpio *, uid_t uid); +static int lookup_uname_helper(struct cpio *, + const char **name, id_t uid); +static void mode_in(struct cpio *) __LA_DEAD; +static void mode_list(struct cpio *) __LA_DEAD; +static void mode_out(struct cpio *); +static void mode_pass(struct cpio *, const char *); +static const char *remove_leading_slash(const char *); +static int restore_time(struct cpio *, struct archive_entry *, + const char *, int fd); +static void usage(void) __LA_DEAD; +static void version(void) __LA_DEAD; +static const char * passphrase_callback(struct archive *, void *); +static void passphrase_free(char *); + +int +main(int argc, char *argv[]) +{ + static char buff[16384]; + struct cpio _cpio; /* Allocated on stack. */ + struct cpio *cpio; + const char *errmsg; + char *tptr; + int uid, gid; + int opt, t; + + cpio = &_cpio; + memset(cpio, 0, sizeof(*cpio)); + cpio->buff = buff; + cpio->buff_size = sizeof(buff); + +#if defined(HAVE_SIGACTION) && defined(SIGPIPE) + { /* Ignore SIGPIPE signals. */ + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); + } +#endif + + /* Set lafe_progname before calling lafe_warnc. */ + lafe_setprogname(*argv, "bsdcpio"); + +#if HAVE_SETLOCALE + if (setlocale(LC_ALL, "") == NULL) + lafe_warnc(0, "Failed to set default locale"); +#endif + + cpio->uid_override = -1; + cpio->gid_override = -1; + cpio->argv = argv; + cpio->argc = argc; + cpio->mode = '\0'; + cpio->verbose = 0; + cpio->compress = '\0'; + cpio->extract_flags = ARCHIVE_EXTRACT_NO_AUTODIR; + cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER; + cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS; + cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT; + cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS; + cpio->extract_flags |= ARCHIVE_EXTRACT_PERM; + cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS; + cpio->extract_flags |= ARCHIVE_EXTRACT_ACL; +#if !defined(_WIN32) && !defined(__CYGWIN__) + if (geteuid() == 0) + cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER; +#endif + cpio->bytes_per_block = 512; + cpio->filename = NULL; + + cpio->matching = archive_match_new(); + if (cpio->matching == NULL) + lafe_errc(1, 0, "Out of memory"); + + while ((opt = cpio_getopt(cpio)) != -1) { + switch (opt) { + case '0': /* GNU convention: --null, -0 */ + cpio->option_null = 1; + break; ++ case '6': /* in/out: assume/create 6th edition (PWB) format */ ++ cpio->option_pwb = 1; ++ break; ++ case '7': /* out: create archive using 7th Edition binary format */ ++ cpio->format = "bin"; ++ break; + case 'A': /* NetBSD/OpenBSD */ + cpio->option_append = 1; + break; + case 'a': /* POSIX 1997 */ + cpio->option_atime_restore = 1; + break; + case 'B': /* POSIX 1997 */ + cpio->bytes_per_block = 5120; + break; + case OPTION_B64ENCODE: + cpio->add_filter = opt; + break; + case 'C': /* NetBSD/OpenBSD */ + errno = 0; + tptr = NULL; + t = (int)strtol(cpio->argument, &tptr, 10); + if (errno || t <= 0 || *(cpio->argument) == '\0' || + tptr == NULL || *tptr != '\0') { + lafe_errc(1, 0, "Invalid blocksize: %s", + cpio->argument); + } + cpio->bytes_per_block = t; + break; + case 'c': /* POSIX 1997 */ + cpio->format = "odc"; + break; + case 'd': /* POSIX 1997 */ + cpio->extract_flags &= ~ARCHIVE_EXTRACT_NO_AUTODIR; + break; + case 'E': /* NetBSD/OpenBSD */ + if (archive_match_include_pattern_from_file( + cpio->matching, cpio->argument, + cpio->option_null) != ARCHIVE_OK) + lafe_errc(1, 0, "Error : %s", + archive_error_string(cpio->matching)); + break; + case 'F': /* NetBSD/OpenBSD/GNU cpio */ + cpio->filename = cpio->argument; + break; + case 'f': /* POSIX 1997 */ + if (archive_match_exclude_pattern(cpio->matching, + cpio->argument) != ARCHIVE_OK) + lafe_errc(1, 0, "Error : %s", + archive_error_string(cpio->matching)); + break; + case OPTION_GRZIP: + cpio->compress = opt; + break; + case 'H': /* GNU cpio (also --format) */ + cpio->format = cpio->argument; + break; + case 'h': + long_help(); + break; + case 'I': /* NetBSD/OpenBSD */ + cpio->filename = cpio->argument; + break; + case 'i': /* POSIX 1997 */ + if (cpio->mode != '\0') + lafe_errc(1, 0, + "Cannot use both -i and -%c", cpio->mode); + cpio->mode = opt; + break; + case 'J': /* GNU tar, others */ + cpio->compress = opt; + break; + case 'j': /* GNU tar, others */ + cpio->compress = opt; + break; + case OPTION_INSECURE: + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_SYMLINKS; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS; + break; + case 'L': /* GNU cpio */ + cpio->option_follow_links = 1; + break; + case 'l': /* POSIX 1997 */ + cpio->option_link = 1; + break; + case OPTION_LRZIP: + case OPTION_LZ4: + case OPTION_LZMA: /* GNU tar, others */ + case OPTION_LZOP: /* GNU tar, others */ + case OPTION_ZSTD: + cpio->compress = opt; + break; + case 'm': /* POSIX 1997 */ + cpio->extract_flags |= ARCHIVE_EXTRACT_TIME; + break; + case 'n': /* GNU cpio */ + cpio->option_numeric_uid_gid = 1; + break; + case OPTION_NO_PRESERVE_OWNER: /* GNU cpio */ + cpio->extract_flags &= ~ARCHIVE_EXTRACT_OWNER; + break; + case 'O': /* GNU cpio */ + cpio->filename = cpio->argument; + break; + case 'o': /* POSIX 1997 */ + if (cpio->mode != '\0') + lafe_errc(1, 0, + "Cannot use both -o and -%c", cpio->mode); + cpio->mode = opt; + break; + case 'p': /* POSIX 1997 */ + if (cpio->mode != '\0') + lafe_errc(1, 0, + "Cannot use both -p and -%c", cpio->mode); + cpio->mode = opt; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT; + cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS; + break; + case OPTION_PASSPHRASE: + cpio->passphrase = cpio->argument; + break; + case OPTION_PRESERVE_OWNER: + cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER; + break; + case OPTION_QUIET: /* GNU cpio */ + cpio->quiet = 1; + break; + case 'R': /* GNU cpio, also --owner */ + /* TODO: owner_parse should return uname/gname + * also; use that to set [ug]name_override. */ + errmsg = owner_parse(cpio->argument, &uid, &gid); + if (errmsg) { + lafe_warnc(-1, "%s", errmsg); + usage(); + } + if (uid != -1) { + cpio->uid_override = uid; + cpio->uname_override = NULL; + } + if (gid != -1) { + cpio->gid_override = gid; + cpio->gname_override = NULL; + } + break; + case 'r': /* POSIX 1997 */ + cpio->option_rename = 1; + break; + case 't': /* POSIX 1997 */ + cpio->option_list = 1; + break; + case 'u': /* POSIX 1997 */ + cpio->extract_flags + &= ~ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER; + break; + case OPTION_UUENCODE: + cpio->add_filter = opt; + break; + case 'v': /* POSIX 1997 */ + cpio->verbose++; + break; + case 'V': /* GNU cpio */ + cpio->dot++; + break; + case OPTION_VERSION: /* GNU convention */ + version(); + break; +#if 0 + /* + * cpio_getopt() handles -W specially, so it's not + * available here. + */ + case 'W': /* Obscure, but useful GNU convention. */ + break; +#endif + case 'y': /* tar convention */ + cpio->compress = opt; + break; + case 'Z': /* tar convention */ + cpio->compress = opt; + break; + case 'z': /* tar convention */ + cpio->compress = opt; + break; + default: + usage(); + } + } + + /* + * Sanity-check args, error out on nonsensical combinations. + */ + /* -t implies -i if no mode was specified. */ + if (cpio->option_list && cpio->mode == '\0') + cpio->mode = 'i'; + /* -t requires -i */ + if (cpio->option_list && cpio->mode != 'i') + lafe_errc(1, 0, "Option -t requires -i"); + /* -n requires -it */ + if (cpio->option_numeric_uid_gid && !cpio->option_list) + lafe_errc(1, 0, "Option -n requires -it"); + /* Can only specify format when writing */ + if (cpio->format != NULL && cpio->mode != 'o') + lafe_errc(1, 0, "Option --format requires -o"); + /* -l requires -p */ + if (cpio->option_link && cpio->mode != 'p') + lafe_errc(1, 0, "Option -l requires -p"); + /* -v overrides -V */ + if (cpio->dot && cpio->verbose) + cpio->dot = 0; + /* TODO: Flag other nonsensical combinations. */ + + switch (cpio->mode) { + case 'o': - /* TODO: Implement old binary format in libarchive, - use that here. */ - if (cpio->format == NULL) - cpio->format = "odc"; /* Default format */ - ++ if (cpio->format == NULL) { ++ if (cpio->option_pwb) ++ cpio->format = "pwb"; ++ else ++ cpio->format = "cpio"; ++ } + mode_out(cpio); + break; + case 'i': + while (*cpio->argv != NULL) { + if (archive_match_include_pattern(cpio->matching, + *cpio->argv) != ARCHIVE_OK) + lafe_errc(1, 0, "Error : %s", + archive_error_string(cpio->matching)); + --cpio->argc; + ++cpio->argv; + } + if (cpio->option_list) + mode_list(cpio); + else + mode_in(cpio); + break; + case 'p': + if (*cpio->argv == NULL || **cpio->argv == '\0') + lafe_errc(1, 0, + "-p mode requires a target directory"); + mode_pass(cpio, *cpio->argv); + break; + default: + lafe_errc(1, 0, + "Must specify at least one of -i, -o, or -p"); + } + + archive_match_free(cpio->matching); + free_cache(cpio->gname_cache); + free_cache(cpio->uname_cache); + free(cpio->destdir); + passphrase_free(cpio->ppbuff); + return (cpio->return_value); +} + +static void +usage(void) +{ + const char *p; + + p = lafe_getprogname(); + + fprintf(stderr, "Brief Usage:\n"); + fprintf(stderr, " List: %s -it < archive\n", p); + fprintf(stderr, " Extract: %s -i < archive\n", p); + fprintf(stderr, " Create: %s -o < filenames > archive\n", p); + fprintf(stderr, " Help: %s --help\n", p); + exit(1); +} + +static const char *long_help_msg = + "First option must be a mode specifier:\n" + " -i Input -o Output -p Pass\n" + "Common Options:\n" + " -v Verbose filenames -V one dot per file\n" + "Create: %p -o [options] < [list of files] > [archive]\n" + " -J,-y,-z,--lzma Compress archive with xz/bzip2/gzip/lzma\n" - " --format {odc|newc|ustar} Select archive format\n" ++ " --format {pwb|bin|odc|newc|ustar} Select archive format\n" + "List: %p -it < [archive]\n" + "Extract: %p -i [options] < [archive]\n"; + + +/* + * Note that the word 'bsdcpio' will always appear in the first line + * of output. + * + * In particular, /bin/sh scripts that need to test for the presence + * of bsdcpio can use the following template: + * + * if (cpio --help 2>&1 | grep bsdcpio >/dev/null 2>&1 ) then \ + * echo bsdcpio; else echo not bsdcpio; fi + */ +static void +long_help(void) +{ + const char *prog; + const char *p; + + prog = lafe_getprogname(); + + fflush(stderr); + + p = (strcmp(prog,"bsdcpio") != 0) ? "(bsdcpio)" : ""; + printf("%s%s: manipulate archive files\n", prog, p); + + for (p = long_help_msg; *p != '\0'; p++) { + if (*p == '%') { + if (p[1] == 'p') { + fputs(prog, stdout); + p++; + } else + putchar('%'); + } else + putchar(*p); + } + version(); +} + +static void +version(void) +{ + fprintf(stdout,"bsdcpio %s - %s \n", + BSDCPIO_VERSION_STRING, + archive_version_details()); + exit(0); +} + +static void +mode_out(struct cpio *cpio) +{ + struct archive_entry *entry, *spare; + struct lafe_line_reader *lr; + const char *p; + int r; + + if (cpio->option_append) + lafe_errc(1, 0, "Append mode not yet supported."); + + cpio->archive_read_disk = archive_read_disk_new(); + if (cpio->archive_read_disk == NULL) + lafe_errc(1, 0, "Failed to allocate archive object"); + if (cpio->option_follow_links) + archive_read_disk_set_symlink_logical(cpio->archive_read_disk); + else + archive_read_disk_set_symlink_physical(cpio->archive_read_disk); + archive_read_disk_set_standard_lookup(cpio->archive_read_disk); + + cpio->archive = archive_write_new(); + if (cpio->archive == NULL) + lafe_errc(1, 0, "Failed to allocate archive object"); + switch (cpio->compress) { + case OPTION_GRZIP: + r = archive_write_add_filter_grzip(cpio->archive); + break; + case 'J': + r = archive_write_add_filter_xz(cpio->archive); + break; + case OPTION_LRZIP: + r = archive_write_add_filter_lrzip(cpio->archive); + break; + case OPTION_LZ4: + r = archive_write_add_filter_lz4(cpio->archive); + break; + case OPTION_LZMA: + r = archive_write_add_filter_lzma(cpio->archive); + break; + case OPTION_LZOP: + r = archive_write_add_filter_lzop(cpio->archive); + break; + case OPTION_ZSTD: + r = archive_write_add_filter_zstd(cpio->archive); + break; + case 'j': case 'y': + r = archive_write_add_filter_bzip2(cpio->archive); + break; + case 'z': + r = archive_write_add_filter_gzip(cpio->archive); + break; + case 'Z': + r = archive_write_add_filter_compress(cpio->archive); + break; + default: + r = archive_write_add_filter_none(cpio->archive); + break; + } + if (r < ARCHIVE_WARN) + lafe_errc(1, 0, "Requested compression not available"); + switch (cpio->add_filter) { + case 0: + r = ARCHIVE_OK; + break; + case OPTION_B64ENCODE: + r = archive_write_add_filter_b64encode(cpio->archive); + break; + case OPTION_UUENCODE: + r = archive_write_add_filter_uuencode(cpio->archive); + break; + } + if (r < ARCHIVE_WARN) + lafe_errc(1, 0, "Requested filter not available"); + r = archive_write_set_format_by_name(cpio->archive, cpio->format); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(cpio->archive)); + archive_write_set_bytes_per_block(cpio->archive, cpio->bytes_per_block); + cpio->linkresolver = archive_entry_linkresolver_new(); + archive_entry_linkresolver_set_strategy(cpio->linkresolver, + archive_format(cpio->archive)); + if (cpio->passphrase != NULL) + r = archive_write_set_passphrase(cpio->archive, + cpio->passphrase); + else + r = archive_write_set_passphrase_callback(cpio->archive, cpio, + &passphrase_callback); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(cpio->archive)); + + /* + * The main loop: Copy each file into the output archive. + */ + r = archive_write_open_filename(cpio->archive, cpio->filename); + if (r != ARCHIVE_OK) + lafe_errc(1, 0, "%s", archive_error_string(cpio->archive)); + lr = lafe_line_reader("-", cpio->option_null); + while ((p = lafe_line_reader_next(lr)) != NULL) + file_to_archive(cpio, p); + lafe_line_reader_free(lr); + + /* + * The hardlink detection may have queued up a couple of entries + * that can now be flushed. + */ + entry = NULL; + archive_entry_linkify(cpio->linkresolver, &entry, &spare); + while (entry != NULL) { + entry_to_archive(cpio, entry); + archive_entry_free(entry); + entry = NULL; + archive_entry_linkify(cpio->linkresolver, &entry, &spare); + } + + r = archive_write_close(cpio->archive); + if (cpio->dot) *** 2629 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Mon Aug 23 05:07:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCF196632C7; Mon, 23 Aug 2021 05: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 4GtKx55h6Kz3pBn; Mon, 23 Aug 2021 05:07:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9BF3163BB; Mon, 23 Aug 2021 05:07:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57LwH023306; Mon, 23 Aug 2021 05:07:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57LRj023305; Mon, 23 Aug 2021 05:07:21 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:21 GMT Message-Id: <202108230507.17N57LRj023305@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: af2f01643184 - main - diff: don't output carriage returns that were stripped on input MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af2f0164318455433db95adce07af829285b78ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:21 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=af2f0164318455433db95adce07af829285b78ad commit af2f0164318455433db95adce07af829285b78ad Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-22 16:05:59 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff: don't output carriage returns that were stripped on input --strip-trailing-cr worked as intended for comparison between files, but the characters were still present in final output. --- usr.bin/diff/diffreg.c | 11 ++++++++++- usr.bin/diff/tests/Makefile | 3 ++- usr.bin/diff/tests/diff_test.sh | 10 ++++++++++ usr.bin/diff/tests/strip_o.out | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 651ec88df909..113b7b621256 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1273,7 +1273,16 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags) } col = 0; for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { - if ((c = getc(lb)) == EOF) { + c = getc(lb); + if (flags & D_STRIPCR && c == '\r') { + if ((c = getc(lb)) == '\n') + j++; + else { + ungetc(c, lb); + c = '\r'; + } + } + if (c == EOF) { if (diff_format == D_EDIT || diff_format == D_REVERSE || diff_format == D_NREVERSE) diff --git a/usr.bin/diff/tests/Makefile b/usr.bin/diff/tests/Makefile index 78744d3bed8e..303a37911fbd 100644 --- a/usr.bin/diff/tests/Makefile +++ b/usr.bin/diff/tests/Makefile @@ -26,7 +26,8 @@ ${PACKAGE}FILES+= \ header.out \ header_ns.out \ ifdef.out \ - group-format.out + group-format.out \ + strip_o.out NETBSD_ATF_TESTS_SH+= netbsd_diff_test diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh index cd893091d016..b8b7fe1d8068 100755 --- a/usr.bin/diff/tests/diff_test.sh +++ b/usr.bin/diff/tests/diff_test.sh @@ -9,6 +9,7 @@ atf_test_case group_format atf_test_case side_by_side atf_test_case brief_format atf_test_case b230049 +atf_test_case stripcr_o atf_test_case b252515 atf_test_case Bflag atf_test_case Nflag @@ -68,6 +69,14 @@ b230049_body() b230049_a.in b230049_b.in } +stripcr_o_body() +{ + printf 'a\nX\nc\n' > stripcr_o_X.in + printf 'a\r\nY\r\nc\r\n' > stripcr_o_Y.in + atf_check -o "file:$(atf_get_srcdir)/strip_o.out" -s eq:1 \ + diff -L1 -L2 -u --strip-trailing-cr stripcr_o_X.in stripcr_o_Y.in +} + b252515_body() { printf 'a b\n' > b252515_a.in @@ -267,6 +276,7 @@ atf_init_test_cases() atf_add_test_case side_by_side atf_add_test_case brief_format atf_add_test_case b230049 + atf_add_test_case stripcr_o atf_add_test_case b252515 atf_add_test_case Bflag atf_add_test_case Nflag diff --git a/usr.bin/diff/tests/strip_o.out b/usr.bin/diff/tests/strip_o.out new file mode 100644 index 000000000000..47bbfbd4e921 --- /dev/null +++ b/usr.bin/diff/tests/strip_o.out @@ -0,0 +1,7 @@ +--- 1 ++++ 2 +@@ -1,3 +1,3 @@ + a +-X ++Y + c From owner-dev-commits-src-all@freebsd.org Mon Aug 23 05:07:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5A34663A82; Mon, 23 Aug 2021 05:07: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 4GtKx661WWz3pKp; Mon, 23 Aug 2021 05: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 B5FD96352; Mon, 23 Aug 2021 05:07: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 17N57M3R023330; Mon, 23 Aug 2021 05:07:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57ML9023329; Mon, 23 Aug 2021 05:07:22 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:22 GMT Message-Id: <202108230507.17N57ML9023329@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: f8e50dd2c67b - main - Register /usr/tests/usr.bin/diff3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f8e50dd2c67baea2bbd75f94218911d5a4d39597 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:23 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=f8e50dd2c67baea2bbd75f94218911d5a4d39597 commit f8e50dd2c67baea2bbd75f94218911d5a4d39597 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-22 10:08:39 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 Register /usr/tests/usr.bin/diff3 I wasn't able to make check to run diff3 tests, but kevans figured out that I was missing diff3 in mtree. --- etc/mtree/BSD.tests.dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index f7965dac2884..b21256c8563c 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -996,6 +996,8 @@ .. diff .. + diff3 + .. dirname .. du From owner-dev-commits-src-all@freebsd.org Mon Aug 23 05:07:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6097F663A84; Mon, 23 Aug 2021 05:07:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKx80K4cz3pHr; Mon, 23 Aug 2021 05:07:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DB15860E6; Mon, 23 Aug 2021 05:07:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57NW7023354; Mon, 23 Aug 2021 05:07:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57NPE023353; Mon, 23 Aug 2021 05:07:23 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:23 GMT Message-Id: <202108230507.17N57NPE023353@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 7f7b03f3897f - main - diff3: sync with upstream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7f7b03f3897f0196e3cc7a3b71c7359cc206ba61 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:24 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=7f7b03f3897f0196e3cc7a3b71c7359cc206ba61 commit 7f7b03f3897f0196e3cc7a3b71c7359cc206ba61 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-20 21:35:24 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3: sync with upstream * replace realloc calls with reallocarray calls * fix merging of files that lack newlines Obtained from: OpenBSD --- usr.bin/diff3/diff3.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index 03cd24283a13..80d4a202728f 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -459,6 +459,8 @@ duplicate(struct range *r1, struct range *r2) do { c = getc(fp[0]); d = getc(fp[1]); + if (c == -1 && d == -1) + break; if (c == -1 || d== -1) errx(EXIT_FAILURE, "logic error"); nchar++; @@ -528,10 +530,17 @@ edscript(int n) } fseek(fp[2], (long)de[n].new.from, SEEK_SET); for (k = de[n].new.to - de[n].new.from; k > 0; k-= j) { + size_t r; j = k > BUFSIZ ? BUFSIZ : k; - if (fread(block, 1, j, fp[2]) != j) + r = fread(block, 1, j, fp[2]); + if (r == 0) { + if (feof(fp[2])) + break; errx(2, "logic error"); - fwrite(block, 1, j, stdout); + } + if (r != j) + j = r; + (void)fwrite(block, 1, j, stdout); } if (!oflag || !overlap[n]) printf(".\n"); @@ -557,22 +566,22 @@ increase(void) newsz = szchanges == 0 ? 64 : 2 * szchanges; incr = newsz - szchanges; - p = realloc(d13, newsz * sizeof(struct diff)); + p = reallocarray(d13, newsz, sizeof(struct diff)); if (p == NULL) err(1, NULL); memset(p + szchanges, 0, incr * sizeof(struct diff)); d13 = p; - p = realloc(d23, newsz * sizeof(struct diff)); + p = reallocarray(d23, newsz, sizeof(struct diff)); if (p == NULL) err(1, NULL); memset(p + szchanges, 0, incr * sizeof(struct diff)); d23 = p; - p = realloc(de, newsz * sizeof(struct diff)); + p = reallocarray(de, newsz, sizeof(struct diff)); if (p == NULL) err(1, NULL); memset(p + szchanges, 0, incr * sizeof(struct diff)); de = p; - q = realloc(overlap, newsz * sizeof(char)); + q = reallocarray(overlap, newsz, sizeof(char)); if (q == NULL) err(1, NULL); memset(q + szchanges, 0, incr * sizeof(char)); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 05:07:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6BAB5663762; Mon, 23 Aug 2021 05:07: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 4GtKxB2J0tz3pSG; Mon, 23 Aug 2021 05:07: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 35BED63BC; Mon, 23 Aug 2021 05:07: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 17N57QuB023409; Mon, 23 Aug 2021 05:07:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57QDG023408; Mon, 23 Aug 2021 05:07:26 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:26 GMT Message-Id: <202108230507.17N57QDG023408@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: e8ff95356cea - main - diff3.1: update manual page to match code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e8ff95356ceaaa941251056e9d0a4211bf428e06 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:26 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=e8ff95356ceaaa941251056e9d0a4211bf428e06 commit e8ff95356ceaaa941251056e9d0a4211bf428e06 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-20 22:50:05 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3.1: update manual page to match code --- usr.bin/diff3/diff3.1 | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/usr.bin/diff3/diff3.1 b/usr.bin/diff3/diff3.1 index 84985632b8b8..cc4bdf1c8836 100644 --- a/usr.bin/diff3/diff3.1 +++ b/usr.bin/diff3/diff3.1 @@ -38,7 +38,11 @@ .Nd 3-way differential file comparison .Sh SYNOPSIS .Nm diff3 -.Op Fl 3aEeXx +.Op Fl 3aEeiXx +.Op Fl Fl diff-program Ar program +.Op Fl L | Fl Fl label Ar label1 +.Op Fl L | Fl Fl label Ar label2 +.Op Fl L | Fl Fl label Ar label3 .Ar file1 file2 file3 .Sh DESCRIPTION The @@ -60,15 +64,16 @@ new versions. .Pp The options are as follows: .Bl -tag -width "-E, -X" -.It Fl 3 +.It Fl 3 , Fl Fl easy-only Produces an output script suitable for .Xr ed 1 with changes specific only to .Ar file3 . -.It Fl a +.It Fl a , Fl Fl text Treat all files as ASCII. -.It Fl E , X +.It Fl E , Fl Fl show-overlap +.It Fl X Similar to .Fl e and @@ -77,7 +82,7 @@ respectively, but treat overlapping changes (i.e., changes that would be noted with ==== in the normal listing) differently. The overlapping lines from both files will be inserted by the edit script, bracketed by "<<<<<<" and ">>>>>>" lines. -.It Fl e +.It Fl e , Fl Fl ed Produces output in a form suitable as an input script for the .Xr ed 1 utility. @@ -99,11 +104,27 @@ and It is useful for backing out changes specific to .Ar file2 only. -.It Fl x +.It Fl i +Appends 'w' and 'q' +.Xr ed 1 +commands. +.It Fl L , Fl Fl label +Defines labels to print instead of file names +.Ar file1 , +.Ar file2 +and +.Ar file3 . +.It Fl x, Fl Fl overlap-only Produces an output script suitable for .Xr ed 1 with changes specific only to all three versions. +.It Fl Fl diff-program Ar program +Use +.Ar program +instead of the default +.Xr diff 1 +to compare files. .El .Pp The From owner-dev-commits-src-all@freebsd.org Mon Aug 23 05:07:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A8561663442; Mon, 23 Aug 2021 05:07: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 4GtKxC3nHzz3p89; Mon, 23 Aug 2021 05:07: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 4B74A627B; Mon, 23 Aug 2021 05:07: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 17N57ROt023433; Mon, 23 Aug 2021 05:07:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57RX6023432; Mon, 23 Aug 2021 05:07:27 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:27 GMT Message-Id: <202108230507.17N57RX6023432@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 54a3415cb69e - main - diff3: implement --strip-trailing-cr MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 54a3415cb69e1ea0e6533ca3fc168deba64f249f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:27 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=54a3415cb69e1ea0e6533ca3fc168deba64f249f commit 54a3415cb69e1ea0e6533ca3fc168deba64f249f Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-21 00:28:58 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3: implement --strip-trailing-cr Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D31626 --- usr.bin/diff3/diff3.1 | 3 +++ usr.bin/diff3/diff3.c | 9 ++++++++- usr.bin/diff3/tests/1cr.txt | 6 ++++++ usr.bin/diff3/tests/Makefile | 1 + usr.bin/diff3/tests/diff3_test.sh | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/usr.bin/diff3/diff3.1 b/usr.bin/diff3/diff3.1 index cc4bdf1c8836..22e04b6af5e8 100644 --- a/usr.bin/diff3/diff3.1 +++ b/usr.bin/diff3/diff3.1 @@ -40,6 +40,7 @@ .Nm diff3 .Op Fl 3aEeiXx .Op Fl Fl diff-program Ar program +.Op Fl Fl strip-trailing-cr .Op Fl L | Fl Fl label Ar label1 .Op Fl L | Fl Fl label Ar label2 .Op Fl L | Fl Fl label Ar label3 @@ -125,6 +126,8 @@ Use instead of the default .Xr diff 1 to compare files. +.It Fl Fl strip-trailing-cr +Strip trailing carriage return on input files. .El .Pp The diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index 18daa54b2360..122243a9448f 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -264,6 +264,12 @@ get_line(FILE *b, size_t *n) if ((len = getline(&buf, &bufsize, b)) < 0) return (NULL); + if (strip_cr && len >= 2 && strcmp("\r\n", &(buf[len - 2])) == 0) { + buf[len - 2] = '\n'; + buf[len - 1] = '\0'; + len--; + } + if (n != NULL) *n = len; @@ -599,7 +605,7 @@ main(int argc, char **argv) char *labels[] = { NULL, NULL, NULL }; const char *diffprog = DIFF_PATH; char *file1, *file2, *file3; - char *diffargv[6]; + char *diffargv[7]; int diffargc = 0; int fd13[2], fd23[2]; int pd13, pd23; @@ -657,6 +663,7 @@ main(int argc, char **argv) break; case STRIPCR_OPT: strip_cr = 1; + diffargv[diffargc++] = __DECONST(char *, "--strip-trailing-cr"); break; } } diff --git a/usr.bin/diff3/tests/1cr.txt b/usr.bin/diff3/tests/1cr.txt new file mode 100644 index 000000000000..c24bf241e68a --- /dev/null +++ b/usr.bin/diff3/tests/1cr.txt @@ -0,0 +1,6 @@ +This is a more complete test +which multiple lines +and a few typ0s to fix +also I plan to add few lines + and to remove +other lines diff --git a/usr.bin/diff3/tests/Makefile b/usr.bin/diff3/tests/Makefile index dd75be1ca02a..2ec7fbaab564 100644 --- a/usr.bin/diff3/tests/Makefile +++ b/usr.bin/diff3/tests/Makefile @@ -6,6 +6,7 @@ ATF_TESTS_SH= diff3_test ${PACKAGE}FILES+= \ 1.txt \ + 1cr.txt \ 2.txt \ 3.txt \ 1.out \ diff --git a/usr.bin/diff3/tests/diff3_test.sh b/usr.bin/diff3/tests/diff3_test.sh index 6c479de2e9c0..f4b5adf95700 100755 --- a/usr.bin/diff3/tests/diff3_test.sh +++ b/usr.bin/diff3/tests/diff3_test.sh @@ -8,6 +8,9 @@ diff3_body() atf_check -o file:$(atf_get_srcdir)/1.out \ diff3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/1.out \ + diff3 --strip-trailing-cr $(atf_get_srcdir)/1cr.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/2.out \ diff3 -e $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt From owner-dev-commits-src-all@freebsd.org Mon Aug 23 05:07:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 616D3663A86; Mon, 23 Aug 2021 05:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtKx91Nj8z3pNN; Mon, 23 Aug 2021 05:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 06DFA5ED1; Mon, 23 Aug 2021 05:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17N57OSY023378; Mon, 23 Aug 2021 05:07:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N57O2O023377; Mon, 23 Aug 2021 05:07:24 GMT (envelope-from git) Date: Mon, 23 Aug 2021 05:07:24 GMT Message-Id: <202108230507.17N57O2O023377@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 702dda4368dc - main - diff3: improve style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 702dda4368dc2d07e8898fcfdddb12d730e6c174 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 05:07:25 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=702dda4368dc2d07e8898fcfdddb12d730e6c174 commit 702dda4368dc2d07e8898fcfdddb12d730e6c174 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-20 21:50:20 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 05:04:28 +0000 diff3: improve style --- usr.bin/diff3/diff3.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index 80d4a202728f..18daa54b2360 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -126,7 +126,7 @@ static int cline[3]; /* # of the last-read line in each file (0-2) */ */ static int last[4]; static int Aflag, eflag, iflag, mflag, Tflag; -static int oflag; /* indicates whether to mark overlaps (-E or -X)*/ +static int oflag; /* indicates whether to mark overlaps (-E or -X) */ static int strip_cr; static char *f1mark, *f2mark, *f3mark; @@ -170,9 +170,9 @@ static struct option longopts[] = { static void usage(void) { - fprintf(stderr, "usage: diff3 [-3aAeEimTxX] [-L lable1] [-L label2] " - "[ -L label3] file1 file2 file3\n"); - exit (2); + fprintf(stderr, "usage: diff3 [-3aAeEimTxX] [-L label1] [-L label2] " + "[-L label3] file1 file2 file3\n"); + exit(2); } static int @@ -186,7 +186,7 @@ readin(int fd, struct diff **dd) f = fdopen(fd, "r"); if (f == NULL) err(2, "fdopen"); - for (i=0; (p = getchange(f)); i++) { + for (i = 0; (p = getchange(f)); i++) { if (i >= szchanges - 1) increase(); a = b = (int)strtoimax(p, &p, 10); @@ -196,7 +196,7 @@ readin(int fd, struct diff **dd) } kind = *p++; c = d = (int)strtoimax(p, &p, 10); - if (*p==',') { + if (*p == ',') { p++; d = (int)strtoimax(p, &p, 10); } @@ -212,8 +212,8 @@ readin(int fd, struct diff **dd) (*dd)[i].new.to = d; } if (i) { - (*dd)[i].old.from = (*dd)[i-1].old.to; - (*dd)[i].new.from = (*dd)[i-1].new.to; + (*dd)[i].old.from = (*dd)[i - 1].old.to; + (*dd)[i].new.from = (*dd)[i - 1].new.to; } fclose(f); return (i); @@ -222,9 +222,9 @@ readin(int fd, struct diff **dd) static int diffexec(const char *diffprog, char **diffargv, int fd[]) { - int pid, pd; + int pd; - switch (pid = pdfork(&pd, PD_CLOEXEC)) { + switch (pdfork(&pd, PD_CLOEXEC)) { case 0: close(fd[0]); if (dup2(fd[1], STDOUT_FILENO) == -1) @@ -396,7 +396,7 @@ prange(struct range *rold) printf("%da\n", rold->from - 1); else { printf("%d", rold->from); - if (rold->to > rold->from+1) + if (rold->to > rold->from + 1) printf(",%d", rold->to - 1); printf("c\n"); } @@ -433,7 +433,7 @@ skip(int i, int from, const char *pr) if ((line = get_line(fp[i], &j)) == NULL) errx(EXIT_FAILURE, "logic error"); if (pr != NULL) - printf("%s%s", Tflag == 1? "\t" : pr, line); + printf("%s%s", Tflag == 1 ? "\t" : pr, line); cline[i]++; } return ((int) n); @@ -455,13 +455,13 @@ duplicate(struct range *r1, struct range *r2) skip(0, r1->from, NULL); skip(1, r2->from, NULL); nchar = 0; - for (nline=0; nline < r1->to - r1->from; nline++) { + for (nline = 0; nline < r1->to - r1->from; nline++) { do { c = getc(fp[0]); d = getc(fp[1]); if (c == -1 && d == -1) break; - if (c == -1 || d== -1) + if (c == -1 || d == -1) errx(EXIT_FAILURE, "logic error"); nchar++; if (c != d) { @@ -482,6 +482,7 @@ repos(int nchar) for (i = 0; i < 2; i++) (void)fseek(fp[i], (long)-nchar, SEEK_CUR); } + /* * collect an editing script for later regurgitation */ @@ -514,7 +515,7 @@ edscript(int n) if (!oflag || !overlap[n]) { prange(&de[n].old); } else { - printf("%da\n", de[n].old.to -1); + printf("%da\n", de[n].old.to - 1); if (Aflag) { printf("%s\n", f2mark); fseek(fp[1], de[n].old.from, SEEK_SET); @@ -529,8 +530,9 @@ edscript(int n) printf("=======\n"); } fseek(fp[2], (long)de[n].new.from, SEEK_SET); - for (k = de[n].new.to - de[n].new.from; k > 0; k-= j) { + for (k = de[n].new.to - de[n].new.from; k > 0; k -= j) { size_t r; + j = k > BUFSIZ ? BUFSIZ : k; r = fread(block, 1, j, fp[2]); if (r == 0) { @@ -759,7 +761,7 @@ main(int argc, char **argv) for (i = 0; i < nke; i++) { status = e[i].data; if (WIFEXITED(status) && WEXITSTATUS(status) >= 2) - errx(2, "diff exited abormally"); + errx(2, "diff exited abnormally"); else if (WIFSIGNALED(status)) errx(2, "diff killed by signal %d", WTERMSIG(status)); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 06:33:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDA1E664953; Mon, 23 Aug 2021 06:33: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 4GtMr35Rh0z4hXN; Mon, 23 Aug 2021 06:33: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 A2FAA7736; Mon, 23 Aug 2021 06:33: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 17N6X7pw042561; Mon, 23 Aug 2021 06:33:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N6X723042560; Mon, 23 Aug 2021 06:33:07 GMT (envelope-from git) Date: Mon, 23 Aug 2021 06:33:07 GMT Message-Id: <202108230633.17N6X723042560@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: 69d2ba675a6d - stable/13 - ufs_dirhash: Correct a typo in a comment MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 69d2ba675a6d567b86a022022ba3fcc64ed4c1f6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 06:33:07 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=69d2ba675a6d567b86a022022ba3fcc64ed4c1f6 commit 69d2ba675a6d567b86a022022ba3fcc64ed4c1f6 Author: Gordon Bergling AuthorDate: 2021-08-20 07:59:18 +0000 Commit: Gordon Bergling CommitDate: 2021-08-23 06:32:50 +0000 ufs_dirhash: Correct a typo in a comment - s/memry/memory/ (cherry picked from commit 464a166c27bb8947d5de1f617170ef6813587cc3) --- sys/ufs/ufs/dirhash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ufs/ufs/dirhash.h b/sys/ufs/ufs/dirhash.h index d38c1112ff5c..1f9097e58af3 100644 --- a/sys/ufs/ufs/dirhash.h +++ b/sys/ufs/ufs/dirhash.h @@ -66,7 +66,7 @@ * placed at the most-recently-used end of the list. This helps a lot * in the worst-case case scenario where every directory access is * to a directory that is not hashed (i.e. the working set of hash - * candidates is much larger than the configured memry limit). In this + * candidates is much larger than the configured memory limit). In this * case it limits the number of hash builds to 1/DH_SCOREINIT of the * number of accesses. */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 06:33:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C227E665125; Mon, 23 Aug 2021 06:33: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 4GtMrr55Z6z4hKK; Mon, 23 Aug 2021 06:33: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 9708F7644; Mon, 23 Aug 2021 06:33: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 17N6XmuK042728; Mon, 23 Aug 2021 06:33:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N6XmRo042727; Mon, 23 Aug 2021 06:33:48 GMT (envelope-from git) Date: Mon, 23 Aug 2021 06:33:48 GMT Message-Id: <202108230633.17N6XmRo042727@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: c4689ec7f15c - stable/12 - ufs_dirhash: Correct a typo in a comment MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: c4689ec7f15cf27c4b15e070c33f8abc5e2a61d8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 06:33:48 -0000 The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c4689ec7f15cf27c4b15e070c33f8abc5e2a61d8 commit c4689ec7f15cf27c4b15e070c33f8abc5e2a61d8 Author: Gordon Bergling AuthorDate: 2021-08-20 07:59:18 +0000 Commit: Gordon Bergling CommitDate: 2021-08-23 06:33:34 +0000 ufs_dirhash: Correct a typo in a comment - s/memry/memory/ (cherry picked from commit 464a166c27bb8947d5de1f617170ef6813587cc3) --- sys/ufs/ufs/dirhash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ufs/ufs/dirhash.h b/sys/ufs/ufs/dirhash.h index 693cb662d859..94ca74c8c9eb 100644 --- a/sys/ufs/ufs/dirhash.h +++ b/sys/ufs/ufs/dirhash.h @@ -66,7 +66,7 @@ * placed at the most-recently-used end of the list. This helps a lot * in the worst-case case scenario where every directory access is * to a directory that is not hashed (i.e. the working set of hash - * candidates is much larger than the configured memry limit). In this + * candidates is much larger than the configured memory limit). In this * case it limits the number of hash builds to 1/DH_SCOREINIT of the * number of accesses. */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 07:23:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B83D665B12; Mon, 23 Aug 2021 07:23: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 4GtNxr1HTvz4vZw; Mon, 23 Aug 2021 07:23: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 1535310373; Mon, 23 Aug 2021 07:23: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 17N7NBpM009441; Mon, 23 Aug 2021 07:23:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N7NB5w009440; Mon, 23 Aug 2021 07:23:11 GMT (envelope-from git) Date: Mon, 23 Aug 2021 07:23:11 GMT Message-Id: <202108230723.17N7NB5w009440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 72a92f91f466 - main - nfsstat(1): Fix a typo in an error message MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72a92f91f466fdb73071ec28982b9f4d4cf9b672 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 07:23:12 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=72a92f91f466fdb73071ec28982b9f4d4cf9b672 commit 72a92f91f466fdb73071ec28982b9f4d4cf9b672 Author: Gordon Bergling AuthorDate: 2021-08-23 07:21:28 +0000 Commit: Gordon Bergling CommitDate: 2021-08-23 07:21:28 +0000 nfsstat(1): Fix a typo in an error message - s/priviledged/privileged/ MFC after: 1 week --- usr.bin/nfsstat/nfsstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c index 72a2c08963cf..e2d747634bcc 100644 --- a/usr.bin/nfsstat/nfsstat.c +++ b/usr.bin/nfsstat/nfsstat.c @@ -182,7 +182,7 @@ main(int argc, char **argv) mntbuf->f_mntfromname, mntbuf->f_mntonname, buf); else if (errno == EPERM) - errx(1, "Only priviledged users" + errx(1, "Only privileged users" " can use the -m option"); } mntbuf++; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:21:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 76683667884; Mon, 23 Aug 2021 09:21:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtRZl2z6Dz4RMD; Mon, 23 Aug 2021 09:21:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4EA9E11A5F; Mon, 23 Aug 2021 09:21: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 17N9LpTD067085; Mon, 23 Aug 2021 09:21:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9LpDe067084; Mon, 23 Aug 2021 09:21:51 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:51 GMT Message-Id: <202108230921.17N9LpDe067084@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: a3c0eaa3c286 - stable/13 - rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0 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: a3c0eaa3c286b8d29247c65463b73d35f7795a86 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:21:51 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a3c0eaa3c286b8d29247c65463b73d35f7795a86 commit a3c0eaa3c286b8d29247c65463b73d35f7795a86 Author: Fangrui Song AuthorDate: 2021-08-14 16:56:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0 (cherry picked from commit e6c76962031625d51fe4225ecfa15c85155eb13a) --- libexec/rtld-elf/amd64/reloc.c | 27 ++++++++++++--------------- libexec/rtld-elf/i386/reloc.c | 27 ++++++++++++--------------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c index 689b0d8635d4..508ae04a7448 100644 --- a/libexec/rtld-elf/amd64/reloc.c +++ b/libexec/rtld-elf/amd64/reloc.c @@ -548,29 +548,26 @@ __tls_get_addr(tls_index *ti) } size_t -calculate_first_tls_offset(size_t size, size_t align, size_t offset) +calculate_tls_offset(size_t prev_offset, size_t prev_size __unused, + size_t size, size_t align, size_t offset) { size_t res; - res = roundup(size, align); - offset &= align - 1; - if (offset != 0) - res += align - offset; - return (res); + /* + * res is the smallest integer satisfying res - prev_offset >= size + * and (-res) % p_align = p_vaddr % p_align (= p_offset % p_align). + */ + res = prev_offset + size + align - 1; + res -= (res + offset) & (align - 1); + return (res); } size_t -calculate_tls_offset(size_t prev_offset, size_t prev_size __unused, size_t size, - size_t align, size_t offset) +calculate_first_tls_offset(size_t size, size_t align, size_t offset) { - size_t res; - - res = roundup(prev_offset + size, align); - offset &= align - 1; - if (offset != 0) - res += align - offset; - return (res); + return (calculate_tls_offset(0, 0, size, align, offset)); } + size_t calculate_tls_end(size_t off, size_t size __unused) { diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c index cab163b35e6a..69da93347bbb 100644 --- a/libexec/rtld-elf/i386/reloc.c +++ b/libexec/rtld-elf/i386/reloc.c @@ -539,29 +539,26 @@ __tls_get_addr(tls_index *ti) } size_t -calculate_first_tls_offset(size_t size, size_t align, size_t offset) +calculate_tls_offset(size_t prev_offset, size_t prev_size __unused, + size_t size, size_t align, size_t offset) { size_t res; - res = roundup(size, align); - offset &= align - 1; - if (offset != 0) - res += align - offset; - return (res); + /* + * res is the smallest integer satisfying res - prev_offset >= size + * and (-res) % p_align = p_vaddr % p_align (= p_offset % p_align). + */ + res = prev_offset + size + align - 1; + res -= (res + offset) & (align - 1); + return (res); } size_t -calculate_tls_offset(size_t prev_offset, size_t prev_size __unused, size_t size, - size_t align, size_t offset) +calculate_first_tls_offset(size_t size, size_t align, size_t offset) { - size_t res; - - res = roundup(prev_offset + size, align); - offset &= align - 1; - if (offset != 0) - res += align - offset; - return (res); + return (calculate_tls_offset(0, 0, size, align, offset)); } + size_t calculate_tls_end(size_t off, size_t size __unused) { From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:21:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 048E666726C; Mon, 23 Aug 2021 09:21: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 4GtRZn5NbPz4RKL; Mon, 23 Aug 2021 09:21: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 980FE11CA0; Mon, 23 Aug 2021 09:21: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 17N9Lr7R067133; Mon, 23 Aug 2021 09:21:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9Lr3k067132; Mon, 23 Aug 2021 09:21:53 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:53 GMT Message-Id: <202108230921.17N9Lr3k067132@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: edb509a026bd - stable/13 - rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK is set 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: edb509a026bd9cd2f6a81fd4d5af1a332f96a00d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:21:54 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=edb509a026bd9cd2f6a81fd4d5af1a332f96a00d commit edb509a026bd9cd2f6a81fd4d5af1a332f96a00d Author: Fangrui Song AuthorDate: 2021-08-15 04:13:33 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK is set (cherry picked from commit 7da378f9de1a042ec0c81ba7ad39a392540d4721) --- libexec/rtld-elf/rtld.1 | 20 +++++++++++++++++++- libexec/rtld-elf/rtld.c | 40 ++++++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/libexec/rtld-elf/rtld.1 b/libexec/rtld-elf/rtld.1 index b6572caac811..8bc4cfade070 100644 --- a/libexec/rtld-elf/rtld.1 +++ b/libexec/rtld-elf/rtld.1 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 24, 2021 +.Dd August 15, 2021 .Dt RTLD 1 .Os .Sh NAME @@ -143,6 +143,24 @@ If set, .Nm will print a table containing all relocations before symbol binding and relocation. +.It Ev LD_DYNAMIC_WEAK +If set, use the ELF standard-compliant symbol lookup behavior: +resolve to the first found symbol definition. +.Pp +By default, +.Fx +provides the non-standard symbol lookup behavior: +when a weak symbol definition is found, remember the definition and +keep searching in the remaining shared objects for a non-weak definition. +If found, the non-weak definition is preferred, otherwise the remembered +weak definition is returned. +.Pp +Symbols exported by dynamic linker itself (see +.Xr dlfcn 3 ) +are always resolved using +.Fx +rules regardless of the presence of the variable. +This variable is unset for set-user-ID and set-group-ID programs. .It Ev LD_LIBMAP A library replacement list in the same format as .Xr libmap.conf 5 . diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 23482e07fc5f..61b823aaacf8 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -209,6 +209,8 @@ static bool dangerous_ld_env; /* True if environment variables have been bool ld_bind_not; /* Disable PLT update */ static char *ld_bind_now; /* Environment variable for immediate binding */ static char *ld_debug; /* Environment variable for debugging */ +static bool ld_dynamic_weak = true; /* True if non-weak definition overrides + weak definition */ static char *ld_library_path; /* Environment variable for search path */ static char *ld_library_dirs; /* Environment variable for library descriptors */ static char *ld_preload; /* Environment variable for libraries to @@ -583,7 +585,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) unsetenv(_LD("LIBMAP_DISABLE")) || unsetenv(_LD("BIND_NOT")) || unsetenv(_LD("DEBUG")) || unsetenv(_LD("ELF_HINTS_PATH")) || unsetenv(_LD("LOADFLTR")) || unsetenv(_LD("LIBRARY_PATH_RPATH")) || - unsetenv(_LD("PRELOAD_FDS"))) { + unsetenv(_LD("PRELOAD_FDS")) || unsetenv(_LD("DYNAMIC_WEAK"))) { _rtld_error("environment corrupt; aborting"); rtld_die(); } @@ -591,6 +593,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) ld_debug = getenv(_LD("DEBUG")); if (ld_bind_now == NULL) ld_bind_not = getenv(_LD("BIND_NOT")) != NULL; + ld_dynamic_weak = getenv(_LD("DYNAMIC_WEAK")) == NULL; libmap_disable = getenv(_LD("LIBMAP_DISABLE")) != NULL; libmap_override = getenv(_LD("LIBMAP")); ld_library_path = getenv(_LD("LIBRARY_PATH")); @@ -610,7 +613,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) } dangerous_ld_env = libmap_disable || (libmap_override != NULL) || (ld_library_path != NULL) || (ld_preload != NULL) || - (ld_elf_hints_path != NULL) || ld_loadfltr; + (ld_elf_hints_path != NULL) || ld_loadfltr || ld_dynamic_weak; ld_tracing = getenv(_LD("TRACE_LOADED_OBJECTS")); ld_utrace = getenv(_LD("UTRACE")); @@ -3673,11 +3676,12 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, continue; res = symlook_obj(&req, obj); if (res == 0) { - if (def == NULL || - ELF_ST_BIND(req.sym_out->st_info) != STB_WEAK) { + if (def == NULL || (ld_dynamic_weak && + ELF_ST_BIND(req.sym_out->st_info) != STB_WEAK)) { def = req.sym_out; defobj = req.defobj_out; - if (ELF_ST_BIND(def->st_info) != STB_WEAK) + if (!ld_dynamic_weak || + ELF_ST_BIND(def->st_info) != STB_WEAK) break; } } @@ -3686,6 +3690,8 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, * Search the dynamic linker itself, and possibly resolve the * symbol from there. This is how the application links to * dynamic linker services such as dlopen. + * Note that we ignore ld_dynamic_weak == false case, + * always overriding weak symbols by rtld definitions. */ if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) { res = symlook_obj(&req, &obj_rtld); @@ -4288,10 +4294,10 @@ symlook_global(SymLook *req, DoneList *donelist) symlook_init_from_req(&req1, req); /* Search all objects loaded at program start up. */ - if (req->defobj_out == NULL || - ELF_ST_BIND(req->sym_out->st_info) == STB_WEAK) { + if (req->defobj_out == NULL || (ld_dynamic_weak && + ELF_ST_BIND(req->sym_out->st_info) == STB_WEAK)) { res = symlook_list(&req1, &list_main, donelist); - if (res == 0 && (req->defobj_out == NULL || + if (res == 0 && (!ld_dynamic_weak || req->defobj_out == NULL || ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK)) { req->sym_out = req1.sym_out; req->defobj_out = req1.defobj_out; @@ -4301,8 +4307,8 @@ symlook_global(SymLook *req, DoneList *donelist) /* Search all DAGs whose roots are RTLD_GLOBAL objects. */ STAILQ_FOREACH(elm, &list_global, link) { - if (req->defobj_out != NULL && - ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK) + if (req->defobj_out != NULL && (!ld_dynamic_weak || + ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK)) break; res = symlook_list(&req1, &elm->obj->dagmembers, donelist); if (res == 0 && (req->defobj_out == NULL || @@ -4351,8 +4357,8 @@ symlook_default(SymLook *req, const Obj_Entry *refobj) /* Search all dlopened DAGs containing the referencing object. */ STAILQ_FOREACH(elm, &refobj->dldags, link) { - if (req->sym_out != NULL && - ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK) + if (req->sym_out != NULL && (!ld_dynamic_weak || + ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK)) break; res = symlook_list(&req1, &elm->obj->dagmembers, &donelist); if (res == 0 && (req->sym_out == NULL || @@ -4397,10 +4403,11 @@ symlook_list(SymLook *req, const Objlist *objlist, DoneList *dlp) continue; symlook_init_from_req(&req1, req); if ((res = symlook_obj(&req1, elm->obj)) == 0) { - if (def == NULL || ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK) { + if (def == NULL || (ld_dynamic_weak && + ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK)) { def = req1.sym_out; defobj = req1.defobj_out; - if (ELF_ST_BIND(def->st_info) != STB_WEAK) + if (!ld_dynamic_weak || ELF_ST_BIND(def->st_info) != STB_WEAK) break; } } @@ -4435,10 +4442,11 @@ symlook_needed(SymLook *req, const Needed_Entry *needed, DoneList *dlp) if (n->obj == NULL || (res = symlook_list(&req1, &n->obj->dagmembers, dlp)) != 0) continue; - if (def == NULL || ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK) { + if (def == NULL || (ld_dynamic_weak && + ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK)) { def = req1.sym_out; defobj = req1.defobj_out; - if (ELF_ST_BIND(def->st_info) != STB_WEAK) + if (!ld_dynamic_weak || ELF_ST_BIND(def->st_info) != STB_WEAK) break; } } From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:21:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 92B2C667269; Mon, 23 Aug 2021 09:21: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 4GtRZm3pD8z4RGr; Mon, 23 Aug 2021 09:21: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 6BAA511B63; Mon, 23 Aug 2021 09:21: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 17N9LqV9067109; Mon, 23 Aug 2021 09:21:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9LqoJ067108; Mon, 23 Aug 2021 09:21:52 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:52 GMT Message-Id: <202108230921.17N9LqoJ067108@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: 2aa761055cd1 - stable/13 - rtld: Remove calculate_tls_end 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: 2aa761055cd169aff2cd03c909a1256dc09c9f4a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:21:52 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2aa761055cd169aff2cd03c909a1256dc09c9f4a commit 2aa761055cd169aff2cd03c909a1256dc09c9f4a Author: Fangrui Song AuthorDate: 2021-08-14 17:02:09 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 rtld: Remove calculate_tls_end (cherry picked from commit 8f63fa78e84afd23fa68c82eabfe64763c92d4f5) --- lib/libc/gen/tls.c | 8 -------- libexec/rtld-elf/aarch64/rtld_machdep.h | 2 +- libexec/rtld-elf/amd64/reloc.c | 6 ------ libexec/rtld-elf/amd64/rtld_machdep.h | 2 +- libexec/rtld-elf/arm/rtld_machdep.h | 2 +- libexec/rtld-elf/i386/reloc.c | 6 ------ libexec/rtld-elf/i386/rtld_machdep.h | 2 +- libexec/rtld-elf/mips/rtld_machdep.h | 2 +- libexec/rtld-elf/powerpc/rtld_machdep.h | 2 +- libexec/rtld-elf/powerpc64/rtld_machdep.h | 2 +- libexec/rtld-elf/riscv/rtld_machdep.h | 2 +- libexec/rtld-elf/rtld.c | 25 ++++++++++++++++--------- 12 files changed, 24 insertions(+), 37 deletions(-) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 98915ef4ddf7..b5f5dfd4d315 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -81,14 +81,6 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign); #error TLS_TCB_ALIGN undefined for target architecture #endif -#if defined(__aarch64__) || defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__riscv) -#define TLS_VARIANT_I -#endif -#if defined(__i386__) || defined(__amd64__) -#define TLS_VARIANT_II -#endif - #if defined(__mips__) || defined(__powerpc__) || defined(__riscv) #define DTV_OFFSET 0x8000 #else diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h index bdd5620867ba..585689afe197 100644 --- a/libexec/rtld-elf/aarch64/rtld_machdep.h +++ b/libexec/rtld-elf/aarch64/rtld_machdep.h @@ -76,7 +76,6 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, round(16, align) #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ round(prev_offset + prev_size, align) -#define calculate_tls_end(off, size) ((off) + (size)) #define calculate_tls_post_size(align) \ round(TLS_TCB_SIZE, align) - TLS_TCB_SIZE @@ -93,6 +92,7 @@ extern void *__tls_get_addr(tls_index *ti); #define md_abi_variant_hook(x) +#define TLS_VARIANT_I 1 #define TLS_DTV_OFFSET 0 #endif diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c index 508ae04a7448..1fec863c063b 100644 --- a/libexec/rtld-elf/amd64/reloc.c +++ b/libexec/rtld-elf/amd64/reloc.c @@ -567,9 +567,3 @@ calculate_first_tls_offset(size_t size, size_t align, size_t offset) { return (calculate_tls_offset(0, 0, size, align, offset)); } - -size_t -calculate_tls_end(size_t off, size_t size __unused) -{ - return (off); -} diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index 30c82dcb0625..baa926445006 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -73,10 +73,10 @@ void *__tls_get_addr(tls_index *ti) __exported; #define md_abi_variant_hook(x) +#define TLS_VARIANT_II 1 #define TLS_DTV_OFFSET 0 size_t calculate_first_tls_offset(size_t size, size_t align, size_t offset); size_t calculate_tls_offset(size_t prev_offset, size_t prev_size, size_t size, size_t align, size_t offset); -size_t calculate_tls_end(size_t off, size_t size); #endif diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index b333b1f153eb..d890cb377fa3 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -68,7 +68,6 @@ typedef struct { round(8, align) #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ round(prev_offset + prev_size, align) -#define calculate_tls_end(off, size) ((off) + (size)) #define calculate_tls_post_size(align) \ round(TLS_TCB_SIZE, align) - TLS_TCB_SIZE @@ -86,6 +85,7 @@ extern void arm_abi_variant_hook(Elf_Auxinfo **); #define md_abi_variant_hook(x) #endif +#define TLS_VARIANT_I 1 #define TLS_DTV_OFFSET 0 #endif diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c index 69da93347bbb..603a93a2338c 100644 --- a/libexec/rtld-elf/i386/reloc.c +++ b/libexec/rtld-elf/i386/reloc.c @@ -558,9 +558,3 @@ calculate_first_tls_offset(size_t size, size_t align, size_t offset) { return (calculate_tls_offset(0, 0, size, align, offset)); } - -size_t -calculate_tls_end(size_t off, size_t size __unused) -{ - return (off); -} diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index 78154a1992d4..33e7d95f966d 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -74,10 +74,10 @@ void *__tls_get_addr(tls_index *ti) __exported; #define md_abi_variant_hook(x) +#define TLS_VARIANT_II 1 #define TLS_DTV_OFFSET 0 size_t calculate_first_tls_offset(size_t size, size_t align, size_t offset); size_t calculate_tls_offset(size_t prev_offset, size_t prev_size, size_t size, size_t align, size_t offset); -size_t calculate_tls_end(size_t off, size_t size); #endif diff --git a/libexec/rtld-elf/mips/rtld_machdep.h b/libexec/rtld-elf/mips/rtld_machdep.h index 041a5d05f9a7..0cb56290152e 100644 --- a/libexec/rtld-elf/mips/rtld_machdep.h +++ b/libexec/rtld-elf/mips/rtld_machdep.h @@ -68,7 +68,6 @@ typedef struct { TLS_TCB_SIZE #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ round(prev_offset + prev_size, align) -#define calculate_tls_end(off, size) ((off) + (size)) #define calculate_tls_post_size(align) 0 extern void *__tls_get_addr(tls_index *ti); @@ -78,6 +77,7 @@ extern void *__tls_get_addr(tls_index *ti); #define md_abi_variant_hook(x) +#define TLS_VARIANT_I 1 #define TLS_DTV_OFFSET 0 #endif diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index a35ac1f4ebf5..c98dc7d3acb5 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -73,6 +73,7 @@ void _rtld_powerpc_pltcall(void); * TLS */ +#define TLS_VARIANT_I 1 #define TLS_TP_OFFSET 0x7000 #define TLS_DTV_OFFSET 0x8000 #define TLS_TCB_SIZE 8 @@ -83,7 +84,6 @@ void _rtld_powerpc_pltcall(void); TLS_TCB_SIZE #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ round(prev_offset + prev_size, align) -#define calculate_tls_end(off, size) ((off) + (size)) #define calculate_tls_post_size(align) 0 typedef struct { diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h index 486f4ffe95bc..98bdbb33affe 100644 --- a/libexec/rtld-elf/powerpc64/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h @@ -65,6 +65,7 @@ extern u_long cpu_features2; /* r4 */ * TLS */ +#define TLS_VARIANT_I 1 #define TLS_TP_OFFSET 0x7000 #define TLS_DTV_OFFSET 0x8000 #define TLS_TCB_SIZE 16 @@ -75,7 +76,6 @@ extern u_long cpu_features2; /* r4 */ TLS_TCB_SIZE #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ round(prev_offset + prev_size, align) -#define calculate_tls_end(off, size) ((off) + (size)) #define calculate_tls_post_size(align) 0 typedef struct { diff --git a/libexec/rtld-elf/riscv/rtld_machdep.h b/libexec/rtld-elf/riscv/rtld_machdep.h index 43349b4ab403..7a087ca2ab7c 100644 --- a/libexec/rtld-elf/riscv/rtld_machdep.h +++ b/libexec/rtld-elf/riscv/rtld_machdep.h @@ -82,6 +82,7 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, /* * TLS */ +#define TLS_VARIANT_I 1 #define TLS_TP_OFFSET 0x0 #define TLS_DTV_OFFSET 0x800 #define TLS_TCB_SIZE 16 @@ -92,7 +93,6 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, TLS_TCB_SIZE #define calculate_tls_offset(prev_offset, prev_size, size, align, offset) \ round(prev_offset + prev_size, align) -#define calculate_tls_end(off, size) ((off) + (size)) #define calculate_tls_post_size(align) 0 typedef struct { diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index eaad89339d07..23482e07fc5f 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -4939,8 +4939,7 @@ tls_get_addr_common(Elf_Addr **dtvp, int index, size_t offset) return (tls_get_addr_slow(dtvp, index, offset, false)); } -#if defined(__aarch64__) || defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__riscv) +#ifdef TLS_VARIANT_I /* * Return pointer to allocated TLS block @@ -5071,9 +5070,9 @@ free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused) free_aligned(get_tls_block_ptr(tcb, tcbsize)); } -#endif +#endif /* TLS_VARIANT_I */ -#if defined(__i386__) || defined(__amd64__) +#ifdef TLS_VARIANT_II /* * Allocate Static TLS using the Variant II method. @@ -5179,7 +5178,7 @@ free_tls(void *tls, size_t tcbsize __unused, size_t tcbalign) free((void*) dtv); } -#endif +#endif /* TLS_VARIANT_II */ /* * Allocate TLS block for module with given index. @@ -5227,6 +5226,11 @@ allocate_tls_offset(Obj_Entry *obj) off = calculate_tls_offset(tls_last_offset, tls_last_size, obj->tlssize, obj->tlsalign, obj->tlspoffset); + obj->tlsoffset = off; +#ifdef TLS_VARIANT_I + off += obj->tlssize; +#endif + /* * If we have already fixed the size of the static TLS block, we * must stay within that size. When allocating the static TLS, we @@ -5234,13 +5238,13 @@ allocate_tls_offset(Obj_Entry *obj) * loading modules which use static TLS. */ if (tls_static_space != 0) { - if (calculate_tls_end(off, obj->tlssize) > tls_static_space) + if (off > tls_static_space) return false; } else if (obj->tlsalign > tls_static_max_align) { tls_static_max_align = obj->tlsalign; } - tls_last_offset = obj->tlsoffset = off; + tls_last_offset = off; tls_last_size = obj->tlssize; obj->tls_done = true; @@ -5257,8 +5261,11 @@ free_tls_offset(Obj_Entry *obj) * simplistic workaround to allow libGL.so.1 to be loaded and * unloaded multiple times. */ - if (calculate_tls_end(obj->tlsoffset, obj->tlssize) - == calculate_tls_end(tls_last_offset, tls_last_size)) { + size_t off = obj->tlsoffset; +#ifdef TLS_VARIANT_I + off += obj->tlssize; +#endif + if (off == tls_last_offset) { tls_last_offset -= obj->tlssize; tls_last_size = 0; } From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:21:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3E9B166789C; Mon, 23 Aug 2021 09:21: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 4GtRZq6qL6z4RRW; Mon, 23 Aug 2021 09:21: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 CCF7211B64; Mon, 23 Aug 2021 09:21: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 17N9LtC7067185; Mon, 23 Aug 2021 09:21:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9LtCW067184; Mon, 23 Aug 2021 09:21:55 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:55 GMT Message-Id: <202108230921.17N9LtCW067184@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: 2395d5ddbf0d - stable/13 - rtld: rework how environment variables are named 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: 2395d5ddbf0dd29367d2bf94e8a021c026856bed Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:21:56 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2395d5ddbf0dd29367d2bf94e8a021c026856bed commit 2395d5ddbf0dd29367d2bf94e8a021c026856bed Author: Konstantin Belousov AuthorDate: 2021-08-15 18:57:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 rtld: rework how environment variables are named (cherry picked from commit 451dc2b7cc0c845a3f76f9ee670f16699c49b491) --- libexec/rtld-elf/arm/rtld_machdep.h | 1 - libexec/rtld-elf/rtld.c | 178 ++++++++++++++++++++++++++---------- 2 files changed, 131 insertions(+), 48 deletions(-) diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index d890cb377fa3..26e677f26d5a 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -80,7 +80,6 @@ extern void arm_abi_variant_hook(Elf_Auxinfo **); #ifdef __ARM_FP #define md_abi_variant_hook(x) arm_abi_variant_hook(x) -#define RTLD_VARIANT_ENV_NAMES #else #define md_abi_variant_hook(x) #endif diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 61b823aaacf8..6826dde8a160 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -342,23 +342,106 @@ ld_utrace_log(int event, void *handle, void *mapbase, size_t mapsize, utrace(&ut, sizeof(ut)); } -#ifdef RTLD_VARIANT_ENV_NAMES -/* - * construct the env variable based on the type of binary that's - * running. - */ -static inline const char * -_LD(const char *var) +enum { + LD_BIND_NOW = 0, + LD_PRELOAD, + LD_LIBMAP, + LD_LIBRARY_PATH, + LD_LIBRARY_PATH_FDS, + LD_LIBMAP_DISABLE, + LD_BIND_NOT, + LD_DEBUG, + LD_ELF_HINTS_PATH, + LD_LOADFLTR, + LD_LIBRARY_PATH_RPATH, + LD_PRELOAD_FDS, + LD_DYNAMIC_WEAK, + LD_TRACE_LOADED_OBJECTS, + LD_UTRACE, + LD_DUMP_REL_PRE, + LD_DUMP_REL_POST, + LD_TRACE_LOADED_OBJECTS_PROGNAME, + LD_TRACE_LOADED_OBJECTS_FMT1, + LD_TRACE_LOADED_OBJECTS_FMT2, + LD_TRACE_LOADED_OBJECTS_ALL, +}; + +struct ld_env_var_desc { + char n[64]; + bool unsecure; +}; + +static struct ld_env_var_desc ld_env_vars[] = { + [LD_BIND_NOW] = + { .n = "BIND_NOW", .unsecure = false }, + [LD_PRELOAD] = + { .n = "PRELOAD", .unsecure = true }, + [LD_LIBMAP] = + { .n = "LIBMAP", .unsecure = true }, + [LD_LIBRARY_PATH] = + { .n = "LIBRARY_PATH", .unsecure = true }, + [LD_LIBRARY_PATH_FDS] = + { .n = "LIBRARY_PATH_FDS", .unsecure = true }, + [LD_LIBMAP_DISABLE] = + { .n = "LIBMAP_DISABLE", .unsecure = true }, + [LD_BIND_NOT] = + { .n = "BIND_NOT", .unsecure = true }, + [LD_DEBUG] = + { .n = "DEBUG", .unsecure = true }, + [LD_ELF_HINTS_PATH] = + { .n = "ELF_HINTS_PATH", .unsecure = true }, + [LD_LOADFLTR] = + { .n = "LOADFLTR", .unsecure = true }, + [LD_LIBRARY_PATH_RPATH] = + { .n = "LIBRARY_PATH_RPATH", .unsecure = true }, + [LD_PRELOAD_FDS] = + { .n = "PRELOAD_FDS", .unsecure = true }, + [LD_DYNAMIC_WEAK] = + { .n = "DYNAMIC_WEAK", .unsecure = true }, + [LD_TRACE_LOADED_OBJECTS] = + { .n = "TRACE_LOADED_OBJECTS", .unsecure = false }, + [LD_UTRACE] = + { .n = "UTRACE", .unsecure = false }, + [LD_DUMP_REL_PRE] = + { .n = "DUMP_REL_PRE", .unsecure = false }, + [LD_DUMP_REL_POST] = + { .n = "DUMP_REL_POST", .unsecure = false }, + [LD_TRACE_LOADED_OBJECTS_PROGNAME] = + { .n = "TRACE_LOADED_OBJECTS_PROGNAME", .unsecure = false}, + [LD_TRACE_LOADED_OBJECTS_FMT1] = + { .n = "TRACE_LOADED_OBJECTS_FMT1", .unsecure = false}, + [LD_TRACE_LOADED_OBJECTS_FMT2] = + { .n = "TRACE_LOADED_OBJECTS_FMT2", .unsecure = false}, + [LD_TRACE_LOADED_OBJECTS_ALL] = + { .n = "TRACE_LOADED_OBJECTS_ALL", .unsecure = false}, +}; + +static const char * +ld_var(int idx) { - static char buffer[128]; + return (ld_env_vars[idx].n); +} - strlcpy(buffer, ld_env_prefix, sizeof(buffer)); - strlcat(buffer, var, sizeof(buffer)); - return (buffer); +static char * +ld_get_env_var(int idx) +{ + return (getenv(ld_var(idx))); +} + +static void +rtld_init_env_vars(void) +{ + struct ld_env_var_desc *lvd; + size_t sz; + int i; + + sz = strlen(ld_env_prefix); + for (i = 0; i < (int)nitems(ld_env_vars); i++) { + lvd = &ld_env_vars[i]; + memmove(lvd->n + sz, lvd->n, strlen(lvd->n) + 1); + memcpy(lvd->n, ld_env_prefix, sz); + } } -#else -#define _LD(x) LD_ x -#endif /* * Main entry point for dynamic linking. The first argument is the @@ -389,6 +472,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) Elf_Addr *argcp; char **argv, **env, **envp, *kexecpath, *library_path_rpath; const char *argv0, *binpath; + struct ld_env_var_desc *lvd; caddr_t imgentry; char buf[MAXPATHLEN]; int argc, fd, i, mib[4], old_osrel, osrel, phnum, rtld_argc; @@ -464,6 +548,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) direct_exec = false; md_abi_variant_hook(aux_info); + rtld_init_env_vars(); fd = -1; if (aux_info[AT_EXECFD] != NULL) { @@ -571,7 +656,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) } } - ld_bind_now = getenv(_LD("BIND_NOW")); + ld_bind_now = ld_get_env_var(LD_BIND_NOW); /* * If the process is tainted, then we un-set the dangerous environment @@ -580,29 +665,27 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) * future processes to honor the potentially un-safe variables. */ if (!trust) { - if (unsetenv(_LD("PRELOAD")) || unsetenv(_LD("LIBMAP")) || - unsetenv(_LD("LIBRARY_PATH")) || unsetenv(_LD("LIBRARY_PATH_FDS")) || - unsetenv(_LD("LIBMAP_DISABLE")) || unsetenv(_LD("BIND_NOT")) || - unsetenv(_LD("DEBUG")) || unsetenv(_LD("ELF_HINTS_PATH")) || - unsetenv(_LD("LOADFLTR")) || unsetenv(_LD("LIBRARY_PATH_RPATH")) || - unsetenv(_LD("PRELOAD_FDS")) || unsetenv(_LD("DYNAMIC_WEAK"))) { - _rtld_error("environment corrupt; aborting"); - rtld_die(); - } + for (i = 0; i < (int)nitems(ld_env_vars); i++) { + lvd = &ld_env_vars[i]; + if (lvd->unsecure && unsetenv(lvd->n)) { + _rtld_error("environment corrupt; aborting"); + rtld_die(); + } + } } - ld_debug = getenv(_LD("DEBUG")); + ld_debug = ld_get_env_var(LD_DEBUG); if (ld_bind_now == NULL) - ld_bind_not = getenv(_LD("BIND_NOT")) != NULL; - ld_dynamic_weak = getenv(_LD("DYNAMIC_WEAK")) == NULL; - libmap_disable = getenv(_LD("LIBMAP_DISABLE")) != NULL; - libmap_override = getenv(_LD("LIBMAP")); - ld_library_path = getenv(_LD("LIBRARY_PATH")); - ld_library_dirs = getenv(_LD("LIBRARY_PATH_FDS")); - ld_preload = getenv(_LD("PRELOAD")); - ld_preload_fds = getenv(_LD("PRELOAD_FDS")); - ld_elf_hints_path = getenv(_LD("ELF_HINTS_PATH")); - ld_loadfltr = getenv(_LD("LOADFLTR")) != NULL; - library_path_rpath = getenv(_LD("LIBRARY_PATH_RPATH")); + ld_bind_not = ld_get_env_var(LD_BIND_NOT) != NULL; + ld_dynamic_weak = ld_get_env_var(LD_DYNAMIC_WEAK) == NULL; + libmap_disable = ld_get_env_var(LD_LIBMAP_DISABLE) != NULL; + libmap_override = ld_get_env_var(LD_LIBMAP); + ld_library_path = ld_get_env_var(LD_LIBRARY_PATH); + ld_library_dirs = ld_get_env_var(LD_LIBRARY_PATH_FDS); + ld_preload = ld_get_env_var(LD_PRELOAD); + ld_preload_fds = ld_get_env_var(LD_PRELOAD_FDS); + ld_elf_hints_path = ld_get_env_var(LD_ELF_HINTS_PATH); + ld_loadfltr = ld_get_env_var(LD_LOADFLTR) != NULL; + library_path_rpath = ld_get_env_var(LD_LIBRARY_PATH_RPATH); if (library_path_rpath != NULL) { if (library_path_rpath[0] == 'y' || library_path_rpath[0] == 'Y' || @@ -611,11 +694,11 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) else ld_library_path_rpath = false; } - dangerous_ld_env = libmap_disable || (libmap_override != NULL) || - (ld_library_path != NULL) || (ld_preload != NULL) || - (ld_elf_hints_path != NULL) || ld_loadfltr || ld_dynamic_weak; - ld_tracing = getenv(_LD("TRACE_LOADED_OBJECTS")); - ld_utrace = getenv(_LD("UTRACE")); + dangerous_ld_env = libmap_disable || libmap_override != NULL || + ld_library_path != NULL || ld_preload != NULL || + ld_elf_hints_path != NULL || ld_loadfltr || ld_dynamic_weak; + ld_tracing = ld_get_env_var(LD_TRACE_LOADED_OBJECTS); + ld_utrace = ld_get_env_var(LD_UTRACE); if ((ld_elf_hints_path == NULL) || strlen(ld_elf_hints_path) == 0) ld_elf_hints_path = ld_elf_hints_default; @@ -751,7 +834,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) exit(0); } - if (getenv(_LD("DUMP_REL_PRE")) != NULL) { + if (ld_get_env_var(LD_DUMP_REL_PRE) != NULL) { dump_relocations(obj_main); exit (0); } @@ -779,7 +862,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) if (do_copy_relocations(obj_main) == -1) rtld_die(); - if (getenv(_LD("DUMP_REL_POST")) != NULL) { + if (ld_get_env_var(LD_DUMP_REL_POST) != NULL) { dump_relocations(obj_main); exit (0); } @@ -4715,16 +4798,17 @@ trace_loaded_objects(Obj_Entry *obj) const char *fmt1, *fmt2, *fmt, *main_local, *list_containers; int c; - if ((main_local = getenv(_LD("TRACE_LOADED_OBJECTS_PROGNAME"))) == NULL) + if ((main_local = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_PROGNAME)) == + NULL) main_local = ""; - if ((fmt1 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT1"))) == NULL) + if ((fmt1 = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_FMT1)) == NULL) fmt1 = "\t%o => %p (%x)\n"; - if ((fmt2 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT2"))) == NULL) + if ((fmt2 = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_FMT2)) == NULL) fmt2 = "\t%o (%x)\n"; - list_containers = getenv(_LD("TRACE_LOADED_OBJECTS_ALL")); + list_containers = ld_get_env_var(LD_TRACE_LOADED_OBJECTS_ALL); for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) { Needed_Entry *needed; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:21:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 048B5666E5E; Mon, 23 Aug 2021 09:21: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 4GtRZp5yvDz4RKP; Mon, 23 Aug 2021 09:21: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 AF23C11AE0; Mon, 23 Aug 2021 09:21: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 17N9LsjZ067157; Mon, 23 Aug 2021 09:21:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9LsNV067156; Mon, 23 Aug 2021 09:21:54 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:54 GMT Message-Id: <202108230921.17N9LsNV067156@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: 6295883670c3 - stable/13 - libc tls: use TLS_DTV_OFFSET defined by rtld.h 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: 6295883670c37f005e59d2ea3b850389a5c6d308 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:21:55 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6295883670c37f005e59d2ea3b850389a5c6d308 commit 6295883670c37f005e59d2ea3b850389a5c6d308 Author: Konstantin Belousov AuthorDate: 2021-08-15 02:14:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 libc tls: use TLS_DTV_OFFSET defined by rtld.h (cherry picked from commit 300e08933e80e9fce02d0d2f7a64e3ad27e4ce8e) --- lib/libc/gen/tls.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index b5f5dfd4d315..d90aac028b88 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -81,12 +81,6 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign); #error TLS_TCB_ALIGN undefined for target architecture #endif -#if defined(__mips__) || defined(__powerpc__) || defined(__riscv) -#define DTV_OFFSET 0x8000 -#else -#define DTV_OFFSET 0 -#endif - #ifndef PIC static size_t libc_tls_static_space; @@ -289,7 +283,7 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign) /* Adjust the DTV. */ dtv = tcb[0]; - dtv[2] = (Elf_Addr)(tls + DTV_OFFSET); + dtv[2] = (Elf_Addr)(tls + TLS_DTV_OFFSET); } else { dtv = __je_bootstrap_malloc(3 * sizeof(Elf_Addr)); if (dtv == NULL) { @@ -300,7 +294,7 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign) tcb[0] = dtv; dtv[0] = 1; /* Generation. */ dtv[1] = 1; /* Segments count. */ - dtv[2] = (Elf_Addr)(tls + DTV_OFFSET); + dtv[2] = (Elf_Addr)(tls + TLS_DTV_OFFSET); if (libc_tls_init_size > 0) memcpy(tls, libc_tls_init, libc_tls_init_size); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:21:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D2E86678A3; Mon, 23 Aug 2021 09:21: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 4GtRZs0vGKz4RP1; Mon, 23 Aug 2021 09:21: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 00DA911CA1; Mon, 23 Aug 2021 09:21: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 17N9LuXL067212; Mon, 23 Aug 2021 09:21:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9LuOF067211; Mon, 23 Aug 2021 09:21:56 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:56 GMT Message-Id: <202108230921.17N9LuOF067211@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: f2f2f23ad70e - stable/13 - rtld: avoid use of of getenv(3) for evaluating rtld env vars (LD_XXX) 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: f2f2f23ad70e6f1a48e93ea69e1ffd7c89c98d7b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:21:57 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f2f2f23ad70e6f1a48e93ea69e1ffd7c89c98d7b commit f2f2f23ad70e6f1a48e93ea69e1ffd7c89c98d7b Author: Konstantin Belousov AuthorDate: 2021-08-16 12:59:05 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 rtld: avoid use of of getenv(3) for evaluating rtld env vars (LD_XXX) (cherry picked from commit bfd4c875a10560aaa2f41e82114df79fde008fdb) --- libexec/rtld-elf/rtld.c | 144 ++++++++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 61 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 6826dde8a160..39c41fe0ed24 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -367,82 +367,105 @@ enum { }; struct ld_env_var_desc { - char n[64]; - bool unsecure; + const char *n; + char *val; + const bool unsecure; }; +#define LD_ENV_DESC(var, unsec) \ + [LD_##var] = { .n = #var, .unsecure = unsec } static struct ld_env_var_desc ld_env_vars[] = { - [LD_BIND_NOW] = - { .n = "BIND_NOW", .unsecure = false }, - [LD_PRELOAD] = - { .n = "PRELOAD", .unsecure = true }, - [LD_LIBMAP] = - { .n = "LIBMAP", .unsecure = true }, - [LD_LIBRARY_PATH] = - { .n = "LIBRARY_PATH", .unsecure = true }, - [LD_LIBRARY_PATH_FDS] = - { .n = "LIBRARY_PATH_FDS", .unsecure = true }, - [LD_LIBMAP_DISABLE] = - { .n = "LIBMAP_DISABLE", .unsecure = true }, - [LD_BIND_NOT] = - { .n = "BIND_NOT", .unsecure = true }, - [LD_DEBUG] = - { .n = "DEBUG", .unsecure = true }, - [LD_ELF_HINTS_PATH] = - { .n = "ELF_HINTS_PATH", .unsecure = true }, - [LD_LOADFLTR] = - { .n = "LOADFLTR", .unsecure = true }, - [LD_LIBRARY_PATH_RPATH] = - { .n = "LIBRARY_PATH_RPATH", .unsecure = true }, - [LD_PRELOAD_FDS] = - { .n = "PRELOAD_FDS", .unsecure = true }, - [LD_DYNAMIC_WEAK] = - { .n = "DYNAMIC_WEAK", .unsecure = true }, - [LD_TRACE_LOADED_OBJECTS] = - { .n = "TRACE_LOADED_OBJECTS", .unsecure = false }, - [LD_UTRACE] = - { .n = "UTRACE", .unsecure = false }, - [LD_DUMP_REL_PRE] = - { .n = "DUMP_REL_PRE", .unsecure = false }, - [LD_DUMP_REL_POST] = - { .n = "DUMP_REL_POST", .unsecure = false }, - [LD_TRACE_LOADED_OBJECTS_PROGNAME] = - { .n = "TRACE_LOADED_OBJECTS_PROGNAME", .unsecure = false}, - [LD_TRACE_LOADED_OBJECTS_FMT1] = - { .n = "TRACE_LOADED_OBJECTS_FMT1", .unsecure = false}, - [LD_TRACE_LOADED_OBJECTS_FMT2] = - { .n = "TRACE_LOADED_OBJECTS_FMT2", .unsecure = false}, - [LD_TRACE_LOADED_OBJECTS_ALL] = - { .n = "TRACE_LOADED_OBJECTS_ALL", .unsecure = false}, + LD_ENV_DESC(BIND_NOW, false), + LD_ENV_DESC(PRELOAD, true), + LD_ENV_DESC(LIBMAP, true), + LD_ENV_DESC(LIBRARY_PATH, true), + LD_ENV_DESC(LIBRARY_PATH_FDS, true), + LD_ENV_DESC(LIBMAP_DISABLE, true), + LD_ENV_DESC(BIND_NOT, true), + LD_ENV_DESC(DEBUG, true), + LD_ENV_DESC(ELF_HINTS_PATH, true), + LD_ENV_DESC(LOADFLTR, true), + LD_ENV_DESC(LIBRARY_PATH_RPATH, true), + LD_ENV_DESC(PRELOAD_FDS, true), + LD_ENV_DESC(DYNAMIC_WEAK, true), + LD_ENV_DESC(TRACE_LOADED_OBJECTS, false), + LD_ENV_DESC(UTRACE, false), + LD_ENV_DESC(DUMP_REL_PRE, false), + LD_ENV_DESC(DUMP_REL_POST, false), + LD_ENV_DESC(TRACE_LOADED_OBJECTS_PROGNAME, false), + LD_ENV_DESC(TRACE_LOADED_OBJECTS_FMT1, false), + LD_ENV_DESC(TRACE_LOADED_OBJECTS_FMT2, false), + LD_ENV_DESC(TRACE_LOADED_OBJECTS_ALL, false), }; -static const char * -ld_var(int idx) +static char * +ld_get_env_var(int idx) { - return (ld_env_vars[idx].n); + return (ld_env_vars[idx].val); } static char * -ld_get_env_var(int idx) +rtld_get_env_val(char **env, const char *name, size_t name_len) { - return (getenv(ld_var(idx))); + char **m, *n, *v; + + for (m = env; *m != NULL; m++) { + n = *m; + v = strchr(n, '='); + if (v == NULL) { + /* corrupt environment? */ + continue; + } + if (v - n == (ptrdiff_t)name_len && + strncmp(name, n, name_len) == 0) + return (v + 1); + } + return (NULL); } static void -rtld_init_env_vars(void) +rtld_init_env_vars_for_prefix(char **env, const char *env_prefix) { struct ld_env_var_desc *lvd; - size_t sz; + size_t prefix_len, nlen; + char **m, *n, *v; int i; - sz = strlen(ld_env_prefix); - for (i = 0; i < (int)nitems(ld_env_vars); i++) { - lvd = &ld_env_vars[i]; - memmove(lvd->n + sz, lvd->n, strlen(lvd->n) + 1); - memcpy(lvd->n, ld_env_prefix, sz); + prefix_len = strlen(env_prefix); + for (m = env; *m != NULL; m++) { + n = *m; + if (strncmp(env_prefix, n, prefix_len) != 0) { + /* Not a rtld environment variable. */ + continue; + } + n += prefix_len; + v = strchr(n, '='); + if (v == NULL) { + /* corrupt environment? */ + continue; + } + for (i = 0; i < (int)nitems(ld_env_vars); i++) { + lvd = &ld_env_vars[i]; + if (lvd->val != NULL) { + /* Saw higher-priority variable name already. */ + continue; + } + nlen = strlen(lvd->n); + if (v - n == (ptrdiff_t)nlen && + strncmp(lvd->n, n, nlen) == 0) { + lvd->val = v + 1; + break; + } + } } } +static void +rtld_init_env_vars(char **env) +{ + rtld_init_env_vars_for_prefix(env, ld_env_prefix); +} + /* * Main entry point for dynamic linking. The first argument is the * stack pointer. The stack is expected to be laid out as described @@ -548,7 +571,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) direct_exec = false; md_abi_variant_hook(aux_info); - rtld_init_env_vars(); + rtld_init_env_vars(env); fd = -1; if (aux_info[AT_EXECFD] != NULL) { @@ -667,12 +690,11 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) if (!trust) { for (i = 0; i < (int)nitems(ld_env_vars); i++) { lvd = &ld_env_vars[i]; - if (lvd->unsecure && unsetenv(lvd->n)) { - _rtld_error("environment corrupt; aborting"); - rtld_die(); - } + if (lvd->unsecure) + lvd->val = NULL; } } + ld_debug = ld_get_env_var(LD_DEBUG); if (ld_bind_now == NULL) ld_bind_not = ld_get_env_var(LD_BIND_NOT) != NULL; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:21:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A6CD667074; Mon, 23 Aug 2021 09:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtRZt1Pr8z4RKX; Mon, 23 Aug 2021 09:21: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 11B2E11CA2; Mon, 23 Aug 2021 09:21: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 17N9LwdT067236; Mon, 23 Aug 2021 09:21:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9LvrH067235; Mon, 23 Aug 2021 09:21:57 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:57 GMT Message-Id: <202108230921.17N9LvrH067235@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: 2b5ccf507a7f - stable/13 - rtld: provide private getenv(3) 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: 2b5ccf507a7f7157dc28cf132fe48ec404ff3d5b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:21:59 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2b5ccf507a7f7157dc28cf132fe48ec404ff3d5b commit 2b5ccf507a7f7157dc28cf132fe48ec404ff3d5b Author: Konstantin Belousov AuthorDate: 2021-08-16 14:02:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 rtld: provide private getenv(3) (cherry picked from commit b4b274889145bbc559613b54e7520b95f43e51e6) --- libexec/rtld-elf/rtld-libc/Makefile.inc | 2 +- libexec/rtld-elf/rtld.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld-libc/Makefile.inc b/libexec/rtld-elf/rtld-libc/Makefile.inc index 94d6cbb5b39f..e3c7ee8ca5cf 100644 --- a/libexec/rtld-elf/rtld-libc/Makefile.inc +++ b/libexec/rtld-elf/rtld-libc/Makefile.inc @@ -27,7 +27,7 @@ SRCS+= rtld_libc.c # Now build the remaining files from libc: .PATH: ${LIBC_SRCTOP}/stdlib -SRCS+= reallocf.c realpath.c getenv.c merge.c reallocarray.c +SRCS+= reallocf.c realpath.c merge.c reallocarray.c # TODO: fix merge.c to build with WARNS=6 .if ${COMPILER_TYPE} == "clang" CFLAGS.merge.c+=-Wno-error=null-pointer-arithmetic diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 39c41fe0ed24..8fb99246a4c1 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -6027,6 +6027,12 @@ rtld_strerror(int errnum) return (sys_errlist[errnum]); } +char * +getenv(const char *name) +{ + return (rtld_get_env_val(environ, name, strlen(name))); +} + /* malloc */ void * malloc(size_t nbytes) From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:22:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF13C6677FF; Mon, 23 Aug 2021 09:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtRZv2d1Mz4RHM; Mon, 23 Aug 2021 09:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2E11011B66; Mon, 23 Aug 2021 09:21: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 17N9LxOO067260; Mon, 23 Aug 2021 09:21:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9LxuH067259; Mon, 23 Aug 2021 09:21:59 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:21:59 GMT Message-Id: <202108230921.17N9LxuH067259@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: 2c0233d2a02f - stable/13 - rtld: constify most variables holding references to the environment values 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: 2c0233d2a02fa456c743f1b9ca540a5c8254f195 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:22:00 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2c0233d2a02fa456c743f1b9ca540a5c8254f195 commit 2c0233d2a02fa456c743f1b9ca540a5c8254f195 Author: Konstantin Belousov AuthorDate: 2021-08-16 16:55:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:20:56 +0000 rtld: constify most variables holding references to the environment values (cherry picked from commit aa68b3bb2e11392f4636b3656b0f0bcacec3385a) --- libexec/rtld-elf/libmap.c | 14 ++++++------ libexec/rtld-elf/libmap.h | 2 +- libexec/rtld-elf/rtld.c | 56 +++++++++++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/libexec/rtld-elf/libmap.c b/libexec/rtld-elf/libmap.c index 499d2cd2a1d9..e4388d14b951 100644 --- a/libexec/rtld-elf/libmap.c +++ b/libexec/rtld-elf/libmap.c @@ -64,22 +64,22 @@ static const char *quickbasename(const char *); #define rtld_isspace(c) ((c) == ' ' || (c) == '\t') int -lm_init(char *libmap_override) +lm_init(const char *libmap_override) { - char *p; + char *l, *p; dbg("lm_init(\"%s\")", libmap_override); TAILQ_INIT(&lmp_head); lmc_parse_file(ld_path_libmap_conf); - if (libmap_override) { + if (libmap_override != NULL) { /* * Do some character replacement to make $LDLIBMAP look * like a text file, then parse it. */ - libmap_override = xstrdup(libmap_override); - for (p = libmap_override; *p; p++) { + l = xstrdup(libmap_override); + for (p = l; *p != 0; p++) { switch (*p) { case '=': *p = ' '; @@ -89,8 +89,8 @@ lm_init(char *libmap_override) break; } } - lmc_parse(libmap_override, p - libmap_override); - free(libmap_override); + lmc_parse(l, p - l); + free(l); } return (lm_count == 0); diff --git a/libexec/rtld-elf/libmap.h b/libexec/rtld-elf/libmap.h index 0e9c668b4444..a5ba143f211f 100644 --- a/libexec/rtld-elf/libmap.h +++ b/libexec/rtld-elf/libmap.h @@ -2,7 +2,7 @@ * $FreeBSD$ */ -int lm_init (char *); +int lm_init(const char *); void lm_fini (void); char * lm_find (const char *, const char *); char * lm_findn (const char *, const char *, const size_t); diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 8fb99246a4c1..1a89a7b2c1de 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -123,7 +123,7 @@ static void linkmap_delete(Obj_Entry *); static void load_filtees(Obj_Entry *, int flags, RtldLockState *); static void unload_filtees(Obj_Entry *, RtldLockState *); static int load_needed_objects(Obj_Entry *, int); -static int load_preload_objects(char *, bool); +static int load_preload_objects(const char *, bool); static Obj_Entry *load_object(const char *, int fd, const Obj_Entry *, int); static void map_stacks_exec(RtldLockState *); static int obj_disable_relro(Obj_Entry *); @@ -202,24 +202,24 @@ int __sys_openat(int, const char *, int, ...); struct r_debug r_debug __exported; /* for GDB; */ static bool libmap_disable; /* Disable libmap */ static bool ld_loadfltr; /* Immediate filters processing */ -static char *libmap_override; /* Maps to use in addition to libmap.conf */ +static const char *libmap_override;/* Maps to use in addition to libmap.conf */ static bool trust; /* False for setuid and setgid programs */ static bool dangerous_ld_env; /* True if environment variables have been used to affect the libraries loaded */ bool ld_bind_not; /* Disable PLT update */ -static char *ld_bind_now; /* Environment variable for immediate binding */ -static char *ld_debug; /* Environment variable for debugging */ +static const char *ld_bind_now; /* Environment variable for immediate binding */ +static const char *ld_debug; /* Environment variable for debugging */ static bool ld_dynamic_weak = true; /* True if non-weak definition overrides weak definition */ -static char *ld_library_path; /* Environment variable for search path */ -static char *ld_library_dirs; /* Environment variable for library descriptors */ -static char *ld_preload; /* Environment variable for libraries to +static const char *ld_library_path;/* Environment variable for search path */ +static const char *ld_library_dirs;/* Environment variable for library descriptors */ +static const char *ld_preload; /* Environment variable for libraries to load first */ -static char *ld_preload_fds; /* Environment variable for libraries represented by +static const char *ld_preload_fds;/* Environment variable for libraries represented by descriptors */ static const char *ld_elf_hints_path; /* Environment variable for alternative hints path */ static const char *ld_tracing; /* Called from ldd to print libs */ -static char *ld_utrace; /* Use utrace() to log events. */ +static const char *ld_utrace; /* Use utrace() to log events. */ static struct obj_entry_q obj_list; /* Queue of all loaded objects */ static Obj_Entry *obj_main; /* The main program shared object */ static Obj_Entry obj_rtld; /* The dynamic linker shared object */ @@ -367,8 +367,8 @@ enum { }; struct ld_env_var_desc { - const char *n; - char *val; + const char * const n; + const char *val; const bool unsecure; }; #define LD_ENV_DESC(var, unsec) \ @@ -398,13 +398,13 @@ static struct ld_env_var_desc ld_env_vars[] = { LD_ENV_DESC(TRACE_LOADED_OBJECTS_ALL, false), }; -static char * +static const char * ld_get_env_var(int idx) { return (ld_env_vars[idx].val); } -static char * +static const char * rtld_get_env_val(char **env, const char *name, size_t name_len) { char **m, *n, *v; @@ -493,8 +493,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) RtldLockState lockstate; struct stat st; Elf_Addr *argcp; - char **argv, **env, **envp, *kexecpath, *library_path_rpath; - const char *argv0, *binpath; + char **argv, **env, **envp, *kexecpath; + const char *argv0, *binpath, *library_path_rpath; struct ld_env_var_desc *lvd; caddr_t imgentry; char buf[MAXPATHLEN]; @@ -2600,36 +2600,42 @@ load_needed_objects(Obj_Entry *first, int flags) } static int -load_preload_objects(char *p, bool isfd) +load_preload_objects(const char *penv, bool isfd) { Obj_Entry *obj; + const char *name; + size_t len; + char savech, *p, *psave; + int fd; static const char delim[] = " \t:;"; - if (p == NULL) + if (penv == NULL) return (0); + p = psave = xstrdup(penv); p += strspn(p, delim); while (*p != '\0') { - const char *name; - size_t len = strcspn(p, delim); - char savech; - int fd; + len = strcspn(p, delim); savech = p[len]; p[len] = '\0'; if (isfd) { name = NULL; fd = parse_integer(p); - if (fd == -1) + if (fd == -1) { + free(psave); return (-1); + } } else { name = p; fd = -1; } obj = load_object(name, fd, NULL, 0); - if (obj == NULL) + if (obj == NULL) { + free(psave); return (-1); /* XXX - cleanup */ + } obj->z_interpose = true; p[len] = savech; p += len; @@ -2637,6 +2643,7 @@ load_preload_objects(char *p, bool isfd) } LD_UTRACE(UTRACE_PRELOAD_FINISHED, NULL, NULL, 0, 0, NULL); + free(psave); return (0); } @@ -6030,7 +6037,8 @@ rtld_strerror(int errnum) char * getenv(const char *name) { - return (rtld_get_env_val(environ, name, strlen(name))); + return (__DECONST(char *, rtld_get_env_val(environ, name, + strlen(name)))); } /* malloc */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:25:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8815A667D9D; Mon, 23 Aug 2021 09:25: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 4GtRfR3M1Qz4RtL; Mon, 23 Aug 2021 09:25:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5BD9011AF8; Mon, 23 Aug 2021 09:25: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 17N9P3HJ070045; Mon, 23 Aug 2021 09:25:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9P38q070044; Mon, 23 Aug 2021 09:25:03 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:25:03 GMT Message-Id: <202108230925.17N9P38q070044@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: 56f6a96f93fa - stable/13 - x86_msr_op: extend the KPI to allow MSR read and single-CPU operations 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: 56f6a96f93fa6449fdb73d1bbba000551277946f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:25:03 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=56f6a96f93fa6449fdb73d1bbba000551277946f commit 56f6a96f93fa6449fdb73d1bbba000551277946f Author: Konstantin Belousov AuthorDate: 2021-08-02 19:52:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:24:39 +0000 x86_msr_op: extend the KPI to allow MSR read and single-CPU operations (cherry picked from commit d0bc4b466683d17b84f9acafe4c3cc746f860dbf) --- sys/dev/hwpmc/hwpmc_core.c | 8 +++--- sys/x86/include/x86_var.h | 18 ++++++++++--- sys/x86/x86/cpu_machdep.c | 65 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 22 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index b0773227fac7..afd587296e01 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -261,8 +261,8 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm, if ((cpu_stdext_feature3 & CPUID_STDEXT3_TSXFA) != 0 && !pmc_tsx_force_abort_set) { pmc_tsx_force_abort_set = true; - x86_msr_op(MSR_TSX_FORCE_ABORT, MSR_OP_RENDEZVOUS | - MSR_OP_WRITE, 1); + x86_msr_op(MSR_TSX_FORCE_ABORT, MSR_OP_RENDEZVOUS_ALL | + MSR_OP_WRITE, 1, NULL); } flags = 0; @@ -403,8 +403,8 @@ iaf_release_pmc(int cpu, int ri, struct pmc *pmc) MPASS(pmc_alloc_refs > 0); if (pmc_alloc_refs-- == 1 && pmc_tsx_force_abort_set) { pmc_tsx_force_abort_set = false; - x86_msr_op(MSR_TSX_FORCE_ABORT, MSR_OP_RENDEZVOUS | - MSR_OP_WRITE, 0); + x86_msr_op(MSR_TSX_FORCE_ABORT, MSR_OP_RENDEZVOUS_ALL | + MSR_OP_WRITE, 0, NULL); } return (0); diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index cc730fcd1bf1..71f7a7eca564 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -153,12 +153,24 @@ int user_dbreg_trap(register_t dr6); int minidumpsys(struct dumperinfo *); struct pcb *get_pcb_td(struct thread *td); +/* + * MSR ops for x86_msr_op() + */ #define MSR_OP_ANDNOT 0x00000001 #define MSR_OP_OR 0x00000002 #define MSR_OP_WRITE 0x00000003 +#define MSR_OP_READ 0x00000004 + +/* + * Where and which execution mode + */ #define MSR_OP_LOCAL 0x10000000 -#define MSR_OP_SCHED 0x20000000 -#define MSR_OP_RENDEZVOUS 0x30000000 -void x86_msr_op(u_int msr, u_int op, uint64_t arg1); +#define MSR_OP_SCHED_ALL 0x20000000 +#define MSR_OP_SCHED_ONE 0x30000000 +#define MSR_OP_RENDEZVOUS_ALL 0x40000000 +#define MSR_OP_RENDEZVOUS_ONE 0x50000000 +#define MSR_OP_CPUID(id) ((id) << 8) + +void x86_msr_op(u_int msr, u_int op, uint64_t arg1, uint64_t *res); #endif diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c index 77ae7b360a25..8ad718372928 100644 --- a/sys/x86/x86/cpu_machdep.c +++ b/sys/x86/x86/cpu_machdep.c @@ -115,6 +115,7 @@ struct msr_op_arg { u_int msr; int op; uint64_t arg1; + uint64_t *res; }; static void @@ -138,33 +139,41 @@ x86_msr_op_one(void *argp) case MSR_OP_WRITE: wrmsr(a->msr, a->arg1); break; + case MSR_OP_READ: + v = rdmsr(a->msr); + *a->res = v; + break; } } #define MSR_OP_EXMODE_MASK 0xf0000000 #define MSR_OP_OP_MASK 0x000000ff +#define MSR_OP_GET_CPUID(x) (((x) & ~MSR_OP_EXMODE_MASK) >> 8) void -x86_msr_op(u_int msr, u_int op, uint64_t arg1) +x86_msr_op(u_int msr, u_int op, uint64_t arg1, uint64_t *res) { struct thread *td; struct msr_op_arg a; + cpuset_t set; u_int exmode; - int bound_cpu, i, is_bound; + int bound_cpu, cpu, i, is_bound; a.op = op & MSR_OP_OP_MASK; MPASS(a.op == MSR_OP_ANDNOT || a.op == MSR_OP_OR || - a.op == MSR_OP_WRITE); + a.op == MSR_OP_WRITE || a.op == MSR_OP_READ); exmode = op & MSR_OP_EXMODE_MASK; - MPASS(exmode == MSR_OP_LOCAL || exmode == MSR_OP_SCHED || - exmode == MSR_OP_RENDEZVOUS); + MPASS(exmode == MSR_OP_LOCAL || exmode == MSR_OP_SCHED_ALL || + exmode == MSR_OP_SCHED_ONE || exmode == MSR_OP_RENDEZVOUS_ALL || + exmode == MSR_OP_RENDEZVOUS_ONE); a.msr = msr; a.arg1 = arg1; + a.res = res; switch (exmode) { case MSR_OP_LOCAL: x86_msr_op_one(&a); break; - case MSR_OP_SCHED: + case MSR_OP_SCHED_ALL: td = curthread; thread_lock(td); is_bound = sched_is_bound(td); @@ -179,8 +188,32 @@ x86_msr_op(u_int msr, u_int op, uint64_t arg1) sched_unbind(td); thread_unlock(td); break; - case MSR_OP_RENDEZVOUS: - smp_rendezvous(NULL, x86_msr_op_one, NULL, &a); + case MSR_OP_SCHED_ONE: + td = curthread; + cpu = MSR_OP_GET_CPUID(op); + thread_lock(td); + is_bound = sched_is_bound(td); + bound_cpu = td->td_oncpu; + if (!is_bound || bound_cpu != cpu) + sched_bind(td, cpu); + x86_msr_op_one(&a); + if (is_bound) { + if (bound_cpu != cpu) + sched_bind(td, bound_cpu); + } else { + sched_unbind(td); + } + thread_unlock(td); + break; + case MSR_OP_RENDEZVOUS_ALL: + smp_rendezvous(smp_no_rendezvous_barrier, x86_msr_op_one, + smp_no_rendezvous_barrier, &a); + break; + case MSR_OP_RENDEZVOUS_ONE: + cpu = MSR_OP_GET_CPUID(op); + CPU_SETOF(cpu, &set); + smp_rendezvous_cpus(set, smp_no_rendezvous_barrier, + x86_msr_op_one, smp_no_rendezvous_barrier, &a); break; } } @@ -868,9 +901,9 @@ hw_ibrs_recalculate(bool for_all_cpus) { if ((cpu_ia32_arch_caps & IA32_ARCH_CAP_IBRS_ALL) != 0) { x86_msr_op(MSR_IA32_SPEC_CTRL, (for_all_cpus ? - MSR_OP_RENDEZVOUS : MSR_OP_LOCAL) | + MSR_OP_RENDEZVOUS_ALL : MSR_OP_LOCAL) | (hw_ibrs_disable != 0 ? MSR_OP_ANDNOT : MSR_OP_OR), - IA32_SPEC_CTRL_IBRS); + IA32_SPEC_CTRL_IBRS, NULL); hw_ibrs_active = hw_ibrs_disable == 0; hw_ibrs_ibpb_active = 0; } else { @@ -926,7 +959,8 @@ hw_ssb_set(bool enable, bool for_all_cpus) hw_ssb_active = enable; x86_msr_op(MSR_IA32_SPEC_CTRL, (enable ? MSR_OP_OR : MSR_OP_ANDNOT) | - (for_all_cpus ? MSR_OP_SCHED : MSR_OP_LOCAL), IA32_SPEC_CTRL_SSBD); + (for_all_cpus ? MSR_OP_SCHED_ALL : MSR_OP_LOCAL), + IA32_SPEC_CTRL_SSBD, NULL); } void @@ -1217,8 +1251,9 @@ taa_set(bool enable, bool all) x86_msr_op(MSR_IA32_TSX_CTRL, (enable ? MSR_OP_OR : MSR_OP_ANDNOT) | - (all ? MSR_OP_RENDEZVOUS : MSR_OP_LOCAL), - IA32_TSX_CTRL_RTM_DISABLE | IA32_TSX_CTRL_TSX_CPUID_CLEAR); + (all ? MSR_OP_RENDEZVOUS_ALL : MSR_OP_LOCAL), + IA32_TSX_CTRL_RTM_DISABLE | IA32_TSX_CTRL_TSX_CPUID_CLEAR, + NULL); } void @@ -1382,8 +1417,8 @@ x86_rngds_mitg_recalculate(bool all_cpus) return; x86_msr_op(MSR_IA32_MCU_OPT_CTRL, (x86_rngds_mitg_enable ? MSR_OP_OR : MSR_OP_ANDNOT) | - (all_cpus ? MSR_OP_RENDEZVOUS : MSR_OP_LOCAL), - IA32_RNGDS_MITG_DIS); + (all_cpus ? MSR_OP_RENDEZVOUS_ALL : MSR_OP_LOCAL), + IA32_RNGDS_MITG_DIS, NULL); } static int From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:25:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1A33667AF9; Mon, 23 Aug 2021 09:25: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 4GtRfS4CM4z4RtM; Mon, 23 Aug 2021 09:25: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 777A9118DA; Mon, 23 Aug 2021 09:25: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 17N9P4Ki070069; Mon, 23 Aug 2021 09:25:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9P4cf070068; Mon, 23 Aug 2021 09:25:04 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:25:04 GMT Message-Id: <202108230925.17N9P4cf070068@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: 1ff28f8a0de5 - stable/13 - coretemp: use x86_msr_op for thermal MSR access 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: 1ff28f8a0de5313ef8344b29ec44a3ab407970e8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:25:04 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1ff28f8a0de5313ef8344b29ec44a3ab407970e8 commit 1ff28f8a0de5313ef8344b29ec44a3ab407970e8 Author: Konstantin Belousov AuthorDate: 2021-08-02 19:53:08 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 09:24:40 +0000 coretemp: use x86_msr_op for thermal MSR access (cherry picked from commit 4cc6fe1e5b73ce540882753d918bc8208849e9e9) --- sys/dev/coretemp/coretemp.c | 57 +++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c index 53a2434254f6..bdc71b284ac7 100644 --- a/sys/dev/coretemp/coretemp.c +++ b/sys/dev/coretemp/coretemp.c @@ -315,56 +315,31 @@ struct coretemp_args { uint64_t val; }; -static void -coretemp_rdmsr(void *arg) -{ - struct coretemp_args *args = arg; - - args->val = rdmsr(args->msr); -} - -static void -coretemp_wrmsr(void *arg) -{ - struct coretemp_args *args = arg; - - wrmsr(args->msr, args->val); -} - +/* + * The digital temperature reading is located at bit 16 + * of MSR_THERM_STATUS. + * + * There is a bit on that MSR that indicates whether the + * temperature is valid or not. + * + * The temperature is computed by subtracting the temperature + * reading by Tj(max). + */ static uint64_t coretemp_get_thermal_msr(int cpu) { - struct coretemp_args args; - cpuset_t cpus; + uint64_t res; - /* - * The digital temperature reading is located at bit 16 - * of MSR_THERM_STATUS. - * - * There is a bit on that MSR that indicates whether the - * temperature is valid or not. - * - * The temperature is computed by subtracting the temperature - * reading by Tj(max). - */ - args.msr = MSR_THERM_STATUS; - CPU_SETOF(cpu, &cpus); - smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_rdmsr, - smp_no_rendezvous_barrier, &args); - return (args.val); + x86_msr_op(MSR_THERM_STATUS, MSR_OP_RENDEZVOUS_ONE | MSR_OP_READ | + MSR_OP_CPUID(cpu), 0, &res); + return (res); } static void coretemp_clear_thermal_msr(int cpu) { - struct coretemp_args args; - cpuset_t cpus; - - args.msr = MSR_THERM_STATUS; - args.val = 0; - CPU_SETOF(cpu, &cpus); - smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_wrmsr, - smp_no_rendezvous_barrier, &args); + x86_msr_op(MSR_THERM_STATUS, MSR_OP_RENDEZVOUS_ONE | MSR_OP_WRITE | + MSR_OP_CPUID(cpu), 0, NULL); } static int From owner-dev-commits-src-all@freebsd.org Mon Aug 23 09:33:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 939C2667CEB; Mon, 23 Aug 2021 09:33: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 4GtRqs3knvz4VDY; Mon, 23 Aug 2021 09:33: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 69783120F9; Mon, 23 Aug 2021 09:33: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 17N9XDLr083067; Mon, 23 Aug 2021 09:33:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17N9XDes083066; Mon, 23 Aug 2021 09:33:13 GMT (envelope-from git) Date: Mon, 23 Aug 2021 09:33:13 GMT Message-Id: <202108230933.17N9XDes083066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Peter Grehan Subject: git: 9ffb4c0adab4 - stable/12 - igc(4): Introduce new driver for the Intel I225 Ethernet controller. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: grehan X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9ffb4c0adab4853ab752ecda6a5ff59ea943af4e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 09:33:13 -0000 The branch stable/12 has been updated by grehan: URL: https://cgit.FreeBSD.org/src/commit/?id=9ffb4c0adab4853ab752ecda6a5ff59ea943af4e commit 9ffb4c0adab4853ab752ecda6a5ff59ea943af4e Author: Peter Grehan AuthorDate: 2021-08-23 11:46:49 +0000 Commit: Peter Grehan CommitDate: 2021-08-23 11:49:23 +0000 igc(4): Introduce new driver for the Intel I225 Ethernet controller. This controller supports 2.5G/1G/100MB/10MB speeds, and allows tx/rx checksum offload, TSO, LRO, and multi-queue operation. The driver was derived from code contributed by Intel, and modified by Netgate to fit into the iflib framework. Thanks to Mike Karels for testing and feedback on the driver. Reviewed by: bcr (manpages), kbowling, scottl, erj Relnotes: yes Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30668 For stable/12, CTLFLAG_NEEDGIANT removed and if_foreach_llmaddr() replaced with if_multiaddr_array(). (cherry picked from commit 517904de5ccac643589c71ac0d2751797f89e4f9) --- share/man/man4/Makefile | 2 + share/man/man4/igc.4 | 167 +++ sys/amd64/conf/GENERIC | 1 + sys/amd64/conf/NOTES | 2 + sys/conf/files | 8 + sys/dev/igc/if_igc.c | 2984 +++++++++++++++++++++++++++++++++++++++++++++ sys/dev/igc/if_igc.h | 430 +++++++ sys/dev/igc/igc_api.c | 735 +++++++++++ sys/dev/igc/igc_api.h | 58 + sys/dev/igc/igc_base.c | 188 +++ sys/dev/igc/igc_base.h | 131 ++ sys/dev/igc/igc_defines.h | 1347 ++++++++++++++++++++ sys/dev/igc/igc_hw.h | 548 +++++++++ sys/dev/igc/igc_i225.c | 1232 +++++++++++++++++++ sys/dev/igc/igc_i225.h | 112 ++ sys/dev/igc/igc_mac.c | 1050 ++++++++++++++++ sys/dev/igc/igc_mac.h | 48 + sys/dev/igc/igc_nvm.c | 721 +++++++++++ sys/dev/igc/igc_nvm.h | 32 + sys/dev/igc/igc_osdep.h | 133 ++ sys/dev/igc/igc_phy.c | 1109 +++++++++++++++++ sys/dev/igc/igc_phy.h | 134 ++ sys/dev/igc/igc_regs.h | 424 +++++++ sys/dev/igc/igc_txrx.c | 580 +++++++++ sys/i386/conf/GENERIC | 1 + sys/i386/conf/NOTES | 1 + sys/modules/Makefile | 2 + sys/modules/igc/Makefile | 11 + 28 files changed, 12191 insertions(+) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 1ea16db94550..ea7430a5ba3f 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -222,6 +222,7 @@ MAN= aac.4 \ iicmux.4 \ iicsmb.4 \ iir.4 \ + ${_igc.4} \ ${_imcsmb.4} \ inet.4 \ inet6.4 \ @@ -835,6 +836,7 @@ _if_urtw.4= if_urtw.4 _if_vmx.4= if_vmx.4 _if_vtnet.4= if_vtnet.4 _if_wpi.4= if_wpi.4 +_igc.4= igc.4 _imcsmb.4= imcsmb.4 _ipmi.4= ipmi.4 _io.4= io.4 diff --git a/share/man/man4/igc.4 b/share/man/man4/igc.4 new file mode 100644 index 000000000000..bb79fbe5a8fa --- /dev/null +++ b/share/man/man4/igc.4 @@ -0,0 +1,167 @@ +.\"- +.\" Copyright 2021 Intel Corp +.\" Copyright 2021 Rubicon Communications, LLC (Netgate) +.\" SPDX-License-Identifier: BSD-3-Clause +.\" +.\" $FreeBSD$ +.\" +.Dd May 10, 2021 +.Dt IGC +.Os +.Sh NAME +.Nm igc +.Nd "Intel Ethernet Controller I225 driver" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device iflib" +.Cd "device igc" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_igc_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for any PCI Express adapter or LOM (LAN +On Motherboard) based on the Intel I225 Multi Gigabit Controller. +The driver supports Transmit/Receive checksum offload, Jumbo Frames, +MSI/MSI-X, TSO, and RSS. +.Pp +Support for Jumbo Frames is provided via the interface MTU setting. +Selecting an MTU larger than 1500 bytes with the +.Xr ifconfig 8 +utility +configures the adapter to receive and transmit Jumbo Frames. +The maximum MTU size for Jumbo Frames is 9216 bytes. +.Pp +This driver version supports VLAN hardware insertion / extraction, and +VLAN checksum offload. +For information on enabling VLANs, see +.Xr ifconfig 8 . +The +.Nm +driver supports the following media types: +.Bl -tag -width ".Cm 10baseT/UTP" +.It Cm autoselect +Enables auto-negotiation for speed and duplex. +.It Cm 10baseT/UTP +Sets 10Mbps operation. +Use the +.Cm mediaopt +option to select +.Cm half-duplex +mode. +.It Cm 100baseTX +Sets 100Mbps operation. +Use the +.Cm mediaopt +option to select +.Cm half-duplex +mode. +.It Cm 1000baseT +Sets 1000Mbps operation. +Only +.Cm full-duplex +mode is supported at this speed. +.It Cm 2500baseT +Sets 2500Mbps operation. +Only +.Cm full-duplex +mode is supported at this speed. +.El +.Pp +.Sh HARDWARE +The +.Nm +driver supports the following models: +.Pp +.Bl -bullet -compact +.It +I225-LM +.It +I225-V +.It +I225-IT +.It +I225-K +.El +.Sh LOADER TUNABLES +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Xr loader.conf 5 . +.Bl -tag -width indent +.It Va hw.igc.igc_disable_crc_stripping +Disable or enable hardware stripping of CRC field. +This is mostly useful on BMC/IPMI shared interfaces where stripping the +CRC causes remote access over IPMI to fail. +Default 0 (enabled). +.It Va hw.igc.rx_int_delay +This value delays the generation of receive interrupts in units +of 1.024 microseconds. +The default value is 0, since adapters may hang with this feature being +enabled. +.It Va hw.igc.rx_abs_int_delay +If hw.igc.rx_int_delay is non-zero, this tunable limits the +maximum delay in which a receive interrupt is generated. +.It Va hw.igc.tx_int_delay +This value delays the generation of transmit interrupts in units +of 1.024 microseconds. +The default value is 64. +.It Va hw.igc.tx_abs_int_delay +If hw.igc.tx_int_delay is non-zero, this tunable limits the +maximum delay in which a transmit interrupt is generated. +.It Va hw.igc.sbp +Show bad packets when in promiscuous mode. +Default is false. +.It Va hw.igc.rx_process_limit +Maximum number of received packets to process at a time. +Default is 100. +A value of -1 means unlimited. +.It Va hw.igc.eee_setting +Disable or enable Energy Efficient Ethernet. +Default 1 (disabled). +.It Va hw.igc.max_interrupt_rate +Maximum device interrupts per second. +The default is 8000. +.El +.Sh DIAGNOSTICS +.Bl -diag +.It "igc%d: Hardware Initialization Failed" +A fatal initialization error has occurred. +.It "igc%d: Unable to allocate bus resource: memory" +A fatal initialization error has occurred. +.It "igc%d: Invalid MAC address" +The MAC address programmed into the EEPROM is either empty or a multicast/broadcast +address. +.El +.Sh SEE ALSO +.Xr altq 4 , +.Xr arp 4 , +.Xr iflib 4 , +.Xr netintro 4 , +.Xr ng_ether 4 , +.Xr vlan 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 14.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +was originally written by +.An Intel Corporation +and converted to the +.Xr iflib 4 +framework by +.An Netgate . diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 1bd3c3762f53..0784544c9c7d 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -223,6 +223,7 @@ device puc # Multi I/O cards and multi-channel UARTs # PCI/PCI-X/PCIe Ethernet NICs that use iflib infrastructure device iflib device em # Intel PRO/1000 Gigabit Ethernet Family +device igc # Intel I225 2.5G Ethernet device ix # Intel PRO/10GbE PCIE PF Ethernet device ixv # Intel PRO/10GbE PCIE VF Ethernet device ixl # Intel 700 Series Physical Function diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index 00dd541c8406..0b949acdc4a3 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -308,6 +308,7 @@ options DRM_DEBUG # Include debug printfs (slow) # (requires miibus) # ice: Intel 800 Series Physical Function # Requires the ice_ddp module for full functionality +# igc: Intel I225 2.5Gb Ethernet adapter # ipw: Intel PRO/Wireless 2100 IEEE 802.11 adapter # Requires the ipw firmware module # iwi: Intel PRO/Wireless 2200BG/2225BG/2915ABG IEEE 802.11 adapters @@ -329,6 +330,7 @@ device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards options ED_3C503 options ED_HPP options ED_SIC +device igc # Intel I225 2.5G Ethernet device ipw # Intel 2100 wireless NICs. device iwi # Intel 2200BG/2225BG/2915ABG wireless NICs. device iwn # Intel 4965/1000/5000/6000 wireless NICs. diff --git a/sys/conf/files b/sys/conf/files index e9557a2cd01c..b014c51127a7 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1886,6 +1886,14 @@ dev/iicbus/sy8106a.c optional sy8106a ext_resources fdt dev/iir/iir.c optional iir dev/iir/iir_ctrl.c optional iir dev/iir/iir_pci.c optional iir pci +dev/igc/if_igc.c optional igc iflib pci +dev/igc/igc_api.c optional igc iflib pci +dev/igc/igc_base.c optional igc iflib pci +dev/igc/igc_i225.c optional igc iflib pci +dev/igc/igc_mac.c optional igc iflib pci +dev/igc/igc_nvm.c optional igc iflib pci +dev/igc/igc_phy.c optional igc iflib pci +dev/igc/igc_txrx.c optional igc iflib pci dev/intpm/intpm.c optional intpm pci # XXX Work around clang warning, until maintainer approves fix. dev/ips/ips.c optional ips \ diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c new file mode 100644 index 000000000000..b72f55166907 --- /dev/null +++ b/sys/dev/igc/if_igc.c @@ -0,0 +1,2984 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2016 Nicole Graziano + * All rights reserved. + * Copyright (c) 2021 Rubicon Communications, LLC (Netgate) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "if_igc.h" +#include +#include + +#ifdef RSS +#include +#include +#endif + +/********************************************************************* + * PCI Device ID Table + * + * Used by probe to select devices to load on + * Last entry must be all 0s + * + * { Vendor ID, Device ID, String } + *********************************************************************/ + +static pci_vendor_info_t igc_vendor_info_array[] = +{ + /* Intel(R) PRO/1000 Network Connection - igc */ + PVID(0x8086, IGC_DEV_ID_I225_LM, "Intel(R) Ethernet Controller I225-LM"), + PVID(0x8086, IGC_DEV_ID_I225_V, "Intel(R) Ethernet Controller I225-V"), + PVID(0x8086, IGC_DEV_ID_I225_K, "Intel(R) Ethernet Controller I225-K"), + PVID(0x8086, IGC_DEV_ID_I225_I, "Intel(R) Ethernet Controller I225-I"), + PVID(0x8086, IGC_DEV_ID_I220_V, "Intel(R) Ethernet Controller I220-V"), + PVID(0x8086, IGC_DEV_ID_I225_K2, "Intel(R) Ethernet Controller I225-K(2)"), + PVID(0x8086, IGC_DEV_ID_I225_LMVP, "Intel(R) Ethernet Controller I225-LMvP(2)"), + PVID(0x8086, IGC_DEV_ID_I226_K, "Intel(R) Ethernet Controller I226-K"), + PVID(0x8086, IGC_DEV_ID_I225_IT, "Intel(R) Ethernet Controller I225-IT(2)"), + PVID(0x8086, IGC_DEV_ID_I226_LM, "Intel(R) Ethernet Controller I226-LM"), + PVID(0x8086, IGC_DEV_ID_I226_V, "Intel(R) Ethernet Controller I226-V"), + PVID(0x8086, IGC_DEV_ID_I226_IT, "Intel(R) Ethernet Controller I226-IT"), + PVID(0x8086, IGC_DEV_ID_I221_V, "Intel(R) Ethernet Controller I221-V"), + PVID(0x8086, IGC_DEV_ID_I226_BLANK_NVM, "Intel(R) Ethernet Controller I226(blankNVM)"), + PVID(0x8086, IGC_DEV_ID_I225_BLANK_NVM, "Intel(R) Ethernet Controller I225(blankNVM)"), + /* required last entry */ + PVID_END +}; + +/********************************************************************* + * Function prototypes + *********************************************************************/ +static void *igc_register(device_t dev); +static int igc_if_attach_pre(if_ctx_t ctx); +static int igc_if_attach_post(if_ctx_t ctx); +static int igc_if_detach(if_ctx_t ctx); +static int igc_if_shutdown(if_ctx_t ctx); +static int igc_if_suspend(if_ctx_t ctx); +static int igc_if_resume(if_ctx_t ctx); + +static int igc_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int ntxqs, int ntxqsets); +static int igc_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxqs, int nrxqsets); +static void igc_if_queues_free(if_ctx_t ctx); + +static uint64_t igc_if_get_counter(if_ctx_t, ift_counter); +static void igc_if_init(if_ctx_t ctx); +static void igc_if_stop(if_ctx_t ctx); +static void igc_if_media_status(if_ctx_t, struct ifmediareq *); +static int igc_if_media_change(if_ctx_t ctx); +static int igc_if_mtu_set(if_ctx_t ctx, uint32_t mtu); +static void igc_if_timer(if_ctx_t ctx, uint16_t qid); +static void igc_if_vlan_register(if_ctx_t ctx, u16 vtag); +static void igc_if_vlan_unregister(if_ctx_t ctx, u16 vtag); +static void igc_if_watchdog_reset(if_ctx_t ctx); +static bool igc_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event); + +static void igc_identify_hardware(if_ctx_t ctx); +static int igc_allocate_pci_resources(if_ctx_t ctx); +static void igc_free_pci_resources(if_ctx_t ctx); +static void igc_reset(if_ctx_t ctx); +static int igc_setup_interface(if_ctx_t ctx); +static int igc_setup_msix(if_ctx_t ctx); + +static void igc_initialize_transmit_unit(if_ctx_t ctx); +static void igc_initialize_receive_unit(if_ctx_t ctx); + +static void igc_if_intr_enable(if_ctx_t ctx); +static void igc_if_intr_disable(if_ctx_t ctx); +static int igc_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid); +static int igc_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid); +static void igc_if_multi_set(if_ctx_t ctx); +static void igc_if_update_admin_status(if_ctx_t ctx); +static void igc_if_debug(if_ctx_t ctx); +static void igc_update_stats_counters(struct igc_adapter *); +static void igc_add_hw_stats(struct igc_adapter *adapter); +static int igc_if_set_promisc(if_ctx_t ctx, int flags); +static void igc_setup_vlan_hw_support(struct igc_adapter *); +static int igc_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); +static void igc_print_nvm_info(struct igc_adapter *); +static int igc_sysctl_debug_info(SYSCTL_HANDLER_ARGS); +static int igc_get_rs(SYSCTL_HANDLER_ARGS); +static void igc_print_debug_info(struct igc_adapter *); +static int igc_is_valid_ether_addr(u8 *); +static int igc_sysctl_int_delay(SYSCTL_HANDLER_ARGS); +static void igc_add_int_delay_sysctl(struct igc_adapter *, const char *, + const char *, struct igc_int_delay_info *, int, int); +/* Management and WOL Support */ +static void igc_get_hw_control(struct igc_adapter *); +static void igc_release_hw_control(struct igc_adapter *); +static void igc_get_wakeup(if_ctx_t ctx); +static void igc_enable_wakeup(if_ctx_t ctx); + +int igc_intr(void *arg); + +/* MSI-X handlers */ +static int igc_if_msix_intr_assign(if_ctx_t, int); +static int igc_msix_link(void *); +static void igc_handle_link(void *context); + +static int igc_set_flowcntl(SYSCTL_HANDLER_ARGS); +static int igc_sysctl_eee(SYSCTL_HANDLER_ARGS); + +static int igc_get_regs(SYSCTL_HANDLER_ARGS); + +static void igc_configure_queues(struct igc_adapter *adapter); + + +/********************************************************************* + * FreeBSD Device Interface Entry Points + *********************************************************************/ +static device_method_t igc_methods[] = { + /* Device interface */ + DEVMETHOD(device_register, igc_register), + DEVMETHOD(device_probe, iflib_device_probe), + DEVMETHOD(device_attach, iflib_device_attach), + DEVMETHOD(device_detach, iflib_device_detach), + DEVMETHOD(device_shutdown, iflib_device_shutdown), + DEVMETHOD(device_suspend, iflib_device_suspend), + DEVMETHOD(device_resume, iflib_device_resume), + DEVMETHOD_END +}; + +static driver_t igc_driver = { + "igc", igc_methods, sizeof(struct igc_adapter), +}; + +static devclass_t igc_devclass; +DRIVER_MODULE(igc, pci, igc_driver, igc_devclass, 0, 0); + +MODULE_DEPEND(igc, pci, 1, 1, 1); +MODULE_DEPEND(igc, ether, 1, 1, 1); +MODULE_DEPEND(igc, iflib, 1, 1, 1); + +IFLIB_PNP_INFO(pci, igc, igc_vendor_info_array); + +static device_method_t igc_if_methods[] = { + DEVMETHOD(ifdi_attach_pre, igc_if_attach_pre), + DEVMETHOD(ifdi_attach_post, igc_if_attach_post), + DEVMETHOD(ifdi_detach, igc_if_detach), + DEVMETHOD(ifdi_shutdown, igc_if_shutdown), + DEVMETHOD(ifdi_suspend, igc_if_suspend), + DEVMETHOD(ifdi_resume, igc_if_resume), + DEVMETHOD(ifdi_init, igc_if_init), + DEVMETHOD(ifdi_stop, igc_if_stop), + DEVMETHOD(ifdi_msix_intr_assign, igc_if_msix_intr_assign), + DEVMETHOD(ifdi_intr_enable, igc_if_intr_enable), + DEVMETHOD(ifdi_intr_disable, igc_if_intr_disable), + DEVMETHOD(ifdi_tx_queues_alloc, igc_if_tx_queues_alloc), + DEVMETHOD(ifdi_rx_queues_alloc, igc_if_rx_queues_alloc), + DEVMETHOD(ifdi_queues_free, igc_if_queues_free), + DEVMETHOD(ifdi_update_admin_status, igc_if_update_admin_status), + DEVMETHOD(ifdi_multi_set, igc_if_multi_set), + DEVMETHOD(ifdi_media_status, igc_if_media_status), + DEVMETHOD(ifdi_media_change, igc_if_media_change), + DEVMETHOD(ifdi_mtu_set, igc_if_mtu_set), + DEVMETHOD(ifdi_promisc_set, igc_if_set_promisc), + DEVMETHOD(ifdi_timer, igc_if_timer), + DEVMETHOD(ifdi_watchdog_reset, igc_if_watchdog_reset), + DEVMETHOD(ifdi_vlan_register, igc_if_vlan_register), + DEVMETHOD(ifdi_vlan_unregister, igc_if_vlan_unregister), + DEVMETHOD(ifdi_get_counter, igc_if_get_counter), + DEVMETHOD(ifdi_rx_queue_intr_enable, igc_if_rx_queue_intr_enable), + DEVMETHOD(ifdi_tx_queue_intr_enable, igc_if_tx_queue_intr_enable), + DEVMETHOD(ifdi_debug, igc_if_debug), + DEVMETHOD(ifdi_needs_restart, igc_if_needs_restart), + DEVMETHOD_END +}; + +static driver_t igc_if_driver = { + "igc_if", igc_if_methods, sizeof(struct igc_adapter) +}; + +/********************************************************************* + * Tunable default values. + *********************************************************************/ + +#define IGC_TICKS_TO_USECS(ticks) ((1024 * (ticks) + 500) / 1000) +#define IGC_USECS_TO_TICKS(usecs) ((1000 * (usecs) + 512) / 1024) + +#define MAX_INTS_PER_SEC 8000 +#define DEFAULT_ITR (1000000000/(MAX_INTS_PER_SEC * 256)) + +/* Allow common code without TSO */ +#ifndef CSUM_TSO +#define CSUM_TSO 0 +#endif + +static SYSCTL_NODE(_hw, OID_AUTO, igc, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, + "igc driver parameters"); + +static int igc_disable_crc_stripping = 0; +SYSCTL_INT(_hw_igc, OID_AUTO, disable_crc_stripping, CTLFLAG_RDTUN, + &igc_disable_crc_stripping, 0, "Disable CRC Stripping"); + +static int igc_tx_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_TIDV_VAL); +static int igc_rx_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_RDTR_VAL); +SYSCTL_INT(_hw_igc, OID_AUTO, tx_int_delay, CTLFLAG_RDTUN, &igc_tx_int_delay_dflt, + 0, "Default transmit interrupt delay in usecs"); +SYSCTL_INT(_hw_igc, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &igc_rx_int_delay_dflt, + 0, "Default receive interrupt delay in usecs"); + +static int igc_tx_abs_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_TADV_VAL); +static int igc_rx_abs_int_delay_dflt = IGC_TICKS_TO_USECS(IGC_RADV_VAL); +SYSCTL_INT(_hw_igc, OID_AUTO, tx_abs_int_delay, CTLFLAG_RDTUN, + &igc_tx_abs_int_delay_dflt, 0, + "Default transmit interrupt delay limit in usecs"); +SYSCTL_INT(_hw_igc, OID_AUTO, rx_abs_int_delay, CTLFLAG_RDTUN, + &igc_rx_abs_int_delay_dflt, 0, + "Default receive interrupt delay limit in usecs"); + +static int igc_smart_pwr_down = false; +SYSCTL_INT(_hw_igc, OID_AUTO, smart_pwr_down, CTLFLAG_RDTUN, &igc_smart_pwr_down, + 0, "Set to true to leave smart power down enabled on newer adapters"); + +/* Controls whether promiscuous also shows bad packets */ +static int igc_debug_sbp = true; +SYSCTL_INT(_hw_igc, OID_AUTO, sbp, CTLFLAG_RDTUN, &igc_debug_sbp, 0, + "Show bad packets in promiscuous mode"); + +/* How many packets rxeof tries to clean at a time */ +static int igc_rx_process_limit = 100; +SYSCTL_INT(_hw_igc, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, + &igc_rx_process_limit, 0, + "Maximum number of received packets to process " + "at a time, -1 means unlimited"); + +/* Energy efficient ethernet - default to OFF */ +static int igc_eee_setting = 1; +SYSCTL_INT(_hw_igc, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &igc_eee_setting, 0, + "Enable Energy Efficient Ethernet"); + +/* +** Tuneable Interrupt rate +*/ +static int igc_max_interrupt_rate = 8000; +SYSCTL_INT(_hw_igc, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, + &igc_max_interrupt_rate, 0, "Maximum interrupts per second"); + +extern struct if_txrx igc_txrx; + +static struct if_shared_ctx igc_sctx_init = { + .isc_magic = IFLIB_MAGIC, + .isc_q_align = PAGE_SIZE, + .isc_tx_maxsize = IGC_TSO_SIZE + sizeof(struct ether_vlan_header), + .isc_tx_maxsegsize = PAGE_SIZE, + .isc_tso_maxsize = IGC_TSO_SIZE + sizeof(struct ether_vlan_header), + .isc_tso_maxsegsize = IGC_TSO_SEG_SIZE, + .isc_rx_maxsize = MAX_JUMBO_FRAME_SIZE, + .isc_rx_nsegments = 1, + .isc_rx_maxsegsize = MJUM9BYTES, + .isc_nfl = 1, + .isc_nrxqs = 1, + .isc_ntxqs = 1, + .isc_admin_intrcnt = 1, + .isc_vendor_info = igc_vendor_info_array, + .isc_driver_version = "1", + .isc_driver = &igc_if_driver, + .isc_flags = IFLIB_NEED_SCRATCH | IFLIB_TSO_INIT_IP | IFLIB_NEED_ZERO_CSUM, + + .isc_nrxd_min = {IGC_MIN_RXD}, + .isc_ntxd_min = {IGC_MIN_TXD}, + .isc_nrxd_max = {IGC_MAX_RXD}, + .isc_ntxd_max = {IGC_MAX_TXD}, + .isc_nrxd_default = {IGC_DEFAULT_RXD}, + .isc_ntxd_default = {IGC_DEFAULT_TXD}, +}; + +/***************************************************************** + * + * Dump Registers + * + ****************************************************************/ +#define IGC_REGS_LEN 739 + +static int igc_get_regs(SYSCTL_HANDLER_ARGS) +{ + struct igc_adapter *adapter = (struct igc_adapter *)arg1; + struct igc_hw *hw = &adapter->hw; + struct sbuf *sb; + u32 *regs_buff; + int rc; + + regs_buff = malloc(sizeof(u32) * IGC_REGS_LEN, M_DEVBUF, M_WAITOK); + memset(regs_buff, 0, IGC_REGS_LEN * sizeof(u32)); + + rc = sysctl_wire_old_buffer(req, 0); + MPASS(rc == 0); + if (rc != 0) { + free(regs_buff, M_DEVBUF); + return (rc); + } + + sb = sbuf_new_for_sysctl(NULL, NULL, 32*400, req); + MPASS(sb != NULL); + if (sb == NULL) { + free(regs_buff, M_DEVBUF); + return (ENOMEM); + } + + /* General Registers */ + regs_buff[0] = IGC_READ_REG(hw, IGC_CTRL); + regs_buff[1] = IGC_READ_REG(hw, IGC_STATUS); + regs_buff[2] = IGC_READ_REG(hw, IGC_CTRL_EXT); + regs_buff[3] = IGC_READ_REG(hw, IGC_ICR); + regs_buff[4] = IGC_READ_REG(hw, IGC_RCTL); + regs_buff[5] = IGC_READ_REG(hw, IGC_RDLEN(0)); + regs_buff[6] = IGC_READ_REG(hw, IGC_RDH(0)); + regs_buff[7] = IGC_READ_REG(hw, IGC_RDT(0)); + regs_buff[8] = IGC_READ_REG(hw, IGC_RXDCTL(0)); + regs_buff[9] = IGC_READ_REG(hw, IGC_RDBAL(0)); + regs_buff[10] = IGC_READ_REG(hw, IGC_RDBAH(0)); + regs_buff[11] = IGC_READ_REG(hw, IGC_TCTL); + regs_buff[12] = IGC_READ_REG(hw, IGC_TDBAL(0)); + regs_buff[13] = IGC_READ_REG(hw, IGC_TDBAH(0)); + regs_buff[14] = IGC_READ_REG(hw, IGC_TDLEN(0)); + regs_buff[15] = IGC_READ_REG(hw, IGC_TDH(0)); + regs_buff[16] = IGC_READ_REG(hw, IGC_TDT(0)); + regs_buff[17] = IGC_READ_REG(hw, IGC_TXDCTL(0)); + + sbuf_printf(sb, "General Registers\n"); + sbuf_printf(sb, "\tCTRL\t %08x\n", regs_buff[0]); + sbuf_printf(sb, "\tSTATUS\t %08x\n", regs_buff[1]); + sbuf_printf(sb, "\tCTRL_EXIT\t %08x\n\n", regs_buff[2]); + + sbuf_printf(sb, "Interrupt Registers\n"); + sbuf_printf(sb, "\tICR\t %08x\n\n", regs_buff[3]); + + sbuf_printf(sb, "RX Registers\n"); + sbuf_printf(sb, "\tRCTL\t %08x\n", regs_buff[4]); + sbuf_printf(sb, "\tRDLEN\t %08x\n", regs_buff[5]); + sbuf_printf(sb, "\tRDH\t %08x\n", regs_buff[6]); + sbuf_printf(sb, "\tRDT\t %08x\n", regs_buff[7]); + sbuf_printf(sb, "\tRXDCTL\t %08x\n", regs_buff[8]); + sbuf_printf(sb, "\tRDBAL\t %08x\n", regs_buff[9]); + sbuf_printf(sb, "\tRDBAH\t %08x\n\n", regs_buff[10]); + + sbuf_printf(sb, "TX Registers\n"); + sbuf_printf(sb, "\tTCTL\t %08x\n", regs_buff[11]); + sbuf_printf(sb, "\tTDBAL\t %08x\n", regs_buff[12]); + sbuf_printf(sb, "\tTDBAH\t %08x\n", regs_buff[13]); + sbuf_printf(sb, "\tTDLEN\t %08x\n", regs_buff[14]); + sbuf_printf(sb, "\tTDH\t %08x\n", regs_buff[15]); + sbuf_printf(sb, "\tTDT\t %08x\n", regs_buff[16]); + sbuf_printf(sb, "\tTXDCTL\t %08x\n", regs_buff[17]); + sbuf_printf(sb, "\tTDFH\t %08x\n", regs_buff[18]); + sbuf_printf(sb, "\tTDFT\t %08x\n", regs_buff[19]); + sbuf_printf(sb, "\tTDFHS\t %08x\n", regs_buff[20]); + sbuf_printf(sb, "\tTDFPC\t %08x\n\n", regs_buff[21]); + + free(regs_buff, M_DEVBUF); + +#ifdef DUMP_DESCS + { + if_softc_ctx_t scctx = adapter->shared; + struct rx_ring *rxr = &rx_que->rxr; + struct tx_ring *txr = &tx_que->txr; + int ntxd = scctx->isc_ntxd[0]; + int nrxd = scctx->isc_nrxd[0]; + int j; + + for (j = 0; j < nrxd; j++) { + u32 staterr = le32toh(rxr->rx_base[j].wb.upper.status_error); + u32 length = le32toh(rxr->rx_base[j].wb.upper.length); + sbuf_printf(sb, "\tReceive Descriptor Address %d: %08" PRIx64 " Error:%d Length:%d\n", j, rxr->rx_base[j].read.buffer_addr, staterr, length); + } + + for (j = 0; j < min(ntxd, 256); j++) { + unsigned int *ptr = (unsigned int *)&txr->tx_base[j]; + + sbuf_printf(sb, "\tTXD[%03d] [0]: %08x [1]: %08x [2]: %08x [3]: %08x eop: %d DD=%d\n", + j, ptr[0], ptr[1], ptr[2], ptr[3], buf->eop, + buf->eop != -1 ? txr->tx_base[buf->eop].upper.fields.status & IGC_TXD_STAT_DD : 0); + + } + } +#endif + + rc = sbuf_finish(sb); + sbuf_delete(sb); + return(rc); +} + +static void * +igc_register(device_t dev) +{ + return (&igc_sctx_init); +} + +static int +igc_set_num_queues(if_ctx_t ctx) +{ + int maxqueues; + + maxqueues = 4; + + return (maxqueues); +} + +#define IGC_CAPS \ + IFCAP_HWCSUM | IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING | \ + IFCAP_VLAN_HWCSUM | IFCAP_WOL | IFCAP_VLAN_HWFILTER | IFCAP_TSO4 | \ + IFCAP_LRO | IFCAP_VLAN_HWTSO | IFCAP_JUMBO_MTU | IFCAP_HWCSUM_IPV6 |\ + IFCAP_TSO6 + +/********************************************************************* + * Device initialization routine + * + * The attach entry point is called when the driver is being loaded. + * This routine identifies the type of hardware, allocates all resources + * and initializes the hardware. + * + * return 0 on success, positive on failure + *********************************************************************/ +static int +igc_if_attach_pre(if_ctx_t ctx) +{ + struct igc_adapter *adapter; + if_softc_ctx_t scctx; + device_t dev; + struct igc_hw *hw; + int error = 0; + + INIT_DEBUGOUT("igc_if_attach_pre: begin"); + dev = iflib_get_dev(ctx); + adapter = iflib_get_softc(ctx); + + adapter->ctx = adapter->osdep.ctx = ctx; + adapter->dev = adapter->osdep.dev = dev; + scctx = adapter->shared = iflib_get_softc_ctx(ctx); + adapter->media = iflib_get_media(ctx); + hw = &adapter->hw; + + adapter->tx_process_limit = scctx->isc_ntxd[0]; + + /* SYSCTL stuff */ + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "nvm", CTLTYPE_INT | CTLFLAG_RW, + adapter, 0, igc_sysctl_nvm_info, "I", "NVM Information"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "debug", CTLTYPE_INT | CTLFLAG_RW, + adapter, 0, igc_sysctl_debug_info, "I", "Debug Information"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "fc", CTLTYPE_INT | CTLFLAG_RW, + adapter, 0, igc_set_flowcntl, "I", "Flow Control"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "reg_dump", + CTLTYPE_STRING | CTLFLAG_RD, adapter, 0, + igc_get_regs, "A", "Dump Registers"); + + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "rs_dump", + CTLTYPE_INT | CTLFLAG_RW, adapter, 0, + igc_get_rs, "I", "Dump RS indexes"); + + /* Determine hardware and mac info */ + igc_identify_hardware(ctx); + + scctx->isc_tx_nsegments = IGC_MAX_SCATTER; + scctx->isc_nrxqsets_max = scctx->isc_ntxqsets_max = igc_set_num_queues(ctx); + if (bootverbose) + device_printf(dev, "attach_pre capping queues at %d\n", + scctx->isc_ntxqsets_max); + + scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0] * sizeof(union igc_adv_tx_desc), IGC_DBA_ALIGN); + scctx->isc_rxqsizes[0] = roundup2(scctx->isc_nrxd[0] * sizeof(union igc_adv_rx_desc), IGC_DBA_ALIGN); + scctx->isc_txd_size[0] = sizeof(union igc_adv_tx_desc); + scctx->isc_rxd_size[0] = sizeof(union igc_adv_rx_desc); + scctx->isc_txrx = &igc_txrx; + scctx->isc_tx_tso_segments_max = IGC_MAX_SCATTER; + scctx->isc_tx_tso_size_max = IGC_TSO_SIZE; + scctx->isc_tx_tso_segsize_max = IGC_TSO_SEG_SIZE; + scctx->isc_capabilities = scctx->isc_capenable = IGC_CAPS; + scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP | CSUM_TSO | + CSUM_IP6_TCP | CSUM_IP6_UDP | CSUM_SCTP | CSUM_IP6_SCTP; + + /* + ** Some new devices, as with ixgbe, now may + ** use a different BAR, so we need to keep + ** track of which is used. + */ + scctx->isc_msix_bar = PCIR_BAR(IGC_MSIX_BAR); + if (pci_read_config(dev, scctx->isc_msix_bar, 4) == 0) + scctx->isc_msix_bar += 4; + + /* Setup PCI resources */ + if (igc_allocate_pci_resources(ctx)) { + device_printf(dev, "Allocation of PCI resources failed\n"); + error = ENXIO; + goto err_pci; + } + + /* Do Shared Code initialization */ + error = igc_setup_init_funcs(hw, true); + if (error) { + device_printf(dev, "Setup of Shared code failed, error %d\n", + error); + error = ENXIO; + goto err_pci; + } + + igc_setup_msix(ctx); + igc_get_bus_info(hw); + + /* Set up some sysctls for the tunable interrupt delays */ + igc_add_int_delay_sysctl(adapter, "rx_int_delay", + "receive interrupt delay in usecs", &adapter->rx_int_delay, + IGC_REGISTER(hw, IGC_RDTR), igc_rx_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "tx_int_delay", + "transmit interrupt delay in usecs", &adapter->tx_int_delay, + IGC_REGISTER(hw, IGC_TIDV), igc_tx_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "rx_abs_int_delay", + "receive interrupt delay limit in usecs", + &adapter->rx_abs_int_delay, + IGC_REGISTER(hw, IGC_RADV), + igc_rx_abs_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "tx_abs_int_delay", + "transmit interrupt delay limit in usecs", + &adapter->tx_abs_int_delay, + IGC_REGISTER(hw, IGC_TADV), + igc_tx_abs_int_delay_dflt); + igc_add_int_delay_sysctl(adapter, "itr", + "interrupt delay limit in usecs/4", + &adapter->tx_itr, + IGC_REGISTER(hw, IGC_ITR), + DEFAULT_ITR); + + hw->mac.autoneg = DO_AUTO_NEG; + hw->phy.autoneg_wait_to_complete = false; + hw->phy.autoneg_advertised = AUTONEG_ADV_DEFAULT; + + /* Copper options */ + if (hw->phy.media_type == igc_media_type_copper) { + hw->phy.mdix = AUTO_ALL_MODES; + } + + /* + * Set the frame limits assuming + * standard ethernet sized frames. + */ + scctx->isc_max_frame_size = adapter->hw.mac.max_frame_size = + ETHERMTU + ETHER_HDR_LEN + ETHERNET_FCS_SIZE; + + /* Allocate multicast array memory. */ + adapter->mta = malloc(sizeof(u8) * ETHER_ADDR_LEN * + MAX_NUM_MULTICAST_ADDRESSES, M_DEVBUF, M_NOWAIT); + if (adapter->mta == NULL) { + device_printf(dev, "Can not allocate multicast setup array\n"); + error = ENOMEM; + goto err_late; + } + + /* Check SOL/IDER usage */ + if (igc_check_reset_block(hw)) + device_printf(dev, "PHY reset is blocked" + " due to SOL/IDER session.\n"); + + /* Sysctl for setting Energy Efficient Ethernet */ + adapter->hw.dev_spec._i225.eee_disable = igc_eee_setting; + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "eee_control", + CTLTYPE_INT | CTLFLAG_RW, + adapter, 0, igc_sysctl_eee, "I", + "Disable Energy Efficient Ethernet"); + + /* + ** Start from a known state, this is + ** important in reading the nvm and + ** mac from that. + */ + igc_reset_hw(hw); + + /* Make sure we have a good EEPROM before we read from it */ + if (igc_validate_nvm_checksum(hw) < 0) { + /* + ** Some PCI-E parts fail the first check due to + ** the link being in sleep state, call it again, + ** if it fails a second time its a real issue. + */ + if (igc_validate_nvm_checksum(hw) < 0) { + device_printf(dev, + "The EEPROM Checksum Is Not Valid\n"); + error = EIO; + goto err_late; + } + } + + /* Copy the permanent MAC address out of the EEPROM */ + if (igc_read_mac_addr(hw) < 0) { + device_printf(dev, "EEPROM read error while reading MAC" + " address\n"); + error = EIO; + goto err_late; + } + + if (!igc_is_valid_ether_addr(hw->mac.addr)) { + device_printf(dev, "Invalid MAC address\n"); + error = EIO; + goto err_late; + } + + /* + * Get Wake-on-Lan and Management info for later use + */ + igc_get_wakeup(ctx); + + /* Enable only WOL MAGIC by default */ + scctx->isc_capenable &= ~IFCAP_WOL; + if (adapter->wol != 0) + scctx->isc_capenable |= IFCAP_WOL_MAGIC; + + iflib_set_mac(ctx, hw->mac.addr); + + return (0); + +err_late: + igc_release_hw_control(adapter); +err_pci: + igc_free_pci_resources(ctx); + free(adapter->mta, M_DEVBUF); + + return (error); +} + +static int +igc_if_attach_post(if_ctx_t ctx) *** 11488 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Mon Aug 23 12:34:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B27C266A694; Mon, 23 Aug 2021 12:34: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 4GtWs44D0kz3JhQ; Mon, 23 Aug 2021 12:34:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74E20145B4; Mon, 23 Aug 2021 12:34:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NCYWCo023171; Mon, 23 Aug 2021 12:34:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NCYWOi023170; Mon, 23 Aug 2021 12:34:32 GMT (envelope-from git) Date: Mon, 23 Aug 2021 12:34:32 GMT Message-Id: <202108231234.17NCYWOi023170@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 187ea09fbbdd - stable/13 - uipc: create dedicated lists for fast and slow timeout callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 187ea09fbbddff0d79d4a154e235a11e251dbad4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 12:34:32 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=187ea09fbbddff0d79d4a154e235a11e251dbad4 commit 187ea09fbbddff0d79d4a154e235a11e251dbad4 Author: Mateusz Guzik AuthorDate: 2021-08-15 21:41:47 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 12:32:01 +0000 uipc: create dedicated lists for fast and slow timeout callbacks This avoids having to walk all possible protocols only to check if they have one (vast majority does not). Original patch by kevans@. Reviewed by: kevans Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit e0a17c3f063fd51430fb2b4f5bc667f79d2967c2) --- sys/kern/uipc_domain.c | 55 ++++++++++++++++++++++++++++++++++++++++---------- sys/sys/protosw.h | 4 ++++ 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 60e30eb1ae00..76c0364f6824 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -74,6 +75,14 @@ static struct callout pfslow_callout; static void pffasttimo(void *); static void pfslowtimo(void *); +static struct rmlock pftimo_lock; +RM_SYSINIT(pftimo_lock, &pftimo_lock, "pftimo"); + +static LIST_HEAD(, protosw) pffast_list = + LIST_HEAD_INITIALIZER(pffast_list); +static LIST_HEAD(, protosw) pfslow_list = + LIST_HEAD_INITIALIZER(pfslow_list); + struct domain *domains; /* registered protocol domains */ int domain_init_status = 0; static struct mtx dom_mtx; /* domain list lock */ @@ -175,8 +184,16 @@ domain_init(void *arg) if (dp->dom_init) (*dp->dom_init)(); - for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) + for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) { protosw_init(pr); + rm_wlock(&pftimo_lock); + if (pr->pr_fasttimo != NULL) + LIST_INSERT_HEAD(&pffast_list, pr, pr_fasttimos); + if (pr->pr_slowtimo != NULL) + LIST_INSERT_HEAD(&pfslow_list, pr, pr_slowtimos); + rm_wunlock(&pftimo_lock); + } + /* * update global information about maximums */ @@ -381,6 +398,13 @@ pf_proto_register(int family, struct protosw *npr) /* Copy the new struct protosw over the spacer. */ bcopy(npr, fpr, sizeof(*fpr)); + rm_wlock(&pftimo_lock); + if (fpr->pr_fasttimo != NULL) + LIST_INSERT_HEAD(&pffast_list, fpr, pr_fasttimos); + if (fpr->pr_slowtimo != NULL) + LIST_INSERT_HEAD(&pfslow_list, fpr, pr_slowtimos); + rm_wunlock(&pftimo_lock); + /* Job is done, no more protection required. */ mtx_unlock(&dom_mtx); @@ -441,6 +465,13 @@ pf_proto_unregister(int family, int protocol, int type) return (EPROTONOSUPPORT); } + rm_wlock(&pftimo_lock); + if (dpr->pr_fasttimo != NULL) + LIST_REMOVE(dpr, pr_fasttimos); + if (dpr->pr_slowtimo != NULL) + LIST_REMOVE(dpr, pr_slowtimos); + rm_wunlock(&pftimo_lock); + /* De-orbit the protocol and make the slot available again. */ dpr->pr_type = 0; dpr->pr_domain = dp; @@ -477,31 +508,33 @@ pfctlinput(int cmd, struct sockaddr *sa) static void pfslowtimo(void *arg) { + struct rm_priotracker tracker; struct epoch_tracker et; - struct domain *dp; struct protosw *pr; + rm_rlock(&pftimo_lock, &tracker); NET_EPOCH_ENTER(et); - for (dp = domains; dp; dp = dp->dom_next) - for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) - if (pr->pr_slowtimo) - (*pr->pr_slowtimo)(); + LIST_FOREACH(pr, &pfslow_list, pr_slowtimos) { + (*pr->pr_slowtimo)(); + } NET_EPOCH_EXIT(et); + rm_runlock(&pftimo_lock, &tracker); callout_reset(&pfslow_callout, hz/2, pfslowtimo, NULL); } static void pffasttimo(void *arg) { + struct rm_priotracker tracker; struct epoch_tracker et; - struct domain *dp; struct protosw *pr; + rm_rlock(&pftimo_lock, &tracker); NET_EPOCH_ENTER(et); - for (dp = domains; dp; dp = dp->dom_next) - for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) - if (pr->pr_fasttimo) - (*pr->pr_fasttimo)(); + LIST_FOREACH(pr, &pffast_list, pr_fasttimos) { + (*pr->pr_fasttimo)(); + } NET_EPOCH_EXIT(et); + rm_runlock(&pftimo_lock, &tracker); callout_reset(&pffast_callout, hz/5, pffasttimo, NULL); } diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 9c3139c866bd..5c876a2052d5 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -35,6 +35,8 @@ #ifndef _SYS_PROTOSW_H_ #define _SYS_PROTOSW_H_ +#include + /* Forward declare these structures referenced from prototypes below. */ struct kaiocb; struct mbuf; @@ -93,6 +95,8 @@ struct protosw { pr_drain_t *pr_drain; /* flush any excess space possible */ struct pr_usrreqs *pr_usrreqs; /* user-protocol hook */ + LIST_ENTRY(protosw) pr_fasttimos; + LIST_ENTRY(protosw) pr_slowtimos; }; /*#endif*/ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 12:34:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B9B63669FE7; Mon, 23 Aug 2021 12:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtWs54rBDz3JyM; Mon, 23 Aug 2021 12:34: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 8E39F143DF; Mon, 23 Aug 2021 12:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NCYXAN023195; Mon, 23 Aug 2021 12:34:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NCYXgJ023194; Mon, 23 Aug 2021 12:34:33 GMT (envelope-from git) Date: Mon, 23 Aug 2021 12:34:33 GMT Message-Id: <202108231234.17NCYXgJ023194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 9134711fb5b7 - stable/13 - uipc: avoid circular pr_{slow, fast}timos MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9134711fb5b70effb53bbdc21c79fe3b0c8a67cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 12:34:33 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9134711fb5b70effb53bbdc21c79fe3b0c8a67cc commit 9134711fb5b70effb53bbdc21c79fe3b0c8a67cc Author: Kyle Evans AuthorDate: 2021-08-18 17:31:45 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 12:33:32 +0000 uipc: avoid circular pr_{slow,fast}timos domain_init() gets reinvoked for each vnet on a system, so we must not alter global state. Practically speaking, we were creating circular lists and tying up a softclock thread into an infinite loop. The breakage here was most easily observed by simply creating a jail in a new vnet and watching the system suddenly become erratic. Reported by: markj Fixes: e0a17c3f063f ("uipc: create dedicated lists for fast ...") Pointy hat: kevans (cherry picked from commit d7e1bdfebacc4de25dc51e14a91d66bb429677c9) --- sys/kern/uipc_domain.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 76c0364f6824..4342f1026783 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -186,12 +186,23 @@ domain_init(void *arg) (*dp->dom_init)(); for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) { protosw_init(pr); - rm_wlock(&pftimo_lock); - if (pr->pr_fasttimo != NULL) - LIST_INSERT_HEAD(&pffast_list, pr, pr_fasttimos); - if (pr->pr_slowtimo != NULL) - LIST_INSERT_HEAD(&pfslow_list, pr, pr_slowtimos); - rm_wunlock(&pftimo_lock); + + /* + * Note that with VIMAGE enabled, domain_init() will be + * re-invoked for each new vnet that's created. The below lists + * are intended to be system-wide, so avoid altering global + * state for non-default vnets. + */ + if (IS_DEFAULT_VNET(curvnet)) { + rm_wlock(&pftimo_lock); + if (pr->pr_fasttimo != NULL) + LIST_INSERT_HEAD(&pffast_list, pr, + pr_fasttimos); + if (pr->pr_slowtimo != NULL) + LIST_INSERT_HEAD(&pfslow_list, pr, + pr_slowtimos); + rm_wunlock(&pftimo_lock); + } } /* From owner-dev-commits-src-all@freebsd.org Mon Aug 23 12:37:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4E24166A921; Mon, 23 Aug 2021 12:37: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 4GtWw51kM9z3LP7; Mon, 23 Aug 2021 12:37: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 1FEFB1427D; Mon, 23 Aug 2021 12:37: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 17NCb8Tk023594; Mon, 23 Aug 2021 12:37:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NCb83t023593; Mon, 23 Aug 2021 12:37:08 GMT (envelope-from git) Date: Mon, 23 Aug 2021 12:37:08 GMT Message-Id: <202108231237.17NCb83t023593@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 3a2f9cf487f7 - stable/13 - pf: save on branching in the common case in pf_test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3a2f9cf487f7da8706b16439497519b8311cede5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 12:37:09 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=3a2f9cf487f7da8706b16439497519b8311cede5 commit 3a2f9cf487f7da8706b16439497519b8311cede5 Author: Mateusz Guzik AuthorDate: 2021-08-17 18:04:31 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 12:34:50 +0000 pf: save on branching in the common case in pf_test Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 5091ca26507b83ebd5ce677dd26bd10e4bad4153) --- sys/netpfil/pf/pf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 633346eee21c..cd3c469dc58e 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6151,7 +6151,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb * PF_RULES_RLOCK(); - if (ip_divert_ptr != NULL && + if (__predict_false(ip_divert_ptr != NULL) && ((ipfwtag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL)) != NULL)) { struct ipfw_rule_ref *rr = (struct ipfw_rule_ref *)(ipfwtag+1); if (rr->info & IPFW_IS_DIVERT && rr->rulenum == 0) { @@ -6419,8 +6419,8 @@ done: IN_LOOPBACK(ntohl(pd.dst->v4.s_addr))) m->m_flags |= M_SKIP_FIREWALL; - if (action == PF_PASS && r->divert.port && ip_divert_ptr != NULL && - !PACKET_LOOPED(&pd)) { + if (__predict_false(ip_divert_ptr != NULL) && action == PF_PASS && + r->divert.port && !PACKET_LOOPED(&pd)) { ipfwtag = m_tag_alloc(MTAG_IPFW_RULE, 0, sizeof(struct ipfw_rule_ref), M_NOWAIT | M_ZERO); if (ipfwtag != NULL) { From owner-dev-commits-src-all@freebsd.org Mon Aug 23 12:37:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 80A5166A740; Mon, 23 Aug 2021 12:37: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 4GtWw62NbXz3L44; Mon, 23 Aug 2021 12:37: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 30D4713F63; Mon, 23 Aug 2021 12:37: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 17NCbAah023619; Mon, 23 Aug 2021 12:37:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NCbA5T023618; Mon, 23 Aug 2021 12:37:10 GMT (envelope-from git) Date: Mon, 23 Aug 2021 12:37:10 GMT Message-Id: <202108231237.17NCbA5T023618@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 43151ddbae85 - stable/13 - pf: assert dir state on pf_test{,6} MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 43151ddbae859d649cccaf0c2a1df8dd44cfd2c2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 12:37:10 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=43151ddbae859d649cccaf0c2a1df8dd44cfd2c2 commit 43151ddbae859d649cccaf0c2a1df8dd44cfd2c2 Author: Mateusz Guzik AuthorDate: 2021-08-17 18:16:09 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 12:34:59 +0000 pf: assert dir state on pf_test{,6} The intent is to line up various enums so that branching in the lines of: idx = (dir == PF_IN ? PF_SK_WIRE : PF_SK_STACK); is avoided. Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 3e875f952af05697807139b460e5124eb5f6137b) --- sys/netpfil/pf/pf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index cd3c469dc58e..09365d5d39ab 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6126,7 +6126,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb * int off, dirndx, pqid = 0; PF_RULES_RLOCK_TRACKER; - + KASSERT(dir == PF_IN || dir == PF_OUT, ("%s: bad direction %d\n", __func__, dir)); M_ASSERTPKTHDR(m); if (!V_pf_status.running) @@ -6575,6 +6575,7 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb int off, terminal = 0, dirndx, rh_cnt = 0, pqid = 0; PF_RULES_RLOCK_TRACKER; + KASSERT(dir == PF_IN || dir == PF_OUT, ("%s: bad direction %d\n", __func__, dir)); M_ASSERTPKTHDR(m); if (!V_pf_status.running) From owner-dev-commits-src-all@freebsd.org Mon Aug 23 12:37:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0EE4B66A999; Mon, 23 Aug 2021 12:37: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 4GtWw75NZNz3L8p; Mon, 23 Aug 2021 12:37: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 577931427E; Mon, 23 Aug 2021 12:37: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 17NCbBRg023643; Mon, 23 Aug 2021 12:37:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NCbBP4023642; Mon, 23 Aug 2021 12:37:11 GMT (envelope-from git) Date: Mon, 23 Aug 2021 12:37:11 GMT Message-Id: <202108231237.17NCbBP4023642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 9fc5596c036e - stable/13 - arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9fc5596c036e11f3649fea97424e09b65ba57b54 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 12:37:12 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9fc5596c036e11f3649fea97424e09b65ba57b54 commit 9fc5596c036e11f3649fea97424e09b65ba57b54 Author: Mateusz Guzik AuthorDate: 2021-07-21 03:34:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 12:35:09 +0000 arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS Stat collection using counter(9) is quite expensive on this platform and these counters are normally not needed. In particular we see about 1.5% bump in packet rate using Cortex-A9 Reviewed by: ian Sponsored by: Rubicon Communications, LLC ("Netgate") Different Revision: https://reviews.freebsd.org/D31592 (cherry picked from commit aec8ad8a9e6aba2d73c98bd41f2994744aae3d01) --- sys/arm/arm/busdma_machdep.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index 7d978ca0163d..8a06e7245cd9 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +//#define ARM_BUSDMA_MAPLOAD_STATS + #define BUSDMA_DCACHE_ALIGN cpuinfo.dcache_line_size #define BUSDMA_DCACHE_MASK cpuinfo.dcache_line_mask @@ -139,12 +141,14 @@ static uint32_t tags_total; static uint32_t maps_total; static uint32_t maps_dmamem; static uint32_t maps_coherent; +#ifdef ARM_BUSDMA_MAPLOAD_STATS static counter_u64_t maploads_total; static counter_u64_t maploads_bounced; static counter_u64_t maploads_coherent; static counter_u64_t maploads_dmamem; static counter_u64_t maploads_mbuf; static counter_u64_t maploads_physmem; +#endif static STAILQ_HEAD(, bounce_zone) bounce_zone_list; @@ -158,6 +162,7 @@ SYSCTL_UINT(_hw_busdma, OID_AUTO, maps_dmamem, CTLFLAG_RD, &maps_dmamem, 0, "Number of active maps for bus_dmamem_alloc buffers"); SYSCTL_UINT(_hw_busdma, OID_AUTO, maps_coherent, CTLFLAG_RD, &maps_coherent, 0, "Number of active maps with BUS_DMA_COHERENT flag set"); +#ifdef ARM_BUSDMA_MAPLOAD_STATS SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_total, CTLFLAG_RD, &maploads_total, "Number of load operations performed"); SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_bounced, CTLFLAG_RD, @@ -170,6 +175,7 @@ SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_mbuf, CTLFLAG_RD, &maploads_mbuf, "Number of load operations for mbufs"); SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_physmem, CTLFLAG_RD, &maploads_physmem, "Number of load operations on physical buffers"); +#endif SYSCTL_INT(_hw_busdma, OID_AUTO, total_bpages, CTLFLAG_RD, &total_bpages, 0, "Total bounce pages"); @@ -222,12 +228,14 @@ busdma_init(void *dummy) { int uma_flags; +#ifdef ARM_BUSDMA_MAPLOAD_STATS maploads_total = counter_u64_alloc(M_WAITOK); maploads_bounced = counter_u64_alloc(M_WAITOK); maploads_coherent = counter_u64_alloc(M_WAITOK); maploads_dmamem = counter_u64_alloc(M_WAITOK); maploads_mbuf = counter_u64_alloc(M_WAITOK); maploads_physmem = counter_u64_alloc(M_WAITOK); +#endif uma_flags = 0; @@ -1058,13 +1066,17 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, if (segs == NULL) segs = map->segments; +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_total, 1); counter_u64_add(maploads_physmem, 1); +#endif if (might_bounce(dmat, map, (bus_addr_t)buf, buflen)) { _bus_dmamap_count_phys(dmat, map, buf, buflen, flags); if (map->pagesneeded != 0) { +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_bounced, 1); +#endif error = _bus_dmamap_reserve_pages(dmat, map, flags); if (error) return (error); @@ -1143,24 +1155,30 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, struct sync_list *sl; int error; +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_total, 1); if (map->flags & DMAMAP_COHERENT) counter_u64_add(maploads_coherent, 1); if (map->flags & DMAMAP_DMAMEM_ALLOC) counter_u64_add(maploads_dmamem, 1); +#endif if (segs == NULL) segs = map->segments; if (flags & BUS_DMA_LOAD_MBUF) { +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_mbuf, 1); +#endif map->flags |= DMAMAP_MBUF; } if (might_bounce(dmat, map, (bus_addr_t)buf, buflen)) { _bus_dmamap_count_pages(dmat, pmap, map, buf, buflen, flags); if (map->pagesneeded != 0) { +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_bounced, 1); +#endif error = _bus_dmamap_reserve_pages(dmat, map, flags); if (error) return (error); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:25:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8BE766B1EB; Mon, 23 Aug 2021 13:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtXzk4Rcyz3q8l; Mon, 23 Aug 2021 13:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8098E14E5A; Mon, 23 Aug 2021 13:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDPM1i092447; Mon, 23 Aug 2021 13:25:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPMGv092446; Mon, 23 Aug 2021 13:25:22 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:22 GMT Message-Id: <202108231325.17NDPMGv092446@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 766a7c73e92a - main - arm64: add read_frequently, read_mostluy and exclusive_cache_line to linker script MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 766a7c73e92aee0fc1a2059919015000e8cbfa05 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:22 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=766a7c73e92aee0fc1a2059919015000e8cbfa05 commit 766a7c73e92aee0fc1a2059919015000e8cbfa05 Author: Mateusz Guzik AuthorDate: 2021-08-23 09:44:23 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:22:17 +0000 arm64: add read_frequently, read_mostluy and exclusive_cache_line to linker script Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31643 --- sys/conf/ldscript.arm64 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/conf/ldscript.arm64 b/sys/conf/ldscript.arm64 index 3c4b77034725..e73f8ed8e65e 100644 --- a/sys/conf/ldscript.arm64 +++ b/sys/conf/ldscript.arm64 @@ -82,6 +82,21 @@ SECTIONS *(.data) *(.gnu.linkonce.d*) } + . = ALIGN(128); + .data.read_frequently : + { + *(SORT_BY_ALIGNMENT(.data.read_frequently)) + } + .data.read_mostly : + { + *(.data.read_mostly) + } + . = ALIGN(128); + .data.exclusive_cache_line : + { + *(.data.exclusive_cache_line) + } + . = ALIGN(128); .data1 : { *(.data1) } . = ALIGN(32 / 8); _start_ctors = .; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:25:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D1C1E66B50A; Mon, 23 Aug 2021 13:25: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 4GtXzl59fbz3pmk; Mon, 23 Aug 2021 13:25: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 9AE4614A68; Mon, 23 Aug 2021 13:25: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 17NDPNOK092473; Mon, 23 Aug 2021 13:25:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPNwp092472; Mon, 23 Aug 2021 13:25:23 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:23 GMT Message-Id: <202108231325.17NDPNwp092472@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: d47afcb2039f - main - arm64: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d47afcb2039f1b0f524f176fe6577359ca4edab1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:23 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=d47afcb2039f1b0f524f176fe6577359ca4edab1 commit d47afcb2039f1b0f524f176fe6577359ca4edab1 Author: Mateusz Guzik AuthorDate: 2021-08-23 09:46:01 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:22:44 +0000 arm64: retire bzero Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31644 --- sys/arm64/arm64/bzero.S | 206 ------------------------------------------------ sys/conf/files.arm64 | 1 - 2 files changed, 207 deletions(-) diff --git a/sys/arm64/arm64/bzero.S b/sys/arm64/arm64/bzero.S deleted file mode 100644 index 6c7f1fef1494..000000000000 --- a/sys/arm64/arm64/bzero.S +++ /dev/null @@ -1,206 +0,0 @@ -/*- - * Copyright (C) 2016 Cavium Inc. - * All rights reserved. - * - * Developed by Semihalf. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - - -#include "assym.inc" - - /* - * void bzero(void *p, size_t size) - * - * x0 - p - * x1 - size - */ -ENTRY(bzero) - cbz x1, ending - - /* - * x5 is number of cache lines to zero - calculated later and - * will become non-zero if buffer is long enough to zero by - * cache lines (and if it is allowed.) - * We need to zero it before proceeding with buffers of size - * smaller than 16 bytes - otherwise the x5 will not be - * calculated and will retain random value. - * "normal" is used for buffers <= 16 bytes and to align buffer - * to cache line for buffers bigger than cache line; non-0 x5 - * after "normal" has completed indicates that it has been used - * to align buffer to cache line and now zero by cache lines will - * be performed, and x5 is amount of cache lines to loop through. - */ - mov x5, xzr - - /* No use of cache assisted zero for buffers with size <= 16 */ - cmp x1, #0x10 - b.le normal - - /* - * Load size of line that will be cleaned by dc zva call. - * 0 means that the instruction is not allowed - */ - ldr x7, =dczva_line_size - ldr x7, [x7] - cbz x7, normal - - /* - * Buffer must be larger than cache line for using cache zeroing - * (and cache line aligned but this is checked after jump) - */ - cmp x1, x7 - b.lt normal - - /* - * Calculate number of bytes to cache aligned address (x4) nad - * number of full cache lines (x5). x6 is final address to zero. - */ - sub x2, x7, #0x01 - mov x3, -1 - eor x3, x3, x2 - add x4, x0, x2 - and x4, x4, x3 - subs x4, x4, x0 - b.eq normal - - /* Calculate number of "lines" in buffer */ - sub x5, x1, x4 - rbit x2, x7 - clz x2, x2 - lsr x5, x5, x2 - - /* - * If number of cache lines is 0, we will not be able to zero - * by cache lines, so go normal way. - */ - cbz x5, normal - /* x6 is final address to zero */ - add x6, x0, x1 - - /* - * We are here because x5 is non-0 so normal will be used to - * align buffer before cache zeroing. x4 holds number of bytes - * needed for alignment. - */ - mov x1, x4 - - /* When jumping here: x0 holds pointer, x1 holds size */ -normal: - /* - * Get buffer offset into 16 byte aligned address; 0 means pointer - * is aligned. - */ - ands x2, x0, #0x0f - b.eq aligned_to_16 - /* Calculate one-byte loop runs to 8 byte aligned address. */ - ands x2, x2, #0x07 - mov x3, #0x08 - sub x2, x3, x2 - /* x2 is number of bytes missing for alignment, x1 is buffer size */ - cmp x1, x2 - csel x2, x1, x2, le - sub x1, x1, x2 - - /* - * Byte by byte copy will copy at least enough bytes to align - * pointer and at most "size". - */ -align: - strb wzr, [x0], #0x01 - subs x2, x2, #0x01 - b.ne align - - /* Now pointer is aligned to 8 bytes */ - cmp x1, #0x10 - b.lt lead_out - /* - * Check if copy of another 8 bytes is needed to align to 16 byte - * address and do it - */ - tbz x0, #0x03, aligned_to_16 - str xzr, [x0], #0x08 - sub x1, x1, #0x08 - - /* While jumping here: x0 is 16 byte alligned address, x1 is size */ -aligned_to_16: - /* If size is less than 16 bytes, use lead_out to copy what remains */ - cmp x1, #0x10 - b.lt lead_out - - lsr x2, x1, #0x04 -zero_by_16: - stp xzr, xzr, [x0], #0x10 - subs x2, x2, #0x01 - b.ne zero_by_16 - - /* - * Lead out requires addresses to be aligned to 8 bytes. It is used to - * zero buffers with sizes < 16 and what can not be zeroed by - * zero_by_16 loop. - */ - ands x1, x1, #0x0f - b.eq lead_out_end -lead_out: - tbz x1, #0x03, lead_out_dword - str xzr, [x0], #0x08 -lead_out_dword: - tbz x1, #0x02, lead_out_word - str wzr, [x0], #0x04 -lead_out_word: - tbz x1, #0x01, lead_out_byte - strh wzr, [x0], #0x02 -lead_out_byte: - tbz x1, #0x00, lead_out_end - strb wzr, [x0], #0x01 - -lead_out_end: - /* - * If x5 is non-zero, this means that normal has been used as - * a lead in to align buffer address to cache size - */ - cbz x5, ending - - /* - * Here x5 holds number of lines to zero; x6 is final address of - * buffer. x0 is cache line aligned pointer. x7 is cache line size - * in bytes - */ -cache_line_zero: - dc zva, x0 - add x0, x0, x7 - subs x5, x5, #0x01 - b.ne cache_line_zero - - /* Need to zero remaining bytes? */ - subs x1, x6, x0 - b.ne normal - -ending: - ret - -END(bzero) - diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index ed3625df0c23..202a911ad8ca 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -33,7 +33,6 @@ arm64/arm64/bus_machdep.c standard arm64/arm64/bus_space_asm.S standard arm64/arm64/busdma_bounce.c standard arm64/arm64/busdma_machdep.c standard -arm64/arm64/bzero.S standard arm64/arm64/clock.c standard arm64/arm64/copyinout.S standard arm64/arm64/cpu_errata.c standard From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:25:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B82E266B0F6; Mon, 23 Aug 2021 13:25: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 4GtXzp2sDkz3pmv; Mon, 23 Aug 2021 13:25: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 E316514E5B; Mon, 23 Aug 2021 13:25: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 17NDPPsx092530; Mon, 23 Aug 2021 13:25:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPP9Y092529; Mon, 23 Aug 2021 13:25:25 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:25 GMT Message-Id: <202108231325.17NDPP9Y092529@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b2d2a5903518 - main - arm: flip memclr to use memset MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2d2a5903518668aa22fb906b021f99d2952c08c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:26 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b2d2a5903518668aa22fb906b021f99d2952c08c commit b2d2a5903518668aa22fb906b021f99d2952c08c Author: Mateusz Guzik AuthorDate: 2021-07-19 13:46:03 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:42 +0000 arm: flip memclr to use memset Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31217 --- sys/libkern/arm/memclr.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/libkern/arm/memclr.S b/sys/libkern/arm/memclr.S index 2883d3f23104..0f01b0b6ad5e 100644 --- a/sys/libkern/arm/memclr.S +++ b/sys/libkern/arm/memclr.S @@ -32,11 +32,13 @@ __FBSDID("$FreeBSD$"); * This implements * void __aeabi_memclr4(void *dest, size_t len) * by calling: - * void bzero(dest, len) + * void *memset(dest, 0, len) */ ENTRY_NP(__aeabi_memclr4) EENTRY_NP(__aeabi_memclr8) - b bzero + mov r2, r1 + mov r1, #0 + b memset EEND(__aeabi_memclr8) END(__aeabi_memclr4) From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:25:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F1BA66B349; Mon, 23 Aug 2021 13:25: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 4GtXzq16RYz3q91; Mon, 23 Aug 2021 13:25: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 0F3F814EC9; Mon, 23 Aug 2021 13:25: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 17NDPQnf092554; Mon, 23 Aug 2021 13:25:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPQFE092553; Mon, 23 Aug 2021 13:25:26 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:26 GMT Message-Id: <202108231325.17NDPQFE092553@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: a12111562116 - main - arm: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a1211156211634ab713c7e910fdc70485b7c9193 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:27 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=a1211156211634ab713c7e910fdc70485b7c9193 commit a1211156211634ab713c7e910fdc70485b7c9193 Author: Mateusz Guzik AuthorDate: 2021-07-19 13:46:20 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:42 +0000 arm: retire bzero Same as bcopy. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/arm/arm/support.S | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sys/arm/arm/support.S b/sys/arm/arm/support.S index 9390b03f62a3..bd2a3ad07805 100644 --- a/sys/arm/arm/support.S +++ b/sys/arm/arm/support.S @@ -104,11 +104,6 @@ __FBSDID("$FreeBSD$"); * On exit: * r0 - dest address */ -/* LINTSTUB: Func: void bzero(void *, size_t) */ -ENTRY(bzero) - mov r3, #0x00 - b do_memset -END(bzero) /* LINTSTUB: Func: void *memset(void *, int, size_t) */ ENTRY(memset) and r3, r1, #0xff /* We deal with bytes */ @@ -213,8 +208,7 @@ do_memset: strbge r3, [ip], #0x01 /* Set another byte */ strbgt r3, [ip] /* and a third */ RET /* Exit */ -EEND(memset) -END(bzero) +END(memset) ENTRY(memcmp) mov ip, r0 From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:25:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 23B9F66B275; Mon, 23 Aug 2021 13:25: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 4GtXzn0Ky5z3q18; Mon, 23 Aug 2021 13:25: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 D772F1522B; Mon, 23 Aug 2021 13:25:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDPOhU092497; Mon, 23 Aug 2021 13:25:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDPO9g092496; Mon, 23 Aug 2021 13:25:24 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:25:24 GMT Message-Id: <202108231325.17NDPO9g092496@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 1652d2ff09ea - main - arm64: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1652d2ff09ea5599ab4fc647038878f24f07f719 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:25:25 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=1652d2ff09ea5599ab4fc647038878f24f07f719 commit 1652d2ff09ea5599ab4fc647038878f24f07f719 Author: Mateusz Guzik AuthorDate: 2021-08-23 09:46:28 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:20 +0000 arm64: retire bcmp Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31645 --- sys/conf/files.arm64 | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 202a911ad8ca..bae23b17cc40 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -9,7 +9,6 @@ kern/pic_if.m optional intrng kern/subr_devmap.c standard kern/subr_intr.c optional intrng kern/subr_physmem.c standard -libkern/bcmp.c standard libkern/memcmp.c standard \ compile-with "${NORMAL_C:N-fsanitize*}" libkern/memset.c standard \ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:34:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2424166B7EC; Mon, 23 Aug 2021 13:34: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 4GtYB00WZfz3rx9; Mon, 23 Aug 2021 13:34: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 ED3D614A7F; Mon, 23 Aug 2021 13:34: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 17NDYFEU005866; Mon, 23 Aug 2021 13:34:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDYFKp005865; Mon, 23 Aug 2021 13:34:15 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:34:15 GMT Message-Id: <202108231334.17NDYFKp005865@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 7fd856ba07b1 - main - vfs: s/__unused/__diagused in crossmp_* MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7fd856ba07b1cfc35eb9b0faad25c3ba4963bf83 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:34:16 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7fd856ba07b1cfc35eb9b0faad25c3ba4963bf83 commit 7fd856ba07b1cfc35eb9b0faad25c3ba4963bf83 Author: Mateusz Guzik AuthorDate: 2021-08-23 10:10:38 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:23:42 +0000 vfs: s/__unused/__diagused in crossmp_* Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_lookup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index a83cc6bb8b74..28d7ada0f434 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -97,9 +97,9 @@ static int crossmp_vop_lock1(struct vop_lock1_args *ap) { struct vnode *vp; - struct lock *lk __unused; - const char *file __unused; - int flags, line __unused; + struct lock *lk __diagused; + const char *file __diagused; + int flags, line __diagused; vp = ap->a_vp; lk = vp->v_vnlock; @@ -123,7 +123,7 @@ static int crossmp_vop_unlock(struct vop_unlock_args *ap) { struct vnode *vp; - struct lock *lk __unused; + struct lock *lk __diagused; vp = ap->a_vp; lk = vp->v_vnlock; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:34:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C06366BB3C; Mon, 23 Aug 2021 13:34: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 4GtYB120Rkz3rnF; Mon, 23 Aug 2021 13:34: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 1F42015149; Mon, 23 Aug 2021 13:34: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 17NDYHmO005890; Mon, 23 Aug 2021 13:34:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDYHm1005889; Mon, 23 Aug 2021 13:34:17 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:34:17 GMT Message-Id: <202108231334.17NDYHm1005889@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b65ad70195d8 - main - cache: retire cache_fast_revlookup sysctl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b65ad70195d874ac28e6e65d2fd8acf5d9a79236 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:34:17 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b65ad70195d874ac28e6e65d2fd8acf5d9a79236 commit b65ad70195d874ac28e6e65d2fd8acf5d9a79236 Author: Mateusz Guzik AuthorDate: 2021-08-23 13:29:42 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:31:44 +0000 cache: retire cache_fast_revlookup sysctl Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_cache.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 199da865e39c..732dbbe53cef 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -253,6 +253,8 @@ SDT_PROBE_DEFINE3(vfs, fplookup, lookup, done, "struct nameidata", "int", "bool" SDT_PROBE_DECLARE(vfs, namei, lookup, entry); SDT_PROBE_DECLARE(vfs, namei, lookup, return); +static char __read_frequently cache_fast_lookup_enabled = true; + /* * This structure describes the elements in the cache of recent * names looked up by namei. @@ -443,10 +445,6 @@ static u_long __exclusive_cache_line numcache;/* number of cache entries allocat struct nchstats nchstats; /* cache effectiveness statistics */ -static bool __read_frequently cache_fast_revlookup = true; -SYSCTL_BOOL(_vfs, OID_AUTO, cache_fast_revlookup, CTLFLAG_RW, - &cache_fast_revlookup, 0, ""); - static bool __read_mostly cache_rename_add = true; SYSCTL_BOOL(_vfs, OID_AUTO, cache_rename_add, CTLFLAG_RW, &cache_rename_add, 0, ""); @@ -3440,7 +3438,7 @@ vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdir, char *buf, VFS_SMR_ASSERT_ENTERED(); - if (!cache_fast_revlookup) { + if (!atomic_load_char(&cache_fast_lookup_enabled)) { vfs_smr_exit(); return (-1); } @@ -3845,7 +3843,6 @@ DB_SHOW_COMMAND(vpath, db_show_vpath) #endif static int cache_fast_lookup = 1; -static char __read_frequently cache_fast_lookup_enabled = true; #define CACHE_FPL_FAILED -2020 From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:44:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8D4CD66BD2D; Mon, 23 Aug 2021 13:44: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 4GtYPy3PfSz3vjZ; Mon, 23 Aug 2021 13:44: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 5CE951549A; Mon, 23 Aug 2021 13:44: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 17NDiciG019583; Mon, 23 Aug 2021 13:44:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDicXM019582; Mon, 23 Aug 2021 13:44:38 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:44:38 GMT Message-Id: <202108231344.17NDicXM019582@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: bc5304a00623 - main - Add arm64 ifunc support in static binaries MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bc5304a006238115291e7568583632889dffbab9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:44:38 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=bc5304a006238115291e7568583632889dffbab9 commit bc5304a006238115291e7568583632889dffbab9 Author: Andrew Turner AuthorDate: 2021-08-20 08:22:48 +0000 Commit: Andrew Turner CommitDate: 2021-08-23 13:39:09 +0000 Add arm64 ifunc support in static binaries Add support for the R_AARCH64_IRELATIVE relocation type in static binaries on arm64. This is based on the powerpc code, updating it to use the arm64 resolver ABI, and use the arm64 relocation type. Tested by: brd Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31641 --- lib/csu/aarch64/Makefile | 3 ++- lib/csu/aarch64/crt1_c.c | 4 +++- lib/csu/aarch64/reloc.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/lib/csu/aarch64/Makefile b/lib/csu/aarch64/Makefile index 666bf569b786..e4c9029fcacc 100644 --- a/lib/csu/aarch64/Makefile +++ b/lib/csu/aarch64/Makefile @@ -2,7 +2,8 @@ .PATH: ${.CURDIR:H}/common -CFLAGS+= -DCRT_IRELOC_SUPPRESS +CFLAGS+= -I${.CURDIR} +CFLAGS+= -DCRT_IRELOC_RELA CRT1OBJS+= crt1_s.o diff --git a/lib/csu/aarch64/crt1_c.c b/lib/csu/aarch64/crt1_c.c index d8c2156ffc21..9b3ffbff22d0 100644 --- a/lib/csu/aarch64/crt1_c.c +++ b/lib/csu/aarch64/crt1_c.c @@ -57,8 +57,10 @@ __start(int argc, char *argv[], char *env[], void (*cleanup)(void)) if (&_DYNAMIC != NULL) atexit(cleanup); - else + else { + process_irelocs(); _init_tls(); + } #ifdef GCRT atexit(_mcleanup); diff --git a/lib/csu/aarch64/reloc.c b/lib/csu/aarch64/reloc.c new file mode 100644 index 000000000000..f3dbf3e3b570 --- /dev/null +++ b/lib/csu/aarch64/reloc.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2019 Leandro Lupori + * Copyright (c) 2021 The FreeBSD Foundation + * + * Portions of this software were developed by Andrew Turner + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +static void +crt1_handle_rela(const Elf_Rela *r) +{ + typedef Elf_Addr (*ifunc_resolver_t)( + uint64_t, uint64_t, uint64_t, uint64_t, + uint64_t, uint64_t, uint64_t, uint64_t); + Elf_Addr *ptr, *where, target; + + switch (ELF_R_TYPE(r->r_info)) { + case R_AARCH64_IRELATIVE: + ptr = (Elf_Addr *)r->r_addend; + where = (Elf_Addr *)r->r_offset; + target = ((ifunc_resolver_t)ptr)(0, 0, 0, 0, 0, 0, 0, 0); + *where = target; + break; + } +} From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:51:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0FE7E66BCC0; Mon, 23 Aug 2021 13:51:52 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtYZH5zwQz4RRY; Mon, 23 Aug 2021 13:51:51 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from shw-obgw-4003a.ext.cloudfilter.net ([10.228.9.183]) by cmsmtp with ESMTP id I8fbm5uL24bInIAMbmHVlt; Mon, 23 Aug 2021 13:51:45 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id IAMamjck1qeviIAMamF6GY; Mon, 23 Aug 2021 13:51:45 +0000 X-Authority-Analysis: v=2.4 cv=B4F8bMhM c=1 sm=1 tr=0 ts=6123a7f1 a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=kj9zAlcOel0A:10 a=MhDmnRu9jo8A:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=p8d-jTAGzcGgB6t1mYAA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 4CF0930C; Mon, 23 Aug 2021 06:51:43 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 17NDphg3006806; Mon, 23 Aug 2021 06:51:43 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202108231351.17NDphg3006806@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Mateusz Guzik cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: b65ad70195d8 - main - cache: retire cache_fast_revlookup sysctl In-reply-to: <202108231334.17NDYHm1005889@gitrepo.freebsd.org> References: <202108231334.17NDYHm1005889@gitrepo.freebsd.org> Comments: In-reply-to Mateusz Guzik message dated "Mon, 23 Aug 2021 13:34:17 +0000." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 23 Aug 2021 06:51:43 -0700 X-CMAE-Envelope: MS4xfPyTv4nB3oVS8uE9dDc9VdQMIGiu7HVabGntFmk7bA1a4ZU46Rj47S4+X68a89XC7qabidjfEAp0Y3LLdM1/HyDCM8yUdiZuWYFA2w3dr5Nt2I7w3wBh 33fVO+n5TChbUziro3v7AeYPWPq0P1uV51Igz34aKbYC1xd8jVJMW9vD+GA+/jtul+m41pSEhyGcN1+zaOpXEBqPM5TXVlwU11KYDQcSQ4ABaiUgAEwVuoZK HlK27ZinqzdOf/vnnKIbdvVRm9kcQQORTRJirc+kCwldsibO9bn95HzIoJ22tg9T7QqDcHPHi4j1lR0h5L4ylaD1BdLYVR0YfjHzL0gt9NM= X-Rspamd-Queue-Id: 4GtYZH5zwQz4RRY X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:51:52 -0000 In message <202108231334.17NDYHm1005889@gitrepo.freebsd.org>, Mateusz Guzik wri tes: > The branch main has been updated by mjg: > > URL: https://cgit.FreeBSD.org/src/commit/?id=b65ad70195d874ac28e6e65d2fd8acf5 > d9a79236 > > commit b65ad70195d874ac28e6e65d2fd8acf5d9a79236 > Author: Mateusz Guzik > AuthorDate: 2021-08-23 13:29:42 +0000 > Commit: Mateusz Guzik > CommitDate: 2021-08-23 13:31:44 +0000 > > cache: retire cache_fast_revlookup sysctl Why? > > Sponsored by: Rubicon Communications, LLC ("Netgate") > --- > sys/kern/vfs_cache.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c > index 199da865e39c..732dbbe53cef 100644 > --- a/sys/kern/vfs_cache.c > +++ b/sys/kern/vfs_cache.c > @@ -253,6 +253,8 @@ SDT_PROBE_DEFINE3(vfs, fplookup, lookup, done, "struct na > meidata", "int", "bool" > SDT_PROBE_DECLARE(vfs, namei, lookup, entry); > SDT_PROBE_DECLARE(vfs, namei, lookup, return); > > +static char __read_frequently cache_fast_lookup_enabled = true; > + > /* > * This structure describes the elements in the cache of recent > * names looked up by namei. > @@ -443,10 +445,6 @@ static u_long __exclusive_cache_line numcache;/* num > ber of cache entries allocat > > struct nchstats nchstats; /* cache effectiveness statisti > cs */ > > -static bool __read_frequently cache_fast_revlookup = true; > -SYSCTL_BOOL(_vfs, OID_AUTO, cache_fast_revlookup, CTLFLAG_RW, > - &cache_fast_revlookup, 0, ""); > - > static bool __read_mostly cache_rename_add = true; > SYSCTL_BOOL(_vfs, OID_AUTO, cache_rename_add, CTLFLAG_RW, > &cache_rename_add, 0, ""); > @@ -3440,7 +3438,7 @@ vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdi > r, char *buf, > > VFS_SMR_ASSERT_ENTERED(); > > - if (!cache_fast_revlookup) { > + if (!atomic_load_char(&cache_fast_lookup_enabled)) { > vfs_smr_exit(); > return (-1); > } > @@ -3845,7 +3843,6 @@ DB_SHOW_COMMAND(vpath, db_show_vpath) > #endif > > static int cache_fast_lookup = 1; > -static char __read_frequently cache_fast_lookup_enabled = true; > > #define CACHE_FPL_FAILED -2020 > > -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:52:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 329F866BF27; Mon, 23 Aug 2021 13:52: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 4GtYZb0tw2z4R2d; Mon, 23 Aug 2021 13:52: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 0756815936; Mon, 23 Aug 2021 13:52: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 17NDq6qU032346; Mon, 23 Aug 2021 13:52:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDq6Pb032345; Mon, 23 Aug 2021 13:52:06 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:52:06 GMT Message-Id: <202108231352.17NDq6Pb032345@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: bf530621e401 - stable/12 - pf: save on branching in the common case in pf_test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: bf530621e4019039cd123cac9b1f765eb5dc157b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:52:07 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=bf530621e4019039cd123cac9b1f765eb5dc157b commit bf530621e4019039cd123cac9b1f765eb5dc157b Author: Mateusz Guzik AuthorDate: 2021-08-17 18:04:31 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:47:35 +0000 pf: save on branching in the common case in pf_test Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 5091ca26507b83ebd5ce677dd26bd10e4bad4153) --- sys/netpfil/pf/pf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index f1b1890f50c5..ae2fdbc32401 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6235,7 +6235,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb * PF_RULES_RLOCK(); - if (ip_divert_ptr != NULL && + if (__predict_false(ip_divert_ptr != NULL) && ((ipfwtag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL)) != NULL)) { struct ipfw_rule_ref *rr = (struct ipfw_rule_ref *)(ipfwtag+1); if (rr->info & IPFW_IS_DIVERT && rr->rulenum == 0) { @@ -6505,9 +6505,8 @@ done: IN_LOOPBACK(ntohl(pd.dst->v4.s_addr))) m->m_flags |= M_SKIP_FIREWALL; - if (action == PF_PASS && r->divert.port && ip_divert_ptr != NULL && - !PACKET_LOOPED(&pd)) { - + if (__predict_false(ip_divert_ptr != NULL) && action == PF_PASS && + r->divert.port && !PACKET_LOOPED(&pd)) { ipfwtag = m_tag_alloc(MTAG_IPFW_RULE, 0, sizeof(struct ipfw_rule_ref), M_NOWAIT | M_ZERO); if (ipfwtag != NULL) { From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:52:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69E8C66BF2E; Mon, 23 Aug 2021 13:52: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 4GtYZc1yZJz4R2h; Mon, 23 Aug 2021 13:52: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 2AFBB157B7; Mon, 23 Aug 2021 13:52: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 17NDq8Kd032370; Mon, 23 Aug 2021 13:52:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDq81B032369; Mon, 23 Aug 2021 13:52:08 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:52:08 GMT Message-Id: <202108231352.17NDq81B032369@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: f978fe565e61 - stable/12 - pf: assert dir state on pf_test{,6} MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: f978fe565e61b0f76ad60fa53b8a3476e17d0f84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:52:08 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f978fe565e61b0f76ad60fa53b8a3476e17d0f84 commit f978fe565e61b0f76ad60fa53b8a3476e17d0f84 Author: Mateusz Guzik AuthorDate: 2021-08-17 18:16:09 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:49:17 +0000 pf: assert dir state on pf_test{,6} The intent is to line up various enums so that branching in the lines of: idx = (dir == PF_IN ? PF_SK_WIRE : PF_SK_STACK); is avoided. Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 3e875f952af05697807139b460e5124eb5f6137b) --- sys/netpfil/pf/pf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index ae2fdbc32401..a690029a1446 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6210,7 +6210,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb * int off, dirndx, pqid = 0; PF_RULES_RLOCK_TRACKER; - + KASSERT(dir == PF_IN || dir == PF_OUT, ("%s: bad direction %d\n", __func__, dir)); M_ASSERTPKTHDR(m); if (!V_pf_status.running) @@ -6661,6 +6661,7 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb int off, terminal = 0, dirndx, rh_cnt = 0, pqid = 0; PF_RULES_RLOCK_TRACKER; + KASSERT(dir == PF_IN || dir == PF_OUT, ("%s: bad direction %d\n", __func__, dir)); M_ASSERTPKTHDR(m); if (!V_pf_status.running) From owner-dev-commits-src-all@freebsd.org Mon Aug 23 13:57:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FD3866BDF3; Mon, 23 Aug 2021 13:57: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 4GtYhp0fRGz4Scy; Mon, 23 Aug 2021 13:57: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 EE9D515758; Mon, 23 Aug 2021 13:57:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NDvTA8032921; Mon, 23 Aug 2021 13:57:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NDvTwP032920; Mon, 23 Aug 2021 13:57:29 GMT (envelope-from git) Date: Mon, 23 Aug 2021 13:57:29 GMT Message-Id: <202108231357.17NDvTwP032920@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: ba32d146077e - stable/12 - arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ba32d146077e187464648456a516041b02c1a4ce Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 13:57:30 -0000 The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ba32d146077e187464648456a516041b02c1a4ce commit ba32d146077e187464648456a516041b02c1a4ce Author: Mateusz Guzik AuthorDate: 2021-07-21 03:34:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 13:56:20 +0000 arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS Stat collection using counter(9) is quite expensive on this platform and these counters are normally not needed. In particular we see about 1.5% bump in packet rate using Cortex-A9 Reviewed by: ian Sponsored by: Rubicon Communications, LLC ("Netgate") Different Revision: https://reviews.freebsd.org/D31592 (cherry picked from commit aec8ad8a9e6aba2d73c98bd41f2994744aae3d01) --- sys/arm/arm/busdma_machdep-v6.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/arm/arm/busdma_machdep-v6.c b/sys/arm/arm/busdma_machdep-v6.c index e54f3c0c7ca0..29547672651d 100644 --- a/sys/arm/arm/busdma_machdep-v6.c +++ b/sys/arm/arm/busdma_machdep-v6.c @@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$"); #include #include +//#define ARM_BUSDMA_MAPLOAD_STATS + #define BUSDMA_DCACHE_ALIGN cpuinfo.dcache_line_size #define BUSDMA_DCACHE_MASK cpuinfo.dcache_line_mask @@ -137,12 +139,14 @@ static uint32_t tags_total; static uint32_t maps_total; static uint32_t maps_dmamem; static uint32_t maps_coherent; +#ifdef ARM_BUSDMA_MAPLOAD_STATS static counter_u64_t maploads_total; static counter_u64_t maploads_bounced; static counter_u64_t maploads_coherent; static counter_u64_t maploads_dmamem; static counter_u64_t maploads_mbuf; static counter_u64_t maploads_physmem; +#endif static STAILQ_HEAD(, bounce_zone) bounce_zone_list; @@ -155,6 +159,7 @@ SYSCTL_UINT(_hw_busdma, OID_AUTO, maps_dmamem, CTLFLAG_RD, &maps_dmamem, 0, "Number of active maps for bus_dmamem_alloc buffers"); SYSCTL_UINT(_hw_busdma, OID_AUTO, maps_coherent, CTLFLAG_RD, &maps_coherent, 0, "Number of active maps with BUS_DMA_COHERENT flag set"); +#ifdef ARM_BUSDMA_MAPLOAD_STATS SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_total, CTLFLAG_RD, &maploads_total, "Number of load operations performed"); SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_bounced, CTLFLAG_RD, @@ -167,6 +172,7 @@ SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_mbuf, CTLFLAG_RD, &maploads_mbuf, "Number of load operations for mbufs"); SYSCTL_COUNTER_U64(_hw_busdma, OID_AUTO, maploads_physmem, CTLFLAG_RD, &maploads_physmem, "Number of load operations on physical buffers"); +#endif SYSCTL_INT(_hw_busdma, OID_AUTO, total_bpages, CTLFLAG_RD, &total_bpages, 0, "Total bounce pages"); @@ -219,12 +225,14 @@ busdma_init(void *dummy) { int uma_flags; +#ifdef ARM_BUSDMA_MAPLOAD_STATS maploads_total = counter_u64_alloc(M_WAITOK); maploads_bounced = counter_u64_alloc(M_WAITOK); maploads_coherent = counter_u64_alloc(M_WAITOK); maploads_dmamem = counter_u64_alloc(M_WAITOK); maploads_mbuf = counter_u64_alloc(M_WAITOK); maploads_physmem = counter_u64_alloc(M_WAITOK); +#endif uma_flags = 0; @@ -1036,13 +1044,17 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, if (segs == NULL) segs = map->segments; +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_total, 1); counter_u64_add(maploads_physmem, 1); +#endif if (might_bounce(dmat, map, (bus_addr_t)buf, buflen)) { _bus_dmamap_count_phys(dmat, map, buf, buflen, flags); if (map->pagesneeded != 0) { +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_bounced, 1); +#endif error = _bus_dmamap_reserve_pages(dmat, map, flags); if (error) return (error); @@ -1121,24 +1133,30 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, struct sync_list *sl; int error; +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_total, 1); if (map->flags & DMAMAP_COHERENT) counter_u64_add(maploads_coherent, 1); if (map->flags & DMAMAP_DMAMEM_ALLOC) counter_u64_add(maploads_dmamem, 1); +#endif if (segs == NULL) segs = map->segments; if (flags & BUS_DMA_LOAD_MBUF) { +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_mbuf, 1); +#endif map->flags |= DMAMAP_MBUF; } if (might_bounce(dmat, map, (bus_addr_t)buf, buflen)) { _bus_dmamap_count_pages(dmat, pmap, map, buf, buflen, flags); if (map->pagesneeded != 0) { +#ifdef ARM_BUSDMA_MAPLOAD_STATS counter_u64_add(maploads_bounced, 1); +#endif error = _bus_dmamap_reserve_pages(dmat, map, flags); if (error) return (error); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 14:45:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93DD066CE06; Mon, 23 Aug 2021 14:45: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 4GtZm83NwJz4gk9; Mon, 23 Aug 2021 14:45: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 5C51F1614B; Mon, 23 Aug 2021 14:45: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 17NEjS1o099145; Mon, 23 Aug 2021 14:45:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NEjSKw099144; Mon, 23 Aug 2021 14:45:28 GMT (envelope-from git) Date: Mon, 23 Aug 2021 14:45:28 GMT Message-Id: <202108231445.17NEjSKw099144@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 3cbf98e2bee9 - main - diff: read whole files to determine if they are ASCII text MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3cbf98e2bee91db9ed9118ff557e02cdd449f49a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 14:45:28 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=3cbf98e2bee91db9ed9118ff557e02cdd449f49a commit 3cbf98e2bee91db9ed9118ff557e02cdd449f49a Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-22 19:57:13 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-23 14:09:05 +0000 diff: read whole files to determine if they are ASCII text Before this change, only the first BUFSIZE bytes were checked. Reviewed by: bapt (previous version) Differential Revision: https://reviews.freebsd.org/D31639 --- usr.bin/diff/diffreg.c | 59 +++++++++++++++++++++++++---------------- usr.bin/diff/tests/diff_test.sh | 14 ++++++++++ 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 113b7b621256..e728441c2cb2 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -180,6 +180,8 @@ struct context_vec { int d; /* end line in new file */ }; +enum readhash { RH_BINARY, RH_OK, RH_EOF }; + #define MIN_PAD 1 static FILE *opentemp(const char *); static void output(char *, FILE *, char *, FILE *, int); @@ -188,7 +190,7 @@ static void range(int, int, const char *); static void uni_range(int, int); static void dump_context_vec(FILE *, FILE *, int); static void dump_unified_vec(FILE *, FILE *, int); -static void prepare(int, FILE *, size_t, int); +static bool prepare(int, FILE *, size_t, int); static void prune(void); static void equiv(struct line *, int, struct line *, int, int *); static void unravel(int); @@ -206,7 +208,7 @@ static int search(int *, int, int); static int skipline(FILE *); static int isqrt(int); static int stone(int *, int, int *, int *, int); -static int readhash(FILE *, int); +static enum readhash readhash(FILE *, int, unsigned *); static int files_differ(FILE *, FILE *, int); static char *match_function(const long *, int, FILE *); static char *preadline(int, size_t, off_t); @@ -380,14 +382,16 @@ diffreg(char *file1, char *file2, int flags, int capsicum) status |= 1; goto closem; } - if ((flags & D_FORCEASCII) == 0 && - (!asciifile(f1) || !asciifile(f2))) { + if ((flags & D_FORCEASCII) != 0) { + (void)prepare(0, f1, stb1.st_size, flags); + (void)prepare(1, f2, stb2.st_size, flags); + } else if (!asciifile(f1) || !asciifile(f2) || + !prepare(0, f1, stb1.st_size, flags) || + !prepare(1, f2, stb2.st_size, flags)) { rval = D_BINARY; status |= 1; goto closem; } - prepare(0, f1, stb1.st_size, flags); - prepare(1, f2, stb2.st_size, flags); prune(); sort(sfile[0], slen[0]); @@ -511,12 +515,13 @@ splice(char *dir, char *path) return (buf); } -static void +static bool prepare(int i, FILE *fd, size_t filesize, int flags) { struct line *p; - int h; - size_t sz, j; + unsigned h; + size_t sz, j = 0; + enum readhash r; rewind(fd); @@ -525,15 +530,23 @@ prepare(int i, FILE *fd, size_t filesize, int flags) sz = 100; p = xcalloc(sz + 3, sizeof(*p)); - for (j = 0; (h = readhash(fd, flags));) { - if (j == sz) { - sz = sz * 3 / 2; - p = xreallocarray(p, sz + 3, sizeof(*p)); + while ((r = readhash(fd, flags, &h)) != RH_EOF) + switch (r) { + case RH_EOF: /* otherwise clang complains */ + case RH_BINARY: + return (false); + case RH_OK: + if (j == sz) { + sz = sz * 3 / 2; + p = xreallocarray(p, sz + 3, sizeof(*p)); + } + p[++j].value = h; } - p[++j].value = h; - } + len[i] = j; file[i] = p; + + return (true); } static void @@ -1350,8 +1363,8 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags) /* * Hash function taken from Robert Sedgewick, Algorithms in C, 3d ed., p 578. */ -static int -readhash(FILE *f, int flags) +static enum readhash +readhash(FILE *f, int flags, unsigned *hash) { int i, t, space; unsigned sum; @@ -1360,6 +1373,9 @@ readhash(FILE *f, int flags) space = 0; for (i = 0;;) { switch (t = getc(f)) { + case '\0': + if ((flags & D_FORCEASCII) == 0) + return (RH_BINARY); case '\r': if (flags & D_STRIPCR) { t = getc(f); @@ -1387,18 +1403,15 @@ readhash(FILE *f, int flags) continue; case EOF: if (i == 0) - return (0); + return (RH_EOF); /* FALLTHROUGH */ case '\n': break; } break; } - /* - * There is a remote possibility that we end up with a zero sum. - * Zero is used as an EOF marker, so return 1 instead. - */ - return (sum == 0 ? 1 : sum); + *hash = sum; + return (RH_OK); } static int diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh index b8b7fe1d8068..4f73b23d686a 100755 --- a/usr.bin/diff/tests/diff_test.sh +++ b/usr.bin/diff/tests/diff_test.sh @@ -18,6 +18,7 @@ atf_test_case conflicting_format atf_test_case label atf_test_case report_identical atf_test_case non_regular_file +atf_test_case binary simple_body() { @@ -265,6 +266,18 @@ non_regular_file_body() diff --label A --label B -u A B } +binary_body() +{ + # the NUL byte has to be after at least BUFSIZ bytes to trick asciifile() + yes 012345678901234567890123456789012345678901234567890 | head -n 174 > A + cp A B + printf '\n\0\n' >> A + printf '\nx\n' >> B + + atf_check -o inline:"Binary files A and B differ\n" -s exit:1 diff A B + atf_check -o inline:"176c\nx\n.\n" -s exit:1 diff -ae A B +} + atf_init_test_cases() { atf_add_test_case simple @@ -285,4 +298,5 @@ atf_init_test_cases() atf_add_test_case label atf_add_test_case report_identical atf_add_test_case non_regular_file + atf_add_test_case binary } From owner-dev-commits-src-all@freebsd.org Mon Aug 23 15:38:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9D6D966D1DB; Mon, 23 Aug 2021 15:38: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 4Gtbx13r7Bz3DQL; Mon, 23 Aug 2021 15:38: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 6CA7A16BAE; Mon, 23 Aug 2021 15:38: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 17NFcDHG066184; Mon, 23 Aug 2021 15:38:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NFcDnT066183; Mon, 23 Aug 2021 15:38:13 GMT (envelope-from git) Date: Mon, 23 Aug 2021 15:38:13 GMT Message-Id: <202108231538.17NFcDnT066183@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: b98f2ec0d635 - stable/13 - libpfctl: Fix endianness issues 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: b98f2ec0d635639987dcb6c6261f9013b35c3777 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 15:38:13 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b98f2ec0d635639987dcb6c6261f9013b35c3777 commit b98f2ec0d635639987dcb6c6261f9013b35c3777 Author: Kristof Provost AuthorDate: 2021-08-20 11:43:15 +0000 Commit: Kristof Provost CommitDate: 2021-08-23 14:19:39 +0000 libpfctl: Fix endianness issues Several fields are supplied in big-endian format, so we need to convert them before we display them. MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 719b5397c2887bc0619bb6ffb38f67f37bbf13c6) --- lib/libpfctl/libpfctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index ced130820d7d..7f1e72513018 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -671,11 +671,11 @@ pf_state_export_to_state(struct pfctl_state *ps, const struct pf_state_export *s pf_state_peer_export_to_state_peer(&ps->src, &s->src); pf_state_peer_export_to_state_peer(&ps->dst, &s->dst); bcopy(&s->rt_addr, &ps->rt_addr, sizeof(ps->rt_addr)); - ps->rule = s->rule; - ps->anchor = s->anchor; - ps->nat_rule = s->nat_rule; - ps->creation = s->creation; - ps->expire = s->expire; + ps->rule = ntohl(s->rule); + ps->anchor = ntohl(s->anchor); + ps->nat_rule = ntohl(s->nat_rule); + ps->creation = ntohl(s->creation); + ps->expire = ntohl(s->expire); ps->packets[0] = s->packets[0]; ps->packets[1] = s->packets[1]; ps->bytes[0] = s->bytes[0]; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 15:38:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 473C466D1DD; Mon, 23 Aug 2021 15:38: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 4Gtbx21RGTz3DVL; Mon, 23 Aug 2021 15:38: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 19E3716AE1; Mon, 23 Aug 2021 15:38: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 17NFcEXH066264; Mon, 23 Aug 2021 15:38:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NFcEpl066263; Mon, 23 Aug 2021 15:38:14 GMT (envelope-from git) Date: Mon, 23 Aug 2021 15:38:14 GMT Message-Id: <202108231538.17NFcEpl066263@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: 956b3ddd6399 - stable/12 - libpfctl: Fix endianness issues 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: 956b3ddd63993ae0f0df968ff9f40e9b0286fc77 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 15:38:14 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=956b3ddd63993ae0f0df968ff9f40e9b0286fc77 commit 956b3ddd63993ae0f0df968ff9f40e9b0286fc77 Author: Kristof Provost AuthorDate: 2021-08-20 11:43:15 +0000 Commit: Kristof Provost CommitDate: 2021-08-23 14:25:28 +0000 libpfctl: Fix endianness issues Several fields are supplied in big-endian format, so we need to convert them before we display them. MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 719b5397c2887bc0619bb6ffb38f67f37bbf13c6) --- lib/libpfctl/libpfctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index ced130820d7d..7f1e72513018 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -671,11 +671,11 @@ pf_state_export_to_state(struct pfctl_state *ps, const struct pf_state_export *s pf_state_peer_export_to_state_peer(&ps->src, &s->src); pf_state_peer_export_to_state_peer(&ps->dst, &s->dst); bcopy(&s->rt_addr, &ps->rt_addr, sizeof(ps->rt_addr)); - ps->rule = s->rule; - ps->anchor = s->anchor; - ps->nat_rule = s->nat_rule; - ps->creation = s->creation; - ps->expire = s->expire; + ps->rule = ntohl(s->rule); + ps->anchor = ntohl(s->anchor); + ps->nat_rule = ntohl(s->nat_rule); + ps->creation = ntohl(s->creation); + ps->expire = ntohl(s->expire); ps->packets[0] = s->packets[0]; ps->packets[1] = s->packets[1]; ps->bytes[0] = s->bytes[0]; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 16:12:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA89566CD73; Mon, 23 Aug 2021 16:12: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 4Gtchl41YCz3Nyb; Mon, 23 Aug 2021 16:12:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6480E176C5; Mon, 23 Aug 2021 16:12: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 17NGCd13019150; Mon, 23 Aug 2021 16:12:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGCdxt019149; Mon, 23 Aug 2021 16:12:39 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:12:39 GMT Message-Id: <202108231612.17NGCdxt019149@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 44056f9a7278 - main - riscv: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 44056f9a72786b24a1ff83649b5a13141be1de84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:12:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=44056f9a72786b24a1ff83649b5a13141be1de84 commit 44056f9a72786b24a1ff83649b5a13141be1de84 Author: Mateusz Guzik AuthorDate: 2021-08-23 15:29:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 16:11:18 +0000 riscv: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: mhorne Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/files.riscv | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index d46d520bd0b7..c5eef10f3519 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -21,7 +21,6 @@ kern/subr_devmap.c standard kern/subr_dummy_vdso_tc.c standard kern/subr_intr.c standard kern/subr_physmem.c standard -libkern/bcmp.c standard libkern/bcopy.c standard libkern/ffs.c standard libkern/ffsl.c standard From owner-dev-commits-src-all@freebsd.org Mon Aug 23 16:12:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7D3166D93F; Mon, 23 Aug 2021 16:12: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 4Gtchm538gz3Nyj; Mon, 23 Aug 2021 16:12: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 8E495176C6; Mon, 23 Aug 2021 16:12: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 17NGCeSc019175; Mon, 23 Aug 2021 16:12:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGCeSM019174; Mon, 23 Aug 2021 16:12:40 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:12:40 GMT Message-Id: <202108231612.17NGCeSM019174@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 451756d1baa8 - main - powerpc: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 451756d1baa8c4e4d1f282dd7bbc05e09cd9d5e5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:12:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=451756d1baa8c4e4d1f282dd7bbc05e09cd9d5e5 commit 451756d1baa8c4e4d1f282dd7bbc05e09cd9d5e5 Author: Mateusz Guzik AuthorDate: 2021-08-23 15:35:28 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 16:11:56 +0000 powerpc: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: jhibbits Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/files.powerpc | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index a57367a23017..5d10740ce41d 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -117,7 +117,6 @@ kern/syscalls.c optional ktr kern/subr_sfbuf.c standard libkern/ashldi3.c optional powerpc | powerpcspe libkern/ashrdi3.c optional powerpc | powerpcspe -libkern/bcmp.c standard libkern/bcopy.c standard libkern/cmpdi2.c optional powerpc | powerpcspe libkern/divdi3.c optional powerpc | powerpcspe From owner-dev-commits-src-all@freebsd.org Mon Aug 23 16:12:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DD47766D6FA; Mon, 23 Aug 2021 16:12: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 4Gtchn5lYgz3P5y; Mon, 23 Aug 2021 16:12: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 AB4E917445; Mon, 23 Aug 2021 16:12: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 17NGCfnK019199; Mon, 23 Aug 2021 16:12:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGCfYu019198; Mon, 23 Aug 2021 16:12:41 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:12:41 GMT Message-Id: <202108231612.17NGCfYu019198@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 362c5920da56 - main - Remove libkern/bcmp.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 362c5920da56964516ea77e29692857c05c096f7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:12:42 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=362c5920da56964516ea77e29692857c05c096f7 commit 362c5920da56964516ea77e29692857c05c096f7 Author: Mateusz Guzik AuthorDate: 2021-08-23 15:40:57 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 16:12:12 +0000 Remove libkern/bcmp.c The kernel was migrated to memcmp in ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") and there are no remaining architectures using the file. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/libkern/bcmp.c | 146 ----------------------------------------------------- sys/sys/systm.h | 1 - 2 files changed, 147 deletions(-) diff --git a/sys/libkern/bcmp.c b/sys/libkern/bcmp.c deleted file mode 100644 index 40ef39953c86..000000000000 --- a/sys/libkern/bcmp.c +++ /dev/null @@ -1,146 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -typedef const void *cvp; -typedef const unsigned char *ustring; -typedef unsigned long ul; -typedef const unsigned long *culp; - -/* - * bcmp -- vax cmpc3 instruction - */ -int -(bcmp)(const void *b1, const void *b2, size_t length) -{ -#if BYTE_ORDER == LITTLE_ENDIAN - /* - * The following code is endian specific. Changing it from - * little-endian to big-endian is fairly trivial, but making - * it do both is more difficult. - * - * Note that this code will reference the entire longword which - * includes the final byte to compare. I don't believe this is - * a problem since AFAIK, objects are not protected at smaller - * than longword boundaries. - */ - int shl, shr, len = length; - ustring p1 = b1, p2 = b2; - ul va, vb; - - if (len == 0) - return (0); - - /* - * align p1 to a longword boundary - */ - while ((long)p1 & (sizeof(long) - 1)) { - if (*p1++ != *p2++) - return (1); - if (--len <= 0) - return (0); - } - - /* - * align p2 to longword boundary and calculate the shift required to - * align p1 and p2 - */ - shr = (long)p2 & (sizeof(long) - 1); - if (shr != 0) { - p2 -= shr; /* p2 now longword aligned */ - shr <<= 3; /* offset in bits */ - shl = (sizeof(long) << 3) - shr; - - va = *(culp)p2; - p2 += sizeof(long); - - while ((len -= sizeof(long)) >= 0) { - vb = *(culp)p2; - p2 += sizeof(long); - if (*(culp)p1 != (va >> shr | vb << shl)) - return (1); - p1 += sizeof(long); - va = vb; - } - /* - * At this point, len is between -sizeof(long) and -1, - * representing 0 .. sizeof(long)-1 bytes remaining. - */ - if (!(len += sizeof(long))) - return (0); - - len <<= 3; /* remaining length in bits */ - /* - * The following is similar to the `if' condition - * inside the above while loop. The ?: is necessary - * to avoid accessing the longword after the longword - * containing the last byte to be compared. - */ - return ((((va >> shr | ((shl < len) ? *(culp)p2 << shl : 0)) ^ - *(culp)p1) & ((1L << len) - 1)) != 0); - } else { - /* p1 and p2 have common alignment so no shifting needed */ - while ((len -= sizeof(long)) >= 0) { - if (*(culp)p1 != *(culp)p2) - return (1); - p1 += sizeof(long); - p2 += sizeof(long); - } - - /* - * At this point, len is between -sizeof(long) and -1, - * representing 0 .. sizeof(long)-1 bytes remaining. - */ - if (!(len += sizeof(long))) - return (0); - - return (((*(culp)p1 ^ *(culp)p2) - & ((1L << (len << 3)) - 1)) != 0); - } -#else - const char *p1, *p2; - - if (length == 0) - return(0); - p1 = b1; - p2 = b2; - do - if (*p1++ != *p2++) - break; - while (--length); - return(length); -#endif -} diff --git a/sys/sys/systm.h b/sys/sys/systm.h index da20492966cd..1be8f1ac49be 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -344,7 +344,6 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags); void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); void bzero(void * _Nonnull buf, size_t len); void explicit_bzero(void * _Nonnull, size_t); -int bcmp(const void *b1, const void *b2, size_t len); void *memset(void * _Nonnull buf, int c, size_t len); void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 16:24:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 045CF66DF3F; Mon, 23 Aug 2021 16:24: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 4GtcyT6hCYz3h2J; Mon, 23 Aug 2021 16:24: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 CDCA017174; Mon, 23 Aug 2021 16:24: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 17NGOXIL032406; Mon, 23 Aug 2021 16:24:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGOXtw032405; Mon, 23 Aug 2021 16:24:33 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:24:33 GMT Message-Id: <202108231624.17NGOXtw032405@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 1a72c3d76aea - stable/13 - e1000: always enable PCSD when RSS hashing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1a72c3d76aeafe4422ff20f81c4142efb983b7d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:24:34 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=1a72c3d76aeafe4422ff20f81c4142efb983b7d7 commit 1a72c3d76aeafe4422ff20f81c4142efb983b7d7 Author: Kevin Bowling AuthorDate: 2021-08-16 17:17:34 +0000 Commit: Kevin Bowling CommitDate: 2021-08-23 16:23:43 +0000 e1000: always enable PCSD when RSS hashing To enable RSS hashing in the NIC, the PCSD bit must be set. By default, this is never set when RXCSUM is disabled - which causes problems higher up in the stack. While here improve the RXCSUM flag assignments when enabling or disabling IFCAP_RXCSUM. See also: https://lists.freebsd.org/pipermail/freebsd-current/2020-May/076148.html Reviewed by: markj, Franco Fichtner , Stephan de Wit Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31501 Co-authored-by: Stephan de Wit Co-authored-by: Franco Fichtner (cherry picked from commit 69e8e8ea3d4be9da6b5bc904a444b51958128ff5) --- sys/dev/e1000/e1000_82575.h | 3 +-- sys/dev/e1000/e1000_defines.h | 11 ++++++----- sys/dev/e1000/if_em.c | 44 ++++++++++++++++++++----------------------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/sys/dev/e1000/e1000_82575.h b/sys/dev/e1000/e1000_82575.h index a96b25f4169d..36045556661b 100644 --- a/sys/dev/e1000/e1000_82575.h +++ b/sys/dev/e1000/e1000_82575.h @@ -143,13 +143,12 @@ struct e1000_adv_context_desc { #define E1000_TX_HEAD_WB_ENABLE 0x1 #define E1000_TX_SEQNUM_WB_ENABLE 0x2 -#define E1000_MRQC_ENABLE_RSS_4Q 0x00000002 +#define E1000_MRQC_ENABLE_RSS_MQ 0x00000002 #define E1000_MRQC_ENABLE_VMDQ 0x00000003 #define E1000_MRQC_ENABLE_VMDQ_RSS_2Q 0x00000005 #define E1000_MRQC_RSS_FIELD_IPV4_UDP 0x00400000 #define E1000_MRQC_RSS_FIELD_IPV6_UDP 0x00800000 #define E1000_MRQC_RSS_FIELD_IPV6_UDP_EX 0x01000000 -#define E1000_MRQC_ENABLE_RSS_8Q 0x00000002 #define E1000_VMRCTL_MIRROR_PORT_SHIFT 8 #define E1000_VMRCTL_MIRROR_DSTPORT_MASK (7 << \ diff --git a/sys/dev/e1000/e1000_defines.h b/sys/dev/e1000/e1000_defines.h index 722596b36e34..262b01dd5b64 100644 --- a/sys/dev/e1000/e1000_defines.h +++ b/sys/dev/e1000/e1000_defines.h @@ -428,11 +428,12 @@ #define E1000_SCTL_ENABLE_SERDES_LOOPBACK 0x0410 /* Receive Checksum Control */ -#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */ -#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */ -#define E1000_RXCSUM_CRCOFL 0x00000800 /* CRC32 offload enable */ -#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ -#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */ +#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */ +#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */ +#define E1000_RXCSUM_IPV6OFL 0x00000400 /* lem(4) IPv6 checksum offload */ +#define E1000_RXCSUM_CRCOFL 0x00000800 /* CRC32 offload enable */ +#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ +#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */ /* Header split receive */ #define E1000_RFCTL_NFSW_DIS 0x00000040 diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 33d5341ed8ce..3f748b6bcacd 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -2838,7 +2838,7 @@ igb_initialize_rss_mapping(struct adapter *adapter) * MRQC: Multiple Receive Queues Command * Set queuing to RSS control, number depends on the device. */ - mrqc = E1000_MRQC_ENABLE_RSS_8Q; + mrqc = E1000_MRQC_ENABLE_RSS_MQ; #ifdef RSS /* XXX ew typecasting */ @@ -3245,37 +3245,33 @@ em_initialize_receive_unit(if_ctx_t ctx) E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); } + /* Set up L3 and L4 csum Rx descriptor offloads */ rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); - if (if_getcapenable(ifp) & IFCAP_RXCSUM && - hw->mac.type >= e1000_82543) { - if (adapter->tx_num_queues > 1) { - if (hw->mac.type >= igb_mac_min) { - rxcsum |= E1000_RXCSUM_PCSD; - if (hw->mac.type != e1000_82575) - rxcsum |= E1000_RXCSUM_CRCOFL; - } else - rxcsum |= E1000_RXCSUM_TUOFL | - E1000_RXCSUM_IPOFL | - E1000_RXCSUM_PCSD; - } else { - if (hw->mac.type >= igb_mac_min) - rxcsum |= E1000_RXCSUM_IPPCSE; - else - rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPOFL; - if (hw->mac.type > e1000_82575) - rxcsum |= E1000_RXCSUM_CRCOFL; - } - } else - rxcsum &= ~E1000_RXCSUM_TUOFL; - - E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum); + if (scctx->isc_capenable & IFCAP_RXCSUM) { + rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPOFL; + if (hw->mac.type > e1000_82575) + rxcsum |= E1000_RXCSUM_CRCOFL; + else if (hw->mac.type < em_mac_min && + scctx->isc_capenable & IFCAP_HWCSUM_IPV6) + rxcsum |= E1000_RXCSUM_IPV6OFL; + } else { + rxcsum &= ~(E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); + if (hw->mac.type > e1000_82575) + rxcsum &= ~E1000_RXCSUM_CRCOFL; + else if (hw->mac.type < em_mac_min) + rxcsum &= ~E1000_RXCSUM_IPV6OFL; + } if (adapter->rx_num_queues > 1) { + /* RSS hash needed in the Rx descriptor */ + rxcsum |= E1000_RXCSUM_PCSD; + if (hw->mac.type >= igb_mac_min) igb_initialize_rss_mapping(adapter); else em_initialize_rss_mapping(adapter); } + E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum); /* * XXX TEMPORARY WORKAROUND: on some systems with 82573 From owner-dev-commits-src-all@freebsd.org Mon Aug 23 16:26:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8FA4E66E20C; Mon, 23 Aug 2021 16:26:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gtd183cvNz3j1M; Mon, 23 Aug 2021 16:26: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 5592D17555; Mon, 23 Aug 2021 16:26: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 17NGQq5I032671; Mon, 23 Aug 2021 16:26:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGQqjU032670; Mon, 23 Aug 2021 16:26:52 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:26:52 GMT Message-Id: <202108231626.17NGQqjU032670@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: e6c2f46affca - stable/12 - e1000: always enable PCSD when RSS hashing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e6c2f46affca13b6ff2ca7c3355376aac94b41d1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:26:52 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=e6c2f46affca13b6ff2ca7c3355376aac94b41d1 commit e6c2f46affca13b6ff2ca7c3355376aac94b41d1 Author: Kevin Bowling AuthorDate: 2021-08-16 17:17:34 +0000 Commit: Kevin Bowling CommitDate: 2021-08-23 16:26:17 +0000 e1000: always enable PCSD when RSS hashing To enable RSS hashing in the NIC, the PCSD bit must be set. By default, this is never set when RXCSUM is disabled - which causes problems higher up in the stack. While here improve the RXCSUM flag assignments when enabling or disabling IFCAP_RXCSUM. See also: https://lists.freebsd.org/pipermail/freebsd-current/2020-May/076148.html Reviewed by: markj, Franco Fichtner , Stephan de Wit Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31501 Co-authored-by: Stephan de Wit Co-authored-by: Franco Fichtner (cherry picked from commit 69e8e8ea3d4be9da6b5bc904a444b51958128ff5) --- sys/dev/e1000/e1000_82575.h | 3 +-- sys/dev/e1000/e1000_defines.h | 11 ++++++----- sys/dev/e1000/if_em.c | 44 ++++++++++++++++++++----------------------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/sys/dev/e1000/e1000_82575.h b/sys/dev/e1000/e1000_82575.h index a96b25f4169d..36045556661b 100644 --- a/sys/dev/e1000/e1000_82575.h +++ b/sys/dev/e1000/e1000_82575.h @@ -143,13 +143,12 @@ struct e1000_adv_context_desc { #define E1000_TX_HEAD_WB_ENABLE 0x1 #define E1000_TX_SEQNUM_WB_ENABLE 0x2 -#define E1000_MRQC_ENABLE_RSS_4Q 0x00000002 +#define E1000_MRQC_ENABLE_RSS_MQ 0x00000002 #define E1000_MRQC_ENABLE_VMDQ 0x00000003 #define E1000_MRQC_ENABLE_VMDQ_RSS_2Q 0x00000005 #define E1000_MRQC_RSS_FIELD_IPV4_UDP 0x00400000 #define E1000_MRQC_RSS_FIELD_IPV6_UDP 0x00800000 #define E1000_MRQC_RSS_FIELD_IPV6_UDP_EX 0x01000000 -#define E1000_MRQC_ENABLE_RSS_8Q 0x00000002 #define E1000_VMRCTL_MIRROR_PORT_SHIFT 8 #define E1000_VMRCTL_MIRROR_DSTPORT_MASK (7 << \ diff --git a/sys/dev/e1000/e1000_defines.h b/sys/dev/e1000/e1000_defines.h index db7659e8d04f..43de1047ed0e 100644 --- a/sys/dev/e1000/e1000_defines.h +++ b/sys/dev/e1000/e1000_defines.h @@ -428,11 +428,12 @@ #define E1000_SCTL_ENABLE_SERDES_LOOPBACK 0x0410 /* Receive Checksum Control */ -#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */ -#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */ -#define E1000_RXCSUM_CRCOFL 0x00000800 /* CRC32 offload enable */ -#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ -#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */ +#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */ +#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */ +#define E1000_RXCSUM_IPV6OFL 0x00000400 /* lem(4) IPv6 checksum offload */ +#define E1000_RXCSUM_CRCOFL 0x00000800 /* CRC32 offload enable */ +#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ +#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */ /* Header split receive */ #define E1000_RFCTL_NFSW_DIS 0x00000040 diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 74641acbb3b3..b7adc5bdab6c 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -2828,7 +2828,7 @@ igb_initialize_rss_mapping(struct adapter *adapter) * MRQC: Multiple Receive Queues Command * Set queuing to RSS control, number depends on the device. */ - mrqc = E1000_MRQC_ENABLE_RSS_8Q; + mrqc = E1000_MRQC_ENABLE_RSS_MQ; #ifdef RSS /* XXX ew typecasting */ @@ -3241,37 +3241,33 @@ em_initialize_receive_unit(if_ctx_t ctx) E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); } + /* Set up L3 and L4 csum Rx descriptor offloads */ rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); - if (if_getcapenable(ifp) & IFCAP_RXCSUM && - hw->mac.type >= e1000_82543) { - if (adapter->tx_num_queues > 1) { - if (hw->mac.type >= igb_mac_min) { - rxcsum |= E1000_RXCSUM_PCSD; - if (hw->mac.type != e1000_82575) - rxcsum |= E1000_RXCSUM_CRCOFL; - } else - rxcsum |= E1000_RXCSUM_TUOFL | - E1000_RXCSUM_IPOFL | - E1000_RXCSUM_PCSD; - } else { - if (hw->mac.type >= igb_mac_min) - rxcsum |= E1000_RXCSUM_IPPCSE; - else - rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPOFL; - if (hw->mac.type > e1000_82575) - rxcsum |= E1000_RXCSUM_CRCOFL; - } - } else - rxcsum &= ~E1000_RXCSUM_TUOFL; - - E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum); + if (scctx->isc_capenable & IFCAP_RXCSUM) { + rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPOFL; + if (hw->mac.type > e1000_82575) + rxcsum |= E1000_RXCSUM_CRCOFL; + else if (hw->mac.type < em_mac_min && + scctx->isc_capenable & IFCAP_HWCSUM_IPV6) + rxcsum |= E1000_RXCSUM_IPV6OFL; + } else { + rxcsum &= ~(E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); + if (hw->mac.type > e1000_82575) + rxcsum &= ~E1000_RXCSUM_CRCOFL; + else if (hw->mac.type < em_mac_min) + rxcsum &= ~E1000_RXCSUM_IPV6OFL; + } if (adapter->rx_num_queues > 1) { + /* RSS hash needed in the Rx descriptor */ + rxcsum |= E1000_RXCSUM_PCSD; + if (hw->mac.type >= igb_mac_min) igb_initialize_rss_mapping(adapter); else em_initialize_rss_mapping(adapter); } + E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum); /* * XXX TEMPORARY WORKAROUND: on some systems with 82573 From owner-dev-commits-src-all@freebsd.org Mon Aug 23 16:30:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9FEE766E057; Mon, 23 Aug 2021 16:30: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 4Gtd4y4742z3jBJ; Mon, 23 Aug 2021 16:30:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 75D93177D8; Mon, 23 Aug 2021 16:30:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NGUAuK036202; Mon, 23 Aug 2021 16:30:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NGUABj036199; Mon, 23 Aug 2021 16:30:10 GMT (envelope-from git) Date: Mon, 23 Aug 2021 16:30:10 GMT Message-Id: <202108231630.17NGUABj036199@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: e0eba8c70dd3 - stable/12 - igc: sync igc_txrx with igb(4) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e0eba8c70dd351e6250e095d48ce6c93d5ded221 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 16:30:10 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=e0eba8c70dd351e6250e095d48ce6c93d5ded221 commit e0eba8c70dd351e6250e095d48ce6c93d5ded221 Author: Kevin Bowling AuthorDate: 2021-07-31 15:00:16 +0000 Commit: Kevin Bowling CommitDate: 2021-08-23 16:29:35 +0000 igc: sync igc_txrx with igb(4) Reviewed by: grehan MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31227 (cherry picked from commit d02e436353d292e6fd50f70ea80507095543764e) --- sys/dev/igc/igc_txrx.c | 92 +++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/sys/dev/igc/igc_txrx.c b/sys/dev/igc/igc_txrx.c index 2636aa77069a..ee4d5a5c0c6b 100644 --- a/sys/dev/igc/igc_txrx.c +++ b/sys/dev/igc/igc_txrx.c @@ -52,16 +52,20 @@ static int igc_isc_txd_credits_update(void *arg, uint16_t txqid, bool clear); static void igc_isc_rxd_refill(void *arg, if_rxd_update_t iru); -static void igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, qidx_t pidx); -static int igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget); +static void igc_isc_rxd_flush(void *arg, uint16_t rxqid, uint8_t flid __unused, + qidx_t pidx); +static int igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, + qidx_t budget); static int igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri); -static int igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status); -static int igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status); +static int igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, + uint32_t *cmd_type_len, uint32_t *olinfo_status); +static int igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, + uint32_t *cmd_type_len, uint32_t *olinfo_status); -static void igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype); -static int igc_determine_rsstype(u16 pkt_info); +static void igc_rx_checksum(uint32_t staterr, if_rxd_info_t ri, uint32_t ptype); +static int igc_determine_rsstype(uint16_t pkt_info); extern void igc_if_enable_intr(if_ctx_t ctx); extern int igc_intr(void *arg); @@ -119,12 +123,13 @@ igc_dump_rs(struct igc_adapter *adapter) * **********************************************************************/ static int -igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status) +igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, uint32_t *cmd_type_len, + uint32_t *olinfo_status) { struct igc_adv_tx_context_desc *TXD; - u32 type_tucmd_mlhl = 0, vlan_macip_lens = 0; - u32 mss_l4len_idx = 0; - u32 paylen; + uint32_t type_tucmd_mlhl = 0, vlan_macip_lens = 0; + uint32_t mss_l4len_idx = 0; + uint32_t paylen; switch(pi->ipi_etype) { case ETHERTYPE_IPV6: @@ -179,11 +184,12 @@ igc_tso_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *oli * **********************************************************************/ static int -igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 *olinfo_status) +igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, uint32_t *cmd_type_len, + uint32_t *olinfo_status) { struct igc_adv_tx_context_desc *TXD; - u32 vlan_macip_lens, type_tucmd_mlhl; - u32 mss_l4len_idx; + uint32_t vlan_macip_lens, type_tucmd_mlhl; + uint32_t mss_l4len_idx; mss_l4len_idx = vlan_macip_lens = type_tucmd_mlhl = 0; /* First check if TSO is to be used */ @@ -242,7 +248,7 @@ igc_tx_ctx_setup(struct tx_ring *txr, if_pkt_info_t pi, u32 *cmd_type_len, u32 * type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_L4T_SCTP; *olinfo_status |= IGC_TXD_POPTS_TXSM << 8; } - break; + break; default: break; } @@ -267,7 +273,7 @@ igc_isc_txd_encap(void *arg, if_pkt_info_t pi) bus_dma_segment_t *segs = pi->ipi_segs; union igc_adv_tx_desc *txd = NULL; int i, j, pidx_last; - u32 olinfo_status, cmd_type_len, txd_flags; + uint32_t olinfo_status, cmd_type_len, txd_flags; qidx_t ntxd; pidx_last = olinfo_status = 0; @@ -422,7 +428,7 @@ igc_isc_rxd_available(void *arg, uint16_t rxqid, qidx_t idx, qidx_t budget) struct igc_rx_queue *que = &sc->rx_queues[rxqid]; struct rx_ring *rxr = &que->rxr; union igc_adv_rx_desc *rxd; - u32 staterr = 0; + uint32_t staterr = 0; int cnt, i; for (cnt = 0, i = idx; cnt < scctx->isc_nrxd[0] && cnt <= budget;) { @@ -453,16 +459,15 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) if_softc_ctx_t scctx = adapter->shared; struct igc_rx_queue *que = &adapter->rx_queues[ri->iri_qsidx]; struct rx_ring *rxr = &que->rxr; - struct ifnet *ifp = iflib_get_ifp(adapter->ctx); union igc_adv_rx_desc *rxd; - u16 pkt_info, len; - u16 vtag = 0; - u32 ptype; - u32 staterr = 0; + uint16_t pkt_info, len, vtag; + uint32_t ptype, staterr; + int i, cidx; bool eop; - int i = 0; - int cidx = ri->iri_cidx; + + staterr = i = vtag = 0; + cidx = ri->iri_cidx; do { rxd = (union igc_adv_rx_desc *)&rxr->rx_base[cidx]; @@ -507,14 +512,15 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) rxr->rx_packets++; - if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) + if ((scctx->isc_capenable & IFCAP_RXCSUM) != 0) igc_rx_checksum(staterr, ri, ptype); - if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 && + if ((scctx->isc_capenable & IFCAP_VLAN_HWTAGGING) != 0 && (staterr & IGC_RXD_STAT_VP) != 0) { ri->iri_vtag = vtag; ri->iri_flags |= M_VLANTAG; } + ri->iri_flowid = le32toh(rxd->wb.lower.hi_dword.rss); ri->iri_rsstype = igc_determine_rsstype(pkt_info); @@ -531,26 +537,34 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) * *********************************************************************/ static void -igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype) +igc_rx_checksum(uint32_t staterr, if_rxd_info_t ri, uint32_t ptype) { - u16 status = (u16)staterr; - u8 errors = (u8) (staterr >> 24); + uint16_t status = (uint16_t)staterr; + uint8_t errors = (uint8_t)(staterr >> 24); - /* Ignore Checksum bit is set */ - if (status & IGC_RXD_STAT_IXSM) { - ri->iri_csum_flags = 0; + if (__predict_false(status & IGC_RXD_STAT_IXSM)) return; - } - if (status & (IGC_RXD_STAT_TCPCS | IGC_RXD_STAT_UDPCS)) { - u64 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - /* Did it pass? */ - if (!(errors & IGC_RXD_ERR_TCPE)) { - ri->iri_csum_flags |= type; + /* If there is a layer 3 or 4 error we are done */ + if (__predict_false(errors & (IGC_RXD_ERR_IPE | IGC_RXD_ERR_TCPE))) + return; + + /* IP Checksum Good */ + if (status & IGC_RXD_STAT_IPCS) + ri->iri_csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID); + + /* Valid L4E checksum */ + if (__predict_true(status & + (IGC_RXD_STAT_TCPCS | IGC_RXD_STAT_UDPCS))) { + /* SCTP header present */ + if (__predict_false((ptype & IGC_RXDADV_PKTTYPE_ETQF) == 0 && + (ptype & IGC_RXDADV_PKTTYPE_SCTP) != 0)) { + ri->iri_csum_flags |= CSUM_SCTP_VALID; + } else { + ri->iri_csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; ri->iri_csum_data = htons(0xffff); } } - return; } /******************************************************************** @@ -559,7 +573,7 @@ igc_rx_checksum(u32 staterr, if_rxd_info_t ri, u32 ptype) * ******************************************************************/ static int -igc_determine_rsstype(u16 pkt_info) +igc_determine_rsstype(uint16_t pkt_info) { switch (pkt_info & IGC_RXDADV_RSSTYPE_MASK) { case IGC_RXDADV_RSSTYPE_IPV4_TCP: From owner-dev-commits-src-all@freebsd.org Mon Aug 23 17:29:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6D83D66EB64; Mon, 23 Aug 2021 17: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 4GtfPs2j4zz4WB4; Mon, 23 Aug 2021 17: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 3B58718695; Mon, 23 Aug 2021 17: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 17NHTrH3013020; Mon, 23 Aug 2021 17: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 17NHTrW4013019; Mon, 23 Aug 2021 17:29:53 GMT (envelope-from git) Date: Mon, 23 Aug 2021 17:29:53 GMT Message-Id: <202108231729.17NHTrW4013019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 5de5419b5e86 - main - ixgbe: Avoid sbuf_trim(9) in sysctl handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 17:29:53 -0000 The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc commit 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc Author: Kevin Bowling AuthorDate: 2021-08-23 16:21:39 +0000 Commit: Kevin Bowling CommitDate: 2021-08-23 17:28:59 +0000 ixgbe: Avoid sbuf_trim(9) in sysctl handler This was an error, we cannot use sbuf_trim(9) in the ixgbe_sbuf_fw_version function because it also gets called in the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction with drain functions as used by sbuf_new_for_sysctl(9). Reviewed by: imp Fixes: 7660e4ea5cb7 MFC after: 1 day Differential Revision: https://reviews.freebsd.org/D31633 --- sys/dev/ixgbe/if_ix.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index 8e14a008e09b..91bf7e4dd218 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -4694,27 +4694,33 @@ ixgbe_sbuf_fw_version(struct ixgbe_hw *hw, struct sbuf *buf) struct ixgbe_nvm_version nvm_ver = {0}; uint16_t phyfw = 0; int status; + const char *space = ""; ixgbe_get_oem_prod_version(hw, &nvm_ver); /* OEM's NVM version */ ixgbe_get_orom_version(hw, &nvm_ver); /* Option ROM */ ixgbe_get_etk_id(hw, &nvm_ver); /* eTrack identifies a build in Intel's SCM */ status = ixgbe_get_phy_firmware_version(hw, &phyfw); - if (nvm_ver.oem_valid) - sbuf_printf(buf, "NVM OEM V%d.%d R%d ", nvm_ver.oem_major, + if (nvm_ver.oem_valid) { + sbuf_printf(buf, "NVM OEM V%d.%d R%d", nvm_ver.oem_major, nvm_ver.oem_minor, nvm_ver.oem_release); + space = " "; + } - if (nvm_ver.or_valid) - sbuf_printf(buf, "Option ROM V%d-b%d-p%d ", nvm_ver.or_major, - nvm_ver.or_build, nvm_ver.or_patch); + if (nvm_ver.or_valid) { + sbuf_printf(buf, "%sOption ROM V%d-b%d-p%d", + space, nvm_ver.or_major, nvm_ver.or_build, nvm_ver.or_patch); + space = " "; + } - if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | NVM_VER_INVALID)) - sbuf_printf(buf, "eTrack 0x%08x ", nvm_ver.etk_id); + if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | + NVM_VER_INVALID)) { + sbuf_printf(buf, "%seTrack 0x%08x", space, nvm_ver.etk_id); + space = " "; + } if (phyfw != 0 && status == IXGBE_SUCCESS) - sbuf_printf(buf, "PHY FW V%d ", phyfw); - - sbuf_trim(buf); + sbuf_printf(buf, "%sPHY FW V%d", space, phyfw); } /* ixgbe_sbuf_fw_version */ /************************************************************************ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 18:38:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AE9966FBB9; Mon, 23 Aug 2021 18:38: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 4Gtgwg03Rvz4tqx; Mon, 23 Aug 2021 18:38: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 DD29A193DF; Mon, 23 Aug 2021 18:38: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 17NIcAub005962; Mon, 23 Aug 2021 18:38:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcAhM005961; Mon, 23 Aug 2021 18:38:10 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:10 GMT Message-Id: <202108231838.17NIcAhM005961@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: ebc52eabdcc5 - main - mips: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ebc52eabdcc5971fee8eaf7e565cd5d970acbdbc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:11 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ebc52eabdcc5971fee8eaf7e565cd5d970acbdbc commit ebc52eabdcc5971fee8eaf7e565cd5d970acbdbc Author: Mateusz Guzik AuthorDate: 2021-08-23 16:25:19 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:04 +0000 mips: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/mips/mips/support.S | 80 ------------------------------------------------- 1 file changed, 80 deletions(-) diff --git a/sys/mips/mips/support.S b/sys/mips/mips/support.S index 13a2d32a156c..4cf1f750fdad 100644 --- a/sys/mips/mips/support.S +++ b/sys/mips/mips/support.S @@ -473,86 +473,6 @@ smallclr: nop END(bzero) - -/* - * bcmp(s1, s2, n) - */ -LEAF(bcmp) - .set noreorder - blt a2, 16, smallcmp # is it worth any trouble? - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - PTR_SUBU a3, zero, a1 # compute # bytes to word align address - bne v0, zero, unalignedcmp # not possible to align addresses - and a3, a3, 3 - - beq a3, zero, 1f - PTR_SUBU a2, a2, a3 # subtract from remaining count - move v0, v1 # init v0,v1 so unmodified bytes match - LWHI v0, 0(a0) # read 1, 2, or 3 bytes - LWHI v1, 0(a1) - PTR_ADDU a1, a1, a3 - bne v0, v1, nomatch - PTR_ADDU a0, a0, a3 -1: - and a3, a2, ~3 # compute number of whole words left - PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 - PTR_ADDU a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # compare words - lw v1, 0(a1) - PTR_ADDU a0, a0, 4 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 4 - bne a0, a3, 2b - nop - b smallcmp # finish remainder - nop -unalignedcmp: - beq a3, zero, 2f - PTR_SUBU a2, a2, a3 # subtract from remaining count - PTR_ADDU a3, a3, a0 # compute ending address -1: - lbu v0, 0(a0) # compare bytes until a1 word aligned - lbu v1, 0(a1) - PTR_ADDU a0, a0, 1 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 1 - bne a0, a3, 1b - nop -2: - and a3, a2, ~3 # compute number of whole words left - PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 - PTR_ADDU a3, a3, a0 # compute ending address -3: - LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned - LWLO v0, 3(a0) - lw v1, 0(a1) - PTR_ADDU a0, a0, 4 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 4 - bne a0, a3, 3b - nop -smallcmp: - ble a2, zero, match - PTR_ADDU a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) - lbu v1, 0(a1) - PTR_ADDU a0, a0, 1 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 1 - bne a0, a3, 1b - nop -match: - j ra - move v0, zero -nomatch: - j ra - li v0, 1 -END(bcmp) - - /* * bit = ffs(value) */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 18:38:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 361C866FD18; Mon, 23 Aug 2021 18:38: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 4Gtgwh12L2z4tkq; Mon, 23 Aug 2021 18:38: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 0AEEE193E0; Mon, 23 Aug 2021 18:38: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 17NIcBHU005986; Mon, 23 Aug 2021 18:38:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcBX0005985; Mon, 23 Aug 2021 18:38:11 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:11 GMT Message-Id: <202108231838.17NIcBX0005985@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 8e4f67f17ff2 - main - i386: retire bcmp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e4f67f17ff27371c6d06c4143807e293f07c51e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:12 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8e4f67f17ff27371c6d06c4143807e293f07c51e commit 8e4f67f17ff27371c6d06c4143807e293f07c51e Author: Mateusz Guzik AuthorDate: 2021-08-23 16:27:17 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:04 +0000 i386: retire bcmp Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/i386/i386/support.s | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index b29354c47455..2fc02a67b600 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -232,31 +232,6 @@ ENTRY(memcpy) ret END(memcpy) -ENTRY(bcmp) - pushl %edi - pushl %esi - movl 12(%esp),%edi - movl 16(%esp),%esi - movl 20(%esp),%edx - - movl %edx,%ecx - shrl $2,%ecx - repe - cmpsl - jne 1f - - movl %edx,%ecx - andl $3,%ecx - repe - cmpsb -1: - setne %al - movsbl %al,%eax - popl %esi - popl %edi - ret -END(bcmp) - /* * Handling of special 386 registers and descriptor tables etc */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 18:38:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 583F266FB53; Mon, 23 Aug 2021 18:38: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 4Gtgwk5S0Yz4tyN; Mon, 23 Aug 2021 18:38: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 58770193E1; Mon, 23 Aug 2021 18:38: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 17NIcEVn006043; Mon, 23 Aug 2021 18:38:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcEqB006042; Mon, 23 Aug 2021 18:38:14 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:14 GMT Message-Id: <202108231838.17NIcEqB006042@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: c69cc8d10180 - main - riscv: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c69cc8d10180e667dc7701f700e4975e627514ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:15 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=c69cc8d10180e667dc7701f700e4975e627514ef commit c69cc8d10180e667dc7701f700e4975e627514ef Author: Mateusz Guzik AuthorDate: 2021-08-23 16:16:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 riscv: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: mhorne Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/riscv/riscv/machdep.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 841bfeda891e..b7fb142a59b4 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -979,14 +979,3 @@ initriscv(struct riscv_bootparams *rvbp) TSEXIT(); } - -#undef bzero -void -bzero(void *buf, size_t len) -{ - uint8_t *p; - - p = buf; - while(len-- > 0) - *p++ = 0; -} From owner-dev-commits-src-all@freebsd.org Mon Aug 23 18:38:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9323E66FE48; Mon, 23 Aug 2021 18:38: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 4Gtgwm5k26z4tyb; Mon, 23 Aug 2021 18:38: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 9384319594; Mon, 23 Aug 2021 18:38: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 17NIcGwH006093; Mon, 23 Aug 2021 18:38:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcGft006092; Mon, 23 Aug 2021 18:38:16 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:16 GMT Message-Id: <202108231838.17NIcGft006092@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: a4c33d65f2f3 - main - mips: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a4c33d65f2f3d0f16e5824b320e226b0c9ba31af Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:18 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=a4c33d65f2f3d0f16e5824b320e226b0c9ba31af commit a4c33d65f2f3d0f16e5824b320e226b0c9ba31af Author: Mateusz Guzik AuthorDate: 2021-08-23 16:26:02 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 mips: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/mips/mips/support.S | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/mips/mips/support.S b/sys/mips/mips/support.S index 4cf1f750fdad..9fd5b919d89e 100644 --- a/sys/mips/mips/support.S +++ b/sys/mips/mips/support.S @@ -440,10 +440,9 @@ memsetsmallclr: END(memset) /* - * bzero(s1, n) + * blkclr(s1, n) */ -LEAF(bzero) -XLEAF(blkclr) +LEAF(blkclr) .set noreorder blt a1, 12, smallclr # small amount to clear? PTR_SUBU a3, zero, a0 # compute # bytes to word align address @@ -471,7 +470,7 @@ smallclr: 2: j ra nop -END(bzero) +END(blkclr) /* * bit = ffs(value) From owner-dev-commits-src-all@freebsd.org Mon Aug 23 18:38:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7FD7666FBBA; Mon, 23 Aug 2021 18:38: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 4Gtgwj2KY3z4trC; Mon, 23 Aug 2021 18:38: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 2C01F191B2; Mon, 23 Aug 2021 18:38: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 17NIcDDc006012; Mon, 23 Aug 2021 18:38:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcDtC006011; Mon, 23 Aug 2021 18:38:13 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:13 GMT Message-Id: <202108231838.17NIcDtC006011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: e0545190ef5c - main - i386: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e0545190ef5c1268bdf9ed7f4d04bc5cd4ec19cf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:13 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e0545190ef5c1268bdf9ed7f4d04bc5cd4ec19cf commit e0545190ef5c1268bdf9ed7f4d04bc5cd4ec19cf Author: Mateusz Guzik AuthorDate: 2021-08-23 16:15:29 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 i386: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/i386/i386/support.s | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 2fc02a67b600..4130affbba5c 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -40,26 +40,6 @@ .text -/* - * bcopy family - * void bzero(void *buf, u_int len) - */ -ENTRY(bzero) - pushl %edi - movl 8(%esp),%edi - movl 12(%esp),%ecx - xorl %eax,%eax - shrl $2,%ecx - rep - stosl - movl 12(%esp),%ecx - andl $3,%ecx - rep - stosb - popl %edi - ret -END(bzero) - ENTRY(sse2_pagezero) pushl %ebx movl 8(%esp),%ecx From owner-dev-commits-src-all@freebsd.org Mon Aug 23 18:38:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 052F766FBBC; Mon, 23 Aug 2021 18:38: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 4Gtgwl4TfLz4thN; Mon, 23 Aug 2021 18:38: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 715B2193E2; Mon, 23 Aug 2021 18:38: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 17NIcFhL006067; Mon, 23 Aug 2021 18:38:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcFkw006066; Mon, 23 Aug 2021 18:38:15 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:15 GMT Message-Id: <202108231838.17NIcFkw006066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 11cb9a096c50 - main - powerpc: retire bzero MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 11cb9a096c505b5bc41b489aa9351a10a555e1d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:16 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=11cb9a096c505b5bc41b489aa9351a10a555e1d7 commit 11cb9a096c505b5bc41b489aa9351a10a555e1d7 Author: Mateusz Guzik AuthorDate: 2021-08-23 16:19:03 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 powerpc: retire bzero Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: jhibbits Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/powerpc/powerpc/machdep.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c index 4e8b6089beea..f35469f4051c 100644 --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -836,44 +836,6 @@ DB_SHOW_COMMAND(frame, db_show_frame) } #endif -#undef bzero -void -bzero(void *buf, size_t len) -{ - caddr_t p; - - p = buf; - - while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) { - *p++ = 0; - len--; - } - - while (len >= sizeof(u_long) * 8) { - *(u_long*) p = 0; - *((u_long*) p + 1) = 0; - *((u_long*) p + 2) = 0; - *((u_long*) p + 3) = 0; - len -= sizeof(u_long) * 8; - *((u_long*) p + 4) = 0; - *((u_long*) p + 5) = 0; - *((u_long*) p + 6) = 0; - *((u_long*) p + 7) = 0; - p += sizeof(u_long) * 8; - } - - while (len >= sizeof(u_long)) { - *(u_long*) p = 0; - len -= sizeof(u_long); - p += sizeof(u_long); - } - - while (len) { - *p++ = 0; - len--; - } -} - /* __stack_chk_fail_local() is called in secure-plt (32-bit). */ #if !defined(__powerpc64__) extern void __stack_chk_fail(void); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 18:38:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7C3BC66FE49; Mon, 23 Aug 2021 18:38: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 4Gtgwp0CpKz4trb; Mon, 23 Aug 2021 18:38: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 AFA7A19602; Mon, 23 Aug 2021 18:38: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 17NIcHW9006117; Mon, 23 Aug 2021 18:38:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NIcHYR006116; Mon, 23 Aug 2021 18:38:17 GMT (envelope-from git) Date: Mon, 23 Aug 2021 18:38:17 GMT Message-Id: <202108231838.17NIcHYR006116@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: e72e16c55df4 - main - Remove bzero declaration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e72e16c55df48194c354e82bd31415529c7a92a9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 18:38:18 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e72e16c55df48194c354e82bd31415529c7a92a9 commit e72e16c55df48194c354e82bd31415529c7a92a9 Author: Mateusz Guzik AuthorDate: 2021-08-23 16:20:53 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 18:38:05 +0000 Remove bzero declaration The kernel was migrated to memset in ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") and there are no remaining architectures using the file. malloc is augmented to prevent KMSAN from breaking. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/sys/malloc.h | 2 +- sys/sys/systm.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 3d88460a751e..b83d78a18444 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -233,7 +233,7 @@ void *malloc(size_t size, struct malloc_type *type, int flags) __malloc_like _malloc_item = malloc(_size, type, (flags) &~ M_ZERO); \ if (((flags) & M_WAITOK) != 0 || \ __predict_true(_malloc_item != NULL)) \ - bzero(_malloc_item, _size); \ + memset(_malloc_item, 0, _size); \ } else { \ _malloc_item = malloc(_size, type, flags); \ } \ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 1be8f1ac49be..17d1e8933997 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -342,7 +342,6 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags); #define ovbcopy(f, t, l) bcopy((f), (t), (l)) void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); -void bzero(void * _Nonnull buf, size_t len); void explicit_bzero(void * _Nonnull, size_t); void *memset(void * _Nonnull buf, int c, size_t len); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 19:37:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1784167066F; Mon, 23 Aug 2021 19:37: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 4GtjDr0CwCz3km3; Mon, 23 Aug 2021 19:37: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 E020719E55; Mon, 23 Aug 2021 19:37: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 17NJbFL1086604; Mon, 23 Aug 2021 19:37:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NJbFjt086603; Mon, 23 Aug 2021 19:37:15 GMT (envelope-from git) Date: Mon, 23 Aug 2021 19:37:15 GMT Message-Id: <202108231937.17NJbFjt086603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 159258afb50a - main - altq: Fix panics on rmc_restart() 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/main X-Git-Reftype: branch X-Git-Commit: 159258afb50ad57f7ed27fe86ded83a7b3a26f90 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 19:37:16 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=159258afb50ad57f7ed27fe86ded83a7b3a26f90 commit 159258afb50ad57f7ed27fe86ded83a7b3a26f90 Author: Kristof Provost AuthorDate: 2021-08-21 11:42:27 +0000 Commit: Kristof Provost CommitDate: 2021-08-23 19:35:41 +0000 altq: Fix panics on rmc_restart() rmc_restart() is called from a timer, but can trigger traffic. This means the curvnet context will not be set. Use the vnet associated with the interface we're currently processing to set it. We also have to enter net_epoch here, for the same reason. Reviewed by: mjg MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31642 --- sys/net/altq/altq_rmclass.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/net/altq/altq_rmclass.c b/sys/net/altq/altq_rmclass.c index a6ede6feebe2..a9af314cd48a 100644 --- a/sys/net/altq/altq_rmclass.c +++ b/sys/net/altq/altq_rmclass.c @@ -1554,10 +1554,13 @@ rmc_restart(void *arg) { struct rm_class *cl = arg; struct rm_ifdat *ifd = cl->ifdat_; + struct epoch_tracker et; int s; s = splnet(); + NET_EPOCH_ENTER(et); IFQ_LOCK(ifd->ifq_); + CURVNET_SET(ifd->ifq_->altq_ifp->if_vnet); if (cl->sleeping_) { cl->sleeping_ = 0; cl->undertime_.tv_sec = 0; @@ -1567,7 +1570,9 @@ rmc_restart(void *arg) (ifd->restart)(ifd->ifq_); } } + CURVNET_RESTORE(); IFQ_UNLOCK(ifd->ifq_); + NET_EPOCH_EXIT(et); splx(s); } From owner-dev-commits-src-all@freebsd.org Mon Aug 23 20:26:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 221536715A4 for ; Mon, 23 Aug 2021 20:26:40 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtkKq0cxLz4TJW for ; Mon, 23 Aug 2021 20:26:39 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f48.google.com with SMTP id z4so12357969wrr.6 for ; Mon, 23 Aug 2021 13:26:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FrYH8P6eg3z9609Ub5AvqXLyXhlhwTB9nqbOpNimJuA=; b=e0gI2wkrntepmu1mFo1Rg/rVgM7u42MD93tSsrG8c7yFe8Ev74bLymxjXbLLugSMCW mbpAZA6yGwXJOjyi29wNi08U3GmGr+G+vtKaqW81H85QBbnZq12oGXhAdMoyY681a+3x 8JknTAzLNokHaQhIn/ryXVk1la1rHEKkm8afIsrKAC5ornoYWDiVUg9teKbYO1d5Y4E+ 7l+zLkR/jRH5jHTXVtTDybOK7pd6EKM4o6WSBwlIXLfw5FvOPnpZs6WGm64z68LC5LuJ Ff9xEw5wBUTS0lBgPODYboJhJSyD5z3NJoTrNEnkTewuQR757NLQS7Tn0t9cw9heiufW eu/w== X-Gm-Message-State: AOAM532Bt94AVONYBXmP82MweTGGn08hdhRyWOR5J9F94lYs+udWR9s0 kjb3DPAL4Q6qDpEFLhacVkGdow== X-Google-Smtp-Source: ABdhPJxe0i3drzll0YQbdIKYtEr5CuQP9AJg+jW0r2w9p7hyCpyqiGWvcfPTYsWtHZ7K3ENJ/JCdkA== X-Received: by 2002:a5d:54ca:: with SMTP id x10mr15569311wrv.101.1629750392197; Mon, 23 Aug 2021 13:26:32 -0700 (PDT) Received: from smtpclient.apple (global-5-143.nat-2.net.cam.ac.uk. [131.111.5.143]) by smtp.gmail.com with ESMTPSA id n8sm200545wmq.18.2021.08.23.13.26.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Aug 2021 13:26:31 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: git: 5ee2c35751ef - main - truncate(1): Add hole-punching support From: Jessica Clarke In-Reply-To: <202108191031.17JAViPg067471@gitrepo.freebsd.org> Date: Mon, 23 Aug 2021 21:26:31 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <87C913E0-77D4-49BE-816C-E0F3BAA18BC2@freebsd.org> References: <202108191031.17JAViPg067471@gitrepo.freebsd.org> To: Ka Ho Ng X-Mailer: Apple Mail (2.3654.100.0.2.22) X-Rspamd-Queue-Id: 4GtkKq0cxLz4TJW X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of jrtc27@jrtc27.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=jrtc27@jrtc27.com X-Spamd-Result: default: False [-2.49 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; MV_CASE(0.50)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; FREEFALL_USER(0.00)[jrtc27]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-0.99)[-0.990]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-all@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.221.48:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.221.48:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[dev-commits-src-all] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 20:26:40 -0000 On 19 Aug 2021, at 11:31, Ka Ho Ng wrote: >=20 > The branch main has been updated by khng: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D5ee2c35751ef5d131222423bf3e25073= f997c337 >=20 > commit 5ee2c35751ef5d131222423bf3e25073f997c337 > Author: Ka Ho Ng > AuthorDate: 2021-08-19 10:30:41 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-19 10:30:41 +0000 >=20 > truncate(1): Add hole-punching support >=20 > This commit adds hole-punching support to the truncate(1) utility. = If > the option -d is specified, truncate(1) performs zeroing, and if > possible hole-punching in case the operation is supported by the > underlying file system of the specified files. >=20 > Sponsored by: The FreeBSD Foundation > Reviewed by: kib > Differential Revision: https://reviews.freebsd.org/D31556 This broke cross-building from macOS and Linux since truncate is a bootstrap tool there and these FreeBSD-specific features don=E2=80=99t = exist. Please disable these features when built as a bootstrap tool (see bin/cat for an example). Jess From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E9963672DAD; Mon, 23 Aug 2021 22:26: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 4Gtmzm5y7Rz3NC2; Mon, 23 Aug 2021 22:26: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 A62C81C7A3; Mon, 23 Aug 2021 22:26: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 17NMQCuv014678; Mon, 23 Aug 2021 22:26:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQCbB014677; Mon, 23 Aug 2021 22:26:12 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:12 GMT Message-Id: <202108232226.17NMQCbB014677@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 5517f7f9e70d - stable/13 - hmt(4): Store Contact Count in separate variable. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5517f7f9e70dcfdb824ce414e4a0f5a24f58fefe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:13 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=5517f7f9e70dcfdb824ce414e4a0f5a24f58fefe commit 5517f7f9e70dcfdb824ce414e4a0f5a24f58fefe Author: Vladimir Kondratyev AuthorDate: 2021-08-16 20:11:36 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:19:43 +0000 hmt(4): Store Contact Count in separate variable. No functional changes. (cherry picked from commit 95add157e341f2c1ce47eaa19b3c5771705ea20d) --- sys/dev/hid/hmt.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c index fd50ea4de829..2eb02811a5a4 100644 --- a/sys/dev/hid/hmt.c +++ b/sys/dev/hid/hmt.c @@ -185,6 +185,7 @@ struct hmt_softc { device_t dev; enum hmt_type type; + int32_t cont_count_max; struct hid_absinfo ai[HMT_N_USAGES]; struct hid_location locs[MAX_MT_SLOTS][HMT_N_USAGES]; struct hid_location cont_count_loc; @@ -332,7 +333,7 @@ hmt_attach(device_t dev) * 'Contact Count Maximum' */ if (cont_count_max > 0) - sc->ai[HMT_SLOT].max = cont_count_max - 1; + sc->cont_count_max = cont_count_max; } else DPRINTF("hid_get_report error=%d\n", err); } else @@ -368,12 +369,19 @@ hmt_attach(device_t dev) } /* Cap contact count maximum to MAX_MT_SLOTS */ - if (sc->ai[HMT_SLOT].max >= MAX_MT_SLOTS) { + if (sc->cont_count_max > MAX_MT_SLOTS) { DPRINTF("Hardware reported %d contacts while only %d is " - "supported\n", (int)sc->ai[HMT_SLOT].max+1, MAX_MT_SLOTS); - sc->ai[HMT_SLOT].max = MAX_MT_SLOTS - 1; + "supported\n", sc->cont_count_max, MAX_MT_SLOTS); + sc->cont_count_max = MAX_MT_SLOTS; } + /* Set number of MT protocol type B slots */ + sc->ai[HMT_SLOT] = (struct hid_absinfo) { + .min = 0, + .max = sc->cont_count_max - 1, + .res = 0, + }; + if (hid_test_quirk(hw, HQ_MT_TIMESTAMP) || hmt_timestamps) sc->do_timestamps = true; #ifdef IICHID_SAMPLING @@ -445,7 +453,7 @@ hmt_attach(device_t dev) sc->is_clickpad ? ", click-pad" : ""); device_printf(sc->dev, "%d contacts with [%s%s%s%s%s] properties. Report range [%d:%d] - [%d:%d]\n", - (int)sc->ai[HMT_SLOT].max + 1, + (int)sc->cont_count_max, isset(sc->caps, HMT_IN_RANGE) ? "R" : "", isset(sc->caps, HMT_CONFIDENCE) ? "C" : "", isset(sc->caps, HMT_WIDTH) ? "W" : "", @@ -834,13 +842,6 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len, if (cont_count_max < 1) cont_count_max = cont; - /* Set number of MT protocol type B slots */ - sc->ai[HMT_SLOT] = (struct hid_absinfo) { - .min = 0, - .max = cont_count_max - 1, - .res = 0, - }; - /* Report touch orientation if both width and height are supported */ if (isset(sc->caps, HMT_WIDTH) && isset(sc->caps, HMT_HEIGHT)) { setbit(sc->caps, HMT_ORIENTATION); @@ -857,6 +858,7 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len, hid_feature, sc->thqa_cert_rid); sc->report_id = report_id; + sc->cont_count_max = cont_count_max; sc->nconts_per_report = cont; sc->has_int_button = has_int_button; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 22401672DB3; Mon, 23 Aug 2021 22:26: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 4Gtmzn6Hfcz3NSL; Mon, 23 Aug 2021 22:26: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 BED781C805; Mon, 23 Aug 2021 22:26: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 17NMQDQk014709; Mon, 23 Aug 2021 22:26:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQDvr014708; Mon, 23 Aug 2021 22:26:13 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:13 GMT Message-Id: <202108232226.17NMQDvr014708@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: ec86cee5db72 - stable/13 - evdev: Do not check maximal contact number for MT initialization MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ec86cee5db72c906ad47ac8e33ffb4bbd9bbf15a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:14 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=ec86cee5db72c906ad47ac8e33ffb4bbd9bbf15a commit ec86cee5db72c906ad47ac8e33ffb4bbd9bbf15a Author: Vladimir Kondratyev AuthorDate: 2021-08-16 20:12:01 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:20:06 +0000 evdev: Do not check maximal contact number for MT initialization This allows singletouch devices which use multitouch protocols to work. Reported by: Mark Kane (cherry picked from commit e40fec4ec9a7a6625b3e332d4f856eb1d05f0def) --- sys/dev/evdev/evdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 086ee36333dc..bc28ae0734f9 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -316,8 +316,7 @@ evdev_register_common(struct evdev_dev *evdev) } /* Initialize multitouch protocol type B states */ - if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT) && - evdev->ev_absinfo != NULL && MAXIMAL_MT_SLOT(evdev) > 0) + if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) evdev_mt_init(evdev); /* Estimate maximum report size */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 90049672AE7; Mon, 23 Aug 2021 22:26: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 4Gtmzr21X0z3N8r; Mon, 23 Aug 2021 22:26: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 19A0F1C4B6; Mon, 23 Aug 2021 22:26: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 17NMQFan014757; Mon, 23 Aug 2021 22:26:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQFvj014756; Mon, 23 Aug 2021 22:26:15 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:15 GMT Message-Id: <202108232226.17NMQFvj014756@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 6c8f2d24d468 - stable/13 - hmt(4): Do not ignore constant usages in HID report descriptor parser MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6c8f2d24d468a1b95dba4db48dcb425a07d49375 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:16 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=6c8f2d24d468a1b95dba4db48dcb425a07d49375 commit 6c8f2d24d468a1b95dba4db48dcb425a07d49375 Author: Jack AuthorDate: 2021-08-16 20:17:41 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:21:24 +0000 hmt(4): Do not ignore constant usages in HID report descriptor parser This fixes hmt to work with MELF0411 1FD2:7012 touchscreen Obtained from: sysutils/iichid (cherry picked from commit cb910670ac59e11808a629c8375c60200f909217) --- sys/dev/hid/hmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c index 2eb02811a5a4..d04db6954d00 100644 --- a/sys/dev/hid/hmt.c +++ b/sys/dev/hid/hmt.c @@ -676,8 +676,8 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len, bool scan_time_found = false; bool has_int_button = false; -#define HMT_HI_ABSOLUTE(hi) \ - (((hi).flags & (HIO_CONST|HIO_VARIABLE|HIO_RELATIVE)) == HIO_VARIABLE) +#define HMT_HI_ABSOLUTE(hi) ((hi).nusages != 0 && \ + ((hi).flags & (HIO_VARIABLE | HIO_RELATIVE)) == HIO_VARIABLE) #define HUMS_THQA_CERT 0xC5 /* From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2BA03672C48; Mon, 23 Aug 2021 22:26: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 4Gtmzq0LjZz3NSQ; Mon, 23 Aug 2021 22:26: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 E28F31C690; Mon, 23 Aug 2021 22:26: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 17NMQE5i014733; Mon, 23 Aug 2021 22:26:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQEIt014732; Mon, 23 Aug 2021 22:26:14 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:14 GMT Message-Id: <202108232226.17NMQEIt014732@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: a711310d2db5 - stable/13 - hid: Add extra constant to units of measurement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a711310d2db5549dce218960e5f405d8fe13d66c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:15 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=a711310d2db5549dce218960e5f405d8fe13d66c commit a711310d2db5549dce218960e5f405d8fe13d66c Author: Vladimir Kondratyev AuthorDate: 2021-08-16 20:13:24 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:20:30 +0000 hid: Add extra constant to units of measurement Some devices like eGalax touchscreens use value of 0x33 instead of 0x13 for inches as unit of measure. Reported by: Mark Kane (cherry picked from commit be75951af1ec2d69d34a8701700b9bfd2a50679e) --- sys/dev/hid/hid.c | 1 + sys/dev/hid/hid.h | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/dev/hid/hid.c b/sys/dev/hid/hid.c index 699bfa4a8bb3..f201182ac20f 100644 --- a/sys/dev/hid/hid.c +++ b/sys/dev/hid/hid.c @@ -856,6 +856,7 @@ hid_item_resolution(struct hid_item *hi) divisor = 10; break; case HUM_INCH: + case HUM_INCH_EGALAX: multiplier = 10; divisor = 254; break; diff --git a/sys/dev/hid/hid.h b/sys/dev/hid/hid.h index 37ab8c9cdf7e..f0311bae689c 100644 --- a/sys/dev/hid/hid.h +++ b/sys/dev/hid/hid.h @@ -185,6 +185,7 @@ #define HUM_CENTIMETER 0x11 #define HUM_RADIAN 0x12 #define HUM_INCH 0x13 +#define HUM_INCH_EGALAX 0x33 #define HUM_DEGREE 0x14 #if defined(_KERNEL) || defined(_STANDALONE) From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 07AE3672BBB; Mon, 23 Aug 2021 22:26: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 4Gtmzw5wwtz3NN8; Mon, 23 Aug 2021 22:26: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 A62491C540; Mon, 23 Aug 2021 22:26: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 17NMQKj0014859; Mon, 23 Aug 2021 22:26:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQK6e014858; Mon, 23 Aug 2021 22:26:20 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:20 GMT Message-Id: <202108232226.17NMQK6e014858@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 8f559509a22b - stable/13 - bitstring(3): Add bitstring traversal macros. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8f559509a22ba8725fa6ec50eca32313e5841fe2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:21 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=8f559509a22ba8725fa6ec50eca32313e5841fe2 commit 8f559509a22ba8725fa6ec50eca32313e5841fe2 Author: Vladimir Kondratyev AuthorDate: 2021-08-16 20:18:58 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:23:10 +0000 bitstring(3): Add bitstring traversal macros. The macro bit_foreach() traverses all set bits in the bitstring in the forward direction, assigning each location in turn to variable. The macro bit_foreach_at() traverses all set bits in the bitstring in the forward direction at or after the zero-based bit index, assigning each location in turn to variable. The bit_foreach_unset() and bit_foreach_unset_at() macros which traverses unset bits are implemented for completeness. Reviewed by: asomers, dougm (cherry picked from commit 14a4d6d01335dd233023834e05897377cb70d52a) --- share/man/man3/bitstring.3 | 46 ++++++++- sys/sys/bitstring.h | 16 ++++ tests/sys/sys/bitstring_test.c | 207 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 268 insertions(+), 1 deletion(-) diff --git a/share/man/man3/bitstring.3 b/share/man/man3/bitstring.3 index 20f5bae24d4d..e5be67a89e4f 100644 --- a/share/man/man3/bitstring.3 +++ b/share/man/man3/bitstring.3 @@ -58,7 +58,7 @@ .\" @(#)bitstring.3 8.1 (Berkeley) 7/19/93 .\" $FreeBSD$ .\" -.Dd November 18, 2019 +.Dd August 8, 2021 .Dt BITSTRING 3 .Os .Sh NAME @@ -106,6 +106,10 @@ .Fn bit_ffc_area_at "bitstr_t *name" "int start" "int nbits" "int size" "int *value" .Ft void .Fn bit_ffs_area_at "bitstr_t *name" "int start" "int nbits" "int size" "int *value" +.Fn bit_foreach "bitstr_t *name" "int nbits" "int var" +.Fn bit_foreach_at "bitstr_t *name" "int start" "int nbits" "int var" +.Fn bit_foreach_unset "bitstr_t *name" "int nbits" "int var" +.Fn bit_foreach_unset_at "bitstr_t *name" "int start" "int nbits" "int var" .Ft void .Fn bit_nclear "bitstr_t *name" "int start" "int stop" .Ft void @@ -327,6 +331,46 @@ bits referenced by at or after the zero-based bit index .Fa start . .Pp +The macro +.Fn bit_foreach +traverses all set bits in the array of +.Fa nbits +referenced by +.Fa name +in the forward direction, assigning each location in turn to +.Fa var . +.Pp +The macro +.Fn bit_foreach_at +traverses all set bits in the array of +.Fa nbits +referenced by +.Fa name +in the forward direction at or after the zero-based bit index +.Fa start , +assigning each location in turn to +.Fa var . +.Pp +The macro +.Fn bit_foreach_unset +traverses all unset bits in the array of +.Fa nbits +referenced by +.Fa name +in the forward direction, assigning each location in turn to +.Fa var . +.Pp +The macro +.Fn bit_foreach_unset_at +traverses all unset bits in the array of +.Fa nbits +referenced by +.Fa name +in the forward direction at or after the zero-based bit index +.Fa start , +assigning each location in turn to +.Fa var . +.Pp The arguments in bit string macros are evaluated only once and may safely have side effects. .Sh EXAMPLES diff --git a/sys/sys/bitstring.h b/sys/sys/bitstring.h index 97b841bbdda6..f898a2392be6 100644 --- a/sys/sys/bitstring.h +++ b/sys/sys/bitstring.h @@ -419,4 +419,20 @@ out: *_result = _value; } +/* Traverse all set bits, assigning each location in turn to iter */ +#define bit_foreach_at(_bitstr, _start, _nbits, _iter) \ + for (bit_ffs_at((_bitstr), (_start), (_nbits), &(_iter)); \ + (_iter) != -1; \ + bit_ffs_at((_bitstr), (_iter) + 1, (_nbits), &(_iter))) +#define bit_foreach(_bitstr, _nbits, _iter) \ + bit_foreach_at(_bitstr, /*start*/0, _nbits, _iter) + +/* Traverse all unset bits, assigning each location in turn to iter */ +#define bit_foreach_unset_at(_bitstr, _start, _nbits, _iter) \ + for (bit_ffc_at((_bitstr), (_start), (_nbits), &(_iter)); \ + (_iter) != -1; \ + bit_ffc_at((_bitstr), (_iter) + 1, (_nbits), &(_iter))) +#define bit_foreach_unset(_bitstr, _nbits, _iter) \ + bit_foreach_unset_at(_bitstr, /*start*/0, _nbits, _iter) + #endif /* _SYS_BITSTRING_H_ */ diff --git a/tests/sys/sys/bitstring_test.c b/tests/sys/sys/bitstring_test.c index 8fdc68ecf68e..c891a98645f8 100644 --- a/tests/sys/sys/bitstring_test.c +++ b/tests/sys/sys/bitstring_test.c @@ -601,6 +601,209 @@ BITSTRING_TC_DEFINE(bit_count) } +BITSTRING_TC_DEFINE(bit_foreach) +/* bitstr_t *bitstr, int nbits, const char *memloc */ +{ + int i, set_bit; + + /* Empty bitstr */ + memset(bitstr, 0x00, bitstr_size(nbits)); + bit_foreach (bitstr, nbits, set_bit) { + atf_tc_fail("bit_foreach_%d_%s_%s: Failed at location %d", + nbits, "clear", memloc, set_bit); + } + + /* Full bitstr */ + i = 0; + memset(bitstr, 0xFF, bitstr_size(nbits)); + bit_foreach(bitstr, nbits, set_bit) { + ATF_REQUIRE_MSG(set_bit == i, + "bit_foreach_%d_%s_%s: Failed on turn %d at location %d", + nbits, "set", memloc, i, set_bit); + i++; + } + ATF_REQUIRE_MSG(i == nbits, + "bit_foreach_%d_%s_%s: Invalid number of turns %d", + nbits, "set", memloc, i); + + /* Alternating bitstr, starts with 0 */ + i = 0; + memset(bitstr, 0xAA, bitstr_size(nbits)); + bit_foreach(bitstr, nbits, set_bit) { + ATF_REQUIRE_MSG(set_bit == i * 2 + 1, + "bit_foreach_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "alternating", 0, memloc, i, set_bit); + i++; + } + ATF_REQUIRE_MSG(i == nbits / 2, + "bit_foreach_%d_%s_%d_%s: Invalid number of turns %d", + nbits, "alternating", 0, memloc, i); + + /* Alternating bitstr, starts with 1 */ + i = 0; + memset(bitstr, 0x55, bitstr_size(nbits)); + bit_foreach(bitstr, nbits, set_bit) { + ATF_REQUIRE_MSG(set_bit == i * 2, + "bit_foreach_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "alternating", 1, memloc, i, set_bit); + i++; + } + ATF_REQUIRE_MSG(i == (nbits + 1) / 2, + "bit_foreach_%d_%s_%d_%s: Invalid number of turns %d", + nbits, "alternating", 1, memloc, i); +} + +BITSTRING_TC_DEFINE(bit_foreach_at) +/* bitstr_t *bitstr, int nbits, const char *memloc */ +{ + int i, s, e, set_bit; + + /* Invalid _start value */ + memset(bitstr, 0xFF, bitstr_size(nbits)); + bit_foreach_at(bitstr, nbits, nbits, set_bit) { + atf_tc_fail("bit_foreach_at_%d_%s_%s: Failed at location %d", + nbits, "invalid_start", memloc, set_bit); + } + + /* Varying start location */ + memset(bitstr, 0xAA, bitstr_size(nbits)); + for (s = 0; s < nbits; s++) { + i = 0; + bit_foreach_at(bitstr, s, nbits, set_bit) { + ATF_REQUIRE_MSG(set_bit == (i + s / 2) * 2 + 1, + "bit_foreach_at_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "vary_start", s, memloc, i, set_bit); + i++; + } + ATF_REQUIRE_MSG(i == nbits / 2 - s / 2, + "bit_foreach_at_%d_%s_%d_%s: Invalid number of turns %d", + nbits, "vary_start", s, memloc, i); + } + + /* Varying end location */ + memset(bitstr, 0xAA, bitstr_size(nbits)); + for (e = 0; e < nbits; e++) { + i = 0; + bit_foreach_at(bitstr, 0, e, set_bit) { + ATF_REQUIRE_MSG(set_bit == i * 2 + 1, + "bit_foreach_at_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "vary_end", e, memloc, i, set_bit); + i++; + } + ATF_REQUIRE_MSG(i == e / 2, + "bit_foreach_at_%d_%s_%d_%s: Invalid number of turns %d", + nbits, "vary_end", e, memloc, i); + } +} + +BITSTRING_TC_DEFINE(bit_foreach_unset) +/* bitstr_t *bitstr, int nbits, const char *memloc */ +{ + int i, unset_bit; + + /* Empty bitstr */ + i = 0; + memset(bitstr, 0, bitstr_size(nbits)); + bit_foreach_unset(bitstr, nbits, unset_bit) { + ATF_REQUIRE_MSG(unset_bit == i, + "bit_foreach_unset_%d_%s_%s: " + "Failed on turn %d at location %d", + nbits, "clear", memloc, i, unset_bit); + i++; + } + ATF_REQUIRE_MSG(i == nbits, + "bit_foreach_unset_%d_%s_%s: Invalid number of turns %d", + nbits, "set", memloc, i); + + /* Full bitstr */ + memset(bitstr, 0xFF, bitstr_size(nbits)); + bit_foreach_unset(bitstr, nbits, unset_bit) { + atf_tc_fail("bit_foreach_unset_%d_%s_%s: " + "Failed at location %d", + nbits, "set", memloc, unset_bit); + } + + /* Alternating bitstr, starts with 0 */ + i = 0; + memset(bitstr, 0xAA, bitstr_size(nbits)); + bit_foreach_unset(bitstr, nbits, unset_bit) { + ATF_REQUIRE_MSG(unset_bit == i * 2, + "bit_foreach_unset_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "alternating", 0, memloc, i, unset_bit); + i++; + } + ATF_REQUIRE_MSG(i == (nbits + 1) / 2, + "bit_foreach_unset_%d_%s_%d_%s: Invalid number of turns %d", + nbits, "alternating", 0, memloc, i); + + /* Alternating bitstr, starts with 1 */ + i = 0; + memset(bitstr, 0x55, bitstr_size(nbits)); + bit_foreach_unset(bitstr, nbits, unset_bit) { + ATF_REQUIRE_MSG(unset_bit == i * 2 + 1, + "bit_foreach_unset_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "alternating", 1, memloc, i, unset_bit); + i++; + } + ATF_REQUIRE_MSG(i == nbits / 2, + "bit_foreach_unset_%d_%s_%d_%s: Invalid number of turns %d", + nbits, "alternating", 1, memloc, i); +} + +BITSTRING_TC_DEFINE(bit_foreach_unset_at) +/* bitstr_t *bitstr, int nbits, const char *memloc */ +{ + int i, s, e, unset_bit; + + /* Invalid _start value */ + memset(bitstr, 0, bitstr_size(nbits)); + bit_foreach_unset_at(bitstr, nbits, nbits, unset_bit) { + atf_tc_fail("bit_foreach_unset_at_%d_%s_%s: " + "Failed at location %d", + nbits, "invalid_start", memloc, unset_bit); + } + + /* Varying start location */ + memset(bitstr, 0xAA, bitstr_size(nbits)); + for (s = 0; s < nbits; s++) { + i = 0; + bit_foreach_unset_at(bitstr, s, nbits, unset_bit) { + ATF_REQUIRE_MSG(unset_bit == (i + (s + 1) / 2) * 2, + "bit_foreach_unset_at_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "vary_start", s, memloc, i, unset_bit); + i++; + } + ATF_REQUIRE_MSG(i == (nbits + 1) / 2 - (s + 1) / 2, + "bit_foreach_unset_at_%d_%s_%d_%s: " + "Invalid number of turns %d", + nbits, "vary_start", s, memloc, i); + } + + /* Varying end location */ + memset(bitstr, 0xAA, bitstr_size(nbits)); + for (e = 0; e < nbits; e++) { + i = 0; + bit_foreach_unset_at(bitstr, 0, e, unset_bit) { + ATF_REQUIRE_MSG(unset_bit == i * 2, + "bit_foreach_unset_at_%d_%s_%d_%s: " + "Failed on turn %d at location %d", + nbits, "vary_end", e, memloc, i, unset_bit); + i++; + } + ATF_REQUIRE_MSG(i == (e + 1) / 2, + "bit_foreach_unset_at_%d_%s_%d_%s: " + "Invalid number of turns %d", + nbits, "vary_end", e, memloc, i); + } +} + ATF_TP_ADD_TCS(tp) { @@ -619,6 +822,10 @@ ATF_TP_ADD_TCS(tp) BITSTRING_TC_ADD(tp, bit_count); BITSTRING_TC_ADD(tp, bit_ffs_area_no_match); BITSTRING_TC_ADD(tp, bit_ffc_area_no_match); + BITSTRING_TC_ADD(tp, bit_foreach); + BITSTRING_TC_ADD(tp, bit_foreach_at); + BITSTRING_TC_ADD(tp, bit_foreach_unset); + BITSTRING_TC_ADD(tp, bit_foreach_unset_at); return (atf_no_error()); } From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 747AB672D0C; Mon, 23 Aug 2021 22:26: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 4Gtmzs2J26z3NQF; Mon, 23 Aug 2021 22:26: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 33D671C24A; Mon, 23 Aug 2021 22:26: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 17NMQHY5014781; Mon, 23 Aug 2021 22:26:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQHBJ014780; Mon, 23 Aug 2021 22:26:17 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:17 GMT Message-Id: <202108232226.17NMQHBJ014780@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 2de8a0d20969 - stable/13 - hid: move proper hat switch handling from ps4dshock to hgame MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2de8a0d20969b977f6c46ff56b49271c0c179f37 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:17 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=2de8a0d20969b977f6c46ff56b49271c0c179f37 commit 2de8a0d20969b977f6c46ff56b49271c0c179f37 Author: Greg V AuthorDate: 2021-08-16 20:18:09 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:21:49 +0000 hid: move proper hat switch handling from ps4dshock to hgame Generic "DirectInput" HID gamepads need this handling too. Reviewed by: wulf (cherry picked from commit 51b2216114546bb13b13002b29fb1263e600a0fc) --- sys/dev/hid/hgame.c | 34 +++++++++++++++++++++++++++++++++- sys/dev/hid/hgame.h | 1 + sys/dev/hid/ps4dshock.c | 35 +++-------------------------------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/sys/dev/hid/hgame.c b/sys/dev/hid/hgame.c index 545c72e76d93..97b1ac91960c 100644 --- a/sys/dev/hid/hgame.c +++ b/sys/dev/hid/hgame.c @@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$"); { HIDMAP_KEY_RANGE(HUP_BUTTON, number_from, number_to, code) } #define HGAME_MAP_ABS(usage, code) \ { HIDMAP_ABS(HUP_GENERIC_DESKTOP, HUG_##usage, code) } +#define HGAME_MAP_GCB(usage, callback) \ + { HIDMAP_ANY_CB(HUP_GENERIC_DESKTOP, HUG_##usage, callback) } #define HGAME_MAP_CRG(usage_from, usage_to, callback) \ { HIDMAP_ANY_CB_RANGE(HUP_GENERIC_DESKTOP, \ HUG_##usage_from, HUG_##usage_to, callback) } @@ -66,7 +68,7 @@ static const struct hidmap_item hgame_map[] = { HGAME_MAP_ABS(RX, ABS_RX), HGAME_MAP_ABS(RY, ABS_RY), HGAME_MAP_ABS(RZ, ABS_RZ), - HGAME_MAP_ABS(HAT_SWITCH, ABS_HAT0X), + HGAME_MAP_GCB(HAT_SWITCH, hgame_hat_switch_cb), HGAME_MAP_CRG(D_PAD_UP, D_PAD_LEFT, hgame_dpad_cb), HGAME_MAP_BRG(17, 57, BTN_TRIGGER_HAPPY), HGAME_FINALCB( hgame_final_cb), @@ -79,6 +81,36 @@ static const struct hid_device_id hgame_devs[] = { HID_DRIVER_INFO(HUG_GAME_PAD) }, }; +int +hgame_hat_switch_cb(HIDMAP_CB_ARGS) +{ + static const struct { int32_t x; int32_t y; } hat_switch_map[] = { + {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, + {-1, -1},{0, 0} + }; + struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); + u_int idx; + + switch (HIDMAP_CB_GET_STATE()) { + case HIDMAP_CB_IS_ATTACHING: + evdev_support_event(evdev, EV_ABS); + evdev_support_abs(evdev, ABS_HAT0X, -1, 1, 0, 0, 0); + evdev_support_abs(evdev, ABS_HAT0Y, -1, 1, 0, 0, 0); + break; + + case HIDMAP_CB_IS_RUNNING: + idx = MIN(nitems(hat_switch_map) - 1, (u_int)ctx.data); + evdev_push_abs(evdev, ABS_HAT0X, hat_switch_map[idx].x); + evdev_push_abs(evdev, ABS_HAT0Y, hat_switch_map[idx].y); + break; + + default: + break; + } + + return (0); +} + /* * Emulate the hat switch report via the D-pad usages * found on XInput/XBox style devices diff --git a/sys/dev/hid/hgame.h b/sys/dev/hid/hgame.h index 32086ec4923c..702c65a4a4c1 100644 --- a/sys/dev/hid/hgame.h +++ b/sys/dev/hid/hgame.h @@ -31,6 +31,7 @@ #include +hidmap_cb_t hgame_hat_switch_cb; hidmap_cb_t hgame_dpad_cb; hidmap_cb_t hgame_final_cb; diff --git a/sys/dev/hid/ps4dshock.c b/sys/dev/hid/ps4dshock.c index eec26f808997..a4afba254c03 100644 --- a/sys/dev/hid/ps4dshock.c +++ b/sys/dev/hid/ps4dshock.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #define HID_DEBUG_VAR ps4dshock_debug +#include #include #include #include @@ -588,7 +589,6 @@ static const uint8_t ps4dshock_rdesc[] = { #define PS4DS_OUTPUT_REPORT5_SIZE 32 #define PS4DS_OUTPUT_REPORT11_SIZE 78 -static hidmap_cb_t ps4dshock_hat_switch_cb; static hidmap_cb_t ps4dshock_final_cb; static hidmap_cb_t ps4dsacc_data_cb; static hidmap_cb_t ps4dsacc_tstamp_cb; @@ -743,7 +743,7 @@ static const struct hidmap_item ps4dshock_map[] = { PS4DS_MAP_BTN(13, BTN_MODE), /* Click button is handled by touchpad driver */ /* PS4DS_MAP_BTN(14, BTN_LEFT), */ - PS4DS_MAP_GCB(HAT_SWITCH, ps4dshock_hat_switch_cb), + PS4DS_MAP_GCB(HAT_SWITCH, hgame_hat_switch_cb), PS4DS_FINALCB( ps4dshock_final_cb), }; static const struct hidmap_item ps4dsacc_map[] = { @@ -787,36 +787,6 @@ static const struct hid_device_id ps4dsmtp_devs[] = { HID_TLC(HUP_DIGITIZERS, HUD_TOUCHPAD) }, }; -static int -ps4dshock_hat_switch_cb(HIDMAP_CB_ARGS) -{ - static const struct { int32_t x; int32_t y; } hat_switch_map[] = { - {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, - {-1, -1},{0, 0} - }; - struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); - u_int idx; - - switch (HIDMAP_CB_GET_STATE()) { - case HIDMAP_CB_IS_ATTACHING: - evdev_support_event(evdev, EV_ABS); - evdev_support_abs(evdev, ABS_HAT0X, -1, 1, 0, 0, 0); - evdev_support_abs(evdev, ABS_HAT0Y, -1, 1, 0, 0, 0); - break; - - case HIDMAP_CB_IS_RUNNING: - idx = MIN(nitems(hat_switch_map) - 1, (u_int)ctx.data); - evdev_push_abs(evdev, ABS_HAT0X, hat_switch_map[idx].x); - evdev_push_abs(evdev, ABS_HAT0Y, hat_switch_map[idx].y); - break; - - default: - break; - } - - return (0); -} - static int ps4dshock_final_cb(HIDMAP_CB_ARGS) { @@ -1414,6 +1384,7 @@ DRIVER_MODULE(ps4dshock, hidbus, ps4dshock_driver, ps4dshock_devclass, NULL, 0); MODULE_DEPEND(ps4dshock, hid, 1, 1, 1); MODULE_DEPEND(ps4dshock, hidbus, 1, 1, 1); MODULE_DEPEND(ps4dshock, hidmap, 1, 1, 1); +MODULE_DEPEND(ps4dshock, hgame, 1, 1, 1); MODULE_DEPEND(ps4dshock, evdev, 1, 1, 1); MODULE_VERSION(ps4dshock, 1); HID_PNP_INFO(ps4dshock_devs); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2058E672BB1; Mon, 23 Aug 2021 22:26: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 4Gtmzt4lprz3NKf; Mon, 23 Aug 2021 22:26: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 5B8A21C806; Mon, 23 Aug 2021 22:26: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 17NMQITc014805; Mon, 23 Aug 2021 22:26:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQIfs014804; Mon, 23 Aug 2021 22:26:18 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:18 GMT Message-Id: <202108232226.17NMQIfs014804@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: bb5eb85e5c01 - stable/13 - ps4dshock(4): Fix touchpad width in HID report descriptor MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bb5eb85e5c01bf4bbd4e0424251bddbc0ed12129 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:19 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=bb5eb85e5c01bf4bbd4e0424251bddbc0ed12129 commit bb5eb85e5c01bf4bbd4e0424251bddbc0ed12129 Author: Vladimir Kondratyev AuthorDate: 2021-08-16 20:18:27 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:22:13 +0000 ps4dshock(4): Fix touchpad width in HID report descriptor (cherry picked from commit 9b2b5f42b4fee7fdb6c7653829da71e9706f849b) --- sys/dev/hid/ps4dshock.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/dev/hid/ps4dshock.c b/sys/dev/hid/ps4dshock.c index a4afba254c03..afb74bc4b843 100644 --- a/sys/dev/hid/ps4dshock.c +++ b/sys/dev/hid/ps4dshock.c @@ -215,7 +215,7 @@ static const uint8_t ps4dshock_rdesc[] = { 0x55, 0x0E, /* Unit Exponent (-2) */ 0x65, 0x11, /* Unit (System: SI Linear, Length: Centimeter) */ 0x35, 0x00, /* Physical Minimum (0) */ - 0x46, 0x80, 0x02, /* Physical Maximum (640) */ + 0x46, 0xB8, 0x01, /* Physical Maximum (440) */ 0x26, 0x80, 0x07, /* Logical Maximum (1920) */ 0x75, 0x0C, /* Report Size (12) */ 0x81, 0x02, /* Input (Data,Var,Abs) */ @@ -244,7 +244,7 @@ static const uint8_t ps4dshock_rdesc[] = { 0x55, 0x0E, /* Unit Exponent (-2) */ 0x65, 0x11, /* Unit (System: SI Linear, Length: Centimeter) */ 0x35, 0x00, /* Physical Minimum (0) */ - 0x46, 0x80, 0x02, /* Physical Maximum (640) */ + 0x46, 0xB8, 0x01, /* Physical Maximum (440) */ 0x26, 0x80, 0x07, /* Logical Maximum (1920) */ 0x75, 0x0C, /* Report Size (12) */ 0x81, 0x02, /* Input (Data,Var,Abs) */ @@ -284,7 +284,7 @@ static const uint8_t ps4dshock_rdesc[] = { 0x55, 0x0E, /* Unit Exponent (-2) */ 0x65, 0x11, /* Unit (System: SI Linear, Length: Centimeter) */ 0x35, 0x00, /* Physical Minimum (0) */ - 0x46, 0x80, 0x02, /* Physical Maximum (640) */ + 0x46, 0xB8, 0x01, /* Physical Maximum (440) */ 0x26, 0x80, 0x07, /* Logical Maximum (1920) */ 0x75, 0x0C, /* Report Size (12) */ 0x81, 0x02, /* Input (Data,Var,Abs) */ @@ -313,7 +313,7 @@ static const uint8_t ps4dshock_rdesc[] = { 0x55, 0x0E, /* Unit Exponent (-2) */ 0x65, 0x11, /* Unit (System: SI Linear, Length: Centimeter) */ 0x35, 0x00, /* Physical Minimum (0) */ - 0x46, 0x80, 0x02, /* Physical Maximum (640) */ + 0x46, 0xB8, 0x01, /* Physical Maximum (440) */ 0x26, 0x80, 0x07, /* Logical Maximum (1920) */ 0x75, 0x0C, /* Report Size (12) */ 0x81, 0x02, /* Input (Data,Var,Abs) */ @@ -353,7 +353,7 @@ static const uint8_t ps4dshock_rdesc[] = { 0x55, 0x0E, /* Unit Exponent (-2) */ 0x65, 0x11, /* Unit (System: SI Linear, Length: Centimeter) */ 0x35, 0x00, /* Physical Minimum (0) */ - 0x46, 0x80, 0x02, /* Physical Maximum (640) */ + 0x46, 0xB8, 0x01, /* Physical Maximum (440) */ 0x26, 0x80, 0x07, /* Logical Maximum (1920) */ 0x75, 0x0C, /* Report Size (12) */ 0x81, 0x02, /* Input (Data,Var,Abs) */ @@ -382,7 +382,7 @@ static const uint8_t ps4dshock_rdesc[] = { 0x55, 0x0E, /* Unit Exponent (-2) */ 0x65, 0x11, /* Unit (System: SI Linear, Length: Centimeter) */ 0x35, 0x00, /* Physical Minimum (0) */ - 0x46, 0x80, 0x02, /* Physical Maximum (640) */ + 0x46, 0xB8, 0x01, /* Physical Maximum (440) */ 0x26, 0x80, 0x07, /* Logical Maximum (1920) */ 0x75, 0x0C, /* Report Size (12) */ 0x81, 0x02, /* Input (Data,Var,Abs) */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD921672C50; Mon, 23 Aug 2021 22:26: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 4Gtmzv415Hz3NHf; Mon, 23 Aug 2021 22:26: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 71B5A1C62A; Mon, 23 Aug 2021 22:26: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 17NMQJo7014835; Mon, 23 Aug 2021 22:26:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQJwM014834; Mon, 23 Aug 2021 22:26:19 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:19 GMT Message-Id: <202108232226.17NMQJwM014834@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 290677c3d6f6 - stable/13 - hms(4): Allow attachment to pointer top level collection. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 290677c3d6f68882d68d3084f8510767ed2d8e08 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:19 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=290677c3d6f68882d68d3084f8510767ed2d8e08 commit 290677c3d6f68882d68d3084f8510767ed2d8e08 Author: Vladimir Kondratyev AuthorDate: 2021-08-16 20:18:43 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:22:43 +0000 hms(4): Allow attachment to pointer top level collection. to be in line with Microsoft mouse driver [1] [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/top-level-collections-opened-by-windows-for-system-use (cherry picked from commit 9b78891df13d12abaf8d0f0b0ca3e7d5f0e857e3) --- sys/dev/hid/hms.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/hid/hms.c b/sys/dev/hid/hms.c index 014354c3acc3..e9923f55861f 100644 --- a/sys/dev/hid/hms.c +++ b/sys/dev/hid/hms.c @@ -109,6 +109,7 @@ static const struct hidmap_item hms_map_wheel_rev[] = { /* A match on these entries will load hms */ static const struct hid_device_id hms_devs[] = { + { HID_TLC(HUP_GENERIC_DESKTOP, HUG_POINTER) }, { HID_TLC(HUP_GENERIC_DESKTOP, HUG_MOUSE) }, }; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 22:26:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 55791672D21; Mon, 23 Aug 2021 22:26: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 4Gtmzy08L9z3NNB; Mon, 23 Aug 2021 22:26: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 BC8941C4B7; Mon, 23 Aug 2021 22:26: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 17NMQL7r014883; Mon, 23 Aug 2021 22:26:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NMQLiv014882; Mon, 23 Aug 2021 22:26:21 GMT (envelope-from git) Date: Mon, 23 Aug 2021 22:26:21 GMT Message-Id: <202108232226.17NMQLiv014882@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 04a49585bb0a - stable/13 - evdev: Use bit_foreach helper macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 04a49585bb0a34e06df9b4f4ef6d6f425aa4b0f7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 22:26:22 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=04a49585bb0a34e06df9b4f4ef6d6f425aa4b0f7 commit 04a49585bb0a34e06df9b4f4ef6d6f425aa4b0f7 Author: Vladimir Kondratyev AuthorDate: 2021-08-16 21:28:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-23 22:23:41 +0000 evdev: Use bit_foreach helper macro for traversing all bits set in the bitstring(9). While here move bit_change() definition to common header. (cherry picked from commit 5f99ae56c9196753ae162ad464c2969ad1a131b6) --- sys/dev/evdev/evdev.c | 25 ++++++------------------- sys/dev/evdev/evdev_private.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index bc28ae0734f9..597342a364af 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -93,15 +93,6 @@ static void evdev_start_repeat(struct evdev_dev *, uint16_t); static void evdev_stop_repeat(struct evdev_dev *); static int evdev_check_event(struct evdev_dev *, uint16_t, uint16_t, int32_t); -static inline void -bit_change(bitstr_t *bitstr, int bit, int value) -{ - if (value) - bit_set(bitstr, bit); - else - bit_clear(bitstr, bit); -} - struct evdev_dev * evdev_alloc(void) { @@ -908,20 +899,16 @@ evdev_restore_after_kdb(struct evdev_dev *evdev) EVDEV_LOCK_ASSERT(evdev); /* Report postponed leds */ - for (code = 0; code < LED_CNT; code++) - if (bit_test(evdev->ev_kdb_led_states, code)) - evdev_send_event(evdev, EV_LED, code, - !bit_test(evdev->ev_led_states, code)); + bit_foreach(evdev->ev_kdb_led_states, LED_CNT, code) + evdev_send_event(evdev, EV_LED, code, + !bit_test(evdev->ev_led_states, code)); bit_nclear(evdev->ev_kdb_led_states, 0, LED_MAX); /* Release stuck keys (CTRL + ALT + ESC) */ evdev_stop_repeat(evdev); - for (code = 0; code < KEY_CNT; code++) { - if (bit_test(evdev->ev_key_states, code)) { - evdev_send_event(evdev, EV_KEY, code, KEY_EVENT_UP); - evdev_send_event(evdev, EV_SYN, SYN_REPORT, 1); - } - } + bit_foreach(evdev->ev_key_states, KEY_CNT, code) + evdev_send_event(evdev, EV_KEY, code, KEY_EVENT_UP); + evdev_send_event(evdev, EV_SYN, SYN_REPORT, 1); } int diff --git a/sys/dev/evdev/evdev_private.h b/sys/dev/evdev/evdev_private.h index 19636823b804..463f93847295 100644 --- a/sys/dev/evdev/evdev_private.h +++ b/sys/dev/evdev/evdev_private.h @@ -247,6 +247,16 @@ struct evdev_client (((client)->ec_buffer_ready + (client)->ec_buffer_size - \ (client)->ec_buffer_head) % (client)->ec_buffer_size) +/* bitstring(3) helper */ +static inline void +bit_change(bitstr_t *bitstr, int bit, int value) +{ + if (value) + bit_set(bitstr, bit); + else + bit_clear(bitstr, bit); +} + /* Input device interface: */ void evdev_send_event(struct evdev_dev *, uint16_t, uint16_t, int32_t); int evdev_inject_event(struct evdev_dev *, uint16_t, uint16_t, int32_t); From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EE8B6736B3; Mon, 23 Aug 2021 23:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtpDX2HQsz3tbw; Mon, 23 Aug 2021 23:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 16C101CCCB; Mon, 23 Aug 2021 23:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMJ8T094582; Mon, 23 Aug 2021 23:22:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNMJ7r094581; Mon, 23 Aug 2021 23:22:19 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:19 GMT Message-Id: <202108232322.17NNMJ7r094581@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: c946f699856f - stable/13 - amd64: rework AP startup 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: c946f699856f6737a5256d7c9f746ac8035339ee Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:20 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c946f699856f6737a5256d7c9f746ac8035339ee commit c946f699856f6737a5256d7c9f746ac8035339ee Author: Konstantin Belousov AuthorDate: 2021-07-10 19:38:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:12 +0000 amd64: rework AP startup (cherry picked from commit d6717f877872e62d9df1e0ce2d8856620c993924) --- sys/amd64/amd64/machdep.c | 4 +- sys/amd64/amd64/mp_machdep.c | 187 ++++++++++++++++--------------------------- sys/amd64/amd64/mpboot.S | 64 +++++++-------- sys/amd64/include/smp.h | 3 +- sys/x86/x86/mp_x86.c | 5 -- sys/x86/xen/pv.c | 1 - 6 files changed, 96 insertions(+), 168 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 93030cbe7126..840570be534a 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -187,7 +187,6 @@ struct init_ops init_ops = { .early_delay = i8254_delay, .parse_memmap = native_parse_memmap, #ifdef SMP - .mp_bootaddress = mp_bootaddress, .start_all_aps = native_start_all_aps, #endif #ifdef DEV_PCI @@ -1288,8 +1287,7 @@ getmemsize(caddr_t kmdp, u_int64_t first) * is configured to support APs and APs for the system start * in real mode mode (e.g. SMP bare metal). */ - if (init_ops.mp_bootaddress) - init_ops.mp_bootaddress(physmap, &physmap_idx); + alloc_ap_trampoline(physmap, &physmap_idx); /* call pmap initialization to make new kernel address space */ pmap_bootstrap(&first); diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index d1064262891f..082a58ada48f 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -106,6 +106,7 @@ char *dbg_stack; void *bootpcpu; extern u_int mptramp_la57; +extern u_int mptramp_nx; /* * Local data and functions. @@ -113,86 +114,6 @@ extern u_int mptramp_la57; static int start_ap(int apic_id); -static bool -is_kernel_paddr(vm_paddr_t pa) -{ - - return (pa >= trunc_2mpage(btext - KERNBASE) && - pa < round_page(_end - KERNBASE)); -} - -static bool -is_mpboot_good(vm_paddr_t start, vm_paddr_t end) -{ - - return (start + AP_BOOTPT_SZ <= GiB(4) && atop(end) < Maxmem); -} - -/* - * Calculate usable address in base memory for AP trampoline code. - */ -void -mp_bootaddress(vm_paddr_t *physmap, unsigned int *physmap_idx) -{ - vm_paddr_t start, end; - unsigned int i; - bool allocated; - - alloc_ap_trampoline(physmap, physmap_idx); - - /* - * Find a memory region big enough below the 4GB boundary to - * store the initial page tables. Region must be mapped by - * the direct map. - * - * Note that it needs to be aligned to a page boundary. - */ - allocated = false; - for (i = *physmap_idx; i <= *physmap_idx; i -= 2) { - /* - * First, try to chomp at the start of the physmap region. - * Kernel binary might claim it already. - */ - start = round_page(physmap[i]); - end = start + AP_BOOTPT_SZ; - if (start < end && end <= physmap[i + 1] && - is_mpboot_good(start, end) && - !is_kernel_paddr(start) && !is_kernel_paddr(end - 1)) { - allocated = true; - physmap[i] = end; - break; - } - - /* - * Second, try to chomp at the end. Again, check - * against kernel. - */ - end = trunc_page(physmap[i + 1]); - start = end - AP_BOOTPT_SZ; - if (start < end && start >= physmap[i] && - is_mpboot_good(start, end) && - !is_kernel_paddr(start) && !is_kernel_paddr(end - 1)) { - allocated = true; - physmap[i + 1] = start; - break; - } - } - if (allocated) { - mptramp_pagetables = start; - if (physmap[i] == physmap[i + 1] && *physmap_idx != 0) { - memmove(&physmap[i], &physmap[i + 2], - sizeof(*physmap) * (*physmap_idx - i + 2)); - *physmap_idx -= 2; - } - } else { - mptramp_pagetables = trunc_page(boot_address) - AP_BOOTPT_SZ; - if (bootverbose) - printf( -"Cannot find enough space for the initial AP page tables, placing them at %#x", - mptramp_pagetables); - } -} - /* * Initialize the IPI handlers and start up the AP's. */ @@ -244,6 +165,9 @@ cpu_mp_start(void) assign_cpu_ids(); mptramp_la57 = la57; + mptramp_nx = pg_nx != 0; + MPASS(kernel_pmap->pm_cr3 < (1UL << 32)); + mptramp_pagetables = kernel_pmap->pm_cr3; /* Start each Application Processor */ init_ops.start_all_aps(); @@ -398,55 +322,67 @@ mp_realloc_pcpu(int cpuid, int domain) int native_start_all_aps(void) { - u_int64_t *pt5, *pt4, *pt3, *pt2; + vm_page_t m_pml4, m_pdp, m_pd[4]; + pml5_entry_t old_pml45; + pml4_entry_t *v_pml4; + pdp_entry_t *v_pdp; + pd_entry_t *v_pd; u_int32_t mpbioswarmvec; - int apic_id, cpu, domain, i, xo; + int apic_id, cpu, domain, i; u_char mpbiosreason; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); - /* copy the AP 1st level boot code */ - bcopy(mptramp_start, (void *)PHYS_TO_DMAP(boot_address), bootMP_size); - - /* Locate the page tables, they'll be below the trampoline */ + /* Create a transient 1:1 mapping of low 4G */ if (la57) { - pt5 = (uint64_t *)PHYS_TO_DMAP(mptramp_pagetables); - xo = 1; + m_pml4 = pmap_page_alloc_below_4g(true); + v_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m_pml4)); } else { - xo = 0; + v_pml4 = &kernel_pmap->pm_pmltop[0]; } - pt4 = (uint64_t *)PHYS_TO_DMAP(mptramp_pagetables + xo * PAGE_SIZE); - pt3 = pt4 + (PAGE_SIZE) / sizeof(u_int64_t); - pt2 = pt3 + (PAGE_SIZE) / sizeof(u_int64_t); - - /* Create the initial 1GB replicated page tables */ - for (i = 0; i < 512; i++) { - if (la57) { - pt5[i] = (u_int64_t)(uintptr_t)(mptramp_pagetables + - PAGE_SIZE); - pt5[i] |= PG_V | PG_RW | PG_U; - } - - /* - * Each slot of the level 4 pages points to the same - * level 3 page. - */ - pt4[i] = (u_int64_t)(uintptr_t)(mptramp_pagetables + - (xo + 1) * PAGE_SIZE); - pt4[i] |= PG_V | PG_RW | PG_U; - - /* - * Each slot of the level 3 pages points to the same - * level 2 page. - */ - pt3[i] = (u_int64_t)(uintptr_t)(mptramp_pagetables + - ((xo + 2) * PAGE_SIZE)); - pt3[i] |= PG_V | PG_RW | PG_U; - - /* The level 2 page slots are mapped with 2MB pages for 1GB. */ - pt2[i] = i * (2 * 1024 * 1024); - pt2[i] |= PG_V | PG_RW | PG_PS | PG_U; + m_pdp = pmap_page_alloc_below_4g(true); + v_pdp = (pdp_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m_pdp)); + m_pd[0] = pmap_page_alloc_below_4g(false); + v_pd = (pd_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m_pd[0])); + for (i = 0; i < NPDEPG; i++) + v_pd[i] = (i << PDRSHIFT) | X86_PG_V | X86_PG_RW | X86_PG_A | + X86_PG_M | PG_PS; + m_pd[1] = pmap_page_alloc_below_4g(false); + v_pd = (pd_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m_pd[1])); + for (i = 0; i < NPDEPG; i++) + v_pd[i] = (NBPDP + (i << PDRSHIFT)) | X86_PG_V | X86_PG_RW | + X86_PG_A | X86_PG_M | PG_PS; + m_pd[2] = pmap_page_alloc_below_4g(false); + v_pd = (pd_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m_pd[2])); + for (i = 0; i < NPDEPG; i++) + v_pd[i] = (2UL * NBPDP + (i << PDRSHIFT)) | X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M | PG_PS; + m_pd[3] = pmap_page_alloc_below_4g(false); + v_pd = (pd_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m_pd[3])); + for (i = 0; i < NPDEPG; i++) + v_pd[i] = (3UL * NBPDP + (i << PDRSHIFT)) | X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M | PG_PS; + v_pdp[0] = VM_PAGE_TO_PHYS(m_pd[0]) | X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M; + v_pdp[1] = VM_PAGE_TO_PHYS(m_pd[1]) | X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M; + v_pdp[2] = VM_PAGE_TO_PHYS(m_pd[2]) | X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M; + v_pdp[3] = VM_PAGE_TO_PHYS(m_pd[3]) | X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M; + old_pml45 = kernel_pmap->pm_pmltop[0]; + if (la57) { + kernel_pmap->pm_pmltop[0] = VM_PAGE_TO_PHYS(m_pml4) | + X86_PG_V | X86_PG_RW | X86_PG_A | X86_PG_M; } + v_pml4[0] = VM_PAGE_TO_PHYS(m_pdp) | X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M; + pmap_invalidate_all(kernel_pmap); + + /* copy the AP 1st level boot code */ + bcopy(mptramp_start, (void *)PHYS_TO_DMAP(boot_address), bootMP_size); + if (bootverbose) + printf("AP boot address %#x\n", boot_address); /* save the current value of the warm-start vector */ if (!efi_boot) @@ -517,6 +453,17 @@ native_start_all_aps(void) outb(CMOS_REG, BIOS_RESET); outb(CMOS_DATA, mpbiosreason); + /* Destroy transient 1:1 mapping */ + kernel_pmap->pm_pmltop[0] = old_pml45; + invlpg(0); + if (la57) + vm_page_free(m_pml4); + vm_page_free(m_pd[3]); + vm_page_free(m_pd[2]); + vm_page_free(m_pd[1]); + vm_page_free(m_pd[0]); + vm_page_free(m_pdp); + /* number of APs actually started */ return (mp_naps); } diff --git a/sys/amd64/amd64/mpboot.S b/sys/amd64/amd64/mpboot.S index afdcffa573a4..1b5657d3bef8 100644 --- a/sys/amd64/amd64/mpboot.S +++ b/sys/amd64/amd64/mpboot.S @@ -95,12 +95,25 @@ protmode: * is later enabled. */ mov %cr4, %eax - orl $CR4_PAE, %eax + orl $(CR4_PAE | CR4_PGE), %eax cmpb $0, mptramp_la57-mptramp_start(%ebx) je 1f orl $CR4_LA57, %eax 1: mov %eax, %cr4 + /* + * If the BSP reported NXE support, enable EFER.NXE for all APs + * prior to loading %cr3. This avoids page faults if the AP + * encounters memory marked with the NX bit prior to detecting and + * enabling NXE support. + */ + cmpb $0,mptramp_nx-mptramp_start(%ebx) + je 2f + movl $MSR_EFER, %ecx + rdmsr + orl $EFER_NXE, %eax + wrmsr +2: /* * Enable EFER.LME so that we get long mode when all the prereqs are * in place. In this case, it turns on when CR0_PG is finally enabled. @@ -112,12 +125,13 @@ protmode: wrmsr /* - * Point to the embedded page tables for startup. Note that this - * only gets accessed after we're actually in 64 bit mode, however - * we can only set the bottom 32 bits of %cr3 in this state. This - * means we are required to use a temporary page table that is below - * the 4GB limit. %ebx is still our relocation base. We could just - * subtract 3 * PAGE_SIZE, but that would be too easy. + * Load kernel page table pointer into %cr3. + * %ebx is still our relocation base. + * + * Note that this only gets accessed after we're actually in 64 bit + * mode, however we can only set the bottom 32 bits of %cr3 in this + * state. This means we depend on the kernel page table being + * allocated from the low 4G. */ leal mptramp_pagetables-mptramp_start(%ebx),%eax movl (%eax), %eax @@ -155,10 +169,8 @@ jmp_64: /* * Yeehar! We're running in 64 bit mode! We can mostly ignore our * segment registers, and get on with it. - * Note that we are running at the correct virtual address, but with - * a 1:1 1GB mirrored mapping over entire address space. We had better - * switch to a real %cr3 promptly so that we can get to the direct map - * space. Remember that jmp is relative and that we've been relocated, + * We are running at the correct virtual address space. + * Note that the jmp is relative and that we've been relocated, * so use an indirect jump. */ .code64 @@ -220,6 +232,10 @@ mptramp_pagetables: mptramp_la57: .long 0 + .globl mptramp_nx +mptramp_nx: + .long 0 + /* * The pseudo descriptor for lgdt to use. */ @@ -243,32 +259,6 @@ bootMP_size: .code64 .p2align 4,0 entry_64: - /* - * If the BSP reported NXE support, enable EFER.NXE for all APs - * prior to loading %cr3. This avoids page faults if the AP - * encounters memory marked with the NX bit prior to detecting and - * enabling NXE support. - */ - movq pg_nx, %rbx - testq %rbx, %rbx - je 1f - movl $MSR_EFER, %ecx - rdmsr - orl $EFER_NXE, %eax - wrmsr - -1: - /* - * Load a real %cr3 that has all the direct map stuff and switches - * off the 1GB replicated mirror. Load a stack pointer and jump - * into AP startup code in C. - */ - cmpl $0, la57 - jne 2f - movq KPML4phys, %rax - jmp 3f -2: movq KPML5phys, %rax -3: movq %rax, %cr3 movq bootSTK, %rsp /* diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index 8fbd89da0e57..84ee73cef723 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -38,8 +38,7 @@ inthand_t IDTVEC(rendezvous_pti); void invlop_handler(void); -int native_start_all_aps(void); -void mp_bootaddress(vm_paddr_t *, unsigned int *); +int native_start_all_aps(void); #endif /* !LOCORE */ #endif /* SMP */ diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index f1c1e45e79b8..441a766f87fb 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -1070,11 +1070,6 @@ init_secondary_tail(void) } #ifdef __amd64__ - /* - * Enable global pages TLB extension - * This also implicitly flushes the TLB - */ - load_cr4(rcr4() | CR4_PGE); if (pmap_pcid_enabled) load_cr4(rcr4() | CR4_PCIDE); load_ds(_udatasel); diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 2fd698772f9d..59c5b464aace 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -134,7 +134,6 @@ struct init_ops xen_pvh_init_ops = { .early_delay = xen_delay, .parse_memmap = xen_pvh_parse_memmap, #ifdef SMP - .mp_bootaddress = mp_bootaddress, .start_all_aps = native_start_all_aps, #endif .msi_init = msi_init, From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 80EE26738C2; Mon, 23 Aug 2021 23:22:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtpDY2ftXz3tYX; Mon, 23 Aug 2021 23:22:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C0981D0B5; Mon, 23 Aug 2021 23:22:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMLPi094606; Mon, 23 Aug 2021 23:22:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNML4T094605; Mon, 23 Aug 2021 23:22:21 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:21 GMT Message-Id: <202108232322.17NNML4T094605@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: a8d453eec1e3 - stable/13 - amd64: stop doing special allocation for the AP startup trampoline 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: a8d453eec1e3ea7c62e82a8e591035876da2580e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:21 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a8d453eec1e3ea7c62e82a8e591035876da2580e commit a8d453eec1e3ea7c62e82a8e591035876da2580e Author: Konstantin Belousov AuthorDate: 2021-07-29 00:22:35 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:13 +0000 amd64: stop doing special allocation for the AP startup trampoline (cherry picked from commit b27fe1c3ba2a1302c2866751e0c618b5a697bf30) --- sys/amd64/amd64/machdep.c | 8 ------- sys/amd64/amd64/mp_machdep.c | 19 +++++++++++---- sys/i386/i386/mp_machdep.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ sys/x86/include/x86_smp.h | 10 ++++++-- sys/x86/x86/mp_x86.c | 54 ------------------------------------------- 5 files changed, 77 insertions(+), 69 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 840570be534a..63f933ad535c 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1281,14 +1281,6 @@ getmemsize(caddr_t kmdp, u_int64_t first) (boothowto & RB_VERBOSE)) printf("Physical memory use set to %ldK\n", Maxmem * 4); - /* - * Make hole for "AP -> long mode" bootstrap code. The - * mp_bootaddress vector is only available when the kernel - * is configured to support APs and APs for the system start - * in real mode mode (e.g. SMP bare metal). - */ - alloc_ap_trampoline(physmap, &physmap_idx); - /* call pmap initialization to make new kernel address space */ pmap_bootstrap(&first); diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 082a58ada48f..383226b96d10 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -112,7 +112,7 @@ extern u_int mptramp_nx; * Local data and functions. */ -static int start_ap(int apic_id); +static int start_ap(int apic_id, vm_paddr_t boot_address); /* * Initialize the IPI handlers and start up the AP's. @@ -322,17 +322,25 @@ mp_realloc_pcpu(int cpuid, int domain) int native_start_all_aps(void) { - vm_page_t m_pml4, m_pdp, m_pd[4]; + vm_page_t m_boottramp, m_pml4, m_pdp, m_pd[4]; pml5_entry_t old_pml45; pml4_entry_t *v_pml4; pdp_entry_t *v_pdp; pd_entry_t *v_pd; + vm_paddr_t boot_address; u_int32_t mpbioswarmvec; int apic_id, cpu, domain, i; u_char mpbiosreason; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); + MPASS(bootMP_size <= PAGE_SIZE); + m_boottramp = vm_page_alloc_contig(NULL, 0, VM_ALLOC_NORMAL | + VM_ALLOC_NOBUSY | VM_ALLOC_NOOBJ, 1, 0, + (1ULL << 20), /* Trampoline should be below 1M for real mode */ + PAGE_SIZE, 0, VM_MEMATTR_DEFAULT); + boot_address = VM_PAGE_TO_PHYS(m_boottramp); + /* Create a transient 1:1 mapping of low 4G */ if (la57) { m_pml4 = pmap_page_alloc_below_4g(true); @@ -382,7 +390,7 @@ native_start_all_aps(void) /* copy the AP 1st level boot code */ bcopy(mptramp_start, (void *)PHYS_TO_DMAP(boot_address), bootMP_size); if (bootverbose) - printf("AP boot address %#x\n", boot_address); + printf("AP boot address %#lx\n", boot_address); /* save the current value of the warm-start vector */ if (!efi_boot) @@ -436,7 +444,7 @@ native_start_all_aps(void) bootAP = cpu; /* attempt to start the Application Processor */ - if (!start_ap(apic_id)) { + if (!start_ap(apic_id, boot_address)) { /* restore the warmstart vector */ if (!efi_boot) *(u_int32_t *)WARMBOOT_OFF = mpbioswarmvec; @@ -463,6 +471,7 @@ native_start_all_aps(void) vm_page_free(m_pd[1]); vm_page_free(m_pd[0]); vm_page_free(m_pdp); + vm_page_free(m_boottramp); /* number of APs actually started */ return (mp_naps); @@ -476,7 +485,7 @@ native_start_all_aps(void) * but it seems to work. */ static int -start_ap(int apic_id) +start_ap(int apic_id, vm_paddr_t boot_address) { int vector, ms; int cpus; diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 91ca6945f1ae..156702118c45 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -147,6 +147,61 @@ static int start_ap(int apic_id); static char *ap_copyout_buf; static char *ap_tramp_stack_base; + +unsigned int boot_address; + +#define MiB(v) (v ## ULL << 20) + +/* Allocate memory for the AP trampoline. */ +void +alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int *physmap_idx) +{ + unsigned int i; + bool allocated; + + allocated = false; + for (i = *physmap_idx; i <= *physmap_idx; i -= 2) { + /* + * Find a memory region big enough and below the 1MB boundary + * for the trampoline code. + * NB: needs to be page aligned. + */ + if (physmap[i] >= MiB(1) || + (trunc_page(physmap[i + 1]) - round_page(physmap[i])) < + round_page(bootMP_size)) + continue; + + allocated = true; + /* + * Try to steal from the end of the region to mimic previous + * behaviour, else fallback to steal from the start. + */ + if (physmap[i + 1] < MiB(1)) { + boot_address = trunc_page(physmap[i + 1]); + if ((physmap[i + 1] - boot_address) < bootMP_size) + boot_address -= round_page(bootMP_size); + physmap[i + 1] = boot_address; + } else { + boot_address = round_page(physmap[i]); + physmap[i] = boot_address + round_page(bootMP_size); + } + if (physmap[i] == physmap[i + 1] && *physmap_idx != 0) { + memmove(&physmap[i], &physmap[i + 2], + sizeof(*physmap) * (*physmap_idx - i + 2)); + *physmap_idx -= 2; + } + break; + } + + if (!allocated) { + boot_address = basemem * 1024 - bootMP_size; + if (bootverbose) + printf( +"Cannot find enough space for the boot trampoline, placing it at %#x", + boot_address); + } +} + /* * Initialize the IPI handlers and start up the AP's. */ diff --git a/sys/x86/include/x86_smp.h b/sys/x86/include/x86_smp.h index e01f869a58f6..b9a1febb70f2 100644 --- a/sys/x86/include/x86_smp.h +++ b/sys/x86/include/x86_smp.h @@ -23,6 +23,10 @@ struct pmap; +#ifdef __i386__ +extern unsigned int boot_address; +#endif + /* global data in mp_x86.c */ extern int mp_naps; extern int boot_cpu_id; @@ -32,7 +36,6 @@ extern int bootAP; extern void *dpcpu; extern char *bootSTK; extern void *bootstacks[]; -extern unsigned int boot_address; extern unsigned int bootMP_size; extern volatile int aps_ready; extern struct mtx ap_boot_mtx; @@ -84,12 +87,15 @@ inthand_t typedef void (*smp_invl_cb_t)(struct pmap *, vm_offset_t addr1, vm_offset_t addr2); +#ifdef __i386__ +void alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int *physmap_idx); +#endif + /* functions in x86_mp.c */ void assign_cpu_ids(void); void cpu_add(u_int apic_id, char boot_cpu); void cpustop_handler(void); void cpususpend_handler(void); -void alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int *physmap_idx); void init_secondary_tail(void); void init_secondary(void); void ipi_startup(int apic_id, int vector); diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 441a766f87fb..db40aab28ad5 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -167,14 +167,10 @@ struct cache_info { int present; } static caches[MAX_CACHE_LEVELS]; -unsigned int boot_address; - static bool stop_mwait = false; SYSCTL_BOOL(_machdep, OID_AUTO, stop_mwait, CTLFLAG_RWTUN, &stop_mwait, 0, "Use MONITOR/MWAIT when stopping CPU, if available"); -#define MiB(v) (v ## ULL << 20) - void mem_range_AP_init(void) { @@ -938,56 +934,6 @@ cpu_mp_probe(void) return (mp_ncpus > 1); } -/* Allocate memory for the AP trampoline. */ -void -alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int *physmap_idx) -{ - unsigned int i; - bool allocated; - - allocated = false; - for (i = *physmap_idx; i <= *physmap_idx; i -= 2) { - /* - * Find a memory region big enough and below the 1MB boundary - * for the trampoline code. - * NB: needs to be page aligned. - */ - if (physmap[i] >= MiB(1) || - (trunc_page(physmap[i + 1]) - round_page(physmap[i])) < - round_page(bootMP_size)) - continue; - - allocated = true; - /* - * Try to steal from the end of the region to mimic previous - * behaviour, else fallback to steal from the start. - */ - if (physmap[i + 1] < MiB(1)) { - boot_address = trunc_page(physmap[i + 1]); - if ((physmap[i + 1] - boot_address) < bootMP_size) - boot_address -= round_page(bootMP_size); - physmap[i + 1] = boot_address; - } else { - boot_address = round_page(physmap[i]); - physmap[i] = boot_address + round_page(bootMP_size); - } - if (physmap[i] == physmap[i + 1] && *physmap_idx != 0) { - memmove(&physmap[i], &physmap[i + 2], - sizeof(*physmap) * (*physmap_idx - i + 2)); - *physmap_idx -= 2; - } - break; - } - - if (!allocated) { - boot_address = basemem * 1024 - bootMP_size; - if (bootverbose) - printf( -"Cannot find enough space for the boot trampoline, placing it at %#x", - boot_address); - } -} - /* * AP CPU's call this to initialize themselves. */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 00C8A673AB6; Mon, 23 Aug 2021 23:22: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 4GtpDb6Gk8z3tc9; Mon, 23 Aug 2021 23:22:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 753511D3AF; Mon, 23 Aug 2021 23:22:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMNkm094654; Mon, 23 Aug 2021 23:22:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNMNHl094653; Mon, 23 Aug 2021 23:22:23 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:23 GMT Message-Id: <202108232322.17NNMNHl094653@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: a686d177a7f6 - stable/13 - Add pmap_vm_page_alloc_check() 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: a686d177a7f6b13566b52f6f73e19d3de62ce623 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:24 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a686d177a7f6b13566b52f6f73e19d3de62ce623 commit a686d177a7f6b13566b52f6f73e19d3de62ce623 Author: Konstantin Belousov AuthorDate: 2021-07-10 19:53:41 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:13 +0000 Add pmap_vm_page_alloc_check() (cherry picked from commit 041b7317f75ecc5e1629e2dd6786c8bdbe1b19eb) --- sys/amd64/include/pmap.h | 4 ++++ sys/arm/include/pmap.h | 2 ++ sys/arm64/include/pmap.h | 2 ++ sys/i386/include/pmap.h | 2 ++ sys/mips/include/pmap.h | 2 ++ sys/powerpc/include/pmap.h | 2 ++ sys/riscv/include/pmap.h | 2 ++ sys/vm/vm_page.c | 1 + 8 files changed, 17 insertions(+) diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index d06a618a08b6..fed65f6aa728 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -448,6 +448,10 @@ extern int invpcid_works; #define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) #define pmap_unmapbios(va, sz) pmap_unmapdev((va), (sz)) +#define pmap_vm_page_alloc_check(m) \ + KASSERT(m->phys_addr < kernphys || m->phys_addr >= KERNend, \ + ("allocating kernel page %p", m)); + struct thread; void pmap_activate_boot(pmap_t pmap); diff --git a/sys/arm/include/pmap.h b/sys/arm/include/pmap.h index 2f407a9c8760..d06d44d648d5 100644 --- a/sys/arm/include/pmap.h +++ b/sys/arm/include/pmap.h @@ -73,5 +73,7 @@ pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused) #define PMAP_ENTER_QUICK_LOCKED 0x10000000 +#define pmap_vm_page_alloc_check(m) + #endif /* _KERNEL */ #endif /* !_MACHINE_PMAP_H_ */ diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h index b05fee999c73..da739bb765e8 100644 --- a/sys/arm64/include/pmap.h +++ b/sys/arm64/include/pmap.h @@ -162,6 +162,8 @@ extern vm_offset_t virtual_end; #define L1_MAPPABLE_P(va, pa, size) \ ((((va) | (pa)) & L1_OFFSET) == 0 && (size) >= L1_SIZE) +#define pmap_vm_page_alloc_check(m) + void pmap_activate_vm(pmap_t); void pmap_bootstrap(vm_offset_t, vm_offset_t, vm_paddr_t, vm_size_t); int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode); diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h index f2e65c829ff4..5ac99b92cad3 100644 --- a/sys/i386/include/pmap.h +++ b/sys/i386/include/pmap.h @@ -238,6 +238,8 @@ pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused) struct sf_buf; +#define pmap_vm_page_alloc_check(m) + /* * Only the following functions or macros may be used before pmap_bootstrap() * is called: pmap_kenter(), pmap_kextract(), pmap_kremove(), vtophys(), and diff --git a/sys/mips/include/pmap.h b/sys/mips/include/pmap.h index 77f75903ccd5..7161a02481c7 100644 --- a/sys/mips/include/pmap.h +++ b/sys/mips/include/pmap.h @@ -166,6 +166,8 @@ extern vm_offset_t virtual_end; #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) #define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) +#define pmap_vm_page_alloc_check(m) + void pmap_bootstrap(void); void *pmap_mapdev(vm_paddr_t, vm_size_t); void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t); diff --git a/sys/powerpc/include/pmap.h b/sys/powerpc/include/pmap.h index a292be660b09..2f1886a27093 100644 --- a/sys/powerpc/include/pmap.h +++ b/sys/powerpc/include/pmap.h @@ -301,6 +301,8 @@ extern struct pmap kernel_pmap_store; #define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) +#define pmap_vm_page_alloc_check(m) + void pmap_bootstrap(vm_offset_t, vm_offset_t); void pmap_kenter(vm_offset_t va, vm_paddr_t pa); void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t); diff --git a/sys/riscv/include/pmap.h b/sys/riscv/include/pmap.h index 64b529e95887..599adfa4ce19 100644 --- a/sys/riscv/include/pmap.h +++ b/sys/riscv/include/pmap.h @@ -139,6 +139,8 @@ extern vm_offset_t virtual_end; struct thread; +#define pmap_vm_page_alloc_check(m) + void pmap_activate_boot(pmap_t); void pmap_activate_sw(struct thread *); void pmap_bootstrap(vm_offset_t, vm_paddr_t, vm_size_t); diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index cdcd9a366212..aae45513a44c 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2416,6 +2416,7 @@ vm_page_alloc_check(vm_page_t m) ("page %p has unexpected memattr %d", m, pmap_page_get_memattr(m))); KASSERT(m->valid == 0, ("free page %p is valid", m)); + pmap_vm_page_alloc_check(m); } /* From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BA13B673DC9; Mon, 23 Aug 2021 23:22:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtpDd0FY9z3tfT; Mon, 23 Aug 2021 23:22:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 989A21CF4A; Mon, 23 Aug 2021 23:22:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMOuL094678; Mon, 23 Aug 2021 23:22:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNMOma094677; Mon, 23 Aug 2021 23:22:24 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:24 GMT Message-Id: <202108232322.17NNMOma094677@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: 945220915466 - stable/13 - amd64 pmap_vm_page_alloc_check(): print more data for failed assert 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: 94522091546658722a943ed484089b7d96b00f90 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:25 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=94522091546658722a943ed484089b7d96b00f90 commit 94522091546658722a943ed484089b7d96b00f90 Author: Konstantin Belousov AuthorDate: 2021-08-01 13:38:17 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:14 +0000 amd64 pmap_vm_page_alloc_check(): print more data for failed assert (cherry picked from commit 1a55a3a729cd4424e17308d3e86b54b9a6e68f7b) --- sys/amd64/include/pmap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index fed65f6aa728..3228494a2aaa 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -450,7 +450,8 @@ extern int invpcid_works; #define pmap_vm_page_alloc_check(m) \ KASSERT(m->phys_addr < kernphys || m->phys_addr >= KERNend, \ - ("allocating kernel page %p", m)); + ("allocating kernel page %p pa %#lx kernphys %#lx kernend %#lx", \ + m, m->phys_addr, kernphys, KERNend)); struct thread; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F606673AB8; Mon, 23 Aug 2021 23:22:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtpDd6b55z3tNV; Mon, 23 Aug 2021 23:22:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A74381CF4C; Mon, 23 Aug 2021 23:22:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMPxV094709; Mon, 23 Aug 2021 23:22:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNMPLs094708; Mon, 23 Aug 2021 23:22:25 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:25 GMT Message-Id: <202108232322.17NNMPLs094708@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: 89423483e83f - stable/13 - amd64 pmap_vm_page_alloc_check(): loose the assert 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: 89423483e83f93993a01c3d5eb3bc3b626e74193 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:26 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=89423483e83f93993a01c3d5eb3bc3b626e74193 commit 89423483e83f93993a01c3d5eb3bc3b626e74193 Author: Konstantin Belousov AuthorDate: 2021-08-01 21:58:21 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:14 +0000 amd64 pmap_vm_page_alloc_check(): loose the assert (cherry picked from commit 665895db262fa596b347e40f6857b37e0f43b184) --- sys/amd64/include/pmap.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index 3228494a2aaa..6fb240e6363a 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -449,9 +449,10 @@ extern int invpcid_works; #define pmap_unmapbios(va, sz) pmap_unmapdev((va), (sz)) #define pmap_vm_page_alloc_check(m) \ - KASSERT(m->phys_addr < kernphys || m->phys_addr >= KERNend, \ - ("allocating kernel page %p pa %#lx kernphys %#lx kernend %#lx", \ - m, m->phys_addr, kernphys, KERNend)); + KASSERT(m->phys_addr < kernphys || \ + m->phys_addr >= kernphys + (vm_offset_t)&_end - KERNSTART, \ + ("allocating kernel page %p pa %#lx kernphys %#lx end %p", \ + m, m->phys_addr, kernphys, &_end)); struct thread; From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C9CDD6736B9; Mon, 23 Aug 2021 23:22:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtpDZ3GYFz3tYd; Mon, 23 Aug 2021 23:22:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 50BE81D32C; Mon, 23 Aug 2021 23:22:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMMFm094630; Mon, 23 Aug 2021 23:22:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNMMZI094629; Mon, 23 Aug 2021 23:22:22 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:22 GMT Message-Id: <202108232322.17NNMMZI094629@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: 8ca493ffb446 - stable/13 - amd64: do not assume that kernel is loaded at 2M physical 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: 8ca493ffb44691e70ae92300b8de1c1d30134ef4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:22 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8ca493ffb44691e70ae92300b8de1c1d30134ef4 commit 8ca493ffb44691e70ae92300b8de1c1d30134ef4 Author: Konstantin Belousov AuthorDate: 2021-07-10 19:48:02 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:13 +0000 amd64: do not assume that kernel is loaded at 2M physical (cherry picked from commit e18380e341410ce70d97560a22827591f4b2d373) --- sys/amd64/amd64/machdep.c | 38 ++++++++++++++++++++++-- sys/amd64/amd64/pmap.c | 72 +++++++++++++++++++++++++++------------------ sys/amd64/include/md_var.h | 7 ++--- sys/amd64/include/vmparam.h | 16 ++++++++-- sys/conf/ldscript.amd64 | 5 ++-- 5 files changed, 96 insertions(+), 42 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 63f933ad535c..2c8711fd3d2a 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1599,7 +1599,10 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) int gsel_tss, x; struct pcpu *pc; struct xstate_hdr *xhdr; - u_int64_t rsp0; + uint64_t cr3, rsp0; + pml4_entry_t *pml4e; + pdp_entry_t *pdpe; + pd_entry_t *pde; char *env; struct user_segment_descriptor *gdt; struct region_descriptor r_gdt; @@ -1608,6 +1611,35 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TSRAW(&thread0, TS_ENTER, __func__, NULL); + /* + * Calculate kernphys by inspecting page table created by loader. + * The assumptions: + * - kernel is mapped at KERNBASE, backed by contiguous phys memory + * aligned at 2M, below 4G (the latter is important for AP startup) + * - there is a 2M hole at KERNBASE + * - kernel is mapped with 2M superpages + * - all participating memory, i.e. kernel, modules, metadata, + * page table is accessible by pre-created 1:1 mapping + * (right now loader creates 1:1 mapping for lower 4G, and all + * memory is from there) + * - there is a usable memory block right after the end of the + * mapped kernel and all modules/metadata, pointed to by + * physfree, for early allocations + */ + cr3 = rcr3(); + pml4e = (pml4_entry_t *)(cr3 & ~PAGE_MASK) + pmap_pml4e_index( + (vm_offset_t)hammer_time); + pdpe = (pdp_entry_t *)(*pml4e & ~PAGE_MASK) + pmap_pdpe_index( + (vm_offset_t)hammer_time); + pde = (pd_entry_t *)(*pdpe & ~PAGE_MASK) + pmap_pde_index( + (vm_offset_t)hammer_time); + kernphys = (vm_paddr_t)(*pde & ~PDRMASK) - + (vm_paddr_t)(((vm_offset_t)hammer_time - KERNBASE) & ~PDRMASK); + + /* Fix-up for 2M hole */ + physfree += kernphys; + kernphys += NBPDR; + kmdp = init_ops.parse_preload_data(modulep); efi_boot = preload_search_info(kmdp, MODINFO_METADATA | @@ -1653,7 +1685,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) /* Init basic tunables, hz etc */ init_param1(); - thread0.td_kstack = physfree + KERNBASE; + thread0.td_kstack = physfree - kernphys + KERNSTART; thread0.td_kstack_pages = kstack_pages; kstack0_sz = thread0.td_kstack_pages * PAGE_SIZE; bzero((void *)thread0.td_kstack, kstack0_sz); @@ -1690,7 +1722,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) wrmsr(MSR_GSBASE, (u_int64_t)pc); wrmsr(MSR_KGSBASE, 0); /* User value while in the kernel */ - dpcpu_init((void *)(physfree + KERNBASE), 0); + dpcpu_init((void *)(physfree - kernphys + KERNSTART), 0); physfree += DPCPU_SIZE; amd64_bsp_pcpu_init1(pc); /* Non-late cninit() and printf() can be moved up to here. */ diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index e5d46449c275..d35422924b1f 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -429,7 +429,8 @@ static u_int64_t DMPDphys; /* phys addr of direct mapped level 2 */ static u_int64_t DMPDPphys; /* phys addr of direct mapped level 3 */ static int ndmpdpphys; /* number of DMPDPphys pages */ -static vm_paddr_t KERNend; /* phys addr of end of bootstrap data */ +vm_paddr_t kernphys; /* phys addr of start of bootstrap data */ +vm_paddr_t KERNend; /* and the end */ /* * pmap_mapdev support pre initialization (i.e. console) @@ -1532,7 +1533,7 @@ nkpt_init(vm_paddr_t addr) #ifdef NKPT pt_pages = NKPT; #else - pt_pages = howmany(addr, NBPDR); + pt_pages = howmany(addr - kernphys, NBPDR) + 1; /* +1 for 2M hole @0 */ pt_pages += NKPDPE(pt_pages); /* @@ -1572,7 +1573,6 @@ nkpt_init(vm_paddr_t addr) static inline pt_entry_t bootaddr_rwx(vm_paddr_t pa) { - /* * The kernel is loaded at a 2MB-aligned address, and memory below that * need not be executable. The .bss section is padded to a 2MB @@ -1580,8 +1580,8 @@ bootaddr_rwx(vm_paddr_t pa) * either. Preloaded kernel modules have their mapping permissions * fixed up by the linker. */ - if (pa < trunc_2mpage(btext - KERNBASE) || - pa >= trunc_2mpage(_end - KERNBASE)) + if (pa < trunc_2mpage(kernphys + btext - KERNSTART) || + pa >= trunc_2mpage(kernphys + _end - KERNSTART)) return (X86_PG_RW | pg_nx); /* @@ -1590,7 +1590,7 @@ bootaddr_rwx(vm_paddr_t pa) * impact read-only data. However, in any case, any page with * read-write data needs to be read-write. */ - if (pa >= trunc_2mpage(brwsection - KERNBASE)) + if (pa >= trunc_2mpage(kernphys + brwsection - KERNSTART)) return (X86_PG_RW | pg_nx); /* @@ -1602,7 +1602,7 @@ bootaddr_rwx(vm_paddr_t pa) * Note that fixups to the .text section will still work until we * set CR0.WP. */ - if (pa < round_2mpage(etext - KERNBASE)) + if (pa < round_2mpage(kernphys + etext - KERNSTART)) return (0); return (pg_nx); } @@ -1610,11 +1610,12 @@ bootaddr_rwx(vm_paddr_t pa) static void create_pagetables(vm_paddr_t *firstaddr) { - int i, j, ndm1g, nkpdpe, nkdmpde; pd_entry_t *pd_p; pdp_entry_t *pdp_p; pml4_entry_t *p4_p; uint64_t DMPDkernphys; + vm_paddr_t pax; + int i, j, ndm1g, nkpdpe, nkdmpde; /* Allocate page table pages for the direct map */ ndmpdp = howmany(ptoa(Maxmem), NBPDP); @@ -1642,9 +1643,11 @@ create_pagetables(vm_paddr_t *firstaddr) /* * Allocate 2M pages for the kernel. These will be used in - * place of the first one or more 1G pages from ndm1g. + * place of the one or more 1G pages from ndm1g that maps + * kernel memory into DMAP. */ - nkdmpde = howmany((vm_offset_t)(brwsection - KERNBASE), NBPDP); + nkdmpde = howmany((vm_offset_t)brwsection - KERNSTART + + kernphys - rounddown2(kernphys, NBPDP), NBPDP); DMPDkernphys = allocpages(firstaddr, nkdmpde); } if (ndm1g < ndmpdp) @@ -1681,14 +1684,18 @@ create_pagetables(vm_paddr_t *firstaddr) pd_p[i] = (KPTphys + ptoa(i)) | X86_PG_RW | X86_PG_V; /* - * Map from physical address zero to the end of loader preallocated - * memory using 2MB pages. This replaces some of the PD entries - * created above. + * Map from start of the kernel in physical memory (staging + * area) to the end of loader preallocated memory using 2MB + * pages. This replaces some of the PD entries created above. + * For compatibility, identity map 2M at the start. */ - for (i = 0; (i << PDRSHIFT) < KERNend; i++) + pd_p[0] = X86_PG_V | PG_PS | pg_g | X86_PG_M | X86_PG_A | + X86_PG_RW | pg_nx; + for (i = 1, pax = kernphys; pax < KERNend; i++, pax += NBPDR) { /* Preset PG_M and PG_A because demotion expects it. */ - pd_p[i] = (i << PDRSHIFT) | X86_PG_V | PG_PS | pg_g | - X86_PG_M | X86_PG_A | bootaddr_rwx(i << PDRSHIFT); + pd_p[i] = pax | X86_PG_V | PG_PS | pg_g | X86_PG_M | + X86_PG_A | bootaddr_rwx(pax); + } /* * Because we map the physical blocks in 2M pages, adjust firstaddr @@ -1735,15 +1742,18 @@ create_pagetables(vm_paddr_t *firstaddr) * use 2M pages with read-only and no-execute permissions. (If using 1G * pages, this will partially overwrite the PDPEs above.) */ - if (ndm1g) { + if (ndm1g > 0) { pd_p = (pd_entry_t *)DMPDkernphys; - for (i = 0; i < (NPDEPG * nkdmpde); i++) - pd_p[i] = (i << PDRSHIFT) | X86_PG_V | PG_PS | pg_g | - X86_PG_M | X86_PG_A | pg_nx | - bootaddr_rwx(i << PDRSHIFT); - for (i = 0; i < nkdmpde; i++) - pdp_p[i] = (DMPDkernphys + ptoa(i)) | X86_PG_RW | - X86_PG_V | pg_nx; + for (i = 0, pax = rounddown2(kernphys, NBPDP); + i < NPDEPG * nkdmpde; i++, pax += NBPDR) { + pd_p[i] = pax | X86_PG_V | PG_PS | pg_g | X86_PG_M | + X86_PG_A | pg_nx | bootaddr_rwx(pax); + } + j = rounddown2(kernphys, NBPDP) >> PDPSHIFT; + for (i = 0; i < nkdmpde; i++) { + pdp_p[i + j] = (DMPDkernphys + ptoa(i)) | + X86_PG_RW | X86_PG_V | pg_nx; + } } /* And recursively map PML4 to itself in order to get PTmap */ @@ -1811,7 +1821,8 @@ pmap_bootstrap(vm_paddr_t *firstaddr) /* * Account for the virtual addresses mapped by create_pagetables(). */ - virtual_avail = (vm_offset_t)KERNBASE + round_2mpage(KERNend); + virtual_avail = (vm_offset_t)KERNSTART + round_2mpage(KERNend - + (vm_paddr_t)kernphys); virtual_end = VM_MAX_KERNEL_ADDRESS; /* @@ -2348,7 +2359,8 @@ pmap_init(void) * Collect the page table pages that were replaced by a 2MB * page in create_pagetables(). They are zero filled. */ - if ((vm_paddr_t)i << PDRSHIFT < KERNend && + if ((i == 0 || + kernphys + ((vm_paddr_t)(i - 1) << PDRSHIFT) < KERNend) && pmap_insert_pt_page(kernel_pmap, mpte, false)) panic("pmap_init: pmap_insert_pt_page failed"); } @@ -6567,7 +6579,9 @@ setpte: mpte < &vm_page_array[vm_page_array_size], ("pmap_promote_pde: page table page is out of range")); KASSERT(mpte->pindex == pmap_pde_pindex(va), - ("pmap_promote_pde: page table page's pindex is wrong")); + ("pmap_promote_pde: page table page's pindex is wrong " + "mpte %p pidx %#lx va %#lx va pde pidx %#lx", + mpte, mpte->pindex, va, pmap_pde_pindex(va))); if (pmap_insert_pt_page(pmap, mpte, true)) { atomic_add_long(&pmap_pde_p_failures, 1); CTR2(KTR_PMAP, @@ -10625,8 +10639,8 @@ pmap_pti_init(void) va = __pcpu[i].pc_common_tss.tss_ist4 + sizeof(struct nmi_pcpu); pmap_pti_add_kva_locked(va - DBG_STACK_SIZE, va, false); } - pmap_pti_add_kva_locked((vm_offset_t)KERNBASE + NBPDR, - (vm_offset_t)etext, true); + pmap_pti_add_kva_locked((vm_offset_t)KERNSTART, (vm_offset_t)etext, + true); pti_finalized = true; VM_OBJECT_WUNLOCK(pti_obj); } diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h index b66e314d99b1..53139711bbff 100644 --- a/sys/amd64/include/md_var.h +++ b/sys/amd64/include/md_var.h @@ -49,11 +49,8 @@ extern vm_paddr_t intel_graphics_stolen_size; extern int la57; -/* - * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its - * value is the physical address at which the kernel is loaded. - */ -extern char kernphys[]; +extern vm_paddr_t kernphys; +extern vm_paddr_t KERNend; extern bool efi_boot; diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index c7ffb218dd4a..b6f79ef8ca84 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -149,8 +149,10 @@ #endif /* - * Kernel physical load address. Needs to be aligned at 2MB superpage - * boundary. + * Kernel physical load address for non-UEFI boot and for legacy UEFI loader. + * Newer UEFI loader loads kernel anywhere below 4G, with memory allocated + * by boot services. + * Needs to be aligned at 2MB superpage boundary. */ #ifndef KERNLOAD #define KERNLOAD 0x200000 @@ -186,7 +188,17 @@ #define LARGEMAP_MIN_ADDRESS KV4ADDR(LMSPML4I, 0, 0, 0) #define LARGEMAP_MAX_ADDRESS KV4ADDR(LMEPML4I + 1, 0, 0, 0) +/* + * Formally kernel mapping starts at KERNBASE, but kernel linker + * script leaves first PDE reserved. For legacy BIOS boot, kernel is + * loaded at KERNLOAD = 2M, and initial kernel page table maps + * physical memory from zero to KERNend starting at KERNBASE. + * + * KERNSTART is where the first actual kernel page is mapped, after + * the compatibility mapping. + */ #define KERNBASE KV4ADDR(KPML4I, KPDPI, 0, 0) +#define KERNSTART (KERNBASE + NBPDR) #define UPT_MAX_ADDRESS KV4ADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I) #define UPT_MIN_ADDRESS KV4ADDR(PML4PML4I, 0, 0, 0) diff --git a/sys/conf/ldscript.amd64 b/sys/conf/ldscript.amd64 index c11ffb6ea49f..68085ff7435c 100644 --- a/sys/conf/ldscript.amd64 +++ b/sys/conf/ldscript.amd64 @@ -5,15 +5,14 @@ ENTRY(btext) SEARCH_DIR("/usr/lib"); SECTIONS { - kernphys = kernload; /* Read-only sections, merged into text segment: */ - . = kernbase + kernphys + SIZEOF_HEADERS; + . = kernbase + kernload + SIZEOF_HEADERS; /* * Use the AT keyword in order to set the right LMA that contains * the physical address where the section should be loaded. This is * needed for the Xen loader which honours the LMA. */ - .interp : AT (kernphys + SIZEOF_HEADERS) { *(.interp) } + .interp : AT (kernload + SIZEOF_HEADERS) { *(.interp) } .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } .dynsym : { *(.dynsym) } From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9D1FF673DCB; Mon, 23 Aug 2021 23:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtpDg2lj6z3tNg; Mon, 23 Aug 2021 23:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D28A11D156; Mon, 23 Aug 2021 23:22:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMQqj094733; Mon, 23 Aug 2021 23:22:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNMQ4K094732; Mon, 23 Aug 2021 23:22:26 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:26 GMT Message-Id: <202108232322.17NNMQ4K094732@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: 1b33aa1f5f99 - stable/13 - amd64 UEFI loader: stop copying staging area to 2M physical 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: 1b33aa1f5f99e1270d526ffa5b652250ec80a7ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:27 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1b33aa1f5f99e1270d526ffa5b652250ec80a7ef commit 1b33aa1f5f99e1270d526ffa5b652250ec80a7ef Author: Konstantin Belousov AuthorDate: 2021-07-10 19:55:56 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:15 +0000 amd64 UEFI loader: stop copying staging area to 2M physical (cherry picked from commit f75caed644a5c8c342a1ea5e7a6d5251f82ed0b1) --- stand/common/bootstrap.h | 3 + stand/common/load_elf.c | 15 ++ stand/efi/loader/arch/amd64/elf64_freebsd.c | 142 +++++++++++++---- stand/efi/loader/bootinfo.c | 6 +- stand/efi/loader/copy.c | 232 ++++++++++++++++++++++++---- stand/efi/loader/loader_efi.h | 10 ++ 6 files changed, 348 insertions(+), 60 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index f671dba96e63..80a306f1d3e7 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -228,6 +228,9 @@ struct preloaded_file size_t f_size; /* file size */ struct kernel_module *f_modules; /* list of modules if any */ struct preloaded_file *f_next; /* next file */ +#ifdef __amd64__ + bool f_kernphys_relocatable; +#endif }; struct file_format diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index f1a9ff8e0c22..9ae91036dbb4 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -207,6 +207,18 @@ static int elf_section_header_convert(const Elf_Ehdr *ehdr, Elf_Shdr *shdr) #undef CONVERT_SWITCH #undef CONVERT_FIELD + +#ifdef __amd64__ +static bool +is_kernphys_relocatable(elf_file_t ef) +{ + Elf_Sym sym; + + return (__elfN(lookup_symbol)(ef, "kernphys", &sym, STT_OBJECT) == 0 && + sym.st_size == 8); +} +#endif + static int __elfN(load_elf_header)(char *filename, elf_file_t ef) { @@ -434,6 +446,9 @@ __elfN(loadfile_raw)(char *filename, uint64_t dest, /* Load OK, return module pointer */ *result = (struct preloaded_file *)fp; err = 0; +#ifdef __amd64__ + fp->f_kernphys_relocatable = is_kernphys_relocatable(&ef); +#endif goto out; ioerr: diff --git a/stand/efi/loader/arch/amd64/elf64_freebsd.c b/stand/efi/loader/arch/amd64/elf64_freebsd.c index 896041e066c9..8826cf76aa80 100644 --- a/stand/efi/loader/arch/amd64/elf64_freebsd.c +++ b/stand/efi/loader/arch/amd64/elf64_freebsd.c @@ -76,7 +76,11 @@ struct file_format *file_formats[] = { static pml4_entry_t *PT4; static pdp_entry_t *PT3; +static pdp_entry_t *PT3_l, *PT3_u; static pd_entry_t *PT2; +static pd_entry_t *PT2_l0, *PT2_l1, *PT2_l2, *PT2_l3, *PT2_u0, *PT2_u1; + +extern EFI_PHYSICAL_ADDRESS staging; static void (*trampoline)(uint64_t stack, void *copy_finish, uint64_t kernend, uint64_t modulep, pml4_entry_t *pagetable, uint64_t entry); @@ -99,6 +103,12 @@ elf64_exec(struct preloaded_file *fp) ACPI_TABLE_RSDP *rsdp; char buf[24]; int revision; + bool copy_auto; + + copy_auto = copy_staging == COPY_STAGING_AUTO; + if (copy_auto) + copy_staging = fp->f_kernphys_relocatable ? + COPY_STAGING_DISABLE : COPY_STAGING_ENABLE; /* * Report the RSDP to the kernel. While this can be found with @@ -145,57 +155,133 @@ elf64_exec(struct preloaded_file *fp) } if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) - return(EFTYPE); + return (EFTYPE); ehdr = (Elf_Ehdr *)&(md->md_data); - trampcode = (vm_offset_t)0x0000000040000000; + trampcode = copy_staging == COPY_STAGING_ENABLE ? + (vm_offset_t)0x0000000040000000 /* 1G */ : + (vm_offset_t)0x0000000100000000; /* 4G */; err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 1, (EFI_PHYSICAL_ADDRESS *)&trampcode); + if (EFI_ERROR(err)) { + printf("Unable to allocate trampoline\n"); + if (copy_auto) + copy_staging = COPY_STAGING_AUTO; + return (ENOMEM); + } bzero((void *)trampcode, EFI_PAGE_SIZE); trampstack = trampcode + EFI_PAGE_SIZE - 8; bcopy((void *)&amd64_tramp, (void *)trampcode, amd64_tramp_size); trampoline = (void *)trampcode; - PT4 = (pml4_entry_t *)0x0000000040000000; - err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3, - (EFI_PHYSICAL_ADDRESS *)&PT4); - bzero(PT4, 3 * EFI_PAGE_SIZE); + if (copy_staging == COPY_STAGING_ENABLE) { + PT4 = (pml4_entry_t *)0x0000000040000000; + err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3, + (EFI_PHYSICAL_ADDRESS *)&PT4); + if (EFI_ERROR(err)) { + printf("Unable to allocate trampoline page table\n"); + BS->FreePages(trampcode, 1); + if (copy_auto) + copy_staging = COPY_STAGING_AUTO; + return (ENOMEM); + } + bzero(PT4, 3 * EFI_PAGE_SIZE); + PT3 = &PT4[512]; + PT2 = &PT3[512]; + + /* + * This is kinda brutal, but every single 1GB VM + * memory segment points to the same first 1GB of + * physical memory. But it is more than adequate. + */ + for (i = 0; i < NPTEPG; i++) { + /* + * Each slot of the L4 pages points to the + * same L3 page. + */ + PT4[i] = (pml4_entry_t)PT3; + PT4[i] |= PG_V | PG_RW; - PT3 = &PT4[512]; - PT2 = &PT3[512]; + /* + * Each slot of the L3 pages points to the + * same L2 page. + */ + PT3[i] = (pdp_entry_t)PT2; + PT3[i] |= PG_V | PG_RW; - /* - * This is kinda brutal, but every single 1GB VM memory segment points - * to the same first 1GB of physical memory. But it is more than - * adequate. - */ - for (i = 0; i < 512; i++) { - /* Each slot of the L4 pages points to the same L3 page. */ - PT4[i] = (pml4_entry_t)PT3; - PT4[i] |= PG_V | PG_RW; - - /* Each slot of the L3 pages points to the same L2 page. */ - PT3[i] = (pdp_entry_t)PT2; - PT3[i] |= PG_V | PG_RW; - - /* The L2 page slots are mapped with 2MB pages for 1GB. */ - PT2[i] = i * (2 * 1024 * 1024); - PT2[i] |= PG_V | PG_RW | PG_PS; + /* + * The L2 page slots are mapped with 2MB pages for 1GB. + */ + PT2[i] = (pd_entry_t)i * (2 * 1024 * 1024); + PT2[i] |= PG_V | PG_RW | PG_PS; + } + } else { + PT4 = (pml4_entry_t *)0x0000000100000000; /* 4G */ + err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 9, + (EFI_PHYSICAL_ADDRESS *)&PT4); + if (EFI_ERROR(err)) { + printf("Unable to allocate trampoline page table\n"); + BS->FreePages(trampcode, 9); + if (copy_auto) + copy_staging = COPY_STAGING_AUTO; + return (ENOMEM); + } + + bzero(PT4, 9 * EFI_PAGE_SIZE); + + PT3_l = &PT4[NPML4EPG * 1]; + PT3_u = &PT4[NPML4EPG * 2]; + PT2_l0 = &PT4[NPML4EPG * 3]; + PT2_l1 = &PT4[NPML4EPG * 4]; + PT2_l2 = &PT4[NPML4EPG * 5]; + PT2_l3 = &PT4[NPML4EPG * 6]; + PT2_u0 = &PT4[NPML4EPG * 7]; + PT2_u1 = &PT4[NPML4EPG * 8]; + + /* 1:1 mapping of lower 4G */ + PT4[0] = (pml4_entry_t)PT3_l | PG_V | PG_RW; + PT3_l[0] = (pdp_entry_t)PT2_l0 | PG_V | PG_RW; + PT3_l[1] = (pdp_entry_t)PT2_l1 | PG_V | PG_RW; + PT3_l[2] = (pdp_entry_t)PT2_l2 | PG_V | PG_RW; + PT3_l[3] = (pdp_entry_t)PT2_l3 | PG_V | PG_RW; + for (i = 0; i < 4 * NPDEPG; i++) { + PT2_l0[i] = ((pd_entry_t)i << PDRSHIFT) | PG_V | + PG_RW | PG_PS; + } + + /* mapping of kernel 2G below top */ + PT4[NPML4EPG - 1] = (pml4_entry_t)PT3_u | PG_V | PG_RW; + PT3_u[NPDPEPG - 2] = (pdp_entry_t)PT2_u0 | PG_V | PG_RW; + PT3_u[NPDPEPG - 1] = (pdp_entry_t)PT2_u1 | PG_V | PG_RW; + /* compat mapping of phys @0 */ + PT2_u0[0] = PG_PS | PG_V | PG_RW; + /* this maps past staging area */ + for (i = 1; i < 2 * NPDEPG; i++) { + PT2_u0[i] = ((pd_entry_t)staging + + ((pd_entry_t)i - 1) * NBPDR) | + PG_V | PG_RW | PG_PS; + } } + printf("staging %#lx (%scoping) tramp %p PT4 %p\n", + staging, copy_staging == COPY_STAGING_ENABLE ? "" : "not ", + trampoline, PT4); printf("Start @ 0x%lx ...\n", ehdr->e_entry); efi_time_fini(); err = bi_load(fp->f_args, &modulep, &kernend); if (err != 0) { efi_time_init(); - return(err); + if (copy_auto) + copy_staging = COPY_STAGING_AUTO; + return (err); } dev_cleanup(); - trampoline(trampstack, efi_copy_finish, kernend, modulep, PT4, - ehdr->e_entry); + trampoline(trampstack, copy_staging == COPY_STAGING_ENABLE ? + efi_copy_finish : efi_copy_finish_nop, kernend, modulep, + PT4, ehdr->e_entry); panic("exec returned"); } diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index a11c45d05a0f..bf98105eee93 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -64,6 +64,8 @@ int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); extern EFI_SYSTEM_TABLE *ST; +int boot_services_gone; + static int bi_getboothowto(char *kargs) { @@ -393,8 +395,10 @@ bi_load_efi_data(struct preloaded_file *kfp) } status = BS->ExitBootServices(IH, efi_mapkey); - if (!EFI_ERROR(status)) + if (!EFI_ERROR(status)) { + boot_services_gone = 1; break; + } } if (retry == 0) { diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index e723b61e3bca..b8ed4c8e027e 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -39,6 +39,11 @@ __FBSDID("$FreeBSD$"); #include "loader_efi.h" +#define M(x) ((x) * 1024 * 1024) +#define G(x) (1UL * (x) * 1024 * 1024 * 1024) + +extern int boot_services_gone; + #if defined(__i386__) || defined(__amd64__) #include #include @@ -175,24 +180,142 @@ out: #ifndef EFI_STAGING_SIZE #if defined(__arm__) -#define EFI_STAGING_SIZE 32 +#define EFI_STAGING_SIZE M(32) +#else +#define EFI_STAGING_SIZE M(64) +#endif +#endif + +#if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \ + defined(__riscv) +#define EFI_STAGING_2M_ALIGN 1 #else -#define EFI_STAGING_SIZE 64 +#define EFI_STAGING_2M_ALIGN 0 #endif + +#if defined(__amd64__) +#define EFI_STAGING_SLOP M(8) +#else +#define EFI_STAGING_SLOP 0 #endif +static u_long staging_slop = EFI_STAGING_SLOP; + EFI_PHYSICAL_ADDRESS staging, staging_end, staging_base; int stage_offset_set = 0; ssize_t stage_offset; +static void +efi_copy_free(void) +{ + BS->FreePages(staging_base, (staging_end - staging_base) / + EFI_PAGE_SIZE); + stage_offset_set = 0; + stage_offset = 0; +} + +#ifdef __amd64__ +int copy_staging = COPY_STAGING_ENABLE; + +static int +command_copy_staging(int argc, char *argv[]) +{ + static const char *const mode[3] = { + [COPY_STAGING_ENABLE] = "enable", + [COPY_STAGING_DISABLE] = "disable", + [COPY_STAGING_AUTO] = "auto", + }; + int prev, res; + + res = CMD_OK; + if (argc > 2) { + res = CMD_ERROR; + } else if (argc == 2) { + prev = copy_staging; + if (strcmp(argv[1], "enable") == 0) + copy_staging = COPY_STAGING_ENABLE; + else if (strcmp(argv[1], "disable") == 0) + copy_staging = COPY_STAGING_DISABLE; + else if (strcmp(argv[1], "auto") == 0) + copy_staging = COPY_STAGING_AUTO; + else { + printf("usage: copy_staging enable|disable|auto\n"); + res = CMD_ERROR; + } + if (res == CMD_OK && prev != copy_staging) { + printf("changed copy_staging, unloading kernel\n"); + unload(); + efi_copy_free(); + efi_copy_init(); + } + } else { + printf("copy staging: %s\n", mode[copy_staging]); + } + return (res); +} +COMMAND_SET(copy_staging, "copy_staging", "copy staging", command_copy_staging); +#endif + +static int +command_staging_slop(int argc, char *argv[]) +{ + char *endp; + u_long new, prev; + int res; + + res = CMD_OK; + if (argc > 2) { + res = CMD_ERROR; + } else if (argc == 2) { + new = strtoul(argv[1], &endp, 0); + if (*endp != '\0') { + printf("invalid slop value\n"); + res = CMD_ERROR; + } + if (res == CMD_OK && staging_slop != new) { + printf("changed slop, unloading kernel\n"); + unload(); + efi_copy_free(); + efi_copy_init(); + } + } else { + printf("staging slop %#lx\n", staging_slop); + } + return (res); +} +COMMAND_SET(staging_slop, "staging_slop", "set staging slop", + command_staging_slop); + +#if defined(__i386__) || defined(__amd64__) +/* + * The staging area must reside in the the first 1GB or 4GB physical + * memory: see elf64_exec() in + * boot/efi/loader/arch/amd64/elf64_freebsd.c. + */ +static EFI_PHYSICAL_ADDRESS +get_staging_max(void) +{ + EFI_PHYSICAL_ADDRESS res; + +#if defined(__i386__) + res = G(1); +#elif defined(__amd64__) + res = copy_staging == COPY_STAGING_ENABLE ? G(1) : G(4); +#endif + return (res); +} +#define EFI_ALLOC_METHOD AllocateMaxAddress +#else +#define EFI_ALLOC_METHOD AllocateAnyPages +#endif + int efi_copy_init(void) { EFI_STATUS status; - unsigned long nr_pages; - nr_pages = EFI_SIZE_TO_PAGES((EFI_STAGING_SIZE) * 1024 * 1024); + nr_pages = EFI_SIZE_TO_PAGES((EFI_STAGING_SIZE)); #if defined(__i386__) || defined(__amd64__) /* @@ -203,18 +326,10 @@ efi_copy_init(void) if (running_on_hyperv()) efi_verify_staging_size(&nr_pages); - /* - * The staging area must reside in the the first 1GB physical - * memory: see elf64_exec() in - * boot/efi/loader/arch/amd64/elf64_freebsd.c. - */ - staging = 1024*1024*1024; - status = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, - nr_pages, &staging); -#else - status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, - nr_pages, &staging); + staging = get_staging_max(); #endif + status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderData, + nr_pages, &staging); if (EFI_ERROR(status)) { printf("failed to allocate staging area: %lu\n", EFI_ERROR_CODE(status)); @@ -223,7 +338,7 @@ efi_copy_init(void) staging_base = staging; staging_end = staging + nr_pages * EFI_PAGE_SIZE; -#if defined(__aarch64__) || defined(__arm__) || defined(__riscv) +#if EFI_STAGING_2M_ALIGN /* * Round the kernel load address to a 2MiB value. This is needed * because the kernel builds a page table based on where it has @@ -231,7 +346,7 @@ efi_copy_init(void) * either a 1MiB or 2MiB page for this we need to make sure it * is correctly aligned for both cases. */ - staging = roundup2(staging, 2 * 1024 * 1024); + staging = roundup2(staging, M(2)); #endif return (0); @@ -240,20 +355,42 @@ efi_copy_init(void) static bool efi_check_space(vm_offset_t end) { - EFI_PHYSICAL_ADDRESS addr; + EFI_PHYSICAL_ADDRESS addr, new_base, new_staging; EFI_STATUS status; unsigned long nr_pages; + end = roundup2(end, EFI_PAGE_SIZE); + /* There is already enough space */ - if (end <= staging_end) + if (end + staging_slop <= staging_end) return (true); - end = roundup2(end, EFI_PAGE_SIZE); - nr_pages = EFI_SIZE_TO_PAGES(end - staging_end); + if (boot_services_gone) { + if (end <= staging_end) + return (true); + panic("efi_check_space: cannot expand staging area " + "after boot services were exited\n"); + } + + /* + * Add slop at the end: + * 1. amd64 kernel expects to do some very early allocations + * by carving out memory after kernend. Slop guarantees + * that it does not ovewrite anything useful. + * 2. It seems that initial calculation of the staging size + * could be somewhat smaller than actually copying in after + * boot services are exited. Slop avoids calling + * BS->AllocatePages() when it cannot work. + */ + end += staging_slop; + nr_pages = EFI_SIZE_TO_PAGES(end - staging_end); #if defined(__i386__) || defined(__amd64__) - /* X86 needs all memory to be allocated under the 1G boundary */ - if (end > 1024*1024*1024) + /* + * i386 needs all memory to be allocated under the 1G boundary. + * amd64 needs all memory to be allocated under the 1G or 4G boundary. + */ + if (end > get_staging_max()) goto before_staging; #endif @@ -268,14 +405,12 @@ efi_check_space(vm_offset_t end) before_staging: /* Try allocating space before the previous allocation */ - if (staging < nr_pages * EFI_PAGE_SIZE) { - printf("Not enough space before allocation\n"); - return (false); - } + if (staging < nr_pages * EFI_PAGE_SIZE) + goto expand; addr = staging - nr_pages * EFI_PAGE_SIZE; -#if defined(__aarch64__) || defined(__arm__) || defined(__riscv) +#if EFI_STAGING_2M_ALIGN /* See efi_copy_init for why this is needed */ - addr = rounddown2(addr, 2 * 1024 * 1024); + addr = rounddown2(addr, M(2)); #endif nr_pages = EFI_SIZE_TO_PAGES(staging_base - addr); status = BS->AllocatePages(AllocateAddress, EfiLoaderData, nr_pages, @@ -288,11 +423,42 @@ before_staging: staging_base = addr; memmove((void *)(uintptr_t)staging_base, (void *)(uintptr_t)staging, staging_end - staging); - stage_offset -= (staging - staging_base); + stage_offset -= staging - staging_base; staging = staging_base; return (true); } +expand: + nr_pages = EFI_SIZE_TO_PAGES(end - (vm_offset_t)staging); +#if EFI_STAGING_2M_ALIGN + nr_pages += M(2) / EFI_PAGE_SIZE; +#endif +#if defined(__i386__) || defined(__amd64__) + new_base = get_staging_max(); +#endif + status = BS->AllocatePages(EFI_ALLOC_METHOD, EfiLoaderData, + nr_pages, &new_base); + if (!EFI_ERROR(status)) { +#if EFI_STAGING_2M_ALIGN + new_staging = roundup2(new_base, M(2)); +#else + new_staging = new_base; +#endif + /* + * Move the old allocation and update the state so + * translation still works. + */ + memcpy((void *)(uintptr_t)new_staging, + (void *)(uintptr_t)staging, staging_end - staging); + BS->FreePages(staging_base, (staging_end - staging_base) / + EFI_PAGE_SIZE); + stage_offset -= staging - new_staging; + staging = new_staging; + staging_end = new_base + nr_pages * EFI_PAGE_SIZE; + staging_base = new_base; + return (true); + } + printf("efi_check_space: Unable to expand staging area\n"); return (false); } @@ -335,7 +501,6 @@ efi_copyout(const vm_offset_t src, void *dest, const size_t len) return (len); } - ssize_t efi_readin(readin_handle_t fd, vm_offset_t dest, const size_t len) { @@ -364,3 +529,8 @@ efi_copy_finish(void) while (src < last) *dst++ = *src++; } + +void +efi_copy_finish_nop(void) +{ +} diff --git a/stand/efi/loader/loader_efi.h b/stand/efi/loader/loader_efi.h index 4d077514e423..8254d16b1592 100644 --- a/stand/efi/loader/loader_efi.h +++ b/stand/efi/loader/loader_efi.h @@ -34,6 +34,15 @@ #include #include +#ifdef __amd64__ +enum { + COPY_STAGING_ENABLE, + COPY_STAGING_DISABLE, + COPY_STAGING_AUTO, +}; +extern int copy_staging; +#endif + int efi_autoload(void); int efi_copy_init(void); @@ -44,5 +53,6 @@ ssize_t efi_readin(readin_handle_t fd, vm_offset_t dest, const size_t len); void * efi_translate(vm_offset_t ptr); void efi_copy_finish(void); +void efi_copy_finish_nop(void); #endif /* _LOADER_EFI_COPY_H_ */ From owner-dev-commits-src-all@freebsd.org Mon Aug 23 23:22:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0986C673ABE; Mon, 23 Aug 2021 23:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtpDh4RF9z3tqK; Mon, 23 Aug 2021 23:22:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCF711D339; Mon, 23 Aug 2021 23:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NNMR3e094757; Mon, 23 Aug 2021 23:22:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NNMRmh094756; Mon, 23 Aug 2021 23:22:27 GMT (envelope-from git) Date: Mon, 23 Aug 2021 23:22:27 GMT Message-Id: <202108232322.17NNMRmh094756@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: 25a4a79ccca0 - stable/13 - loader: fix multiboot loading on UEFI 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: 25a4a79ccca09a7d0259e393fd7902dacc867b9a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 23:22:29 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=25a4a79ccca09a7d0259e393fd7902dacc867b9a commit 25a4a79ccca09a7d0259e393fd7902dacc867b9a Author: Roger Pau Monné AuthorDate: 2021-08-11 14:55:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-23 23:21:15 +0000 loader: fix multiboot loading on UEFI (cherry picked from commit 5e4279a8f35aa4b46debf728d3f743d64f15aaf8) --- stand/common/load_elf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 9ae91036dbb4..c163b50c9737 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -447,7 +447,7 @@ __elfN(loadfile_raw)(char *filename, uint64_t dest, *result = (struct preloaded_file *)fp; err = 0; #ifdef __amd64__ - fp->f_kernphys_relocatable = is_kernphys_relocatable(&ef); + fp->f_kernphys_relocatable = multiboot || is_kernphys_relocatable(&ef); #endif goto out; @@ -1253,6 +1253,11 @@ __elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp, char *strp; unsigned long hash; + if (ef->nbuckets == 0) { + printf(__elfN(bad_symtable)); + return ENOENT; + } + hash = elf_hash(name); COPYOUT(&ef->buckets[hash % ef->nbuckets], &symnum, sizeof(symnum)); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 00:50:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93213674F0D; Tue, 24 Aug 2021 00:50: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 4Gtr9x3K9Dz4p8x; Tue, 24 Aug 2021 00:50: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 5AE761DFC4; Tue, 24 Aug 2021 00:50: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 17O0oDsN007388; Tue, 24 Aug 2021 00:50:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O0oDok007384; Tue, 24 Aug 2021 00:50:13 GMT (envelope-from git) Date: Tue, 24 Aug 2021 00:50:13 GMT Message-Id: <202108240050.17O0oDok007384@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 784459fc1641 - stable/13 - ixgbe: Avoid sbuf_trim(9) in sysctl handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 784459fc1641a3b8f391af1e6aa78e2428188830 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 00:50:13 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=784459fc1641a3b8f391af1e6aa78e2428188830 commit 784459fc1641a3b8f391af1e6aa78e2428188830 Author: Kevin Bowling AuthorDate: 2021-08-23 16:21:39 +0000 Commit: Kevin Bowling CommitDate: 2021-08-24 00:50:02 +0000 ixgbe: Avoid sbuf_trim(9) in sysctl handler This was an error, we cannot use sbuf_trim(9) in the ixgbe_sbuf_fw_version function because it also gets called in the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction with drain functions as used by sbuf_new_for_sysctl(9). Reviewed by: imp Fixes: 7660e4ea5cb7 MFC after: 1 day Differential Revision: https://reviews.freebsd.org/D31633 (cherry picked from commit 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc) --- sys/dev/ixgbe/if_ix.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index 8e14a008e09b..91bf7e4dd218 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -4694,27 +4694,33 @@ ixgbe_sbuf_fw_version(struct ixgbe_hw *hw, struct sbuf *buf) struct ixgbe_nvm_version nvm_ver = {0}; uint16_t phyfw = 0; int status; + const char *space = ""; ixgbe_get_oem_prod_version(hw, &nvm_ver); /* OEM's NVM version */ ixgbe_get_orom_version(hw, &nvm_ver); /* Option ROM */ ixgbe_get_etk_id(hw, &nvm_ver); /* eTrack identifies a build in Intel's SCM */ status = ixgbe_get_phy_firmware_version(hw, &phyfw); - if (nvm_ver.oem_valid) - sbuf_printf(buf, "NVM OEM V%d.%d R%d ", nvm_ver.oem_major, + if (nvm_ver.oem_valid) { + sbuf_printf(buf, "NVM OEM V%d.%d R%d", nvm_ver.oem_major, nvm_ver.oem_minor, nvm_ver.oem_release); + space = " "; + } - if (nvm_ver.or_valid) - sbuf_printf(buf, "Option ROM V%d-b%d-p%d ", nvm_ver.or_major, - nvm_ver.or_build, nvm_ver.or_patch); + if (nvm_ver.or_valid) { + sbuf_printf(buf, "%sOption ROM V%d-b%d-p%d", + space, nvm_ver.or_major, nvm_ver.or_build, nvm_ver.or_patch); + space = " "; + } - if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | NVM_VER_INVALID)) - sbuf_printf(buf, "eTrack 0x%08x ", nvm_ver.etk_id); + if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | + NVM_VER_INVALID)) { + sbuf_printf(buf, "%seTrack 0x%08x", space, nvm_ver.etk_id); + space = " "; + } if (phyfw != 0 && status == IXGBE_SUCCESS) - sbuf_printf(buf, "PHY FW V%d ", phyfw); - - sbuf_trim(buf); + sbuf_printf(buf, "%sPHY FW V%d", space, phyfw); } /* ixgbe_sbuf_fw_version */ /************************************************************************ From owner-dev-commits-src-all@freebsd.org Tue Aug 24 00:50:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 97F00675042; Tue, 24 Aug 2021 00:50: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 4GtrBZ3whdz4pJb; Tue, 24 Aug 2021 00:50: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 660321E5A5; Tue, 24 Aug 2021 00:50: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 17O0oka2012095; Tue, 24 Aug 2021 00:50:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O0okv7012094; Tue, 24 Aug 2021 00:50:46 GMT (envelope-from git) Date: Tue, 24 Aug 2021 00:50:46 GMT Message-Id: <202108240050.17O0okv7012094@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 6d499e322d18 - stable/12 - ixgbe: Avoid sbuf_trim(9) in sysctl handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 6d499e322d184f3e20d25876591e4729e67c4359 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 00:50:46 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=6d499e322d184f3e20d25876591e4729e67c4359 commit 6d499e322d184f3e20d25876591e4729e67c4359 Author: Kevin Bowling AuthorDate: 2021-08-23 16:21:39 +0000 Commit: Kevin Bowling CommitDate: 2021-08-24 00:50:35 +0000 ixgbe: Avoid sbuf_trim(9) in sysctl handler This was an error, we cannot use sbuf_trim(9) in the ixgbe_sbuf_fw_version function because it also gets called in the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction with drain functions as used by sbuf_new_for_sysctl(9). Reviewed by: imp Fixes: 7660e4ea5cb7 MFC after: 1 day Differential Revision: https://reviews.freebsd.org/D31633 (cherry picked from commit 5de5419b5e8685ab2261edaafe6fdb6fc36e8bbc) --- sys/dev/ixgbe/if_ix.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index 740c8e224653..0a64c4ffe595 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -4600,27 +4600,33 @@ ixgbe_sbuf_fw_version(struct ixgbe_hw *hw, struct sbuf *buf) struct ixgbe_nvm_version nvm_ver = {0}; uint16_t phyfw = 0; int status; + const char *space = ""; ixgbe_get_oem_prod_version(hw, &nvm_ver); /* OEM's NVM version */ ixgbe_get_orom_version(hw, &nvm_ver); /* Option ROM */ ixgbe_get_etk_id(hw, &nvm_ver); /* eTrack identifies a build in Intel's SCM */ status = ixgbe_get_phy_firmware_version(hw, &phyfw); - if (nvm_ver.oem_valid) - sbuf_printf(buf, "NVM OEM V%d.%d R%d ", nvm_ver.oem_major, + if (nvm_ver.oem_valid) { + sbuf_printf(buf, "NVM OEM V%d.%d R%d", nvm_ver.oem_major, nvm_ver.oem_minor, nvm_ver.oem_release); + space = " "; + } - if (nvm_ver.or_valid) - sbuf_printf(buf, "Option ROM V%d-b%d-p%d ", nvm_ver.or_major, - nvm_ver.or_build, nvm_ver.or_patch); + if (nvm_ver.or_valid) { + sbuf_printf(buf, "%sOption ROM V%d-b%d-p%d", + space, nvm_ver.or_major, nvm_ver.or_build, nvm_ver.or_patch); + space = " "; + } - if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | NVM_VER_INVALID)) - sbuf_printf(buf, "eTrack 0x%08x ", nvm_ver.etk_id); + if (nvm_ver.etk_id != ((NVM_VER_INVALID << NVM_ETK_SHIFT) | + NVM_VER_INVALID)) { + sbuf_printf(buf, "%seTrack 0x%08x", space, nvm_ver.etk_id); + space = " "; + } if (phyfw != 0 && status == IXGBE_SUCCESS) - sbuf_printf(buf, "PHY FW V%d ", phyfw); - - sbuf_trim(buf); + sbuf_printf(buf, "%sPHY FW V%d", space, phyfw); } /* ixgbe_sbuf_fw_version */ /************************************************************************ From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B0306752EE; Tue, 24 Aug 2021 01:01: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 4GtrRD6prdz4rM0; Tue, 24 Aug 2021 01:01:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D14BC1E89D; Tue, 24 Aug 2021 01:01: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 17O11iae026199; Tue, 24 Aug 2021 01:01:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11i9B026198; Tue, 24 Aug 2021 01:01:44 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:44 GMT Message-Id: <202108240101.17O11i9B026198@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: df8406ca0f05 - stable/13 - nfs tls: Update for SSL_OP_ENABLE_KTLS. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: df8406ca0f053649dbd6a808486141a11bb4c3a8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:45 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=df8406ca0f053649dbd6a808486141a11bb4c3a8 commit df8406ca0f053649dbd6a808486141a11bb4c3a8 Author: John Baldwin AuthorDate: 2021-08-10 21:18:43 +0000 Commit: John Baldwin CommitDate: 2021-08-24 00:59:34 +0000 nfs tls: Update for SSL_OP_ENABLE_KTLS. Upstream OpenSSL (and the KTLS backport) have switched to an opt-in option (SSL_OP_ENABLE_KTLS) in place of opt-out modes (SSL_MODE_NO_KTLS_TX and SSL_MODE_NO_KTLS_RX) for controlling kernel TLS. Reviewed by: rmacklem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31445 (cherry picked from commit c7bb0f47f721a2095ed6100bca595ba68fa5645a) --- usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c | 5 +++++ usr.sbin/rpc.tlsservd/rpc.tlsservd.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c index af803f203ffd..5e66f4b4b2dd 100644 --- a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c +++ b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c @@ -573,9 +573,14 @@ rpctls_setupcl_ssl(void) SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; #else flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1_3; +#endif +#ifdef SSL_OP_ENABLE_KTLS + flags |= SSL_OP_ENABLE_KTLS; #endif SSL_CTX_set_options(ctx, flags); +#ifdef SSL_MODE_NO_KTLS_TX SSL_CTX_clear_mode(ctx, SSL_MODE_NO_KTLS_TX | SSL_MODE_NO_KTLS_RX); +#endif return (ctx); } diff --git a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c index 1c7687cad87a..71787b162acd 100644 --- a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c +++ b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c @@ -636,7 +636,12 @@ rpctls_setup_ssl(const char *certdir) SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, rpctls_verify_callback); } +#ifdef SSL_OP_ENABLE_KTLS + SSL_CTX_set_options(ctx, SSL_OP_ENABLE_KTLS); +#endif +#ifdef SSL_MODE_NO_KTLS_TX SSL_CTX_clear_mode(ctx, SSL_MODE_NO_KTLS_TX | SSL_MODE_NO_KTLS_RX); +#endif return (ctx); } From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 653A36752FB; Tue, 24 Aug 2021 01:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtrRH1kkFz4rF2; Tue, 24 Aug 2021 01:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 23EDF1E9A0; Tue, 24 Aug 2021 01:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17O11lTq026250; Tue, 24 Aug 2021 01:01:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11lcj026249; Tue, 24 Aug 2021 01:01:47 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:47 GMT Message-Id: <202108240101.17O11lcj026249@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: d00932bea68b - stable/13 - OpenSSL: ktls: Initial support for ChaCha20-Poly1305 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: d00932bea68b702c22e105593777dbfe8c7a2479 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:47 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d00932bea68b702c22e105593777dbfe8c7a2479 commit d00932bea68b702c22e105593777dbfe8c7a2479 Author: John Baldwin AuthorDate: 2021-08-17 21:38:47 +0000 Commit: John Baldwin CommitDate: 2021-08-24 00:59:35 +0000 OpenSSL: ktls: Initial support for ChaCha20-Poly1305 Linux kernel is going to support ChaCha20-Poly1305 in TLS offload. Add support for this cipher. Reviewed by: jkim Obtained from: OpenSSL (3aa7212e0a4fd1533c8a28b8587dd8b022f3a66f) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31439 (cherry picked from commit 63c6d3e283eb01d32f54e2a153e6719d19e4a80d) --- crypto/openssl/include/internal/ktls.h | 8 ++++++++ crypto/openssl/ssl/ktls.c | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/crypto/openssl/include/internal/ktls.h b/crypto/openssl/include/internal/ktls.h index 622d7be76d1e..393794298ccd 100644 --- a/crypto/openssl/include/internal/ktls.h +++ b/crypto/openssl/include/internal/ktls.h @@ -219,6 +219,11 @@ static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, # define OPENSSL_KTLS_TLS13 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) # define OPENSSL_KTLS_AES_CCM_128 +# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) +# ifndef OPENSSL_NO_CHACHA +# define OPENSSL_KTLS_CHACHA20_POLY1305 +# endif +# endif # endif # endif @@ -251,6 +256,9 @@ struct tls_crypto_info_all { # endif # ifdef OPENSSL_KTLS_AES_CCM_128 struct tls12_crypto_info_aes_ccm_128 ccm128; +# endif +# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 + struct tls12_crypto_info_chacha20_poly1305 chacha20poly1305; # endif }; size_t tls_crypto_info_len; diff --git a/crypto/openssl/ssl/ktls.c b/crypto/openssl/ssl/ktls.c index 7123ecac0051..f82946b260ab 100644 --- a/crypto/openssl/ssl/ktls.c +++ b/crypto/openssl/ssl/ktls.c @@ -126,7 +126,9 @@ int ktls_check_supported_cipher(const SSL *s, const EVP_CIPHER *c, return 0; } - /* check that cipher is AES_GCM_128, AES_GCM_256, AES_CCM_128 */ + /* check that cipher is AES_GCM_128, AES_GCM_256, AES_CCM_128 + * or Chacha20-Poly1305 + */ switch (EVP_CIPHER_nid(c)) { # ifdef OPENSSL_KTLS_AES_CCM_128 @@ -139,6 +141,9 @@ int ktls_check_supported_cipher(const SSL *s, const EVP_CIPHER *c, # endif # ifdef OPENSSL_KTLS_AES_GCM_256 case NID_aes_256_gcm: +# endif +# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 + case NID_chacha20_poly1305: # endif return 1; default: @@ -211,6 +216,20 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd, if (rec_seq != NULL) *rec_seq = crypto_info->ccm128.rec_seq; return 1; +# endif +# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 + case NID_chacha20_poly1305: + crypto_info->chacha20poly1305.info.cipher_type = TLS_CIPHER_CHACHA20_POLY1305; + crypto_info->chacha20poly1305.info.version = s->version; + crypto_info->tls_crypto_info_len = sizeof(crypto_info->chacha20poly1305); + memcpy(crypto_info->chacha20poly1305.iv, iiv, + TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE); + memcpy(crypto_info->chacha20poly1305.key, key, EVP_CIPHER_key_length(c)); + memcpy(crypto_info->chacha20poly1305.rec_seq, rl_sequence, + TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE); + if (rec_seq != NULL) + *rec_seq = crypto_info->chacha20poly1305.rec_seq; + return 1; # endif default: return 0; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 969F467523D; Tue, 24 Aug 2021 01:01: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 4GtrRJ3FJFz4rF9; Tue, 24 Aug 2021 01:01: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 4C51D1E45C; Tue, 24 Aug 2021 01:01: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 17O11maB026274; Tue, 24 Aug 2021 01:01:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11mru026273; Tue, 24 Aug 2021 01:01:48 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:48 GMT Message-Id: <202108240101.17O11mru026273@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: 622809b0868f - stable/13 - OpenSSL: Only enable KTLS if it is explicitly configured 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: 622809b0868f502550080dc2e3759fc645443744 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:48 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=622809b0868f502550080dc2e3759fc645443744 commit 622809b0868f502550080dc2e3759fc645443744 Author: John Baldwin AuthorDate: 2021-08-17 21:39:03 +0000 Commit: John Baldwin CommitDate: 2021-08-24 00:59:35 +0000 OpenSSL: Only enable KTLS if it is explicitly configured It has always been the case that KTLS is not compiled by default. However if it is compiled then it was automatically used unless specifically configured not to. This is problematic because it avoids any crypto implementations from providers. A user who configures all crypto to use the FIPS provider may unexpectedly find that TLS related crypto is actually being performed outside of the FIPS boundary. Instead we change KTLS so that it is disabled by default. We also swap to using a single "option" (i.e. SSL_OP_ENABLE_KTLS) rather than two separate "modes", (i.e. SSL_MODE_NO_KTLS_RX and SSL_MODE_NO_KTLS_TX). Reviewed by: jkim Obtained from: OpenSSL (a3a54179b6754fbed6d88e434baac710a83aaf80) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31440 (cherry picked from commit 62ca9fc1ad569eb3fafd281e03812a598b9856ee) --- crypto/openssl/include/openssl/ssl.h | 12 +++--------- crypto/openssl/ssl/ktls.c | 1 + crypto/openssl/ssl/ssl_conf.c | 3 ++- crypto/openssl/ssl/t1_enc.c | 6 +----- crypto/openssl/ssl/tls13_enc.c | 5 +++-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/crypto/openssl/include/openssl/ssl.h b/crypto/openssl/include/openssl/ssl.h index 09620489bc20..cfb87e63226e 100644 --- a/crypto/openssl/include/openssl/ssl.h +++ b/crypto/openssl/include/openssl/ssl.h @@ -303,7 +303,9 @@ typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx); /* Allow initial connection to servers that don't support RI */ # define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004U -/* Reserved value (until OpenSSL 1.2.0) 0x00000008U */ +/* Enable support for Kernel TLS */ +# define SSL_OP_ENABLE_KTLS 0x00000008U + # define SSL_OP_TLSEXT_PADDING 0x00000010U /* Reserved value (until OpenSSL 1.2.0) 0x00000020U */ # define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0x00000040U @@ -493,10 +495,6 @@ typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx); * Support Asynchronous operation */ # define SSL_MODE_ASYNC 0x00000100U -/* - * Don't use the kernel TLS data-path for sending. - */ -# define SSL_MODE_NO_KTLS_TX 0x00000200U /* * When using DTLS/SCTP, include the terminating zero in the label @@ -510,10 +508,6 @@ typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx); * - OpenSSL 1.1.1 and 1.1.1a */ # define SSL_MODE_DTLS_SCTP_LABEL_LENGTH_BUG 0x00000400U -/* - * Don't use the kernel TLS data-path for receiving. - */ -# define SSL_MODE_NO_KTLS_RX 0x00000800U /* Cert related flags */ /* diff --git a/crypto/openssl/ssl/ktls.c b/crypto/openssl/ssl/ktls.c index f82946b260ab..47328a7c7c73 100644 --- a/crypto/openssl/ssl/ktls.c +++ b/crypto/openssl/ssl/ktls.c @@ -137,6 +137,7 @@ int ktls_check_supported_cipher(const SSL *s, const EVP_CIPHER *c, return 0; # endif # ifdef OPENSSL_KTLS_AES_GCM_128 + /* Fall through */ case NID_aes_128_gcm: # endif # ifdef OPENSSL_KTLS_AES_GCM_256 diff --git a/crypto/openssl/ssl/ssl_conf.c b/crypto/openssl/ssl/ssl_conf.c index 0a3fef7c8c14..8013c62f0770 100644 --- a/crypto/openssl/ssl/ssl_conf.c +++ b/crypto/openssl/ssl/ssl_conf.c @@ -391,7 +391,8 @@ static int cmd_Options(SSL_CONF_CTX *cctx, const char *value) SSL_FLAG_TBL("AllowNoDHEKEX", SSL_OP_ALLOW_NO_DHE_KEX), SSL_FLAG_TBL("PrioritizeChaCha", SSL_OP_PRIORITIZE_CHACHA), SSL_FLAG_TBL("MiddleboxCompat", SSL_OP_ENABLE_MIDDLEBOX_COMPAT), - SSL_FLAG_TBL_INV("AntiReplay", SSL_OP_NO_ANTI_REPLAY) + SSL_FLAG_TBL_INV("AntiReplay", SSL_OP_NO_ANTI_REPLAY), + SSL_FLAG_TBL("KTLS", SSL_OP_ENABLE_KTLS) }; if (value == NULL) return -3; diff --git a/crypto/openssl/ssl/t1_enc.c b/crypto/openssl/ssl/t1_enc.c index d4614210685a..7d2eb381af1a 100644 --- a/crypto/openssl/ssl/t1_enc.c +++ b/crypto/openssl/ssl/t1_enc.c @@ -362,11 +362,7 @@ int tls1_change_cipher_state(SSL *s, int which) goto err; } #ifndef OPENSSL_NO_KTLS - if (s->compress) - goto skip_ktls; - - if (((which & SSL3_CC_READ) && (s->mode & SSL_MODE_NO_KTLS_RX)) - || ((which & SSL3_CC_WRITE) && (s->mode & SSL_MODE_NO_KTLS_TX))) + if (s->compress || (s->options & SSL_OP_ENABLE_KTLS) == 0) goto skip_ktls; /* ktls supports only the maximum fragment size */ diff --git a/crypto/openssl/ssl/tls13_enc.c b/crypto/openssl/ssl/tls13_enc.c index d9f050ee346d..39530237d897 100644 --- a/crypto/openssl/ssl/tls13_enc.c +++ b/crypto/openssl/ssl/tls13_enc.c @@ -724,8 +724,9 @@ int tls13_change_cipher_state(SSL *s, int which) s->statem.enc_write_state = ENC_WRITE_STATE_VALID; #ifndef OPENSSL_NO_KTLS # if defined(OPENSSL_KTLS_TLS13) - if (!(which & SSL3_CC_WRITE) || !(which & SSL3_CC_APPLICATION) - || ((which & SSL3_CC_WRITE) && (s->mode & SSL_MODE_NO_KTLS_TX))) + if (!(which & SSL3_CC_WRITE) + || !(which & SSL3_CC_APPLICATION) + || (s->options & SSL_OP_ENABLE_KTLS) == 0) goto skip_ktls; /* ktls supports only the maximum fragment size */ From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 221F26751E7; Tue, 24 Aug 2021 01:01: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 4GtrRG0TFJz4rK4; Tue, 24 Aug 2021 01:01: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 ECA9B1E45B; Tue, 24 Aug 2021 01:01: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 17O11jLO026226; Tue, 24 Aug 2021 01:01:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11jwC026225; Tue, 24 Aug 2021 01:01:45 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:45 GMT Message-Id: <202108240101.17O11jwC026225@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: ebe38d767ff3 - stable/13 - OpenSSL: Correct the return value of BIO_get_ktls_*(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ebe38d767ff3c735a60a9de2ed3d42cd794b5917 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:46 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ebe38d767ff3c735a60a9de2ed3d42cd794b5917 commit ebe38d767ff3c735a60a9de2ed3d42cd794b5917 Author: John Baldwin AuthorDate: 2021-08-17 21:37:47 +0000 Commit: John Baldwin CommitDate: 2021-08-24 00:59:34 +0000 OpenSSL: Correct the return value of BIO_get_ktls_*(). BIO_get_ktls_send() and BIO_get_ktls_recv() are documented as returning either 0 or 1. However, they were actually returning the internal value of the associated BIO flag for the true case instead of 1. Also trim redundant ternary operators. Reviewed by: jkim Obtained from: OpenSSL (f16e52b67c9261bdc7e1284a50502a802921ac6d) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31438 (cherry picked from commit 334d228a204c16d1384a978ab9b209e4e7e33275) --- crypto/openssl/crypto/bio/bss_conn.c | 6 +++--- crypto/openssl/crypto/bio/bss_fd.c | 2 +- crypto/openssl/crypto/bio/bss_sock.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crypto/openssl/crypto/bio/bss_conn.c b/crypto/openssl/crypto/bio/bss_conn.c index d4786442803e..10cf20871cb0 100644 --- a/crypto/openssl/crypto/bio/bss_conn.c +++ b/crypto/openssl/crypto/bio/bss_conn.c @@ -539,7 +539,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) } break; case BIO_CTRL_EOF: - ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0; break; # ifndef OPENSSL_NO_KTLS case BIO_CTRL_SET_KTLS: @@ -549,9 +549,9 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) BIO_set_ktls_flag(b, num); break; case BIO_CTRL_GET_KTLS_SEND: - return BIO_should_ktls_flag(b, 1); + return BIO_should_ktls_flag(b, 1) != 0; case BIO_CTRL_GET_KTLS_RECV: - return BIO_should_ktls_flag(b, 0); + return BIO_should_ktls_flag(b, 0) != 0; case BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG: BIO_set_ktls_ctrl_msg_flag(b); data->record_type = num; diff --git a/crypto/openssl/crypto/bio/bss_fd.c b/crypto/openssl/crypto/bio/bss_fd.c index ccbe1626baf2..8d03e48ce993 100644 --- a/crypto/openssl/crypto/bio/bss_fd.c +++ b/crypto/openssl/crypto/bio/bss_fd.c @@ -189,7 +189,7 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) ret = 1; break; case BIO_CTRL_EOF: - ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0; break; default: ret = 0; diff --git a/crypto/openssl/crypto/bio/bss_sock.c b/crypto/openssl/crypto/bio/bss_sock.c index a1fc23c7c938..8de1f5829207 100644 --- a/crypto/openssl/crypto/bio/bss_sock.c +++ b/crypto/openssl/crypto/bio/bss_sock.c @@ -191,9 +191,9 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) BIO_set_ktls_flag(b, num); break; case BIO_CTRL_GET_KTLS_SEND: - return BIO_should_ktls_flag(b, 1); + return BIO_should_ktls_flag(b, 1) != 0; case BIO_CTRL_GET_KTLS_RECV: - return BIO_should_ktls_flag(b, 0); + return BIO_should_ktls_flag(b, 0) != 0; case BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG: BIO_set_ktls_ctrl_msg_flag(b); b->ptr = (void *)num; @@ -205,7 +205,7 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) break; # endif case BIO_CTRL_EOF: - ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0; break; default: ret = 0; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C1052675624; Tue, 24 Aug 2021 01:01:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtrRM16Tzz4rFM; Tue, 24 Aug 2021 01:01: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 96BE21E64C; Tue, 24 Aug 2021 01:01: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 17O11oJO026322; Tue, 24 Aug 2021 01:01:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11okZ026321; Tue, 24 Aug 2021 01:01:50 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:50 GMT Message-Id: <202108240101.17O11okZ026321@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: 58dcc1777a56 - stable/13 - OpenSSL: Refactor KTLS tests to better support TLS 1.3. 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: 58dcc1777a56643adedee232d488aa851ab455eb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:52 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=58dcc1777a56643adedee232d488aa851ab455eb commit 58dcc1777a56643adedee232d488aa851ab455eb Author: John Baldwin AuthorDate: 2021-08-17 21:39:58 +0000 Commit: John Baldwin CommitDate: 2021-08-24 00:59:35 +0000 OpenSSL: Refactor KTLS tests to better support TLS 1.3. Most of this upstream commit touched tests not included in the vendor import. The one change merged in is to remove a constant only present in an internal header to appease the older tests. Reviewed by: jkim Obtained from: OpenSSL (e1fdd5262e4a45ce3aaa631768e877ee7b6da21b) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31442 (cherry picked from commit d6e78ecb0bcd5af750c72745c4c51fe211046bff) --- crypto/openssl/include/internal/ktls.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crypto/openssl/include/internal/ktls.h b/crypto/openssl/include/internal/ktls.h index 393794298ccd..e824cf3f3f92 100644 --- a/crypto/openssl/include/internal/ktls.h +++ b/crypto/openssl/include/internal/ktls.h @@ -39,12 +39,6 @@ # define OPENSSL_KTLS_AES_GCM_256 # define OPENSSL_KTLS_TLS13 -/* - * Only used by the tests in sslapitest.c. - */ -# define TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE 8 -# define TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE 8 - typedef struct tls_enable ktls_crypto_info_t; /* From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A86A9674CFA; Tue, 24 Aug 2021 01:01: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 4GtrRK3xrYz4rMF; Tue, 24 Aug 2021 01:01: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 6E2061E5ED; Tue, 24 Aug 2021 01:01: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 17O11nE9026298; Tue, 24 Aug 2021 01:01:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11n3B026297; Tue, 24 Aug 2021 01:01:49 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:49 GMT Message-Id: <202108240101.17O11n3B026297@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: a1509acded2f - stable/13 - OpenSSL: Update KTLS documentation 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: a1509acded2ff9ccfbbe10d9d8d5282b62370443 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:49 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a1509acded2ff9ccfbbe10d9d8d5282b62370443 commit a1509acded2ff9ccfbbe10d9d8d5282b62370443 Author: John Baldwin AuthorDate: 2021-08-17 21:39:32 +0000 Commit: John Baldwin CommitDate: 2021-08-24 00:59:35 +0000 OpenSSL: Update KTLS documentation KTLS support has been changed to be off by default, and configuration is via a single "option" rather two "modes". Documentation is updated accordingly. Reviewed by: jkim Obtained from: OpenSSL (6878f4300213cfd7d4f01e26a8b97f70344da100) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31441 (cherry picked from commit a208223130fb12daac9b4f52be1b3477b03ac521) --- crypto/openssl/doc/man3/SSL_CONF_cmd.pod | 4 ++++ crypto/openssl/doc/man3/SSL_CTX_set_mode.pod | 17 ----------------- crypto/openssl/doc/man3/SSL_CTX_set_options.pod | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/crypto/openssl/doc/man3/SSL_CONF_cmd.pod b/crypto/openssl/doc/man3/SSL_CONF_cmd.pod index 900c4f3a5648..a3f447a986e3 100644 --- a/crypto/openssl/doc/man3/SSL_CONF_cmd.pod +++ b/crypto/openssl/doc/man3/SSL_CONF_cmd.pod @@ -495,6 +495,10 @@ specification. Some applications may be able to mitigate the replay risks in other ways and in such cases the built-in OpenSSL functionality is not required. Disabling anti-replay is equivalent to setting B. +B: Enables kernel TLS if support has been compiled in, and it is supported +by the negotiated ciphersuites and extensions. Equivalent to +B. + =item B The B argument is a comma separated list of flags to set. diff --git a/crypto/openssl/doc/man3/SSL_CTX_set_mode.pod b/crypto/openssl/doc/man3/SSL_CTX_set_mode.pod index 27eaebad1ea0..85e3353e0e2c 100644 --- a/crypto/openssl/doc/man3/SSL_CTX_set_mode.pod +++ b/crypto/openssl/doc/man3/SSL_CTX_set_mode.pod @@ -114,22 +114,6 @@ enables this behaviour to allow interoperability with such broken implementations. Please note that setting this option breaks interoperability with correct implementations. This option only applies to DTLS over SCTP. -=item SSL_MODE_NO_KTLS_TX - -Disable the use of the kernel TLS egress data-path. -By default kernel TLS is enabled if it is supported by the negotiated ciphersuites -and extensions and OpenSSL has been compiled with support for it. -The kernel TLS data-path implements the record layer, -and the crypto algorithm. The kernel will utilize the best hardware -available for crypto. Using the kernel data-path should reduce the memory -footprint of OpenSSL because no buffering is required. Also, the throughput -should improve because data copy is avoided when user data is encrypted into -kernel memory instead of the usual encrypt than copy to kernel. - -Kernel TLS might not support all the features of OpenSSL. For instance, -renegotiation, and setting the maximum fragment size is not possible as of -Linux 4.20. - =back All modes are off by default except for SSL_MODE_AUTO_RETRY which is on by @@ -150,7 +134,6 @@ L, L =head1 HISTORY SSL_MODE_ASYNC was added in OpenSSL 1.1.0. -SSL_MODE_NO_KTLS_TX was first added to OpenSSL 3.0.0. =head1 COPYRIGHT diff --git a/crypto/openssl/doc/man3/SSL_CTX_set_options.pod b/crypto/openssl/doc/man3/SSL_CTX_set_options.pod index 969e0366c45a..231fe92d8e78 100644 --- a/crypto/openssl/doc/man3/SSL_CTX_set_options.pod +++ b/crypto/openssl/doc/man3/SSL_CTX_set_options.pod @@ -237,6 +237,29 @@ functionality is not required. Those applications can turn this feature off by setting this option. This is a server-side opton only. It is ignored by clients. +=item SSL_OP_ENABLE_KTLS + +Enable the use of kernel TLS. In order to benefit from kernel TLS OpenSSL must +have been compiled with support for it, and it must be supported by the +negotiated ciphersuites and extensions. The specific ciphersuites and extensions +that are supported may vary by platform and kernel version. + +The kernel TLS data-path implements the record layer, and the encryption +algorithm. The kernel will utilize the best hardware +available for encryption. Using the kernel data-path should reduce the memory +footprint of OpenSSL because no buffering is required. Also, the throughput +should improve because data copy is avoided when user data is encrypted into +kernel memory instead of the usual encrypt then copy to kernel. + +Kernel TLS might not support all the features of OpenSSL. For instance, +renegotiation, and setting the maximum fragment size is not possible as of +Linux 4.20. + +Note that with kernel TLS enabled some cryptographic operations are performed +by the kernel directly and not via any available OpenSSL Providers. This might +be undesirable if, for example, the application requires all cryptographic +operations to be performed by the FIPS provider. + =back The following options no longer have any effect but their identifiers are From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC852675248; Tue, 24 Aug 2021 01:01: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 4GtrRN0S7gz4rFP; Tue, 24 Aug 2021 01:01:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A85CF1E64D; Tue, 24 Aug 2021 01:01:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17O11pTm026352; Tue, 24 Aug 2021 01:01:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11p86026351; Tue, 24 Aug 2021 01:01:51 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:51 GMT Message-Id: <202108240101.17O11p86026351@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: b08bb7f8961d - stable/13 - OpenSSL: Add support for Chacha20-Poly1305 to kernel TLS on FreeBSD. 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: b08bb7f8961d1df15b41754a454d45aa333bb118 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:53 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b08bb7f8961d1df15b41754a454d45aa333bb118 commit b08bb7f8961d1df15b41754a454d45aa333bb118 Author: John Baldwin AuthorDate: 2021-08-17 21:40:16 +0000 Commit: John Baldwin CommitDate: 2021-08-24 00:59:35 +0000 OpenSSL: Add support for Chacha20-Poly1305 to kernel TLS on FreeBSD. FreeBSD's kernel TLS supports Chacha20 for both TLS 1.2 and TLS 1.3. NB: This commit has not yet been merged upstream as it is deemed a new feature and did not make the feature freeze cutoff for OpenSSL 3.0. Reviewed by: jkim Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31443 (cherry picked from commit 6372fd253e3266c6eb271f49159f1632d527c9bd) --- crypto/openssl/include/internal/ktls.h | 5 +++++ crypto/openssl/ssl/ktls.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/crypto/openssl/include/internal/ktls.h b/crypto/openssl/include/internal/ktls.h index e824cf3f3f92..5f9e3f91edb2 100644 --- a/crypto/openssl/include/internal/ktls.h +++ b/crypto/openssl/include/internal/ktls.h @@ -38,6 +38,11 @@ # define OPENSSL_KTLS_AES_GCM_128 # define OPENSSL_KTLS_AES_GCM_256 # define OPENSSL_KTLS_TLS13 +# ifdef TLS_CHACHA20_IV_LEN +# ifndef OPENSSL_NO_CHACHA +# define OPENSSL_KTLS_CHACHA20_POLY1305 +# endif +# endif typedef struct tls_enable ktls_crypto_info_t; diff --git a/crypto/openssl/ssl/ktls.c b/crypto/openssl/ssl/ktls.c index 47328a7c7c73..c7a440b79bd2 100644 --- a/crypto/openssl/ssl/ktls.c +++ b/crypto/openssl/ssl/ktls.c @@ -37,6 +37,10 @@ int ktls_check_supported_cipher(const SSL *s, const EVP_CIPHER *c, case SSL_AES128GCM: case SSL_AES256GCM: return 1; +# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 + case SSL_CHACHA20POLY1305: + return 1; +# endif case SSL_AES128: case SSL_AES256: if (s->ext.use_etm) @@ -71,6 +75,12 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd, else crypto_info->iv_len = EVP_GCM_TLS_FIXED_IV_LEN; break; +# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 + case SSL_CHACHA20POLY1305: + crypto_info->cipher_algorithm = CRYPTO_CHACHA20_POLY1305; + crypto_info->iv_len = EVP_CIPHER_CTX_iv_length(dd); + break; +# endif case SSL_AES128: case SSL_AES256: switch (s->s3->tmp.new_cipher->algorithm_mac) { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 01:01:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 58DAF67524D; Tue, 24 Aug 2021 01:01: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 4GtrRP0PK8z4rHh; Tue, 24 Aug 2021 01:01: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 C06FD1E64F; Tue, 24 Aug 2021 01:01: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 17O11q4Q026376; Tue, 24 Aug 2021 01:01:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O11q2b026375; Tue, 24 Aug 2021 01:01:52 GMT (envelope-from git) Date: Tue, 24 Aug 2021 01:01:52 GMT Message-Id: <202108240101.17O11q2b026375@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: c8d58f20ac77 - stable/13 - UPDATING: Add a note about OpenSSL defaulting KTLS to off. 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: c8d58f20ac77ebd48a41294e3b9c26efa3e98c1e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 01:01:53 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c8d58f20ac77ebd48a41294e3b9c26efa3e98c1e commit c8d58f20ac77ebd48a41294e3b9c26efa3e98c1e Author: John Baldwin AuthorDate: 2021-08-17 21:40:33 +0000 Commit: John Baldwin CommitDate: 2021-08-24 01:00:17 +0000 UPDATING: Add a note about OpenSSL defaulting KTLS to off. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31444 (cherry picked from commit 671a35b176e4b3c445696a8b423db5f8de26c285) --- UPDATING | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/UPDATING b/UPDATING index 6ad89bbf6602..ba5ec4f6d205 100644 --- a/UPDATING +++ b/UPDATING @@ -12,6 +12,14 @@ Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before updating system packages and/or ports. +20210823: + As of commit 622809b0868f OpenSSL no longer enables kernel TLS + by default. Users can enable kernel TLS via the "KTLS" SSL + option. This can be enabled globally by using a custom + OpenSSL config file via OPENSSL_CONF or via an + application-specific configuration option for applications + which permit setting SSL options via SSL_CONF_cmd(3). + 20210803: Commits 9fb6e613373c and 9ec7dbf46b0a both changed the internal KAPI between the NFS modules. Bump __FreeBSD_version to 1300514. From owner-dev-commits-src-all@freebsd.org Tue Aug 24 02:29:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 84842676A08; Tue, 24 Aug 2021 02:29: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 4GttNy2wm3z4fZk; Tue, 24 Aug 2021 02:29:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4CCD72012F; Tue, 24 Aug 2021 02:29:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17O2TsRv036742; Tue, 24 Aug 2021 02:29:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O2TsSp036741; Tue, 24 Aug 2021 02:29:54 GMT (envelope-from git) Date: Tue, 24 Aug 2021 02:29:54 GMT Message-Id: <202108240229.17O2TsSp036741@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: ccda3e7069b4 - stable/13 - ntb_transport(4): Mark callouts MP-safe. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ccda3e7069b42dfda39358af64cbc4e2c52cd32d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 02:29:54 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=ccda3e7069b42dfda39358af64cbc4e2c52cd32d commit ccda3e7069b42dfda39358af64cbc4e2c52cd32d Author: Alexander Motin AuthorDate: 2021-08-10 20:30:12 +0000 Commit: Alexander Motin CommitDate: 2021-08-24 02:29:46 +0000 ntb_transport(4): Mark callouts MP-safe. The only thing around NTB using Giant lock is NewBus, and these callouts have nothing to do with it. MFC after: 2 weeks (cherry picked from commit c6902e7796bc78df011131a2b8b024faed884b8f) --- sys/dev/ntb/ntb_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/ntb/ntb_transport.c b/sys/dev/ntb/ntb_transport.c index d6bccfb0f08c..3977be6db7cf 100644 --- a/sys/dev/ntb/ntb_transport.c +++ b/sys/dev/ntb/ntb_transport.c @@ -492,8 +492,8 @@ ntb_transport_attach(device_t dev) for (i = 0; i < nt->qp_count; i++) ntb_transport_init_queue(nt, i); - callout_init(&nt->link_work, 0); - callout_init(&nt->link_watchdog, 0); + callout_init(&nt->link_work, 1); + callout_init(&nt->link_watchdog, 1); TASK_INIT(&nt->link_cleanup, 0, ntb_transport_link_cleanup_work, nt); nt->link_is_up = false; @@ -639,7 +639,7 @@ ntb_transport_init_queue(struct ntb_transport_ctx *nt, unsigned int qp_num) qp->tx_max_frame = qmin(transport_mtu, tx_size / 2); qp->tx_max_entry = tx_size / qp->tx_max_frame; - callout_init(&qp->link_work, 0); + callout_init(&qp->link_work, 1); callout_init(&qp->rx_full, 1); mtx_init(&qp->ntb_rx_q_lock, "ntb rx q", NULL, MTX_SPIN); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 02:29:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EED7667637D; Tue, 24 Aug 2021 02:29:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GttNz5F9tz4fZm; Tue, 24 Aug 2021 02:29: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 735BD20046; Tue, 24 Aug 2021 02:29: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 17O2TtkD036766; Tue, 24 Aug 2021 02:29:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O2Tt4t036765; Tue, 24 Aug 2021 02:29:55 GMT (envelope-from git) Date: Tue, 24 Aug 2021 02:29:55 GMT Message-Id: <202108240229.17O2Tt4t036765@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: a58ed3b4f446 - stable/13 - ntb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a58ed3b4f4468a20fde6f2dbbfe2fdb7a1357ef7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 02:29:56 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=a58ed3b4f4468a20fde6f2dbbfe2fdb7a1357ef7 commit a58ed3b4f4468a20fde6f2dbbfe2fdb7a1357ef7 Author: Alexander Motin AuthorDate: 2021-08-10 20:24:48 +0000 Commit: Alexander Motin CommitDate: 2021-08-24 02:29:46 +0000 ntb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags. Most of the sysctls just read hardware registers. They don't need any locking. MFC after: 2 weeks (cherry picked from commit 50f16247a110d2ace56f1120304616f3e6ad9763) --- sys/dev/ntb/ntb_hw/ntb_hw_intel.c | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c index 8eb210efb065..2c7a0ecb30c2 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c @@ -2521,15 +2521,15 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) globals = SYSCTL_CHILDREN(device_get_sysctl_tree(ntb->device)); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "link_status", - CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, sysctl_handle_link_status_human, "A", "Link status (human readable)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "active", - CTLFLAG_RD | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RD | CTLTYPE_UINT, ntb, 0, sysctl_handle_link_status, "IU", "Link status (1=active, 0=inactive)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "admin_up", - CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RW | CTLTYPE_UINT, ntb, 0, sysctl_handle_link_admin, "IU", "Set/get interface status (1=UP, 0=DOWN)"); @@ -2555,7 +2555,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) } SYSCTL_ADD_PROC(ctx, tree_par, OID_AUTO, "features", - CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_NEEDGIANT, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, sysctl_handle_features, "A", "Features/errata of this NTB device"); SYSCTL_ADD_UINT(ctx, tree_par, OID_AUTO, "ntb_ctl", CTLFLAG_RD, @@ -2589,63 +2589,63 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) regpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ntbcntl", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->reg->ntb_ctl, sysctl_handle_register, "IU", "NTB Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcap", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | 0x19c, sysctl_handle_register, "IU", "NTB Link Capabilities"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcon", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | 0x1a0, sysctl_handle_register, "IU", "NTB Link Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_mask", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_mask, sysctl_handle_register, "QU", "Doorbell mask register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_bell", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_bell, sysctl_handle_register, "QU", "Doorbell register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_xlat, sysctl_handle_register, "QU", "Incoming XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "IU", "Incoming XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_xlat, sysctl_handle_register, "IU", "Incoming XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "QU", "Incoming XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_limit, sysctl_handle_register, "QU", "Incoming LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "IU", "Incoming LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_limit, sysctl_handle_register, "IU", "Incoming LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "QU", "Incoming LMT45 register"); } @@ -2657,7 +2657,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Xeon HW statistics"); statpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, statpar, OID_AUTO, "upstream_mem_miss", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | XEON_USMEMMISS_OFFSET, sysctl_handle_register, "SU", "Upstream Memory Miss"); @@ -2666,55 +2666,55 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) errpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ppd", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | NTB_PPD_OFFSET, sysctl_handle_register, "CU", "PPD"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR23SZ_OFFSET, sysctl_handle_register, "CU", "PBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR4SZ_OFFSET, sysctl_handle_register, "CU", "PBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR5SZ_OFFSET, sysctl_handle_register, "CU", "PBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR23SZ_OFFSET, sysctl_handle_register, "CU", "SBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR4SZ_OFFSET, sysctl_handle_register, "CU", "SBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR5SZ_OFFSET, sysctl_handle_register, "CU", "SBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "devsts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_DEVSTS_OFFSET, sysctl_handle_register, "SU", "DEVSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_LINK_STATUS_OFFSET, sysctl_handle_register, "SU", "LNKSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "slnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_SLINK_STATUS_OFFSET, sysctl_handle_register, "SU", "SLNKSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "uncerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_UNCERRSTS_OFFSET, sysctl_handle_register, "IU", "UNCERRSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "corerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_CORERRSTS_OFFSET, sysctl_handle_register, "IU", "CORERRSTS"); @@ -2722,75 +2722,75 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) return; SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01l", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETL, sysctl_handle_register, "IU", "Outgoing XLAT0L register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01u", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETU, sysctl_handle_register, "IU", "Outgoing XLAT0U register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_1].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_3].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | XEON_PBAR2LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | XEON_PBAR5LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar01_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar0_base, sysctl_handle_register, "QU", "Secondary BAR01 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_base, sysctl_handle_register, "QU", "Secondary BAR23 base register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "IU", "Secondary BAR4 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_base, sysctl_handle_register, "IU", "Secondary BAR5 base register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar45_base", - CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_NEEDGIANT, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "QU", "Secondary BAR45 base register"); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 02:35:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78677676D84; Tue, 24 Aug 2021 02:35: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 4GttWD2gPCz4grq; Tue, 24 Aug 2021 02:35: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 4345420268; Tue, 24 Aug 2021 02:35: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 17O2ZKlo049491; Tue, 24 Aug 2021 02:35:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O2ZKWD049490; Tue, 24 Aug 2021 02:35:20 GMT (envelope-from git) Date: Tue, 24 Aug 2021 02:35:20 GMT Message-Id: <202108240235.17O2ZKWD049490@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: 2d26a28153d2 - stable/12 - ntb_transport(4): Mark callouts MP-safe. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2d26a28153d21ed059b6f2fc854e3eaf9e85e6d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 02:35:20 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=2d26a28153d21ed059b6f2fc854e3eaf9e85e6d7 commit 2d26a28153d21ed059b6f2fc854e3eaf9e85e6d7 Author: Alexander Motin AuthorDate: 2021-08-10 20:30:12 +0000 Commit: Alexander Motin CommitDate: 2021-08-24 02:34:58 +0000 ntb_transport(4): Mark callouts MP-safe. The only thing around NTB using Giant lock is NewBus, and these callouts have nothing to do with it. MFC after: 2 weeks (cherry picked from commit c6902e7796bc78df011131a2b8b024faed884b8f) --- sys/dev/ntb/ntb_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/ntb/ntb_transport.c b/sys/dev/ntb/ntb_transport.c index 2208bbee0143..219e54720537 100644 --- a/sys/dev/ntb/ntb_transport.c +++ b/sys/dev/ntb/ntb_transport.c @@ -490,8 +490,8 @@ ntb_transport_attach(device_t dev) for (i = 0; i < nt->qp_count; i++) ntb_transport_init_queue(nt, i); - callout_init(&nt->link_work, 0); - callout_init(&nt->link_watchdog, 0); + callout_init(&nt->link_work, 1); + callout_init(&nt->link_watchdog, 1); TASK_INIT(&nt->link_cleanup, 0, ntb_transport_link_cleanup_work, nt); nt->link_is_up = false; @@ -637,7 +637,7 @@ ntb_transport_init_queue(struct ntb_transport_ctx *nt, unsigned int qp_num) qp->tx_max_frame = qmin(transport_mtu, tx_size / 2); qp->tx_max_entry = tx_size / qp->tx_max_frame; - callout_init(&qp->link_work, 0); + callout_init(&qp->link_work, 1); callout_init(&qp->rx_full, 1); mtx_init(&qp->ntb_rx_q_lock, "ntb rx q", NULL, MTX_SPIN); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 02:35:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E6926767F8; Tue, 24 Aug 2021 02:35: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 4GttWV3zQ2z4gnF; Tue, 24 Aug 2021 02:35: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 6ED6320269; Tue, 24 Aug 2021 02:35: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 17O2ZYD6049620; Tue, 24 Aug 2021 02:35:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O2ZYJ6049619; Tue, 24 Aug 2021 02:35:34 GMT (envelope-from git) Date: Tue, 24 Aug 2021 02:35:34 GMT Message-Id: <202108240235.17O2ZYJ6049619@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: 17c83ffd10b5 - stable/13 - ntb_hw_intel(4): Add CTLFLAG_MPSAFE flags. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 17c83ffd10b528074f1dbdff1a0dfcf130430ef9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 02:35:34 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=17c83ffd10b528074f1dbdff1a0dfcf130430ef9 commit 17c83ffd10b528074f1dbdff1a0dfcf130430ef9 Author: Alexander Motin AuthorDate: 2021-08-11 00:03:12 +0000 Commit: Alexander Motin CommitDate: 2021-08-24 02:35:30 +0000 ntb_hw_intel(4): Add CTLFLAG_MPSAFE flags. I should have added those in 50f16247a1. MFC after: 2 weeks (cherry picked from commit 94feb1f1eb4c3527efdbd0b3f556eb3cb37c3318) --- sys/dev/ntb/ntb_hw/ntb_hw_intel.c | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c index 2c7a0ecb30c2..716bca8c27ce 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c @@ -2521,15 +2521,15 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) globals = SYSCTL_CHILDREN(device_get_sysctl_tree(ntb->device)); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "link_status", - CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_link_status_human, "A", "Link status (human readable)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "active", - CTLFLAG_RD | CTLTYPE_UINT, ntb, 0, + CTLFLAG_RD | CTLTYPE_UINT | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_link_status, "IU", "Link status (1=active, 0=inactive)"); SYSCTL_ADD_PROC(ctx, globals, OID_AUTO, "admin_up", - CTLFLAG_RW | CTLTYPE_UINT, ntb, 0, + CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_link_admin, "IU", "Set/get interface status (1=UP, 0=DOWN)"); @@ -2555,7 +2555,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) } SYSCTL_ADD_PROC(ctx, tree_par, OID_AUTO, "features", - CTLFLAG_RD | CTLTYPE_STRING, ntb, 0, + CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE, ntb, 0, sysctl_handle_features, "A", "Features/errata of this NTB device"); SYSCTL_ADD_UINT(ctx, tree_par, OID_AUTO, "ntb_ctl", CTLFLAG_RD, @@ -2589,63 +2589,63 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) regpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ntbcntl", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->reg->ntb_ctl, sysctl_handle_register, "IU", "NTB Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcap", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | 0x19c, sysctl_handle_register, "IU", "NTB Link Capabilities"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcon", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | 0x1a0, sysctl_handle_register, "IU", "NTB Link Control register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_mask", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_mask, sysctl_handle_register, "QU", "Doorbell mask register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_bell", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_bell, sysctl_handle_register, "QU", "Doorbell register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_xlat, sysctl_handle_register, "QU", "Incoming XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "IU", "Incoming XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_xlat, sysctl_handle_register, "IU", "Incoming XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_xlat, sysctl_handle_register, "QU", "Incoming XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_limit, sysctl_handle_register, "QU", "Incoming LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "IU", "Incoming LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_limit, sysctl_handle_register, "IU", "Incoming LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "incoming_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_limit, sysctl_handle_register, "QU", "Incoming LMT45 register"); } @@ -2657,7 +2657,7 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Xeon HW statistics"); statpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, statpar, OID_AUTO, "upstream_mem_miss", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | XEON_USMEMMISS_OFFSET, sysctl_handle_register, "SU", "Upstream Memory Miss"); @@ -2666,55 +2666,55 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) errpar = SYSCTL_CHILDREN(tmptree); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ppd", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | NTB_PPD_OFFSET, sysctl_handle_register, "CU", "PPD"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR23SZ_OFFSET, sysctl_handle_register, "CU", "PBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR4SZ_OFFSET, sysctl_handle_register, "CU", "PBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "pbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_PBAR5SZ_OFFSET, sysctl_handle_register, "CU", "PBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR23SZ_OFFSET, sysctl_handle_register, "CU", "SBAR23 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR4SZ_OFFSET, sysctl_handle_register, "CU", "SBAR4 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_sz", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_8 | NTB_PCI_REG | XEON_SBAR5SZ_OFFSET, sysctl_handle_register, "CU", "SBAR5 SZ (log2)"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "devsts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_DEVSTS_OFFSET, sysctl_handle_register, "SU", "DEVSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_LINK_STATUS_OFFSET, sysctl_handle_register, "SU", "LNKSTS"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "slnksts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_16 | NTB_PCI_REG | XEON_SLINK_STATUS_OFFSET, sysctl_handle_register, "SU", "SLNKSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "uncerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_UNCERRSTS_OFFSET, sysctl_handle_register, "IU", "UNCERRSTS"); SYSCTL_ADD_PROC(ctx, errpar, OID_AUTO, "corerrsts", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | NTB_PCI_REG | XEON_CORERRSTS_OFFSET, sysctl_handle_register, "IU", "CORERRSTS"); @@ -2722,75 +2722,75 @@ intel_ntb_sysctl_init(struct ntb_softc *ntb) return; SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01l", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETL, sysctl_handle_register, "IU", "Outgoing XLAT0L register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat01u", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_B2B_XLAT_OFFSETU, sysctl_handle_register, "IU", "Outgoing XLAT0U register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_1].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->bar_info[NTB_B2B_BAR_3].pbarxlat_off, sysctl_handle_register, "IU", "Outgoing XLAT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_xlat45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->bar_info[NTB_B2B_BAR_2].pbarxlat_off, sysctl_handle_register, "QU", "Outgoing XLAT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt23", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | XEON_PBAR2LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT23 register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt4", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT4 register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt5", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | XEON_PBAR5LMT_OFFSET, sysctl_handle_register, "IU", "Outgoing LMT5 register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "outgoing_lmt45", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | XEON_PBAR4LMT_OFFSET, sysctl_handle_register, "QU", "Outgoing LMT45 register"); } SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar01_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar0_base, sysctl_handle_register, "QU", "Secondary BAR01 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar23_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar2_base, sysctl_handle_register, "QU", "Secondary BAR23 base register"); if (HAS_FEATURE(ntb, NTB_SPLIT_BAR)) { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar4_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "IU", "Secondary BAR4 base register"); SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar5_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_32 | ntb->xlat_reg->bar5_base, sysctl_handle_register, "IU", "Secondary BAR5 base register"); } else { SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "sbar45_base", - CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, + CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE, ntb, NTB_REG_64 | ntb->xlat_reg->bar4_base, sysctl_handle_register, "QU", "Secondary BAR45 base register"); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 09:18:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75121653BA5; Tue, 24 Aug 2021 09:18: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 4Gv3SB22wqz4d5c; Tue, 24 Aug 2021 09:18: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 2CF8F25BCF; Tue, 24 Aug 2021 09:18: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 17O9IIL6086535; Tue, 24 Aug 2021 09:18:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O9IIWL086534; Tue, 24 Aug 2021 09:18:18 GMT (envelope-from git) Date: Tue, 24 Aug 2021 09:18:18 GMT Message-Id: <202108240918.17O9IIWL086534@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 5425ba833257 - main - truncate(1): Fix cross-build CI failure due to missing fspacectl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5425ba8332571e57f9fe623346cb9d83293264d4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:18:18 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=5425ba8332571e57f9fe623346cb9d83293264d4 commit 5425ba8332571e57f9fe623346cb9d83293264d4 Author: Ka Ho Ng AuthorDate: 2021-08-24 08:26:04 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 09:08:28 +0000 truncate(1): Fix cross-build CI failure due to missing fspacectl For other platforms, fspacectl(2) is absent. This commit masks out the calls to fspacectl(2) and replace them with a ENODEV errno. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31619 --- tools/build/Makefile | 5 +++++ tools/build/fcntl.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ tools/build/fspacectl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/tools/build/Makefile b/tools/build/Makefile index 948a5f9dfdb2..3b49eb44475e 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -88,6 +88,11 @@ INCS+= strings.h SRCS+= explicit_bzero.c .endif +_WITH_FSPACECTL!= grep -c fspacectl ${HOST_INCLUDE_ROOT}/fcntl.h || true +.if ${_WITH_FSPACECTL} == 0 +INCS+= fcntl.h +SRCS+= fspacectl.c +.endif .if exists(${HOST_INCLUDE_ROOT}/capsicum_helpers.h) _WITH_CAPH_ENTER!= grep -c caph_enter ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true diff --git a/tools/build/fcntl.h b/tools/build/fcntl.h new file mode 100644 index 000000000000..3f88a4bf73d3 --- /dev/null +++ b/tools/build/fcntl.h @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2016 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LEGACY_SYS_FCNTL_H_ +#define _LEGACY_SYS_FCNTL_H_ + +#include_next + +struct spacectl_range { + off_t r_offset; + off_t r_len; +}; + +#define SPACECTL_DEALLOC 1 + +#define SPACECTL_F_SUPPORTED 0 + +__BEGIN_DECLS +int fspacectl(int, int, const struct spacectl_range *, int, + struct spacectl_range *); +__END_DECLS + +#endif /* !_LEGACY_SYS_STAT_H_ */ diff --git a/tools/build/fspacectl.c b/tools/build/fspacectl.c new file mode 100644 index 000000000000..c17802c51e01 --- /dev/null +++ b/tools/build/fspacectl.c @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software was developed by Ka Ho Ng + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +/* + * This is currently a stub implementation of fspacectl(2). + */ +int +fspacectl(int fd, int cmd, const struct spacectl_range *rqsr, int flags, + struct spacectl_range *rmsr) +{ + errno = ENOSYS; + return (-1); +} \ No newline at end of file From owner-dev-commits-src-all@freebsd.org Tue Aug 24 09:18:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8875E653D0B; Tue, 24 Aug 2021 09:18: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 4Gv3SC33JLz4d3v; Tue, 24 Aug 2021 09:18: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 4FE1525B42; Tue, 24 Aug 2021 09:18:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17O9IJMT086559; Tue, 24 Aug 2021 09:18:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O9IJ9V086558; Tue, 24 Aug 2021 09:18:19 GMT (envelope-from git) Date: Tue, 24 Aug 2021 09:18:19 GMT Message-Id: <202108240918.17O9IJ9V086558@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 1eaa36523cb9 - main - fspacectl(2): Clarifies the return values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1eaa36523cb921e90d61b20531ed525aba0cfe7e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:18:19 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=1eaa36523cb921e90d61b20531ed525aba0cfe7e commit 1eaa36523cb921e90d61b20531ed525aba0cfe7e Author: Ka Ho Ng AuthorDate: 2021-08-24 09:04:02 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 09:08:28 +0000 fspacectl(2): Clarifies the return values rmacklem@ spotted two things in the system call: - Upon returning from a successful operation, vop_stddeallocate can update rmsr.r_offset to a value greater than file size. This behavior, although being harmless, can be confusing. - The EINVAL return value for rqsr.r_offset + rqsr.r_len > OFF_MAX is undocumented. This commit has the following changes: - vop_stddeallocate and shm_deallocate to bound the the affected area further by the file size. - The EINVAL case for rqsr.r_offset + rqsr.r_len > OFF_MAX is documented. - The fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9)'s return len is explicitly documented the be the value 0, and the return offset is restricted to be the smallest of off + len and current file size suggested by kib@. This semantic allows callers to interact better with potential file size growth after the call. Sponsored by: The FreeBSD Foundation Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D31604 --- lib/libc/sys/fspacectl.2 | 27 ++++++++++++++++++++++----- share/man/man9/VOP_DEALLOCATE.9 | 8 ++++++++ share/man/man9/vn_deallocate.9 | 8 ++++++++ sys/kern/uipc_shm.c | 11 +++++++++-- sys/kern/vfs_default.c | 8 ++++++-- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/lib/libc/sys/fspacectl.2 b/lib/libc/sys/fspacectl.2 index 2f581d1c1fb8..0e369785b883 100644 --- a/lib/libc/sys/fspacectl.2 +++ b/lib/libc/sys/fspacectl.2 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 4, 2021 +.Dd August 18, 2021 .Dt FSPACECTL 2 .Os .Sh NAME @@ -67,6 +67,17 @@ argument is non-NULL, the .Fa spacectl_range structure it points to is updated to contain the unprocessed operation range after the system call returns. +.Pp +For a successful completion without an unprocessed part in the requested +operation range, +.Fa "rmsr->r_len" +is updated to be the value 0, and +.Fa "rmsr->r_offset" +is updated to be the smallest of +.Fa "rqsr->r_offset" + +.Fa "rqsr->r_len" ; +and the end-of-file offset. +The file descriptor's file offset is not used or modified by the system call. Both .Fa rqsr and @@ -92,9 +103,9 @@ Zero a region in the file specified by the .Fa rqsr argument. The -.Va "rqsr->r_offset" +.Fa "rqsr->r_offset" has to be a value greater than or equal to 0, and the -.Va "rqsr->r_len" +.Fa "rqsr->r_len" has to be a value greater than 0. .Pp If the file system supports hole-punching, @@ -132,11 +143,17 @@ If the argument is .Dv SPACECTL_DEALLOC , either the -.Fa "range->r_offset" +.Fa "rqsr->r_offset" argument was less than zero, or the -.Fa "range->r_len" +.Fa "rqsr->r_len" argument was less than or equal to zero. .It Bq Er EINVAL +The value of +.Fa "rqsr->r_offset" + +.Fa "rqsr->r_len" +is greater than +.Dv OFF_MAX . +.It Bq Er EINVAL An invalid or unsupported flag is included in .Fa flags . .It Bq Er EINVAL diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9 index dbfe048f2235..2ec915c6fef3 100644 --- a/share/man/man9/VOP_DEALLOCATE.9 +++ b/share/man/man9/VOP_DEALLOCATE.9 @@ -74,6 +74,14 @@ and are updated to reflect the portion of the range that still needs to be zeroed/deallocated on return. Partial result is considered a successful operation. +For a successful completion without an unprocessed portion of the range, +.Fa *len +is updated to be the value 0, and +.Fa *offset +is updated to be the smallest of +.Fa *offset + +.Fa *len +passed to the call and the end-of-file offset. .Sh LOCKS The vnode should be locked on entry and will still be locked on exit. .Sh RETURN VALUES diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9 index 29edcd57ff5d..08f4e92ec597 100644 --- a/share/man/man9/vn_deallocate.9 +++ b/share/man/man9/vn_deallocate.9 @@ -95,6 +95,14 @@ Attempt to bypass buffer cache. and .Fa *length are updated to reflect the unprocessed operation range of the call. +For a successful completion, +.Fa *length +is updated to be the value 0, and +.Fa *offset +is updated to be the smallest of +.Fa *offset + +.Fa *length +passed to the call and the end-of-file offset. .Sh RETURN VALUES Upon successful completion, the value 0 is returned; otherwise the appropriate error is returned. diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 16d1e22a898b..60815ef24c26 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1905,6 +1905,8 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) off = *offset; len = *length; KASSERT(off + len <= (vm_ooffset_t)OFF_MAX, ("off + len overflows")); + if (off + len > shmfd->shm_size) + len = shmfd->shm_size - off; object = shmfd->shm_object; startofs = off & PAGE_MASK; endofs = (off + len) & PAGE_MASK; @@ -1913,6 +1915,13 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) pi = OFF_TO_IDX(off + PAGE_MASK); error = 0; + /* Handle the case when offset is beyond shm size */ + if ((off_t)len < 0) { + *offset = shmfd->shm_size; + *length = 0; + return (0); + } + VM_OBJECT_WLOCK(object); if (startofs != 0) { @@ -1974,8 +1983,6 @@ shm_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, break; } error = shm_deallocate(shmfd, &off, &len, flags); - if (error != 0) - break; *offset = off; *length = len; break; diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d9328cd39b00..d5df9cd8bf7b 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1138,14 +1138,13 @@ vop_stddeallocate(struct vop_deallocate_args *ap) vp = ap->a_vp; offset = *ap->a_offset; - len = *ap->a_len; cred = ap->a_cred; error = VOP_GETATTR(vp, &va, cred); if (error) return (error); - len = omin(OFF_MAX - offset, *ap->a_len); + len = omin((off_t)va.va_size - offset, *ap->a_len); while (len > 0) { noff = offset; error = vn_bmap_seekhole_locked(vp, FIOSEEKDATA, &noff, cred); @@ -1185,6 +1184,11 @@ vop_stddeallocate(struct vop_deallocate_args *ap) if (should_yield()) break; } + /* Handle the case when offset is beyond EOF */ + if (len < 0) { + offset += len; + len = 0; + } out: *ap->a_offset = offset; *ap->a_len = len; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 09:18:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3684653D13; Tue, 24 Aug 2021 09:18:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv3SD4Qhxz4d5k; Tue, 24 Aug 2021 09:18:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 758B425D40; Tue, 24 Aug 2021 09:18: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 17O9IKQW086583; Tue, 24 Aug 2021 09:18:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17O9IK11086582; Tue, 24 Aug 2021 09:18:20 GMT (envelope-from git) Date: Tue, 24 Aug 2021 09:18:20 GMT Message-Id: <202108240918.17O9IK11086582@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 1a4c5061fc5b - main - param: Bump __FreeBSD_version to 1400031 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1a4c5061fc5ba8f2eee41456a6873547915f268a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:18:20 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=1a4c5061fc5ba8f2eee41456a6873547915f268a commit 1a4c5061fc5ba8f2eee41456a6873547915f268a Author: Ka Ho Ng AuthorDate: 2021-08-24 09:13:00 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 09:13:00 +0000 param: Bump __FreeBSD_version to 1400031 Commit 1eaa36523cb9 introduces backward compatible changes to fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9). rmsr.r_offset and *offset is updated to contain meaningful value upon returning from the call. Sponsored by: The FreeBSD Foundation --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 5ab48dce2a74..82787b4552af 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400030 +#define __FreeBSD_version 1400031 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-all@freebsd.org Tue Aug 24 09:24:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F2BC653ECB; Tue, 24 Aug 2021 09:24:32 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv3bM6fPKz4fqL; Tue, 24 Aug 2021 09:24:31 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from dac1f024b.dhcp.in.dimsumlabs.com (unknown [IPv6:2001:470:fbdc:6066:bc48:c3eb:8afc:1748]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: khng/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 0D802272F8; Tue, 24 Aug 2021 09:24:30 +0000 (UTC) (envelope-from khng@FreeBSD.org) Subject: Re: git: 1a4c5061fc5b - main - param: Bump __FreeBSD_version to 1400031 From: Ka Ho Ng To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108240918.17O9IK11086582@gitrepo.freebsd.org> Message-ID: <1754c408-7e5b-d661-3f01-445d200415d2@FreeBSD.org> Date: Tue, 24 Aug 2021 17:24:27 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <202108240918.17O9IK11086582@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:24:32 -0000 On 2021/8/24 5:18 PM, Ka Ho Ng wrote: > The branch main has been updated by khng: > > URL: https://cgit.FreeBSD.org/src/commit/?id=1a4c5061fc5ba8f2eee41456a6873547915f268a > > commit 1a4c5061fc5ba8f2eee41456a6873547915f268a > Author: Ka Ho Ng > AuthorDate: 2021-08-24 09:13:00 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-24 09:13:00 +0000 > > param: Bump __FreeBSD_version to 1400031 > > Commit 1eaa36523cb9 introduces backward compatible changes to > fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9). > rmsr.r_offset and *offset is updated to contain meaningful value upon > returning from the call. > > Sponsored by: The FreeBSD Foundation > --- > sys/sys/param.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/sys/param.h b/sys/sys/param.h > index 5ab48dce2a74..82787b4552af 100644 > --- a/sys/sys/param.h > +++ b/sys/sys/param.h > @@ -76,7 +76,7 @@ > * cannot include sys/param.h and should only be updated here. > */ > #undef __FreeBSD_version > -#define __FreeBSD_version 1400030 > +#define __FreeBSD_version 1400031 > > /* > * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, > Despite that, file system modules implementing VOP_DEALLOCATE(9) need to update *ap->a_offset to omin(*offset + *length, file_sz). Ka Ho From owner-dev-commits-src-all@freebsd.org Tue Aug 24 09:59:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A161365435D; Tue, 24 Aug 2021 09:59:46 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv4N23xP8z4pq5; Tue, 24 Aug 2021 09:59:46 +0000 (UTC) (envelope-from khng@FreeBSD.org) Received: from dac1f024b.dhcp.in.dimsumlabs.com (unknown [IPv6:2001:470:fbdc:6066:bc48:c3eb:8afc:1748]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: khng/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 9CCFD27548; Tue, 24 Aug 2021 09:59:45 +0000 (UTC) (envelope-from khng@FreeBSD.org) Subject: Re: git: 5425ba833257 - main - truncate(1): Fix cross-build CI failure due to missing fspacectl From: Ka Ho Ng To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108240918.17O9IIWL086534@gitrepo.freebsd.org> Message-ID: <7448352e-2ab8-477a-801e-21eb26743ab2@FreeBSD.org> Date: Tue, 24 Aug 2021 17:59:43 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <202108240918.17O9IIWL086534@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 09:59:46 -0000 On 2021/8/24 5:18 PM, Ka Ho Ng wrote: > The branch main has been updated by khng: > > URL: https://cgit.FreeBSD.org/src/commit/?id=5425ba8332571e57f9fe623346cb9d83293264d4 > > commit 5425ba8332571e57f9fe623346cb9d83293264d4 > Author: Ka Ho Ng > AuthorDate: 2021-08-24 08:26:04 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-24 09:08:28 +0000 > > truncate(1): Fix cross-build CI failure due to missing fspacectl > > For other platforms, fspacectl(2) is absent. This commit masks out the > calls to fspacectl(2) and replace them with a ENODEV errno. > > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D31619 > --- > tools/build/Makefile | 5 +++++ > tools/build/fcntl.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > tools/build/fspacectl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 97 insertions(+) > > diff --git a/tools/build/Makefile b/tools/build/Makefile > index 948a5f9dfdb2..3b49eb44475e 100644 > --- a/tools/build/Makefile > +++ b/tools/build/Makefile > @@ -88,6 +88,11 @@ INCS+= strings.h > SRCS+= explicit_bzero.c > .endif > > +_WITH_FSPACECTL!= grep -c fspacectl ${HOST_INCLUDE_ROOT}/fcntl.h || true > +.if ${_WITH_FSPACECTL} == 0 > +INCS+= fcntl.h > +SRCS+= fspacectl.c > +.endif > > .if exists(${HOST_INCLUDE_ROOT}/capsicum_helpers.h) > _WITH_CAPH_ENTER!= grep -c caph_enter ${HOST_INCLUDE_ROOT}/capsicum_helpers.h || true > diff --git a/tools/build/fcntl.h b/tools/build/fcntl.h > new file mode 100644 > index 000000000000..3f88a4bf73d3 > --- /dev/null > +++ b/tools/build/fcntl.h > @@ -0,0 +1,48 @@ > +/*- > + * Copyright (c) 2016 Jilles Tjoelker > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + * > + * $FreeBSD$ > + */ > + > +#ifndef _LEGACY_SYS_FCNTL_H_ > +#define _LEGACY_SYS_FCNTL_H_ > + > +#include_next > + > +struct spacectl_range { > + off_t r_offset; > + off_t r_len; > +}; > + > +#define SPACECTL_DEALLOC 1 > + > +#define SPACECTL_F_SUPPORTED 0 > + > +__BEGIN_DECLS > +int fspacectl(int, int, const struct spacectl_range *, int, > + struct spacectl_range *); > +__END_DECLS > + > +#endif /* !_LEGACY_SYS_STAT_H_ */ > diff --git a/tools/build/fspacectl.c b/tools/build/fspacectl.c > new file mode 100644 > index 000000000000..c17802c51e01 > --- /dev/null > +++ b/tools/build/fspacectl.c > @@ -0,0 +1,44 @@ > +/*- > + * Copyright (c) 2021 The FreeBSD Foundation > + * > + * This software was developed by Ka Ho Ng > + * under sponsorship from the FreeBSD Foundation. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > + > +/* > + * This is currently a stub implementation of fspacectl(2). > + */ > +int > +fspacectl(int fd, int cmd, const struct spacectl_range *rqsr, int flags, > + struct spacectl_range *rmsr) > +{ > + errno = ENOSYS; > + return (-1); > +} > \ No newline at end of file > s/ENODEV/ENOSYS Ka Ho From owner-dev-commits-src-all@freebsd.org Tue Aug 24 11:24:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 241E765544D; Tue, 24 Aug 2021 11:24: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 4Gv6FS0Bznz3lkl; Tue, 24 Aug 2021 11:24: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 DEFF127746; Tue, 24 Aug 2021 11:24: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 17OBOBIY059757; Tue, 24 Aug 2021 11:24:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOBlP059756; Tue, 24 Aug 2021 11:24:11 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:11 GMT Message-Id: <202108241124.17OBOBlP059756@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 38941f5993a1 - main - i386: retire bcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 38941f5993a161cd4ce21a0c0b2360d3ee73cf84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:12 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=38941f5993a161cd4ce21a0c0b2360d3ee73cf84 commit 38941f5993a161cd4ce21a0c0b2360d3ee73cf84 Author: Mateusz Guzik AuthorDate: 2021-08-23 19:18:49 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 i386: retire bcopy Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/i386/i386/support.s | 9 --------- 1 file changed, 9 deletions(-) diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 4130affbba5c..c1ded3bb9357 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -127,17 +127,8 @@ END(fillw) /* * memmove(dst, src, cnt) (return dst) - * bcopy(src, dst, cnt) * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 */ -ENTRY(bcopy) - movl 4(%esp),%eax - movl 8(%esp),%edx - movl %eax,8(%esp) - movl %edx,4(%esp) - jmp memmove -END(bcopy) - ENTRY(memmove) pushl %ebp movl %esp,%ebp From owner-dev-commits-src-all@freebsd.org Tue Aug 24 11:24:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 361F36559EE; Tue, 24 Aug 2021 11:24: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 4Gv6FT0lD6z3lkq; Tue, 24 Aug 2021 11:24: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 F0E99277A2; Tue, 24 Aug 2021 11:24: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 17OBOCGX059782; Tue, 24 Aug 2021 11:24:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOCcP059781; Tue, 24 Aug 2021 11:24:12 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:12 GMT Message-Id: <202108241124.17OBOCcP059781@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: d0bc029b4a1e - main - arm64: retire bcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d0bc029b4a1ec6522375a1db7d5fc73e3b0461f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:13 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=d0bc029b4a1ec6522375a1db7d5fc73e3b0461f3 commit d0bc029b4a1ec6522375a1db7d5fc73e3b0461f3 Author: Mateusz Guzik AuthorDate: 2021-08-23 19:21:48 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 arm64: retire bcopy Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") Reviewed by: andrew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31651 --- sys/arm64/arm64/memmove.S | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sys/arm64/arm64/memmove.S b/sys/arm64/arm64/memmove.S index 4b99dccc536e..22e7edb54636 100644 --- a/sys/arm64/arm64/memmove.S +++ b/sys/arm64/arm64/memmove.S @@ -84,12 +84,7 @@ __FBSDID("$FreeBSD$"); unrolled loop processes 64 bytes per iteration. */ -ENTRY(bcopy) - /* Switch the input pointers when called as bcopy */ - mov x3, x1 - mov x1, x0 - mov x0, x3 -EENTRY(memmove) +ENTRY(memmove) sub tmp1, dstin, src cmp count, 96 ccmp tmp1, count, 2, hi @@ -146,5 +141,4 @@ EENTRY(memmove) stp B_l, B_h, [dstin, 16] stp C_l, C_h, [dstin] 3: ret -EEND(memmove) -END(bcopy) +END(memmove) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 11:24:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61F4A655884; Tue, 24 Aug 2021 11:24: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 4Gv6FV28hgz3m34; Tue, 24 Aug 2021 11:24: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 2899527A04; Tue, 24 Aug 2021 11:24: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 17OBOEFj059806; Tue, 24 Aug 2021 11:24:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOElP059805; Tue, 24 Aug 2021 11:24:14 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:14 GMT Message-Id: <202108241124.17OBOElP059805@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 9a1d562085cb - main - mips: retire ovbcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a1d562085cb4623a95e3e7a649d81099ce67470 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:14 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9a1d562085cb4623a95e3e7a649d81099ce67470 commit 9a1d562085cb4623a95e3e7a649d81099ce67470 Author: Mateusz Guzik AuthorDate: 2021-08-24 08:49:31 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 mips: retire ovbcopy ovbcopy is unused since 9f45b2da8fa08638 ("Define ovbcopy() as a macro which expands to the equivalent bcopy() call") bcopy is left in place because it is used by assembly primitives Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/mips/mips/bcopy.S | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/mips/mips/bcopy.S b/sys/mips/mips/bcopy.S index 4205ca5e1680..ffd86f1de26d 100644 --- a/sys/mips/mips/bcopy.S +++ b/sys/mips/mips/bcopy.S @@ -74,7 +74,6 @@ XLEAF(memmove) move a1, v0 XLEAF(bcopy) -XLEAF(ovbcopy) /* * Make sure we can copy forwards. */ From owner-dev-commits-src-all@freebsd.org Tue Aug 24 11:24:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D002265546A; Tue, 24 Aug 2021 11:24: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 4Gv6FW44XSz3lvY; Tue, 24 Aug 2021 11:24: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 4B96E2733D; Tue, 24 Aug 2021 11:24: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 17OBOFO7059830; Tue, 24 Aug 2021 11:24:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOFOd059829; Tue, 24 Aug 2021 11:24:15 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:15 GMT Message-Id: <202108241124.17OBOFOd059829@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 7ec4365671e3 - main - libkern: remove bcopy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7ec4365671e395f99e32f954e2f83b735aca4ac7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:15 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7ec4365671e395f99e32f954e2f83b735aca4ac7 commit 7ec4365671e395f99e32f954e2f83b735aca4ac7 Author: Mateusz Guzik AuthorDate: 2021-08-24 11:21:52 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:07 +0000 libkern: remove bcopy Unused since ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines.") File name remains to reduce churn. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/libkern/bcopy.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sys/libkern/bcopy.c b/sys/libkern/bcopy.c index 8e34ad0daa53..833a9854f181 100644 --- a/sys/libkern/bcopy.c +++ b/sys/libkern/bcopy.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #undef memcpy #undef memmove -#undef bcopy /* * sizeof(word) MUST BE A POWER OF TWO @@ -147,10 +146,3 @@ done: } __strong_reference(memcpy, memmove); - -void -(bcopy)(const void *src0, void *dst0, size_t length) -{ - - memcpy(dst0, src0, length); -} From owner-dev-commits-src-all@freebsd.org Tue Aug 24 11:24:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B47AB6551D8; Tue, 24 Aug 2021 11:24: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 4Gv6FX4S7hz3lm7; Tue, 24 Aug 2021 11:24: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 6DB912733E; Tue, 24 Aug 2021 11:24: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 17OBOGOj059854; Tue, 24 Aug 2021 11:24:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OBOGxs059853; Tue, 24 Aug 2021 11:24:16 GMT (envelope-from git) Date: Tue, 24 Aug 2021 11:24:16 GMT Message-Id: <202108241124.17OBOGxs059853@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 36fc38301824 - main - Remove bcopy declaration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36fc38301824e2d6ca774200d8be972a6196f353 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 11:24:17 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=36fc38301824e2d6ca774200d8be972a6196f353 commit 36fc38301824e2d6ca774200d8be972a6196f353 Author: Mateusz Guzik AuthorDate: 2021-08-24 11:22:56 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 11:24:08 +0000 Remove bcopy declaration The kernel was migrated to memmove in ba96f37758412151 ("Use __builtin for various mem* and b* (e.g. bzero) routines."). Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/sys/systm.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 17d1e8933997..17c110a957c9 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -341,7 +341,6 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags); #define HD_OMIT_CHARS (1 << 18) #define ovbcopy(f, t, l) bcopy((f), (t), (l)) -void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); void explicit_bzero(void * _Nonnull, size_t); void *memset(void * _Nonnull buf, int c, size_t len); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 12:53:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D762665724A; Tue, 24 Aug 2021 12:53: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 4Gv8Dh5TBRz4gyM; Tue, 24 Aug 2021 12:53: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 A47C59DA; Tue, 24 Aug 2021 12:53: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 17OCreFV078593; Tue, 24 Aug 2021 12:53:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OCreNW078592; Tue, 24 Aug 2021 12:53:40 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:53:40 GMT Message-Id: <202108241253.17OCreNW078592@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: a6daf4d500b4 - stable/13 - Add arp/ndp tests in addition to rtsock ll tests. 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: a6daf4d500b47fbc4c1b4f859fa9338b78e3a266 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:53:40 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a6daf4d500b47fbc4c1b4f859fa9338b78e3a266 commit a6daf4d500b47fbc4c1b4f859fa9338b78e3a266 Author: Alexander V. Chernikov AuthorDate: 2021-02-20 18:20:24 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 07:02:15 +0000 Add arp/ndp tests in addition to rtsock ll tests. (cherry picked from commit f17f94cd1b99c61faa08aa988b47805c53b78ac7) --- tests/sys/netinet/Makefile | 2 +- tests/sys/netinet/arp.sh | 97 +++++++++++++++++++++++++++++++++++++ tests/sys/netinet6/Makefile | 3 +- tests/sys/netinet6/ndp.sh | 115 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 215 insertions(+), 2 deletions(-) diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index a053ec711fff..ec2e6e679c18 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -12,7 +12,7 @@ ATF_TESTS_C= ip_reass_test \ socket_afinet \ tcp_connect_port_test -ATF_TESTS_SH= carp fibs fibs_test redirect divert forward output lpm +ATF_TESTS_SH= carp fibs fibs_test redirect divert forward output lpm arp TEST_METADATA.output+= required_programs="python" PROGS= udp_dontroute tcp_user_cookie diff --git a/tests/sys/netinet/arp.sh b/tests/sys/netinet/arp.sh new file mode 100755 index 000000000000..8b5b30911314 --- /dev/null +++ b/tests/sys/netinet/arp.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env atf-sh +#- +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2021 Alexander V. Chernikov +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +. $(atf_get_srcdir)/../common/vnet.subr + +atf_test_case "arp_add_success" "cleanup" +arp_add_success_head() { + atf_set descr 'Test static arp record addition' + atf_set require.user root +} + +arp_add_success_body() { + + vnet_init + + jname="v4t-arp_add_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + + jexec ${jname} ifconfig ${epair0}a inet 198.51.100.1/24 + + atf_check jexec ${jname} arp -s 198.51.100.2 90:10:00:01:02:03 + + atf_check -o match:"\? \(198.51.100.2\) at 90:10:00:01:02:03 on ${epair0}a permanent" jexec ${jname} arp -ni ${epair0}a 198.51.100.2 +} + +arp_add_success_cleanup() { + vnet_cleanup +} + + +atf_test_case "arp_del_success" "cleanup" +arp_del_success_head() { + atf_set descr 'Test arp record deletion' + atf_set require.user root +} + +arp_del_success_body() { + + vnet_init + + jname="v4t-arp_del_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + + jexec ${jname} ifconfig ${epair0}a inet 198.51.100.1/24 + + jexec ${jname} ping -c1 -t1 198.51.100.2 + + atf_check -o match:"198.51.100.2 \(198.51.100.2\) deleted" jexec ${jname} arp -nd 198.51.100.2 +} + +arp_del_success_cleanup() { + vnet_cleanup +} + + +atf_init_test_cases() +{ + + atf_add_test_case "arp_add_success" + atf_add_test_case "arp_del_success" +} + +# end + diff --git a/tests/sys/netinet6/Makefile b/tests/sys/netinet6/Makefile index 0ad95af97c83..dfae9f698ec4 100644 --- a/tests/sys/netinet6/Makefile +++ b/tests/sys/netinet6/Makefile @@ -14,7 +14,8 @@ ATF_TESTS_SH= \ forward6 \ output6 \ lpm6 \ - fibs6 + fibs6 \ + ndp TEST_METADATA.output6+= required_programs="python" ${PACKAGE}FILES+= exthdr.py diff --git a/tests/sys/netinet6/ndp.sh b/tests/sys/netinet6/ndp.sh new file mode 100755 index 000000000000..2b26ffd4c448 --- /dev/null +++ b/tests/sys/netinet6/ndp.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env atf-sh +#- +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2021 Alexander V. Chernikov +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +. $(atf_get_srcdir)/../common/vnet.subr + +atf_test_case "ndp_add_gu_success" "cleanup" +ndp_add_gu_success_head() { + atf_set descr 'Test static ndp record addition' + atf_set require.user root +} + +ndp_add_gu_success_body() { + + vnet_init + + jname="v6t-ndp_add_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + jexec ${jname} ndp -i ${epair0}a -- -disabled + jexec ${jname} ifconfig ${epair0}a up + + jexec ${jname} ifconfig ${epair0}a inet6 2001:db8::1/64 + + # wait for DAD to complete + while [ `jexec ${jname} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do + sleep 0.1 + done + + atf_check jexec ${jname} ndp -s 2001:db8::2 90:10:00:01:02:03 + + t=`jexec ${jname} ndp -an | grep 2001:db8::2 | awk '{print $1, $2, $3, $4}'` + if [ "${t}" != "2001:db8::2 90:10:00:01:02:03 ${epair0}a permanent" ]; then + atf_fail "Wrong output: ${t}" + fi + echo "T='${t}'" +} + +ndp_add_gu_success_cleanup() { + vnet_cleanup +} + +atf_test_case "ndp_del_gu_success" "cleanup" +ndp_del_gu_success_head() { + atf_set descr 'Test ndp record deletion' + atf_set require.user root +} + +ndp_del_gu_success_body() { + + vnet_init + + jname="v6t-ndp_del_gu_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + + jexec ${jname} ndp -i ${epair0}a -- -disabled + jexec ${jname} ifconfig ${epair0}a up + + jexec ${jname} ifconfig ${epair0}a inet6 2001:db8::1/64 + + # wait for DAD to complete + while [ `jexec ${jname} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do + sleep 0.1 + done + + jexec ${jname} ping -c1 -t1 2001:db8::2 + + atf_check -o match:"2001:db8::2 \(2001:db8::2\) deleted" jexec ${jname} ndp -nd 2001:db8::2 +} + +ndp_del_success_cleanup() { + vnet_cleanup +} + + +atf_init_test_cases() +{ + + atf_add_test_case "ndp_add_gu_success" + atf_add_test_case "ndp_del_gu_success" +} + +# end + From owner-dev-commits-src-all@freebsd.org Tue Aug 24 12:53:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 94E48657389; Tue, 24 Aug 2021 12: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 4Gv8Dl0pwQz4gsc; Tue, 24 Aug 2021 12: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 EF088838; Tue, 24 Aug 2021 12:53: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 17OCrggY078750; Tue, 24 Aug 2021 12: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 17OCrgFX078744; Tue, 24 Aug 2021 12:53:42 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:53:42 GMT Message-Id: <202108241253.17OCrgFX078744@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: 78cb8d7f2991 - stable/12 - netinet tests: delete an interface with pending lookups 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: 78cb8d7f2991498177a7c40dee502cddd4dd5e1c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:53:43 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=78cb8d7f2991498177a7c40dee502cddd4dd5e1c commit 78cb8d7f2991498177a7c40dee502cddd4dd5e1c Author: Kristof Provost AuthorDate: 2021-08-17 14:19:29 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 07:03:15 +0000 netinet tests: delete an interface with pending lookups This has been known to trigger panics. It currently doesn't, but we may as well have a test for it. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit e86469075c5e391cc86e5bcd4f252712a69de37e) --- tests/sys/netinet/arp.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/sys/netinet/arp.sh b/tests/sys/netinet/arp.sh index 8b5b30911314..b909b9a48fb3 100755 --- a/tests/sys/netinet/arp.sh +++ b/tests/sys/netinet/arp.sh @@ -85,12 +85,48 @@ arp_del_success_cleanup() { vnet_cleanup } +atf_test_case "pending_delete_if" "cleanup" +pending_delete_if_head() { + atf_set descr 'Test having pending link layer lookups on interface delete' + atf_set require.user root +} + +pending_delete_if_body() { + vnet_init + + jname="arp_pending_delete_if" + epair=$(vnet_mkepair) + + ifconfig ${epair}b up + + vnet_mkjail ${jname} ${epair}a + jexec ${jname} ifconfig ${epair}a 198.51.100.1/24 + for i in `seq 2 200` + do + jexec ${jname} ping 198.51.100.${i} & + done + + # Give the ping processes time to send their ARP requests + sleep 1 + + jexec ${jname} arp -an + jexec ${jname} killall ping + + # Delete the interface. Test failure panics the machine. + ifconfig ${epair}b destroy +} + +pending_delete_if_cleanup() { + vnet_cleanup +} + atf_init_test_cases() { atf_add_test_case "arp_add_success" atf_add_test_case "arp_del_success" + atf_add_test_case "pending_delete_if" } # end From owner-dev-commits-src-all@freebsd.org Tue Aug 24 12:53:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1CE656568A1; Tue, 24 Aug 2021 12: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 4Gv8Dj6QtJz4gwk; Tue, 24 Aug 2021 12:53: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 C2CB29DB; Tue, 24 Aug 2021 12: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 17OCrfoQ078664; Tue, 24 Aug 2021 12: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 17OCrfbi078658; Tue, 24 Aug 2021 12:53:41 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:53:41 GMT Message-Id: <202108241253.17OCrfbi078658@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: c2a591055248 - stable/13 - netinet tests: delete an interface with pending lookups 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: c2a591055248d015a5c92c8dc638222f5e5a6e62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:53:42 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c2a591055248d015a5c92c8dc638222f5e5a6e62 commit c2a591055248d015a5c92c8dc638222f5e5a6e62 Author: Kristof Provost AuthorDate: 2021-08-17 14:19:29 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 07:03:21 +0000 netinet tests: delete an interface with pending lookups This has been known to trigger panics. It currently doesn't, but we may as well have a test for it. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit e86469075c5e391cc86e5bcd4f252712a69de37e) --- tests/sys/netinet/arp.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/sys/netinet/arp.sh b/tests/sys/netinet/arp.sh index 8b5b30911314..b909b9a48fb3 100755 --- a/tests/sys/netinet/arp.sh +++ b/tests/sys/netinet/arp.sh @@ -85,12 +85,48 @@ arp_del_success_cleanup() { vnet_cleanup } +atf_test_case "pending_delete_if" "cleanup" +pending_delete_if_head() { + atf_set descr 'Test having pending link layer lookups on interface delete' + atf_set require.user root +} + +pending_delete_if_body() { + vnet_init + + jname="arp_pending_delete_if" + epair=$(vnet_mkepair) + + ifconfig ${epair}b up + + vnet_mkjail ${jname} ${epair}a + jexec ${jname} ifconfig ${epair}a 198.51.100.1/24 + for i in `seq 2 200` + do + jexec ${jname} ping 198.51.100.${i} & + done + + # Give the ping processes time to send their ARP requests + sleep 1 + + jexec ${jname} arp -an + jexec ${jname} killall ping + + # Delete the interface. Test failure panics the machine. + ifconfig ${epair}b destroy +} + +pending_delete_if_cleanup() { + vnet_cleanup +} + atf_init_test_cases() { atf_add_test_case "arp_add_success" atf_add_test_case "arp_del_success" + atf_add_test_case "pending_delete_if" } # end From owner-dev-commits-src-all@freebsd.org Tue Aug 24 12:53:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5BE15657073; Tue, 24 Aug 2021 12: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 4Gv8Dk0HN4z4gsW; Tue, 24 Aug 2021 12: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 DA132AC0; Tue, 24 Aug 2021 12: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 17OCrfsq078700; Tue, 24 Aug 2021 12: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 17OCrfNI078698; Tue, 24 Aug 2021 12:53:41 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:53:41 GMT Message-Id: <202108241253.17OCrfNI078698@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: ffb2af1d1870 - stable/12 - Add arp/ndp tests in addition to rtsock ll tests. 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: ffb2af1d187015588ced9cef4abebf0fed7b85d8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:53:42 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ffb2af1d187015588ced9cef4abebf0fed7b85d8 commit ffb2af1d187015588ced9cef4abebf0fed7b85d8 Author: Alexander V. Chernikov AuthorDate: 2021-02-20 18:20:24 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 07:02:53 +0000 Add arp/ndp tests in addition to rtsock ll tests. (cherry picked from commit f17f94cd1b99c61faa08aa988b47805c53b78ac7) --- tests/sys/netinet/Makefile | 2 +- tests/sys/netinet/arp.sh | 97 +++++++++++++++++++++++++++++++++++++ tests/sys/netinet6/Makefile | 1 + tests/sys/netinet6/ndp.sh | 115 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+), 1 deletion(-) diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index f92c47b136db..f5b465557282 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -8,7 +8,7 @@ TESTS_SUBDIRS+= libalias ATF_TESTS_C= ip_reass_test \ so_reuseport_lb_test -ATF_TESTS_SH= fibs_test +ATF_TESTS_SH= fibs_test arp PROGS= udp_dontroute tcp_user_cookie diff --git a/tests/sys/netinet/arp.sh b/tests/sys/netinet/arp.sh new file mode 100755 index 000000000000..8b5b30911314 --- /dev/null +++ b/tests/sys/netinet/arp.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env atf-sh +#- +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2021 Alexander V. Chernikov +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +. $(atf_get_srcdir)/../common/vnet.subr + +atf_test_case "arp_add_success" "cleanup" +arp_add_success_head() { + atf_set descr 'Test static arp record addition' + atf_set require.user root +} + +arp_add_success_body() { + + vnet_init + + jname="v4t-arp_add_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + + jexec ${jname} ifconfig ${epair0}a inet 198.51.100.1/24 + + atf_check jexec ${jname} arp -s 198.51.100.2 90:10:00:01:02:03 + + atf_check -o match:"\? \(198.51.100.2\) at 90:10:00:01:02:03 on ${epair0}a permanent" jexec ${jname} arp -ni ${epair0}a 198.51.100.2 +} + +arp_add_success_cleanup() { + vnet_cleanup +} + + +atf_test_case "arp_del_success" "cleanup" +arp_del_success_head() { + atf_set descr 'Test arp record deletion' + atf_set require.user root +} + +arp_del_success_body() { + + vnet_init + + jname="v4t-arp_del_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + + jexec ${jname} ifconfig ${epair0}a inet 198.51.100.1/24 + + jexec ${jname} ping -c1 -t1 198.51.100.2 + + atf_check -o match:"198.51.100.2 \(198.51.100.2\) deleted" jexec ${jname} arp -nd 198.51.100.2 +} + +arp_del_success_cleanup() { + vnet_cleanup +} + + +atf_init_test_cases() +{ + + atf_add_test_case "arp_add_success" + atf_add_test_case "arp_del_success" +} + +# end + diff --git a/tests/sys/netinet6/Makefile b/tests/sys/netinet6/Makefile index bdedc404a16e..d66c7f04c0e1 100644 --- a/tests/sys/netinet6/Makefile +++ b/tests/sys/netinet6/Makefile @@ -9,6 +9,7 @@ ATF_TESTS_SH= \ exthdr \ mld \ scapyi386 + ndp ${PACKAGE}FILES+= exthdr.py ${PACKAGE}FILES+= mld.py diff --git a/tests/sys/netinet6/ndp.sh b/tests/sys/netinet6/ndp.sh new file mode 100755 index 000000000000..2b26ffd4c448 --- /dev/null +++ b/tests/sys/netinet6/ndp.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env atf-sh +#- +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2021 Alexander V. Chernikov +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +. $(atf_get_srcdir)/../common/vnet.subr + +atf_test_case "ndp_add_gu_success" "cleanup" +ndp_add_gu_success_head() { + atf_set descr 'Test static ndp record addition' + atf_set require.user root +} + +ndp_add_gu_success_body() { + + vnet_init + + jname="v6t-ndp_add_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + jexec ${jname} ndp -i ${epair0}a -- -disabled + jexec ${jname} ifconfig ${epair0}a up + + jexec ${jname} ifconfig ${epair0}a inet6 2001:db8::1/64 + + # wait for DAD to complete + while [ `jexec ${jname} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do + sleep 0.1 + done + + atf_check jexec ${jname} ndp -s 2001:db8::2 90:10:00:01:02:03 + + t=`jexec ${jname} ndp -an | grep 2001:db8::2 | awk '{print $1, $2, $3, $4}'` + if [ "${t}" != "2001:db8::2 90:10:00:01:02:03 ${epair0}a permanent" ]; then + atf_fail "Wrong output: ${t}" + fi + echo "T='${t}'" +} + +ndp_add_gu_success_cleanup() { + vnet_cleanup +} + +atf_test_case "ndp_del_gu_success" "cleanup" +ndp_del_gu_success_head() { + atf_set descr 'Test ndp record deletion' + atf_set require.user root +} + +ndp_del_gu_success_body() { + + vnet_init + + jname="v6t-ndp_del_gu_success" + + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}a + + jexec ${jname} ndp -i ${epair0}a -- -disabled + jexec ${jname} ifconfig ${epair0}a up + + jexec ${jname} ifconfig ${epair0}a inet6 2001:db8::1/64 + + # wait for DAD to complete + while [ `jexec ${jname} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do + sleep 0.1 + done + + jexec ${jname} ping -c1 -t1 2001:db8::2 + + atf_check -o match:"2001:db8::2 \(2001:db8::2\) deleted" jexec ${jname} ndp -nd 2001:db8::2 +} + +ndp_del_success_cleanup() { + vnet_cleanup +} + + +atf_init_test_cases() +{ + + atf_add_test_case "ndp_add_gu_success" + atf_add_test_case "ndp_del_gu_success" +} + +# end + From owner-dev-commits-src-all@freebsd.org Tue Aug 24 12:57:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86F616574A5; Tue, 24 Aug 2021 12:57: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 4Gv8KF3NWpz4jTN; Tue, 24 Aug 2021 12:57: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 5D01E8B7; Tue, 24 Aug 2021 12:57: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 17OCvbGp079143; Tue, 24 Aug 2021 12:57:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OCvbon079142; Tue, 24 Aug 2021 12:57:37 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:57:37 GMT Message-Id: <202108241257.17OCvbon079142@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: e59eff9ad328 - main - pfctl: fix killing states by ID 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/main X-Git-Reftype: branch X-Git-Commit: e59eff9ad3285838730acf48f6d066cec0e53114 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:57:37 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e59eff9ad3285838730acf48f6d066cec0e53114 commit e59eff9ad3285838730acf48f6d066cec0e53114 Author: Kristof Provost AuthorDate: 2021-08-24 10:24:28 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 10:54:13 +0000 pfctl: fix killing states by ID Since the conversion to the new DIOCKILLSTATESNV the kernel no longer exists the id and creatorid to be big-endian. As a result killing states by id (i.e. `pfctl -k id -k 12345`) no longer worked. Reported by: Özkan KIRIK MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 6c689edf7c43..ad2cfd4e63bc 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -908,7 +908,6 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) if ((sscanf(state_kill[1], "%jx/%x", &kill.cmp.id, &kill.cmp.creatorid)) == 2) - HTONL(kill.cmp.creatorid); else if ((sscanf(state_kill[1], "%jx", &kill.cmp.id)) == 1) { kill.cmp.creatorid = 0; } else { @@ -920,7 +919,6 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) usage(); } - kill.cmp.id = htobe64(kill.cmp.id); if (pfctl_kill_states(dev, &kill, &killed)) err(1, "DIOCKILLSTATES"); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 12:57:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6ADE657458; Tue, 24 Aug 2021 12:57: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 4Gv8KG4gq9z4jRG; Tue, 24 Aug 2021 12:57: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 8012CBCB; Tue, 24 Aug 2021 12:57: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 17OCvcrE079167; Tue, 24 Aug 2021 12:57:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OCvcQt079166; Tue, 24 Aug 2021 12:57:38 GMT (envelope-from git) Date: Tue, 24 Aug 2021 12:57:38 GMT Message-Id: <202108241257.17OCvcQt079166@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: bbf832f34479 - main - pf tests: test killing states by ID 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/main X-Git-Reftype: branch X-Git-Commit: bbf832f34479d19bff0fa8dc43b48ab5553cc85e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 12:57:38 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=bbf832f34479d19bff0fa8dc43b48ab5553cc85e commit bbf832f34479d19bff0fa8dc43b48ab5553cc85e Author: Kristof Provost AuthorDate: 2021-08-24 10:36:57 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 10:54:13 +0000 pf tests: test killing states by ID MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/killstate.sh | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index e140ee4d144d..91fa9b42c8be 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -519,6 +519,70 @@ interface_cleanup() pft_cleanup } +atf_test_case "id" "cleanup" +id_head() +{ + atf_set descr 'Test killing states by id' + atf_set require.user root + atf_set require.progs scapy +} + +id_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in proto tcp" \ + "pass in proto icmp" + + # Sanity check & establish state + # Note: use pft_ping so we always use the same ID, so pf considers all + # echo requests part of the same flow. + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Established state means we can still ping alcatraz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Get the state ID + id=$(jexec alcatraz pfctl -ss -vvv | grep -A 3 icmp | + grep -A 3 192.0.2.2 | awk '/id:/ { printf("%s/%s", $2, $4); }') + + # Kill the wrong ID + jexec alcatraz pfctl -k id -k 1 + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Kill the correct ID + jexec alcatraz pfctl -k id -k ${id} + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a +} + +id_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" @@ -528,4 +592,5 @@ atf_init_test_cases() atf_add_test_case "gateway" atf_add_test_case "match" atf_add_test_case "interface" + atf_add_test_case "id" } From owner-dev-commits-src-all@freebsd.org Tue Aug 24 13:21:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 344756579F0; Tue, 24 Aug 2021 13:21: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 4Gv8s00zdwz4qqf; Tue, 24 Aug 2021 13:21: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 0AE5A1061; Tue, 24 Aug 2021 13:21: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 17ODLdoc015896; Tue, 24 Aug 2021 13:21:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ODLdTl015895; Tue, 24 Aug 2021 13:21:39 GMT (envelope-from git) Date: Tue, 24 Aug 2021 13:21:39 GMT Message-Id: <202108241321.17ODLdTl015895@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 9ce320820e6d - main - pfctl: build fix 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/main X-Git-Reftype: branch X-Git-Commit: 9ce320820e6d760df11a88de11fbae024c18d23c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 13:21:40 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9ce320820e6d760df11a88de11fbae024c18d23c commit 9ce320820e6d760df11a88de11fbae024c18d23c Author: Kristof Provost AuthorDate: 2021-08-24 11:21:05 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 11:21:05 +0000 pfctl: build fix Fix the build issue introduced in e59eff9ad328 (pfctl: fix killing states by ID) MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index ad2cfd4e63bc..016075058b21 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -907,7 +907,8 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) kill.kill_match = true; if ((sscanf(state_kill[1], "%jx/%x", - &kill.cmp.id, &kill.cmp.creatorid)) == 2) + &kill.cmp.id, &kill.cmp.creatorid)) == 2) { + } else if ((sscanf(state_kill[1], "%jx", &kill.cmp.id)) == 1) { kill.cmp.creatorid = 0; } else { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 13:30:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DAFE165765F; Tue, 24 Aug 2021 13:30: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 4Gv937546zz4sMk; Tue, 24 Aug 2021 13:30: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 970491223; Tue, 24 Aug 2021 13:30: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 17ODURXH028158; Tue, 24 Aug 2021 13:30:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ODURlQ028157; Tue, 24 Aug 2021 13:30:27 GMT (envelope-from git) Date: Tue, 24 Aug 2021 13:30:27 GMT Message-Id: <202108241330.17ODURlQ028157@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: 15c4c3b58d0f - stable/12 - netinet6 tests: build fix 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: 15c4c3b58d0f569fd6af66db9d96d7207a43b20a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 13:30:27 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=15c4c3b58d0f569fd6af66db9d96d7207a43b20a commit 15c4c3b58d0f569fd6af66db9d96d7207a43b20a Author: Kristof Provost AuthorDate: 2021-08-24 13:29:36 +0000 Commit: Kristof Provost CommitDate: 2021-08-24 13:29:36 +0000 netinet6 tests: build fix Add missing '\'. Direct commit to stable/12 due to mismerge. Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netinet6/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sys/netinet6/Makefile b/tests/sys/netinet6/Makefile index d66c7f04c0e1..dcf9ce7f6279 100644 --- a/tests/sys/netinet6/Makefile +++ b/tests/sys/netinet6/Makefile @@ -8,7 +8,7 @@ FILESDIR= ${TESTSDIR} ATF_TESTS_SH= \ exthdr \ mld \ - scapyi386 + scapyi386 \ ndp ${PACKAGE}FILES+= exthdr.py From owner-dev-commits-src-all@freebsd.org Tue Aug 24 13:59:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 14BDC6584AC; Tue, 24 Aug 2021 13:59: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 4Gv9hV06drz519p; Tue, 24 Aug 2021 13:59: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 E07801987; Tue, 24 Aug 2021 13:59: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 17ODxLWp060647; Tue, 24 Aug 2021 13:59:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17ODxLsg060646; Tue, 24 Aug 2021 13:59:21 GMT (envelope-from git) Date: Tue, 24 Aug 2021 13:59:21 GMT Message-Id: <202108241359.17ODxLsg060646@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 37296464defd - main - memcpy.3: remove BUGS section allowing overlapping strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 37296464defda0aa769c39ab554deb4875aef000 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 13:59:22 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=37296464defda0aa769c39ab554deb4875aef000 commit 37296464defda0aa769c39ab554deb4875aef000 Author: Ed Maste AuthorDate: 2021-08-24 13:20:18 +0000 Commit: Ed Maste CommitDate: 2021-08-24 13:58:10 +0000 memcpy.3: remove BUGS section allowing overlapping strings The removed text claimed that memcpy is implemented using bcopy and thus strings may overlap. Use of bcopy is an implementation detail that is no longer true, even if the implementation (on some archs) does allow overlap. In any case behaviour is undefined per the C standard if memcpy is called with overlapping objects, and this man page already claimed that src and dst may not overlap. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31192 --- lib/libc/string/memcpy.3 | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/libc/string/memcpy.3 b/lib/libc/string/memcpy.3 index c65e4145264a..66a91592d90e 100644 --- a/lib/libc/string/memcpy.3 +++ b/lib/libc/string/memcpy.3 @@ -86,19 +86,3 @@ The function conforms to .St -isoC . -.Sh BUGS -In this implementation -.Fn memcpy -and -.Fn mempcpy -are implemented using -.Xr bcopy 3 , -and therefore the strings may overlap. -On other systems, copying overlapping strings may produce surprises. -Programs intended to be portable should use -.Xr memmove 3 -when -.Fa src -and -.Fa dst -may overlap. From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:05:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 008BC658897; Tue, 24 Aug 2021 14:05:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gv9r66ZQmz531w; Tue, 24 Aug 2021 14:05: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 C9C4E17FE; Tue, 24 Aug 2021 14:05: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 17OE5wSg074498; Tue, 24 Aug 2021 14:05:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE5wVI074497; Tue, 24 Aug 2021 14:05:58 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:05:58 GMT Message-Id: <202108241405.17OE5wVI074497@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: ab3a18095fae - main - Makefile.inc1: Make sure sub-makes see MK_CLANG_BOOTSTRAP=no when XCC is a path MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ab3a18095faebe306989f25288c44968f4144063 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:05:59 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=ab3a18095faebe306989f25288c44968f4144063 commit ab3a18095faebe306989f25288c44968f4144063 Author: Jessica Clarke AuthorDate: 2021-08-24 13:55:31 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 Makefile.inc1: Make sure sub-makes see MK_CLANG_BOOTSTRAP=no when XCC is a path Currently we override MK_CLANG_BOOTSTRAP to no so we don't build a bootstrap compiler, but subdirectories don't see that and so the hack in bsd.sys.mk to prefer our includes over Clang's resource dir for external toolchains is not enabled unless you use -DWITHOUT_CLANG_BOOTSTRAP explicitly on top of XCC (which tools/build/make.py does not do), causing duplicate definition errors when building rtld-elf due to the use of -ffreestanding (Clang's stdint.h will use the system one when hosted, but its own when freestanding, and only has glibc's preprocessor guards, not FreeBSD's). This broke when dropping CLANG_BOOTSTRAP from BROKEN_OPTIONS. Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week Reviewed by: imp, arichardson Differential Revision: https://reviews.freebsd.org/D31529 --- Makefile.inc1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.inc1 b/Makefile.inc1 index 5bb2412e4042..604fef201c48 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -93,6 +93,9 @@ X${COMPILER}?= ${${COMPILER}} # a cross compiler. .if ${XCC:N${CCACHE_BIN}:M/*} MK_CLANG_BOOTSTRAP= no +# Make sure sub-makes see the option as disabled so the hack in bsd.sys.mk to +# work around incompatible headers in Clang's resource directory is enabled. +.MAKEOVERRIDES+= MK_CLANG_BOOTSTRAP .endif # Pull in compiler metadata from buildworld/toolchain if possible to avoid From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:06:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 35DEF65869C; Tue, 24 Aug 2021 14:06: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 4Gv9r80wdbz52yy; Tue, 24 Aug 2021 14:06: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 F329717FF; Tue, 24 Aug 2021 14:05: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 17OE5xhT074522; Tue, 24 Aug 2021 14:05:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE5xcf074521; Tue, 24 Aug 2021 14:05:59 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:05:59 GMT Message-Id: <202108241405.17OE5xcf074521@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 1e4c802913af - main - Fix bootstrapping to actually build lldb-tblgen for later use MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1e4c802913af619ac15741bbd276e1141ca17dc9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:00 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=1e4c802913af619ac15741bbd276e1141ca17dc9 commit 1e4c802913af619ac15741bbd276e1141ca17dc9 Author: Jessica Clarke AuthorDate: 2021-08-24 13:59:04 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 Fix bootstrapping to actually build lldb-tblgen for later use Because MK_LLDB=no is in BSARGS, the bootstrap-tools recursive make does not add lldb-tblgen to _clang_tblgen, causing it to not be built. This means that the build currently always uses the host's lldb-tblgen (which, whilst currently it appears to work, could in future break if TableGen backends are added or altered) and, if it doesn't exist (either because the current FreeBSD system was built with it disabled, or you're building on macOS/Linux), fails. Linux and macOS cross-builds used to work simply because LLDB was previously in BROKEN_OPTIONS when building on non-FreeBSD. Instead, move MK_LLDB=no from BSARGS to XMAKE. This ensures that the lib/clang build in cross-tools continues to not build LLDB parts for the bootstrap toolchain (both to save time/space on FreeBSD, and because our vendored LLDB does not include the macOS and Linux host files so those would fail to build). The DIRDEPS target is updated to move MK_LLDB=no from the BSARGS block that mirrors Makefile.inc1 to the line that disables additional toolchain components. The DIRDEPS build likely suffers from the same issue currently, but having never used it and not being familiar with how it works I am leaving that as-is. If it does suffer from the same issue it should be easily reproducible by renaming /usr/bin/lldb-tblgen or moving it to a directory not in PATH. Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week Reviewed by: dim, emaste, imp Differential Revision: https://reviews.freebsd.org/D31531 --- Makefile.inc1 | 2 +- targets/pseudo/bootstrap-tools/Makefile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 604fef201c48..b59c1913f8ce 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -727,7 +727,6 @@ BSARGS= DESTDIR= \ MK_CLANG_FORMAT=no \ MK_CLANG_FULL=no \ MK_HTML=no \ - MK_LLDB=no \ MK_MAN=no \ MK_PROFILE=no \ MK_RETPOLINE=no \ @@ -771,6 +770,7 @@ TMAKE= \ XMAKE= ${BMAKE} \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \ + MK_LLDB=no \ MK_TESTS=no # kernel-tools stage diff --git a/targets/pseudo/bootstrap-tools/Makefile b/targets/pseudo/bootstrap-tools/Makefile index 3ac47053a388..d5545f082283 100644 --- a/targets/pseudo/bootstrap-tools/Makefile +++ b/targets/pseudo/bootstrap-tools/Makefile @@ -48,7 +48,6 @@ BSARGS= DESTDIR= \ MK_CLANG_FORMAT=no \ MK_CLANG_FULL=no \ MK_HTML=no \ - MK_LLDB=no \ MK_MAN=no \ MK_PROFILE=no \ MK_RETPOLINE=no \ @@ -59,7 +58,7 @@ BSARGS= DESTDIR= \ MK_MAN_UTILS=yes # We will handle building the toolchain and cross-compiler. -BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no +BSARGS+= MK_CROSS_COMPILER=no MK_CLANG=no MK_LLDB=no DISTRIB_ENV= INSTALL="sh ${SRCTOP}/tools/install.sh" NO_FSCHG=1 MK_TESTS=no legacy: .MAKE ${META_DEPS} From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:06:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 92D0D658455; Tue, 24 Aug 2021 14:06: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 4Gv9r933srz533W; Tue, 24 Aug 2021 14:06: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 3418E1739; Tue, 24 Aug 2021 14:06: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 17OE61ue074546; Tue, 24 Aug 2021 14:06:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE619s074545; Tue, 24 Aug 2021 14:06:01 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:06:01 GMT Message-Id: <202108241406.17OE619s074545@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: c8edd0542647 - main - clang: Support building with GCC and DEBUG_FILES disabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c8edd0542647f59ab07dd73e865edd34706397a5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:01 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=c8edd0542647f59ab07dd73e865edd34706397a5 commit c8edd0542647f59ab07dd73e865edd34706397a5 Author: Jessica Clarke AuthorDate: 2021-08-24 13:59:18 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 clang: Support building with GCC and DEBUG_FILES disabled If MK_DEBUG_FILES=no then the Clang link rule has clang as .TARGET, rather than clang.full, causing the implicit ${CFLAGS.${.TARGET:T}} to be CFLAGS.clang, and thus pull in flags intended for when your compiler is Clang, not when linking Clang itself. This doesn't matter if your compiler is in fact Clang, but it breaks using GCC as, for example, bsd.sys.mk adds -Qunused-arguments to CFLAGS.clang. This is seen when trying to build a bootstrap toolchain on Linux where GCC is the system compiler. Thus, introduce a new internal NO_TARGET_FLAGS variable that is set by Clang to disable the addition of these implicit flags. This is a bigger hammer than necessary, as flags for .o files would be safe, but that is not needed for Clang. Note that the same problem does not arise for LDFLAGS when building LLD with BFD, since our build produces a program called ld.lld, not plain lld (unlike upstream, where ld.lld is a symlink to lld so they can support multiple different flavours in one binary). Suggested by: sjg Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week Reviewed by: dim, imp, emaste Differential Revision: https://reviews.freebsd.org/D31532 --- share/mk/bsd.sys.mk | 9 ++++++++- usr.bin/clang/clang/Makefile | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index a964cf6e596c..80cc3080e552 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -273,7 +273,14 @@ LDFLAGS+= ${LDFLAGS.${LINKER_TYPE}} # Only allow .TARGET when not using PROGS as it has the same syntax # per PROG which is ambiguous with this syntax. This is only needed # for PROG_VARS vars. -.if !defined(_RECURSING_PROGS) +# +# Some directories (currently just clang) also need to disable this since +# CFLAGS.${COMPILER_TYPE}, CFLAGS.${.IMPSRC:T} and CFLAGS.${.TARGET:T} all live +# in the same namespace, meaning that, for example, GCC builds of clang pick up +# CFLAGS.clang via CFLAGS.${.TARGET:T} and thus try to pass Clang-specific +# flags. Ideally the different sources of CFLAGS would be namespaced to avoid +# collisions. +.if !defined(_RECURSING_PROGS) && !defined(NO_TARGET_FLAGS) .if ${MK_WARNS} != "no" CFLAGS+= ${CWARNFLAGS.${.TARGET:T}} .endif diff --git a/usr.bin/clang/clang/Makefile b/usr.bin/clang/clang/Makefile index ec42fe78cf90..31f092608583 100644 --- a/usr.bin/clang/clang/Makefile +++ b/usr.bin/clang/clang/Makefile @@ -34,4 +34,7 @@ MLINKS+= clang.1 cc.1 \ LIBADD+= z +# Ensure we don't add CFLAGS.clang when using GCC +NO_TARGET_FLAGS= + .include "../clang.prog.mk" From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:06:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8737D6581D4; Tue, 24 Aug 2021 14:06: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 4Gv9rB2s2jz533Z; Tue, 24 Aug 2021 14:06: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 4102F1C96; Tue, 24 Aug 2021 14:06: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 17OE62li074574; Tue, 24 Aug 2021 14:06:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE62Cq074573; Tue, 24 Aug 2021 14:06:02 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:06:02 GMT Message-Id: <202108241406.17OE62Cq074573@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: c1f7d8dd23db - main - clang: Build with -fno-strict-aliasing when using GCC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c1f7d8dd23db693106fcd66e0b1766a3f3194670 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:02 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=c1f7d8dd23db693106fcd66e0b1766a3f3194670 commit c1f7d8dd23db693106fcd66e0b1766a3f3194670 Author: Jessica Clarke AuthorDate: 2021-08-24 13:59:36 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 clang: Build with -fno-strict-aliasing when using GCC Somewhat ironically, there are strict aliasing violations in Clang, which can result in the following assertion failure: Assertion `*(NamedDecl **)&Data == ND && "PointerUnion mangles the NamedDecl pointer!"' failed. Upstream's clang/CMakeLists.txt specifically (not LLVM as a whole) passes -fno-strict-aliasing if the compiler is not Clang, and this fixes the above issue. This was seen when cross-building from Linux using a bootstrap compiler, but likely also affects worlds built with a new enough external GCC toolchain. MFC after: 1 week Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D31533 --- lib/clang/clang.build.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk index 0d3151178eb9..fb64b16935f2 100644 --- a/lib/clang/clang.build.mk +++ b/lib/clang/clang.build.mk @@ -13,4 +13,6 @@ CFLAGS+= -DCLANG_ENABLE_ARCMT CFLAGS+= -DCLANG_ENABLE_STATIC_ANALYZER .endif +CFLAGS.gcc+= -fno-strict-aliasing + .include "llvm.build.mk" From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:06:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A82626582C6; Tue, 24 Aug 2021 14:06: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 4Gv9rC3vkhz52nq; Tue, 24 Aug 2021 14:06:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64AD01D00; Tue, 24 Aug 2021 14:06: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 17OE63ZF074601; Tue, 24 Aug 2021 14:06:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OE63aY074600; Tue, 24 Aug 2021 14:06:03 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:06:03 GMT Message-Id: <202108241406.17OE63aY074600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 83ec48b79275 - main - Revert "Mark LLDB/CLANG_BOOTSTRAP/LLD_BOOTSTRAP as broken on non-FreeBSD for now" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 83ec48b79275b5211b06675dba04dab1f58c3a70 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:06:04 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=83ec48b79275b5211b06675dba04dab1f58c3a70 commit 83ec48b79275b5211b06675dba04dab1f58c3a70 Author: Jessica Clarke AuthorDate: 2021-08-24 14:00:06 +0000 Commit: Jessica Clarke CommitDate: 2021-08-24 14:04:25 +0000 Revert "Mark LLDB/CLANG_BOOTSTRAP/LLD_BOOTSTRAP as broken on non-FreeBSD for now" The fixes for this have now been committed so we can re-enable these. This reverts commit d9f25575a29ff7c83f226349a10a37b9aaf75ad5. MFC after: 1 week --- share/mk/src.opts.mk | 7 ------- 1 file changed, 7 deletions(-) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index e4427cb637a1..bd360dd1ad29 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -360,13 +360,6 @@ __DEFAULT_YES_OPTIONS+=OPENMP __DEFAULT_NO_OPTIONS+=OPENMP .endif -.if ${.MAKE.OS} != "FreeBSD" -# Bootstrapping the toolchain and building LLDB currently results in build -# failures non-FreeBSD, so disable these options until the fixes that are -# currently under review have landed. -BROKEN_OPTIONS+=LLDB CLANG_BOOTSTRAP LLD_BOOTSTRAP -.endif - .include # From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:24:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8DD72658FA1; Tue, 24 Aug 2021 14:24: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 4GvBFh3Ktyz57lr; Tue, 24 Aug 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5A98C177E; Tue, 24 Aug 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OEOeWG000498; Tue, 24 Aug 2021 14:24:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OEOePe000497; Tue, 24 Aug 2021 14:24:40 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:24:40 GMT Message-Id: <202108241424.17OEOePe000497@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 80b1995bb5d6 - main - arm: export actlr as sysctl hw.cpu.quirks.actlr_value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80b1995bb5d6e4a962c9a53ddede2420c299d9e4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:24:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=80b1995bb5d6e4a962c9a53ddede2420c299d9e4 commit 80b1995bb5d6e4a962c9a53ddede2420c299d9e4 Author: Mateusz Guzik AuthorDate: 2021-08-24 14:20:13 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-24 14:21:39 +0000 arm: export actlr as sysctl hw.cpu.quirks.actlr_value Reviewed by: cognet Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/arm/arm/cpuinfo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/arm/arm/cpuinfo.c b/sys/arm/arm/cpuinfo.c index a14fc578cd05..7a60fa335bc6 100644 --- a/sys/arm/arm/cpuinfo.c +++ b/sys/arm/arm/cpuinfo.c @@ -77,6 +77,19 @@ SYSCTL_INT(_hw_cpu_quirks, OID_AUTO, actlr_set, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &cpu_quirks_actlr_set, 0, "Bits to be set in ACTLR"); +static int +sysctl_hw_cpu_quirks_actrl_value(SYSCTL_HANDLER_ARGS) +{ + uint32_t reg; + + reg = cp15_actlr_get(); + return (SYSCTL_OUT(req, ®, sizeof(reg))); +} +SYSCTL_PROC(_hw_cpu_quirks, OID_AUTO, actlr_value, + CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_hw_cpu_quirks_actrl_value, "IU", + "Value of ACTLR"); + /* Read and parse CPU id scheme */ void cpuinfo_init(void) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:58:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 319FD65970D; Tue, 24 Aug 2021 14:58: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 4GvC0d0d6Mz3KhG; Tue, 24 Aug 2021 14:58: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 F20F72164; Tue, 24 Aug 2021 14:58: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 17OEwOEw040400; Tue, 24 Aug 2021 14:58:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OEwObq040399; Tue, 24 Aug 2021 14:58:24 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:58:24 GMT Message-Id: <202108241458.17OEwObq040399@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: 304d3f32ba3b - stable/13 - ipfw: fix possible data race between jump cache reading and updating. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 304d3f32ba3b3c97406eaa2dbbb39fcda0fd2fad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:58:25 -0000 The branch stable/13 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=304d3f32ba3b3c97406eaa2dbbb39fcda0fd2fad commit 304d3f32ba3b3c97406eaa2dbbb39fcda0fd2fad Author: Andrey V. Elsukov AuthorDate: 2021-08-17 08:08:28 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-08-24 14:56:56 +0000 ipfw: fix possible data race between jump cache reading and updating. Jump cache is used to reduce the cost of rule lookup for O_SKIPTO and O_CALLRETURN actions. It uses rules chain id to check correctness of cached value. But due to the possible race, there is the chance that one thread can read invalid value. In some cases this can lead to out of bounds access and panic. Use thread fence operations to constrain the reordering of accesses. Also rename jump_fast and jump_linear functions to jump_cached and jump_lookup_pos respectively. Submitted by: Arseny Smalyuk Obtained from: Yandex LLC Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D31484 (cherry picked from commit 322e5efda8578bb9c0a0ab0ef785cd1e1c222c85) --- sys/netpfil/ipfw/ip_fw2.c | 107 ++++++++++++++++++++++++--------------- sys/netpfil/ipfw/ip_fw_private.h | 12 ++++- 2 files changed, 75 insertions(+), 44 deletions(-) diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index f03180cd3bca..bcf775009d25 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -144,14 +144,14 @@ VNET_DEFINE(unsigned int, fw_tables_sets) = 0; /* Don't use set-aware tables */ /* Use 128 tables by default */ static unsigned int default_fw_tables = IPFW_TABLES_DEFAULT; +static int jump_lookup_pos(struct ip_fw_chain *chain, struct ip_fw *f, int num, + int tablearg, int jump_backwards); #ifndef LINEAR_SKIPTO -static int jump_fast(struct ip_fw_chain *chain, struct ip_fw *f, int num, +static int jump_cached(struct ip_fw_chain *chain, struct ip_fw *f, int num, int tablearg, int jump_backwards); -#define JUMP(ch, f, num, targ, back) jump_fast(ch, f, num, targ, back) +#define JUMP(ch, f, num, targ, back) jump_cached(ch, f, num, targ, back) #else -static int jump_linear(struct ip_fw_chain *chain, struct ip_fw *f, int num, - int tablearg, int jump_backwards); -#define JUMP(ch, f, num, targ, back) jump_linear(ch, f, num, targ, back) +#define JUMP(ch, f, num, targ, back) jump_lookup_pos(ch, f, num, targ, back) #endif /* @@ -1227,60 +1227,83 @@ set_match(struct ip_fw_args *args, int slot, args->flags |= IPFW_ARGS_REF; } -#ifndef LINEAR_SKIPTO -/* - * Helper function to enable cached rule lookups using - * cached_id and cached_pos fields in ipfw rule. - */ static int -jump_fast(struct ip_fw_chain *chain, struct ip_fw *f, int num, +jump_lookup_pos(struct ip_fw_chain *chain, struct ip_fw *f, int num, int tablearg, int jump_backwards) { - int f_pos; + int f_pos, i; - /* If possible use cached f_pos (in f->cached_pos), - * whose version is written in f->cached_id - * (horrible hacks to avoid changing the ABI). - */ - if (num != IP_FW_TARG && f->cached_id == chain->id) - f_pos = f->cached_pos; - else { - int i = IP_FW_ARG_TABLEARG(chain, num, skipto); - /* make sure we do not jump backward */ - if (jump_backwards == 0 && i <= f->rulenum) - i = f->rulenum + 1; - if (chain->idxmap != NULL) - f_pos = chain->idxmap[i]; - else - f_pos = ipfw_find_rule(chain, i, 0); - /* update the cache */ - if (num != IP_FW_TARG) { - f->cached_id = chain->id; - f->cached_pos = f_pos; - } - } + i = IP_FW_ARG_TABLEARG(chain, num, skipto); + /* make sure we do not jump backward */ + if (jump_backwards == 0 && i <= f->rulenum) + i = f->rulenum + 1; + +#ifndef LINEAR_SKIPTO + if (chain->idxmap != NULL) + f_pos = chain->idxmap[i]; + else + f_pos = ipfw_find_rule(chain, i, 0); +#else + f_pos = chain->idxmap[i]; +#endif /* LINEAR_SKIPTO */ return (f_pos); } -#else + + +#ifndef LINEAR_SKIPTO /* - * Helper function to enable real fast rule lookups. + * Helper function to enable cached rule lookups using + * cache.id and cache.pos fields in ipfw rule. */ static int -jump_linear(struct ip_fw_chain *chain, struct ip_fw *f, int num, +jump_cached(struct ip_fw_chain *chain, struct ip_fw *f, int num, int tablearg, int jump_backwards) { int f_pos; - num = IP_FW_ARG_TABLEARG(chain, num, skipto); - /* make sure we do not jump backward */ - if (jump_backwards == 0 && num <= f->rulenum) - num = f->rulenum + 1; - f_pos = chain->idxmap[num]; + /* Can't use cache with IP_FW_TARG */ + if (num == IP_FW_TARG) + return jump_lookup_pos(chain, f, num, tablearg, jump_backwards); + + /* + * If possible use cached f_pos (in f->cache.pos), + * whose version is written in f->cache.id (horrible hacks + * to avoid changing the ABI). + * + * Multiple threads can execute the same rule simultaneously, + * we need to ensure that cache.pos is updated before cache.id. + */ +#ifdef __LP64__ + struct ip_fw_jump_cache cache; + + cache.raw_value = f->cache.raw_value; + if (cache.id == chain->id) + return (cache.pos); + + f_pos = jump_lookup_pos(chain, f, num, tablearg, jump_backwards); + + cache.pos = f_pos; + cache.id = chain->id; + f->cache.raw_value = cache.raw_value; +#else + if (f->cache.id == chain->id) { + /* Load pos after id */ + atomic_thread_fence_acq(); + return (f->cache.pos); + } + + f_pos = jump_lookup_pos(chain, f, num, tablearg, jump_backwards); + + f->cache.pos = f_pos; + /* Store id after pos */ + atomic_thread_fence_rel(); + f->cache.id = chain->id; +#endif /* !__LP64__ */ return (f_pos); } -#endif +#endif /* !LINEAR_SKIPTO */ #define TARG(k, f) IP_FW_ARG_TABLEARG(chain, k, f) /* diff --git a/sys/netpfil/ipfw/ip_fw_private.h b/sys/netpfil/ipfw/ip_fw_private.h index 56624209e4cb..1440b1a40eee 100644 --- a/sys/netpfil/ipfw/ip_fw_private.h +++ b/sys/netpfil/ipfw/ip_fw_private.h @@ -265,6 +265,15 @@ struct tables_config; * ACTION_PTR(r) is the start of the first action (things to do * once a rule matched). */ +struct ip_fw_jump_cache { + union { + struct { + uint32_t id; + uint32_t pos; + }; + uint64_t raw_value; + }; +}; struct ip_fw { uint16_t act_ofs; /* offset of action in 32-bit units */ @@ -273,10 +282,9 @@ struct ip_fw { uint8_t set; /* rule set (0..31) */ uint8_t flags; /* currently unused */ counter_u64_t cntr; /* Pointer to rule counters */ + struct ip_fw_jump_cache cache; /* used by jump_fast */ uint32_t timestamp; /* tv_sec of last match */ uint32_t id; /* rule id */ - uint32_t cached_id; /* used by jump_fast */ - uint32_t cached_pos; /* used by jump_fast */ uint32_t refcnt; /* number of references */ struct ip_fw *next; /* linked list of deleted rules */ From owner-dev-commits-src-all@freebsd.org Tue Aug 24 14:59:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF8FE65972F; Tue, 24 Aug 2021 14:59: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 4GvC215w3kz3L5h; Tue, 24 Aug 2021 14:59: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 B2E0926CC; Tue, 24 Aug 2021 14:59: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 17OExb0f040599; Tue, 24 Aug 2021 14:59:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OExbIe040598; Tue, 24 Aug 2021 14:59:37 GMT (envelope-from git) Date: Tue, 24 Aug 2021 14:59:37 GMT Message-Id: <202108241459.17OExbIe040598@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: 8d0ced747a02 - stable/12 - ipfw: fix possible data race between jump cache reading and updating. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8d0ced747a02c4f2337eccbe9ea2e1e38384f533 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 14:59:38 -0000 The branch stable/12 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=8d0ced747a02c4f2337eccbe9ea2e1e38384f533 commit 8d0ced747a02c4f2337eccbe9ea2e1e38384f533 Author: Andrey V. Elsukov AuthorDate: 2021-08-17 08:08:28 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-08-24 14:59:01 +0000 ipfw: fix possible data race between jump cache reading and updating. Jump cache is used to reduce the cost of rule lookup for O_SKIPTO and O_CALLRETURN actions. It uses rules chain id to check correctness of cached value. But due to the possible race, there is the chance that one thread can read invalid value. In some cases this can lead to out of bounds access and panic. Use thread fence operations to constrain the reordering of accesses. Also rename jump_fast and jump_linear functions to jump_cached and jump_lookup_pos respectively. Submitted by: Arseny Smalyuk Obtained from: Yandex LLC Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D31484 (cherry picked from commit 322e5efda8578bb9c0a0ab0ef785cd1e1c222c85) --- sys/netpfil/ipfw/ip_fw2.c | 107 ++++++++++++++++++++++++--------------- sys/netpfil/ipfw/ip_fw_private.h | 12 ++++- 2 files changed, 75 insertions(+), 44 deletions(-) diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index 9d60b446dc73..aa16f92adf64 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -143,14 +143,14 @@ VNET_DEFINE(unsigned int, fw_tables_sets) = 0; /* Don't use set-aware tables */ /* Use 128 tables by default */ static unsigned int default_fw_tables = IPFW_TABLES_DEFAULT; +static int jump_lookup_pos(struct ip_fw_chain *chain, struct ip_fw *f, int num, + int tablearg, int jump_backwards); #ifndef LINEAR_SKIPTO -static int jump_fast(struct ip_fw_chain *chain, struct ip_fw *f, int num, +static int jump_cached(struct ip_fw_chain *chain, struct ip_fw *f, int num, int tablearg, int jump_backwards); -#define JUMP(ch, f, num, targ, back) jump_fast(ch, f, num, targ, back) +#define JUMP(ch, f, num, targ, back) jump_cached(ch, f, num, targ, back) #else -static int jump_linear(struct ip_fw_chain *chain, struct ip_fw *f, int num, - int tablearg, int jump_backwards); -#define JUMP(ch, f, num, targ, back) jump_linear(ch, f, num, targ, back) +#define JUMP(ch, f, num, targ, back) jump_lookup_pos(ch, f, num, targ, back) #endif /* @@ -1228,60 +1228,83 @@ set_match(struct ip_fw_args *args, int slot, args->flags |= IPFW_ARGS_REF; } -#ifndef LINEAR_SKIPTO -/* - * Helper function to enable cached rule lookups using - * cached_id and cached_pos fields in ipfw rule. - */ static int -jump_fast(struct ip_fw_chain *chain, struct ip_fw *f, int num, +jump_lookup_pos(struct ip_fw_chain *chain, struct ip_fw *f, int num, int tablearg, int jump_backwards) { - int f_pos; + int f_pos, i; - /* If possible use cached f_pos (in f->cached_pos), - * whose version is written in f->cached_id - * (horrible hacks to avoid changing the ABI). - */ - if (num != IP_FW_TARG && f->cached_id == chain->id) - f_pos = f->cached_pos; - else { - int i = IP_FW_ARG_TABLEARG(chain, num, skipto); - /* make sure we do not jump backward */ - if (jump_backwards == 0 && i <= f->rulenum) - i = f->rulenum + 1; - if (chain->idxmap != NULL) - f_pos = chain->idxmap[i]; - else - f_pos = ipfw_find_rule(chain, i, 0); - /* update the cache */ - if (num != IP_FW_TARG) { - f->cached_id = chain->id; - f->cached_pos = f_pos; - } - } + i = IP_FW_ARG_TABLEARG(chain, num, skipto); + /* make sure we do not jump backward */ + if (jump_backwards == 0 && i <= f->rulenum) + i = f->rulenum + 1; + +#ifndef LINEAR_SKIPTO + if (chain->idxmap != NULL) + f_pos = chain->idxmap[i]; + else + f_pos = ipfw_find_rule(chain, i, 0); +#else + f_pos = chain->idxmap[i]; +#endif /* LINEAR_SKIPTO */ return (f_pos); } -#else + + +#ifndef LINEAR_SKIPTO /* - * Helper function to enable real fast rule lookups. + * Helper function to enable cached rule lookups using + * cache.id and cache.pos fields in ipfw rule. */ static int -jump_linear(struct ip_fw_chain *chain, struct ip_fw *f, int num, +jump_cached(struct ip_fw_chain *chain, struct ip_fw *f, int num, int tablearg, int jump_backwards) { int f_pos; - num = IP_FW_ARG_TABLEARG(chain, num, skipto); - /* make sure we do not jump backward */ - if (jump_backwards == 0 && num <= f->rulenum) - num = f->rulenum + 1; - f_pos = chain->idxmap[num]; + /* Can't use cache with IP_FW_TARG */ + if (num == IP_FW_TARG) + return jump_lookup_pos(chain, f, num, tablearg, jump_backwards); + + /* + * If possible use cached f_pos (in f->cache.pos), + * whose version is written in f->cache.id (horrible hacks + * to avoid changing the ABI). + * + * Multiple threads can execute the same rule simultaneously, + * we need to ensure that cache.pos is updated before cache.id. + */ +#ifdef __LP64__ + struct ip_fw_jump_cache cache; + + cache.raw_value = f->cache.raw_value; + if (cache.id == chain->id) + return (cache.pos); + + f_pos = jump_lookup_pos(chain, f, num, tablearg, jump_backwards); + + cache.pos = f_pos; + cache.id = chain->id; + f->cache.raw_value = cache.raw_value; +#else + if (f->cache.id == chain->id) { + /* Load pos after id */ + atomic_thread_fence_acq(); + return (f->cache.pos); + } + + f_pos = jump_lookup_pos(chain, f, num, tablearg, jump_backwards); + + f->cache.pos = f_pos; + /* Store id after pos */ + atomic_thread_fence_rel(); + f->cache.id = chain->id; +#endif /* !__LP64__ */ return (f_pos); } -#endif +#endif /* !LINEAR_SKIPTO */ #define TARG(k, f) IP_FW_ARG_TABLEARG(chain, k, f) /* diff --git a/sys/netpfil/ipfw/ip_fw_private.h b/sys/netpfil/ipfw/ip_fw_private.h index df0985e6326a..e786a9bf883e 100644 --- a/sys/netpfil/ipfw/ip_fw_private.h +++ b/sys/netpfil/ipfw/ip_fw_private.h @@ -281,6 +281,15 @@ struct tables_config; * ACTION_PTR(r) is the start of the first action (things to do * once a rule matched). */ +struct ip_fw_jump_cache { + union { + struct { + uint32_t id; + uint32_t pos; + }; + uint64_t raw_value; + }; +}; struct ip_fw { uint16_t act_ofs; /* offset of action in 32-bit units */ @@ -289,10 +298,9 @@ struct ip_fw { uint8_t set; /* rule set (0..31) */ uint8_t flags; /* currently unused */ counter_u64_t cntr; /* Pointer to rule counters */ + struct ip_fw_jump_cache cache; /* used by jump_fast */ uint32_t timestamp; /* tv_sec of last match */ uint32_t id; /* rule id */ - uint32_t cached_id; /* used by jump_fast */ - uint32_t cached_pos; /* used by jump_fast */ uint32_t refcnt; /* number of references */ struct ip_fw *next; /* linked list of deleted rules */ From owner-dev-commits-src-all@freebsd.org Tue Aug 24 15:49:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8966165A6B2; Tue, 24 Aug 2021 15:49:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvD7c3GXqz3q9n; Tue, 24 Aug 2021 15:49:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5875531E1; Tue, 24 Aug 2021 15:49:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OFnWcB007481; Tue, 24 Aug 2021 15:49:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OFnWXQ007480; Tue, 24 Aug 2021 15:49:32 GMT (envelope-from git) Date: Tue, 24 Aug 2021 15:49:32 GMT Message-Id: <202108241549.17OFnWXQ007480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: c12118f6cec0 - main - tmpfs: Fix styles MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c12118f6cec0ca5f720be6c06d6c59d551461e5a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 15:49:32 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=c12118f6cec0ca5f720be6c06d6c59d551461e5a commit c12118f6cec0ca5f720be6c06d6c59d551461e5a Author: Ka Ho Ng AuthorDate: 2021-08-24 13:09:21 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 14:45:08 +0000 tmpfs: Fix styles A lot of return statements were in the wrong style before this commit. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/fs/tmpfs/tmpfs_subr.c | 6 +++--- sys/fs/tmpfs/tmpfs_vfsops.c | 4 ++-- sys/fs/tmpfs/tmpfs_vnops.c | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index b7dae82a71b4..387bc741e3cf 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -714,7 +714,7 @@ tmpfs_alloc_dirent(struct tmpfs_mount *tmp, struct tmpfs_node *node, *de = nde; - return 0; + return (0); } /* @@ -1861,11 +1861,11 @@ tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucred *cred, struct thread *p) /* Disallow this operation if the file system is mounted read-only. */ if (vp->v_mount->mnt_flag & MNT_RDONLY) - return EROFS; + return (EROFS); /* Immutable or append-only files cannot be modified, either. */ if (node->tn_flags & (IMMUTABLE | APPEND)) - return EPERM; + return (EPERM); /* * To modify the permissions on a file, must possess VADMIN diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 7dffb9027946..b8ecedbb0348 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -479,7 +479,7 @@ tmpfs_mount(struct mount *mp) vfs_getnewfsid(mp); vfs_mountedfrom(mp, "tmpfs"); - return 0; + return (0); } /* ARGSUSED2 */ @@ -644,7 +644,7 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp) sbp->f_ffree = sbp->f_files - used; /* sbp->f_owner = tmp->tn_uid; */ - return 0; + return (0); } static int diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 5d0d80639046..325b8d2789bb 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -277,9 +277,9 @@ tmpfs_mknod(struct vop_mknod_args *v) if (vap->va_type != VBLK && vap->va_type != VCHR && vap->va_type != VFIFO) - return EINVAL; + return (EINVAL); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } struct fileops tmpfs_fnops; @@ -517,7 +517,7 @@ tmpfs_getattr(struct vop_getattr_args *v) vap->va_bytes = node->tn_size; vap->va_filerev = 0; - return 0; + return (0); } int @@ -575,7 +575,7 @@ tmpfs_setattr(struct vop_setattr_args *v) MPASS(VOP_ISLOCKED(vp)); - return error; + return (error); } static int @@ -705,7 +705,7 @@ tmpfs_fsync(struct vop_fsync_args *v) tmpfs_check_mtime(vp); tmpfs_update(vp); - return 0; + return (0); } static int @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return error; + return (0); } /* @@ -1264,7 +1264,7 @@ tmpfs_mkdir(struct vop_mkdir_args *v) MPASS(vap->va_type == VDIR); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } static int @@ -1355,7 +1355,7 @@ tmpfs_rmdir(struct vop_rmdir_args *v) error = 0; out: - return error; + return (error); } static int @@ -1373,7 +1373,7 @@ tmpfs_symlink(struct vop_symlink_args *v) vap->va_type = VLNK; #endif - return tmpfs_alloc_file(dvp, vpp, vap, cnp, target); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, target)); } static int @@ -1396,7 +1396,7 @@ tmpfs_readdir(struct vop_readdir_args *va) /* This operation only makes sense on directory nodes. */ if (vp->v_type != VDIR) - return ENOTDIR; + return (ENOTDIR); maxcookies = 0; node = VP_TO_TMPFS_DIR(vp); @@ -1433,7 +1433,7 @@ tmpfs_readdir(struct vop_readdir_args *va) *eofflag = (error == 0 && uio->uio_offset == TMPFS_DIRCOOKIE_EOF); - return error; + return (error); } static int @@ -1580,7 +1580,7 @@ tmpfs_print(struct vop_print_args *v) printf("\n"); - return 0; + return (0); } int @@ -1634,7 +1634,7 @@ tmpfs_pathconf(struct vop_pathconf_args *v) error = vop_stdpathconf(v); } - return error; + return (error); } static int From owner-dev-commits-src-all@freebsd.org Tue Aug 24 15:49:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D957065A536; Tue, 24 Aug 2021 15:49: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 4GvD7d5VGkz3qD4; Tue, 24 Aug 2021 15:49: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 7BA8431E2; Tue, 24 Aug 2021 15:49: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 17OFnXik007505; Tue, 24 Aug 2021 15:49:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OFnXA0007504; Tue, 24 Aug 2021 15:49:33 GMT (envelope-from git) Date: Tue, 24 Aug 2021 15:49:33 GMT Message-Id: <202108241549.17OFnXA0007504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 5c1428d2c4a6 - main - uipc_shm: Handle offset on shm_size as if it is beyond shm_size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5c1428d2c4a63ae373181579b3af35d7e12f2e7c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 15:49:34 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=5c1428d2c4a63ae373181579b3af35d7e12f2e7c commit 5c1428d2c4a63ae373181579b3af35d7e12f2e7c Author: Ka Ho Ng AuthorDate: 2021-08-24 14:39:43 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 15:49:18 +0000 uipc_shm: Handle offset on shm_size as if it is beyond shm_size This avoids any unnecessary works in such case. Sponsored by: The FreeBSD Foundation Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D31655 --- sys/kern/uipc_shm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 60815ef24c26..c632c7f150df 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1915,8 +1915,8 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) pi = OFF_TO_IDX(off + PAGE_MASK); error = 0; - /* Handle the case when offset is beyond shm size */ - if ((off_t)len < 0) { + /* Handle the case when offset is on or beyond shm size. */ + if ((off_t)len <= 0) { *offset = shmfd->shm_size; *length = 0; return (0); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 16:37:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 571F065ACDA; Tue, 24 Aug 2021 16:37: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 4GvFBh243cz4YB1; Tue, 24 Aug 2021 16:37: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 2FFA14088; Tue, 24 Aug 2021 16:37: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 17OGbGFW074300; Tue, 24 Aug 2021 16:37:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OGbGVi074299; Tue, 24 Aug 2021 16:37:16 GMT (envelope-from git) Date: Tue, 24 Aug 2021 16:37:16 GMT Message-Id: <202108241637.17OGbGVi074299@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: a48416f844e3 - main - tmpfs: Fix error being cleared after commit c12118f6cec0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a48416f844e3007b4e9f6df125e25cf3a1daad62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 16:37:16 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=a48416f844e3007b4e9f6df125e25cf3a1daad62 commit a48416f844e3007b4e9f6df125e25cf3a1daad62 Author: Ka Ho Ng AuthorDate: 2021-08-24 16:35:29 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-24 16:35:29 +0000 tmpfs: Fix error being cleared after commit c12118f6cec0 In tmpfs_link() error was erroneously cleared in commit c12118f6cec0. Sponsored by: The FreeBSD Foundation MFC after: 3 days MFC with: c12118f6cec0 --- sys/fs/tmpfs/tmpfs_vnops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 325b8d2789bb..326a5132990d 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return (0); + return (error); } /* From owner-dev-commits-src-all@freebsd.org Tue Aug 24 16:45:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4817965B3EC; Tue, 24 Aug 2021 16:45:02 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvFMf109Cz4ZZ8; Tue, 24 Aug 2021 16:45:02 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lf1-x12a.google.com with SMTP id o10so46829461lfr.11; Tue, 24 Aug 2021 09:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ja/3H8dl+/XQh34gBZZfcOranCJ+xED03YFPnFzo5Gs=; b=HMJgfJgAcx9GHRDXJPexI06ENHgHthalpvxuRkXcilg7Ca4PRfVXrr+dSlz54sTBYB DFT78nKLt47phYL2wn2wWvJYgCSO9ToGjfa+AcClwIYcYuyXVdPDyne2YGNe2iJS02Sa CIZHhbuAbE1B2w0GpVp0v0Mg9Bj4LaK6+qyMjSgE+s7N4kkQlNAY8hyhy5D3U0Zf4sjS 3s6+z/4siAYblE8rH4bxWX+R9HJgVhUsG+9Od/rDpW+jyoTNhYWAecEEq/YcGDwXOLjF GGw0IT+2esQc3SGiOd/RPKtYCzfOiQSkL2hoBiZ7MSYtfwYfwnPkqVFwY1BYEgaOiIqE eY2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ja/3H8dl+/XQh34gBZZfcOranCJ+xED03YFPnFzo5Gs=; b=Szd0VeZ/d43otKzKfpdd1BYLgM7lwsHEco67rR7RNyTRWEJhcGmQGOcWG9mEUxSk72 djeaUDR2an9iVHEEqta7oz1tbuq6ZH+yAqXs/SNzWQJ70V1kHiyJKEW2yFToLUs7O2IS gFRg3L79WVydhVo+vVSfcJsb+BmF+tNUxemvONxOe2nMlUdtcglbjQ7BmeyPvl7op6Ur GBcIIf/sm6ypI/6IHLeSXN41eFIPlmD1UaLMmFFA7PtkogLAN7E78z/sa5/K9IDqnkFO h0/QR7EzPdtYcP5O773FO2pHzNV9MIwbMS8xa36MJVfvNWizkGhTkk3WKa/voGS3kG0j Jn9Q== X-Gm-Message-State: AOAM531Ti9YfEdA72ZGZ8lB4QDrK4w2ON4GETC5AS4KWcAM766OVJVLq xs7TdjtxiyDEXUSGa56gj0vsZkoeJ9GatxL17zTUQDHL X-Google-Smtp-Source: ABdhPJwqBfU6h0yyuEOneACd6D2NJ88RASFxKan/hefsKImgUSvTtGemrznqitY0UqWSNjdZAA4mQZ8nZn4STXcjG4I= X-Received: by 2002:a05:6512:541:: with SMTP id h1mr28854325lfl.118.1629823494757; Tue, 24 Aug 2021 09:44:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:6f04:0:0:0:0:0 with HTTP; Tue, 24 Aug 2021 09:44:54 -0700 (PDT) In-Reply-To: <202108241637.17OGbGVi074299@gitrepo.freebsd.org> References: <202108241637.17OGbGVi074299@gitrepo.freebsd.org> From: Mateusz Guzik Date: Tue, 24 Aug 2021 18:44:54 +0200 Message-ID: Subject: Re: git: a48416f844e3 - main - tmpfs: Fix error being cleared after commit c12118f6cec0 To: Ka Ho Ng Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4GvFMf109Cz4ZZ8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 16:45:02 -0000 On 8/24/21, Ka Ho Ng wrote: > The branch main has been updated by khng: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=a48416f844e3007b4e9f6df125e25cf3a1daad62 > > commit a48416f844e3007b4e9f6df125e25cf3a1daad62 > Author: Ka Ho Ng > AuthorDate: 2021-08-24 16:35:29 +0000 > Commit: Ka Ho Ng > CommitDate: 2021-08-24 16:35:29 +0000 > > tmpfs: Fix error being cleared after commit c12118f6cec0 > > In tmpfs_link() error was erroneously cleared in commit c12118f6cec0. > > Sponsored by: The FreeBSD Foundation > MFC after: 3 days > MFC with: c12118f6cec0 > --- > sys/fs/tmpfs/tmpfs_vnops.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c > index 325b8d2789bb..326a5132990d 100644 > --- a/sys/fs/tmpfs/tmpfs_vnops.c > +++ b/sys/fs/tmpfs/tmpfs_vnops.c > @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) > error = 0; > > out: > - return (0); > + return (error); > } > You should use coccinelle for changs like this. > /* > -- Mateusz Guzik From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:27:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3357065D286; Tue, 24 Aug 2021 18:27: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 4GvHfL0YRwz3MwH; Tue, 24 Aug 2021 18:27: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 EF9C15AEB; Tue, 24 Aug 2021 18:27: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 17OIRr0t022912; Tue, 24 Aug 2021 18:27:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIRrOP022911; Tue, 24 Aug 2021 18:27:53 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:27:53 GMT Message-Id: <202108241827.17OIRrOP022911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Tetlow Subject: git: 91a8bed5a49e - main - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91a8bed5a49eb2d1e4e096a4c68c108cebec8818 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:27:54 -0000 The branch main has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=91a8bed5a49eb2d1e4e096a4c68c108cebec8818 commit 91a8bed5a49eb2d1e4e096a4c68c108cebec8818 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:40:49 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:26:45 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index 45a93c4512fe..0695dae0dca2 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -145,7 +145,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -219,6 +233,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:27:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 883BF65D030; Tue, 24 Aug 2021 18:27: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 4GvHfN38l8z3N9F; Tue, 24 Aug 2021 18:27: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 36B7059BE; Tue, 24 Aug 2021 18:27: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 17OIRu0P022960; Tue, 24 Aug 2021 18:27:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIRuUx022959; Tue, 24 Aug 2021 18:27:56 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:27:56 GMT Message-Id: <202108241827.17OIRuUx022959@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Tetlow Subject: git: aef815e7873b - main - Fix multiple OpenSSL vulnerabilities. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aef815e7873b006bd040ac1690425709635e32e7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:27:56 -0000 The branch main has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=aef815e7873b006bd040ac1690425709635e32e7 commit aef815e7873b006bd040ac1690425709635e32e7 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:03:46 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:26:45 +0000 Fix multiple OpenSSL vulnerabilities. Approved by: so Security: SA-21:16.openssl Security: CVE-2021-3711 Security: CVE-2021-3712 --- crypto/openssl/crypto/asn1/asn1_lib.c | 12 ++++- crypto/openssl/crypto/asn1/t_spki.c | 2 +- crypto/openssl/crypto/ec/ec_asn1.c | 5 +- crypto/openssl/crypto/sm2/sm2_crypt.c | 27 +++++------ crypto/openssl/crypto/sm2/sm2_pmeth.c | 2 +- crypto/openssl/crypto/x509v3/v3_akey.c | 38 +++++++++++++-- crypto/openssl/crypto/x509v3/v3_alt.c | 10 ++-- crypto/openssl/crypto/x509v3/v3_cpols.c | 9 ++-- crypto/openssl/crypto/x509v3/v3_ncons.c | 77 +++++++++++++++++++++---------- crypto/openssl/crypto/x509v3/v3_pci.c | 3 +- crypto/openssl/crypto/x509v3/v3_utl.c | 53 ++++++++++++++++----- crypto/openssl/include/crypto/sm2.h | 3 +- crypto/openssl/include/crypto/x509.h | 5 ++ crypto/openssl/include/openssl/opensslv.h | 2 +- 14 files changed, 177 insertions(+), 71 deletions(-) diff --git a/crypto/openssl/crypto/asn1/asn1_lib.c b/crypto/openssl/crypto/asn1/asn1_lib.c index 366afc5f6c6b..8e62f3307443 100644 --- a/crypto/openssl/crypto/asn1/asn1_lib.c +++ b/crypto/openssl/crypto/asn1/asn1_lib.c @@ -292,7 +292,12 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) } if ((size_t)str->length <= len || str->data == NULL) { c = str->data; +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* No NUL terminator in fuzzing builds */ + str->data = OPENSSL_realloc(c, len); +#else str->data = OPENSSL_realloc(c, len + 1); +#endif if (str->data == NULL) { ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); str->data = c; @@ -302,8 +307,13 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) str->length = len; if (data != NULL) { memcpy(str->data, data, len); - /* an allowance for strings :-) */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* + * Add a NUL terminator. This should not be necessary - but we add it as + * a safety precaution + */ str->data[len] = '\0'; +#endif } return 1; } diff --git a/crypto/openssl/crypto/asn1/t_spki.c b/crypto/openssl/crypto/asn1/t_spki.c index 51b56d0aa9f7..64ee77eeecba 100644 --- a/crypto/openssl/crypto/asn1/t_spki.c +++ b/crypto/openssl/crypto/asn1/t_spki.c @@ -38,7 +38,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) } chal = spki->spkac->challenge; if (chal->length) - BIO_printf(out, " Challenge String: %s\n", chal->data); + BIO_printf(out, " Challenge String: %.*s\n", chal->length, chal->data); i = OBJ_obj2nid(spki->sig_algor.algorithm); BIO_printf(out, " Signature Algorithm: %s", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); diff --git a/crypto/openssl/crypto/ec/ec_asn1.c b/crypto/openssl/crypto/ec/ec_asn1.c index 7b7c75ce8443..e497a259095d 100644 --- a/crypto/openssl/crypto/ec/ec_asn1.c +++ b/crypto/openssl/crypto/ec/ec_asn1.c @@ -761,7 +761,10 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) ret->seed_len = params->curve->seed->length; } - if (!params->order || !params->base || !params->base->data) { + if (params->order == NULL + || params->base == NULL + || params->base->data == NULL + || params->base->length == 0) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } diff --git a/crypto/openssl/crypto/sm2/sm2_crypt.c b/crypto/openssl/crypto/sm2/sm2_crypt.c index ef505f64412b..00055a4e510e 100644 --- a/crypto/openssl/crypto/sm2/sm2_crypt.c +++ b/crypto/openssl/crypto/sm2/sm2_crypt.c @@ -61,29 +61,20 @@ static size_t ec_field_size(const EC_GROUP *group) return field_size; } -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size) +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size) { - const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); - const int md_size = EVP_MD_size(digest); - size_t overhead; + struct SM2_Ciphertext_st *sm2_ctext = NULL; - if (md_size < 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_DIGEST); - return 0; - } - if (field_size == 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_FIELD); - return 0; - } + sm2_ctext = d2i_SM2_Ciphertext(NULL, &ct, ct_size); - overhead = 10 + 2 * field_size + (size_t)md_size; - if (msg_len <= overhead) { + if (sm2_ctext == NULL) { SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_ENCODING); return 0; } - *pt_size = msg_len - overhead; + *pt_size = sm2_ctext->C2->length; + SM2_Ciphertext_free(sm2_ctext); + return 1; } @@ -303,6 +294,10 @@ int sm2_decrypt(const EC_KEY *key, C2 = sm2_ctext->C2->data; C3 = sm2_ctext->C3->data; msg_len = sm2_ctext->C2->length; + if (*ptext_len < (size_t)msg_len) { + SM2err(SM2_F_SM2_DECRYPT, SM2_R_BUFFER_TOO_SMALL); + goto done; + } ctx = BN_CTX_new(); if (ctx == NULL) { diff --git a/crypto/openssl/crypto/sm2/sm2_pmeth.c b/crypto/openssl/crypto/sm2/sm2_pmeth.c index b42a14c32f26..27025fbf3a2c 100644 --- a/crypto/openssl/crypto/sm2/sm2_pmeth.c +++ b/crypto/openssl/crypto/sm2/sm2_pmeth.c @@ -151,7 +151,7 @@ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { - if (!sm2_plaintext_size(ec, md, inlen, outlen)) + if (!sm2_plaintext_size(in, inlen, outlen)) return -1; else return 1; diff --git a/crypto/openssl/crypto/x509v3/v3_akey.c b/crypto/openssl/crypto/x509v3/v3_akey.c index d9f770433cfb..f917142223b7 100644 --- a/crypto/openssl/crypto/x509v3/v3_akey.c +++ b/crypto/openssl/crypto/x509v3/v3_akey.c @@ -39,20 +39,48 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, STACK_OF(CONF_VALUE) *extlist) { - char *tmp; + char *tmp = NULL; + STACK_OF(CONF_VALUE) *origextlist = extlist, *tmpextlist; + if (akeyid->keyid) { tmp = OPENSSL_buf2hexstr(akeyid->keyid->data, akeyid->keyid->length); - X509V3_add_value("keyid", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (!X509V3_add_value("keyid", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } - if (akeyid->issuer) - extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (akeyid->issuer) { + tmpextlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (tmpextlist == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } + extlist = tmpextlist; + } if (akeyid->serial) { tmp = OPENSSL_buf2hexstr(akeyid->serial->data, akeyid->serial->length); - X509V3_add_value("serial", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!X509V3_add_value("serial", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } return extlist; + err: + if (origextlist == NULL) + sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free); + return NULL; } /*- diff --git a/crypto/openssl/crypto/x509v3/v3_alt.c b/crypto/openssl/crypto/x509v3/v3_alt.c index 4dce0041012e..6e5f9f8b0eac 100644 --- a/crypto/openssl/crypto/x509v3/v3_alt.c +++ b/crypto/openssl/crypto/x509v3/v3_alt.c @@ -9,6 +9,7 @@ #include #include "internal/cryptlib.h" +#include "crypto/x509.h" #include #include #include "ext_dat.h" @@ -99,17 +100,20 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, break; case GEN_EMAIL: - if (!X509V3_add_value_uchar("email", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("email", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_DNS: - if (!X509V3_add_value_uchar("DNS", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("DNS", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_URI: - if (!X509V3_add_value_uchar("URI", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("URI", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; diff --git a/crypto/openssl/crypto/x509v3/v3_cpols.c b/crypto/openssl/crypto/x509v3/v3_cpols.c index 1d12c899125c..861e8455dd08 100644 --- a/crypto/openssl/crypto/x509v3/v3_cpols.c +++ b/crypto/openssl/crypto/x509v3/v3_cpols.c @@ -422,7 +422,8 @@ static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, qualinfo = sk_POLICYQUALINFO_value(quals, i); switch (OBJ_obj2nid(qualinfo->pqualid)) { case NID_id_qt_cps: - BIO_printf(out, "%*sCPS: %s\n", indent, "", + BIO_printf(out, "%*sCPS: %.*s\n", indent, "", + qualinfo->d.cpsuri->length, qualinfo->d.cpsuri->data); break; @@ -447,7 +448,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) if (notice->noticeref) { NOTICEREF *ref; ref = notice->noticeref; - BIO_printf(out, "%*sOrganization: %s\n", indent, "", + BIO_printf(out, "%*sOrganization: %.*s\n", indent, "", + ref->organization->length, ref->organization->data); BIO_printf(out, "%*sNumber%s: ", indent, "", sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); @@ -470,7 +472,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) BIO_puts(out, "\n"); } if (notice->exptext) - BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", + BIO_printf(out, "%*sExplicit Text: %.*s\n", indent, "", + notice->exptext->length, notice->exptext->data); } diff --git a/crypto/openssl/crypto/x509v3/v3_ncons.c b/crypto/openssl/crypto/x509v3/v3_ncons.c index 2a7b4f0992a8..cb701c4d844b 100644 --- a/crypto/openssl/crypto/x509v3/v3_ncons.c +++ b/crypto/openssl/crypto/x509v3/v3_ncons.c @@ -63,8 +63,31 @@ ASN1_SEQUENCE(NAME_CONSTRAINTS) = { IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +#define IA5_OFFSET_LEN(ia5base, offset) \ + ((ia5base)->length - ((unsigned char *)(offset) - (ia5base)->data)) + +/* Like memchr but for ASN1_IA5STRING. Additionally you can specify the + * starting point to search from + */ +# define ia5memchr(str, start, c) memchr(start, c, IA5_OFFSET_LEN(str, start)) + +/* Like memrrchr but for ASN1_IA5STRING */ +static char *ia5memrchr(ASN1_IA5STRING *str, int c) +{ + int i; + + for (i = str->length; i > 0 && str->data[i - 1] != c; i--); + + if (i == 0) + return NULL; + + return (char *)&str->data[i - 1]; +} + /* - * We cannot use strncasecmp here because that applies locale specific rules. + * We cannot use strncasecmp here because that applies locale specific rules. It + * also doesn't work with ASN1_STRINGs that may have embedded NUL characters. * For example in Turkish 'I' is not the uppercase character for 'i'. We need to * do a simple ASCII case comparison ignoring the locale (that is why we use * numeric constants below). @@ -89,20 +112,12 @@ static int ia5ncasecmp(const char *s1, const char *s2, size_t n) /* c1 > c2 */ return 1; - } else if (*s1 == 0) { - /* If we get here we know that *s2 == 0 too */ - return 0; } } return 0; } -static int ia5casecmp(const char *s1, const char *s2) -{ - return ia5ncasecmp(s1, s2, SIZE_MAX); -} - static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { @@ -337,7 +352,7 @@ static int cn2dnsid(ASN1_STRING *cn, unsigned char **dnsid, size_t *idlen) --utf8_length; /* Reject *embedded* NULs */ - if ((size_t)utf8_length != strlen((char *)utf8_value)) { + if (memchr(utf8_value, 0, utf8_length) != NULL) { OPENSSL_free(utf8_value); return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; } @@ -536,9 +551,14 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; + /* Empty matches everything */ - if (!*baseptr) + if (base->length == 0) return X509_V_OK; + + if (dns->length < base->length) + return X509_V_ERR_PERMITTED_VIOLATION; + /* * Otherwise can add zero or more components on the left so compare RHS * and if dns is longer and expect '.' as preceding character. @@ -549,7 +569,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) return X509_V_ERR_PERMITTED_VIOLATION; } - if (ia5casecmp(baseptr, dnsptr)) + if (ia5ncasecmp(baseptr, dnsptr, base->length)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -560,16 +580,17 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *emlptr = (char *)eml->data; + const char *baseat = ia5memrchr(base, '@'); + const char *emlat = ia5memrchr(eml, '@'); + size_t basehostlen, emlhostlen; - const char *baseat = strchr(baseptr, '@'); - const char *emlat = strchr(emlptr, '@'); if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (!baseat && (*baseptr == '.')) { + if (!baseat && base->length > 0 && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; - if (ia5casecmp(baseptr, emlptr) == 0) + if (ia5ncasecmp(baseptr, emlptr, base->length) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; @@ -589,8 +610,10 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) baseptr = baseat + 1; } emlptr = emlat + 1; + basehostlen = IA5_OFFSET_LEN(base, baseptr); + emlhostlen = IA5_OFFSET_LEN(eml, emlptr); /* Just have hostname left to match: case insensitive */ - if (ia5casecmp(baseptr, emlptr)) + if (basehostlen != emlhostlen || ia5ncasecmp(baseptr, emlptr, emlhostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -601,10 +624,14 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *hostptr = (char *)uri->data; - const char *p = strchr(hostptr, ':'); + const char *p = ia5memchr(uri, (char *)uri->data, ':'); int hostlen; + /* Check for foo:// and skip past it */ - if (!p || (p[1] != '/') || (p[2] != '/')) + if (p == NULL + || IA5_OFFSET_LEN(uri, p) < 3 + || p[1] != '/' + || p[2] != '/') return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; @@ -612,13 +639,13 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) /* Look for a port indicator as end of hostname first */ - p = strchr(hostptr, ':'); + p = ia5memchr(uri, hostptr, ':'); /* Otherwise look for trailing slash */ - if (!p) - p = strchr(hostptr, '/'); + if (p == NULL) + p = ia5memchr(uri, hostptr, '/'); - if (!p) - hostlen = strlen(hostptr); + if (p == NULL) + hostlen = IA5_OFFSET_LEN(uri, hostptr); else hostlen = p - hostptr; @@ -626,7 +653,7 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (*baseptr == '.') { + if (base->length > 0 && *baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; if (ia5ncasecmp(p, baseptr, base->length) == 0) diff --git a/crypto/openssl/crypto/x509v3/v3_pci.c b/crypto/openssl/crypto/x509v3/v3_pci.c index 3d124fa6d95d..98b6ef25e280 100644 --- a/crypto/openssl/crypto/x509v3/v3_pci.c +++ b/crypto/openssl/crypto/x509v3/v3_pci.c @@ -77,7 +77,8 @@ static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); BIO_puts(out, "\n"); if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) - BIO_printf(out, "%*sPolicy Text: %s\n", indent, "", + BIO_printf(out, "%*sPolicy Text: %.*s\n", indent, "", + pci->proxyPolicy->policy->length, pci->proxyPolicy->policy->data); return 1; } diff --git a/crypto/openssl/crypto/x509v3/v3_utl.c b/crypto/openssl/crypto/x509v3/v3_utl.c index 7281a7b917a8..706dd22ffaba 100644 --- a/crypto/openssl/crypto/x509v3/v3_utl.c +++ b/crypto/openssl/crypto/x509v3/v3_utl.c @@ -12,6 +12,7 @@ #include "e_os.h" #include "internal/cryptlib.h" #include +#include #include "crypto/ctype.h" #include #include @@ -34,17 +35,23 @@ static int ipv6_hex(unsigned char *out, const char *in, int inlen); /* Add a CONF_VALUE name value pair to stack */ -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist) +static int x509v3_add_len_value(const char *name, const char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; int sk_allocated = (*extlist == NULL); - if (name && (tname = OPENSSL_strdup(name)) == NULL) - goto err; - if (value && (tvalue = OPENSSL_strdup(value)) == NULL) + if (name != NULL && (tname = OPENSSL_strdup(name)) == NULL) goto err; + if (value != NULL) { + /* We don't allow embeded NUL characters */ + if (memchr(value, 0, vallen) != NULL) + goto err; + tvalue = OPENSSL_strndup(value, vallen); + if (tvalue == NULL) + goto err; + } if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; if (sk_allocated && (*extlist = sk_CONF_VALUE_new_null()) == NULL) @@ -67,10 +74,26 @@ int X509V3_add_value(const char *name, const char *value, return 0; } +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist) { - return X509V3_add_value(name, (const char *)value, extlist); + return x509v3_add_len_value(name, (const char *)value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, (const char *)value, vallen, extlist); } /* Free function for STACK_OF(CONF_VALUE) */ @@ -502,18 +525,26 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email /* First some sanity checks */ if (email->type != V_ASN1_IA5STRING) return 1; - if (!email->data || !email->length) + if (email->data == NULL || email->length == 0) + return 1; + if (memchr(email->data, 0, email->length) != NULL) return 1; if (*sk == NULL) *sk = sk_OPENSSL_STRING_new(sk_strcmp); if (*sk == NULL) return 0; + + emtmp = OPENSSL_strndup((char *)email->data, email->length); + if (emtmp == NULL) + return 0; + /* Don't add duplicates */ - if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) + if (sk_OPENSSL_STRING_find(*sk, emtmp) != -1) { + OPENSSL_free(emtmp); return 1; - emtmp = OPENSSL_strdup((char *)email->data); - if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) { - OPENSSL_free(emtmp); /* free on push failure */ + } + if (!sk_OPENSSL_STRING_push(*sk, emtmp)) { + OPENSSL_free(emtmp); /* free on push failure */ X509_email_free(*sk); *sk = NULL; return 0; diff --git a/crypto/openssl/include/crypto/sm2.h b/crypto/openssl/include/crypto/sm2.h index 76ee80baff19..50851a83cea2 100644 --- a/crypto/openssl/include/crypto/sm2.h +++ b/crypto/openssl/include/crypto/sm2.h @@ -60,8 +60,7 @@ int sm2_verify(const unsigned char *dgst, int dgstlen, int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, size_t *ct_size); -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size); +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size); int sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, diff --git a/crypto/openssl/include/crypto/x509.h b/crypto/openssl/include/crypto/x509.h index b53c2b03c39e..7ffb8abfe71b 100644 --- a/crypto/openssl/include/crypto/x509.h +++ b/crypto/openssl/include/crypto/x509.h @@ -8,6 +8,8 @@ */ #include "internal/refcount.h" +#include +#include /* Internal X509 structures and functions: not for application use */ @@ -284,3 +286,6 @@ int a2i_ipadd(unsigned char *ipout, const char *ipasc); int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); void x509_init_sig_info(X509 *x); + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist); diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h index ec4a1123f131..328d0971c414 100644 --- a/crypto/openssl/include/openssl/opensslv.h +++ b/crypto/openssl/include/openssl/opensslv.h @@ -40,7 +40,7 @@ extern "C" { * major minor fix final patch/beta) */ # define OPENSSL_VERSION_NUMBER 0x101010bfL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 25 Mar 2021" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 24 Aug 2021" /*- * The macros below are to be used for shared library (.so, .dll, ...) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:27:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3FB2965D482; Tue, 24 Aug 2021 18:27: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 4GvHfM1Ngdz3Myk; Tue, 24 Aug 2021 18:27: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 178495AEC; Tue, 24 Aug 2021 18:27: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 17OIRtRA022936; Tue, 24 Aug 2021 18:27:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIRs3h022935; Tue, 24 Aug 2021 18:27:54 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:27:54 GMT Message-Id: <202108241827.17OIRs3h022935@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Tetlow Subject: git: 64ae2f785e06 - main - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 64ae2f785e0672286901c15045a24cbc533538d3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:27:55 -0000 The branch main has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=64ae2f785e0672286901c15045a24cbc533538d3 commit 64ae2f785e0672286901c15045a24cbc533538d3 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:59:01 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:26:45 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 9a546f3fecad..dfde6edce734 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -704,8 +704,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 239A765D599; Tue, 24 Aug 2021 18:28: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 4GvHfz0KMwz3N3J; Tue, 24 Aug 2021 18:28: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 E76DA5939; Tue, 24 Aug 2021 18:28: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 17OISQAk023250; Tue, 24 Aug 2021 18:28:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISQ21023249; Tue, 24 Aug 2021 18:28:26 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:26 GMT Message-Id: <202108241828.17OISQ21023249@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 0729ba2f49c9 - stable/13 - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0729ba2f49c956789701aecb70f4f555181fd3a7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:27 -0000 The branch stable/13 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=0729ba2f49c956789701aecb70f4f555181fd3a7 commit 0729ba2f49c956789701aecb70f4f555181fd3a7 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:40:49 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:50:50 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 (cherry picked from commit 515216929c40169cc72b62466ff9238682661613) --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index 45a93c4512fe..0695dae0dca2 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -145,7 +145,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -219,6 +233,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A7C2765D2D5; Tue, 24 Aug 2021 18:28: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 4GvHg03QlWz3N7d; Tue, 24 Aug 2021 18:28: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 1C2EE56BE; Tue, 24 Aug 2021 18:28: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 17OISRjc023274; Tue, 24 Aug 2021 18:28:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISROZ023273; Tue, 24 Aug 2021 18:28:27 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:27 GMT Message-Id: <202108241828.17OISROZ023273@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: a75324d674f5 - stable/13 - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a75324d674f5df10f1407080a49cfe933dbb06ec Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:28 -0000 The branch stable/13 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=a75324d674f5df10f1407080a49cfe933dbb06ec commit a75324d674f5df10f1407080a49cfe933dbb06ec Author: Gordon Tetlow AuthorDate: 2021-08-24 17:59:01 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:59:43 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 (cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5) --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 9a546f3fecad..dfde6edce734 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -704,8 +704,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 971D765D5A3; Tue, 24 Aug 2021 18:28: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 4GvHg12xRxz3N3Q; Tue, 24 Aug 2021 18:28:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37A10593A; Tue, 24 Aug 2021 18:28: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 17OISTwG023298; Tue, 24 Aug 2021 18:28:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISTcE023297; Tue, 24 Aug 2021 18:28:29 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:29 GMT Message-Id: <202108241828.17OISTcE023297@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 9d31ae318711 - stable/13 - Fix multiple OpenSSL vulnerabilities. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9d31ae318711825d3a6ffa544d197708905435cf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:29 -0000 The branch stable/13 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=9d31ae318711825d3a6ffa544d197708905435cf commit 9d31ae318711825d3a6ffa544d197708905435cf Author: Gordon Tetlow AuthorDate: 2021-08-24 18:03:46 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:05:48 +0000 Fix multiple OpenSSL vulnerabilities. Approved by: so Security: SA-21:16.openssl Security: CVE-2021-3711 Security: CVE-2021-3712 (cherry picked from commit be158ffe54dcc4a633652685afc5e37894e10ea0) --- crypto/openssl/crypto/asn1/asn1_lib.c | 12 ++++- crypto/openssl/crypto/asn1/t_spki.c | 2 +- crypto/openssl/crypto/ec/ec_asn1.c | 5 +- crypto/openssl/crypto/sm2/sm2_crypt.c | 27 +++++------ crypto/openssl/crypto/sm2/sm2_pmeth.c | 2 +- crypto/openssl/crypto/x509v3/v3_akey.c | 38 +++++++++++++-- crypto/openssl/crypto/x509v3/v3_alt.c | 10 ++-- crypto/openssl/crypto/x509v3/v3_cpols.c | 9 ++-- crypto/openssl/crypto/x509v3/v3_ncons.c | 77 +++++++++++++++++++++---------- crypto/openssl/crypto/x509v3/v3_pci.c | 3 +- crypto/openssl/crypto/x509v3/v3_utl.c | 53 ++++++++++++++++----- crypto/openssl/include/crypto/sm2.h | 3 +- crypto/openssl/include/crypto/x509.h | 5 ++ crypto/openssl/include/openssl/opensslv.h | 2 +- 14 files changed, 177 insertions(+), 71 deletions(-) diff --git a/crypto/openssl/crypto/asn1/asn1_lib.c b/crypto/openssl/crypto/asn1/asn1_lib.c index 366afc5f6c6b..8e62f3307443 100644 --- a/crypto/openssl/crypto/asn1/asn1_lib.c +++ b/crypto/openssl/crypto/asn1/asn1_lib.c @@ -292,7 +292,12 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) } if ((size_t)str->length <= len || str->data == NULL) { c = str->data; +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* No NUL terminator in fuzzing builds */ + str->data = OPENSSL_realloc(c, len); +#else str->data = OPENSSL_realloc(c, len + 1); +#endif if (str->data == NULL) { ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); str->data = c; @@ -302,8 +307,13 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) str->length = len; if (data != NULL) { memcpy(str->data, data, len); - /* an allowance for strings :-) */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* + * Add a NUL terminator. This should not be necessary - but we add it as + * a safety precaution + */ str->data[len] = '\0'; +#endif } return 1; } diff --git a/crypto/openssl/crypto/asn1/t_spki.c b/crypto/openssl/crypto/asn1/t_spki.c index 51b56d0aa9f7..64ee77eeecba 100644 --- a/crypto/openssl/crypto/asn1/t_spki.c +++ b/crypto/openssl/crypto/asn1/t_spki.c @@ -38,7 +38,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) } chal = spki->spkac->challenge; if (chal->length) - BIO_printf(out, " Challenge String: %s\n", chal->data); + BIO_printf(out, " Challenge String: %.*s\n", chal->length, chal->data); i = OBJ_obj2nid(spki->sig_algor.algorithm); BIO_printf(out, " Signature Algorithm: %s", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); diff --git a/crypto/openssl/crypto/ec/ec_asn1.c b/crypto/openssl/crypto/ec/ec_asn1.c index 7b7c75ce8443..e497a259095d 100644 --- a/crypto/openssl/crypto/ec/ec_asn1.c +++ b/crypto/openssl/crypto/ec/ec_asn1.c @@ -761,7 +761,10 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) ret->seed_len = params->curve->seed->length; } - if (!params->order || !params->base || !params->base->data) { + if (params->order == NULL + || params->base == NULL + || params->base->data == NULL + || params->base->length == 0) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } diff --git a/crypto/openssl/crypto/sm2/sm2_crypt.c b/crypto/openssl/crypto/sm2/sm2_crypt.c index ef505f64412b..00055a4e510e 100644 --- a/crypto/openssl/crypto/sm2/sm2_crypt.c +++ b/crypto/openssl/crypto/sm2/sm2_crypt.c @@ -61,29 +61,20 @@ static size_t ec_field_size(const EC_GROUP *group) return field_size; } -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size) +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size) { - const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); - const int md_size = EVP_MD_size(digest); - size_t overhead; + struct SM2_Ciphertext_st *sm2_ctext = NULL; - if (md_size < 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_DIGEST); - return 0; - } - if (field_size == 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_FIELD); - return 0; - } + sm2_ctext = d2i_SM2_Ciphertext(NULL, &ct, ct_size); - overhead = 10 + 2 * field_size + (size_t)md_size; - if (msg_len <= overhead) { + if (sm2_ctext == NULL) { SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_ENCODING); return 0; } - *pt_size = msg_len - overhead; + *pt_size = sm2_ctext->C2->length; + SM2_Ciphertext_free(sm2_ctext); + return 1; } @@ -303,6 +294,10 @@ int sm2_decrypt(const EC_KEY *key, C2 = sm2_ctext->C2->data; C3 = sm2_ctext->C3->data; msg_len = sm2_ctext->C2->length; + if (*ptext_len < (size_t)msg_len) { + SM2err(SM2_F_SM2_DECRYPT, SM2_R_BUFFER_TOO_SMALL); + goto done; + } ctx = BN_CTX_new(); if (ctx == NULL) { diff --git a/crypto/openssl/crypto/sm2/sm2_pmeth.c b/crypto/openssl/crypto/sm2/sm2_pmeth.c index b42a14c32f26..27025fbf3a2c 100644 --- a/crypto/openssl/crypto/sm2/sm2_pmeth.c +++ b/crypto/openssl/crypto/sm2/sm2_pmeth.c @@ -151,7 +151,7 @@ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { - if (!sm2_plaintext_size(ec, md, inlen, outlen)) + if (!sm2_plaintext_size(in, inlen, outlen)) return -1; else return 1; diff --git a/crypto/openssl/crypto/x509v3/v3_akey.c b/crypto/openssl/crypto/x509v3/v3_akey.c index d9f770433cfb..f917142223b7 100644 --- a/crypto/openssl/crypto/x509v3/v3_akey.c +++ b/crypto/openssl/crypto/x509v3/v3_akey.c @@ -39,20 +39,48 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, STACK_OF(CONF_VALUE) *extlist) { - char *tmp; + char *tmp = NULL; + STACK_OF(CONF_VALUE) *origextlist = extlist, *tmpextlist; + if (akeyid->keyid) { tmp = OPENSSL_buf2hexstr(akeyid->keyid->data, akeyid->keyid->length); - X509V3_add_value("keyid", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (!X509V3_add_value("keyid", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } - if (akeyid->issuer) - extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (akeyid->issuer) { + tmpextlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (tmpextlist == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } + extlist = tmpextlist; + } if (akeyid->serial) { tmp = OPENSSL_buf2hexstr(akeyid->serial->data, akeyid->serial->length); - X509V3_add_value("serial", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!X509V3_add_value("serial", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } return extlist; + err: + if (origextlist == NULL) + sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free); + return NULL; } /*- diff --git a/crypto/openssl/crypto/x509v3/v3_alt.c b/crypto/openssl/crypto/x509v3/v3_alt.c index 4dce0041012e..6e5f9f8b0eac 100644 --- a/crypto/openssl/crypto/x509v3/v3_alt.c +++ b/crypto/openssl/crypto/x509v3/v3_alt.c @@ -9,6 +9,7 @@ #include #include "internal/cryptlib.h" +#include "crypto/x509.h" #include #include #include "ext_dat.h" @@ -99,17 +100,20 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, break; case GEN_EMAIL: - if (!X509V3_add_value_uchar("email", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("email", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_DNS: - if (!X509V3_add_value_uchar("DNS", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("DNS", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_URI: - if (!X509V3_add_value_uchar("URI", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("URI", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; diff --git a/crypto/openssl/crypto/x509v3/v3_cpols.c b/crypto/openssl/crypto/x509v3/v3_cpols.c index 1d12c899125c..861e8455dd08 100644 --- a/crypto/openssl/crypto/x509v3/v3_cpols.c +++ b/crypto/openssl/crypto/x509v3/v3_cpols.c @@ -422,7 +422,8 @@ static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, qualinfo = sk_POLICYQUALINFO_value(quals, i); switch (OBJ_obj2nid(qualinfo->pqualid)) { case NID_id_qt_cps: - BIO_printf(out, "%*sCPS: %s\n", indent, "", + BIO_printf(out, "%*sCPS: %.*s\n", indent, "", + qualinfo->d.cpsuri->length, qualinfo->d.cpsuri->data); break; @@ -447,7 +448,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) if (notice->noticeref) { NOTICEREF *ref; ref = notice->noticeref; - BIO_printf(out, "%*sOrganization: %s\n", indent, "", + BIO_printf(out, "%*sOrganization: %.*s\n", indent, "", + ref->organization->length, ref->organization->data); BIO_printf(out, "%*sNumber%s: ", indent, "", sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); @@ -470,7 +472,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) BIO_puts(out, "\n"); } if (notice->exptext) - BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", + BIO_printf(out, "%*sExplicit Text: %.*s\n", indent, "", + notice->exptext->length, notice->exptext->data); } diff --git a/crypto/openssl/crypto/x509v3/v3_ncons.c b/crypto/openssl/crypto/x509v3/v3_ncons.c index 2a7b4f0992a8..cb701c4d844b 100644 --- a/crypto/openssl/crypto/x509v3/v3_ncons.c +++ b/crypto/openssl/crypto/x509v3/v3_ncons.c @@ -63,8 +63,31 @@ ASN1_SEQUENCE(NAME_CONSTRAINTS) = { IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +#define IA5_OFFSET_LEN(ia5base, offset) \ + ((ia5base)->length - ((unsigned char *)(offset) - (ia5base)->data)) + +/* Like memchr but for ASN1_IA5STRING. Additionally you can specify the + * starting point to search from + */ +# define ia5memchr(str, start, c) memchr(start, c, IA5_OFFSET_LEN(str, start)) + +/* Like memrrchr but for ASN1_IA5STRING */ +static char *ia5memrchr(ASN1_IA5STRING *str, int c) +{ + int i; + + for (i = str->length; i > 0 && str->data[i - 1] != c; i--); + + if (i == 0) + return NULL; + + return (char *)&str->data[i - 1]; +} + /* - * We cannot use strncasecmp here because that applies locale specific rules. + * We cannot use strncasecmp here because that applies locale specific rules. It + * also doesn't work with ASN1_STRINGs that may have embedded NUL characters. * For example in Turkish 'I' is not the uppercase character for 'i'. We need to * do a simple ASCII case comparison ignoring the locale (that is why we use * numeric constants below). @@ -89,20 +112,12 @@ static int ia5ncasecmp(const char *s1, const char *s2, size_t n) /* c1 > c2 */ return 1; - } else if (*s1 == 0) { - /* If we get here we know that *s2 == 0 too */ - return 0; } } return 0; } -static int ia5casecmp(const char *s1, const char *s2) -{ - return ia5ncasecmp(s1, s2, SIZE_MAX); -} - static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { @@ -337,7 +352,7 @@ static int cn2dnsid(ASN1_STRING *cn, unsigned char **dnsid, size_t *idlen) --utf8_length; /* Reject *embedded* NULs */ - if ((size_t)utf8_length != strlen((char *)utf8_value)) { + if (memchr(utf8_value, 0, utf8_length) != NULL) { OPENSSL_free(utf8_value); return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; } @@ -536,9 +551,14 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; + /* Empty matches everything */ - if (!*baseptr) + if (base->length == 0) return X509_V_OK; + + if (dns->length < base->length) + return X509_V_ERR_PERMITTED_VIOLATION; + /* * Otherwise can add zero or more components on the left so compare RHS * and if dns is longer and expect '.' as preceding character. @@ -549,7 +569,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) return X509_V_ERR_PERMITTED_VIOLATION; } - if (ia5casecmp(baseptr, dnsptr)) + if (ia5ncasecmp(baseptr, dnsptr, base->length)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -560,16 +580,17 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *emlptr = (char *)eml->data; + const char *baseat = ia5memrchr(base, '@'); + const char *emlat = ia5memrchr(eml, '@'); + size_t basehostlen, emlhostlen; - const char *baseat = strchr(baseptr, '@'); - const char *emlat = strchr(emlptr, '@'); if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (!baseat && (*baseptr == '.')) { + if (!baseat && base->length > 0 && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; - if (ia5casecmp(baseptr, emlptr) == 0) + if (ia5ncasecmp(baseptr, emlptr, base->length) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; @@ -589,8 +610,10 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) baseptr = baseat + 1; } emlptr = emlat + 1; + basehostlen = IA5_OFFSET_LEN(base, baseptr); + emlhostlen = IA5_OFFSET_LEN(eml, emlptr); /* Just have hostname left to match: case insensitive */ - if (ia5casecmp(baseptr, emlptr)) + if (basehostlen != emlhostlen || ia5ncasecmp(baseptr, emlptr, emlhostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -601,10 +624,14 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *hostptr = (char *)uri->data; - const char *p = strchr(hostptr, ':'); + const char *p = ia5memchr(uri, (char *)uri->data, ':'); int hostlen; + /* Check for foo:// and skip past it */ - if (!p || (p[1] != '/') || (p[2] != '/')) + if (p == NULL + || IA5_OFFSET_LEN(uri, p) < 3 + || p[1] != '/' + || p[2] != '/') return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; @@ -612,13 +639,13 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) /* Look for a port indicator as end of hostname first */ - p = strchr(hostptr, ':'); + p = ia5memchr(uri, hostptr, ':'); /* Otherwise look for trailing slash */ - if (!p) - p = strchr(hostptr, '/'); + if (p == NULL) + p = ia5memchr(uri, hostptr, '/'); - if (!p) - hostlen = strlen(hostptr); + if (p == NULL) + hostlen = IA5_OFFSET_LEN(uri, hostptr); else hostlen = p - hostptr; @@ -626,7 +653,7 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (*baseptr == '.') { + if (base->length > 0 && *baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; if (ia5ncasecmp(p, baseptr, base->length) == 0) diff --git a/crypto/openssl/crypto/x509v3/v3_pci.c b/crypto/openssl/crypto/x509v3/v3_pci.c index 3d124fa6d95d..98b6ef25e280 100644 --- a/crypto/openssl/crypto/x509v3/v3_pci.c +++ b/crypto/openssl/crypto/x509v3/v3_pci.c @@ -77,7 +77,8 @@ static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); BIO_puts(out, "\n"); if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) - BIO_printf(out, "%*sPolicy Text: %s\n", indent, "", + BIO_printf(out, "%*sPolicy Text: %.*s\n", indent, "", + pci->proxyPolicy->policy->length, pci->proxyPolicy->policy->data); return 1; } diff --git a/crypto/openssl/crypto/x509v3/v3_utl.c b/crypto/openssl/crypto/x509v3/v3_utl.c index 7281a7b917a8..706dd22ffaba 100644 --- a/crypto/openssl/crypto/x509v3/v3_utl.c +++ b/crypto/openssl/crypto/x509v3/v3_utl.c @@ -12,6 +12,7 @@ #include "e_os.h" #include "internal/cryptlib.h" #include +#include #include "crypto/ctype.h" #include #include @@ -34,17 +35,23 @@ static int ipv6_hex(unsigned char *out, const char *in, int inlen); /* Add a CONF_VALUE name value pair to stack */ -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist) +static int x509v3_add_len_value(const char *name, const char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; int sk_allocated = (*extlist == NULL); - if (name && (tname = OPENSSL_strdup(name)) == NULL) - goto err; - if (value && (tvalue = OPENSSL_strdup(value)) == NULL) + if (name != NULL && (tname = OPENSSL_strdup(name)) == NULL) goto err; + if (value != NULL) { + /* We don't allow embeded NUL characters */ + if (memchr(value, 0, vallen) != NULL) + goto err; + tvalue = OPENSSL_strndup(value, vallen); + if (tvalue == NULL) + goto err; + } if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; if (sk_allocated && (*extlist = sk_CONF_VALUE_new_null()) == NULL) @@ -67,10 +74,26 @@ int X509V3_add_value(const char *name, const char *value, return 0; } +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist) { - return X509V3_add_value(name, (const char *)value, extlist); + return x509v3_add_len_value(name, (const char *)value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, (const char *)value, vallen, extlist); } /* Free function for STACK_OF(CONF_VALUE) */ @@ -502,18 +525,26 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email /* First some sanity checks */ if (email->type != V_ASN1_IA5STRING) return 1; - if (!email->data || !email->length) + if (email->data == NULL || email->length == 0) + return 1; + if (memchr(email->data, 0, email->length) != NULL) return 1; if (*sk == NULL) *sk = sk_OPENSSL_STRING_new(sk_strcmp); if (*sk == NULL) return 0; + + emtmp = OPENSSL_strndup((char *)email->data, email->length); + if (emtmp == NULL) + return 0; + /* Don't add duplicates */ - if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) + if (sk_OPENSSL_STRING_find(*sk, emtmp) != -1) { + OPENSSL_free(emtmp); return 1; - emtmp = OPENSSL_strdup((char *)email->data); - if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) { - OPENSSL_free(emtmp); /* free on push failure */ + } + if (!sk_OPENSSL_STRING_push(*sk, emtmp)) { + OPENSSL_free(emtmp); /* free on push failure */ X509_email_free(*sk); *sk = NULL; return 0; diff --git a/crypto/openssl/include/crypto/sm2.h b/crypto/openssl/include/crypto/sm2.h index 76ee80baff19..50851a83cea2 100644 --- a/crypto/openssl/include/crypto/sm2.h +++ b/crypto/openssl/include/crypto/sm2.h @@ -60,8 +60,7 @@ int sm2_verify(const unsigned char *dgst, int dgstlen, int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, size_t *ct_size); -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size); +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size); int sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, diff --git a/crypto/openssl/include/crypto/x509.h b/crypto/openssl/include/crypto/x509.h index b53c2b03c39e..7ffb8abfe71b 100644 --- a/crypto/openssl/include/crypto/x509.h +++ b/crypto/openssl/include/crypto/x509.h @@ -8,6 +8,8 @@ */ #include "internal/refcount.h" +#include +#include /* Internal X509 structures and functions: not for application use */ @@ -284,3 +286,6 @@ int a2i_ipadd(unsigned char *ipout, const char *ipasc); int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); void x509_init_sig_info(X509 *x); + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist); diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h index ec4a1123f131..328d0971c414 100644 --- a/crypto/openssl/include/openssl/opensslv.h +++ b/crypto/openssl/include/openssl/opensslv.h @@ -40,7 +40,7 @@ extern "C" { * major minor fix final patch/beta) */ # define OPENSSL_VERSION_NUMBER 0x101010bfL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 25 Mar 2021" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 24 Aug 2021" /*- * The macros below are to be used for shared library (.so, .dll, ...) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDB7B65D6A6; Tue, 24 Aug 2021 18:28: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 4GvHgD6K3bz3NC9; Tue, 24 Aug 2021 18:28: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 B8E06565E; Tue, 24 Aug 2021 18:28: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 17OISeel023443; Tue, 24 Aug 2021 18:28:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISebx023442; Tue, 24 Aug 2021 18:28:40 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:40 GMT Message-Id: <202108241828.17OISebx023442@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 8c8400954f30 - stable/12 - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8c8400954f308680cd2862b417495cf656ed85fa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:41 -0000 The branch stable/12 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=8c8400954f308680cd2862b417495cf656ed85fa commit 8c8400954f308680cd2862b417495cf656ed85fa Author: Gordon Tetlow AuthorDate: 2021-08-24 17:40:49 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:51:09 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 (cherry picked from commit 515216929c40169cc72b62466ff9238682661613) --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index 45a93c4512fe..0695dae0dca2 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -145,7 +145,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -219,6 +233,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 87E1965D571; Tue, 24 Aug 2021 18:28: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 4GvHgG2hRkz3N84; Tue, 24 Aug 2021 18:28: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 E488A593B; Tue, 24 Aug 2021 18:28: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 17OISfGX023467; Tue, 24 Aug 2021 18:28:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISfQT023466; Tue, 24 Aug 2021 18:28:41 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:41 GMT Message-Id: <202108241828.17OISfQT023466@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: dc844e386896 - stable/12 - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: dc844e386896f62a847d3294cd90b3412dcce9ca Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:43 -0000 The branch stable/12 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=dc844e386896f62a847d3294cd90b3412dcce9ca commit dc844e386896f62a847d3294cd90b3412dcce9ca Author: Gordon Tetlow AuthorDate: 2021-08-24 17:59:01 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:59:53 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 (cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5) --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 9a546f3fecad..dfde6edce734 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -704,8 +704,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A10EA65D5C1; Tue, 24 Aug 2021 18:28:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHgJ2cCTz3NH5; Tue, 24 Aug 2021 18:28:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED25556C0; Tue, 24 Aug 2021 18:28: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 17OISgnV023491; Tue, 24 Aug 2021 18:28:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISg3m023490; Tue, 24 Aug 2021 18:28:42 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:42 GMT Message-Id: <202108241828.17OISg3m023490@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 32b373007169 - stable/12 - Fix multiple OpenSSL vulnerabilities. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 32b37300716924acaea1ac645b7be189e3905801 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:45 -0000 The branch stable/12 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=32b37300716924acaea1ac645b7be189e3905801 commit 32b37300716924acaea1ac645b7be189e3905801 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:03:46 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:07:19 +0000 Fix multiple OpenSSL vulnerabilities. Approved by: so Security: SA-21:16.openssl Security: CVE-2021-3711 Security: CVE-2021-3712 (cherry picked from commit be158ffe54dcc4a633652685afc5e37894e10ea0) --- crypto/openssl/crypto/asn1/asn1_lib.c | 12 ++++- crypto/openssl/crypto/asn1/t_spki.c | 2 +- crypto/openssl/crypto/ec/ec_asn1.c | 5 +- crypto/openssl/crypto/sm2/sm2_crypt.c | 27 +++++------ crypto/openssl/crypto/sm2/sm2_pmeth.c | 2 +- crypto/openssl/crypto/x509v3/v3_akey.c | 38 +++++++++++++-- crypto/openssl/crypto/x509v3/v3_alt.c | 10 ++-- crypto/openssl/crypto/x509v3/v3_cpols.c | 9 ++-- crypto/openssl/crypto/x509v3/v3_ncons.c | 77 +++++++++++++++++++++---------- crypto/openssl/crypto/x509v3/v3_pci.c | 3 +- crypto/openssl/crypto/x509v3/v3_utl.c | 53 ++++++++++++++++----- crypto/openssl/include/crypto/sm2.h | 3 +- crypto/openssl/include/crypto/x509.h | 5 ++ crypto/openssl/include/openssl/opensslv.h | 2 +- 14 files changed, 177 insertions(+), 71 deletions(-) diff --git a/crypto/openssl/crypto/asn1/asn1_lib.c b/crypto/openssl/crypto/asn1/asn1_lib.c index 366afc5f6c6b..8e62f3307443 100644 --- a/crypto/openssl/crypto/asn1/asn1_lib.c +++ b/crypto/openssl/crypto/asn1/asn1_lib.c @@ -292,7 +292,12 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) } if ((size_t)str->length <= len || str->data == NULL) { c = str->data; +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* No NUL terminator in fuzzing builds */ + str->data = OPENSSL_realloc(c, len); +#else str->data = OPENSSL_realloc(c, len + 1); +#endif if (str->data == NULL) { ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); str->data = c; @@ -302,8 +307,13 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) str->length = len; if (data != NULL) { memcpy(str->data, data, len); - /* an allowance for strings :-) */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* + * Add a NUL terminator. This should not be necessary - but we add it as + * a safety precaution + */ str->data[len] = '\0'; +#endif } return 1; } diff --git a/crypto/openssl/crypto/asn1/t_spki.c b/crypto/openssl/crypto/asn1/t_spki.c index 51b56d0aa9f7..64ee77eeecba 100644 --- a/crypto/openssl/crypto/asn1/t_spki.c +++ b/crypto/openssl/crypto/asn1/t_spki.c @@ -38,7 +38,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) } chal = spki->spkac->challenge; if (chal->length) - BIO_printf(out, " Challenge String: %s\n", chal->data); + BIO_printf(out, " Challenge String: %.*s\n", chal->length, chal->data); i = OBJ_obj2nid(spki->sig_algor.algorithm); BIO_printf(out, " Signature Algorithm: %s", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); diff --git a/crypto/openssl/crypto/ec/ec_asn1.c b/crypto/openssl/crypto/ec/ec_asn1.c index 7b7c75ce8443..e497a259095d 100644 --- a/crypto/openssl/crypto/ec/ec_asn1.c +++ b/crypto/openssl/crypto/ec/ec_asn1.c @@ -761,7 +761,10 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) ret->seed_len = params->curve->seed->length; } - if (!params->order || !params->base || !params->base->data) { + if (params->order == NULL + || params->base == NULL + || params->base->data == NULL + || params->base->length == 0) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } diff --git a/crypto/openssl/crypto/sm2/sm2_crypt.c b/crypto/openssl/crypto/sm2/sm2_crypt.c index ef505f64412b..00055a4e510e 100644 --- a/crypto/openssl/crypto/sm2/sm2_crypt.c +++ b/crypto/openssl/crypto/sm2/sm2_crypt.c @@ -61,29 +61,20 @@ static size_t ec_field_size(const EC_GROUP *group) return field_size; } -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size) +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size) { - const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); - const int md_size = EVP_MD_size(digest); - size_t overhead; + struct SM2_Ciphertext_st *sm2_ctext = NULL; - if (md_size < 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_DIGEST); - return 0; - } - if (field_size == 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_FIELD); - return 0; - } + sm2_ctext = d2i_SM2_Ciphertext(NULL, &ct, ct_size); - overhead = 10 + 2 * field_size + (size_t)md_size; - if (msg_len <= overhead) { + if (sm2_ctext == NULL) { SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_ENCODING); return 0; } - *pt_size = msg_len - overhead; + *pt_size = sm2_ctext->C2->length; + SM2_Ciphertext_free(sm2_ctext); + return 1; } @@ -303,6 +294,10 @@ int sm2_decrypt(const EC_KEY *key, C2 = sm2_ctext->C2->data; C3 = sm2_ctext->C3->data; msg_len = sm2_ctext->C2->length; + if (*ptext_len < (size_t)msg_len) { + SM2err(SM2_F_SM2_DECRYPT, SM2_R_BUFFER_TOO_SMALL); + goto done; + } ctx = BN_CTX_new(); if (ctx == NULL) { diff --git a/crypto/openssl/crypto/sm2/sm2_pmeth.c b/crypto/openssl/crypto/sm2/sm2_pmeth.c index b42a14c32f26..27025fbf3a2c 100644 --- a/crypto/openssl/crypto/sm2/sm2_pmeth.c +++ b/crypto/openssl/crypto/sm2/sm2_pmeth.c @@ -151,7 +151,7 @@ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { - if (!sm2_plaintext_size(ec, md, inlen, outlen)) + if (!sm2_plaintext_size(in, inlen, outlen)) return -1; else return 1; diff --git a/crypto/openssl/crypto/x509v3/v3_akey.c b/crypto/openssl/crypto/x509v3/v3_akey.c index d9f770433cfb..f917142223b7 100644 --- a/crypto/openssl/crypto/x509v3/v3_akey.c +++ b/crypto/openssl/crypto/x509v3/v3_akey.c @@ -39,20 +39,48 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, STACK_OF(CONF_VALUE) *extlist) { - char *tmp; + char *tmp = NULL; + STACK_OF(CONF_VALUE) *origextlist = extlist, *tmpextlist; + if (akeyid->keyid) { tmp = OPENSSL_buf2hexstr(akeyid->keyid->data, akeyid->keyid->length); - X509V3_add_value("keyid", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (!X509V3_add_value("keyid", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } - if (akeyid->issuer) - extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (akeyid->issuer) { + tmpextlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (tmpextlist == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } + extlist = tmpextlist; + } if (akeyid->serial) { tmp = OPENSSL_buf2hexstr(akeyid->serial->data, akeyid->serial->length); - X509V3_add_value("serial", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!X509V3_add_value("serial", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } return extlist; + err: + if (origextlist == NULL) + sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free); + return NULL; } /*- diff --git a/crypto/openssl/crypto/x509v3/v3_alt.c b/crypto/openssl/crypto/x509v3/v3_alt.c index 4dce0041012e..6e5f9f8b0eac 100644 --- a/crypto/openssl/crypto/x509v3/v3_alt.c +++ b/crypto/openssl/crypto/x509v3/v3_alt.c @@ -9,6 +9,7 @@ #include #include "internal/cryptlib.h" +#include "crypto/x509.h" #include #include #include "ext_dat.h" @@ -99,17 +100,20 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, break; case GEN_EMAIL: - if (!X509V3_add_value_uchar("email", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("email", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_DNS: - if (!X509V3_add_value_uchar("DNS", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("DNS", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_URI: - if (!X509V3_add_value_uchar("URI", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("URI", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; diff --git a/crypto/openssl/crypto/x509v3/v3_cpols.c b/crypto/openssl/crypto/x509v3/v3_cpols.c index 1d12c899125c..861e8455dd08 100644 --- a/crypto/openssl/crypto/x509v3/v3_cpols.c +++ b/crypto/openssl/crypto/x509v3/v3_cpols.c @@ -422,7 +422,8 @@ static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, qualinfo = sk_POLICYQUALINFO_value(quals, i); switch (OBJ_obj2nid(qualinfo->pqualid)) { case NID_id_qt_cps: - BIO_printf(out, "%*sCPS: %s\n", indent, "", + BIO_printf(out, "%*sCPS: %.*s\n", indent, "", + qualinfo->d.cpsuri->length, qualinfo->d.cpsuri->data); break; @@ -447,7 +448,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) if (notice->noticeref) { NOTICEREF *ref; ref = notice->noticeref; - BIO_printf(out, "%*sOrganization: %s\n", indent, "", + BIO_printf(out, "%*sOrganization: %.*s\n", indent, "", + ref->organization->length, ref->organization->data); BIO_printf(out, "%*sNumber%s: ", indent, "", sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); @@ -470,7 +472,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) BIO_puts(out, "\n"); } if (notice->exptext) - BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", + BIO_printf(out, "%*sExplicit Text: %.*s\n", indent, "", + notice->exptext->length, notice->exptext->data); } diff --git a/crypto/openssl/crypto/x509v3/v3_ncons.c b/crypto/openssl/crypto/x509v3/v3_ncons.c index 2a7b4f0992a8..cb701c4d844b 100644 --- a/crypto/openssl/crypto/x509v3/v3_ncons.c +++ b/crypto/openssl/crypto/x509v3/v3_ncons.c @@ -63,8 +63,31 @@ ASN1_SEQUENCE(NAME_CONSTRAINTS) = { IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +#define IA5_OFFSET_LEN(ia5base, offset) \ + ((ia5base)->length - ((unsigned char *)(offset) - (ia5base)->data)) + +/* Like memchr but for ASN1_IA5STRING. Additionally you can specify the + * starting point to search from + */ +# define ia5memchr(str, start, c) memchr(start, c, IA5_OFFSET_LEN(str, start)) + +/* Like memrrchr but for ASN1_IA5STRING */ +static char *ia5memrchr(ASN1_IA5STRING *str, int c) +{ + int i; + + for (i = str->length; i > 0 && str->data[i - 1] != c; i--); + + if (i == 0) + return NULL; + + return (char *)&str->data[i - 1]; +} + /* - * We cannot use strncasecmp here because that applies locale specific rules. + * We cannot use strncasecmp here because that applies locale specific rules. It + * also doesn't work with ASN1_STRINGs that may have embedded NUL characters. * For example in Turkish 'I' is not the uppercase character for 'i'. We need to * do a simple ASCII case comparison ignoring the locale (that is why we use * numeric constants below). @@ -89,20 +112,12 @@ static int ia5ncasecmp(const char *s1, const char *s2, size_t n) /* c1 > c2 */ return 1; - } else if (*s1 == 0) { - /* If we get here we know that *s2 == 0 too */ - return 0; } } return 0; } -static int ia5casecmp(const char *s1, const char *s2) -{ - return ia5ncasecmp(s1, s2, SIZE_MAX); -} - static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { @@ -337,7 +352,7 @@ static int cn2dnsid(ASN1_STRING *cn, unsigned char **dnsid, size_t *idlen) --utf8_length; /* Reject *embedded* NULs */ - if ((size_t)utf8_length != strlen((char *)utf8_value)) { + if (memchr(utf8_value, 0, utf8_length) != NULL) { OPENSSL_free(utf8_value); return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; } @@ -536,9 +551,14 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; + /* Empty matches everything */ - if (!*baseptr) + if (base->length == 0) return X509_V_OK; + + if (dns->length < base->length) + return X509_V_ERR_PERMITTED_VIOLATION; + /* * Otherwise can add zero or more components on the left so compare RHS * and if dns is longer and expect '.' as preceding character. @@ -549,7 +569,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) return X509_V_ERR_PERMITTED_VIOLATION; } - if (ia5casecmp(baseptr, dnsptr)) + if (ia5ncasecmp(baseptr, dnsptr, base->length)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -560,16 +580,17 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *emlptr = (char *)eml->data; + const char *baseat = ia5memrchr(base, '@'); + const char *emlat = ia5memrchr(eml, '@'); + size_t basehostlen, emlhostlen; - const char *baseat = strchr(baseptr, '@'); - const char *emlat = strchr(emlptr, '@'); if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (!baseat && (*baseptr == '.')) { + if (!baseat && base->length > 0 && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; - if (ia5casecmp(baseptr, emlptr) == 0) + if (ia5ncasecmp(baseptr, emlptr, base->length) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; @@ -589,8 +610,10 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) baseptr = baseat + 1; } emlptr = emlat + 1; + basehostlen = IA5_OFFSET_LEN(base, baseptr); + emlhostlen = IA5_OFFSET_LEN(eml, emlptr); /* Just have hostname left to match: case insensitive */ - if (ia5casecmp(baseptr, emlptr)) + if (basehostlen != emlhostlen || ia5ncasecmp(baseptr, emlptr, emlhostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -601,10 +624,14 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *hostptr = (char *)uri->data; - const char *p = strchr(hostptr, ':'); + const char *p = ia5memchr(uri, (char *)uri->data, ':'); int hostlen; + /* Check for foo:// and skip past it */ - if (!p || (p[1] != '/') || (p[2] != '/')) + if (p == NULL + || IA5_OFFSET_LEN(uri, p) < 3 + || p[1] != '/' + || p[2] != '/') return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; @@ -612,13 +639,13 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) /* Look for a port indicator as end of hostname first */ - p = strchr(hostptr, ':'); + p = ia5memchr(uri, hostptr, ':'); /* Otherwise look for trailing slash */ - if (!p) - p = strchr(hostptr, '/'); + if (p == NULL) + p = ia5memchr(uri, hostptr, '/'); - if (!p) - hostlen = strlen(hostptr); + if (p == NULL) + hostlen = IA5_OFFSET_LEN(uri, hostptr); else hostlen = p - hostptr; @@ -626,7 +653,7 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (*baseptr == '.') { + if (base->length > 0 && *baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; if (ia5ncasecmp(p, baseptr, base->length) == 0) diff --git a/crypto/openssl/crypto/x509v3/v3_pci.c b/crypto/openssl/crypto/x509v3/v3_pci.c index 3d124fa6d95d..98b6ef25e280 100644 --- a/crypto/openssl/crypto/x509v3/v3_pci.c +++ b/crypto/openssl/crypto/x509v3/v3_pci.c @@ -77,7 +77,8 @@ static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); BIO_puts(out, "\n"); if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) - BIO_printf(out, "%*sPolicy Text: %s\n", indent, "", + BIO_printf(out, "%*sPolicy Text: %.*s\n", indent, "", + pci->proxyPolicy->policy->length, pci->proxyPolicy->policy->data); return 1; } diff --git a/crypto/openssl/crypto/x509v3/v3_utl.c b/crypto/openssl/crypto/x509v3/v3_utl.c index 7281a7b917a8..706dd22ffaba 100644 --- a/crypto/openssl/crypto/x509v3/v3_utl.c +++ b/crypto/openssl/crypto/x509v3/v3_utl.c @@ -12,6 +12,7 @@ #include "e_os.h" #include "internal/cryptlib.h" #include +#include #include "crypto/ctype.h" #include #include @@ -34,17 +35,23 @@ static int ipv6_hex(unsigned char *out, const char *in, int inlen); /* Add a CONF_VALUE name value pair to stack */ -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist) +static int x509v3_add_len_value(const char *name, const char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; int sk_allocated = (*extlist == NULL); - if (name && (tname = OPENSSL_strdup(name)) == NULL) - goto err; - if (value && (tvalue = OPENSSL_strdup(value)) == NULL) + if (name != NULL && (tname = OPENSSL_strdup(name)) == NULL) goto err; + if (value != NULL) { + /* We don't allow embeded NUL characters */ + if (memchr(value, 0, vallen) != NULL) + goto err; + tvalue = OPENSSL_strndup(value, vallen); + if (tvalue == NULL) + goto err; + } if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; if (sk_allocated && (*extlist = sk_CONF_VALUE_new_null()) == NULL) @@ -67,10 +74,26 @@ int X509V3_add_value(const char *name, const char *value, return 0; } +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist) { - return X509V3_add_value(name, (const char *)value, extlist); + return x509v3_add_len_value(name, (const char *)value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, (const char *)value, vallen, extlist); } /* Free function for STACK_OF(CONF_VALUE) */ @@ -502,18 +525,26 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email /* First some sanity checks */ if (email->type != V_ASN1_IA5STRING) return 1; - if (!email->data || !email->length) + if (email->data == NULL || email->length == 0) + return 1; + if (memchr(email->data, 0, email->length) != NULL) return 1; if (*sk == NULL) *sk = sk_OPENSSL_STRING_new(sk_strcmp); if (*sk == NULL) return 0; + + emtmp = OPENSSL_strndup((char *)email->data, email->length); + if (emtmp == NULL) + return 0; + /* Don't add duplicates */ - if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) + if (sk_OPENSSL_STRING_find(*sk, emtmp) != -1) { + OPENSSL_free(emtmp); return 1; - emtmp = OPENSSL_strdup((char *)email->data); - if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) { - OPENSSL_free(emtmp); /* free on push failure */ + } + if (!sk_OPENSSL_STRING_push(*sk, emtmp)) { + OPENSSL_free(emtmp); /* free on push failure */ X509_email_free(*sk); *sk = NULL; return 0; diff --git a/crypto/openssl/include/crypto/sm2.h b/crypto/openssl/include/crypto/sm2.h index 76ee80baff19..50851a83cea2 100644 --- a/crypto/openssl/include/crypto/sm2.h +++ b/crypto/openssl/include/crypto/sm2.h @@ -60,8 +60,7 @@ int sm2_verify(const unsigned char *dgst, int dgstlen, int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, size_t *ct_size); -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size); +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size); int sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, diff --git a/crypto/openssl/include/crypto/x509.h b/crypto/openssl/include/crypto/x509.h index b53c2b03c39e..7ffb8abfe71b 100644 --- a/crypto/openssl/include/crypto/x509.h +++ b/crypto/openssl/include/crypto/x509.h @@ -8,6 +8,8 @@ */ #include "internal/refcount.h" +#include +#include /* Internal X509 structures and functions: not for application use */ @@ -284,3 +286,6 @@ int a2i_ipadd(unsigned char *ipout, const char *ipasc); int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); void x509_init_sig_info(X509 *x); + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist); diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h index e7aa93096c2f..efec95a85d03 100644 --- a/crypto/openssl/include/openssl/opensslv.h +++ b/crypto/openssl/include/openssl/opensslv.h @@ -40,7 +40,7 @@ extern "C" { * major minor fix final patch/beta) */ # define OPENSSL_VERSION_NUMBER 0x101010bfL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 25 Mar 2021" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 24 Aug 2021" /*- * The macros below are to be used for shared library (.so, .dll, ...) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1817765D728; Tue, 24 Aug 2021 18:28: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 4GvHgS6kByz3NST; Tue, 24 Aug 2021 18:28:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A169F56C1; Tue, 24 Aug 2021 18:28:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OISqeR023632; Tue, 24 Aug 2021 18:28:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISqYg023631; Tue, 24 Aug 2021 18:28:52 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:52 GMT Message-Id: <202108241828.17OISqYg023631@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 1b55a830a08a - stable/11 - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 1b55a830a08a643815144017e6e434d674652cca Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:53 -0000 The branch stable/11 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=1b55a830a08a643815144017e6e434d674652cca commit 1b55a830a08a643815144017e6e434d674652cca Author: Gordon Tetlow AuthorDate: 2021-08-24 17:40:49 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:51:18 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 (cherry picked from commit 515216929c40169cc72b62466ff9238682661613) --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index a2aa49e2b362..deff5e3a756a 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -144,7 +144,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -217,6 +231,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:28:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 385D465D72E; Tue, 24 Aug 2021 18:28: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 4GvHgT6Y2qz3NPm; Tue, 24 Aug 2021 18:28: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 B736556C2; Tue, 24 Aug 2021 18:28: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 17OISrfA023656; Tue, 24 Aug 2021 18:28:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OISrTN023655; Tue, 24 Aug 2021 18:28:53 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:28:53 GMT Message-Id: <202108241828.17OISrTN023655@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 4200a810ea2c - stable/11 - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 4200a810ea2cea77cd8473565f1c12c585f76e09 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:28:54 -0000 The branch stable/11 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=4200a810ea2cea77cd8473565f1c12c585f76e09 commit 4200a810ea2cea77cd8473565f1c12c585f76e09 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:59:01 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:00:03 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 (cherry picked from commit 3be62d49ae2b6f9050f39fe74210c88f35901fa5) --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index c034b5efa240..1755012fc99b 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -702,8 +702,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 19FB565D84D; Tue, 24 Aug 2021 18:29: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 4GvHgs5r5wz3NLR; Tue, 24 Aug 2021 18:29: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 A1DB256C4; Tue, 24 Aug 2021 18:29: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 17OITD13023828; Tue, 24 Aug 2021 18:29:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITDkh023827; Tue, 24 Aug 2021 18:29:13 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:13 GMT Message-Id: <202108241829.17OITDkh023827@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: f66e34809906 - releng/13.0 - Fix virtio_blk(4) failing to attach on some hypervisors. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: f66e34809906a3222446e1407bd9add84dd6f10c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:14 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=f66e34809906a3222446e1407bd9add84dd6f10c commit f66e34809906a3222446e1407bd9add84dd6f10c Author: Gordon Tetlow AuthorDate: 2021-08-24 16:31:52 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 16:36:55 +0000 Fix virtio_blk(4) failing to attach on some hypervisors. Approved by: so Security: EN-21:23.virtio_blk --- sys/dev/virtio/block/virtio_blk.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index 50642fb0b009..8a5558f4571d 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -126,6 +126,7 @@ static int vtblk_detach(device_t); static int vtblk_suspend(device_t); static int vtblk_resume(device_t); static int vtblk_shutdown(device_t); +static int vtblk_attach_completed(device_t); static int vtblk_config_change(device_t); static int vtblk_open(struct disk *); @@ -255,6 +256,7 @@ static device_method_t vtblk_methods[] = { DEVMETHOD(device_shutdown, vtblk_shutdown), /* VirtIO methods. */ + DEVMETHOD(virtio_attach_completed, vtblk_attach_completed), DEVMETHOD(virtio_config_change, vtblk_config_change), DEVMETHOD_END @@ -378,8 +380,6 @@ vtblk_attach(device_t dev) goto fail; } - vtblk_create_disk(sc); - virtqueue_enable_intr(sc->vtblk_vq); fail: @@ -461,6 +461,22 @@ vtblk_shutdown(device_t dev) return (0); } +static int +vtblk_attach_completed(device_t dev) +{ + struct vtblk_softc *sc; + + sc = device_get_softc(dev); + + /* + * Create disk after attach as VIRTIO_BLK_T_GET_ID can only be + * processed after the device acknowledged + * VIRTIO_CONFIG_STATUS_DRIVER_OK. + */ + vtblk_create_disk(sc); + return (0); +} + static int vtblk_config_change(device_t dev) { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 73F3C65DA8D; Tue, 24 Aug 2021 18:29: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 4GvHgv0D7tz3NFQ; Tue, 24 Aug 2021 18:29: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 D0D7A59C2; Tue, 24 Aug 2021 18:29: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 17OITE16023853; Tue, 24 Aug 2021 18:29:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITEMI023852; Tue, 24 Aug 2021 18:29:14 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:14 GMT Message-Id: <202108241829.17OITEMI023852@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 3ef67fed446a - releng/13.0 - Fix OpenSSL 1.1.1e API functions not being exported. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 3ef67fed446a040140374513c0995ce9a6033394 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:16 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=3ef67fed446a040140374513c0995ce9a6033394 commit 3ef67fed446a040140374513c0995ce9a6033394 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:25:47 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:25:47 +0000 Fix OpenSSL 1.1.1e API functions not being exported. Approved by: so Security: EN-21:24.libcrypto --- secure/lib/libcrypto/Version.map | 17 ++++++++++++++++- secure/lib/libssl/Version.map | 1 - 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/secure/lib/libcrypto/Version.map b/secure/lib/libcrypto/Version.map index 33432019a023..bed7623b9c47 100644 --- a/secure/lib/libcrypto/Version.map +++ b/secure/lib/libcrypto/Version.map @@ -4450,7 +4450,22 @@ OPENSSL_1_1_1d { global: X509_get0_authority_issuer; X509_get0_authority_serial; - local: *; } OPENSSL_1_1_1c; +OPENSSL_1_1_1e { + global: + EVP_PKEY_meth_get_digestsign; + EVP_PKEY_meth_get_digestverify; + EVP_PKEY_meth_set_digestsign; + EVP_PKEY_meth_set_digestverify; + RSA_get0_pss_params; +} OPENSSL_1_1_1d; +OPENSSL_1_1_1h { + global: + EC_KEY_decoded_from_explicit_params; + X509_ALGOR_copy; + X509_REQ_set0_signature; + X509_REQ_set1_signature_algo; + local: *; +} OPENSSL_1_1_1e; diff --git a/secure/lib/libssl/Version.map b/secure/lib/libssl/Version.map index 8c5eba6795ec..3e4e00950def 100644 --- a/secure/lib/libssl/Version.map +++ b/secure/lib/libssl/Version.map @@ -512,7 +512,6 @@ OPENSSL_1_1_1 { OPENSSL_1_1_1a { global: SSL_get_signature_type_nid; - local: *; } OPENSSL_1_1_1; OPENSSL_1_1_1e { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0A38165DA98; Tue, 24 Aug 2021 18:29: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 4GvHgw5m9Bz3NWV; Tue, 24 Aug 2021 18:29: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 0E4B458A0; Tue, 24 Aug 2021 18:29: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 17OITFig023877; Tue, 24 Aug 2021 18:29:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITF8H023876; Tue, 24 Aug 2021 18:29:15 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:15 GMT Message-Id: <202108241829.17OITF8H023876@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 4f590ee3ed7e - releng/13.0 - Fix NVMe iovec construction for large IOs. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 4f590ee3ed7eb15cb3583f5fa1af75f0f45a475c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:17 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=4f590ee3ed7eb15cb3583f5fa1af75f0f45a475c commit 4f590ee3ed7eb15cb3583f5fa1af75f0f45a475c Author: Gordon Tetlow AuthorDate: 2021-08-24 17:28:07 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:28:07 +0000 Fix NVMe iovec construction for large IOs. Approved by: so Security: EN-21:25.bhyve --- usr.sbin/bhyve/pci_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index 24f401630d6d..bd21819f0607 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -1976,7 +1976,7 @@ nvme_write_read_blockif(struct pci_nvme_softc *sc, /* PRP2 is pointer to a physical region page list */ while (bytes) { /* Last entry in list points to the next list */ - if (prp_list == last) { + if ((prp_list == last) && (bytes > PAGE_SIZE)) { uint64_t prp = *prp_list; prp_list = paddr_guest2host(vmctx, prp, From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1473B65D7FF; Tue, 24 Aug 2021 18:29: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 4GvHgy4gRvz3NWj; Tue, 24 Aug 2021 18:29: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 3CE6656C5; Tue, 24 Aug 2021 18:29: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 17OITIXG023925; Tue, 24 Aug 2021 18:29:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITI1p023924; Tue, 24 Aug 2021 18:29:18 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:18 GMT Message-Id: <202108241829.17OITI1p023924@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: c8a2cc4ba845 - releng/13.0 - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: c8a2cc4ba845333c122fb6d86ee7430a01cc397e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:19 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=c8a2cc4ba845333c122fb6d86ee7430a01cc397e commit c8a2cc4ba845333c122fb6d86ee7430a01cc397e Author: Gordon Tetlow AuthorDate: 2021-08-24 17:37:45 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:37:45 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index 45a93c4512fe..0695dae0dca2 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -145,7 +145,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -219,6 +233,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0747165DB89; Tue, 24 Aug 2021 18:29: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 4GvHh00Hqjz3NFm; Tue, 24 Aug 2021 18:29: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 628035942; Tue, 24 Aug 2021 18:29: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 17OITJbM023949; Tue, 24 Aug 2021 18:29:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITJmP023948; Tue, 24 Aug 2021 18:29:19 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:19 GMT Message-Id: <202108241829.17OITJmP023948@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 060510ba8bfb - releng/13.0 - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 060510ba8bfba7a59908fb5aa99aa8d17d6882c8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:21 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=060510ba8bfba7a59908fb5aa99aa8d17d6882c8 commit 060510ba8bfba7a59908fb5aa99aa8d17d6882c8 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:00:47 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:00:47 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 9a546f3fecad..dfde6edce734 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -704,8 +704,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 552FD65D9A5; Tue, 24 Aug 2021 18:29:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHh142b3z3NFr; Tue, 24 Aug 2021 18:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 71E5159C3; Tue, 24 Aug 2021 18:29: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 17OITKus023979; Tue, 24 Aug 2021 18:29:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITKkc023978; Tue, 24 Aug 2021 18:29:20 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:20 GMT Message-Id: <202108241829.17OITKkc023978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 2261c814b7fa - releng/13.0 - Fix multiple OpenSSL vulnerabilities. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 2261c814b7fa4730f308b476eff1afb0dcdf35ec Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:23 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=2261c814b7fa4730f308b476eff1afb0dcdf35ec commit 2261c814b7fa4730f308b476eff1afb0dcdf35ec Author: Gordon Tetlow AuthorDate: 2021-08-24 18:08:04 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:08:04 +0000 Fix multiple OpenSSL vulnerabilities. Approved by: so Security: SA-21:16.openssl Security: CVE-2021-3711 Security: CVE-2021-3712 --- crypto/openssl/crypto/asn1/asn1_lib.c | 12 ++++- crypto/openssl/crypto/asn1/t_spki.c | 2 +- crypto/openssl/crypto/ec/ec_asn1.c | 5 +- crypto/openssl/crypto/sm2/sm2_crypt.c | 27 +++++------ crypto/openssl/crypto/sm2/sm2_pmeth.c | 2 +- crypto/openssl/crypto/x509v3/v3_akey.c | 38 +++++++++++++-- crypto/openssl/crypto/x509v3/v3_alt.c | 10 ++-- crypto/openssl/crypto/x509v3/v3_cpols.c | 9 ++-- crypto/openssl/crypto/x509v3/v3_ncons.c | 77 +++++++++++++++++++++---------- crypto/openssl/crypto/x509v3/v3_pci.c | 3 +- crypto/openssl/crypto/x509v3/v3_utl.c | 53 ++++++++++++++++----- crypto/openssl/include/crypto/sm2.h | 3 +- crypto/openssl/include/crypto/x509.h | 5 ++ crypto/openssl/include/openssl/opensslv.h | 2 +- 14 files changed, 177 insertions(+), 71 deletions(-) diff --git a/crypto/openssl/crypto/asn1/asn1_lib.c b/crypto/openssl/crypto/asn1/asn1_lib.c index 366afc5f6c6b..8e62f3307443 100644 --- a/crypto/openssl/crypto/asn1/asn1_lib.c +++ b/crypto/openssl/crypto/asn1/asn1_lib.c @@ -292,7 +292,12 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) } if ((size_t)str->length <= len || str->data == NULL) { c = str->data; +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* No NUL terminator in fuzzing builds */ + str->data = OPENSSL_realloc(c, len); +#else str->data = OPENSSL_realloc(c, len + 1); +#endif if (str->data == NULL) { ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); str->data = c; @@ -302,8 +307,13 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) str->length = len; if (data != NULL) { memcpy(str->data, data, len); - /* an allowance for strings :-) */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* + * Add a NUL terminator. This should not be necessary - but we add it as + * a safety precaution + */ str->data[len] = '\0'; +#endif } return 1; } diff --git a/crypto/openssl/crypto/asn1/t_spki.c b/crypto/openssl/crypto/asn1/t_spki.c index 51b56d0aa9f7..64ee77eeecba 100644 --- a/crypto/openssl/crypto/asn1/t_spki.c +++ b/crypto/openssl/crypto/asn1/t_spki.c @@ -38,7 +38,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) } chal = spki->spkac->challenge; if (chal->length) - BIO_printf(out, " Challenge String: %s\n", chal->data); + BIO_printf(out, " Challenge String: %.*s\n", chal->length, chal->data); i = OBJ_obj2nid(spki->sig_algor.algorithm); BIO_printf(out, " Signature Algorithm: %s", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); diff --git a/crypto/openssl/crypto/ec/ec_asn1.c b/crypto/openssl/crypto/ec/ec_asn1.c index 7b7c75ce8443..e497a259095d 100644 --- a/crypto/openssl/crypto/ec/ec_asn1.c +++ b/crypto/openssl/crypto/ec/ec_asn1.c @@ -761,7 +761,10 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) ret->seed_len = params->curve->seed->length; } - if (!params->order || !params->base || !params->base->data) { + if (params->order == NULL + || params->base == NULL + || params->base->data == NULL + || params->base->length == 0) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } diff --git a/crypto/openssl/crypto/sm2/sm2_crypt.c b/crypto/openssl/crypto/sm2/sm2_crypt.c index ef505f64412b..00055a4e510e 100644 --- a/crypto/openssl/crypto/sm2/sm2_crypt.c +++ b/crypto/openssl/crypto/sm2/sm2_crypt.c @@ -61,29 +61,20 @@ static size_t ec_field_size(const EC_GROUP *group) return field_size; } -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size) +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size) { - const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); - const int md_size = EVP_MD_size(digest); - size_t overhead; + struct SM2_Ciphertext_st *sm2_ctext = NULL; - if (md_size < 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_DIGEST); - return 0; - } - if (field_size == 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_FIELD); - return 0; - } + sm2_ctext = d2i_SM2_Ciphertext(NULL, &ct, ct_size); - overhead = 10 + 2 * field_size + (size_t)md_size; - if (msg_len <= overhead) { + if (sm2_ctext == NULL) { SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_ENCODING); return 0; } - *pt_size = msg_len - overhead; + *pt_size = sm2_ctext->C2->length; + SM2_Ciphertext_free(sm2_ctext); + return 1; } @@ -303,6 +294,10 @@ int sm2_decrypt(const EC_KEY *key, C2 = sm2_ctext->C2->data; C3 = sm2_ctext->C3->data; msg_len = sm2_ctext->C2->length; + if (*ptext_len < (size_t)msg_len) { + SM2err(SM2_F_SM2_DECRYPT, SM2_R_BUFFER_TOO_SMALL); + goto done; + } ctx = BN_CTX_new(); if (ctx == NULL) { diff --git a/crypto/openssl/crypto/sm2/sm2_pmeth.c b/crypto/openssl/crypto/sm2/sm2_pmeth.c index b42a14c32f26..27025fbf3a2c 100644 --- a/crypto/openssl/crypto/sm2/sm2_pmeth.c +++ b/crypto/openssl/crypto/sm2/sm2_pmeth.c @@ -151,7 +151,7 @@ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { - if (!sm2_plaintext_size(ec, md, inlen, outlen)) + if (!sm2_plaintext_size(in, inlen, outlen)) return -1; else return 1; diff --git a/crypto/openssl/crypto/x509v3/v3_akey.c b/crypto/openssl/crypto/x509v3/v3_akey.c index d9f770433cfb..f917142223b7 100644 --- a/crypto/openssl/crypto/x509v3/v3_akey.c +++ b/crypto/openssl/crypto/x509v3/v3_akey.c @@ -39,20 +39,48 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, STACK_OF(CONF_VALUE) *extlist) { - char *tmp; + char *tmp = NULL; + STACK_OF(CONF_VALUE) *origextlist = extlist, *tmpextlist; + if (akeyid->keyid) { tmp = OPENSSL_buf2hexstr(akeyid->keyid->data, akeyid->keyid->length); - X509V3_add_value("keyid", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (!X509V3_add_value("keyid", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } - if (akeyid->issuer) - extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (akeyid->issuer) { + tmpextlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (tmpextlist == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } + extlist = tmpextlist; + } if (akeyid->serial) { tmp = OPENSSL_buf2hexstr(akeyid->serial->data, akeyid->serial->length); - X509V3_add_value("serial", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!X509V3_add_value("serial", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } return extlist; + err: + if (origextlist == NULL) + sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free); + return NULL; } /*- diff --git a/crypto/openssl/crypto/x509v3/v3_alt.c b/crypto/openssl/crypto/x509v3/v3_alt.c index 4dce0041012e..6e5f9f8b0eac 100644 --- a/crypto/openssl/crypto/x509v3/v3_alt.c +++ b/crypto/openssl/crypto/x509v3/v3_alt.c @@ -9,6 +9,7 @@ #include #include "internal/cryptlib.h" +#include "crypto/x509.h" #include #include #include "ext_dat.h" @@ -99,17 +100,20 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, break; case GEN_EMAIL: - if (!X509V3_add_value_uchar("email", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("email", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_DNS: - if (!X509V3_add_value_uchar("DNS", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("DNS", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_URI: - if (!X509V3_add_value_uchar("URI", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("URI", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; diff --git a/crypto/openssl/crypto/x509v3/v3_cpols.c b/crypto/openssl/crypto/x509v3/v3_cpols.c index 1d12c899125c..861e8455dd08 100644 --- a/crypto/openssl/crypto/x509v3/v3_cpols.c +++ b/crypto/openssl/crypto/x509v3/v3_cpols.c @@ -422,7 +422,8 @@ static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, qualinfo = sk_POLICYQUALINFO_value(quals, i); switch (OBJ_obj2nid(qualinfo->pqualid)) { case NID_id_qt_cps: - BIO_printf(out, "%*sCPS: %s\n", indent, "", + BIO_printf(out, "%*sCPS: %.*s\n", indent, "", + qualinfo->d.cpsuri->length, qualinfo->d.cpsuri->data); break; @@ -447,7 +448,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) if (notice->noticeref) { NOTICEREF *ref; ref = notice->noticeref; - BIO_printf(out, "%*sOrganization: %s\n", indent, "", + BIO_printf(out, "%*sOrganization: %.*s\n", indent, "", + ref->organization->length, ref->organization->data); BIO_printf(out, "%*sNumber%s: ", indent, "", sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); @@ -470,7 +472,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) BIO_puts(out, "\n"); } if (notice->exptext) - BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", + BIO_printf(out, "%*sExplicit Text: %.*s\n", indent, "", + notice->exptext->length, notice->exptext->data); } diff --git a/crypto/openssl/crypto/x509v3/v3_ncons.c b/crypto/openssl/crypto/x509v3/v3_ncons.c index 2a7b4f0992a8..cb701c4d844b 100644 --- a/crypto/openssl/crypto/x509v3/v3_ncons.c +++ b/crypto/openssl/crypto/x509v3/v3_ncons.c @@ -63,8 +63,31 @@ ASN1_SEQUENCE(NAME_CONSTRAINTS) = { IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +#define IA5_OFFSET_LEN(ia5base, offset) \ + ((ia5base)->length - ((unsigned char *)(offset) - (ia5base)->data)) + +/* Like memchr but for ASN1_IA5STRING. Additionally you can specify the + * starting point to search from + */ +# define ia5memchr(str, start, c) memchr(start, c, IA5_OFFSET_LEN(str, start)) + +/* Like memrrchr but for ASN1_IA5STRING */ +static char *ia5memrchr(ASN1_IA5STRING *str, int c) +{ + int i; + + for (i = str->length; i > 0 && str->data[i - 1] != c; i--); + + if (i == 0) + return NULL; + + return (char *)&str->data[i - 1]; +} + /* - * We cannot use strncasecmp here because that applies locale specific rules. + * We cannot use strncasecmp here because that applies locale specific rules. It + * also doesn't work with ASN1_STRINGs that may have embedded NUL characters. * For example in Turkish 'I' is not the uppercase character for 'i'. We need to * do a simple ASCII case comparison ignoring the locale (that is why we use * numeric constants below). @@ -89,20 +112,12 @@ static int ia5ncasecmp(const char *s1, const char *s2, size_t n) /* c1 > c2 */ return 1; - } else if (*s1 == 0) { - /* If we get here we know that *s2 == 0 too */ - return 0; } } return 0; } -static int ia5casecmp(const char *s1, const char *s2) -{ - return ia5ncasecmp(s1, s2, SIZE_MAX); -} - static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { @@ -337,7 +352,7 @@ static int cn2dnsid(ASN1_STRING *cn, unsigned char **dnsid, size_t *idlen) --utf8_length; /* Reject *embedded* NULs */ - if ((size_t)utf8_length != strlen((char *)utf8_value)) { + if (memchr(utf8_value, 0, utf8_length) != NULL) { OPENSSL_free(utf8_value); return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; } @@ -536,9 +551,14 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; + /* Empty matches everything */ - if (!*baseptr) + if (base->length == 0) return X509_V_OK; + + if (dns->length < base->length) + return X509_V_ERR_PERMITTED_VIOLATION; + /* * Otherwise can add zero or more components on the left so compare RHS * and if dns is longer and expect '.' as preceding character. @@ -549,7 +569,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) return X509_V_ERR_PERMITTED_VIOLATION; } - if (ia5casecmp(baseptr, dnsptr)) + if (ia5ncasecmp(baseptr, dnsptr, base->length)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -560,16 +580,17 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *emlptr = (char *)eml->data; + const char *baseat = ia5memrchr(base, '@'); + const char *emlat = ia5memrchr(eml, '@'); + size_t basehostlen, emlhostlen; - const char *baseat = strchr(baseptr, '@'); - const char *emlat = strchr(emlptr, '@'); if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (!baseat && (*baseptr == '.')) { + if (!baseat && base->length > 0 && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; - if (ia5casecmp(baseptr, emlptr) == 0) + if (ia5ncasecmp(baseptr, emlptr, base->length) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; @@ -589,8 +610,10 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) baseptr = baseat + 1; } emlptr = emlat + 1; + basehostlen = IA5_OFFSET_LEN(base, baseptr); + emlhostlen = IA5_OFFSET_LEN(eml, emlptr); /* Just have hostname left to match: case insensitive */ - if (ia5casecmp(baseptr, emlptr)) + if (basehostlen != emlhostlen || ia5ncasecmp(baseptr, emlptr, emlhostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -601,10 +624,14 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *hostptr = (char *)uri->data; - const char *p = strchr(hostptr, ':'); + const char *p = ia5memchr(uri, (char *)uri->data, ':'); int hostlen; + /* Check for foo:// and skip past it */ - if (!p || (p[1] != '/') || (p[2] != '/')) + if (p == NULL + || IA5_OFFSET_LEN(uri, p) < 3 + || p[1] != '/' + || p[2] != '/') return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; @@ -612,13 +639,13 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) /* Look for a port indicator as end of hostname first */ - p = strchr(hostptr, ':'); + p = ia5memchr(uri, hostptr, ':'); /* Otherwise look for trailing slash */ - if (!p) - p = strchr(hostptr, '/'); + if (p == NULL) + p = ia5memchr(uri, hostptr, '/'); - if (!p) - hostlen = strlen(hostptr); + if (p == NULL) + hostlen = IA5_OFFSET_LEN(uri, hostptr); else hostlen = p - hostptr; @@ -626,7 +653,7 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (*baseptr == '.') { + if (base->length > 0 && *baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; if (ia5ncasecmp(p, baseptr, base->length) == 0) diff --git a/crypto/openssl/crypto/x509v3/v3_pci.c b/crypto/openssl/crypto/x509v3/v3_pci.c index 3d124fa6d95d..98b6ef25e280 100644 --- a/crypto/openssl/crypto/x509v3/v3_pci.c +++ b/crypto/openssl/crypto/x509v3/v3_pci.c @@ -77,7 +77,8 @@ static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); BIO_puts(out, "\n"); if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) - BIO_printf(out, "%*sPolicy Text: %s\n", indent, "", + BIO_printf(out, "%*sPolicy Text: %.*s\n", indent, "", + pci->proxyPolicy->policy->length, pci->proxyPolicy->policy->data); return 1; } diff --git a/crypto/openssl/crypto/x509v3/v3_utl.c b/crypto/openssl/crypto/x509v3/v3_utl.c index 7281a7b917a8..706dd22ffaba 100644 --- a/crypto/openssl/crypto/x509v3/v3_utl.c +++ b/crypto/openssl/crypto/x509v3/v3_utl.c @@ -12,6 +12,7 @@ #include "e_os.h" #include "internal/cryptlib.h" #include +#include #include "crypto/ctype.h" #include #include @@ -34,17 +35,23 @@ static int ipv6_hex(unsigned char *out, const char *in, int inlen); /* Add a CONF_VALUE name value pair to stack */ -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist) +static int x509v3_add_len_value(const char *name, const char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; int sk_allocated = (*extlist == NULL); - if (name && (tname = OPENSSL_strdup(name)) == NULL) - goto err; - if (value && (tvalue = OPENSSL_strdup(value)) == NULL) + if (name != NULL && (tname = OPENSSL_strdup(name)) == NULL) goto err; + if (value != NULL) { + /* We don't allow embeded NUL characters */ + if (memchr(value, 0, vallen) != NULL) + goto err; + tvalue = OPENSSL_strndup(value, vallen); + if (tvalue == NULL) + goto err; + } if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; if (sk_allocated && (*extlist = sk_CONF_VALUE_new_null()) == NULL) @@ -67,10 +74,26 @@ int X509V3_add_value(const char *name, const char *value, return 0; } +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist) { - return X509V3_add_value(name, (const char *)value, extlist); + return x509v3_add_len_value(name, (const char *)value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, (const char *)value, vallen, extlist); } /* Free function for STACK_OF(CONF_VALUE) */ @@ -502,18 +525,26 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email /* First some sanity checks */ if (email->type != V_ASN1_IA5STRING) return 1; - if (!email->data || !email->length) + if (email->data == NULL || email->length == 0) + return 1; + if (memchr(email->data, 0, email->length) != NULL) return 1; if (*sk == NULL) *sk = sk_OPENSSL_STRING_new(sk_strcmp); if (*sk == NULL) return 0; + + emtmp = OPENSSL_strndup((char *)email->data, email->length); + if (emtmp == NULL) + return 0; + /* Don't add duplicates */ - if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) + if (sk_OPENSSL_STRING_find(*sk, emtmp) != -1) { + OPENSSL_free(emtmp); return 1; - emtmp = OPENSSL_strdup((char *)email->data); - if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) { - OPENSSL_free(emtmp); /* free on push failure */ + } + if (!sk_OPENSSL_STRING_push(*sk, emtmp)) { + OPENSSL_free(emtmp); /* free on push failure */ X509_email_free(*sk); *sk = NULL; return 0; diff --git a/crypto/openssl/include/crypto/sm2.h b/crypto/openssl/include/crypto/sm2.h index 76ee80baff19..50851a83cea2 100644 --- a/crypto/openssl/include/crypto/sm2.h +++ b/crypto/openssl/include/crypto/sm2.h @@ -60,8 +60,7 @@ int sm2_verify(const unsigned char *dgst, int dgstlen, int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, size_t *ct_size); -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size); +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size); int sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, diff --git a/crypto/openssl/include/crypto/x509.h b/crypto/openssl/include/crypto/x509.h index b53c2b03c39e..7ffb8abfe71b 100644 --- a/crypto/openssl/include/crypto/x509.h +++ b/crypto/openssl/include/crypto/x509.h @@ -8,6 +8,8 @@ */ #include "internal/refcount.h" +#include +#include /* Internal X509 structures and functions: not for application use */ @@ -284,3 +286,6 @@ int a2i_ipadd(unsigned char *ipout, const char *ipasc); int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); void x509_init_sig_info(X509 *x); + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist); diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h index ec4a1123f131..328d0971c414 100644 --- a/crypto/openssl/include/openssl/opensslv.h +++ b/crypto/openssl/include/openssl/opensslv.h @@ -40,7 +40,7 @@ extern "C" { * major minor fix final patch/beta) */ # define OPENSSL_VERSION_NUMBER 0x101010bfL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 25 Mar 2021" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k-freebsd 24 Aug 2021" /*- * The macros below are to be used for shared library (.so, .dll, ...) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B426265DA20; Tue, 24 Aug 2021 18:29: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 4GvHgx2rWXz3NYV; Tue, 24 Aug 2021 18:29: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 156EE5829; Tue, 24 Aug 2021 18:29: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 17OITGMM023901; Tue, 24 Aug 2021 18:29:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITG8p023900; Tue, 24 Aug 2021 18:29:16 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:16 GMT Message-Id: <202108241829.17OITG8p023900@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: ec08bc89d4b3 - releng/13.0 - Fix missing error handling in bhyve(8) device models. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: ec08bc89d4b3a94ff676e8e9ce6663508f18148b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:18 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=ec08bc89d4b3a94ff676e8e9ce6663508f18148b commit ec08bc89d4b3a94ff676e8e9ce6663508f18148b Author: Gordon Tetlow AuthorDate: 2021-08-24 17:33:35 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:33:35 +0000 Fix missing error handling in bhyve(8) device models. Approved by: so Security: SA-21:13.bhyve Security: CVE-2021-29631 --- usr.sbin/bhyve/pci_virtio_9p.c | 4 +++- usr.sbin/bhyve/pci_virtio_console.c | 7 ++++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- usr.sbin/bhyve/pci_virtio_scsi.c | 10 ++++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index 7e8542a46e05..7e11fba649b7 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -195,13 +195,15 @@ pci_vt9p_notify(void *vsc, struct vqueue_info *vq) struct iovec iov[VT9P_MAX_IOV]; struct pci_vt9p_softc *sc; struct pci_vt9p_request *preq; - uint16_t idx, n, i; + int n; + uint16_t idx, i; uint16_t flags[VT9P_MAX_IOV]; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, VT9P_MAX_IOV, flags); + assert(n >= 1 && n <= VT9P_MAX_IOV); preq = calloc(1, sizeof(struct pci_vt9p_request)); preq->vsr_sc = sc; preq->vsr_idx = idx; diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 133902ccb129..2f87220a0e4f 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -421,6 +421,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -561,7 +562,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &idx, &iov, 1, NULL); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -580,7 +580,8 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_softc *sc; struct pci_vtcon_port *port; struct iovec iov[1]; - uint16_t idx, n; + int n; + uint16_t idx; uint16_t flags[8]; sc = vsc; @@ -588,7 +589,7 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, 1, flags); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 10ba9ddfbfaf..46267c6e4c84 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -113,7 +113,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) { struct iovec iov; struct pci_vtrnd_softc *sc; - int len; + int len, n; uint16_t idx; sc = vsc; @@ -124,7 +124,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &idx, &iov, 1, NULL); + n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index 92a3311b6924..a2b83b77148e 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -557,15 +557,16 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) { struct pci_vtscsi_softc *sc; struct iovec iov[VTSCSI_MAXSEG]; - uint16_t idx, n; + uint16_t idx; void *buf = NULL; size_t bufsize; - int iolen; + int iolen, n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, NULL); + assert(n >= 1 && n <= VTSCSI_MAXSEG); bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); buf_to_iov(buf + bufsize - iolen, iolen, iov, n, @@ -595,8 +596,8 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_request *req; struct iovec iov[VTSCSI_MAXSEG]; uint16_t flags[VTSCSI_MAXSEG]; - uint16_t idx, n, i; - int readable; + uint16_t idx, i; + int readable, n; sc = vsc; q = &sc->vss_queues[vq->vq_num - 2]; @@ -604,6 +605,7 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { readable = 0; n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, flags); + assert(n >= 1 && n <= VTSCSI_MAXSEG); /* Count readable descriptors */ for (i = 0; i < n; i++) { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC17B65DA39; Tue, 24 Aug 2021 18:29:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHh24FvVz3NNn; Tue, 24 Aug 2021 18:29:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C79F5541; Tue, 24 Aug 2021 18:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OITLfk024003; Tue, 24 Aug 2021 18:29:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITLmL024002; Tue, 24 Aug 2021 18:29:21 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:21 GMT Message-Id: <202108241829.17OITLmL024002@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 940681634ee1 - releng/13.0 - Add UPDATING entries and bump version. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 940681634ee17d12225ecd722c07fef1a0bde813 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:24 -0000 The branch releng/13.0 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=940681634ee17d12225ecd722c07fef1a0bde813 commit 940681634ee17d12225ecd722c07fef1a0bde813 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:23:29 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:23:29 +0000 Add UPDATING entries and bump version. Approved by: so --- UPDATING | 23 +++++++++++++++++++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index dcf580314337..804f8d7af263 100644 --- a/UPDATING +++ b/UPDATING @@ -11,6 +11,29 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +20210824: + 13.0-RELEASE-p4 FreeBSD-EN-21:23.virtio_blk + FreeBSD-EN-21:24.libcrypto + FreeBSD-EN-21:25.bhyve + FreeBSD-SA-21:13.bhyve + FreeBSD-SA-21:14.ggatec + FreeBSD-SA-21:15.libfetch + FreeBSD-SA-21:16.openssl + + Fix virtio_blk(4) failing to attach on some hypervisors. [EN-21:23.virtio_blk] + + Fix OpenSSL 1.1.1e API functions not being exported. [EN-21:24.libcrypto] + + Fix NVMe iovec construction for large IOs. [EN-21:25.bhyve] + + Fix missing error handling in bhyve(8) device models. [SA-21:13.bhyve] + + Fix remote code execution in ggatec(8). [SA-21:14.ggatec] + + Fix libfetch out of bounds read. [SA-21:15.libfetch] + + Fix multiple OpenSSL vulnerabilities. [SA-21:16.openssl] + 20210629: 13.0-RELEASE-p3 FreeBSD-EN-21:18.libc++ FreeBSD-EN-21:19.libcasper diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 5207dff32cb4..83b0c973bc13 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -54,7 +54,7 @@ TYPE="FreeBSD" REVISION="13.0" -BRANCH="RELEASE-p3" +BRANCH="RELEASE-p4" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 557BA65DC8E; Tue, 24 Aug 2021 18:29:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHhC0w8wz3NcW; Tue, 24 Aug 2021 18:29:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 015E85543; Tue, 24 Aug 2021 18:29:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OITUY8024186; Tue, 24 Aug 2021 18:29:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITUmt024185; Tue, 24 Aug 2021 18:29:30 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:30 GMT Message-Id: <202108241829.17OITUmt024185@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 01819b58294a - releng/12.2 - Fix OpenSSL 1.1.1e API functions not being exported. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 01819b58294a6d39b606d17a970f4a9fa5f73df8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:31 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=01819b58294a6d39b606d17a970f4a9fa5f73df8 commit 01819b58294a6d39b606d17a970f4a9fa5f73df8 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:27:05 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:27:05 +0000 Fix OpenSSL 1.1.1e API functions not being exported. Approved by: so Security: EN-21:24.libcrypto --- secure/lib/libcrypto/Version.map | 17 ++++++++++++++++- secure/lib/libssl/Version.map | 1 - 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/secure/lib/libcrypto/Version.map b/secure/lib/libcrypto/Version.map index 33432019a023..bed7623b9c47 100644 --- a/secure/lib/libcrypto/Version.map +++ b/secure/lib/libcrypto/Version.map @@ -4450,7 +4450,22 @@ OPENSSL_1_1_1d { global: X509_get0_authority_issuer; X509_get0_authority_serial; - local: *; } OPENSSL_1_1_1c; +OPENSSL_1_1_1e { + global: + EVP_PKEY_meth_get_digestsign; + EVP_PKEY_meth_get_digestverify; + EVP_PKEY_meth_set_digestsign; + EVP_PKEY_meth_set_digestverify; + RSA_get0_pss_params; +} OPENSSL_1_1_1d; +OPENSSL_1_1_1h { + global: + EC_KEY_decoded_from_explicit_params; + X509_ALGOR_copy; + X509_REQ_set0_signature; + X509_REQ_set1_signature_algo; + local: *; +} OPENSSL_1_1_1e; diff --git a/secure/lib/libssl/Version.map b/secure/lib/libssl/Version.map index 9011ff99d88d..118ac93966e3 100644 --- a/secure/lib/libssl/Version.map +++ b/secure/lib/libssl/Version.map @@ -512,5 +512,4 @@ OPENSSL_1_1_1 { OPENSSL_1_1_1a { global: SSL_get_signature_type_nid; - local: *; } OPENSSL_1_1_1; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6011E65DAE2; Tue, 24 Aug 2021 18:29: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 4GvHhH3WvDz3NPH; Tue, 24 Aug 2021 18:29: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 5AAE459C4; Tue, 24 Aug 2021 18:29: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 17OITYt1024265; Tue, 24 Aug 2021 18:29:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITYqu024264; Tue, 24 Aug 2021 18:29:34 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:34 GMT Message-Id: <202108241829.17OITYqu024264@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 14ba78b3f877 - releng/12.2 - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 14ba78b3f877a3e48cbec029444fbb34c30f5a15 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:36 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=14ba78b3f877a3e48cbec029444fbb34c30f5a15 commit 14ba78b3f877a3e48cbec029444fbb34c30f5a15 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:40:19 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:40:19 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index a2aa49e2b362..deff5e3a756a 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -144,7 +144,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -217,6 +231,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9CAA465DB20; Tue, 24 Aug 2021 18:29: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 4GvHhD2Pgzz3NZL; Tue, 24 Aug 2021 18:29: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 0DC2756C8; Tue, 24 Aug 2021 18:29: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 17OITVH4024217; Tue, 24 Aug 2021 18:29:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITVP4024216; Tue, 24 Aug 2021 18:29:31 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:31 GMT Message-Id: <202108241829.17OITVP4024216@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 0fe77ad6131b - releng/12.2 - Fix NVMe iovec construction for large IOs. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 0fe77ad6131bcb92268d52c38b81cbc1cb6f213f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:33 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=0fe77ad6131bcb92268d52c38b81cbc1cb6f213f commit 0fe77ad6131bcb92268d52c38b81cbc1cb6f213f Author: Gordon Tetlow AuthorDate: 2021-08-24 17:28:37 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:28:37 +0000 Fix NVMe iovec construction for large IOs. Approved by: so Security: EN-21:25.bhyve --- usr.sbin/bhyve/pci_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index 0d95a702124e..189e8a3d8522 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -1968,7 +1968,7 @@ nvme_write_read_blockif(struct pci_nvme_softc *sc, /* PRP2 is pointer to a physical region page list */ while (bytes) { /* Last entry in list points to the next list */ - if (prp_list == last) { + if ((prp_list == last) && (bytes > PAGE_SIZE)) { uint64_t prp = *prp_list; prp_list = paddr_guest2host(vmctx, prp, From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4E31C65DB27; Tue, 24 Aug 2021 18:29: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 4GvHhF4xpsz3NlK; Tue, 24 Aug 2021 18:29: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 390D55945; Tue, 24 Aug 2021 18:29: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 17OITXbE024241; Tue, 24 Aug 2021 18:29:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITX0T024240; Tue, 24 Aug 2021 18:29:33 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:33 GMT Message-Id: <202108241829.17OITX0T024240@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: b6dad073f555 - releng/12.2 - Fix missing error handling in bhyve(8) device models. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: b6dad073f555953f0c368e6a61fe24f44bdffc66 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:34 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=b6dad073f555953f0c368e6a61fe24f44bdffc66 commit b6dad073f555953f0c368e6a61fe24f44bdffc66 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:34:36 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:34:36 +0000 Fix missing error handling in bhyve(8) device models. Approved by: so Security: SA-21:13.bhyve Security: CVE-2021-29631 --- usr.sbin/bhyve/pci_virtio_console.c | 7 ++++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- usr.sbin/bhyve/pci_virtio_scsi.c | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index baec5534142a..d0567fe964a8 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -418,6 +418,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -558,7 +559,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &idx, &iov, 1, NULL); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -577,7 +577,8 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_softc *sc; struct pci_vtcon_port *port; struct iovec iov[1]; - uint16_t idx, n; + int n; + uint16_t idx; uint16_t flags[8]; sc = vsc; @@ -585,7 +586,7 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, 1, flags); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 4f908324cfa9..738bab7f6d48 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -113,7 +113,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) { struct iovec iov; struct pci_vtrnd_softc *sc; - int len; + int len, n; uint16_t idx; sc = vsc; @@ -124,7 +124,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &idx, &iov, 1, NULL); + n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index 04c5302f501f..0c2342134b3d 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -556,15 +556,16 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) { struct pci_vtscsi_softc *sc; struct iovec iov[VTSCSI_MAXSEG]; - uint16_t idx, n; + uint16_t idx; void *buf = NULL; size_t bufsize; - int iolen; + int iolen, n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, NULL); + assert(n >= 1 && n <= VTSCSI_MAXSEG); bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); buf_to_iov(buf + bufsize - iolen, iolen, iov, n, @@ -594,8 +595,8 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_request *req; struct iovec iov[VTSCSI_MAXSEG]; uint16_t flags[VTSCSI_MAXSEG]; - uint16_t idx, n, i; - int readable; + uint16_t idx, i; + int readable, n; sc = vsc; q = &sc->vss_queues[vq->vq_num - 2]; @@ -603,6 +604,7 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { readable = 0; n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, flags); + assert(n >= 1 && n <= VTSCSI_MAXSEG); /* Count readable descriptors */ for (i = 0; i < n; i++) { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 354E565DA69; Tue, 24 Aug 2021 18:29: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 4GvHhJ5CgTz3NlT; Tue, 24 Aug 2021 18:29: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 796D25663; Tue, 24 Aug 2021 18:29: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 17OITZSQ024289; Tue, 24 Aug 2021 18:29:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITZOa024288; Tue, 24 Aug 2021 18:29:35 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:35 GMT Message-Id: <202108241829.17OITZOa024288@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 9dc80086cde1 - releng/12.2 - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 9dc80086cde19485df8947439a12987f56a26c60 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:37 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=9dc80086cde19485df8947439a12987f56a26c60 commit 9dc80086cde19485df8947439a12987f56a26c60 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:02:27 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:02:27 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 72165d63fd19..334f9a0ac885 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -704,8 +704,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E0B8165DD80; Tue, 24 Aug 2021 18:29: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 4GvHhL0W8tz3NjD; Tue, 24 Aug 2021 18:29: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 9DDAF582A; Tue, 24 Aug 2021 18:29: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 17OITatf024313; Tue, 24 Aug 2021 18:29:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITaQi024312; Tue, 24 Aug 2021 18:29:36 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:36 GMT Message-Id: <202108241829.17OITaQi024312@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 9faa0bc4fade - releng/12.2 - Fix multiple OpenSSL vulnerabilities. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 9faa0bc4fadeb52b1bab3ed134cca3ccd8524456 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:39 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=9faa0bc4fadeb52b1bab3ed134cca3ccd8524456 commit 9faa0bc4fadeb52b1bab3ed134cca3ccd8524456 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:08:20 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:08:20 +0000 Fix multiple OpenSSL vulnerabilities. Approved by: so Security: SA-21:16.openssl Security: CVE-2021-3711 Security: CVE-2021-3712 --- crypto/openssl/crypto/asn1/asn1_lib.c | 12 ++++- crypto/openssl/crypto/asn1/t_spki.c | 2 +- crypto/openssl/crypto/ec/ec_asn1.c | 5 +- crypto/openssl/crypto/sm2/sm2_crypt.c | 27 +++++------ crypto/openssl/crypto/sm2/sm2_pmeth.c | 2 +- crypto/openssl/crypto/x509v3/v3_akey.c | 38 +++++++++++++-- crypto/openssl/crypto/x509v3/v3_alt.c | 10 ++-- crypto/openssl/crypto/x509v3/v3_cpols.c | 9 ++-- crypto/openssl/crypto/x509v3/v3_ncons.c | 77 +++++++++++++++++++++---------- crypto/openssl/crypto/x509v3/v3_pci.c | 3 +- crypto/openssl/crypto/x509v3/v3_utl.c | 53 ++++++++++++++++----- crypto/openssl/include/crypto/sm2.h | 3 +- crypto/openssl/include/crypto/x509.h | 5 ++ crypto/openssl/include/openssl/opensslv.h | 2 +- 14 files changed, 177 insertions(+), 71 deletions(-) diff --git a/crypto/openssl/crypto/asn1/asn1_lib.c b/crypto/openssl/crypto/asn1/asn1_lib.c index 366afc5f6c6b..8e62f3307443 100644 --- a/crypto/openssl/crypto/asn1/asn1_lib.c +++ b/crypto/openssl/crypto/asn1/asn1_lib.c @@ -292,7 +292,12 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) } if ((size_t)str->length <= len || str->data == NULL) { c = str->data; +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* No NUL terminator in fuzzing builds */ + str->data = OPENSSL_realloc(c, len); +#else str->data = OPENSSL_realloc(c, len + 1); +#endif if (str->data == NULL) { ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); str->data = c; @@ -302,8 +307,13 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) str->length = len; if (data != NULL) { memcpy(str->data, data, len); - /* an allowance for strings :-) */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* + * Add a NUL terminator. This should not be necessary - but we add it as + * a safety precaution + */ str->data[len] = '\0'; +#endif } return 1; } diff --git a/crypto/openssl/crypto/asn1/t_spki.c b/crypto/openssl/crypto/asn1/t_spki.c index 51b56d0aa9f7..64ee77eeecba 100644 --- a/crypto/openssl/crypto/asn1/t_spki.c +++ b/crypto/openssl/crypto/asn1/t_spki.c @@ -38,7 +38,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) } chal = spki->spkac->challenge; if (chal->length) - BIO_printf(out, " Challenge String: %s\n", chal->data); + BIO_printf(out, " Challenge String: %.*s\n", chal->length, chal->data); i = OBJ_obj2nid(spki->sig_algor.algorithm); BIO_printf(out, " Signature Algorithm: %s", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); diff --git a/crypto/openssl/crypto/ec/ec_asn1.c b/crypto/openssl/crypto/ec/ec_asn1.c index 7b7c75ce8443..e497a259095d 100644 --- a/crypto/openssl/crypto/ec/ec_asn1.c +++ b/crypto/openssl/crypto/ec/ec_asn1.c @@ -761,7 +761,10 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) ret->seed_len = params->curve->seed->length; } - if (!params->order || !params->base || !params->base->data) { + if (params->order == NULL + || params->base == NULL + || params->base->data == NULL + || params->base->length == 0) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } diff --git a/crypto/openssl/crypto/sm2/sm2_crypt.c b/crypto/openssl/crypto/sm2/sm2_crypt.c index ef505f64412b..00055a4e510e 100644 --- a/crypto/openssl/crypto/sm2/sm2_crypt.c +++ b/crypto/openssl/crypto/sm2/sm2_crypt.c @@ -61,29 +61,20 @@ static size_t ec_field_size(const EC_GROUP *group) return field_size; } -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size) +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size) { - const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); - const int md_size = EVP_MD_size(digest); - size_t overhead; + struct SM2_Ciphertext_st *sm2_ctext = NULL; - if (md_size < 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_DIGEST); - return 0; - } - if (field_size == 0) { - SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_FIELD); - return 0; - } + sm2_ctext = d2i_SM2_Ciphertext(NULL, &ct, ct_size); - overhead = 10 + 2 * field_size + (size_t)md_size; - if (msg_len <= overhead) { + if (sm2_ctext == NULL) { SM2err(SM2_F_SM2_PLAINTEXT_SIZE, SM2_R_INVALID_ENCODING); return 0; } - *pt_size = msg_len - overhead; + *pt_size = sm2_ctext->C2->length; + SM2_Ciphertext_free(sm2_ctext); + return 1; } @@ -303,6 +294,10 @@ int sm2_decrypt(const EC_KEY *key, C2 = sm2_ctext->C2->data; C3 = sm2_ctext->C3->data; msg_len = sm2_ctext->C2->length; + if (*ptext_len < (size_t)msg_len) { + SM2err(SM2_F_SM2_DECRYPT, SM2_R_BUFFER_TOO_SMALL); + goto done; + } ctx = BN_CTX_new(); if (ctx == NULL) { diff --git a/crypto/openssl/crypto/sm2/sm2_pmeth.c b/crypto/openssl/crypto/sm2/sm2_pmeth.c index b42a14c32f26..27025fbf3a2c 100644 --- a/crypto/openssl/crypto/sm2/sm2_pmeth.c +++ b/crypto/openssl/crypto/sm2/sm2_pmeth.c @@ -151,7 +151,7 @@ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { - if (!sm2_plaintext_size(ec, md, inlen, outlen)) + if (!sm2_plaintext_size(in, inlen, outlen)) return -1; else return 1; diff --git a/crypto/openssl/crypto/x509v3/v3_akey.c b/crypto/openssl/crypto/x509v3/v3_akey.c index d9f770433cfb..f917142223b7 100644 --- a/crypto/openssl/crypto/x509v3/v3_akey.c +++ b/crypto/openssl/crypto/x509v3/v3_akey.c @@ -39,20 +39,48 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, STACK_OF(CONF_VALUE) *extlist) { - char *tmp; + char *tmp = NULL; + STACK_OF(CONF_VALUE) *origextlist = extlist, *tmpextlist; + if (akeyid->keyid) { tmp = OPENSSL_buf2hexstr(akeyid->keyid->data, akeyid->keyid->length); - X509V3_add_value("keyid", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + return NULL; + } + if (!X509V3_add_value("keyid", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } - if (akeyid->issuer) - extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (akeyid->issuer) { + tmpextlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); + if (tmpextlist == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } + extlist = tmpextlist; + } if (akeyid->serial) { tmp = OPENSSL_buf2hexstr(akeyid->serial->data, akeyid->serial->length); - X509V3_add_value("serial", tmp, &extlist); + if (tmp == NULL) { + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!X509V3_add_value("serial", tmp, &extlist)) { + OPENSSL_free(tmp); + X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_X509_LIB); + goto err; + } OPENSSL_free(tmp); } return extlist; + err: + if (origextlist == NULL) + sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free); + return NULL; } /*- diff --git a/crypto/openssl/crypto/x509v3/v3_alt.c b/crypto/openssl/crypto/x509v3/v3_alt.c index 4dce0041012e..6e5f9f8b0eac 100644 --- a/crypto/openssl/crypto/x509v3/v3_alt.c +++ b/crypto/openssl/crypto/x509v3/v3_alt.c @@ -9,6 +9,7 @@ #include #include "internal/cryptlib.h" +#include "crypto/x509.h" #include #include #include "ext_dat.h" @@ -99,17 +100,20 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, break; case GEN_EMAIL: - if (!X509V3_add_value_uchar("email", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("email", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_DNS: - if (!X509V3_add_value_uchar("DNS", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("DNS", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; case GEN_URI: - if (!X509V3_add_value_uchar("URI", gen->d.ia5->data, &ret)) + if (!x509v3_add_len_value_uchar("URI", gen->d.ia5->data, + gen->d.ia5->length, &ret)) return NULL; break; diff --git a/crypto/openssl/crypto/x509v3/v3_cpols.c b/crypto/openssl/crypto/x509v3/v3_cpols.c index 1d12c899125c..861e8455dd08 100644 --- a/crypto/openssl/crypto/x509v3/v3_cpols.c +++ b/crypto/openssl/crypto/x509v3/v3_cpols.c @@ -422,7 +422,8 @@ static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, qualinfo = sk_POLICYQUALINFO_value(quals, i); switch (OBJ_obj2nid(qualinfo->pqualid)) { case NID_id_qt_cps: - BIO_printf(out, "%*sCPS: %s\n", indent, "", + BIO_printf(out, "%*sCPS: %.*s\n", indent, "", + qualinfo->d.cpsuri->length, qualinfo->d.cpsuri->data); break; @@ -447,7 +448,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) if (notice->noticeref) { NOTICEREF *ref; ref = notice->noticeref; - BIO_printf(out, "%*sOrganization: %s\n", indent, "", + BIO_printf(out, "%*sOrganization: %.*s\n", indent, "", + ref->organization->length, ref->organization->data); BIO_printf(out, "%*sNumber%s: ", indent, "", sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); @@ -470,7 +472,8 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent) BIO_puts(out, "\n"); } if (notice->exptext) - BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", + BIO_printf(out, "%*sExplicit Text: %.*s\n", indent, "", + notice->exptext->length, notice->exptext->data); } diff --git a/crypto/openssl/crypto/x509v3/v3_ncons.c b/crypto/openssl/crypto/x509v3/v3_ncons.c index 2a7b4f0992a8..cb701c4d844b 100644 --- a/crypto/openssl/crypto/x509v3/v3_ncons.c +++ b/crypto/openssl/crypto/x509v3/v3_ncons.c @@ -63,8 +63,31 @@ ASN1_SEQUENCE(NAME_CONSTRAINTS) = { IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +#define IA5_OFFSET_LEN(ia5base, offset) \ + ((ia5base)->length - ((unsigned char *)(offset) - (ia5base)->data)) + +/* Like memchr but for ASN1_IA5STRING. Additionally you can specify the + * starting point to search from + */ +# define ia5memchr(str, start, c) memchr(start, c, IA5_OFFSET_LEN(str, start)) + +/* Like memrrchr but for ASN1_IA5STRING */ +static char *ia5memrchr(ASN1_IA5STRING *str, int c) +{ + int i; + + for (i = str->length; i > 0 && str->data[i - 1] != c; i--); + + if (i == 0) + return NULL; + + return (char *)&str->data[i - 1]; +} + /* - * We cannot use strncasecmp here because that applies locale specific rules. + * We cannot use strncasecmp here because that applies locale specific rules. It + * also doesn't work with ASN1_STRINGs that may have embedded NUL characters. * For example in Turkish 'I' is not the uppercase character for 'i'. We need to * do a simple ASCII case comparison ignoring the locale (that is why we use * numeric constants below). @@ -89,20 +112,12 @@ static int ia5ncasecmp(const char *s1, const char *s2, size_t n) /* c1 > c2 */ return 1; - } else if (*s1 == 0) { - /* If we get here we know that *s2 == 0 too */ - return 0; } } return 0; } -static int ia5casecmp(const char *s1, const char *s2) -{ - return ia5ncasecmp(s1, s2, SIZE_MAX); -} - static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { @@ -337,7 +352,7 @@ static int cn2dnsid(ASN1_STRING *cn, unsigned char **dnsid, size_t *idlen) --utf8_length; /* Reject *embedded* NULs */ - if ((size_t)utf8_length != strlen((char *)utf8_value)) { + if (memchr(utf8_value, 0, utf8_length) != NULL) { OPENSSL_free(utf8_value); return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; } @@ -536,9 +551,14 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; + /* Empty matches everything */ - if (!*baseptr) + if (base->length == 0) return X509_V_OK; + + if (dns->length < base->length) + return X509_V_ERR_PERMITTED_VIOLATION; + /* * Otherwise can add zero or more components on the left so compare RHS * and if dns is longer and expect '.' as preceding character. @@ -549,7 +569,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) return X509_V_ERR_PERMITTED_VIOLATION; } - if (ia5casecmp(baseptr, dnsptr)) + if (ia5ncasecmp(baseptr, dnsptr, base->length)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -560,16 +580,17 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *emlptr = (char *)eml->data; + const char *baseat = ia5memrchr(base, '@'); + const char *emlat = ia5memrchr(eml, '@'); + size_t basehostlen, emlhostlen; - const char *baseat = strchr(baseptr, '@'); - const char *emlat = strchr(emlptr, '@'); if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (!baseat && (*baseptr == '.')) { + if (!baseat && base->length > 0 && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; - if (ia5casecmp(baseptr, emlptr) == 0) + if (ia5ncasecmp(baseptr, emlptr, base->length) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; @@ -589,8 +610,10 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) baseptr = baseat + 1; } emlptr = emlat + 1; + basehostlen = IA5_OFFSET_LEN(base, baseptr); + emlhostlen = IA5_OFFSET_LEN(eml, emlptr); /* Just have hostname left to match: case insensitive */ - if (ia5casecmp(baseptr, emlptr)) + if (basehostlen != emlhostlen || ia5ncasecmp(baseptr, emlptr, emlhostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -601,10 +624,14 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *hostptr = (char *)uri->data; - const char *p = strchr(hostptr, ':'); + const char *p = ia5memchr(uri, (char *)uri->data, ':'); int hostlen; + /* Check for foo:// and skip past it */ - if (!p || (p[1] != '/') || (p[2] != '/')) + if (p == NULL + || IA5_OFFSET_LEN(uri, p) < 3 + || p[1] != '/' + || p[2] != '/') return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; @@ -612,13 +639,13 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) /* Look for a port indicator as end of hostname first */ - p = strchr(hostptr, ':'); + p = ia5memchr(uri, hostptr, ':'); /* Otherwise look for trailing slash */ - if (!p) - p = strchr(hostptr, '/'); + if (p == NULL) + p = ia5memchr(uri, hostptr, '/'); - if (!p) - hostlen = strlen(hostptr); + if (p == NULL) + hostlen = IA5_OFFSET_LEN(uri, hostptr); else hostlen = p - hostptr; @@ -626,7 +653,7 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: initial '.' is RHS match */ - if (*baseptr == '.') { + if (base->length > 0 && *baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; if (ia5ncasecmp(p, baseptr, base->length) == 0) diff --git a/crypto/openssl/crypto/x509v3/v3_pci.c b/crypto/openssl/crypto/x509v3/v3_pci.c index 3d124fa6d95d..98b6ef25e280 100644 --- a/crypto/openssl/crypto/x509v3/v3_pci.c +++ b/crypto/openssl/crypto/x509v3/v3_pci.c @@ -77,7 +77,8 @@ static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); BIO_puts(out, "\n"); if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) - BIO_printf(out, "%*sPolicy Text: %s\n", indent, "", + BIO_printf(out, "%*sPolicy Text: %.*s\n", indent, "", + pci->proxyPolicy->policy->length, pci->proxyPolicy->policy->data); return 1; } diff --git a/crypto/openssl/crypto/x509v3/v3_utl.c b/crypto/openssl/crypto/x509v3/v3_utl.c index 7281a7b917a8..706dd22ffaba 100644 --- a/crypto/openssl/crypto/x509v3/v3_utl.c +++ b/crypto/openssl/crypto/x509v3/v3_utl.c @@ -12,6 +12,7 @@ #include "e_os.h" #include "internal/cryptlib.h" #include +#include #include "crypto/ctype.h" #include #include @@ -34,17 +35,23 @@ static int ipv6_hex(unsigned char *out, const char *in, int inlen); /* Add a CONF_VALUE name value pair to stack */ -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist) +static int x509v3_add_len_value(const char *name, const char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; int sk_allocated = (*extlist == NULL); - if (name && (tname = OPENSSL_strdup(name)) == NULL) - goto err; - if (value && (tvalue = OPENSSL_strdup(value)) == NULL) + if (name != NULL && (tname = OPENSSL_strdup(name)) == NULL) goto err; + if (value != NULL) { + /* We don't allow embeded NUL characters */ + if (memchr(value, 0, vallen) != NULL) + goto err; + tvalue = OPENSSL_strndup(value, vallen); + if (tvalue == NULL) + goto err; + } if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; if (sk_allocated && (*extlist = sk_CONF_VALUE_new_null()) == NULL) @@ -67,10 +74,26 @@ int X509V3_add_value(const char *name, const char *value, return 0; } +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist) { - return X509V3_add_value(name, (const char *)value, extlist); + return x509v3_add_len_value(name, (const char *)value, + value != NULL ? strlen((const char *)value) : 0, + extlist); +} + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist) +{ + return x509v3_add_len_value(name, (const char *)value, vallen, extlist); } /* Free function for STACK_OF(CONF_VALUE) */ @@ -502,18 +525,26 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email /* First some sanity checks */ if (email->type != V_ASN1_IA5STRING) return 1; - if (!email->data || !email->length) + if (email->data == NULL || email->length == 0) + return 1; + if (memchr(email->data, 0, email->length) != NULL) return 1; if (*sk == NULL) *sk = sk_OPENSSL_STRING_new(sk_strcmp); if (*sk == NULL) return 0; + + emtmp = OPENSSL_strndup((char *)email->data, email->length); + if (emtmp == NULL) + return 0; + /* Don't add duplicates */ - if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) + if (sk_OPENSSL_STRING_find(*sk, emtmp) != -1) { + OPENSSL_free(emtmp); return 1; - emtmp = OPENSSL_strdup((char *)email->data); - if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) { - OPENSSL_free(emtmp); /* free on push failure */ + } + if (!sk_OPENSSL_STRING_push(*sk, emtmp)) { + OPENSSL_free(emtmp); /* free on push failure */ X509_email_free(*sk); *sk = NULL; return 0; diff --git a/crypto/openssl/include/crypto/sm2.h b/crypto/openssl/include/crypto/sm2.h index 76ee80baff19..50851a83cea2 100644 --- a/crypto/openssl/include/crypto/sm2.h +++ b/crypto/openssl/include/crypto/sm2.h @@ -60,8 +60,7 @@ int sm2_verify(const unsigned char *dgst, int dgstlen, int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, size_t *ct_size); -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size); +int sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size); int sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, diff --git a/crypto/openssl/include/crypto/x509.h b/crypto/openssl/include/crypto/x509.h index b53c2b03c39e..7ffb8abfe71b 100644 --- a/crypto/openssl/include/crypto/x509.h +++ b/crypto/openssl/include/crypto/x509.h @@ -8,6 +8,8 @@ */ #include "internal/refcount.h" +#include +#include /* Internal X509 structures and functions: not for application use */ @@ -284,3 +286,6 @@ int a2i_ipadd(unsigned char *ipout, const char *ipasc); int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); void x509_init_sig_info(X509 *x); + +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) **extlist); diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h index 68f715fe6164..e384f741e5bd 100644 --- a/crypto/openssl/include/openssl/opensslv.h +++ b/crypto/openssl/include/openssl/opensslv.h @@ -40,7 +40,7 @@ extern "C" { * major minor fix final patch/beta) */ # define OPENSSL_VERSION_NUMBER 0x1010108fL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1h-freebsd 22 Sep 2020" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1h-freebsd 24 Aug 2021" /*- * The macros below are to be used for shared library (.so, .dll, ...) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B602E65DB3B; Tue, 24 Aug 2021 18:29: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 4GvHhL70Ydz3NfX; Tue, 24 Aug 2021 18:29: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 C8A6556C9; Tue, 24 Aug 2021 18:29: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 17OITbSO024343; Tue, 24 Aug 2021 18:29:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITbvS024342; Tue, 24 Aug 2021 18:29:37 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:37 GMT Message-Id: <202108241829.17OITbvS024342@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 895e0245469d - releng/12.2 - Fix multiple vulnerabilities in OpenSSL. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 895e0245469d0d3a267d2685f27d97532c461520 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:40 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=895e0245469d0d3a267d2685f27d97532c461520 commit 895e0245469d0d3a267d2685f27d97532c461520 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:09:09 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:09:09 +0000 Fix multiple vulnerabilities in OpenSSL. Approved by: so Security: SA-21:17.openssl Security: CVE-2021-23840 Security: CVE-2021-23841 --- crypto/openssl/crypto/err/openssl.txt | 3 ++- crypto/openssl/crypto/evp/evp_enc.c | 27 +++++++++++++++++++++++++++ crypto/openssl/crypto/evp/evp_err.c | 4 +++- crypto/openssl/crypto/x509/x509_cmp.c | 2 ++ crypto/openssl/include/openssl/evperr.h | 7 +++---- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/crypto/openssl/crypto/err/openssl.txt b/crypto/openssl/crypto/err/openssl.txt index 815460b24f67..7e1776375df7 100644 --- a/crypto/openssl/crypto/err/openssl.txt +++ b/crypto/openssl/crypto/err/openssl.txt @@ -1,4 +1,4 @@ -# Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 1999-2021 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 @@ -2283,6 +2283,7 @@ EVP_R_ONLY_ONESHOT_SUPPORTED:177:only oneshot supported EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE:150:\ operation not supported for this keytype EVP_R_OPERATON_NOT_INITIALIZED:151:operaton not initialized +EVP_R_OUTPUT_WOULD_OVERFLOW:184:output would overflow EVP_R_PARTIALLY_OVERLAPPING:162:partially overlapping buffers EVP_R_PBKDF2_ERROR:181:pbkdf2 error EVP_R_PKEY_APPLICATION_ASN1_METHOD_ALREADY_REGISTERED:179:\ diff --git a/crypto/openssl/crypto/evp/evp_enc.c b/crypto/openssl/crypto/evp/evp_enc.c index b9b6490fe069..0843caf4f0a4 100644 --- a/crypto/openssl/crypto/evp/evp_enc.c +++ b/crypto/openssl/crypto/evp/evp_enc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include "internal/cryptlib.h" #include @@ -355,6 +356,19 @@ static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx, return 1; } else { j = bl - i; + + /* + * Once we've processed the first j bytes from in, the amount of + * data left that is a multiple of the block length is: + * (inl - j) & ~(bl - 1) + * We must ensure that this amount of data, plus the one block that + * we process from ctx->buf does not exceed INT_MAX + */ + if (((inl - j) & ~(bl - 1)) > INT_MAX - bl) { + EVPerr(EVP_F_EVP_ENCRYPTDECRYPTUPDATE, + EVP_R_OUTPUT_WOULD_OVERFLOW); + return 0; + } memcpy(&(ctx->buf[i]), in, j); inl -= j; in += j; @@ -502,6 +516,19 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING); return 0; } + /* + * final_used is only ever set if buf_len is 0. Therefore the maximum + * length output we will ever see from evp_EncryptDecryptUpdate is + * the maximum multiple of the block length that is <= inl, or just: + * inl & ~(b - 1) + * Since final_used has been set then the final output length is: + * (inl & ~(b - 1)) + b + * This must never exceed INT_MAX + */ + if ((inl & ~(b - 1)) > INT_MAX - b) { + EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_OUTPUT_WOULD_OVERFLOW); + return 0; + } memcpy(out, ctx->final, b); out += b; fix_len = 1; diff --git a/crypto/openssl/crypto/evp/evp_err.c b/crypto/openssl/crypto/evp/evp_err.c index 05481d827fb4..32ac0125de24 100644 --- a/crypto/openssl/crypto/evp/evp_err.c +++ b/crypto/openssl/crypto/evp/evp_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2021 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 @@ -239,6 +239,8 @@ static const ERR_STRING_DATA EVP_str_reasons[] = { "operation not supported for this keytype"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_OPERATON_NOT_INITIALIZED), "operaton not initialized"}, + {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_OUTPUT_WOULD_OVERFLOW), + "output would overflow"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PARTIALLY_OVERLAPPING), "partially overlapping buffers"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PBKDF2_ERROR), "pbkdf2 error"}, diff --git a/crypto/openssl/crypto/x509/x509_cmp.c b/crypto/openssl/crypto/x509/x509_cmp.c index d1600e1e8dda..99920e2997a9 100644 --- a/crypto/openssl/crypto/x509/x509_cmp.c +++ b/crypto/openssl/crypto/x509/x509_cmp.c @@ -39,6 +39,8 @@ unsigned long X509_issuer_and_serial_hash(X509 *a) if (ctx == NULL) goto err; f = X509_NAME_oneline(a->cert_info.issuer, NULL, 0); + if (f == NULL) + goto err; if (!EVP_DigestInit_ex(ctx, EVP_md5(), NULL)) goto err; if (!EVP_DigestUpdate(ctx, (unsigned char *)f, strlen(f))) diff --git a/crypto/openssl/include/openssl/evperr.h b/crypto/openssl/include/openssl/evperr.h index d2b26ea582de..b4ea90ae9df3 100644 --- a/crypto/openssl/include/openssl/evperr.h +++ b/crypto/openssl/include/openssl/evperr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2021 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 @@ -11,9 +11,7 @@ #ifndef HEADER_EVPERR_H # define HEADER_EVPERR_H -# ifndef HEADER_SYMHACKS_H -# include -# endif +# include # ifdef __cplusplus extern "C" @@ -179,6 +177,7 @@ int ERR_load_EVP_strings(void); # define EVP_R_ONLY_ONESHOT_SUPPORTED 177 # define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150 # define EVP_R_OPERATON_NOT_INITIALIZED 151 +# define EVP_R_OUTPUT_WOULD_OVERFLOW 184 # define EVP_R_PARTIALLY_OVERLAPPING 162 # define EVP_R_PBKDF2_ERROR 181 # define EVP_R_PKEY_APPLICATION_ASN1_METHOD_ALREADY_REGISTERED 179 From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A34BF65DC24; Tue, 24 Aug 2021 18:29: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 4GvHhM5HGTz3NVB; Tue, 24 Aug 2021 18:29:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E4E6E5664; Tue, 24 Aug 2021 18:29: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 17OITc6v024367; Tue, 24 Aug 2021 18:29:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITcGX024366; Tue, 24 Aug 2021 18:29:38 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:38 GMT Message-Id: <202108241829.17OITcGX024366@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 12803d8a99c5 - releng/12.2 - Add UPDATING entries and bump version MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 12803d8a99c563b18a340c5154b36d6d567bff9e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:40 -0000 The branch releng/12.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=12803d8a99c563b18a340c5154b36d6d567bff9e commit 12803d8a99c563b18a340c5154b36d6d567bff9e Author: Gordon Tetlow AuthorDate: 2021-08-24 18:19:55 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:19:55 +0000 Add UPDATING entries and bump version Approved by: so --- UPDATING | 22 ++++++++++++++++++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index 6cdcd8aa554d..d3ee5af37087 100644 --- a/UPDATING +++ b/UPDATING @@ -16,6 +16,28 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20210824: p10 FreeBSD-EN-21:24.libcrypto + FreeBSD-EN-21:25.bhyve + FreeBSD-SA-21:13.bhyve + FreeBSD-SA-21:14.ggatec + FreeBSD-SA-21:15.libfetch + FreeBSD-SA-21:16.openssl + FreeBSD-SA-21:17.openssl + + Fix OpenSSL 1.1.1e API functions not being exported. [EN-21:24.libcrypto] + + Fix NVMe iovec construction for large IOs. [EN-21:25.bhyve] + + Fix missing error handling in bhyve(8) device models. [SA-21:13.bhyve] + + Fix remote code execution in ggatec(8). [SA-21:14.ggatec] + + Fix libfetch out of bounds read. [SA-21:15.libfetch] + + Fix multiple OpenSSL vulnerabilities. [SA-21:16.openssl] + + Fix multiple vulnerabilities in OpenSSL. [SA-21:17.openssl] + 20210629: p9 FreeBSD-EN-21:19.libcasper FreeBSD-EN-21:22.linux_futex diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 460c80a4a0e0..df86d0be3b91 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -49,7 +49,7 @@ TYPE="FreeBSD" REVISION="12.2" -BRANCH="RELEASE-p9" +BRANCH="RELEASE-p10" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DBF2E65DBF1; Tue, 24 Aug 2021 18:29: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 4GvHhZ03Dsz3NdP; Tue, 24 Aug 2021 18:29: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 907E05AF0; Tue, 24 Aug 2021 18:29: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 17OITnIN024544; Tue, 24 Aug 2021 18:29:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITnXM024543; Tue, 24 Aug 2021 18:29:49 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:49 GMT Message-Id: <202108241829.17OITnXM024543@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: a7db88b5db58 - releng/11.4 - Fix missing error handling in bhyve(8) device models. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: a7db88b5db5817a806a38800c615b7755a3e6b34 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:51 -0000 The branch releng/11.4 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=a7db88b5db5817a806a38800c615b7755a3e6b34 commit a7db88b5db5817a806a38800c615b7755a3e6b34 Author: Gordon Tetlow AuthorDate: 2021-08-24 17:34:59 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:34:59 +0000 Fix missing error handling in bhyve(8) device models. Approved by: so Security: SA-21:13.bhyve Security: CVE-2021-29631 --- usr.sbin/bhyve/pci_virtio_console.c | 7 ++++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 13aa4ad30cca..73528a2e1476 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -404,6 +404,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -544,7 +545,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &idx, &iov, 1, NULL); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -563,7 +563,8 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_softc *sc; struct pci_vtcon_port *port; struct iovec iov[1]; - uint16_t idx, n; + int n; + uint16_t idx; uint16_t flags[8]; sc = vsc; @@ -571,7 +572,7 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, 1, flags); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 44bc55e0039e..5d2fac0c723a 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -109,7 +109,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) { struct iovec iov; struct pci_vtrnd_softc *sc; - int len; + int len, n; uint16_t idx; sc = vsc; @@ -120,7 +120,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &idx, &iov, 1, NULL); + n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 51F7365DDA2; Tue, 24 Aug 2021 18:29: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 4GvHhZ6v4Bz3NdX; Tue, 24 Aug 2021 18:29: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 AF8935544; Tue, 24 Aug 2021 18:29: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 17OIToOr024569; Tue, 24 Aug 2021 18:29:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITo4x024568; Tue, 24 Aug 2021 18:29:50 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:50 GMT Message-Id: <202108241829.17OITo4x024568@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 8fe0dbe59a7f - releng/11.4 - Fix remote code execution in ggatec(8). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: 8fe0dbe59a7fdf65997de99f60fc4f385408b14a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:51 -0000 The branch releng/11.4 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=8fe0dbe59a7fdf65997de99f60fc4f385408b14a commit 8fe0dbe59a7fdf65997de99f60fc4f385408b14a Author: Gordon Tetlow AuthorDate: 2021-08-24 17:40:25 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 17:40:25 +0000 Fix remote code execution in ggatec(8). Approved by: so Security: SA-21:14.ggatec Security: CVE-2021-29630 --- sbin/ggate/ggatec/ggatec.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index a2aa49e2b362..deff5e3a756a 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -144,7 +144,21 @@ send_thread(void *arg __unused) case BIO_WRITE: hdr.gh_cmd = GGATE_CMD_WRITE; break; + default: + g_gate_log(LOG_NOTICE, "Unknown gctl_cmd: %i", ggio.gctl_cmd); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; + } + + /* Don't send requests for more data than we can handle the response for! */ + if (ggio.gctl_length > MAXPHYS) { + g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); + ggio.gctl_error = EOPNOTSUPP; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + continue; } + hdr.gh_seq = ggio.gctl_seq; hdr.gh_offset = ggio.gctl_offset; hdr.gh_length = ggio.gctl_length; @@ -217,6 +231,12 @@ recv_thread(void *arg __unused) ggio.gctl_length = hdr.gh_length; ggio.gctl_error = hdr.gh_error; + /* Do not overflow our buffer if there is a bogus response. */ + if (ggio.gctl_length > (off_t) sizeof(buf)) { + g_gate_log(LOG_ERR, "Received too big response: %zd", ggio.gctl_length); + break; + } + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { data = g_gate_recv(recvfd, ggio.gctl_data, ggio.gctl_length, MSG_WAITALL); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5619165DB69; Tue, 24 Aug 2021 18: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 4GvHhc14FVz3Ndc; Tue, 24 Aug 2021 18:29: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 CC3E659C5; Tue, 24 Aug 2021 18:29: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 17OITp7J024593; Tue, 24 Aug 2021 18:29:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITps7024592; Tue, 24 Aug 2021 18:29:51 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:51 GMT Message-Id: <202108241829.17OITps7024592@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: fab38dac6506 - releng/11.4 - Fix libfetch out of bounds read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: fab38dac650664eb614ab28ff2535d97bec21e89 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:53 -0000 The branch releng/11.4 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=fab38dac650664eb614ab28ff2535d97bec21e89 commit fab38dac650664eb614ab28ff2535d97bec21e89 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:02:42 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:02:42 +0000 Fix libfetch out of bounds read. Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159 --- lib/libfetch/ftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index c034b5efa240..1755012fc99b 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -702,8 +702,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, goto ouch; } l = (e == FTP_PASSIVE_MODE ? 6 : 21); - for (i = 0; *p && i < l; i++, p++) + for (i = 0; *p && i < l; i++, p++) { addr[i] = strtol(p, &p, 10); + if (*p == '\0' && i < l - 1) + break; + } if (i < l) { e = FTP_PROTOCOL_ERROR; goto ouch; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08DAC65DD3A; Tue, 24 Aug 2021 18:29: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 4GvHhd18Ykz3NbY; Tue, 24 Aug 2021 18: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 EA6E959C6; Tue, 24 Aug 2021 18:29: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 17OITq5A024617; Tue, 24 Aug 2021 18:29:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OITqxo024616; Tue, 24 Aug 2021 18:29:52 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:52 GMT Message-Id: <202108241829.17OITqxo024616@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: eb5ad8d173c9 - releng/11.4 - Fix multiple vulnerabilities in OpenSSL. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: eb5ad8d173c9f01bd3d541ec2152f1285e4d1b51 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:54 -0000 The branch releng/11.4 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=eb5ad8d173c9f01bd3d541ec2152f1285e4d1b51 commit eb5ad8d173c9f01bd3d541ec2152f1285e4d1b51 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:11:12 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:11:12 +0000 Fix multiple vulnerabilities in OpenSSL. Approved by: so Security: SA-21:17.openssl Security: CVE-2021-23840 Security: CVE-2021-23841 --- crypto/openssl/crypto/evp/evp.h | 2 ++ crypto/openssl/crypto/evp/evp_enc.c | 27 +++++++++++++++++++++++++++ crypto/openssl/crypto/evp/evp_err.c | 4 +++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/crypto/openssl/crypto/evp/evp.h b/crypto/openssl/crypto/evp/evp.h index 883a9434899b..4ec0e25d07ac 100644 --- a/crypto/openssl/crypto/evp/evp.h +++ b/crypto/openssl/crypto/evp/evp.h @@ -1491,6 +1491,7 @@ void ERR_load_EVP_strings(void); # define EVP_F_EVP_DECRYPTFINAL_EX 101 # define EVP_F_EVP_DECRYPTUPDATE 181 # define EVP_F_EVP_DIGESTINIT_EX 128 +# define EVP_F_EVP_ENCRYPTDECRYPTUPDATE 182 # define EVP_F_EVP_ENCRYPTFINAL_EX 127 # define EVP_F_EVP_ENCRYPTUPDATE 180 # define EVP_F_EVP_MD_CTX_COPY_EX 110 @@ -1602,6 +1603,7 @@ void ERR_load_EVP_strings(void); # define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 # define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150 # define EVP_R_OPERATON_NOT_INITIALIZED 151 +# define EVP_R_OUTPUT_WOULD_OVERFLOW 172 # define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 # define EVP_R_PRIVATE_KEY_DECODE_ERROR 145 # define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146 diff --git a/crypto/openssl/crypto/evp/evp_enc.c b/crypto/openssl/crypto/evp/evp_enc.c index c63fb53ac85e..f392f6d01363 100644 --- a/crypto/openssl/crypto/evp/evp_enc.c +++ b/crypto/openssl/crypto/evp/evp_enc.c @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -357,6 +358,19 @@ static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx, return 1; } else { j = bl - i; + + /* + * Once we've processed the first j bytes from in, the amount of + * data left that is a multiple of the block length is: + * (inl - j) & ~(bl - 1) + * We must ensure that this amount of data, plus the one block that + * we process from ctx->buf does not exceed INT_MAX + */ + if (((inl - j) & ~(bl - 1)) > INT_MAX - bl) { + EVPerr(EVP_F_EVP_ENCRYPTDECRYPTUPDATE, + EVP_R_OUTPUT_WOULD_OVERFLOW); + return 0; + } memcpy(&(ctx->buf[i]), in, j); if (!M_do_cipher(ctx, out, ctx->buf, bl)) return 0; @@ -482,6 +496,19 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, OPENSSL_assert(b <= sizeof(ctx->final)); if (ctx->final_used) { + /* + * final_used is only ever set if buf_len is 0. Therefore the maximum + * length output we will ever see from evp_EncryptDecryptUpdate is + * the maximum multiple of the block length that is <= inl, or just: + * inl & ~(b - 1) + * Since final_used has been set then the final output length is: + * (inl & ~(b - 1)) + b + * This must never exceed INT_MAX + */ + if ((inl & ~(b - 1)) > INT_MAX - b) { + EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_OUTPUT_WOULD_OVERFLOW); + return 0; + } memcpy(out, ctx->final, b); out += b; fix_len = 1; diff --git a/crypto/openssl/crypto/evp/evp_err.c b/crypto/openssl/crypto/evp/evp_err.c index 11647b92c613..0b1e59ead606 100644 --- a/crypto/openssl/crypto/evp/evp_err.c +++ b/crypto/openssl/crypto/evp/evp_err.c @@ -1,6 +1,6 @@ /* crypto/evp/evp_err.c */ /* ==================================================================== - * Copyright (c) 1999-2019 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2021 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -94,6 +94,7 @@ static ERR_STRING_DATA EVP_str_functs[] = { {ERR_FUNC(EVP_F_EVP_DECRYPTFINAL_EX), "EVP_DecryptFinal_ex"}, {ERR_FUNC(EVP_F_EVP_DECRYPTUPDATE), "EVP_DecryptUpdate"}, {ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"}, + {ERR_FUNC(EVP_F_EVP_ENCRYPTDECRYPTUPDATE), "EVP_ENCRYPTDECRYPTUPDATE"}, {ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"}, {ERR_FUNC(EVP_F_EVP_ENCRYPTUPDATE), "EVP_EncryptUpdate"}, {ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"}, @@ -215,6 +216,7 @@ static ERR_STRING_DATA EVP_str_reasons[] = { {ERR_REASON(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE), "operation not supported for this keytype"}, {ERR_REASON(EVP_R_OPERATON_NOT_INITIALIZED), "operaton not initialized"}, + {ERR_REASON(EVP_R_OUTPUT_WOULD_OVERFLOW), "output would overflow"}, {ERR_REASON(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE), "pkcs8 unknown broken type"}, {ERR_REASON(EVP_R_PRIVATE_KEY_DECODE_ERROR), "private key decode error"}, From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:29:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4EB2A65DE87; Tue, 24 Aug 2021 18:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvHhg56Nsz3NpH; Tue, 24 Aug 2021 18:29: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 1A1BB5AF1; Tue, 24 Aug 2021 18:29:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17OITrbu024641; Tue, 24 Aug 2021 18: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 17OITrGJ024640; Tue, 24 Aug 2021 18:29:53 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:29:53 GMT Message-Id: <202108241829.17OITrGJ024640@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: d106002967ef - releng/11.4 - Add UPDATING entries and bump version. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: d106002967eff712894ab8b5337bbbff106ce5e0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:29:56 -0000 The branch releng/11.4 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=d106002967eff712894ab8b5337bbbff106ce5e0 commit d106002967eff712894ab8b5337bbbff106ce5e0 Author: Gordon Tetlow AuthorDate: 2021-08-24 18:16:00 +0000 Commit: Gordon Tetlow CommitDate: 2021-08-24 18:16:00 +0000 Add UPDATING entries and bump version. Approved by: so --- UPDATING | 13 +++++++++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index 39436624b2d7..f1bd6252cd01 100644 --- a/UPDATING +++ b/UPDATING @@ -16,6 +16,19 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20210824: p13 FreeBSD-SA-21:13.bhyve + FreeBSD-SA-21:14.ggatec + FreeBSD-SA-21:15.libfetch + FreeBSD-SA-21:17.openssl + + Fix missing error handling in bhyve(8) device models. [SA-21:13.bhyve] + + Fix remote code execution in ggatec(8). [SA-21:14.ggatec] + + Fix libfetch out of bounds read. [SA-21:15.libfetch] + + Fix multiple vulnerabilities in OpenSSL. [SA-21:17.openssl] + 20210629: p12 FreeBSD-EN-21:19.libcasper FreeBSD-EN-21:22.linux_futex diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index fd228bf9ad03..21296d4fb0cd 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -44,7 +44,7 @@ TYPE="FreeBSD" REVISION="11.4" -BRANCH="RELEASE-p12" +BRANCH="RELEASE-p13" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:32:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A156365E7AF; Tue, 24 Aug 2021 18:32: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 4GvHlM3HXTz3Q3t; Tue, 24 Aug 2021 18:32: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 5716D5B9F; Tue, 24 Aug 2021 18:32: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 17OIWFT4037218; Tue, 24 Aug 2021 18:32:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIWFjZ037217; Tue, 24 Aug 2021 18:32:15 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:32:15 GMT Message-Id: <202108241832.17OIWFjZ037217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 71fbc6faed62 - main - bhyve: Fix vq_getchain() error handling bugs in various device models MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71fbc6faed62e8eb5864f7c40839740f5e9f5558 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:32:15 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71fbc6faed62e8eb5864f7c40839740f5e9f5558 commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558 Author: Mark Johnston AuthorDate: 2021-08-24 18:10:08 +0000 Commit: Mark Johnston CommitDate: 2021-08-24 18:29:13 +0000 bhyve: Fix vq_getchain() error handling bugs in various device models Reviewed by: grehan, khng Approved by: so Security: CVE-2021-29631 Security: FreeBSD-SA-21:13.bhyve --- usr.sbin/bhyve/pci_virtio_9p.c | 3 ++- usr.sbin/bhyve/pci_virtio_console.c | 6 +++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- usr.sbin/bhyve/pci_virtio_scsi.c | 8 +++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index f96d53858225..70f3eba4bc34 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -198,12 +198,13 @@ pci_vt9p_notify(void *vsc, struct vqueue_info *vq) struct pci_vt9p_softc *sc; struct pci_vt9p_request *preq; struct vi_req req; - uint16_t n; + int n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VT9P_MAX_IOV, &req); + assert(n >= 1 && n <= VT9P_MAX_IOV); preq = calloc(1, sizeof(struct pci_vt9p_request)); preq->vsr_sc = sc; preq->vsr_idx = req.idx; diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 6832a3f92774..71c3375a57ac 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -442,6 +442,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &iov, 1, &req); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -582,7 +583,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &iov, 1, &req); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -602,14 +602,14 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_port *port; struct iovec iov[1]; struct vi_req req; - uint16_t n; + int n; sc = vsc; port = pci_vtcon_vq_to_port(sc, vq); while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, 1, &req); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 1d2d6144f949..7274d0b05912 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -114,7 +114,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) struct iovec iov; struct pci_vtrnd_softc *sc; struct vi_req req; - int len; + int len, n; sc = vsc; @@ -124,7 +124,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &iov, 1, &req); + n = vq_getchain(vq, &iov, 1, &req); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index e8124b9b3441..37eba90fa2bc 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -559,15 +559,16 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_softc *sc; struct iovec iov[VTSCSI_MAXSEG]; struct vi_req req; - uint16_t n; void *buf = NULL; size_t bufsize; - int iolen; + int iolen, n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &req); + assert(n >= 1 && n <= VTSCSI_MAXSEG); + bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); buf_to_iov(buf + bufsize - iolen, iolen, iov, n, @@ -597,13 +598,14 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_request *req; struct iovec iov[VTSCSI_MAXSEG]; struct vi_req vireq; - uint16_t n; + int n; sc = vsc; q = &sc->vss_queues[vq->vq_num - 2]; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &vireq); + assert(n >= 1 && n <= VTSCSI_MAXSEG); req = calloc(1, sizeof(struct pci_vtscsi_request)); req->vsr_idx = vireq.idx; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:32:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D129665E8D1; Tue, 24 Aug 2021 18:32: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 4GvHlW2gQqz3Q1P; Tue, 24 Aug 2021 18:32: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 169195C39; Tue, 24 Aug 2021 18:32: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 17OIWMmg037341; Tue, 24 Aug 2021 18:32:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIWM7r037340; Tue, 24 Aug 2021 18:32:22 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:32:22 GMT Message-Id: <202108241832.17OIWM7r037340@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: 20f96f215562 - stable/13 - bhyve: Fix vq_getchain() error handling bugs in various device models 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: 20f96f215562c7533053e01b186066ad935d11d0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:32:24 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=20f96f215562c7533053e01b186066ad935d11d0 commit 20f96f215562c7533053e01b186066ad935d11d0 Author: Mark Johnston AuthorDate: 2021-08-24 18:10:08 +0000 Commit: Mark Johnston CommitDate: 2021-08-24 18:29:48 +0000 bhyve: Fix vq_getchain() error handling bugs in various device models Reviewed by: grehan, khng Approved by: so Security: CVE-2021-29631 Security: FreeBSD-SA-21:13.bhyve (cherry picked from commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558) --- usr.sbin/bhyve/pci_virtio_9p.c | 3 ++- usr.sbin/bhyve/pci_virtio_console.c | 6 +++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- usr.sbin/bhyve/pci_virtio_scsi.c | 8 +++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_9p.c b/usr.sbin/bhyve/pci_virtio_9p.c index f96d53858225..70f3eba4bc34 100644 --- a/usr.sbin/bhyve/pci_virtio_9p.c +++ b/usr.sbin/bhyve/pci_virtio_9p.c @@ -198,12 +198,13 @@ pci_vt9p_notify(void *vsc, struct vqueue_info *vq) struct pci_vt9p_softc *sc; struct pci_vt9p_request *preq; struct vi_req req; - uint16_t n; + int n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VT9P_MAX_IOV, &req); + assert(n >= 1 && n <= VT9P_MAX_IOV); preq = calloc(1, sizeof(struct pci_vt9p_request)); preq->vsr_sc = sc; preq->vsr_idx = req.idx; diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 6832a3f92774..71c3375a57ac 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -442,6 +442,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &iov, 1, &req); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -582,7 +583,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &iov, 1, &req); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -602,14 +602,14 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_port *port; struct iovec iov[1]; struct vi_req req; - uint16_t n; + int n; sc = vsc; port = pci_vtcon_vq_to_port(sc, vq); while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, 1, &req); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 1d2d6144f949..7274d0b05912 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -114,7 +114,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) struct iovec iov; struct pci_vtrnd_softc *sc; struct vi_req req; - int len; + int len, n; sc = vsc; @@ -124,7 +124,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &iov, 1, &req); + n = vq_getchain(vq, &iov, 1, &req); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index e8124b9b3441..37eba90fa2bc 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -559,15 +559,16 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_softc *sc; struct iovec iov[VTSCSI_MAXSEG]; struct vi_req req; - uint16_t n; void *buf = NULL; size_t bufsize; - int iolen; + int iolen, n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &req); + assert(n >= 1 && n <= VTSCSI_MAXSEG); + bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); buf_to_iov(buf + bufsize - iolen, iolen, iov, n, @@ -597,13 +598,14 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_request *req; struct iovec iov[VTSCSI_MAXSEG]; struct vi_req vireq; - uint16_t n; + int n; sc = vsc; q = &sc->vss_queues[vq->vq_num - 2]; while (vq_has_descs(vq)) { n = vq_getchain(vq, iov, VTSCSI_MAXSEG, &vireq); + assert(n >= 1 && n <= VTSCSI_MAXSEG); req = calloc(1, sizeof(struct pci_vtscsi_request)); req->vsr_idx = vireq.idx; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:32:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C5D465EA1B; Tue, 24 Aug 2021 18:32: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 4GvHlZ72Fxz3Q81; Tue, 24 Aug 2021 18:32: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 CD4BC5566; Tue, 24 Aug 2021 18:32: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 17OIWQdE037455; Tue, 24 Aug 2021 18:32:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIWQeL037454; Tue, 24 Aug 2021 18:32:26 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:32:26 GMT Message-Id: <202108241832.17OIWQeL037454@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: 398bfe63e6f7 - stable/12 - bhyve: Fix vq_getchain() error handling bugs in various device models 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: 398bfe63e6f7d265c6bae2f56da29d37f6fc7a01 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:32:27 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=398bfe63e6f7d265c6bae2f56da29d37f6fc7a01 commit 398bfe63e6f7d265c6bae2f56da29d37f6fc7a01 Author: Mark Johnston AuthorDate: 2021-08-24 18:13:00 +0000 Commit: Mark Johnston CommitDate: 2021-08-24 18:30:15 +0000 bhyve: Fix vq_getchain() error handling bugs in various device models Reviewed by: grehan, khng Approved by: so Security: CVE-2021-29631 Security: FreeBSD-SA-21:13.bhyve (cherry picked from commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558) --- usr.sbin/bhyve/pci_virtio_console.c | 7 ++++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- usr.sbin/bhyve/pci_virtio_scsi.c | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index baec5534142a..d0567fe964a8 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -418,6 +418,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -558,7 +559,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &idx, &iov, 1, NULL); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -577,7 +577,8 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_softc *sc; struct pci_vtcon_port *port; struct iovec iov[1]; - uint16_t idx, n; + int n; + uint16_t idx; uint16_t flags[8]; sc = vsc; @@ -585,7 +586,7 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, 1, flags); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 4f908324cfa9..738bab7f6d48 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -113,7 +113,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) { struct iovec iov; struct pci_vtrnd_softc *sc; - int len; + int len, n; uint16_t idx; sc = vsc; @@ -124,7 +124,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &idx, &iov, 1, NULL); + n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index 04c5302f501f..0c2342134b3d 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -556,15 +556,16 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) { struct pci_vtscsi_softc *sc; struct iovec iov[VTSCSI_MAXSEG]; - uint16_t idx, n; + uint16_t idx; void *buf = NULL; size_t bufsize; - int iolen; + int iolen, n; sc = vsc; while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, NULL); + assert(n >= 1 && n <= VTSCSI_MAXSEG); bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); buf_to_iov(buf + bufsize - iolen, iolen, iov, n, @@ -594,8 +595,8 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) struct pci_vtscsi_request *req; struct iovec iov[VTSCSI_MAXSEG]; uint16_t flags[VTSCSI_MAXSEG]; - uint16_t idx, n, i; - int readable; + uint16_t idx, i; + int readable, n; sc = vsc; q = &sc->vss_queues[vq->vq_num - 2]; @@ -603,6 +604,7 @@ pci_vtscsi_requestq_notify(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { readable = 0; n = vq_getchain(vq, &idx, iov, VTSCSI_MAXSEG, flags); + assert(n >= 1 && n <= VTSCSI_MAXSEG); /* Count readable descriptors */ for (i = 0; i < n; i++) { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 18:32:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0365D65EA1E; Tue, 24 Aug 2021 18:32: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 4GvHlh5lnBz3Q4X; Tue, 24 Aug 2021 18:32: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 BE25A5B27; Tue, 24 Aug 2021 18:32: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 17OIWUDD037576; Tue, 24 Aug 2021 18:32:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OIWUtx037575; Tue, 24 Aug 2021 18:32:30 GMT (envelope-from git) Date: Tue, 24 Aug 2021 18:32:30 GMT Message-Id: <202108241832.17OIWUtx037575@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: eb01dfe6c01c - stable/11 - bhyve: Fix vq_getchain() error handling bugs in various device models MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: eb01dfe6c01c700418a872ae520187a1292ea7da Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 18:32:33 -0000 The branch stable/11 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=eb01dfe6c01c700418a872ae520187a1292ea7da commit eb01dfe6c01c700418a872ae520187a1292ea7da Author: Mark Johnston AuthorDate: 2021-08-24 18:19:49 +0000 Commit: Mark Johnston CommitDate: 2021-08-24 18:30:31 +0000 bhyve: Fix vq_getchain() error handling bugs in various device models Reviewed by: grehan, khng Approved by: so Security: CVE-2021-29631 Security: FreeBSD-SA-21:13.bhyve (cherry picked from commit 71fbc6faed62e8eb5864f7c40839740f5e9f5558) --- usr.sbin/bhyve/pci_virtio_console.c | 7 ++++--- usr.sbin/bhyve/pci_virtio_rnd.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 13aa4ad30cca..73528a2e1476 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -404,6 +404,7 @@ pci_vtcon_sock_rx(int fd __unused, enum ev_type t __unused, void *arg) do { n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = readv(sock->vss_conn_fd, &iov, n); if (len == 0 || (len < 0 && errno == EWOULDBLOCK)) { @@ -544,7 +545,6 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, return; n = vq_getchain(vq, &idx, &iov, 1, NULL); - assert(n == 1); memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); @@ -563,7 +563,8 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) struct pci_vtcon_softc *sc; struct pci_vtcon_port *port; struct iovec iov[1]; - uint16_t idx, n; + int n; + uint16_t idx; uint16_t flags[8]; sc = vsc; @@ -571,7 +572,7 @@ pci_vtcon_notify_tx(void *vsc, struct vqueue_info *vq) while (vq_has_descs(vq)) { n = vq_getchain(vq, &idx, iov, 1, flags); - assert(n >= 1); + assert(n == 1); if (port != NULL) port->vsp_cb(port, port->vsp_arg, iov, 1); diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 44bc55e0039e..5d2fac0c723a 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -109,7 +109,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) { struct iovec iov; struct pci_vtrnd_softc *sc; - int len; + int len, n; uint16_t idx; sc = vsc; @@ -120,7 +120,8 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) } while (vq_has_descs(vq)) { - vq_getchain(vq, &idx, &iov, 1, NULL); + n = vq_getchain(vq, &idx, &iov, 1, NULL); + assert(n == 1); len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 22:25:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0E637667C5A; Tue, 24 Aug 2021 22:25: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 4GvNwV6rZbz3spn; Tue, 24 Aug 2021 22:25: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 C8C8510D4E; Tue, 24 Aug 2021 22:25: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 17OMPU2k046559; Tue, 24 Aug 2021 22:25:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17OMPUI5046558; Tue, 24 Aug 2021 22:25:30 GMT (envelope-from git) Date: Tue, 24 Aug 2021 22:25:30 GMT Message-Id: <202108242225.17OMPUI5046558@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4f0f5bf99591 - main - iscsi: Validate DataSN values in Data-In PDUs in the initiator. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f0f5bf99591ad9907822082270523ac919e3b8c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 22:25:31 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4f0f5bf99591ad9907822082270523ac919e3b8c commit 4f0f5bf99591ad9907822082270523ac919e3b8c Author: John Baldwin AuthorDate: 2021-08-24 21:58:34 +0000 Commit: John Baldwin CommitDate: 2021-08-24 21:58:34 +0000 iscsi: Validate DataSN values in Data-In PDUs in the initiator. As is done in the target, require that DataSN values are consecutive and in-order. If an out of order Data-In PDU is received, force a session reconnect. In addition, when a SCSI Response PDU is received, verify that the ExpDataSN field matches the count of Data-In PDUs received for this command. If not, force a session reconnect. Reviewed by: mav Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D31594 --- sys/dev/iscsi/iscsi.c | 21 ++++++++++++++++++++- sys/dev/iscsi/iscsi.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 60b3e3766da7..eba365f7ad3e 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -892,6 +892,15 @@ iscsi_pdu_handle_scsi_response(struct icl_pdu *response) } ccb = io->io_ccb; + if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs %u)", + ntohl(bhssr->bhssr_expdatasn), io->io_datasn); + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } /* * With iSER, after getting good response we can be sure @@ -1047,6 +1056,17 @@ iscsi_pdu_handle_data_in(struct icl_pdu *response) return; } + if (io->io_datasn != ntohl(bhsdi->bhsdi_datasn)) { + ISCSI_SESSION_WARN(is, "received Data-In PDU with " + "DataSN %u, while expected %u; dropping connection", + ntohl(bhsdi->bhsdi_datasn), io->io_datasn); + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } + io->io_datasn += response->ip_additional_pdus + 1; + data_segment_len = icl_pdu_data_segment_length(response); if (data_segment_len == 0) { /* @@ -1096,7 +1116,6 @@ iscsi_pdu_handle_data_in(struct icl_pdu *response) icl_pdu_get_data(response, 0, csio->data_ptr + oreceived, data_segment_len); /* - * XXX: Check DataSN. * XXX: Check F. */ if ((bhsdi->bhsdi_flags & BHSDI_FLAGS_S) == 0) { diff --git a/sys/dev/iscsi/iscsi.h b/sys/dev/iscsi/iscsi.h index fe1cc64f88db..871fc6fc90e9 100644 --- a/sys/dev/iscsi/iscsi.h +++ b/sys/dev/iscsi/iscsi.h @@ -44,6 +44,7 @@ struct iscsi_outstanding { TAILQ_ENTRY(iscsi_outstanding) io_next; union ccb *io_ccb; size_t io_received; + uint32_t io_datasn; uint32_t io_initiator_task_tag; uint32_t io_referenced_task_tag; void *io_icl_prv; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 62F316692B7; Tue, 24 Aug 2021 23: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 4GvPn728fFz4ZyM; Tue, 24 Aug 2021 23: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 32FEC118C4; Tue, 24 Aug 2021 23: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 17ON4BdF000701; Tue, 24 Aug 2021 23: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 17ON4BeH000700; Tue, 24 Aug 2021 23:04:11 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:11 GMT Message-Id: <202108242304.17ON4BeH000700@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 98a7606b85e0 - main - evdev: Multitouch code style changes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 98a7606b85e05132f328a2498dccab78df31cb7e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:11 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=98a7606b85e05132f328a2498dccab78df31cb7e commit 98a7606b85e05132f328a2498dccab78df31cb7e Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:43:41 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:43:41 +0000 evdev: Multitouch code style changes. 1. Move touch count reporting helpers to utils. They are not multitouch. 2. Use evdev_mt prefix for private multitouch support routines. 3. Use int instead of int32_t where fixed size is not required. 4. Export some internal functions. This change should be no-op. MFC after: 2 weeks --- sys/dev/evdev/cdev.c | 2 +- sys/dev/evdev/evdev.c | 19 +++--- sys/dev/evdev/evdev.h | 12 +++- sys/dev/evdev/evdev_mt.c | 152 +++++++++++++++++++----------------------- sys/dev/evdev/evdev_private.h | 12 ++-- sys/dev/evdev/evdev_utils.c | 41 ++++++++++++ 6 files changed, 134 insertions(+), 104 deletions(-) diff --git a/sys/dev/evdev/cdev.c b/sys/dev/evdev/cdev.c index 66d00ad16aee..d124e691a7c3 100644 --- a/sys/dev/evdev/cdev.c +++ b/sys/dev/evdev/cdev.c @@ -621,7 +621,7 @@ evdev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, MIN(len / sizeof(int32_t) - 1, MAXIMAL_MT_SLOT(evdev) + 1); for (int i = 0; i < nvalues; i++) ((int32_t *)data)[i + 1] = - evdev_get_mt_value(evdev, i, code); + evdev_mt_get_value(evdev, i, code); return (0); case EVIOCGKEY(0): diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 597342a364af..8483faee8d6b 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -707,8 +707,8 @@ evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, else if (!ABS_IS_MT(code)) old_value = evdev->ev_absinfo[code].value; else if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) - old_value = evdev_get_mt_value(evdev, - evdev_get_last_mt_slot(evdev), code); + old_value = evdev_mt_get_value(evdev, + evdev_mt_get_last_slot(evdev), code); else /* Pass MT protocol type A events as is */ break; @@ -788,7 +788,7 @@ evdev_sparse_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, switch (code) { case ABS_MT_SLOT: /* Postpone ABS_MT_SLOT till next event */ - evdev_set_last_mt_slot(evdev, value); + evdev_mt_set_last_slot(evdev, value); return (EV_SKIP_EVENT); case ABS_MT_FIRST ... ABS_MT_LAST: @@ -796,11 +796,11 @@ evdev_sparse_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) break; /* Don`t repeat MT protocol type B events */ - last_mt_slot = evdev_get_last_mt_slot(evdev); - if (evdev_get_mt_value(evdev, last_mt_slot, code) + last_mt_slot = evdev_mt_get_last_slot(evdev); + if (evdev_mt_get_value(evdev, last_mt_slot, code) == value) return (EV_SKIP_EVENT); - evdev_set_mt_value(evdev, last_mt_slot, code, value); + evdev_mt_set_value(evdev, last_mt_slot, code, value); if (last_mt_slot != CURRENT_MT_SLOT(evdev)) { CURRENT_MT_SLOT(evdev) = last_mt_slot; evdev->ev_report_opened = true; @@ -941,11 +941,8 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, evdev_modify_event(evdev, type, code, &value); if (type == EV_SYN && code == SYN_REPORT && - bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) - evdev_send_mt_autorel(evdev); - if (type == EV_SYN && code == SYN_REPORT && evdev->ev_report_opened && - bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) - evdev_send_mt_compat(evdev); + bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + evdev_mt_sync_frame(evdev); evdev_send_event(evdev, type, code, value); EVDEV_EXIT(evdev); diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 30d6a106d8b3..fe21f8cea4c2 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -131,11 +131,15 @@ void evdev_set_flag(struct evdev_dev *, uint16_t); void *evdev_get_softc(struct evdev_dev *); /* Multitouch related functions: */ -int32_t evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); -void evdev_support_nfingers(struct evdev_dev *, int32_t); +int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); void evdev_support_mt_compat(struct evdev_dev *); -void evdev_push_nfingers(struct evdev_dev *, int32_t); void evdev_push_mt_compat(struct evdev_dev *); +void evdev_mt_push_autorel(struct evdev_dev *); +static inline int +evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) +{ + return (evdev_get_mt_slot_by_tracking_id(evdev, id)); +} /* Utility functions: */ uint16_t evdev_hid2key(int); @@ -144,6 +148,8 @@ uint16_t evdev_scancode2key(int *, int); void evdev_push_mouse_btn(struct evdev_dev *, int); void evdev_push_leds(struct evdev_dev *, int); void evdev_push_repeats(struct evdev_dev *, keyboard_t *); +void evdev_support_nfingers(struct evdev_dev *, int); +void evdev_push_nfingers(struct evdev_dev *, int); /* Event reporting shortcuts: */ static __inline int diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 1f9c9756db02..e8f892e235c0 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -42,14 +42,6 @@ #define debugf(fmt, args...) #endif -static uint16_t evdev_fngmap[] = { - BTN_TOOL_FINGER, - BTN_TOOL_DOUBLETAP, - BTN_TOOL_TRIPLETAP, - BTN_TOOL_QUADTAP, - BTN_TOOL_QUINTTAP, -}; - static uint16_t evdev_mtstmap[][2] = { { ABS_MT_POSITION_X, ABS_X }, { ABS_MT_POSITION_Y, ABS_Y }, @@ -58,23 +50,26 @@ static uint16_t evdev_mtstmap[][2] = { }; struct evdev_mt_slot { - uint64_t ev_report; - int32_t ev_mt_states[MT_CNT]; + uint64_t ev_report; + int32_t val[MT_CNT]; }; struct evdev_mt { - int32_t ev_mt_last_reported_slot; - struct evdev_mt_slot ev_mt_slots[]; + int last_reported_slot; + struct evdev_mt_slot slots[]; }; +static void evdev_mt_send_st_compat(struct evdev_dev *); +static void evdev_mt_send_autorel(struct evdev_dev *); + void evdev_mt_init(struct evdev_dev *evdev) { - int32_t slot, slots; + int slot, slots; slots = MAXIMAL_MT_SLOT(evdev) + 1; - evdev->ev_mt = malloc(offsetof(struct evdev_mt, ev_mt_slots) + + evdev->ev_mt = malloc(offsetof(struct evdev_mt, slots) + sizeof(struct evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); /* Initialize multitouch protocol type B states */ @@ -84,9 +79,9 @@ evdev_mt_init(struct evdev_dev *evdev) * report counter (0) as it brokes free slot detection in * evdev_get_mt_slot_by_tracking_id. So initialize it to -1 */ - evdev->ev_mt->ev_mt_slots[slot] = (struct evdev_mt_slot) { + evdev->ev_mt->slots[slot] = (struct evdev_mt_slot) { .ev_report = 0xFFFFFFFFFFFFFFFFULL, - .ev_mt_states[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] = -1, + .val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] = -1, }; } @@ -97,49 +92,66 @@ evdev_mt_init(struct evdev_dev *evdev) void evdev_mt_free(struct evdev_dev *evdev) { - free(evdev->ev_mt, M_EVDEV); } -int32_t -evdev_get_last_mt_slot(struct evdev_dev *evdev) +void +evdev_mt_sync_frame(struct evdev_dev *evdev) { + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) + evdev_mt_send_autorel(evdev); + if (evdev->ev_report_opened && + bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) + evdev_mt_send_st_compat(evdev); +} - return (evdev->ev_mt->ev_mt_last_reported_slot); +int +evdev_mt_get_last_slot(struct evdev_dev *evdev) +{ + return (evdev->ev_mt->last_reported_slot); } void -evdev_set_last_mt_slot(struct evdev_dev *evdev, int32_t slot) +evdev_mt_set_last_slot(struct evdev_dev *evdev, int slot) { + struct evdev_mt *mt = evdev->ev_mt; + + MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - evdev->ev_mt->ev_mt_slots[slot].ev_report = evdev->ev_report_count; - evdev->ev_mt->ev_mt_last_reported_slot = slot; + mt->slots[slot].ev_report = evdev->ev_report_count; + mt->last_reported_slot = slot; } -inline int32_t -evdev_get_mt_value(struct evdev_dev *evdev, int32_t slot, int16_t code) +int32_t +evdev_mt_get_value(struct evdev_dev *evdev, int slot, int16_t code) { + struct evdev_mt *mt = evdev->ev_mt; + + MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - return (evdev->ev_mt-> - ev_mt_slots[slot].ev_mt_states[ABS_MT_INDEX(code)]); + return (mt->slots[slot].val[ABS_MT_INDEX(code)]); } -inline void -evdev_set_mt_value(struct evdev_dev *evdev, int32_t slot, int16_t code, +void +evdev_mt_set_value(struct evdev_dev *evdev, int slot, int16_t code, int32_t value) { + struct evdev_mt *mt = evdev->ev_mt; + + MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - evdev->ev_mt->ev_mt_slots[slot].ev_mt_states[ABS_MT_INDEX(code)] = - value; + mt->slots[slot].val[ABS_MT_INDEX(code)] = value; } -int32_t +int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) { - int32_t tr_id, slot, free_slot = -1; + struct evdev_mt *mt = evdev->ev_mt; + int32_t tr_id; + int slot, free_slot = -1; for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - tr_id = evdev_get_mt_value(evdev, slot, ABS_MT_TRACKING_ID); + tr_id = evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID); if (tr_id == tracking_id) return (slot); /* @@ -149,27 +161,17 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) * ABS_MT_TRACKING_ID change. */ if (free_slot == -1 && tr_id == -1 && - evdev->ev_mt->ev_mt_slots[slot].ev_report != - evdev->ev_report_count) + mt->slots[slot].ev_report != evdev->ev_report_count) free_slot = slot; } return (free_slot); } -void -evdev_support_nfingers(struct evdev_dev *evdev, int32_t nfingers) -{ - int32_t i; - - for (i = 0; i < MIN(nitems(evdev_fngmap), nfingers); i++) - evdev_support_key(evdev, evdev_fngmap[i]); -} - void evdev_support_mt_compat(struct evdev_dev *evdev) { - int32_t i; + int i; if (evdev->ev_absinfo == NULL) return; @@ -195,56 +197,32 @@ evdev_support_mt_compat(struct evdev_dev *evdev) static int32_t evdev_count_fingers(struct evdev_dev *evdev) { - int32_t nfingers = 0, i; + int nfingers = 0, i; for (i = 0; i <= MAXIMAL_MT_SLOT(evdev); i++) - if (evdev_get_mt_value(evdev, i, ABS_MT_TRACKING_ID) != -1) + if (evdev_mt_get_value(evdev, i, ABS_MT_TRACKING_ID) != -1) nfingers++; return (nfingers); } static void -evdev_send_nfingers(struct evdev_dev *evdev, int32_t nfingers) -{ - int32_t i; - - EVDEV_LOCK_ASSERT(evdev); - - if (nfingers > nitems(evdev_fngmap)) - nfingers = nitems(evdev_fngmap); - - for (i = 0; i < nitems(evdev_fngmap); i++) - evdev_send_event(evdev, EV_KEY, evdev_fngmap[i], - nfingers == i + 1); -} - -void -evdev_push_nfingers(struct evdev_dev *evdev, int32_t nfingers) +evdev_mt_send_st_compat(struct evdev_dev *evdev) { - - EVDEV_ENTER(evdev); - evdev_send_nfingers(evdev, nfingers); - EVDEV_EXIT(evdev); -} - -void -evdev_send_mt_compat(struct evdev_dev *evdev) -{ - int32_t nfingers, i; + int nfingers, i; EVDEV_LOCK_ASSERT(evdev); nfingers = evdev_count_fingers(evdev); evdev_send_event(evdev, EV_KEY, BTN_TOUCH, nfingers > 0); - if (evdev_get_mt_value(evdev, 0, ABS_MT_TRACKING_ID) != -1) + if (evdev_mt_get_value(evdev, 0, ABS_MT_TRACKING_ID) != -1) /* Echo 0-th MT-slot as ST-slot */ for (i = 0; i < nitems(evdev_mtstmap); i++) if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) evdev_send_event(evdev, EV_ABS, evdev_mtstmap[i][1], - evdev_get_mt_value(evdev, 0, + evdev_mt_get_value(evdev, 0, evdev_mtstmap[i][0])); /* Touchscreens should not report tool taps */ @@ -260,24 +238,32 @@ evdev_push_mt_compat(struct evdev_dev *evdev) { EVDEV_ENTER(evdev); - evdev_send_mt_compat(evdev); + evdev_mt_send_st_compat(evdev); EVDEV_EXIT(evdev); } -void -evdev_send_mt_autorel(struct evdev_dev *evdev) +static void +evdev_mt_send_autorel(struct evdev_dev *evdev) { - int32_t slot; + struct evdev_mt *mt = evdev->ev_mt; + int slot; EVDEV_LOCK_ASSERT(evdev); for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - if (evdev->ev_mt->ev_mt_slots[slot].ev_report != - evdev->ev_report_count && - evdev_get_mt_value(evdev, slot, ABS_MT_TRACKING_ID) != -1){ + if (mt->slots[slot].ev_report != evdev->ev_report_count && + evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) != -1){ evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); } } } + +void +evdev_mt_push_autorel(struct evdev_dev *evdev) +{ + EVDEV_ENTER(evdev); + evdev_mt_send_autorel(evdev); + EVDEV_EXIT(evdev); +} diff --git a/sys/dev/evdev/evdev_private.h b/sys/dev/evdev/evdev_private.h index 463f93847295..fc079a324ba4 100644 --- a/sys/dev/evdev/evdev_private.h +++ b/sys/dev/evdev/evdev_private.h @@ -279,14 +279,14 @@ void evdev_revoke_client(struct evdev_client *); /* Multitouch related functions: */ void evdev_mt_init(struct evdev_dev *); void evdev_mt_free(struct evdev_dev *); -int32_t evdev_get_last_mt_slot(struct evdev_dev *); -void evdev_set_last_mt_slot(struct evdev_dev *, int32_t); -int32_t evdev_get_mt_value(struct evdev_dev *, int32_t, int16_t); -void evdev_set_mt_value(struct evdev_dev *, int32_t, int16_t, int32_t); -void evdev_send_mt_compat(struct evdev_dev *); -void evdev_send_mt_autorel(struct evdev_dev *); +void evdev_mt_sync_frame(struct evdev_dev *); +int evdev_mt_get_last_slot(struct evdev_dev *); +void evdev_mt_set_last_slot(struct evdev_dev *, int); +int32_t evdev_mt_get_value(struct evdev_dev *, int, int16_t); +void evdev_mt_set_value(struct evdev_dev *, int, int16_t, int32_t); /* Utility functions: */ void evdev_client_dumpqueue(struct evdev_client *); +void evdev_send_nfingers(struct evdev_dev *, int); #endif /* _DEV_EVDEV_EVDEV_PRIVATE_H */ diff --git a/sys/dev/evdev/evdev_utils.c b/sys/dev/evdev/evdev_utils.c index dcdd3a6d5126..9bb58d9b7ba1 100644 --- a/sys/dev/evdev/evdev_utils.c +++ b/sys/dev/evdev/evdev_utils.c @@ -38,6 +38,7 @@ #include #include +#include #include #define NONE KEY_RESERVED @@ -205,6 +206,14 @@ static uint16_t evdev_led_codes[] = { LED_SCROLLL, /* SLKED */ }; +static uint16_t evdev_nfinger_codes[] = { + BTN_TOOL_FINGER, + BTN_TOOL_DOUBLETAP, + BTN_TOOL_TRIPLETAP, + BTN_TOOL_QUADTAP, + BTN_TOOL_QUINTTAP, +}; + uint16_t evdev_hid2key(int scancode) { @@ -300,3 +309,35 @@ evdev_push_repeats(struct evdev_dev *evdev, keyboard_t *kbd) evdev_push_event(evdev, EV_REP, REP_DELAY, kbd->kb_delay1); evdev_push_event(evdev, EV_REP, REP_PERIOD, kbd->kb_delay2); } + +void +evdev_support_nfingers(struct evdev_dev *evdev, int nfingers) +{ + int i; + + for (i = 0; i < MIN(nitems(evdev_nfinger_codes), nfingers); i++) + evdev_support_key(evdev, evdev_nfinger_codes[i]); +} + +void +evdev_send_nfingers(struct evdev_dev *evdev, int nfingers) +{ + int i; + + EVDEV_LOCK_ASSERT(evdev); + + if (nfingers > nitems(evdev_nfinger_codes)) + nfingers = nitems(evdev_nfinger_codes); + + for (i = 0; i < nitems(evdev_nfinger_codes); i++) + evdev_send_event(evdev, EV_KEY, evdev_nfinger_codes[i], + nfingers == i + 1); +} + +void +evdev_push_nfingers(struct evdev_dev *evdev, int nfingers) +{ + EVDEV_ENTER(evdev); + evdev_send_nfingers(evdev, nfingers); + EVDEV_EXIT(evdev); +} From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDC36669068; Tue, 24 Aug 2021 23: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 4GvPn83HKDz4ZhM; Tue, 24 Aug 2021 23: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 4AC8911B0E; Tue, 24 Aug 2021 23: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 17ON4CxP000725; Tue, 24 Aug 2021 23: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 17ON4CW0000724; Tue, 24 Aug 2021 23:04:12 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:12 GMT Message-Id: <202108242304.17ON4CW0000724@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 2dc7188e532f - main - evdev: Use bitsets to track active touches and slots changed in current report MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2dc7188e532f0147b36a44ce5c033d9f59cbd9f4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:13 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=2dc7188e532f0147b36a44ce5c033d9f59cbd9f4 commit 2dc7188e532f0147b36a44ce5c033d9f59cbd9f4 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:44:36 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:44:36 +0000 evdev: Use bitsets to track active touches and slots changed in current report Obtained from: OpenBSD MFC after: 2 weeks --- sys/dev/evdev/evdev_mt.c | 94 ++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 51 deletions(-) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index e8f892e235c0..a28b034884ba 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -42,6 +42,13 @@ #define debugf(fmt, args...) #endif +typedef u_int slotset_t; + +_Static_assert(MAX_MT_SLOTS < sizeof(slotset_t) * 8, "MAX_MT_SLOTS too big"); + +#define FOREACHBIT(v, i) \ + for ((i) = ffs(v) - 1; (i) != -1; (i) = ffs((v) & (~1 << (i))) - 1) + static uint16_t evdev_mtstmap[][2] = { { ABS_MT_POSITION_X, ABS_X }, { ABS_MT_POSITION_Y, ABS_Y }, @@ -50,18 +57,27 @@ static uint16_t evdev_mtstmap[][2] = { }; struct evdev_mt_slot { - uint64_t ev_report; int32_t val[MT_CNT]; }; struct evdev_mt { int last_reported_slot; + /* the set of slots with active touches */ + slotset_t touches; + /* the set of slots with unsynchronized state */ + slotset_t frame; struct evdev_mt_slot slots[]; }; static void evdev_mt_send_st_compat(struct evdev_dev *); static void evdev_mt_send_autorel(struct evdev_dev *); +static inline int +ffc_slot(struct evdev_dev *evdev, slotset_t slots) +{ + return (ffs(~slots & (2U << MAXIMAL_MT_SLOT(evdev)) - 1) - 1); +} + void evdev_mt_init(struct evdev_dev *evdev) { @@ -73,17 +89,9 @@ evdev_mt_init(struct evdev_dev *evdev) sizeof(struct evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); /* Initialize multitouch protocol type B states */ - for (slot = 0; slot < slots; slot++) { - /* - * .ev_report should not be initialized to initial value of - * report counter (0) as it brokes free slot detection in - * evdev_get_mt_slot_by_tracking_id. So initialize it to -1 - */ - evdev->ev_mt->slots[slot] = (struct evdev_mt_slot) { - .ev_report = 0xFFFFFFFFFFFFFFFFULL, - .val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] = -1, - }; - } + for (slot = 0; slot < slots; slot++) + evdev->ev_mt->slots[slot].val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] + = -1; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_support_mt_compat(evdev); @@ -103,6 +111,7 @@ evdev_mt_sync_frame(struct evdev_dev *evdev) if (evdev->ev_report_opened && bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_mt_send_st_compat(evdev); + evdev->ev_mt->frame = 0; } int @@ -118,7 +127,7 @@ evdev_mt_set_last_slot(struct evdev_dev *evdev, int slot) MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); - mt->slots[slot].ev_report = evdev->ev_report_count; + mt->frame |= 1U << slot; mt->last_reported_slot = slot; } @@ -140,6 +149,12 @@ evdev_mt_set_value(struct evdev_dev *evdev, int slot, int16_t code, MPASS(slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev)); + if (code == ABS_MT_TRACKING_ID) { + if (value != -1) + mt->touches |= 1U << slot; + else + mt->touches &= ~(1U << slot); + } mt->slots[slot].val[ABS_MT_INDEX(code)] = value; } @@ -147,25 +162,17 @@ int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) { struct evdev_mt *mt = evdev->ev_mt; - int32_t tr_id; - int slot, free_slot = -1; + int slot; - for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - tr_id = evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID); - if (tr_id == tracking_id) + FOREACHBIT(mt->touches, slot) + if (evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) == + tracking_id) return (slot); - /* - * Its possible that slot will be reassigned in a place of just - * released one within the same report. To avoid this compare - * report counter with slot`s report number updated with each - * ABS_MT_TRACKING_ID change. - */ - if (free_slot == -1 && tr_id == -1 && - mt->slots[slot].ev_report != evdev->ev_report_count) - free_slot = slot; - } - - return (free_slot); + /* + * Do not allow allocation of new slot in a place of just + * released one within the same report. + */ + return (ffc_slot(evdev, mt->touches | mt->frame)); } void @@ -194,29 +201,18 @@ evdev_support_mt_compat(struct evdev_dev *evdev) evdev->ev_absinfo[evdev_mtstmap[i][0]].resolution); } -static int32_t -evdev_count_fingers(struct evdev_dev *evdev) -{ - int nfingers = 0, i; - - for (i = 0; i <= MAXIMAL_MT_SLOT(evdev); i++) - if (evdev_mt_get_value(evdev, i, ABS_MT_TRACKING_ID) != -1) - nfingers++; - - return (nfingers); -} - static void evdev_mt_send_st_compat(struct evdev_dev *evdev) { + struct evdev_mt *mt = evdev->ev_mt; int nfingers, i; EVDEV_LOCK_ASSERT(evdev); - nfingers = evdev_count_fingers(evdev); + nfingers = bitcount(mt->touches); evdev_send_event(evdev, EV_KEY, BTN_TOUCH, nfingers > 0); - if (evdev_mt_get_value(evdev, 0, ABS_MT_TRACKING_ID) != -1) + if ((mt->touches & 1U << 0) != 0) /* Echo 0-th MT-slot as ST-slot */ for (i = 0; i < nitems(evdev_mtstmap); i++) if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) @@ -250,13 +246,9 @@ evdev_mt_send_autorel(struct evdev_dev *evdev) EVDEV_LOCK_ASSERT(evdev); - for (slot = 0; slot <= MAXIMAL_MT_SLOT(evdev); slot++) { - if (mt->slots[slot].ev_report != evdev->ev_report_count && - evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) != -1){ - evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); - evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, - -1); - } + FOREACHBIT(mt->touches & ~mt->frame, slot) { + evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); + evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); } } From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F3FF1669150; Tue, 24 Aug 2021 23:04: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 4GvPn95VkMz4Zkx; Tue, 24 Aug 2021 23: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 731CE11B0F; Tue, 24 Aug 2021 23: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 17ON4D4S000749; Tue, 24 Aug 2021 23: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 17ON4DsM000748; Tue, 24 Aug 2021 23:04:13 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:13 GMT Message-Id: <202108242304.17ON4DsM000748@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: fbe17f9017e7 - main - evdev: Send first active rather than 0-th slot state as ST report MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbe17f9017e785dd564ce7fc5553a9136d3a0b03 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:14 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=fbe17f9017e785dd564ce7fc5553a9136d3a0b03 commit fbe17f9017e785dd564ce7fc5553a9136d3a0b03 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:45:16 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:45:16 +0000 evdev: Send first active rather than 0-th slot state as ST report MFC after: 2 weeks --- sys/dev/evdev/evdev_mt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index a28b034884ba..0ededf053f36 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -205,20 +205,21 @@ static void evdev_mt_send_st_compat(struct evdev_dev *evdev) { struct evdev_mt *mt = evdev->ev_mt; - int nfingers, i; + int nfingers, i, st_slot; EVDEV_LOCK_ASSERT(evdev); nfingers = bitcount(mt->touches); evdev_send_event(evdev, EV_KEY, BTN_TOUCH, nfingers > 0); - if ((mt->touches & 1U << 0) != 0) - /* Echo 0-th MT-slot as ST-slot */ + /* Send first active MT-slot state as single touch report */ + st_slot = ffs(mt->touches) - 1; + if (st_slot != -1) for (i = 0; i < nitems(evdev_mtstmap); i++) if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) evdev_send_event(evdev, EV_ABS, evdev_mtstmap[i][1], - evdev_mt_get_value(evdev, 0, + evdev_mt_get_value(evdev, st_slot, evdev_mtstmap[i][0])); /* Touchscreens should not report tool taps */ From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 09CF2669153; Tue, 24 Aug 2021 23: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 4GvPnB6jltz4ZwR; Tue, 24 Aug 2021 23: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 889F511B10; Tue, 24 Aug 2021 23: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 17ON4Ep7000773; Tue, 24 Aug 2021 23: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 17ON4EJ2000772; Tue, 24 Aug 2021 23:04:14 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:14 GMT Message-Id: <202108242304.17ON4EJ2000772@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 314913ed7c6e - main - evdev: force no fuzz for autogenerated single touch compat events. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 314913ed7c6e6e1b7c80a1063620f478961419b7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:16 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=314913ed7c6e6e1b7c80a1063620f478961419b7 commit 314913ed7c6e6e1b7c80a1063620f478961419b7 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:45:50 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:45:50 +0000 evdev: force no fuzz for autogenerated single touch compat events. As fuzz has already been applied on multitouch event processing. This allows to remove existing workaround for double fuzz procesing. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 2 +- sys/dev/evdev/evdev_mt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 8483faee8d6b..d6f6cc2e003f 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -876,6 +876,7 @@ evdev_send_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, EVDEV_LOCK_ASSERT(evdev); + evdev_modify_event(evdev, type, code, &value); sparse = evdev_sparse_event(evdev, type, code, value); switch (sparse) { case EV_REPORT_MT_SLOT: @@ -939,7 +940,6 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, evdev_restore_after_kdb(evdev); } - evdev_modify_event(evdev, type, code, &value); if (type == EV_SYN && code == SYN_REPORT && bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) evdev_mt_sync_frame(evdev); diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 0ededf053f36..0b5d2cb6bb85 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -196,7 +196,7 @@ evdev_support_mt_compat(struct evdev_dev *evdev) evdev_support_abs(evdev, evdev_mtstmap[i][1], evdev->ev_absinfo[evdev_mtstmap[i][0]].minimum, evdev->ev_absinfo[evdev_mtstmap[i][0]].maximum, - evdev->ev_absinfo[evdev_mtstmap[i][0]].fuzz, + 0, evdev->ev_absinfo[evdev_mtstmap[i][0]].flat, evdev->ev_absinfo[evdev_mtstmap[i][0]].resolution); } From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 651D966932B; Tue, 24 Aug 2021 23:04: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 4GvPnD09kmz4Zsv; Tue, 24 Aug 2021 23: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 9BA8F11B11; Tue, 24 Aug 2021 23: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 17ON4FKL000797; Tue, 24 Aug 2021 23: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 17ON4FfL000796; Tue, 24 Aug 2021 23:04:15 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:15 GMT Message-Id: <202108242304.17ON4FfL000796@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 127e54deb6d8 - main - evdev: Normalize width and pressure of single touch compat events MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 127e54deb6d8899e1dc1bc6251d512e19f21b0f1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:17 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=127e54deb6d8899e1dc1bc6251d512e19f21b0f1 commit 127e54deb6d8899e1dc1bc6251d512e19f21b0f1 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:46:49 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:46:49 +0000 evdev: Normalize width and pressure of single touch compat events to match Synaptics touchpad reporting range. MFC after: 2 weeks --- sys/dev/evdev/evdev_mt.c | 67 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 0b5d2cb6bb85..a3600e837960 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -49,11 +49,15 @@ _Static_assert(MAX_MT_SLOTS < sizeof(slotset_t) * 8, "MAX_MT_SLOTS too big"); #define FOREACHBIT(v, i) \ for ((i) = ffs(v) - 1; (i) != -1; (i) = ffs((v) & (~1 << (i))) - 1) -static uint16_t evdev_mtstmap[][2] = { - { ABS_MT_POSITION_X, ABS_X }, - { ABS_MT_POSITION_Y, ABS_Y }, - { ABS_MT_PRESSURE, ABS_PRESSURE }, - { ABS_MT_TOUCH_MAJOR, ABS_TOOL_WIDTH }, +struct { + uint16_t mt; + uint16_t st; + int32_t max; +} static evdev_mtstmap[] = { + { ABS_MT_POSITION_X, ABS_X, 0 }, + { ABS_MT_POSITION_Y, ABS_Y, 0 }, + { ABS_MT_PRESSURE, ABS_PRESSURE, 255 }, + { ABS_MT_TOUCH_MAJOR, ABS_TOOL_WIDTH, 15 }, }; struct evdev_mt_slot { @@ -62,6 +66,7 @@ struct evdev_mt_slot { struct evdev_mt { int last_reported_slot; + u_int mtst_events; /* the set of slots with active touches */ slotset_t touches; /* the set of slots with unsynchronized state */ @@ -175,9 +180,20 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) return (ffc_slot(evdev, mt->touches | mt->frame)); } +static inline int32_t +evdev_mt_normalize(int32_t value, int32_t mtmin, int32_t mtmax, int32_t stmax) +{ + if (stmax != 0 && mtmax != mtmin) { + value = (value - mtmin) * stmax / (mtmax - mtmin); + value = MAX(MIN(value, stmax), 0); + } + return (value); +} + void evdev_support_mt_compat(struct evdev_dev *evdev) { + struct input_absinfo *ai; int i; if (evdev->ev_absinfo == NULL) @@ -191,14 +207,28 @@ evdev_support_mt_compat(struct evdev_dev *evdev) evdev_support_nfingers(evdev, MAXIMAL_MT_SLOT(evdev) + 1); /* Echo 0-th MT-slot as ST-slot */ - for (i = 0; i < nitems(evdev_mtstmap); i++) - if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][0])) - evdev_support_abs(evdev, evdev_mtstmap[i][1], - evdev->ev_absinfo[evdev_mtstmap[i][0]].minimum, - evdev->ev_absinfo[evdev_mtstmap[i][0]].maximum, + for (i = 0; i < nitems(evdev_mtstmap); i++) { + if (!bit_test(evdev->ev_abs_flags, evdev_mtstmap[i].mt) || + bit_test(evdev->ev_abs_flags, evdev_mtstmap[i].st)) + continue; + ai = evdev->ev_absinfo + evdev_mtstmap[i].mt; + evdev->ev_mt->mtst_events |= 1U << i; + if (evdev_mtstmap[i].max != 0) + evdev_support_abs(evdev, evdev_mtstmap[i].st, 0, - evdev->ev_absinfo[evdev_mtstmap[i][0]].flat, - evdev->ev_absinfo[evdev_mtstmap[i][0]].resolution); + evdev_mtstmap[i].max, + 0, + evdev_mt_normalize( + ai->flat, 0, ai->maximum, evdev_mtstmap[i].max), + 0); + else + evdev_support_abs(evdev, evdev_mtstmap[i].st, + ai->minimum, + ai->maximum, + 0, + ai->flat, + ai->resolution); + } } static void @@ -215,12 +245,13 @@ evdev_mt_send_st_compat(struct evdev_dev *evdev) /* Send first active MT-slot state as single touch report */ st_slot = ffs(mt->touches) - 1; if (st_slot != -1) - for (i = 0; i < nitems(evdev_mtstmap); i++) - if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) - evdev_send_event(evdev, EV_ABS, - evdev_mtstmap[i][1], - evdev_mt_get_value(evdev, st_slot, - evdev_mtstmap[i][0])); + FOREACHBIT(mt->mtst_events, i) + evdev_send_event(evdev, EV_ABS, evdev_mtstmap[i].st, + evdev_mt_normalize(evdev_mt_get_value(evdev, + st_slot, evdev_mtstmap[i].mt), + evdev->ev_absinfo[evdev_mtstmap[i].mt].minimum, + evdev->ev_absinfo[evdev_mtstmap[i].mt].maximum, + evdev_mtstmap[i].max)); /* Touchscreens should not report tool taps */ if (!bit_test(evdev->ev_prop_flags, INPUT_PROP_DIRECT)) From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B65DE669157; Tue, 24 Aug 2021 23:04: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 4GvPnF069qz4Zt2; Tue, 24 Aug 2021 23: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 D835F118C5; Tue, 24 Aug 2021 23: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 17ON4Ga7000827; Tue, 24 Aug 2021 23: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 17ON4Gbn000826; Tue, 24 Aug 2021 23:04:16 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:16 GMT Message-Id: <202108242304.17ON4Gbn000826@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 059360287e33 - main - evdev: Give short aliases to items of evdev_mt_slot array MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 059360287e3344f48f5a7839e2d6d54016b18b19 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:18 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=059360287e3344f48f5a7839e2d6d54016b18b19 commit 059360287e3344f48f5a7839e2d6d54016b18b19 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:47:34 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:47:34 +0000 evdev: Give short aliases to items of evdev_mt_slot array with using of unioned anonymous structure. Access to the same data by using different members of union generally works despite it is not supported by C specs. Also add helper function to report entire slot state. MFC after: 2 weeks --- sys/dev/evdev/evdev.h | 24 ++++++++++++++++++ sys/dev/evdev/evdev_mt.c | 63 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index fe21f8cea4c2..64bf75f04efd 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -102,6 +102,29 @@ struct evdev_methods evdev_keycode_t *ev_set_keycode; }; +union evdev_mt_slot { + int32_t val[MT_CNT]; + struct { + int32_t maj; /* ABS_MT_TOUCH_MAJOR */ + int32_t min; /* ABS_MT_TOUCH_MINOR */ + int32_t w_maj; /* ABS_MT_WIDTH_MAJOR */ + int32_t w_min; /* ABS_MT_WIDTH_MINOR */ + int32_t ori; /* ABS_MT_ORIENTATION */ + int32_t x; /* ABS_MT_POSITION_X */ + int32_t y; /* ABS_MT_POSITION_Y */ + int32_t type; /* ABS_MT_TOOL_TYPE */ + int32_t blob_id; /* ABS_MT_BLOB_ID */ + int32_t id; /* ABS_MT_TRACKING_ID */ + int32_t p; /* ABS_MT_PRESSURE */ + int32_t dist; /* ABS_MT_DISTANCE */ + int32_t tool_x; /* ABS_MT_TOOL_X */ + int32_t tool_y; /* ABS_MT_TOOL_Y */ + }; +}; +_Static_assert(offsetof(union evdev_mt_slot, tool_y) == + offsetof(union evdev_mt_slot, val[ABS_MT_INDEX(ABS_MT_TOOL_Y)]), + "evdev_mt_slot array members does not match their structure aliases"); + /* Input device interface: */ struct evdev_dev *evdev_alloc(void); void evdev_free(struct evdev_dev *); @@ -134,6 +157,7 @@ void *evdev_get_softc(struct evdev_dev *); int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); void evdev_support_mt_compat(struct evdev_dev *); void evdev_push_mt_compat(struct evdev_dev *); +int evdev_mt_push_slot(struct evdev_dev *, int, union evdev_mt_slot *); void evdev_mt_push_autorel(struct evdev_dev *); static inline int evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index a3600e837960..6f5cce4a008d 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -60,10 +60,6 @@ struct { { ABS_MT_TOUCH_MAJOR, ABS_TOOL_WIDTH, 15 }, }; -struct evdev_mt_slot { - int32_t val[MT_CNT]; -}; - struct evdev_mt { int last_reported_slot; u_int mtst_events; @@ -71,7 +67,7 @@ struct evdev_mt { slotset_t touches; /* the set of slots with unsynchronized state */ slotset_t frame; - struct evdev_mt_slot slots[]; + union evdev_mt_slot slots[]; }; static void evdev_mt_send_st_compat(struct evdev_dev *); @@ -91,12 +87,11 @@ evdev_mt_init(struct evdev_dev *evdev) slots = MAXIMAL_MT_SLOT(evdev) + 1; evdev->ev_mt = malloc(offsetof(struct evdev_mt, slots) + - sizeof(struct evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); + sizeof(union evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); /* Initialize multitouch protocol type B states */ for (slot = 0; slot < slots; slot++) - evdev->ev_mt->slots[slot].val[ABS_MT_INDEX(ABS_MT_TRACKING_ID)] - = -1; + evdev->ev_mt->slots[slot].id = -1; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_support_mt_compat(evdev); @@ -119,6 +114,49 @@ evdev_mt_sync_frame(struct evdev_dev *evdev) evdev->ev_mt->frame = 0; } +static void +evdev_mt_send_slot(struct evdev_dev *evdev, int slot, + union evdev_mt_slot *state) +{ + int i; + bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); + + EVDEV_LOCK_ASSERT(evdev); + MPASS(type_a || (slot >= 0 && slot <= MAXIMAL_MT_SLOT(evdev))); + MPASS(!type_a || state != NULL); + + if (!type_a) { + evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); + if (state == NULL) { + evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); + return; + } + } + bit_foreach_at(evdev->ev_abs_flags, ABS_MT_FIRST, ABS_MT_LAST + 1, i) + evdev_send_event(evdev, EV_ABS, i, + state->val[ABS_MT_INDEX(i)]); + if (type_a) + evdev_send_event(evdev, EV_SYN, SYN_MT_REPORT, 1); +} + +int +evdev_mt_push_slot(struct evdev_dev *evdev, int slot, + union evdev_mt_slot *state) +{ + bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); + + if (type_a && state == NULL) + return (EINVAL); + if (!type_a && (slot < 0 || slot > MAXIMAL_MT_SLOT(evdev))) + return (EINVAL); + + EVDEV_ENTER(evdev); + evdev_mt_send_slot(evdev, slot, state); + EVDEV_EXIT(evdev); + + return (0); +} + int evdev_mt_get_last_slot(struct evdev_dev *evdev) { @@ -170,8 +208,7 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) int slot; FOREACHBIT(mt->touches, slot) - if (evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) == - tracking_id) + if (mt->slots[slot].id == tracking_id) return (slot); /* * Do not allow allocation of new slot in a place of just @@ -278,10 +315,8 @@ evdev_mt_send_autorel(struct evdev_dev *evdev) EVDEV_LOCK_ASSERT(evdev); - FOREACHBIT(mt->touches & ~mt->frame, slot) { - evdev_send_event(evdev, EV_ABS, ABS_MT_SLOT, slot); - evdev_send_event(evdev, EV_ABS, ABS_MT_TRACKING_ID, -1); - } + FOREACHBIT(mt->touches & ~mt->frame, slot) + evdev_mt_send_slot(evdev, slot, NULL); } void From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2DBA766925A; Tue, 24 Aug 2021 23: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 4GvPnL51kdz4Zqt; Tue, 24 Aug 2021 23: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 6945711B13; Tue, 24 Aug 2021 23: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 17ON4LaG000924; Tue, 24 Aug 2021 23: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 17ON4L8c000923; Tue, 24 Aug 2021 23:04:21 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:21 GMT Message-Id: <202108242304.17ON4L8c000923@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: d056693d7bc6 - main - evdev: Add support for automatic MT protocol type A to type B conversion. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d056693d7bc6c1b5f2c1612e5b34807f173e21c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:23 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=d056693d7bc6c1b5f2c1612e5b34807f173e21c7 commit d056693d7bc6c1b5f2c1612e5b34807f173e21c7 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:53:56 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:53:56 +0000 evdev: Add support for automatic MT protocol type A to type B conversion. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 5 +++-- sys/dev/evdev/evdev_mt.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 74335b6f40b1..2fd7c2e201ea 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -306,8 +306,9 @@ evdev_register_common(struct evdev_dev *evdev) } } - /* Initialize multitouch protocol type B states */ - if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + /* Initialize multitouch protocol type B states or A to B converter */ + if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT) || + bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) evdev_mt_init(evdev); /* Estimate maximum report size */ diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index d5bf4affea1b..3030a60e098a 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -79,6 +79,7 @@ struct evdev_mt { int last_reported_slot; uint16_t tracking_id; int32_t tracking_ids[MAX_MT_SLOTS]; + bool type_a; u_int mtst_events; /* the set of slots with active touches */ slotset_t touches; @@ -108,6 +109,16 @@ evdev_mt_init(struct evdev_dev *evdev) struct evdev_mt *mt; size_t size = offsetof(struct evdev_mt, slots); int slot, slots; + bool type_a; + + type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); + if (type_a) { + /* Add events produced by MT type A to type B converter */ + evdev_support_abs(evdev, + ABS_MT_SLOT, 0, MAX_MT_SLOTS - 1, 0, 0, 0); + evdev_support_abs(evdev, + ABS_MT_TRACKING_ID, -1, MAX_MT_SLOTS - 1, 0, 0, 0); + } slots = MAXIMAL_MT_SLOT(evdev) + 1; size += sizeof(mt->slots[0]) * slots; @@ -118,6 +129,7 @@ evdev_mt_init(struct evdev_dev *evdev) mt = malloc(size, M_EVDEV, M_WAITOK | M_ZERO); evdev->ev_mt = mt; + mt->type_a = type_a; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { mt->match_slots = mt->slots + slots; @@ -186,13 +198,16 @@ evdev_mt_push_slot(struct evdev_dev *evdev, int slot, struct evdev_mt *mt = evdev->ev_mt; bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); - if (type_a && state == NULL) + if ((type_a || (mt != NULL && mt->type_a)) && state == NULL) return (EINVAL); if (!type_a && (slot < 0 || slot > MAXIMAL_MT_SLOT(evdev))) return (EINVAL); EVDEV_ENTER(evdev); - if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK) && mt->type_a) { + mt->match_slots[mt->match_slot] = *state; + evdev_mt_record_event(evdev, EV_SYN, SYN_MT_REPORT, 1); + } else if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { evdev_mt_record_event(evdev, EV_ABS, ABS_MT_SLOT, slot); if (state != NULL) mt->match_slots[mt->match_slot] = *state; @@ -394,14 +409,25 @@ evdev_mt_record_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, EVDEV_LOCK_ASSERT(evdev); switch (type) { + case EV_SYN: + if (code == SYN_MT_REPORT) { + /* MT protocol type A support */ + KASSERT(mt->type_a, ("Not a MT type A protocol")); + mt->match_frame |= 1U << mt->match_slot; + mt->match_slot++; + return (true); + } + break; case EV_ABS: if (code == ABS_MT_SLOT) { /* MT protocol type B support */ + KASSERT(!mt->type_a, ("Not a MT type B protocol")); KASSERT(value >= 0, ("Negative slot number")); mt->match_slot = value; mt->match_frame |= 1U << mt->match_slot; return (true); } else if (code == ABS_MT_TRACKING_ID) { + KASSERT(!mt->type_a, ("Not a MT type B protocol")); if (value == -1) mt->match_frame &= ~(1U << mt->match_slot); return (true); @@ -496,6 +522,8 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) struct evdev_mt *mt = evdev->ev_mt; int slot; + KASSERT(!mt->type_a, ("Not a MT type B protocol")); + /* * Ignore tracking_id if slot assignment is performed by evdev. * Events are written sequentially to temporary matching buffer. From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 544E566938B; Tue, 24 Aug 2021 23: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 4GvPnH6dycz4ZnT; Tue, 24 Aug 2021 23: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 2216211B12; Tue, 24 Aug 2021 23: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 17ON4Jav000876; Tue, 24 Aug 2021 23: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 17ON4J7x000875; Tue, 24 Aug 2021 23:04:19 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:19 GMT Message-Id: <202108242304.17ON4J7x000875@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 4c0a134e32a7 - main - evdev: Import support for touch-tracking. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4c0a134e32a7f4dec556fea15c8de22f69864492 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:20 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=4c0a134e32a7f4dec556fea15c8de22f69864492 commit 4c0a134e32a7f4dec556fea15c8de22f69864492 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:50:53 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:50:53 +0000 evdev: Import support for touch-tracking. Touch tracking is a process of assignment of unique trackingID to each initiated contact on the surface. Keeping the trackingIDs persistent across multitouch reports requires solving of so called Euclidian Bipartite Matching problem. This commit imports EBM-solver implementation based on Dinitz-Kronrod algorithm to find minimum cost matching between contacts listed in two consecutive reports. Obtained from: OpenBSD MFC after: 2 weeks --- sys/dev/evdev/evdev.h | 3 + sys/dev/evdev/evdev_mt.c | 211 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 212 insertions(+), 2 deletions(-) diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index e1c5aedb029c..4cf885612c3e 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -91,6 +91,7 @@ extern int evdev_sysmouse_t_axis; #define EVDEV_FLAG_EXT_EPOCH 0x03 /* evdev_push_* is allways called with * input (global) epoch entered */ #define EVDEV_FLAG_MT_KEEPID 0x04 /* Do not reassign tracking ID */ +#define EVDEV_FLAG_MT_TRACK 0x05 /* Assign touch to slot by evdev */ #define EVDEV_FLAG_MAX 0x1F #define EVDEV_FLAG_CNT (EVDEV_FLAG_MAX + 1) @@ -159,6 +160,8 @@ int evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t); void evdev_support_mt_compat(struct evdev_dev *); void evdev_push_mt_compat(struct evdev_dev *); int evdev_mt_push_slot(struct evdev_dev *, int, union evdev_mt_slot *); +int evdev_mt_push_frame(struct evdev_dev *, union evdev_mt_slot *, int); +void evdev_mt_match_frame(struct evdev_dev *, union evdev_mt_slot *, int); void evdev_mt_push_autorel(struct evdev_dev *); static inline int evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 1a600fe3480d..f61943604a3a 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -25,6 +25,21 @@ * * $FreeBSD$ */ +/*- + * Copyright (c) 2015, 2016 Ulf Brosziewski + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #include #include @@ -69,6 +84,7 @@ struct evdev_mt { slotset_t touches; /* the set of slots with unsynchronized state */ slotset_t frame; + int *matrix; union evdev_mt_slot slots[]; }; @@ -84,12 +100,24 @@ ffc_slot(struct evdev_dev *evdev, slotset_t slots) void evdev_mt_init(struct evdev_dev *evdev) { + struct evdev_mt *mt; + size_t size = offsetof(struct evdev_mt, slots); int slot, slots; slots = MAXIMAL_MT_SLOT(evdev) + 1; + size += sizeof(mt->slots[0]) * slots; + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + size += sizeof(mt->matrix[0]) * (slots + 6) * slots; + } + + mt = malloc(size, M_EVDEV, M_WAITOK | M_ZERO); + evdev->ev_mt = mt; - evdev->ev_mt = malloc(offsetof(struct evdev_mt, slots) + - sizeof(union evdev_mt_slot) * slots, M_EVDEV, M_WAITOK | M_ZERO); + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + evdev_support_abs(evdev, + ABS_MT_TRACKING_ID, -1, slots - 1, 0, 0, 0); + mt->matrix = (int *)(mt->slots + slots); + } /* Initialize multitouch protocol type B states */ for (slot = 0; slot < slots; slot++) @@ -162,6 +190,185 @@ evdev_mt_push_slot(struct evdev_dev *evdev, int slot, return (0); } +/* + * Find a minimum-weight matching for an m-by-n matrix. + * + * m must be greater than or equal to n. The size of the buffer must be + * at least 3m + 3n. + * + * On return, the first m elements of the buffer contain the row-to- + * column mappings, i.e., buffer[i] is the column index for row i, or -1 + * if there is no assignment for that row (which may happen if n < m). + * + * Wrong results because of overflows will not occur with input values + * in the range of 0 to INT_MAX / 2 inclusive. + * + * The function applies the Dinic-Kronrod algorithm. It is not modern or + * popular, but it seems to be a good choice for small matrices at least. + * The original form of the algorithm is modified as follows: There is no + * initial search for row minima, the initial assignments are in a + * "virtual" column with the index -1 and zero values. This permits inputs + * with n < m, and it simplifies the reassignments. + */ +static void +evdev_mt_matching(int *matrix, int m, int n, int *buffer) +{ + int i, j, k, d, e, row, col, delta; + int *p; + int *r2c = buffer; /* row-to-column assignments */ + int *red = r2c + m; /* reduced values of the assignments */ + int *mc = red + m; /* row-wise minimal elements of cs */ + int *cs = mc + m; /* the column set */ + int *c2r = cs + n; /* column-to-row assignments in cs */ + int *cd = c2r + n; /* column deltas (reduction) */ + + for (p = r2c; p < red; *p++ = -1) {} + for (; p < mc; *p++ = 0) {} + for (col = 0; col < n; col++) { + delta = INT_MAX; + for (i = 0, p = matrix + col; i < m; i++, p += n) { + d = *p - red[i]; + if (d < delta || (d == delta && r2c[i] < 0)) { + delta = d; + row = i; + } + } + cd[col] = delta; + if (r2c[row] < 0) { + r2c[row] = col; + continue; + } + for (p = mc; p < cs; *p++ = col) {} + for (k = 0; (j = r2c[row]) >= 0;) { + cs[k++] = j; + c2r[j] = row; + mc[row] -= n; + delta = INT_MAX; + for (i = 0, p = matrix; i < m; i++, p += n) + if (mc[i] >= 0) { + d = p[mc[i]] - cd[mc[i]]; + e = p[j] - cd[j]; + if (e < d) { + d = e; + mc[i] = j; + } + d -= red[i]; + if (d < delta || (d == delta + && r2c[i] < 0)) { + delta = d; + row = i; + } + } + cd[col] += delta; + for (i = 0; i < k; i++) { + cd[cs[i]] += delta; + red[c2r[cs[i]]] -= delta; + } + } + for (j = mc[row]; (r2c[row] = j) != col;) { + row = c2r[j]; + j = mc[row] + n; + } + } +} + +/* + * Assign tracking IDs to the points in the pt array. The tracking ID + * assignment pairs the points with points of the previous frame in + * such a way that the sum of the squared distances is minimal. Using + * squares instead of simple distances favours assignments with more uniform + * distances, and it is faster. + * Set tracking id to -1 for unassigned (new) points. + */ +void +evdev_mt_match_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, + int size) +{ + struct evdev_mt *mt = evdev->ev_mt; + int i, j, m, n, dx, dy, slot, num_touches; + int *p, *r2c, *c2r; + + EVDEV_LOCK_ASSERT(evdev); + MPASS(mt->matrix != NULL); + MPASS(size >= 0 && size <= MAXIMAL_MT_SLOT(evdev) + 1); + + if (size == 0) + return; + + p = mt->matrix; + num_touches = bitcount(mt->touches); + if (num_touches >= size) { + FOREACHBIT(mt->touches, slot) + for (i = 0; i < size; i++) { + dx = pt[i].x - mt->slots[slot].x; + dy = pt[i].y - mt->slots[slot].y; + *p++ = dx * dx + dy * dy; + } + m = num_touches; + n = size; + } else { + for (i = 0; i < size; i++) + FOREACHBIT(mt->touches, slot) { + dx = pt[i].x - mt->slots[slot].x; + dy = pt[i].y - mt->slots[slot].y; + *p++ = dx * dx + dy * dy; + } + m = size; + n = num_touches; + } + evdev_mt_matching(mt->matrix, m, n, p); + + r2c = p; + c2r = p + m; + for (i = 0; i < m; i++) + if ((j = r2c[i]) >= 0) + c2r[j] = i; + + p = (n == size ? c2r : r2c); + for (i = 0; i < size; i++) + if (*p++ < 0) + pt[i].id = -1; + + p = (n == size ? r2c : c2r); + FOREACHBIT(mt->touches, slot) + if ((i = *p++) >= 0) + pt[i].id = mt->tracking_ids[slot]; +} + +static void +evdev_mt_send_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, int size) +{ + struct evdev_mt *mt = evdev->ev_mt; + union evdev_mt_slot *slot; + + EVDEV_LOCK_ASSERT(evdev); + MPASS(size >= 0 && size <= MAXIMAL_MT_SLOT(evdev) + 1); + + /* + * While MT-matching assign tracking IDs of new contacts to be equal + * to a slot number to make things simpler. + */ + for (slot = pt; slot < pt + size; slot++) { + if (slot->id < 0) + slot->id = ffc_slot(evdev, mt->touches | mt->frame); + if (slot->id >= 0) + evdev_mt_send_slot(evdev, slot->id, slot); + } +} + +int +evdev_mt_push_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, int size) +{ + if (size < 0 || size > MAXIMAL_MT_SLOT(evdev) + 1) + return (EINVAL); + + EVDEV_ENTER(evdev); + evdev_mt_send_frame(evdev, pt, size); + EVDEV_EXIT(evdev); + + return (0); +} + int evdev_mt_get_last_slot(struct evdev_dev *evdev) { From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EA0266915D; Tue, 24 Aug 2021 23: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 4GvPnG2ymdz4ZqY; Tue, 24 Aug 2021 23: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 0E573119D6; Tue, 24 Aug 2021 23: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 17ON4HHH000852; Tue, 24 Aug 2021 23: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 17ON4Hhk000851; Tue, 24 Aug 2021 23:04:17 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:17 GMT Message-Id: <202108242304.17ON4Hhk000851@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 66bd52f5e241 - main - evdev: Make MT tracking IDs monotonically increasing sequence. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 66bd52f5e241bd2548015f847f12cdff69176c40 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:20 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=66bd52f5e241bd2548015f847f12cdff69176c40 commit 66bd52f5e241bd2548015f847f12cdff69176c40 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:48:33 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:48:33 +0000 evdev: Make MT tracking IDs monotonically increasing sequence. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 16 ++++++++++++---- sys/dev/evdev/evdev.h | 1 + sys/dev/evdev/evdev_mt.c | 35 ++++++++++++++++++++++++++++++++++- sys/dev/evdev/evdev_private.h | 1 + sys/dev/evdev/uinput.c | 1 + 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index d6f6cc2e003f..b5eed0e5f02f 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -701,15 +701,23 @@ evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, break; case EV_ABS: - fuzz = evdev->ev_absinfo[code].fuzz; - if (fuzz == 0 || code == ABS_MT_SLOT) + if (code == ABS_MT_SLOT) break; else if (!ABS_IS_MT(code)) old_value = evdev->ev_absinfo[code].value; - else if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + else if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) + /* Pass MT protocol type A events as is */ + break; + else if (code == ABS_MT_TRACKING_ID) { + *value = evdev_mt_reassign_id(evdev, + evdev_mt_get_last_slot(evdev), *value); + break; + } else old_value = evdev_mt_get_value(evdev, evdev_mt_get_last_slot(evdev), code); - else /* Pass MT protocol type A events as is */ + + fuzz = evdev->ev_absinfo[code].fuzz; + if (fuzz == 0) break; abs_change = abs(*value - old_value); diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 64bf75f04efd..e1c5aedb029c 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -90,6 +90,7 @@ extern int evdev_sysmouse_t_axis; * current MT protocol type B report */ #define EVDEV_FLAG_EXT_EPOCH 0x03 /* evdev_push_* is allways called with * input (global) epoch entered */ +#define EVDEV_FLAG_MT_KEEPID 0x04 /* Do not reassign tracking ID */ #define EVDEV_FLAG_MAX 0x1F #define EVDEV_FLAG_CNT (EVDEV_FLAG_MAX + 1) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index 6f5cce4a008d..1a600fe3480d 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -62,6 +62,8 @@ struct { struct evdev_mt { int last_reported_slot; + uint16_t tracking_id; + int32_t tracking_ids[MAX_MT_SLOTS]; u_int mtst_events; /* the set of slots with active touches */ slotset_t touches; @@ -93,6 +95,9 @@ evdev_mt_init(struct evdev_dev *evdev) for (slot = 0; slot < slots; slot++) evdev->ev_mt->slots[slot].id = -1; + if (!bit_test(evdev->ev_flags, EVDEV_FLAG_MT_KEEPID)) + evdev_support_abs(evdev, + ABS_MT_TRACKING_ID, -1, UINT16_MAX, 0, 0, 0); if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT)) evdev_support_mt_compat(evdev); } @@ -208,7 +213,7 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) int slot; FOREACHBIT(mt->touches, slot) - if (mt->slots[slot].id == tracking_id) + if (mt->tracking_ids[slot] == tracking_id) return (slot); /* * Do not allow allocation of new slot in a place of just @@ -217,6 +222,34 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) return (ffc_slot(evdev, mt->touches | mt->frame)); } +int32_t +evdev_mt_reassign_id(struct evdev_dev *evdev, int slot, int32_t id) +{ + struct evdev_mt *mt = evdev->ev_mt; + int32_t nid; + + if (id == -1 || bit_test(evdev->ev_flags, EVDEV_FLAG_MT_KEEPID)) { + mt->tracking_ids[slot] = id; + return (id); + } + + nid = evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID); + if (nid != -1) { + KASSERT(id == mt->tracking_ids[slot], + ("MT-slot tracking id has changed")); + return (nid); + } + + mt->tracking_ids[slot] = id; +again: + nid = mt->tracking_id++; + FOREACHBIT(mt->touches, slot) + if (evdev_mt_get_value(evdev, slot, ABS_MT_TRACKING_ID) == nid) + goto again; + + return (nid); +} + static inline int32_t evdev_mt_normalize(int32_t value, int32_t mtmin, int32_t mtmax, int32_t stmax) { diff --git a/sys/dev/evdev/evdev_private.h b/sys/dev/evdev/evdev_private.h index fc079a324ba4..3fb2d61d091a 100644 --- a/sys/dev/evdev/evdev_private.h +++ b/sys/dev/evdev/evdev_private.h @@ -284,6 +284,7 @@ int evdev_mt_get_last_slot(struct evdev_dev *); void evdev_mt_set_last_slot(struct evdev_dev *, int); int32_t evdev_mt_get_value(struct evdev_dev *, int, int16_t); void evdev_mt_set_value(struct evdev_dev *, int, int16_t, int32_t); +int32_t evdev_mt_reassign_id(struct evdev_dev *, int, int32_t); /* Utility functions: */ void evdev_client_dumpqueue(struct evdev_client *); diff --git a/sys/dev/evdev/uinput.c b/sys/dev/evdev/uinput.c index ceecee652ac3..e7854e89f645 100644 --- a/sys/dev/evdev/uinput.c +++ b/sys/dev/evdev/uinput.c @@ -495,6 +495,7 @@ uinput_ioctl_sub(struct uinput_cdev_state *state, u_long cmd, caddr_t data) evdev_set_methods(state->ucs_evdev, state, &uinput_ev_methods); evdev_set_flag(state->ucs_evdev, EVDEV_FLAG_SOFTREPEAT); + evdev_set_flag(state->ucs_evdev, EVDEV_FLAG_MT_KEEPID); ret = evdev_register(state->ucs_evdev); if (ret == 0) state->ucs_state = UINPUT_RUNNING; From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1677669481; Tue, 24 Aug 2021 23: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 4GvPnN2Vc1z4Zx1; Tue, 24 Aug 2021 23: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 94A6711819; Tue, 24 Aug 2021 23: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 17ON4Mhf000954; Tue, 24 Aug 2021 23: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 17ON4Mtq000953; Tue, 24 Aug 2021 23:04:22 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:22 GMT Message-Id: <202108242304.17ON4Mtq000953@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9fa1201d60dc - main - atp(4), wsp(4): Return correct priority from probe() method; MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9fa1201d60dc7004f11d950f0fbd277bdcdcaf2d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:24 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9fa1201d60dc7004f11d950f0fbd277bdcdcaf2d commit 9fa1201d60dc7004f11d950f0fbd277bdcdcaf2d Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:59:17 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:59:17 +0000 atp(4), wsp(4): Return correct priority from probe() method; MFC after: 2 weeks --- sys/dev/usb/input/atp.c | 4 ++-- sys/dev/usb/input/wsp.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/dev/usb/input/atp.c b/sys/dev/usb/input/atp.c index 3515c08a1a6d..585afbaf1a1b 100644 --- a/sys/dev/usb/input/atp.c +++ b/sys/dev/usb/input/atp.c @@ -2175,11 +2175,11 @@ atp_probe(device_t self) if ((usbd_lookup_id_by_uaa(fg_devs, sizeof(fg_devs), uaa)) == 0) return ((uaa->info.bInterfaceProtocol == UIPROTO_MOUSE) ? - 0 : ENXIO); + BUS_PROBE_DEFAULT : ENXIO); if ((usbd_lookup_id_by_uaa(wsp_devs, sizeof(wsp_devs), uaa)) == 0) if (uaa->info.bIfaceIndex == WELLSPRING_INTERFACE_INDEX) - return (0); + return (BUS_PROBE_DEFAULT); return (ENXIO); } diff --git a/sys/dev/usb/input/wsp.c b/sys/dev/usb/input/wsp.c index c44c4aceb308..0c449726d916 100644 --- a/sys/dev/usb/input/wsp.c +++ b/sys/dev/usb/input/wsp.c @@ -720,7 +720,10 @@ wsp_probe(device_t self) /* check if we are attaching to the first match */ if (uaa->info.bIfaceIndex != i) return (ENXIO); - return (usbd_lookup_id_by_uaa(wsp_devs, sizeof(wsp_devs), uaa)); + if (usbd_lookup_id_by_uaa(wsp_devs, sizeof(wsp_devs), uaa) != 0) + return (ENXIO); + + return (BUS_PROBE_DEFAULT); } static int From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 27DF966907A; Tue, 24 Aug 2021 23: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 4GvPnK3xdyz4Zt8; Tue, 24 Aug 2021 23:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4267E11A88; Tue, 24 Aug 2021 23: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 17ON4KaB000900; Tue, 24 Aug 2021 23: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 17ON4KlT000899; Tue, 24 Aug 2021 23:04:20 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:20 GMT Message-Id: <202108242304.17ON4KlT000899@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: f76051c7dabe - main - evdev: Add implicit mode for touch tracking. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f76051c7dabe952b75127a8031d87d78b603be20 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:22 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=f76051c7dabe952b75127a8031d87d78b603be20 commit f76051c7dabe952b75127a8031d87d78b603be20 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:52:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:52:37 +0000 evdev: Add implicit mode for touch tracking. In implicit mode assignment of slot number and tracking id is performed automatically on each synchronization requested by device driver. This is done with creation of intermediate buffer for multitouch events. This buffer holds untracked events until synchronization is requested by device driver. It is needed as touch assigment requires knowledges of all touch positions pushed in current and previous reports. MFC after: 2 weeks --- sys/dev/evdev/evdev.c | 7 +++- sys/dev/evdev/evdev.h | 1 + sys/dev/evdev/evdev_mt.c | 97 ++++++++++++++++++++++++++++++++++++++++--- sys/dev/evdev/evdev_private.h | 1 + 4 files changed, 99 insertions(+), 7 deletions(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index b5eed0e5f02f..74335b6f40b1 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -951,8 +951,13 @@ evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, if (type == EV_SYN && code == SYN_REPORT && bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) evdev_mt_sync_frame(evdev); - evdev_send_event(evdev, type, code, value); + else + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK) && + evdev_mt_record_event(evdev, type, code, value)) + goto exit; + evdev_send_event(evdev, type, code, value); +exit: EVDEV_EXIT(evdev); return (0); diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 4cf885612c3e..dde9bba9b1e2 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -162,6 +162,7 @@ void evdev_push_mt_compat(struct evdev_dev *); int evdev_mt_push_slot(struct evdev_dev *, int, union evdev_mt_slot *); int evdev_mt_push_frame(struct evdev_dev *, union evdev_mt_slot *, int); void evdev_mt_match_frame(struct evdev_dev *, union evdev_mt_slot *, int); +union evdev_mt_slot *evdev_mt_get_match_slots(struct evdev_dev *); void evdev_mt_push_autorel(struct evdev_dev *); static inline int evdev_mt_id_to_slot(struct evdev_dev *evdev, int32_t id) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index f61943604a3a..d5bf4affea1b 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Vladimir Kondratyev + * Copyright (c) 2016, 2020 Vladimir Kondratyev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,12 +84,17 @@ struct evdev_mt { slotset_t touches; /* the set of slots with unsynchronized state */ slotset_t frame; + /* the set of slots to match with active touches */ + slotset_t match_frame; + int match_slot; + union evdev_mt_slot *match_slots; int *matrix; union evdev_mt_slot slots[]; }; static void evdev_mt_send_st_compat(struct evdev_dev *); static void evdev_mt_send_autorel(struct evdev_dev *); +static void evdev_mt_replay_events(struct evdev_dev *); static inline int ffc_slot(struct evdev_dev *evdev, slotset_t slots) @@ -107,6 +112,7 @@ evdev_mt_init(struct evdev_dev *evdev) slots = MAXIMAL_MT_SLOT(evdev) + 1; size += sizeof(mt->slots[0]) * slots; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + size += sizeof(mt->match_slots[0]) * slots; size += sizeof(mt->matrix[0]) * (slots + 6) * slots; } @@ -114,14 +120,13 @@ evdev_mt_init(struct evdev_dev *evdev) evdev->ev_mt = mt; if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { - evdev_support_abs(evdev, - ABS_MT_TRACKING_ID, -1, slots - 1, 0, 0, 0); - mt->matrix = (int *)(mt->slots + slots); + mt->match_slots = mt->slots + slots; + mt->matrix = (int *)(mt->match_slots + slots); } /* Initialize multitouch protocol type B states */ for (slot = 0; slot < slots; slot++) - evdev->ev_mt->slots[slot].id = -1; + mt->slots[slot].id = -1; if (!bit_test(evdev->ev_flags, EVDEV_FLAG_MT_KEEPID)) evdev_support_abs(evdev, @@ -139,6 +144,8 @@ evdev_mt_free(struct evdev_dev *evdev) void evdev_mt_sync_frame(struct evdev_dev *evdev) { + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) + evdev_mt_replay_events(evdev); if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL)) evdev_mt_send_autorel(evdev); if (evdev->ev_report_opened && @@ -176,6 +183,7 @@ int evdev_mt_push_slot(struct evdev_dev *evdev, int slot, union evdev_mt_slot *state) { + struct evdev_mt *mt = evdev->ev_mt; bool type_a = !bit_test(evdev->ev_abs_flags, ABS_MT_SLOT); if (type_a && state == NULL) @@ -184,7 +192,15 @@ evdev_mt_push_slot(struct evdev_dev *evdev, int slot, return (EINVAL); EVDEV_ENTER(evdev); - evdev_mt_send_slot(evdev, slot, state); + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) { + evdev_mt_record_event(evdev, EV_ABS, ABS_MT_SLOT, slot); + if (state != NULL) + mt->match_slots[mt->match_slot] = *state; + else + evdev_mt_record_event(evdev, EV_ABS, + ABS_MT_TRACKING_ID, -1); + } else + evdev_mt_send_slot(evdev, slot, state); EVDEV_EXIT(evdev); return (0); @@ -369,6 +385,67 @@ evdev_mt_push_frame(struct evdev_dev *evdev, union evdev_mt_slot *pt, int size) return (0); } +bool +evdev_mt_record_event(struct evdev_dev *evdev, uint16_t type, uint16_t code, + int32_t value) +{ + struct evdev_mt *mt = evdev->ev_mt; + + EVDEV_LOCK_ASSERT(evdev); + + switch (type) { + case EV_ABS: + if (code == ABS_MT_SLOT) { + /* MT protocol type B support */ + KASSERT(value >= 0, ("Negative slot number")); + mt->match_slot = value; + mt->match_frame |= 1U << mt->match_slot; + return (true); + } else if (code == ABS_MT_TRACKING_ID) { + if (value == -1) + mt->match_frame &= ~(1U << mt->match_slot); + return (true); + } else if (ABS_IS_MT(code)) { + KASSERT(mt->match_slot >= 0, ("Negative slot")); + KASSERT(mt->match_slot <= MAXIMAL_MT_SLOT(evdev), + ("Slot number too big")); + mt->match_slots[mt->match_slot]. + val[ABS_MT_INDEX(code)] = value; + return (true); + } + break; + default: + break; + } + + return (false); +} + +static void +evdev_mt_replay_events(struct evdev_dev *evdev) +{ + struct evdev_mt *mt = evdev->ev_mt; + int slot, size = 0; + + EVDEV_LOCK_ASSERT(evdev); + + FOREACHBIT(mt->match_frame, slot) { + if (slot != size) + mt->match_slots[size] = mt->match_slots[slot]; + size++; + } + evdev_mt_match_frame(evdev, mt->match_slots, size); + evdev_mt_send_frame(evdev, mt->match_slots, size); + mt->match_slot = 0; + mt->match_frame = 0; +} + +union evdev_mt_slot * +evdev_mt_get_match_slots(struct evdev_dev *evdev) +{ + return (evdev->ev_mt->match_slots); +} + int evdev_mt_get_last_slot(struct evdev_dev *evdev) { @@ -419,6 +496,13 @@ evdev_get_mt_slot_by_tracking_id(struct evdev_dev *evdev, int32_t tracking_id) struct evdev_mt *mt = evdev->ev_mt; int slot; + /* + * Ignore tracking_id if slot assignment is performed by evdev. + * Events are written sequentially to temporary matching buffer. + */ + if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) + return (ffc_slot(evdev, mt->match_frame)); + FOREACHBIT(mt->touches, slot) if (mt->tracking_ids[slot] == tracking_id) return (slot); @@ -554,6 +638,7 @@ evdev_mt_send_autorel(struct evdev_dev *evdev) int slot; EVDEV_LOCK_ASSERT(evdev); + KASSERT(mt->match_frame == 0, ("Unmatched events exist")); FOREACHBIT(mt->touches & ~mt->frame, slot) evdev_mt_send_slot(evdev, slot, NULL); diff --git a/sys/dev/evdev/evdev_private.h b/sys/dev/evdev/evdev_private.h index 3fb2d61d091a..48cd82ae0639 100644 --- a/sys/dev/evdev/evdev_private.h +++ b/sys/dev/evdev/evdev_private.h @@ -285,6 +285,7 @@ void evdev_mt_set_last_slot(struct evdev_dev *, int); int32_t evdev_mt_get_value(struct evdev_dev *, int, int16_t); void evdev_mt_set_value(struct evdev_dev *, int, int16_t, int32_t); int32_t evdev_mt_reassign_id(struct evdev_dev *, int, int32_t); +bool evdev_mt_record_event(struct evdev_dev *, uint16_t, uint16_t, int32_t); /* Utility functions: */ void evdev_client_dumpqueue(struct evdev_client *); From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F764669162; Tue, 24 Aug 2021 23: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 4GvPnN6CfTz4Znn; Tue, 24 Aug 2021 23: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 B750D118C6; Tue, 24 Aug 2021 23: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 17ON4Nl0000978; Tue, 24 Aug 2021 23: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 17ON4N9I000977; Tue, 24 Aug 2021 23:04:23 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:23 GMT Message-Id: <202108242304.17ON4N9I000977@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 250ab004074d - main - wsp(4): Compact parameter structure. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 250ab004074df27372b9afb18003c1e39d79aff5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:25 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=250ab004074df27372b9afb18003c1e39d79aff5 commit 250ab004074df27372b9afb18003c1e39d79aff5 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 22:59:48 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 22:59:48 +0000 wsp(4): Compact parameter structure. MFC after: 2 weeks --- sys/dev/usb/input/wsp.c | 295 ++++++++++++++++-------------------------------- 1 file changed, 96 insertions(+), 199 deletions(-) diff --git a/sys/dev/usb/input/wsp.c b/sys/dev/usb/input/wsp.c index 0c449726d916..cc99c4678633 100644 --- a/sys/dev/usb/input/wsp.c +++ b/sys/dev/usb/input/wsp.c @@ -169,7 +169,8 @@ enum tp_type { TYPE1, /* plain trackpad */ TYPE2, /* button integrated in trackpad */ TYPE3, /* additional header fields since June 2013 */ - TYPE4 /* additional header field for pressure data */ + TYPE4, /* additional header field for pressure data */ + TYPE_CNT }; /* trackpad finger data offsets, le16-aligned */ @@ -192,6 +193,67 @@ enum tp_type { #define FSIZE_TYPE3 (14 * 2) #define FSIZE_TYPE4 (15 * 2) +struct wsp_tp { + uint8_t caps; /* device capability bitmask */ + uint8_t button; /* offset to button data */ + uint8_t offset; /* offset to trackpad finger data */ + uint8_t fsize; /* bytes in single finger block */ + uint8_t delta; /* offset from header to finger struct */ + uint8_t iface_index; + uint8_t um_size; /* usb control message length */ + uint8_t um_req_idx; /* usb control message index */ + uint8_t um_switch_idx; /* usb control message mode switch index */ + uint8_t um_switch_on; /* usb control message mode switch on */ + uint8_t um_switch_off; /* usb control message mode switch off */ +} const static wsp_tp[TYPE_CNT] = { + [TYPE1] = { + .caps = 0, + .button = 0, + .offset = FINGER_TYPE1, + .fsize = FSIZE_TYPE1, + .delta = 0, + .iface_index = 0, + .um_size = 8, + .um_req_idx = 0x00, + .um_switch_idx = 0, + .um_switch_on = 0x01, + .um_switch_off = 0x08, + }, + [TYPE2] = { + .caps = HAS_INTEGRATED_BUTTON, + .button = BUTTON_TYPE2, + .offset = FINGER_TYPE2, + .fsize = FSIZE_TYPE2, + .delta = 0, + .iface_index = 0, + .um_size = 8, + .um_req_idx = 0x00, + .um_switch_idx = 0, + .um_switch_on = 0x01, + .um_switch_off = 0x08, + }, + [TYPE3] = { + .caps = HAS_INTEGRATED_BUTTON, + .button = BUTTON_TYPE3, + .offset = FINGER_TYPE3, + .fsize = FSIZE_TYPE3, + .delta = 0, + }, + [TYPE4] = { + .caps = HAS_INTEGRATED_BUTTON, + .button = BUTTON_TYPE4, + .offset = FINGER_TYPE4, + .fsize = FSIZE_TYPE4, + .delta = 2, + .iface_index = 2, + .um_size = 2, + .um_req_idx = 0x02, + .um_switch_idx = 1, + .um_switch_on = 0x01, + .um_switch_off = 0x00, + }, +}; + /* trackpad finger header - little endian */ struct tp_header { uint8_t flag; @@ -253,215 +315,48 @@ enum { /* device-specific configuration */ struct wsp_dev_params { - uint8_t caps; /* device capability bitmask */ - uint8_t tp_type; /* type of trackpad interface */ - uint8_t tp_button; /* offset to button data */ - uint8_t tp_offset; /* offset to trackpad finger data */ - uint8_t tp_fsize; /* bytes in single finger block */ - uint8_t tp_delta; /* offset from header to finger struct */ - uint8_t iface_index; - uint8_t um_size; /* usb control message length */ - uint8_t um_req_val; /* usb control message value */ - uint8_t um_req_idx; /* usb control message index */ - uint8_t um_switch_idx; /* usb control message mode switch index */ - uint8_t um_switch_on; /* usb control message mode switch on */ - uint8_t um_switch_off; /* usb control message mode switch off */ + const struct wsp_tp* tp; }; static const struct wsp_dev_params wsp_dev_params[WSP_FLAG_MAX] = { [WSP_FLAG_WELLSPRING1] = { - .caps = 0, - .tp_type = TYPE1, - .tp_button = 0, - .tp_offset = FINGER_TYPE1, - .tp_fsize = FSIZE_TYPE1, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE1, }, [WSP_FLAG_WELLSPRING2] = { - .caps = 0, - .tp_type = TYPE1, - .tp_button = 0, - .tp_offset = FINGER_TYPE1, - .tp_fsize = FSIZE_TYPE1, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE1, }, [WSP_FLAG_WELLSPRING3] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING4] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING4A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING5] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING6] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING5A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING6A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING7] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING7A] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE2, - .tp_button = BUTTON_TYPE2, - .tp_offset = FINGER_TYPE2, - .tp_fsize = FSIZE_TYPE2, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE2, }, [WSP_FLAG_WELLSPRING8] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE3, - .tp_button = BUTTON_TYPE3, - .tp_offset = FINGER_TYPE3, - .tp_fsize = FSIZE_TYPE3, - .tp_delta = 0, - .iface_index = 0, - .um_size = 8, - .um_req_val = 0x03, - .um_req_idx = 0x00, - .um_switch_idx = 0, - .um_switch_on = 0x01, - .um_switch_off = 0x08, + .tp = wsp_tp + TYPE3, }, [WSP_FLAG_WELLSPRING9] = { - .caps = HAS_INTEGRATED_BUTTON, - .tp_type = TYPE4, - .tp_button = BUTTON_TYPE4, - .tp_offset = FINGER_TYPE4, - .tp_fsize = FSIZE_TYPE4, - .tp_delta = 2, - .iface_index = 2, - .um_size = 2, - .um_req_val = 0x03, - .um_req_idx = 0x02, - .um_switch_idx = 1, - .um_switch_on = 0x01, - .um_switch_off = 0x00, + .tp = wsp_tp + TYPE4, }, }; #define WSP_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } @@ -647,12 +542,12 @@ wsp_set_device_mode(struct wsp_softc *sc, uint8_t on) usb_error_t err; /* Type 3 does not require a mode switch */ - if (params->tp_type == TYPE3) + if (params->tp == wsp_tp + TYPE3) return 0; err = usbd_req_get_report(sc->sc_usb_device, NULL, - mode_bytes, params->um_size, params->iface_index, - params->um_req_val, params->um_req_idx); + mode_bytes, params->tp->um_size, params->tp->iface_index, + UHID_FEATURE_REPORT, params->tp->um_req_idx); if (err != USB_ERR_NORMAL_COMPLETION) { DPRINTF("Failed to read device mode (%d)\n", err); @@ -667,12 +562,12 @@ wsp_set_device_mode(struct wsp_softc *sc, uint8_t on) */ pause("WHW", hz / 4); - mode_bytes[params->um_switch_idx] = - on ? params->um_switch_on : params->um_switch_off; + mode_bytes[params->tp->um_switch_idx] = + on ? params->tp->um_switch_on : params->tp->um_switch_off; return (usbd_req_set_report(sc->sc_usb_device, NULL, - mode_bytes, params->um_size, params->iface_index, - params->um_req_val, params->um_req_idx)); + mode_bytes, params->tp->um_size, params->tp->iface_index, + UHID_FEATURE_REPORT, params->tp->um_req_idx)); } static int @@ -881,8 +776,8 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, sc->tp_data, len); - if ((len < params->tp_offset + params->tp_fsize) || - ((len - params->tp_offset) % params->tp_fsize) != 0) { + if ((len < params->tp->offset + params->tp->fsize) || + ((len - params->tp->offset) % params->tp->fsize) != 0) { DPRINTFN(WSP_LLEVEL_INFO, "Invalid length: %d, %x, %x\n", len, sc->tp_data[0], sc->tp_data[1]); goto tr_setup; @@ -895,10 +790,12 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) h = (struct tp_header *)(sc->tp_data); - if (params->tp_type >= TYPE2) { - ibt = sc->tp_data[params->tp_button]; - ntouch = sc->tp_data[params->tp_button - 1]; - } + if (params->tp != wsp_tp + TYPE1) { + ibt = sc->tp_data[params->tp->button]; + ntouch = sc->tp_data[params->tp->button - 1]; + } else + ntouch = (len - params->tp->offset) / params->tp->fsize; + /* range check */ if (ntouch < 0) ntouch = 0; @@ -906,7 +803,7 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) ntouch = MAX_FINGERS; for (i = 0; i != ntouch; i++) { - f = (struct tp_finger *)(sc->tp_data + params->tp_offset + params->tp_delta + i * params->tp_fsize); + f = (struct tp_finger *)(sc->tp_data + params->tp->offset + params->tp->delta + i * params->tp->fsize); /* swap endianness, if any */ if (le16toh(0x1234) != 0x1234) { f->origin = le16toh((uint16_t)f->origin); @@ -940,9 +837,9 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) sc->sc_status.button = 0; if (ibt != 0) { - if ((params->caps & HAS_INTEGRATED_BUTTON) && ntouch == 2) + if ((params->tp->caps & HAS_INTEGRATED_BUTTON) && ntouch == 2) sc->sc_status.button |= MOUSE_BUTTON3DOWN; - else if ((params->caps & HAS_INTEGRATED_BUTTON) && ntouch == 3) + else if ((params->tp->caps & HAS_INTEGRATED_BUTTON) && ntouch == 3) sc->sc_status.button |= MOUSE_BUTTON2DOWN; else sc->sc_status.button |= MOUSE_BUTTON1DOWN; @@ -989,7 +886,7 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) */ switch (sc->ntaps) { case 1: - if (!(params->caps & HAS_INTEGRATED_BUTTON) || tun.enable_single_tap_clicks) { + if (!(params->tp->caps & HAS_INTEGRATED_BUTTON) || tun.enable_single_tap_clicks) { wsp_add_to_queue(sc, 0, 0, 0, MOUSE_BUTTON1DOWN); DPRINTFN(WSP_LLEVEL_INFO, "LEFT CLICK!\n"); } From owner-dev-commits-src-all@freebsd.org Tue Aug 24 23:04:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 13F3366916B; Tue, 24 Aug 2021 23: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 4GvPnQ5Cyrz4b2b; Tue, 24 Aug 2021 23:04: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 D2AFC117B4; Tue, 24 Aug 2021 23: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 17ON4OGh001002; Tue, 24 Aug 2021 23: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 17ON4ODq001001; Tue, 24 Aug 2021 23:04:24 GMT (envelope-from git) Date: Tue, 24 Aug 2021 23:04:24 GMT Message-Id: <202108242304.17ON4ODq001001@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 8d73071c47ff - main - wsp(4): Add evdev support. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8d73071c47ff1f911bdaec6356f37feb4e3b7cb5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 23:04:28 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=8d73071c47ff1f911bdaec6356f37feb4e3b7cb5 commit 8d73071c47ff1f911bdaec6356f37feb4e3b7cb5 Author: Vladimir Kondratyev AuthorDate: 2021-08-24 23:01:42 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-08-24 23:01:42 +0000 wsp(4): Add evdev support. Reviewed by: hselasky Tested by: Greg V, Constantin Furst MFC after: 2 weeks PR: 252236 Differential revision: https://reviews.freebsd.org/D31653 --- sys/dev/usb/input/wsp.c | 305 ++++++++++++++++++++++++++++++++++++++++--- sys/modules/usb/wsp/Makefile | 4 +- 2 files changed, 287 insertions(+), 22 deletions(-) diff --git a/sys/dev/usb/input/wsp.c b/sys/dev/usb/input/wsp.c index cc99c4678633..2c70b24d1f89 100644 --- a/sys/dev/usb/input/wsp.c +++ b/sys/dev/usb/input/wsp.c @@ -29,6 +29,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_evdev.h" + #include #include #include @@ -56,6 +58,11 @@ __FBSDID("$FreeBSD$"); #define USB_DEBUG_VAR wsp_debug #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + #include #define WSP_DRIVER_NAME "wsp" @@ -288,9 +295,14 @@ struct tp_finger { } __packed; /* trackpad finger data size, empirically at least ten fingers */ +#ifdef EVDEV_SUPPORT +#define MAX_FINGERS MAX_MT_SLOTS +#else #define MAX_FINGERS 16 +#endif #define SIZEOF_FINGER sizeof(struct tp_finger) #define SIZEOF_ALL_FINGERS (MAX_FINGERS * SIZEOF_FINGER) +#define MAX_FINGER_ORIENTATION 16384 #if (WSP_BUFFER_MAX < ((MAX_FINGERS * FSIZE_TYPE4) + FINGER_TYPE4)) #error "WSP_BUFFER_MAX is too small" @@ -313,50 +325,147 @@ enum { WSP_FLAG_MAX, }; +/* device-specific parameters */ +struct wsp_param { + int snratio; /* signal-to-noise ratio */ + int min; /* device minimum reading */ + int max; /* device maximum reading */ + int size; /* physical size, mm */ +}; + /* device-specific configuration */ struct wsp_dev_params { const struct wsp_tp* tp; + struct wsp_param p; /* finger pressure limits */ + struct wsp_param w; /* finger width limits */ + struct wsp_param x; /* horizontal limits */ + struct wsp_param y; /* vertical limits */ + struct wsp_param o; /* orientation limits */ }; +/* logical signal quality */ +#define SN_PRESSURE 45 /* pressure signal-to-noise ratio */ +#define SN_WIDTH 25 /* width signal-to-noise ratio */ +#define SN_COORD 250 /* coordinate signal-to-noise ratio */ +#define SN_ORIENT 10 /* orientation signal-to-noise ratio */ + static const struct wsp_dev_params wsp_dev_params[WSP_FLAG_MAX] = { [WSP_FLAG_WELLSPRING1] = { .tp = wsp_tp + TYPE1, + .p = { SN_PRESSURE, 0, 256, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4824, 5342, 105 }, + .y = { SN_COORD, -172, 5820, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING2] = { .tp = wsp_tp + TYPE1, + .p = { SN_PRESSURE, 0, 256, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4824, 4824, 105 }, + .y = { SN_COORD, -172, 4290, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING3] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4460, 5166, 105 }, + .y = { SN_COORD, -75, 6700, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING4] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING4A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4616, 5112, 105 }, + .y = { SN_COORD, -142, 5234, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING5] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4415, 5050, 105 }, + .y = { SN_COORD, -55, 6680, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING6] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING5A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4750, 5280, 105 }, + .y = { SN_COORD, -150, 6730, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING6A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING7] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4750, 5280, 105 }, + .y = { SN_COORD, -150, 6730, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING7A] = { .tp = wsp_tp + TYPE2, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4750, 5280, 105 }, + .y = { SN_COORD, -150, 6730, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING8] = { .tp = wsp_tp + TYPE3, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4620, 5140, 105 }, + .y = { SN_COORD, -150, 6600, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, [WSP_FLAG_WELLSPRING9] = { .tp = wsp_tp + TYPE4, + .p = { SN_PRESSURE, 0, 300, 0 }, + .w = { SN_WIDTH, 0, 2048, 0 }, + .x = { SN_COORD, -4828, 5345, 105 }, + .y = { SN_COORD, -203, 6803, 75 }, + .o = { SN_ORIENT, + -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, }, }; #define WSP_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } @@ -445,12 +554,17 @@ struct wsp_softc { const struct wsp_dev_params *sc_params; /* device configuration */ +#ifdef EVDEV_SUPPORT + struct evdev_dev *sc_evdev; +#endif mousehw_t sc_hw; mousemode_t sc_mode; u_int sc_pollrate; mousestatus_t sc_status; + int sc_fflags; u_int sc_state; -#define WSP_ENABLED 0x01 +#define WSP_ENABLED 0x01 +#define WSP_EVDEV_OPENED 0x02 struct tp_finger *index[MAX_FINGERS]; /* finger index data */ int16_t pos_x[MAX_FINGERS]; /* position array */ @@ -491,8 +605,8 @@ struct wsp_softc { /* * function prototypes */ -static usb_fifo_cmd_t wsp_start_read; -static usb_fifo_cmd_t wsp_stop_read; +static usb_fifo_cmd_t wsp_fifo_start_read; +static usb_fifo_cmd_t wsp_fifo_stop_read; static usb_fifo_open_t wsp_open; static usb_fifo_close_t wsp_close; static usb_fifo_ioctl_t wsp_ioctl; @@ -501,11 +615,20 @@ static struct usb_fifo_methods wsp_fifo_methods = { .f_open = &wsp_open, .f_close = &wsp_close, .f_ioctl = &wsp_ioctl, - .f_start_read = &wsp_start_read, - .f_stop_read = &wsp_stop_read, + .f_start_read = &wsp_fifo_start_read, + .f_stop_read = &wsp_fifo_stop_read, .basename[0] = WSP_DRIVER_NAME, }; +#ifdef EVDEV_SUPPORT +static evdev_open_t wsp_ev_open; +static evdev_close_t wsp_ev_close; +static const struct evdev_methods wsp_evdev_methods = { + .ev_open = &wsp_ev_open, + .ev_close = &wsp_ev_close, +}; +#endif + /* device initialization and shutdown */ static int wsp_enable(struct wsp_softc *sc); static void wsp_disable(struct wsp_softc *sc); @@ -714,6 +837,56 @@ wsp_attach(device_t dev) sc->sc_touch = WSP_UNTOUCH; sc->scr_mode = WSP_SCR_NONE; +#ifdef EVDEV_SUPPORT + sc->sc_evdev = evdev_alloc(); + evdev_set_name(sc->sc_evdev, device_get_desc(dev)); + evdev_set_phys(sc->sc_evdev, device_get_nameunit(dev)); + evdev_set_id(sc->sc_evdev, BUS_USB, uaa->info.idVendor, + uaa->info.idProduct, 0); + evdev_set_serial(sc->sc_evdev, usb_get_serial(uaa->device)); + evdev_set_methods(sc->sc_evdev, sc, &wsp_evdev_methods); + evdev_support_prop(sc->sc_evdev, INPUT_PROP_POINTER); + evdev_support_event(sc->sc_evdev, EV_SYN); + evdev_support_event(sc->sc_evdev, EV_ABS); + evdev_support_event(sc->sc_evdev, EV_KEY); + +#define WSP_SUPPORT_ABS(evdev, code, param) \ + evdev_support_abs((evdev), (code), (param).min, (param).max, \ + ((param).max - (param).min) / (param).snratio, 0, \ + (param).size != 0 ? ((param).max - (param).min) / (param).size : 0); + + /* finger position */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_POSITION_X, sc->sc_params->x); + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_POSITION_Y, sc->sc_params->y); + /* finger pressure */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_PRESSURE, sc->sc_params->p); + /* finger touch area */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_TOUCH_MAJOR, sc->sc_params->w); + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_TOUCH_MINOR, sc->sc_params->w); + /* finger approach area */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_WIDTH_MAJOR, sc->sc_params->w); + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_WIDTH_MINOR, sc->sc_params->w); + /* finger orientation */ + WSP_SUPPORT_ABS(sc->sc_evdev, ABS_MT_ORIENTATION, sc->sc_params->o); + /* button properties */ + evdev_support_key(sc->sc_evdev, BTN_LEFT); + if ((sc->sc_params->tp->caps & HAS_INTEGRATED_BUTTON) != 0) + evdev_support_prop(sc->sc_evdev, INPUT_PROP_BUTTONPAD); + /* Enable automatic touch assignment for type B MT protocol */ + evdev_support_abs(sc->sc_evdev, ABS_MT_SLOT, + 0, MAX_FINGERS - 1, 0, 0, 0); + evdev_support_abs(sc->sc_evdev, ABS_MT_TRACKING_ID, + -1, MAX_FINGERS - 1, 0, 0, 0); + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_TRACK); + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_AUTOREL); + /* Synaptics compatibility events */ + evdev_set_flag(sc->sc_evdev, EVDEV_FLAG_MT_STCOMPAT); + + err = evdev_register(sc->sc_evdev); + if (err) + goto detach; +#endif + return (0); detach: @@ -735,6 +908,10 @@ wsp_detach(device_t dev) usb_fifo_detach(&sc->sc_fifo); +#ifdef EVDEV_SUPPORT + evdev_free(sc->sc_evdev); +#endif + usbd_transfer_unsetup(sc->sc_xfer, WSP_N_TRANSFER); mtx_destroy(&sc->sc_mutex); @@ -761,6 +938,9 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) int rdz = 0; int len; int i; +#ifdef EVDEV_SUPPORT + int slot = 0; +#endif wsp_runing_rangecheck(&tun); @@ -829,8 +1009,31 @@ wsp_intr_callback(struct usb_xfer *xfer, usb_error_t error) sc->pos_x[i] = f->abs_x; sc->pos_y[i] = -f->abs_y; sc->index[i] = f; +#ifdef EVDEV_SUPPORT + if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE && f->touch_major != 0) { + union evdev_mt_slot slot_data = { + .id = slot, + .x = f->abs_x, + .y = params->y.min + params->y.max - f->abs_y, + .p = f->pressure, + .maj = f->touch_major << 1, + .min = f->touch_minor << 1, + .w_maj = f->tool_major << 1, + .w_min = f->tool_minor << 1, + .ori = params->o.max - f->orientation, + }; + evdev_mt_push_slot(sc->sc_evdev, slot, &slot_data); + slot++; + } +#endif } +#ifdef EVDEV_SUPPORT + if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE) { + evdev_push_key(sc->sc_evdev, BTN_LEFT, ibt); + evdev_sync(sc->sc_evdev); + } +#endif sc->sc_status.flags &= ~MOUSE_POSCHANGED; sc->sc_status.flags &= ~MOUSE_STDBUTTONSCHANGED; sc->sc_status.obutton = sc->sc_status.button; @@ -1135,9 +1338,8 @@ wsp_reset_buf(struct wsp_softc *sc) } static void -wsp_start_read(struct usb_fifo *fifo) +wsp_start_read(struct wsp_softc *sc) { - struct wsp_softc *sc = usb_fifo_softc(fifo); int rate; /* Check if we should override the default polling interval */ @@ -1158,49 +1360,109 @@ wsp_start_read(struct usb_fifo *fifo) } static void -wsp_stop_read(struct usb_fifo *fifo) +wsp_stop_read(struct wsp_softc *sc) { - struct wsp_softc *sc = usb_fifo_softc(fifo); - usbd_transfer_stop(sc->sc_xfer[WSP_INTR_DT]); } static int wsp_open(struct usb_fifo *fifo, int fflags) { - DPRINTFN(WSP_LLEVEL_INFO, "\n"); + struct wsp_softc *sc = usb_fifo_softc(fifo); + int rc = 0; - if (fflags & FREAD) { - struct wsp_softc *sc = usb_fifo_softc(fifo); - int rc; + DPRINTFN(WSP_LLEVEL_INFO, "\n"); - if (sc->sc_state & WSP_ENABLED) - return (EBUSY); + if (sc->sc_fflags & fflags) + return (EBUSY); + if (fflags & FREAD) { if (usb_fifo_alloc_buffer(fifo, WSP_FIFO_BUF_SIZE, WSP_FIFO_QUEUE_MAXLEN)) { return (ENOMEM); } - rc = wsp_enable(sc); +#ifdef EVDEV_SUPPORT + if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) +#endif + rc = wsp_enable(sc); if (rc != 0) { usb_fifo_free_buffer(fifo); return (rc); } } + sc->sc_fflags |= fflags & (FREAD | FWRITE); return (0); } static void wsp_close(struct usb_fifo *fifo, int fflags) { - if (fflags & FREAD) { - struct wsp_softc *sc = usb_fifo_softc(fifo); + struct wsp_softc *sc = usb_fifo_softc(fifo); - wsp_disable(sc); + if (fflags & FREAD) { +#ifdef EVDEV_SUPPORT + if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) +#endif + wsp_disable(sc); usb_fifo_free_buffer(fifo); } + + sc->sc_fflags &= ~(fflags & (FREAD | FWRITE)); +} + +static void +wsp_fifo_start_read(struct usb_fifo *fifo) +{ + struct wsp_softc *sc = usb_fifo_softc(fifo); + + wsp_start_read(sc); +} + +static void +wsp_fifo_stop_read(struct usb_fifo *fifo) +{ + struct wsp_softc *sc = usb_fifo_softc(fifo); + +#ifdef EVDEV_SUPPORT + if ((sc->sc_state & WSP_EVDEV_OPENED) == 0) +#endif + wsp_stop_read(sc); } +#ifdef EVDEV_SUPPORT +static int +wsp_ev_open(struct evdev_dev *evdev) +{ + struct wsp_softc *sc = evdev_get_softc(evdev); + int rc = 0; + + mtx_lock(&sc->sc_mutex); + if (sc->sc_fflags == 0) + rc = wsp_enable(sc); + if (rc == 0) { + wsp_start_read(sc); + sc->sc_state |= WSP_EVDEV_OPENED; + } + mtx_unlock(&sc->sc_mutex); + + return (rc); +} + +static int +wsp_ev_close(struct evdev_dev *evdev) +{ + struct wsp_softc *sc = evdev_get_softc(evdev); + + mtx_lock(&sc->sc_mutex); + sc->sc_state &= ~WSP_EVDEV_OPENED; + if (sc->sc_fflags == 0) + wsp_stop_read(sc); + mtx_unlock(&sc->sc_mutex); + + return (0); +} +#endif + int wsp_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags) { @@ -1312,5 +1574,8 @@ static devclass_t wsp_devclass; DRIVER_MODULE(wsp, uhub, wsp_driver, wsp_devclass, NULL, 0); MODULE_DEPEND(wsp, usb, 1, 1, 1); MODULE_DEPEND(wsp, hid, 1, 1, 1); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(wsp, evdev, 1, 1, 1); +#endif MODULE_VERSION(wsp, 1); USB_PNP_HOST_INFO(wsp_devs); diff --git a/sys/modules/usb/wsp/Makefile b/sys/modules/usb/wsp/Makefile index a5215c0150f5..73a289a09544 100644 --- a/sys/modules/usb/wsp/Makefile +++ b/sys/modules/usb/wsp/Makefile @@ -30,7 +30,7 @@ S= ${SRCTOP}/sys .PATH: $S/dev/usb/input KMOD= wsp -SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h vnode_if.h usbdevs.h \ - wsp.c +SRCS= opt_bus.h opt_evdev.h opt_usb.h device_if.h bus_if.h usb_if.h \ + vnode_if.h usbdevs.h wsp.c .include From owner-dev-commits-src-all@freebsd.org Wed Aug 25 01:53:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1ED6F66C01F; Wed, 25 Aug 2021 01:53: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 4GvTY109R2z4S1N; Wed, 25 Aug 2021 01:53: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 E232613E9D; Wed, 25 Aug 2021 01:53: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 17P1ruLL025567; Wed, 25 Aug 2021 01:53:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P1ruXj025566; Wed, 25 Aug 2021 01:53:56 GMT (envelope-from git) Date: Wed, 25 Aug 2021 01:53:56 GMT Message-Id: <202108250153.17P1ruXj025566@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: 143efcdb3b8c - stable/13 - cam(4): Mark all sysctls as CTLFLAG_MPSAFE. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 143efcdb3b8ce64fc051e0a48055d2ad5cb9648b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 01:53:57 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=143efcdb3b8ce64fc051e0a48055d2ad5cb9648b commit 143efcdb3b8ce64fc051e0a48055d2ad5cb9648b Author: Alexander Motin AuthorDate: 2021-08-11 00:05:40 +0000 Commit: Alexander Motin CommitDate: 2021-08-25 01:53:17 +0000 cam(4): Mark all sysctls as CTLFLAG_MPSAFE. This code does not use Giant lock for very long time. MFC after: 2 weeks (cherry picked from commit 303477d3253007bb5732deed2daea86b2cbd9aa8) --- sys/cam/ata/ata_da.c | 6 +++--- sys/cam/cam_iosched.c | 14 +++++++------- sys/cam/ctl/ctl.c | 2 +- sys/cam/ctl/ctl_ha.c | 2 +- sys/cam/scsi/scsi_all.c | 2 +- sys/cam/scsi/scsi_cd.c | 2 +- sys/cam/scsi/scsi_da.c | 12 ++++++------ sys/cam/scsi/scsi_xpt.c | 24 ++---------------------- 8 files changed, 22 insertions(+), 42 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 38d996510f98..36d0416a65a4 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1483,7 +1483,7 @@ adasysctlinit(void *context, int pending) SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_method", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, softc, 0, adadeletemethodsysctl, "A", "BIO_DELETE execution method"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, @@ -1506,12 +1506,12 @@ adasysctlinit(void *context, int pending) &softc->write_cache, 0, "Enable disk write cache."); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_mode", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, adazonemodesysctl, "A", "Zone Mode"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_support", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, adazonesupsysctl, "A", "Zone Support"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index 218b52687f42..50b6db88cebd 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -1009,7 +1009,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "limiter", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, ios, 0, cam_iosched_limiter_sysctl, "A", "Current limiting type."); SYSCTL_ADD_INT(ctx, n, @@ -1027,7 +1027,7 @@ cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stat SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "latencies", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, &ios->latencies, 0, cam_iosched_sysctl_latencies, "A", "Array of power of 2 latency from 1ms to 1.024s"); @@ -1057,22 +1057,22 @@ cam_iosched_cl_sysctl_init(struct cam_iosched_softc *isc) SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "type", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, clp, 0, cam_iosched_control_type_sysctl, "A", "Control loop algorithm"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "steer_interval", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->steer_interval, 0, cam_iosched_sbintime_sysctl, "A", "How often to steer (in us)"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "lolat", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->lolat, 0, cam_iosched_sbintime_sysctl, "A", "Low water mark for Latency (in us)"); SYSCTL_ADD_PROC(ctx, n, OID_AUTO, "hilat", - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, &clp->hilat, 0, cam_iosched_sbintime_sysctl, "A", "Hi water mark for Latency (in us)"); SYSCTL_ADD_INT(ctx, n, @@ -1200,7 +1200,7 @@ void cam_iosched_sysctl_init(struct cam_iosched_softc *isc, "How biased towards read should we be independent of limits"); SYSCTL_ADD_PROC(ctx, n, - OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + OID_AUTO, "quanta", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, &isc->quanta, 0, cam_iosched_quanta_sysctl, "I", "How many quanta per second do we slice the I/O up into"); diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 575c8eea5198..8ad8bcec434b 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -1978,7 +1978,7 @@ ctl_init(void) SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "ha_role", - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, ctl_ha_role_sysctl, "I", "HA role for this head"); if (softc->is_single == 0) { diff --git a/sys/cam/ctl/ctl_ha.c b/sys/cam/ctl/ctl_ha.c index 80dfc543303d..e2ecb9706f56 100644 --- a/sys/cam/ctl/ctl_ha.c +++ b/sys/cam/ctl/ctl_ha.c @@ -896,7 +896,7 @@ ctl_ha_msg_init(struct ctl_softc *ctl_softc) SYSCTL_ADD_PROC(&ctl_softc->sysctl_ctx, SYSCTL_CHILDREN(ctl_softc->sysctl_tree), OID_AUTO, "ha_peer", - CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, ctl_ha_peer_sysctl, "A", "HA peer connection method"); if (ctl_ha_msg_register(CTL_HA_CHAN_DATA, ctl_dt_event_handler) diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c index a84c5b8d6c22..729a2a06e616 100644 --- a/sys/cam/scsi/scsi_all.c +++ b/sys/cam/scsi/scsi_all.c @@ -9236,7 +9236,7 @@ sysctl_scsi_delay(SYSCTL_HANDLER_ARGS) return (set_scsi_delay(delay)); } SYSCTL_PROC(_kern_cam, OID_AUTO, scsi_delay, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, 0, sysctl_scsi_delay, "I", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_scsi_delay, "I", "Delay to allow devices to settle after a SCSI bus reset (ms)"); static int diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index e009b0a586c3..da367ad65c5d 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -539,7 +539,7 @@ cdsysctlinit(void *context, int pending) */ SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "minimum_cmd_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->minimum_command_size, 0, cdcmdsizesysctl, "I", "Minimum CDB size"); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index b281dbfd4ee1..abe66e4acd35 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1575,7 +1575,7 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, &da_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, dasysctlsofttimeout, "I", "Soft I/O timeout (ms)"); TUNABLE_INT64("kern.cam.da.default_softtimeout", &da_default_softtimeout); @@ -2272,17 +2272,17 @@ dasysctlinit(void *context, int pending) */ SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_method", - CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0, dadeletemethodsysctl, "A", "BIO_DELETE execution method"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "delete_max", - CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, softc, 0, dadeletemaxsysctl, "Q", "Maximum BIO_DELETE size"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "minimum_cmd_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->minimum_cmd_size, 0, dacmdsizesysctl, "I", "Minimum CDB size"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, @@ -2300,12 +2300,12 @@ dasysctlinit(void *context, int pending) SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_mode", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, dazonemodesysctl, "A", "Zone Mode"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_support", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, softc, 0, dazonesupsysctl, "A", "Zone Support"); SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 2ec1490c0edf..24e8d420a88d 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -79,11 +79,8 @@ struct scsi_quirk_entry { #define SCSI_QUIRK(dev) ((struct scsi_quirk_entry *)((dev)->quirk)) static int cam_srch_hi = 0; -static int sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 0, 0, - sysctl_cam_search_luns, "I", - "allow search above LUN 7 for SCSI3 and greater devices"); +SYSCTL_INT(_kern_cam, OID_AUTO, cam_srch_hi, CTLFLAG_RWTUN, + &cam_srch_hi, 0, "Search above LUN 7 for SCSI3 and greater devices"); #define CAM_SCSI2_MAXLUN 8 #define CAM_CAN_GET_SIMPLE_LUN(x, i) \ @@ -1903,23 +1900,6 @@ scsi_find_quirk(struct cam_ed *device) device->maxtags = quirk->maxtags; } -static int -sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS) -{ - int error, val; - - val = cam_srch_hi; - error = sysctl_handle_int(oidp, &val, 0, req); - if (error != 0 || req->newptr == NULL) - return (error); - if (val == 0 || val == 1) { - cam_srch_hi = val; - return (0); - } else { - return (EINVAL); - } -} - typedef struct { union ccb *request_ccb; struct ccb_pathinq *cpi; From owner-dev-commits-src-all@freebsd.org Wed Aug 25 01:53:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 43DBA66BE8C; Wed, 25 Aug 2021 01:53:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvTY21Bz3z4S5g; Wed, 25 Aug 2021 01:53:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1254313CE4; Wed, 25 Aug 2021 01:53:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17P1rvke025591; Wed, 25 Aug 2021 01:53:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P1rvLi025590; Wed, 25 Aug 2021 01:53:57 GMT (envelope-from git) Date: Wed, 25 Aug 2021 01:53:57 GMT Message-Id: <202108250153.17P1rvLi025590@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: abe64b99b38b - stable/13 - geom(4): Mark all sysctls as CTLFLAG_MPSAFE. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: abe64b99b38b1a8fbded31e820acc7b25b9cc0fb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 01:53:58 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=abe64b99b38b1a8fbded31e820acc7b25b9cc0fb commit abe64b99b38b1a8fbded31e820acc7b25b9cc0fb Author: Alexander Motin AuthorDate: 2021-08-11 00:18:46 +0000 Commit: Alexander Motin CommitDate: 2021-08-25 01:53:17 +0000 geom(4): Mark all sysctls as CTLFLAG_MPSAFE. This code does not use Giant lock for very long time. MFC after: 2 weeks (cherry picked from commit c2da954203c0feb933d3be304710e0346c9ed222) --- sys/geom/cache/g_cache.c | 4 ++-- sys/geom/geom_disk.c | 2 +- sys/geom/geom_kern.c | 6 +++--- sys/geom/journal/g_journal.c | 6 +++--- sys/geom/stripe/g_stripe.c | 16 ++-------------- sys/geom/zero/g_zero.c | 2 +- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/sys/geom/cache/g_cache.c b/sys/geom/cache/g_cache.c index 05e45e6ea452..2caae5ede0f4 100644 --- a/sys/geom/cache/g_cache.c +++ b/sys/geom/cache/g_cache.c @@ -85,11 +85,11 @@ sysctl_handle_pct(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_cache, OID_AUTO, used_lo, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &g_cache_used_lo, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, &g_cache_used_lo, 0, sysctl_handle_pct, "IU", ""); SYSCTL_PROC(_kern_geom_cache, OID_AUTO, used_hi, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &g_cache_used_hi, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, &g_cache_used_hi, 0, sysctl_handle_pct, "IU", ""); diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index fb215fb3dab5..3ce203c33a73 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -745,7 +745,7 @@ g_disk_create(void *arg, int flag) "LED name"); SYSCTL_ADD_PROC(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "flags", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, dp, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dp, 0, g_disk_sysctl_flags, "A", "Report disk flags"); } pp->private = sc; diff --git a/sys/geom/geom_kern.c b/sys/geom/geom_kern.c index e06824afc9fd..4b7219591dce 100644 --- a/sys/geom/geom_kern.c +++ b/sys/geom/geom_kern.c @@ -208,17 +208,17 @@ SYSCTL_NODE(_kern, OID_AUTO, geom, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "GEOMetry management"); SYSCTL_PROC(_kern_geom, OID_AUTO, confxml, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, 0, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_geom_confxml, "", "Dump the GEOM config in XML"); SYSCTL_PROC(_kern_geom, OID_AUTO, confdot, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, 0, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_geom_confdot, "", "Dump the GEOM config in dot"); SYSCTL_PROC(_kern_geom, OID_AUTO, conftxt, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, 0, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_geom_conftxt, "", "Dump the GEOM config in txt"); diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 0b518d172b5a..7c8c60183bff 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -129,7 +129,7 @@ g_journal_record_entries_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal, OID_AUTO, record_entries, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, g_journal_record_entries_sysctl, "I", "Maximum number of entires in one journal record"); SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, @@ -163,7 +163,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0, g_journal_cache_limit_sysctl, "I", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, @@ -186,7 +186,7 @@ g_journal_cache_switch_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, switch, - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, g_journal_cache_switch_sysctl, "I", "Force switch when we hit this percent of cache use"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, misses, CTLFLAG_RW, diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c index 22cc16753d9a..9b4df1b8dba6 100644 --- a/sys/geom/stripe/g_stripe.c +++ b/sys/geom/stripe/g_stripe.c @@ -77,20 +77,8 @@ static u_int g_stripe_debug = 0; SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RWTUN, &g_stripe_debug, 0, "Debug level"); static int g_stripe_fast = 0; -static int -g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) -{ - int error, fast; - - fast = g_stripe_fast; - error = sysctl_handle_int(oidp, &fast, 0, req); - if (error == 0 && req->newptr != NULL) - g_stripe_fast = fast; - return (error); -} -SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, NULL, 0, - g_sysctl_stripe_fast, "I", +SYSCTL_INT(_kern_geom_stripe, OID_AUTO, fast, + CTLFLAG_RWTUN, &g_stripe_fast, 0, "Fast, but memory-consuming, mode"); static u_long g_stripe_maxmem; SYSCTL_ULONG(_kern_geom_stripe, OID_AUTO, maxmem, diff --git a/sys/geom/zero/g_zero.c b/sys/geom/zero/g_zero.c index ef43a032d470..c533a758a236 100644 --- a/sys/geom/zero/g_zero.c +++ b/sys/geom/zero/g_zero.c @@ -49,7 +49,7 @@ static SYSCTL_NODE(_kern_geom, OID_AUTO, zero, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "GEOM_ZERO stuff"); static int g_zero_clear = 1; SYSCTL_PROC(_kern_geom_zero, OID_AUTO, clear, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &g_zero_clear, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, &g_zero_clear, 0, g_zero_clear_sysctl, "I", "Clear read data buffer"); static int g_zero_byte = 0; From owner-dev-commits-src-all@freebsd.org Wed Aug 25 01:53:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9AA5A66BE91; Wed, 25 Aug 2021 01:53:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvTY32czwz4Rjr; Wed, 25 Aug 2021 01:53:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C57813CE5; Wed, 25 Aug 2021 01:53: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 17P1rxlR025615; Wed, 25 Aug 2021 01:53:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P1rxCQ025614; Wed, 25 Aug 2021 01:53:59 GMT (envelope-from git) Date: Wed, 25 Aug 2021 01:53:59 GMT Message-Id: <202108250153.17P1rxCQ025614@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: 2daa57cafbc8 - stable/13 - Mark some sysctls as CTLFLAG_MPSAFE. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2daa57cafbc816061a1ec56bf484a8a4b31dcf42 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 01:53:59 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=2daa57cafbc816061a1ec56bf484a8a4b31dcf42 commit 2daa57cafbc816061a1ec56bf484a8a4b31dcf42 Author: Alexander Motin AuthorDate: 2021-08-11 00:44:27 +0000 Commit: Alexander Motin CommitDate: 2021-08-25 01:53:18 +0000 Mark some sysctls as CTLFLAG_MPSAFE. MFC after: 2 weeks (cherry picked from commit b776de6796fa0cd1b7dfaad75402e10907d47f29) --- sys/dev/ahci/ahci.c | 2 +- sys/dev/ioat/ioat.c | 6 +++--- sys/dev/isp/isp_freebsd.c | 2 +- sys/dev/mpr/mpr.c | 2 +- sys/dev/mps/mps.c | 6 +++--- sys/dev/mpt/mpt_raid.c | 12 +++--------- sys/dev/nvme/nvme_sysctl.c | 18 +++++++++--------- 7 files changed, 21 insertions(+), 27 deletions(-) diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 8991d9c23fbc..054250d21668 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -922,7 +922,7 @@ ahci_ch_attach(device_t dev) ctx = device_get_sysctl_ctx(dev); tree = device_get_sysctl_tree(dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "disable_phy", - CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, ch, + CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, ch, 0, ahci_ch_disablephy_proc, "IU", "Disable PHY"); return (0); diff --git a/sys/dev/ioat/ioat.c b/sys/dev/ioat/ioat.c index 7e6a33a4285b..45a6c273822d 100644 --- a/sys/dev/ioat/ioat.c +++ b/sys/dev/ioat/ioat.c @@ -1952,7 +1952,7 @@ ioat_setup_sysctl(device_t device) "submitter processing"); SYSCTL_ADD_PROC(ctx, state, OID_AUTO, "chansts", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, ioat, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, ioat, 0, sysctl_handle_chansts, "A", "String of the channel status"); SYSCTL_ADD_U16(ctx, state, OID_AUTO, "intrdelay", CTLFLAG_RD, @@ -1965,7 +1965,7 @@ ioat_setup_sysctl(device_t device) hammer = SYSCTL_CHILDREN(tmp); SYSCTL_ADD_PROC(ctx, hammer, OID_AUTO, "force_hw_reset", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, ioat, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, ioat, 0, sysctl_handle_reset, "I", "Set to non-zero to reset the hardware"); tmp = SYSCTL_ADD_NODE(ctx, par, OID_AUTO, "stats", @@ -1992,7 +1992,7 @@ ioat_setup_sysctl(device_t device) "The raw CHANERR when the channel was last halted"); SYSCTL_ADD_PROC(ctx, statpar, OID_AUTO, "desc_per_interrupt", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, ioat, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, ioat, 0, sysctl_handle_dpi, "A", "Descriptors per interrupt"); } diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index 657d3c4446ed..d5e70e96fc44 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -191,7 +191,7 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan) "Cause a Lost Frame on a Read"); #endif SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "role", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "role", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, isp, chan, isp_role_sysctl, "I", "Current role"); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "speed", CTLFLAG_RD, &fcp->isp_gbspeed, 0, diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c index 5d57be27f9b2..264123ed62ec 100644 --- a/sys/dev/mpr/mpr.c +++ b/sys/dev/mpr/mpr.c @@ -1914,7 +1914,7 @@ mpr_setup_sysctl(struct mpr_softc *sc) SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "dump_reqs", - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_NEEDGIANT, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, sc, 0, mpr_dump_reqs, "I", "Dump Active Requests"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c index e4d79b10e358..935b20a1bc5a 100644 --- a/sys/dev/mps/mps.c +++ b/sys/dev/mps/mps.c @@ -1761,17 +1761,17 @@ mps_setup_sysctl(struct mps_softc *sc) SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "mapping_table_dump", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, mps_mapping_dump, "A", "Mapping Table Dump"); SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "encl_table_dump", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, mps_mapping_encl_dump, "A", "Enclosure Table Dump"); SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "dump_reqs", - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_NEEDGIANT, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, sc, 0, mps_dump_reqs, "I", "Dump Active Requests"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), diff --git a/sys/dev/mpt/mpt_raid.c b/sys/dev/mpt/mpt_raid.c index 28667d85cf4d..8350122bc337 100644 --- a/sys/dev/mpt/mpt_raid.c +++ b/sys/dev/mpt/mpt_raid.c @@ -1744,8 +1744,6 @@ mpt_raid_sysctl_vol_member_wce(SYSCTL_HANDLER_ARGS) u_int size; u_int i; - GIANT_REQUIRED; - mpt = (struct mpt_softc *)arg1; str = mpt_vol_mwce_strs[mpt->raid_mwce_setting]; error = SYSCTL_OUT(req, str, strlen(str) + 1); @@ -1778,8 +1776,6 @@ mpt_raid_sysctl_vol_resync_rate(SYSCTL_HANDLER_ARGS) u_int raid_resync_rate; int error; - GIANT_REQUIRED; - mpt = (struct mpt_softc *)arg1; raid_resync_rate = mpt->raid_resync_rate; @@ -1798,8 +1794,6 @@ mpt_raid_sysctl_vol_queue_depth(SYSCTL_HANDLER_ARGS) u_int raid_queue_depth; int error; - GIANT_REQUIRED; - mpt = (struct mpt_softc *)arg1; raid_queue_depth = mpt->raid_queue_depth; @@ -1818,17 +1812,17 @@ mpt_raid_sysctl_attach(struct mpt_softc *mpt) struct sysctl_oid *tree = device_get_sysctl_tree(mpt->dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "vol_member_wce", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "vol_member_wce", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, mpt, 0, mpt_raid_sysctl_vol_member_wce, "A", "volume member WCE(On,Off,On-During-Rebuild,NC)"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "vol_queue_depth", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "vol_queue_depth", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, mpt, 0, mpt_raid_sysctl_vol_queue_depth, "I", "default volume queue depth"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "vol_resync_rate", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "vol_resync_rate", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, mpt, 0, mpt_raid_sysctl_vol_resync_rate, "I", "volume resync priority (0 == NC, 1 - 255)"); SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c index e1771febea9b..9ec1f14511f5 100644 --- a/sys/dev/nvme/nvme_sysctl.c +++ b/sys/dev/nvme/nvme_sysctl.c @@ -278,7 +278,7 @@ nvme_sysctl_initialize_queue(struct nvme_qpair *qpair, "Number of commands ending in failure after all retries"); SYSCTL_ADD_PROC(ctrlr_ctx, que_list, OID_AUTO, - "dump_debug", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "dump_debug", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, qpair, 0, nvme_sysctl_dump_debug, "IU", "Dump debug data"); } @@ -301,46 +301,46 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr) "Number of I/O queue pairs"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_int_coal_time, "IU", "Interrupt coalescing timeout (in microseconds)"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "int_coal_threshold", - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, ctrlr, 0, + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_int_coal_threshold, "IU", "Interrupt coalescing threshold"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "timeout_period", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "timeout_period", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_timeout_period, "IU", "Timeout period (in seconds)"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_cmds", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + "num_cmds", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_cmds, "IU", "Number of commands submitted"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "num_intr_handler_calls", - CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, ctrlr, 0, + CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_intr_handler_calls, "IU", "Number of times interrupt handler was invoked (will " "typically be less than number of actual interrupts " "generated due to coalescing)"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_retries", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + "num_retries", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_retries, "IU", "Number of commands retried"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "num_failures", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + "num_failures", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_num_failures, "IU", "Number of commands ending in failure after all retries"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, - "reset_stats", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, ctrlr, + "reset_stats", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, nvme_sysctl_reset_stats, "IU", "Reset statistics to zero"); que_tree = SYSCTL_ADD_NODE(ctrlr_ctx, ctrlr_list, OID_AUTO, "adminq", From owner-dev-commits-src-all@freebsd.org Wed Aug 25 01:54:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EE74B66BF4F; Wed, 25 Aug 2021 01:54: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 4GvTY43m3cz4S7Y; Wed, 25 Aug 2021 01:54: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 5E115138E8; Wed, 25 Aug 2021 01:54: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 17P1s0hL025639; Wed, 25 Aug 2021 01:54:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P1s0jW025638; Wed, 25 Aug 2021 01:54:00 GMT (envelope-from git) Date: Wed, 25 Aug 2021 01:54:00 GMT Message-Id: <202108250154.17P1s0jW025638@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: f6dbc0d7335f - stable/13 - Mark some sysctls as CTLFLAG_MPSAFE. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f6dbc0d7335f804f3dd32621f1c15c4750d9b75b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 01:54:01 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=f6dbc0d7335f804f3dd32621f1c15c4750d9b75b commit f6dbc0d7335f804f3dd32621f1c15c4750d9b75b Author: Alexander Motin AuthorDate: 2021-08-11 02:17:53 +0000 Commit: Alexander Motin CommitDate: 2021-08-25 01:53:18 +0000 Mark some sysctls as CTLFLAG_MPSAFE. MFC after: 2 weeks (cherry picked from commit 67f508db84b8b789db37c60972f255574417b8ed) --- sys/kern/kern_intr.c | 4 ++-- sys/kern/kern_shutdown.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 41667b57fd4f..0cbfce030a36 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -1612,7 +1612,7 @@ sysctl_intrnames(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_hw, OID_AUTO, intrnames, - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_intrnames, "", "Interrupt Names"); @@ -1641,7 +1641,7 @@ sysctl_intrcnt(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_hw, OID_AUTO, intrcnt, - CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_intrcnt, "", "Interrupt Counts"); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index e200b6d8a4b4..fb2a69401801 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -740,7 +740,7 @@ SYSCTL_INT(_debug_kassert, OID_AUTO, suppress_in_panic, KASSERT_RWTUN, static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_debug_kassert, OID_AUTO, kassert, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_NEEDGIANT, NULL, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_MPSAFE, NULL, 0, kassert_sysctl_kassert, "I", "set to trigger a test kassert"); @@ -1021,7 +1021,7 @@ dumpdevname_sysctl_handler(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_kern_shutdown, OID_AUTO, dumpdevname, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, &dumper_configs, 0, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, &dumper_configs, 0, dumpdevname_sysctl_handler, "A", "Device(s) for kernel dumps"); From owner-dev-commits-src-all@freebsd.org Wed Aug 25 02:02:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5509266C1E9; Wed, 25 Aug 2021 02:02: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 4GvTkc1yvqz4TVh; Wed, 25 Aug 2021 02:02: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 2C3781402D; Wed, 25 Aug 2021 02:02: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 17P22GAG039641; Wed, 25 Aug 2021 02:02:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P22G7w039640; Wed, 25 Aug 2021 02:02:16 GMT (envelope-from git) Date: Wed, 25 Aug 2021 02:02:16 GMT Message-Id: <202108250202.17P22G7w039640@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 3b29c8b4bdb0 - main - ddb: do not assume that ffs is mounted with softdep MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3b29c8b4bdb0e396d7bb5d0760f11d7fa4208c84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 02:02:16 -0000 The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=3b29c8b4bdb0e396d7bb5d0760f11d7fa4208c84 commit 3b29c8b4bdb0e396d7bb5d0760f11d7fa4208c84 Author: Keith Owens AuthorDate: 2021-08-25 01:59:31 +0000 Commit: Eric van Gyzen CommitDate: 2021-08-25 02:00:19 +0000 ddb: do not assume that ffs is mounted with softdep Avoid a panic when debugging with "show ffs" in ddb. Reviewed By: kib, markj, mckusick MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D31622 --- sys/ufs/ffs/ffs_softdep.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index e518cc5c5deb..6f1de407135e 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -15009,9 +15009,15 @@ db_print_ffs(struct ufsmount *ump) { db_printf("mp %p (%s) devvp %p\n", ump->um_mountp, ump->um_mountp->mnt_stat.f_mntonname, ump->um_devvp); - db_printf(" fs %p su_wl %d su_deps %d su_req %d\n", - ump->um_fs, ump->softdep_on_worklist, - ump->softdep_deps, ump->softdep_req); + db_printf(" fs %p ", ump->um_fs); + + if (ump->um_softdep != NULL) { + db_printf("su_wl %d su_deps %d su_req %d\n", + ump->softdep_on_worklist, ump->softdep_deps, + ump->softdep_req); + } else { + db_printf("su disabled\n"); + } } static void From owner-dev-commits-src-all@freebsd.org Wed Aug 25 06:25:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 866C366F4AF; Wed, 25 Aug 2021 06:25: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 4GvbZc33ngz4jnK; Wed, 25 Aug 2021 06:25:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 51CD81792C; Wed, 25 Aug 2021 06:25: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 17P6Pi0x088189; Wed, 25 Aug 2021 06:25:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P6Pihj088188; Wed, 25 Aug 2021 06:25:44 GMT (envelope-from git) Date: Wed, 25 Aug 2021 06:25:44 GMT Message-Id: <202108250625.17P6Pihj088188@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: a2d0f28a8e69 - stable/13 - rpc(3): Correct a few common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a2d0f28a8e691dc927516e156d771f6fb60bde62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 06:25:44 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a2d0f28a8e691dc927516e156d771f6fb60bde62 commit a2d0f28a8e691dc927516e156d771f6fb60bde62 Author: Gordon Bergling AuthorDate: 2021-08-22 06:16:09 +0000 Commit: Gordon Bergling CommitDate: 2021-08-25 06:25:12 +0000 rpc(3): Correct a few common typos in source code comments - s/therfore/therefor/ - s/activte/active/ Obtained from: NetBSD (cherry picked from commit 0d55bc8eb2ab9508c43e135616ca887ed719ea9a) --- lib/libc/rpc/clnt_dg.c | 4 ++-- lib/libc/rpc/clnt_vc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index a1cd7502e2ad..26bf34633623 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -92,9 +92,9 @@ static void clnt_dg_destroy(CLIENT *); * This machinery implements per-fd locks for MT-safety. It is not * sufficient to do per-CLIENT handle locks for MT-safety because a * user may create more than one CLIENT handle with the same fd behind - * it. Therfore, we allocate an array of flags (dg_fd_locks), protected + * it. Therefore, we allocate an array of flags (dg_fd_locks), protected * by the clnt_fd_lock mutex, and an array (dg_cv) of condition variables - * similarly protected. Dg_fd_lock[fd] == 1 => a call is activte on some + * similarly protected. Dg_fd_lock[fd] == 1 => a call is active on some * CLIENT handle created for that fd. * The current implementation holds locks across the entire RPC and reply, * including retransmissions. Yes, this is silly, and as soon as this diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index dec1791dcc95..ebd4e303916f 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -123,9 +123,9 @@ struct ct_data { * This machinery implements per-fd locks for MT-safety. It is not * sufficient to do per-CLIENT handle locks for MT-safety because a * user may create more than one CLIENT handle with the same fd behind - * it. Therfore, we allocate an array of flags (vc_fd_locks), protected + * it. Therefore, we allocate an array of flags (vc_fd_locks), protected * by the clnt_fd_lock mutex, and an array (vc_cv) of condition variables - * similarly protected. Vc_fd_lock[fd] == 1 => a call is activte on some + * similarly protected. Vc_fd_lock[fd] == 1 => a call is active on some * CLIENT handle created for that fd. * The current implementation holds locks across the entire RPC and reply. * Yes, this is silly, and as soon as this code is proven to work, this From owner-dev-commits-src-all@freebsd.org Wed Aug 25 06:27:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC68066F14F; Wed, 25 Aug 2021 06:27: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 4Gvbcn5b2Dz4jnm; Wed, 25 Aug 2021 06:27: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 9E245178B0; Wed, 25 Aug 2021 06:27: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 17P6RbL7088426; Wed, 25 Aug 2021 06:27:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17P6Rbjg088425; Wed, 25 Aug 2021 06:27:37 GMT (envelope-from git) Date: Wed, 25 Aug 2021 06:27:37 GMT Message-Id: <202108250627.17P6Rbjg088425@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: f251abcdfe15 - stable/12 - rpc(3): Correct a few common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: f251abcdfe15836186c69a2b279255e077a45277 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 06:27:37 -0000 The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=f251abcdfe15836186c69a2b279255e077a45277 commit f251abcdfe15836186c69a2b279255e077a45277 Author: Gordon Bergling AuthorDate: 2021-08-22 06:16:09 +0000 Commit: Gordon Bergling CommitDate: 2021-08-25 06:27:09 +0000 rpc(3): Correct a few common typos in source code comments - s/therfore/therefor/ - s/activte/active/ Obtained from: NetBSD (cherry picked from commit 0d55bc8eb2ab9508c43e135616ca887ed719ea9a) --- lib/libc/rpc/clnt_dg.c | 4 ++-- lib/libc/rpc/clnt_vc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index a1cd7502e2ad..26bf34633623 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -92,9 +92,9 @@ static void clnt_dg_destroy(CLIENT *); * This machinery implements per-fd locks for MT-safety. It is not * sufficient to do per-CLIENT handle locks for MT-safety because a * user may create more than one CLIENT handle with the same fd behind - * it. Therfore, we allocate an array of flags (dg_fd_locks), protected + * it. Therefore, we allocate an array of flags (dg_fd_locks), protected * by the clnt_fd_lock mutex, and an array (dg_cv) of condition variables - * similarly protected. Dg_fd_lock[fd] == 1 => a call is activte on some + * similarly protected. Dg_fd_lock[fd] == 1 => a call is active on some * CLIENT handle created for that fd. * The current implementation holds locks across the entire RPC and reply, * including retransmissions. Yes, this is silly, and as soon as this diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index dec1791dcc95..ebd4e303916f 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -123,9 +123,9 @@ struct ct_data { * This machinery implements per-fd locks for MT-safety. It is not * sufficient to do per-CLIENT handle locks for MT-safety because a * user may create more than one CLIENT handle with the same fd behind - * it. Therfore, we allocate an array of flags (vc_fd_locks), protected + * it. Therefore, we allocate an array of flags (vc_fd_locks), protected * by the clnt_fd_lock mutex, and an array (vc_cv) of condition variables - * similarly protected. Vc_fd_lock[fd] == 1 => a call is activte on some + * similarly protected. Vc_fd_lock[fd] == 1 => a call is active on some * CLIENT handle created for that fd. * The current implementation holds locks across the entire RPC and reply. * Yes, this is silly, and as soon as this code is proven to work, this From owner-dev-commits-src-all@freebsd.org Wed Aug 25 08:04:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AC580670710; Wed, 25 Aug 2021 08: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 4GvdmX3pP1z3hW8; Wed, 25 Aug 2021 08: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 6A74919082; Wed, 25 Aug 2021 08: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 17P84SDU025165; Wed, 25 Aug 2021 08: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 17P84SCM025164; Wed, 25 Aug 2021 08:04:28 GMT (envelope-from git) Date: Wed, 25 Aug 2021 08:04:28 GMT Message-Id: <202108250804.17P84SCM025164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2e5ff01d0a1f - main - if_vlan: add the ALTQ support to if_vlan. 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/main X-Git-Reftype: branch X-Git-Commit: 2e5ff01d0a1fabc757252f9c28ad5cddc98a652d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 08:04:28 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2e5ff01d0a1fabc757252f9c28ad5cddc98a652d commit 2e5ff01d0a1fabc757252f9c28ad5cddc98a652d Author: Luiz Otavio O Souza AuthorDate: 2021-08-21 09:41:03 +0000 Commit: Kristof Provost CommitDate: 2021-08-25 06:56:45 +0000 if_vlan: add the ALTQ support to if_vlan. Inspired by the iflib implementation, allow ALTQ to be used with if_vlan interfaces. Reviewed by: donner Obtained from: pfsense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31647 --- sys/net/if_vlan.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 39978afe7ce1..10a254d22440 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -305,6 +305,10 @@ static int vlan_setflag(struct ifnet *ifp, int flag, int status, static int vlan_setflags(struct ifnet *ifp, int status); static int vlan_setmulti(struct ifnet *ifp); static int vlan_transmit(struct ifnet *ifp, struct mbuf *m); +#ifdef ALTQ +static void vlan_altq_start(struct ifnet *ifp); +static int vlan_altq_transmit(struct ifnet *ifp, struct mbuf *m); +#endif static int vlan_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro); static void vlan_unconfig(struct ifnet *ifp); @@ -1097,7 +1101,15 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifp->if_dunit = unit; ifp->if_init = vlan_init; +#ifdef ALTQ + ifp->if_start = vlan_altq_start; + ifp->if_transmit = vlan_altq_transmit; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = 0; + IFQ_SET_READY(&ifp->if_snd); +#else ifp->if_transmit = vlan_transmit; +#endif ifp->if_qflush = vlan_qflush; ifp->if_ioctl = vlan_ioctl; #if defined(KERN_TLS) || defined(RATELIMIT) @@ -1150,6 +1162,9 @@ vlan_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) if (ifp->if_vlantrunk) return (EBUSY); +#ifdef ALTQ + IFQ_PURGE(&ifp->if_snd); +#endif ether_ifdetach(ifp); /* first, remove it from system-wide lists */ vlan_unconfig(ifp); /* now it can be unconfigured and freed */ /* @@ -1271,6 +1286,38 @@ vlan_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, return p->if_output(ifp, m, dst, ro); } +#ifdef ALTQ +static void +vlan_altq_start(if_t ifp) +{ + struct ifaltq *ifq = &ifp->if_snd; + struct mbuf *m; + + IFQ_LOCK(ifq); + IFQ_DEQUEUE_NOLOCK(ifq, m); + while (m != NULL) { + vlan_transmit(ifp, m); + IFQ_DEQUEUE_NOLOCK(ifq, m); + } + IFQ_UNLOCK(ifq); +} + +static int +vlan_altq_transmit(if_t ifp, struct mbuf *m) +{ + int err; + + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_ENQUEUE(&ifp->if_snd, m, err); + if (err == 0) + vlan_altq_start(ifp); + } else + err = vlan_transmit(ifp, m); + + return (err); +} +#endif /* ALTQ */ + /* * The ifp->if_qflush entry point for vlan(4) is a no-op. */ From owner-dev-commits-src-all@freebsd.org Wed Aug 25 08:04:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7B5E670903; Wed, 25 Aug 2021 08: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 4GvdmY4nLsz3hFX; Wed, 25 Aug 2021 08:04:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8769F18F58; Wed, 25 Aug 2021 08: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 17P84To5025189; Wed, 25 Aug 2021 08: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 17P84TPn025188; Wed, 25 Aug 2021 08:04:29 GMT (envelope-from git) Date: Wed, 25 Aug 2021 08:04:29 GMT Message-Id: <202108250804.17P84TPn025188@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: e62175df4ec2 - main - pf tests: test ALTQ CBQ on top of if_vlan 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/main X-Git-Reftype: branch X-Git-Commit: e62175df4ec2c8fe2aa2e372f683ddb933768e62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 08:04:30 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e62175df4ec2c8fe2aa2e372f683ddb933768e62 commit e62175df4ec2c8fe2aa2e372f683ddb933768e62 Author: Kristof Provost AuthorDate: 2021-08-23 14:58:50 +0000 Commit: Kristof Provost CommitDate: 2021-08-25 06:57:10 +0000 pf tests: test ALTQ CBQ on top of if_vlan The main purpose of this test is to verify that we can use ALTQ on top of if_vlan, but while we're here we also exercise the CBQ code. There's already a basis test for HFSC, so it makes sense to test another algorithm while we test if_vlan. Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31649 --- tests/sys/common/vnet.subr | 7 ++++++ tests/sys/netpfil/pf/altq.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/tests/sys/common/vnet.subr b/tests/sys/common/vnet.subr index f9a9e9c428fd..590e8dea992e 100644 --- a/tests/sys/common/vnet.subr +++ b/tests/sys/common/vnet.subr @@ -24,6 +24,13 @@ vnet_mkbridge() echo ${ifname} } +vnet_mkvlan() +{ + ifname=$(ifconfig vlan create) + echo ${ifname} >> created_interfaces.lst + echo ${ifname} +} + vnet_mkloopback() { ifname=$(ifconfig lo create) diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh index 294c01e9f8bd..53cf10e47565 100644 --- a/tests/sys/netpfil/pf/altq.sh +++ b/tests/sys/netpfil/pf/altq.sh @@ -86,9 +86,69 @@ match_cleanup() altq_cleanup } +atf_test_case "cbq_vlan" "cleanup" +cbq_vlan_head() +{ + atf_set descr 'CBQ over VLAN test' + atf_set require.user root +} + +cbq_vlan_body() +{ + altq_init + is_altq_supported cbq + + epair=$(vnet_mkepair) + vnet_mkjail altq_cbq_vlan ${epair}b + + vlan=$(vnet_mkvlan) + ifconfig ${vlan} vlan 42 vlandev ${epair}a + ifconfig ${vlan} 192.0.2.1/24 up + ifconfig ${epair}a up + + vlanj=$(jexec altq_cbq_vlan ifconfig vlan create) + echo ${vlanj} >> created_interfaces.lst + + jexec altq_cbq_vlan ifconfig ${epair}b up + jexec altq_cbq_vlan ifconfig ${vlanj} vlan 42 vlandev ${epair}b + jexec altq_cbq_vlan ifconfig ${vlanj} 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec altq_cbq_vlan pfctl -e + pft_set_rules altq_cbq_vlan \ + "altq on ${vlanj} bandwidth 14000b cbq queue { default }" \ + "queue default bandwidth 14000b cbq(default) { slow } " \ + "queue slow bandwidth 6000b cbq(borrow)" \ + "match proto icmp queue slow" \ + "match proto tcp queue default" \ + "pass" + + # single ping succeeds just fine + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # "Saturate the link" + ping -i .01 -c 50 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get these packet dropped. + rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }') + echo "Received $rcv packets" + if [ ${rcv} -gt 1 ] + then + atf_fail "Received ${rcv} packets in a saturated link" + fi +} + +cbq_vlan_cleanup() +{ + altq_cleanup +} + atf_init_test_cases() { atf_add_test_case "hfsc" atf_add_test_case "match" + atf_add_test_case "cbq_vlan" } From owner-dev-commits-src-all@freebsd.org Wed Aug 25 15:14:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F469675C4A; Wed, 25 Aug 2021 15:14:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvqJW0SMbz3QmQ; Wed, 25 Aug 2021 15:14:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E78C71EC90; Wed, 25 Aug 2021 15:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PFEIVi097540; Wed, 25 Aug 2021 15:14:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PFEIST097539; Wed, 25 Aug 2021 15:14:18 GMT (envelope-from git) Date: Wed, 25 Aug 2021 15:14:18 GMT Message-Id: <202108251514.17PFEIST097539@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: dc6ab77d66f8 - main - tcp: make network epoch expectations of LRO explicit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dc6ab77d66f892566de926274e6a58a637975510 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 15:14:19 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=dc6ab77d66f892566de926274e6a58a637975510 commit dc6ab77d66f892566de926274e6a58a637975510 Author: Michael Tuexen AuthorDate: 2021-08-25 15:09:25 +0000 Commit: Michael Tuexen CommitDate: 2021-08-25 15:12:36 +0000 tcp: make network epoch expectations of LRO explicit Reviewed by: gallatin, hselasky MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D31648 --- sys/netinet/tcp_lro.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index cb548d457bb3..cb9681559777 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -598,6 +598,7 @@ tcp_lro_flush_inactive(struct lro_ctrl *lc, const struct timeval *timeout) uint64_t now, tov; struct bintime bt; + NET_EPOCH_ASSERT(); if (LIST_EMPTY(&lc->lro_active)) return; @@ -1177,8 +1178,6 @@ tcp_lro_lookup(struct ifnet *ifp, struct lro_parser *pa) { struct inpcb *inp; - NET_EPOCH_ASSERT(); - switch (pa->data.lro_type) { #ifdef INET6 case LRO_TYPE_IPV6_TCP: @@ -1368,7 +1367,10 @@ tcp_lro_flush(struct lro_ctrl *lc, struct lro_entry *le) /* Only optimise if there are multiple packets waiting. */ #ifdef TCPHPTS int error; +#endif + NET_EPOCH_ASSERT(); +#ifdef TCPHPTS CURVNET_SET(lc->ifp->if_vnet); error = tcp_lro_flush_tcphpts(lc, le); CURVNET_RESTORE(); @@ -1479,6 +1481,7 @@ tcp_lro_flush_all(struct lro_ctrl *lc) uint64_t nseq; unsigned x; + NET_EPOCH_ASSERT(); /* check if no mbufs to flush */ if (lc->lro_mbuf_count == 0) goto done; @@ -1919,6 +1922,7 @@ tcp_lro_rx(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum) void tcp_lro_queue_mbuf(struct lro_ctrl *lc, struct mbuf *mb) { + NET_EPOCH_ASSERT(); /* sanity checks */ if (__predict_false(lc->ifp == NULL || lc->lro_mbuf_data == NULL || lc->lro_mbuf_max == 0)) { From owner-dev-commits-src-all@freebsd.org Wed Aug 25 16:04:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 513EB67702E; Wed, 25 Aug 2021 16:04: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 4GvrQM1PzNz3vRC; Wed, 25 Aug 2021 16: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 1535F1F5C8; Wed, 25 Aug 2021 16: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 17PG4QV4064335; Wed, 25 Aug 2021 16:04:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PG4QpD064334; Wed, 25 Aug 2021 16:04:26 GMT (envelope-from git) Date: Wed, 25 Aug 2021 16:04:26 GMT Message-Id: <202108251604.17PG4QpD064334@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 9e202d036dd6 - main - fspacectl(2): Changes on rmsr.r_offset's minimum value returned MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e202d036dd6f38ce0f578aa2086ebc358315bab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 16:04:27 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=9e202d036dd6f38ce0f578aa2086ebc358315bab commit 9e202d036dd6f38ce0f578aa2086ebc358315bab Author: Ka Ho Ng AuthorDate: 2021-08-25 16:02:27 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 16:03:37 +0000 fspacectl(2): Changes on rmsr.r_offset's minimum value returned rmsr.r_offset now is set to rqsr.r_offset plus the number of bytes zeroed before hitting the end-of-file. After this change rmsr.r_offset no longer contains the EOF when the requested operation range is completely beyond the end-of-file. Instead in such case rmsr.r_offset is equal to rqsr.r_offset. Callers can obtain the number of bytes zeroed by subtracting rqsr.r_offset from rmsr.r_offset. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31677 --- lib/libc/sys/fspacectl.2 | 9 ++++----- share/man/man9/VOP_DEALLOCATE.9 | 9 +++------ share/man/man9/vn_deallocate.9 | 7 ++----- sys/kern/uipc_shm.c | 1 - sys/kern/vfs_default.c | 5 ++--- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/libc/sys/fspacectl.2 b/lib/libc/sys/fspacectl.2 index 0e369785b883..430f3de950df 100644 --- a/lib/libc/sys/fspacectl.2 +++ b/lib/libc/sys/fspacectl.2 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 18, 2021 +.Dd August 25, 2021 .Dt FSPACECTL 2 .Os .Sh NAME @@ -73,10 +73,9 @@ operation range, .Fa "rmsr->r_len" is updated to be the value 0, and .Fa "rmsr->r_offset" -is updated to be the smallest of -.Fa "rqsr->r_offset" + -.Fa "rqsr->r_len" ; -and the end-of-file offset. +is updated to be +.Fa "rqsr->r_offset" +plus the number of bytes zeroed before the end-of-file. The file descriptor's file offset is not used or modified by the system call. Both .Fa rqsr diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9 index 2ec915c6fef3..d20fe1590314 100644 --- a/share/man/man9/VOP_DEALLOCATE.9 +++ b/share/man/man9/VOP_DEALLOCATE.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 11, 2021 +.Dd August 25, 2021 .Dt VOP_DEALLOCATE 9 .Os .Sh NAME @@ -74,14 +74,11 @@ and are updated to reflect the portion of the range that still needs to be zeroed/deallocated on return. Partial result is considered a successful operation. -For a successful completion without an unprocessed portion of the range, +For a non-partial successful completion, .Fa *len is updated to be the value 0, and .Fa *offset -is updated to be the smallest of -.Fa *offset + -.Fa *len -passed to the call and the end-of-file offset. +is incremented by the number of bytes zeroed before the end-of-file. .Sh LOCKS The vnode should be locked on entry and will still be locked on exit. .Sh RETURN VALUES diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9 index 08f4e92ec597..ce1515ddaaa1 100644 --- a/share/man/man9/vn_deallocate.9 +++ b/share/man/man9/vn_deallocate.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 11, 2021 +.Dd August 25, 2021 .Dt VN_DEALLOCATE 9 .Os .Sh NAME @@ -99,10 +99,7 @@ For a successful completion, .Fa *length is updated to be the value 0, and .Fa *offset -is updated to be the smallest of -.Fa *offset + -.Fa *length -passed to the call and the end-of-file offset. +is incremented by the number of bytes zeroed before the end-of-file. .Sh RETURN VALUES Upon successful completion, the value 0 is returned; otherwise the appropriate error is returned. diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index c632c7f150df..c672c0477b95 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1917,7 +1917,6 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) /* Handle the case when offset is on or beyond shm size. */ if ((off_t)len <= 0) { - *offset = shmfd->shm_size; *length = 0; return (0); } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d5df9cd8bf7b..9fd43004b8fd 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1156,6 +1156,7 @@ vop_stddeallocate(struct vop_deallocate_args *ap) /* * No more data region to be filled */ + offset += len; len = 0; error = 0; break; @@ -1185,10 +1186,8 @@ vop_stddeallocate(struct vop_deallocate_args *ap) break; } /* Handle the case when offset is beyond EOF */ - if (len < 0) { - offset += len; + if (len < 0) len = 0; - } out: *ap->a_offset = offset; *ap->a_len = len; From owner-dev-commits-src-all@freebsd.org Wed Aug 25 16:04:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB3D0676D59; Wed, 25 Aug 2021 16: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 4GvrQN38FWz3vZ4; Wed, 25 Aug 2021 16: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 2B6ED1F69F; Wed, 25 Aug 2021 16: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 17PG4Sbv064359; Wed, 25 Aug 2021 16: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 17PG4Sev064358; Wed, 25 Aug 2021 16:04:28 GMT (envelope-from git) Date: Wed, 25 Aug 2021 16:04:28 GMT Message-Id: <202108251604.17PG4Sev064358@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 76321d2d432e - main - param: Bump __FreeBSD_version to 1400032 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 76321d2d432ed270d93b282e54e59b708c0cf3b4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 16:04:28 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=76321d2d432ed270d93b282e54e59b708c0cf3b4 commit 76321d2d432ed270d93b282e54e59b708c0cf3b4 Author: Ka Ho Ng AuthorDate: 2021-08-25 16:02:43 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 16:03:55 +0000 param: Bump __FreeBSD_version to 1400032 Commit 9e202d036dd6 introduces incompatible changes to fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9)'s rmsr.r_offset/*offset return value. Sponsored by: The FreeBSD Foundation --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 82787b4552af..04baa3cf3690 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400031 +#define __FreeBSD_version 1400032 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-all@freebsd.org Wed Aug 25 16:22:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CB8AE677498; Wed, 25 Aug 2021 16:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gvrq051FKz4VYD; Wed, 25 Aug 2021 16:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 863271F6E4; Wed, 25 Aug 2021 16:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PGMKfg090817; Wed, 25 Aug 2021 16:22:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PGMKDc090816; Wed, 25 Aug 2021 16:22:20 GMT (envelope-from git) Date: Wed, 25 Aug 2021 16:22:20 GMT Message-Id: <202108251622.17PGMKDc090816@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 9f7a81b133c7 - main - diff3: document and test -T MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9f7a81b133c715f649136dcd0ad004e4180c56c9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 16:22:20 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=9f7a81b133c715f649136dcd0ad004e4180c56c9 commit 9f7a81b133c715f649136dcd0ad004e4180c56c9 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-23 19:33:27 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-25 16:20:59 +0000 diff3: document and test -T Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D31650 --- usr.bin/diff3/diff3.1 | 11 +++++++++-- usr.bin/diff3/tests/1t.out | 14 ++++++++++++++ usr.bin/diff3/tests/Makefile | 1 + usr.bin/diff3/tests/diff3_test.sh | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/usr.bin/diff3/diff3.1 b/usr.bin/diff3/diff3.1 index 22e04b6af5e8..2cf1e57cb74e 100644 --- a/usr.bin/diff3/diff3.1 +++ b/usr.bin/diff3/diff3.1 @@ -30,7 +30,7 @@ .\" @(#)diff3.1 8.2 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd May 25, 2017 +.Dd August 23, 2021 .Dt DIFF3 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Nd 3-way differential file comparison .Sh SYNOPSIS .Nm diff3 -.Op Fl 3aEeiXx +.Op Fl 3aEeiTXx .Op Fl Fl diff-program Ar program .Op Fl Fl strip-trailing-cr .Op Fl L | Fl Fl label Ar label1 @@ -115,6 +115,13 @@ Defines labels to print instead of file names .Ar file2 and .Ar file3 . +.It Fl T, Fl Fl initial-tab +In the normal listing, +use a tab instead of two spaces +at the beginning of each line. +In modes that produce an +.Xr ed 1 +script, this option changes nothing. .It Fl x, Fl Fl overlap-only Produces an output script suitable for .Xr ed 1 diff --git a/usr.bin/diff3/tests/1t.out b/usr.bin/diff3/tests/1t.out new file mode 100644 index 000000000000..fc54ce50286f --- /dev/null +++ b/usr.bin/diff3/tests/1t.out @@ -0,0 +1,14 @@ +==== +1:2,3c + which multiple lines + and a few typ0s to fix +2:2,3c + which multiple lines + and a few typos to fix +3:2c + and a few typ0s to fix +====2 +1:4a +3:3a +2:5c + New line diff --git a/usr.bin/diff3/tests/Makefile b/usr.bin/diff3/tests/Makefile index 2ec7fbaab564..b8bea154944b 100644 --- a/usr.bin/diff3/tests/Makefile +++ b/usr.bin/diff3/tests/Makefile @@ -10,6 +10,7 @@ ${PACKAGE}FILES+= \ 2.txt \ 3.txt \ 1.out \ + 1t.out \ 2.out \ 3.out \ 4.out \ diff --git a/usr.bin/diff3/tests/diff3_test.sh b/usr.bin/diff3/tests/diff3_test.sh index f4b5adf95700..64031b023187 100755 --- a/usr.bin/diff3/tests/diff3_test.sh +++ b/usr.bin/diff3/tests/diff3_test.sh @@ -11,6 +11,9 @@ diff3_body() atf_check -o file:$(atf_get_srcdir)/1.out \ diff3 --strip-trailing-cr $(atf_get_srcdir)/1cr.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/1t.out \ + diff3 -T $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt + atf_check -o file:$(atf_get_srcdir)/2.out \ diff3 -e $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt From owner-dev-commits-src-all@freebsd.org Wed Aug 25 17:18:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8657C677DBD; Wed, 25 Aug 2021 17:18: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 4Gvt3F34mMz4lxC; Wed, 25 Aug 2021 17:18: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 4A1C920575; Wed, 25 Aug 2021 17:18: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 17PHI1d1057859; Wed, 25 Aug 2021 17:18:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PHI1KY057858; Wed, 25 Aug 2021 17:18:01 GMT (envelope-from git) Date: Wed, 25 Aug 2021 17:18:01 GMT Message-Id: <202108251718.17PHI1KY057858@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: 26a28a789aa7 - stable/12 - Allow the pseudo-errnos to be returned as well in boot loader 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: 26a28a789aa7d3041a4cf961526da2e6404fc1ac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 17:18:01 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=26a28a789aa7d3041a4cf961526da2e6404fc1ac commit 26a28a789aa7d3041a4cf961526da2e6404fc1ac Author: Warner Losh AuthorDate: 2020-08-28 17:49:56 +0000 Commit: Kyle Evans CommitDate: 2021-08-25 17:17:42 +0000 Allow the pseudo-errnos to be returned as well in boot loader Expose the pseudo-errno values in _STANDALONE is defined so that code in the boot loader can make use of them. Nothing uses them today, but the zstd support that's coming will need them. (cherry picked from commit 0c35b860913807d4937098d5238c5f4363fb6362) --- sys/sys/errno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/errno.h b/sys/sys/errno.h index 6994c0612f79..e53a8d4c6c7f 100644 --- a/sys/sys/errno.h +++ b/sys/sys/errno.h @@ -187,7 +187,7 @@ __END_DECLS #define ELAST 97 /* Must be equal largest errno */ #endif /* _POSIX_SOURCE */ -#if defined(_KERNEL) || defined(_WANT_KERNEL_ERRNO) +#if defined(_KERNEL) || defined(_WANT_KERNEL_ERRNO) || defined(_STANDALONE) /* pseudo-errors returned inside kernel to modify return to process */ #define ERESTART (-1) /* restart syscall */ #define EJUSTRETURN (-2) /* don't modify regs, just return */ From owner-dev-commits-src-all@freebsd.org Wed Aug 25 17:18:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC8D5677B42; Wed, 25 Aug 2021 17:18: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 4Gvt3V5SN5z4m3W; Wed, 25 Aug 2021 17:18: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 A377F1FAFD; Wed, 25 Aug 2021 17:18:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PHIEl4057995; Wed, 25 Aug 2021 17:18:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PHIEa9057994; Wed, 25 Aug 2021 17:18:14 GMT (envelope-from git) Date: Wed, 25 Aug 2021 17:18:14 GMT Message-Id: <202108251718.17PHIEa9057994@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: 70eee3be0678 - stable/11 - Allow the pseudo-errnos to be returned as well in boot loader 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/11 X-Git-Reftype: branch X-Git-Commit: 70eee3be067870f8147afa7695bf2494fd1e3aa4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 17:18:14 -0000 The branch stable/11 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=70eee3be067870f8147afa7695bf2494fd1e3aa4 commit 70eee3be067870f8147afa7695bf2494fd1e3aa4 Author: Warner Losh AuthorDate: 2020-08-28 17:49:56 +0000 Commit: Kyle Evans CommitDate: 2021-08-25 17:18:08 +0000 Allow the pseudo-errnos to be returned as well in boot loader Expose the pseudo-errno values in _STANDALONE is defined so that code in the boot loader can make use of them. Nothing uses them today, but the zstd support that's coming will need them. (cherry picked from commit 0c35b860913807d4937098d5238c5f4363fb6362) --- sys/sys/errno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/errno.h b/sys/sys/errno.h index 0292c6a17da2..41d657149222 100644 --- a/sys/sys/errno.h +++ b/sys/sys/errno.h @@ -184,7 +184,7 @@ __END_DECLS #define ELAST 96 /* Must be equal largest errno */ #endif /* _POSIX_SOURCE */ -#if defined(_KERNEL) || defined(_WANT_KERNEL_ERRNO) +#if defined(_KERNEL) || defined(_WANT_KERNEL_ERRNO) || defined(_STANDALONE) /* pseudo-errors returned inside kernel to modify return to process */ #define ERESTART (-1) /* restart syscall */ #define EJUSTRETURN (-2) /* don't modify regs, just return */ From owner-dev-commits-src-all@freebsd.org Wed Aug 25 19:27:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF2D0659DAD; Wed, 25 Aug 2021 19:27: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 4Gvww66KRwz3Pbd; Wed, 25 Aug 2021 19:27: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 C138921876; Wed, 25 Aug 2021 19:27: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 17PJR2P9031298; Wed, 25 Aug 2021 19:27:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PJR21A031297; Wed, 25 Aug 2021 19:27:02 GMT (envelope-from git) Date: Wed, 25 Aug 2021 19:27:02 GMT Message-Id: <202108251927.17PJR21A031297@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 6032b6ba9596 - main - amd64 UEFI loader: enable automatic disable of staging area copying MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6032b6ba9596927aba15a8004ade521a593a7d58 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 19:27:03 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6032b6ba9596927aba15a8004ade521a593a7d58 commit 6032b6ba9596927aba15a8004ade521a593a7d58 Author: Konstantin Belousov AuthorDate: 2021-08-10 01:38:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-25 19:26:52 +0000 amd64 UEFI loader: enable automatic disable of staging area copying Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 month --- stand/efi/loader/copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index b8ed4c8e027e..ba5da28aee92 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -215,7 +215,7 @@ efi_copy_free(void) } #ifdef __amd64__ -int copy_staging = COPY_STAGING_ENABLE; +int copy_staging = COPY_STAGING_AUTO; static int command_copy_staging(int argc, char *argv[]) From owner-dev-commits-src-all@freebsd.org Wed Aug 25 20:29:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 97AA565AC83; Wed, 25 Aug 2021 20:29:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvyJg3ppPz3vBf; Wed, 25 Aug 2021 20:29: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 6B0ED22D5F; Wed, 25 Aug 2021 20:29: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 17PKTtXR011162; Wed, 25 Aug 2021 20:29:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PKTtR1011161; Wed, 25 Aug 2021 20:29:55 GMT (envelope-from git) Date: Wed, 25 Aug 2021 20:29:55 GMT Message-Id: <202108252029.17PKTtR1011161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 1d874ba4f8ba - main - fsetown: Fix process lookup bugs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1d874ba4f8ba58296cd9df611f5346dad8e91664 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 20:29:55 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1d874ba4f8ba58296cd9df611f5346dad8e91664 commit 1d874ba4f8ba58296cd9df611f5346dad8e91664 Author: Mark Johnston AuthorDate: 2021-08-25 20:18:10 +0000 Commit: Mark Johnston CommitDate: 2021-08-25 20:18:10 +0000 fsetown: Fix process lookup bugs - pget()/pfind() will acquire the PID hash bucket locks, which are sleepable sx locks, but this means that the sigio mutex cannot be held while calling these functions. Instead, use pget() to hold the process, after which we lock the sigio and proc locks, respectively. - funsetownlst() assumes that processes cannot be registered for SIGIO once they have P_WEXIT set. However, pfind() will happily return exiting processes, breaking the invariant. Add an explicit check for P_WEXIT in fsetown() to fix this. [1] Fixes: f52979098d3c ("Fix a pair of races in SIGIO registration") Reported by: syzkaller [1] Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31661 --- sys/kern/kern_descrip.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index c7269e4b33a9..e6a6a36801e4 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1031,18 +1031,16 @@ funsetown_locked(struct sigio *sigio) if (sigio == NULL) return (NULL); - *(sigio->sio_myref) = NULL; + *sigio->sio_myref = NULL; if (sigio->sio_pgid < 0) { pg = sigio->sio_pgrp; PGRP_LOCK(pg); - SLIST_REMOVE(&sigio->sio_pgrp->pg_sigiolst, sigio, - sigio, sio_pgsigio); + SLIST_REMOVE(&pg->pg_sigiolst, sigio, sigio, sio_pgsigio); PGRP_UNLOCK(pg); } else { p = sigio->sio_proc; PROC_LOCK(p); - SLIST_REMOVE(&sigio->sio_proc->p_sigiolst, sigio, - sigio, sio_pgsigio); + SLIST_REMOVE(&p->p_sigiolst, sigio, sigio, sio_pgsigio); PROC_UNLOCK(p); } return (sigio); @@ -1156,18 +1154,25 @@ fsetown(pid_t pgid, struct sigio **sigiop) } ret = 0; + osigio = NULL; sigio = malloc(sizeof(struct sigio), M_SIGIO, M_WAITOK); sigio->sio_pgid = pgid; sigio->sio_ucred = crhold(curthread->td_ucred); sigio->sio_myref = sigiop; - sx_slock(&proctree_lock); - SIGIO_LOCK(); - osigio = funsetown_locked(*sigiop); if (pgid > 0) { - proc = pfind(pgid); - if (proc == NULL) { + ret = pget(pgid, PGET_NOTWEXIT | PGET_NOTID | PGET_HOLD, &proc); + SIGIO_LOCK(); + if (ret != 0) + goto fail; + + osigio = funsetown_locked(*sigiop); + + PROC_LOCK(proc); + _PRELE(proc); + if ((proc->p_flag & P_WEXIT) != 0) { + PROC_UNLOCK(proc); ret = ESRCH; goto fail; } @@ -1190,12 +1195,17 @@ fsetown(pid_t pgid, struct sigio **sigiop) SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, sio_pgsigio); PROC_UNLOCK(proc); } else /* if (pgid < 0) */ { + sx_slock(&proctree_lock); + SIGIO_LOCK(); pgrp = pgfind(-pgid); if (pgrp == NULL) { + sx_sunlock(&proctree_lock); ret = ESRCH; goto fail; } + osigio = funsetown_locked(*sigiop); + /* * Policy - Don't allow a process to FSETOWN a process * in another session. @@ -1205,16 +1215,17 @@ fsetown(pid_t pgid, struct sigio **sigiop) * group for maximum safety. */ if (pgrp->pg_session != curthread->td_proc->p_session) { + sx_sunlock(&proctree_lock); PGRP_UNLOCK(pgrp); ret = EPERM; goto fail; } - SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); sigio->sio_pgrp = pgrp; + SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); PGRP_UNLOCK(pgrp); + sx_sunlock(&proctree_lock); } - sx_sunlock(&proctree_lock); *sigiop = sigio; SIGIO_UNLOCK(); if (osigio != NULL) @@ -1223,7 +1234,6 @@ fsetown(pid_t pgid, struct sigio **sigiop) fail: SIGIO_UNLOCK(); - sx_sunlock(&proctree_lock); sigiofree(sigio); if (osigio != NULL) sigiofree(osigio); From owner-dev-commits-src-all@freebsd.org Wed Aug 25 20:29:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D73F865A861; Wed, 25 Aug 2021 20:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GvyJh5RC4z3v48; Wed, 25 Aug 2021 20:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 96A2A22D60; Wed, 25 Aug 2021 20:29:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PKTuxl011186; Wed, 25 Aug 2021 20:29:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PKTuQH011185; Wed, 25 Aug 2021 20:29:56 GMT (envelope-from git) Date: Wed, 25 Aug 2021 20:29:56 GMT Message-Id: <202108252029.17PKTuQH011185@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a507a40f3b58 - main - fsetown: Simplify error handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a507a40f3b587bde7ab391f8f1400a25f33e65c1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 20:29:57 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a507a40f3b587bde7ab391f8f1400a25f33e65c1 commit a507a40f3b587bde7ab391f8f1400a25f33e65c1 Author: Mark Johnston AuthorDate: 2021-08-25 20:20:07 +0000 Commit: Mark Johnston CommitDate: 2021-08-25 20:20:07 +0000 fsetown: Simplify error handling No functional change intended. Suggested by: kib Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31671 --- sys/kern/kern_descrip.c | 106 ++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 61 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index e6a6a36801e4..f78e999ab3b5 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1153,88 +1153,72 @@ fsetown(pid_t pgid, struct sigio **sigiop) return (0); } - ret = 0; - osigio = NULL; - sigio = malloc(sizeof(struct sigio), M_SIGIO, M_WAITOK); sigio->sio_pgid = pgid; sigio->sio_ucred = crhold(curthread->td_ucred); sigio->sio_myref = sigiop; + osigio = NULL; + ret = 0; if (pgid > 0) { ret = pget(pgid, PGET_NOTWEXIT | PGET_NOTID | PGET_HOLD, &proc); SIGIO_LOCK(); - if (ret != 0) - goto fail; - - osigio = funsetown_locked(*sigiop); - - PROC_LOCK(proc); - _PRELE(proc); - if ((proc->p_flag & P_WEXIT) != 0) { - PROC_UNLOCK(proc); - ret = ESRCH; - goto fail; - } - - /* - * Policy - Don't allow a process to FSETOWN a process - * in another session. - * - * Remove this test to allow maximum flexibility or - * restrict FSETOWN to the current process or process - * group for maximum safety. - */ - if (proc->p_session != curthread->td_proc->p_session) { + if (ret == 0) { + osigio = funsetown_locked(*sigiop); + + PROC_LOCK(proc); + _PRELE(proc); + if ((proc->p_flag & P_WEXIT) != 0) { + ret = ESRCH; + } else if (proc->p_session != + curthread->td_proc->p_session) { + /* + * Policy - Don't allow a process to FSETOWN a + * process in another session. + * + * Remove this test to allow maximum flexibility + * or restrict FSETOWN to the current process or + * process group for maximum safety. + */ + ret = EPERM; + } else { + sigio->sio_proc = proc; + SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, + sio_pgsigio); + } PROC_UNLOCK(proc); - ret = EPERM; - goto fail; } - - sigio->sio_proc = proc; - SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, sio_pgsigio); - PROC_UNLOCK(proc); } else /* if (pgid < 0) */ { sx_slock(&proctree_lock); SIGIO_LOCK(); pgrp = pgfind(-pgid); if (pgrp == NULL) { - sx_sunlock(&proctree_lock); ret = ESRCH; - goto fail; - } - - osigio = funsetown_locked(*sigiop); - - /* - * Policy - Don't allow a process to FSETOWN a process - * in another session. - * - * Remove this test to allow maximum flexibility or - * restrict FSETOWN to the current process or process - * group for maximum safety. - */ - if (pgrp->pg_session != curthread->td_proc->p_session) { - sx_sunlock(&proctree_lock); + } else { + osigio = funsetown_locked(*sigiop); + + if (pgrp->pg_session != curthread->td_proc->p_session) { + /* + * Policy - Don't allow a process to FSETOWN a + * process in another session. + * + * Remove this test to allow maximum flexibility + * or restrict FSETOWN to the current process or + * process group for maximum safety. + */ + ret = EPERM; + } else { + sigio->sio_pgrp = pgrp; + SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, + sio_pgsigio); + } PGRP_UNLOCK(pgrp); - ret = EPERM; - goto fail; } - - sigio->sio_pgrp = pgrp; - SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); - PGRP_UNLOCK(pgrp); sx_sunlock(&proctree_lock); } - *sigiop = sigio; - SIGIO_UNLOCK(); - if (osigio != NULL) - sigiofree(osigio); - return (0); - -fail: + if (ret == 0) + *sigiop = sigio; SIGIO_UNLOCK(); - sigiofree(sigio); if (osigio != NULL) sigiofree(osigio); return (ret); From owner-dev-commits-src-all@freebsd.org Wed Aug 25 21:35:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DF5D465BB54; Wed, 25 Aug 2021 21:35: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 4Gvzm062kXz4lnj; Wed, 25 Aug 2021 21:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B7BF8239C2; Wed, 25 Aug 2021 21:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PLZCZC004035; Wed, 25 Aug 2021 21:35:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PLZCsW004034; Wed, 25 Aug 2021 21:35:12 GMT (envelope-from git) Date: Wed, 25 Aug 2021 21:35:12 GMT Message-Id: <202108252135.17PLZCsW004034@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 399be91098ad - main - tmpfs: Move partial page invalidation to a separate helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 399be91098adb23aa27ca1228b81a3ad67e8bba2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 21:35:12 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=399be91098adb23aa27ca1228b81a3ad67e8bba2 commit 399be91098adb23aa27ca1228b81a3ad67e8bba2 Author: Ka Ho Ng AuthorDate: 2021-08-25 21:30:53 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 21:34:54 +0000 tmpfs: Move partial page invalidation to a separate helper The partial page invalidation code is factored out to be a separate helper from tmpfs_reg_resize(). Sponsored by: The FreeBSD Foundation Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31683 --- sys/fs/tmpfs/tmpfs_subr.c | 96 +++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 387bc741e3cf..e746a7455860 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -361,6 +361,57 @@ tmpfs_pages_check_avail(struct tmpfs_mount *tmp, size_t req_pages) return (1); } +static int +tmpfs_partial_page_invalidate(vm_object_t object, vm_pindex_t idx, int base, + int end, boolean_t ignerr) +{ + vm_page_t m; + int rv, error; + + VM_OBJECT_ASSERT_WLOCKED(object); + KASSERT(base >= 0, ("%s: base %d", __func__, base)); + KASSERT(end - base <= PAGE_SIZE, ("%s: base %d end %d", __func__, base, + end)); + error = 0; + +retry: + m = vm_page_grab(object, idx, VM_ALLOC_NOCREAT); + if (m != NULL) { + MPASS(vm_page_all_valid(m)); + } else if (vm_pager_has_page(object, idx, NULL, NULL)) { + m = vm_page_alloc(object, idx, VM_ALLOC_NORMAL | + VM_ALLOC_WAITFAIL); + if (m == NULL) + goto retry; + vm_object_pip_add(object, 1); + VM_OBJECT_WUNLOCK(object); + rv = vm_pager_get_pages(object, &m, 1, NULL, NULL); + VM_OBJECT_WLOCK(object); + vm_object_pip_wakeup(object); + if (rv == VM_PAGER_OK) { + /* + * Since the page was not resident, and therefore not + * recently accessed, immediately enqueue it for + * asynchronous laundering. The current operation is + * not regarded as an access. + */ + vm_page_launder(m); + } else { + vm_page_free(m); + m = NULL; + if (!ignerr) + error = EIO; + } + } + if (m != NULL) { + pmap_zero_page_area(m, base, end - base); + vm_page_set_dirty(m); + vm_page_xunbusy(m); + } + + return (error); +} + void tmpfs_ref_node(struct tmpfs_node *node) { @@ -1662,10 +1713,9 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) struct tmpfs_mount *tmp; struct tmpfs_node *node; vm_object_t uobj; - vm_page_t m; vm_pindex_t idx, newpages, oldpages; off_t oldsize; - int base, rv; + int base, error; MPASS(vp->v_type == VREG); MPASS(newsize >= 0); @@ -1702,45 +1752,11 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) base = newsize & PAGE_MASK; if (base != 0) { idx = OFF_TO_IDX(newsize); -retry: - m = vm_page_grab(uobj, idx, VM_ALLOC_NOCREAT); - if (m != NULL) { - MPASS(vm_page_all_valid(m)); - } else if (vm_pager_has_page(uobj, idx, NULL, NULL)) { - m = vm_page_alloc(uobj, idx, VM_ALLOC_NORMAL | - VM_ALLOC_WAITFAIL); - if (m == NULL) - goto retry; - vm_object_pip_add(uobj, 1); + error = tmpfs_partial_page_invalidate(uobj, idx, base, + PAGE_SIZE, ignerr); + if (error != 0) { VM_OBJECT_WUNLOCK(uobj); - rv = vm_pager_get_pages(uobj, &m, 1, NULL, - NULL); - VM_OBJECT_WLOCK(uobj); - vm_object_pip_wakeup(uobj); - if (rv == VM_PAGER_OK) { - /* - * Since the page was not resident, - * and therefore not recently - * accessed, immediately enqueue it - * for asynchronous laundering. The - * current operation is not regarded - * as an access. - */ - vm_page_launder(m); - } else { - vm_page_free(m); - if (ignerr) - m = NULL; - else { - VM_OBJECT_WUNLOCK(uobj); - return (EIO); - } - } - } - if (m != NULL) { - pmap_zero_page_area(m, base, PAGE_SIZE - base); - vm_page_set_dirty(m); - vm_page_xunbusy(m); + return (error); } } From owner-dev-commits-src-all@freebsd.org Wed Aug 25 21:35:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 261F465B833; Wed, 25 Aug 2021 21:35:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gvzm20Q0Xz4lqp; Wed, 25 Aug 2021 21:35: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 DC51D23DE0; Wed, 25 Aug 2021 21:35:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17PLZDMn004059; Wed, 25 Aug 2021 21:35:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PLZDQR004058; Wed, 25 Aug 2021 21:35:13 GMT (envelope-from git) Date: Wed, 25 Aug 2021 21:35:13 GMT Message-Id: <202108252135.17PLZDQR004058@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 8d7cd10ba633 - main - tmpfs: Implement VOP_DEALLOCATE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8d7cd10ba633309a2fa8c0d6475f85e0266e3d94 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 21:35:14 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=8d7cd10ba633309a2fa8c0d6475f85e0266e3d94 commit 8d7cd10ba633309a2fa8c0d6475f85e0266e3d94 Author: Ka Ho Ng AuthorDate: 2021-08-25 21:34:35 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-25 21:34:54 +0000 tmpfs: Implement VOP_DEALLOCATE Implementing VOP_DEALLOCATE to allow hole-punching in the same manner as POSIX shared memory's fspacectl(SPACECTL_DEALLOC) support. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31684 --- sys/fs/tmpfs/tmpfs.h | 1 + sys/fs/tmpfs/tmpfs_subr.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++ sys/fs/tmpfs/tmpfs_vnops.c | 7 ++++ 3 files changed, 93 insertions(+) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 99368d67aaaa..bfa12b0382bc 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -459,6 +459,7 @@ int tmpfs_dir_getdents(struct tmpfs_mount *, struct tmpfs_node *, int tmpfs_dir_whiteout_add(struct vnode *, struct componentname *); void tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *); int tmpfs_reg_resize(struct vnode *, off_t, boolean_t); +int tmpfs_reg_punch_hole(struct vnode *vp, off_t *, off_t *); int tmpfs_chflags(struct vnode *, u_long, struct ucred *, struct thread *); int tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *); int tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *, diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index e746a7455860..1b7521cf0b0d 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1775,6 +1775,91 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) return (0); } +/* + * Punch hole in the aobj associated with the regular file pointed to by 'vp'. + * Requests completely beyond the end-of-file are converted to no-op. + * + * Returns 0 on success or error code from tmpfs_partial_page_invalidate() on + * failure. + */ +int +tmpfs_reg_punch_hole(struct vnode *vp, off_t *offset, off_t *length) +{ + struct tmpfs_mount *tmp; + struct tmpfs_node *node; + vm_object_t object; + vm_pindex_t pistart, pi, piend; + int startofs, endofs, end; + off_t off, len; + int error; + + KASSERT(*length <= OFF_MAX - *offset, ("%s: offset + length overflows", + __func__)); + node = VP_TO_TMPFS_NODE(vp); + KASSERT(node->tn_type == VREG, ("%s: node is not regular file", + __func__)); + object = node->tn_reg.tn_aobj; + tmp = VFS_TO_TMPFS(vp->v_mount); + off = *offset; + len = omin(node->tn_size - off, *length); + startofs = off & PAGE_MASK; + endofs = (off + len) & PAGE_MASK; + pistart = OFF_TO_IDX(off); + piend = OFF_TO_IDX(off + len); + pi = OFF_TO_IDX((vm_ooffset_t)off + PAGE_MASK); + error = 0; + + /* Handle the case when offset is on or beyond file size. */ + if (len <= 0) { + *length = 0; + return (0); + } + + VM_OBJECT_WLOCK(object); + + /* + * If there is a partial page at the beginning of the hole-punching + * request, fill the partial page with zeroes. + */ + if (startofs != 0) { + end = pistart != piend ? PAGE_SIZE : endofs; + error = tmpfs_partial_page_invalidate(object, pistart, startofs, + end, FALSE); + if (error != 0) + goto out; + off += end - startofs; + len -= end - startofs; + } + + /* + * Toss away the full pages in the affected area. + */ + if (pi < piend) { + vm_object_page_remove(object, pi, piend, 0); + off += IDX_TO_OFF(piend - pi); + len -= IDX_TO_OFF(piend - pi); + } + + /* + * If there is a partial page at the end of the hole-punching request, + * fill the partial page with zeroes. + */ + if (endofs != 0 && pistart != piend) { + error = tmpfs_partial_page_invalidate(object, piend, 0, endofs, + FALSE); + if (error != 0) + goto out; + off += endofs; + len -= endofs; + } + +out: + VM_OBJECT_WUNLOCK(object); + *offset = off; + *length = len; + return (error); +} + void tmpfs_check_mtime(struct vnode *vp) { diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 326a5132990d..d8c74cecdfe4 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -695,6 +695,12 @@ out: return (error); } +static int +tmpfs_deallocate(struct vop_deallocate_args *v) +{ + return (tmpfs_reg_punch_hole(v->a_vp, v->a_offset, v->a_len)); +} + static int tmpfs_fsync(struct vop_fsync_args *v) { @@ -1840,6 +1846,7 @@ struct vop_vector tmpfs_vnodeop_entries = { .vop_read = tmpfs_read, .vop_read_pgcache = tmpfs_read_pgcache, .vop_write = tmpfs_write, + .vop_deallocate = tmpfs_deallocate, .vop_fsync = tmpfs_fsync, .vop_remove = tmpfs_remove, .vop_link = tmpfs_link, From owner-dev-commits-src-all@freebsd.org Wed Aug 25 23:52:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F188065D2D0; Wed, 25 Aug 2021 23:52: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 4Gw2pM6CFgz3vvj; Wed, 25 Aug 2021 23:52: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 BCC02257BB; Wed, 25 Aug 2021 23:52: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 17PNqRAY089692; Wed, 25 Aug 2021 23:52:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PNqRt5089691; Wed, 25 Aug 2021 23:52:27 GMT (envelope-from git) Date: Wed, 25 Aug 2021 23:52:27 GMT Message-Id: <202108252352.17PNqRt5089691@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 8cb9af94fffc - stable/13 - iflib: emulate counters in netmap mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8cb9af94fffc2096d273c0e764dbcdf90774633b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 23:52:28 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=8cb9af94fffc2096d273c0e764dbcdf90774633b commit 8cb9af94fffc2096d273c0e764dbcdf90774633b Author: Stephan de Wit AuthorDate: 2021-08-18 07:17:43 +0000 Commit: Kevin Bowling CommitDate: 2021-08-25 23:51:42 +0000 iflib: emulate counters in netmap mode When iflib devices are in netmap mode the driver counters are no longer updated making it look from userspace tools that traffic has stopped. Reported by: Franco Fichtner Reviewed by: vmaffione, iflib (erj, gallatin) Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31550 (cherry picked from commit 66fa12d8fb61485780f32f0226e79d3389567496) --- sys/net/iflib.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index a71c48e772e5..046ee31604d3 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -988,6 +988,7 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) u_int const lim = kring->nkr_num_slots - 1; u_int const head = kring->rhead; struct if_pkt_info pi; + int tx_pkts = 0, tx_bytes = 0; /* * interrupts on every tx packet are expensive so request @@ -1071,6 +1072,10 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) ctx->isc_txd_encap(ctx->ifc_softc, &pi); DBG_COUNTER_INC(tx_encap); + /* Update transmit counters */ + tx_bytes += pi.ipi_len; + tx_pkts++; + /* Reinit per-packet info for the next one. */ flags = seg_idx = pkt_len = 0; nic_i_start = -1; @@ -1129,6 +1134,10 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) iflib_netmap_timer, txq, txq->ift_netmap_timer.c_cpu, 0); } + + if_inc_counter(ifp, IFCOUNTER_OBYTES, tx_bytes); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, tx_pkts); + return (0); } @@ -1156,7 +1165,7 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) u_int n; u_int const lim = kring->nkr_num_slots - 1; int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR; - int i = 0; + int i = 0, rx_bytes = 0, rx_pkts = 0; if_ctx_t ctx = ifp->if_softc; if_shared_ctx_t sctx = ctx->ifc_sctx; @@ -1227,6 +1236,10 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) if (i == (ri.iri_nfrags - 1)) { ring->slot[nm_i].len -= crclen; ring->slot[nm_i].flags = 0; + + /* Update receive counters */ + rx_bytes += ri.iri_len; + rx_pkts++; } else ring->slot[nm_i].flags = NS_MOREFRAG; } @@ -1264,6 +1277,9 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) */ netmap_fl_refill(rxq, kring, false); + if_inc_counter(ifp, IFCOUNTER_IBYTES, rx_bytes); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, rx_pkts); + return (0); } From owner-dev-commits-src-all@freebsd.org Wed Aug 25 23:52:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D9AFD65DAE2; Wed, 25 Aug 2021 23:52: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 4Gw2pp5pNnz3wCc; Wed, 25 Aug 2021 23:52: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 AEEBD25B33; Wed, 25 Aug 2021 23:52: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 17PNqopB089830; Wed, 25 Aug 2021 23:52:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PNqodK089829; Wed, 25 Aug 2021 23:52:50 GMT (envelope-from git) Date: Wed, 25 Aug 2021 23:52:50 GMT Message-Id: <202108252352.17PNqodK089829@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 412a609da482 - stable/13 - gre: simplify RSS ifdefs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 412a609da4821f52865bbd2b81a4493a3586aca0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 23:52:50 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=412a609da4821f52865bbd2b81a4493a3586aca0 commit 412a609da4821f52865bbd2b81a4493a3586aca0 Author: Franco Fichtner AuthorDate: 2021-08-18 17:05:29 +0000 Commit: Kevin Bowling CommitDate: 2021-08-25 23:52:35 +0000 gre: simplify RSS ifdefs Use the early break to avoid else definitions. When RSS gains a runtime option previous constructs would duplicate and convolute the existing code. While here init flowid and skip magic numbers and late default assignment. Reviewed by: melifaro, kbowling Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31584 (cherry picked from commit bb250fae9e9e278b681cf3a71ced718700ecf74c) --- sys/net/if_gre.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index aa3e4062b060..19014f9fd3de 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -643,46 +643,37 @@ gre_setseqn(struct grehdr *gh, uint32_t seq) static uint32_t gre_flowid(struct gre_softc *sc, struct mbuf *m, uint32_t af) { - uint32_t flowid; + uint32_t flowid = 0; if ((sc->gre_options & GRE_UDPENCAP) == 0 || sc->gre_port != 0) - return (0); -#ifndef RSS - switch (af) { -#ifdef INET - case AF_INET: - flowid = mtod(m, struct ip *)->ip_src.s_addr ^ - mtod(m, struct ip *)->ip_dst.s_addr; - break; -#endif -#ifdef INET6 - case AF_INET6: - flowid = mtod(m, struct ip6_hdr *)->ip6_src.s6_addr32[3] ^ - mtod(m, struct ip6_hdr *)->ip6_dst.s6_addr32[3]; - break; -#endif - default: - flowid = 0; - } -#else /* RSS */ + return (flowid); switch (af) { #ifdef INET case AF_INET: +#ifdef RSS flowid = rss_hash_ip4_2tuple(mtod(m, struct ip *)->ip_src, mtod(m, struct ip *)->ip_dst); break; +#endif + flowid = mtod(m, struct ip *)->ip_src.s_addr ^ + mtod(m, struct ip *)->ip_dst.s_addr; + break; #endif #ifdef INET6 case AF_INET6: +#ifdef RSS flowid = rss_hash_ip6_2tuple( &mtod(m, struct ip6_hdr *)->ip6_src, &mtod(m, struct ip6_hdr *)->ip6_dst); break; +#endif + flowid = mtod(m, struct ip6_hdr *)->ip6_src.s6_addr32[3] ^ + mtod(m, struct ip6_hdr *)->ip6_dst.s6_addr32[3]; + break; #endif default: - flowid = 0; + break; } -#endif return (flowid); } From owner-dev-commits-src-all@freebsd.org Wed Aug 25 23:54:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5D20365D93A; Wed, 25 Aug 2021 23:54: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 4Gw2rS27rnz4QwJ; Wed, 25 Aug 2021 23:54: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 30C852595F; Wed, 25 Aug 2021 23:54: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 17PNsGqK090038; Wed, 25 Aug 2021 23:54:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PNsGLG090037; Wed, 25 Aug 2021 23:54:16 GMT (envelope-from git) Date: Wed, 25 Aug 2021 23:54:16 GMT Message-Id: <202108252354.17PNsGLG090037@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 8751bff1a72e - stable/13 - dhclient: support supersede statement for option 54 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8751bff1a72e55a7829881c583baca77d373f0cf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 23:54:16 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=8751bff1a72e55a7829881c583baca77d373f0cf commit 8751bff1a72e55a7829881c583baca77d373f0cf Author: Fabian Kurtz AuthorDate: 2021-08-18 17:12:48 +0000 Commit: Kevin Bowling CommitDate: 2021-08-25 23:54:05 +0000 dhclient: support supersede statement for option 54 PR: 217978 Reported by: Franco Fichtner Reviewed by: markj Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31503 (cherry picked from commit 0a539a0f005e8acbe4974ede30aa928099c988b9) --- sbin/dhclient/dhclient.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 8c2615e4c3dc..a1628f0ee22f 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -931,6 +931,8 @@ void state_bound(void *ipp) { struct interface_info *ip = ipp; + u_int8_t *dp = NULL; + int len; ASSERT_STATE(state, S_BOUND); @@ -938,10 +940,17 @@ state_bound(void *ipp) make_request(ip, ip->client->active); ip->client->xid = ip->client->packet.xid; - if (ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) { - memcpy(ip->client->destination.iabuf, ip->client->active-> - options[DHO_DHCP_SERVER_IDENTIFIER].data, 4); - ip->client->destination.len = 4; + if (ip->client->config->default_actions[DHO_DHCP_SERVER_IDENTIFIER] == + ACTION_SUPERSEDE) { + dp = ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].data; + len = ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].len; + } else { + dp = ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].data; + len = ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len; + } + if (len == 4) { + memcpy(ip->client->destination.iabuf, dp, len); + ip->client->destination.len = len; } else ip->client->destination = iaddr_broadcast; From owner-dev-commits-src-all@freebsd.org Wed Aug 25 23:57:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B00E565DCB8; Wed, 25 Aug 2021 23:57: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 4Gw2wf4XbKz4RrB; Wed, 25 Aug 2021 23:57: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 83D2625835; Wed, 25 Aug 2021 23:57: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 17PNvs69090411; Wed, 25 Aug 2021 23:57:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17PNvs0D090410; Wed, 25 Aug 2021 23:57:54 GMT (envelope-from git) Date: Wed, 25 Aug 2021 23:57:54 GMT Message-Id: <202108252357.17PNvs0D090410@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 23740b94359a - stable/13 - iflib: Improve mapping of TX/RX queues to CPUs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 23740b94359a7343765c45f34d1897dc952500c3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 23:57:54 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=23740b94359a7343765c45f34d1897dc952500c3 commit 23740b94359a7343765c45f34d1897dc952500c3 Author: Patrick Kelsey AuthorDate: 2021-04-26 04:25:59 +0000 Commit: Kevin Bowling CommitDate: 2021-08-25 23:54:38 +0000 iflib: Improve mapping of TX/RX queues to CPUs iflib now supports mapping each (TX,RX) queue pair to the same CPU (default), to separate CPUs, or to a pair of physical and logical CPUs that share the same L2 cache. The mapping mechanism supports unequal numbers of TX and RX queues, with the excess queues always being mapped to consecutive physical CPUs. When the platform cannot distinguish between physical and logical CPUs, all are treated as physical CPUs. See the comment on get_cpuid_for_queue() for the entire matrix. The following device-specific tunables influence the mapping process: dev...iflib.core_offset (existing) dev...iflib.separate_txrx (existing) dev...iflib.use_logical_cores (new) The following new, read-only sysctls provide visibility of the mapping results: dev...iflib.{t,r}xq.cpu When an iflib driver allocates TX softirqs without providing reference RX IRQs, iflib now binds those TX softirqs to CPUs using the above mapping mechanism (that is, treats them as if they were TX IRQs). Previously, such bindings were left up to the grouptaskqueue code and thus fell outside of the iflib CPU mapping strategy. Reviewed by: kbowling Tested by: olivier, pkelsey MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D24094 (cherry picked from commit ca7005f1893d199b7c28d5b159e1bdbb55e74543) --- sys/net/iflib.c | 454 +++++++++++++++++++++++++++++++++++-------------------- sys/sys/cpuset.h | 1 + 2 files changed, 294 insertions(+), 161 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 046ee31604d3..55ba1895a059 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -195,6 +195,8 @@ struct iflib_ctx { uint16_t ifc_sysctl_core_offset; #define CORE_OFFSET_UNSPECIFIED 0xffff uint8_t ifc_sysctl_separate_txrx; + uint8_t ifc_sysctl_use_logical_cores; + bool ifc_cpus_are_physical_cores; qidx_t ifc_sysctl_ntxds[8]; qidx_t ifc_sysctl_nrxds[8]; @@ -725,7 +727,7 @@ struct cpu_offset { SLIST_ENTRY(cpu_offset) entries; cpuset_t set; unsigned int refcount; - uint16_t offset; + uint16_t next_cpuid; }; static struct mtx cpu_offset_mtx; MTX_SYSINIT(iflib_cpu_offset, &cpu_offset_mtx, "iflib_cpu_offset lock", @@ -4679,41 +4681,291 @@ iflib_rem_pfil(if_ctx_t ctx) pfil_head_unregister(pfil); } + +/* + * Advance forward by n members of the cpuset ctx->ifc_cpus starting from + * cpuid and wrapping as necessary. + */ +static unsigned int +cpuid_advance(if_ctx_t ctx, unsigned int cpuid, unsigned int n) +{ + unsigned int first_valid; + unsigned int last_valid; + + /* cpuid should always be in the valid set */ + MPASS(CPU_ISSET(cpuid, &ctx->ifc_cpus)); + + /* valid set should never be empty */ + MPASS(!CPU_EMPTY(&ctx->ifc_cpus)); + + first_valid = CPU_FFS(&ctx->ifc_cpus) - 1; + last_valid = CPU_FLS(&ctx->ifc_cpus) - 1; + n = n % CPU_COUNT(&ctx->ifc_cpus); + while (n > 0) { + do { + cpuid++; + if (cpuid > last_valid) + cpuid = first_valid; + } while (!CPU_ISSET(cpuid, &ctx->ifc_cpus)); + n--; + } + + return (cpuid); +} + +#if defined(SMP) && defined(SCHED_ULE) +extern struct cpu_group *cpu_top; /* CPU topology */ + +static int +find_child_with_core(int cpu, struct cpu_group *grp) +{ + int i; + + if (grp->cg_children == 0) + return -1; + + MPASS(grp->cg_child); + for (i = 0; i < grp->cg_children; i++) { + if (CPU_ISSET(cpu, &grp->cg_child[i].cg_mask)) + return i; + } + + return -1; +} + + +/* + * Find an L2 neighbor of the given CPU or return -1 if none found. This + * does not distinguish among multiple L2 neighbors if the given CPU has + * more than one (it will always return the same result in that case). + */ +static int +find_l2_neighbor(int cpu) +{ + struct cpu_group *grp; + int i; + + grp = cpu_top; + if (grp == NULL) + return -1; + + /* + * Find the smallest CPU group that contains the given core. + */ + i = 0; + while ((i = find_child_with_core(cpu, grp)) != -1) { + /* + * If the smallest group containing the given CPU has less + * than two members, we conclude the given CPU has no + * L2 neighbor. + */ + if (grp->cg_child[i].cg_count <= 1) + return (-1); + grp = &grp->cg_child[i]; + } + + /* Must share L2. */ + if (grp->cg_level > CG_SHARE_L2 || grp->cg_level == CG_SHARE_NONE) + return -1; + + /* + * Select the first member of the set that isn't the reference + * CPU, which at this point is guaranteed to exist. + */ + for (i = 0; i < CPU_SETSIZE; i++) { + if (CPU_ISSET(i, &grp->cg_mask) && i != cpu) + return (i); + } + + /* Should never be reached */ + return (-1); +} + +#else +static int +find_l2_neighbor(int cpu) +{ + + return (-1); +} +#endif + +/* + * CPU mapping behaviors + * --------------------- + * 'separate txrx' refers to the separate_txrx sysctl + * 'use logical' refers to the use_logical_cores sysctl + * 'INTR CPUS' indicates whether bus_get_cpus(INTR_CPUS) succeeded + * + * separate use INTR + * txrx logical CPUS result + * ---------- --------- ------ ------------------------------------------------ + * - - X RX and TX queues mapped to consecutive physical + * cores with RX/TX pairs on same core and excess + * of either following + * - X X RX and TX queues mapped to consecutive cores + * of any type with RX/TX pairs on same core and + * excess of either following + * X - X RX and TX queues mapped to consecutive physical + * cores; all RX then all TX + * X X X RX queues mapped to consecutive physical cores + * first, then TX queues mapped to L2 neighbor of + * the corresponding RX queue if one exists, + * otherwise to consecutive physical cores + * - n/a - RX and TX queues mapped to consecutive cores of + * any type with RX/TX pairs on same core and excess + * of either following + * X n/a - RX and TX queues mapped to consecutive cores of + * any type; all RX then all TX + */ +static unsigned int +get_cpuid_for_queue(if_ctx_t ctx, unsigned int base_cpuid, unsigned int qid, + bool is_tx) +{ + if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; + unsigned int core_index; + + if (ctx->ifc_sysctl_separate_txrx) { + /* + * When using separate CPUs for TX and RX, the assignment + * will always be of a consecutive CPU out of the set of + * context CPUs, except for the specific case where the + * context CPUs are phsyical cores, the use of logical cores + * has been enabled, the assignment is for TX, the TX qid + * corresponds to an RX qid, and the CPU assigned to the + * corresponding RX queue has an L2 neighbor. + */ + if (ctx->ifc_sysctl_use_logical_cores && + ctx->ifc_cpus_are_physical_cores && + is_tx && qid < scctx->isc_nrxqsets) { + int l2_neighbor; + unsigned int rx_cpuid; + + rx_cpuid = cpuid_advance(ctx, base_cpuid, qid); + l2_neighbor = find_l2_neighbor(rx_cpuid); + if (l2_neighbor != -1) { + return (l2_neighbor); + } + /* + * ... else fall through to the normal + * consecutive-after-RX assignment scheme. + * + * Note that we are assuming that all RX queue CPUs + * have an L2 neighbor, or all do not. If a mixed + * scenario is possible, we will have to keep track + * separately of how many queues prior to this one + * were not able to be assigned to an L2 neighbor. + */ + } + if (is_tx) + core_index = scctx->isc_nrxqsets + qid; + else + core_index = qid; + } else { + core_index = qid; + } + + return (cpuid_advance(ctx, base_cpuid, core_index)); +} + static uint16_t get_ctx_core_offset(if_ctx_t ctx) { if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; struct cpu_offset *op; - uint16_t qc; - uint16_t ret = ctx->ifc_sysctl_core_offset; + cpuset_t assigned_cpus; + unsigned int cores_consumed; + unsigned int base_cpuid = ctx->ifc_sysctl_core_offset; + unsigned int first_valid; + unsigned int last_valid; + unsigned int i; - if (ret != CORE_OFFSET_UNSPECIFIED) - return (ret); + first_valid = CPU_FFS(&ctx->ifc_cpus) - 1; + last_valid = CPU_FLS(&ctx->ifc_cpus) - 1; - if (ctx->ifc_sysctl_separate_txrx) - qc = scctx->isc_ntxqsets + scctx->isc_nrxqsets; - else - qc = max(scctx->isc_ntxqsets, scctx->isc_nrxqsets); + if (base_cpuid != CORE_OFFSET_UNSPECIFIED) { + /* + * Align the user-chosen base CPU ID to the next valid CPU + * for this device. If the chosen base CPU ID is smaller + * than the first valid CPU or larger than the last valid + * CPU, we assume the user does not know what the valid + * range is for this device and is thinking in terms of a + * zero-based reference frame, and so we shift the given + * value into the valid range (and wrap accordingly) so the + * intent is translated to the proper frame of reference. + * If the base CPU ID is within the valid first/last, but + * does not correspond to a valid CPU, it is advanced to the + * next valid CPU (wrapping if necessary). + */ + if (base_cpuid < first_valid || base_cpuid > last_valid) { + /* shift from zero-based to first_valid-based */ + base_cpuid += first_valid; + /* wrap to range [first_valid, last_valid] */ + base_cpuid = (base_cpuid - first_valid) % + (last_valid - first_valid + 1); + } + if (!CPU_ISSET(base_cpuid, &ctx->ifc_cpus)) { + /* + * base_cpuid is in [first_valid, last_valid], but + * not a member of the valid set. In this case, + * there will always be a member of the valid set + * with a CPU ID that is greater than base_cpuid, + * and we simply advance to it. + */ + while (!CPU_ISSET(base_cpuid, &ctx->ifc_cpus)) + base_cpuid++; + } + return (base_cpuid); + } + + /* + * Determine how many cores will be consumed by performing the CPU + * assignments and counting how many of the assigned CPUs correspond + * to CPUs in the set of context CPUs. This is done using the CPU + * ID first_valid as the base CPU ID, as the base CPU must be within + * the set of context CPUs. + * + * Note not all assigned CPUs will be in the set of context CPUs + * when separate CPUs are being allocated to TX and RX queues, + * assignment to logical cores has been enabled, the set of context + * CPUs contains only physical CPUs, and TX queues are mapped to L2 + * neighbors of CPUs that RX queues have been mapped to - in this + * case we do only want to count how many CPUs in the set of context + * CPUs have been consumed, as that determines the next CPU in that + * set to start allocating at for the next device for which + * core_offset is not set. + */ + CPU_ZERO(&assigned_cpus); + for (i = 0; i < scctx->isc_ntxqsets; i++) + CPU_SET(get_cpuid_for_queue(ctx, first_valid, i, true), + &assigned_cpus); + for (i = 0; i < scctx->isc_nrxqsets; i++) + CPU_SET(get_cpuid_for_queue(ctx, first_valid, i, false), + &assigned_cpus); + CPU_AND(&assigned_cpus, &ctx->ifc_cpus); + cores_consumed = CPU_COUNT(&assigned_cpus); mtx_lock(&cpu_offset_mtx); SLIST_FOREACH(op, &cpu_offsets, entries) { if (CPU_CMP(&ctx->ifc_cpus, &op->set) == 0) { - ret = op->offset; - op->offset += qc; + base_cpuid = op->next_cpuid; + op->next_cpuid = cpuid_advance(ctx, op->next_cpuid, + cores_consumed); MPASS(op->refcount < UINT_MAX); op->refcount++; break; } } - if (ret == CORE_OFFSET_UNSPECIFIED) { - ret = 0; + if (base_cpuid == CORE_OFFSET_UNSPECIFIED) { + base_cpuid = first_valid; op = malloc(sizeof(struct cpu_offset), M_IFLIB, M_NOWAIT | M_ZERO); if (op == NULL) { device_printf(ctx->ifc_dev, "allocation for cpu offset failed.\n"); } else { - op->offset = qc; + op->next_cpuid = cpuid_advance(ctx, base_cpuid, + cores_consumed); op->refcount = 1; CPU_COPY(&ctx->ifc_cpus, &op->set); SLIST_INSERT_HEAD(&cpu_offsets, op, entries); @@ -4721,7 +4973,7 @@ get_ctx_core_offset(if_ctx_t ctx) } mtx_unlock(&cpu_offset_mtx); - return (ret); + return (base_cpuid); } static void @@ -4850,7 +5102,9 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) != 0) { device_printf(dev, "Unable to fetch CPU list\n"); CPU_COPY(&all_cpus, &ctx->ifc_cpus); - } + ctx->ifc_cpus_are_physical_cores = false; + } else + ctx->ifc_cpus_are_physical_cores = true; MPASS(CPU_COUNT(&ctx->ifc_cpus) > 0); /* @@ -5969,128 +6223,6 @@ iflib_irq_alloc(if_ctx_t ctx, if_irq_t irq, int rid, return (_iflib_irq_alloc(ctx, irq, rid, filter, handler, arg, name)); } -#ifdef SMP -static int -find_nth(if_ctx_t ctx, int qid) -{ - cpuset_t cpus; - int i, cpuid, eqid, count; - - CPU_COPY(&ctx->ifc_cpus, &cpus); - count = CPU_COUNT(&cpus); - eqid = qid % count; - /* clear up to the qid'th bit */ - for (i = 0; i < eqid; i++) { - cpuid = CPU_FFS(&cpus); - MPASS(cpuid != 0); - CPU_CLR(cpuid-1, &cpus); - } - cpuid = CPU_FFS(&cpus); - MPASS(cpuid != 0); - return (cpuid-1); -} - -#ifdef SCHED_ULE -extern struct cpu_group *cpu_top; /* CPU topology */ - -static int -find_child_with_core(int cpu, struct cpu_group *grp) -{ - int i; - - if (grp->cg_children == 0) - return -1; - - MPASS(grp->cg_child); - for (i = 0; i < grp->cg_children; i++) { - if (CPU_ISSET(cpu, &grp->cg_child[i].cg_mask)) - return i; - } - - return -1; -} - -/* - * Find the nth "close" core to the specified core - * "close" is defined as the deepest level that shares - * at least an L2 cache. With threads, this will be - * threads on the same core. If the shared cache is L3 - * or higher, simply returns the same core. - */ -static int -find_close_core(int cpu, int core_offset) -{ - struct cpu_group *grp; - int i; - int fcpu; - cpuset_t cs; - - grp = cpu_top; - if (grp == NULL) - return cpu; - i = 0; - while ((i = find_child_with_core(cpu, grp)) != -1) { - /* If the child only has one cpu, don't descend */ - if (grp->cg_child[i].cg_count <= 1) - break; - grp = &grp->cg_child[i]; - } - - /* If they don't share at least an L2 cache, use the same CPU */ - if (grp->cg_level > CG_SHARE_L2 || grp->cg_level == CG_SHARE_NONE) - return cpu; - - /* Now pick one */ - CPU_COPY(&grp->cg_mask, &cs); - - /* Add the selected CPU offset to core offset. */ - for (i = 0; (fcpu = CPU_FFS(&cs)) != 0; i++) { - if (fcpu - 1 == cpu) - break; - CPU_CLR(fcpu - 1, &cs); - } - MPASS(fcpu); - - core_offset += i; - - CPU_COPY(&grp->cg_mask, &cs); - for (i = core_offset % grp->cg_count; i > 0; i--) { - MPASS(CPU_FFS(&cs)); - CPU_CLR(CPU_FFS(&cs) - 1, &cs); - } - MPASS(CPU_FFS(&cs)); - return CPU_FFS(&cs) - 1; -} -#else -static int -find_close_core(int cpu, int core_offset __unused) -{ - return cpu; -} -#endif - -static int -get_core_offset(if_ctx_t ctx, iflib_intr_type_t type, int qid) -{ - switch (type) { - case IFLIB_INTR_TX: - /* TX queues get cores which share at least an L2 cache with the corresponding RX queue */ - /* XXX handle multiple RX threads per core and more than two core per L2 group */ - return qid / CPU_COUNT(&ctx->ifc_cpus) + 1; - case IFLIB_INTR_RX: - case IFLIB_INTR_RXTX: - /* RX queues get the specified core */ - return qid / CPU_COUNT(&ctx->ifc_cpus); - default: - return -1; - } -} -#else -#define get_core_offset(ctx, type, qid) CPU_FIRST() -#define find_close_core(cpuid, tid) CPU_FIRST() -#define find_nth(ctx, gid) CPU_FIRST() -#endif - /* Just to avoid copy/paste */ static inline int iflib_irq_set_affinity(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, @@ -6098,21 +6230,14 @@ iflib_irq_set_affinity(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, const char *name) { device_t dev; - int co, cpuid, err, tid; + unsigned int base_cpuid, cpuid; + int err; dev = ctx->ifc_dev; - co = ctx->ifc_sysctl_core_offset; - if (ctx->ifc_sysctl_separate_txrx && type == IFLIB_INTR_TX) - co += ctx->ifc_softc_ctx.isc_nrxqsets; - cpuid = find_nth(ctx, qid + co); - tid = get_core_offset(ctx, type, qid); - if (tid < 0) { - device_printf(dev, "get_core_offset failed\n"); - return (EOPNOTSUPP); - } - cpuid = find_close_core(cpuid, tid); - err = taskqgroup_attach_cpu(tqg, gtask, uniq, cpuid, dev, irq->ii_res, - name); + base_cpuid = ctx->ifc_sysctl_core_offset; + cpuid = get_cpuid_for_queue(ctx, base_cpuid, qid, type == IFLIB_INTR_TX); + err = taskqgroup_attach_cpu(tqg, gtask, uniq, cpuid, dev, + irq ? irq->ii_res : NULL, name); if (err) { device_printf(dev, "taskqgroup_attach_cpu failed %d\n", err); return (err); @@ -6201,8 +6326,8 @@ iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid, return (0); if (tqrid != -1) { - err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, - q, name); + err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, q, + name); if (err) return (err); } else { @@ -6215,6 +6340,7 @@ iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid, void iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, void *arg, int qid, const char *name) { + device_t dev; struct grouptask *gtask; struct taskqgroup *tqg; gtask_fn_t *fn; @@ -6246,14 +6372,11 @@ iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, default: panic("unknown net intr type"); } - if (irq != NULL) { - err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, - q, name); - if (err) - taskqgroup_attach(tqg, gtask, q, ctx->ifc_dev, - irq->ii_res, name); - } else { - taskqgroup_attach(tqg, gtask, q, NULL, NULL, name); + err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, q, name); + if (err) { + dev = ctx->ifc_dev; + taskqgroup_attach(tqg, gtask, q, dev, irq ? irq->ii_res : NULL, + name); } } @@ -6735,6 +6858,9 @@ iflib_add_device_sysctl_pre(if_ctx_t ctx) SYSCTL_ADD_U8(ctx_list, oid_list, OID_AUTO, "separate_txrx", CTLFLAG_RDTUN, &ctx->ifc_sysctl_separate_txrx, 0, "use separate cores for TX and RX"); + SYSCTL_ADD_U8(ctx_list, oid_list, OID_AUTO, "use_logical_cores", + CTLFLAG_RDTUN, &ctx->ifc_sysctl_use_logical_cores, 0, + "try to make use of logical cores for TX and RX"); /* XXX change for per-queue sizes */ SYSCTL_ADD_PROC(ctx_list, oid_list, OID_AUTO, "override_ntxds", @@ -6779,6 +6905,9 @@ iflib_add_device_sysctl_post(if_ctx_t ctx) queue_node = SYSCTL_ADD_NODE(ctx_list, child, OID_AUTO, namebuf, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Queue Name"); queue_list = SYSCTL_CHILDREN(queue_node); + SYSCTL_ADD_INT(ctx_list, queue_list, OID_AUTO, "cpu", + CTLFLAG_RD, + &txq->ift_task.gt_cpu, 0, "cpu this queue is bound to"); #if MEMORY_LOGGING SYSCTL_ADD_QUAD(ctx_list, queue_list, OID_AUTO, "txq_dequeued", CTLFLAG_RD, @@ -6861,6 +6990,9 @@ iflib_add_device_sysctl_post(if_ctx_t ctx) queue_node = SYSCTL_ADD_NODE(ctx_list, child, OID_AUTO, namebuf, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Queue Name"); queue_list = SYSCTL_CHILDREN(queue_node); + SYSCTL_ADD_INT(ctx_list, queue_list, OID_AUTO, "cpu", + CTLFLAG_RD, + &rxq->ifr_task.gt_cpu, 0, "cpu this queue is bound to"); if (sctx->isc_flags & IFLIB_HAS_RXCQ) { SYSCTL_ADD_U16(ctx_list, queue_list, OID_AUTO, "rxq_cq_cidx", CTLFLAG_RD, diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index c48a0440d808..1a96bb4766ce 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -65,6 +65,7 @@ #define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s) #define CPU_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) #define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p) +#define CPU_FLS(p) BIT_FLS(CPU_SETSIZE, p) #define CPU_COUNT(p) ((int)BIT_COUNT(CPU_SETSIZE, p)) #define CPUSET_FSET BITSET_FSET(_NCPUWORDS) #define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER From owner-dev-commits-src-all@freebsd.org Thu Aug 26 00:03:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CC2A65DDA8; Thu, 26 Aug 2021 00:03:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gw32r1s4Lz4TJd; Thu, 26 Aug 2021 00:03:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C10825EA9; Thu, 26 Aug 2021 00:03:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q03GV7004108; Thu, 26 Aug 2021 00:03:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q03GEP004107; Thu, 26 Aug 2021 00:03:16 GMT (envelope-from git) Date: Thu, 26 Aug 2021 00:03:16 GMT Message-Id: <202108260003.17Q03GEP004107@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 477308acc5f0 - stable/12 - iflib: emulate counters in netmap mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 477308acc5f0c11940e98c4f278f2f4f1b072360 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 00:03:16 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=477308acc5f0c11940e98c4f278f2f4f1b072360 commit 477308acc5f0c11940e98c4f278f2f4f1b072360 Author: Stephan de Wit AuthorDate: 2021-08-18 07:17:43 +0000 Commit: Kevin Bowling CommitDate: 2021-08-26 00:01:26 +0000 iflib: emulate counters in netmap mode When iflib devices are in netmap mode the driver counters are no longer updated making it look from userspace tools that traffic has stopped. Reported by: Franco Fichtner Reviewed by: vmaffione, iflib (erj, gallatin) Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31550 (cherry picked from commit 66fa12d8fb61485780f32f0226e79d3389567496) --- sys/net/iflib.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 1976852209a1..fb43a62ba67f 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -994,6 +994,7 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) u_int const lim = kring->nkr_num_slots - 1; u_int const head = kring->rhead; struct if_pkt_info pi; + int tx_pkts = 0, tx_bytes = 0; /* * interrupts on every tx packet are expensive so request @@ -1077,6 +1078,10 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) ctx->isc_txd_encap(ctx->ifc_softc, &pi); DBG_COUNTER_INC(tx_encap); + /* Update transmit counters */ + tx_bytes += pi.ipi_len; + tx_pkts++; + /* Reinit per-packet info for the next one. */ flags = seg_idx = pkt_len = 0; nic_i_start = -1; @@ -1135,6 +1140,10 @@ iflib_netmap_txsync(struct netmap_kring *kring, int flags) iflib_netmap_timer, txq, txq->ift_netmap_timer.c_cpu, 0); } + + if_inc_counter(ifp, IFCOUNTER_OBYTES, tx_bytes); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, tx_pkts); + return (0); } @@ -1162,7 +1171,7 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) u_int n; u_int const lim = kring->nkr_num_slots - 1; int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR; - int i = 0; + int i = 0, rx_bytes = 0, rx_pkts = 0; if_ctx_t ctx = ifp->if_softc; if_shared_ctx_t sctx = ctx->ifc_sctx; @@ -1233,6 +1242,10 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) if (i == (ri.iri_nfrags - 1)) { ring->slot[nm_i].len -= crclen; ring->slot[nm_i].flags = 0; + + /* Update receive counters */ + rx_bytes += ri.iri_len; + rx_pkts++; } else ring->slot[nm_i].flags = NS_MOREFRAG; } @@ -1270,6 +1283,9 @@ iflib_netmap_rxsync(struct netmap_kring *kring, int flags) */ netmap_fl_refill(rxq, kring, false); + if_inc_counter(ifp, IFCOUNTER_IBYTES, rx_bytes); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, rx_pkts); + return (0); } From owner-dev-commits-src-all@freebsd.org Thu Aug 26 00:03:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A396E65DDA9; Thu, 26 Aug 2021 00:03: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 4Gw32s2VSSz4TWV; Thu, 26 Aug 2021 00:03:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3D58425C78; Thu, 26 Aug 2021 00:03:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q03Hs4004138; Thu, 26 Aug 2021 00:03:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q03HK7004137; Thu, 26 Aug 2021 00:03:17 GMT (envelope-from git) Date: Thu, 26 Aug 2021 00:03:17 GMT Message-Id: <202108260003.17Q03HK7004137@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 5e2076065c8b - stable/12 - gre: simplify RSS ifdefs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 5e2076065c8b7dc60db1a856e1acdf2d8070400e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 00:03:17 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5e2076065c8b7dc60db1a856e1acdf2d8070400e commit 5e2076065c8b7dc60db1a856e1acdf2d8070400e Author: Franco Fichtner AuthorDate: 2021-08-18 17:05:29 +0000 Commit: Kevin Bowling CommitDate: 2021-08-26 00:01:53 +0000 gre: simplify RSS ifdefs Use the early break to avoid else definitions. When RSS gains a runtime option previous constructs would duplicate and convolute the existing code. While here init flowid and skip magic numbers and late default assignment. Reviewed by: melifaro, kbowling Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31584 (cherry picked from commit bb250fae9e9e278b681cf3a71ced718700ecf74c) --- sys/net/if_gre.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index cb0e83d10537..462a2ecdc680 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -643,46 +643,37 @@ gre_setseqn(struct grehdr *gh, uint32_t seq) static uint32_t gre_flowid(struct gre_softc *sc, struct mbuf *m, uint32_t af) { - uint32_t flowid; + uint32_t flowid = 0; if ((sc->gre_options & GRE_UDPENCAP) == 0 || sc->gre_port != 0) - return (0); -#ifndef RSS - switch (af) { -#ifdef INET - case AF_INET: - flowid = mtod(m, struct ip *)->ip_src.s_addr ^ - mtod(m, struct ip *)->ip_dst.s_addr; - break; -#endif -#ifdef INET6 - case AF_INET6: - flowid = mtod(m, struct ip6_hdr *)->ip6_src.s6_addr32[3] ^ - mtod(m, struct ip6_hdr *)->ip6_dst.s6_addr32[3]; - break; -#endif - default: - flowid = 0; - } -#else /* RSS */ + return (flowid); switch (af) { #ifdef INET case AF_INET: +#ifdef RSS flowid = rss_hash_ip4_2tuple(mtod(m, struct ip *)->ip_src, mtod(m, struct ip *)->ip_dst); break; +#endif + flowid = mtod(m, struct ip *)->ip_src.s_addr ^ + mtod(m, struct ip *)->ip_dst.s_addr; + break; #endif #ifdef INET6 case AF_INET6: +#ifdef RSS flowid = rss_hash_ip6_2tuple( &mtod(m, struct ip6_hdr *)->ip6_src, &mtod(m, struct ip6_hdr *)->ip6_dst); break; +#endif + flowid = mtod(m, struct ip6_hdr *)->ip6_src.s6_addr32[3] ^ + mtod(m, struct ip6_hdr *)->ip6_dst.s6_addr32[3]; + break; #endif default: - flowid = 0; + break; } -#endif return (flowid); } From owner-dev-commits-src-all@freebsd.org Thu Aug 26 00:03:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5BEDE65DD6C; Thu, 26 Aug 2021 00:03: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 4Gw32v0DbGz4TL7; Thu, 26 Aug 2021 00:03: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 6D30125EAA; Thu, 26 Aug 2021 00:03: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 17Q03ID1004163; Thu, 26 Aug 2021 00:03:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q03IIE004162; Thu, 26 Aug 2021 00:03:18 GMT (envelope-from git) Date: Thu, 26 Aug 2021 00:03:18 GMT Message-Id: <202108260003.17Q03IIE004162@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 663441de575d - stable/12 - dhclient: support supersede statement for option 54 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 663441de575dbdd38275d298ba220a4dc871f14b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 00:03:19 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=663441de575dbdd38275d298ba220a4dc871f14b commit 663441de575dbdd38275d298ba220a4dc871f14b Author: Fabian Kurtz AuthorDate: 2021-08-18 17:12:48 +0000 Commit: Kevin Bowling CommitDate: 2021-08-26 00:02:21 +0000 dhclient: support supersede statement for option 54 PR: 217978 Reported by: Franco Fichtner Reviewed by: markj Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31503 (cherry picked from commit 0a539a0f005e8acbe4974ede30aa928099c988b9) --- sbin/dhclient/dhclient.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 4108405d99b0..628490874e69 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -923,6 +923,8 @@ void state_bound(void *ipp) { struct interface_info *ip = ipp; + u_int8_t *dp = NULL; + int len; ASSERT_STATE(state, S_BOUND); @@ -930,10 +932,17 @@ state_bound(void *ipp) make_request(ip, ip->client->active); ip->client->xid = ip->client->packet.xid; - if (ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) { - memcpy(ip->client->destination.iabuf, ip->client->active-> - options[DHO_DHCP_SERVER_IDENTIFIER].data, 4); - ip->client->destination.len = 4; + if (ip->client->config->default_actions[DHO_DHCP_SERVER_IDENTIFIER] == + ACTION_SUPERSEDE) { + dp = ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].data; + len = ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].len; + } else { + dp = ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].data; + len = ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len; + } + if (len == 4) { + memcpy(ip->client->destination.iabuf, dp, len); + ip->client->destination.len = len; } else ip->client->destination = iaddr_broadcast; From owner-dev-commits-src-all@freebsd.org Thu Aug 26 00:04:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4285A65DFEB; Thu, 26 Aug 2021 00: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 4Gw3441FL7z4Tlm; Thu, 26 Aug 2021 00: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 139B525B70; Thu, 26 Aug 2021 00: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 17Q04J7G004373; Thu, 26 Aug 2021 00: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 17Q04JhZ004372; Thu, 26 Aug 2021 00:04:19 GMT (envelope-from git) Date: Thu, 26 Aug 2021 00:04:19 GMT Message-Id: <202108260004.17Q04JhZ004372@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: c4055d704360 - stable/11 - dhclient: support supersede statement for option 54 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: c4055d704360af150d4c9f535aef7a53e99f9d75 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 00:04:20 -0000 The branch stable/11 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c4055d704360af150d4c9f535aef7a53e99f9d75 commit c4055d704360af150d4c9f535aef7a53e99f9d75 Author: Fabian Kurtz AuthorDate: 2021-08-18 17:12:48 +0000 Commit: Kevin Bowling CommitDate: 2021-08-26 00:03:54 +0000 dhclient: support supersede statement for option 54 PR: 217978 Reported by: Franco Fichtner Reviewed by: markj Obtained from: OPNsense MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31503 (cherry picked from commit 0a539a0f005e8acbe4974ede30aa928099c988b9) --- sbin/dhclient/dhclient.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index ec4ad127a4a7..7ca9cfe8ab42 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -889,6 +889,8 @@ void state_bound(void *ipp) { struct interface_info *ip = ipp; + u_int8_t *dp = NULL; + int len; ASSERT_STATE(state, S_BOUND); @@ -896,10 +898,17 @@ state_bound(void *ipp) make_request(ip, ip->client->active); ip->client->xid = ip->client->packet.xid; - if (ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len == 4) { - memcpy(ip->client->destination.iabuf, ip->client->active-> - options[DHO_DHCP_SERVER_IDENTIFIER].data, 4); - ip->client->destination.len = 4; + if (ip->client->config->default_actions[DHO_DHCP_SERVER_IDENTIFIER] == + ACTION_SUPERSEDE) { + dp = ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].data; + len = ip->client->config->defaults[DHO_DHCP_SERVER_IDENTIFIER].len; + } else { + dp = ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].data; + len = ip->client->active->options[DHO_DHCP_SERVER_IDENTIFIER].len; + } + if (len == 4) { + memcpy(ip->client->destination.iabuf, dp, len); + ip->client->destination.len = len; } else ip->client->destination = iaddr_broadcast; From owner-dev-commits-src-all@freebsd.org Thu Aug 26 00:31:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2E96865E415; Thu, 26 Aug 2021 00:31: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 4Gw3gf0lRfz4dSs; Thu, 26 Aug 2021 00:31: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 01A9B26273; Thu, 26 Aug 2021 00:31: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 17Q0Vf5m041168; Thu, 26 Aug 2021 00:31:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q0VfZB041167; Thu, 26 Aug 2021 00:31:41 GMT (envelope-from git) Date: Thu, 26 Aug 2021 00:31:41 GMT Message-Id: <202108260031.17Q0VfZB041167@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 524ea0dea9b0 - stable/13 - e1000: Update intel shared code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 524ea0dea9b07183c1f36ec894d9494fcc0ffe5a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 00:31:42 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=524ea0dea9b07183c1f36ec894d9494fcc0ffe5a commit 524ea0dea9b07183c1f36ec894d9494fcc0ffe5a Author: Kevin Bowling AuthorDate: 2021-08-19 14:59:34 +0000 Commit: Kevin Bowling CommitDate: 2021-08-26 00:31:17 +0000 e1000: Update intel shared code Sync the e1000 shared code with DPDK shared code "cid-gigabit.2020.06.05.tar.gz released by ND" Primary focus was on client platforms (ich8lan). More work remains here but we need an Intel contact for client networking. Reviewed by: grehan, Intel Networking (erj, earlier rev) Obtained from: DPDK MFC after: 1 week Sponsored by: me Differential Revision: https://reviews.freebsd.org/D31547 (cherry picked from commit fc7682b17f3738573099b8b03f5628dcc8148adb) --- sys/dev/e1000/e1000_80003es2lan.c | 36 ++--- sys/dev/e1000/e1000_80003es2lan.h | 38 ++--- sys/dev/e1000/e1000_82540.c | 40 ++--- sys/dev/e1000/e1000_82541.c | 40 ++--- sys/dev/e1000/e1000_82541.h | 40 ++--- sys/dev/e1000/e1000_82542.c | 40 ++--- sys/dev/e1000/e1000_82543.c | 40 ++--- sys/dev/e1000/e1000_82543.h | 40 ++--- sys/dev/e1000/e1000_82571.c | 42 ++--- sys/dev/e1000/e1000_82571.h | 40 ++--- sys/dev/e1000/e1000_82575.c | 40 ++--- sys/dev/e1000/e1000_82575.h | 40 ++--- sys/dev/e1000/e1000_api.c | 56 ++++--- sys/dev/e1000/e1000_api.h | 41 ++--- sys/dev/e1000/e1000_defines.h | 73 ++++++--- sys/dev/e1000/e1000_hw.h | 42 ++--- sys/dev/e1000/e1000_i210.c | 140 ++++++++++++++--- sys/dev/e1000/e1000_i210.h | 42 ++--- sys/dev/e1000/e1000_ich8lan.c | 316 ++++++++++++++++++++++++++++++-------- sys/dev/e1000/e1000_ich8lan.h | 47 +++--- sys/dev/e1000/e1000_mac.c | 40 ++--- sys/dev/e1000/e1000_mac.h | 40 ++--- sys/dev/e1000/e1000_manage.c | 40 ++--- sys/dev/e1000/e1000_manage.h | 40 ++--- sys/dev/e1000/e1000_mbx.c | 40 ++--- sys/dev/e1000/e1000_mbx.h | 40 ++--- sys/dev/e1000/e1000_nvm.c | 199 +++++++++++++++++++++--- sys/dev/e1000/e1000_nvm.h | 42 +++-- sys/dev/e1000/e1000_osdep.c | 40 ++--- sys/dev/e1000/e1000_osdep.h | 40 ++--- sys/dev/e1000/e1000_phy.c | 62 ++++---- sys/dev/e1000/e1000_phy.h | 49 +++--- sys/dev/e1000/e1000_regs.h | 55 ++++--- sys/dev/e1000/e1000_vf.c | 43 +++--- sys/dev/e1000/e1000_vf.h | 40 ++--- sys/dev/e1000/if_em.c | 10 +- 36 files changed, 1298 insertions(+), 755 deletions(-) diff --git a/sys/dev/e1000/e1000_80003es2lan.c b/sys/dev/e1000/e1000_80003es2lan.c index 5c0220adfc6f..c1aa47a73ac8 100644 --- a/sys/dev/e1000/e1000_80003es2lan.c +++ b/sys/dev/e1000/e1000_80003es2lan.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its + + 3. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_80003es2lan.h b/sys/dev/e1000/e1000_80003es2lan.h index cbf0eafa9407..501cfc958819 100644 --- a/sys/dev/e1000/e1000_80003es2lan.h +++ b/sys/dev/e1000/e1000_80003es2lan.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82540.c b/sys/dev/e1000/e1000_82540.c index adc944a8ebb4..720798260f8a 100644 --- a/sys/dev/e1000/e1000_82540.c +++ b/sys/dev/e1000/e1000_82540.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82541.c b/sys/dev/e1000/e1000_82541.c index ead974cb1358..aaa3de7f02ce 100644 --- a/sys/dev/e1000/e1000_82541.c +++ b/sys/dev/e1000/e1000_82541.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82541.h b/sys/dev/e1000/e1000_82541.h index ce29548a4d85..d31065d9a182 100644 --- a/sys/dev/e1000/e1000_82541.h +++ b/sys/dev/e1000/e1000_82541.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82542.c b/sys/dev/e1000/e1000_82542.c index 09906699ab10..2fdf7066865b 100644 --- a/sys/dev/e1000/e1000_82542.c +++ b/sys/dev/e1000/e1000_82542.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82543.c b/sys/dev/e1000/e1000_82543.c index e247b01f6cda..42c4726fa8c7 100644 --- a/sys/dev/e1000/e1000_82543.c +++ b/sys/dev/e1000/e1000_82543.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82543.h b/sys/dev/e1000/e1000_82543.h index 98289524f6d8..27f8507fb63c 100644 --- a/sys/dev/e1000/e1000_82543.h +++ b/sys/dev/e1000/e1000_82543.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82571.c b/sys/dev/e1000/e1000_82571.c index 348a3daa3c05..8db1fcb921a9 100644 --- a/sys/dev/e1000/e1000_82571.c +++ b/sys/dev/e1000/e1000_82571.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -515,7 +515,7 @@ e1000_get_hw_semaphore_82574(struct e1000_hw *hw) u32 extcnf_ctrl; s32 i = 0; /* XXX assert that mutex is held */ - DEBUGFUNC("e1000_get_hw_semaphore_82573"); + DEBUGFUNC("e1000_get_hw_semaphore_82574"); ASSERT_CTX_LOCK_HELD(hw); extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); diff --git a/sys/dev/e1000/e1000_82571.h b/sys/dev/e1000/e1000_82571.h index a39f63c53e2d..77303adb162f 100644 --- a/sys/dev/e1000/e1000_82571.h +++ b/sys/dev/e1000/e1000_82571.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82575.c b/sys/dev/e1000/e1000_82575.c index 81bd419fcf0d..d588539ca8e8 100644 --- a/sys/dev/e1000/e1000_82575.c +++ b/sys/dev/e1000/e1000_82575.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82575.h b/sys/dev/e1000/e1000_82575.h index 36045556661b..22c2f8c4a2f5 100644 --- a/sys/dev/e1000/e1000_82575.h +++ b/sys/dev/e1000/e1000_82575.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_api.c b/sys/dev/e1000/e1000_api.c index b1d5ef74c24f..b28ab77f3794 100644 --- a/sys/dev/e1000/e1000_api.c +++ b/sys/dev/e1000/e1000_api.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -383,6 +383,7 @@ s32 e1000_set_mac_type(struct e1000_hw *hw) break; case E1000_DEV_ID_I210_COPPER_FLASHLESS: case E1000_DEV_ID_I210_SERDES_FLASHLESS: + case E1000_DEV_ID_I210_SGMII_FLASHLESS: case E1000_DEV_ID_I210_COPPER: case E1000_DEV_ID_I210_COPPER_OEM1: case E1000_DEV_ID_I210_COPPER_IT: @@ -1268,6 +1269,21 @@ s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size) return e1000_read_pba_length_generic(hw, pba_num_size); } +/** + * e1000_read_pba_num - Read device part number + * @hw: pointer to the HW structure + * @pba_num: pointer to device part number + * + * Reads the product board assembly (PBA) number from the EEPROM and stores + * the value in pba_num. + * Currently no func pointer exists and all implementations are handled in the + * generic version of this function. + **/ +s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num) +{ + return e1000_read_pba_num_generic(hw, pba_num); +} + /** * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum * @hw: pointer to the HW structure diff --git a/sys/dev/e1000/e1000_api.h b/sys/dev/e1000/e1000_api.h index bf5f637cb3dd..b558b1cf5f23 100644 --- a/sys/dev/e1000/e1000_api.h +++ b/sys/dev/e1000/e1000_api.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -100,6 +100,7 @@ void e1000_power_down_phy(struct e1000_hw *hw); s32 e1000_read_mac_addr(struct e1000_hw *hw); s32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size); s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size); +s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *part_num); void e1000_reload_nvm(struct e1000_hw *hw); s32 e1000_update_nvm_checksum(struct e1000_hw *hw); s32 e1000_validate_nvm_checksum(struct e1000_hw *hw); diff --git a/sys/dev/e1000/e1000_defines.h b/sys/dev/e1000/e1000_defines.h index 262b01dd5b64..6c1138ed9335 100644 --- a/sys/dev/e1000/e1000_defines.h +++ b/sys/dev/e1000/e1000_defines.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -1070,11 +1070,44 @@ /* NVM Word Offsets */ #define NVM_COMPAT 0x0003 #define NVM_ID_LED_SETTINGS 0x0004 +#define NVM_VERSION 0x0005 #define NVM_SERDES_AMPLITUDE 0x0006 /* SERDES output amplitude */ #define NVM_PHY_CLASS_WORD 0x0007 #define E1000_I210_NVM_FW_MODULE_PTR 0x0010 #define E1000_I350_NVM_FW_MODULE_PTR 0x0051 #define NVM_FUTURE_INIT_WORD1 0x0019 +#define NVM_ETRACK_WORD 0x0042 +#define NVM_ETRACK_HIWORD 0x0043 +#define NVM_COMB_VER_OFF 0x0083 +#define NVM_COMB_VER_PTR 0x003D + +/* NVM version defines */ +#define NVM_MAJOR_MASK 0xF000 +#define NVM_MINOR_MASK 0x0FF0 +#define NVM_IMAGE_ID_MASK 0x000F +#define NVM_COMB_VER_MASK 0x00FF +#define NVM_MAJOR_SHIFT 12 +#define NVM_MINOR_SHIFT 4 +#define NVM_COMB_VER_SHFT 8 +#define NVM_VER_INVALID 0xFFFF *** 2218 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Thu Aug 26 00:32:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 663E865E435; Thu, 26 Aug 2021 00:32: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 4Gw3hK28Q3z4dlm; Thu, 26 Aug 2021 00:32: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 3260F264A6; Thu, 26 Aug 2021 00:32: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 17Q0WHKJ043704; Thu, 26 Aug 2021 00:32:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q0WHs9043703; Thu, 26 Aug 2021 00:32:17 GMT (envelope-from git) Date: Thu, 26 Aug 2021 00:32:17 GMT Message-Id: <202108260032.17Q0WHs9043703@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: bd942358645c - stable/12 - e1000: Update intel shared code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: bd942358645c35e98e4ed2690eca3e351a8796a4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 00:32:17 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=bd942358645c35e98e4ed2690eca3e351a8796a4 commit bd942358645c35e98e4ed2690eca3e351a8796a4 Author: Kevin Bowling AuthorDate: 2021-08-19 14:59:34 +0000 Commit: Kevin Bowling CommitDate: 2021-08-26 00:32:07 +0000 e1000: Update intel shared code Sync the e1000 shared code with DPDK shared code "cid-gigabit.2020.06.05.tar.gz released by ND" Primary focus was on client platforms (ich8lan). More work remains here but we need an Intel contact for client networking. Reviewed by: grehan, Intel Networking (erj, earlier rev) Obtained from: DPDK MFC after: 1 week Sponsored by: me Differential Revision: https://reviews.freebsd.org/D31547 (cherry picked from commit fc7682b17f3738573099b8b03f5628dcc8148adb) --- sys/dev/e1000/e1000_80003es2lan.c | 36 ++--- sys/dev/e1000/e1000_80003es2lan.h | 38 ++--- sys/dev/e1000/e1000_82540.c | 40 ++--- sys/dev/e1000/e1000_82541.c | 40 ++--- sys/dev/e1000/e1000_82541.h | 40 ++--- sys/dev/e1000/e1000_82542.c | 40 ++--- sys/dev/e1000/e1000_82543.c | 40 ++--- sys/dev/e1000/e1000_82543.h | 40 ++--- sys/dev/e1000/e1000_82571.c | 42 ++--- sys/dev/e1000/e1000_82571.h | 40 ++--- sys/dev/e1000/e1000_82575.c | 40 ++--- sys/dev/e1000/e1000_82575.h | 40 ++--- sys/dev/e1000/e1000_api.c | 56 ++++--- sys/dev/e1000/e1000_api.h | 41 ++--- sys/dev/e1000/e1000_defines.h | 73 ++++++--- sys/dev/e1000/e1000_hw.h | 42 ++--- sys/dev/e1000/e1000_i210.c | 140 ++++++++++++++--- sys/dev/e1000/e1000_i210.h | 42 ++--- sys/dev/e1000/e1000_ich8lan.c | 316 ++++++++++++++++++++++++++++++-------- sys/dev/e1000/e1000_ich8lan.h | 47 +++--- sys/dev/e1000/e1000_mac.c | 40 ++--- sys/dev/e1000/e1000_mac.h | 40 ++--- sys/dev/e1000/e1000_manage.c | 40 ++--- sys/dev/e1000/e1000_manage.h | 40 ++--- sys/dev/e1000/e1000_mbx.c | 40 ++--- sys/dev/e1000/e1000_mbx.h | 40 ++--- sys/dev/e1000/e1000_nvm.c | 199 +++++++++++++++++++++--- sys/dev/e1000/e1000_nvm.h | 42 +++-- sys/dev/e1000/e1000_osdep.c | 40 ++--- sys/dev/e1000/e1000_osdep.h | 40 ++--- sys/dev/e1000/e1000_phy.c | 62 ++++---- sys/dev/e1000/e1000_phy.h | 49 +++--- sys/dev/e1000/e1000_regs.h | 55 ++++--- sys/dev/e1000/e1000_vf.c | 43 +++--- sys/dev/e1000/e1000_vf.h | 40 ++--- sys/dev/e1000/if_em.c | 10 +- 36 files changed, 1298 insertions(+), 755 deletions(-) diff --git a/sys/dev/e1000/e1000_80003es2lan.c b/sys/dev/e1000/e1000_80003es2lan.c index 5c0220adfc6f..c1aa47a73ac8 100644 --- a/sys/dev/e1000/e1000_80003es2lan.c +++ b/sys/dev/e1000/e1000_80003es2lan.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its + + 3. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_80003es2lan.h b/sys/dev/e1000/e1000_80003es2lan.h index cbf0eafa9407..501cfc958819 100644 --- a/sys/dev/e1000/e1000_80003es2lan.h +++ b/sys/dev/e1000/e1000_80003es2lan.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82540.c b/sys/dev/e1000/e1000_82540.c index d90c8f9b73f1..0296397ee013 100644 --- a/sys/dev/e1000/e1000_82540.c +++ b/sys/dev/e1000/e1000_82540.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82541.c b/sys/dev/e1000/e1000_82541.c index 04f3b356b6f1..bd5ff7e0d11f 100644 --- a/sys/dev/e1000/e1000_82541.c +++ b/sys/dev/e1000/e1000_82541.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82541.h b/sys/dev/e1000/e1000_82541.h index ce29548a4d85..d31065d9a182 100644 --- a/sys/dev/e1000/e1000_82541.h +++ b/sys/dev/e1000/e1000_82541.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82542.c b/sys/dev/e1000/e1000_82542.c index 57deeb87a089..2bd38b674cc4 100644 --- a/sys/dev/e1000/e1000_82542.c +++ b/sys/dev/e1000/e1000_82542.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82543.c b/sys/dev/e1000/e1000_82543.c index 48ad49294f31..ac81cbd296f2 100644 --- a/sys/dev/e1000/e1000_82543.c +++ b/sys/dev/e1000/e1000_82543.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82543.h b/sys/dev/e1000/e1000_82543.h index 98289524f6d8..27f8507fb63c 100644 --- a/sys/dev/e1000/e1000_82543.h +++ b/sys/dev/e1000/e1000_82543.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82571.c b/sys/dev/e1000/e1000_82571.c index 348a3daa3c05..8db1fcb921a9 100644 --- a/sys/dev/e1000/e1000_82571.c +++ b/sys/dev/e1000/e1000_82571.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -515,7 +515,7 @@ e1000_get_hw_semaphore_82574(struct e1000_hw *hw) u32 extcnf_ctrl; s32 i = 0; /* XXX assert that mutex is held */ - DEBUGFUNC("e1000_get_hw_semaphore_82573"); + DEBUGFUNC("e1000_get_hw_semaphore_82574"); ASSERT_CTX_LOCK_HELD(hw); extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); diff --git a/sys/dev/e1000/e1000_82571.h b/sys/dev/e1000/e1000_82571.h index a39f63c53e2d..77303adb162f 100644 --- a/sys/dev/e1000/e1000_82571.h +++ b/sys/dev/e1000/e1000_82571.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82575.c b/sys/dev/e1000/e1000_82575.c index 81bd419fcf0d..d588539ca8e8 100644 --- a/sys/dev/e1000/e1000_82575.c +++ b/sys/dev/e1000/e1000_82575.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_82575.h b/sys/dev/e1000/e1000_82575.h index 36045556661b..22c2f8c4a2f5 100644 --- a/sys/dev/e1000/e1000_82575.h +++ b/sys/dev/e1000/e1000_82575.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/dev/e1000/e1000_api.c b/sys/dev/e1000/e1000_api.c index b1d5ef74c24f..b28ab77f3794 100644 --- a/sys/dev/e1000/e1000_api.c +++ b/sys/dev/e1000/e1000_api.c @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -383,6 +383,7 @@ s32 e1000_set_mac_type(struct e1000_hw *hw) break; case E1000_DEV_ID_I210_COPPER_FLASHLESS: case E1000_DEV_ID_I210_SERDES_FLASHLESS: + case E1000_DEV_ID_I210_SGMII_FLASHLESS: case E1000_DEV_ID_I210_COPPER: case E1000_DEV_ID_I210_COPPER_OEM1: case E1000_DEV_ID_I210_COPPER_IT: @@ -1268,6 +1269,21 @@ s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size) return e1000_read_pba_length_generic(hw, pba_num_size); } +/** + * e1000_read_pba_num - Read device part number + * @hw: pointer to the HW structure + * @pba_num: pointer to device part number + * + * Reads the product board assembly (PBA) number from the EEPROM and stores + * the value in pba_num. + * Currently no func pointer exists and all implementations are handled in the + * generic version of this function. + **/ +s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num) +{ + return e1000_read_pba_num_generic(hw, pba_num); +} + /** * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum * @hw: pointer to the HW structure diff --git a/sys/dev/e1000/e1000_api.h b/sys/dev/e1000/e1000_api.h index bf5f637cb3dd..b558b1cf5f23 100644 --- a/sys/dev/e1000/e1000_api.h +++ b/sys/dev/e1000/e1000_api.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -100,6 +100,7 @@ void e1000_power_down_phy(struct e1000_hw *hw); s32 e1000_read_mac_addr(struct e1000_hw *hw); s32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size); s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size); +s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *part_num); void e1000_reload_nvm(struct e1000_hw *hw); s32 e1000_update_nvm_checksum(struct e1000_hw *hw); s32 e1000_validate_nvm_checksum(struct e1000_hw *hw); diff --git a/sys/dev/e1000/e1000_defines.h b/sys/dev/e1000/e1000_defines.h index 43de1047ed0e..c3223123879c 100644 --- a/sys/dev/e1000/e1000_defines.h +++ b/sys/dev/e1000/e1000_defines.h @@ -1,32 +1,32 @@ /****************************************************************************** SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2001-2015, Intel Corporation + Copyright (c) 2001-2020, Intel Corporation All rights reserved. - - Redistribution and use in source and binary forms, with or without + + 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, + + 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 + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -1070,11 +1070,44 @@ /* NVM Word Offsets */ #define NVM_COMPAT 0x0003 #define NVM_ID_LED_SETTINGS 0x0004 +#define NVM_VERSION 0x0005 #define NVM_SERDES_AMPLITUDE 0x0006 /* SERDES output amplitude */ #define NVM_PHY_CLASS_WORD 0x0007 #define E1000_I210_NVM_FW_MODULE_PTR 0x0010 #define E1000_I350_NVM_FW_MODULE_PTR 0x0051 #define NVM_FUTURE_INIT_WORD1 0x0019 +#define NVM_ETRACK_WORD 0x0042 +#define NVM_ETRACK_HIWORD 0x0043 +#define NVM_COMB_VER_OFF 0x0083 +#define NVM_COMB_VER_PTR 0x003D + +/* NVM version defines */ +#define NVM_MAJOR_MASK 0xF000 +#define NVM_MINOR_MASK 0x0FF0 +#define NVM_IMAGE_ID_MASK 0x000F +#define NVM_COMB_VER_MASK 0x00FF +#define NVM_MAJOR_SHIFT 12 +#define NVM_MINOR_SHIFT 4 +#define NVM_COMB_VER_SHFT 8 +#define NVM_VER_INVALID 0xFFFF *** 2218 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Thu Aug 26 03:00:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 808B965FBC6; Thu, 26 Aug 2021 03:00: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 4Gw6z830dvz3rsp; Thu, 26 Aug 2021 03:00: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 4FD3A29A; Thu, 26 Aug 2021 03:00: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 17Q30KjZ038113; Thu, 26 Aug 2021 03:00:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q30KUm038110; Thu, 26 Aug 2021 03:00:20 GMT (envelope-from git) Date: Thu, 26 Aug 2021 03:00:20 GMT Message-Id: <202108260300.17Q30KUm038110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 3daa8e165c66 - main - pxeboot: improve and simplify rx handling 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/main X-Git-Reftype: branch X-Git-Commit: 3daa8e165c661c1b45e759f4997f447384c15446 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 03:00:20 -0000 The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=3daa8e165c661c1b45e759f4997f447384c15446 commit 3daa8e165c661c1b45e759f4997f447384c15446 Author: Kyle Evans AuthorDate: 2021-08-12 02:49:17 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 02:59:08 +0000 pxeboot: improve and simplify rx handling This pushes the bulk of the rx servicing into a single loop that's only slightly convoluted, and it addresses a problem with rx handling in the process. If we hit a tx interrupt while we're processing, we'd previously drop the frame on the floor completely and ultimately timeout, increasing boot time on particularly busy hosts as we keep having to backoff and resend. After this patch, we don't seem to hit timeouts at all on zoo anymore though loading a 27M kernel is still relatively slow (~1m20s). Reviewed by: tsoome Triage by: Ash Gokhale Sponsored By: National Bureau of Economic Research Sponsored by: Klara, Inc. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31512 --- stand/i386/libi386/pxe.c | 154 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 106 insertions(+), 48 deletions(-) diff --git a/stand/i386/libi386/pxe.c b/stand/i386/libi386/pxe.c index 217692b515f0..e80a1961e191 100644 --- a/stand/i386/libi386/pxe.c +++ b/stand/i386/libi386/pxe.c @@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$"); #include +#include +#include #include #include #include @@ -432,91 +434,144 @@ pxe_netif_init(struct iodesc *desc, void *machdep_hint) } static int -pxe_netif_receive(void **pkt) +pxe_netif_receive_isr(t_PXENV_UNDI_ISR *isr, void **pkt, ssize_t *retsize) { - t_PXENV_UNDI_ISR *isr; + static bool data_pending; char *buf, *ptr, *frame; size_t size, rsize; - isr = bio_alloc(sizeof(*isr)); - if (isr == NULL) - return (-1); + buf = NULL; + size = rsize = 0; + + /* + * We can save ourselves the next two pxe calls because we already know + * we weren't done grabbing everything. + */ + if (data_pending) { + data_pending = false; + goto nextbuf; + } + /* + * We explicitly don't check for OURS/NOT_OURS as a result of START; + * it's been reported that some cards are known to mishandle these. + */ bzero(isr, sizeof(*isr)); isr->FuncFlag = PXENV_UNDI_ISR_IN_START; pxe_call(PXENV_UNDI_ISR, isr); + /* We could translate Status... */ if (isr->Status != 0) { - bio_free(isr, sizeof(*isr)); - return (-1); + return (ENXIO); } bzero(isr, sizeof(*isr)); isr->FuncFlag = PXENV_UNDI_ISR_IN_PROCESS; pxe_call(PXENV_UNDI_ISR, isr); if (isr->Status != 0) { - bio_free(isr, sizeof(*isr)); - return (-1); + return (ENXIO); } - - while (isr->FuncFlag == PXENV_UNDI_ISR_OUT_TRANSMIT) { + if (isr->FuncFlag == PXENV_UNDI_ISR_OUT_BUSY) { /* - * Wait till transmit is done. + * Let the caller decide if we need to be restarted. It will + * currently blindly restart us, but it could check timeout in + * the future. */ - bzero(isr, sizeof(*isr)); - isr->FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT; - pxe_call(PXENV_UNDI_ISR, isr); - if (isr->Status != 0 || - isr->FuncFlag == PXENV_UNDI_ISR_OUT_DONE) { - bio_free(isr, sizeof(*isr)); - return (-1); - } + return (ERESTART); } - while (isr->FuncFlag != PXENV_UNDI_ISR_OUT_RECEIVE) { - if (isr->Status != 0 || - isr->FuncFlag == PXENV_UNDI_ISR_OUT_DONE) { - bio_free(isr, sizeof(*isr)); - return (-1); + /* + * By design, we'll hardly ever hit this terminal condition unless we + * pick up nothing but tx interrupts here. More frequently, we will + * process rx buffers until we hit the terminal condition in the middle. + */ + while (isr->FuncFlag != PXENV_UNDI_ISR_OUT_DONE) { + /* + * This might have given us PXENV_UNDI_ISR_OUT_TRANSMIT, in + * which case we can just disregard and move on to the next + * buffer/frame. + */ + if (isr->FuncFlag != PXENV_UNDI_ISR_OUT_RECEIVE) + goto nextbuf; + + if (buf == NULL) { + /* + * Grab size from the first Frame that we picked up, + * allocate an rx buf to hold. Careful here, as we may + * see a fragmented frame that's spread out across + * multiple GET_NEXT calls. + */ + size = isr->FrameLength; + buf = malloc(size + ETHER_ALIGN); + if (buf == NULL) + return (ENOMEM); + + ptr = buf + ETHER_ALIGN; } - bzero(isr, sizeof(*isr)); - isr->FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT; - pxe_call(PXENV_UNDI_ISR, isr); - } - - size = isr->FrameLength; - buf = malloc(size + ETHER_ALIGN); - if (buf == NULL) { - bio_free(isr, sizeof(*isr)); - return (-1); - } - ptr = buf + ETHER_ALIGN; - rsize = 0; - while (rsize < size) { frame = (char *)((uintptr_t)isr->Frame.segment << 4); frame += isr->Frame.offset; bcopy(PTOV(frame), ptr, isr->BufferLength); ptr += isr->BufferLength; rsize += isr->BufferLength; + /* + * Stop here before we risk catching the start of another frame. + * It would be nice to continue reading until we actually get a + * PXENV_UNDI_ISR_OUT_DONE, but our network stack in libsa isn't + * suitable for reading more than one packet at a time. + */ + if (rsize >= size) { + data_pending = true; + break; + } + +nextbuf: bzero(isr, sizeof(*isr)); isr->FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT; pxe_call(PXENV_UNDI_ISR, isr); if (isr->Status != 0) { - bio_free(isr, sizeof(*isr)); free(buf); - return (-1); + return (ENXIO); } + } - /* Did we got another update? */ - if (isr->FuncFlag == PXENV_UNDI_ISR_OUT_RECEIVE) - continue; - break; + /* + * We may have never picked up a frame at all (all tx), in which case + * the caller should restart us. + */ + if (rsize == 0) { + return (ERESTART); } *pkt = buf; + *retsize = rsize; + return (0); +} + +static int +pxe_netif_receive(void **pkt, ssize_t *size) +{ + t_PXENV_UNDI_ISR *isr; + int ret; + + isr = bio_alloc(sizeof(*isr)); + if (isr == NULL) + return (ENOMEM); + + /* + * This completely ignores the timeout specified in pxe_netif_get(), but + * we shouldn't be running long enough here for that to make a + * difference. + */ + for (;;) { + /* We'll only really re-enter for PXENV_UNDI_ISR_OUT_BUSY. */ + ret = pxe_netif_receive_isr(isr, pkt, size); + if (ret != ERESTART) + break; + } + bio_free(isr, sizeof(*isr)); - return (rsize); + return (ret); } static ssize_t @@ -525,16 +580,19 @@ pxe_netif_get(struct iodesc *desc, void **pkt, time_t timeout) time_t t; void *ptr; int ret = -1; + ssize_t size; t = getsecs(); + size = 0; while ((getsecs() - t) < timeout) { - ret = pxe_netif_receive(&ptr); + ret = pxe_netif_receive(&ptr, &size); if (ret != -1) { *pkt = ptr; break; } } - return (ret); + + return (ret == 0 ? size : -1); } static ssize_t From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:37:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0D424662D59; Thu, 26 Aug 2021 06:37: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 4GwCnv6l0mz3tgl; Thu, 26 Aug 2021 06:37:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CFBF12AF7; Thu, 26 Aug 2021 06:37: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 17Q6bdto028928; Thu, 26 Aug 2021 06:37:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6bdT6028927; Thu, 26 Aug 2021 06:37:39 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:37:39 GMT Message-Id: <202108260637.17Q6bdT6028927@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: 40ea449c41b6 - stable/13 - kenv: s/dump/list/ to clarify meaning 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: 40ea449c41b66e059b9b6d211c1cdcb1eef087c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:37:40 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=40ea449c41b66e059b9b6d211c1cdcb1eef087c7 commit 40ea449c41b66e059b9b6d211c1cdcb1eef087c7 Author: Kyle Evans AuthorDate: 2021-06-21 03:11:26 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:35:24 +0000 kenv: s/dump/list/ to clarify meaning The contents of the kenv will be dumped to stdout, while dump could have also meant 'discard'. Call it 'list' instead. (cherry picked from commit 46438b5366f9405beb6f76474a5aae822352f012) --- bin/kenv/kenv.1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/kenv/kenv.1 b/bin/kenv/kenv.1 index f93b73f15816..0cadbefb41b3 100644 --- a/bin/kenv/kenv.1 +++ b/bin/kenv/kenv.1 @@ -24,12 +24,12 @@ .\" .\" $FreeBSD$ .\" -.Dd October 5, 2020 +.Dd June 20, 2021 .Dt KENV 1 .Os .Sh NAME .Nm kenv -.Nd dump or modify the kernel environment +.Nd list or modify the kernel environment .Sh SYNOPSIS .Nm .Op Fl hNq @@ -43,7 +43,7 @@ .Sh DESCRIPTION The .Nm -utility will dump the kernel environment if +utility will list all variables in the kernel environment if invoked without arguments. If the .Fl h From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:37:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8AB49662D71; Thu, 26 Aug 2021 06:37: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 4GwCny2xqjz3txc; Thu, 26 Aug 2021 06:37: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 2E7D72F56; Thu, 26 Aug 2021 06:37: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 17Q6bgi4028978; Thu, 26 Aug 2021 06:37:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6bgHj028977; Thu, 26 Aug 2021 06:37:42 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:37:42 GMT Message-Id: <202108260637.17Q6bgHj028977@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: d511b903b9ed - stable/13 - kenv: allow listing of static kernel environments 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: d511b903b9ed6faaedd26bafe92d7f363051455a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:37:42 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=d511b903b9ed6faaedd26bafe92d7f363051455a commit d511b903b9ed6faaedd26bafe92d7f363051455a Author: Kyle Evans AuthorDate: 2021-06-20 19:36:10 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:35:33 +0000 kenv: allow listing of static kernel environments The early environment is typically cleared, so these new options need the PRESERVE_EARLY_KENV kernel config(8) option. These environments are reported as missing by kenv(1) if the option is not present in the running kernel. (cherry picked from commit db0f26439357b78863e61985acd1e5acf75ce73d) --- bin/kenv/kenv.1 | 18 +++++++ bin/kenv/kenv.c | 38 +++++++++---- lib/libc/sys/kenv.2 | 24 +++++++-- sys/kern/kern_environment.c | 129 +++++++++++++++++++++++++++++--------------- sys/sys/kenv.h | 10 ++-- 5 files changed, 160 insertions(+), 59 deletions(-) diff --git a/bin/kenv/kenv.1 b/bin/kenv/kenv.1 index 0cadbefb41b3..980bec117515 100644 --- a/bin/kenv/kenv.1 +++ b/bin/kenv/kenv.1 @@ -32,6 +32,7 @@ .Nd list or modify the kernel environment .Sh SYNOPSIS .Nm +.Op Fl l | s .Op Fl hNq .Nm .Op Fl qv @@ -45,6 +46,23 @@ The .Nm utility will list all variables in the kernel environment if invoked without arguments. +.Pp +If the +.Fl l +option is specified, then the static environment provided by +.Xr loader 8 +will be listed instead. +Similarly, the +.Fl s +option will list the static environment defined by the kernel config. +Both of the +.Fl l +and +.Fl s +options are dependent on the kernel being configured to preserve early kernel +environments. +The default kernel configuration does not preserve these environments. +.Pp If the .Fl h option is specified, it will limit the report to kernel probe hints. diff --git a/bin/kenv/kenv.c b/bin/kenv/kenv.c index 77caeaf5bca2..ecf30ee6b617 100644 --- a/bin/kenv/kenv.c +++ b/bin/kenv/kenv.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -36,14 +37,16 @@ __FBSDID("$FreeBSD$"); #include static void usage(void); -static int kdumpenv(void); +static int kdumpenv(int dump_type); static int kgetenv(const char *); static int ksetenv(const char *, char *); static int kunsetenv(const char *); static int hflag = 0; +static int lflag = 0; static int Nflag = 0; static int qflag = 0; +static int sflag = 0; static int uflag = 0; static int vflag = 0; @@ -51,7 +54,7 @@ static void usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n", - "usage: kenv [-hNq]", + "usage: kenv [-l|-s] [-hNq]", " kenv [-qv] variable[=value]", " kenv [-q] -u variable"); exit(1); @@ -65,17 +68,23 @@ main(int argc, char **argv) val = NULL; env = NULL; - while ((ch = getopt(argc, argv, "hNquv")) != -1) { + while ((ch = getopt(argc, argv, "hlNqsuv")) != -1) { switch (ch) { case 'h': hflag++; break; + case 'l': + lflag++; + break; case 'N': Nflag++; break; case 'q': qflag++; break; + case 's': + sflag++; + break; case 'u': uflag++; break; @@ -100,12 +109,23 @@ main(int argc, char **argv) } if ((hflag || Nflag) && env != NULL) usage(); + if (lflag && sflag) + usage(); if (argc > 0 || ((uflag || vflag) && env == NULL)) usage(); if (env == NULL) { - error = kdumpenv(); - if (error && !qflag) - warn("kdumpenv"); + if (lflag) + error = kdumpenv(KENV_DUMP_LOADER); + else if (sflag) + error = kdumpenv(KENV_DUMP_STATIC); + else + error = kdumpenv(KENV_DUMP); + if (error && !qflag) { + if (errno == ENOENT) + warnx("requested environment is unavailable"); + else + warn("kdumpenv"); + } } else if (val == NULL) { if (uflag) { error = kunsetenv(env); @@ -125,12 +145,12 @@ main(int argc, char **argv) } static int -kdumpenv(void) +kdumpenv(int dump_type) { char *buf, *bp, *cp; int buflen, envlen; - envlen = kenv(KENV_DUMP, NULL, NULL, 0); + envlen = kenv(dump_type, NULL, NULL, 0); if (envlen < 0) return (-1); for (;;) { @@ -138,7 +158,7 @@ kdumpenv(void) buf = calloc(1, buflen + 1); if (buf == NULL) return (-1); - envlen = kenv(KENV_DUMP, NULL, buf, buflen); + envlen = kenv(dump_type, NULL, buf, buflen); if (envlen < 0) { free(buf); return (-1); diff --git a/lib/libc/sys/kenv.2 b/lib/libc/sys/kenv.2 index 06f708170a2f..a1f994569111 100644 --- a/lib/libc/sys/kenv.2 +++ b/lib/libc/sys/kenv.2 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 20, 2017 +.Dd June 20, 2021 .Dt KENV 2 .Os .Sh NAME @@ -49,7 +49,7 @@ the kernel environment. The .Fa action argument can be one of the following: -.Bl -tag -width ".Dv KENV_UNSET" +.Bl -tag -width ".Dv KENV_DUMP_LOADER" .It Dv KENV_GET Get the .Fa value @@ -90,7 +90,7 @@ and arguments are ignored. This option is only available to the superuser. .It Dv KENV_DUMP -Dump as much of the kernel environment as will fit in +Dump as much of the dynamic kernel environment as will fit in .Fa value , whose size is given in .Fa len . @@ -103,6 +103,18 @@ will return the number of bytes required to copy out the entire environment. The .Fa name is ignored. +.It Dv KENV_DUMP_LOADER +Dump the static environment provided by +.Xr loader 8 , +with semantics identical to +.Dv KENV_DUMP . +Duplicate and malformed variables originally present in this environment are +discarded by the kernel and will not appear in the output. +.It Dv KENV_DUMP_STATIC +Dump the static environment defined by the kernel +.Xr config 5 . +The semantics are identical to +.Dv KENV_DUMP_LOADER . .El .Sh RETURN VALUES The @@ -142,6 +154,12 @@ for a .Dv KENV_GET or .Dv KENV_UNSET . +.It Bq Er ENOENT +The requested environment is not available for a +.Dv KENV_DUMP_LOADER +or +.Dv KENV_DUMP_STATIC . +The kernel is configured to destroy these environments by default. .It Bq Er EPERM A user other than the superuser attempted to set or unset a kernel environment variable. diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index 8dc345559e95..2a4c62d64a0f 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -92,60 +92,103 @@ bool dynamic_kenv; #define KENV_CHECK if (!dynamic_kenv) \ panic("%s: called before SI_SUB_KMEM", __func__) +static int +kenv_dump(struct thread *td, char **envp, int what, char *value, int len) +{ + char *buffer, *senv; + size_t done, needed, buflen; + int error; + + error = 0; + buffer = NULL; + done = needed = 0; + + MPASS(what == KENV_DUMP || what == KENV_DUMP_LOADER || + what == KENV_DUMP_STATIC); + + /* + * For non-dynamic kernel environment, we pass in either md_envp or + * kern_envp and we must traverse with kernenv_next(). This shuffling + * of pointers simplifies the below loop by only differing in how envp + * is modified. + */ + if (what != KENV_DUMP) { + senv = (char *)envp; + envp = &senv; + } + + buflen = len; + if (buflen > KENV_SIZE * (KENV_MNAMELEN + kenv_mvallen + 2)) + buflen = KENV_SIZE * (KENV_MNAMELEN + + kenv_mvallen + 2); + if (len > 0 && value != NULL) + buffer = malloc(buflen, M_TEMP, M_WAITOK|M_ZERO); + + /* Only take the lock for the dynamic kenv. */ + if (what == KENV_DUMP) + mtx_lock(&kenv_lock); + while (*envp != NULL) { + len = strlen(*envp) + 1; + needed += len; + len = min(len, buflen - done); + /* + * If called with a NULL or insufficiently large + * buffer, just keep computing the required size. + */ + if (value != NULL && buffer != NULL && len > 0) { + bcopy(*envp, buffer + done, len); + done += len; + } + + /* Advance the pointer depending on the kenv format. */ + if (what == KENV_DUMP) + envp++; + else + senv = kernenv_next(senv); + } + if (what == KENV_DUMP) + mtx_unlock(&kenv_lock); + if (buffer != NULL) { + error = copyout(buffer, value, done); + free(buffer, M_TEMP); + } + td->td_retval[0] = ((done == needed) ? 0 : needed); + return (error); +} + int -sys_kenv(td, uap) - struct thread *td; - struct kenv_args /* { - int what; - const char *name; - char *value; - int len; - } */ *uap; +sys_kenv(struct thread *td, struct kenv_args *uap) { - char *name, *value, *buffer = NULL; - size_t len, done, needed, buflen; - int error, i; + char *name, *value; + size_t len; + int error; KASSERT(dynamic_kenv, ("kenv: dynamic_kenv = false")); error = 0; - if (uap->what == KENV_DUMP) { + + switch (uap->what) { + case KENV_DUMP: #ifdef MAC error = mac_kenv_check_dump(td->td_ucred); if (error) return (error); #endif - done = needed = 0; - buflen = uap->len; - if (buflen > KENV_SIZE * (KENV_MNAMELEN + kenv_mvallen + 2)) - buflen = KENV_SIZE * (KENV_MNAMELEN + - kenv_mvallen + 2); - if (uap->len > 0 && uap->value != NULL) - buffer = malloc(buflen, M_TEMP, M_WAITOK|M_ZERO); - mtx_lock(&kenv_lock); - for (i = 0; kenvp[i] != NULL; i++) { - len = strlen(kenvp[i]) + 1; - needed += len; - len = min(len, buflen - done); - /* - * If called with a NULL or insufficiently large - * buffer, just keep computing the required size. - */ - if (uap->value != NULL && buffer != NULL && len > 0) { - bcopy(kenvp[i], buffer + done, len); - done += len; - } - } - mtx_unlock(&kenv_lock); - if (buffer != NULL) { - error = copyout(buffer, uap->value, done); - free(buffer, M_TEMP); - } - td->td_retval[0] = ((done == needed) ? 0 : needed); - return (error); - } - - switch (uap->what) { + return (kenv_dump(td, kenvp, uap->what, uap->value, uap->len)); + case KENV_DUMP_LOADER: + case KENV_DUMP_STATIC: +#ifdef MAC + error = mac_kenv_check_dump(td->td_ucred); + if (error) + return (error); +#endif +#ifdef PRESERVE_EARLY_KENV + return (kenv_dump(td, + uap->what == KENV_DUMP_LOADER ? (char **)md_envp : + (char **)kern_envp, uap->what, uap->value, uap->len)); +#else + return (ENOENT); +#endif case KENV_SET: error = priv_check(td, PRIV_KENV_SET); if (error) diff --git a/sys/sys/kenv.h b/sys/sys/kenv.h index 4c851631f343..eccdc027adcc 100644 --- a/sys/sys/kenv.h +++ b/sys/sys/kenv.h @@ -34,10 +34,12 @@ /* * Constants for the kenv(2) syscall */ -#define KENV_GET 0 -#define KENV_SET 1 -#define KENV_UNSET 2 -#define KENV_DUMP 3 +#define KENV_GET 0 +#define KENV_SET 1 +#define KENV_UNSET 2 +#define KENV_DUMP 3 +#define KENV_DUMP_LOADER 4 +#define KENV_DUMP_STATIC 5 #define KENV_MNAMELEN 128 /* Maximum name length (for the syscall) */ #define KENV_MVALLEN 128 /* Maximum value length (for the syscall) */ From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:37:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2503F662D66; Thu, 26 Aug 2021 06:37: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 4GwCnx0bQyz3tvT; Thu, 26 Aug 2021 06:37: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 F24372AF8; Thu, 26 Aug 2021 06:37: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 17Q6beoS028952; Thu, 26 Aug 2021 06:37:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6be0b028951; Thu, 26 Aug 2021 06:37:40 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:37:40 GMT Message-Id: <202108260637.17Q6be0b028951@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: 8e11e8fb782c - stable/13 - kern: add an option for preserving the early kenv 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: 8e11e8fb782cab5bbcde7a3f44f614c75f4b163d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:37:41 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=8e11e8fb782cab5bbcde7a3f44f614c75f4b163d commit 8e11e8fb782cab5bbcde7a3f44f614c75f4b163d Author: Kyle Evans AuthorDate: 2021-06-20 19:29:31 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:35:30 +0000 kern: add an option for preserving the early kenv Some downstream configurations do not store secrets in the early (loader/static) environments and desire a way to preserve these for diagnostic reasons. Provide an option to do so. (cherry picked from commit 7a129c973b5ba0fa916dfa658d523bec66dbd02d) --- sys/conf/options | 8 ++++++++ sys/kern/kern_environment.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/sys/conf/options b/sys/conf/options index b6956193d841..121a23ed876c 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -1020,3 +1020,11 @@ IICHID_DEBUG opt_hid.h IICHID_SAMPLING opt_hid.h HKBD_DFLT_KEYMAP opt_hkbd.h HIDRAW_MAKE_UHID_ALIAS opt_hid.h + +# kenv options +# The early kernel environment (loader environment, config(8)-provided static) +# is typically cleared after the dynamic environment comes up to ensure that +# we're not inadvertently holding on to 'secret' values in these stale envs. +# This option is insecure except in controlled environments where the static +# environment's contents are known to be safe. +PRESERVE_EARLY_KENV opt_global.h diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index 54992e6594ed..8dc345559e95 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -365,7 +365,11 @@ init_dynamic_kenv_from(char *init_env, int *curpos) kenvp[i] = malloc(len, M_KENV, M_WAITOK); strcpy(kenvp[i++], cp); sanitize: +#ifdef PRESERVE_EARLY_KENV + continue; +#else explicit_bzero(cp, len - 1); +#endif } *curpos = i; } From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:43:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7F0CE6632EB; Thu, 26 Aug 2021 06:43: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 4GwCwC3D2qz4RgV; Thu, 26 Aug 2021 06:43: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 5636D32C1; Thu, 26 Aug 2021 06:43: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 17Q6h7Fj042605; Thu, 26 Aug 2021 06:43:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6h7a2042604; Thu, 26 Aug 2021 06:43:07 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:43:07 GMT Message-Id: <202108260643.17Q6h7a2042604@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: 9ee8e86c0da0 - stable/13 - init: execute /etc/rc.final after all user processes have terminated 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: 9ee8e86c0da02b0c0ef1d8b933788f9193b7e46d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:43:07 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=9ee8e86c0da02b0c0ef1d8b933788f9193b7e46d commit 9ee8e86c0da02b0c0ef1d8b933788f9193b7e46d Author: Kyle Evans AuthorDate: 2021-07-20 10:40:30 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:42:00 +0000 init: execute /etc/rc.final after all user processes have terminated This can be useful for, e.g., unmounting filesystems that were needed for shutdown. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #63 (cherry picked from commit 4d1597691916240b9023ee9f15e249503abf67fd) --- sbin/init/init.8 | 17 ++++++++++++++--- sbin/init/init.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ sbin/init/pathnames.h | 1 + 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/sbin/init/init.8 b/sbin/init/init.8 index d852c32ef487..9475b1cce48f 100644 --- a/sbin/init/init.8 +++ b/sbin/init/init.8 @@ -31,7 +31,7 @@ .\" @(#)init.8 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd August 6, 2019 +.Dd July 22, 2021 .Dt INIT 8 .Os .Sh NAME @@ -279,6 +279,14 @@ Otherwise, .Dq Li reboot argument is used. .Pp +After all user processes have been terminated, +.Nm +will try to run the +.Pa /etc/rc.final +script. +This script can be used to finally prepare and unmount filesystems that may have +been needed during shutdown, for instance. +.Pp The role of .Nm is so critical that if it dies, the system will reboot itself @@ -371,9 +379,10 @@ It is used for running the or .Va init_script if set, as well as for the -.Pa /etc/rc +.Pa /etc/rc , +.Pa /etc/rc.shutdown , and -.Pa /etc/rc.shutdown +.Pa /etc/rc.final scripts. The value of the corresponding .Xr kenv 2 @@ -403,6 +412,8 @@ the terminal initialization information file system startup commands .It Pa /etc/rc.shutdown system shutdown commands +.It Pa /etc/rc.final +system shutdown commands (after process termination) .It Pa /var/log/init.log log of .Xr rc 8 diff --git a/sbin/init/init.c b/sbin/init/init.c index 943db9f26bd3..230c141bd351 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -109,6 +109,7 @@ static void disaster(int); static void revoke_ttys(void); static int runshutdown(void); static char *strk(char *); +static void runfinal(void); /* * We really need a recursive typedef... @@ -876,6 +877,8 @@ single_user(void) if (Reboot) { /* Instead of going single user, let's reboot the machine */ sync(); + /* Run scripts after all processes have been terminated. */ + runfinal(); if (reboot(howto) == -1) { emergency("reboot(%#x) failed, %m", howto); _exit(1); /* panic and reboot */ @@ -2039,3 +2042,51 @@ setprocresources(const char *cname) } } #endif + +/* + * Run /etc/rc.final to execute scripts after all user processes have been + * terminated. + */ +static void +runfinal(void) +{ + struct stat sb; + pid_t other_pid, pid; + sigset_t mask; + + /* Avoid any surprises. */ + alarm(0); + + /* rc.final is optional. */ + if (stat(_PATH_RUNFINAL, &sb) == -1 && errno == ENOENT) + return; + if (access(_PATH_RUNFINAL, X_OK) != 0) { + warning("%s exists, but not executable", _PATH_RUNFINAL); + return; + } + + pid = fork(); + if (pid == 0) { + /* + * Reopen stdin/stdout/stderr so that scripts can write to + * console. + */ + close(0); + open(_PATH_DEVNULL, O_RDONLY); + close(1); + close(2); + open_console(); + dup2(1, 2); + sigemptyset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); + signal(SIGCHLD, SIG_DFL); + execl(_PATH_RUNFINAL, _PATH_RUNFINAL, NULL); + perror("execl(" _PATH_RUNFINAL ") failed"); + exit(1); + } + + /* Wait for rc.final script to exit */ + while ((other_pid = waitpid(-1, NULL, 0)) != pid && other_pid > 0) { + continue; + } +} diff --git a/sbin/init/pathnames.h b/sbin/init/pathnames.h index 2ed366e4f7f7..7dc75ba52491 100644 --- a/sbin/init/pathnames.h +++ b/sbin/init/pathnames.h @@ -41,5 +41,6 @@ #define _PATH_SLOGGER "/sbin/session_logger" #define _PATH_RUNCOM "/etc/rc" #define _PATH_RUNDOWN "/etc/rc.shutdown" +#define _PATH_RUNFINAL "/etc/rc.final" #define _PATH_REROOT "/dev/reroot" #define _PATH_REROOT_INIT _PATH_REROOT "/init" From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:43:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCFAF663328; Thu, 26 Aug 2021 06:43: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 4GwCxB5vYGz4RvW; Thu, 26 Aug 2021 06:43: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 B40C23484; Thu, 26 Aug 2021 06:43: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 17Q6hwpf042829; Thu, 26 Aug 2021 06:43:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6hwh1042828; Thu, 26 Aug 2021 06:43:58 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:43:58 GMT Message-Id: <202108260643.17Q6hwh1042828@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: a68421a0e61d - stable/12 - kenv: s/dump/list/ to clarify meaning 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: a68421a0e61d61c5e0b51b5f1f821fdd10c65ea2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:43:58 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=a68421a0e61d61c5e0b51b5f1f821fdd10c65ea2 commit a68421a0e61d61c5e0b51b5f1f821fdd10c65ea2 Author: Kyle Evans AuthorDate: 2021-06-21 03:11:26 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:39:49 +0000 kenv: s/dump/list/ to clarify meaning The contents of the kenv will be dumped to stdout, while dump could have also meant 'discard'. Call it 'list' instead. (cherry picked from commit 46438b5366f9405beb6f76474a5aae822352f012) --- bin/kenv/kenv.1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/kenv/kenv.1 b/bin/kenv/kenv.1 index 0010caf7b243..7a124b7ba756 100644 --- a/bin/kenv/kenv.1 +++ b/bin/kenv/kenv.1 @@ -24,12 +24,12 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2012 +.Dd August 26, 2021 .Dt KENV 1 .Os .Sh NAME .Nm kenv -.Nd dump or modify the kernel environment +.Nd list or modify the kernel environment .Sh SYNOPSIS .Nm .Op Fl hNq @@ -43,7 +43,7 @@ .Sh DESCRIPTION The .Nm -utility will dump the kernel environment if +utility will list all variables in the kernel environment if invoked without arguments. If the .Fl h From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:44:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4AE9663387; Thu, 26 Aug 2021 06:44: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 4GwCxF5sqpz4S04; Thu, 26 Aug 2021 06:44: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 01C8C331F; Thu, 26 Aug 2021 06:43: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 17Q6hxQ3042853; Thu, 26 Aug 2021 06:43:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6hxQn042852; Thu, 26 Aug 2021 06:43:59 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:43:59 GMT Message-Id: <202108260643.17Q6hxQn042852@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: ef70a18d88e6 - stable/12 - kern: add an option for preserving the early kenv 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: ef70a18d88e65879a78992dd6c5e3fc7a1cdb225 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:44:02 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=ef70a18d88e65879a78992dd6c5e3fc7a1cdb225 commit ef70a18d88e65879a78992dd6c5e3fc7a1cdb225 Author: Kyle Evans AuthorDate: 2021-06-20 19:29:31 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:40:38 +0000 kern: add an option for preserving the early kenv Some downstream configurations do not store secrets in the early (loader/static) environments and desire a way to preserve these for diagnostic reasons. Provide an option to do so. (cherry picked from commit 7a129c973b5ba0fa916dfa658d523bec66dbd02d) --- sys/conf/options | 8 ++++++++ sys/kern/kern_environment.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/sys/conf/options b/sys/conf/options index 561e2574b964..b2c3eebacf70 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -1028,3 +1028,11 @@ NVME_USE_NVD opt_nvme.h # amdsbwd options AMDSBWD_DEBUG opt_amdsbwd.h + +# kenv options +# The early kernel environment (loader environment, config(8)-provided static) +# is typically cleared after the dynamic environment comes up to ensure that +# we're not inadvertently holding on to 'secret' values in these stale envs. +# This option is insecure except in controlled environments where the static +# environment's contents are known to be safe. +PRESERVE_EARLY_KENV opt_global.h diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index 761113f108ec..f37fce450cd9 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -368,7 +368,11 @@ init_dynamic_kenv_from(char *init_env, int *curpos) kenvp[i] = malloc(len, M_KENV, M_WAITOK); strcpy(kenvp[i++], cp); sanitize: +#ifdef PRESERVE_EARLY_KENV + continue; +#else explicit_bzero(cp, len - 1); +#endif } *curpos = i; } From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:44:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4428663386; Thu, 26 Aug 2021 06:44: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 4GwCxF5x9Yz4RsG; Thu, 26 Aug 2021 06:44: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 41D592ECF; Thu, 26 Aug 2021 06:44: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 17Q6i0OZ042892; Thu, 26 Aug 2021 06:44:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6i0YG042891; Thu, 26 Aug 2021 06:44:00 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:44:00 GMT Message-Id: <202108260644.17Q6i0YG042891@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: a961049fc9b6 - stable/12 - kenv: allow listing of static kernel environments 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: a961049fc9b6e4b14ec071b6c457901b1badbea1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:44:02 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=a961049fc9b6e4b14ec071b6c457901b1badbea1 commit a961049fc9b6e4b14ec071b6c457901b1badbea1 Author: Kyle Evans AuthorDate: 2021-06-20 19:36:10 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:40:45 +0000 kenv: allow listing of static kernel environments The early environment is typically cleared, so these new options need the PRESERVE_EARLY_KENV kernel config(8) option. These environments are reported as missing by kenv(1) if the option is not present in the running kernel. (cherry picked from commit db0f26439357b78863e61985acd1e5acf75ce73d) --- bin/kenv/kenv.1 | 18 ++++++ bin/kenv/kenv.c | 38 ++++++++++--- lib/libc/sys/kenv.2 | 24 +++++++- sys/kern/kern_environment.c | 131 +++++++++++++++++++++++++++++--------------- sys/sys/kenv.h | 10 ++-- 5 files changed, 161 insertions(+), 60 deletions(-) diff --git a/bin/kenv/kenv.1 b/bin/kenv/kenv.1 index 7a124b7ba756..65e4793617a5 100644 --- a/bin/kenv/kenv.1 +++ b/bin/kenv/kenv.1 @@ -32,6 +32,7 @@ .Nd list or modify the kernel environment .Sh SYNOPSIS .Nm +.Op Fl l | s .Op Fl hNq .Nm .Op Fl qv @@ -45,6 +46,23 @@ The .Nm utility will list all variables in the kernel environment if invoked without arguments. +.Pp +If the +.Fl l +option is specified, then the static environment provided by +.Xr loader 8 +will be listed instead. +Similarly, the +.Fl s +option will list the static environment defined by the kernel config. +Both of the +.Fl l +and +.Fl s +options are dependent on the kernel being configured to preserve early kernel +environments. +The default kernel configuration does not preserve these environments. +.Pp If the .Fl h option is specified, it will limit the report to kernel probe hints. diff --git a/bin/kenv/kenv.c b/bin/kenv/kenv.c index 77caeaf5bca2..ecf30ee6b617 100644 --- a/bin/kenv/kenv.c +++ b/bin/kenv/kenv.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -36,14 +37,16 @@ __FBSDID("$FreeBSD$"); #include static void usage(void); -static int kdumpenv(void); +static int kdumpenv(int dump_type); static int kgetenv(const char *); static int ksetenv(const char *, char *); static int kunsetenv(const char *); static int hflag = 0; +static int lflag = 0; static int Nflag = 0; static int qflag = 0; +static int sflag = 0; static int uflag = 0; static int vflag = 0; @@ -51,7 +54,7 @@ static void usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n", - "usage: kenv [-hNq]", + "usage: kenv [-l|-s] [-hNq]", " kenv [-qv] variable[=value]", " kenv [-q] -u variable"); exit(1); @@ -65,17 +68,23 @@ main(int argc, char **argv) val = NULL; env = NULL; - while ((ch = getopt(argc, argv, "hNquv")) != -1) { + while ((ch = getopt(argc, argv, "hlNqsuv")) != -1) { switch (ch) { case 'h': hflag++; break; + case 'l': + lflag++; + break; case 'N': Nflag++; break; case 'q': qflag++; break; + case 's': + sflag++; + break; case 'u': uflag++; break; @@ -100,12 +109,23 @@ main(int argc, char **argv) } if ((hflag || Nflag) && env != NULL) usage(); + if (lflag && sflag) + usage(); if (argc > 0 || ((uflag || vflag) && env == NULL)) usage(); if (env == NULL) { - error = kdumpenv(); - if (error && !qflag) - warn("kdumpenv"); + if (lflag) + error = kdumpenv(KENV_DUMP_LOADER); + else if (sflag) + error = kdumpenv(KENV_DUMP_STATIC); + else + error = kdumpenv(KENV_DUMP); + if (error && !qflag) { + if (errno == ENOENT) + warnx("requested environment is unavailable"); + else + warn("kdumpenv"); + } } else if (val == NULL) { if (uflag) { error = kunsetenv(env); @@ -125,12 +145,12 @@ main(int argc, char **argv) } static int -kdumpenv(void) +kdumpenv(int dump_type) { char *buf, *bp, *cp; int buflen, envlen; - envlen = kenv(KENV_DUMP, NULL, NULL, 0); + envlen = kenv(dump_type, NULL, NULL, 0); if (envlen < 0) return (-1); for (;;) { @@ -138,7 +158,7 @@ kdumpenv(void) buf = calloc(1, buflen + 1); if (buf == NULL) return (-1); - envlen = kenv(KENV_DUMP, NULL, buf, buflen); + envlen = kenv(dump_type, NULL, buf, buflen); if (envlen < 0) { free(buf); return (-1); diff --git a/lib/libc/sys/kenv.2 b/lib/libc/sys/kenv.2 index 06f708170a2f..a1f994569111 100644 --- a/lib/libc/sys/kenv.2 +++ b/lib/libc/sys/kenv.2 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 20, 2017 +.Dd June 20, 2021 .Dt KENV 2 .Os .Sh NAME @@ -49,7 +49,7 @@ the kernel environment. The .Fa action argument can be one of the following: -.Bl -tag -width ".Dv KENV_UNSET" +.Bl -tag -width ".Dv KENV_DUMP_LOADER" .It Dv KENV_GET Get the .Fa value @@ -90,7 +90,7 @@ and arguments are ignored. This option is only available to the superuser. .It Dv KENV_DUMP -Dump as much of the kernel environment as will fit in +Dump as much of the dynamic kernel environment as will fit in .Fa value , whose size is given in .Fa len . @@ -103,6 +103,18 @@ will return the number of bytes required to copy out the entire environment. The .Fa name is ignored. +.It Dv KENV_DUMP_LOADER +Dump the static environment provided by +.Xr loader 8 , +with semantics identical to +.Dv KENV_DUMP . +Duplicate and malformed variables originally present in this environment are +discarded by the kernel and will not appear in the output. +.It Dv KENV_DUMP_STATIC +Dump the static environment defined by the kernel +.Xr config 5 . +The semantics are identical to +.Dv KENV_DUMP_LOADER . .El .Sh RETURN VALUES The @@ -142,6 +154,12 @@ for a .Dv KENV_GET or .Dv KENV_UNSET . +.It Bq Er ENOENT +The requested environment is not available for a +.Dv KENV_DUMP_LOADER +or +.Dv KENV_DUMP_STATIC . +The kernel is configured to destroy these environments by default. .It Bq Er EPERM A user other than the superuser attempted to set or unset a kernel environment variable. diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index f37fce450cd9..127435406713 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -91,60 +91,103 @@ bool dynamic_kenv; #define KENV_CHECK if (!dynamic_kenv) \ panic("%s: called before SI_SUB_KMEM", __func__) +static int +kenv_dump(struct thread *td, char **envp, int what, char *value, int len) +{ + char *buffer, *senv; + size_t done, needed, buflen; + int error; + + error = 0; + buffer = NULL; + done = needed = 0; + + MPASS(what == KENV_DUMP || what == KENV_DUMP_LOADER || + what == KENV_DUMP_STATIC); + + /* + * For non-dynamic kernel environment, we pass in either md_envp or + * kern_envp and we must traverse with kernenv_next(). This shuffling + * of pointers simplifies the below loop by only differing in how envp + * is modified. + */ + if (what != KENV_DUMP) { + senv = (char *)envp; + envp = &senv; + } + + buflen = len; + if (buflen > KENV_SIZE * (KENV_MNAMELEN + kenv_mvallen + 2)) + buflen = KENV_SIZE * (KENV_MNAMELEN + + kenv_mvallen + 2); + if (len > 0 && value != NULL) + buffer = malloc(buflen, M_TEMP, M_WAITOK|M_ZERO); + + /* Only take the lock for the dynamic kenv. */ + if (what == KENV_DUMP) + mtx_lock(&kenv_lock); + while (*envp != NULL) { + len = strlen(*envp) + 1; + needed += len; + len = min(len, buflen - done); + /* + * If called with a NULL or insufficiently large + * buffer, just keep computing the required size. + */ + if (value != NULL && buffer != NULL && len > 0) { + bcopy(*envp, buffer + done, len); + done += len; + } + + /* Advance the pointer depending on the kenv format. */ + if (what == KENV_DUMP) + envp++; + else + senv = kernenv_next(senv); + } + if (what == KENV_DUMP) + mtx_unlock(&kenv_lock); + if (buffer != NULL) { + error = copyout(buffer, value, done); + free(buffer, M_TEMP); + } + td->td_retval[0] = ((done == needed) ? 0 : needed); + return (error); +} + int -sys_kenv(td, uap) - struct thread *td; - struct kenv_args /* { - int what; - const char *name; - char *value; - int len; - } */ *uap; -{ - char *name, *value, *buffer = NULL; - size_t len, done, needed, buflen; - int error, i; +sys_kenv(struct thread *td, struct kenv_args *uap) +{ + char *name, *value; + size_t len; + int error; KASSERT(dynamic_kenv, ("kenv: dynamic_kenv = false")); error = 0; - if (uap->what == KENV_DUMP) { + + switch (uap->what) { + case KENV_DUMP: #ifdef MAC error = mac_kenv_check_dump(td->td_ucred); if (error) return (error); #endif - done = needed = 0; - buflen = uap->len; - if (buflen > KENV_SIZE * (KENV_MNAMELEN + kenv_mvallen + 2)) - buflen = KENV_SIZE * (KENV_MNAMELEN + - kenv_mvallen + 2); - if (uap->len > 0 && uap->value != NULL) - buffer = malloc(buflen, M_TEMP, M_WAITOK|M_ZERO); - mtx_lock(&kenv_lock); - for (i = 0; kenvp[i] != NULL; i++) { - len = strlen(kenvp[i]) + 1; - needed += len; - len = min(len, buflen - done); - /* - * If called with a NULL or insufficiently large - * buffer, just keep computing the required size. - */ - if (uap->value != NULL && buffer != NULL && len > 0) { - bcopy(kenvp[i], buffer + done, len); - done += len; - } - } - mtx_unlock(&kenv_lock); - if (buffer != NULL) { - error = copyout(buffer, uap->value, done); - free(buffer, M_TEMP); - } - td->td_retval[0] = ((done == needed) ? 0 : needed); - return (error); - } - - switch (uap->what) { + return (kenv_dump(td, kenvp, uap->what, uap->value, uap->len)); + case KENV_DUMP_LOADER: + case KENV_DUMP_STATIC: +#ifdef MAC + error = mac_kenv_check_dump(td->td_ucred); + if (error) + return (error); +#endif +#ifdef PRESERVE_EARLY_KENV + return (kenv_dump(td, + uap->what == KENV_DUMP_LOADER ? (char **)md_envp : + (char **)kern_envp, uap->what, uap->value, uap->len)); +#else + return (ENOENT); +#endif case KENV_SET: error = priv_check(td, PRIV_KENV_SET); if (error) diff --git a/sys/sys/kenv.h b/sys/sys/kenv.h index fd1ae31f6a95..3920d80c21c7 100644 --- a/sys/sys/kenv.h +++ b/sys/sys/kenv.h @@ -34,10 +34,12 @@ /* * Constants for the kenv(2) syscall */ -#define KENV_GET 0 -#define KENV_SET 1 -#define KENV_UNSET 2 -#define KENV_DUMP 3 +#define KENV_GET 0 +#define KENV_SET 1 +#define KENV_UNSET 2 +#define KENV_DUMP 3 +#define KENV_DUMP_LOADER 4 +#define KENV_DUMP_STATIC 5 #define KENV_MNAMELEN 128 /* Maximum name length (for the syscall) */ #define KENV_MVALLEN 128 /* Maximum value length (for the syscall) */ From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:44:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE935662F6A; Thu, 26 Aug 2021 06:44:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwCxG3Z96z4S09; Thu, 26 Aug 2021 06:44:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 34B1432C2; Thu, 26 Aug 2021 06:44:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q6i232042918; Thu, 26 Aug 2021 06:44:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6i2fv042917; Thu, 26 Aug 2021 06:44:02 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:44:02 GMT Message-Id: <202108260644.17Q6i2fv042917@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: 63c85520018a - stable/12 - init: execute /etc/rc.final after all user processes have terminated 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: 63c85520018a2720c245e63a2d50d258b4e5201b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:44:03 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=63c85520018a2720c245e63a2d50d258b4e5201b commit 63c85520018a2720c245e63a2d50d258b4e5201b Author: Kyle Evans AuthorDate: 2021-07-20 10:40:30 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:43:37 +0000 init: execute /etc/rc.final after all user processes have terminated This can be useful for, e.g., unmounting filesystems that were needed for shutdown. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #63 (cherry picked from commit 4d1597691916240b9023ee9f15e249503abf67fd) --- sbin/init/init.8 | 17 ++++++++++++++--- sbin/init/init.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ sbin/init/pathnames.h | 1 + 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/sbin/init/init.8 b/sbin/init/init.8 index d852c32ef487..9475b1cce48f 100644 --- a/sbin/init/init.8 +++ b/sbin/init/init.8 @@ -31,7 +31,7 @@ .\" @(#)init.8 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd August 6, 2019 +.Dd July 22, 2021 .Dt INIT 8 .Os .Sh NAME @@ -279,6 +279,14 @@ Otherwise, .Dq Li reboot argument is used. .Pp +After all user processes have been terminated, +.Nm +will try to run the +.Pa /etc/rc.final +script. +This script can be used to finally prepare and unmount filesystems that may have +been needed during shutdown, for instance. +.Pp The role of .Nm is so critical that if it dies, the system will reboot itself @@ -371,9 +379,10 @@ It is used for running the or .Va init_script if set, as well as for the -.Pa /etc/rc +.Pa /etc/rc , +.Pa /etc/rc.shutdown , and -.Pa /etc/rc.shutdown +.Pa /etc/rc.final scripts. The value of the corresponding .Xr kenv 2 @@ -403,6 +412,8 @@ the terminal initialization information file system startup commands .It Pa /etc/rc.shutdown system shutdown commands +.It Pa /etc/rc.final +system shutdown commands (after process termination) .It Pa /var/log/init.log log of .Xr rc 8 diff --git a/sbin/init/init.c b/sbin/init/init.c index 59bcfb6893dd..772d37b78664 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -109,6 +109,7 @@ static void disaster(int); static void revoke_ttys(void); static int runshutdown(void); static char *strk(char *); +static void runfinal(void); /* * We really need a recursive typedef... @@ -878,6 +879,8 @@ single_user(void) if (Reboot) { /* Instead of going single user, let's reboot the machine */ sync(); + /* Run scripts after all processes have been terminated. */ + runfinal(); if (reboot(howto) == -1) { emergency("reboot(%#x) failed, %s", howto, strerror(errno)); @@ -2040,3 +2043,51 @@ setprocresources(const char *cname) } } #endif + +/* + * Run /etc/rc.final to execute scripts after all user processes have been + * terminated. + */ +static void +runfinal(void) +{ + struct stat sb; + pid_t other_pid, pid; + sigset_t mask; + + /* Avoid any surprises. */ + alarm(0); + + /* rc.final is optional. */ + if (stat(_PATH_RUNFINAL, &sb) == -1 && errno == ENOENT) + return; + if (access(_PATH_RUNFINAL, X_OK) != 0) { + warning("%s exists, but not executable", _PATH_RUNFINAL); + return; + } + + pid = fork(); + if (pid == 0) { + /* + * Reopen stdin/stdout/stderr so that scripts can write to + * console. + */ + close(0); + open(_PATH_DEVNULL, O_RDONLY); + close(1); + close(2); + open_console(); + dup2(1, 2); + sigemptyset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); + signal(SIGCHLD, SIG_DFL); + execl(_PATH_RUNFINAL, _PATH_RUNFINAL, NULL); + perror("execl(" _PATH_RUNFINAL ") failed"); + exit(1); + } + + /* Wait for rc.final script to exit */ + while ((other_pid = waitpid(-1, NULL, 0)) != pid && other_pid > 0) { + continue; + } +} diff --git a/sbin/init/pathnames.h b/sbin/init/pathnames.h index 2ed366e4f7f7..7dc75ba52491 100644 --- a/sbin/init/pathnames.h +++ b/sbin/init/pathnames.h @@ -41,5 +41,6 @@ #define _PATH_SLOGGER "/sbin/session_logger" #define _PATH_RUNCOM "/etc/rc" #define _PATH_RUNDOWN "/etc/rc.shutdown" +#define _PATH_RUNFINAL "/etc/rc.final" #define _PATH_REROOT "/dev/reroot" #define _PATH_REROOT_INIT _PATH_REROOT "/init" From owner-dev-commits-src-all@freebsd.org Thu Aug 26 06:44:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08EA4663497; Thu, 26 Aug 2021 06:44: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 4GwCxg5MhKz4S7n; Thu, 26 Aug 2021 06:44: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 713B3303E; Thu, 26 Aug 2021 06:44: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 17Q6iNjN043089; Thu, 26 Aug 2021 06:44:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q6iNR6043088; Thu, 26 Aug 2021 06:44:23 GMT (envelope-from git) Date: Thu, 26 Aug 2021 06:44:23 GMT Message-Id: <202108260644.17Q6iNR6043088@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: 18f89d2df457 - stable/13 - kern: remove deprecated makesyscalls.sh 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: 18f89d2df4570af90c0316d47b4c2fb1d2aae96a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 06:44:24 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=18f89d2df4570af90c0316d47b4c2fb1d2aae96a commit 18f89d2df4570af90c0316d47b4c2fb1d2aae96a Author: Kyle Evans AuthorDate: 2021-07-29 03:18:13 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 06:44:15 +0000 kern: remove deprecated makesyscalls.sh makesyscalls was rewritten in Lua and introduced in d3276301ab. In the time since, no objections have risen and a warning was introduced long ago on invocation of makesyscalls.sh that it would be removed before FreeBSD 13. Belatedly follow through on that. (cherry picked from commit e3707726c168eeb0ba06d13873dd71590b77d604) --- sys/kern/makesyscalls.sh | 805 ----------------------------------------------- 1 file changed, 805 deletions(-) diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh deleted file mode 100644 index 8cbd00a69fcd..000000000000 --- a/sys/kern/makesyscalls.sh +++ /dev/null @@ -1,805 +0,0 @@ -#! /bin/sh - -# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93 -# $FreeBSD$ - -set -e - -# name of compat options: -compat=COMPAT_43 -compat4=COMPAT_FREEBSD4 -compat6=COMPAT_FREEBSD6 -compat7=COMPAT_FREEBSD7 -compat10=COMPAT_FREEBSD10 -compat11=COMPAT_FREEBSD11 -compat12=COMPAT_FREEBSD12 - -# output files: -sysnames="syscalls.c" -sysproto="../sys/sysproto.h" -sysproto_h=_SYS_SYSPROTO_H_ -syshdr="../sys/syscall.h" -sysmk="../sys/syscall.mk" -syssw="init_sysent.c" -syscallprefix="SYS_" -switchname="sysent" -namesname="syscallnames" -systrace="systrace_args.c" - -# tmp files: -sysaue="sysent.aue.$$" -sysdcl="sysent.dcl.$$" -syscompat="sysent.compat.$$" -syscompatdcl="sysent.compatdcl.$$" -syscompat4="sysent.compat4.$$" -syscompat4dcl="sysent.compat4dcl.$$" -syscompat6="sysent.compat6.$$" -syscompat6dcl="sysent.compat6dcl.$$" -syscompat7="sysent.compat7.$$" -syscompat7dcl="sysent.compat7dcl.$$" -syscompat10="sysent.compat10.$$" -syscompat10dcl="sysent.compat10dcl.$$" -syscompat11="sysent.compat11.$$" -syscompat11dcl="sysent.compat11dcl.$$" -syscompat12="sysent.compat12.$$" -syscompat12dcl="sysent.compat12dcl.$$" -sysent="sysent.switch.$$" -sysinc="sysinc.switch.$$" -sysarg="sysarg.switch.$$" -sysprotoend="sysprotoend.$$" -systracetmp="systrace.$$" -systraceret="systraceret.$$" -capabilities_conf="capabilities.conf" - -trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $syscompat12 $syscompat12dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0 - -touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $syscompat12 $syscompat12dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret - -case $# in - 0) echo "usage: $0 input-file " 1>&2 - exit 1 - ;; -esac - -1>&2 echo "$0: This script has been replaced by sys/tools/makesyscalls.lua and" -1>&2 echo "$0: will be removed before FreeBSD 13. See also: sys/conf/sysent.mk" - -if [ -n "$2" ]; then - . "$2" -fi - -if [ -n "$capenabled" ]; then - # do nothing -elif [ -r $capabilities_conf ]; then - capenabled=`egrep -v '^#|^$' $capabilities_conf` - capenabled=`echo $capenabled | sed 's/ /,/g'` -else - capenabled="" -fi - -sed -e ' - # FreeBSD ID, includes, comments, and blank lines - /.*\$FreeBSD/b done_joining - /^[#;]/b done_joining - /^$/b done_joining - - # Join lines ending in backslash -:joining - /\\$/{a\ - - N - s/\\\n// - b joining - } - - # OBSOL, etc lines without function signatures - /^[0-9][^{]*$/b done_joining - - # Join incomplete signatures. The { must appear on the first line - # and the } must appear on the last line (modulo lines joined by - # backslashes). - /^[^}]*$/{a\ - - N - s/\n// - b joining - } -:done_joining -2,${ - /^#/!s/\([{}()*,]\)/ \1 /g -} -' < $1 | awk " - BEGIN { - sysaue = \"$sysaue\" - sysdcl = \"$sysdcl\" - sysproto = \"$sysproto\" - sysprotoend = \"$sysprotoend\" - sysproto_h = \"$sysproto_h\" - syscompat = \"$syscompat\" - syscompatdcl = \"$syscompatdcl\" - syscompat4 = \"$syscompat4\" - syscompat4dcl = \"$syscompat4dcl\" - syscompat6 = \"$syscompat6\" - syscompat6dcl = \"$syscompat6dcl\" - syscompat7 = \"$syscompat7\" - syscompat7dcl = \"$syscompat7dcl\" - syscompat10 = \"$syscompat10\" - syscompat10dcl = \"$syscompat10dcl\" - syscompat11 = \"$syscompat11\" - syscompat11dcl = \"$syscompat11dcl\" - syscompat12 = \"$syscompat12\" - syscompat12dcl = \"$syscompat12dcl\" - sysent = \"$sysent\" - syssw = \"$syssw\" - sysinc = \"$sysinc\" - sysarg = \"$sysarg\" - sysnames = \"$sysnames\" - syshdr = \"$syshdr\" - sysmk = \"$sysmk\" - systrace = \"$systrace\" - systracetmp = \"$systracetmp\" - systraceret = \"$systraceret\" - compat = \"$compat\" - compat4 = \"$compat4\" - compat6 = \"$compat6\" - compat7 = \"$compat7\" - compat10 = \"$compat10\" - compat11 = \"$compat11\" - compat12 = \"$compat12\" - syscallprefix = \"$syscallprefix\" - switchname = \"$switchname\" - namesname = \"$namesname\" - infile = \"$1\" - abi_func_prefix = \"$abi_func_prefix\" - capenabled_string = \"$capenabled\" - "' - - # Avoid a literal generated file tag here. - generated = "@" "generated"; - - split(capenabled_string, capenabled, ","); - - printf "\n/* The casts are bogus but will do for now. */\n" > sysent - printf "struct sysent %s[] = {\n",switchname > sysent - - printf "/*\n * System call switch table.\n *\n" > syssw - printf " * DO NOT EDIT-- this file is automatically " generated ".\n" > syssw - printf " * $%s$\n", "FreeBSD" > syssw - printf " */\n\n" > syssw - - printf "/*\n * System call prototypes.\n *\n" > sysarg - printf " * DO NOT EDIT-- this file is automatically " generated ".\n" > sysarg - printf " * $%s$\n", "FreeBSD" > sysarg - printf " */\n\n" > sysarg - printf "#ifndef %s\n", sysproto_h > sysarg - printf "#define\t%s\n\n", sysproto_h > sysarg - printf "#include \n" > sysarg - printf "#include \n" > sysarg - printf "#include \n" > sysarg - printf "#include \n" > sysarg - printf "#include \n" > sysarg - printf "#include \n" > sysarg - printf "#include \n" > sysarg - printf "#include \n\n" > sysarg - printf "#include \n\n" > sysarg - printf "struct proc;\n\n" > sysarg - printf "struct thread;\n\n" > sysarg - printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg - printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg - printf "#if BYTE_ORDER == LITTLE_ENDIAN\n"> sysarg - printf "#define\tPADL_(t)\t0\n" > sysarg - printf "#define\tPADR_(t)\tPAD_(t)\n" > sysarg - printf "#else\n" > sysarg - printf "#define\tPADL_(t)\tPAD_(t)\n" > sysarg - printf "#define\tPADR_(t)\t0\n" > sysarg - printf "#endif\n\n" > sysarg - - printf "\n#ifdef %s\n\n", compat > syscompat - printf "\n#ifdef %s\n\n", compat4 > syscompat4 - printf "\n#ifdef %s\n\n", compat6 > syscompat6 - printf "\n#ifdef %s\n\n", compat7 > syscompat7 - printf "\n#ifdef %s\n\n", compat10 > syscompat10 - printf "\n#ifdef %s\n\n", compat11 > syscompat11 - printf "\n#ifdef %s\n\n", compat12 > syscompat12 - - printf "/*\n * System call names.\n *\n" > sysnames - printf " * DO NOT EDIT-- this file is automatically " generated ".\n" > sysnames - printf " * $%s$\n", "FreeBSD" > sysnames - printf " */\n\n" > sysnames - printf "const char *%s[] = {\n", namesname > sysnames - - printf "/*\n * System call numbers.\n *\n" > syshdr - printf " * DO NOT EDIT-- this file is automatically " generated ".\n" > syshdr - printf " * $%s$\n", "FreeBSD" > syshdr - printf " */\n\n" > syshdr - - printf "# FreeBSD system call object files.\n" > sysmk - printf "# DO NOT EDIT-- this file is automatically " generated ".\n" > sysmk - printf "# $%s$\n", "FreeBSD" > sysmk - printf "MIASM = " > sysmk - - printf "/*\n * System call argument to DTrace register array converstion.\n *\n" > systrace - printf " * DO NOT EDIT-- this file is automatically " generated ".\n" > systrace - printf " * $%s$\n", "FreeBSD" > systrace - printf " * This file is part of the DTrace syscall provider.\n */\n\n" > systrace - printf "static void\nsystrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)\n{\n" > systrace - printf "\tint64_t *iarg = (int64_t *) uarg;\n" > systrace - printf "\tswitch (sysnum) {\n" > systrace - - printf "static void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracetmp - printf "\tswitch (sysnum) {\n" > systracetmp - - printf "static void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceret - printf "\tswitch (sysnum) {\n" > systraceret - } - NR == 1 { - next - } - NF == 0 || $1 ~ /^;/ { - next - } - $1 ~ /^#[ ]*include/ { - print > sysinc - next - } - $1 ~ /^#[ ]*if/ { - print > sysent - print > sysdcl - print > sysarg - print > syscompat - print > syscompat4 - print > syscompat6 - print > syscompat7 - print > syscompat10 - print > syscompat11 - print > syscompat12 - print > sysnames - print > systrace - print > systracetmp - print > systraceret - savesyscall = syscall - next - } - $1 ~ /^#[ ]*else/ { - print > sysent - print > sysdcl - print > sysarg - print > syscompat - print > syscompat4 - print > syscompat6 - print > syscompat7 - print > syscompat10 - print > syscompat11 - print > syscompat12 - print > sysnames - print > systrace - print > systracetmp - print > systraceret - syscall = savesyscall - next - } - $1 ~ /^#/ { - print > sysent - print > sysdcl - print > sysarg - print > syscompat - print > syscompat4 - print > syscompat6 - print > syscompat7 - print > syscompat10 - print > syscompat11 - print > syscompat12 - print > sysnames - print > systrace - print > systracetmp - print > systraceret - next - } - # Returns true if the type "name" is the first flag in the type field - function type(name, flags, n) { - n = split($3, flags, /\|/) - return (n > 0 && flags[1] == name) - } - # Returns true if the flag "name" is set in the type field - function flag(name, flags, i, n) { - n = split($3, flags, /\|/) - for (i = 1; i <= n; i++) - if (flags[i] == name) - return 1 - return 0 - } - { - n = split($1, syscall_range, /-/) - if (n == 1) { - syscall_range[2] = syscall_range[1] - } else if (n == 2) { - if (!type("UNIMPL")) { - printf "%s: line %d: range permitted only with UNIMPL\n", - infile, NR - exit 1 - } - } else { - printf "%s: line %d: invalid syscall number or range %s\n", - infile, NR, $1 - exit 1 - } - } - syscall != syscall_range[1] { - printf "%s: line %d: syscall number out of sync at %d\n", - infile, NR, syscall - printf "line is:\n" - print - exit 1 - } - function align_sysent_comment(column) { - printf("\t") > sysent - column = column + 8 - column % 8 - while (column < 56) { - printf("\t") > sysent - column = column + 8 - } - } - function parserr(was, wanted) { - printf "%s: line %d: unexpected %s (expected %s)\n", - infile, NR, was, wanted - exit 1 - } - function parseline() { - f=4 # toss number, type, audit event - ret_inc = 0 - argc= 0; - argssize = "0" - thr_flag = "SY_THR_STATIC" - if (flag("NOTSTATIC")) { - thr_flag = "SY_THR_ABSENT" - } - if ($NF != "}") { - funcalias=$(NF-2) - argalias=$(NF-1) - rettype=$NF - end=NF-3 - } else { - funcalias="" - argalias="" - rettype="int" - if ($(f+2) == "*") { - ret_inc = 1 - } - end=NF - } - if (flag("NODEF")) { - auditev="AUE_NULL" - funcname=$(4 + ret_inc) - argssize = "AS(" $(6 + ret_inc) ")" - return - } - if ($f != "{") - parserr($f, "{") - f++ - if ($end != "}") - parserr($end, "}") - end-- - if ($end != ";") - parserr($end, ";") - end-- - if ($end != ")") - parserr($end, ")") - end-- - - syscallret=$f - f++ - while (ret_inc > 0) { - syscallret=syscallret " " $f - f++ - ret_inc-- - } - - funcname=$f - - # - # We now know the func name, so define a flags field for it. - # Do this before any other processing as we may return early - # from it. - # - for (cap in capenabled) { - if (funcname == capenabled[cap] || - funcname == abi_func_prefix capenabled[cap]) { - flags = "SYF_CAPENABLED"; - break; - } - } - - if (funcalias == "") - funcalias = funcname - if (argalias == "") { - argalias = funcname "_args" - if (flag("COMPAT")) - argalias = "o" argalias - if (flag("COMPAT4")) - argalias = "freebsd4_" argalias - if (flag("COMPAT6")) - argalias = "freebsd6_" argalias - if (flag("COMPAT7")) - argalias = "freebsd7_" argalias - if (flag("COMPAT10")) - argalias = "freebsd10_" argalias - if (flag("COMPAT11")) - argalias = "freebsd11_" argalias - if (flag("COMPAT12")) - argalias = "freebsd12_" argalias - } - f++ - - if ($f != "(") - parserr($f, ")") - f++ - - if (f == end) { - if ($f != "void") - parserr($f, "argument definition") - return - } - - while (f <= end) { - argc++ - argtype[argc]="" - oldf="" - while (f < end && $(f+1) != ",") { - if (argtype[argc] != "" && oldf != "*") - argtype[argc] = argtype[argc]" "; - argtype[argc] = argtype[argc]$f; - oldf = $f; - f++ - } - if (argtype[argc] == "") - parserr($f, "argument definition") - - # The parser adds space around parens. - # Remove it from annotations. - gsub(/ \( /, "(", argtype[argc]); - gsub(/ \)/, ")", argtype[argc]); - - #remove annotations - gsub(/_In[^ ]*[_)] /, "", argtype[argc]); - gsub(/_Out[^ ]*[_)] /, "", argtype[argc]); - - argname[argc]=$f; - f += 2; # skip name, and any comma - } - if (argc != 0) - argssize = "AS(" argalias ")" - } - { comment = $4 - if (NF < 7) - for (i = 5; i <= NF; i++) - comment = comment " " $i - } - - # - # The AUE_ audit event identifier. - # - { - auditev = $2; - } - - # - # The flags, if any. - # - { - flags = "0"; - } - - type("STD") || type("NODEF") || type("NOARGS") || type("NOPROTO") \ - || type("NOSTD") { - parseline() - printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall) > systrace - printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systracetmp - printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systraceret - if (argc > 0) { - printf("\t\tswitch(ndx) {\n") > systracetmp - printf("\t\tstruct %s *p = params;\n", argalias) > systrace - for (i = 1; i <= argc; i++) { - arg = argtype[i] - sub("__restrict$", "", arg) - if (index(arg, "*") > 0) - printf("\t\tcase %d:\n\t\t\tp = \"userland %s\";\n\t\t\tbreak;\n", i - 1, arg) > systracetmp - else - printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systracetmp - if (index(arg, "*") > 0 || arg == "caddr_t") - printf("\t\tuarg[%d] = (intptr_t) p->%s; /* %s */\n", \ - i - 1, \ - argname[i], arg) > systrace - else if (arg == "union l_semun") - printf("\t\tuarg[%d] = p->%s.buf; /* %s */\n", \ - i - 1, \ - argname[i], arg) > systrace - else if (substr(arg, 1, 1) == "u" || arg == "size_t") - printf("\t\tuarg[%d] = p->%s; /* %s */\n", \ - i - 1, \ - argname[i], arg) > systrace - else - printf("\t\tiarg[%d] = p->%s; /* %s */\n", \ - i - 1, \ - argname[i], arg) > systrace - } - printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systracetmp - - printf("\t\tif (ndx == 0 || ndx == 1)\n") > systraceret - printf("\t\t\tp = \"%s\";\n", syscallret) > systraceret - printf("\t\tbreak;\n") > systraceret - } - printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace - printf("\t\tbreak;\n") > systracetmp - if (!flag("NOARGS") && !flag("NOPROTO") && !flag("NODEF")) { - if (argc != 0) { - printf("struct %s {\n", argalias) > sysarg - for (i = 1; i <= argc; i++) - printf("\tchar %s_l_[PADL_(%s)]; " \ - "%s %s; char %s_r_[PADR_(%s)];\n", - argname[i], argtype[i], - argtype[i], argname[i], - argname[i], argtype[i]) > sysarg - printf("};\n") > sysarg - } else - printf("struct %s {\n\tregister_t dummy;\n};\n", - argalias) > sysarg - } - if (!flag("NOPROTO") && !flag("NODEF")) { - if (funcname == "nosys" || funcname == "lkmnosys" || - funcname == "sysarch" || funcname ~ /^freebsd/ || - funcname ~ /^linux/ || funcname ~ /^cloudabi/) { - printf("%s\t%s(struct thread *, struct %s *)", - rettype, funcname, argalias) > sysdcl - } else { - printf("%s\tsys_%s(struct thread *, struct %s *)", - rettype, funcname, argalias) > sysdcl - } - printf(";\n") > sysdcl - printf("#define\t%sAUE_%s\t%s\n", syscallprefix, - funcalias, auditev) > sysaue - } - printf("\t{ %s, (sy_call_t *)", argssize) > sysent - column = 8 + 2 + length(argssize) + 15 - if (flag("NOSTD")) { - printf("lkmressys, AUE_NULL, NULL, 0, 0, %s, SY_THR_ABSENT },", flags) > sysent - column = column + length("lkmressys") + length("AUE_NULL") + 3 - } else { - if (funcname == "nosys" || funcname == "sysarch" || - funcname == "lkmnosys" || funcname ~ /^freebsd/ || - funcname ~ /^linux/ || funcname ~ /^cloudabi/) { - printf("%s, %s, NULL, 0, 0, %s, %s },", funcname, auditev, flags, thr_flag) > sysent - column = column + length(funcname) + length(auditev) + length(flags) + 3 - } else { - printf("sys_%s, %s, NULL, 0, 0, %s, %s },", funcname, auditev, flags, thr_flag) > sysent - column = column + length(funcname) + length(auditev) + length(flags) + 3 + 4 - } - } - align_sysent_comment(column) - printf("/* %d = %s */\n", syscall, funcalias) > sysent - printf("\t\"%s\",\t\t\t/* %d = %s */\n", - funcalias, syscall, funcalias) > sysnames - if (!flag("NODEF")) { - printf("#define\t%s%s\t%d\n", syscallprefix, - funcalias, syscall) > syshdr - printf(" \\\n\t%s.o", funcalias) > sysmk - } - syscall++ - next - } - type("COMPAT") || type("COMPAT4") || type("COMPAT6") || \ - type("COMPAT7") || type("COMPAT10") || type("COMPAT11") || \ - type("COMPAT12") { - if (flag("COMPAT")) { - ncompat++ - out = syscompat - outdcl = syscompatdcl - wrap = "compat" - prefix = "o" - descr = "old" - } else if (flag("COMPAT4")) { - ncompat4++ - out = syscompat4 - outdcl = syscompat4dcl - wrap = "compat4" - prefix = "freebsd4_" - descr = "freebsd4" - } else if (flag("COMPAT6")) { - ncompat6++ - out = syscompat6 - outdcl = syscompat6dcl - wrap = "compat6" - prefix = "freebsd6_" - descr = "freebsd6" - } else if (flag("COMPAT7")) { - ncompat7++ - out = syscompat7 - outdcl = syscompat7dcl - wrap = "compat7" - prefix = "freebsd7_" - descr = "freebsd7" - } else if (flag("COMPAT10")) { - ncompat10++ - out = syscompat10 - outdcl = syscompat10dcl - wrap = "compat10" - prefix = "freebsd10_" - descr = "freebsd10" - } else if (flag("COMPAT11")) { - ncompat11++ - out = syscompat11 - outdcl = syscompat11dcl - wrap = "compat11" - prefix = "freebsd11_" - descr = "freebsd11" - } else if (flag("COMPAT12")) { - ncompat12++ - out = syscompat12 - outdcl = syscompat12dcl - wrap = "compat12" - prefix = "freebsd12_" - descr = "freebsd12" - } - parseline() - if (argc != 0 && !flag("NOARGS") && !flag("NOPROTO") && \ - !flag("NODEF")) { - printf("struct %s {\n", argalias) > out - for (i = 1; i <= argc; i++) - printf("\tchar %s_l_[PADL_(%s)]; %s %s; " \ - "char %s_r_[PADR_(%s)];\n", - argname[i], argtype[i], - argtype[i], argname[i], - argname[i], argtype[i]) > out - printf("};\n") > out - } - else if (!flag("NOARGS") && !flag("NOPROTO") && !flag("NODEF")) - printf("struct %s {\n\tregister_t dummy;\n};\n", - argalias) > sysarg - if (!flag("NOPROTO") && !flag("NODEF")) { - printf("%s\t%s%s(struct thread *, struct %s *);\n", - rettype, prefix, funcname, argalias) > outdcl - printf("#define\t%sAUE_%s%s\t%s\n", syscallprefix, - prefix, funcname, auditev) > sysaue - } - if (flag("NOSTD")) { - printf("\t{ %s, (sy_call_t *)%s, %s, NULL, 0, 0, 0, SY_THR_ABSENT },", - "0", "lkmressys", "AUE_NULL") > sysent - align_sysent_comment(8 + 2 + length("0") + 15 + \ - length("lkmressys") + length("AUE_NULL") + 3) - } else { - printf("\t{ %s(%s,%s), %s, NULL, 0, 0, %s, %s },", - wrap, argssize, funcname, auditev, flags, thr_flag) > sysent - align_sysent_comment(8 + 9 + length(argssize) + 1 + \ - length(funcname) + length(auditev) + \ - length(flags) + 4) - } - printf("/* %d = %s %s */\n", syscall, descr, funcalias) > sysent - printf("\t\"%s.%s\",\t\t/* %d = %s %s */\n", - wrap, funcalias, syscall, descr, funcalias) > sysnames - # Do not provide freebsdN_* symbols in libc for < FreeBSD 7 - if (flag("COMPAT") || flag("COMPAT4") || flag("COMPAT6")) { - printf("\t\t\t\t/* %d is %s %s */\n", - syscall, descr, funcalias) > syshdr - } else if (!flag("NODEF")) { - printf("#define\t%s%s%s\t%d\n", syscallprefix, - prefix, funcalias, syscall) > syshdr - printf(" \\\n\t%s%s.o", prefix, funcalias) > sysmk - } - syscall++ - next - } - type("OBSOL") { - printf("\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },") > sysent - align_sysent_comment(34) - printf("/* %d = obsolete %s */\n", syscall, comment) > sysent - printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", - $4, syscall, comment) > sysnames - printf("\t\t\t\t/* %d is obsolete %s */\n", - syscall, comment) > syshdr - syscall++ - next - } - type("UNIMPL") { - while (syscall <= syscall_range[2]) { - printf("\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },\t\t\t/* %d = %s */\n", - syscall, comment) > sysent - printf("\t\"#%d\",\t\t\t/* %d = %s */\n", - syscall, syscall, comment) > sysnames - syscall++ - } - next - } - { - printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $3 - exit 1 - } - END { - printf "\n#define AS(name) (sizeof(struct name) / sizeof(register_t))\n" > sysinc - - if (ncompat != 0) { - printf "\n#ifdef %s\n", compat > sysinc - printf "#define compat(n, name) n, (sy_call_t *)__CONCAT(o,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - - if (ncompat4 != 0) { - printf "\n#ifdef %s\n", compat4 > sysinc - printf "#define compat4(n, name) n, (sy_call_t *)__CONCAT(freebsd4_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat4(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - - if (ncompat6 != 0) { - printf "\n#ifdef %s\n", compat6 > sysinc - printf "#define compat6(n, name) n, (sy_call_t *)__CONCAT(freebsd6_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat6(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - - if (ncompat7 != 0) { - printf "\n#ifdef %s\n", compat7 > sysinc - printf "#define compat7(n, name) n, (sy_call_t *)__CONCAT(freebsd7_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat7(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - if (ncompat10 != 0) { - printf "\n#ifdef %s\n", compat10 > sysinc - printf "#define compat10(n, name) n, (sy_call_t *)__CONCAT(freebsd10_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat10(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - if (ncompat11 != 0) { - printf "\n#ifdef %s\n", compat11 > sysinc - printf "#define compat11(n, name) n, (sy_call_t *)__CONCAT(freebsd11_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat11(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - if (ncompat12 != 0) { - printf "\n#ifdef %s\n", compat12 > sysinc - printf "#define compat12(n, name) n, (sy_call_t *)__CONCAT(freebsd12_,name)\n" > sysinc - printf "#else\n" > sysinc - printf "#define compat12(n, name) 0, (sy_call_t *)nosys\n" > sysinc - printf "#endif\n" > sysinc - } - - printf("\n#endif /* %s */\n\n", compat) > syscompatdcl - printf("\n#endif /* %s */\n\n", compat4) > syscompat4dcl - printf("\n#endif /* %s */\n\n", compat6) > syscompat6dcl - printf("\n#endif /* %s */\n\n", compat7) > syscompat7dcl - printf("\n#endif /* %s */\n\n", compat10) > syscompat10dcl - printf("\n#endif /* %s */\n\n", compat11) > syscompat11dcl - printf("\n#endif /* %s */\n\n", compat12) > syscompat12dcl - - printf("\n#undef PAD_\n") > sysprotoend - printf("#undef PADL_\n") > sysprotoend - printf("#undef PADR_\n") > sysprotoend - printf("\n#endif /* !%s */\n", sysproto_h) > sysprotoend - - printf("\n") > sysmk - printf("};\n") > sysent - printf("};\n") > sysnames - printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall) \ - > syshdr - printf "\tdefault:\n\t\t*n_args = 0;\n\t\tbreak;\n\t};\n}\n" > systrace - printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systracetmp - printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systraceret - } ' - -cat $sysinc $sysent >> $syssw -cat $sysarg $sysdcl \ - $syscompat $syscompatdcl \ - $syscompat4 $syscompat4dcl \ - $syscompat6 $syscompat6dcl \ - $syscompat7 $syscompat7dcl \ - $syscompat10 $syscompat10dcl \ - $syscompat11 $syscompat11dcl \ - $syscompat12 $syscompat12dcl \ - $sysaue $sysprotoend > $sysproto -cat $systracetmp >> $systrace -cat $systraceret >> $systrace - From owner-dev-commits-src-all@freebsd.org Thu Aug 26 08:43:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AED436655B6; Thu, 26 Aug 2021 08:43: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 4GwGZw4V1yz3N8n; Thu, 26 Aug 2021 08:43: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 81F604ECF; Thu, 26 Aug 2021 08:43: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 17Q8hK56008842; Thu, 26 Aug 2021 08:43:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q8hKPD008841; Thu, 26 Aug 2021 08:43:20 GMT (envelope-from git) Date: Thu, 26 Aug 2021 08:43:20 GMT Message-Id: <202108260843.17Q8hKPD008841@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: cb08b3020f7a - stable/13 - loader: open file list should be dynamic MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cb08b3020f7ae3e647c27cff9e7dd5be24d60ffe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 08:43:20 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=cb08b3020f7ae3e647c27cff9e7dd5be24d60ffe commit cb08b3020f7ae3e647c27cff9e7dd5be24d60ffe Author: Toomas Soome AuthorDate: 2021-07-31 08:09:48 +0000 Commit: Toomas Soome CommitDate: 2021-08-26 07:59:28 +0000 loader: open file list should be dynamic Summary: Open file list is currently created as statically allocated array (64 items). Once this array is filled up, loader will not be able to operate with files. In most cases, this mechanism is good enough, but the problem appears, when we have many disks with zfs pool(s). In current loader implementation, all discovered zfs pool configurations are kept in memory and disk devices open - consuming the open file array. Rewrite the open file mechanism to use dynamically allocated list. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D31364 (cherry picked from commit 97cbd5e722389a575e820c4e03f38053308f08ea) --- stand/libsa/close.c | 33 +++++++++---- stand/libsa/closeall.c | 58 ++++++----------------- stand/libsa/fstat.c | 9 ++-- stand/libsa/ioctl.c | 22 ++++----- stand/libsa/iodesc.h | 2 + stand/libsa/lseek.c | 5 +- stand/libsa/net.h | 2 - stand/libsa/netif.c | 122 +++++++++++++++++++++++++++++++++++++++---------- stand/libsa/open.c | 66 ++++++++++++++++++++++---- stand/libsa/read.c | 5 +- stand/libsa/readdir.c | 5 +- stand/libsa/stand.h | 8 +++- stand/libsa/write.c | 5 +- 13 files changed, 227 insertions(+), 115 deletions(-) diff --git a/stand/libsa/close.c b/stand/libsa/close.c index d8f62fef6198..a177eb85eb3a 100644 --- a/stand/libsa/close.c +++ b/stand/libsa/close.c @@ -68,23 +68,38 @@ __FBSDID("$FreeBSD$"); int close(int fd) { - struct open_file *f = &files[fd]; + struct open_file *f, *last; int err1 = 0, err2 = 0; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL) { errno = EBADF; return (-1); } free(f->f_rabuf); f->f_rabuf = NULL; - if (!(f->f_flags & F_RAW) && f->f_ops) - err1 = (f->f_ops->fo_close)(f); - if (!(f->f_flags & F_NODEV) && f->f_dev) - err2 = (f->f_dev->dv_close)(f); - if (f->f_devdata != NULL) - devclose(f); - f->f_flags = 0; + if (f->f_flags != 0) { + if (!(f->f_flags & F_RAW) && f->f_ops) + err1 = (f->f_ops->fo_close)(f); + if (!(f->f_flags & F_NODEV) && f->f_dev) + err2 = (f->f_dev->dv_close)(f); + if (f->f_devdata != NULL) + devclose(f); + f->f_flags = 0; + } else { + /* Attempt to close already closed file. */ + err1 = EBADF; + } + + /* free unused entries from tail. */ + TAILQ_FOREACH_REVERSE_SAFE(last, &files, file_list, f_link, f) { + if (last->f_flags != 0) + break; + TAILQ_REMOVE(&files, last, f_link); + free(last); + } + if (err1) { errno = err1; return (-1); diff --git a/stand/libsa/closeall.c b/stand/libsa/closeall.c index 9693130ebf9b..92c6955cf5da 100644 --- a/stand/libsa/closeall.c +++ b/stand/libsa/closeall.c @@ -1,11 +1,7 @@ -/* $NetBSD: closeall.c,v 1.1 1996/01/13 22:25:36 leo Exp $ */ - /*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * This code is derived from software contributed to Berkeley by - * The Mach Operating System project at Carnegie-Mellon University. + * Copyright (c) 2021 Toomas Soome * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -15,14 +11,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -31,33 +24,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)close.c 8.1 (Berkeley) 6/11/93 - * - * - * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Author: Alessandro Forin - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. */ #include @@ -66,11 +32,17 @@ __FBSDID("$FreeBSD$"); #include "stand.h" void -closeall() +closeall(void) { - int i; + struct open_file *f; - for (i = 0; i < SOPEN_MAX; i++) - if (files[i].f_flags != 0) - (void)close(i); + /* + * Pick up last entry and close it, this will also trigger + * the removal of this entry, and we end up with empty list. + */ + while ((f = TAILQ_LAST(&files, file_list)) != NULL) { + (void)close(f->f_id); + } + /* reset errno from close() */ + errno = 0; } diff --git a/stand/libsa/fstat.c b/stand/libsa/fstat.c index cb2df8cbf0ac..47893416e0bf 100644 --- a/stand/libsa/fstat.c +++ b/stand/libsa/fstat.c @@ -37,13 +37,12 @@ __FBSDID("$FreeBSD$"); #include "stand.h" int -fstat(fd, sb) - int fd; - struct stat *sb; +fstat(int fd, struct stat *sb) { - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL || f->f_flags == 0) { errno = EBADF; return (-1); } diff --git a/stand/libsa/ioctl.c b/stand/libsa/ioctl.c index 807b308e5e50..7363236ada0e 100644 --- a/stand/libsa/ioctl.c +++ b/stand/libsa/ioctl.c @@ -32,30 +32,30 @@ * SUCH DAMAGE. * * @(#)ioctl.c 8.1 (Berkeley) 6/11/93 - * + * * * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University * All Rights Reserved. * * Author: Alessandro Forin - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. */ @@ -66,14 +66,12 @@ __FBSDID("$FreeBSD$"); #include "stand.h" int -ioctl(fd, cmd, arg) - int fd; - u_long cmd; - char *arg; +ioctl(int fd, u_long cmd, char *arg) { - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL || f->f_flags == 0) { errno = EBADF; return (-1); } diff --git a/stand/libsa/iodesc.h b/stand/libsa/iodesc.h index 37ae044af9d9..199fbcf74e98 100644 --- a/stand/libsa/iodesc.h +++ b/stand/libsa/iodesc.h @@ -47,6 +47,8 @@ struct iodesc { u_long xid; /* transaction identification */ u_char myea[6]; /* my ethernet address */ struct netif *io_netif; + int io_id; /* descriptor id */ + TAILQ_ENTRY(iodesc) io_link; /* next entry in list */ }; #endif /* __SYS_LIBNETBOOT_IODESC_H */ diff --git a/stand/libsa/lseek.c b/stand/libsa/lseek.c index 1a39eb31421b..c4ca97b148d6 100644 --- a/stand/libsa/lseek.c +++ b/stand/libsa/lseek.c @@ -69,9 +69,10 @@ off_t lseek(int fd, off_t offset, int where) { off_t bufpos, filepos, target; - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + f = fd2open_file(fd); + if (f == NULL || f->f_flags == 0) { errno = EBADF; return (-1); } diff --git a/stand/libsa/net.h b/stand/libsa/net.h index 36b7cacc95ef..77a11c8dcab6 100644 --- a/stand/libsa/net.h +++ b/stand/libsa/net.h @@ -97,8 +97,6 @@ extern u_int intf_mtu; extern int debug; /* defined in the machdep sources */ -extern struct iodesc sockets[SOPEN_MAX]; - /* ARP/RevARP functions: */ u_char *arpwhohas(struct iodesc *, struct in_addr); void arp_reply(struct iodesc *, void *); diff --git a/stand/libsa/netif.c b/stand/libsa/netif.c index d255cc663d5a..2d32ccd9de7e 100644 --- a/stand/libsa/netif.c +++ b/stand/libsa/netif.c @@ -47,7 +47,19 @@ __FBSDID("$FreeBSD$"); #include "net.h" #include "netif.h" -struct iodesc sockets[SOPEN_MAX]; +typedef TAILQ_HEAD(socket_list, iodesc) socket_list_t; + +/* + * Open socket list. The current implementation and assumption is, + * we only remove entries from tail and we only add new entries to tail. + * This decision is to keep iodesc id management simple - we get list + * entries ordered by continiously growing io_id field. + * If we do have multiple sockets open and we do close socket not from tail, + * this entry will be marked unused. netif_open() will reuse unused entry, or + * netif_close() will free all unused tail entries. + */ +static socket_list_t sockets = TAILQ_HEAD_INITIALIZER(sockets); + #ifdef NETIF_DEBUG int netif_debug = 0; #endif @@ -63,7 +75,7 @@ netif_init(void) { struct netif_driver *drv; int d, i; - + #ifdef NETIF_DEBUG if (netif_debug) printf("netif_init: called\n"); @@ -108,7 +120,7 @@ netif_select(void *machdep_hint) for (u = 0; u < drv->netif_nifs; u++) { cur_if.nif_unit = u; unit_done = 0; - + #ifdef NETIF_DEBUG if (netif_debug) printf("\t%s%d:", drv->netif_bname, @@ -179,14 +191,14 @@ netif_attach(struct netif *nif, struct iodesc *desc, void *machdep_hint) if (netif_debug) printf("%s%d: netif_attach\n", drv->netif_bname, nif->nif_unit); #endif - desc->io_netif = nif; + desc->io_netif = nif; #ifdef PARANOID if (drv->netif_init == NULL) panic("%s%d: no netif_init support", drv->netif_bname, nif->nif_unit); #endif drv->netif_init(desc, machdep_hint); - bzero(drv->netif_ifs[nif->nif_unit].dif_stats, + bzero(drv->netif_ifs[nif->nif_unit].dif_stats, sizeof(struct netif_stats)); } @@ -261,35 +273,71 @@ netif_put(struct iodesc *desc, void *pkt, size_t len) return (rv); } +/* + * socktodesc_impl: + * + * Walk socket list and return pointer to iodesc structure. + * if id is < 0, return first unused iodesc. + */ +static struct iodesc * +socktodesc_impl(int socket) +{ + struct iodesc *s; + + TAILQ_FOREACH(s, &sockets, io_link) { + /* search by socket id */ + if (socket >= 0) { + if (s->io_id == socket) + break; + continue; + } + /* search for first unused entry */ + if (s->io_netif == NULL) + break; + } + return (s); +} + struct iodesc * socktodesc(int sock) { - if (sock >= SOPEN_MAX) { + struct iodesc *desc; + + if (sock < 0) + desc = NULL; + else + desc = socktodesc_impl(sock); + + if (desc == NULL) errno = EBADF; - return (NULL); - } - return (&sockets[sock]); + + return (desc); } int netif_open(void *machdep_hint) { - int fd; struct iodesc *s; struct netif *nif; - + /* find a free socket */ - for (fd = 0, s = sockets; fd < SOPEN_MAX; fd++, s++) - if (s->io_netif == (struct netif *)0) - goto fnd; - errno = EMFILE; - return (-1); - -fnd: - bzero(s, sizeof(*s)); + s = socktodesc_impl(-1); + if (s == NULL) { + struct iodesc *last; + + s = calloc(1, sizeof (*s)); + if (s == NULL) + return (-1); + + last = TAILQ_LAST(&sockets, socket_list); + if (last != NULL) + s->io_id = last->io_id + 1; + TAILQ_INSERT_TAIL(&sockets, s, io_link); + } + netif_init(); nif = netif_select(machdep_hint); - if (!nif) + if (!nif) panic("netboot: no interfaces left untried"); if (netif_probe(nif, machdep_hint)) { printf("netboot: couldn't probe %s%d\n", @@ -299,18 +347,42 @@ fnd: } netif_attach(nif, s, machdep_hint); - return (fd); + return (s->io_id); } int netif_close(int sock) { - if (sock >= SOPEN_MAX) { - errno = EBADF; + struct iodesc *s, *last; + int err; + + err = 0; + s = socktodesc_impl(sock); + if (s == NULL || sock < 0) { + err = EBADF; + return (-1); + } + netif_detach(s->io_netif); + bzero(&s->destip, sizeof (s->destip)); + bzero(&s->myip, sizeof (s->myip)); + s->destport = 0; + s->myport = 0; + s->xid = 0; + bzero(s->myea, sizeof (s->myea)); + s->io_netif = NULL; + + /* free unused entries from tail. */ + TAILQ_FOREACH_REVERSE_SAFE(last, &sockets, socket_list, io_link, s) { + if (last->io_netif != NULL) + break; + TAILQ_REMOVE(&sockets, last, io_link); + free(last); + } + + if (err) { + errno = err; return (-1); } - netif_detach(sockets[sock].io_netif); - sockets[sock].io_netif = (struct netif *)0; return (0); } diff --git a/stand/libsa/open.c b/stand/libsa/open.c index d1f1fcf9bb4d..e2591b680319 100644 --- a/stand/libsa/open.c +++ b/stand/libsa/open.c @@ -67,17 +67,66 @@ __FBSDID("$FreeBSD$"); struct fs_ops *exclusive_file_system; -struct open_file files[SOPEN_MAX]; +/* + * Open file list. The current implementation and assumption is, + * we only remove entries from tail and we only add new entries to tail. + * This decision is to keep file id management simple - we get list + * entries ordered by continiously growing f_id field. + * If we do have multiple files open and we do close file not from tail, + * this entry will be marked unused. open() will reuse unused entry, or + * close will free all unused tail entries. + * + * Only case we expect open file list to grow long, is with zfs pools with + * many disks. + */ +file_list_t files = TAILQ_HEAD_INITIALIZER(files); + +/* + * Walk file list and return pointer to open_file structure. + * if fd is < 0, return first unused open_file. + */ +struct open_file * +fd2open_file(int fd) +{ + struct open_file *f; + + TAILQ_FOREACH(f, &files, f_link) { + if (fd >= 0) { + if (f->f_id == fd) + break; + continue; + } + + if (f->f_flags == 0) + break; + } + return (f); +} static int -o_gethandle(void) +o_gethandle(struct open_file **ptr) { - int fd; + struct open_file *f, *last; - for (fd = 0; fd < SOPEN_MAX; fd++) - if (files[fd].f_flags == 0) - return (fd); - return (-1); + /* Pick up unused entry */ + f = fd2open_file(-1); + if (f != NULL) { + *ptr = f; + return (f->f_id); + } + + /* Add new entry */ + f = calloc(1, sizeof (*f)); + if (f == NULL) + return (-1); + + last = TAILQ_LAST(&files, file_list); + if (last != NULL) + f->f_id = last->f_id + 1; + TAILQ_INSERT_TAIL(&files, f, f_link); + + *ptr = f; + return (f->f_id); } static void @@ -96,12 +145,11 @@ open(const char *fname, int mode) int fd, i, error, besterror; const char *file; - if ((fd = o_gethandle()) == -1) { + if ((fd = o_gethandle(&f)) == -1) { errno = EMFILE; return (-1); } - f = &files[fd]; f->f_flags = mode + 1; f->f_dev = NULL; f->f_ops = NULL; diff --git a/stand/libsa/read.c b/stand/libsa/read.c index 021425371ee7..7d19dae0670d 100644 --- a/stand/libsa/read.c +++ b/stand/libsa/read.c @@ -69,10 +69,11 @@ __FBSDID("$FreeBSD$"); ssize_t read(int fd, void *dest, size_t bcount) { - struct open_file *f = &files[fd]; + struct open_file *f; size_t resid; - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { + f = fd2open_file(fd); + if (f == NULL || !(f->f_flags & F_READ)) { errno = EBADF; return (-1); } diff --git a/stand/libsa/readdir.c b/stand/libsa/readdir.c index e49d93d15ed6..7757647e11e8 100644 --- a/stand/libsa/readdir.c +++ b/stand/libsa/readdir.c @@ -34,9 +34,10 @@ struct dirent * readdirfd(int fd) { static struct dirent dir; /* XXX not thread safe */ - struct open_file *f = &files[fd]; + struct open_file *f; - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { + f = fd2open_file(fd); + if (f == NULL || !(f->f_flags & F_READ)) { errno = EBADF; return (NULL); } diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h index 6da4966738b4..e49b8c50619d 100644 --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -65,6 +65,7 @@ #include #include #include +#include /* this header intentionally exports NULL from */ #include @@ -182,11 +183,14 @@ struct open_file { char *f_rabuf; /* readahead buffer pointer */ size_t f_ralen; /* valid data in readahead buffer */ off_t f_raoffset; /* consumer offset in readahead buffer */ + int f_id; /* file number */ + TAILQ_ENTRY(open_file) f_link; /* next entry */ #define SOPEN_RASIZE 512 }; -#define SOPEN_MAX 64 -extern struct open_file files[]; +typedef TAILQ_HEAD(file_list, open_file) file_list_t; +extern file_list_t files; +extern struct open_file *fd2open_file(int); /* f_flags values */ #define F_READ 0x0001 /* file opened for reading */ diff --git a/stand/libsa/write.c b/stand/libsa/write.c index 7d054e005cda..db82d7eaf4f6 100644 --- a/stand/libsa/write.c +++ b/stand/libsa/write.c @@ -69,10 +69,11 @@ __FBSDID("$FreeBSD$"); ssize_t write(int fd, const void *dest, size_t bcount) { - struct open_file *f = &files[fd]; + struct open_file *f; size_t resid; - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) { + f = fd2open_file(fd); + if (f == NULL || !(f->f_flags & F_WRITE)) { errno = EBADF; return (-1); } From owner-dev-commits-src-all@freebsd.org Thu Aug 26 08:47:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9012E6653C4; Thu, 26 Aug 2021 08:47: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 4GwGh13hXTz3PcB; Thu, 26 Aug 2021 08:47: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 6272E50B2; Thu, 26 Aug 2021 08:47: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 17Q8ljJt009504; Thu, 26 Aug 2021 08:47:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q8ljE4009503; Thu, 26 Aug 2021 08:47:45 GMT (envelope-from git) Date: Thu, 26 Aug 2021 08:47:45 GMT Message-Id: <202108260847.17Q8ljE4009503@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: ed760a3a6f6f - stable/13 - libsa: cstyle cleanup of dosfs.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ed760a3a6f6f4087d181193a324addc67bf306da Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 08:47:45 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=ed760a3a6f6f4087d181193a324addc67bf306da commit ed760a3a6f6f4087d181193a324addc67bf306da Author: Toomas Soome AuthorDate: 2021-08-19 14:33:24 +0000 Commit: Toomas Soome CommitDate: 2021-08-26 08:02:22 +0000 libsa: cstyle cleanup of dosfs.c No functional changes intended. (cherry picked from commit 3ec0714d6db0060113f6cadac6f4e44640603e8f) --- stand/libsa/dosfs.c | 1175 ++++++++++++++++++++++++++------------------------- 1 file changed, 595 insertions(+), 580 deletions(-) diff --git a/stand/libsa/dosfs.c b/stand/libsa/dosfs.c index 2d6029be837e..656af3642c88 100644 --- a/stand/libsa/dosfs.c +++ b/stand/libsa/dosfs.c @@ -69,40 +69,40 @@ struct fs_ops dosfs_fsops = { /* DOS "BIOS Parameter Block" */ typedef struct { - u_char secsiz[2]; /* sector size */ - u_char spc; /* sectors per cluster */ - u_char ressec[2]; /* reserved sectors */ - u_char fats; /* FATs */ - u_char dirents[2]; /* root directory entries */ - u_char secs[2]; /* total sectors */ - u_char media; /* media descriptor */ - u_char spf[2]; /* sectors per FAT */ - u_char spt[2]; /* sectors per track */ - u_char heads[2]; /* drive heads */ - u_char hidsec[4]; /* hidden sectors */ - u_char lsecs[4]; /* huge sectors */ - u_char lspf[4]; /* huge sectors per FAT */ - u_char xflg[2]; /* flags */ - u_char vers[2]; /* filesystem version */ - u_char rdcl[4]; /* root directory start cluster */ - u_char infs[2]; /* filesystem info sector */ - u_char bkbs[2]; /* backup boot sector */ + u_char secsiz[2]; /* sector size */ + u_char spc; /* sectors per cluster */ + u_char ressec[2]; /* reserved sectors */ + u_char fats; /* FATs */ + u_char dirents[2]; /* root directory entries */ + u_char secs[2]; /* total sectors */ + u_char media; /* media descriptor */ + u_char spf[2]; /* sectors per FAT */ + u_char spt[2]; /* sectors per track */ + u_char heads[2]; /* drive heads */ + u_char hidsec[4]; /* hidden sectors */ + u_char lsecs[4]; /* huge sectors */ + u_char lspf[4]; /* huge sectors per FAT */ + u_char xflg[2]; /* flags */ + u_char vers[2]; /* filesystem version */ + u_char rdcl[4]; /* root directory start cluster */ + u_char infs[2]; /* filesystem info sector */ + u_char bkbs[2]; /* backup boot sector */ } DOS_BPB; /* Initial portion of DOS boot sector */ typedef struct { - u_char jmp[3]; /* usually 80x86 'jmp' opcode */ - u_char oem[8]; /* OEM name and version */ - DOS_BPB bpb; /* BPB */ + u_char jmp[3]; /* usually 80x86 'jmp' opcode */ + u_char oem[8]; /* OEM name and version */ + DOS_BPB bpb; /* BPB */ } DOS_BS; /* Supply missing "." and ".." root directory entries */ static const char *const dotstr[2] = {".", ".."}; static DOS_DE dot[2] = { - {". ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, - {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}}, - {".. ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, - {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}} + {". ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}}, + {".. ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}} }; /* The usual conversion macros to avoid multiplication and division */ @@ -148,31 +148,31 @@ static int ioget(struct open_file *, daddr_t, void *, size_t); static int dos_read_fatblk(DOS_FS *fs, struct open_file *fd, u_int blknum) { - int err; - size_t io_size; - daddr_t offset_in_fat, max_offset_in_fat; - - offset_in_fat = ((daddr_t)blknum) * FATBLKSZ; - max_offset_in_fat = secbyt(fs->spf); - io_size = FATBLKSZ; - if (offset_in_fat > max_offset_in_fat) - offset_in_fat = max_offset_in_fat; - if (offset_in_fat + io_size > max_offset_in_fat) - io_size = ((size_t)(max_offset_in_fat - offset_in_fat)); - - if (io_size != 0) { - err = ioget(fd, fs->lsnfat + bytsec(offset_in_fat), - fs->fatbuf, io_size); - if (err != 0) { - fs->fatbuf_blknum = ((u_int)(-1)); - return (err); - } - } - if (io_size < FATBLKSZ) - memset(fs->fatbuf + io_size, 0, FATBLKSZ - io_size); - - fs->fatbuf_blknum = blknum; - return (0); + int err; + size_t io_size; + daddr_t offset_in_fat, max_offset_in_fat; + + offset_in_fat = ((daddr_t)blknum) * FATBLKSZ; + max_offset_in_fat = secbyt(fs->spf); + io_size = FATBLKSZ; + if (offset_in_fat > max_offset_in_fat) + offset_in_fat = max_offset_in_fat; + if (offset_in_fat + io_size > max_offset_in_fat) + io_size = ((size_t)(max_offset_in_fat - offset_in_fat)); + + if (io_size != 0) { + err = ioget(fd, fs->lsnfat + bytsec(offset_in_fat), + fs->fatbuf, io_size); + if (err != 0) { + fs->fatbuf_blknum = ((u_int)(-1)); + return (err); + } + } + if (io_size < FATBLKSZ) + memset(fs->fatbuf + io_size, 0, FATBLKSZ - io_size); + + fs->fatbuf_blknum = blknum; + return (0); } /* @@ -181,38 +181,38 @@ dos_read_fatblk(DOS_FS *fs, struct open_file *fd, u_int blknum) static int dos_mount(DOS_FS *fs, struct open_file *fd) { - int err; - u_char *buf; - - bzero(fs, sizeof(DOS_FS)); - fs->fd = fd; - - if ((buf = malloc(secbyt(1))) == NULL) - return (errno); - if ((err = ioget(fs->fd, 0, buf, secbyt(1))) || - (err = parsebs(fs, (DOS_BS *)buf))) { - free(buf); - return (err); - } - free(buf); - - if ((fs->fatbuf = malloc(FATBLKSZ)) == NULL) - return (errno); - err = dos_read_fatblk(fs, fd, 0); - if (err != 0) { - free(fs->fatbuf); - return (err); - } - - fs->root = dot[0]; - fs->root.name[0] = ' '; - if (fs->fatsz == 32) { - fs->root.clus[0] = fs->rdcl & 0xff; - fs->root.clus[1] = (fs->rdcl >> 8) & 0xff; - fs->root.dex.h_clus[0] = (fs->rdcl >> 16) & 0xff; - fs->root.dex.h_clus[1] = (fs->rdcl >> 24) & 0xff; - } - return (0); + int err; + u_char *buf; + + bzero(fs, sizeof(DOS_FS)); + fs->fd = fd; + + if ((buf = malloc(secbyt(1))) == NULL) + return (errno); + if ((err = ioget(fs->fd, 0, buf, secbyt(1))) || + (err = parsebs(fs, (DOS_BS *)buf))) { + free(buf); + return (err); + } + free(buf); + + if ((fs->fatbuf = malloc(FATBLKSZ)) == NULL) + return (errno); + err = dos_read_fatblk(fs, fd, 0); + if (err != 0) { + free(fs->fatbuf); + return (err); + } + + fs->root = dot[0]; + fs->root.name[0] = ' '; + if (fs->fatsz == 32) { + fs->root.clus[0] = fs->rdcl & 0xff; + fs->root.clus[1] = (fs->rdcl >> 8) & 0xff; + fs->root.dex.h_clus[0] = (fs->rdcl >> 16) & 0xff; + fs->root.dex.h_clus[1] = (fs->rdcl >> 24) & 0xff; + } + return (0); } /* @@ -221,11 +221,11 @@ dos_mount(DOS_FS *fs, struct open_file *fd) static int dos_unmount(DOS_FS *fs) { - if (fs->links) - return (EBUSY); - free(fs->fatbuf); - free(fs); - return (0); + if (fs->links) + return (EBUSY); + free(fs->fatbuf); + free(fs); + return (0); } /* @@ -234,45 +234,45 @@ dos_unmount(DOS_FS *fs) static int dos_open(const char *path, struct open_file *fd) { - DOS_DE *de; - DOS_FILE *f; - DOS_FS *fs; - u_int size, clus; - int err; - - /* Allocate mount structure, associate with open */ - if ((fs = malloc(sizeof(DOS_FS))) == NULL) - return (errno); - if ((err = dos_mount(fs, fd))) { - free(fs); - return (err); - } - - if ((err = namede(fs, path, &de))) { - dos_unmount(fs); - return (err); - } - - clus = stclus(fs->fatsz, de); - size = cv4(de->size); - - if ((!(de->attr & FA_DIR) && (!clus != !size)) || - ((de->attr & FA_DIR) && size) || - (clus && !okclus(fs, clus))) { - dos_unmount(fs); - return (EINVAL); - } - if ((f = malloc(sizeof(DOS_FILE))) == NULL) { - err = errno; - dos_unmount(fs); - return (err); - } - bzero(f, sizeof(DOS_FILE)); - f->fs = fs; - fs->links++; - f->de = *de; - fd->f_fsdata = (void *)f; - return (0); + DOS_DE *de; + DOS_FILE *f; + DOS_FS *fs; + u_int size, clus; + int err; + + /* Allocate mount structure, associate with open */ + if ((fs = malloc(sizeof(DOS_FS))) == NULL) + return (errno); + if ((err = dos_mount(fs, fd))) { + free(fs); + return (err); + } + + if ((err = namede(fs, path, &de))) { + dos_unmount(fs); + return (err); + } + + clus = stclus(fs->fatsz, de); + size = cv4(de->size); + + if ((!(de->attr & FA_DIR) && (!clus != !size)) || + ((de->attr & FA_DIR) && size) || + (clus && !okclus(fs, clus))) { + dos_unmount(fs); + return (EINVAL); + } + if ((f = malloc(sizeof(DOS_FILE))) == NULL) { + err = errno; + dos_unmount(fs); + return (err); + } + bzero(f, sizeof(DOS_FILE)); + f->fs = fs; + fs->links++; + f->de = *de; + fd->f_fsdata = (void *)f; + return (0); } /* @@ -281,57 +281,58 @@ dos_open(const char *path, struct open_file *fd) static int dos_read(struct open_file *fd, void *buf, size_t nbyte, size_t *resid) { - off_t size; - u_int nb, off, clus, c, cnt, n; - DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; - int err = 0; - - /* - * as ioget() can be called *a lot*, use twiddle here. - * also 4 seems to be good value not to slow loading down too much: - * with 270MB file (~540k ioget() calls, twiddle can easily waste 4-5sec. - */ - twiddle(4); - nb = (u_int)nbyte; - if ((size = fsize(f->fs, &f->de)) == -1) - return (EINVAL); - if (nb > (n = size - f->offset)) - nb = n; - off = f->offset; - if ((clus = stclus(f->fs->fatsz, &f->de))) - off &= f->fs->bsize - 1; - c = f->c; - cnt = nb; - while (cnt) { - n = 0; - if (!c) { - if ((c = clus)) - n = bytblk(f->fs, f->offset); - } else if (!off) - n++; - while (n--) { - if ((err = fatget(f->fs, &c))) - goto out; - if (!okclus(f->fs, c)) { - err = EINVAL; - goto out; - } + off_t size; + u_int nb, off, clus, c, cnt, n; + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + int err = 0; + + /* + * as ioget() can be called *a lot*, use twiddle here. + * also 4 seems to be good value not to slow loading down too much: + * with 270MB file (~540k ioget() calls, twiddle can easily waste + * 4-5 sec. + */ + twiddle(4); + nb = (u_int)nbyte; + if ((size = fsize(f->fs, &f->de)) == -1) + return (EINVAL); + if (nb > (n = size - f->offset)) + nb = n; + off = f->offset; + if ((clus = stclus(f->fs->fatsz, &f->de))) + off &= f->fs->bsize - 1; + c = f->c; + cnt = nb; + while (cnt) { + n = 0; + if (!c) { + if ((c = clus)) + n = bytblk(f->fs, f->offset); + } else if (!off) + n++; + while (n--) { + if ((err = fatget(f->fs, &c))) + goto out; + if (!okclus(f->fs, c)) { + err = EINVAL; + goto out; + } + } + if (!clus || (n = f->fs->bsize - off) > cnt) + n = cnt; + if ((err = ioread(f->fs, (c ? blkoff(f->fs, c) : + secbyt(f->fs->lsndir)) + off, buf, n))) + goto out; + f->offset += n; + f->c = c; + off = 0; + buf = (char *)buf + n; + cnt -= n; } - if (!clus || (n = f->fs->bsize - off) > cnt) - n = cnt; - if ((err = ioread(f->fs, (c ? blkoff(f->fs, c) : - secbyt(f->fs->lsndir)) + off, buf, n))) - goto out; - f->offset += n; - f->c = c; - off = 0; - buf = (char *)buf + n; - cnt -= n; - } - out: - if (resid) - *resid = nbyte - nb + cnt; - return (err); +out: + if (resid) + *resid = nbyte - nb + cnt; + return (err); } /* @@ -340,33 +341,33 @@ dos_read(struct open_file *fd, void *buf, size_t nbyte, size_t *resid) static off_t dos_seek(struct open_file *fd, off_t offset, int whence) { - off_t off; - u_int size; - DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; - - size = cv4(f->de.size); - switch (whence) { - case SEEK_SET: - off = 0; - break; - case SEEK_CUR: - off = f->offset; - break; - case SEEK_END: - off = size; - break; - default: - errno = EINVAL; - return (-1); - } - off += offset; - if (off < 0 || off > size) { - errno = EINVAL; - return (-1); - } - f->offset = (u_int)off; - f->c = 0; - return (off); + off_t off; + u_int size; + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + + size = cv4(f->de.size); + switch (whence) { + case SEEK_SET: + off = 0; + break; + case SEEK_CUR: + off = f->offset; + break; + case SEEK_END: + off = size; + break; + default: + errno = EINVAL; + return (-1); + } + off += offset; + if (off < 0 || off > size) { + errno = EINVAL; + return (-1); + } + f->offset = (u_int)off; + f->c = 0; + return (off); } /* @@ -375,13 +376,13 @@ dos_seek(struct open_file *fd, off_t offset, int whence) static int dos_close(struct open_file *fd) { - DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; - DOS_FS *fs = f->fs; + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + DOS_FS *fs = f->fs; - f->fs->links--; - free(f); - dos_unmount(fs); - return (0); + f->fs->links--; + free(f); + dos_unmount(fs); + return (0); } /* @@ -390,105 +391,106 @@ dos_close(struct open_file *fd) static int dos_stat(struct open_file *fd, struct stat *sb) { - DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; - - /* only important stuff */ - sb->st_mode = f->de.attr & FA_DIR ? S_IFDIR | 0555 : S_IFREG | 0444; - sb->st_nlink = 1; - sb->st_uid = 0; - sb->st_gid = 0; - if ((sb->st_size = fsize(f->fs, &f->de)) == -1) - return (EINVAL); - return (0); + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + + /* only important stuff */ + sb->st_mode = f->de.attr & FA_DIR ? S_IFDIR | 0555 : S_IFREG | 0444; + sb->st_nlink = 1; + sb->st_uid = 0; + sb->st_gid = 0; + if ((sb->st_size = fsize(f->fs, &f->de)) == -1) + return (EINVAL); + return (0); } static int dos_checksum(unsigned char *name, unsigned char *ext) { - int x, i; - char buf[11]; - - bcopy(name, buf, 8); - bcopy(ext, buf+8, 3); - x = 0; - for (i = 0; i < 11; i++) { - x = ((x & 1) << 7) | (x >> 1); - x += buf[i]; - x &= 0xff; - } - return (x); + int x, i; + char buf[11]; + + bcopy(name, buf, 8); + bcopy(ext, buf+8, 3); + x = 0; + for (i = 0; i < 11; i++) { + x = ((x & 1) << 7) | (x >> 1); + x += buf[i]; + x &= 0xff; + } + return (x); } static int dos_readdir(struct open_file *fd, struct dirent *d) { - /* DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; */ - u_char fn[261]; - DOS_DIR dd; - size_t res; - u_int chk, x, xdn; - int err; - - x = chk = 0; - while (1) { - xdn = x; - x = 0; - err = dos_read(fd, &dd, sizeof(dd), &res); - if (err) - return (err); - if (res == sizeof(dd)) - return (ENOENT); - if (dd.de.name[0] == 0) - return (ENOENT); - - /* Skip deleted entries */ - if (dd.de.name[0] == 0xe5) - continue; - - /* Check if directory entry is volume label */ - if (dd.de.attr & FA_LABEL) { - /* - * If volume label set, check if the current entry is - * extended entry (FA_XDE) for long file names. - */ - if ((dd.de.attr & FA_MASK) == FA_XDE) { - /* - * Read through all following extended entries - * to get the long file name. 0x40 marks the - * last entry containing part of long file name. - */ - if (dd.xde.seq & 0x40) - chk = dd.xde.chk; - else if (dd.xde.seq != xdn - 1 || dd.xde.chk != chk) - continue; - x = dd.xde.seq & ~0x40; - if (x < 1 || x > 20) { - x = 0; - continue; + /* DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; */ + u_char fn[261]; + DOS_DIR dd; + size_t res; + u_int chk, x, xdn; + int err; + + x = chk = 0; + for (;;) { + xdn = x; + x = 0; + err = dos_read(fd, &dd, sizeof(dd), &res); + if (err) + return (err); + if (res == sizeof(dd)) + return (ENOENT); + if (dd.de.name[0] == 0) + return (ENOENT); + + /* Skip deleted entries */ + if (dd.de.name[0] == 0xe5) + continue; + + /* Check if directory entry is volume label */ + if (dd.de.attr & FA_LABEL) { + /* + * If volume label set, check if the current entry is + * extended entry (FA_XDE) for long file names. + */ + if ((dd.de.attr & FA_MASK) == FA_XDE) { + /* + * Read through all following extended entries + * to get the long file name. 0x40 marks the + * last entry containing part of long file name. + */ + if (dd.xde.seq & 0x40) + chk = dd.xde.chk; + else if (dd.xde.seq != xdn - 1 || + dd.xde.chk != chk) + continue; + x = dd.xde.seq & ~0x40; + if (x < 1 || x > 20) { + x = 0; + continue; + } + cp_xdnm(fn, &dd.xde); + } else { + /* skip only volume label entries */ + continue; + } + } else { + if (xdn == 1) { + x = dos_checksum(dd.de.name, dd.de.ext); + if (x == chk) + break; + } else { + cp_sfn(fn, &dd.de); + break; + } + x = 0; } - cp_xdnm(fn, &dd.xde); - } else { - /* skip only volume label entries */ - continue; - } - } else { - if (xdn == 1) { - x = dos_checksum(dd.de.name, dd.de.ext); - if (x == chk) - break; - } else { - cp_sfn(fn, &dd.de); - break; - } - x = 0; } - } - d->d_fileno = (dd.de.clus[1] << 8) + dd.de.clus[0]; - d->d_reclen = sizeof(*d); - d->d_type = (dd.de.attr & FA_DIR) ? DT_DIR : DT_REG; - memcpy(d->d_name, fn, sizeof(d->d_name)); - return (0); + d->d_fileno = (dd.de.clus[1] << 8) + dd.de.clus[0]; + d->d_reclen = sizeof(*d); + d->d_type = (dd.de.attr & FA_DIR) ? DT_DIR : DT_REG; + memcpy(d->d_name, fn, sizeof(d->d_name)); + return (0); } /* @@ -497,47 +499,47 @@ dos_readdir(struct open_file *fd, struct dirent *d) static int parsebs(DOS_FS *fs, DOS_BS *bs) { - u_int sc; - - if ((bs->jmp[0] != 0x69 && - bs->jmp[0] != 0xe9 && - (bs->jmp[0] != 0xeb || bs->jmp[2] != 0x90)) || - bs->bpb.media < 0xf0) - return (EINVAL); - if (cv2(bs->bpb.secsiz) != SECSIZ) - return (EINVAL); - if (!(fs->spc = bs->bpb.spc) || fs->spc & (fs->spc - 1)) - return (EINVAL); - fs->bsize = secbyt(fs->spc); - fs->bshift = ffs(fs->bsize) - 1; - if ((fs->spf = cv2(bs->bpb.spf))) { - if (bs->bpb.fats != 2) - return (EINVAL); - if (!(fs->dirents = cv2(bs->bpb.dirents))) - return (EINVAL); - } else { - if (!(fs->spf = cv4(bs->bpb.lspf))) - return (EINVAL); - if (!bs->bpb.fats || bs->bpb.fats > 16) - return (EINVAL); - if ((fs->rdcl = cv4(bs->bpb.rdcl)) < LOCLUS) - return (EINVAL); - } - if (!(fs->lsnfat = cv2(bs->bpb.ressec))) - return (EINVAL); - fs->lsndir = fs->lsnfat + fs->spf * bs->bpb.fats; - fs->lsndta = fs->lsndir + entsec(fs->dirents); - if (!(sc = cv2(bs->bpb.secs)) && !(sc = cv4(bs->bpb.lsecs))) - return (EINVAL); - if (fs->lsndta > sc) - return (EINVAL); - if ((fs->xclus = secblk(fs, sc - fs->lsndta) + 1) < LOCLUS) - return (EINVAL); - fs->fatsz = fs->dirents ? fs->xclus < 0xff6 ? 12 : 16 : 32; - sc = (secbyt(fs->spf) << 1) / (fs->fatsz >> 2) - 1; - if (fs->xclus > sc) - fs->xclus = sc; - return (0); + u_int sc; + + if ((bs->jmp[0] != 0x69 && + bs->jmp[0] != 0xe9 && + (bs->jmp[0] != 0xeb || bs->jmp[2] != 0x90)) || + bs->bpb.media < 0xf0) + return (EINVAL); + if (cv2(bs->bpb.secsiz) != SECSIZ) + return (EINVAL); + if (!(fs->spc = bs->bpb.spc) || fs->spc & (fs->spc - 1)) + return (EINVAL); + fs->bsize = secbyt(fs->spc); + fs->bshift = ffs(fs->bsize) - 1; + if ((fs->spf = cv2(bs->bpb.spf))) { + if (bs->bpb.fats != 2) + return (EINVAL); + if (!(fs->dirents = cv2(bs->bpb.dirents))) + return (EINVAL); + } else { + if (!(fs->spf = cv4(bs->bpb.lspf))) + return (EINVAL); + if (!bs->bpb.fats || bs->bpb.fats > 16) + return (EINVAL); + if ((fs->rdcl = cv4(bs->bpb.rdcl)) < LOCLUS) + return (EINVAL); + } + if (!(fs->lsnfat = cv2(bs->bpb.ressec))) + return (EINVAL); + fs->lsndir = fs->lsnfat + fs->spf * bs->bpb.fats; + fs->lsndta = fs->lsndir + entsec(fs->dirents); + if (!(sc = cv2(bs->bpb.secs)) && !(sc = cv4(bs->bpb.lsecs))) + return (EINVAL); + if (fs->lsndta > sc) + return (EINVAL); + if ((fs->xclus = secblk(fs, sc - fs->lsndta) + 1) < LOCLUS) + return (EINVAL); + fs->fatsz = fs->dirents ? fs->xclus < 0xff6 ? 12 : 16 : 32; + sc = (secbyt(fs->spf) << 1) / (fs->fatsz >> 2) - 1; + if (fs->xclus > sc) + fs->xclus = sc; + return (0); } /* @@ -546,33 +548,33 @@ parsebs(DOS_FS *fs, DOS_BS *bs) static int namede(DOS_FS *fs, const char *path, DOS_DE **dep) { - char name[256]; - DOS_DE *de; - char *s; - size_t n; - int err; - - err = 0; - de = &fs->root; - while (*path) { - while (*path == '/') - path++; - if (*path == '\0') - break; - if (!(s = strchr(path, '/'))) - s = strchr(path, 0); - if ((n = s - path) > 255) - return (ENAMETOOLONG); - memcpy(name, path, n); - name[n] = 0; - path = s; - if (!(de->attr & FA_DIR)) - return (ENOTDIR); - if ((err = lookup(fs, stclus(fs->fatsz, de), name, &de))) - return (err); - } - *dep = de; - return (0); + char name[256]; + DOS_DE *de; + char *s; + size_t n; + int err; + + err = 0; + de = &fs->root; + while (*path) { + while (*path == '/') + path++; + if (*path == '\0') + break; + if (!(s = strchr(path, '/'))) + s = strchr(path, 0); + if ((n = s - path) > 255) + return (ENAMETOOLONG); + memcpy(name, path, n); + name[n] = 0; + path = s; + if (!(de->attr & FA_DIR)) + return (ENOTDIR); + if ((err = lookup(fs, stclus(fs->fatsz, de), name, &de))) + return (err); + } + *dep = de; + return (0); } /* @@ -581,78 +583,85 @@ namede(DOS_FS *fs, const char *path, DOS_DE **dep) static int lookup(DOS_FS *fs, u_int clus, const char *name, DOS_DE **dep) { - static DOS_DIR dir[DEPSEC]; - u_char lfn[261]; - u_char sfn[13]; - u_int nsec, lsec, xdn, chk, sec, ent, x; - int err, ok; - - if (!clus) - for (ent = 0; ent < 2; ent++) - if (!strcasecmp(name, dotstr[ent])) { - *dep = dot + ent; - return (0); - } - if (!clus && fs->fatsz == 32) - clus = fs->rdcl; - nsec = !clus ? entsec(fs->dirents) : fs->spc; - lsec = 0; - xdn = chk = 0; - for (;;) { - if (!clus && !lsec) - lsec = fs->lsndir; - else if (okclus(fs, clus)) - lsec = blklsn(fs, clus); - else - return (EINVAL); - for (sec = 0; sec < nsec; sec++) { - if ((err = ioget(fs->fd, lsec + sec, dir, secbyt(1)))) - return (err); - for (ent = 0; ent < DEPSEC; ent++) { - if (!*dir[ent].de.name) - return (ENOENT); - if (*dir[ent].de.name != 0xe5) { - if ((dir[ent].de.attr & FA_MASK) == FA_XDE) { - x = dir[ent].xde.seq; - if (x & 0x40 || (x + 1 == xdn && - dir[ent].xde.chk == chk)) { - if (x & 0x40) { - chk = dir[ent].xde.chk; - x &= ~0x40; - } - if (x >= 1 && x <= 20) { - cp_xdnm(lfn, &dir[ent].xde); - xdn = x; - continue; - } - } - } else if (!(dir[ent].de.attr & FA_LABEL)) { - if ((ok = xdn == 1)) { - x = dos_checksum(dir[ent].de.name, dir[ent].de.ext); - ok = chk == x && - !strcasecmp(name, (const char *)lfn); - } - if (!ok) { - cp_sfn(sfn, &dir[ent].de); - ok = !strcasecmp(name, (const char *)sfn); - } - if (ok) { - *dep = &dir[ent].de; - return (0); - } - } + static DOS_DIR dir[DEPSEC]; + u_char lfn[261]; + u_char sfn[13]; + u_int nsec, lsec, xdn, chk, sec, ent, x; + int err, ok; + + if (!clus) + for (ent = 0; ent < 2; ent++) + if (!strcasecmp(name, dotstr[ent])) { + *dep = dot + ent; + return (0); } - xdn = 0; - } - } - if (!clus) - break; - if ((err = fatget(fs, &clus))) - return (err); - if (fatend(fs->fatsz, clus)) - break; - } - return (ENOENT); + if (!clus && fs->fatsz == 32) + clus = fs->rdcl; + nsec = !clus ? entsec(fs->dirents) : fs->spc; + lsec = 0; + xdn = chk = 0; + for (;;) { + if (!clus && !lsec) + lsec = fs->lsndir; + else if (okclus(fs, clus)) + lsec = blklsn(fs, clus); + else + return (EINVAL); + for (sec = 0; sec < nsec; sec++) { + if ((err = ioget(fs->fd, lsec + sec, dir, secbyt(1)))) + return (err); + for (ent = 0; ent < DEPSEC; ent++) { + if (!*dir[ent].de.name) + return (ENOENT); + if (*dir[ent].de.name != 0xe5) { + if ((dir[ent].de.attr & FA_MASK) == + FA_XDE) { + x = dir[ent].xde.seq; + if (x & 0x40 || (x + 1 == xdn && + dir[ent].xde.chk == chk)) { + if (x & 0x40) { + chk = dir[ent].xde.chk; + x &= ~0x40; + } + if (x >= 1 && x <= 20) { + cp_xdnm(lfn, &dir[ent].xde); + xdn = x; + continue; + } + } + } else if (!(dir[ent].de.attr & + FA_LABEL)) { + if ((ok = xdn == 1)) { + x = dos_checksum( + dir[ent].de.name, + dir[ent].de.ext); + ok = chk == x && + !strcasecmp(name, + (const char *)lfn); + } + if (!ok) { + cp_sfn(sfn, + &dir[ent].de); + ok = !strcasecmp(name, *** 375 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Thu Aug 26 09:16:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 36511665D0D; Thu, 26 Aug 2021 09:16: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 4GwHJw0r7sz3n3Y; Thu, 26 Aug 2021 09:16: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 04D145523; Thu, 26 Aug 2021 09:16: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 17Q9GFIU051311; Thu, 26 Aug 2021 09:16:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9GF2w051310; Thu, 26 Aug 2021 09:16:15 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:16:15 GMT Message-Id: <202108260916.17Q9GF2w051310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 3706af423ff2 - main - Add support for Lewisburg GPIO through P2SB MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3706af423ff257540dfe88bcb91fb0ab54e60946 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:16:16 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=3706af423ff257540dfe88bcb91fb0ab54e60946 commit 3706af423ff257540dfe88bcb91fb0ab54e60946 Author: Arnaud Ysmal AuthorDate: 2021-06-29 13:54:07 +0000 Commit: Wojciech Macek CommitDate: 2021-08-26 09:00:39 +0000 Add support for Lewisburg GPIO through P2SB Obtained from: Semihalf Sponsored by: Stormshield Differential revision: https://reviews.freebsd.org/D31269 --- sys/conf/files.amd64 | 3 + sys/dev/p2sb/lewisburg_gpio.c | 269 ++++++++++++++++++++++++++++++ sys/dev/p2sb/lewisburg_gpiocm.c | 351 ++++++++++++++++++++++++++++++++++++++++ sys/dev/p2sb/lewisburg_gpiocm.h | 12 ++ sys/dev/p2sb/p2sb.c | 215 ++++++++++++++++++++++++ sys/dev/p2sb/p2sb.h | 11 ++ sys/modules/Makefile | 3 + sys/modules/p2sb/Makefile | 7 + 8 files changed, 871 insertions(+) diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index d58cf7927206..1bcfaa05d0ba 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -363,6 +363,9 @@ dev/viawd/viawd.c optional viawd dev/vmd/vmd.c optional vmd dev/vmd/vmd_bus.c optional vmd_bus dev/wbwd/wbwd.c optional wbwd +dev/p2sb/p2sb.c optional p2sb pci +dev/p2sb/lewisburg_gpiocm.c optional lbggpiocm p2sb +dev/p2sb/lewisburg_gpio.c optional lbggpio lbggpiocm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/imgact_aout.c optional compat_aout diff --git a/sys/dev/p2sb/lewisburg_gpio.c b/sys/dev/p2sb/lewisburg_gpio.c new file mode 100644 index 000000000000..d0b08520eb87 --- /dev/null +++ b/sys/dev/p2sb/lewisburg_gpio.c @@ -0,0 +1,269 @@ +/*- + * Copyright (c) 2018 Stormshield + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include /* defines used in kernel.h */ +#include +#include +#include +#include /* types used in module initialization */ +#include /* cdevsw struct */ +#include /* uio struct */ +#include +#include /* structs, prototypes for pci bus stuff and DEVMETHOD macros! */ +#include + +#include +#include +#include + +#include + +#include "gpio_if.h" + +#include "lewisburg_gpiocm.h" + +#define P2SB_GROUP_GPIO_MAX_PINS 24 +struct lbggpio_softc +{ + device_t sc_busdev; + int groupid; + int pins_off; + int npins; + char grpname; + struct gpio_pin gpio_setup[P2SB_GROUP_GPIO_MAX_PINS]; +}; + +static device_t +lbggpio_get_bus(device_t dev) +{ + struct lbggpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->sc_busdev); +} + +static int +lbggpio_pin_max(device_t dev, int *maxpin) +{ + struct lbggpio_softc *sc; + + if (maxpin == NULL) + return (EINVAL); + + sc = device_get_softc(dev); + + *maxpin = sc->npins - 1; + + return (0); +} + +static int +lbggpio_pin_getname(device_t dev, uint32_t pin, char *name) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (name == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + strlcpy(name, sc->gpio_setup[pin].gp_name, GPIOMAXNAME); + + return (0); +} + +static int +lbggpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (flags == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + *flags = sc->gpio_setup[pin].gp_flags; + + return (0); +} + +static int +lbggpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (caps == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + *caps = sc->gpio_setup[pin].gp_caps; + + return (0); +} + +static int +lbggpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (pin >= sc->npins) + return (EINVAL); + + /* Check for unwanted flags. */ + if ((flags & sc->gpio_setup[pin].gp_caps) != flags) + return (EINVAL); + + lbggpiocm_pin_setflags(device_get_parent(dev), dev, pin, flags); + sc->gpio_setup[pin].gp_flags = flags; + + return (0); +} + +static int +lbggpio_pin_get(device_t dev, uint32_t pin, uint32_t *value) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (value == NULL) + return (EINVAL); + + if (pin >= sc->npins) + return (EINVAL); + + return (lbggpiocm_pin_get(device_get_parent(dev), dev, pin, value)); +} + +static int +lbggpio_pin_set(device_t dev, uint32_t pin, uint32_t value) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (pin >= sc->npins) + return (EINVAL); + + return (lbggpiocm_pin_set(device_get_parent(dev), dev, pin, value)); +} + +static int +lbggpio_pin_toggle(device_t dev, uint32_t pin) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + + if (pin >= sc->npins) + return (EINVAL); + + return (lbggpiocm_pin_toggle(device_get_parent(dev), dev, pin)); +} + +static int +lbggpio_probe(device_t dev) +{ + struct lbggpio_softc *sc = device_get_softc(dev); + /* X is a placeholder for the actual one letter group name. */ + static char desc[] = "LewisBurg GPIO Group X"; + + sc->npins = lbggpiocm_get_group_npins(device_get_parent(dev), dev); + sc->grpname = lbggpiocm_get_group_name(device_get_parent(dev), dev); + if (sc->npins <= 0) + return (ENXIO); + + desc[sizeof(desc)-2] = sc->grpname; + device_set_desc_copy(dev, desc); + return (BUS_PROBE_DEFAULT); +} + +static int +lbggpio_attach(device_t dev) +{ + uint32_t i; + struct lbggpio_softc *sc; + + sc = device_get_softc(dev); + /* GPIO config */ + for (i = 0; i < sc->npins; ++i) { + sc->gpio_setup[i].gp_pin = i; + snprintf(sc->gpio_setup[i].gp_name, + sizeof(sc->gpio_setup[i].gp_name), + "GPIO %c%u", sc->grpname, i); + sc->gpio_setup[i].gp_caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + } + + /* support gpio */ + sc->sc_busdev = gpiobus_attach_bus(dev); + if (sc->sc_busdev == NULL) + return (ENXIO); + + return (0); +} + +static int +lbggpio_detach(device_t dev) +{ + struct lbggpio_softc *sc; + + sc = device_get_softc(dev); + + if (sc->sc_busdev) + gpiobus_detach_bus(dev); + + return (0); +} + +static device_method_t lbggpio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, lbggpio_probe), + DEVMETHOD(device_attach, lbggpio_attach), + DEVMETHOD(device_detach, lbggpio_detach), + + /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, lbggpio_get_bus), + DEVMETHOD(gpio_pin_max, lbggpio_pin_max), + DEVMETHOD(gpio_pin_getcaps, lbggpio_pin_getcaps), + DEVMETHOD(gpio_pin_getflags, lbggpio_pin_getflags), + DEVMETHOD(gpio_pin_setflags, lbggpio_pin_setflags), + DEVMETHOD(gpio_pin_getname, lbggpio_pin_getname), + DEVMETHOD(gpio_pin_set, lbggpio_pin_set), + DEVMETHOD(gpio_pin_get, lbggpio_pin_get), + DEVMETHOD(gpio_pin_toggle, lbggpio_pin_toggle), + + DEVMETHOD_END +}; + +static driver_t lbggpio_driver = { + "gpio", + lbggpio_methods, + sizeof(struct lbggpio_softc) +}; + +static devclass_t lbggpio_devclass; + +DRIVER_MODULE(lbggpio, lbggpiocm, lbggpio_driver, lbggpio_devclass, NULL, NULL); +MODULE_DEPEND(lbggpio, gpiobus, 1, 1, 1); diff --git a/sys/dev/p2sb/lewisburg_gpiocm.c b/sys/dev/p2sb/lewisburg_gpiocm.c new file mode 100644 index 000000000000..4a046a50aed4 --- /dev/null +++ b/sys/dev/p2sb/lewisburg_gpiocm.c @@ -0,0 +1,351 @@ +/*- + * Copyright (c) 2018 Stormshield + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "gpio_if.h" + +#include "lewisburg_gpiocm.h" +#include "p2sb.h" + +#define PADBAR 0x00c + +#define PADCFG0_GPIORXDIS (1<<9) +#define PADCFG0_GPIOTXDIS (1<<8) +#define PADCFG0_GPIORXSTATE (1<<1) +#define PADCFG0_GPIOTXSTATE (1<<0) + +#define MAX_PAD_PER_GROUP 24 + +#define LBGGPIOCM_READ(sc, reg) p2sb_port_read_4(sc->p2sb, sc->port, reg) +#define LBGGPIOCM_WRITE(sc, reg, val) \ + p2sb_port_write_4(sc->p2sb, sc->port, reg, val) +#define LBGGPIOCM_LOCK(sc) p2sb_lock(sc->p2sb) +#define LBGGPIOCM_UNLOCK(sc) p2sb_unlock(sc->p2sb) + +struct lbggroup { + int groupid; + int npins; + int pins_off; + device_t dev; + char grpname; +}; + +struct lbgcommunity { + uint8_t npins; + const char *name; + uint32_t pad_off; + struct lbggroup groups[3]; + int ngroups; + const char *grpnames; +}; +#define LBG_COMMUNITY(n, np, g) \ +{ \ + .name = n, \ + .npins = np, \ + .grpnames = g, \ +} + +static struct lbgcommunity lbg_communities[] = { + LBG_COMMUNITY("LewisBurg GPIO Community 0", 72, "ABF"), + LBG_COMMUNITY("LewisBurg GPIO Community 1", 61, "CDE"), + LBG_COMMUNITY("LewisBurg GPIO Community 2", 0, ""), + LBG_COMMUNITY("LewisBurg GPIO Community 3", 12, "I"), + LBG_COMMUNITY("LewisBurg GPIO Community 4", 36, "JK"), + LBG_COMMUNITY("LewisBurg GPIO Community 5", 66, "GHL"), +}; + +struct lbggpiocm_softc +{ + int port; + device_t p2sb; + struct lbgcommunity *community; +}; + +static struct lbggroup *lbggpiocm_get_group(struct lbggpiocm_softc *sc, + device_t child); + +static __inline struct lbggroup * +lbggpiocm_get_group(struct lbggpiocm_softc *sc, device_t child) +{ + int i; + + for (i = 0; i < sc->community->ngroups; ++i) + if (sc->community->groups[i].dev == child) + return (&sc->community->groups[i]); + return (NULL); +} + + +static __inline uint32_t +lbggpiocm_getpad(struct lbggpiocm_softc *sc, uint32_t pin) +{ + + if (pin >= sc->community->npins) + return (0); + + return (sc->community->pad_off + 2 * 4 * pin); +} + +int +lbggpiocm_get_group_npins(device_t dev, device_t child) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + struct lbggroup *group; + + group = lbggpiocm_get_group(sc, child); + if (group != NULL) + return (group->npins); + return (-1); +} + +char +lbggpiocm_get_group_name(device_t dev, device_t child) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + struct lbggroup *group; + + group = lbggpiocm_get_group(sc, child); + if (group != NULL) + return (group->grpname); + return ('\0'); +} + +static int +lbggpiocm_pin2cpin(struct lbggpiocm_softc *sc, device_t child, uint32_t pin) +{ + struct lbggroup *group; + + group = lbggpiocm_get_group(sc, child); + if (group != NULL) + return (pin + group->pins_off); + return (-1); +} + +int +lbggpiocm_pin_setflags(device_t dev, device_t child, uint32_t pin, uint32_t flags) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, padval; + int rpin; + + if ((flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == + (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) + return (EINVAL); + + if ((flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == 0) + return (EINVAL); + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + padval = LBGGPIOCM_READ(sc, padreg); + + if (flags & GPIO_PIN_INPUT) { + padval &= ~PADCFG0_GPIORXDIS; + padval |= PADCFG0_GPIOTXDIS; + } else if (flags & GPIO_PIN_OUTPUT) { + padval &= ~PADCFG0_GPIOTXDIS; + padval |= PADCFG0_GPIORXDIS; + } + + LBGGPIOCM_WRITE(sc, padreg, padval); + LBGGPIOCM_UNLOCK(sc); + + return (0); +} + +int +lbggpiocm_pin_get(device_t dev, device_t child, uint32_t pin, uint32_t *value) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, val; + int rpin; + + if (value == NULL) + return (EINVAL); + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + val = LBGGPIOCM_READ(sc, padreg); + LBGGPIOCM_UNLOCK(sc); + + if (!(val & PADCFG0_GPIOTXDIS)) + *value = !!(val & PADCFG0_GPIOTXSTATE); + else + *value = !!(val & PADCFG0_GPIORXSTATE); + + return (0); +} + +int +lbggpiocm_pin_set(device_t dev, device_t child, uint32_t pin, uint32_t value) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, padcfg; + int rpin; + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + + padcfg = LBGGPIOCM_READ(sc, padreg); + if (value) + padcfg |= PADCFG0_GPIOTXSTATE; + else + padcfg &= ~PADCFG0_GPIOTXSTATE; + LBGGPIOCM_WRITE(sc, padreg, padcfg); + + LBGGPIOCM_UNLOCK(sc); + + return (0); +} + +int +lbggpiocm_pin_toggle(device_t dev, device_t child, uint32_t pin) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + uint32_t padreg, padcfg; + int rpin; + + rpin = lbggpiocm_pin2cpin(sc, child, pin); + if (rpin < 0) + return (EINVAL); + + padreg = lbggpiocm_getpad(sc, rpin); + + LBGGPIOCM_LOCK(sc); + padcfg = LBGGPIOCM_READ(sc, padreg); + padcfg ^= PADCFG0_GPIOTXSTATE; + LBGGPIOCM_WRITE(sc, padreg, padcfg); + + LBGGPIOCM_UNLOCK(sc); + + return (0); +} + +static int +lbggpiocm_probe(device_t dev) +{ + struct lbggpiocm_softc *sc = device_get_softc(dev); + int unit; + + sc->p2sb = device_get_parent(dev); + unit = device_get_unit(dev); + KASSERT(unit < nitems(lbg_communities), ("Wrong number of devices or communities")); + sc->port = p2sb_get_port(sc->p2sb, unit); + sc->community = &lbg_communities[unit]; + if (sc->port < 0) + return (ENXIO); + + device_set_desc(dev, sc->community->name); + return (BUS_PROBE_DEFAULT); +} + +static int +lbggpiocm_attach(device_t dev) +{ + uint32_t npins; + struct lbggpiocm_softc *sc; + struct lbggroup *group; + int i; + + sc = device_get_softc(dev); + if (sc->community->npins == 0) + return (ENXIO); + + LBGGPIOCM_LOCK(sc); + sc->community->pad_off = LBGGPIOCM_READ(sc, PADBAR); + LBGGPIOCM_UNLOCK(sc); + + npins = sc->community->npins; + for (i = 0; i < nitems(sc->community->groups) && npins > 0; ++i) { + group = &sc->community->groups[i]; + + group->groupid = i; + group->grpname = sc->community->grpnames[i]; + group->pins_off = i * MAX_PAD_PER_GROUP; + group->npins = npins < MAX_PAD_PER_GROUP ? npins : + MAX_PAD_PER_GROUP; + npins -= group->npins; + group->dev = device_add_child(dev, "gpio", -1); + } + sc->community->ngroups = i; + return (bus_generic_attach(dev)); +} + +static int +lbggpiocm_detach(device_t dev) +{ + int error; + + error = device_delete_children(dev); + if (error) + return (error); + + return (bus_generic_detach(dev)); +} + +static device_method_t lbggpiocm_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, lbggpiocm_probe), + DEVMETHOD(device_attach, lbggpiocm_attach), + DEVMETHOD(device_detach, lbggpiocm_detach), + + DEVMETHOD_END +}; + +static driver_t lbggpiocm_driver = { + "lbggpiocm", + lbggpiocm_methods, + sizeof(struct lbggpiocm_softc) +}; +static devclass_t lbggpiocm_devclass; +DRIVER_MODULE(lbggpiocm, p2sb, lbggpiocm_driver, lbggpiocm_devclass, NULL, NULL); diff --git a/sys/dev/p2sb/lewisburg_gpiocm.h b/sys/dev/p2sb/lewisburg_gpiocm.h new file mode 100644 index 000000000000..7fcbf919949b --- /dev/null +++ b/sys/dev/p2sb/lewisburg_gpiocm.h @@ -0,0 +1,12 @@ +#ifndef __LEWISBURG_GPIOCM_H__ +#define __LEWISBURG_GPIOCM_H__ + +int lbggpiocm_get_group_npins(device_t dev, device_t child); +char lbggpiocm_get_group_name(device_t dev, device_t child); + +int lbggpiocm_pin_setflags(device_t, device_t, uint32_t, uint32_t); +int lbggpiocm_pin_get(device_t, device_t, uint32_t, uint32_t *); +int lbggpiocm_pin_set(device_t, device_t, uint32_t, uint32_t); +int lbggpiocm_pin_toggle(device_t, device_t, uint32_t); + +#endif /* __LEWISBURG_GPIOCM_H__ */ diff --git a/sys/dev/p2sb/p2sb.c b/sys/dev/p2sb/p2sb.c new file mode 100644 index 000000000000..80836cbb2f59 --- /dev/null +++ b/sys/dev/p2sb/p2sb.c @@ -0,0 +1,215 @@ +/*- + * Copyright (c) 2018 Stormshield + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Implementation of Primary to Sideband bridge (P2SB), the documentation is available here : + * https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/c620-series-chipset-datasheet.pdf + * section 36.9 P2SB Bridge. + * This device exposes a 16MB memory block, this block is composed of 256 64KB blocks called ports. + * The indexes of this array (target port ID) can be found on the Table 36-10 of the documentation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "p2sb.h" + +#define PCI_PRODUCT_LEWISBURG_P2SB 0xa1a08086 + +#define P2SB_PORT2ADDRESS_SHIFT 16 +#define P2SB_PORT_ADDRESS(port) ((uint32_t)port << P2SB_PORT2ADDRESS_SHIFT) + +static const uint8_t lbg_communities[] = { + 0xAF, 0xAE, 0xAD, 0xAC, 0xAB, 0x11 +}; + +/* The softc holds our per-instance data. */ +struct p2sb_softc { + device_t dev; + int rid; + struct resource *res; + struct intel_community *communities; + int ncommunities; + struct mtx mutex; +}; + +int +p2sb_get_port(device_t dev, int unit) +{ + + if (unit >= nitems(lbg_communities)) + return (EINVAL); + return (lbg_communities[unit]); +} + +uint32_t +p2sb_port_read_4(device_t dev, uint8_t port, uint32_t reg) +{ + struct p2sb_softc *sc; + + KASSERT(reg < (1<res, P2SB_PORT_ADDRESS(port) + reg)); +} + +void +p2sb_port_write_4(device_t dev, uint8_t port, uint32_t reg, uint32_t val) +{ + struct p2sb_softc *sc; + + KASSERT(reg < (1<res, P2SB_PORT_ADDRESS(port) + reg, val); +} + +void +p2sb_lock(device_t dev) +{ + struct p2sb_softc *sc; + + sc = device_get_softc(dev); + mtx_lock_spin(&sc->mutex); +} + +void +p2sb_unlock(device_t dev) +{ + struct p2sb_softc *sc; + + sc = device_get_softc(dev); + mtx_unlock_spin(&sc->mutex); +} + + +static int +p2sb_probe(device_t dev) +{ + + if (pci_get_devid(dev) == PCI_PRODUCT_LEWISBURG_P2SB) { + device_set_desc(dev, "Lewisburg P2SB"); + return (BUS_PROBE_DEFAULT); + } + return (ENXIO); +} + +/* Attach function is only called if the probe is successful. */ + +static int +p2sb_attach(device_t dev) +{ + struct p2sb_softc *sc; + int i; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->rid = PCIR_BAR(0); + sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->rid, RF_ACTIVE); + if (sc->res == NULL) { + device_printf(dev, "Could not allocate memory.\n"); + return (ENXIO); + } + mtx_init(&sc->mutex, device_get_nameunit(dev), NULL, MTX_SPIN); + for (i = 0; i < nitems(lbg_communities); ++i) + device_add_child(dev, "lbggpiocm", i); + + return (bus_generic_attach(dev)); +} + +/* Detach device. */ + +static int +p2sb_detach(device_t dev) +{ + struct p2sb_softc *sc; + + /* Teardown the state in our softc created in our attach routine. */ + device_delete_children(dev); + sc = device_get_softc(dev); + mtx_destroy(&sc->mutex); + if (sc->res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, sc->rid, sc->res); + return (0); +} + +/* Called during system shutdown after sync. */ + +static int +p2sb_shutdown(device_t dev) +{ + + return (0); +} + +/* + * Device suspend routine. + */ +static int +p2sb_suspend(device_t dev) +{ + + return (0); +} + +/* + * Device resume routine. + */ +static int +p2sb_resume(device_t dev) +{ + + return (0); +} + +static device_method_t p2sb_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, p2sb_probe), + DEVMETHOD(device_attach, p2sb_attach), + DEVMETHOD(device_detach, p2sb_detach), + DEVMETHOD(device_shutdown, p2sb_shutdown), + DEVMETHOD(device_suspend, p2sb_suspend), + DEVMETHOD(device_resume, p2sb_resume), + + DEVMETHOD_END +}; + +static devclass_t p2sb_devclass; + +DEFINE_CLASS_0(p2sb, p2sb_driver, p2sb_methods, sizeof(struct p2sb_softc)); +DRIVER_MODULE(p2sb, pci, p2sb_driver, p2sb_devclass, 0, 0); diff --git a/sys/dev/p2sb/p2sb.h b/sys/dev/p2sb/p2sb.h new file mode 100644 index 000000000000..7c060a02fcf9 --- /dev/null +++ b/sys/dev/p2sb/p2sb.h @@ -0,0 +1,11 @@ +#ifndef __P2SB_H__ +#define __P2SB_H__ + +void p2sb_lock(device_t dev); +void p2sb_unlock(device_t dev); + +uint32_t p2sb_port_read_4(device_t dev, uint8_t port, uint32_t reg); +void p2sb_port_write_4(device_t dev, uint8_t port, uint32_t reg, uint32_t val); +int p2sb_get_port(device_t dev, int unit); + +#endif /* __P2SB_H__ */ diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 7ef3c5a477ce..585e2bdc80ca 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -358,6 +358,7 @@ SUBDIR= \ stge \ ${_sume} \ ${_superio} \ + ${_p2sb} \ ${_sym} \ ${_syscons} \ sysvipc \ @@ -662,6 +663,7 @@ _safe= safe _speaker= speaker _splash= splash _sppp= sppp +_p2sb= p2sb _wbwd= wbwd _aac= aac @@ -755,6 +757,7 @@ _sfxge= sfxge _sgx= sgx _sgx_linux= sgx_linux _smartpqi= smartpqi +_p2sb= p2sb .if ${MK_BHYVE} != "no" || defined(ALL_MODULES) .if ${KERN_OPTS:MSMP} diff --git a/sys/modules/p2sb/Makefile b/sys/modules/p2sb/Makefile new file mode 100644 index 000000000000..8f4d604f73d5 --- /dev/null +++ b/sys/modules/p2sb/Makefile @@ -0,0 +1,7 @@ +.PATH: ${.CURDIR}/../../dev/p2sb + +KMOD= p2sb +SRCS= p2sb.c lewisburg_gpio.c lewisburg_gpiocm.c +SRCS+= device_if.h bus_if.h pci_if.h gpio_if.h + +.include From owner-dev-commits-src-all@freebsd.org Thu Aug 26 09:24:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8D562665EB7; Thu, 26 Aug 2021 09:24: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 4GwHVB3GjZz3pXn; Thu, 26 Aug 2021 09:24: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 4E5D45450; Thu, 26 Aug 2021 09:24: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 17Q9OIf2064572; Thu, 26 Aug 2021 09:24:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9OIZu064571; Thu, 26 Aug 2021 09:24:18 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:24:18 GMT Message-Id: <202108260924.17Q9OIZu064571@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: cd46399b9ccf - main - pf tests: ALTQ priority test 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/main X-Git-Reftype: branch X-Git-Commit: cd46399b9ccf04f6ec00a532e52c8b1edb007af7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:24:18 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=cd46399b9ccf04f6ec00a532e52c8b1edb007af7 commit cd46399b9ccf04f6ec00a532e52c8b1edb007af7 Author: Kristof Provost AuthorDate: 2021-08-26 08:25:57 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 09:23:39 +0000 pf tests: ALTQ priority test Test that ALTQ can prioritise one type of traffic over another. Do this by establishing a slow link and saturating it with ICMP echos. When prioritised TCP connections reliably go through. When not prioritised TCP connections reliably fail. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/altq.sh | 94 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh index 53cf10e47565..ebb28f34c22e 100644 --- a/tests/sys/netpfil/pf/altq.sh +++ b/tests/sys/netpfil/pf/altq.sh @@ -145,10 +145,102 @@ cbq_vlan_cleanup() altq_cleanup } +atf_test_case "prioritise" "cleanup" +prioritise_head() +{ + atf_set descr "Test prioritising one type of traffic over the other" + atf_set require.user root +} + +prioritise_body() +{ + altq_init + is_altq_supported cbq + + epair=$(vnet_mkepair) + vnet_mkjail altq_prioritise ${epair}b + + ifconfig ${epair}a 192.0.2.1/24 up + jexec altq_prioritise ifconfig ${epair}b 192.0.2.2/24 up + + jexec altq_prioritise /usr/sbin/inetd -p inetd-altq.pid \ + $(atf_get_srcdir)/../pf/echo_inetd.conf + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec altq_prioritise pfctl -e + pft_set_rules altq_prioritise \ + "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \ + "queue default priority 7 cbq(default)" \ + "queue slow priority 1 cbq" \ + "match proto icmp queue slow" \ + "match proto tcp queue default" \ + "pass" + + # single ping succeeds just fine + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # Unsaturated TCP succeeds + reply=$(echo "foo" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" != "foo" ]; + then + atf_fail "Unsaturated echo failed" + fi + + # "Saturate the link" + ping -i .01 -c 50 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get these packet dropped. + rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }') + echo "Received $rcv packets" + if [ ${rcv} -gt 1 ] + then + atf_fail "Received ${rcv} packets in a saturated link" + fi + + # TCP should still pass + for i in `seq 1 10` + do + reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" != "foo_${i}" ]; + then + atf_fail "Prioritised echo failed ${i}" + fi + + done + + # Now reverse priority + pft_set_rules altq_prioritise \ + "altq on ${epair}b bandwidth 6000b cbq queue { default, slow }" \ + "queue default priority 7 cbq(default)" \ + "queue slow priority 1 cbq" \ + "match proto tcp queue slow" \ + "match proto icmp queue default" \ + "pass" + + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + ping -i .01 -c 50 -s 1200 192.0.2.2 + for i in `seq 1 10` + do + reply=$(echo "foo_${i}" | nc -w 5 -N 192.0.2.2 7) + if [ "$reply" == "foo_${i}" ]; + then + atf_fail "Unexpected echo success" + fi + + done +} + +prioritise_cleanup() +{ + altq_cleanup +} + atf_init_test_cases() { atf_add_test_case "hfsc" atf_add_test_case "match" atf_add_test_case "cbq_vlan" + atf_add_test_case "prioritise" } - From owner-dev-commits-src-all@freebsd.org Thu Aug 26 09:24:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6137665E5E; Thu, 26 Aug 2021 09:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwHVD4fzkz3pZt; Thu, 26 Aug 2021 09:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 870E95830; Thu, 26 Aug 2021 09:24:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q9OK1g064625; Thu, 26 Aug 2021 09:24:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9OKq2064624; Thu, 26 Aug 2021 09:24:20 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:24:20 GMT Message-Id: <202108260924.17Q9OKq2064624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 062463698eea - main - pf tests: Test ALTQ on top of if_bridge 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/main X-Git-Reftype: branch X-Git-Commit: 062463698eeafc7f75ce22541a244238f37ef2e2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:24:20 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=062463698eeafc7f75ce22541a244238f37ef2e2 commit 062463698eeafc7f75ce22541a244238f37ef2e2 Author: Kristof Provost AuthorDate: 2021-08-25 09:08:38 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 09:23:45 +0000 pf tests: Test ALTQ on top of if_bridge Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31676 --- tests/sys/netpfil/pf/altq.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh index ebb28f34c22e..2b5b1828595f 100644 --- a/tests/sys/netpfil/pf/altq.sh +++ b/tests/sys/netpfil/pf/altq.sh @@ -145,6 +145,54 @@ cbq_vlan_cleanup() altq_cleanup } +atf_test_case "codel_bridge" "cleanup" +codel_bridge_head() +{ + atf_set descr 'codel over if_bridge test' + atf_set require.user root +} + +codel_bridge_body() +{ + altq_init + is_altq_supported codel + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail altq_codel_bridge ${epair}b + + bridge=$(jexec altq_codel_bridge ifconfig bridge create) + jexec altq_codel_bridge ifconfig ${bridge} addm ${epair}b + jexec altq_codel_bridge ifconfig ${epair}b up + jexec altq_codel_bridge ifconfig ${bridge} 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2 + + jexec altq_codel_bridge pfctl -e + pft_set_rules altq_codel_bridge \ + "altq on ${bridge} bandwidth 1000b codelq queue { slow }" \ + "match queue slow" \ + "pass" + + # "Saturate the link" + ping -i .1 -c 5 -s 1200 192.0.2.2 + + # We should now be hitting the limits and get these packet dropped. + rcv=$(ping -i .1 -c 5 -s 1200 192.0.2.2 | tr "," "\n" | awk '/packets received/ { print $1; }') + echo "Received $rcv packets" + if [ ${rcv} -gt 1 ] + then + atf_fail "Received ${rcv} packets in a saturated link" + fi +} + +codel_bridge_cleanup() +{ + altq_cleanup +} + atf_test_case "prioritise" "cleanup" prioritise_head() { @@ -242,5 +290,6 @@ atf_init_test_cases() atf_add_test_case "hfsc" atf_add_test_case "match" atf_add_test_case "cbq_vlan" + atf_add_test_case "codel_bridge" atf_add_test_case "prioritise" } From owner-dev-commits-src-all@freebsd.org Thu Aug 26 09:24:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A2CDC665C43; Thu, 26 Aug 2021 09:24:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwHVC42Nqz3pd4; Thu, 26 Aug 2021 09:24:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6FB0056B2; Thu, 26 Aug 2021 09:24:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17Q9OJMP064596; Thu, 26 Aug 2021 09:24:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17Q9OJiB064595; Thu, 26 Aug 2021 09:24:19 GMT (envelope-from git) Date: Thu, 26 Aug 2021 09:24:19 GMT Message-Id: <202108260924.17Q9OJiB064595@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: eb680a63de1d - main - if_bridge: add ALTQ support 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/main X-Git-Reftype: branch X-Git-Commit: eb680a63de1dbf5c974f483975dcb2c60ec6fa08 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 09:24:19 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=eb680a63de1dbf5c974f483975dcb2c60ec6fa08 commit eb680a63de1dbf5c974f483975dcb2c60ec6fa08 Author: Luiz Otavio O Souza AuthorDate: 2021-08-25 09:07:44 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 09:23:44 +0000 if_bridge: add ALTQ support Similar to the recent addition of ALTQ support to if_vlan. Reviewed by: donner Obtained from: pfsense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31675 --- sys/net/if_bridge.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index adf1c9155ee1..703a76086c55 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -298,6 +298,10 @@ static void bridge_init(void *); static void bridge_dummynet(struct mbuf *, struct ifnet *); static void bridge_stop(struct ifnet *, int); static int bridge_transmit(struct ifnet *, struct mbuf *); +#ifdef ALTQ +static void bridge_altq_start(if_t); +static int bridge_altq_transmit(if_t, struct mbuf *); +#endif static void bridge_qflush(struct ifnet *); static struct mbuf *bridge_input(struct ifnet *, struct mbuf *); static int bridge_output(struct ifnet *, struct mbuf *, struct sockaddr *, @@ -726,7 +730,15 @@ bridge_clone_create(struct if_clone *ifc, int unit, caddr_t params) if_initname(ifp, bridge_name, unit); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bridge_ioctl; +#ifdef ALTQ + ifp->if_start = bridge_altq_start; + ifp->if_transmit = bridge_altq_transmit; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = 0; + IFQ_SET_READY(&ifp->if_snd); +#else ifp->if_transmit = bridge_transmit; +#endif ifp->if_qflush = bridge_qflush; ifp->if_init = bridge_init; ifp->if_type = IFT_BRIDGE; @@ -798,6 +810,9 @@ bridge_clone_destroy(struct ifnet *ifp) BRIDGE_LIST_UNLOCK(); bstp_detach(&sc->sc_stp); +#ifdef ALTQ + IFQ_PURGE(&ifp->if_snd); +#endif NET_EPOCH_EXIT(et); ether_ifdetach(ifp); @@ -2219,6 +2234,38 @@ bridge_transmit(struct ifnet *ifp, struct mbuf *m) return (error); } +#ifdef ALTQ +static void +bridge_altq_start(if_t ifp) +{ + struct ifaltq *ifq = &ifp->if_snd; + struct mbuf *m; + + IFQ_LOCK(ifq); + IFQ_DEQUEUE_NOLOCK(ifq, m); + while (m != NULL) { + bridge_transmit(ifp, m); + IFQ_DEQUEUE_NOLOCK(ifq, m); + } + IFQ_UNLOCK(ifq); +} + +static int +bridge_altq_transmit(if_t ifp, struct mbuf *m) +{ + int err; + + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_ENQUEUE(&ifp->if_snd, m, err); + if (err == 0) + bridge_altq_start(ifp); + } else + err = bridge_transmit(ifp, m); + + return (err); +} +#endif /* ALTQ */ + /* * The ifp->if_qflush entry point for if_bridge(4) is no-op. */ From owner-dev-commits-src-all@freebsd.org Thu Aug 26 10:05:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67CDD6668B1; Thu, 26 Aug 2021 10:05: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 4GwJPC29Ksz4XRX; Thu, 26 Aug 2021 10:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 328E06277; Thu, 26 Aug 2021 10:05: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 17QA53rF018815; Thu, 26 Aug 2021 10:05:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QA53dv018814; Thu, 26 Aug 2021 10:05:03 GMT (envelope-from git) Date: Thu, 26 Aug 2021 10:05:03 GMT Message-Id: <202108261005.17QA53dv018814@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 9da8235cc843 - main - ichwd: add Lewisburg Super SKUs, Cannon and Comet Lake support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9da8235cc843364bd2df7a4d6fcd8c1be7ca67c0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 10:05:03 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=9da8235cc843364bd2df7a4d6fcd8c1be7ca67c0 commit 9da8235cc843364bd2df7a4d6fcd8c1be7ca67c0 Author: Paweł Anikiel AuthorDate: 2021-07-30 08:57:28 +0000 Commit: Wojciech Macek CommitDate: 2021-08-26 10:04:28 +0000 ichwd: add Lewisburg Super SKUs, Cannon and Comet Lake support Cannon and Comet Lake PCHs have their PMC hidden, so when reading the ACPI Base Address fails, we assume a default value. Obtained from: Semihalf Sponsored by: Stormshield --- sys/dev/ichwd/ichwd.c | 27 ++++++++++++++++++++------- sys/dev/ichwd/ichwd.h | 14 ++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/sys/dev/ichwd/ichwd.c b/sys/dev/ichwd/ichwd.c index 587f99f9e7ee..5aab4af0a1f7 100644 --- a/sys/dev/ichwd/ichwd.c +++ b/sys/dev/ichwd/ichwd.c @@ -296,6 +296,9 @@ static struct ichwd_device ichwd_devices[] = { static struct ichwd_device ichwd_smb_devices[] = { { DEVICEID_LEWISBURG_SMB, "Lewisburg watchdog timer", 10, 4 }, + { DEVICEID_LEWISBURG_SMB_SSKU, "Lewisburg watchdog timer", 10, 4 }, + { DEVICEID_CANNON_SMB, "Cannon Lake watchdog timer", 10, 4, PMC_HIDDEN}, + { DEVICEID_COMET_SMB, "Comet Lake watchdog timer", 10, 4, PMC_HIDDEN}, { DEVICEID_SRPTLP_SMB, "Sunrise Point-LP watchdog timer", 10, 4 }, { DEVICEID_C3000, "Intel Atom C3000 watchdog timer", 10, 4 }, { 0, NULL, 0, 0 }, @@ -788,13 +791,23 @@ ichwd_smb_attach(device_t dev) isab = device_get_parent(device_get_parent(dev)); pmdev = pci_find_dbsf(pci_get_domain(isab), pci_get_bus(isab), 31, 2); if (pmdev == NULL) { - device_printf(dev, "unable to find Power Management device\n"); - return (ENXIO); - } - acpi_base = pci_read_config(pmdev, ICH_PMBASE, 4) & 0xffffff00; - if (acpi_base == 0) { - device_printf(dev, "ACPI base address is not set\n"); - return (ENXIO); + if (id_p->quirks & PMC_HIDDEN) { + /* + * Since the PMC is hidden, we take the default value for the + * given device, which happens to be the same for the ones we + * support. + */ + acpi_base = ACPI_DEFAULT_CANNON; + } else { + device_printf(dev, "unable to find Power Management device\n"); + return (ENXIO); + } + } else { + acpi_base = pci_read_config(pmdev, ICH_PMBASE, 4) & 0xffffff00; + if (acpi_base == 0) { + device_printf(dev, "ACPI base address is not set\n"); + return (ENXIO); + } } /* Allocate SMI control I/O register space. */ diff --git a/sys/dev/ichwd/ichwd.h b/sys/dev/ichwd/ichwd.h index f78485249871..4a15d5201a4b 100644 --- a/sys/dev/ichwd/ichwd.h +++ b/sys/dev/ichwd/ichwd.h @@ -38,6 +38,7 @@ struct ichwd_device { char *desc; unsigned int ich_version; unsigned int tco_version; + uint32_t quirks; }; struct ichwd_softc { @@ -277,6 +278,9 @@ struct ichwd_softc { #define DEVICEID_WCPT_LP7 0x9cc7 #define DEVICEID_WCPT_LP9 0x9cc9 #define DEVICEID_LEWISBURG_SMB 0xa1a3 +#define DEVICEID_LEWISBURG_SMB_SSKU 0xa223 +#define DEVICEID_CANNON_SMB 0xa323 +#define DEVICEID_COMET_SMB 0x06a3 #define DEVICEID_SRPTLP_SMB 0x9d23 /* ICH LPC Interface Bridge Registers (ICH5 and older) */ @@ -386,6 +390,9 @@ struct ichwd_softc { #define TCO_INTRD_SEL_INTR 0x0001 #define TCO_INTRD_SEL_SMI 0x0002 +/* default ACPI Base values */ +#define ACPI_DEFAULT_CANNON 0x1800 + /* * Masks for the TCO timer value field in TCO_RLD. * If the datasheets are to be believed, the minimum value actually varies @@ -408,4 +415,11 @@ struct ichwd_softc { */ #define ICHWD_TCO_V3_TICK 1000000000 +/* + * Quirks + */ + +/* On Cannon Lake and Commet Lake PHCs, the PMC is hidden */ +#define PMC_HIDDEN (1 << 0) + #endif From owner-dev-commits-src-all@freebsd.org Thu Aug 26 10:56:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 51D7F66749E; Thu, 26 Aug 2021 10:56: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 4GwKXd1bHfz4mdY; Thu, 26 Aug 2021 10:56: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 10D4E6D8F; Thu, 26 Aug 2021 10:56: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 17QAuWck085362; Thu, 26 Aug 2021 10:56:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QAuWPS085361; Thu, 26 Aug 2021 10:56:32 GMT (envelope-from git) Date: Thu, 26 Aug 2021 10:56:32 GMT Message-Id: <202108261056.17QAuWPS085361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: da3a09d8941d - main - ipfw_nat64: fix direct output mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da3a09d8941dc29f20447e263b3a6d60370c6203 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 10:56:33 -0000 The branch main has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=da3a09d8941dc29f20447e263b3a6d60370c6203 commit da3a09d8941dc29f20447e263b3a6d60370c6203 Author: Andrey V. Elsukov AuthorDate: 2021-08-26 10:48:23 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-08-26 10:48:23 +0000 ipfw_nat64: fix direct output mode In nat64_find_route[46] handle NHF_GATEWAY flag and use destination address from next hop to do link layer address lookup. PR: 255928 Reviewed by: melifaro Obtained from: Yandex LLC MFC after: 1 week Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D31680 --- sys/netpfil/ipfw/nat64/nat64_translate.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/sys/netpfil/ipfw/nat64/nat64_translate.c b/sys/netpfil/ipfw/nat64/nat64_translate.c index 29666a7d3a9a..aa6f47656d9d 100644 --- a/sys/netpfil/ipfw/nat64/nat64_translate.c +++ b/sys/netpfil/ipfw/nat64/nat64_translate.c @@ -622,27 +622,22 @@ static struct nhop_object * nat64_find_route6(struct sockaddr_in6 *dst, struct mbuf *m) { struct nhop_object *nh; + NET_EPOCH_ASSERT(); - nh = fib6_lookup(M_GETFIB(m), &dst->sin6_addr, 0, 0, 0); + nh = fib6_lookup(M_GETFIB(m), &dst->sin6_addr, 0, NHR_NONE, 0); if (nh == NULL) - return NULL; + return (NULL); if (nh->nh_flags & (NHF_BLACKHOLE | NHF_REJECT)) - return NULL; - /* - * XXX: we need to use destination address with embedded scope - * zone id, because LLTABLE uses such form of addresses for lookup. - */ + return (NULL); + dst->sin6_family = AF_INET6; dst->sin6_len = sizeof(*dst); - dst->sin6_addr = ifatoia6(nh->nh_ifa)->ia_addr.sin6_addr; - if (IN6_IS_SCOPE_LINKLOCAL(&dst->sin6_addr)) - dst->sin6_addr.s6_addr16[1] = - htons(nh->nh_ifp->if_index & 0xffff); + if (nh->nh_flags & NHF_GATEWAY) + dst->sin6_addr = nh->gw6_sa.sin6_addr; dst->sin6_port = 0; dst->sin6_scope_id = 0; dst->sin6_flowinfo = 0; - - return nh; + return (nh); } #define NAT64_ICMP6_PLEN 64 @@ -776,17 +771,18 @@ nat64_find_route4(struct sockaddr_in *dst, struct mbuf *m) struct nhop_object *nh; NET_EPOCH_ASSERT(); - nh = fib4_lookup(M_GETFIB(m), dst->sin_addr, 0, 0, 0); + nh = fib4_lookup(M_GETFIB(m), dst->sin_addr, 0, NHR_NONE, 0); if (nh == NULL) - return NULL; + return (NULL); if (nh->nh_flags & (NHF_BLACKHOLE | NHF_BROADCAST | NHF_REJECT)) - return NULL; + return (NULL); dst->sin_family = AF_INET; dst->sin_len = sizeof(*dst); - dst->sin_addr = IA_SIN(nh->nh_ifa)->sin_addr; + if (nh->nh_flags & NHF_GATEWAY) + dst->sin_addr = nh->gw4_sa.sin_addr; dst->sin_port = 0; - return nh; + return (nh); } #define NAT64_ICMP_PLEN 64 From owner-dev-commits-src-all@freebsd.org Thu Aug 26 11:38:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6E75667BD9; Thu, 26 Aug 2021 11:38: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 4GwLTC5yC6z3Dfh; Thu, 26 Aug 2021 11:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B485D7346; Thu, 26 Aug 2021 11:38: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 17QBcd2I039941; Thu, 26 Aug 2021 11:38:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QBcdXr039940; Thu, 26 Aug 2021 11:38:39 GMT (envelope-from git) Date: Thu, 26 Aug 2021 11:38:39 GMT Message-Id: <202108261138.17QBcdXr039940@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 7b2561b46be6 - main - vfs: stop open-coding vfs_getvfs in kern_unmount MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7b2561b46be609deedeaacb7ccb35b5bc70d77ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 11:38:40 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7b2561b46be609deedeaacb7ccb35b5bc70d77ad commit 7b2561b46be609deedeaacb7ccb35b5bc70d77ad Author: Mateusz Guzik AuthorDate: 2021-08-26 08:29:47 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-26 11:38:31 +0000 vfs: stop open-coding vfs_getvfs in kern_unmount Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_mount.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 6804f6eb68bf..2d955fc4889f 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1589,7 +1589,8 @@ kern_unmount(struct thread *td, const char *path, int flags) struct nameidata nd; struct mount *mp; char *pathbuf; - int error, id0, id1; + fsid_t fsid; + int error; AUDIT_ARG_VALUE(flags); if (jailed(td->td_ucred) || usermount == 0) { @@ -1607,20 +1608,12 @@ kern_unmount(struct thread *td, const char *path, int flags) if (flags & MNT_BYFSID) { AUDIT_ARG_TEXT(pathbuf); /* Decode the filesystem ID. */ - if (sscanf(pathbuf, "FSID:%d:%d", &id0, &id1) != 2) { + if (sscanf(pathbuf, "FSID:%d:%d", &fsid.val[0], &fsid.val[1]) != 2) { free(pathbuf, M_TEMP); return (EINVAL); } - mtx_lock(&mountlist_mtx); - TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) { - if (mp->mnt_stat.f_fsid.val[0] == id0 && - mp->mnt_stat.f_fsid.val[1] == id1) { - vfs_ref(mp); - break; - } - } - mtx_unlock(&mountlist_mtx); + mp = vfs_getvfs(&fsid); } else { /* * Try to find global path for path argument. From owner-dev-commits-src-all@freebsd.org Thu Aug 26 11:46:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45F2C668309; Thu, 26 Aug 2021 11:46: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 4GwLfP0lmvz3GgF; Thu, 26 Aug 2021 11:46: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 F3DE976E3; Thu, 26 Aug 2021 11:46: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 17QBkaZG053850; Thu, 26 Aug 2021 11:46:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QBkaHA053849; Thu, 26 Aug 2021 11:46:36 GMT (envelope-from git) Date: Thu, 26 Aug 2021 11:46:36 GMT Message-Id: <202108261146.17QBkaHA053849@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: 3bcf919c4e89 - stable/13 - dhclient: skip_to_semi() consumes semicolon already 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: 3bcf919c4e891287038150116ee81054a46b0075 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 11:46:37 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3bcf919c4e891287038150116ee81054a46b0075 commit 3bcf919c4e891287038150116ee81054a46b0075 Author: Franco Fichtner AuthorDate: 2021-08-19 13:11:38 +0000 Commit: Mark Johnston CommitDate: 2021-08-26 11:46:01 +0000 dhclient: skip_to_semi() consumes semicolon already When invalid statement is found the next statement is skipped even if it is valid. Reviewed by: markj (cherry picked from commit a313b5240a477e0d04294ffd170408d954181daa) --- sbin/dhclient/clparse.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 58ece525f8d1..c7b02a073aa3 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -199,7 +199,6 @@ void parse_client_statement(FILE *cfile, struct interface_info *ip, struct client_config *config) { - int token; char *val; struct option *option; time_t tmp; @@ -290,15 +289,11 @@ parse_client_statement(FILE *cfile, struct interface_info *ip, parse_reject_statement(cfile, config); return; default: - parse_warn("expecting a statement."); - skip_to_semi(cfile); break; } - token = next_token(&val, cfile); - if (token != SEMI) { - parse_warn("semicolon expected."); - skip_to_semi(cfile); - } + + parse_warn("expecting a statement."); + skip_to_semi(cfile); } unsigned @@ -637,7 +632,7 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, if (token != STRING) { parse_warn("expecting interface name (in quotes)."); skip_to_semi(cfile); - break; + return; } ip = interface_or_dummy(val); *ipp = ip; @@ -674,7 +669,7 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, default: parse_warn("expecting lease declaration."); skip_to_semi(cfile); - break; + return; } token = next_token(&val, cfile); if (token != SEMI) { From owner-dev-commits-src-all@freebsd.org Thu Aug 26 11:46:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C2DE6680ED; Thu, 26 Aug 2021 11:46: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 4GwLfQ1dzvz3Gb7; Thu, 26 Aug 2021 11:46: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 206207451; Thu, 26 Aug 2021 11:46: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 17QBkcG5053874; Thu, 26 Aug 2021 11:46:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QBkc1b053873; Thu, 26 Aug 2021 11:46:38 GMT (envelope-from git) Date: Thu, 26 Aug 2021 11:46:38 GMT Message-Id: <202108261146.17QBkc1b053873@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: 75df39760ce0 - stable/13 - dhclient: remove patching of static values in BPF programs 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: 75df39760ce01d5c22292a24b921820a257776ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 11:46:38 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=75df39760ce01d5c22292a24b921820a257776ea commit 75df39760ce01d5c22292a24b921820a257776ea Author: Franco Fichtner AuthorDate: 2021-08-19 13:08:59 +0000 Commit: Mark Johnston CommitDate: 2021-08-26 11:46:11 +0000 dhclient: remove patching of static values in BPF programs Reviewed by: markj (cherry picked from commit 5851803f4bcab48bddfe1600bda3906c4f83fad5) --- sbin/dhclient/bpf.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c index a50abca62fd3..41eb4f402e66 100644 --- a/sbin/dhclient/bpf.c +++ b/sbin/dhclient/bpf.c @@ -105,7 +105,7 @@ if_register_bpf(struct interface_info *info, int flags) * Packet write filter program: * 'ip and udp and src port bootps and dst port (bootps or bootpc)' */ -static struct bpf_insn dhcp_bpf_wfilter[] = { +static const struct bpf_insn dhcp_bpf_wfilter[] = { BPF_STMT(BPF_LD + BPF_B + BPF_IND, 14), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, (IPVERSION << 4) + 5, 0, 12), @@ -119,18 +119,18 @@ static struct bpf_insn dhcp_bpf_wfilter[] = { /* Make sure this isn't a fragment... */ BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20), - BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 6, 0), /* patched */ + BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, IP_MF|IP_OFFMASK, 6, 0), /* Get the IP header length... */ BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 14), /* Make sure it's from the right port... */ BPF_STMT(BPF_LD + BPF_H + BPF_IND, 14), - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 68, 0, 3), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, LOCAL_PORT, 0, 3), /* Make sure it is to the right ports ... */ BPF_STMT(BPF_LD + BPF_H + BPF_IND, 16), - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, REMOTE_PORT, 0, 1), /* If we passed all the tests, ask for the whole packet. */ BPF_STMT(BPF_RET+BPF_K, (u_int)-1), @@ -139,8 +139,6 @@ static struct bpf_insn dhcp_bpf_wfilter[] = { BPF_STMT(BPF_RET+BPF_K, 0), }; -static int dhcp_bpf_wfilter_len = nitems(dhcp_bpf_wfilter); - void if_register_send(struct interface_info *info) { @@ -161,11 +159,8 @@ if_register_send(struct interface_info *info) error("Kernel BPF version out of range - recompile dhcpd!"); /* Set up the bpf write filter program structure. */ - p.bf_len = dhcp_bpf_wfilter_len; - p.bf_insns = dhcp_bpf_wfilter; - - if (dhcp_bpf_wfilter[7].k == 0x1fff) - dhcp_bpf_wfilter[7].k = htons(IP_MF|IP_OFFMASK); + p.bf_insns = __DECONST(struct bpf_insn *, dhcp_bpf_wfilter); + p.bf_len = nitems(dhcp_bpf_wfilter); if (ioctl(info->wfdesc, BIOCSETWF, &p) < 0) error("Can't install write filter program: %m"); @@ -190,11 +185,8 @@ if_register_send(struct interface_info *info) /* * Packet filter program... - * - * XXX: Changes to the filter program may require changes to the - * constant offsets used in if_register_send to patch the BPF program! */ -static struct bpf_insn dhcp_bpf_filter[] = { +static const struct bpf_insn dhcp_bpf_filter[] = { /* Make sure this is an IP packet... */ BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8), @@ -205,14 +197,14 @@ static struct bpf_insn dhcp_bpf_filter[] = { /* Make sure this isn't a fragment... */ BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20), - BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0), + BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, IP_MF|IP_OFFMASK, 4, 0), /* Get the IP header length... */ BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 14), /* Make sure it's to the right port... */ BPF_STMT(BPF_LD + BPF_H + BPF_IND, 16), - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), /* patch */ + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, LOCAL_PORT, 0, 1), /* If we passed all the tests, ask for the whole packet. */ BPF_STMT(BPF_RET+BPF_K, (u_int)-1), @@ -221,8 +213,6 @@ static struct bpf_insn dhcp_bpf_filter[] = { BPF_STMT(BPF_RET+BPF_K, 0), }; -static int dhcp_bpf_filter_len = nitems(dhcp_bpf_filter); - void if_register_receive(struct interface_info *info) { @@ -263,15 +253,8 @@ if_register_receive(struct interface_info *info) info->rbuf_len = 0; /* Set up the bpf filter program structure. */ - p.bf_len = dhcp_bpf_filter_len; - p.bf_insns = dhcp_bpf_filter; - - /* Patch the server port into the BPF program... - * - * XXX: changes to filter program may require changes to the - * insn number(s) used below! - */ - dhcp_bpf_filter[8].k = LOCAL_PORT; + p.bf_insns = __DECONST(struct bpf_insn *, dhcp_bpf_filter); + p.bf_len = nitems(dhcp_bpf_filter); if (ioctl(info->rfdesc, BIOCSETF, &p) < 0) error("Can't install packet filter program: %m"); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 12:02:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E21D668D25; Thu, 26 Aug 2021 12:02: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 4GwM1646Pkz3MZJ; Thu, 26 Aug 2021 12:02: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 6AFFA7C16; Thu, 26 Aug 2021 12:02: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 17QC2oEp080407; Thu, 26 Aug 2021 12:02:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC2oHH080406; Thu, 26 Aug 2021 12:02:50 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:02:50 GMT Message-Id: <202108261202.17QC2oHH080406@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 0d28d014c855 - main - vfs: refactor kern_unmount MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0d28d014c8552520879d3c4f75b3e89dd116eaa5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:02:50 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=0d28d014c8552520879d3c4f75b3e89dd116eaa5 commit 0d28d014c8552520879d3c4f75b3e89dd116eaa5 Author: Mateusz Guzik AuthorDate: 2021-08-26 11:49:41 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-26 11:58:28 +0000 vfs: refactor kern_unmount Split unmounting by path and id in preparation for other changes. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_mount.c | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 2d955fc4889f..40581d9e6e79 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1588,7 +1588,7 @@ kern_unmount(struct thread *td, const char *path, int flags) { struct nameidata nd; struct mount *mp; - char *pathbuf; + char *fsidbuf, *pathbuf; fsid_t fsid; int error; @@ -1599,22 +1599,34 @@ kern_unmount(struct thread *td, const char *path, int flags) return (error); } - pathbuf = malloc(MNAMELEN, M_TEMP, M_WAITOK); - error = copyinstr(path, pathbuf, MNAMELEN, NULL); - if (error) { - free(pathbuf, M_TEMP); - return (error); - } if (flags & MNT_BYFSID) { - AUDIT_ARG_TEXT(pathbuf); + fsidbuf = malloc(MNAMELEN, M_TEMP, M_WAITOK); + error = copyinstr(path, fsidbuf, MNAMELEN, NULL); + if (error) { + free(fsidbuf, M_TEMP); + return (error); + } + + AUDIT_ARG_TEXT(fsidbuf); /* Decode the filesystem ID. */ - if (sscanf(pathbuf, "FSID:%d:%d", &fsid.val[0], &fsid.val[1]) != 2) { - free(pathbuf, M_TEMP); + if (sscanf(fsidbuf, "FSID:%d:%d", &fsid.val[0], &fsid.val[1]) != 2) { + free(fsidbuf, M_TEMP); return (EINVAL); } mp = vfs_getvfs(&fsid); + free(fsidbuf, M_TEMP); + if (mp == NULL) { + return (ENOENT); + } } else { + pathbuf = malloc(MNAMELEN, M_TEMP, M_WAITOK); + error = copyinstr(path, pathbuf, MNAMELEN, NULL); + if (error) { + free(pathbuf, M_TEMP); + return (error); + } + /* * Try to find global path for path argument. */ @@ -1635,16 +1647,16 @@ kern_unmount(struct thread *td, const char *path, int flags) } } mtx_unlock(&mountlist_mtx); - } - free(pathbuf, M_TEMP); - if (mp == NULL) { - /* - * Previously we returned ENOENT for a nonexistent path and - * EINVAL for a non-mountpoint. We cannot tell these apart - * now, so in the !MNT_BYFSID case return the more likely - * EINVAL for compatibility. - */ - return ((flags & MNT_BYFSID) ? ENOENT : EINVAL); + free(pathbuf, M_TEMP); + if (mp == NULL) { + /* + * Previously we returned ENOENT for a nonexistent path and + * EINVAL for a non-mountpoint. We cannot tell these apart + * now, so in the !MNT_BYFSID case return the more likely + * EINVAL for compatibility. + */ + return (EINVAL); + } } /* From owner-dev-commits-src-all@freebsd.org Thu Aug 26 12:06:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B60596689AB; Thu, 26 Aug 2021 12:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwM5M4mj0z3N6s; Thu, 26 Aug 2021 12:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8882C7943; Thu, 26 Aug 2021 12:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17QC6VoU080926; Thu, 26 Aug 2021 12:06:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC6VHk080925; Thu, 26 Aug 2021 12:06:31 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:06:31 GMT Message-Id: <202108261206.17QC6VHk080925@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: 09e25aff543c - stable/13 - ipfw: use unsigned int for dummynet bandwidth 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: 09e25aff543c37bf912fb09f61d139a54f2d55a5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:06:31 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=09e25aff543c37bf912fb09f61d139a54f2d55a5 commit 09e25aff543c37bf912fb09f61d139a54f2d55a5 Author: Luiz Otavio O Souza AuthorDate: 2021-08-17 07:54:40 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 12:05:26 +0000 ipfw: use unsigned int for dummynet bandwidth This allows the maximum value of 4294967295 (~4Gb/s) instead of previous value of 2147483647 (~2Gb/s). Reviewed by: np, scottl Obtained from: pfSense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31582 (cherry picked from commit 20ffd88ed54fe3fd098ac30bd221275b2a14f52c) --- sbin/ipfw/dummynet.c | 13 +++++++------ sys/netinet/ip_dummynet.h | 4 ++-- sys/netpfil/ipfw/ip_dn_glue.c | 4 ++-- sys/netpfil/ipfw/ip_dn_io.c | 3 ++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sbin/ipfw/dummynet.c b/sbin/ipfw/dummynet.c index 24d835fbb98e..88367694a404 100644 --- a/sbin/ipfw/dummynet.c +++ b/sbin/ipfw/dummynet.c @@ -23,6 +23,7 @@ */ #define NEW_AQM +#include #include #include /* XXX there are several sysctl leftover here */ @@ -794,9 +795,9 @@ is_valid_number(const char *s) * set clocking interface or bandwidth value */ static void -read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) +read_bandwidth(char *arg, uint32_t *bandwidth, char *if_name, int namelen) { - if (*bandwidth != -1) + if (*bandwidth != (uint32_t)-1) warnx("duplicate token, override bandwidth value!"); if (arg[0] >= 'a' && arg[0] <= 'z') { @@ -810,7 +811,7 @@ read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) strlcpy(if_name, arg, namelen); *bandwidth = 0; } else { /* read bandwidth value */ - int bw; + uint64_t bw; char *end = NULL; bw = strtoul(arg, &end, 0); @@ -829,10 +830,10 @@ read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) _substrcmp2(end, "by", "bytes") == 0) bw *= 8; - if (bw < 0) + if (bw > UINT_MAX) errx(EX_DATAERR, "bandwidth too large"); - *bandwidth = bw; + *bandwidth = (uint32_t)bw; if (if_name) if_name[0] = '\0'; } @@ -1737,7 +1738,7 @@ end_mask: if (p) { if (p->delay > 10000) errx(EX_DATAERR, "delay must be < 10000"); - if (p->bandwidth == -1) + if (p->bandwidth == (uint32_t)-1) p->bandwidth = 0; } if (fs) { diff --git a/sys/netinet/ip_dummynet.h b/sys/netinet/ip_dummynet.h index de38ed9fbedf..533dc5ccd85f 100644 --- a/sys/netinet/ip_dummynet.h +++ b/sys/netinet/ip_dummynet.h @@ -131,7 +131,7 @@ struct dn_link { * XXX what about burst ? */ int32_t link_nr; - int bandwidth; /* bit/s or bits/tick. */ + uint32_t bandwidth; /* bit/s or bits/tick. */ int delay; /* ms and ticks */ uint64_t burst; /* scaled. bits*Hz XXX */ }; @@ -214,7 +214,7 @@ struct dn_profile { char name[ED_MAX_NAME_LEN]; int link_nr; int loss_level; - int bandwidth; // XXX use link bandwidth? + uint32_t bandwidth; // XXX use link bandwidth? int samples_no; /* actual len of samples[] */ int samples[ED_MAX_SAMPLES_NO]; /* may be shorter */ }; diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c index e035fedaaf91..a690aa0290d7 100644 --- a/sys/netpfil/ipfw/ip_dn_glue.c +++ b/sys/netpfil/ipfw/ip_dn_glue.c @@ -166,7 +166,7 @@ struct dn_pipe7 { /* a pipe */ SLIST_ENTRY(dn_pipe7) next; /* linked list in a hash slot */ int pipe_nr ; /* number */ - int bandwidth; /* really, bytes/tick. */ + uint32_t bandwidth; /* really, bytes/tick. */ int delay ; /* really, ticks */ struct mbuf *head, *tail ; /* packets in delay line */ @@ -231,7 +231,7 @@ struct dn_pipe8 { /* a pipe */ SLIST_ENTRY(dn_pipe8) next; /* linked list in a hash slot */ int pipe_nr ; /* number */ - int bandwidth; /* really, bytes/tick. */ + uint32_t bandwidth; /* really, bytes/tick. */ int delay ; /* really, ticks */ struct mbuf *head, *tail ; /* packets in delay line */ diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 11357b44e05e..dad5cb087b39 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -591,7 +591,8 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) struct dn_schk *s = si->sched; struct mbuf *m = NULL; int delay_line_idle = (si->dline.mq.head == NULL); - int done, bw; + int done; + uint32_t bw; if (q == NULL) { q = &def_q; From owner-dev-commits-src-all@freebsd.org Thu Aug 26 12:06:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 170D4668CC5; Thu, 26 Aug 2021 12:06: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 4GwM5N6zW0z3N77; Thu, 26 Aug 2021 12:06: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 C6B6A7661; Thu, 26 Aug 2021 12:06: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 17QC6WZt081037; Thu, 26 Aug 2021 12:06:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC6Waw081036; Thu, 26 Aug 2021 12:06:32 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:06:32 GMT Message-Id: <202108261206.17QC6Waw081036@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: 217e75db75d4 - stable/12 - ipfw: use unsigned int for dummynet bandwidth 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: 217e75db75d4646f73b078d898d3ce7366dad77a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:06:33 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=217e75db75d4646f73b078d898d3ce7366dad77a commit 217e75db75d4646f73b078d898d3ce7366dad77a Author: Luiz Otavio O Souza AuthorDate: 2021-08-17 07:54:40 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 07:26:45 +0000 ipfw: use unsigned int for dummynet bandwidth This allows the maximum value of 4294967295 (~4Gb/s) instead of previous value of 2147483647 (~2Gb/s). Reviewed by: np, scottl Obtained from: pfSense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31582 (cherry picked from commit 20ffd88ed54fe3fd098ac30bd221275b2a14f52c) --- sbin/ipfw/dummynet.c | 13 +++++++------ sys/netinet/ip_dummynet.h | 4 ++-- sys/netpfil/ipfw/ip_dn_glue.c | 4 ++-- sys/netpfil/ipfw/ip_dn_io.c | 3 ++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sbin/ipfw/dummynet.c b/sbin/ipfw/dummynet.c index 24d835fbb98e..88367694a404 100644 --- a/sbin/ipfw/dummynet.c +++ b/sbin/ipfw/dummynet.c @@ -23,6 +23,7 @@ */ #define NEW_AQM +#include #include #include /* XXX there are several sysctl leftover here */ @@ -794,9 +795,9 @@ is_valid_number(const char *s) * set clocking interface or bandwidth value */ static void -read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) +read_bandwidth(char *arg, uint32_t *bandwidth, char *if_name, int namelen) { - if (*bandwidth != -1) + if (*bandwidth != (uint32_t)-1) warnx("duplicate token, override bandwidth value!"); if (arg[0] >= 'a' && arg[0] <= 'z') { @@ -810,7 +811,7 @@ read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) strlcpy(if_name, arg, namelen); *bandwidth = 0; } else { /* read bandwidth value */ - int bw; + uint64_t bw; char *end = NULL; bw = strtoul(arg, &end, 0); @@ -829,10 +830,10 @@ read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen) _substrcmp2(end, "by", "bytes") == 0) bw *= 8; - if (bw < 0) + if (bw > UINT_MAX) errx(EX_DATAERR, "bandwidth too large"); - *bandwidth = bw; + *bandwidth = (uint32_t)bw; if (if_name) if_name[0] = '\0'; } @@ -1737,7 +1738,7 @@ end_mask: if (p) { if (p->delay > 10000) errx(EX_DATAERR, "delay must be < 10000"); - if (p->bandwidth == -1) + if (p->bandwidth == (uint32_t)-1) p->bandwidth = 0; } if (fs) { diff --git a/sys/netinet/ip_dummynet.h b/sys/netinet/ip_dummynet.h index 9d64b3e9e8b5..8d25592842c5 100644 --- a/sys/netinet/ip_dummynet.h +++ b/sys/netinet/ip_dummynet.h @@ -131,7 +131,7 @@ struct dn_link { * XXX what about burst ? */ int32_t link_nr; - int bandwidth; /* bit/s or bits/tick. */ + uint32_t bandwidth; /* bit/s or bits/tick. */ int delay; /* ms and ticks */ uint64_t burst; /* scaled. bits*Hz XXX */ }; @@ -216,7 +216,7 @@ struct dn_profile { char name[ED_MAX_NAME_LEN]; int link_nr; int loss_level; - int bandwidth; // XXX use link bandwidth? + uint32_t bandwidth; // XXX use link bandwidth? int samples_no; /* actual len of samples[] */ int samples[ED_MAX_SAMPLES_NO]; /* may be shorter */ }; diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c index cfea43110c9e..1bb3c1efbf07 100644 --- a/sys/netpfil/ipfw/ip_dn_glue.c +++ b/sys/netpfil/ipfw/ip_dn_glue.c @@ -166,7 +166,7 @@ struct dn_pipe7 { /* a pipe */ SLIST_ENTRY(dn_pipe7) next; /* linked list in a hash slot */ int pipe_nr ; /* number */ - int bandwidth; /* really, bytes/tick. */ + uint32_t bandwidth; /* really, bytes/tick. */ int delay ; /* really, ticks */ struct mbuf *head, *tail ; /* packets in delay line */ @@ -232,7 +232,7 @@ struct dn_pipe8 { /* a pipe */ SLIST_ENTRY(dn_pipe8) next; /* linked list in a hash slot */ int pipe_nr ; /* number */ - int bandwidth; /* really, bytes/tick. */ + uint32_t bandwidth; /* really, bytes/tick. */ int delay ; /* really, ticks */ struct mbuf *head, *tail ; /* packets in delay line */ diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 114cfac440ee..3a1140e8e7ea 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -587,7 +587,8 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) struct dn_schk *s = si->sched; struct mbuf *m = NULL; int delay_line_idle = (si->dline.mq.head == NULL); - int done, bw; + int done; + uint32_t bw; if (q == NULL) { q = &def_q; From owner-dev-commits-src-all@freebsd.org Thu Aug 26 12:06:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 133D66689AC; Thu, 26 Aug 2021 12:06: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 4GwM5N6Ksmz3N91; Thu, 26 Aug 2021 12:06: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 9C0117660; Thu, 26 Aug 2021 12:06: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 17QC6W2h080980; Thu, 26 Aug 2021 12:06:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC6Wx7080973; Thu, 26 Aug 2021 12:06:32 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:06:32 GMT Message-Id: <202108261206.17QC6Wx7080973@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: df8824452d84 - stable/13 - lagg: don't update link layer addresses on destroy 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: df8824452d841826de1dafe9f83e3a2631b3d9c8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:06:33 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=df8824452d841826de1dafe9f83e3a2631b3d9c8 commit df8824452d841826de1dafe9f83e3a2631b3d9c8 Author: Luiz Otavio O Souza AuthorDate: 2021-08-17 14:23:50 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 12:05:27 +0000 lagg: don't update link layer addresses on destroy When the lagg is being destroyed it is not necessary update the lladdr of all the lagg members every time we update the primary interface. Reviewed by: scottl Obtained from: pfSense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31586 (cherry picked from commit c138424148f900dc449c757869453120ae3277f3) --- sys/net/if_lagg.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 9a3c22789fa5..c53e5b283b76 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -969,14 +969,16 @@ lagg_port_destroy(struct lagg_port *lp, int rundelport) bcopy(lladdr, IF_LLADDR(sc->sc_ifp), sc->sc_ifp->if_addrlen); lagg_proto_lladdr(sc); EVENTHANDLER_INVOKE(iflladdr_event, sc->sc_ifp); - } - /* - * Update lladdr for each port (new primary needs update - * as well, to switch from old lladdr to its 'real' one) - */ - CK_SLIST_FOREACH(lp_ptr, &sc->sc_ports, lp_entries) - if_setlladdr(lp_ptr->lp_ifp, lladdr, lp_ptr->lp_ifp->if_addrlen); + /* + * Update lladdr for each port (new primary needs update + * as well, to switch from old lladdr to its 'real' one). + * We can skip this if the lagg is being destroyed. + */ + CK_SLIST_FOREACH(lp_ptr, &sc->sc_ports, lp_entries) + if_setlladdr(lp_ptr->lp_ifp, lladdr, + lp_ptr->lp_ifp->if_addrlen); + } } if (lp->lp_ifflags) From owner-dev-commits-src-all@freebsd.org Thu Aug 26 12:06:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2291F668CCA; Thu, 26 Aug 2021 12:06: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 4GwM5R30dpz3N2D; Thu, 26 Aug 2021 12:06: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 12CA97B24; Thu, 26 Aug 2021 12:06: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 17QC6Ysg081147; Thu, 26 Aug 2021 12:06:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC6YXi081146; Thu, 26 Aug 2021 12:06:34 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:06:34 GMT Message-Id: <202108261206.17QC6YXi081146@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: 56a4e77d461e - stable/12 - rtsold: make it work on if_vlan interfaces 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: 56a4e77d461e3d4ad9b95afe9bb847cb7573075e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:06:36 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=56a4e77d461e3d4ad9b95afe9bb847cb7573075e commit 56a4e77d461e3d4ad9b95afe9bb847cb7573075e Author: Luiz Otavio O Souza AuthorDate: 2021-08-19 09:48:04 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 07:26:49 +0000 rtsold: make it work on if_vlan interfaces Reviewed by: kp Obtained from: pfsense MFC after: 1 week (cherry picked from commit 1a4d7030bbfec0f830e87bf7c2810f049f8ca8ac) --- usr.sbin/rtsold/if.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index b2f2c640b175..0f7f2ce7cba5 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -262,6 +262,7 @@ lladdropt_length(struct sockaddr_dl *sdl) { switch (sdl->sdl_type) { case IFT_ETHER: + case IFT_L2VLAN: return (ROUNDUP8(ETHER_ADDR_LEN + 2)); default: return (0); @@ -277,6 +278,7 @@ lladdropt_fill(struct sockaddr_dl *sdl, struct nd_opt_hdr *ndopt) switch (sdl->sdl_type) { case IFT_ETHER: + case IFT_L2VLAN: ndopt->nd_opt_len = (ROUNDUP8(ETHER_ADDR_LEN + 2)) >> 3; addr = (char *)(ndopt + 1); memcpy(addr, LLADDR(sdl), ETHER_ADDR_LEN); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 12:06:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8B4DE6689B6; Thu, 26 Aug 2021 12:06: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 4GwM5Q1kb1z3N7F; Thu, 26 Aug 2021 12:06: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 EAEE27C18; Thu, 26 Aug 2021 12:06: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 17QC6XEQ081085; Thu, 26 Aug 2021 12:06:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC6XVV081084; Thu, 26 Aug 2021 12:06:33 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:06:33 GMT Message-Id: <202108261206.17QC6XVV081084@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: 864aa7e4a609 - stable/12 - lagg: don't update link layer addresses on destroy 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: 864aa7e4a6092e09d7155037262427a4ea57eb2b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:06:34 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=864aa7e4a6092e09d7155037262427a4ea57eb2b commit 864aa7e4a6092e09d7155037262427a4ea57eb2b Author: Luiz Otavio O Souza AuthorDate: 2021-08-17 14:23:50 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 07:26:47 +0000 lagg: don't update link layer addresses on destroy When the lagg is being destroyed it is not necessary update the lladdr of all the lagg members every time we update the primary interface. Reviewed by: scottl Obtained from: pfSense MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31586 (cherry picked from commit c138424148f900dc449c757869453120ae3277f3) --- sys/net/if_lagg.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 6831b40d099f..57c56604e65e 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -944,14 +944,16 @@ lagg_port_destroy(struct lagg_port *lp, int rundelport) bcopy(lladdr, IF_LLADDR(sc->sc_ifp), sc->sc_ifp->if_addrlen); lagg_proto_lladdr(sc); EVENTHANDLER_INVOKE(iflladdr_event, sc->sc_ifp); - } - /* - * Update lladdr for each port (new primary needs update - * as well, to switch from old lladdr to its 'real' one) - */ - CK_SLIST_FOREACH(lp_ptr, &sc->sc_ports, lp_entries) - if_setlladdr(lp_ptr->lp_ifp, lladdr, lp_ptr->lp_ifp->if_addrlen); + /* + * Update lladdr for each port (new primary needs update + * as well, to switch from old lladdr to its 'real' one). + * We can skip this if the lagg is being destroyed. + */ + CK_SLIST_FOREACH(lp_ptr, &sc->sc_ports, lp_entries) + if_setlladdr(lp_ptr->lp_ifp, lladdr, + lp_ptr->lp_ifp->if_addrlen); + } } if (lp->lp_ifflags) From owner-dev-commits-src-all@freebsd.org Thu Aug 26 12:06:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A536668D91; Thu, 26 Aug 2021 12:06: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 4GwM5Q03Yqz3N24; Thu, 26 Aug 2021 12:06: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 C31677B23; Thu, 26 Aug 2021 12:06: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 17QC6X7j081061; Thu, 26 Aug 2021 12:06:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QC6XLY081060; Thu, 26 Aug 2021 12:06:33 GMT (envelope-from git) Date: Thu, 26 Aug 2021 12:06:33 GMT Message-Id: <202108261206.17QC6XLY081060@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: 2cbe61a73d86 - stable/13 - rtsold: make it work on if_vlan interfaces 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: 2cbe61a73d861810b3cee4da6464b0e01d1399ae Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 12:06:34 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2cbe61a73d861810b3cee4da6464b0e01d1399ae commit 2cbe61a73d861810b3cee4da6464b0e01d1399ae Author: Luiz Otavio O Souza AuthorDate: 2021-08-19 09:48:04 +0000 Commit: Kristof Provost CommitDate: 2021-08-26 12:05:27 +0000 rtsold: make it work on if_vlan interfaces Reviewed by: kp Obtained from: pfsense MFC after: 1 week (cherry picked from commit 1a4d7030bbfec0f830e87bf7c2810f049f8ca8ac) --- usr.sbin/rtsold/if.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index b2f2c640b175..0f7f2ce7cba5 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -262,6 +262,7 @@ lladdropt_length(struct sockaddr_dl *sdl) { switch (sdl->sdl_type) { case IFT_ETHER: + case IFT_L2VLAN: return (ROUNDUP8(ETHER_ADDR_LEN + 2)); default: return (0); @@ -277,6 +278,7 @@ lladdropt_fill(struct sockaddr_dl *sdl, struct nd_opt_hdr *ndopt) switch (sdl->sdl_type) { case IFT_ETHER: + case IFT_L2VLAN: ndopt->nd_opt_len = (ROUNDUP8(ETHER_ADDR_LEN + 2)) >> 3; addr = (char *)(ndopt + 1); memcpy(addr, LLADDR(sdl), ETHER_ADDR_LEN); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 15:16:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1E31666BB0B; Thu, 26 Aug 2021 15:16: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 4GwRJb0C1wz3Lfx; Thu, 26 Aug 2021 15:16: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 E35E61214E; Thu, 26 Aug 2021 15:16: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 17QFGUxZ035445; Thu, 26 Aug 2021 15:16:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QFGULJ035444; Thu, 26 Aug 2021 15:16:30 GMT (envelope-from git) Date: Thu, 26 Aug 2021 15:16:30 GMT Message-Id: <202108261516.17QFGULJ035444@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 58d868c88d21 - main - sound(4): Fix some common typos in comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 58d868c88d21b46d3d6d40a2920e7ba8996723b8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 15:16:31 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=58d868c88d21b46d3d6d40a2920e7ba8996723b8 commit 58d868c88d21b46d3d6d40a2920e7ba8996723b8 Author: Gordon Bergling AuthorDate: 2021-08-26 15:15:55 +0000 Commit: Gordon Bergling CommitDate: 2021-08-26 15:15:55 +0000 sound(4): Fix some common typos in comments - s/doens't/doesn't/ - s/apropriate/appropriate/ - s/intepretation/interpretation/ MFC after: 5 days --- sys/dev/sound/midi/sequencer.c | 4 ++-- sys/dev/sound/pcm/feeder_chain.c | 2 +- sys/dev/sound/pcm/feeder_matrix.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c index ed8ba6dde699..6c80b3ec261c 100644 --- a/sys/dev/sound/midi/sequencer.c +++ b/sys/dev/sound/midi/sequencer.c @@ -894,7 +894,7 @@ mseq_read(struct cdev *i_dev, struct uio *uio, int ioflag) /* * I think the semantics are to return as soon * as possible. - * Second thought, it doens't seem like midimoutain + * Second thought, it doesn't seem like midimoutain * expects that at all. * TODO: Look up in some sort of spec */ @@ -1441,7 +1441,7 @@ mseq_poll(struct cdev *i_dev, int events, struct thread *td) ret = 0; - /* Look up the apropriate queue and select it. */ + /* Look up the appropriate queue and select it. */ if ((events & (POLLOUT | POLLWRNORM)) != 0) { /* Start playing. */ scp->playing = 1; diff --git a/sys/dev/sound/pcm/feeder_chain.c b/sys/dev/sound/pcm/feeder_chain.c index 73922ab55396..b2d48abd71d1 100644 --- a/sys/dev/sound/pcm/feeder_chain.c +++ b/sys/dev/sound/pcm/feeder_chain.c @@ -652,7 +652,7 @@ feeder_chain(struct pcm_channel *c) } /* - * The 'hardware' possibly have different intepretation of channel + * The 'hardware' possibly have different interpretation of channel * matrixing, so get it first ..... */ hwmatrix = CHANNEL_GETMATRIX(c->methods, c->devinfo, hwfmt); diff --git a/sys/dev/sound/pcm/feeder_matrix.c b/sys/dev/sound/pcm/feeder_matrix.c index 7d965860f886..c6a65113574a 100644 --- a/sys/dev/sound/pcm/feeder_matrix.c +++ b/sys/dev/sound/pcm/feeder_matrix.c @@ -699,7 +699,7 @@ feeder_matrix_compare(struct pcmchan_matrix *m_in, struct pcmchan_matrix *m_out) } /* - * XXX 4front intepretation of "surround" is ambigous and sort of + * XXX 4front interpretation of "surround" is ambigous and sort of * conflicting with "rear"/"back". Map it to "side". Well.. * who cares? */ From owner-dev-commits-src-all@freebsd.org Thu Aug 26 16:09:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7DB5266C61A; Thu, 26 Aug 2021 16:09: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 4GwSV42tfBz3tv3; Thu, 26 Aug 2021 16:09: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 4BCA312F73; Thu, 26 Aug 2021 16:09: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 17QG9mgu005367; Thu, 26 Aug 2021 16:09:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QG9mZ6005366; Thu, 26 Aug 2021 16:09:48 GMT (envelope-from git) Date: Thu, 26 Aug 2021 16:09:48 GMT Message-Id: <202108261609.17QG9mZ6005366@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7aa47cace149 - main - amd64: remove lfence after swapgs on syscall entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7aa47cace14948a7b8277a4b24a0ca9e0308990a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 16:09:48 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7aa47cace14948a7b8277a4b24a0ca9e0308990a commit 7aa47cace14948a7b8277a4b24a0ca9e0308990a Author: Konstantin Belousov AuthorDate: 2021-08-25 19:28:57 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-26 16:09:21 +0000 amd64: remove lfence after swapgs on syscall entry According to the description of SBSS issue at https://software.intel.com/content/www/us/en/develop/articles/software-security-guidance/technical-documentation/speculative-behavior-swapgs-and-segment-registers.html lfence after swapgs is needed only for the case when swapgs could be speculatively executed. Since syscall entry, unlike exception and interrupt entries, executes swapgs unconditionally, there is no opportunity for speculation. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31682 --- sys/amd64/amd64/exception.S | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index d1e49faa40e7..6471f9a3041c 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -524,7 +524,6 @@ prot_addrf: SUPERALIGN_TEXT IDTVEC(fast_syscall_pti) swapgs - lfence cmpq $~0,PCPU(UCR3) je fast_syscall_common movq %rax,PCPU(SCRATCH_RAX) @@ -535,7 +534,6 @@ IDTVEC(fast_syscall_pti) SUPERALIGN_TEXT IDTVEC(fast_syscall) swapgs - lfence fast_syscall_common: movq %rsp,PCPU(SCRATCH_RSP) movq PCPU(RSP0),%rsp From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:28:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5FAD066D25A; Thu, 26 Aug 2021 17:28: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 4GwVFQ1gRlz4mqQ; Thu, 26 Aug 2021 17:28: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 212F713FE7; Thu, 26 Aug 2021 17:28: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 17QHSwbu010974; Thu, 26 Aug 2021 17:28:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHSwF2010973; Thu, 26 Aug 2021 17:28:58 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:28:58 GMT Message-Id: <202108261728.17QHSwF2010973@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: 453e51048a83 - stable/13 - devclass_alloc_unit: move "at" hint test to after device-in-use test 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: 453e51048a83b8b73706a8f8520ad7ce193c0f51 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:28:58 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=453e51048a83b8b73706a8f8520ad7ce193c0f51 commit 453e51048a83b8b73706a8f8520ad7ce193c0f51 Author: Adam Fenn AuthorDate: 2021-08-02 16:27:17 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 devclass_alloc_unit: move "at" hint test to after device-in-use test Only perform this expensive operation when the unit number is a potential candidate (i.e. not already in use), thereby reducing device scan time on systems with many devices, unit numbers, and drivers. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #61 (cherry picked from commit 8ca384eb1d429aae866f53abfadafc71ab009dc6) --- sys/kern/subr_bus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index f0198a0e1fa3..5bd3a4f3d450 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1640,15 +1640,15 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp) /* Unwired device, find the next available slot for it */ unit = 0; for (unit = 0;; unit++) { + /* If this device slot is already in use, skip it. */ + if (unit < dc->maxunit && dc->devices[unit] != NULL) + continue; + /* If there is an "at" hint for a unit then skip it. */ if (resource_string_value(dc->name, unit, "at", &s) == 0) continue; - /* If this device slot is already in use, skip it. */ - if (unit < dc->maxunit && dc->devices[unit] != NULL) - continue; - break; } } From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:29:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E71A266D469; Thu, 26 Aug 2021 17:29: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 4GwVFS5PPBz4mmn; Thu, 26 Aug 2021 17:29: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 5EE3313FE8; Thu, 26 Aug 2021 17:29: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 17QHT00k011028; Thu, 26 Aug 2021 17:29:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHT0Jr011027; Thu, 26 Aug 2021 17:29:00 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:29:00 GMT Message-Id: <202108261729.17QHT0Jr011027@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: 48ac2697742e - stable/13 - pkg: allow multiple add arguments again 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: 48ac2697742ed4e0beed3f074af41b7a9e21b662 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:29:01 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=48ac2697742ed4e0beed3f074af41b7a9e21b662 commit 48ac2697742ed4e0beed3f074af41b7a9e21b662 Author: Kyle Evans AuthorDate: 2021-02-18 03:41:53 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 pkg: allow multiple add arguments again While pkg(7) add only handles a single 'add' argument, pkg-add(8) fully handles multiple arguments. Stop rejecting it, just turn off local-bootstrap mode and proceed to remote bootstrap if we need it. While we're here, check if the first argument to pkg add is even a pkg package. If it's not, also do remote bootstrap instead. Future work could improve this altogether by picking out a pkg package out of many and local bootstrap then pass the rest through to the newly installed pkg. (cherry picked from commit 40b9f924b189ce8fa871db600b4abc99b03c6a65) --- usr.sbin/pkg/pkg.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 8193dc79a430..1196c78e5cc9 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -1056,6 +1056,40 @@ cleanup: return (ret); } +#define PKG_NAME "pkg" +#define PKG_DEVEL_NAME PKG_NAME "-devel" +#define PKG_PKG PKG_NAME "." + +static bool +pkg_is_pkg_pkg(const char *pkg) +{ + char *vstart; + size_t namelen; + + /* + * Chop off the final "-" (version delimiter) and check the name that + * precedes it. If we didn't have a version delimiter, it must be the + * pkg.$archive short form but we'll check it anyways. pkg-devel short + * form will look like a pkg archive with 'devel' version, but that's + * OK. We otherwise assumed that non-pkg packages will always have a + * version component. + */ + vstart = strrchr(pkg, '-'); + if (vstart == NULL) { + return (strlen(pkg) > sizeof(PKG_PKG) - 1 && + strncmp(pkg, PKG_PKG, sizeof(PKG_PKG) - 1) == 0); + } + + namelen = vstart - pkg; + if (namelen == sizeof(PKG_NAME) - 1 && + strncmp(pkg, PKG_NAME, sizeof(PKG_NAME) - 1) == 0) + return (true); + if (namelen == sizeof(PKG_DEVEL_NAME) - 1 && + strncmp(pkg, PKG_DEVEL_NAME, sizeof(PKG_DEVEL_NAME) - 1) == 0) + return (true); + return (false); +} + int main(int argc, char *argv[]) { @@ -1159,13 +1193,25 @@ main(int argc, char *argv[]) fprintf(stderr, args_bootstrap_message); exit(EXIT_FAILURE); } - // For add, we accept exactly one further argument else if (add_pkg && pkgarg != NULL) { - fprintf(stderr, args_add_message); - exit(EXIT_FAILURE); + /* + * Additional arguments also means it's not a + * local bootstrap request. + */ + add_pkg = false; } else if (add_pkg) { - pkgarg = argv[optind-1]; + /* + * If it's not a request for pkg or pkg-devel, + * then we must assume they were trying to + * install some other local package and we + * should try to bootstrap from the repo. + */ + if (!pkg_is_pkg_pkg(argv[optind-1])) { + add_pkg = false; + } else { + pkgarg = argv[optind-1]; + } } break; default: From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:28:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86A8566D2B5; Thu, 26 Aug 2021 17:28:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwVFR2gW3z4mbw; Thu, 26 Aug 2021 17:28:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38944141B7; Thu, 26 Aug 2021 17:28: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 17QHSxcM011002; Thu, 26 Aug 2021 17:28:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHSxHf011001; Thu, 26 Aug 2021 17:28:59 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:28:59 GMT Message-Id: <202108261728.17QHSxHf011001@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: e70e1b132ee8 - stable/13 - malloc(9): Document/complete aligned variants 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: e70e1b132ee88611b2ea8e849811c73ee600cea9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:28:59 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=e70e1b132ee88611b2ea8e849811c73ee600cea9 commit e70e1b132ee88611b2ea8e849811c73ee600cea9 Author: Adam Fenn AuthorDate: 2021-08-02 20:33:31 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 malloc(9): Document/complete aligned variants Comments on a pending kvmclock driver suggested adding a malloc_aligned() to complement malloc_domainset_aligned(); add it now, and document both. (cherry picked from commit 6162cf885c00a0893a0961415f1829942343dcc1) (cherry picked from commit 04cc0c393c317b6d5e28c8dc80cd1b5ea071f28f) --- share/man/man9/malloc.9 | 25 ++++++++++++++++++++++++- sys/kern/kern_malloc.c | 7 +++++++ sys/sys/malloc.h | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9 index b8c6e504e0c0..71375e90951f 100644 --- a/share/man/man9/malloc.9 +++ b/share/man/man9/malloc.9 @@ -29,7 +29,7 @@ .\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $ .\" $FreeBSD$ .\" -.Dd March 6, 2021 +.Dd July 2, 2021 .Dt MALLOC 9 .Os .Sh NAME @@ -58,6 +58,13 @@ .Ft size_t .Fn malloc_usable_size "const void *addr" .Ft void * +.Fo malloc_aligned +.Fa "size_t size" +.Fa "size_t align" +.Fa "struct malloc_type *type" +.Fa "int flags" +.Fc +.Ft void * .Fn malloc_exec "size_t size" "struct malloc_type *type" "int flags" .Fn MALLOC_DECLARE type .In sys/param.h @@ -69,6 +76,14 @@ .Ft void * .Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" .Ft void * +.Fo malloc_domainset_aligned +.Fa "size_t size" +.Fa "size_t align" +.Fa "struct malloc_type *type" +.Fa "struct domainset *ds" +.Fa "int flags" +.Fc +.Ft void * .Fn malloc_domainset_exec "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" .Ft void * .Fn mallocarray_domainset "size_t nmemb" "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" @@ -88,6 +103,14 @@ See .Xr domainset 9 for some example policies. .Pp +The +.Fn malloc_aligned +and +.Fn malloc_domainset_aligned +variants return allocations aligned as specified by +.Fa align , +which must be non-zero, a power of two, and less than or equal to the page size. +.Pp Both .Fn malloc_exec and diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 48383358e3ad..364828e6a1e6 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -763,6 +763,13 @@ malloc_domainset_exec(size_t size, struct malloc_type *mtp, struct domainset *ds return (malloc_large(&size, mtp, ds, flags DEBUG_REDZONE_ARG)); } +void * +malloc_aligned(size_t size, size_t align, struct malloc_type *type, int flags) +{ + return (malloc_domainset_aligned(size, align, type, DOMAINSET_RR(), + flags)); +} + void * malloc_domainset_aligned(size_t size, size_t align, struct malloc_type *mtp, struct domainset *ds, int flags) diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 8982e534fc22..93ec81c252ff 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -264,6 +264,8 @@ void *realloc(void *addr, size_t size, struct malloc_type *type, int flags) __result_use_check __alloc_size(2); void *reallocf(void *addr, size_t size, struct malloc_type *type, int flags) __result_use_check __alloc_size(2); +void *malloc_aligned(size_t size, size_t align, struct malloc_type *type, + int flags) __malloc_like __result_use_check __alloc_size(1); void *malloc_domainset_aligned(size_t size, size_t align, struct malloc_type *mtp, struct domainset *ds, int flags) __malloc_like __result_use_check __alloc_size(1); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:29:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BAC5B66D595; Thu, 26 Aug 2021 17:29: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 4GwVFT4PmYz4mYL; Thu, 26 Aug 2021 17:29: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 7EA8914212; Thu, 26 Aug 2021 17:29: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 17QHT1dA011053; Thu, 26 Aug 2021 17:29:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHT1gu011052; Thu, 26 Aug 2021 17:29:01 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:29:01 GMT Message-Id: <202108261729.17QHT1gu011052@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: 55eea57aba30 - stable/13 - pkg: use specific CONFSNAME_${file} for FreeBSD.conf 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: 55eea57aba3091ceb668aed4f25e763f10ea5748 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:29:02 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=55eea57aba3091ceb668aed4f25e763f10ea5748 commit 55eea57aba3091ceb668aed4f25e763f10ea5748 Author: Kyle Evans AuthorDate: 2021-02-18 04:10:46 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 pkg: use specific CONFSNAME_${file} for FreeBSD.conf Setting CONFSNAME directly is a little more complicated for downstream consumers, as any additional CONFS that are added here will inherit the group name by default. This is perhaps arguably a design flaw in CONFS because inheriting NAME will never give a good result when additional files are added, but this is a low-effort change. While we're here, pull FreeBSD.conf.${branch} out into a PKGCONF variable so one can just drop a new repo config in entirely with a new naming scheme. CONFSNAME gets set based on chopping anything off after ".conf", so that, e.g.: - FooBSD.conf => FooBSD.conf - FooBSD.conf.internal => FooBSD.conf (cherry picked from commit d35164539b14a6d14fb587e58a0c7a1668d7643a) --- usr.sbin/pkg/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile index a71f0b2acb86..dd3db00885b1 100644 --- a/usr.sbin/pkg/Makefile +++ b/usr.sbin/pkg/Makefile @@ -15,8 +15,9 @@ PKGCONFBRANCH?= latest . endif . endif .endif -CONFS= FreeBSD.conf.${PKGCONFBRANCH} -CONFSNAME= FreeBSD.conf +PKGCONF?= FreeBSD.conf.${PKGCONFBRANCH} +CONFS= ${PKGCONF} +CONFSNAME_${PKGCONF}= ${PKGCONF:C/\.conf.+$/.conf/} CONFSDIR= /etc/pkg CONFSMODE= 644 PROG= pkg From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:29:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A86666D60E; Thu, 26 Aug 2021 17:29: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 4GwVFV5t2wz4mYQ; Thu, 26 Aug 2021 17:29: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 A98F614213; Thu, 26 Aug 2021 17:29: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 17QHT2ZU011077; Thu, 26 Aug 2021 17:29:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHT29r011076; Thu, 26 Aug 2021 17:29:02 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:29:02 GMT Message-Id: <202108261729.17QHT29r011076@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: f6aab4dd7706 - stable/13 - crunchgen: sprinkle some const-poisoning around 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: f6aab4dd770603f249f914192843efd618bd1bdc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:29:03 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=f6aab4dd770603f249f914192843efd618bd1bdc commit f6aab4dd770603f249f914192843efd618bd1bdc Author: Kyle Evans AuthorDate: 2021-08-19 06:13:13 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 crunchgen: sprinkle some const-poisoning around (cherry picked from commit db7f7446b5bcb26c7aaf13c8151b4ae8051c5732) --- usr.sbin/crunch/crunchgen/crunchgen.c | 10 +++++----- usr.sbin/crunch/crunchgen/mkskel.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index 95ed5ca6636a..c6cf2a08cc7b 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -96,8 +96,8 @@ char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], execfname[MAXPATHLEN]; char tempfname[MAXPATHLEN], cachename[MAXPATHLEN], curfilename[MAXPATHLEN]; bool tempfname_initialized = false; char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */ -char *objprefix; /* where are the objects ? */ -char *path_make; +const char *objprefix; /* where are the objects ? */ +const char *path_make; int linenum = -1; int goterror = 0; @@ -123,7 +123,7 @@ void usage(void); void parse_conf_file(void); void gen_outputs(void); -extern char *crunched_skel[]; +extern const char *crunched_skel[]; int @@ -721,7 +721,7 @@ fillin_program_objs(prog_t *p, char *path) char *obj, *cp; int fd, rc; FILE *f; - char *objvar="OBJS"; + const char *objvar="OBJS"; strlst_t *s; char line[MAXLINELEN]; @@ -912,7 +912,7 @@ gen_output_makefile(void) void gen_output_cfile(void) { - char **cp; + const char **cp; FILE *outcf; prog_t *p; strlst_t *s; diff --git a/usr.sbin/crunch/crunchgen/mkskel.sh b/usr.sbin/crunch/crunchgen/mkskel.sh index fd53d78bbbac..274bb7274cbd 100644 --- a/usr.sbin/crunch/crunchgen/mkskel.sh +++ b/usr.sbin/crunch/crunchgen/mkskel.sh @@ -4,7 +4,7 @@ cat < Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9F85E66D780; Thu, 26 Aug 2021 17:29: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 4GwVFZ24Mtz4msW; Thu, 26 Aug 2021 17:29: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 17E7213DDD; Thu, 26 Aug 2021 17:29: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 17QHT5Px011149; Thu, 26 Aug 2021 17:29:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHT5oh011148; Thu, 26 Aug 2021 17:29:05 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:29:05 GMT Message-Id: <202108261729.17QHT5oh011148@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: c81c1995e9ad - stable/13 - crunchgen: fix remaining issues under WARNS=6 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: c81c1995e9ad471a317ac7e86a9c5332a3f979f7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:29:06 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=c81c1995e9ad471a317ac7e86a9c5332a3f979f7 commit c81c1995e9ad471a317ac7e86a9c5332a3f979f7 Author: Kyle Evans AuthorDate: 2021-08-19 06:22:16 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 crunchgen: fix remaining issues under WARNS=6 Entirely variables that should be static, save for one 'no previous declaration' in mkskel.sh. (cherry picked from commit bfd70233c3e2bc5c29db6f96fb90b58439908d29) --- usr.sbin/crunch/crunchgen/crunchgen.c | 43 ++++++++++++++++++----------------- usr.sbin/crunch/crunchgen/mkskel.sh | 1 + 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index c6cf2a08cc7b..94792c5ec50b 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -85,27 +85,28 @@ typedef struct prog { /* global state */ -strlst_t *buildopts = NULL; -strlst_t *srcdirs = NULL; -strlst_t *libs = NULL; -strlst_t *libs_so = NULL; -prog_t *progs = NULL; - -char confname[MAXPATHLEN], infilename[MAXPATHLEN]; -char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], execfname[MAXPATHLEN]; -char tempfname[MAXPATHLEN], cachename[MAXPATHLEN], curfilename[MAXPATHLEN]; -bool tempfname_initialized = false; -char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */ -const char *objprefix; /* where are the objects ? */ -const char *path_make; -int linenum = -1; -int goterror = 0; - -int verbose, readcache; /* options */ -int reading_cache; -int makeobj = 0; /* add 'make obj' rules to the makefile */ - -int list_mode; +static strlst_t *buildopts = NULL; +static strlst_t *srcdirs = NULL; +static strlst_t *libs = NULL; +static strlst_t *libs_so = NULL; +static prog_t *progs = NULL; + +static char confname[MAXPATHLEN], infilename[MAXPATHLEN]; +static char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], execfname[MAXPATHLEN]; +static char tempfname[MAXPATHLEN], cachename[MAXPATHLEN]; +static char curfilename[MAXPATHLEN]; +static bool tempfname_initialized = false; +static char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */ +static const char *objprefix; /* where are the objects ? */ +static const char *path_make; +static int linenum = -1; +static int goterror = 0; + +static int verbose, readcache; /* options */ +static int reading_cache; +static int makeobj = 0; /* add 'make obj' rules to the makefile */ + +static int list_mode; /* general library routines */ diff --git a/usr.sbin/crunch/crunchgen/mkskel.sh b/usr.sbin/crunch/crunchgen/mkskel.sh index 274bb7274cbd..3e5a1618e4ad 100644 --- a/usr.sbin/crunch/crunchgen/mkskel.sh +++ b/usr.sbin/crunch/crunchgen/mkskel.sh @@ -4,6 +4,7 @@ cat < Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 554B466D690; Thu, 26 Aug 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 4GwVFX0Nlcz4mql; Thu, 26 Aug 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 D00D313ECF; Thu, 26 Aug 2021 17:29: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 17QHT3Fb011101; Thu, 26 Aug 2021 17:29:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHT3Wx011100; Thu, 26 Aug 2021 17:29:03 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:29:03 GMT Message-Id: <202108261729.17QHT3Wx011100@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: 76520030a0a1 - stable/13 - crunchide: address complaints from WARNS=6 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: 76520030a0a13ed8793cf13a4d62d2f90e6904d3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:29:04 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=76520030a0a13ed8793cf13a4d62d2f90e6904d3 commit 76520030a0a13ed8793cf13a4d62d2f90e6904d3 Author: Kyle Evans AuthorDate: 2021-08-19 06:17:36 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 crunchide: address complaints from WARNS=6 - One (1) constify - One (1) argument is unused - One (1) local shadows a global - Various globals that should be static (cherry picked from commit dd7c7ff192d07912fb7f5874868649c3aa05944a) --- usr.sbin/crunch/crunchide/crunchide.c | 8 ++++---- usr.sbin/crunch/crunchide/exec_elf32.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/usr.sbin/crunch/crunchide/crunchide.c b/usr.sbin/crunch/crunchide/crunchide.c index b7eba3995173..324402501491 100644 --- a/usr.sbin/crunch/crunchide/crunchide.c +++ b/usr.sbin/crunch/crunchide/crunchide.c @@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$"); #include "extern.h" -char *pname = "crunchide"; +static const char *pname = "crunchide"; void usage(void); @@ -85,7 +85,7 @@ void add_file_to_keep_list(char *filename); int hide_syms(const char *filename); -int verbose; +static int verbose; int main(int, char *[]); @@ -137,7 +137,7 @@ usage(void) /* ---------------------------- */ -struct keep { +static struct keep { struct keep *next; char *sym; } *keep_list; @@ -206,7 +206,7 @@ add_file_to_keep_list(char *filename) /* ---------------------------- */ -struct { +static struct { const char *name; int (*check)(int, const char *); /* 1 if match, zero if not */ int (*hide)(int, const char *); /* non-zero if error */ diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c index 28641107cc5c..f7b8601911fe 100644 --- a/usr.sbin/crunch/crunchide/exec_elf32.c +++ b/usr.sbin/crunch/crunchide/exec_elf32.c @@ -155,7 +155,7 @@ xrealloc(void *ptr, size_t size, const char *fn, const char *use) } int -ELFNAMEEND(check)(int fd, const char *fn) +ELFNAMEEND(check)(int fd, const char *fn __unused) { Elf_Ehdr eh; struct stat sb; @@ -435,12 +435,12 @@ ELFNAMEEND(hide)(int fd, const char *fn) * update section header table in ascending order of offset */ for (i = strtabidx + 1; i < shnum; i++) { - Elf_Off off, align; - off = xewtoh(layoutp[i - 1].shdr->sh_offset) + + Elf_Off soff, align; + soff = xewtoh(layoutp[i - 1].shdr->sh_offset) + xewtoh(layoutp[i - 1].shdr->sh_size); align = xewtoh(layoutp[i].shdr->sh_addralign); - off = (off + (align - 1)) & ~(align - 1); - layoutp[i].shdr->sh_offset = htoxew(off); + soff = (soff + (align - 1)) & ~(align - 1); + layoutp[i].shdr->sh_offset = htoxew(soff); } /* From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:29:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 88F6366D60F; Thu, 26 Aug 2021 17:29: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 4GwVFY0gY9z4mYW; Thu, 26 Aug 2021 17:29: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 E232114214; Thu, 26 Aug 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 17QHT4Ib011125; Thu, 26 Aug 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 17QHT4F7011124; Thu, 26 Aug 2021 17:29:04 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:29:04 GMT Message-Id: <202108261729.17QHT4F7011124@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: 90bf0d3033f4 - stable/13 - crunchide: static'ify remaining non-exported functions 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: 90bf0d3033f4387a80effc2bbc39d36ce08a0858 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:29:05 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=90bf0d3033f4387a80effc2bbc39d36ce08a0858 commit 90bf0d3033f4387a80effc2bbc39d36ce08a0858 Author: Kyle Evans AuthorDate: 2021-08-19 06:29:02 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 crunchide: static'ify remaining non-exported functions (cherry picked from commit 7ff87026d65c77f90391ead3f2fc752223d16e01) --- usr.sbin/crunch/crunchide/crunchide.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.sbin/crunch/crunchide/crunchide.c b/usr.sbin/crunch/crunchide/crunchide.c index 324402501491..1f2f98893bac 100644 --- a/usr.sbin/crunch/crunchide/crunchide.c +++ b/usr.sbin/crunch/crunchide/crunchide.c @@ -78,12 +78,12 @@ __FBSDID("$FreeBSD$"); static const char *pname = "crunchide"; -void usage(void); +static void usage(void); -void add_to_keep_list(char *symbol); -void add_file_to_keep_list(char *filename); +static void add_to_keep_list(char *symbol); +static void add_file_to_keep_list(char *filename); -int hide_syms(const char *filename); +static int hide_syms(const char *filename); static int verbose; @@ -126,7 +126,7 @@ main(int argc, char **argv) return errors; } -void +static void usage(void) { fprintf(stderr, @@ -142,7 +142,7 @@ static struct keep { char *sym; } *keep_list; -void +static void add_to_keep_list(char *symbol) { struct keep *newp, *prevp, *curp; @@ -182,7 +182,7 @@ in_keep_list(const char *symbol) return curp && cmp == 0; } -void +static void add_file_to_keep_list(char *filename) { FILE *keepf; @@ -219,7 +219,7 @@ static struct { #endif }; -int +static int hide_syms(const char *filename) { int fd, i, n, rv; From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:29:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F16DF66D5A7; Thu, 26 Aug 2021 17:29: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 4GwVFb34rMz4mhd; Thu, 26 Aug 2021 17:29: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 38D2913DDE; Thu, 26 Aug 2021 17:29: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 17QHT714011179; Thu, 26 Aug 2021 17:29:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHT7nF011178; Thu, 26 Aug 2021 17:29:07 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:29:07 GMT Message-Id: <202108261729.17QHT7nF011178@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: 75046797387c - stable/13 - crunch: drop WARNS override 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: 75046797387c7627af10e47dbdf9540851a39be9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:29:08 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=75046797387c7627af10e47dbdf9540851a39be9 commit 75046797387c7627af10e47dbdf9540851a39be9 Author: Kyle Evans AuthorDate: 2021-08-19 06:33:13 +0000 Commit: Kyle Evans CommitDate: 2021-08-26 17:28:38 +0000 crunch: drop WARNS override crunchide and crunchgen now build fine with default WARNS (cherry picked from commit d59c5e023d558161e4f519b88d5209d8bab18bc7) --- usr.sbin/crunch/Makefile.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/usr.sbin/crunch/Makefile.inc b/usr.sbin/crunch/Makefile.inc index 36175b7e5258..f8ffe675db6e 100644 --- a/usr.sbin/crunch/Makefile.inc +++ b/usr.sbin/crunch/Makefile.inc @@ -2,5 +2,3 @@ # modify to taste BINDIR?= /usr/bin - -WARNS?= 2 From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:32:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 32E8C66D8C2; Thu, 26 Aug 2021 17:32: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 4GwVKL0vYLz4nKn; Thu, 26 Aug 2021 17:32: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 07ECC14321; Thu, 26 Aug 2021 17:32: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 17QHWLsd023798; Thu, 26 Aug 2021 17:32:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QHWLXT023797; Thu, 26 Aug 2021 17:32:21 GMT (envelope-from git) Date: Thu, 26 Aug 2021 17:32:21 GMT Message-Id: <202108261732.17QHWLXT023797@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 26d79d40a74f - main - Hyper-V: hn: Enter network epoch when required MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 26d79d40a74fc804c76acd88a1f8f10f9827a2b3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:32:22 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=26d79d40a74fc804c76acd88a1f8f10f9827a2b3 commit 26d79d40a74fc804c76acd88a1f8f10f9827a2b3 Author: Michael Tuexen AuthorDate: 2021-08-26 17:27:04 +0000 Commit: Michael Tuexen CommitDate: 2021-08-26 17:32:00 +0000 Hyper-V: hn: Enter network epoch when required PR: 254695 --- sys/dev/hyperv/netvsc/if_hn.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index cd0b5a5fa8b9..0ec398bed670 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -2883,7 +2884,11 @@ static void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { #if defined(INET) || defined(INET6) + struct epoch_tracker et; + + NET_EPOCH_ENTER(et); tcp_lro_flush_all(&rxr->hn_lro); + NET_EPOCH_EXIT(et); #endif /* @@ -7459,6 +7464,7 @@ static void hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { + struct epoch_tracker et; const struct vmbus_chanpkt_rxbuf *pkt; const struct hn_nvs_hdr *nvs_hdr; int count, i, hlen; @@ -7496,6 +7502,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, return; } + NET_EPOCH_ENTER(et); /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; ++i) { int ofs, len; @@ -7511,6 +7518,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, rxr->rsc.is_last = (i == (count - 1)); hn_rndis_rxpkt(rxr, rxr->hn_rxbuf + ofs, len); } + NET_EPOCH_EXIT(et); /* * Ack the consumed RXBUF associated w/ this channel packet, From owner-dev-commits-src-all@freebsd.org Thu Aug 26 17:36:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B516D66DC83; Thu, 26 Aug 2021 17:36:58 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from drew.franken.de (mail-n.franken.de [193.175.24.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.franken.de", Issuer "Sectigo RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwVQf2gvpz4qCX; Thu, 26 Aug 2021 17:36:58 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from smtpclient.apple (ip1f100e9c.dynamic.kabel-deutschland.de [31.16.14.156]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTPSA id F34BA721E282D; Thu, 26 Aug 2021 19:36:49 +0200 (CEST) From: tuexen@freebsd.org Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: 26d79d40a74f - main - Hyper-V: hn: Enter network epoch when required Date: Thu, 26 Aug 2021 19:36:49 +0200 References: <202108261732.17QHWLXT023797@gitrepo.freebsd.org> To: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" In-Reply-To: <202108261732.17QHWLXT023797@gitrepo.freebsd.org> Message-Id: <62898771-43CF-42E3-81DF-E3467F5BD7C4@freebsd.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail-n.franken.de X-Rspamd-Queue-Id: 4GwVQf2gvpz4qCX X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:680, ipnet:193.174.0.0/15, country:DE] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 17:36:58 -0000 > On 26. Aug 2021, at 19:32, Michael Tuexen wrote: >=20 > The branch main has been updated by tuexen: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D26d79d40a74fc804c76acd88a1f8f10f= 9827a2b3 >=20 > commit 26d79d40a74fc804c76acd88a1f8f10f9827a2b3 > Author: Michael Tuexen > AuthorDate: 2021-08-26 17:27:04 +0000 > Commit: Michael Tuexen > CommitDate: 2021-08-26 17:32:00 +0000 >=20 > Hyper-V: hn: Enter network epoch when required >=20 > PR: 254695 Missing: Reviewed by: hselasky, gallatin Tested by: gbe MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D31679 > --- > sys/dev/hyperv/netvsc/if_hn.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/sys/dev/hyperv/netvsc/if_hn.c = b/sys/dev/hyperv/netvsc/if_hn.c > index cd0b5a5fa8b9..0ec398bed670 100644 > --- a/sys/dev/hyperv/netvsc/if_hn.c > +++ b/sys/dev/hyperv/netvsc/if_hn.c > @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include >=20 > #include > #include > @@ -2883,7 +2884,11 @@ static void > hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) > { > #if defined(INET) || defined(INET6) > + struct epoch_tracker et; > + > + NET_EPOCH_ENTER(et); > tcp_lro_flush_all(&rxr->hn_lro); > + NET_EPOCH_EXIT(et); > #endif >=20 > /* > @@ -7459,6 +7464,7 @@ static void > hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel = *chan, > const struct vmbus_chanpkt_hdr *pkthdr) > { > + struct epoch_tracker et; > const struct vmbus_chanpkt_rxbuf *pkt; > const struct hn_nvs_hdr *nvs_hdr; > int count, i, hlen; > @@ -7496,6 +7502,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, = struct vmbus_channel *chan, > return; > } >=20 > + NET_EPOCH_ENTER(et); > /* Each range represents 1 RNDIS pkt that contains 1 Ethernet = frame */ > for (i =3D 0; i < count; ++i) { > int ofs, len; > @@ -7511,6 +7518,7 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, = struct vmbus_channel *chan, > rxr->rsc.is_last =3D (i =3D=3D (count - 1)); > hn_rndis_rxpkt(rxr, rxr->hn_rxbuf + ofs, len); > } > + NET_EPOCH_EXIT(et); >=20 > /* > * Ack the consumed RXBUF associated w/ this channel packet, From owner-dev-commits-src-all@freebsd.org Thu Aug 26 18:09:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B34766E158; Thu, 26 Aug 2021 18:09: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 4GwW8L2nlhz3Fhr; Thu, 26 Aug 2021 18:09: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 4445E14A19; Thu, 26 Aug 2021 18:09: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 17QI9cxn065457; Thu, 26 Aug 2021 18:09:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QI9c1t065456; Thu, 26 Aug 2021 18:09:38 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:09:38 GMT Message-Id: <202108261809.17QI9c1t065456@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 5e9c2a6a9023 - stable/13 - Apply clang fix for assertion failure compiling multimedia/minitube MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5e9c2a6a902346a6d7d29bc8c81f0b3fcccaa57f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:09:38 -0000 The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5e9c2a6a902346a6d7d29bc8c81f0b3fcccaa57f commit 5e9c2a6a902346a6d7d29bc8c81f0b3fcccaa57f Author: Dimitry Andric AuthorDate: 2021-08-21 21:03:37 +0000 Commit: Dimitry Andric CommitDate: 2021-08-26 18:05:27 +0000 Apply clang fix for assertion failure compiling multimedia/minitube Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu): Do not merge LocalInstantiationScope for template specialization A lambda in a function template may be recursively instantiated. The recursive lambda will cause a lambda function instantiated multiple times, one inside another. The inner LocalInstantiationScope should not be marked as MergeWithParentScope since it already has references to locals properly substituted, otherwise it causes assertion due to the check for duplicate locals in merged LocalInstantiationScope. Reviewed by: Richard Smith Differential Revision: https://reviews.llvm.org/D98068 Reported by: yuri PR: 257978 (cherry picked from commit efa485d5c390b745f53761da9159721243c48b7b) --- .../llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index dc1e0ef60cac..216a64e02380 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4841,10 +4841,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // Introduce a new scope where local variable instantiations will be // recorded, unless we're actually a member function within a local // class, in which case we need to merge our results with the parent - // scope (of the enclosing function). + // scope (of the enclosing function). The exception is instantiating + // a function template specialization, since the template to be + // instantiated already has references to locals properly substituted. bool MergeWithParentScope = false; if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext())) - MergeWithParentScope = Rec->isLocalClass(); + MergeWithParentScope = + Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization(); LocalInstantiationScope Scope(*this, MergeWithParentScope); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 18:10:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5368A66E4BB; Thu, 26 Aug 2021 18:10: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 4GwW8p1x4yz3G4X; Thu, 26 Aug 2021 18:10: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 2A13614855; Thu, 26 Aug 2021 18:10: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 17QIA20q067373; Thu, 26 Aug 2021 18:10:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIA2wr067371; Thu, 26 Aug 2021 18:10:02 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:10:02 GMT Message-Id: <202108261810.17QIA2wr067371@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: d7d2f810f8a9 - stable/12 - Apply clang fix for assertion failure compiling multimedia/minitube MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d7d2f810f8a9a21282803bf886705656f1af26c3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:10:02 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=d7d2f810f8a9a21282803bf886705656f1af26c3 commit d7d2f810f8a9a21282803bf886705656f1af26c3 Author: Dimitry Andric AuthorDate: 2021-08-21 21:03:37 +0000 Commit: Dimitry Andric CommitDate: 2021-08-26 18:05:13 +0000 Apply clang fix for assertion failure compiling multimedia/minitube Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu): Do not merge LocalInstantiationScope for template specialization A lambda in a function template may be recursively instantiated. The recursive lambda will cause a lambda function instantiated multiple times, one inside another. The inner LocalInstantiationScope should not be marked as MergeWithParentScope since it already has references to locals properly substituted, otherwise it causes assertion due to the check for duplicate locals in merged LocalInstantiationScope. Reviewed by: Richard Smith Differential Revision: https://reviews.llvm.org/D98068 Reported by: yuri PR: 257978 (cherry picked from commit efa485d5c390b745f53761da9159721243c48b7b) --- .../llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index f801e79c8902..f36fa8d11b3b 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4658,10 +4658,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // Introduce a new scope where local variable instantiations will be // recorded, unless we're actually a member function within a local // class, in which case we need to merge our results with the parent - // scope (of the enclosing function). + // scope (of the enclosing function). The exception is instantiating + // a function template specialization, since the template to be + // instantiated already has references to locals properly substituted. bool MergeWithParentScope = false; if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext())) - MergeWithParentScope = Rec->isLocalClass(); + MergeWithParentScope = + Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization(); LocalInstantiationScope Scope(*this, MergeWithParentScope); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 18:10:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 963EC66E17D; Thu, 26 Aug 2021 18:10:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GwW993v83z3G8w; Thu, 26 Aug 2021 18:10:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6DF9F14B87; Thu, 26 Aug 2021 18:10: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 17QIALIh073677; Thu, 26 Aug 2021 18:10:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIALiD073669; Thu, 26 Aug 2021 18:10:21 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:10:21 GMT Message-Id: <202108261810.17QIALiD073669@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 9e1de6e82503 - stable/11 - Apply clang fix for assertion failure compiling multimedia/minitube MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 9e1de6e8250355cda0615332d43bbba61d4d873f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:10:21 -0000 The branch stable/11 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=9e1de6e8250355cda0615332d43bbba61d4d873f commit 9e1de6e8250355cda0615332d43bbba61d4d873f Author: Dimitry Andric AuthorDate: 2021-08-21 21:03:37 +0000 Commit: Dimitry Andric CommitDate: 2021-08-26 18:05:01 +0000 Apply clang fix for assertion failure compiling multimedia/minitube Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu): Do not merge LocalInstantiationScope for template specialization A lambda in a function template may be recursively instantiated. The recursive lambda will cause a lambda function instantiated multiple times, one inside another. The inner LocalInstantiationScope should not be marked as MergeWithParentScope since it already has references to locals properly substituted, otherwise it causes assertion due to the check for duplicate locals in merged LocalInstantiationScope. Reviewed by: Richard Smith Differential Revision: https://reviews.llvm.org/D98068 Reported by: yuri PR: 257978 (cherry picked from commit efa485d5c390b745f53761da9159721243c48b7b) --- .../llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index f801e79c8902..f36fa8d11b3b 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4658,10 +4658,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // Introduce a new scope where local variable instantiations will be // recorded, unless we're actually a member function within a local // class, in which case we need to merge our results with the parent - // scope (of the enclosing function). + // scope (of the enclosing function). The exception is instantiating + // a function template specialization, since the template to be + // instantiated already has references to locals properly substituted. bool MergeWithParentScope = false; if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext())) - MergeWithParentScope = Rec->isLocalClass(); + MergeWithParentScope = + Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization(); LocalInstantiationScope Scope(*this, MergeWithParentScope); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 18:15:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3311566E8E1; Thu, 26 Aug 2021 18:15: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 4GwWGm0m5Jz3Hdp; Thu, 26 Aug 2021 18:15: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 02B8314B4C; Thu, 26 Aug 2021 18:15: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 17QIFBgv078442; Thu, 26 Aug 2021 18:15:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIFBTf078441; Thu, 26 Aug 2021 18:15:11 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:15:11 GMT Message-Id: <202108261815.17QIFBTf078441@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 620cf65c2bc4 - main - netinet: prevent NULL pointer dereference in in_aifaddr_ioctl() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 620cf65c2bc4035a07e1152da419a4e60d36ff9b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:15:12 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=620cf65c2bc4035a07e1152da419a4e60d36ff9b commit 620cf65c2bc4035a07e1152da419a4e60d36ff9b Author: Artem Khramov AuthorDate: 2021-08-24 14:26:35 +0000 Commit: Warner Losh CommitDate: 2021-08-26 18:08:03 +0000 netinet: prevent NULL pointer dereference in in_aifaddr_ioctl() It appears that maliciously crafted ifaliasreq can lead to NULL pointer dereference in in_aifaddr_ioctl(). In order to replicate that, one needs to 1. Ensure that carp(4) is not loaded 2. Issue SIOCAIFADDR call setting ifra_vhid field of the request to a negative value. A repro code would look like this. int main() { struct ifaliasreq req; struct sockaddr_in sin, mask; int fd, error; bzero(&sin, sizeof(struct sockaddr_in)); bzero(&mask, sizeof(struct sockaddr_in)); sin.sin_len = sizeof(struct sockaddr_in); sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr("192.168.88.2"); mask.sin_len = sizeof(struct sockaddr_in); mask.sin_family = AF_INET; mask.sin_addr.s_addr = inet_addr("255.255.255.0"); fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) return (-1); memset(&req, 0, sizeof(struct ifaliasreq)); strlcpy(req.ifra_name, "lo0", sizeof(req.ifra_name)); memcpy(&req.ifra_addr, &sin, sin.sin_len); memcpy(&req.ifra_mask, &mask, mask.sin_len); req.ifra_vhid = -1; return ioctl(fd, SIOCAIFADDR, (char *)&req); } To fix, discard both positive and negative vhid values in in_aifaddr_ioctl, if carp(4) is not loaded. This prevents NULL pointer dereference and kernel panic. Reviewed by: imp@ Pull Request: https://github.com/freebsd/freebsd-src/pull/530 --- sys/netinet/in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index d1dd2b31b6ef..f9b46b414007 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -376,7 +376,7 @@ in_aifaddr_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, struct thread *td) (dstaddr->sin_len != sizeof(struct sockaddr_in) || dstaddr->sin_addr.s_addr == INADDR_ANY)) return (EDESTADDRREQ); - if (vhid > 0 && carp_attach_p == NULL) + if (vhid != 0 && carp_attach_p == NULL) return (EPROTONOSUPPORT); /* From owner-dev-commits-src-all@freebsd.org Thu Aug 26 18:52:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18F7266EC7B; Thu, 26 Aug 2021 18:52: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 4GwX6H0DBxz3hJN; Thu, 26 Aug 2021 18:52: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 E4EB5154A5; Thu, 26 Aug 2021 18:52: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 17QIqswP031010; Thu, 26 Aug 2021 18:52:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIqsuh031009; Thu, 26 Aug 2021 18:52:54 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:52:54 GMT Message-Id: <202108261852.17QIqsuh031009@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: f1e2cc1c667a - main - vfs: drop dedicated sysinit for mountlist_mtx MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f1e2cc1c667a4fd5f3f6097a1e7a4d13bb4d887e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:52:55 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f1e2cc1c667a4fd5f3f6097a1e7a4d13bb4d887e commit f1e2cc1c667a4fd5f3f6097a1e7a4d13bb4d887e Author: Mateusz Guzik AuthorDate: 2021-08-26 12:53:10 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-26 18:52:03 +0000 vfs: drop dedicated sysinit for mountlist_mtx Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 40581d9e6e79..73fd8321c9da 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -122,7 +122,6 @@ struct mntlist mountlist = TAILQ_HEAD_INITIALIZER(mountlist); /* For any iteration/modification of mountlist */ struct mtx_padalign __exclusive_cache_line mountlist_mtx; -MTX_SYSINIT(mountlist, &mountlist_mtx, "mountlist", MTX_DEF); EVENTHANDLER_LIST_DEFINE(vfs_mounted); EVENTHANDLER_LIST_DEFINE(vfs_unmounted); @@ -188,6 +187,7 @@ vfs_mount_init(void *dummy __unused) deferred_unmount_retry_delay_hz = hz; mount_zone = uma_zcreate("Mountpoints", sizeof(struct mount), NULL, NULL, mount_init, mount_fini, UMA_ALIGN_CACHE, UMA_ZONE_NOFREE); + mtx_init(&mountlist_mtx, "mountlist", NULL, MTX_DEF); } SYSINIT(vfs_mount, SI_SUB_VFS, SI_ORDER_ANY, vfs_mount_init, NULL); From owner-dev-commits-src-all@freebsd.org Thu Aug 26 18:53:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A27F066F2AF; Thu, 26 Aug 2021 18:53: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 4GwX7G1Vhtz3hx3; Thu, 26 Aug 2021 18:53: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 11A8815446; Thu, 26 Aug 2021 18:53: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 17QIrjiQ031203; Thu, 26 Aug 2021 18:53:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QIrjEs031202; Thu, 26 Aug 2021 18:53:45 GMT (envelope-from git) Date: Thu, 26 Aug 2021 18:53:45 GMT Message-Id: <202108261853.17QIrjEs031202@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: f643997a1761 - main - Cleanup compiler warning flags in lib/libefivar/Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f643997a1761689ef9108d69b86d42881ea0ab1c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 18:53:46 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=f643997a1761689ef9108d69b86d42881ea0ab1c commit f643997a1761689ef9108d69b86d42881ea0ab1c Author: Dimitry Andric AuthorDate: 2021-08-26 18:53:18 +0000 Commit: Dimitry Andric CommitDate: 2021-08-26 18:53:26 +0000 Cleanup compiler warning flags in lib/libefivar/Makefile There is no need to set -Wno-unused-parameter twice, and instead of appending to CFLAGS, append to CWARNFLAGS instead. While here, add -Wno-unused-but-set-variable for the sake of clang 13.0.0. MFC after: 3 days --- lib/libefivar/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libefivar/Makefile b/lib/libefivar/Makefile index 3c6b17333407..c1503f4e5b62 100644 --- a/lib/libefivar/Makefile +++ b/lib/libefivar/Makefile @@ -43,8 +43,7 @@ MAN= efivar.3 CFLAGS+= -I${EFIBOOT}/include CFLAGS+= -I${.CURDIR} -I${EDK2INC} - -CFLAGS.efivar-dp-format.c=-Wno-unused-parameter +CFLAGS+= -fno-strict-aliasing MLINKS+=efivar.3 efi_set_variables_supported.3 \ efivar.3 efi_del_variable.3 \ @@ -65,4 +64,9 @@ WARNS?= 9 .include -CFLAGS+= -fno-strict-aliasing -Wno-cast-align -Wno-unused-parameter +CWARNFLAGS+= -Wno-cast-align +CWARNFLAGS+= -Wno-unused-parameter + +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 130000 +CWARNFLAGS+= -Wno-unused-but-set-variable +.endif From owner-dev-commits-src-all@freebsd.org Thu Aug 26 20:10:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 21B5B67065F; Thu, 26 Aug 2021 20:10: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 4GwYqM0LPfz4YN5; Thu, 26 Aug 2021 20:10: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 E3DD4162E9; Thu, 26 Aug 2021 20:10: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 17QKA6XI028307; Thu, 26 Aug 2021 20:10:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17QKA6b1028304; Thu, 26 Aug 2021 20:10:06 GMT (envelope-from git) Date: Thu, 26 Aug 2021 20:10:06 GMT Message-Id: <202108262010.17QKA6b1028304@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: d396c67f26b0 - main - googletest: Silence warnings about deprecated implicit copy constructors MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d396c67f26b079c2808002c07212d9df9818a11b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 20:10:07 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=d396c67f26b079c2808002c07212d9df9818a11b commit d396c67f26b079c2808002c07212d9df9818a11b Author: Dimitry Andric AuthorDate: 2021-08-26 20:06:49 +0000 Commit: Dimitry Andric CommitDate: 2021-08-26 20:06:53 +0000 googletest: Silence warnings about deprecated implicit copy constructors Our copy of googletest is rather stale, and causes a number of -Werror warnings about implicit copy constructor definitions being deprecated, because several classes have user-declared copy assignment operators. Silence the warnings until we either upgrade or remove googletest. MFC after: 3 days --- lib/googletest/Makefile.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc index 36f7228c079b..b77322df4ee2 100644 --- a/lib/googletest/Makefile.inc +++ b/lib/googletest/Makefile.inc @@ -10,3 +10,6 @@ CXXFLAGS+= ${GTESTS_FLAGS} # Silence warnings about usage of deprecated std::auto_ptr CXXWARNFLAGS+= -Wno-deprecated-declarations + +# Silence warnings about usage of deprecated implicit copy constructors +CXXWARNFLAGS+= -Wno-deprecated-copy From owner-dev-commits-src-all@freebsd.org Fri Aug 27 00:39:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8168D673F55; Fri, 27 Aug 2021 00:39: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 4GwgpF2C25z4YqV; Fri, 27 Aug 2021 00: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 1819619B9C; Fri, 27 Aug 2021 00: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 17R0dXQa084645; Fri, 27 Aug 2021 00: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 17R0dWZj084644; Fri, 27 Aug 2021 00:39:32 GMT (envelope-from git) Date: Fri, 27 Aug 2021 00:39:32 GMT Message-Id: <202108270039.17R0dWZj084644@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 15cb3b5404bd - main - pcib(4): Write window registers after resource adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 15cb3b5404bd3181c0fbdc056f5a5299876f8f39 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 00:39:33 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=15cb3b5404bd3181c0fbdc056f5a5299876f8f39 commit 15cb3b5404bd3181c0fbdc056f5a5299876f8f39 Author: Alexander Motin AuthorDate: 2021-08-27 00:21:56 +0000 Commit: Alexander Motin CommitDate: 2021-08-27 00:39:27 +0000 pcib(4): Write window registers after resource adjustment When adjusting resources we should write updated window base/limit into the registers. Without this newly added address range won't be routed through the bridge properly. Use MIN()/MAX() against current window base/limit to not shrink it on the other side if the window is shared by several resources. Align passed resource start/end to the set window granularity to keep it properly aligned. Currently this is mostly called by other bridges having the same window alignment, but it may be change one day. Reviewed by: jrtc27, jhb MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D31693 --- sys/dev/pci/pci_pci.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 83106eaa455b..33e277ed01ae 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -2345,6 +2345,7 @@ pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, { struct pcib_softc *sc; struct pcib_window *w; + rman_res_t wmask; int error; sc = device_get_softc(bus); @@ -2375,9 +2376,18 @@ pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, * then we need to expand the window. */ if (start < w->base || end > w->limit) { - error = pcib_expand_window(sc, w, type, start, end); + wmask = ((rman_res_t)1 << w->step) - 1; + error = pcib_expand_window(sc, w, type, + MIN(start & ~wmask, w->base), + MAX(end | wmask, w->limit)); if (error != 0) return (error); + if (bootverbose) + device_printf(sc->dev, + "grew %s window to %#jx-%#jx\n", + w->name, (uintmax_t)w->base, + (uintmax_t)w->limit); + pcib_write_windows(sc, w->mask); } } From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:01:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0ECCC674597; Fri, 27 Aug 2021 01:01: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 4GwhH66zd3z4g4L; Fri, 27 Aug 2021 01:01: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 D856C1A304; Fri, 27 Aug 2021 01:01: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 17R1163P019997; Fri, 27 Aug 2021 01:01:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1164o019996; Fri, 27 Aug 2021 01:01:06 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:01:06 GMT Message-Id: <202108270101.17R1164o019996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: c5af0ac1a732 - main - Add support for recording EC2 AMI Ids in SSM MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c5af0ac1a732491aab789dda0da368ff48497871 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:01:07 -0000 The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=c5af0ac1a732491aab789dda0da368ff48497871 commit c5af0ac1a732491aab789dda0da368ff48497871 Author: Colin Percival AuthorDate: 2021-08-27 00:54:53 +0000 Commit: Colin Percival CommitDate: 2021-08-27 01:01:02 +0000 Add support for recording EC2 AMI Ids in SSM If SSMPREFIX is specified, AMI Ids will be recorded in the SSM Parameter Store under the name ${SSMPREFIX}/${ARCH}/${FLAVOUR}/${ROOTFS}/${REVISION}/${BRANCH} where ARCH is "amd64" or "arm64", FLAVOUR is "base" (but may have other options in the future), ROOTFS is "ufs" (but may have other options in the future), and REVISION and BRANCH have their normal meanings. FreeBSD will be using the public prefix "/aws/service/freebsd", resulting in SSM Parameter names which look like /aws/service/freebsd/amd64/base/ufs/14.0/CURRENT Relnotes: yes Sponsored by: https://patreon.com/cperciva MFC after: 2 weeks --- release/Makefile.ec2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release/Makefile.ec2 b/release/Makefile.ec2 index 171de4ee2fa0..5683cb6634b6 100644 --- a/release/Makefile.ec2 +++ b/release/Makefile.ec2 @@ -18,6 +18,9 @@ PUBLICSNAP= --publicsnap EC2SNSREL= ${REVISION}-${BRANCH} EC2SNSVERS= ${GITBRANCH}@${GITREV} .endif +.if defined(SSMPREFIX) && !empty(SSMPREFIX) +SSMOPTS= --ssm-name ${SSMPREFIX}/${TARGET_ARCH:S/aarch64/arm64/}/base/ufs/${REVISION}/${BRANCH} +.endif .if ${TARGET_ARCH} != "amd64" EC2ARCH= --${TARGET_ARCH:S/aarch64/arm64/} .endif @@ -62,7 +65,7 @@ ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL} @false .endif /usr/local/bin/bsdec2-image-upload ${PUBLISH} ${PUBLICSNAP} \ - ${EC2ARCH} --sriov --ena \ + ${EC2ARCH} ${SSMOPTS} --sriov --ena \ ${.OBJDIR}/ec2.raw \ "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \ "${TYPE}/${TARGET} ${GITBRANCH}@${GITREV}" \ From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:08:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B36667461E; Fri, 27 Aug 2021 01:08: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 4GwhSB1vmgz4ht3; Fri, 27 Aug 2021 01:08: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 287D01A2BF; Fri, 27 Aug 2021 01:08: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 17R18wOv025206; Fri, 27 Aug 2021 01:08:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R18wBY025205; Fri, 27 Aug 2021 01:08:58 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:08:58 GMT Message-Id: <202108270108.17R18wBY025205@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: 96f65d85d431 - stable/13 - nfsd: Fix sanity check for NFSv4.2 Allocate operations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 96f65d85d43167e3e65738c2b93414dea071015a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:08:58 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=96f65d85d43167e3e65738c2b93414dea071015a commit 96f65d85d43167e3e65738c2b93414dea071015a Author: Rick Macklem AuthorDate: 2021-08-12 23:48:28 +0000 Commit: Rick Macklem CommitDate: 2021-08-27 01:05:28 +0000 nfsd: Fix sanity check for NFSv4.2 Allocate operations The NFSv4.2 Allocate operation sanity checks the aa_offset and aa_length arguments. Since they are assigned to variables of type off_t (signed) it was possible for them to be negative. It was also possible for aa_offset+aa_length to exceed OFF_MAX when stored in lo_end, which is uint64_t. This patch adds checks for these cases to the sanity check. (cherry picked from commit 06afb53bcd7b6a928bc90acb820383302ea8be9e) --- sys/fs/nfsserver/nfs_nfsdserv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 0ba3472b4ff9..12181d04f1fa 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -5347,12 +5347,18 @@ nfsrvd_allocate(struct nfsrv_descript *nd, __unused int isdgram, off = fxdr_hyper(tl); tl += 2; lop->lo_first = off; len = fxdr_hyper(tl); - lop->lo_end = off + len; + lop->lo_end = lop->lo_first + len; /* - * Paranoia, just in case it wraps around, which shouldn't - * ever happen anyhow. + * Sanity check the offset and length. + * off and len are off_t (signed int64_t) whereas + * lo_first and lo_end are uint64_t and, as such, + * if off >= 0 && len > 0, lo_end cannot overflow + * unless off_t is changed to something other than + * int64_t. Check lo_end < lo_first in case that + * is someday the case. */ - if (nd->nd_repstat == 0 && (lop->lo_end < lop->lo_first || len <= 0)) + if (nd->nd_repstat == 0 && (len <= 0 || off < 0 || lop->lo_end > + OFF_MAX || lop->lo_end < lop->lo_first)) nd->nd_repstat = NFSERR_INVAL; if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG) From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:12:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ADE0D674B06; Fri, 27 Aug 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 4GwhXF4BFxz4jhj; Fri, 27 Aug 2021 01:12:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 77A571A595; Fri, 27 Aug 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 17R1CT6w037798; Fri, 27 Aug 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 17R1CTNH037797; Fri, 27 Aug 2021 01:12:29 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:29 GMT Message-Id: <202108270112.17R1CTNH037797@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: edcdb6d19e1b - stable/12 - devclass_alloc_unit: move "at" hint test to after device-in-use test 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: edcdb6d19e1b03170a6ba37f45e23ef64b5d8d1d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:29 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=edcdb6d19e1b03170a6ba37f45e23ef64b5d8d1d commit edcdb6d19e1b03170a6ba37f45e23ef64b5d8d1d Author: Adam Fenn AuthorDate: 2021-08-02 16:27:17 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 devclass_alloc_unit: move "at" hint test to after device-in-use test Only perform this expensive operation when the unit number is a potential candidate (i.e. not already in use), thereby reducing device scan time on systems with many devices, unit numbers, and drivers. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #61 (cherry picked from commit 8ca384eb1d429aae866f53abfadafc71ab009dc6) --- sys/kern/subr_bus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 8ecbd3f71d9a..46c098237f48 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1663,15 +1663,15 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp) /* Unwired device, find the next available slot for it */ unit = 0; for (unit = 0;; unit++) { + /* If this device slot is already in use, skip it. */ + if (unit < dc->maxunit && dc->devices[unit] != NULL) + continue; + /* If there is an "at" hint for a unit then skip it. */ if (resource_string_value(dc->name, unit, "at", &s) == 0) continue; - /* If this device slot is already in use, skip it. */ - if (unit < dc->maxunit && dc->devices[unit] != NULL) - continue; - break; } } From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:12:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8FB6E67417A; Fri, 27 Aug 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 4GwhXG6kW8z4jhp; Fri, 27 Aug 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 A59631A596; Fri, 27 Aug 2021 01:12: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 17R1CUiP037822; Fri, 27 Aug 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 17R1CU80037821; Fri, 27 Aug 2021 01:12:30 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:30 GMT Message-Id: <202108270112.17R1CU80037821@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: b3e2d70a7f30 - stable/12 - malloc(9): Document/complete aligned variants 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: b3e2d70a7f301d21f38e38983677989dc88a6c3f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:31 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=b3e2d70a7f301d21f38e38983677989dc88a6c3f commit b3e2d70a7f301d21f38e38983677989dc88a6c3f Author: Adam Fenn AuthorDate: 2021-08-02 20:33:31 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 malloc(9): Document/complete aligned variants Comments on a pending kvmclock driver suggested adding a malloc_aligned() to complement malloc_domainset_aligned(); add it now, and document both. (cherry picked from commit 6162cf885c00a0893a0961415f1829942343dcc1) (cherry picked from commit 04cc0c393c317b6d5e28c8dc80cd1b5ea071f28f) --- share/man/man9/malloc.9 | 25 ++++++++++++++++++++++++- sys/kern/kern_malloc.c | 7 +++++++ sys/sys/malloc.h | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9 index bdfdaca6bba9..a42183bb476c 100644 --- a/share/man/man9/malloc.9 +++ b/share/man/man9/malloc.9 @@ -29,7 +29,7 @@ .\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $ .\" $FreeBSD$ .\" -.Dd March 6, 2021 +.Dd August 26, 2021 .Dt MALLOC 9 .Os .Sh NAME @@ -55,6 +55,13 @@ .Fn reallocf "void *addr" "size_t size" "struct malloc_type *type" "int flags" .Ft size_t .Fn malloc_usable_size "const void *addr" +.Ft void * +.Fo malloc_aligned +.Fa "size_t size" +.Fa "size_t align" +.Fa "struct malloc_type *type" +.Fa "int flags" +.Fc .Fn MALLOC_DECLARE type .In sys/param.h .In sys/malloc.h @@ -65,6 +72,14 @@ .Ft void * .Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" .Ft void * +.Fo malloc_domainset_aligned +.Fa "size_t size" +.Fa "size_t align" +.Fa "struct malloc_type *type" +.Fa "struct domainset *ds" +.Fa "int flags" +.Fc +.Ft void * .Fn mallocarray_domainset "size_t nmemb" "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags" .Ft void .Fn free_domain "void *addr" "struct malloc_type *type" @@ -87,6 +102,14 @@ Memory allocated with this function should be returned with .Fn free_domain . .Pp The +.Fn malloc_aligned +and +.Fn malloc_domainset_aligned +variants return allocations aligned as specified by +.Fa align , +which must be non-zero, a power of two, and less than or equal to the page size. +.Pp +The .Fn mallocarray function allocates uninitialized memory in kernel address space for an array of diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 41eef1d6a4ac..f16163d396e2 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -658,6 +658,13 @@ malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds, return (ret); } +void * +malloc_aligned(size_t size, size_t align, struct malloc_type *type, int flags) +{ + return (malloc_domainset_aligned(size, align, type, DOMAINSET_RR(), + flags)); +} + void * malloc_domainset_aligned(size_t size, size_t align, struct malloc_type *mtp, struct domainset *ds, int flags) diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index bf7ec5c8e9c6..4459176ca9d3 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -252,6 +252,8 @@ void *realloc(void *addr, size_t size, struct malloc_type *type, int flags) __result_use_check __alloc_size(2); void *reallocf(void *addr, size_t size, struct malloc_type *type, int flags) __result_use_check __alloc_size(2); +void *malloc_aligned(size_t size, size_t align, struct malloc_type *type, + int flags) __malloc_like __result_use_check __alloc_size(1); void *malloc_domainset_aligned(size_t size, size_t align, struct malloc_type *mtp, struct domainset *ds, int flags) __malloc_like __result_use_check __alloc_size(1); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:12:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6787B6743FE; Fri, 27 Aug 2021 01:12: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 4GwhXL01Qjz4jc3; Fri, 27 Aug 2021 01:12: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 214671A523; Fri, 27 Aug 2021 01:12: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 17R1CWqC037877; Fri, 27 Aug 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 17R1CWoW037876; Fri, 27 Aug 2021 01:12:32 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:32 GMT Message-Id: <202108270112.17R1CWoW037876@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: 96a692ed6ff4 - stable/12 - pkg: use specific CONFSNAME_${file} for FreeBSD.conf 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: 96a692ed6ff41d4f20ce40f6e250b03c606fb986 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:34 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=96a692ed6ff41d4f20ce40f6e250b03c606fb986 commit 96a692ed6ff41d4f20ce40f6e250b03c606fb986 Author: Kyle Evans AuthorDate: 2021-02-18 04:10:46 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 pkg: use specific CONFSNAME_${file} for FreeBSD.conf Setting CONFSNAME directly is a little more complicated for downstream consumers, as any additional CONFS that are added here will inherit the group name by default. This is perhaps arguably a design flaw in CONFS because inheriting NAME will never give a good result when additional files are added, but this is a low-effort change. While we're here, pull FreeBSD.conf.${branch} out into a PKGCONF variable so one can just drop a new repo config in entirely with a new naming scheme. CONFSNAME gets set based on chopping anything off after ".conf", so that, e.g.: - FooBSD.conf => FooBSD.conf - FooBSD.conf.internal => FooBSD.conf (cherry picked from commit d35164539b14a6d14fb587e58a0c7a1668d7643a) --- usr.sbin/pkg/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile index 725367ad4485..3e3b99372786 100644 --- a/usr.sbin/pkg/Makefile +++ b/usr.sbin/pkg/Makefile @@ -15,8 +15,9 @@ PKGCONFBRANCH?= latest . endif . endif .endif -CONFS= FreeBSD.conf.${PKGCONFBRANCH} -CONFSNAME= FreeBSD.conf +PKGCONF?= FreeBSD.conf.${PKGCONFBRANCH} +CONFS= ${PKGCONF} +CONFSNAME_${PKGCONF}= ${PKGCONF:C/\.conf.+$/.conf/} CONFSDIR= /etc/pkg CONFSMODE= 644 PROG= pkg From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:12:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54F5E674C80; Fri, 27 Aug 2021 01:12: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 4GwhXM2kFZz4k1M; Fri, 27 Aug 2021 01:12: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 2CCD21A3B7; Fri, 27 Aug 2021 01:12: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 17R1CZh6037925; Fri, 27 Aug 2021 01:12:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1CZTd037924; Fri, 27 Aug 2021 01:12:35 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:35 GMT Message-Id: <202108270112.17R1CZTd037924@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: 46e1f6a8b7b3 - stable/12 - crunchide: address complaints from WARNS=6 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: 46e1f6a8b7b31679e73a4ec1575bc995b142e122 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:36 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=46e1f6a8b7b31679e73a4ec1575bc995b142e122 commit 46e1f6a8b7b31679e73a4ec1575bc995b142e122 Author: Kyle Evans AuthorDate: 2021-08-19 06:17:36 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 crunchide: address complaints from WARNS=6 - One (1) constify - One (1) argument is unused - One (1) local shadows a global - Various globals that should be static (cherry picked from commit dd7c7ff192d07912fb7f5874868649c3aa05944a) --- usr.sbin/crunch/crunchide/crunchide.c | 8 ++++---- usr.sbin/crunch/crunchide/exec_elf32.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/usr.sbin/crunch/crunchide/crunchide.c b/usr.sbin/crunch/crunchide/crunchide.c index b7eba3995173..324402501491 100644 --- a/usr.sbin/crunch/crunchide/crunchide.c +++ b/usr.sbin/crunch/crunchide/crunchide.c @@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$"); #include "extern.h" -char *pname = "crunchide"; +static const char *pname = "crunchide"; void usage(void); @@ -85,7 +85,7 @@ void add_file_to_keep_list(char *filename); int hide_syms(const char *filename); -int verbose; +static int verbose; int main(int, char *[]); @@ -137,7 +137,7 @@ usage(void) /* ---------------------------- */ -struct keep { +static struct keep { struct keep *next; char *sym; } *keep_list; @@ -206,7 +206,7 @@ add_file_to_keep_list(char *filename) /* ---------------------------- */ -struct { +static struct { const char *name; int (*check)(int, const char *); /* 1 if match, zero if not */ int (*hide)(int, const char *); /* non-zero if error */ diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c index 28641107cc5c..f7b8601911fe 100644 --- a/usr.sbin/crunch/crunchide/exec_elf32.c +++ b/usr.sbin/crunch/crunchide/exec_elf32.c @@ -155,7 +155,7 @@ xrealloc(void *ptr, size_t size, const char *fn, const char *use) } int -ELFNAMEEND(check)(int fd, const char *fn) +ELFNAMEEND(check)(int fd, const char *fn __unused) { Elf_Ehdr eh; struct stat sb; @@ -435,12 +435,12 @@ ELFNAMEEND(hide)(int fd, const char *fn) * update section header table in ascending order of offset */ for (i = strtabidx + 1; i < shnum; i++) { - Elf_Off off, align; - off = xewtoh(layoutp[i - 1].shdr->sh_offset) + + Elf_Off soff, align; + soff = xewtoh(layoutp[i - 1].shdr->sh_offset) + xewtoh(layoutp[i - 1].shdr->sh_size); align = xewtoh(layoutp[i].shdr->sh_addralign); - off = (off + (align - 1)) & ~(align - 1); - layoutp[i].shdr->sh_offset = htoxew(off); + soff = (soff + (align - 1)) & ~(align - 1); + layoutp[i].shdr->sh_offset = htoxew(soff); } /* From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:12:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 00956674AB9; Fri, 27 Aug 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 4GwhXJ1S7fz4jdy; Fri, 27 Aug 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 C46BF1A6C9; Fri, 27 Aug 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 17R1CVVu037852; Fri, 27 Aug 2021 01:12:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1CVop037851; Fri, 27 Aug 2021 01:12:31 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:31 GMT Message-Id: <202108270112.17R1CVop037851@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: 6cd271fbc243 - stable/12 - pkg: allow multiple add arguments again 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: 6cd271fbc243b9b2c6e657cd7772e3bafa210be0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:34 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=6cd271fbc243b9b2c6e657cd7772e3bafa210be0 commit 6cd271fbc243b9b2c6e657cd7772e3bafa210be0 Author: Kyle Evans AuthorDate: 2021-02-18 03:41:53 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 pkg: allow multiple add arguments again While pkg(7) add only handles a single 'add' argument, pkg-add(8) fully handles multiple arguments. Stop rejecting it, just turn off local-bootstrap mode and proceed to remote bootstrap if we need it. While we're here, check if the first argument to pkg add is even a pkg package. If it's not, also do remote bootstrap instead. Future work could improve this altogether by picking out a pkg package out of many and local bootstrap then pass the rest through to the newly installed pkg. (cherry picked from commit 40b9f924b189ce8fa871db600b4abc99b03c6a65) --- usr.sbin/pkg/pkg.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index da3498438fa1..7f66bdf663d3 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -1056,6 +1056,40 @@ cleanup: return (ret); } +#define PKG_NAME "pkg" +#define PKG_DEVEL_NAME PKG_NAME "-devel" +#define PKG_PKG PKG_NAME "." + +static bool +pkg_is_pkg_pkg(const char *pkg) +{ + char *vstart; + size_t namelen; + + /* + * Chop off the final "-" (version delimiter) and check the name that + * precedes it. If we didn't have a version delimiter, it must be the + * pkg.$archive short form but we'll check it anyways. pkg-devel short + * form will look like a pkg archive with 'devel' version, but that's + * OK. We otherwise assumed that non-pkg packages will always have a + * version component. + */ + vstart = strrchr(pkg, '-'); + if (vstart == NULL) { + return (strlen(pkg) > sizeof(PKG_PKG) - 1 && + strncmp(pkg, PKG_PKG, sizeof(PKG_PKG) - 1) == 0); + } + + namelen = vstart - pkg; + if (namelen == sizeof(PKG_NAME) - 1 && + strncmp(pkg, PKG_NAME, sizeof(PKG_NAME) - 1) == 0) + return (true); + if (namelen == sizeof(PKG_DEVEL_NAME) - 1 && + strncmp(pkg, PKG_DEVEL_NAME, sizeof(PKG_DEVEL_NAME) - 1) == 0) + return (true); + return (false); +} + int main(int argc, char *argv[]) { @@ -1160,13 +1194,25 @@ main(int argc, char *argv[]) fprintf(stderr, args_bootstrap_message); exit(EXIT_FAILURE); } - // For add, we accept exactly one further argument else if (add_pkg && pkgarg != NULL) { - fprintf(stderr, args_add_message); - exit(EXIT_FAILURE); + /* + * Additional arguments also means it's not a + * local bootstrap request. + */ + add_pkg = false; } else if (add_pkg) { - pkgarg = argv[optind-1]; + /* + * If it's not a request for pkg or pkg-devel, + * then we must assume they were trying to + * install some other local package and we + * should try to bootstrap from the repo. + */ + if (!pkg_is_pkg_pkg(argv[optind-1])) { + add_pkg = false; + } else { + pkgarg = argv[optind-1]; + } } break; default: From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:12:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F27C2674B18; Fri, 27 Aug 2021 01:12: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 4GwhXL3Nyfz4jnH; Fri, 27 Aug 2021 01:12: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 365921A700; Fri, 27 Aug 2021 01:12: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 17R1CXeJ037901; Fri, 27 Aug 2021 01:12:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1CXwo037900; Fri, 27 Aug 2021 01:12:33 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:33 GMT Message-Id: <202108270112.17R1CXwo037900@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: bb194ea3356a - stable/12 - crunchgen: sprinkle some const-poisoning around 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: bb194ea3356aaa18901279f538d293864c3118ab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:36 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=bb194ea3356aaa18901279f538d293864c3118ab commit bb194ea3356aaa18901279f538d293864c3118ab Author: Kyle Evans AuthorDate: 2021-08-19 06:13:13 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 crunchgen: sprinkle some const-poisoning around (cherry picked from commit db7f7446b5bcb26c7aaf13c8151b4ae8051c5732) --- usr.sbin/crunch/crunchgen/crunchgen.c | 10 +++++----- usr.sbin/crunch/crunchgen/mkskel.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index 95ed5ca6636a..c6cf2a08cc7b 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -96,8 +96,8 @@ char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], execfname[MAXPATHLEN]; char tempfname[MAXPATHLEN], cachename[MAXPATHLEN], curfilename[MAXPATHLEN]; bool tempfname_initialized = false; char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */ -char *objprefix; /* where are the objects ? */ -char *path_make; +const char *objprefix; /* where are the objects ? */ +const char *path_make; int linenum = -1; int goterror = 0; @@ -123,7 +123,7 @@ void usage(void); void parse_conf_file(void); void gen_outputs(void); -extern char *crunched_skel[]; +extern const char *crunched_skel[]; int @@ -721,7 +721,7 @@ fillin_program_objs(prog_t *p, char *path) char *obj, *cp; int fd, rc; FILE *f; - char *objvar="OBJS"; + const char *objvar="OBJS"; strlst_t *s; char line[MAXLINELEN]; @@ -912,7 +912,7 @@ gen_output_makefile(void) void gen_output_cfile(void) { - char **cp; + const char **cp; FILE *outcf; prog_t *p; strlst_t *s; diff --git a/usr.sbin/crunch/crunchgen/mkskel.sh b/usr.sbin/crunch/crunchgen/mkskel.sh index fd53d78bbbac..274bb7274cbd 100644 --- a/usr.sbin/crunch/crunchgen/mkskel.sh +++ b/usr.sbin/crunch/crunchgen/mkskel.sh @@ -4,7 +4,7 @@ cat < Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C33DB674B92; Fri, 27 Aug 2021 01:12: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 4GwhXQ0h5Vz4jsS; Fri, 27 Aug 2021 01:12: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 67C421A34C; Fri, 27 Aug 2021 01:12: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 17R1CbhD037973; Fri, 27 Aug 2021 01:12:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1CbYv037972; Fri, 27 Aug 2021 01:12:37 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:37 GMT Message-Id: <202108270112.17R1CbYv037972@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: 62885c0f0e57 - stable/12 - crunchgen: fix remaining issues under WARNS=6 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: 62885c0f0e57aa39c9a374a9bbd2147519a5003e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:39 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=62885c0f0e57aa39c9a374a9bbd2147519a5003e commit 62885c0f0e57aa39c9a374a9bbd2147519a5003e Author: Kyle Evans AuthorDate: 2021-08-19 06:22:16 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 crunchgen: fix remaining issues under WARNS=6 Entirely variables that should be static, save for one 'no previous declaration' in mkskel.sh. (cherry picked from commit bfd70233c3e2bc5c29db6f96fb90b58439908d29) --- usr.sbin/crunch/crunchgen/crunchgen.c | 43 ++++++++++++++++++----------------- usr.sbin/crunch/crunchgen/mkskel.sh | 1 + 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index c6cf2a08cc7b..94792c5ec50b 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -85,27 +85,28 @@ typedef struct prog { /* global state */ -strlst_t *buildopts = NULL; -strlst_t *srcdirs = NULL; -strlst_t *libs = NULL; -strlst_t *libs_so = NULL; -prog_t *progs = NULL; - -char confname[MAXPATHLEN], infilename[MAXPATHLEN]; -char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], execfname[MAXPATHLEN]; -char tempfname[MAXPATHLEN], cachename[MAXPATHLEN], curfilename[MAXPATHLEN]; -bool tempfname_initialized = false; -char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */ -const char *objprefix; /* where are the objects ? */ -const char *path_make; -int linenum = -1; -int goterror = 0; - -int verbose, readcache; /* options */ -int reading_cache; -int makeobj = 0; /* add 'make obj' rules to the makefile */ - -int list_mode; +static strlst_t *buildopts = NULL; +static strlst_t *srcdirs = NULL; +static strlst_t *libs = NULL; +static strlst_t *libs_so = NULL; +static prog_t *progs = NULL; + +static char confname[MAXPATHLEN], infilename[MAXPATHLEN]; +static char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], execfname[MAXPATHLEN]; +static char tempfname[MAXPATHLEN], cachename[MAXPATHLEN]; +static char curfilename[MAXPATHLEN]; +static bool tempfname_initialized = false; +static char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */ +static const char *objprefix; /* where are the objects ? */ +static const char *path_make; +static int linenum = -1; +static int goterror = 0; + +static int verbose, readcache; /* options */ +static int reading_cache; +static int makeobj = 0; /* add 'make obj' rules to the makefile */ + +static int list_mode; /* general library routines */ diff --git a/usr.sbin/crunch/crunchgen/mkskel.sh b/usr.sbin/crunch/crunchgen/mkskel.sh index 274bb7274cbd..3e5a1618e4ad 100644 --- a/usr.sbin/crunch/crunchgen/mkskel.sh +++ b/usr.sbin/crunch/crunchgen/mkskel.sh @@ -4,6 +4,7 @@ cat < Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5BD3D6745F8; Fri, 27 Aug 2021 01:12: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 4GwhXR06Y2z4jj1; Fri, 27 Aug 2021 01:12: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 88F0D1A701; Fri, 27 Aug 2021 01:12: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 17R1CcKe038003; Fri, 27 Aug 2021 01:12:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1Ccq1038002; Fri, 27 Aug 2021 01:12:38 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:38 GMT Message-Id: <202108270112.17R1Ccq1038002@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: f96130dbeeb1 - stable/12 - crunch: drop WARNS override 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: f96130dbeeb1baf3480d5b95cfa34bd16650f17b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:41 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=f96130dbeeb1baf3480d5b95cfa34bd16650f17b commit f96130dbeeb1baf3480d5b95cfa34bd16650f17b Author: Kyle Evans AuthorDate: 2021-08-19 06:33:13 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 crunch: drop WARNS override crunchide and crunchgen now build fine with default WARNS (cherry picked from commit d59c5e023d558161e4f519b88d5209d8bab18bc7) --- usr.sbin/crunch/Makefile.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/usr.sbin/crunch/Makefile.inc b/usr.sbin/crunch/Makefile.inc index 36175b7e5258..f8ffe675db6e 100644 --- a/usr.sbin/crunch/Makefile.inc +++ b/usr.sbin/crunch/Makefile.inc @@ -2,5 +2,3 @@ # modify to taste BINDIR?= /usr/bin - -WARNS?= 2 From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:12:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA833674B1A; Fri, 27 Aug 2021 01:12: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 4GwhXP1DjTz4jvY; Fri, 27 Aug 2021 01:12: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 66EF11A3B8; Fri, 27 Aug 2021 01:12: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 17R1CaOp037949; Fri, 27 Aug 2021 01:12:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1CaLF037948; Fri, 27 Aug 2021 01:12:36 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:12:36 GMT Message-Id: <202108270112.17R1CaLF037948@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: 5c22fa5d0713 - stable/12 - crunchide: static'ify remaining non-exported functions 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: 5c22fa5d071355d88dd81959ba1f4bb9887e9aa4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:12:38 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=5c22fa5d071355d88dd81959ba1f4bb9887e9aa4 commit 5c22fa5d071355d88dd81959ba1f4bb9887e9aa4 Author: Kyle Evans AuthorDate: 2021-08-19 06:29:02 +0000 Commit: Kyle Evans CommitDate: 2021-08-27 01:10:58 +0000 crunchide: static'ify remaining non-exported functions (cherry picked from commit 7ff87026d65c77f90391ead3f2fc752223d16e01) --- usr.sbin/crunch/crunchide/crunchide.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.sbin/crunch/crunchide/crunchide.c b/usr.sbin/crunch/crunchide/crunchide.c index 324402501491..1f2f98893bac 100644 --- a/usr.sbin/crunch/crunchide/crunchide.c +++ b/usr.sbin/crunch/crunchide/crunchide.c @@ -78,12 +78,12 @@ __FBSDID("$FreeBSD$"); static const char *pname = "crunchide"; -void usage(void); +static void usage(void); -void add_to_keep_list(char *symbol); -void add_file_to_keep_list(char *filename); +static void add_to_keep_list(char *symbol); +static void add_file_to_keep_list(char *filename); -int hide_syms(const char *filename); +static int hide_syms(const char *filename); static int verbose; @@ -126,7 +126,7 @@ main(int argc, char **argv) return errors; } -void +static void usage(void) { fprintf(stderr, @@ -142,7 +142,7 @@ static struct keep { char *sym; } *keep_list; -void +static void add_to_keep_list(char *symbol) { struct keep *newp, *prevp, *curp; @@ -182,7 +182,7 @@ in_keep_list(const char *symbol) return curp && cmp == 0; } -void +static void add_file_to_keep_list(char *filename) { FILE *keepf; @@ -219,7 +219,7 @@ static struct { #endif }; -int +static int hide_syms(const char *filename) { int fd, i, n, rv; From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:19:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93155674EBF; Fri, 27 Aug 2021 01:19: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 4Gwhhd3dQpz4kpd; Fri, 27 Aug 2021 01:19: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 654811A59C; Fri, 27 Aug 2021 01:19: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 17R1JjxM038607; Fri, 27 Aug 2021 01:19:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1JjV3038606; Fri, 27 Aug 2021 01:19:45 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:19:45 GMT Message-Id: <202108270119.17R1JjV3038606@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: bb958dcf3d8a - main - nfsd: Add support for the NFSv4.2 Deallocate operation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb958dcf3d8af3a033dacbf8133681c9b0c73b2f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:19:45 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=bb958dcf3d8af3a033dacbf8133681c9b0c73b2f commit bb958dcf3d8af3a033dacbf8133681c9b0c73b2f Author: Rick Macklem AuthorDate: 2021-08-27 01:14:11 +0000 Commit: Rick Macklem CommitDate: 2021-08-27 01:14:11 +0000 nfsd: Add support for the NFSv4.2 Deallocate operation The recently added VOP_DEALLOCATE(9) VOP call allows implementation of the Deallocate NFSv4.2 operation. Since the Deallocate operation is a single succeed/fail operation, the call to VOP_DEALLOCATE(9) loops so long as progress is being made. It calls maybe_yield() between loop iterations to allow other processes to preempt it. Where RFC 7862 underspecifies behaviour, the code is written to be Linux NFSv4.2 server compatible. Reviewed by: khng Differential Revision: https://reviews.freebsd.org/D31624 --- sys/fs/nfs/nfs_var.h | 4 + sys/fs/nfsserver/nfs_nfsdport.c | 201 ++++++++++++++++++++++++++++++++++++++ sys/fs/nfsserver/nfs_nfsdserv.c | 105 ++++++++++++++++++++ sys/fs/nfsserver/nfs_nfsdsocket.c | 2 +- 4 files changed, 311 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index b4c21c6f7029..5ddae345f906 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -282,6 +282,8 @@ int nfsrvd_teststateid(struct nfsrv_descript *, int, vnode_t, struct nfsexstuff *); int nfsrvd_allocate(struct nfsrv_descript *, int, vnode_t, struct nfsexstuff *); +int nfsrvd_deallocate(struct nfsrv_descript *, int, + vnode_t, struct nfsexstuff *); int nfsrvd_copy_file_range(struct nfsrv_descript *, int, vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *); int nfsrvd_seek(struct nfsrv_descript *, int, @@ -752,6 +754,8 @@ int nfsrv_setacl(struct vnode *, NFSACL_T *, struct ucred *, NFSPROC_T *); int nfsvno_seek(struct nfsrv_descript *, struct vnode *, u_long, off_t *, int, bool *, struct ucred *, NFSPROC_T *); int nfsvno_allocate(struct vnode *, off_t, off_t, struct ucred *, NFSPROC_T *); +int nfsvno_deallocate(struct vnode *, off_t, off_t, struct ucred *, + NFSPROC_T *); int nfsvno_getxattr(struct vnode *, char *, uint32_t, struct ucred *, uint64_t, int, struct thread *, struct mbuf **, struct mbuf **, int *); int nfsvno_setxattr(struct vnode *, char *, int, struct mbuf *, char *, diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index efe9aac7a136..d93c547c5530 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -132,6 +132,8 @@ static int nfsrv_writedsrpc(fhandle_t *, off_t, int, struct ucred *, char *, int *); static int nfsrv_allocatedsrpc(fhandle_t *, off_t, off_t, struct ucred *, NFSPROC_T *, struct vnode *, struct nfsmount **, int, int *); +static int nfsrv_deallocatedsrpc(fhandle_t *, off_t, off_t, struct ucred *, + NFSPROC_T *, struct vnode *, struct nfsmount **, int, int *); static int nfsrv_setacldsrpc(fhandle_t *, struct ucred *, NFSPROC_T *, struct vnode *, struct nfsmount **, int, struct acl *, int *); static int nfsrv_setattrdsrpc(fhandle_t *, struct ucred *, NFSPROC_T *, @@ -4898,6 +4900,9 @@ tryagain: } else if (ioproc == NFSPROC_ALLOCATE) error = nfsrv_allocatedsrpc(fh, off, *offp, cred, p, vp, &nmp[0], mirrorcnt, &failpos); + else if (ioproc == NFSPROC_DEALLOCATE) + error = nfsrv_deallocatedsrpc(fh, off, *offp, cred, p, + vp, &nmp[0], mirrorcnt, &failpos); else { error = nfsrv_getattrdsrpc(&fh[mirrorcnt - 1], cred, p, vp, nmp[mirrorcnt - 1], nap); @@ -5679,6 +5684,166 @@ nfsrv_allocatedsrpc(fhandle_t *fhp, off_t off, off_t len, struct ucred *cred, return (error); } +/* + * Do a deallocate RPC on a DS data file, using this structure for the + * arguments, so that this function can be executed by a separate kernel + * process. + */ +struct nfsrvdeallocatedsdorpc { + int done; + int inprog; + struct task tsk; + fhandle_t fh; + off_t off; + off_t len; + struct nfsmount *nmp; + struct ucred *cred; + NFSPROC_T *p; + int err; +}; + +static int +nfsrv_deallocatedsdorpc(struct nfsmount *nmp, fhandle_t *fhp, off_t off, + off_t len, struct nfsvattr *nap, struct ucred *cred, NFSPROC_T *p) +{ + uint32_t *tl; + struct nfsrv_descript *nd; + nfsattrbit_t attrbits; + nfsv4stateid_t st; + int error; + + nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO); + nfscl_reqstart(nd, NFSPROC_DEALLOCATE, nmp, (u_int8_t *)fhp, + sizeof(fhandle_t), NULL, NULL, 0, 0); + + /* + * Use a stateid where other is an alternating 01010 pattern and + * seqid is 0xffffffff. This value is not defined as special by + * the RFC and is used by the FreeBSD NFS server to indicate an + * MDS->DS proxy operation. + */ + st.other[0] = 0x55555555; + st.other[1] = 0x55555555; + st.other[2] = 0x55555555; + st.seqid = 0xffffffff; + nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + NFSX_UNSIGNED); + txdr_hyper(off, tl); tl += 2; + txdr_hyper(len, tl); tl += 2; + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: len=%jd\n", (intmax_t)len); + + *tl = txdr_unsigned(NFSV4OP_GETATTR); + NFSGETATTR_ATTRBIT(&attrbits); + nfsrv_putattrbit(nd, &attrbits); + error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, + cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL); + if (error != 0) { + free(nd, M_TEMP); + return (error); + } + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: aft allocaterpc=%d\n", + nd->nd_repstat); + if (nd->nd_repstat == 0) { + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + error = nfsv4_loadattr(nd, NULL, nap, NULL, NULL, 0, NULL, NULL, + NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL); + } else + error = nd->nd_repstat; + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: aft loadattr=%d\n", error); +nfsmout: + m_freem(nd->nd_mrep); + free(nd, M_TEMP); + NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc error=%d\n", error); + return (error); +} + +/* + * Start up the thread that will execute nfsrv_deallocatedsdorpc(). + */ +static void +start_deallocatedsdorpc(void *arg, int pending) +{ + struct nfsrvdeallocatedsdorpc *drpc; + + drpc = (struct nfsrvdeallocatedsdorpc *)arg; + drpc->err = nfsrv_deallocatedsdorpc(drpc->nmp, &drpc->fh, drpc->off, + drpc->len, NULL, drpc->cred, drpc->p); + drpc->done = 1; + NFSD_DEBUG(4, "start_deallocatedsdorpc: err=%d\n", drpc->err); +} + +static int +nfsrv_deallocatedsrpc(fhandle_t *fhp, off_t off, off_t len, struct ucred *cred, + NFSPROC_T *p, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt, + int *failposp) +{ + struct nfsrvdeallocatedsdorpc *drpc, *tdrpc = NULL; + struct nfsvattr na; + int error, i, ret, timo; + + NFSD_DEBUG(4, "in nfsrv_deallocatedsrpc\n"); + drpc = NULL; + if (mirrorcnt > 1) + tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, + M_WAITOK); + + /* + * Do the deallocate RPC for every DS, using a separate kernel process + * for every DS except the last one. + */ + error = 0; + for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { + tdrpc->done = 0; + NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp)); + tdrpc->off = off; + tdrpc->len = len; + tdrpc->nmp = *nmpp; + tdrpc->cred = cred; + tdrpc->p = p; + tdrpc->inprog = 0; + tdrpc->err = 0; + ret = EIO; + if (nfs_pnfsiothreads != 0) { + ret = nfs_pnfsio(start_deallocatedsdorpc, tdrpc); + NFSD_DEBUG(4, "nfsrv_deallocatedsrpc: nfs_pnfsio=%d\n", + ret); + } + if (ret != 0) { + ret = nfsrv_deallocatedsdorpc(*nmpp, fhp, off, len, + NULL, cred, p); + if (nfsds_failerr(ret) && *failposp == -1) + *failposp = i; + else if (error == 0 && ret != 0) + error = ret; + } + nmpp++; + fhp++; + } + ret = nfsrv_deallocatedsdorpc(*nmpp, fhp, off, len, &na, cred, p); + if (nfsds_failerr(ret) && *failposp == -1 && mirrorcnt > 1) + *failposp = mirrorcnt - 1; + else if (error == 0 && ret != 0) + error = ret; + if (error == 0) + error = nfsrv_setextattr(vp, &na, p); + NFSD_DEBUG(4, "nfsrv_deallocatedsrpc: aft setextat=%d\n", error); + tdrpc = drpc; + timo = hz / 50; /* Wait for 20msec. */ + if (timo < 1) + timo = 1; + for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { + /* Wait for RPCs on separate threads to complete. */ + while (tdrpc->inprog != 0 && tdrpc->done == 0) + tsleep(&tdrpc->tsk, PVFS, "srvalds", timo); + if (nfsds_failerr(tdrpc->err) && *failposp == -1) + *failposp = i; + else if (error == 0 && tdrpc->err != 0) + error = tdrpc->err; + } + free(drpc, M_TEMP); + return (error); +} + static int nfsrv_setattrdsdorpc(fhandle_t *fhp, struct ucred *cred, NFSPROC_T *p, struct vnode *vp, struct nfsmount *nmp, struct nfsvattr *nap, @@ -6425,6 +6590,42 @@ nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, return (error); } +/* + * Deallocate vnode op call. + */ +int +nfsvno_deallocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, + NFSPROC_T *p) +{ + int error; + off_t olen; + + ASSERT_VOP_ELOCKED(vp, "nfsvno_deallocate vp"); + /* + * Attempt to deallocate on a DS file. A return of ENOENT implies + * there is no DS file to deallocate on. + */ + error = nfsrv_proxyds(vp, off, 0, cred, p, NFSPROC_DEALLOCATE, NULL, + NULL, NULL, NULL, NULL, &len, 0, NULL); + if (error != ENOENT) + return (error); + + /* + * Do the actual VOP_DEALLOCATE(), looping so long as + * progress is being made, to achieve completion. + */ + do { + olen = len; + error = VOP_DEALLOCATE(vp, &off, &len, 0, IO_SYNC, cred); + if (error == 0 && len > 0 && olen > len) + maybe_yield(); + } while (error == 0 && len > 0 && olen > len); + if (error == 0 && len > 0) + error = NFSERR_IO; + NFSEXITCODE(error); + return (error); +} + /* * Get Extended Atribute vnode op into an mbuf list. */ diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 12181d04f1fa..2d4635c75204 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -5389,6 +5389,111 @@ nfsmout: return (error); } +/* + * nfs deallocate service + */ +int +nfsrvd_deallocate(struct nfsrv_descript *nd, __unused int isdgram, + vnode_t vp, struct nfsexstuff *exp) +{ + uint32_t *tl; + struct nfsvattr forat; + int error = 0, forat_ret = 1, gotproxystateid; + off_t off, len; + struct nfsstate st, *stp = &st; + struct nfslock lo, *lop = &lo; + nfsv4stateid_t stateid; + nfsquad_t clientid; + nfsattrbit_t attrbits; + + gotproxystateid = 0; + NFSM_DISSECT(tl, uint32_t *, NFSX_STATEID + 2 * NFSX_HYPER); + stp->ls_flags = (NFSLCK_CHECK | NFSLCK_WRITEACCESS); + lop->lo_flags = NFSLCK_WRITE; + stp->ls_ownerlen = 0; + stp->ls_op = NULL; + stp->ls_uid = nd->nd_cred->cr_uid; + stp->ls_stateid.seqid = fxdr_unsigned(u_int32_t, *tl++); + clientid.lval[0] = stp->ls_stateid.other[0] = *tl++; + clientid.lval[1] = stp->ls_stateid.other[1] = *tl++; + if ((nd->nd_flag & ND_IMPLIEDCLID) != 0) { + if ((nd->nd_flag & ND_NFSV41) != 0) + clientid.qval = nd->nd_clientid.qval; + else if (nd->nd_clientid.qval != clientid.qval) + printf("EEK2 multiple clids\n"); + } else { + if ((nd->nd_flag & ND_NFSV41) != 0) + printf("EEK! no clientid from session\n"); + nd->nd_flag |= ND_IMPLIEDCLID; + nd->nd_clientid.qval = clientid.qval; + } + stp->ls_stateid.other[2] = *tl++; + /* + * Don't allow this to be done for a DS. + */ + if ((nd->nd_flag & ND_DSSERVER) != 0) + nd->nd_repstat = NFSERR_NOTSUPP; + /* However, allow the proxy stateid. */ + if (stp->ls_stateid.seqid == 0xffffffff && + stp->ls_stateid.other[0] == 0x55555555 && + stp->ls_stateid.other[1] == 0x55555555 && + stp->ls_stateid.other[2] == 0x55555555) + gotproxystateid = 1; + off = fxdr_hyper(tl); tl += 2; + lop->lo_first = off; + len = fxdr_hyper(tl); + if (len < 0) + len = OFF_MAX; + NFSD_DEBUG(4, "dealloc: off=%jd len=%jd\n", (intmax_t)off, + (intmax_t)len); + lop->lo_end = lop->lo_first + len; + /* + * Sanity check the offset and length. + * off and len are off_t (signed int64_t) whereas + * lo_first and lo_end are uint64_t and, as such, + * if off >= 0 && len > 0, lo_end cannot overflow + * unless off_t is changed to something other than + * int64_t. Check lo_end < lo_first in case that + * is someday the case. + * The error to return is not specified by RFC 7862 so I + * made this compatible with the Linux knfsd. + */ + if (nd->nd_repstat == 0) { + if (off < 0 || lop->lo_end > NFSRV_MAXFILESIZE) + nd->nd_repstat = NFSERR_FBIG; + else if (len == 0 || lop->lo_end < lop->lo_first) + nd->nd_repstat = NFSERR_INVAL; + } + + if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG) + nd->nd_repstat = NFSERR_WRONGTYPE; + NFSZERO_ATTRBIT(&attrbits); + NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_OWNER); + forat_ret = nfsvno_getattr(vp, &forat, nd, curthread, 1, &attrbits); + if (nd->nd_repstat == 0) + nd->nd_repstat = forat_ret; + if (nd->nd_repstat == 0 && (forat.na_uid != nd->nd_cred->cr_uid || + NFSVNO_EXSTRICTACCESS(exp))) + nd->nd_repstat = nfsvno_accchk(vp, VWRITE, nd->nd_cred, exp, + curthread, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, + NULL); + if (nd->nd_repstat == 0 && gotproxystateid == 0) + nd->nd_repstat = nfsrv_lockctrl(vp, &stp, &lop, NULL, clientid, + &stateid, exp, nd, curthread); + + if (nd->nd_repstat == 0) + nd->nd_repstat = nfsvno_deallocate(vp, off, len, nd->nd_cred, + curthread); + vput(vp); + NFSD_DEBUG(4, "eo deallocate=%d\n", nd->nd_repstat); + NFSEXITCODE2(0, nd); + return (0); +nfsmout: + vput(vp); + NFSEXITCODE2(error, nd); + return (error); +} + /* * nfs copy service */ diff --git a/sys/fs/nfsserver/nfs_nfsdsocket.c b/sys/fs/nfsserver/nfs_nfsdsocket.c index 85771974be2f..fdd46b6290e9 100644 --- a/sys/fs/nfsserver/nfs_nfsdsocket.c +++ b/sys/fs/nfsserver/nfs_nfsdsocket.c @@ -198,7 +198,7 @@ int (*nfsrv4_ops0[NFSV42_NOPS])(struct nfsrv_descript *, nfsrvd_allocate, (int (*)(struct nfsrv_descript *, int, vnode_t , struct nfsexstuff *))0, nfsrvd_notsupp, - nfsrvd_notsupp, + nfsrvd_deallocate, nfsrvd_ioadvise, nfsrvd_layouterror, nfsrvd_layoutstats, From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:36:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B18DB675044; Fri, 27 Aug 2021 01:36: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 4Gwj4H3g0vz4pw8; Fri, 27 Aug 2021 01:36: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 5B28A1A76D; Fri, 27 Aug 2021 01:36: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 17R1al0G065218; Fri, 27 Aug 2021 01:36:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1alG6065217; Fri, 27 Aug 2021 01:36:47 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:36:47 GMT Message-Id: <202108270136.17R1alG6065217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 8b043521b416 - stable/13 - intel ethernet: Use ether_gen_addr(9) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8b043521b41664f4f2bd18087511508b7af776c0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:36:47 -0000 The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=8b043521b41664f4f2bd18087511508b7af776c0 commit 8b043521b41664f4f2bd18087511508b7af776c0 Author: Kevin Bowling AuthorDate: 2021-08-20 14:45:30 +0000 Commit: Kevin Bowling CommitDate: 2021-08-27 01:33:48 +0000 intel ethernet: Use ether_gen_addr(9) Use ether_gen_addr(9) for VF MAC generation Reviewed by: Intel Networking (erj), kevans MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31616 (cherry picked from commit 0e5811a2a9a1b4a7e0c79b73e3b9b9d15d481577) --- sys/dev/e1000/if_em.c | 7 ++----- sys/dev/ixgbe/if_ixv.c | 10 ++++------ sys/dev/ixl/if_iavf.c | 10 +++------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 5c958806d824..6e3a8f73190f 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -1076,11 +1076,8 @@ em_if_attach_pre(if_ctx_t ctx) if (!em_is_valid_ether_addr(hw->mac.addr)) { if (adapter->vf_ifp) { - u8 addr[ETHER_ADDR_LEN]; - arc4rand(&addr, sizeof(addr), 0); - addr[0] &= 0xFE; - addr[0] |= 0x02; - bcopy(addr, hw->mac.addr, sizeof(addr)); + ether_gen_addr(iflib_get_ifp(ctx), + (struct ether_addr *)hw->mac.addr); } else { device_printf(dev, "Invalid MAC address\n"); error = EIO; diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c index 9744a3347cec..301d3c0368ae 100644 --- a/sys/dev/ixgbe/if_ixv.c +++ b/sys/dev/ixgbe/if_ixv.c @@ -465,12 +465,10 @@ ixv_if_attach_pre(if_ctx_t ctx) /* If no mac address was assigned, make a random one */ if (!ixv_check_ether_addr(hw->mac.addr)) { - u8 addr[ETHER_ADDR_LEN]; - arc4rand(&addr, sizeof(addr), 0); - addr[0] &= 0xFE; - addr[0] |= 0x02; - bcopy(addr, hw->mac.addr, sizeof(addr)); - bcopy(addr, hw->mac.perm_addr, sizeof(addr)); + ether_gen_addr(iflib_get_ifp(ctx), + (struct ether_addr *)hw->mac.addr); + bcopy(hw->mac.addr, hw->mac.perm_addr, + sizeof(hw->mac.perm_addr)); } /* Most of the iflib initialization... */ diff --git a/sys/dev/ixl/if_iavf.c b/sys/dev/ixl/if_iavf.c index f6eb91c2a855..123db2e2461d 100644 --- a/sys/dev/ixl/if_iavf.c +++ b/sys/dev/ixl/if_iavf.c @@ -433,13 +433,9 @@ iavf_if_attach_pre(if_ctx_t ctx) iavf_dbg_init(sc, "Resource Acquisition complete\n"); /* If no mac address was assigned just make a random one */ - if (!iavf_check_ether_addr(hw->mac.addr)) { - u8 addr[ETHER_ADDR_LEN]; - arc4rand(&addr, sizeof(addr), 0); - addr[0] &= 0xFE; - addr[0] |= 0x02; - bcopy(addr, hw->mac.addr, sizeof(addr)); - } + if (!iavf_check_ether_addr(hw->mac.addr)) + ether_gen_addr(iflib_get_ifp(ctx), + (struct ether_addr *)hw->mac.addr); bcopy(hw->mac.addr, hw->mac.perm_addr, ETHER_ADDR_LEN); iflib_set_mac(ctx, hw->mac.addr); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 01:39:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A57C3675322; Fri, 27 Aug 2021 01:39: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 4Gwj794Fydz4qCX; Fri, 27 Aug 2021 01:39: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 6FB991AA88; Fri, 27 Aug 2021 01:39: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 17R1dHX6065494; Fri, 27 Aug 2021 01:39:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R1dHDT065493; Fri, 27 Aug 2021 01:39:17 GMT (envelope-from git) Date: Fri, 27 Aug 2021 01:39:17 GMT Message-Id: <202108270139.17R1dHDT065493@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 200842074ba6 - stable/12 - intel ethernet: Use ether_gen_addr(9) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 200842074ba60e8e4c8ab2776a3d2b85d3cd4101 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 01:39:17 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=200842074ba60e8e4c8ab2776a3d2b85d3cd4101 commit 200842074ba60e8e4c8ab2776a3d2b85d3cd4101 Author: Kevin Bowling AuthorDate: 2021-08-20 14:45:30 +0000 Commit: Kevin Bowling CommitDate: 2021-08-27 01:38:09 +0000 intel ethernet: Use ether_gen_addr(9) Use ether_gen_addr(9) for VF MAC generation Reviewed by: Intel Networking (erj), kevans MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31616 (cherry picked from commit 0e5811a2a9a1b4a7e0c79b73e3b9b9d15d481577) --- sys/dev/e1000/if_em.c | 7 ++----- sys/dev/ixgbe/if_ixv.c | 10 ++++------ sys/dev/ixl/if_iavf.c | 10 +++------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 2a6afd244445..315437145e1c 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -1078,11 +1078,8 @@ em_if_attach_pre(if_ctx_t ctx) if (!em_is_valid_ether_addr(hw->mac.addr)) { if (adapter->vf_ifp) { - u8 addr[ETHER_ADDR_LEN]; - arc4rand(&addr, sizeof(addr), 0); - addr[0] &= 0xFE; - addr[0] |= 0x02; - bcopy(addr, hw->mac.addr, sizeof(addr)); + ether_gen_addr(iflib_get_ifp(ctx), + (struct ether_addr *)hw->mac.addr); } else { device_printf(dev, "Invalid MAC address\n"); error = EIO; diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c index 8a242b9b8cba..ca69275928a5 100644 --- a/sys/dev/ixgbe/if_ixv.c +++ b/sys/dev/ixgbe/if_ixv.c @@ -468,12 +468,10 @@ ixv_if_attach_pre(if_ctx_t ctx) /* If no mac address was assigned, make a random one */ if (!ixv_check_ether_addr(hw->mac.addr)) { - u8 addr[ETHER_ADDR_LEN]; - arc4rand(&addr, sizeof(addr), 0); - addr[0] &= 0xFE; - addr[0] |= 0x02; - bcopy(addr, hw->mac.addr, sizeof(addr)); - bcopy(addr, hw->mac.perm_addr, sizeof(addr)); + ether_gen_addr(iflib_get_ifp(ctx), + (struct ether_addr *)hw->mac.addr); + bcopy(hw->mac.addr, hw->mac.perm_addr, + sizeof(hw->mac.perm_addr)); } /* Most of the iflib initialization... */ diff --git a/sys/dev/ixl/if_iavf.c b/sys/dev/ixl/if_iavf.c index 066c565ec53e..72853a35138a 100644 --- a/sys/dev/ixl/if_iavf.c +++ b/sys/dev/ixl/if_iavf.c @@ -435,13 +435,9 @@ iavf_if_attach_pre(if_ctx_t ctx) iavf_dbg_init(sc, "Resource Acquisition complete\n"); /* If no mac address was assigned just make a random one */ - if (!iavf_check_ether_addr(hw->mac.addr)) { - u8 addr[ETHER_ADDR_LEN]; - arc4rand(&addr, sizeof(addr), 0); - addr[0] &= 0xFE; - addr[0] |= 0x02; - bcopy(addr, hw->mac.addr, sizeof(addr)); - } + if (!iavf_check_ether_addr(hw->mac.addr)) + ether_gen_addr(iflib_get_ifp(ctx), + (struct ether_addr *)hw->mac.addr); bcopy(hw->mac.addr, hw->mac.perm_addr, ETHER_ADDR_LEN); iflib_set_mac(ctx, hw->mac.addr); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 08:15:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F24C965A45E; Fri, 27 Aug 2021 08:15: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 4Gwsw269HWz4fPY; Fri, 27 Aug 2021 08:15: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 BAE3A1FD3F; Fri, 27 Aug 2021 08:15: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 17R8FExj098861; Fri, 27 Aug 2021 08:15:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8FEGc098860; Fri, 27 Aug 2021 08:15:14 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:15:14 GMT Message-Id: <202108270815.17R8FEGc098860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hiroki Sato Subject: git: 9823a0c0acf4 - main - inet6(4): add a missing IPPROTO_ETHERIP entry MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9823a0c0acf4fc277a71336ea737e1de7c65742f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:15:15 -0000 The branch main has been updated by hrs: URL: https://cgit.FreeBSD.org/src/commit/?id=9823a0c0acf4fc277a71336ea737e1de7c65742f commit 9823a0c0acf4fc277a71336ea737e1de7c65742f Author: Hiroki Sato AuthorDate: 2021-08-27 08:14:35 +0000 Commit: Hiroki Sato CommitDate: 2021-08-27 08:14:35 +0000 inet6(4): add a missing IPPROTO_ETHERIP entry bridge(4) + gif(4) did not work when the outer protocol was IPv6. Submitted by: Masahiro Kozuka PR: 256820 MFC after: 3 days --- sys/netinet6/in6_proto.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 56ef41a27e88..909564b8c7e5 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -293,6 +293,15 @@ struct protosw inet6sw[] = { .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs }, +{ + .pr_type = SOCK_RAW, + .pr_domain = &inet6domain, + .pr_protocol = IPPROTO_ETHERIP, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, + .pr_input = encap6_input, + .pr_ctloutput = rip6_ctloutput, + .pr_usrreqs = &rip6_usrreqs +}, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, From owner-dev-commits-src-all@freebsd.org Fri Aug 27 08:52:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3BE8865ACC9; Fri, 27 Aug 2021 08:52: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 4GwtlG5YkJz4rJd; Fri, 27 Aug 2021 08:52: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 A855820885; Fri, 27 Aug 2021 08:52: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 17R8qgLu051055; Fri, 27 Aug 2021 08:52:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qgYJ051054; Fri, 27 Aug 2021 08:52:42 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:42 GMT Message-Id: <202108270852.17R8qgYJ051054@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: 19f7f91133af - main - libc/posix1e: Add acl_from_mode_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 19f7f91133af6b699a87ed7656987ba017a75b6a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:43 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=19f7f91133af6b699a87ed7656987ba017a75b6a commit 19f7f91133af6b699a87ed7656987ba017a75b6a Author: Gleb Popov AuthorDate: 2021-01-19 15:25:07 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:49:19 +0000 libc/posix1e: Add acl_from_mode_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 2 + lib/libc/posix1e/Symbol.map | 4 ++ lib/libc/posix1e/acl_from_mode_np.3 | 95 +++++++++++++++++++++++++++++ lib/libc/posix1e/acl_from_mode_np.c | 115 ++++++++++++++++++++++++++++++++++++ sys/sys/acl.h | 3 +- 5 files changed, 218 insertions(+), 1 deletion(-) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index fadc952f7acc..865a5e120b0f 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -18,6 +18,7 @@ SRCS+= acl_branding.c \ acl_entry.c \ acl_flag.c \ acl_free.c \ + acl_from_mode_np.c \ acl_from_text.c \ acl_from_text_nfs4.c \ acl_get.c \ @@ -54,6 +55,7 @@ MAN+= acl.3 \ acl_delete_perm.3 \ acl_dup.3 \ acl_free.3 \ + acl_from_mode_np.3 \ acl_from_text.3 \ acl_get.3 \ acl_get_brand_np.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index 346c8ca7e290..6cc05daee818 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -84,3 +84,7 @@ FBSD_1.1 { acl_strip_np; acl_to_text_np; }; + +FBSD_1.7 { + acl_from_mode_np; +}; diff --git a/lib/libc/posix1e/acl_from_mode_np.3 b/lib/libc/posix1e/acl_from_mode_np.3 new file mode 100644 index 000000000000..6ba80de5567b --- /dev/null +++ b/lib/libc/posix1e/acl_from_mode_np.3 @@ -0,0 +1,95 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd January 20, 2021 +.Dt ACL_FROM_MODE_NP 3 +.Os +.Sh NAME +.Nm acl_from_mode_np +.Nd create an ACL from status information +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft acl_t +.Fn acl_from_mode_np "const mode_t mode" +.Sh DESCRIPTION +The +.Fn acl_from_mode_np +function is a non-portable call that converts the permissions set referred to by +.Va mode +into the corresponding minimal ACL structure, appropriate for applying to +files or manipulating. +.Pp +This function causes memory to be allocated. +The caller should free any +free-able memory, when the new ACL is no longer required, by calling +.Xr acl_free 3 +with the +.Va (void *)acl_t +as an argument. +.Sh RETURN VALUES +Upon successful completion, the function returns a pointer to the +internal representation of the ACL in working storage. +Otherwise, a value +of +.Va (acl_t)NULL +is returned, and +.Va errno +is set to indicate the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_from_mode_np +function returns a value of +.Va (acl_t)NULL +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er ENOMEM +The ACL working storage requires more memory than is allowed by the +hardware or system-imposed memory management constraints. +.El +.Sh SEE ALSO +.Xr acl 3 , +.Xr acl_free 3 , +.Xr acl_from_text 3 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_from_mode_np.c b/lib/libc/posix1e/acl_from_mode_np.c new file mode 100644 index 000000000000..d78109469720 --- /dev/null +++ b/lib/libc/posix1e/acl_from_mode_np.c @@ -0,0 +1,115 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Robert N M Watson, Gleb Popov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* + * acl_from_mode_np: Create an ACL from a mode_t. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +/* + * return an ACL corresponding to the permissions + * contained in mode_t + */ +acl_t +acl_from_mode_np(const mode_t mode) +{ + acl_t acl; + acl_entry_t entry; + acl_permset_t perms; + + /* create the ACL */ + acl = acl_init(3); + /* here and below, the only possible reason to fail is ENOMEM, so + * no need to set errno again + */ + if (acl == NULL) + return (NULL); + + /* First entry: ACL_USER_OBJ */ + if (acl_create_entry(&acl, &entry) == -1) + return (NULL); + /* TODO: need to handle error there and below? */ + acl_set_tag_type(entry, ACL_USER_OBJ); + + acl_get_permset(entry, &perms); + acl_clear_perms(perms); + + /* calculate user mode */ + if (mode & S_IRUSR) + acl_add_perm(perms, ACL_READ); + if (mode & S_IWUSR) + acl_add_perm(perms, ACL_WRITE); + if (mode & S_IXUSR) + acl_add_perm(perms, ACL_EXECUTE); + + acl_set_permset(entry, perms); + + /* Second entry: ACL_GROUP_OBJ */ + if (acl_create_entry(&acl, &entry) == -1) + return (NULL); + acl_set_tag_type(entry, ACL_GROUP_OBJ); + + acl_get_permset(entry, &perms); + acl_clear_perms(perms); + + /* calculate group mode */ + if (mode & S_IRGRP) + acl_add_perm(perms, ACL_READ); + if (mode & S_IWGRP) + acl_add_perm(perms, ACL_WRITE); + if (mode & S_IXGRP) + acl_add_perm(perms, ACL_EXECUTE); + + acl_set_permset(entry, perms); + + /* Third entry: ACL_OTHER */ + if (acl_create_entry(&acl, &entry) == -1) + return (NULL); + acl_set_tag_type(entry, ACL_OTHER); + + acl_get_permset(entry, &perms); + acl_clear_perms(perms); + + /* calculate other mode */ + if (mode & S_IROTH) + acl_add_perm(perms, ACL_READ); + if (mode & S_IWOTH) + acl_add_perm(perms, ACL_WRITE); + if (mode & S_IXOTH) + acl_add_perm(perms, ACL_EXECUTE); + + acl_set_permset(entry, perms); + + return (acl); +} diff --git a/sys/sys/acl.h b/sys/sys/acl.h index 196447a6d9cb..71bb0f2ac058 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -30,7 +30,7 @@ * * $FreeBSD$ */ -/* +/* * Developed by the TrustedBSD Project. * Support for POSIX.1e and NFSv4 access control lists. */ @@ -379,6 +379,7 @@ int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); acl_t acl_dup(acl_t _acl); int acl_free(void *_obj_p); +acl_t acl_from_mode_np(const mode_t mode); acl_t acl_from_text(const char *_buf_p); int acl_get_brand_np(acl_t _acl, int *_brand_p); int acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 08:52:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B9DA65AF7D; Fri, 27 Aug 2021 08:52: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 4GwtlJ0Gfwz4rDK; Fri, 27 Aug 2021 08:52:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D8555206C4; Fri, 27 Aug 2021 08:52: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 17R8qh16051079; Fri, 27 Aug 2021 08:52:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qhsE051078; Fri, 27 Aug 2021 08:52:43 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:43 GMT Message-Id: <202108270852.17R8qhsE051078@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: 937f807a3675 - main - libc/posix1e: Add acl_cmp_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 937f807a3675d0970be68437c2eb5ce4c82fd68f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:44 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=937f807a3675d0970be68437c2eb5ce4c82fd68f commit 937f807a3675d0970be68437c2eb5ce4c82fd68f Author: Gleb Popov AuthorDate: 2021-01-19 15:26:19 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:08 +0000 libc/posix1e: Add acl_cmp_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 2 + lib/libc/posix1e/Symbol.map | 1 + lib/libc/posix1e/acl_cmp_np.3 | 83 ++++++++++++++++++++++++++++++++++++++++++ lib/libc/posix1e/acl_cmp_np.c | 55 ++++++++++++++++++++++++++++ lib/libc/posix1e/acl_support.c | 2 - sys/sys/acl.h | 1 + 6 files changed, 142 insertions(+), 2 deletions(-) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index 865a5e120b0f..de3fa17ab3c9 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -11,6 +11,7 @@ subr_acl_nfs4.c: ${SRCTOP}/sys/kern/subr_acl_nfs4.c CONFS+= posix1e/mac.conf SRCS+= acl_branding.c \ acl_calc_mask.c \ + acl_cmp_np.c \ acl_compat.c \ acl_copy.c \ acl_delete.c \ @@ -47,6 +48,7 @@ MAN+= acl.3 \ acl_calc_mask.3 \ acl_clear_flags_np.3 \ acl_clear_perms.3 \ + acl_cmp_np.3 \ acl_copy_entry.3 \ acl_create_entry.3 \ acl_delete.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index 6cc05daee818..a83d69e9a887 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -86,5 +86,6 @@ FBSD_1.1 { }; FBSD_1.7 { + acl_cmp_np; acl_from_mode_np; }; diff --git a/lib/libc/posix1e/acl_cmp_np.3 b/lib/libc/posix1e/acl_cmp_np.3 new file mode 100644 index 000000000000..a8dca4959d2e --- /dev/null +++ b/lib/libc/posix1e/acl_cmp_np.3 @@ -0,0 +1,83 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd January 20, 2021 +.Dt ACL_CMP_NP 3 +.Os +.Sh NAME +.Nm acl_cmp +.Nd compare between two ACLs +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft int +.Fn acl_cmp_np "acl_t acl1" "acl_t acl2" +.Sh DESCRIPTION +The +.Fn acl_cmp_np +function is a non-portable call that checks if ACLs pointed to by +.Va acl1 +and +.Va acl2 +are equivalent. +The two ACLs are considered equal when they contain the same +entries with matching tag types, qualifiers and permissions. +.Sh RETURN VALUES +Upon successful completion, this function returns 0 if the given ACLs are +equivalent and 1 if they differ. +Otherwise, the value -1 is returned, and +.Va errno +indicates the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_cmp_np +function shall return a value of +.Va -1 +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er EINVAL +Either first or second argument does not point to a valid ACL. +.Sh SEE ALSO +.Xr acl 3 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_cmp_np.c b/lib/libc/posix1e/acl_cmp_np.c new file mode 100644 index 000000000000..43fe9dcb3f7e --- /dev/null +++ b/lib/libc/posix1e/acl_cmp_np.c @@ -0,0 +1,55 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* + * acl_cmp_np: Compare two ACL's. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "acl_support.h" + +/* + * returns 0 if acl_t's are identical, 1 otherwise + */ +int +acl_cmp_np(acl_t acl1, acl_t acl2) +{ + if (acl1 == NULL || acl2 == NULL) { + errno = EINVAL; + return (-1); + } + + if (_acl_brand(acl1) != _acl_brand(acl2)) + return (1); + + return (_acl_differs(acl1, acl2)); +} diff --git a/lib/libc/posix1e/acl_support.c b/lib/libc/posix1e/acl_support.c index bb09d119f988..342d2853ddda 100644 --- a/lib/libc/posix1e/acl_support.c +++ b/lib/libc/posix1e/acl_support.c @@ -62,8 +62,6 @@ _acl_differs(const acl_t a, const acl_t b) struct acl_entry *entrya, *entryb; assert(_acl_brand(a) == _acl_brand(b)); - assert(_acl_brand(a) != ACL_BRAND_UNKNOWN); - assert(_acl_brand(b) != ACL_BRAND_UNKNOWN); if (a->ats_acl.acl_cnt != b->ats_acl.acl_cnt) return (1); diff --git a/sys/sys/acl.h b/sys/sys/acl.h index 71bb0f2ac058..bbf0987a75e4 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -363,6 +363,7 @@ int acl_add_perm(acl_permset_t _permset_d, acl_perm_t _perm); int acl_calc_mask(acl_t *_acl_p); int acl_clear_flags_np(acl_flagset_t _flagset_d); int acl_clear_perms(acl_permset_t _permset_d); +int acl_cmp_np(acl_t _acl1, acl_t _acl2); int acl_copy_entry(acl_entry_t _dest_d, acl_entry_t _src_d); ssize_t acl_copy_ext(void *_buf_p, acl_t _acl, ssize_t _size); acl_t acl_copy_int(const void *_buf_p); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 08:52:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5099965B3A4; Fri, 27 Aug 2021 08:52: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 4GwtlK1L0fz4rB5; Fri, 27 Aug 2021 08:52: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 0824420901; Fri, 27 Aug 2021 08:52: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 17R8qiIQ051103; Fri, 27 Aug 2021 08:52:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qipP051102; Fri, 27 Aug 2021 08:52:44 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:44 GMT Message-Id: <202108270852.17R8qipP051102@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: d81d5b2f2c9c - main - libc/posix1e: Add acl_equiv_mode_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d81d5b2f2c9cda96ad960aac3313b89b2769323e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:45 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=d81d5b2f2c9cda96ad960aac3313b89b2769323e commit d81d5b2f2c9cda96ad960aac3313b89b2769323e Author: Gleb Popov AuthorDate: 2021-01-19 18:05:57 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:15 +0000 libc/posix1e: Add acl_equiv_mode_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 2 + lib/libc/posix1e/Symbol.map | 1 + lib/libc/posix1e/acl_equiv_mode_np.3 | 95 ++++++++++++++++++++++++++++++++ lib/libc/posix1e/acl_equiv_mode_np.c | 101 +++++++++++++++++++++++++++++++++++ sys/sys/acl.h | 1 + 5 files changed, 200 insertions(+) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index de3fa17ab3c9..181e43026a6d 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -17,6 +17,7 @@ SRCS+= acl_branding.c \ acl_delete.c \ acl_delete_entry.c \ acl_entry.c \ + acl_equiv_mode_np.c \ acl_flag.c \ acl_free.c \ acl_from_mode_np.c \ @@ -56,6 +57,7 @@ MAN+= acl.3 \ acl_delete_flag_np.3 \ acl_delete_perm.3 \ acl_dup.3 \ + acl_equiv_mode_np.3 \ acl_free.3 \ acl_from_mode_np.3 \ acl_from_text.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index a83d69e9a887..40098d42d13d 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -87,5 +87,6 @@ FBSD_1.1 { FBSD_1.7 { acl_cmp_np; + acl_equiv_mode_np; acl_from_mode_np; }; diff --git a/lib/libc/posix1e/acl_equiv_mode_np.3 b/lib/libc/posix1e/acl_equiv_mode_np.3 new file mode 100644 index 000000000000..33281e349fba --- /dev/null +++ b/lib/libc/posix1e/acl_equiv_mode_np.3 @@ -0,0 +1,95 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd January 20, 2021 +.Dt ACL_EQUIV_MODE_NP 3 +.Os +.Sh NAME +.Nm acl_equiv_mode_np +.Nd check if ACL can be represented as UNIX permissions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft int +.Fn acl_equiv_mode_np "acl_t acl" "mode_t* mode_p" +.Sh DESCRIPTION +The +.Fn acl_equiv_mode_np +function is a non-portable call which checks that entries contained in the +.Va acl +argument use only the ACL_USER_OBJ, ACL_GROUP_OBJ, and ACL_OTHER tag types, and that +permissions contained in these entries consist only of ACL_READ, ACL_WRITE and +ACL_EXECUTE. +If the check succeeds, the ACL can be represented as traditional UNIX +file permissions bits set. +.Pp +If +.Va mode_p +is not NULL and the check succeeds, the function fills the argument with a mode +value corresponding to permissions contained in the ACL. +.Sh RETURN VALUES +Upon successful completion, the function returns 0 if the ACL can be represented +as UNIX permissions and 1 if it is not possible. +Otherwise, a value +of +.Va -1 +is returned, and +.Va errno +is set to indicate the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_equiv_mode_np +function returns a value of +.Va -1 +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er EINVAL +Argument +.Fa acl +does not point to a valid ACL. +.El +.Sh SEE ALSO +.Xr acl 3 , +.Xr acl_from_mode_np 3 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_equiv_mode_np.c b/lib/libc/posix1e/acl_equiv_mode_np.c new file mode 100644 index 000000000000..a6dfb03bfc46 --- /dev/null +++ b/lib/libc/posix1e/acl_equiv_mode_np.c @@ -0,0 +1,101 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* + * acl_equiv_mode_np: Check if an ACL can be represented as a mode_t. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include "acl_support.h" + +int +acl_equiv_mode_np(acl_t acl, mode_t *mode_p) +{ + mode_t ret_mode = 0; + + if (acl == NULL) { + errno = EINVAL; + return (-1); + } + + /* Linux returns 0 for ACL returned by acl_init() */ + if (_acl_brand(acl) == ACL_BRAND_UNKNOWN && acl->ats_acl.acl_cnt == 0) + return (0); + + // TODO: Do we want to handle ACL_BRAND_NFS4 in this function? */ + if (_acl_brand(acl) != ACL_BRAND_POSIX) + return (1); + + for (int cur_entry = 0; cur_entry < acl->ats_acl.acl_cnt; cur_entry++) { + acl_entry_t entry = &acl->ats_acl.acl_entry[cur_entry]; + + if ((entry->ae_perm & ACL_PERM_BITS) != entry->ae_perm) + return (1); + + switch (entry->ae_tag) { + case ACL_USER_OBJ: + if (entry->ae_perm & ACL_READ) + ret_mode |= S_IRUSR; + if (entry->ae_perm & ACL_WRITE) + ret_mode |= S_IWUSR; + if (entry->ae_perm & ACL_EXECUTE) + ret_mode |= S_IXUSR; + break; + case ACL_GROUP_OBJ: + if (entry->ae_perm & ACL_READ) + ret_mode |= S_IRGRP; + if (entry->ae_perm & ACL_WRITE) + ret_mode |= S_IWGRP; + if (entry->ae_perm & ACL_EXECUTE) + ret_mode |= S_IXGRP; + break; + case ACL_OTHER: + if (entry->ae_perm & ACL_READ) + ret_mode |= S_IROTH; + if (entry->ae_perm & ACL_WRITE) + ret_mode |= S_IWOTH; + if (entry->ae_perm & ACL_EXECUTE) + ret_mode |= S_IXOTH; + break; + default: + return (1); + } + } + + if (mode_p != NULL) + *mode_p = ret_mode; + + return (0); +} diff --git a/sys/sys/acl.h b/sys/sys/acl.h index bbf0987a75e4..7c81570739c6 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -379,6 +379,7 @@ int acl_delete_def_link_np(const char *_path_p); int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); acl_t acl_dup(acl_t _acl); +int acl_equiv_mode_np(acl_t acl, mode_t *mode_p); int acl_free(void *_obj_p); acl_t acl_from_mode_np(const mode_t mode); acl_t acl_from_text(const char *_buf_p); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 08:52:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED68965B359; Fri, 27 Aug 2021 08:52: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 4GwtlM2qZ1z4r3K; Fri, 27 Aug 2021 08:52: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 36C232051E; Fri, 27 Aug 2021 08:52: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 17R8qlRG051158; Fri, 27 Aug 2021 08:52:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qlXE051157; Fri, 27 Aug 2021 08:52:47 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:47 GMT Message-Id: <202108270852.17R8qlXE051157@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: f8b88be850a5 - main - tests/sys/acl: Add ATF C test for newly added acl_* functions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f8b88be850a51eb982a476b27b74686a445e9a38 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:48 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=f8b88be850a51eb982a476b27b74686a445e9a38 commit f8b88be850a51eb982a476b27b74686a445e9a38 Author: Gleb Popov AuthorDate: 2021-01-23 10:00:47 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:21 +0000 tests/sys/acl: Add ATF C test for newly added acl_* functions. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- tests/sys/acl/Makefile | 2 + tests/sys/acl/acl-api-test.c | 194 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) diff --git a/tests/sys/acl/Makefile b/tests/sys/acl/Makefile index bd548f06951e..abc505efe90b 100644 --- a/tests/sys/acl/Makefile +++ b/tests/sys/acl/Makefile @@ -14,6 +14,8 @@ ${PACKAGE}FILES+= tools-posix.test SCRIPTS+= run +ATF_TESTS_C+= acl-api-test + TAP_TESTS_SH+= 00 TAP_TESTS_SH+= 01 TAP_TESTS_SH+= 02 diff --git a/tests/sys/acl/acl-api-test.c b/tests/sys/acl/acl-api-test.c new file mode 100644 index 000000000000..3bd288313fed --- /dev/null +++ b/tests/sys/acl/acl-api-test.c @@ -0,0 +1,194 @@ +/*- + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +#include +#include + +#include + +/* Compatibility shim to make it possible to run this test on Linux + * gcc -I/path/to/atf/include -L/path/to/atf/lib -latf-c -lacl acl-api-test.c + */ +#ifdef __linux__ +#include +#define acl_from_mode_np acl_from_mode +#define acl_equiv_mode_np acl_equiv_mode +#define acl_cmp_np acl_cmp +#endif + +static const mode_t all_modes[] = { + S_IRUSR, + S_IWUSR, + S_IXUSR, + S_IRGRP, + S_IWGRP, + S_IXGRP, + S_IROTH, + S_IWOTH, + S_IXOTH +}; + +static mode_t gen_random_mode(void) +{ + mode_t mode = 0; + + for (unsigned i = 0; i < sizeof(all_modes) / sizeof(mode_t); i++) { + if (rand() % 2) + mode |= all_modes[i]; + } + + return (mode); +} + +/* Generate a random mode_t, produce an acl_t from it, + * then use acl_equiv_mode_np to produce a mode_t again. + * The call should succeed and mode_t's should be equal + */ +ATF_TC_WITHOUT_HEAD(acl_mode_roundup); +ATF_TC_BODY(acl_mode_roundup, tc) +{ + int num_tests = 100; + + while (num_tests--) { + mode_t src_mode, equiv_mode; + acl_t acl; + + src_mode = gen_random_mode(); + + acl = acl_from_mode_np(src_mode); + ATF_REQUIRE(acl != NULL); + + ATF_CHECK_EQ(0, acl_equiv_mode_np(acl, &equiv_mode)); + ATF_CHECK_EQ(src_mode, equiv_mode); + + acl_free(acl); + } +} + +/* Successfull acl_equiv_mode_np calls are tested in acl_mode_roundup. + * Here some specific cases are tested. + */ +ATF_TC_WITHOUT_HEAD(acl_equiv_mode_test); +ATF_TC_BODY(acl_equiv_mode_test, tc) +{ + acl_t acl; + acl_entry_t entry; + mode_t mode; + int uid = 0; + + acl = acl_init(1); + ATF_REQUIRE(acl != NULL); + + /* empty acl maps to 0000 UNIX mode */ + ATF_CHECK_EQ(0, acl_equiv_mode_np(acl, &mode)); + ATF_CHECK_EQ(0, mode); + +#ifndef __linux__ + /* NFS-branded acl's can't be converted to UNIX mode */ + ATF_REQUIRE_EQ(0, acl_create_entry(&acl, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_EVERYONE)); + ATF_CHECK_EQ(1, acl_equiv_mode_np(acl, &mode)); +#endif + + /* acl's with qualified user entries can't be converted to UNIX mode */ + acl_free(acl); + acl = acl_init(1); + ATF_REQUIRE(acl != NULL); + ATF_REQUIRE_EQ(0, acl_create_entry(&acl, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_USER)); + ATF_REQUIRE_EQ(0, acl_set_qualifier(entry, &uid)); + ATF_CHECK_EQ(1, acl_equiv_mode_np(acl, &mode)); + + /* passing NULL causes EINVAL */ + ATF_CHECK_ERRNO(EINVAL, acl_equiv_mode_np(NULL, &mode)); +} + +ATF_TC_WITHOUT_HEAD(acl_cmp_test); +ATF_TC_BODY(acl_cmp_test, tc) +{ + acl_t empty_acl, acl1, acl2; + acl_entry_t entry; + acl_permset_t perms; + + empty_acl = acl_init(1); + ATF_REQUIRE(empty_acl != NULL); + + acl1 = acl_init(3); + ATF_REQUIRE(acl1 != NULL); + + /* first, check that two empty acls are equal */ + ATF_CHECK_EQ(0, acl_cmp_np(acl1, empty_acl)); + + /* now create an entry and compare against empty acl */ + ATF_REQUIRE_EQ(0, acl_create_entry(&acl1, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_USER_OBJ)); + ATF_REQUIRE_EQ(0, acl_get_permset(entry, &perms)); + ATF_REQUIRE_EQ(0, acl_clear_perms(perms)); + ATF_REQUIRE_EQ(0, acl_add_perm(perms, ACL_READ)); + ATF_CHECK_EQ(1, acl_cmp_np(empty_acl, acl1)); + + /* make a dup of non-empty acl and check that they are equal */ + acl2 = acl_dup(acl1); + ATF_REQUIRE(acl2 != NULL); + ATF_CHECK_EQ(0, acl_cmp_np(acl1, acl2)); + + /* change the tag type and compare */ + ATF_REQUIRE_EQ(1, acl_get_entry(acl1, ACL_FIRST_ENTRY, &entry)); + ATF_REQUIRE_EQ(0, acl_set_tag_type(entry, ACL_GROUP_OBJ)); + ATF_CHECK_EQ(1, acl_cmp_np(acl1, acl2)); + + /* change the permset and compare */ + acl_free(acl2); + acl2 = acl_dup(acl1); + ATF_REQUIRE(acl2 != NULL); + ATF_REQUIRE_EQ(1, acl_get_entry(acl1, ACL_FIRST_ENTRY, &entry)); + ATF_REQUIRE_EQ(0, acl_get_permset(entry, &perms)); + ATF_REQUIRE_EQ(0, acl_clear_perms(perms)); + ATF_CHECK_EQ(1, acl_cmp_np(acl1, acl2)); + + /* check that passing NULL yields EINVAL */ + ATF_CHECK_ERRNO(EINVAL, acl_cmp_np(NULL, NULL)); + ATF_CHECK_ERRNO(EINVAL, acl_cmp_np(acl1, NULL)); + ATF_CHECK_ERRNO(EINVAL, acl_cmp_np(NULL, acl1)); + + acl_free(empty_acl); + acl_free(acl1); + acl_free(acl2); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, acl_mode_roundup); + ATF_TP_ADD_TC(tp, acl_equiv_mode_test); + ATF_TP_ADD_TC(tp, acl_cmp_test); + + return (atf_no_error()); +} From owner-dev-commits-src-all@freebsd.org Fri Aug 27 08:52:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 05FBE65B689; Fri, 27 Aug 2021 08:52: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 4GwtlN51VBz4rKG; Fri, 27 Aug 2021 08:52: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 5A9292051F; Fri, 27 Aug 2021 08:52: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 17R8qmjP051182; Fri, 27 Aug 2021 08:52:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qmh5051181; Fri, 27 Aug 2021 08:52:48 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:48 GMT Message-Id: <202108270852.17R8qmh5051181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: c468923b2210 - main - libc/posix1e: Add acl_extended_file_np() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c468923b22104bd5fbc408a0a2ef815d5138914a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:49 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c468923b22104bd5fbc408a0a2ef815d5138914a commit c468923b22104bd5fbc408a0a2ef815d5138914a Author: Gleb Popov AuthorDate: 2021-03-12 08:52:58 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:26 +0000 libc/posix1e: Add acl_extended_file_np() function. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- lib/libc/posix1e/Makefile.inc | 4 ++ lib/libc/posix1e/Symbol.map | 3 ++ lib/libc/posix1e/acl_extended_file_np.3 | 95 +++++++++++++++++++++++++++++++++ lib/libc/posix1e/acl_extended_file_np.c | 85 +++++++++++++++++++++++++++++ sys/sys/acl.h | 7 ++- 5 files changed, 192 insertions(+), 2 deletions(-) diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc index 181e43026a6d..3bceef2ff7de 100644 --- a/lib/libc/posix1e/Makefile.inc +++ b/lib/libc/posix1e/Makefile.inc @@ -18,6 +18,7 @@ SRCS+= acl_branding.c \ acl_delete_entry.c \ acl_entry.c \ acl_equiv_mode_np.c \ + acl_extended_file_np.c \ acl_flag.c \ acl_free.c \ acl_from_mode_np.c \ @@ -58,6 +59,7 @@ MAN+= acl.3 \ acl_delete_perm.3 \ acl_dup.3 \ acl_equiv_mode_np.3 \ + acl_extended_file_np.3 \ acl_free.3 \ acl_from_mode_np.3 \ acl_from_text.3 \ @@ -98,6 +100,8 @@ MLINKS+=acl_create_entry.3 acl_create_entry_np.3\ acl_delete.3 acl_delete_file_np.3 \ acl_delete.3 acl_delete_fd_np.3 \ acl_delete_entry.3 acl_delete_entry_np.3\ + acl_extended_file_np.3 acl_extended_file_nofollow_np.3 \ + acl_extended_file_np.3 acl_extended_link_np.3 \ acl_get.3 acl_get_file.3 \ acl_get.3 acl_get_fd.3 \ acl_get.3 acl_get_fd_np.3 \ diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index 40098d42d13d..d78691419c90 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -88,5 +88,8 @@ FBSD_1.1 { FBSD_1.7 { acl_cmp_np; acl_equiv_mode_np; + acl_extended_file_np; + acl_extended_file_nofollow_np; + acl_extended_link_np; acl_from_mode_np; }; diff --git a/lib/libc/posix1e/acl_extended_file_np.3 b/lib/libc/posix1e/acl_extended_file_np.3 new file mode 100644 index 000000000000..26572be9d2b3 --- /dev/null +++ b/lib/libc/posix1e/acl_extended_file_np.3 @@ -0,0 +1,95 @@ +.\"- +.\" Copyright (c) 2021 Gleb Popov +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd February 26, 2021 +.Dt ACL_EXTENDED_FILE_NP 3 +.Os +.Sh NAME +.Nm acl_extended_file_np , +.Nm acl_extended_file_nofollow_np , +.Nm acl_extended_link_np +.Nd checks if the file has extended ACLs set +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/acl.h +.Ft int +.Fn acl_extended_file_np "const char* path_p" +.Ft int +.Fn acl_extended_file_nofollow_np "const char* path_p" +.Ft int +.Fn acl_extended_link_np "const char* path_p" +.Sh DESCRIPTION +The +.Fn acl_extended_file_np +function is a non-portable call that checks if the file or directory referred to +by the argument +.Va path_p +contains extended access ACLs. The +.Fn acl_extended_file_nofollow_np +function works the same way, except it does not follow symlinks. The +.Fn acl_extended_link_np +function is a synonim to +.Fn acl_extended_file_nofollow_np +named in FreeBSD style. +An ACL is considered to be extended access one if it contains entries other +than the three required entries of tag types ACL_USER_OBJ, ACL_GROUP_OBJ and +ACL_OTHER. +.Sh RETURN VALUES +Upon successful completion, this function returns 0 if the file object does not +contain extended access ACLs and 1 in the other case. +Otherwise, the value -1 is returned, and +.Va errno +indicates the error. +.Sh ERRORS +If any of the following conditions occur, the +.Fn acl_extended_file_np +function shall return a value of +.Va -1 +and set +.Va errno +to the corresponding value: +.Bl -tag -width Er +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.Sh SEE ALSO +.Xr extattr_get_file 2 , +.Xr posix1e 3 +.Sh STANDARDS +POSIX.1e is described in IEEE POSIX.1e draft 17. +Discussion +of the draft continues on the cross-platform POSIX.1e implementation +mailing list. +To join this list, see the +.Fx +POSIX.1e implementation +page for more information. +.Sh HISTORY +POSIX.1e support was introduced in +.Fx 4.0 , +and development continues. +.Sh AUTHORS +.An Gleb Popov diff --git a/lib/libc/posix1e/acl_extended_file_np.c b/lib/libc/posix1e/acl_extended_file_np.c new file mode 100644 index 000000000000..c2980825b6b6 --- /dev/null +++ b/lib/libc/posix1e/acl_extended_file_np.c @@ -0,0 +1,85 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Gleb Popov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* + * acl_extended_file_np: Check if the file has extended ACLs set. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include + +typedef acl_t (*acl_get_func)(const char *, acl_type_t); +typedef long (*pathconf_func)(const char *, int); + +static int +_acl_extended_file(acl_get_func f, pathconf_func pathconf_f, const char* path_p); + +int +acl_extended_file_np(const char *path_p) +{ + return (_acl_extended_file(acl_get_file, pathconf, path_p)); +} + +int +acl_extended_file_nofollow_np(const char *path_p) +{ + return (_acl_extended_file(acl_get_link_np, lpathconf, path_p)); +} + +int +acl_extended_link_np(const char *path_p) +{ + return (_acl_extended_file(acl_get_link_np, lpathconf, path_p)); +} + +int +_acl_extended_file(acl_get_func acl_get, pathconf_func pathconf_f, const char* path_p) +{ + acl_t acl; + int retval, istrivial, acltype = ACL_TYPE_ACCESS; + + retval = pathconf_f(path_p, _PC_ACL_NFS4); + if (retval > 0) + acltype = ACL_TYPE_NFS4; + + acl = acl_get(path_p, acltype); + if (acl == NULL) + return (-1); + + retval = acl_is_trivial_np(acl, &istrivial); + acl_free(acl); + if (retval == -1) + return (-1); + + return (!istrivial); +} diff --git a/sys/sys/acl.h b/sys/sys/acl.h index 7c81570739c6..b6958e73c881 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -379,9 +379,12 @@ int acl_delete_def_link_np(const char *_path_p); int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); acl_t acl_dup(acl_t _acl); -int acl_equiv_mode_np(acl_t acl, mode_t *mode_p); +int acl_equiv_mode_np(acl_t _acl, mode_t *_mode_p); +int acl_extended_file_np(const char* _path_p); +int acl_extended_file_nofollow_np(const char* _path_p); +int acl_extended_link_np(const char* _path_p); int acl_free(void *_obj_p); -acl_t acl_from_mode_np(const mode_t mode); +acl_t acl_from_mode_np(const mode_t _mode); acl_t acl_from_text(const char *_buf_p); int acl_get_brand_np(acl_t _acl, int *_brand_p); int acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 08:52:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EAD865B601; Fri, 27 Aug 2021 08:52: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 4GwtlL2bzmz4rB8; Fri, 27 Aug 2021 08:52: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 191A32081F; Fri, 27 Aug 2021 08:52: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 17R8qjK6051131; Fri, 27 Aug 2021 08:52:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17R8qjmr051130; Fri, 27 Aug 2021 08:52:45 GMT (envelope-from git) Date: Fri, 27 Aug 2021 08:52:45 GMT Message-Id: <202108270852.17R8qjmr051130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: fcef0684f108 - main - Fix build of bin/getfacl after libc changes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fcef0684f1084aeacae556adc5d4d5853b7e748e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 08:52:46 -0000 The branch main has been updated by arrowd (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=fcef0684f1084aeacae556adc5d4d5853b7e748e commit fcef0684f1084aeacae556adc5d4d5853b7e748e Author: Gleb Popov AuthorDate: 2021-01-20 09:47:44 +0000 Commit: Gleb Popov CommitDate: 2021-08-27 08:52:18 +0000 Fix build of bin/getfacl after libc changes. Reviewed by: kib, debdrup, gbe Approved by: kib Differential Revision: https://reviews.freebsd.org/D28255 --- bin/getfacl/getfacl.c | 93 +-------------------------------------------------- 1 file changed, 1 insertion(+), 92 deletions(-) diff --git a/bin/getfacl/getfacl.c b/bin/getfacl/getfacl.c index d59ddbcfc871..ecdc73f74fbc 100644 --- a/bin/getfacl/getfacl.c +++ b/bin/getfacl/getfacl.c @@ -83,97 +83,6 @@ getgname(gid_t gid) return (gr->gr_name); } -/* - * return an ACL corresponding to the permissions - * contained in mode_t - */ -static acl_t -acl_from_mode(const mode_t mode) -{ - acl_t acl; - acl_entry_t entry; - acl_permset_t perms; - - /* create the ACL */ - acl = acl_init(3); - if (!acl) - return NULL; - - /* First entry: ACL_USER_OBJ */ - if (acl_create_entry(&acl, &entry) == -1) - return NULL; - if (acl_set_tag_type(entry, ACL_USER_OBJ) == -1) - return NULL; - - if (acl_get_permset(entry, &perms) == -1) - return NULL; - if (acl_clear_perms(perms) == -1) - return NULL; - - /* calculate user mode */ - if (mode & S_IRUSR) - if (acl_add_perm(perms, ACL_READ) == -1) - return NULL; - if (mode & S_IWUSR) - if (acl_add_perm(perms, ACL_WRITE) == -1) - return NULL; - if (mode & S_IXUSR) - if (acl_add_perm(perms, ACL_EXECUTE) == -1) - return NULL; - if (acl_set_permset(entry, perms) == -1) - return NULL; - - /* Second entry: ACL_GROUP_OBJ */ - if (acl_create_entry(&acl, &entry) == -1) - return NULL; - if (acl_set_tag_type(entry, ACL_GROUP_OBJ) == -1) - return NULL; - - if (acl_get_permset(entry, &perms) == -1) - return NULL; - if (acl_clear_perms(perms) == -1) - return NULL; - - /* calculate group mode */ - if (mode & S_IRGRP) - if (acl_add_perm(perms, ACL_READ) == -1) - return NULL; - if (mode & S_IWGRP) - if (acl_add_perm(perms, ACL_WRITE) == -1) - return NULL; - if (mode & S_IXGRP) - if (acl_add_perm(perms, ACL_EXECUTE) == -1) - return NULL; - if (acl_set_permset(entry, perms) == -1) - return NULL; - - /* Third entry: ACL_OTHER */ - if (acl_create_entry(&acl, &entry) == -1) - return NULL; - if (acl_set_tag_type(entry, ACL_OTHER) == -1) - return NULL; - - if (acl_get_permset(entry, &perms) == -1) - return NULL; - if (acl_clear_perms(perms) == -1) - return NULL; - - /* calculate other mode */ - if (mode & S_IROTH) - if (acl_add_perm(perms, ACL_READ) == -1) - return NULL; - if (mode & S_IWOTH) - if (acl_add_perm(perms, ACL_WRITE) == -1) - return NULL; - if (mode & S_IXOTH) - if (acl_add_perm(perms, ACL_EXECUTE) == -1) - return NULL; - if (acl_set_permset(entry, perms) == -1) - return NULL; - - return(acl); -} - static int print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag, int qflag, int vflag) @@ -229,7 +138,7 @@ print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag, errno = 0; if (type == ACL_TYPE_DEFAULT) return(0); - acl = acl_from_mode(sb.st_mode); + acl = acl_from_mode_np(sb.st_mode); if (!acl) { warn("%s: acl_from_mode() failed", path); return(-1); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 10:40:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 610D265CD7E for ; Fri, 27 Aug 2021 10:40: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 4Gwx872CLQz4RNK; Fri, 27 Aug 2021 10:40: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 28ED021E12; Fri, 27 Aug 2021 10:40: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 17RAetca097053; Fri, 27 Aug 2021 10:40:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RAet5p097052; Fri, 27 Aug 2021 10:40:55 GMT (envelope-from git) Date: Fri, 27 Aug 2021 10:40:55 GMT Message-Id: <202108271040.17RAet5p097052@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org From: Martin Matuska Subject: git: 9aa547618472..6c0d5e8e0e5f - vendor/libarchive - vendor branch updated MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/vendor/libarchive X-Git-Reftype: branch X-Git-Commit: 6c0d5e8e0e5f66cbb974dba994cb265fc89d19e8 X-Git-Oldrev: 9aa5476184726da9d9159568c9b15e29451b5778 X-Git-Newrev: 6c0d5e8e0e5f66cbb974dba994cb265fc89d19e8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 10:40:55 -0000 The branch vendor/libarchive has been updated by mm: URL: https://cgit.FreeBSD.org/src/log/?id=9aa547618472..6c0d5e8e0e5f 6c0d5e8e0e5f vendor/libarchive: cherry-pick 8a1bd5c18 from upstream From owner-dev-commits-src-all@freebsd.org Fri Aug 27 10:51:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6DF9965D95A; Fri, 27 Aug 2021 10:51: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 4GwxNq2klpz4V77; Fri, 27 Aug 2021 10:51: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 4633E22035; Fri, 27 Aug 2021 10:51: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 17RApts0011785; Fri, 27 Aug 2021 10:51:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RApsmG011784; Fri, 27 Aug 2021 10:51:54 GMT (envelope-from git) Date: Fri, 27 Aug 2021 10:51:54 GMT Message-Id: <202108271051.17RApsmG011784@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Martin Matuska Subject: git: c577bdfce6b4 - main - libarchive: import bugfix from upstream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c577bdfce6b4451ab897bfe5013543e78a7f9b62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 10:51:55 -0000 The branch main has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=c577bdfce6b4451ab897bfe5013543e78a7f9b62 commit c577bdfce6b4451ab897bfe5013543e78a7f9b62 Merge: c468923b2210 6c0d5e8e0e5f Author: Martin Matuska AuthorDate: 2021-08-27 10:51:01 +0000 Commit: Martin Matuska CommitDate: 2021-08-27 10:51:01 +0000 libarchive: import bugfix from upstream Reworked bugfix for upstream issue #1566: Do not follow symlinks when processing the fixup list MFC after: 2 weeks .../libarchive/archive_write_disk_posix.c | 62 +++++++++++++++------- .../libarchive/test/test_write_disk_fixup.c | 44 +++++++++++---- 2 files changed, 78 insertions(+), 28 deletions(-) From owner-dev-commits-src-all@freebsd.org Fri Aug 27 11:42:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C5A8065E4A0; Fri, 27 Aug 2021 11:42: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 4GwyWT4jsQz4ryy; Fri, 27 Aug 2021 11:42: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 893A822CA2; Fri, 27 Aug 2021 11:42: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 17RBgjrf080086; Fri, 27 Aug 2021 11:42:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RBgjsJ080085; Fri, 27 Aug 2021 11:42:45 GMT (envelope-from git) Date: Fri, 27 Aug 2021 11:42:45 GMT Message-Id: <202108271142.17RBgjsJ080085@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 9a91689e414c - stable/13 - vfs: Add get_write_ioflag helper to calculate ioflag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9a91689e414cf26204fc993b4d32c4a1fc61aaf0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 11:42:45 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=9a91689e414cf26204fc993b4d32c4a1fc61aaf0 commit 9a91689e414cf26204fc993b4d32c4a1fc61aaf0 Author: Ka Ho Ng AuthorDate: 2021-08-12 09:35:34 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 08:50:12 +0000 vfs: Add get_write_ioflag helper to calculate ioflag Converted vn_write to use this helper. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31513 (cherry picked from commit c15384f8963191a238cb4a33382b4d394f1ac0b4) --- sys/kern/vfs_vnops.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index b7e53add5a35..8f5442bf3429 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -914,6 +914,35 @@ get_advice(struct file *fp, struct uio *uio) return (ret); } +static int +get_write_ioflag(struct file *fp) +{ + int ioflag; + struct mount *mp; + struct vnode *vp; + + ioflag = 0; + vp = fp->f_vnode; + mp = atomic_load_ptr(&vp->v_mount); + + if ((fp->f_flag & O_DIRECT) != 0) + ioflag |= IO_DIRECT; + + if ((fp->f_flag & O_FSYNC) != 0 || + (mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS) != 0)) + ioflag |= IO_SYNC; + + /* + * For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE() + * or VOP_DEALLOCATE() implementations that don't understand IO_DATASYNC + * fall back to full O_SYNC behavior. + */ + if ((fp->f_flag & O_DSYNC) != 0) + ioflag |= IO_SYNC | IO_DATASYNC; + + return (ioflag); +} + int vn_read_from_obj(struct vnode *vp, struct uio *uio) { @@ -1113,25 +1142,12 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, if (vp->v_type == VREG) bwillwrite(); ioflag = IO_UNIT; - if (vp->v_type == VREG && (fp->f_flag & O_APPEND)) + if (vp->v_type == VREG && (fp->f_flag & O_APPEND) != 0) ioflag |= IO_APPEND; - if (fp->f_flag & FNONBLOCK) + if ((fp->f_flag & FNONBLOCK) != 0) ioflag |= IO_NDELAY; - if (fp->f_flag & O_DIRECT) - ioflag |= IO_DIRECT; + ioflag |= get_write_ioflag(fp); - mp = atomic_load_ptr(&vp->v_mount); - if ((fp->f_flag & O_FSYNC) || - (mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS))) - ioflag |= IO_SYNC; - - /* - * For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE() - * implementations that don't understand IO_DATASYNC fall back to full - * O_SYNC behavior. - */ - if (fp->f_flag & O_DSYNC) - ioflag |= IO_SYNC | IO_DATASYNC; mp = NULL; need_finished_write = false; if (vp->v_type != VCHR) { From owner-dev-commits-src-all@freebsd.org Fri Aug 27 11:42:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F61065E709; Fri, 27 Aug 2021 11:42: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 4GwyWV656Bz4sCg; Fri, 27 Aug 2021 11:42: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 986A822CA3; Fri, 27 Aug 2021 11:42: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 17RBgk8G080110; Fri, 27 Aug 2021 11:42:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RBgkcO080109; Fri, 27 Aug 2021 11:42:46 GMT (envelope-from git) Date: Fri, 27 Aug 2021 11:42:46 GMT Message-Id: <202108271142.17RBgkcO080109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: e899971b817c - stable/13 - sound: Add an example of basic sound application MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e899971b817cb214c04032586225c32fefb2a0cf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 11:42:47 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=e899971b817cb214c04032586225c32fefb2a0cf commit e899971b817cb214c04032586225c32fefb2a0cf Author: Goran Mekić AuthorDate: 2021-08-04 10:04:54 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 08:50:44 +0000 sound: Add an example of basic sound application This is an example demonstrating the usage of the OSS-compatible APIs provided by the sound(4) subsystem. It reads frames from a dsp node and writes them to the same dsp node. Reviewed by: hselasky, bcr Differential revision: https://reviews.freebsd.org/D30149 (cherry picked from commit 21d854658801f6ddb91de3a3c3384e90f5d920f2) --- share/examples/Makefile | 7 ++ share/examples/sound/README | 66 +++++++++++ share/examples/sound/basic.c | 99 ++++++++++++++++ share/examples/sound/ossinit.h | 262 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 434 insertions(+) diff --git a/share/examples/Makefile b/share/examples/Makefile index f4273d2266f0..1d916f344b77 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -30,6 +30,7 @@ LDIRS= BSD_daemon \ printing \ ses \ scsi_target \ + sound \ sunrpc \ ypldap @@ -315,6 +316,12 @@ SE_SCSI_TARGET= \ scsi_target.8 \ scsi_cmds.c +SE_DIRS+= sound +SE_SOUND= \ + basic.c \ + ossinit.h \ + README + SE_DIRS+= sunrpc SE_SUNRPC= Makefile diff --git a/share/examples/sound/README b/share/examples/sound/README new file mode 100644 index 000000000000..0188a26348c8 --- /dev/null +++ b/share/examples/sound/README @@ -0,0 +1,66 @@ +Briefly summarised, a general audio application will: +- open(2) +- ioctl(2) +- read(2) +- write(2) +- close(2) + +In this example, read/write will be called in a loop for a duration of +record/playback. Usually, /dev/dsp is the device you want to open, but it can +be any OSS compatible device, even user space one created with virtual_oss. For +configuring sample rate, bit depth and all other configuring of the device +ioctl is used. As devices can support multiple sample rates and formats, what +specific application should do in case there's an error issuing ioctl, as not +all errors are fatal, is upon the developer to decide. As a general guideline +Official OSS development howto should be used. FreeBSD OSS and virtual_oss are +different to a small degree. + +For more advanced OSS and real-time applications, developers need to handle +buffers more carefully. The size of the buffer in OSS is selected using fragment +size size_selector and the buffer size is 2^size_selector for values between 4 +and 16. The formula on the official site is: + +int frag = (max_fragments << 16) | (size_selector); +ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag); + +The max_fragments determines in how many fragments the buffer will be, hence if +the size_selector is 4, the requested size is 2^4 = 16 and for the +max_fragments of 2, the total buffer size will be + +(2 ^ size_selector) * max_fragments + +or in this case 32 bytes. Please note that size of buffer is in bytes not +samples. For example, 24bit sample will be represented with 3 bytes. If you're +porting audio app from Linux, you should be aware that 24 bit samples are +represented with 4 bytes (usually int). + +FreeBSD kernel will round up max_fragments and size of fragment/buffer, so the +last thing any OSS code should do is get info about buffer with audio_buf_info +and SNDCTL_DSP_GETOSPACE. That also means that not all values of max_fragments +are permitted. + +From kernel perspective, there are few points OSS developers should be aware of: +- There is a software facing buffer (bs) and a hardware driver buffer (b) +- The sizes can be seen with cat /dev/sndstat as [b:_/_/_] [bs:_/_/_] (needed: + sysctl hw.snd.verbose=2) +- OSS ioctl only concern software buffer fragments, not hardware + +For USB the block size is according to hw.usb.uaudio.buffer_ms sysctl, meaning +2ms at 48kHz gives 0.002 * 48000 = 96 samples per block, all multiples of this +work well. Block size for virtual_oss, if used, should be set accordingly. + +OSS driver insists on reading / writing a certain number of samples at a time, +one fragment full of samples. It is bound to do so in a fixed time frame, to +avoid under- and overruns in communication with the hardware. + +The idea of a total buffer size that holds max_fragments fragments is to give +some slack and allow application to be about max_fragments - 1 fragments late. +Let's call this the jitter tolerance. The jitter tolerance may be much less if +there is a slight mismatch between the period and the samples per fragment. + +Jitter tolerance gets better if we can make either the period or the samples +per fragment considerably smaller than the other. In our case that means we +divide the total buffer size into smaller fragments, keeping overall latency at +the same level. + +Official OSS development howto: http://manuals.opensound.com/developer/DSP.html diff --git a/share/examples/sound/basic.c b/share/examples/sound/basic.c new file mode 100644 index 000000000000..c903cbd8bf11 --- /dev/null +++ b/share/examples/sound/basic.c @@ -0,0 +1,99 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Goran Mekić + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ossinit.h" + +int +main() +{ + config_t config = { + .device = "/dev/dsp", + .channels = -1, + .format = format, + .frag = -1, + .sample_rate = 48000, + .sample_size = sizeof(sample_t), + .buffer_info.fragments = -1, + .mmap = 0, + }; + + /* Initialize device */ + oss_init(&config); + + /* + * Allocate input and output buffers so that their size match + * frag_size + */ + int ret; + int bytes = config.buffer_info.bytes; + int8_t *ibuf = malloc(bytes); + int8_t *obuf = malloc(bytes); + sample_t *channels = malloc(bytes); + + printf( + "bytes: %d, fragments: %d, fragsize: %d, fragstotal: %d, samples: %d\n", + bytes, + config.buffer_info.fragments, + config.buffer_info.fragsize, + config.buffer_info.fragstotal, + config.sample_count + ); + + /* Minimal engine: read input and copy it to the output */ + for (;;) { + ret = read(config.fd, ibuf, bytes); + if (ret < bytes) { + fprintf( + stderr, + "Requested %d bytes, but read %d!\n", + bytes, + ret + ); + break; + } + oss_split(&config, (sample_t *)ibuf, channels); + /* All processing will happen here */ + oss_merge(&config, channels, (sample_t *)obuf); + ret = write(config.fd, obuf, bytes); + if (ret < bytes) { + fprintf( + stderr, + "Requested %d bytes, but wrote %d!\n", + bytes, + ret + ); + break; + } + } + + /* Cleanup */ + free(channels); + free(obuf); + free(ibuf); + close(config.fd); + return (0); +} diff --git a/share/examples/sound/ossinit.h b/share/examples/sound/ossinit.h new file mode 100644 index 000000000000..b5fbd3e99244 --- /dev/null +++ b/share/examples/sound/ossinit.h @@ -0,0 +1,262 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Goran Mekić + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include + + +#ifndef SAMPLE_SIZE +#define SAMPLE_SIZE 16 +#endif + +/* Format can be unsigned, in which case replace S with U */ +#if SAMPLE_SIZE == 32 +typedef int32_t sample_t; +int format = AFMT_S32_NE; /* Signed 32bit native endian format */ +#elif SAMPLE_SIZE == 16 +typedef int16_t sample_t; +int format = AFMT_S16_NE; /* Signed 16bit native endian format */ +#elif SAMPLE_SIZE == 8 +typedef int8_t sample_t; +int format = AFMT_S8_NE; /* Signed 8bit native endian format */ +#else +#error Unsupported sample format! +typedef int32_t sample_t; +int format = AFMT_S32_NE; /* Not a real value, just silencing + * compiler errors */ +#endif + + + +/* + * Minimal configuration for OSS + * For real world applications, this structure will probably contain many + * more fields + */ +typedef struct config { + char *device; + int channels; + int fd; + int format; + int frag; + int sample_count; + int sample_rate; + int sample_size; + int chsamples; + int mmap; + oss_audioinfo audio_info; + audio_buf_info buffer_info; +} config_t; + + +/* + * Error state is indicated by value=-1 in which case application exits + * with error + */ +static inline void +check_error(const int value, const char *message) +{ + if (value == -1) { + fprintf(stderr, "OSS error: %s %s\n", message, strerror(errno)); + exit(1); + } +} + + + +/* Calculate frag by giving it minimal size of buffer */ +static inline int +size2frag(int x) +{ + int frag = 0; + + while ((1 << frag) < x) { + ++frag; + } + return frag; +} + + +/* + * Split input buffer into channels. Input buffer is in interleaved format + * which means if we have 2 channels (L and R), this is what the buffer of + * 8 samples would contain: L,R,L,R,L,R,L,R. The result are two channels + * containing: L,L,L,L and R,R,R,R. + */ +void +oss_split(config_t *config, sample_t *input, sample_t *output) +{ + int channel; + int index; + + for (int i = 0; i < config->sample_count; ++i) { + channel = i % config->channels; + index = i / config->channels; + output[channel * index] = input[i]; + } +} + + +/* + * Convert channels into interleaved format and place it in output + * buffer + */ +void +oss_merge(config_t *config, sample_t *input, sample_t *output) +{ + for (int channel = 0; channel < config->channels; ++channel) { + for (int index = 0; index < config->chsamples; ++index) { + output[index * config->channels + channel] = input[channel * index]; + } + } +} + +void +oss_init(config_t *config) +{ + int error; + int tmp; + + /* Open the device for read and write */ + config->fd = open(config->device, O_RDWR); + check_error(config->fd, "open"); + + /* Get device information */ + config->audio_info.dev = -1; + error = ioctl(config->fd, SNDCTL_ENGINEINFO, &(config->audio_info)); + check_error(error, "SNDCTL_ENGINEINFO"); + printf("min_channels: %d\n", config->audio_info.min_channels); + printf("max_channels: %d\n", config->audio_info.max_channels); + printf("latency: %d\n", config->audio_info.latency); + printf("handle: %s\n", config->audio_info.handle); + if (config->audio_info.min_rate > config->sample_rate || config->sample_rate > config->audio_info.max_rate) { + fprintf(stderr, "%s doesn't support chosen ", config->device); + fprintf(stderr, "samplerate of %dHz!\n", config->sample_rate); + exit(1); + } + if (config->channels < 1) { + config->channels = config->audio_info.max_channels; + } + + /* + * If device is going to be used in mmap mode, disable all format + * conversions. Official OSS documentation states error code should not be + * checked. http://manuals.opensound.com/developer/mmap_test.c.html#LOC10 + */ + if (config->mmap) { + tmp = 0; + ioctl(config->fd, SNDCTL_DSP_COOKEDMODE, &tmp); + } + + /* + * Set number of channels. If number of channels is chosen to the value + * near the one wanted, save it in config + */ + tmp = config->channels; + error = ioctl(config->fd, SNDCTL_DSP_CHANNELS, &tmp); + check_error(error, "SNDCTL_DSP_CHANNELS"); + if (tmp != config->channels) { /* or check if tmp is close enough? */ + fprintf(stderr, "%s doesn't support chosen ", config->device); + fprintf(stderr, "channel count of %d", config->channels); + fprintf(stderr, ", set to %d!\n", tmp); + } + config->channels = tmp; + + /* Set format, or bit size: 8, 16, 24 or 32 bit sample */ + tmp = config->format; + error = ioctl(config->fd, SNDCTL_DSP_SETFMT, &tmp); + check_error(error, "SNDCTL_DSP_SETFMT"); + if (tmp != config->format) { + fprintf(stderr, "%s doesn't support chosen sample format!\n", config->device); + exit(1); + } + + /* Most common values for samplerate (in kHz): 44.1, 48, 88.2, 96 */ + tmp = config->sample_rate; + error = ioctl(config->fd, SNDCTL_DSP_SPEED, &tmp); + check_error(error, "SNDCTL_DSP_SPEED"); + + /* Get and check device capabilities */ + error = ioctl(config->fd, SNDCTL_DSP_GETCAPS, &(config->audio_info.caps)); + check_error(error, "SNDCTL_DSP_GETCAPS"); + if (!(config->audio_info.caps & PCM_CAP_DUPLEX)) { + fprintf(stderr, "Device doesn't support full duplex!\n"); + exit(1); + } + if (config->mmap) { + if (!(config->audio_info.caps & PCM_CAP_TRIGGER)) { + fprintf(stderr, "Device doesn't support triggering!\n"); + exit(1); + } + if (!(config->audio_info.caps & PCM_CAP_MMAP)) { + fprintf(stderr, "Device doesn't support mmap mode!\n"); + exit(1); + } + } + + /* + * If desired frag is smaller than minimum, based on number of channels + * and format (size in bits: 8, 16, 24, 32), set that as frag. Buffer size + * is 2^frag, but the real size of the buffer will be read when the + * configuration of the device is successfull + */ + int min_frag = size2frag(config->sample_size * config->channels); + + if (config->frag < min_frag) { + config->frag = min_frag; + } + + /* + * Allocate buffer in fragments. Total buffer will be split in number + * of fragments (2 by default) + */ + if (config->buffer_info.fragments < 0) { + config->buffer_info.fragments = 2; + } + tmp = ((config->buffer_info.fragments) << 16) | config->frag; + error = ioctl(config->fd, SNDCTL_DSP_SETFRAGMENT, &tmp); + check_error(error, "SNDCTL_DSP_SETFRAGMENT"); + + /* When all is set and ready to go, get the size of buffer */ + error = ioctl(config->fd, SNDCTL_DSP_GETOSPACE, &(config->buffer_info)); + check_error(error, "SNDCTL_DSP_GETOSPACE"); + if (config->buffer_info.bytes < 1) { + fprintf( + stderr, + "OSS buffer error: buffer size can not be %d\n", + config->buffer_info.bytes + ); + exit(1); + } + config->sample_count = config->buffer_info.bytes / config->sample_size; + config->chsamples = config->sample_count / config->channels; +} From owner-dev-commits-src-all@freebsd.org Fri Aug 27 11:42:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2528065E70C; Fri, 27 Aug 2021 11:42: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 4GwyWY1SL9z4s6G; Fri, 27 Aug 2021 11:42: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 DF72A22B1C; Fri, 27 Aug 2021 11:42: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 17RBgmDl080158; Fri, 27 Aug 2021 11:42:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RBgm8j080157; Fri, 27 Aug 2021 11:42:48 GMT (envelope-from git) Date: Fri, 27 Aug 2021 11:42:48 GMT Message-Id: <202108271142.17RBgm8j080157@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 3bda6fa6a021 - stable/13 - tmpfs: Fix error being cleared after commit c12118f6cec0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3bda6fa6a0210256c3d7ae5f771fb2626f0f62b7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 11:42:50 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=3bda6fa6a0210256c3d7ae5f771fb2626f0f62b7 commit 3bda6fa6a0210256c3d7ae5f771fb2626f0f62b7 Author: Ka Ho Ng AuthorDate: 2021-08-24 16:35:29 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 08:51:54 +0000 tmpfs: Fix error being cleared after commit c12118f6cec0 In tmpfs_link() error was erroneously cleared in commit c12118f6cec0. Sponsored by: The FreeBSD Foundation MFC with: c12118f6cec0 (cherry picked from commit a48416f844e3007b4e9f6df125e25cf3a1daad62) --- sys/fs/tmpfs/tmpfs_vnops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 325b8d2789bb..326a5132990d 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return (0); + return (error); } /* From owner-dev-commits-src-all@freebsd.org Fri Aug 27 11:42:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9A61E65E4A2; Fri, 27 Aug 2021 11:42: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 4GwyWW6kjdz4rqp; Fri, 27 Aug 2021 11:42: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 BEE3922CA4; Fri, 27 Aug 2021 11:42: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 17RBglAw080134; Fri, 27 Aug 2021 11:42:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RBgl84080133; Fri, 27 Aug 2021 11:42:47 GMT (envelope-from git) Date: Fri, 27 Aug 2021 11:42:47 GMT Message-Id: <202108271142.17RBgl84080133@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: e678b3ee8bf5 - stable/13 - tmpfs: Fix styles MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e678b3ee8bf55e8a2995f50a07cc3f7a0fd63dbf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 11:42:48 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=e678b3ee8bf55e8a2995f50a07cc3f7a0fd63dbf commit e678b3ee8bf55e8a2995f50a07cc3f7a0fd63dbf Author: Ka Ho Ng AuthorDate: 2021-08-24 13:09:21 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 08:51:43 +0000 tmpfs: Fix styles A lot of return statements were in the wrong style before this commit. Sponsored by: The FreeBSD Foundation (cherry picked from commit c12118f6cec0ca5f720be6c06d6c59d551461e5a) --- sys/fs/tmpfs/tmpfs_subr.c | 6 +++--- sys/fs/tmpfs/tmpfs_vfsops.c | 4 ++-- sys/fs/tmpfs/tmpfs_vnops.c | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index b7dae82a71b4..387bc741e3cf 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -714,7 +714,7 @@ tmpfs_alloc_dirent(struct tmpfs_mount *tmp, struct tmpfs_node *node, *de = nde; - return 0; + return (0); } /* @@ -1861,11 +1861,11 @@ tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucred *cred, struct thread *p) /* Disallow this operation if the file system is mounted read-only. */ if (vp->v_mount->mnt_flag & MNT_RDONLY) - return EROFS; + return (EROFS); /* Immutable or append-only files cannot be modified, either. */ if (node->tn_flags & (IMMUTABLE | APPEND)) - return EPERM; + return (EPERM); /* * To modify the permissions on a file, must possess VADMIN diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 7dffb9027946..b8ecedbb0348 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -479,7 +479,7 @@ tmpfs_mount(struct mount *mp) vfs_getnewfsid(mp); vfs_mountedfrom(mp, "tmpfs"); - return 0; + return (0); } /* ARGSUSED2 */ @@ -644,7 +644,7 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp) sbp->f_ffree = sbp->f_files - used; /* sbp->f_owner = tmp->tn_uid; */ - return 0; + return (0); } static int diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 5d0d80639046..325b8d2789bb 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -277,9 +277,9 @@ tmpfs_mknod(struct vop_mknod_args *v) if (vap->va_type != VBLK && vap->va_type != VCHR && vap->va_type != VFIFO) - return EINVAL; + return (EINVAL); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } struct fileops tmpfs_fnops; @@ -517,7 +517,7 @@ tmpfs_getattr(struct vop_getattr_args *v) vap->va_bytes = node->tn_size; vap->va_filerev = 0; - return 0; + return (0); } int @@ -575,7 +575,7 @@ tmpfs_setattr(struct vop_setattr_args *v) MPASS(VOP_ISLOCKED(vp)); - return error; + return (error); } static int @@ -705,7 +705,7 @@ tmpfs_fsync(struct vop_fsync_args *v) tmpfs_check_mtime(vp); tmpfs_update(vp); - return 0; + return (0); } static int @@ -808,7 +808,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return error; + return (0); } /* @@ -1264,7 +1264,7 @@ tmpfs_mkdir(struct vop_mkdir_args *v) MPASS(vap->va_type == VDIR); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } static int @@ -1355,7 +1355,7 @@ tmpfs_rmdir(struct vop_rmdir_args *v) error = 0; out: - return error; + return (error); } static int @@ -1373,7 +1373,7 @@ tmpfs_symlink(struct vop_symlink_args *v) vap->va_type = VLNK; #endif - return tmpfs_alloc_file(dvp, vpp, vap, cnp, target); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, target)); } static int @@ -1396,7 +1396,7 @@ tmpfs_readdir(struct vop_readdir_args *va) /* This operation only makes sense on directory nodes. */ if (vp->v_type != VDIR) - return ENOTDIR; + return (ENOTDIR); maxcookies = 0; node = VP_TO_TMPFS_DIR(vp); @@ -1433,7 +1433,7 @@ tmpfs_readdir(struct vop_readdir_args *va) *eofflag = (error == 0 && uio->uio_offset == TMPFS_DIRCOOKIE_EOF); - return error; + return (error); } static int @@ -1580,7 +1580,7 @@ tmpfs_print(struct vop_print_args *v) printf("\n"); - return 0; + return (0); } int @@ -1634,7 +1634,7 @@ tmpfs_pathconf(struct vop_pathconf_args *v) error = vop_stdpathconf(v); } - return error; + return (error); } static int From owner-dev-commits-src-all@freebsd.org Fri Aug 27 11:42:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA5EA65E6DB; Fri, 27 Aug 2021 11:42: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 4GwyWZ2QFcz4sFV; Fri, 27 Aug 2021 11:42: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 1706F22C75; Fri, 27 Aug 2021 11:42: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 17RBgnLO080188; Fri, 27 Aug 2021 11:42:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RBgnWw080187; Fri, 27 Aug 2021 11:42:49 GMT (envelope-from git) Date: Fri, 27 Aug 2021 11:42:49 GMT Message-Id: <202108271142.17RBgnWw080187@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 877ba067c0fb - stable/13 - vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 877ba067c0fb8e09ef6a47100817615b648bd5ee Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 11:42:51 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=877ba067c0fb8e09ef6a47100817615b648bd5ee commit 877ba067c0fb8e09ef6a47100817615b648bd5ee Author: Ka Ho Ng AuthorDate: 2021-08-02 09:54:40 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 08:52:49 +0000 vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1 In hw.vmm.create sysctl handler the maximum length of vm name is VM_MAX_NAMELEN. However in vm_create() the maximum length allowed is only VM_MAX_NAMELEN - 1 chars. Bump the length of the internal buffer to allow the length of VM_MAX_NAMELEN for vm name. Reviewed by: grehan Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31372 (cherry picked from commit df95cc76affbbf114c9ff2e4ee011b6f162aa8bd) --- sys/amd64/vmm/vmm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 5c2a404f45a7..80fcde8d80fa 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -174,7 +174,7 @@ struct vm { struct mem_map mem_maps[VM_MAX_MEMMAPS]; /* (i) guest address space */ struct mem_seg mem_segs[VM_MAX_MEMSEGS]; /* (o) guest memory regions */ struct vmspace *vmspace; /* (o) guest's address space */ - char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */ + char name[VM_MAX_NAMELEN+1]; /* (o) virtual machine name */ struct vcpu vcpu[VM_MAXCPU]; /* (i) guest vcpus */ /* The following describe the vm cpu topology */ uint16_t sockets; /* (o) num of sockets */ @@ -480,7 +480,8 @@ vm_create(const char *name, struct vm **retvm) if (!vmm_initialized) return (ENXIO); - if (name == NULL || strlen(name) >= VM_MAX_NAMELEN) + if (name == NULL || strnlen(name, VM_MAX_NAMELEN + 1) == + VM_MAX_NAMELEN + 1) return (EINVAL); vmspace = vmmops_vmspace_alloc(0, VM_MAXUSER_ADDRESS_LA48); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 11:49:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E49365E933; Fri, 27 Aug 2021 11:49: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 4Gwyfh2cl9z4vhd; Fri, 27 Aug 2021 11:49: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 418E62292A; Fri, 27 Aug 2021 11:49: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 17RBn0gF080743; Fri, 27 Aug 2021 11:49:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RBn0F3080742; Fri, 27 Aug 2021 11:49:00 GMT (envelope-from git) Date: Fri, 27 Aug 2021 11:49:00 GMT Message-Id: <202108271149.17RBn0F3080742@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: 9a4d48a645a7 - main - llvm/powerpc64*: fix broken binaries generated by clang12 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: alfredo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a4d48a645a7a3ebee05fae25afd154a132b638a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 11:49:00 -0000 The branch main has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=9a4d48a645a7a3ebee05fae25afd154a132b638a commit 9a4d48a645a7a3ebee05fae25afd154a132b638a Author: Alfredo Dal'Ava Junior AuthorDate: 2021-08-27 14:47:11 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2021-08-27 14:47:11 +0000 llvm/powerpc64*: fix broken binaries generated by clang12 Amends LLVM commit 2518433f861fcb877d0a7bdd9aec1aec1f77505a that was pointed as the source of regression on LLVM12. This affects powerpc64*, making binaries crash with segmentation fault due to bad code generation around "__stack_chk_guard" Root cause and/or proper fix is under investigation by: https://bugs.llvm.org/show_bug.cgi?id=51590 Reviewed by: dim MFC after: 2 days Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D31698 --- contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp b/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp index 28c8bd0a7ded..74fea674f962 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1961,7 +1961,8 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const { GlobalVariable::ExternalLinkage, nullptr, "__stack_chk_guard"); if (TM.getRelocationModel() == Reloc::Static && - !TM.getTargetTriple().isWindowsGNUEnvironment()) + !TM.getTargetTriple().isWindowsGNUEnvironment() && + !(TM.getTargetTriple().isPPC64() && TM.getTargetTriple().isOSFreeBSD())) GV->setDSOLocal(true); } } From owner-dev-commits-src-all@freebsd.org Fri Aug 27 12:46:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C755065F373; Fri, 27 Aug 2021 12:46:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gwzx74lw9z3hfQ; Fri, 27 Aug 2021 12:46:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B886234E4; Fri, 27 Aug 2021 12:46:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RCkZil059997; Fri, 27 Aug 2021 12:46:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCkZIR059996; Fri, 27 Aug 2021 12:46:35 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:46:35 GMT Message-Id: <202108271246.17RCkZIR059996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 45d1b7b34a5a - stable/12 - sound: Add an example of basic sound application MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 45d1b7b34a5a431562fa793d2361a51497b19ff1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:46:35 -0000 The branch stable/12 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=45d1b7b34a5a431562fa793d2361a51497b19ff1 commit 45d1b7b34a5a431562fa793d2361a51497b19ff1 Author: Goran Mekić AuthorDate: 2021-08-04 10:04:54 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 12:05:27 +0000 sound: Add an example of basic sound application This is an example demonstrating the usage of the OSS-compatible APIs provided by the sound(4) subsystem. It reads frames from a dsp node and writes them to the same dsp node. Reviewed by: hselasky, bcr Differential revision: https://reviews.freebsd.org/D30149 (cherry picked from commit 21d854658801f6ddb91de3a3c3384e90f5d920f2) --- share/examples/Makefile | 7 ++ share/examples/sound/README | 66 +++++++++++ share/examples/sound/basic.c | 99 ++++++++++++++++ share/examples/sound/ossinit.h | 262 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 434 insertions(+) diff --git a/share/examples/Makefile b/share/examples/Makefile index 6b58daf5310e..5eab9f5210d7 100644 --- a/share/examples/Makefile +++ b/share/examples/Makefile @@ -30,6 +30,7 @@ LDIRS= BSD_daemon \ printing \ ses \ scsi_target \ + sound \ sunrpc \ ypldap @@ -317,6 +318,12 @@ SE_SCSI_TARGET= \ scsi_target.8 \ scsi_cmds.c +SE_DIRS+= sound +SE_SOUND= \ + basic.c \ + ossinit.h \ + README + SE_DIRS+= sunrpc SE_SUNRPC= Makefile diff --git a/share/examples/sound/README b/share/examples/sound/README new file mode 100644 index 000000000000..0188a26348c8 --- /dev/null +++ b/share/examples/sound/README @@ -0,0 +1,66 @@ +Briefly summarised, a general audio application will: +- open(2) +- ioctl(2) +- read(2) +- write(2) +- close(2) + +In this example, read/write will be called in a loop for a duration of +record/playback. Usually, /dev/dsp is the device you want to open, but it can +be any OSS compatible device, even user space one created with virtual_oss. For +configuring sample rate, bit depth and all other configuring of the device +ioctl is used. As devices can support multiple sample rates and formats, what +specific application should do in case there's an error issuing ioctl, as not +all errors are fatal, is upon the developer to decide. As a general guideline +Official OSS development howto should be used. FreeBSD OSS and virtual_oss are +different to a small degree. + +For more advanced OSS and real-time applications, developers need to handle +buffers more carefully. The size of the buffer in OSS is selected using fragment +size size_selector and the buffer size is 2^size_selector for values between 4 +and 16. The formula on the official site is: + +int frag = (max_fragments << 16) | (size_selector); +ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag); + +The max_fragments determines in how many fragments the buffer will be, hence if +the size_selector is 4, the requested size is 2^4 = 16 and for the +max_fragments of 2, the total buffer size will be + +(2 ^ size_selector) * max_fragments + +or in this case 32 bytes. Please note that size of buffer is in bytes not +samples. For example, 24bit sample will be represented with 3 bytes. If you're +porting audio app from Linux, you should be aware that 24 bit samples are +represented with 4 bytes (usually int). + +FreeBSD kernel will round up max_fragments and size of fragment/buffer, so the +last thing any OSS code should do is get info about buffer with audio_buf_info +and SNDCTL_DSP_GETOSPACE. That also means that not all values of max_fragments +are permitted. + +From kernel perspective, there are few points OSS developers should be aware of: +- There is a software facing buffer (bs) and a hardware driver buffer (b) +- The sizes can be seen with cat /dev/sndstat as [b:_/_/_] [bs:_/_/_] (needed: + sysctl hw.snd.verbose=2) +- OSS ioctl only concern software buffer fragments, not hardware + +For USB the block size is according to hw.usb.uaudio.buffer_ms sysctl, meaning +2ms at 48kHz gives 0.002 * 48000 = 96 samples per block, all multiples of this +work well. Block size for virtual_oss, if used, should be set accordingly. + +OSS driver insists on reading / writing a certain number of samples at a time, +one fragment full of samples. It is bound to do so in a fixed time frame, to +avoid under- and overruns in communication with the hardware. + +The idea of a total buffer size that holds max_fragments fragments is to give +some slack and allow application to be about max_fragments - 1 fragments late. +Let's call this the jitter tolerance. The jitter tolerance may be much less if +there is a slight mismatch between the period and the samples per fragment. + +Jitter tolerance gets better if we can make either the period or the samples +per fragment considerably smaller than the other. In our case that means we +divide the total buffer size into smaller fragments, keeping overall latency at +the same level. + +Official OSS development howto: http://manuals.opensound.com/developer/DSP.html diff --git a/share/examples/sound/basic.c b/share/examples/sound/basic.c new file mode 100644 index 000000000000..c903cbd8bf11 --- /dev/null +++ b/share/examples/sound/basic.c @@ -0,0 +1,99 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Goran Mekić + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ossinit.h" + +int +main() +{ + config_t config = { + .device = "/dev/dsp", + .channels = -1, + .format = format, + .frag = -1, + .sample_rate = 48000, + .sample_size = sizeof(sample_t), + .buffer_info.fragments = -1, + .mmap = 0, + }; + + /* Initialize device */ + oss_init(&config); + + /* + * Allocate input and output buffers so that their size match + * frag_size + */ + int ret; + int bytes = config.buffer_info.bytes; + int8_t *ibuf = malloc(bytes); + int8_t *obuf = malloc(bytes); + sample_t *channels = malloc(bytes); + + printf( + "bytes: %d, fragments: %d, fragsize: %d, fragstotal: %d, samples: %d\n", + bytes, + config.buffer_info.fragments, + config.buffer_info.fragsize, + config.buffer_info.fragstotal, + config.sample_count + ); + + /* Minimal engine: read input and copy it to the output */ + for (;;) { + ret = read(config.fd, ibuf, bytes); + if (ret < bytes) { + fprintf( + stderr, + "Requested %d bytes, but read %d!\n", + bytes, + ret + ); + break; + } + oss_split(&config, (sample_t *)ibuf, channels); + /* All processing will happen here */ + oss_merge(&config, channels, (sample_t *)obuf); + ret = write(config.fd, obuf, bytes); + if (ret < bytes) { + fprintf( + stderr, + "Requested %d bytes, but wrote %d!\n", + bytes, + ret + ); + break; + } + } + + /* Cleanup */ + free(channels); + free(obuf); + free(ibuf); + close(config.fd); + return (0); +} diff --git a/share/examples/sound/ossinit.h b/share/examples/sound/ossinit.h new file mode 100644 index 000000000000..b5fbd3e99244 --- /dev/null +++ b/share/examples/sound/ossinit.h @@ -0,0 +1,262 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Goran Mekić + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include + + +#ifndef SAMPLE_SIZE +#define SAMPLE_SIZE 16 +#endif + +/* Format can be unsigned, in which case replace S with U */ +#if SAMPLE_SIZE == 32 +typedef int32_t sample_t; +int format = AFMT_S32_NE; /* Signed 32bit native endian format */ +#elif SAMPLE_SIZE == 16 +typedef int16_t sample_t; +int format = AFMT_S16_NE; /* Signed 16bit native endian format */ +#elif SAMPLE_SIZE == 8 +typedef int8_t sample_t; +int format = AFMT_S8_NE; /* Signed 8bit native endian format */ +#else +#error Unsupported sample format! +typedef int32_t sample_t; +int format = AFMT_S32_NE; /* Not a real value, just silencing + * compiler errors */ +#endif + + + +/* + * Minimal configuration for OSS + * For real world applications, this structure will probably contain many + * more fields + */ +typedef struct config { + char *device; + int channels; + int fd; + int format; + int frag; + int sample_count; + int sample_rate; + int sample_size; + int chsamples; + int mmap; + oss_audioinfo audio_info; + audio_buf_info buffer_info; +} config_t; + + +/* + * Error state is indicated by value=-1 in which case application exits + * with error + */ +static inline void +check_error(const int value, const char *message) +{ + if (value == -1) { + fprintf(stderr, "OSS error: %s %s\n", message, strerror(errno)); + exit(1); + } +} + + + +/* Calculate frag by giving it minimal size of buffer */ +static inline int +size2frag(int x) +{ + int frag = 0; + + while ((1 << frag) < x) { + ++frag; + } + return frag; +} + + +/* + * Split input buffer into channels. Input buffer is in interleaved format + * which means if we have 2 channels (L and R), this is what the buffer of + * 8 samples would contain: L,R,L,R,L,R,L,R. The result are two channels + * containing: L,L,L,L and R,R,R,R. + */ +void +oss_split(config_t *config, sample_t *input, sample_t *output) +{ + int channel; + int index; + + for (int i = 0; i < config->sample_count; ++i) { + channel = i % config->channels; + index = i / config->channels; + output[channel * index] = input[i]; + } +} + + +/* + * Convert channels into interleaved format and place it in output + * buffer + */ +void +oss_merge(config_t *config, sample_t *input, sample_t *output) +{ + for (int channel = 0; channel < config->channels; ++channel) { + for (int index = 0; index < config->chsamples; ++index) { + output[index * config->channels + channel] = input[channel * index]; + } + } +} + +void +oss_init(config_t *config) +{ + int error; + int tmp; + + /* Open the device for read and write */ + config->fd = open(config->device, O_RDWR); + check_error(config->fd, "open"); + + /* Get device information */ + config->audio_info.dev = -1; + error = ioctl(config->fd, SNDCTL_ENGINEINFO, &(config->audio_info)); + check_error(error, "SNDCTL_ENGINEINFO"); + printf("min_channels: %d\n", config->audio_info.min_channels); + printf("max_channels: %d\n", config->audio_info.max_channels); + printf("latency: %d\n", config->audio_info.latency); + printf("handle: %s\n", config->audio_info.handle); + if (config->audio_info.min_rate > config->sample_rate || config->sample_rate > config->audio_info.max_rate) { + fprintf(stderr, "%s doesn't support chosen ", config->device); + fprintf(stderr, "samplerate of %dHz!\n", config->sample_rate); + exit(1); + } + if (config->channels < 1) { + config->channels = config->audio_info.max_channels; + } + + /* + * If device is going to be used in mmap mode, disable all format + * conversions. Official OSS documentation states error code should not be + * checked. http://manuals.opensound.com/developer/mmap_test.c.html#LOC10 + */ + if (config->mmap) { + tmp = 0; + ioctl(config->fd, SNDCTL_DSP_COOKEDMODE, &tmp); + } + + /* + * Set number of channels. If number of channels is chosen to the value + * near the one wanted, save it in config + */ + tmp = config->channels; + error = ioctl(config->fd, SNDCTL_DSP_CHANNELS, &tmp); + check_error(error, "SNDCTL_DSP_CHANNELS"); + if (tmp != config->channels) { /* or check if tmp is close enough? */ + fprintf(stderr, "%s doesn't support chosen ", config->device); + fprintf(stderr, "channel count of %d", config->channels); + fprintf(stderr, ", set to %d!\n", tmp); + } + config->channels = tmp; + + /* Set format, or bit size: 8, 16, 24 or 32 bit sample */ + tmp = config->format; + error = ioctl(config->fd, SNDCTL_DSP_SETFMT, &tmp); + check_error(error, "SNDCTL_DSP_SETFMT"); + if (tmp != config->format) { + fprintf(stderr, "%s doesn't support chosen sample format!\n", config->device); + exit(1); + } + + /* Most common values for samplerate (in kHz): 44.1, 48, 88.2, 96 */ + tmp = config->sample_rate; + error = ioctl(config->fd, SNDCTL_DSP_SPEED, &tmp); + check_error(error, "SNDCTL_DSP_SPEED"); + + /* Get and check device capabilities */ + error = ioctl(config->fd, SNDCTL_DSP_GETCAPS, &(config->audio_info.caps)); + check_error(error, "SNDCTL_DSP_GETCAPS"); + if (!(config->audio_info.caps & PCM_CAP_DUPLEX)) { + fprintf(stderr, "Device doesn't support full duplex!\n"); + exit(1); + } + if (config->mmap) { + if (!(config->audio_info.caps & PCM_CAP_TRIGGER)) { + fprintf(stderr, "Device doesn't support triggering!\n"); + exit(1); + } + if (!(config->audio_info.caps & PCM_CAP_MMAP)) { + fprintf(stderr, "Device doesn't support mmap mode!\n"); + exit(1); + } + } + + /* + * If desired frag is smaller than minimum, based on number of channels + * and format (size in bits: 8, 16, 24, 32), set that as frag. Buffer size + * is 2^frag, but the real size of the buffer will be read when the + * configuration of the device is successfull + */ + int min_frag = size2frag(config->sample_size * config->channels); + + if (config->frag < min_frag) { + config->frag = min_frag; + } + + /* + * Allocate buffer in fragments. Total buffer will be split in number + * of fragments (2 by default) + */ + if (config->buffer_info.fragments < 0) { + config->buffer_info.fragments = 2; + } + tmp = ((config->buffer_info.fragments) << 16) | config->frag; + error = ioctl(config->fd, SNDCTL_DSP_SETFRAGMENT, &tmp); + check_error(error, "SNDCTL_DSP_SETFRAGMENT"); + + /* When all is set and ready to go, get the size of buffer */ + error = ioctl(config->fd, SNDCTL_DSP_GETOSPACE, &(config->buffer_info)); + check_error(error, "SNDCTL_DSP_GETOSPACE"); + if (config->buffer_info.bytes < 1) { + fprintf( + stderr, + "OSS buffer error: buffer size can not be %d\n", + config->buffer_info.bytes + ); + exit(1); + } + config->sample_count = config->buffer_info.bytes / config->sample_size; + config->chsamples = config->sample_count / config->channels; +} From owner-dev-commits-src-all@freebsd.org Fri Aug 27 12:46:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3DA4A65F3E4; Fri, 27 Aug 2021 12:46: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 4Gwzx96ZgVz3hff; Fri, 27 Aug 2021 12:46: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 C01F523A82; Fri, 27 Aug 2021 12:46: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 17RCkbvC060047; Fri, 27 Aug 2021 12:46:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCkbvG060046; Fri, 27 Aug 2021 12:46:37 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:46:37 GMT Message-Id: <202108271246.17RCkbvG060046@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 9d2067ec4027 - stable/12 - tmpfs: Fix error being cleared after commit c12118f6cec0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9d2067ec4027e23e2eed5131f4aaa9ff34b40534 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:46:38 -0000 The branch stable/12 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=9d2067ec4027e23e2eed5131f4aaa9ff34b40534 commit 9d2067ec4027e23e2eed5131f4aaa9ff34b40534 Author: Ka Ho Ng AuthorDate: 2021-08-24 16:35:29 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 12:05:32 +0000 tmpfs: Fix error being cleared after commit c12118f6cec0 In tmpfs_link() error was erroneously cleared in commit c12118f6cec0. Sponsored by: The FreeBSD Foundation MFC with: c12118f6cec0 (cherry picked from commit a48416f844e3007b4e9f6df125e25cf3a1daad62) --- sys/fs/tmpfs/tmpfs_vnops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 8b9afd1f887a..615414acd335 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -653,7 +653,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return (0); + return (error); } /* From owner-dev-commits-src-all@freebsd.org Fri Aug 27 12:46:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E8BF865F779; Fri, 27 Aug 2021 12:46: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 4Gwzx85PtDz3hR6; Fri, 27 Aug 2021 12:46: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 9BCA023A46; Fri, 27 Aug 2021 12:46: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 17RCkaUX060021; Fri, 27 Aug 2021 12:46:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCkamW060020; Fri, 27 Aug 2021 12:46:36 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:46:36 GMT Message-Id: <202108271246.17RCkamW060020@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 2b567cd65f0d - stable/12 - tmpfs: Fix styles MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2b567cd65f0d8babef86f2cb89c81e3b1bc314aa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:46:37 -0000 The branch stable/12 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=2b567cd65f0d8babef86f2cb89c81e3b1bc314aa commit 2b567cd65f0d8babef86f2cb89c81e3b1bc314aa Author: Ka Ho Ng AuthorDate: 2021-08-24 13:09:21 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 12:05:30 +0000 tmpfs: Fix styles A lot of return statements were in the wrong style before this commit. Sponsored by: The FreeBSD Foundation (cherry picked from commit c12118f6cec0ca5f720be6c06d6c59d551461e5a) --- sys/fs/tmpfs/tmpfs_subr.c | 6 +++--- sys/fs/tmpfs/tmpfs_vfsops.c | 4 ++-- sys/fs/tmpfs/tmpfs_vnops.c | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index bea1189d2e82..ec9d7bc78a92 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -515,7 +515,7 @@ tmpfs_alloc_dirent(struct tmpfs_mount *tmp, struct tmpfs_node *node, *de = nde; - return 0; + return (0); } /* @@ -1648,11 +1648,11 @@ tmpfs_chmod(struct vnode *vp, mode_t mode, struct ucred *cred, struct thread *p) /* Disallow this operation if the file system is mounted read-only. */ if (vp->v_mount->mnt_flag & MNT_RDONLY) - return EROFS; + return (EROFS); /* Immutable or append-only files cannot be modified, either. */ if (node->tn_flags & (IMMUTABLE | APPEND)) - return EPERM; + return (EPERM); /* * To modify the permissions on a file, must possess VADMIN diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 219ec9ee69f2..6f7091d8b52f 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -463,7 +463,7 @@ tmpfs_mount(struct mount *mp) vfs_getnewfsid(mp); vfs_mountedfrom(mp, "tmpfs"); - return 0; + return (0); } /* ARGSUSED2 */ @@ -628,7 +628,7 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp) sbp->f_ffree = sbp->f_files - used; /* sbp->f_owner = tmp->tn_uid; */ - return 0; + return (0); } static int diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 7df835113397..8b9afd1f887a 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -272,9 +272,9 @@ tmpfs_mknod(struct vop_mknod_args *v) if (vap->va_type != VBLK && vap->va_type != VCHR && vap->va_type != VFIFO) - return EINVAL; + return (EINVAL); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } static int @@ -412,7 +412,7 @@ tmpfs_getattr(struct vop_getattr_args *v) vap->va_bytes = node->tn_size; vap->va_filerev = 0; - return 0; + return (0); } int @@ -469,7 +469,7 @@ tmpfs_setattr(struct vop_setattr_args *v) MPASS(VOP_ISLOCKED(vp)); - return error; + return (error); } static int @@ -551,7 +551,7 @@ tmpfs_fsync(struct vop_fsync_args *v) tmpfs_check_mtime(vp); tmpfs_update(vp); - return 0; + return (0); } static int @@ -653,7 +653,7 @@ tmpfs_link(struct vop_link_args *v) error = 0; out: - return error; + return (0); } /* @@ -1094,7 +1094,7 @@ tmpfs_mkdir(struct vop_mkdir_args *v) MPASS(vap->va_type == VDIR); - return tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); } static int @@ -1187,7 +1187,7 @@ tmpfs_rmdir(struct vop_rmdir_args *v) error = 0; out: - return error; + return (error); } static int @@ -1205,7 +1205,7 @@ tmpfs_symlink(struct vop_symlink_args *v) vap->va_type = VLNK; #endif - return tmpfs_alloc_file(dvp, vpp, vap, cnp, target); + return (tmpfs_alloc_file(dvp, vpp, vap, cnp, target)); } static int @@ -1228,7 +1228,7 @@ tmpfs_readdir(struct vop_readdir_args *va) /* This operation only makes sense on directory nodes. */ if (vp->v_type != VDIR) - return ENOTDIR; + return (ENOTDIR); maxcookies = 0; node = VP_TO_TMPFS_DIR(vp); @@ -1265,7 +1265,7 @@ tmpfs_readdir(struct vop_readdir_args *va) *eofflag = (error == 0 && uio->uio_offset == TMPFS_DIRCOOKIE_EOF); - return error; + return (error); } static int @@ -1380,7 +1380,7 @@ tmpfs_print(struct vop_print_args *v) printf("\n"); - return 0; + return (0); } int @@ -1430,7 +1430,7 @@ tmpfs_pathconf(struct vop_pathconf_args *v) error = vop_stdpathconf(v); } - return error; + return (error); } static int From owner-dev-commits-src-all@freebsd.org Fri Aug 27 12:46:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AEDA65F826; Fri, 27 Aug 2021 12:46: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 4GwzxC0pMGz3hYf; Fri, 27 Aug 2021 12:46:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E66EE239BD; Fri, 27 Aug 2021 12:46: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 17RCkcUL060075; Fri, 27 Aug 2021 12:46:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCkcK9060074; Fri, 27 Aug 2021 12:46:38 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:46:38 GMT Message-Id: <202108271246.17RCkcK9060074@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 74ef8d180fb0 - stable/12 - vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 74ef8d180fb0f063fffc63b7100073c1a43f8bf6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:46:39 -0000 The branch stable/12 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=74ef8d180fb0f063fffc63b7100073c1a43f8bf6 commit 74ef8d180fb0f063fffc63b7100073c1a43f8bf6 Author: Ka Ho Ng AuthorDate: 2021-08-02 09:54:40 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 12:05:34 +0000 vmm: Bump vmname buffer in struct vm to VM_MAX_NAMELEN + 1 In hw.vmm.create sysctl handler the maximum length of vm name is VM_MAX_NAMELEN. However in vm_create() the maximum length allowed is only VM_MAX_NAMELEN - 1 chars. Bump the length of the internal buffer to allow the length of VM_MAX_NAMELEN for vm name. Reviewed by: grehan Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31372 (cherry picked from commit df95cc76affbbf114c9ff2e4ee011b6f162aa8bd) --- sys/amd64/vmm/vmm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 9774cc60d187..f22b213e9c96 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -164,7 +164,7 @@ struct vm { struct mem_map mem_maps[VM_MAX_MEMMAPS]; /* (i) guest address space */ struct mem_seg mem_segs[VM_MAX_MEMSEGS]; /* (o) guest memory regions */ struct vmspace *vmspace; /* (o) guest's address space */ - char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */ + char name[VM_MAX_NAMELEN+1]; /* (o) virtual machine name */ struct vcpu vcpu[VM_MAXCPU]; /* (i) guest vcpus */ /* The following describe the vm cpu topology */ uint16_t sockets; /* (o) num of sockets */ @@ -451,7 +451,8 @@ vm_create(const char *name, struct vm **retvm) if (!vmm_initialized) return (ENXIO); - if (name == NULL || strlen(name) >= VM_MAX_NAMELEN) + if (name == NULL || strnlen(name, VM_MAX_NAMELEN + 1) == + VM_MAX_NAMELEN + 1) return (EINVAL); vmspace = VMSPACE_ALLOC(0, VM_MAXUSER_ADDRESS); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 12:48:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F50465FBC0; Fri, 27 Aug 2021 12:48: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 4Gwzzb1l9Lz3jLQ; Fri, 27 Aug 2021 12:48: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 23E052383F; Fri, 27 Aug 2021 12:48: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 17RCmh99060342; Fri, 27 Aug 2021 12:48:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCmhoK060341; Fri, 27 Aug 2021 12:48:43 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:48:43 GMT Message-Id: <202108271248.17RCmhoK060341@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d174534a273d - main - tcp: Remove unused v6 state definitions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d174534a273d1b5a603656dbaf6b03a34a09273e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:48:43 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d174534a273d1b5a603656dbaf6b03a34a09273e commit d174534a273d1b5a603656dbaf6b03a34a09273e Author: Mark Johnston AuthorDate: 2021-08-27 12:31:32 +0000 Commit: Mark Johnston CommitDate: 2021-08-27 12:31:32 +0000 tcp: Remove unused v6 state definitions These are supposedly for compatibility with KAME, but they are completely unused in our tree and don't exist in OpenBSD or NetBSD. Reviewed by: kbowling, bz, gnn Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31700 --- sys/netinet/tcp_fsm.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/sys/netinet/tcp_fsm.h b/sys/netinet/tcp_fsm.h index 8bd129f613cf..ecef72fef26e 100644 --- a/sys/netinet/tcp_fsm.h +++ b/sys/netinet/tcp_fsm.h @@ -59,20 +59,6 @@ #define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ #define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ -/* for KAME src sync over BSD*'s */ -#define TCP6_NSTATES TCP_NSTATES -#define TCP6S_CLOSED TCPS_CLOSED -#define TCP6S_LISTEN TCPS_LISTEN -#define TCP6S_SYN_SENT TCPS_SYN_SENT -#define TCP6S_SYN_RECEIVED TCPS_SYN_RECEIVED -#define TCP6S_ESTABLISHED TCPS_ESTABLISHED -#define TCP6S_CLOSE_WAIT TCPS_CLOSE_WAIT -#define TCP6S_FIN_WAIT_1 TCPS_FIN_WAIT_1 -#define TCP6S_CLOSING TCPS_CLOSING -#define TCP6S_LAST_ACK TCPS_LAST_ACK -#define TCP6S_FIN_WAIT_2 TCPS_FIN_WAIT_2 -#define TCP6S_TIME_WAIT TCPS_TIME_WAIT - #define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED) #define TCPS_HAVEESTABLISHED(s) ((s) >= TCPS_ESTABLISHED) #define TCPS_HAVERCVDFIN(s) \ From owner-dev-commits-src-all@freebsd.org Fri Aug 27 12:48:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 90B9765F874; Fri, 27 Aug 2021 12:48: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 4Gwzzc2hyhz3jGh; Fri, 27 Aug 2021 12:48:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3FA272395E; Fri, 27 Aug 2021 12:48: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 17RCmin2060366; Fri, 27 Aug 2021 12:48:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RCmiP7060365; Fri, 27 Aug 2021 12:48:44 GMT (envelope-from git) Date: Fri, 27 Aug 2021 12:48:44 GMT Message-Id: <202108271248.17RCmiP7060365@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 091869def9ee - main - connect: Use soconnectat() unconditionally in kern_connect() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 091869def9eeb9796c3627ea95bf6cc46cf952a0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 12:48:45 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=091869def9eeb9796c3627ea95bf6cc46cf952a0 commit 091869def9eeb9796c3627ea95bf6cc46cf952a0 Author: Mark Johnston AuthorDate: 2021-08-27 12:32:07 +0000 Commit: Mark Johnston CommitDate: 2021-08-27 12:32:07 +0000 connect: Use soconnectat() unconditionally in kern_connect() soconnect(...) is equivalent to soconnectat(AT_FDCWD, ...), so rely on this to save a branch. No functional change intended. MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/kern/uipc_syscalls.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 18505b54d603..3208dc0491dd 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -511,10 +511,7 @@ kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa) if (error != 0) goto bad; #endif - if (dirfd == AT_FDCWD) - error = soconnect(so, sa, td); - else - error = soconnectat(dirfd, so, sa, td); + error = soconnectat(dirfd, so, sa, td); if (error != 0) goto bad; if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) { From owner-dev-commits-src-all@freebsd.org Fri Aug 27 13:08:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2ECC666039E; Fri, 27 Aug 2021 13:08:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx0QC0sxHz3qW4; Fri, 27 Aug 2021 13:08:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 061B323BD1; Fri, 27 Aug 2021 13:08:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17RD8IQT087648; Fri, 27 Aug 2021 13:08:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RD8IPl087647; Fri, 27 Aug 2021 13:08:18 GMT (envelope-from git) Date: Fri, 27 Aug 2021 13:08:18 GMT Message-Id: <202108271308.17RD8IPl087647@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ka Ho Ng Subject: git: 6e2fc728d8da - stable/13 - AMD-vi: Fortify IVHD device_identify process MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6e2fc728d8da06d4f849061cce6540fdc2ea6000 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 13:08:19 -0000 The branch stable/13 has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=6e2fc728d8da06d4f849061cce6540fdc2ea6000 commit 6e2fc728d8da06d4f849061cce6540fdc2ea6000 Author: Ka Ho Ng AuthorDate: 2021-04-19 08:07:03 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 13:05:58 +0000 AMD-vi: Fortify IVHD device_identify process - Use malloc(9) to allocate ivhd_hdrs list. The previous assumption that there are at most 10 IVHDs in a system is not true. A counter example would be a system with 4 IOMMUs, and each IOMMU is related to IVHDs type 10h, 11h and 40h in the ACPI IVRS table. - Always scan through the whole ivhd_hdrs list to find IVHDs that has the same DeviceId but less prioritized IVHD type. Sponsored by: The FreeBSD Foundation MFC with: 74ada297e897 Reviewed by: grehan Approved by: lwhsu (mentor) Differential Revision: https://reviews.freebsd.org/D29525 (cherry picked from commit 6fe60f1d5c39c94fc87534e9dd4e9630594e0bec) --- sys/amd64/vmm/amd/ivrs_drv.c | 47 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/sys/amd64/vmm/amd/ivrs_drv.c b/sys/amd64/vmm/amd/ivrs_drv.c index 430d18a059a2..68c31788e29d 100644 --- a/sys/amd64/vmm/amd/ivrs_drv.c +++ b/sys/amd64/vmm/amd/ivrs_drv.c @@ -57,7 +57,7 @@ int ivhd_count; /* Number of IVHD header. */ * Cached IVHD header list. * Single entry for each IVHD, filtered the legacy one. */ -ACPI_IVRS_HARDWARE1 *ivhd_hdrs[10]; +ACPI_IVRS_HARDWARE1 **ivhd_hdrs; extern int amdvi_ptp_level; /* Page table levels. */ @@ -134,9 +134,11 @@ ivrs_is_ivhd(UINT8 type) static int ivhd_count_iter(ACPI_IVRS_HEADER * ivrs_he, void *arg) { + int *count; + count = (int *)arg; if (ivrs_is_ivhd(ivrs_he->Type)) - ivhd_count++; + (*count)++; return (1); } @@ -349,7 +351,7 @@ ivhd_identify(driver_t *driver, device_t parent) ACPI_TABLE_IVRS *ivrs; ACPI_IVRS_HARDWARE1 *ivhd; ACPI_STATUS status; - int i, count = 0; + int i, j, count = 0; uint32_t ivrs_ivinfo; if (acpi_disabled("ivhd")) @@ -370,32 +372,35 @@ ivhd_identify(driver_t *driver, device_t parent) REG_BITS(ivrs_ivinfo, 7, 5), REG_BITS(ivrs_ivinfo, 22, 22), "\020\001EFRSup"); - ivrs_hdr_iterate_tbl(ivhd_count_iter, NULL); - if (!ivhd_count) + ivrs_hdr_iterate_tbl(ivhd_count_iter, &count); + if (!count) return; - for (i = 0; i < ivhd_count; i++) { + ivhd_hdrs = malloc(sizeof(void *) * count, M_DEVBUF, + M_WAITOK | M_ZERO); + for (i = 0; i < count; i++) { ivhd = ivhd_find_by_index(i); KASSERT(ivhd, ("ivhd%d is NULL\n", i)); - ivhd_hdrs[i] = ivhd; - } - /* - * Scan for presence of legacy and non-legacy device type - * for same AMD-Vi device and override the old one. - */ - for (i = ivhd_count - 1 ; i > 0 ; i--){ - if (ivhd_is_newer(&ivhd_hdrs[i-1]->Header, - &ivhd_hdrs[i]->Header)) { - memmove(&ivhd_hdrs[i-1], &ivhd_hdrs[i], - sizeof(void *) * (ivhd_count - i)); - ivhd_count--; + /* + * Scan for presence of legacy and non-legacy device type + * for same IOMMU device and override the old one. + * + * If there is no existing IVHD to the same IOMMU device, + * the IVHD header pointer is appended. + */ + for (j = 0; j < ivhd_count; j++) { + if (ivhd_is_newer(&ivhd_hdrs[j]->Header, &ivhd->Header)) + break; } + ivhd_hdrs[j] = ivhd; + if (j == ivhd_count) + ivhd_count++; } ivhd_devs = malloc(sizeof(device_t) * ivhd_count, M_DEVBUF, M_WAITOK | M_ZERO); - for (i = 0; i < ivhd_count; i++) { + for (i = 0, j = 0; i < ivhd_count; i++) { ivhd = ivhd_hdrs[i]; KASSERT(ivhd, ("ivhd%d is NULL\n", i)); @@ -417,13 +422,13 @@ ivhd_identify(driver_t *driver, device_t parent) break; } } - count++; + j++; } /* * Update device count in case failed to attach. */ - ivhd_count = count; + ivhd_count = j; } static int From owner-dev-commits-src-all@freebsd.org Fri Aug 27 13:44:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D5E80660B53; Fri, 27 Aug 2021 13:44: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 4Gx1D32P4Kz4Ynx; Fri, 27 Aug 2021 13:44: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 3666524744; Fri, 27 Aug 2021 13:44: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 17RDiZKx039792; Fri, 27 Aug 2021 13:44:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RDiZdB039791; Fri, 27 Aug 2021 13:44:35 GMT (envelope-from git) Date: Fri, 27 Aug 2021 13:44:35 GMT Message-Id: <202108271344.17RDiZdB039791@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: 6e1df1d14c6d - main - pmap_extract.9: Fix pmap_extract_and_hold()'s function type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6e1df1d14c6dfcc209c1416ec0832e4d08191c72 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 13:44:36 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=6e1df1d14c6dfcc209c1416ec0832e4d08191c72 commit 6e1df1d14c6dfcc209c1416ec0832e4d08191c72 Author: Ka Ho Ng AuthorDate: 2021-08-27 13:42:49 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-27 13:44:16 +0000 pmap_extract.9: Fix pmap_extract_and_hold()'s function type pmap_extract_and_hold() returns a vm_page_t instead of a physical page address. Sponsored by: The FreeBSD Foundation Reviewed by: alc MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D31691 --- share/man/man9/pmap_extract.9 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/man/man9/pmap_extract.9 b/share/man/man9/pmap_extract.9 index d2154ebe8a0b..77f3b47ec51e 100644 --- a/share/man/man9/pmap_extract.9 +++ b/share/man/man9/pmap_extract.9 @@ -38,7 +38,7 @@ .In vm/pmap.h .Ft vm_paddr_t .Fn pmap_extract "pmap_t pmap" "vm_offset_t va" -.Ft vm_paddr_t +.Ft vm_page_t .Fn pmap_extract_and_hold "pmap_t pmap" "vm_offset_t va" "vm_prot_t prot" .Sh DESCRIPTION The @@ -73,7 +73,9 @@ will be returned. .Pp The .Fn pmap_extract_and_hold -function will return the physical page address associated with the +function will return the +.Ft vm_page_t +associated with the virtual address .Fa va inside the physical map From owner-dev-commits-src-all@freebsd.org Fri Aug 27 15:39:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F10356620FE; Fri, 27 Aug 2021 15:39: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 4Gx3n56JTvz3vLX; Fri, 27 Aug 2021 15:39: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 ABD9225579; Fri, 27 Aug 2021 15:39: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 17RFdrDR089110; Fri, 27 Aug 2021 15:39:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdrJG089109; Fri, 27 Aug 2021 15:39:53 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:53 GMT Message-Id: <202108271539.17RFdrJG089109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 92d4e088274c - main - msdosfs: unstaticise msdosfs_lookup_ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 92d4e088274c7ada268645588503f22f390c5fb8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:54 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=92d4e088274c7ada268645588503f22f390c5fb8 commit 92d4e088274c7ada268645588503f22f390c5fb8 Author: Konstantin Belousov AuthorDate: 2021-08-01 17:11:40 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: unstaticise msdosfs_lookup_ and rename it to msdosfs_lookup_ino(), similarly to UFS Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 2 ++ sys/fs/msdosfs/msdosfs_lookup.c | 11 ++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index 7c838b5cc81c..f133f3f90cd6 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -267,6 +267,8 @@ extern struct vop_vector msdosfs_vnodeops; int msdosfs_lookup(struct vop_cachedlookup_args *); int msdosfs_inactive(struct vop_inactive_args *); int msdosfs_reclaim(struct vop_reclaim_args *); +int msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, + struct componentname *cnp, uint64_t *inum); #endif /* diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index a32b0372243c..bdfff7bf3206 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -63,14 +63,11 @@ #include #include -static int msdosfs_lookup_(struct vnode *vdp, struct vnode **vpp, - struct componentname *cnp, uint64_t *inum); - int msdosfs_lookup(struct vop_cachedlookup_args *ap) { - return (msdosfs_lookup_(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); + return (msdosfs_lookup_ino(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); } struct deget_dotdot { @@ -110,8 +107,8 @@ msdosfs_deget_dotdot(struct mount *mp, void *arg, int lkflags, * out to disk. This way disk blocks containing directory entries and in * memory denode's will be in synch. */ -static int -msdosfs_lookup_(struct vnode *vdp, struct vnode **vpp, +int +msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, struct componentname *cnp, uint64_t *dd_inum) { struct mbnambuf nb; @@ -558,7 +555,7 @@ foundroot: * Recheck that ".." still points to the inode we * looked up before pdp lock was dropped. */ - error = msdosfs_lookup_(pdp, NULL, cnp, &inode1); + error = msdosfs_lookup_ino(pdp, NULL, cnp, &inode1); if (error) { vput(*vpp); *vpp = NULL; From owner-dev-commits-src-all@freebsd.org Fri Aug 27 15:39:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 65C68662532; Fri, 27 Aug 2021 15:39: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 4Gx3n706kqz3vJ3; Fri, 27 Aug 2021 15:39: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 CC9B925D9B; Fri, 27 Aug 2021 15:39: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 17RFdsRm089134; Fri, 27 Aug 2021 15:39:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdslW089133; Fri, 27 Aug 2021 15:39:54 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:54 GMT Message-Id: <202108271539.17RFdslW089133@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ae7e8a02e6e9 - main - msdosfs deget(): add locking flags argument MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae7e8a02e6e93455e026036132c4d053b2c12ad9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:56 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ae7e8a02e6e93455e026036132c4d053b2c12ad9 commit ae7e8a02e6e93455e026036132c4d053b2c12ad9 Author: Konstantin Belousov AuthorDate: 2021-08-01 17:53:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs deget(): add locking flags argument LK_EXCLUSIVE must be passed always, some consumers need the ability to specify LK_NOWAIT Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 2 +- sys/fs/msdosfs/msdosfs_denode.c | 13 ++++++++----- sys/fs/msdosfs/msdosfs_lookup.c | 15 +++++++++------ sys/fs/msdosfs/msdosfs_vfsops.c | 5 +++-- usr.sbin/makefs/msdos/msdosfs_denode.c | 2 +- usr.sbin/makefs/msdos/msdosfs_lookup.c | 2 +- usr.sbin/makefs/msdos/msdosfs_vfsops.c | 2 +- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index f133f3f90cd6..80ebf250febf 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -275,7 +275,7 @@ int msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, * Internal service routine prototypes. */ struct componentname; -int deget(struct msdosfsmount *, u_long, u_long, struct denode **); +int deget(struct msdosfsmount *, u_long, u_long, int, struct denode **); int uniqdosname(struct denode *, struct componentname *, u_char *); int readep(struct msdosfsmount *pmp, u_long dirclu, u_long dirofs, struct buf **bpp, struct direntry **epp); diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 369533067ce9..d97e61f7932c 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -92,11 +92,12 @@ de_vncmpf(struct vnode *vp, void *arg) * diroffset is relative to the beginning of the root directory, * otherwise it is cluster relative. * diroffset - offset past begin of cluster of denode we want + * lkflags - locking flags (LK_NOWAIT) * depp - returns the address of the gotten denode. */ int deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, - struct denode **depp) + int lkflags, struct denode **depp) { int error; uint64_t inode; @@ -107,9 +108,11 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, struct buf *bp; #ifdef MSDOSFS_DEBUG - printf("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n", - pmp, dirclust, diroffset, depp); + printf("deget(pmp %p, dirclust %lu, diroffset %lx, flags %#x, " + "depp %p)\n", + pmp, dirclust, diroffset, flags, depp); #endif + MPASS((lkflags & LK_TYPE_MASK) == LK_EXCLUSIVE); /* * On FAT32 filesystems, root is a (more or less) normal @@ -133,7 +136,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, */ inode = (uint64_t)pmp->pm_bpcluster * dirclust + diroffset; - error = vfs_hash_get(mntp, inode, LK_EXCLUSIVE, curthread, &nvp, + error = vfs_hash_get(mntp, inode, lkflags, curthread, &nvp, de_vncmpf, &inode); if (error) return (error); @@ -171,7 +174,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, *depp = NULL; return (error); } - error = vfs_hash_insert(nvp, inode, LK_EXCLUSIVE, curthread, &xvp, + error = vfs_hash_insert(nvp, inode, lkflags, curthread, &xvp, de_vncmpf, &inode); if (error) { *depp = NULL; diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index bdfff7bf3206..d47f2969904b 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -86,7 +86,8 @@ msdosfs_deget_dotdot(struct mount *mp, void *arg, int lkflags, pmp = VFSTOMSDOSFS(mp); dd_arg = arg; - error = deget(pmp, dd_arg->cluster, dd_arg->blkoff, &rdp); + error = deget(pmp, dd_arg->cluster, dd_arg->blkoff, + LK_EXCLUSIVE, &rdp); if (error == 0) *rvp = DETOV(rdp); return (error); @@ -495,7 +496,7 @@ foundroot: *vpp = vdp; return (0); } - error = deget(pmp, cluster, blkoff, &tdp); + error = deget(pmp, cluster, blkoff, LK_EXCLUSIVE, &tdp); if (error) return (error); *vpp = DETOV(tdp); @@ -523,7 +524,8 @@ foundroot: if (dp->de_StartCluster == scn && isadir) return (EISDIR); - if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) + if ((error = deget(pmp, cluster, blkoff, LK_EXCLUSIVE, + &tdp)) != 0) return (error); *vpp = DETOV(tdp); cnp->cn_flags |= SAVENAME; @@ -569,7 +571,8 @@ foundroot: VREF(vdp); /* we want ourself, ie "." */ *vpp = vdp; } else { - if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) + if ((error = deget(pmp, cluster, blkoff, LK_EXCLUSIVE, + &tdp)) != 0) return (error); *vpp = DETOV(tdp); } @@ -708,7 +711,7 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp, else diroffset = 0; } - return deget(pmp, dirclust, diroffset, depp); + return (deget(pmp, dirclust, diroffset, LK_EXCLUSIVE, depp)); } return 0; @@ -862,7 +865,7 @@ doscheckpath(struct denode *source, struct denode *target) brelse(bp); bp = NULL; /* NOTE: deget() clears dep on error */ - if ((error = deget(pmp, scn, 0, &dep)) != 0) + if ((error = deget(pmp, scn, 0, LK_EXCLUSIVE, &dep)) != 0) break; } out:; diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 187463cc7f4d..68c8a93a18af 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -847,7 +847,7 @@ msdosfs_root(struct mount *mp, int flags, struct vnode **vpp) #ifdef MSDOSFS_DEBUG printf("msdosfs_root(); mp %p, pmp %p\n", mp, pmp); #endif - error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep); + error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, LK_EXCLUSIVE, &ndep); if (error) return (error); *vpp = DETOV(ndep); @@ -988,7 +988,8 @@ msdosfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) struct denode *dep; int error; - error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, &dep); + error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, + LK_EXCLUSIVE, &dep); if (error) { *vpp = NULLVP; return (error); diff --git a/usr.sbin/makefs/msdos/msdosfs_denode.c b/usr.sbin/makefs/msdos/msdosfs_denode.c index 48c305824793..3fbd867275d2 100644 --- a/usr.sbin/makefs/msdos/msdosfs_denode.c +++ b/usr.sbin/makefs/msdos/msdosfs_denode.c @@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$"); */ int deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, - struct denode **depp) + int lkflags __unused, struct denode **depp) { int error; uint64_t inode; diff --git a/usr.sbin/makefs/msdos/msdosfs_lookup.c b/usr.sbin/makefs/msdos/msdosfs_lookup.c index a4db6ae1a4a2..fb2f4deceaf2 100644 --- a/usr.sbin/makefs/msdos/msdosfs_lookup.c +++ b/usr.sbin/makefs/msdos/msdosfs_lookup.c @@ -187,7 +187,7 @@ createde(struct denode *dep, struct denode *ddep, struct denode **depp, else diroffset = 0; } - return deget(pmp, dirclust, diroffset, depp); + return deget(pmp, dirclust, diroffset, 0, depp); } return 0; diff --git a/usr.sbin/makefs/msdos/msdosfs_vfsops.c b/usr.sbin/makefs/msdos/msdosfs_vfsops.c index dd933bb2be61..508e044ac1ca 100644 --- a/usr.sbin/makefs/msdos/msdosfs_vfsops.c +++ b/usr.sbin/makefs/msdos/msdosfs_vfsops.c @@ -349,7 +349,7 @@ msdosfs_root(struct msdosfsmount *pmp, struct m_vnode *vp) { int error; *vp = *(struct m_vnode *)pmp->pm_devvp; - if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep)) != 0) { + if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, 0, &ndep)) != 0) { errno = error; return -1; } From owner-dev-commits-src-all@freebsd.org Fri Aug 27 15:39:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9243B66232C; Fri, 27 Aug 2021 15:39: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 4Gx3n91WX9z3vNp; Fri, 27 Aug 2021 15:39: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 E7ED925C6F; Fri, 27 Aug 2021 15:39: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 17RFdtEH089164; Fri, 27 Aug 2021 15:39:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdt88089163; Fri, 27 Aug 2021 15:39:55 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:55 GMT Message-Id: <202108271539.17RFdt88089163@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 95d42526e92c - main - msdosfs: fix rename MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 95d42526e92cb2a9842d71d3c585aabf32da7534 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:57 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=95d42526e92cb2a9842d71d3c585aabf32da7534 commit 95d42526e92cb2a9842d71d3c585aabf32da7534 Author: Konstantin Belousov AuthorDate: 2021-08-01 17:46:59 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: fix rename Use the same locking algorithm for msdosfs_rename() as used by ufs_rename(). Convert doscheckpath() to non-sleeping version. Reported by: trasz PR: 257522 In collaboration with: pho Reviewed by: mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 5 +- sys/fs/msdosfs/msdosfs_denode.c | 1 + sys/fs/msdosfs/msdosfs_lookup.c | 79 ++++---- sys/fs/msdosfs/msdosfs_vnops.c | 430 +++++++++++++++++++++------------------- 4 files changed, 274 insertions(+), 241 deletions(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index 80ebf250febf..67ffa522000a 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -268,7 +268,7 @@ int msdosfs_lookup(struct vop_cachedlookup_args *); int msdosfs_inactive(struct vop_inactive_args *); int msdosfs_reclaim(struct vop_reclaim_args *); int msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, - struct componentname *cnp, uint64_t *inum); + struct componentname *cnp, daddr_t *scnp, u_long *blkoffp); #endif /* @@ -288,6 +288,7 @@ int createde(struct denode *dep, struct denode *ddep, struct denode **depp, stru int deupdat(struct denode *dep, int waitfor); int removede(struct denode *pdep, struct denode *dep); int detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred); -int doscheckpath( struct denode *source, struct denode *target); +int doscheckpath( struct denode *source, struct denode *target, + daddr_t *wait_scn); #endif /* _KERNEL || MAKEFS */ #endif /* !_FS_MSDOSFS_DENODE_H_ */ diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index d97e61f7932c..64f75c267959 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -167,6 +167,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, ldep->de_inode = inode; cluster_init_vn(&ldep->de_clusterw); lockmgr(nvp->v_vnlock, LK_EXCLUSIVE, NULL); + VN_LOCK_AREC(nvp); /* for doscheckpath */ fc_purge(ldep, 0); /* init the FAT cache for this denode */ error = insmntque(nvp, mntp); if (error != 0) { diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index d47f2969904b..2c3d02db37a0 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -67,7 +67,8 @@ int msdosfs_lookup(struct vop_cachedlookup_args *ap) { - return (msdosfs_lookup_ino(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL)); + return (msdosfs_lookup_ino(ap->a_dvp, ap->a_vpp, ap->a_cnp, NULL, + NULL)); } struct deget_dotdot { @@ -109,8 +110,8 @@ msdosfs_deget_dotdot(struct mount *mp, void *arg, int lkflags, * memory denode's will be in synch. */ int -msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, - struct componentname *cnp, uint64_t *dd_inum) +msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, struct componentname + *cnp, daddr_t *scnp, u_long *blkoffp) { struct mbnambuf nb; daddr_t bn; @@ -119,11 +120,11 @@ msdosfs_lookup_ino(struct vnode *vdp, struct vnode **vpp, int slotoffset = 0; int frcn; u_long cluster; - int blkoff; + u_long blkoff; int diroff; int blsize; int isadir; /* ~0 if found direntry is a directory */ - u_long scn; /* starting cluster number */ + daddr_t scn; /* starting cluster number */ struct vnode *pdp; struct denode *dp; struct denode *tdp; @@ -464,8 +465,9 @@ foundroot: if (FAT32(pmp) && scn == MSDOSFSROOT) scn = pmp->pm_rootdirblk; - if (dd_inum != NULL) { - *dd_inum = (uint64_t)pmp->pm_bpcluster * scn + blkoff; + if (scnp != NULL) { + *scnp = cluster; + *blkoffp = blkoff; return (0); } @@ -557,12 +559,15 @@ foundroot: * Recheck that ".." still points to the inode we * looked up before pdp lock was dropped. */ - error = msdosfs_lookup_ino(pdp, NULL, cnp, &inode1); + error = msdosfs_lookup_ino(pdp, NULL, cnp, &scn, &blkoff); if (error) { vput(*vpp); *vpp = NULL; return (error); } + if (FAT32(pmp) && scn == MSDOSFSROOT) + scn = pmp->pm_rootdirblk; + inode1 = scn * pmp->pm_bpcluster + blkoff; if (VTODE(*vpp)->de_inode != inode1) { vput(*vpp); goto restart; @@ -794,10 +799,9 @@ dosdirempty(struct denode *dep) * * Returns 0 if target is NOT a subdirectory of source. * Otherwise returns a non-zero error number. - * The target inode is always unlocked on return. */ int -doscheckpath(struct denode *source, struct denode *target) +doscheckpath(struct denode *source, struct denode *target, daddr_t *wait_scn) { daddr_t scn; struct msdosfsmount *pmp; @@ -806,26 +810,25 @@ doscheckpath(struct denode *source, struct denode *target) struct buf *bp = NULL; int error = 0; - dep = target; + *wait_scn = 0; + + pmp = target->de_pmp; + KASSERT(pmp == source->de_pmp, + ("doscheckpath: source and target on different filesystems")); + if ((target->de_Attributes & ATTR_DIRECTORY) == 0 || - (source->de_Attributes & ATTR_DIRECTORY) == 0) { - error = ENOTDIR; - goto out; - } - if (dep->de_StartCluster == source->de_StartCluster) { - error = EEXIST; - goto out; - } - if (dep->de_StartCluster == MSDOSFSROOT) - goto out; - pmp = dep->de_pmp; -#ifdef DIAGNOSTIC - if (pmp != source->de_pmp) - panic("doscheckpath: source and target on different filesystems"); -#endif - if (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk) - goto out; + (source->de_Attributes & ATTR_DIRECTORY) == 0) + return (ENOTDIR); + + if (target->de_StartCluster == source->de_StartCluster) + return (EEXIST); + + if (target->de_StartCluster == MSDOSFSROOT || + (FAT32(pmp) && target->de_StartCluster == pmp->pm_rootdirblk)) + return (0); + dep = target; + vget(DETOV(dep), LK_EXCLUSIVE); for (;;) { if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) { error = ENOTDIR; @@ -833,19 +836,22 @@ doscheckpath(struct denode *source, struct denode *target) } scn = dep->de_StartCluster; error = bread(pmp->pm_devvp, cntobn(pmp, scn), - pmp->pm_bpcluster, NOCRED, &bp); - if (error) + pmp->pm_bpcluster, NOCRED, &bp); + if (error != 0) break; - ep = (struct direntry *) bp->b_data + 1; + ep = (struct direntry *)bp->b_data + 1; if ((ep->deAttributes & ATTR_DIRECTORY) == 0 || bcmp(ep->deName, ".. ", 11) != 0) { error = ENOTDIR; + brelse(bp); break; } + scn = getushort(ep->deStartCluster); if (FAT32(pmp)) scn |= getushort(ep->deHighClust) << 16; + brelse(bp); if (scn == source->de_StartCluster) { error = EINVAL; @@ -862,15 +868,14 @@ doscheckpath(struct denode *source, struct denode *target) } vput(DETOV(dep)); - brelse(bp); - bp = NULL; + dep = NULL; /* NOTE: deget() clears dep on error */ - if ((error = deget(pmp, scn, 0, LK_EXCLUSIVE, &dep)) != 0) + error = deget(pmp, scn, 0, LK_EXCLUSIVE | LK_NOWAIT, &dep); + if (error != 0) { + *wait_scn = scn; break; + } } -out:; - if (bp) - brelse(bp); #ifdef MSDOSFS_DEBUG if (error == ENOTDIR) printf("doscheckpath(): .. not a directory?\n"); diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 5cd2c27cb46b..c81e192a6158 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -937,24 +937,27 @@ msdosfs_link(struct vop_link_args *ap) static int msdosfs_rename(struct vop_rename_args *ap) { - struct vnode *tdvp = ap->a_tdvp; - struct vnode *fvp = ap->a_fvp; - struct vnode *fdvp = ap->a_fdvp; - struct vnode *tvp = ap->a_tvp; - struct componentname *tcnp = ap->a_tcnp; - struct componentname *fcnp = ap->a_fcnp; - struct denode *ip, *xp, *dp, *zp; + struct vnode *fdvp, *fvp, *tdvp, *tvp, *vp; + struct componentname *fcnp, *tcnp; + struct denode *fdip, *fip, *tdip, *tip, *nip; u_char toname[12], oldname[11]; u_long from_diroffset, to_diroffset; + bool doingdirectory, newparent; u_char to_count; - int doingdirectory = 0, newparent = 0; int error; - u_long cn, pcl; - daddr_t bn; + u_long cn, pcl, blkoff; + daddr_t bn, wait_scn, scn; struct msdosfsmount *pmp; + struct mount *mp; struct direntry *dotdotp; struct buf *bp; + tdvp = ap->a_tdvp; + fvp = ap->a_fvp; + fdvp = ap->a_fdvp; + tvp = ap->a_tvp; + tcnp = ap->a_tcnp; + fcnp = ap->a_fcnp; pmp = VFSTOMSDOSFS(fdvp->v_mount); #ifdef DIAGNOSTIC @@ -965,19 +968,11 @@ msdosfs_rename(struct vop_rename_args *ap) /* * Check for cross-device rename. */ + mp = fvp->v_mount; if (fvp->v_mount != tdvp->v_mount || - (tvp && fvp->v_mount != tvp->v_mount)) { + (tvp != NULL && fvp->v_mount != tvp->v_mount)) { error = EXDEV; -abortit: - if (tdvp == tvp) - vrele(tdvp); - else - vput(tdvp); - if (tvp) - vput(tvp); - vrele(fdvp); - vrele(fvp); - return (error); + goto abortit; } /* @@ -988,11 +983,99 @@ abortit: goto abortit; } - error = vn_lock(fvp, LK_EXCLUSIVE); - if (error) - goto abortit; - dp = VTODE(fdvp); - ip = VTODE(fvp); + /* + * When the target exists, both the directory + * and target vnodes are passed locked. + */ + VOP_UNLOCK(tdvp); + if (tvp != NULL && tvp != tdvp) + VOP_UNLOCK(tvp); + +relock: + doingdirectory = newparent = false; + + error = vn_lock(fdvp, LK_EXCLUSIVE); + if (error != 0) + goto releout; + if (vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) { + VOP_UNLOCK(fdvp); + error = vn_lock(tdvp, LK_EXCLUSIVE); + if (error != 0) + goto releout; + VOP_UNLOCK(tdvp); + goto relock; + } + + error = msdosfs_lookup_ino(fdvp, NULL, fcnp, &scn, &blkoff); + if (error != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + goto releout; + } + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE | LK_NOWAIT, &nip); + if (error != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + if (error != EBUSY) + goto releout; + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE, &nip); + if (error != 0) + goto releout; + vp = fvp; + fvp = DETOV(nip); + VOP_UNLOCK(fvp); + vrele(vp); + goto relock; + } + vrele(fvp); + fvp = DETOV(nip); + from_diroffset = fdip->de_fndoffset; + + error = msdosfs_lookup_ino(tdvp, NULL, tcnp, &scn, &blkoff); + if (error != 0 && error != EJUSTRETURN) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(fvp); + goto releout; + } + if (error == EJUSTRETURN && tvp != NULL) { + vrele(tvp); + tvp = NULL; + } + if (error == 0) { + nip = NULL; + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE | LK_NOWAIT, + &nip); + if (tvp != NULL) { + vrele(tvp); + tvp = NULL; + } + if (error != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(fvp); + if (error != EBUSY) + goto releout; + error = deget(pmp, scn, blkoff, LK_EXCLUSIVE, + &nip); + if (error != 0) + goto releout; + vput(DETOV(nip)); + goto relock; + } + tvp = DETOV(nip); + } + + fdip = VTODE(fdvp); + fip = VTODE(fvp); + tdip = VTODE(tdvp); + tip = tvp != NULL ? VTODE(tvp) : NULL; + + /* + * Remember direntry place to use for destination + */ + to_diroffset = tdip->de_fndoffset; + to_count = tdip->de_fndcnt; /* * Be sure we are not renaming ".", "..", or an alias of ".". This @@ -1000,35 +1083,20 @@ abortit: * "ls" or "pwd" with the "." directory entry missing, and "cd .." * doesn't work if the ".." entry is missing. */ - if (ip->de_Attributes & ATTR_DIRECTORY) { + if ((fip->de_Attributes & ATTR_DIRECTORY) != 0) { /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') || - dp == ip || - (fcnp->cn_flags & ISDOTDOT) || - (tcnp->cn_flags & ISDOTDOT) || - (ip->de_flag & DE_RENAME)) { - VOP_UNLOCK(fvp); + fdip == fip || + (fcnp->cn_flags & ISDOTDOT) != 0 || + (tcnp->cn_flags & ISDOTDOT) != 0) { error = EINVAL; - goto abortit; + goto unlock; } - ip->de_flag |= DE_RENAME; - doingdirectory++; + doingdirectory = true; } - /* - * When the target exists, both the directory - * and target vnodes are returned locked. - */ - dp = VTODE(tdvp); - xp = tvp ? VTODE(tvp) : NULL; - /* - * Remember direntry place to use for destination - */ - to_diroffset = dp->de_fndoffset; - to_count = dp->de_fndcnt; - /* * If ".." must be changed (ie the directory gets a new * parent) then the source directory must not be in the @@ -1040,55 +1108,59 @@ abortit: * call to doscheckpath(). */ error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); - VOP_UNLOCK(fvp); - if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster) - newparent = 1; + if (fdip->de_StartCluster != tdip->de_StartCluster) + newparent = true; if (doingdirectory && newparent) { - if (error) /* write access check above */ - goto bad; - if (xp != NULL) - vput(tvp); - /* - * doscheckpath() vput()'s dp, - * so we have to do a relookup afterwards - */ - error = doscheckpath(ip, dp); - if (error) - goto out; + if (error != 0) /* write access check above */ + goto unlock; + error = doscheckpath(fip, tdip, &wait_scn); + if (wait_scn != 0) { + VOP_UNLOCK(fdvp); + VOP_UNLOCK(tdvp); + VOP_UNLOCK(fvp); + if (tvp != NULL && tvp != tdvp) + VOP_UNLOCK(tvp); + error = deget(pmp, wait_scn, 0, LK_EXCLUSIVE, + &nip); + if (error == 0) { + vput(DETOV(nip)); + goto relock; + } + } + if (error != 0) + goto unlock; if ((tcnp->cn_flags & SAVESTART) == 0) panic("msdosfs_rename: lost to startdir"); - error = relookup(tdvp, &tvp, tcnp); - if (error) - goto out; - dp = VTODE(tdvp); - xp = tvp ? VTODE(tvp) : NULL; } - if (xp != NULL) { + if (tip != NULL) { /* * Target must be empty if a directory and have no links * to it. Also, ensure source and target are compatible * (both directories, or both not directories). */ - if (xp->de_Attributes & ATTR_DIRECTORY) { - if (!dosdirempty(xp)) { + if ((tip->de_Attributes & ATTR_DIRECTORY) != 0) { + if (!dosdirempty(tip)) { error = ENOTEMPTY; - goto bad; + goto unlock; } if (!doingdirectory) { error = ENOTDIR; - goto bad; + goto unlock; } cache_purge(tdvp); } else if (doingdirectory) { error = EISDIR; - goto bad; + goto unlock; } - error = removede(dp, xp); - if (error) - goto bad; + error = msdosfs_lookup_ino(tdvp, NULL, tcnp, &scn, &blkoff); + MPASS(error == 0); + error = removede(tdip, tip); + if (error != 0) + goto unlock; vput(tvp); - xp = NULL; + tvp = NULL; + tip = NULL; } /* @@ -1096,146 +1168,83 @@ abortit: * into the denode and directory entry for the destination * file/directory. */ - error = uniqdosname(VTODE(tdvp), tcnp, toname); - if (error) - goto abortit; + error = uniqdosname(tdip, tcnp, toname); + if (error != 0) + goto unlock; /* - * Since from wasn't locked at various places above, - * have to do a relookup here. + * First write a new entry in the destination + * directory and mark the entry in the source directory + * as deleted. Then move the denode to the correct hash + * chain for its new location in the filesystem. And, if + * we moved a directory, then update its .. entry to point + * to the new parent directory. */ - fcnp->cn_flags &= ~MODMASK; - fcnp->cn_flags |= LOCKPARENT | LOCKLEAF; - if ((fcnp->cn_flags & SAVESTART) == 0) - panic("msdosfs_rename: lost from startdir"); - if (!newparent) - VOP_UNLOCK(tdvp); - if (relookup(fdvp, &fvp, fcnp) == 0) - vrele(fdvp); - if (fvp == NULL) { - /* - * From name has disappeared. - */ - if (doingdirectory) - panic("rename: lost dir entry"); - if (newparent) - VOP_UNLOCK(tdvp); - vrele(tdvp); - vrele(ap->a_fvp); - /* - * fdvp may be locked and has a reference. We need to - * release the lock and reference, unless to and from - * directories are the same. In that case it is already - * unlocked. - */ - if (tdvp != fdvp) - vput(fdvp); - return 0; + memcpy(oldname, fip->de_Name, 11); + memcpy(fip->de_Name, toname, 11); /* update denode */ + error = msdosfs_lookup_ino(tdvp, NULL, tcnp, &scn, &blkoff); + MPASS(error == EJUSTRETURN); + error = createde(fip, tdip, NULL, tcnp); + if (error != 0) { + memcpy(fip->de_Name, oldname, 11); + goto unlock; } - xp = VTODE(fvp); - zp = VTODE(fdvp); - from_diroffset = zp->de_fndoffset; /* - * Ensure that the directory entry still exists and has not - * changed till now. If the source is a file the entry may - * have been unlinked or renamed. In either case there is - * no further work to be done. If the source is a directory - * then it cannot have been rmdir'ed or renamed; this is - * prohibited by the DE_RENAME flag. + * If fip is for a directory, then its name should always + * be "." since it is for the directory entry in the + * directory itself (msdosfs_lookup() always translates + * to the "." entry so as to get a unique denode, except + * for the root directory there are different + * complications). However, we just corrupted its name + * to pass the correct name to createde(). Undo this. */ - if (xp != ip) { - if (doingdirectory) - panic("rename: lost dir entry"); - if (newparent) - VOP_UNLOCK(fdvp); - vrele(ap->a_fvp); - xp = NULL; - } else { - vrele(fvp); - xp = NULL; - - /* - * First write a new entry in the destination - * directory and mark the entry in the source directory - * as deleted. Then move the denode to the correct hash - * chain for its new location in the filesystem. And, if - * we moved a directory, then update its .. entry to point - * to the new parent directory. - */ - memcpy(oldname, ip->de_Name, 11); - memcpy(ip->de_Name, toname, 11); /* update denode */ - dp->de_fndoffset = to_diroffset; - dp->de_fndcnt = to_count; - error = createde(ip, dp, (struct denode **)0, tcnp); - if (error) { - memcpy(ip->de_Name, oldname, 11); - if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); - goto bad; - } - /* - * If ip is for a directory, then its name should always - * be "." since it is for the directory entry in the - * directory itself (msdosfs_lookup() always translates - * to the "." entry so as to get a unique denode, except - * for the root directory there are different - * complications). However, we just corrupted its name - * to pass the correct name to createde(). Undo this. - */ - if ((ip->de_Attributes & ATTR_DIRECTORY) != 0) - memcpy(ip->de_Name, oldname, 11); - ip->de_refcnt++; - zp->de_fndoffset = from_diroffset; - error = removede(zp, ip); - if (error) { - /* XXX should downgrade to ro here, fs is corrupt */ - if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); - goto bad; - } - if (!doingdirectory) { - error = pcbmap(dp, de_cluster(pmp, to_diroffset), 0, - &ip->de_dirclust, 0); - if (error) { - /* XXX should downgrade to ro here, fs is corrupt */ - if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); - goto bad; - } - if (ip->de_dirclust == MSDOSFSROOT) - ip->de_diroffset = to_diroffset; - else - ip->de_diroffset = to_diroffset & pmp->pm_crbomask; + if ((fip->de_Attributes & ATTR_DIRECTORY) != 0) + memcpy(fip->de_Name, oldname, 11); + fip->de_refcnt++; + error = msdosfs_lookup_ino(fdvp, NULL, fcnp, &scn, &blkoff); + MPASS(error == 0); + error = removede(fdip, fip); + if (error != 0) { + /* XXX should downgrade to ro here, fs is corrupt */ + goto unlock; + } + if (!doingdirectory) { + error = pcbmap(tdip, de_cluster(pmp, to_diroffset), 0, + &fip->de_dirclust, 0); + if (error != 0) { + /* + * XXX should downgrade to ro here, + * fs is corrupt + */ + goto unlock; } - reinsert(ip); - if (newparent) - VOP_UNLOCK(fdvp); + if (fip->de_dirclust == MSDOSFSROOT) + fip->de_diroffset = to_diroffset; + else + fip->de_diroffset = to_diroffset & pmp->pm_crbomask; } + reinsert(fip); /* * If we moved a directory to a new parent directory, then we must * fixup the ".." entry in the moved directory. */ if (doingdirectory && newparent) { - cn = ip->de_StartCluster; + cn = fip->de_StartCluster; if (cn == MSDOSFSROOT) { /* this should never happen */ panic("msdosfs_rename(): updating .. in root directory?"); } else bn = cntobn(pmp, cn); error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, - NOCRED, &bp); - if (error) { + NOCRED, &bp); + if (error != 0) { /* XXX should downgrade to ro here, fs is corrupt */ - VOP_UNLOCK(fvp); - goto bad; + goto unlock; } dotdotp = (struct direntry *)bp->b_data + 1; - pcl = dp->de_StartCluster; + pcl = tdip->de_StartCluster; if (FAT32(pmp) && pcl == pmp->pm_rootdirblk) pcl = MSDOSFSROOT; putushort(dotdotp->deStartCluster, pcl); @@ -1245,8 +1254,7 @@ abortit: bdwrite(bp); else if ((error = bwrite(bp)) != 0) { /* XXX should downgrade to ro here, fs is corrupt */ - VOP_UNLOCK(fvp); - goto bad; + goto unlock; } } @@ -1258,17 +1266,35 @@ abortit: * namecache entries that were installed for this direntry. */ cache_purge(fvp); - VOP_UNLOCK(fvp); -bad: - if (xp) - vput(tvp); + +unlock: + vput(fdvp); + vput(fvp); + if (tvp != NULL) { + if (tvp != tdvp) + vput(tvp); + else + vrele(tvp); + } vput(tdvp); -out: - ip->de_flag &= ~DE_RENAME; + return (error); +releout: + vrele(tdvp); + if (tvp != NULL) + vrele(tvp); + vrele(fdvp); + vrele(fvp); + return (error); +abortit: + if (tdvp == tvp) + vrele(tdvp); + else + vput(tdvp); + if (tvp != NULL) + vput(tvp); vrele(fdvp); vrele(fvp); return (error); - } static struct { @@ -1428,7 +1454,7 @@ msdosfs_rmdir(struct vop_rmdir_args *ap) * non-empty.) */ error = 0; - if (!dosdirempty(ip) || ip->de_flag & DE_RENAME) { + if (!dosdirempty(ip)) { error = ENOTEMPTY; goto out; } From owner-dev-commits-src-all@freebsd.org Fri Aug 27 15:39:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F39F866237C; Fri, 27 Aug 2021 15:39: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 4Gx3n94t0dz3vWS; Fri, 27 Aug 2021 15:39: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 3AB3625F02; Fri, 27 Aug 2021 15:39: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 17RFduoX089189; Fri, 27 Aug 2021 15:39:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdu5v089188; Fri, 27 Aug 2021 15:39:56 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:56 GMT Message-Id: <202108271539.17RFdu5v089188@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 6ae13c0feb96 - main - msdosfs: add doscheckpath lock MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6ae13c0feb96a1ea97e814213271b41b3d090d2d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:39:58 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6ae13c0feb96a1ea97e814213271b41b3d090d2d commit 6ae13c0feb96a1ea97e814213271b41b3d090d2d Author: Konstantin Belousov AuthorDate: 2021-08-07 20:18:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: add doscheckpath lock Similar to the UFS revision 8df4bc48c89a130207 Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/msdosfs_lookup.c | 1 + sys/fs/msdosfs/msdosfs_vfsops.c | 3 +++ sys/fs/msdosfs/msdosfs_vnops.c | 11 ++++++++++- sys/fs/msdosfs/msdosfsmount.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index 2c3d02db37a0..9940800a72c2 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -813,6 +813,7 @@ doscheckpath(struct denode *source, struct denode *target, daddr_t *wait_scn) *wait_scn = 0; pmp = target->de_pmp; + lockmgr_assert(&pmp->pm_checkpath_lock, KA_XLOCKED); KASSERT(pmp == source->de_pmp, ("doscheckpath: source and target on different filesystems")); diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 68c8a93a18af..0f6d41b3c77c 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -469,6 +469,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) pmp->pm_bo = bo; lockinit(&pmp->pm_fatlock, 0, msdosfs_lock_msg, 0, 0); + lockinit(&pmp->pm_checkpath_lock, 0, "msdoscp", 0, 0); /* * Initialize ownerships and permissions, since nothing else will @@ -740,6 +741,7 @@ error_exit: } if (pmp) { lockdestroy(&pmp->pm_fatlock); + lockdestroy(&pmp->pm_checkpath_lock); free(pmp->pm_inusemap, M_MSDOSFSFAT); free(pmp, M_MSDOSFSMNT); mp->mnt_data = NULL; @@ -829,6 +831,7 @@ msdosfs_unmount(struct mount *mp, int mntflags) dev_rel(pmp->pm_dev); free(pmp->pm_inusemap, M_MSDOSFSFAT); lockdestroy(&pmp->pm_fatlock); + lockdestroy(&pmp->pm_checkpath_lock); free(pmp, M_MSDOSFSMNT); mp->mnt_data = NULL; MNT_ILOCK(mp); diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index c81e192a6158..6197340e8943 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -942,7 +942,7 @@ msdosfs_rename(struct vop_rename_args *ap) struct denode *fdip, *fip, *tdip, *tip, *nip; u_char toname[12], oldname[11]; u_long from_diroffset, to_diroffset; - bool doingdirectory, newparent; + bool checkpath_locked, doingdirectory, newparent; u_char to_count; int error; u_long cn, pcl, blkoff; @@ -991,6 +991,8 @@ msdosfs_rename(struct vop_rename_args *ap) if (tvp != NULL && tvp != tdvp) VOP_UNLOCK(tvp); + checkpath_locked = false; + relock: doingdirectory = newparent = false; @@ -1113,8 +1115,12 @@ relock: if (doingdirectory && newparent) { if (error != 0) /* write access check above */ goto unlock; + lockmgr(&pmp->pm_checkpath_lock, LK_EXCLUSIVE, NULL); + checkpath_locked = true; error = doscheckpath(fip, tdip, &wait_scn); if (wait_scn != 0) { + lockmgr(&pmp->pm_checkpath_lock, LK_RELEASE, NULL); + checkpath_locked = false; VOP_UNLOCK(fdvp); VOP_UNLOCK(tdvp); VOP_UNLOCK(fvp); @@ -1268,6 +1274,8 @@ relock: cache_purge(fvp); unlock: + if (checkpath_locked) + lockmgr(&pmp->pm_checkpath_lock, LK_RELEASE, NULL); vput(fdvp); vput(fvp); if (tvp != NULL) { @@ -1279,6 +1287,7 @@ unlock: vput(tdvp); return (error); releout: + MPASS(!checkpath_locked); vrele(tdvp); if (tvp != NULL) vrele(tvp); diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h index 75b187860270..46a02e611cf5 100644 --- a/sys/fs/msdosfs/msdosfsmount.h +++ b/sys/fs/msdosfs/msdosfsmount.h @@ -114,6 +114,7 @@ struct msdosfsmount { void *pm_d2u; /* DOS->Local iconv handle */ #ifndef MAKEFS struct lock pm_fatlock; /* lockmgr protecting allocations */ + struct lock pm_checkpath_lock; /* protects doscheckpath result */ #endif }; From owner-dev-commits-src-all@freebsd.org Fri Aug 27 15:40:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 23C25662809; Fri, 27 Aug 2021 15:40: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 4Gx3nB6GqYz3vZ0; Fri, 27 Aug 2021 15:39: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 434322557B; Fri, 27 Aug 2021 15:39: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 17RFdweA089213; Fri, 27 Aug 2021 15:39:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdwMY089212; Fri, 27 Aug 2021 15:39:58 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:58 GMT Message-Id: <202108271539.17RFdwMY089212@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 85fb840ebf3c - main - msdosfs: drop now unused DE_RENAME MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 85fb840ebf3c213e45939188303bd5fe0aca4422 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:40:00 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=85fb840ebf3c213e45939188303bd5fe0aca4422 commit 85fb840ebf3c213e45939188303bd5fe0aca4422 Author: Konstantin Belousov AuthorDate: 2021-08-07 20:21:27 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 msdosfs: drop now unused DE_RENAME Submitted by: trasz Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/fs/msdosfs/denode.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index 67ffa522000a..c8e2dd09e697 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -173,7 +173,6 @@ struct denode { #define DE_CREATE 0x0008 /* Creation time update */ #define DE_ACCESS 0x0010 /* Access time update */ #define DE_MODIFIED 0x0020 /* Denode has been modified */ -#define DE_RENAME 0x0040 /* Denode is in the process of being renamed */ /* Maximum size of a file on a FAT filesystem */ #define MSDOSFS_FILESIZE_MAX 0xFFFFFFFFLL From owner-dev-commits-src-all@freebsd.org Fri Aug 27 15:40:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9B588662782; Fri, 27 Aug 2021 15:40: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 4Gx3nC5xgzz3vZ2; Fri, 27 Aug 2021 15:39:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6210225BD4; Fri, 27 Aug 2021 15:39: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 17RFdxMf089237; Fri, 27 Aug 2021 15:39:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RFdxfP089236; Fri, 27 Aug 2021 15:39:59 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:39:59 GMT Message-Id: <202108271539.17RFdxfP089236@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7c1e4aab7934 - main - vfs_hash_insert: ensure that predicate is true MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7c1e4aab7934933f0669c2b922976b30ed628a3f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:40:00 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7c1e4aab7934933f0669c2b922976b30ed628a3f commit 7c1e4aab7934933f0669c2b922976b30ed628a3f Author: Konstantin Belousov AuthorDate: 2021-08-17 13:47:25 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 vfs_hash_insert: ensure that predicate is true After vnode lock, recheck v_hash. When vfs_hash_insert() is used with a predicate, recheck it after the selected vnode is locked. Since vfs_hash_lock is dropped, vnode could be rehashed during the sleep for the vnode lock, which could go unnoticed there. Reported and tested by: pho Reviewed by: mckusick, rmacklem Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/kern/vfs_hash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_hash.c b/sys/kern/vfs_hash.c index e10e9b57e316..c5d67c8b2b33 100644 --- a/sys/kern/vfs_hash.c +++ b/sys/kern/vfs_hash.c @@ -93,8 +93,14 @@ vfs_hash_get(const struct mount *mp, u_int hash, int flags, struct thread *td, error = vget_finish(vp, flags, vs); if (error == ENOENT && (flags & LK_NOWAIT) == 0) break; - if (error) + if (error != 0) return (error); + if (vp->v_hash != hash || + (fn != NULL && fn(vp, arg))) { + vput(vp); + /* Restart the bucket walk. */ + break; + } *vpp = vp; return (0); } From owner-dev-commits-src-all@freebsd.org Fri Aug 27 15:40:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 613E066253C; Fri, 27 Aug 2021 15: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 4Gx3nD6rJhz3vRf; Fri, 27 Aug 2021 15:40: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 765AF25CCE; Fri, 27 Aug 2021 15: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 17RFe0J0089636; Fri, 27 Aug 2021 15: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 17RFe0RG089623; Fri, 27 Aug 2021 15:40:00 GMT (envelope-from git) Date: Fri, 27 Aug 2021 15:40:00 GMT Message-Id: <202108271540.17RFe0RG089623@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f19063ab029b - main - vfs_hash_rehash(): require the vnode to be exclusively locked MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f19063ab029b067e1763780aebca4bd620453110 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 15:40:01 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f19063ab029b067e1763780aebca4bd620453110 commit f19063ab029b067e1763780aebca4bd620453110 Author: Konstantin Belousov AuthorDate: 2021-08-18 11:14:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 15:39:45 +0000 vfs_hash_rehash(): require the vnode to be exclusively locked Rehash updates v_hash. Also, rehash moves the vnode to different hash bucket, which should be noticed in vfs_hash_get() after sleeping for the vnode lock. Reviewed by: mckusick, rmacklem Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31464 --- sys/kern/vfs_hash.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/kern/vfs_hash.c b/sys/kern/vfs_hash.c index c5d67c8b2b33..2e446e69a314 100644 --- a/sys/kern/vfs_hash.c +++ b/sys/kern/vfs_hash.c @@ -196,6 +196,7 @@ vfs_hash_insert(struct vnode *vp, u_int hash, int flags, struct thread *td, void vfs_hash_rehash(struct vnode *vp, u_int hash) { + ASSERT_VOP_ELOCKED(vp, "rehash requires excl lock"); rw_wlock(&vfs_hash_lock); LIST_REMOVE(vp, v_hashlist); From owner-dev-commits-src-all@freebsd.org Fri Aug 27 16:08:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EC800662AFA; Fri, 27 Aug 2021 16:08:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx4QQ602Pz4Zrv; Fri, 27 Aug 2021 16: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 B566F25F78; Fri, 27 Aug 2021 16: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 17RG8krb029153; Fri, 27 Aug 2021 16: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 17RG8kKW029152; Fri, 27 Aug 2021 16:08:46 GMT (envelope-from git) Date: Fri, 27 Aug 2021 16:08:46 GMT Message-Id: <202108271608.17RG8kKW029152@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: a436245ccf1a - stable/12 - iflib: Improve mapping of TX/RX queues to CPUs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: a436245ccf1ab7accd234b7f75904e24a44b8be6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 16:08:47 -0000 The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a436245ccf1ab7accd234b7f75904e24a44b8be6 commit a436245ccf1ab7accd234b7f75904e24a44b8be6 Author: Patrick Kelsey AuthorDate: 2021-04-26 04:25:59 +0000 Commit: Kevin Bowling CommitDate: 2021-08-27 16:08:27 +0000 iflib: Improve mapping of TX/RX queues to CPUs iflib now supports mapping each (TX,RX) queue pair to the same CPU (default), to separate CPUs, or to a pair of physical and logical CPUs that share the same L2 cache. The mapping mechanism supports unequal numbers of TX and RX queues, with the excess queues always being mapped to consecutive physical CPUs. When the platform cannot distinguish between physical and logical CPUs, all are treated as physical CPUs. See the comment on get_cpuid_for_queue() for the entire matrix. The following device-specific tunables influence the mapping process: dev...iflib.core_offset (existing) dev...iflib.separate_txrx (existing) dev...iflib.use_logical_cores (new) The following new, read-only sysctls provide visibility of the mapping results: dev...iflib.{t,r}xq.cpu When an iflib driver allocates TX softirqs without providing reference RX IRQs, iflib now binds those TX softirqs to CPUs using the above mapping mechanism (that is, treats them as if they were TX IRQs). Previously, such bindings were left up to the grouptaskqueue code and thus fell outside of the iflib CPU mapping strategy. Reviewed by: kbowling Tested by: olivier, pkelsey MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D24094 (cherry picked from commit ca7005f1893d199b7c28d5b159e1bdbb55e74543) --- sys/net/iflib.c | 449 +++++++++++++++++++++++++++++++++++-------------------- sys/sys/cpuset.h | 1 + 2 files changed, 291 insertions(+), 159 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index fb43a62ba67f..8dc1715e625d 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -197,6 +197,8 @@ struct iflib_ctx { uint16_t ifc_sysctl_core_offset; #define CORE_OFFSET_UNSPECIFIED 0xffff uint8_t ifc_sysctl_separate_txrx; + uint8_t ifc_sysctl_use_logical_cores; + bool ifc_cpus_are_physical_cores; qidx_t ifc_sysctl_ntxds[8]; qidx_t ifc_sysctl_nrxds[8]; @@ -731,7 +733,7 @@ struct cpu_offset { SLIST_ENTRY(cpu_offset) entries; cpuset_t set; unsigned int refcount; - uint16_t offset; + uint16_t next_cpuid; }; static struct mtx cpu_offset_mtx; MTX_SYSINIT(iflib_cpu_offset, &cpu_offset_mtx, "iflib_cpu_offset lock", @@ -4641,41 +4643,290 @@ iflib_reset_qvalues(if_ctx_t ctx) } } +/* + * Advance forward by n members of the cpuset ctx->ifc_cpus starting from + * cpuid and wrapping as necessary. + */ +static unsigned int +cpuid_advance(if_ctx_t ctx, unsigned int cpuid, unsigned int n) +{ + unsigned int first_valid; + unsigned int last_valid; + + /* cpuid should always be in the valid set */ + MPASS(CPU_ISSET(cpuid, &ctx->ifc_cpus)); + + /* valid set should never be empty */ + MPASS(!CPU_EMPTY(&ctx->ifc_cpus)); + + first_valid = CPU_FFS(&ctx->ifc_cpus) - 1; + last_valid = CPU_FLS(&ctx->ifc_cpus) - 1; + n = n % CPU_COUNT(&ctx->ifc_cpus); + while (n > 0) { + do { + cpuid++; + if (cpuid > last_valid) + cpuid = first_valid; + } while (!CPU_ISSET(cpuid, &ctx->ifc_cpus)); + n--; + } + + return (cpuid); +} + +#if defined(SMP) && defined(SCHED_ULE) +extern struct cpu_group *cpu_top; /* CPU topology */ + +static int +find_child_with_core(int cpu, struct cpu_group *grp) +{ + int i; + + if (grp->cg_children == 0) + return -1; + + MPASS(grp->cg_child); + for (i = 0; i < grp->cg_children; i++) { + if (CPU_ISSET(cpu, &grp->cg_child[i].cg_mask)) + return i; + } + + return -1; +} + + +/* + * Find an L2 neighbor of the given CPU or return -1 if none found. This + * does not distinguish among multiple L2 neighbors if the given CPU has + * more than one (it will always return the same result in that case). + */ +static int +find_l2_neighbor(int cpu) +{ + struct cpu_group *grp; + int i; + + grp = cpu_top; + if (grp == NULL) + return -1; + + /* + * Find the smallest CPU group that contains the given core. + */ + i = 0; + while ((i = find_child_with_core(cpu, grp)) != -1) { + /* + * If the smallest group containing the given CPU has less + * than two members, we conclude the given CPU has no + * L2 neighbor. + */ + if (grp->cg_child[i].cg_count <= 1) + return (-1); + grp = &grp->cg_child[i]; + } + + /* Must share L2. */ + if (grp->cg_level > CG_SHARE_L2 || grp->cg_level == CG_SHARE_NONE) + return -1; + + /* + * Select the first member of the set that isn't the reference + * CPU, which at this point is guaranteed to exist. + */ + for (i = 0; i < CPU_SETSIZE; i++) { + if (CPU_ISSET(i, &grp->cg_mask) && i != cpu) + return (i); + } + + /* Should never be reached */ + return (-1); +} + +#else +static int +find_l2_neighbor(int cpu) +{ + + return (-1); +} +#endif + +/* + * CPU mapping behaviors + * --------------------- + * 'separate txrx' refers to the separate_txrx sysctl + * 'use logical' refers to the use_logical_cores sysctl + * 'INTR CPUS' indicates whether bus_get_cpus(INTR_CPUS) succeeded + * + * separate use INTR + * txrx logical CPUS result + * ---------- --------- ------ ------------------------------------------------ + * - - X RX and TX queues mapped to consecutive physical + * cores with RX/TX pairs on same core and excess + * of either following + * - X X RX and TX queues mapped to consecutive cores + * of any type with RX/TX pairs on same core and + * excess of either following + * X - X RX and TX queues mapped to consecutive physical + * cores; all RX then all TX + * X X X RX queues mapped to consecutive physical cores + * first, then TX queues mapped to L2 neighbor of + * the corresponding RX queue if one exists, + * otherwise to consecutive physical cores + * - n/a - RX and TX queues mapped to consecutive cores of + * any type with RX/TX pairs on same core and excess + * of either following + * X n/a - RX and TX queues mapped to consecutive cores of + * any type; all RX then all TX + */ +static unsigned int +get_cpuid_for_queue(if_ctx_t ctx, unsigned int base_cpuid, unsigned int qid, + bool is_tx) +{ + if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; + unsigned int core_index; + + if (ctx->ifc_sysctl_separate_txrx) { + /* + * When using separate CPUs for TX and RX, the assignment + * will always be of a consecutive CPU out of the set of + * context CPUs, except for the specific case where the + * context CPUs are phsyical cores, the use of logical cores + * has been enabled, the assignment is for TX, the TX qid + * corresponds to an RX qid, and the CPU assigned to the + * corresponding RX queue has an L2 neighbor. + */ + if (ctx->ifc_sysctl_use_logical_cores && + ctx->ifc_cpus_are_physical_cores && + is_tx && qid < scctx->isc_nrxqsets) { + int l2_neighbor; + unsigned int rx_cpuid; + + rx_cpuid = cpuid_advance(ctx, base_cpuid, qid); + l2_neighbor = find_l2_neighbor(rx_cpuid); + if (l2_neighbor != -1) { + return (l2_neighbor); + } + /* + * ... else fall through to the normal + * consecutive-after-RX assignment scheme. + * + * Note that we are assuming that all RX queue CPUs + * have an L2 neighbor, or all do not. If a mixed + * scenario is possible, we will have to keep track + * separately of how many queues prior to this one + * were not able to be assigned to an L2 neighbor. + */ + } + if (is_tx) + core_index = scctx->isc_nrxqsets + qid; + else + core_index = qid; + } else { + core_index = qid; + } + + return (cpuid_advance(ctx, base_cpuid, core_index)); +} + static uint16_t get_ctx_core_offset(if_ctx_t ctx) { if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; struct cpu_offset *op; - uint16_t qc; - uint16_t ret = ctx->ifc_sysctl_core_offset; + cpuset_t assigned_cpus; + unsigned int cores_consumed; + unsigned int base_cpuid = ctx->ifc_sysctl_core_offset; + unsigned int first_valid; + unsigned int last_valid; + unsigned int i; - if (ret != CORE_OFFSET_UNSPECIFIED) - return (ret); + first_valid = CPU_FFS(&ctx->ifc_cpus) - 1; + last_valid = CPU_FLS(&ctx->ifc_cpus) - 1; - if (ctx->ifc_sysctl_separate_txrx) - qc = scctx->isc_ntxqsets + scctx->isc_nrxqsets; - else - qc = max(scctx->isc_ntxqsets, scctx->isc_nrxqsets); + if (base_cpuid != CORE_OFFSET_UNSPECIFIED) { + /* + * Align the user-chosen base CPU ID to the next valid CPU + * for this device. If the chosen base CPU ID is smaller + * than the first valid CPU or larger than the last valid + * CPU, we assume the user does not know what the valid + * range is for this device and is thinking in terms of a + * zero-based reference frame, and so we shift the given + * value into the valid range (and wrap accordingly) so the + * intent is translated to the proper frame of reference. + * If the base CPU ID is within the valid first/last, but + * does not correspond to a valid CPU, it is advanced to the + * next valid CPU (wrapping if necessary). + */ + if (base_cpuid < first_valid || base_cpuid > last_valid) { + /* shift from zero-based to first_valid-based */ + base_cpuid += first_valid; + /* wrap to range [first_valid, last_valid] */ + base_cpuid = (base_cpuid - first_valid) % + (last_valid - first_valid + 1); + } + if (!CPU_ISSET(base_cpuid, &ctx->ifc_cpus)) { + /* + * base_cpuid is in [first_valid, last_valid], but + * not a member of the valid set. In this case, + * there will always be a member of the valid set + * with a CPU ID that is greater than base_cpuid, + * and we simply advance to it. + */ + while (!CPU_ISSET(base_cpuid, &ctx->ifc_cpus)) + base_cpuid++; + } + return (base_cpuid); + } + + /* + * Determine how many cores will be consumed by performing the CPU + * assignments and counting how many of the assigned CPUs correspond + * to CPUs in the set of context CPUs. This is done using the CPU + * ID first_valid as the base CPU ID, as the base CPU must be within + * the set of context CPUs. + * + * Note not all assigned CPUs will be in the set of context CPUs + * when separate CPUs are being allocated to TX and RX queues, + * assignment to logical cores has been enabled, the set of context + * CPUs contains only physical CPUs, and TX queues are mapped to L2 + * neighbors of CPUs that RX queues have been mapped to - in this + * case we do only want to count how many CPUs in the set of context + * CPUs have been consumed, as that determines the next CPU in that + * set to start allocating at for the next device for which + * core_offset is not set. + */ + CPU_ZERO(&assigned_cpus); + for (i = 0; i < scctx->isc_ntxqsets; i++) + CPU_SET(get_cpuid_for_queue(ctx, first_valid, i, true), + &assigned_cpus); + for (i = 0; i < scctx->isc_nrxqsets; i++) + CPU_SET(get_cpuid_for_queue(ctx, first_valid, i, false), + &assigned_cpus); + CPU_AND(&assigned_cpus, &ctx->ifc_cpus); + cores_consumed = CPU_COUNT(&assigned_cpus); mtx_lock(&cpu_offset_mtx); SLIST_FOREACH(op, &cpu_offsets, entries) { if (CPU_CMP(&ctx->ifc_cpus, &op->set) == 0) { - ret = op->offset; - op->offset += qc; + base_cpuid = op->next_cpuid; + op->next_cpuid = cpuid_advance(ctx, op->next_cpuid, + cores_consumed); MPASS(op->refcount < UINT_MAX); op->refcount++; break; } } - if (ret == CORE_OFFSET_UNSPECIFIED) { - ret = 0; + if (base_cpuid == CORE_OFFSET_UNSPECIFIED) { + base_cpuid = first_valid; op = malloc(sizeof(struct cpu_offset), M_IFLIB, M_NOWAIT | M_ZERO); if (op == NULL) { device_printf(ctx->ifc_dev, "allocation for cpu offset failed.\n"); } else { - op->offset = qc; + op->next_cpuid = cpuid_advance(ctx, base_cpuid, + cores_consumed); op->refcount = 1; CPU_COPY(&ctx->ifc_cpus, &op->set); SLIST_INSERT_HEAD(&cpu_offsets, op, entries); @@ -4683,7 +4934,7 @@ get_ctx_core_offset(if_ctx_t ctx) } mtx_unlock(&cpu_offset_mtx); - return (ret); + return (base_cpuid); } static void @@ -4807,7 +5058,9 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) != 0) { device_printf(dev, "Unable to fetch CPU list\n"); CPU_COPY(&all_cpus, &ctx->ifc_cpus); - } + ctx->ifc_cpus_are_physical_cores = false; + } else + ctx->ifc_cpus_are_physical_cores = true; MPASS(CPU_COUNT(&ctx->ifc_cpus) > 0); /* @@ -5933,128 +6186,6 @@ iflib_irq_alloc(if_ctx_t ctx, if_irq_t irq, int rid, return (_iflib_irq_alloc(ctx, irq, rid, filter, handler, arg, name)); } -#ifdef SMP -static int -find_nth(if_ctx_t ctx, int qid) -{ - cpuset_t cpus; - int i, cpuid, eqid, count; - - CPU_COPY(&ctx->ifc_cpus, &cpus); - count = CPU_COUNT(&cpus); - eqid = qid % count; - /* clear up to the qid'th bit */ - for (i = 0; i < eqid; i++) { - cpuid = CPU_FFS(&cpus); - MPASS(cpuid != 0); - CPU_CLR(cpuid-1, &cpus); - } - cpuid = CPU_FFS(&cpus); - MPASS(cpuid != 0); - return (cpuid-1); -} - -#ifdef SCHED_ULE -extern struct cpu_group *cpu_top; /* CPU topology */ - -static int -find_child_with_core(int cpu, struct cpu_group *grp) -{ - int i; - - if (grp->cg_children == 0) - return -1; - - MPASS(grp->cg_child); - for (i = 0; i < grp->cg_children; i++) { - if (CPU_ISSET(cpu, &grp->cg_child[i].cg_mask)) - return i; - } - - return -1; -} - -/* - * Find the nth "close" core to the specified core - * "close" is defined as the deepest level that shares - * at least an L2 cache. With threads, this will be - * threads on the same core. If the shared cache is L3 - * or higher, simply returns the same core. - */ -static int -find_close_core(int cpu, int core_offset) -{ - struct cpu_group *grp; - int i; - int fcpu; - cpuset_t cs; - - grp = cpu_top; - if (grp == NULL) - return cpu; - i = 0; - while ((i = find_child_with_core(cpu, grp)) != -1) { - /* If the child only has one cpu, don't descend */ - if (grp->cg_child[i].cg_count <= 1) - break; - grp = &grp->cg_child[i]; - } - - /* If they don't share at least an L2 cache, use the same CPU */ - if (grp->cg_level > CG_SHARE_L2 || grp->cg_level == CG_SHARE_NONE) - return cpu; - - /* Now pick one */ - CPU_COPY(&grp->cg_mask, &cs); - - /* Add the selected CPU offset to core offset. */ - for (i = 0; (fcpu = CPU_FFS(&cs)) != 0; i++) { - if (fcpu - 1 == cpu) - break; - CPU_CLR(fcpu - 1, &cs); - } - MPASS(fcpu); - - core_offset += i; - - CPU_COPY(&grp->cg_mask, &cs); - for (i = core_offset % grp->cg_count; i > 0; i--) { - MPASS(CPU_FFS(&cs)); - CPU_CLR(CPU_FFS(&cs) - 1, &cs); - } - MPASS(CPU_FFS(&cs)); - return CPU_FFS(&cs) - 1; -} -#else -static int -find_close_core(int cpu, int core_offset __unused) -{ - return cpu; -} -#endif - -static int -get_core_offset(if_ctx_t ctx, iflib_intr_type_t type, int qid) -{ - switch (type) { - case IFLIB_INTR_TX: - /* TX queues get cores which share at least an L2 cache with the corresponding RX queue */ - /* XXX handle multiple RX threads per core and more than two core per L2 group */ - return qid / CPU_COUNT(&ctx->ifc_cpus) + 1; - case IFLIB_INTR_RX: - case IFLIB_INTR_RXTX: - /* RX queues get the specified core */ - return qid / CPU_COUNT(&ctx->ifc_cpus); - default: - return -1; - } -} -#else -#define get_core_offset(ctx, type, qid) CPU_FIRST() -#define find_close_core(cpuid, tid) CPU_FIRST() -#define find_nth(ctx, gid) CPU_FIRST() -#endif - /* Just to avoid copy/paste */ static inline int iflib_irq_set_affinity(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, @@ -6062,19 +6193,12 @@ iflib_irq_set_affinity(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, const char *name) { device_t dev; - int co, cpuid, err, tid; + unsigned int base_cpuid, cpuid; + int err; dev = ctx->ifc_dev; - co = ctx->ifc_sysctl_core_offset; - if (ctx->ifc_sysctl_separate_txrx && type == IFLIB_INTR_TX) - co += ctx->ifc_softc_ctx.isc_nrxqsets; - cpuid = find_nth(ctx, qid + co); - tid = get_core_offset(ctx, type, qid); - if (tid < 0) { - device_printf(dev, "get_core_offset failed\n"); - return (EOPNOTSUPP); - } - cpuid = find_close_core(cpuid, tid); + base_cpuid = ctx->ifc_sysctl_core_offset; + cpuid = get_cpuid_for_queue(ctx, base_cpuid, qid, type == IFLIB_INTR_TX); err = taskqgroup_attach_cpu(tqg, gtask, uniq, cpuid, rman_get_start(irq->ii_res), name); if (err) { @@ -6165,8 +6289,8 @@ iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid, return (0); if (tqrid != -1) { - err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, - q, name); + err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, q, + name); if (err) return (err); } else { @@ -6180,6 +6304,7 @@ iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid, void iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, void *arg, int qid, const char *name) { + device_t dev; struct grouptask *gtask; struct taskqgroup *tqg; gtask_fn_t *fn; @@ -6209,14 +6334,11 @@ iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, panic("unknown net intr type"); } GROUPTASK_INIT(gtask, 0, fn, q); - if (irq != NULL) { - err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, - q, name); - if (err) - taskqgroup_attach(tqg, gtask, q, - rman_get_start(irq->ii_res), name); - } else { - taskqgroup_attach(tqg, gtask, q, -1, name); + err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, q, name); + if (err) { + dev = ctx->ifc_dev; + taskqgroup_attach(tqg, gtask, q, rman_get_start(irq->ii_res), + name); } } @@ -6700,6 +6822,9 @@ iflib_add_device_sysctl_pre(if_ctx_t ctx) SYSCTL_ADD_U8(ctx_list, oid_list, OID_AUTO, "separate_txrx", CTLFLAG_RDTUN, &ctx->ifc_sysctl_separate_txrx, 0, "use separate cores for TX and RX"); + SYSCTL_ADD_U8(ctx_list, oid_list, OID_AUTO, "use_logical_cores", + CTLFLAG_RDTUN, &ctx->ifc_sysctl_use_logical_cores, 0, + "try to make use of logical cores for TX and RX"); /* XXX change for per-queue sizes */ SYSCTL_ADD_PROC(ctx_list, oid_list, OID_AUTO, "override_ntxds", @@ -6744,6 +6869,9 @@ iflib_add_device_sysctl_post(if_ctx_t ctx) queue_node = SYSCTL_ADD_NODE(ctx_list, child, OID_AUTO, namebuf, CTLFLAG_RD, NULL, "Queue Name"); queue_list = SYSCTL_CHILDREN(queue_node); + SYSCTL_ADD_S16(ctx_list, queue_list, OID_AUTO, "cpu", + CTLFLAG_RD, + &txq->ift_task.gt_cpu, 0, "cpu this queue is bound to"); #if MEMORY_LOGGING SYSCTL_ADD_QUAD(ctx_list, queue_list, OID_AUTO, "txq_dequeued", CTLFLAG_RD, @@ -6825,6 +6953,9 @@ iflib_add_device_sysctl_post(if_ctx_t ctx) queue_node = SYSCTL_ADD_NODE(ctx_list, child, OID_AUTO, namebuf, CTLFLAG_RD, NULL, "Queue Name"); queue_list = SYSCTL_CHILDREN(queue_node); + SYSCTL_ADD_S16(ctx_list, queue_list, OID_AUTO, "cpu", + CTLFLAG_RD, + &rxq->ifr_task.gt_cpu, 0, "cpu this queue is bound to"); if (sctx->isc_flags & IFLIB_HAS_RXCQ) { SYSCTL_ADD_U16(ctx_list, queue_list, OID_AUTO, "rxq_cq_cidx", CTLFLAG_RD, diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 829237df6fd2..0af1351c8067 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -65,6 +65,7 @@ #define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s) #define CPU_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) #define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p) +#define CPU_FLS(p) BIT_FLS(CPU_SETSIZE, p) #define CPU_COUNT(p) BIT_COUNT(CPU_SETSIZE, p) #define CPUSET_FSET BITSET_FSET(_NCPUWORDS) #define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER From owner-dev-commits-src-all@freebsd.org Fri Aug 27 16:49:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8CA066388E; Fri, 27 Aug 2021 16:49: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 4Gx5Kg4R74z4t82; Fri, 27 Aug 2021 16:49: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 8023F26CE5; Fri, 27 Aug 2021 16:49: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 17RGnh4e082263; Fri, 27 Aug 2021 16:49:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RGnhMa082262; Fri, 27 Aug 2021 16:49:43 GMT (envelope-from git) Date: Fri, 27 Aug 2021 16:49:43 GMT Message-Id: <202108271649.17RGnhMa082262@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b850806921a7 - main - Restore the definition of EFI_STAGING_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b850806921a735f3f307bc4b2634c7e9008f5a9c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 16:49:43 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b850806921a735f3f307bc4b2634c7e9008f5a9c commit b850806921a735f3f307bc4b2634c7e9008f5a9c Author: Konstantin Belousov AuthorDate: 2021-08-26 19:32:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 16:48:53 +0000 Restore the definition of EFI_STAGING_SIZE The definition can be overridden by users, and before f75caed644a5c it was in MBs. Make the symbol' unit MB, to be compatible with users customizations. Reported and tested by: Harry Schmalzbauer Sponsored by: The FreeBSD Foundation MFC after: 1 week --- stand/efi/loader/copy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index ba5da28aee92..65f595c12b11 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -180,9 +180,9 @@ out: #ifndef EFI_STAGING_SIZE #if defined(__arm__) -#define EFI_STAGING_SIZE M(32) +#define EFI_STAGING_SIZE 32 #else -#define EFI_STAGING_SIZE M(64) +#define EFI_STAGING_SIZE 64 #endif #endif @@ -315,7 +315,7 @@ efi_copy_init(void) EFI_STATUS status; unsigned long nr_pages; - nr_pages = EFI_SIZE_TO_PAGES((EFI_STAGING_SIZE)); + nr_pages = EFI_SIZE_TO_PAGES(M(1) * (EFI_STAGING_SIZE)); #if defined(__i386__) || defined(__amd64__) /* From owner-dev-commits-src-all@freebsd.org Fri Aug 27 16:49:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D6E04663155; Fri, 27 Aug 2021 16:49: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 4Gx5Kh5Nv8z4tDs; Fri, 27 Aug 2021 16:49:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A18C42675F; Fri, 27 Aug 2021 16:49: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 17RGniwW082287; Fri, 27 Aug 2021 16:49:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RGnivU082286; Fri, 27 Aug 2021 16:49:44 GMT (envelope-from git) Date: Fri, 27 Aug 2021 16:49:44 GMT Message-Id: <202108271649.17RGnivU082286@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b54eec836660 - main - efi loader: disallow user to configure staging area size less than default MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b54eec8366605d9c2303277cf2ab4b605289910a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 16:49:45 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b54eec8366605d9c2303277cf2ab4b605289910a commit b54eec8366605d9c2303277cf2ab4b605289910a Author: Konstantin Belousov AuthorDate: 2021-08-26 21:46:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-27 16:49:01 +0000 efi loader: disallow user to configure staging area size less than default We need to round it up to 2M, for instance. Having staging area too small might cause the first resize to use negative size for memmove()/memcpy(), which kills loader. Tested by: Harry Schmalzbauer Sponsored by: The FreeBSD Foundation MFC after: 1 week --- stand/efi/loader/copy.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index 65f595c12b11..2552ae86d966 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -178,12 +178,13 @@ out: } #endif /* __i386__ || __amd64__ */ -#ifndef EFI_STAGING_SIZE #if defined(__arm__) -#define EFI_STAGING_SIZE 32 +#define DEFAULT_EFI_STAGING_SIZE 32 #else -#define EFI_STAGING_SIZE 64 +#define DEFAULT_EFI_STAGING_SIZE 64 #endif +#ifndef EFI_STAGING_SIZE +#define EFI_STAGING_SIZE DEFAULT_EFI_STAGING_SIZE #endif #if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \ @@ -314,8 +315,12 @@ efi_copy_init(void) { EFI_STATUS status; unsigned long nr_pages; + vm_offset_t ess; - nr_pages = EFI_SIZE_TO_PAGES(M(1) * (EFI_STAGING_SIZE)); + ess = EFI_STAGING_SIZE; + if (ess < DEFAULT_EFI_STAGING_SIZE) + ess = DEFAULT_EFI_STAGING_SIZE; + nr_pages = EFI_SIZE_TO_PAGES(M(1) * ess); #if defined(__i386__) || defined(__amd64__) /* From owner-dev-commits-src-all@freebsd.org Fri Aug 27 17:09:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0A82B663FAB; Fri, 27 Aug 2021 17: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 4Gx5m56jsdz3Gq1; Fri, 27 Aug 2021 17: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 CEDB926EFF; Fri, 27 Aug 2021 17: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 17RH99nc009618; Fri, 27 Aug 2021 17: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 17RH99T3009617; Fri, 27 Aug 2021 17:09:09 GMT (envelope-from git) Date: Fri, 27 Aug 2021 17:09:09 GMT Message-Id: <202108271709.17RH99T3009617@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Stephen J. Kiernan" Subject: git: fd80208a5f92 - main - Add SDT probes virtqueue::enqueue_segments:{entry, return} MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: stevek X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fd80208a5f92a60381d7bb7b5225bcdc38ab6fd5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 17:09:10 -0000 The branch main has been updated by stevek: URL: https://cgit.FreeBSD.org/src/commit/?id=fd80208a5f92a60381d7bb7b5225bcdc38ab6fd5 commit fd80208a5f92a60381d7bb7b5225bcdc38ab6fd5 Author: Stephen J. Kiernan AuthorDate: 2021-08-27 17:08:59 +0000 Commit: Stephen J. Kiernan CommitDate: 2021-08-27 17:08:59 +0000 Add SDT probes virtqueue::enqueue_segments:{entry,return} This allows one to be able to map the sglist entries passed into the vq_ring_enqueue_segments() function to the segment indexes used in the virtqueue. This function normally gets inlined and may not available via FBT probes. Differential Revision: https://reviews.freebsd.org/D31620 --- sys/dev/virtio/virtqueue.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index 14c2088b70a8..59aefb31d9ac 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -137,6 +138,11 @@ static int vq_ring_must_notify_host(struct virtqueue *); static void vq_ring_notify_host(struct virtqueue *); static void vq_ring_free_chain(struct virtqueue *, uint16_t); +SDT_PROVIDER_DEFINE(virtqueue); +SDT_PROBE_DEFINE6(virtqueue, , enqueue_segments, entry, "struct virtqueue *", + "struct vring_desc *", "uint16_t", "struct sglist *", "int", "int"); +SDT_PROBE_DEFINE1(virtqueue, , enqueue_segments, return, "uint16_t"); + #define vq_modern(_vq) (((_vq)->vq_flags & VIRTQUEUE_FLAG_MODERN) != 0) #define vq_htog16(_vq, _val) virtio_htog16(vq_modern(_vq), _val) #define vq_htog32(_vq, _val) virtio_htog32(vq_modern(_vq), _val) @@ -703,6 +709,9 @@ vq_ring_enqueue_segments(struct virtqueue *vq, struct vring_desc *desc, int i, needed; uint16_t idx; + SDT_PROBE6(virtqueue, , enqueue_segments, entry, vq, desc, head_idx, + sg, readable, writable); + needed = readable + writable; for (i = 0, idx = head_idx, seg = sg->sg_segs; @@ -722,6 +731,7 @@ vq_ring_enqueue_segments(struct virtqueue *vq, struct vring_desc *desc, dp->flags |= vq_gtoh16(vq, VRING_DESC_F_WRITE); } + SDT_PROBE1(virtqueue, , enqueue_segments, return, idx); return (idx); } From owner-dev-commits-src-all@freebsd.org Fri Aug 27 17:47:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0A926644D2; Fri, 27 Aug 2021 17:47: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 4Gx6bz5QLnz3R1S; Fri, 27 Aug 2021 17:47: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 8EDEB2792C; Fri, 27 Aug 2021 17:47: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 17RHlBh5061970; Fri, 27 Aug 2021 17:47:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RHlBwD061969; Fri, 27 Aug 2021 17:47:11 GMT (envelope-from git) Date: Fri, 27 Aug 2021 17:47:11 GMT Message-Id: <202108271747.17RHlBwD061969@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 4e5d32a445f9 - main - Fix null pointer subtraction in mergesort() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e5d32a445f90d37966cd6de571978551654e3f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 17:47:12 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=4e5d32a445f90d37966cd6de571978551654e3f3 commit 4e5d32a445f90d37966cd6de571978551654e3f3 Author: Dimitry Andric AuthorDate: 2021-08-27 17:45:43 +0000 Commit: Dimitry Andric CommitDate: 2021-08-27 17:46:18 +0000 Fix null pointer subtraction in mergesort() Clang 13 produces the following warning for this function: lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction] if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) ^ ~~~~~~~~~ This is meant to check whether the size and base parameters are aligned to the size of an int, so use our __is_aligned() macro instead. Also remove the comment that indicated this "stupid subtraction" was done to pacify some ancient and unknown Cray compiler, and which has been there since the BSD 4.4 Lite Lib Sources were imported. MFC after: 3 days --- lib/libc/stdlib/merge.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 853d6ae93fcb..7d8484ed10b9 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -129,12 +129,8 @@ mergesort(void *base, size_t nmemb, size_t size, cmp_t cmp) if (nmemb == 0) return (0); - /* - * XXX - * Stupid subtraction for the Cray. - */ iflag = 0; - if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) + if (__is_aligned(size, ISIZE) && __is_aligned(base, ISIZE)) iflag = 1; if ((list2 = malloc(nmemb * size + PSIZE)) == NULL) From owner-dev-commits-src-all@freebsd.org Fri Aug 27 20:52:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2858F667A09; Fri, 27 Aug 2021 20:52: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 4GxBk96hYHz3Kwj; Fri, 27 Aug 2021 20:52: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 CEB322397; Fri, 27 Aug 2021 20:52: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 17RKqn2V015545; Fri, 27 Aug 2021 20:52:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RKqnrT015544; Fri, 27 Aug 2021 20:52:49 GMT (envelope-from git) Date: Fri, 27 Aug 2021 20:52:49 GMT Message-Id: <202108272052.17RKqnrT015544@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: f5c6c43d4c39 - main - Add a regression test for ggatec remote code execution MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f5c6c43d4c3910d5f8d61c0fae4582d863baa066 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 20:52:50 -0000 The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=f5c6c43d4c3910d5f8d61c0fae4582d863baa066 commit f5c6c43d4c3910d5f8d61c0fae4582d863baa066 Author: Alan Somers AuthorDate: 2021-08-27 20:40:05 +0000 Commit: Alan Somers CommitDate: 2021-08-27 20:52:45 +0000 Add a regression test for ggatec remote code execution Tests that ggatec appropriately handles unsupported BIO operations, rather than overflowing a buffer. Submitted by: Johannes Bruelltuete PR: 213479 Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D31318 --- tests/sys/geom/class/gate/ggate_test.sh | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/sys/geom/class/gate/ggate_test.sh b/tests/sys/geom/class/gate/ggate_test.sh index 7045d7292a75..d19d250215cc 100644 --- a/tests/sys/geom/class/gate/ggate_test.sh +++ b/tests/sys/geom/class/gate/ggate_test.sh @@ -5,6 +5,39 @@ PLAINFILES=plainfiles PORT=33080 CONF=gg.exports +atf_test_case ggatec_trim cleanup +ggatec_trim_head() +{ + atf_set "descr" "ggatec survives a trim" + atf_set "require.progs" "ggatec" + atf_set "require.user" "root" + atf_set "timeout" 60 +} + +ggatec_trim_body() +{ + load_ggate + + us=$(alloc_ggate_dev) + work=$(alloc_md) + atf_check -e ignore -o ignore dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc + echo $CONF >> $PLAINFILES + echo "localhost RW /dev/$work" > $CONF + atf_check ggated -p $PORT -F $PIDFILE $CONF + atf_check ggatec create -p $PORT -u $us localhost /dev/$work + ggate_dev=/dev/ggate${us} + wait_for_ggate_device ${ggate_dev} + + # ggatec only supports read or write. + atf_check -s not-exit:0 -e ignore -o ignore trim -q -f ${ggate_dev} +} + +ggatec_trim_cleanup() +{ + common_cleanup +} + + atf_test_case ggated cleanup ggated_head() { @@ -133,6 +166,7 @@ atf_init_test_cases() atf_add_test_case ggated atf_add_test_case ggatel_file atf_add_test_case ggatel_md + atf_add_test_case ggatec_trim } alloc_ggate_dev() From owner-dev-commits-src-all@freebsd.org Fri Aug 27 21:40:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 25D06668174; Fri, 27 Aug 2021 21:40: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 4GxCms09Gwz3nfp; Fri, 27 Aug 2021 21:40: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 DED20277E; Fri, 27 Aug 2021 21:40: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 17RLeCsw073554; Fri, 27 Aug 2021 21:40:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17RLeCT4073548; Fri, 27 Aug 2021 21:40:12 GMT (envelope-from git) Date: Fri, 27 Aug 2021 21:40:12 GMT Message-Id: <202108272140.17RLeCT4073548@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 5a3a8cb01ab8 - main - Silence more gtest warnings, now in fusefs tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2021 21:40:13 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6 commit 5a3a8cb01ab8ef4aa16a1950b1ef804070ce1ac6 Author: Dimitry Andric AuthorDate: 2021-08-27 21:39:23 +0000 Commit: Dimitry Andric CommitDate: 2021-08-27 21:39:36 +0000 Silence more gtest warnings, now in fusefs tests Follow-up d396c67f26b0 by also silencing warnings about deprecated implicit copy constructors in the fusefs tests, which use googletest. Fixes: d396c67f26b0 MFC after: 3 days --- tests/sys/fs/fusefs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile index 832b30dc6911..c3706e940840 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -77,6 +77,8 @@ CXXWARNFLAGS.readdir.cc+= -Wno-cast-align .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 80000 CXXWARNFLAGS+= -Wno-class-memaccess .endif +# Supress warnings about deprecated implicit copy constructors in gtest. +CXXWARNFLAGS+= -Wno-deprecated-copy CXXFLAGS+= -I${SRCTOP}/tests CXXFLAGS+= -I${FUSEFS} CXXFLAGS+= -I${MOUNT} From owner-dev-commits-src-all@freebsd.org Sat Aug 28 01:29:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D92D66ACDE; Sat, 28 Aug 2021 01:29:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxJsG0mdMz3qTf; Sat, 28 Aug 2021 01:29:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F244F5D26; Sat, 28 Aug 2021 01:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17S1TLTH075280; Sat, 28 Aug 2021 01:29:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S1TLst075279; Sat, 28 Aug 2021 01:29:21 GMT (envelope-from git) Date: Sat, 28 Aug 2021 01:29:21 GMT Message-Id: <202108280129.17S1TLst075279@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: da779f262c58 - main - vfs_default: Change vop_stddeallocate() from static to global MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da779f262c58c65f7061e979371a89d1df1acccc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 01:29:22 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=da779f262c58c65f7061e979371a89d1df1acccc commit da779f262c58c65f7061e979371a89d1df1acccc Author: Rick Macklem AuthorDate: 2021-08-28 01:25:44 +0000 Commit: Rick Macklem CommitDate: 2021-08-28 01:25:44 +0000 vfs_default: Change vop_stddeallocate() from static to global A future commit to the NFS client uses vop_stddeallocate() for cases where the NFS server does not support a Deallocate operation. Change vop_stddeallocate() from static to global so that it can be called by the NFS client. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31640 --- sys/kern/vfs_default.c | 3 +-- sys/sys/vnode.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 9fd43004b8fd..d66443e6d6f0 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -93,7 +93,6 @@ static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); static int vop_stdread_pgcache(struct vop_read_pgcache_args *ap); static int vop_stdstat(struct vop_stat_args *ap); static int vop_stdvput_pair(struct vop_vput_pair_args *ap); -static int vop_stddeallocate(struct vop_deallocate_args *ap); /* * This vnode table stores what we want to do if the filesystem doesn't @@ -1126,7 +1125,7 @@ vp_zerofill(struct vnode *vp, struct vattr *vap, off_t *offsetp, off_t *lenp, return (error); } -static int +int vop_stddeallocate(struct vop_deallocate_args *ap) { struct vnode *vp; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 56591a8d8a8d..61c6a13010f6 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -861,6 +861,7 @@ int vop_stdadvlock(struct vop_advlock_args *ap); int vop_stdadvlockasync(struct vop_advlockasync_args *ap); int vop_stdadvlockpurge(struct vop_advlockpurge_args *ap); int vop_stdallocate(struct vop_allocate_args *ap); +int vop_stddeallocate(struct vop_deallocate_args *ap); int vop_stdset_text(struct vop_set_text_args *ap); int vop_stdpathconf(struct vop_pathconf_args *); int vop_stdpoll(struct vop_poll_args *); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 01:35:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1FE7466B5A2; Sat, 28 Aug 2021 01:35: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 4GxK0J6rBzz3s0H; Sat, 28 Aug 2021 01:35: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 AAA5F5F69; Sat, 28 Aug 2021 01:35: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 17S1ZSd8088891; Sat, 28 Aug 2021 01:35:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S1ZSZO088890; Sat, 28 Aug 2021 01:35:28 GMT (envelope-from git) Date: Sat, 28 Aug 2021 01:35:28 GMT Message-Id: <202108280135.17S1ZSZO088890@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 08b9cc316a31 - main - nfscl: Add a VOP_DEALLOCATE() for the NFSv4.2 client MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 08b9cc316a319fba95af8bb13b262fe0d5526ec3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 01:35:29 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=08b9cc316a319fba95af8bb13b262fe0d5526ec3 commit 08b9cc316a319fba95af8bb13b262fe0d5526ec3 Author: Rick Macklem AuthorDate: 2021-08-28 01:31:36 +0000 Commit: Rick Macklem CommitDate: 2021-08-28 01:31:36 +0000 nfscl: Add a VOP_DEALLOCATE() for the NFSv4.2 client This patch adds a VOP_DEALLOCATE() to the NFS client. For NFSv4.2 servers that support the Deallocate operation, it is used. Otherwise, it falls back on calling vop_stddeallocate(). Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31640 --- sys/fs/nfs/nfs_var.h | 2 + sys/fs/nfsclient/nfs_clrpcops.c | 112 ++++++++++++++++++++++++++++++++++++++++ sys/fs/nfsclient/nfs_clvnops.c | 79 ++++++++++++++++++++++++++++ sys/fs/nfsclient/nfsmount.h | 1 + 4 files changed, 194 insertions(+) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 5ddae345f906..bae4affa72e2 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -553,6 +553,8 @@ int nfscl_findlayoutforio(struct nfscllayout *, uint64_t, uint32_t, void nfscl_freenfsclds(struct nfsclds *); int nfsrpc_allocate(vnode_t, off_t, off_t, struct nfsvattr *, int *, struct ucred *, NFSPROC_T *, void *); +int nfsrpc_deallocate(vnode_t, off_t, off_t, struct nfsvattr *, int *, + struct ucred *, NFSPROC_T *, void *); int nfsrpc_copy_file_range(vnode_t, off_t *, vnode_t, off_t *, size_t *, unsigned int, int *, struct nfsvattr *, int *, struct nfsvattr *, struct ucred *, bool, bool *); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index de4030876bfe..f9636bc28365 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -132,6 +132,8 @@ static int nfsrpc_readrpc(vnode_t , struct uio *, struct ucred *, static int nfsrpc_writerpc(vnode_t , struct uio *, int *, int *, struct ucred *, nfsv4stateid_t *, NFSPROC_T *, struct nfsvattr *, int *, void *); +static int nfsrpc_deallocaterpc(vnode_t, off_t, off_t, nfsv4stateid_t *, + struct nfsvattr *, int *, struct ucred *, NFSPROC_T *, void *); static int nfsrpc_createv23(vnode_t , char *, int, struct vattr *, nfsquad_t, int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *, struct nfsfh **, int *, int *, void *); @@ -2089,6 +2091,116 @@ nfsmout: return (error); } +/* + * Do an nfs deallocate operation. + */ +int +nfsrpc_deallocate(vnode_t vp, off_t offs, off_t len, struct nfsvattr *nap, + int *attrflagp, struct ucred *cred, NFSPROC_T *p, void *stuff) +{ + int error, expireret = 0, openerr, retrycnt; + uint32_t clidrev = 0; + struct nfsmount *nmp = VFSTONFS(vp->v_mount); + struct nfsfh *nfhp; + nfsv4stateid_t stateid; + void *lckp; + + if (nmp->nm_clp != NULL) + clidrev = nmp->nm_clp->nfsc_clientidrev; + retrycnt = 0; + do { + lckp = NULL; + openerr = 1; + nfhp = VTONFS(vp)->n_fhp; + error = nfscl_getstateid(vp, nfhp->nfh_fh, nfhp->nfh_len, + NFSV4OPEN_ACCESSWRITE, 0, cred, p, &stateid, &lckp); + if (error != 0) { + /* + * No Open stateid, so try and open the file + * now. + */ + openerr = nfsrpc_open(vp, FWRITE, cred, p); + if (openerr == 0) + nfscl_getstateid(vp, nfhp->nfh_fh, + nfhp->nfh_len, NFSV4OPEN_ACCESSWRITE, 0, + cred, p, &stateid, &lckp); + } + error = nfsrpc_deallocaterpc(vp, offs, len, &stateid, nap, + attrflagp, cred, p, stuff); + if (error == NFSERR_STALESTATEID) + nfscl_initiate_recovery(nmp->nm_clp); + if (lckp != NULL) + nfscl_lockderef(lckp); + if (openerr == 0) + nfsrpc_close(vp, 0, p); + if (error == NFSERR_GRACE || error == NFSERR_STALESTATEID || + error == NFSERR_STALEDONTRECOVER || error == NFSERR_DELAY || + error == NFSERR_OLDSTATEID || error == NFSERR_BADSESSION) { + (void) nfs_catnap(PZERO, error, "nfs_deallocate"); + } else if ((error == NFSERR_EXPIRED || + error == NFSERR_BADSTATEID) && clidrev != 0) { + expireret = nfscl_hasexpired(nmp->nm_clp, clidrev, p); + } + retrycnt++; + } while (error == NFSERR_GRACE || error == NFSERR_STALESTATEID || + error == NFSERR_STALEDONTRECOVER || error == NFSERR_DELAY || + error == NFSERR_BADSESSION || + (error == NFSERR_OLDSTATEID && retrycnt < 20) || + ((error == NFSERR_EXPIRED || error == NFSERR_BADSTATEID) && + expireret == 0 && clidrev != 0 && retrycnt < 4)); + if (error && retrycnt >= 4) + error = EIO; + return (error); +} + +/* + * The actual deallocate RPC. + */ +static int +nfsrpc_deallocaterpc(vnode_t vp, off_t offs, off_t len, + nfsv4stateid_t *stateidp, struct nfsvattr *nap, int *attrflagp, + struct ucred *cred, NFSPROC_T *p, void *stuff) +{ + uint32_t *tl; + struct nfsnode *np = VTONFS(vp); + int error, wccflag; + struct nfsrv_descript nfsd; + struct nfsrv_descript *nd = &nfsd; + nfsattrbit_t attrbits; + + *attrflagp = 0; + NFSCL_REQSTART(nd, NFSPROC_DEALLOCATE, vp); + nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER); + txdr_hyper(offs, tl); + tl += 2; + txdr_hyper(len, tl); + NFSWRITEGETATTR_ATTRBIT(&attrbits); + NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV4OP_GETATTR); + nfsrv_putattrbit(nd, &attrbits); + error = nfscl_request(nd, vp, p, cred, stuff); + if (error != 0) + return (error); + wccflag = 0; + error = nfscl_wcc_data(nd, vp, nap, attrflagp, &wccflag, stuff); + if (error != 0) + goto nfsmout; + if (nd->nd_repstat == 0) { + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + error = nfsm_loadattr(nd, nap); + if (error != 0) + goto nfsmout; + *attrflagp = NFS_LATTR_NOSHRINK; + } + NFSWRITERPC_SETTIME(wccflag, np, nap, 1); +nfsmout: + m_freem(nd->nd_mrep); + if (nd->nd_repstat != 0 && error == 0) + error = nd->nd_repstat; + return (error); +} + /* * nfs mknod rpc * For NFS v2 this is a kludge. Use a create rpc but with the IFMT bits of the diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 39340692563f..bfd77d50bc91 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -146,6 +146,7 @@ static vop_getacl_t nfs_getacl; static vop_setacl_t nfs_setacl; static vop_advise_t nfs_advise; static vop_allocate_t nfs_allocate; +static vop_deallocate_t nfs_deallocate; static vop_copy_file_range_t nfs_copy_file_range; static vop_ioctl_t nfs_ioctl; static vop_getextattr_t nfs_getextattr; @@ -193,6 +194,7 @@ static struct vop_vector newnfs_vnodeops_nosig = { .vop_setacl = nfs_setacl, .vop_advise = nfs_advise, .vop_allocate = nfs_allocate, + .vop_deallocate = nfs_deallocate, .vop_copy_file_range = nfs_copy_file_range, .vop_ioctl = nfs_ioctl, .vop_getextattr = nfs_getextattr, @@ -3681,6 +3683,83 @@ nfs_allocate(struct vop_allocate_args *ap) return (error); } +/* + * nfs deallocate call + */ +static int +nfs_deallocate(struct vop_deallocate_args *ap) +{ + struct vnode *vp = ap->a_vp; + struct thread *td = curthread; + struct nfsvattr nfsva; + struct nfsmount *nmp; + off_t tlen; + int attrflag, error, ret; + + error = 0; + attrflag = 0; + nmp = VFSTONFS(vp->v_mount); + mtx_lock(&nmp->nm_mtx); + if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && + (nmp->nm_privflag & NFSMNTP_NODEALLOCATE) == 0) { + mtx_unlock(&nmp->nm_mtx); + tlen = omin(OFF_MAX - *ap->a_offset, *ap->a_len); + NFSCL_DEBUG(4, "dealloc: off=%jd len=%jd maxfilesize=%ju\n", + (intmax_t)*ap->a_offset, (intmax_t)tlen, + (uintmax_t)nmp->nm_maxfilesize); + if ((uint64_t)*ap->a_offset >= nmp->nm_maxfilesize) { + /* Avoid EFBIG error return from the NFSv4.2 server. */ + *ap->a_len = 0; + return (0); + } + if ((uint64_t)*ap->a_offset + tlen > nmp->nm_maxfilesize) + tlen = nmp->nm_maxfilesize - *ap->a_offset; + if (error == 0) + error = ncl_vinvalbuf(vp, V_SAVE, td, 1); + if (error == 0) { + vnode_pager_purge_range(vp, *ap->a_offset, + *ap->a_offset + tlen); + error = nfsrpc_deallocate(vp, *ap->a_offset, tlen, + &nfsva, &attrflag, ap->a_cred, td, NULL); + NFSCL_DEBUG(4, "dealloc: rpc=%d\n", error); + } + if (error == 0) { + NFSCL_DEBUG(4, "dealloc: attrflag=%d na_size=%ju\n", + attrflag, (uintmax_t)nfsva.na_size); + if (attrflag != 0) { + if ((uint64_t)*ap->a_offset < nfsva.na_size) + *ap->a_offset += omin((off_t) + nfsva.na_size - *ap->a_offset, + tlen); + } + *ap->a_len = 0; + } else if (error == NFSERR_NOTSUPP) { + mtx_lock(&nmp->nm_mtx); + nmp->nm_privflag |= NFSMNTP_NODEALLOCATE; + mtx_unlock(&nmp->nm_mtx); + } + } else { + mtx_unlock(&nmp->nm_mtx); + error = EIO; + } + /* + * If the NFS server cannot perform the Deallocate operation, just call + * vop_stddeallocate() to perform it. + */ + if (error != 0 && error != NFSERR_FBIG && error != NFSERR_INVAL) { + error = vop_stddeallocate(ap); + NFSCL_DEBUG(4, "dealloc: stddeallocate=%d\n", error); + } + if (attrflag != 0) { + ret = nfscl_loadattrcache(&vp, &nfsva, NULL, NULL, 0, 1); + if (error == 0 && ret != 0) + error = ret; + } + if (error != 0) + error = nfscl_maperr(td, error, (uid_t)0, (gid_t)0); + return (error); +} + /* * nfs copy_file_range call */ diff --git a/sys/fs/nfsclient/nfsmount.h b/sys/fs/nfsclient/nfsmount.h index a5997e474be9..d5771f157034 100644 --- a/sys/fs/nfsclient/nfsmount.h +++ b/sys/fs/nfsclient/nfsmount.h @@ -124,6 +124,7 @@ struct nfsmount { #define NFSMNTP_NOADVISE 0x00000100 #define NFSMNTP_NOALLOCATE 0x00000200 #define NFSMNTP_DELEGISSUED 0x00000400 +#define NFSMNTP_NODEALLOCATE 0x00000800 /* New mount flags only used by the kernel via nmount(2). */ #define NFSMNT_TLS 0x00000001 From owner-dev-commits-src-all@freebsd.org Sat Aug 28 02:21:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 738BF66BFA5; Sat, 28 Aug 2021 02:21: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 4GxL1P2sr0z4ZV2; Sat, 28 Aug 2021 02:21:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B1096665; Sat, 28 Aug 2021 02:21: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 17S2LT6t051450; Sat, 28 Aug 2021 02:21:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S2LTgZ051430; Sat, 28 Aug 2021 02:21:29 GMT (envelope-from git) Date: Sat, 28 Aug 2021 02:21:29 GMT Message-Id: <202108280221.17S2LTgZ051430@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: f0278de38052 - stable/13 - Refactor/optimize cpu_search_*(). 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: f0278de380520b897e6936171425af035caa9289 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 02:21:29 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=f0278de380520b897e6936171425af035caa9289 commit f0278de380520b897e6936171425af035caa9289 Author: Alexander Motin AuthorDate: 2021-07-29 01:18:50 +0000 Commit: Alexander Motin CommitDate: 2021-08-28 02:17:55 +0000 Refactor/optimize cpu_search_*(). Remove cpu_search_both(), unused for many years. Without it there is less sense for the trick of compiling common cpu_search() into separate cpu_search_lowest() and cpu_search_highest(), so split them completely, making code more readable. While there, split iteration over children groups and CPUs, complicating code for very small deduplication. Stop passing cpuset_t arguments by value and avoid some manipulations. Since MAXCPU bump from 64 to 256, what was a single register turned into 32-byte memory array, requiring memory allocation and accesses. Splitting struct cpu_search into parameter and result parts allows to even more reduce stack usage, since the first can be passed through on recursion. Remove CPU_FFS() from the hot paths, precalculating first and last CPU for each CPU group in advance during initialization. Again, it was not a problem for 64 CPUs before, but for 256 FFS needs much more code. With these changes on 80-thread system doing ~260K uncached ZFS reads per second I observe ~30% reduction of time spent in cpu_search_*(). MFC after: 1 month (cherry picked from commit aefe0a8c32d370f2fdd0d0771eb59f8845beda17) --- sys/kern/sched_ule.c | 290 +++++++++++++++++++++------------------------------ sys/kern/subr_smp.c | 12 +++ sys/sys/smp.h | 2 + 3 files changed, 134 insertions(+), 170 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 49bf3328f3d9..6e9ef73efe99 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -631,170 +631,120 @@ sched_random(void) } struct cpu_search { - cpuset_t cs_mask; + cpuset_t *cs_mask; u_int 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; }; -#define CPU_SEARCH_LOWEST 0x1 -#define CPU_SEARCH_HIGHEST 0x2 -#define CPU_SEARCH_BOTH (CPU_SEARCH_LOWEST|CPU_SEARCH_HIGHEST) - -static __always_inline int cpu_search(const struct cpu_group *cg, - struct cpu_search *low, struct cpu_search *high, const int match); -int __noinline cpu_search_lowest(const struct cpu_group *cg, - struct cpu_search *low); -int __noinline cpu_search_highest(const struct cpu_group *cg, - struct cpu_search *high); -int __noinline cpu_search_both(const struct cpu_group *cg, - struct cpu_search *low, struct cpu_search *high); - -/* - * Search the tree of cpu_groups for the lowest or highest loaded cpu - * according to the match argument. This routine actually compares the - * load on all paths through the tree and finds the least loaded cpu on - * the least loaded path, which may differ from the least loaded cpu in - * the system. This balances work among caches and buses. - * - * This inline is instantiated in three forms below using constants for the - * match argument. It is reduced to the minimum set for each case. It is - * also recursive to the depth of the tree. - */ -static __always_inline int -cpu_search(const struct cpu_group *cg, struct cpu_search *low, - struct cpu_search *high, const int match) -{ - struct cpu_search lgroup; - struct cpu_search hgroup; - cpuset_t cpumask; - struct cpu_group *child; +/* + * Search the tree of cpu_groups for the lowest or highest loaded CPU. + * These routines actually compare the load on all paths through the tree + * and find the least loaded cpu on the least loaded path, which may differ + * from the least loaded cpu in the system. This balances work among caches + * and buses. + */ +static int +cpu_search_lowest(const struct cpu_group *cg, const struct cpu_search *s, + struct cpu_search_res *r) +{ + struct cpu_search_res lr; struct tdq *tdq; - int cpu, i, hload, lload, load, total, rnd; + int c, bload, l, load, total; total = 0; - cpumask = cg->cg_mask; - if (match & CPU_SEARCH_LOWEST) { - lload = INT_MAX; - lgroup = *low; - } - if (match & CPU_SEARCH_HIGHEST) { - hload = INT_MIN; - hgroup = *high; - } + bload = INT_MAX; + r->cs_cpu = -1; - /* Iterate through the child CPU groups and then remaining CPUs. */ - for (i = cg->cg_children, cpu = mp_maxid; ; ) { - if (i == 0) { -#ifdef HAVE_INLINE_FFSL - cpu = CPU_FFS(&cpumask) - 1; -#else - while (cpu >= 0 && !CPU_ISSET(cpu, &cpumask)) - cpu--; -#endif - if (cpu < 0) - break; - child = NULL; - } else - child = &cg->cg_child[i - 1]; - - if (match & CPU_SEARCH_LOWEST) - lgroup.cs_cpu = -1; - if (match & CPU_SEARCH_HIGHEST) - hgroup.cs_cpu = -1; - if (child) { /* Handle child CPU group. */ - CPU_ANDNOT(&cpumask, &child->cg_mask); - switch (match) { - case CPU_SEARCH_LOWEST: - load = cpu_search_lowest(child, &lgroup); - break; - case CPU_SEARCH_HIGHEST: - load = cpu_search_highest(child, &hgroup); - break; - case CPU_SEARCH_BOTH: - load = cpu_search_both(child, &lgroup, &hgroup); - break; - } - } else { /* Handle child CPU. */ - CPU_CLR(cpu, &cpumask); - tdq = TDQ_CPU(cpu); - load = tdq->tdq_load * 256; - rnd = sched_random() % 32; - if (match & CPU_SEARCH_LOWEST) { - if (cpu == low->cs_prefer) - load -= 64; - /* If that CPU is allowed and get data. */ - if (tdq->tdq_lowpri > lgroup.cs_pri && - tdq->tdq_load <= lgroup.cs_limit && - CPU_ISSET(cpu, &lgroup.cs_mask)) { - lgroup.cs_cpu = cpu; - lgroup.cs_load = load - rnd; - } + /* 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_lowest(&cg->cg_child[c], s, &lr); + total += load; + if (lr.cs_cpu >= 0 && (load < bload || + (load == bload && lr.cs_load < r->cs_load))) { + bload = load; + r->cs_cpu = lr.cs_cpu; + r->cs_load = lr.cs_load; } - if (match & CPU_SEARCH_HIGHEST) - if (tdq->tdq_load >= hgroup.cs_limit && - tdq->tdq_transferable && - CPU_ISSET(cpu, &hgroup.cs_mask)) { - hgroup.cs_cpu = cpu; - hgroup.cs_load = load - rnd; - } } - total += load; + return (total); + } - /* We have info about child item. Compare it. */ - if (match & CPU_SEARCH_LOWEST) { - if (lgroup.cs_cpu >= 0 && - (load < lload || - (load == lload && lgroup.cs_load < low->cs_load))) { - lload = load; - low->cs_cpu = lgroup.cs_cpu; - low->cs_load = lgroup.cs_load; - } - } - if (match & CPU_SEARCH_HIGHEST) - if (hgroup.cs_cpu >= 0 && - (load > hload || - (load == hload && hgroup.cs_load > high->cs_load))) { - hload = load; - high->cs_cpu = hgroup.cs_cpu; - high->cs_load = hgroup.cs_load; - } - if (child) { - i--; - if (i == 0 && CPU_EMPTY(&cpumask)) - break; + /* Loop through children CPUs otherwise. */ + for (c = cg->cg_last; c >= cg->cg_first; c--) { + if (!CPU_ISSET(c, &cg->cg_mask)) + continue; + tdq = TDQ_CPU(c); + l = tdq->tdq_load; + load = l * 256; + if (c == s->cs_prefer) + load -= 128; + total += load; + if (l > s->cs_limit || tdq->tdq_lowpri <= s->cs_pri || + !CPU_ISSET(c, s->cs_mask)) + continue; + load -= sched_random() % 128; + if (load < bload) { + bload = load; + r->cs_cpu = c; } -#ifndef HAVE_INLINE_FFSL - else - cpu--; -#endif } + r->cs_load = bload; return (total); } -/* - * cpu_search instantiations must pass constants to maintain the inline - * optimization. - */ -int -cpu_search_lowest(const struct cpu_group *cg, struct cpu_search *low) +static int +cpu_search_highest(const struct cpu_group *cg, const struct cpu_search *s, + struct cpu_search_res *r) { - return cpu_search(cg, low, NULL, CPU_SEARCH_LOWEST); -} + struct cpu_search_res lr; + struct tdq *tdq; + int c, bload, l, load, total; -int -cpu_search_highest(const struct cpu_group *cg, struct cpu_search *high) -{ - return cpu_search(cg, NULL, high, CPU_SEARCH_HIGHEST); -} + total = 0; + bload = INT_MIN; + r->cs_cpu = -1; -int -cpu_search_both(const struct cpu_group *cg, struct cpu_search *low, - struct cpu_search *high) -{ - return cpu_search(cg, low, high, CPU_SEARCH_BOTH); + /* 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))) { + bload = load; + r->cs_cpu = lr.cs_cpu; + r->cs_load = lr.cs_load; + } + } + return (total); + } + + /* Loop through children CPUs otherwise. */ + for (c = cg->cg_last; c >= cg->cg_first; c--) { + if (!CPU_ISSET(c, &cg->cg_mask)) + continue; + tdq = TDQ_CPU(c); + l = tdq->tdq_load; + load = l * 256; + total += load; + if (l < s->cs_limit || !tdq->tdq_transferable || + !CPU_ISSET(c, s->cs_mask)) + continue; + load -= sched_random() % 128; + if (load > bload) { + bload = load; + r->cs_cpu = c; + } + } + r->cs_load = bload; + return (total); } /* @@ -803,33 +753,33 @@ cpu_search_both(const struct cpu_group *cg, struct cpu_search *low, * acceptable. */ static inline int -sched_lowest(const struct cpu_group *cg, cpuset_t mask, int pri, int maxload, +sched_lowest(const struct cpu_group *cg, cpuset_t *mask, int pri, int maxload, int prefer) { - struct cpu_search low; + struct cpu_search s; + struct cpu_search_res r; - low.cs_cpu = -1; - low.cs_prefer = prefer; - low.cs_mask = mask; - low.cs_pri = pri; - low.cs_limit = maxload; - cpu_search_lowest(cg, &low); - return low.cs_cpu; + s.cs_prefer = prefer; + s.cs_mask = mask; + s.cs_pri = pri; + s.cs_limit = maxload; + cpu_search_lowest(cg, &s, &r); + return (r.cs_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) { - struct cpu_search high; + struct cpu_search s; + struct cpu_search_res r; - high.cs_cpu = -1; - high.cs_mask = mask; - high.cs_limit = minload; - cpu_search_highest(cg, &high); - return high.cs_cpu; + s.cs_mask = mask; + s.cs_limit = minload; + cpu_search_highest(cg, &s, &r); + return (r.cs_cpu); } static void @@ -841,7 +791,7 @@ sched_balance_group(struct cpu_group *cg) CPU_FILL(&hmask); for (;;) { - high = sched_highest(cg, hmask, 2); + high = sched_highest(cg, &hmask, 2); /* Stop if there is no more CPU with transferrable threads. */ if (high == -1) break; @@ -853,7 +803,7 @@ sched_balance_group(struct cpu_group *cg) anylow = 1; tdq = TDQ_CPU(high); nextlow: - low = sched_lowest(cg, lmask, -1, tdq->tdq_load - 1, high); + low = sched_lowest(cg, &lmask, -1, tdq->tdq_load - 1, high); /* Stop if we looked well and found no less loaded CPU. */ if (anylow && low == -1) break; @@ -995,7 +945,7 @@ tdq_idled(struct tdq *tdq) restart: switchcnt = tdq->tdq_switchcnt + tdq->tdq_oldswitchcnt; for (cg = tdq->tdq_cg; ; ) { - cpu = sched_highest(cg, mask, steal_thresh); + cpu = sched_highest(cg, &mask, steal_thresh); /* * We were assigned a thread but not preempted. Returning * 0 here will cause our caller to switch to it. @@ -1244,7 +1194,7 @@ sched_pickcpu(struct thread *td, int flags) struct cpu_group *cg, *ccg; struct td_sched *ts; struct tdq *tdq; - cpuset_t mask; + cpuset_t *mask; int cpu, pri, self, intr; self = PCPU_GET(cpuid); @@ -1287,14 +1237,14 @@ sched_pickcpu(struct thread *td, int flags) SCHED_AFFINITY(ts, CG_SHARE_L2)) { if (cg->cg_flags & CG_FLAG_THREAD) { /* Check all SMT threads for being idle. */ - for (cpu = CPU_FFS(&cg->cg_mask) - 1; ; cpu++) { + for (cpu = cg->cg_first; cpu <= cg->cg_last; cpu++) { if (CPU_ISSET(cpu, &cg->cg_mask) && TDQ_CPU(cpu)->tdq_lowpri < PRI_MIN_IDLE) break; - if (cpu >= mp_maxid) { - SCHED_STAT_INC(pickcpu_idle_affinity); - return (ts->ts_cpu); - } + } + if (cpu > cg->cg_last) { + SCHED_STAT_INC(pickcpu_idle_affinity); + return (ts->ts_cpu); } } else { SCHED_STAT_INC(pickcpu_idle_affinity); @@ -1321,7 +1271,7 @@ llc: if (ccg == cpu_top) ccg = NULL; cpu = -1; - mask = td->td_cpuset->cs_mask; + mask = &td->td_cpuset->cs_mask; pri = td->td_priority; /* * Try hard to keep interrupts within found LLC. Search the LLC for @@ -1931,7 +1881,7 @@ tdq_trysteal(struct tdq *tdq) spinlock_enter(); TDQ_UNLOCK(tdq); for (i = 1, cg = tdq->tdq_cg; ; ) { - cpu = sched_highest(cg, mask, steal_thresh); + cpu = sched_highest(cg, &mask, steal_thresh); /* * If a thread was added while interrupts were disabled don't * steal one here. @@ -3002,7 +2952,7 @@ sysctl_kern_sched_topology_spec_internal(struct sbuf *sb, struct cpu_group *cg, sbuf_printf(sb, "%*s ", indent, "", cg->cg_count, cpusetobj_strprint(cpusetbuf, &cg->cg_mask)); first = TRUE; - for (i = 0; i < MAXCPU; i++) { + for (i = cg->cg_first; i <= cg->cg_last; i++) { if (CPU_ISSET(i, &cg->cg_mask)) { if (!first) sbuf_printf(sb, ", "); diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 935fb6ee977c..bfe890d773f9 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -630,6 +630,17 @@ smp_rendezvous(void (* setup_func)(void *), static struct cpu_group group[MAXCPU * MAX_CACHE_LEVELS + 1]; +static void +smp_topo_fill(struct cpu_group *cg) +{ + int c; + + for (c = 0; c < cg->cg_children; c++) + smp_topo_fill(&cg->cg_child[c]); + cg->cg_first = CPU_FFS(&cg->cg_mask) - 1; + cg->cg_last = CPU_FLS(&cg->cg_mask) - 1; +} + struct cpu_group * smp_topo(void) { @@ -693,6 +704,7 @@ smp_topo(void) top = &top->cg_child[0]; top->cg_parent = NULL; } + smp_topo_fill(top); return (top); } diff --git a/sys/sys/smp.h b/sys/sys/smp.h index a971ffbbd91b..cee1199015a7 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -81,6 +81,8 @@ struct cpu_group { struct cpu_group *cg_child; /* Optional children groups. */ cpuset_t cg_mask; /* Mask of cpus in this group. */ int32_t cg_count; /* Count of cpus in this group. */ + int32_t cg_first; /* First cpu in this group. */ + int32_t cg_last; /* Last cpu in this group. */ int16_t cg_children; /* Number of children groups. */ int8_t cg_level; /* Shared cache level. */ int8_t cg_flags; /* Traversal modifiers. */ From owner-dev-commits-src-all@freebsd.org Sat Aug 28 02:21:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AB88366BDA6; Sat, 28 Aug 2021 02:21: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 4GxL1Q3qCYz4ZZk; Sat, 28 Aug 2021 02:21: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 6877F6AE0; Sat, 28 Aug 2021 02:21: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 17S2LU4S052164; Sat, 28 Aug 2021 02:21:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S2LUPf052163; Sat, 28 Aug 2021 02:21:30 GMT (envelope-from git) Date: Sat, 28 Aug 2021 02:21:30 GMT Message-Id: <202108280221.17S2LUPf052163@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: 18bc112f63b6 - stable/13 - sched_ule(4): Reduce duplicate search for load. 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: 18bc112f63b61c6f912419cb613bb92959216dab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 02:21:30 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=18bc112f63b61c6f912419cb613bb92959216dab commit 18bc112f63b61c6f912419cb613bb92959216dab Author: Alexander Motin AuthorDate: 2021-08-02 02:07:51 +0000 Commit: Alexander Motin CommitDate: 2021-08-28 02:17:55 +0000 sched_ule(4): Reduce duplicate search for load. When sched_highest() called for some CPU group returns nothing, idle thread calls it for the parent CPU group. But the parent CPU group also includes the CPU group we've just searched, and unless there is a race going on, it is unlikely we find anything new this time. Avoid the double search in case of parent group having only two sub- groups (the most prominent case). Instead of escalating to the parent group run the next search over the sibling subgroup and escalate two levels up after if that fail too. In case of more than two siblings the difference is less significant, while searching the parent group can result in better decision if we find several candidate CPUs. On 2-socket 40-core Xeon system I am measuring ~25% reduction of CPU time spent inside cpu_search_highest() in both SMT (2x20x2) and non- SMT (2x20) cases. MFC after: 1 month (cherry picked from commit 2668bb2add8d11c56524ce9014b510412f8f6aa9) --- sys/kern/sched_ule.c | 63 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 6e9ef73efe99..55af36f40bc1 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -933,10 +933,10 @@ tdq_move(struct tdq *from, struct tdq *to) static int tdq_idled(struct tdq *tdq) { - struct cpu_group *cg; + struct cpu_group *cg, *parent; struct tdq *steal; cpuset_t mask; - int cpu, switchcnt; + int cpu, switchcnt, goup; if (smp_started == 0 || steal_idle == 0 || tdq->tdq_cg == NULL) return (1); @@ -944,7 +944,7 @@ tdq_idled(struct tdq *tdq) CPU_CLR(PCPU_GET(cpuid), &mask); restart: switchcnt = tdq->tdq_switchcnt + tdq->tdq_oldswitchcnt; - for (cg = tdq->tdq_cg; ; ) { + for (cg = tdq->tdq_cg, goup = 0; ; ) { cpu = sched_highest(cg, &mask, steal_thresh); /* * We were assigned a thread but not preempted. Returning @@ -952,10 +952,29 @@ tdq_idled(struct tdq *tdq) */ if (tdq->tdq_load) return (0); + + /* + * We found no CPU to steal from in this group. Escalate to + * the parent and repeat. But if parent has only two children + * groups we can avoid searching this group again by searching + * the other one specifically and then escalating two levels. + */ if (cpu == -1) { - cg = cg->cg_parent; - if (cg == NULL) + if (goup) { + cg = cg->cg_parent; + goup = 0; + } + parent = cg->cg_parent; + if (parent == NULL) return (1); + if (parent->cg_children == 2) { + if (cg == &parent->cg_child[0]) + cg = &parent->cg_child[1]; + else + cg = &parent->cg_child[0]; + goup = 1; + } else + cg = parent; continue; } steal = TDQ_CPU(cpu); @@ -1868,10 +1887,10 @@ lend: static void tdq_trysteal(struct tdq *tdq) { - struct cpu_group *cg; + struct cpu_group *cg, *parent; struct tdq *steal; cpuset_t mask; - int cpu, i; + int cpu, i, goup; if (smp_started == 0 || trysteal_limit == 0 || tdq->tdq_cg == NULL) return; @@ -1880,7 +1899,7 @@ tdq_trysteal(struct tdq *tdq) /* We don't want to be preempted while we're iterating. */ spinlock_enter(); TDQ_UNLOCK(tdq); - for (i = 1, cg = tdq->tdq_cg; ; ) { + for (i = 1, cg = tdq->tdq_cg, goup = 0; ; ) { cpu = sched_highest(cg, &mask, steal_thresh); /* * If a thread was added while interrupts were disabled don't @@ -1890,13 +1909,35 @@ tdq_trysteal(struct tdq *tdq) TDQ_LOCK(tdq); break; } + + /* + * We found no CPU to steal from in this group. Escalate to + * the parent and repeat. But if parent has only two children + * groups we can avoid searching this group again by searching + * the other one specifically and then escalating two levels. + */ if (cpu == -1) { - i++; - cg = cg->cg_parent; - if (cg == NULL || i > trysteal_limit) { + if (goup) { + cg = cg->cg_parent; + goup = 0; + } + if (++i > trysteal_limit) { + TDQ_LOCK(tdq); + break; + } + parent = cg->cg_parent; + if (parent == NULL) { TDQ_LOCK(tdq); break; } + if (parent->cg_children == 2) { + if (cg == &parent->cg_child[0]) + cg = &parent->cg_child[1]; + else + cg = &parent->cg_child[0]; + goup = 1; + } else + cg = parent; continue; } steal = TDQ_CPU(cpu); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 02:21:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0C00166BFA6; Sat, 28 Aug 2021 02:21: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 4GxL1R5mSgz4ZgX; Sat, 28 Aug 2021 02:21: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 8F5C0684B; Sat, 28 Aug 2021 02:21: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 17S2LVXt052188; Sat, 28 Aug 2021 02:21:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S2LVT7052187; Sat, 28 Aug 2021 02:21:31 GMT (envelope-from git) Date: Sat, 28 Aug 2021 02:21:31 GMT Message-Id: <202108280221.17S2LVT7052187@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: 97e945e0fffc - stable/13 - sched_ule(4): Use trylock when stealing load. 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: 97e945e0fffc18a06cd39cf6220dfaca32a25bbb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 02:21:32 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=97e945e0fffc18a06cd39cf6220dfaca32a25bbb commit 97e945e0fffc18a06cd39cf6220dfaca32a25bbb Author: Alexander Motin AuthorDate: 2021-08-02 02:42:01 +0000 Commit: Alexander Motin CommitDate: 2021-08-28 02:17:56 +0000 sched_ule(4): Use trylock when stealing load. On some load patterns it is possible for several CPUs to try steal thread from the same CPU despite randomization introduced. It may cause significant lock contention when holding one queue lock idle thread tries to acquire another one. Use of trylock on the remote queue allows both reduce the contention and handle lock ordering easier. If we can't get lock inside tdq_trysteal() we just return, allowing tdq_idled() handle it. If it happens in tdq_idled(), then we repeat search for load skipping this CPU. On 2-socket 80-thread Xeon system I am observing dramatic reduction of the lock spinning time when doing random uncached 4KB reads from 12 ZVOLs, while IOPS increase from 327K to 403K. MFC after: 1 month (cherry picked from commit 8bb173fb5bc33a02d5a4670c9a60bba0ece07bac) --- sys/kern/sched_ule.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 55af36f40bc1..3185ae3a6e1f 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -300,6 +300,8 @@ static struct tdq tdq_cpu; #define TDQ_LOCK_ASSERT(t, type) mtx_assert(TDQ_LOCKPTR((t)), (type)) #define TDQ_LOCK(t) mtx_lock_spin(TDQ_LOCKPTR((t))) #define TDQ_LOCK_FLAGS(t, f) mtx_lock_spin_flags(TDQ_LOCKPTR((t)), (f)) +#define TDQ_TRYLOCK(t) mtx_trylock_spin(TDQ_LOCKPTR((t))) +#define TDQ_TRYLOCK_FLAGS(t, f) mtx_trylock_spin_flags(TDQ_LOCKPTR((t)), (f)) #define TDQ_UNLOCK(t) mtx_unlock_spin(TDQ_LOCKPTR((t))) #define TDQ_LOCKPTR(t) ((struct mtx *)(&(t)->tdq_lock)) @@ -989,13 +991,22 @@ tdq_idled(struct tdq *tdq) if (steal->tdq_load < steal_thresh || steal->tdq_transferable == 0) goto restart; - tdq_lock_pair(tdq, steal); /* - * We were assigned a thread while waiting for the locks. - * Switch to it now instead of stealing a thread. + * 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 so continue searching. */ - if (tdq->tdq_load) - break; + TDQ_LOCK(tdq); + if (tdq->tdq_load > 0) { + mi_switch(SW_VOL | SWT_IDLE); + return (0); + } + if (TDQ_TRYLOCK_FLAGS(steal, MTX_DUPOK) == 0) { + TDQ_UNLOCK(tdq); + CPU_CLR(cpu, &mask); + continue; + } /* * The data returned by sched_highest() is stale and * the chosen CPU no longer has an eligible thread, or @@ -1948,18 +1959,18 @@ tdq_trysteal(struct tdq *tdq) if (steal->tdq_load < steal_thresh || steal->tdq_transferable == 0) continue; - tdq_lock_pair(tdq, steal); /* - * If we get to this point, unconditonally exit the loop - * to bound the time spent in the critcal section. - * - * If a thread was added while interrupts were disabled don't - * steal one here. + * 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. */ - if (tdq->tdq_load > 0) { - TDQ_UNLOCK(steal); + TDQ_LOCK(tdq); + if (tdq->tdq_load > 0) + break; + if (TDQ_TRYLOCK_FLAGS(steal, MTX_DUPOK) == 0) break; - } /* * The data returned by sched_highest() is stale and * the chosen CPU no longer has an eligible thread. From owner-dev-commits-src-all@freebsd.org Sat Aug 28 02:21:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 293C466BDB3; Sat, 28 Aug 2021 02:21: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 4GxL1S5wNxz4ZVL; Sat, 28 Aug 2021 02:21: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 AEF60684D; Sat, 28 Aug 2021 02:21: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 17S2LWst052212; Sat, 28 Aug 2021 02:21:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S2LW62052211; Sat, 28 Aug 2021 02:21:32 GMT (envelope-from git) Date: Sat, 28 Aug 2021 02:21:32 GMT Message-Id: <202108280221.17S2LW62052211@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: 57cf5a9f0bec - stable/13 - sched_ule(4): Pre-seed sched_random(). 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: 57cf5a9f0becc6d4b7cbdaad5be10ab28859b5ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 02:21:33 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=57cf5a9f0becc6d4b7cbdaad5be10ab28859b5ad commit 57cf5a9f0becc6d4b7cbdaad5be10ab28859b5ad Author: Alexander Motin AuthorDate: 2021-08-02 14:50:34 +0000 Commit: Alexander Motin CommitDate: 2021-08-28 02:17:56 +0000 sched_ule(4): Pre-seed sched_random(). I don't think it changes anything, but why not. While there, make cpu_search_highest() use all 8 lower load bits for noise, since it does not use cs_prefer and the code is not shared with cpu_search_lowest() any more. MFC after: 1 month (cherry picked from commit ca34553b6f631ec4ec5ae9f3825e3196e172c35d) --- sys/kern/sched_ule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 3185ae3a6e1f..60f92a16f2e9 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -739,7 +739,7 @@ cpu_search_highest(const struct cpu_group *cg, const struct cpu_search *s, if (l < s->cs_limit || !tdq->tdq_transferable || !CPU_ISSET(c, s->cs_mask)) continue; - load -= sched_random() % 128; + load -= sched_random() % 256; if (load > bload) { bload = load; r->cs_cpu = c; @@ -1416,6 +1416,7 @@ sched_setup_smp(void) tdq->tdq_cg = smp_topo_find(cpu_top, i); if (tdq->tdq_cg == NULL) panic("Can't find cpu group for %d\n", i); + DPCPU_ID_SET(i, randomval, i * 69069 + 5); } PCPU_SET(sched, DPCPU_PTR(tdq)); balance_tdq = TDQ_SELF(); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 05:44:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB95B66E719; Sat, 28 Aug 2021 05:44: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 4GxQWm5GbJz3nYT; Sat, 28 Aug 2021 05:44: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 7E1CC113ED; Sat, 28 Aug 2021 05:44: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 17S5iaTT023299; Sat, 28 Aug 2021 05:44:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S5iadk023298; Sat, 28 Aug 2021 05:44:36 GMT (envelope-from git) Date: Sat, 28 Aug 2021 05:44:36 GMT Message-Id: <202108280544.17S5iadk023298@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: d54fdcd59e23 - stable/13 - loader: FB console does leave garbage on screen while scrolling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d54fdcd59e23defaf5f6b458701c360c9b2a5dd8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 05:44:37 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=d54fdcd59e23defaf5f6b458701c360c9b2a5dd8 commit d54fdcd59e23defaf5f6b458701c360c9b2a5dd8 Author: Toomas Soome AuthorDate: 2021-08-21 11:25:36 +0000 Commit: Toomas Soome CommitDate: 2021-08-28 05:37:03 +0000 loader: FB console does leave garbage on screen while scrolling Scrolling screen will leave "trail" of chars from first column. Apparently caused by cursor location mismanagement. Make sure we do not [attempt to] set cursor out of the screen. (cherry picked from commit e5a50b03297fa09652b3cf319bc6e863392554e0) --- stand/common/gfx_fb.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index 92af49913748..71c162a77f27 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -976,20 +976,26 @@ gfx_fb_fill(void *arg, const teken_rect_t *r, teken_char_t c, } static void -gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on) +gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *pos, bool on) { unsigned x, y, width, height; const uint8_t *glyph; + teken_pos_t p; int idx; - idx = p->tp_col + p->tp_row * state->tg_tp.tp_col; + p = *pos; + if (p.tp_col >= state->tg_tp.tp_col) + p.tp_col = state->tg_tp.tp_col - 1; + if (p.tp_row >= state->tg_tp.tp_row) + p.tp_row = state->tg_tp.tp_row - 1; + idx = p.tp_col + p.tp_row * state->tg_tp.tp_col; if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row) return; width = state->tg_font.vf_width; height = state->tg_font.vf_height; - x = state->tg_origin.tp_col + p->tp_col * width; - y = state->tg_origin.tp_row + p->tp_row * height; + x = state->tg_origin.tp_col + p.tp_col * width; + y = state->tg_origin.tp_row + p.tp_row * height; /* * Save original display content to preserve image data. @@ -1017,7 +1023,7 @@ gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on) if (state->tg_cursor_image != NULL && gfxfb_blt(state->tg_cursor_image, GfxFbBltBufferToVideo, 0, 0, x, y, width, height, 0) == 0) { - state->tg_cursor = *p; + state->tg_cursor = p; return; } } @@ -1025,9 +1031,9 @@ gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on) glyph = font_lookup(&state->tg_font, screen_buffer[idx].c, &screen_buffer[idx].a); gfx_bitblt_bitmap(state, glyph, &screen_buffer[idx].a, 0xff, on); - gfx_fb_printchar(state, p); + gfx_fb_printchar(state, &p); - state->tg_cursor = *p; + state->tg_cursor = p; } void From owner-dev-commits-src-all@freebsd.org Sat Aug 28 08:21:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1CA2C66FFB8; Sat, 28 Aug 2021 08:21: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 4GxV0D4xtzz3F1y; Sat, 28 Aug 2021 08:21: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 8F34D1395C; Sat, 28 Aug 2021 08:21: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 17S8L0tO033573; Sat, 28 Aug 2021 08:21:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S8L0Ee033572; Sat, 28 Aug 2021 08:21:00 GMT (envelope-from git) Date: Sat, 28 Aug 2021 08:21:00 GMT Message-Id: <202108280821.17S8L0Ee033572@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 6558f29ac87a - stable/13 - fstyp: add BeFS support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6558f29ac87acae20689e1f0e950afdc9f37e335 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 08:21:01 -0000 The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=6558f29ac87acae20689e1f0e950afdc9f37e335 commit 6558f29ac87acae20689e1f0e950afdc9f37e335 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-17 15:07:31 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-28 08:15:53 +0000 fstyp: add BeFS support A simple support for detecting BeFS (BeOS) filesystem Submitted by: Miguel Gocobachi Differential Revision: https://reviews.freebsd.org/D29917 (cherry picked from commit 0e92585cde5101506720ca1b904372317b7d84b6) --- usr.sbin/fstyp/Makefile | 2 +- usr.sbin/fstyp/befs.c | 70 +++++++++++++++++++++++++++++++++++++ usr.sbin/fstyp/fstyp.8 | 4 ++- usr.sbin/fstyp/fstyp.c | 1 + usr.sbin/fstyp/fstyp.h | 1 + usr.sbin/fstyp/tests/Makefile | 1 + usr.sbin/fstyp/tests/befs.img.bz2 | Bin 0 -> 132 bytes usr.sbin/fstyp/tests/fstyp_test.sh | 11 ++++++ 8 files changed, 88 insertions(+), 2 deletions(-) diff --git a/usr.sbin/fstyp/Makefile b/usr.sbin/fstyp/Makefile index 14b5d9dfd9c3..384e2f7dee60 100644 --- a/usr.sbin/fstyp/Makefile +++ b/usr.sbin/fstyp/Makefile @@ -3,7 +3,7 @@ .include PROG= fstyp -SRCS= apfs.c cd9660.c exfat.c ext2fs.c fstyp.c geli.c hammer.c \ +SRCS= apfs.c befs.c cd9660.c exfat.c ext2fs.c fstyp.c geli.c hammer.c \ hammer2.c hfsplus.c msdosfs.c ntfs.c ufs.c .if ${MK_ZFS} != "no" diff --git a/usr.sbin/fstyp/befs.c b/usr.sbin/fstyp/befs.c new file mode 100644 index 000000000000..352fe7d4c296 --- /dev/null +++ b/usr.sbin/fstyp/befs.c @@ -0,0 +1,70 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Miguel Gocobachi + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include "fstyp.h" + +#define B_OS_NAME_LENGTH 32 +#define BEFS_BLOCK_OFFSET 512 +#define BEFS_SUPER_BLOCK_MAGIC1 0x42465331 + +struct disk_super_block { + char name[B_OS_NAME_LENGTH]; + int32_t magic1; +}; + +int +fstyp_befs(FILE *fp, char *label, size_t size) +{ + struct disk_super_block *volume; + + volume = read_buf(fp, BEFS_BLOCK_OFFSET, sizeof(*volume)); + + if (volume == NULL) { + return (1); + } + + if (volume->magic1 == BEFS_SUPER_BLOCK_MAGIC1) { + strlcpy(label, volume->name, size); + free(volume); + + return (0); + } + + free(volume); + + return (1); +} diff --git a/usr.sbin/fstyp/fstyp.8 b/usr.sbin/fstyp/fstyp.8 index d587e331490f..22d41628d8d5 100644 --- a/usr.sbin/fstyp/fstyp.8 +++ b/usr.sbin/fstyp/fstyp.8 @@ -42,7 +42,7 @@ The .Nm utility is used to determine the filesystem type on a given device. -It can recognize ISO-9660, exFAT, Ext2, FAT, NTFS, and UFS filesystems. +It can recognize BeFS (BeOS), ISO-9660, exFAT, Ext2, FAT, NTFS, and UFS filesystems. When the .Fl u flag is specified, @@ -59,6 +59,8 @@ The filesystem name is printed to the standard output as, respectively: .Bl -item -offset indent -compact .It +befs +.It cd9660 .It exfat diff --git a/usr.sbin/fstyp/fstyp.c b/usr.sbin/fstyp/fstyp.c index 46b5d6100011..b39277914aed 100644 --- a/usr.sbin/fstyp/fstyp.c +++ b/usr.sbin/fstyp/fstyp.c @@ -64,6 +64,7 @@ static struct { char *precache_encoding; } fstypes[] = { { "apfs", &fstyp_apfs, true, NULL }, + { "befs", &fstyp_befs, false, NULL }, { "cd9660", &fstyp_cd9660, false, NULL }, { "exfat", &fstyp_exfat, false, EXFAT_ENC }, { "ext2fs", &fstyp_ext2fs, false, NULL }, diff --git a/usr.sbin/fstyp/fstyp.h b/usr.sbin/fstyp/fstyp.h index 73861d7fdc0d..f11d66f5ffc2 100644 --- a/usr.sbin/fstyp/fstyp.h +++ b/usr.sbin/fstyp/fstyp.h @@ -50,6 +50,7 @@ char *checked_strdup(const char *s); void rtrim(char *label, size_t size); int fstyp_apfs(FILE *fp, char *label, size_t size); +int fstyp_befs(FILE *fp, char *label, size_t size); int fstyp_cd9660(FILE *fp, char *label, size_t size); int fstyp_exfat(FILE *fp, char *label, size_t size); int fstyp_ext2fs(FILE *fp, char *label, size_t size); diff --git a/usr.sbin/fstyp/tests/Makefile b/usr.sbin/fstyp/tests/Makefile index 9c4624af3a4c..c821bc9b45eb 100644 --- a/usr.sbin/fstyp/tests/Makefile +++ b/usr.sbin/fstyp/tests/Makefile @@ -4,6 +4,7 @@ PACKAGE= tests ATF_TESTS_SH= fstyp_test +${PACKAGE}FILES+= befs.img.bz2 ${PACKAGE}FILES+= dfr-01-xfat.img.bz2 ${PACKAGE}FILES+= ext2.img.bz2 ${PACKAGE}FILES+= ext3.img.bz2 diff --git a/usr.sbin/fstyp/tests/befs.img.bz2 b/usr.sbin/fstyp/tests/befs.img.bz2 new file mode 100644 index 000000000000..c2a6693216d5 Binary files /dev/null and b/usr.sbin/fstyp/tests/befs.img.bz2 differ diff --git a/usr.sbin/fstyp/tests/fstyp_test.sh b/usr.sbin/fstyp/tests/fstyp_test.sh index 8f76424f5f75..81a549629dd7 100755 --- a/usr.sbin/fstyp/tests/fstyp_test.sh +++ b/usr.sbin/fstyp/tests/fstyp_test.sh @@ -27,6 +27,16 @@ # $FreeBSD$ +atf_test_case befs +befs_head() { + atf_set "descr" "fstyp(8) can detect BeFS and label filesystem" +} +befs_body() { + bzcat $(atf_get_srcdir)/befs.img.bz2 > befs.img + atf_check -s exit:0 -o inline:"befs\n" fstyp befs.img + atf_check -s exit:0 -o inline:"befs BeFS\n" fstyp -l befs.img +} + atf_test_case cd9660 cd9660_head() { atf_set "descr" "fstyp(8) should detect cd9660 filesystems" @@ -257,6 +267,7 @@ zeros_body() { atf_init_test_cases() { + atf_add_test_case befs atf_add_test_case cd9660 atf_add_test_case cd9660_label atf_add_test_case dir From owner-dev-commits-src-all@freebsd.org Sat Aug 28 08:21:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44003670588; Sat, 28 Aug 2021 08:21: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 4GxV0F69vQz3F8g; Sat, 28 Aug 2021 08:21: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 B55C913BB4; Sat, 28 Aug 2021 08:21: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 17S8L1UJ033599; Sat, 28 Aug 2021 08:21:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S8L18o033598; Sat, 28 Aug 2021 08:21:01 GMT (envelope-from git) Date: Sat, 28 Aug 2021 08:21:01 GMT Message-Id: <202108280821.17S8L18o033598@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: e5db193a6579 - stable/13 - style.9: remove an outdated comment about indent(1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e5db193a65798809ab09bb97b0d2c9bcba3c7eab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 08:21:02 -0000 The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=e5db193a65798809ab09bb97b0d2c9bcba3c7eab commit e5db193a65798809ab09bb97b0d2c9bcba3c7eab Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-17 15:56:41 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-28 08:16:33 +0000 style.9: remove an outdated comment about indent(1) (cherry picked from commit f49931c1423e1c9454214f82bbb3ec30d0fee57d) --- share/man/man9/style.9 | 3 --- 1 file changed, 3 deletions(-) diff --git a/share/man/man9/style.9 b/share/man/man9/style.9 index 10ca64cde817..16782fe22197 100644 --- a/share/man/man9/style.9 +++ b/share/man/man9/style.9 @@ -718,9 +718,6 @@ scope is undesirable and will elicit complaints from a good compiler. Casts and .Ic sizeof Ns 's are not followed by a space. -Note that -.Xr indent 1 -does not understand this rule. .Ic sizeof Ns 's are written with parenthesis always. The redundant parenthesis rules do not apply to From owner-dev-commits-src-all@freebsd.org Sat Aug 28 08:21:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 66CF4670492; Sat, 28 Aug 2021 08:21: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 4GxV0H1Fp8z3FGP; Sat, 28 Aug 2021 08:21:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5CCE13C86; Sat, 28 Aug 2021 08:21: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 17S8L2ku033623; Sat, 28 Aug 2021 08:21:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S8L2at033622; Sat, 28 Aug 2021 08:21:02 GMT (envelope-from git) Date: Sat, 28 Aug 2021 08:21:02 GMT Message-Id: <202108280821.17S8L2at033622@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: a346729d1c3f - stable/13 - mount.h: improve a comment about flags MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a346729d1c3f228a8430fe6fb6c44b7fe19287fb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 08:21:03 -0000 The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=a346729d1c3f228a8430fe6fb6c44b7fe19287fb commit a346729d1c3f228a8430fe6fb6c44b7fe19287fb Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-14 20:07:09 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-28 08:16:52 +0000 mount.h: improve a comment about flags (cherry picked from commit c66e9307ea9520f3d6e4d38dc842a99a31ae80bf) --- sys/sys/mount.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/sys/mount.h b/sys/sys/mount.h index cd0d0071aa1b..aa876cdb00e9 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -378,9 +378,7 @@ struct mntoptnames { #define MNT_EXTLSCERTUSER 0x0000010000000000ULL /* require TLS with user cert */ /* - * Flags set by internal operations, - * but visible to the user. - * XXX some of these are not quite right.. (I've never seen the root flag set) + * Flags set by internal operations, but visible to the user. */ #define MNT_LOCAL 0x0000000000001000ULL /* filesystem is stored locally */ #define MNT_QUOTA 0x0000000000002000ULL /* quotas are enabled on fs */ From owner-dev-commits-src-all@freebsd.org Sat Aug 28 08:21:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1B7D67042A; Sat, 28 Aug 2021 08:21: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 4GxV0J25YRz3FCs; Sat, 28 Aug 2021 08:21: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 044FB13642; Sat, 28 Aug 2021 08:21: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 17S8L3tS033647; Sat, 28 Aug 2021 08:21:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S8L3AJ033646; Sat, 28 Aug 2021 08:21:03 GMT (envelope-from git) Date: Sat, 28 Aug 2021 08:21:03 GMT Message-Id: <202108280821.17S8L3AJ033646@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: b25642d653ba - stable/13 - sh: fix NO_HISTORY build MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b25642d653bab04fa6f5190b54d3a205cdc5e508 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 08:21:04 -0000 The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=b25642d653bab04fa6f5190b54d3a205cdc5e508 commit b25642d653bab04fa6f5190b54d3a205cdc5e508 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-18 20:40:39 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-28 08:17:29 +0000 sh: fix NO_HISTORY build (cherry picked from commit 35b253d9d238c46a710a0cd7ba027ec87ba7c8ba) --- bin/sh/histedit.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index ba2bec357181..8d9e9fc64db3 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -506,27 +506,6 @@ bindcmd(int argc, char **argv) return ret; } -#else -#include "error.h" - -int -histcmd(int argc __unused, char **argv __unused) -{ - - error("not compiled with history support"); - /*NOTREACHED*/ - return (0); -} - -int -bindcmd(int argc __unused, char **argv __unused) -{ - - error("not compiled with line editing support"); - return (0); -} -#endif - /* * Comparator function for qsort(). The use of curpos here is to skip * characters that we already know to compare equal (common prefix). @@ -647,3 +626,24 @@ sh_complete(EditLine *sel, int ch __unused) L" \t\n\"\\'`@$><=;|&{(", NULL, NULL, (size_t)100, NULL, &((int) {0}), NULL, NULL, FN_QUOTE_MATCH); } + +#else +#include "error.h" + +int +histcmd(int argc __unused, char **argv __unused) +{ + + error("not compiled with history support"); + /*NOTREACHED*/ + return (0); +} + +int +bindcmd(int argc __unused, char **argv __unused) +{ + + error("not compiled with line editing support"); + return (0); +} +#endif From owner-dev-commits-src-all@freebsd.org Sat Aug 28 08:21:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D3BEB670237; Sat, 28 Aug 2021 08:21: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 4GxV0K2Zfsz3FCw; Sat, 28 Aug 2021 08:21: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 21019134EC; Sat, 28 Aug 2021 08:21: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 17S8L4Sp033671; Sat, 28 Aug 2021 08:21:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S8L42i033670; Sat, 28 Aug 2021 08:21:04 GMT (envelope-from git) Date: Sat, 28 Aug 2021 08:21:04 GMT Message-Id: <202108280821.17S8L42i033670@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: ff5f61e07d70 - stable/13 - ls: prevent no-color build from complaining when COLORTERM is non-empty MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ff5f61e07d70dda34afeac4505db28d72dcad2b1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 08:21:06 -0000 The branch stable/13 has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=ff5f61e07d70dda34afeac4505db28d72dcad2b1 commit ff5f61e07d70dda34afeac4505db28d72dcad2b1 Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-18 20:47:37 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-28 08:17:55 +0000 ls: prevent no-color build from complaining when COLORTERM is non-empty (cherry picked from commit ced2dcadccfcff8f7991b3cb5f6f70d6710eadfb) --- bin/ls/ls.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 338b3d1d2a26..92575711251d 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -105,9 +105,7 @@ static void traverse(int, char **, int); static const struct option long_opts[] = { -#ifdef COLORLS {"color", optional_argument, NULL, COLOR_OPT}, -#endif {NULL, no_argument, NULL, 0} }; @@ -448,8 +446,8 @@ main(int argc, char *argv[]) case 'y': f_samesort = 1; break; -#ifdef COLORLS case COLOR_OPT: +#ifdef COLORLS if (optarg == NULL || do_color_always(optarg)) colorflag = COLORFLAG_ALWAYS; else if (do_color_auto(optarg)) @@ -460,6 +458,8 @@ main(int argc, char *argv[]) errx(2, "unsupported --color value '%s' (must be always, auto, or never)", optarg); break; +#else + warnx("color support not compiled in"); #endif default: case '?': @@ -503,8 +503,6 @@ main(int argc, char *argv[]) f_color = 1; explicitansi = true; } -#else - warnx("color support not compiled in"); #endif /*COLORLS*/ } From owner-dev-commits-src-all@freebsd.org Sat Aug 28 10:16:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2714671CC2; Sat, 28 Aug 2021 10:16: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 4GxXYg5K4Mz4X5M; Sat, 28 Aug 2021 10:16:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9EE4A1530B; Sat, 28 Aug 2021 10:16: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 17SAGdKq084878; Sat, 28 Aug 2021 10:16:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SAGdao084877; Sat, 28 Aug 2021 10:16:39 GMT (envelope-from git) Date: Sat, 28 Aug 2021 10:16:39 GMT Message-Id: <202108281016.17SAGdao084877@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 0e98ea64237d - stable/13 - loader: loader_lua can run command_more twice MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0e98ea64237d3050d608a37652c98dc9823dce14 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 10:16:39 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=0e98ea64237d3050d608a37652c98dc9823dce14 commit 0e98ea64237d3050d608a37652c98dc9823dce14 Author: Toomas Soome AuthorDate: 2021-08-21 18:17:18 +0000 Commit: Toomas Soome CommitDate: 2021-08-28 07:38:35 +0000 loader: loader_lua can run command_more twice When we quit pager, the return value 1 is returned and command_more() interprets it as error. when lua loader gets error from command, it will try to interpret it once more, so we get the same file shown once more. There is no reason why we should return error from command_more(). (cherry picked from commit 7b0d05d56dfaad4e1d5a19727e34252072913d17) --- stand/common/commands.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stand/common/commands.c b/stand/common/commands.c index 4c1c9b2b6a86..9f7252014d87 100644 --- a/stand/common/commands.c +++ b/stand/common/commands.c @@ -484,10 +484,7 @@ command_more(int argc, char *argv[]) } pager_close(); - if (res == 0) - return (CMD_OK); - else - return (CMD_ERROR); + return (CMD_OK); } static int From owner-dev-commits-src-all@freebsd.org Sat Aug 28 13:38:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 983CF67499A; Sat, 28 Aug 2021 13:38: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 4Gxd2p3fF1z4c3P; Sat, 28 Aug 2021 13:38: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 60EFE1796C; Sat, 28 Aug 2021 13:38: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 17SDcgBD054622; Sat, 28 Aug 2021 13:38:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SDcgnx054621; Sat, 28 Aug 2021 13:38:42 GMT (envelope-from git) Date: Sat, 28 Aug 2021 13:38:42 GMT Message-Id: <202108281338.17SDcgnx054621@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 4544929cb55e - main - Silence unused parameter warnings in fspacectl(2) bootstrap stub MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4544929cb55e0cb8496ec23e565aab8251e22e81 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 13:38:42 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=4544929cb55e0cb8496ec23e565aab8251e22e81 commit 4544929cb55e0cb8496ec23e565aab8251e22e81 Author: Dimitry Andric AuthorDate: 2021-08-28 13:37:24 +0000 Commit: Dimitry Andric CommitDate: 2021-08-28 13:37:43 +0000 Silence unused parameter warnings in fspacectl(2) bootstrap stub While here, replace spaces with tabs and add a newline at EOF. Fixes: 5425ba8332571e57f9fe623346cb9d83293264d4 MFC after: 3 days --- tools/build/fspacectl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/build/fspacectl.c b/tools/build/fspacectl.c index c17802c51e01..13abca23a318 100644 --- a/tools/build/fspacectl.c +++ b/tools/build/fspacectl.c @@ -36,9 +36,10 @@ __FBSDID("$FreeBSD$"); * This is currently a stub implementation of fspacectl(2). */ int -fspacectl(int fd, int cmd, const struct spacectl_range *rqsr, int flags, - struct spacectl_range *rmsr) +fspacectl(int fd __unused, int cmd __unused, + const struct spacectl_range *rqsr __unused, int flags __unused, + struct spacectl_range *rmsr __unused) { - errno = ENOSYS; - return (-1); -} \ No newline at end of file + errno = ENOSYS; + return (-1); +} From owner-dev-commits-src-all@freebsd.org Sat Aug 28 14:12:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DADD5674FF2; Sat, 28 Aug 2021 14:12: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 4GxdnD5SwQz4qsn; Sat, 28 Aug 2021 14:12: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 A13231875C; Sat, 28 Aug 2021 14:12: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 17SEC0kJ008303; Sat, 28 Aug 2021 14:12:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SEC01m008302; Sat, 28 Aug 2021 14:12:00 GMT (envelope-from git) Date: Sat, 28 Aug 2021 14:12:00 GMT Message-Id: <202108281412.17SEC01m008302@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 3ae61b972b04 - main - sh: improve emacs mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3ae61b972b042f2ea35d1670bd2ce5820400d27b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 14:12:01 -0000 The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=3ae61b972b042f2ea35d1670bd2ce5820400d27b commit 3ae61b972b042f2ea35d1670bd2ce5820400d27b Author: Baptiste Daroussin AuthorDate: 2021-08-28 12:59:53 +0000 Commit: Baptiste Daroussin CommitDate: 2021-08-28 14:11:57 +0000 sh: improve emacs mode in emacs mode ^W should delete the previous word by default Note that upstreaming this change directly into libedit is in process. Reported by: manu Reviewed by: jills, pstef, manu Differential Revision: https://reviews.freebsd.org/D29493 --- bin/sh/histedit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index bd82016c33cb..b680a99c4ace 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -204,6 +204,7 @@ bad: else if (Eflag) { el_set(el, EL_EDITOR, "emacs"); el_set(el, EL_BIND, "^R", "em-inc-search-prev", NULL); + el_set(el, EL_BIND, "^W", "ed-delete-prev-word", NULL); } el_set(el, EL_BIND, "^I", "sh-complete", NULL); el_source(el, NULL); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 16:28:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6F4B26766D7; Sat, 28 Aug 2021 16:28: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 4GxhqD2NQFz4j6M; Sat, 28 Aug 2021 16:28: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 3AEF01A6C7; Sat, 28 Aug 2021 16:28: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 17SGSu7W082308; Sat, 28 Aug 2021 16:28:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGSut3082307; Sat, 28 Aug 2021 16:28:56 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:28:56 GMT Message-Id: <202108281628.17SGSut3082307@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 16b71d98d96a - main - ocs_fs(4): Fix some common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 16b71d98d96a3a9a2ac666440aa80f12d478959d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:28:56 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=16b71d98d96a3a9a2ac666440aa80f12d478959d commit 16b71d98d96a3a9a2ac666440aa80f12d478959d Author: Gordon Bergling AuthorDate: 2021-08-28 16:24:08 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:24:08 +0000 ocs_fs(4): Fix some common typos in source code comments - s/transfered/transferred/ - s/associted/associated/ MFC after: 3 days --- sys/dev/ocs_fc/ocs_gendump.c | 2 +- sys/dev/ocs_fc/ocs_hw_queues.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/ocs_fc/ocs_gendump.c b/sys/dev/ocs_fc/ocs_gendump.c index d24870f39668..83155d90c3a3 100644 --- a/sys/dev/ocs_fc/ocs_gendump.c +++ b/sys/dev/ocs_fc/ocs_gendump.c @@ -234,7 +234,7 @@ ocs_fdb_dump(ocs_t *ocs) * @par Description * This function creates a DMA buffer to hold a Lancer dump, * sets the dump location to point to that buffer, then calls - * ocs_gen_dump to cause a dump to be transfered to the buffer. + * ocs_gen_dump to cause a dump to be transferred to the buffer. * After the dump is complete it copies the dump to the provided * user space buffer. * diff --git a/sys/dev/ocs_fc/ocs_hw_queues.c b/sys/dev/ocs_fc/ocs_hw_queues.c index 242b2f0df115..704eb951d2b7 100644 --- a/sys/dev/ocs_fc/ocs_hw_queues.c +++ b/sys/dev/ocs_fc/ocs_hw_queues.c @@ -966,7 +966,7 @@ hw_queue_teardown(ocs_hw_t *hw) * If wq_steering is OCS_HW_WQ_STEERING_REQUEST, then a WQ from the EQ that * the IO request came in on is selected. * - * If wq_steering is OCS_HW_WQ_STEERING_CPU, then a WQ associted with the + * If wq_steering is OCS_HW_WQ_STEERING_CPU, then a WQ associated with the * CPU the request is made on is selected. * * @param hw pointer to HW object From owner-dev-commits-src-all@freebsd.org Sat Aug 28 16:54:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE1BA676DF8; Sat, 28 Aug 2021 16:54: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 4GxjNg4gXVz4qWp; Sat, 28 Aug 2021 16:54: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 893D01B06F; Sat, 28 Aug 2021 16:54: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 17SGsRlk020890; Sat, 28 Aug 2021 16:54:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGsRSr020889; Sat, 28 Aug 2021 16:54:27 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:54:27 GMT Message-Id: <202108281654.17SGsRSr020889@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 586c9dc37470 - main - inet(3): Fix a few common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 586c9dc37470a2b862b50c041d70229026dd530a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:54:27 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=586c9dc37470a2b862b50c041d70229026dd530a commit 586c9dc37470a2b862b50c041d70229026dd530a Author: Gordon Bergling AuthorDate: 2021-08-28 16:53:02 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:53:02 +0000 inet(3): Fix a few common typos in source code comments - s/funtion/function/ MFC after: 3 days --- sys/netinet/in_pcbgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/in_pcbgroup.c b/sys/netinet/in_pcbgroup.c index cade2574db5d..11ed75be1198 100644 --- a/sys/netinet/in_pcbgroup.c +++ b/sys/netinet/in_pcbgroup.c @@ -186,7 +186,7 @@ in_pcbgroup_init(struct inpcbinfo *pcbinfo, u_int hashfields, * XXXRW: The notion of a bucket to CPU mapping is common at * both pcbgroup and RSS layers -- does that mean that we * should migrate it all from RSS to here, and just leave RSS - * responsible only for providing hashing and mapping funtions? + * responsible only for providing hashing and mapping functions? */ #ifdef RSS pcbgroup->ipg_cpu = rss_getcpu(pgn); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 16:54:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 062EE6764F9; Sat, 28 Aug 2021 16:54:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxjNh69gVz4qNS; Sat, 28 Aug 2021 16:54:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A4D441B070; Sat, 28 Aug 2021 16:54:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17SGsSVe020918; Sat, 28 Aug 2021 16:54:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGsSrr020917; Sat, 28 Aug 2021 16:54:28 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:54:28 GMT Message-Id: <202108281654.17SGsSrr020917@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 10e0082fff4e - main - inet6(4): Fix a few common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 10e0082fff4ec9392db2763ce3b095bc010526df Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:54:29 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=10e0082fff4ec9392db2763ce3b095bc010526df commit 10e0082fff4ec9392db2763ce3b095bc010526df Author: Gordon Bergling AuthorDate: 2021-08-28 16:53:59 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:53:59 +0000 inet6(4): Fix a few common typos in source code comments - s/reshedule/reschedule/ MFC after: 3 days --- sys/netinet6/nd6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 14312f0a30a3..6a9e2a4fdd7c 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -666,7 +666,7 @@ nd6_is_stale(struct llentry *lle, long *pdelay, int *do_switch) /* * V_nd6_delay still not passed since the first * hit in STALE state. - * Reshedule timer and return. + * Reschedule timer and return. */ *pdelay = (long)(nd_delay - delay) * hz; return (1); @@ -850,7 +850,7 @@ nd6_llinfo_timer(void *arg) if (nd6_is_stale(ln, &delay, &do_switch) != 0) { /* * No packet has used this entry and GC timeout - * has not been passed. Reshedule timer and + * has not been passed. Reschedule timer and * return. */ nd6_llinfo_settimer_locked(ln, delay); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 16:57:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 185FD676F84; Sat, 28 Aug 2021 16:57: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 4GxjSc09N6z4qv1; Sat, 28 Aug 2021 16:57: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 E10411ABDA; Sat, 28 Aug 2021 16:57: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 17SGvpr3021268; Sat, 28 Aug 2021 16:57:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SGvpDg021267; Sat, 28 Aug 2021 16:57:51 GMT (envelope-from git) Date: Sat, 28 Aug 2021 16:57:51 GMT Message-Id: <202108281657.17SGvpDg021267@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 5bdf58e19609 - main - Fix some common typos in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5bdf58e196096993758b3e50291db17104025b65 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 16:57:52 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5bdf58e196096993758b3e50291db17104025b65 commit 5bdf58e196096993758b3e50291db17104025b65 Author: Gordon Bergling AuthorDate: 2021-08-28 16:57:23 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 16:57:23 +0000 Fix some common typos in source code comments - s/priviledged/privileged/ - s/funtion/function/ - s/doens't/doesn't/ - s/sychronization/synchronization/ MFC after: 3 days --- sys/arm/arm/trap-v6.c | 4 ++-- sys/dev/cxgbe/cudbg/fastlz_api.c | 2 +- sys/dev/mii/lxtphy.c | 2 +- sys/dev/oce/oce_mbox.c | 2 +- sys/dev/qlnx/qlnxe/ecore.h | 2 +- sys/dev/rtsx/rtsx.c | 2 +- sys/dev/sfxge/sfxge.c | 2 +- sys/geom/journal/g_journal.c | 2 +- sys/i386/i386/perfmon.c | 2 +- usr.bin/tip/tip/tip.h | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/arm/arm/trap-v6.c b/sys/arm/arm/trap-v6.c index cd141376d381..7bd5780af338 100644 --- a/sys/arm/arm/trap-v6.c +++ b/sys/arm/arm/trap-v6.c @@ -114,7 +114,7 @@ struct abort { * for cache operations working on virtual addresses. For now, we will * consider this abort as fatal. In fact, no cache maintenance on * not mapped virtual addresses should be called. As cache maintenance - * operation (except DMB, DSB, and Flush Prefetch Buffer) are priviledged, + * operation (except DMB, DSB, and Flush Prefetch Buffer) are privileged, * the abort is fatal for user mode as well for now. (This is good place to * note that cache maintenance on virtual address fill TLB.) * Acces Bit (L1 & L2): @@ -654,7 +654,7 @@ abort_align(struct trapframe *tf, u_int idx, u_int fsr, u_int far, * According to manual, FAULT_ICACHE is translation fault during cache * maintenance operation. In fact, no cache maintenance operation on * not mapped virtual addresses should be called. As cache maintenance - * operation (except DMB, DSB, and Flush Prefetch Buffer) are priviledged, + * operation (except DMB, DSB, and Flush Prefetch Buffer) are privileged, * the abort is concider as fatal for now. However, all the matter with * cache maintenance operation on virtual addresses could be really complex * and fuzzy in SMP case, so maybe in future standard fault mechanism diff --git a/sys/dev/cxgbe/cudbg/fastlz_api.c b/sys/dev/cxgbe/cudbg/fastlz_api.c index a513557ad352..7a8131f6da3e 100644 --- a/sys/dev/cxgbe/cudbg/fastlz_api.c +++ b/sys/dev/cxgbe/cudbg/fastlz_api.c @@ -442,7 +442,7 @@ int decompress_buffer(struct cudbg_buffer *pc_buff, remaining = chunk_size; checksum = 1L; for (;;) { - /* Write a funtion for this */ + /* Write a function for this */ r = (CUDBG_BLOCK_SIZE < remaining) ? CUDBG_BLOCK_SIZE : remaining; bytes_read = diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 699c1d6f83b6..31900cc5a34b 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -203,7 +203,7 @@ lxtphy_status(struct mii_softc *sc) /* * Get link status from the CSR; we need to read the CSR * for media type anyhow, and the link status in the CSR - * doens't latch, so fewer register reads are required. + * doesn't latch, so fewer register reads are required. */ csr = PHY_READ(sc, MII_LXTPHY_CSR); if (csr & CSR_LINK) diff --git a/sys/dev/oce/oce_mbox.c b/sys/dev/oce/oce_mbox.c index 7470d7a13b07..321775c13d1e 100644 --- a/sys/dev/oce/oce_mbox.c +++ b/sys/dev/oce/oce_mbox.c @@ -118,7 +118,7 @@ oce_reset_fun(POCE_SOFTC sc) } /** - * @brief This funtions tells firmware we are + * @brief This functions tells firmware we are * done with commands. * @param sc software handle to the device * @returns 0 on success, ETIMEDOUT on failure diff --git a/sys/dev/qlnx/qlnxe/ecore.h b/sys/dev/qlnx/qlnxe/ecore.h index 33af8f124658..32a6b98156c5 100644 --- a/sys/dev/qlnx/qlnxe/ecore.h +++ b/sys/dev/qlnx/qlnxe/ecore.h @@ -702,7 +702,7 @@ struct ecore_hwfn { struct ecore_ptt *p_main_ptt; struct ecore_ptt *p_dpc_ptt; - /* PTP will be used only by the leading funtion. + /* PTP will be used only by the leading function. * Usage of all PTP-apis should be synchronized as result. */ struct ecore_ptt *p_ptp_ptt; diff --git a/sys/dev/rtsx/rtsx.c b/sys/dev/rtsx/rtsx.c index cb85685c875c..cae35243d137 100644 --- a/sys/dev/rtsx/rtsx.c +++ b/sys/dev/rtsx/rtsx.c @@ -624,7 +624,7 @@ rtsx_handle_card_present(struct rtsx_softc *sc) } /* - * This funtion is called at startup. + * This function is called at startup. */ static void rtsx_card_task(void *arg, int pending __unused) diff --git a/sys/dev/sfxge/sfxge.c b/sys/dev/sfxge/sfxge.c index 866f940a7b29..62daadf35ae5 100644 --- a/sys/dev/sfxge/sfxge.c +++ b/sys/dev/sfxge/sfxge.c @@ -984,7 +984,7 @@ sfxge_vpd_init(struct sfxge_softc *sc) if ((rc = efx_vpd_size(sc->enp, &sc->vpd_size)) != 0) { /* - * Unpriviledged functions deny VPD access. + * Unprivileged functions deny VPD access. * Simply skip VPD in this case. */ if (rc == EACCES) diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 7c8c60183bff..97516ed293e7 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -256,7 +256,7 @@ struct meminfo { #endif /* - * We use our own malloc/realloc/free funtions, so we can collect statistics + * We use our own malloc/realloc/free functions, so we can collect statistics * and force journal switch when we're running out of cache. */ static void * diff --git a/sys/i386/i386/perfmon.c b/sys/i386/i386/perfmon.c index 3f35b59faa80..cb8c0acfc0dc 100644 --- a/sys/i386/i386/perfmon.c +++ b/sys/i386/i386/perfmon.c @@ -62,7 +62,7 @@ static d_open_t perfmon_open; static d_ioctl_t perfmon_ioctl; /* - * XXX perfmon_init_dev(void *) is a split from the perfmon_init() funtion. + * XXX perfmon_init_dev(void *) is a split from the perfmon_init() function. * This solves a problem for DEVFS users. It loads the "perfmon" driver after * the DEVFS subsystem has been kicked into action. The SI_ORDER_ANY is to * assure that it is the most lowest priority task which, guarantees the diff --git a/usr.bin/tip/tip/tip.h b/usr.bin/tip/tip/tip.h index 298b08cb6692..a5d53b9a6aad 100644 --- a/usr.bin/tip/tip/tip.h +++ b/usr.bin/tip/tip/tip.h @@ -247,7 +247,7 @@ EXTERN int gotdefterm; EXTERN FILE *fscript; /* FILE for scripting */ EXTERN int fildes[2]; /* file transfer synchronization channel */ -EXTERN int repdes[2]; /* read process sychronization channel */ +EXTERN int repdes[2]; /* read process synchronization channel */ EXTERN int FD; /* open file descriptor to remote host */ EXTERN int AC; /* open file descriptor to dialer (v831 only) */ EXTERN int vflag; /* print .tiprc initialization sequence */ From owner-dev-commits-src-all@freebsd.org Sat Aug 28 17:24:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BC8B16772A0; Sat, 28 Aug 2021 17:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gxk3q4gxsz3DQT; Sat, 28 Aug 2021 17:24: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 848FB1B608; Sat, 28 Aug 2021 17:24: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 17SHOthv061395; Sat, 28 Aug 2021 17:24:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SHOtem061394; Sat, 28 Aug 2021 17:24:55 GMT (envelope-from git) Date: Sat, 28 Aug 2021 17:24:55 GMT Message-Id: <202108281724.17SHOtem061394@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: b1603638e38b - main - Fix a common typo in man pages and src comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b1603638e38b3d8c23da6599e389db9a9218c240 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 17:24:55 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=b1603638e38b3d8c23da6599e389db9a9218c240 commit b1603638e38b3d8c23da6599e389db9a9218c240 Author: Gordon Bergling AuthorDate: 2021-08-28 17:24:27 +0000 Commit: Gordon Bergling CommitDate: 2021-08-28 17:24:27 +0000 Fix a common typo in man pages and src comments - s/desciptor/descriptor/ MFC after: 5 days --- sbin/mount_fusefs/mount_fusefs.8 | 2 +- share/man/man4/proto.4 | 2 +- sys/dev/aic7xxx/aic79xx.h | 2 +- sys/dev/aic7xxx/aic7xxx.h | 2 +- sys/dev/isci/scil/sci_memory_descriptor_list.h | 2 +- sys/dev/isci/scil/scif_sas_controller.h | 2 +- sys/dev/mge/if_mge.c | 2 +- sys/dev/nge/if_nge.c | 2 +- sys/dev/sk/if_sk.c | 2 +- sys/dev/ti/if_ti.c | 2 +- sys/dev/usb/input/uhid_snes.c | 2 +- sys/dev/vr/if_vr.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sbin/mount_fusefs/mount_fusefs.8 b/sbin/mount_fusefs/mount_fusefs.8 index b4ab86c57ae2..051a5c273ef7 100644 --- a/sbin/mount_fusefs/mount_fusefs.8 +++ b/sbin/mount_fusefs/mount_fusefs.8 @@ -309,7 +309,7 @@ If not set, the multiplexer path .Ar /dev/fuse is used. .It Ev FUSE_DEV_FD -File desciptor of an opened Fuse device to use. +File descriptor of an opened Fuse device to use. Overrides .Ev FUSE_DEV_NAME . .It Ev FUSE_NO_MOUNT diff --git a/share/man/man4/proto.4 b/share/man/man4/proto.4 index 39f585dad65c..bd861697c10d 100644 --- a/share/man/man4/proto.4 +++ b/share/man/man4/proto.4 @@ -267,7 +267,7 @@ single contigous region of physical memory. In practice this also tends to give a single contigous region in bus space. This may change over time. .It PROTO_IOC_BUSDMA_MEM_FREE -Free previously allocated memory and destroy the memory desciptor. +Free previously allocated memory and destroy the memory descriptor. The .Nm driver is not in a position to track whether the memory has been mapped in diff --git a/sys/dev/aic7xxx/aic79xx.h b/sys/dev/aic7xxx/aic79xx.h index 38b152ef4051..bb3949c5f749 100644 --- a/sys/dev/aic7xxx/aic79xx.h +++ b/sys/dev/aic7xxx/aic79xx.h @@ -696,7 +696,7 @@ struct scb_data { /************************ Target Mode Definitions *****************************/ /* - * Connection desciptor for select-in requests in target mode. + * Connection descriptor for select-in requests in target mode. */ struct target_cmd { uint8_t scsiid; /* Our ID and the initiator's ID */ diff --git a/sys/dev/aic7xxx/aic7xxx.h b/sys/dev/aic7xxx/aic7xxx.h index a3abc456f8c5..f48e793fea6a 100644 --- a/sys/dev/aic7xxx/aic7xxx.h +++ b/sys/dev/aic7xxx/aic7xxx.h @@ -644,7 +644,7 @@ struct scb_data { /************************ Target Mode Definitions *****************************/ /* - * Connection desciptor for select-in requests in target mode. + * Connection descriptor for select-in requests in target mode. */ struct target_cmd { uint8_t scsiid; /* Our ID and the initiator's ID */ diff --git a/sys/dev/isci/scil/sci_memory_descriptor_list.h b/sys/dev/isci/scil/sci_memory_descriptor_list.h index 6b78fbc6055d..21516c13231c 100644 --- a/sys/dev/isci/scil/sci_memory_descriptor_list.h +++ b/sys/dev/isci/scil/sci_memory_descriptor_list.h @@ -96,7 +96,7 @@ typedef struct SCI_PHYSICAL_MEMORY_DESCRIPTOR void * virtual_address; /** - * This field contains the physical address associated with this desciptor + * This field contains the physical address associated with this descriptor * element. This field shall be zero when the descriptor is retrieved from * the SCI implementation. The user shall set this field prior * sci_controller_start() diff --git a/sys/dev/isci/scil/scif_sas_controller.h b/sys/dev/isci/scil/scif_sas_controller.h index fc7583e84367..3de39864811c 100644 --- a/sys/dev/isci/scil/scif_sas_controller.h +++ b/sys/dev/isci/scil/scif_sas_controller.h @@ -121,7 +121,7 @@ typedef struct SCIF_SAS_CONTROLLER SCI_BASE_CONTROLLER_STATE_HANDLER_T * state_handlers; /** - * This field contains the memory desciptors defining the physical + * This field contains the memory descriptors defining the physical * memory requirements for this controller. */ SCI_PHYSICAL_MEMORY_DESCRIPTOR_T mdes[SCIF_SAS_MAX_MEMORY_DESCRIPTORS]; diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c index dc044749ae72..16deb330c06c 100644 --- a/sys/dev/mge/if_mge.c +++ b/sys/dev/mge/if_mge.c @@ -697,7 +697,7 @@ static void mge_free_dma(struct mge_softc *sc) { - /* Free desciptors and mbufs */ + /* Free descriptors and mbufs */ mge_free_desc(sc, sc->mge_rx_desc, MGE_RX_DESC_NUM, sc->mge_rx_dtag, 1); mge_free_desc(sc, sc->mge_tx_desc, MGE_TX_DESC_NUM, sc->mge_tx_dtag, 0); diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c index c099896d7bc8..67e1f03ebdd2 100644 --- a/sys/dev/nge/if_nge.c +++ b/sys/dev/nge/if_nge.c @@ -1950,7 +1950,7 @@ nge_encap(struct nge_softc *sc, struct mbuf **m_head) if ((m->m_flags & M_VLANTAG) != 0) desc->nge_extsts |= htole32(NGE_TXEXTSTS_VLANPKT | bswap16(m->m_pkthdr.ether_vtag)); - /* Set EOP on the last desciptor. */ + /* Set EOP on the last descriptor. */ desc->nge_cmdsts &= htole32(~NGE_CMDSTS_MORE); /* Set checksum offload in the first descriptor. */ diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index a6431044e30f..809cfa6f9e14 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -2445,7 +2445,7 @@ sk_encap(sc_if, m_head) } sc_if->sk_cdata.sk_tx_prod = frag; - /* set EOF on the last desciptor */ + /* set EOF on the last descriptor */ frag = (frag + SK_TX_RING_CNT - 1) % SK_TX_RING_CNT; f = &sc_if->sk_rdata.sk_tx_ring[frag]; f->sk_ctl |= htole32(SK_TXCTL_LASTFRAG | SK_TXCTL_EOF_INTR); diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 06769bc97c9f..9871212d6379 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -53,7 +53,7 @@ * * The Tigon 2 contains 2 R4000 CPUs and requires a newer firmware * revision, which supports new features such as extended commands, - * extended jumbo receive ring desciptors and a mini receive ring. + * extended jumbo receive ring descriptors and a mini receive ring. * * Alteon Networks is to be commended for releasing such a vast amount * of development material for the Tigon NIC without requiring an NDA diff --git a/sys/dev/usb/input/uhid_snes.c b/sys/dev/usb/input/uhid_snes.c index 5b68560a47e9..181e38eba7b1 100644 --- a/sys/dev/usb/input/uhid_snes.c +++ b/sys/dev/usb/input/uhid_snes.c @@ -296,7 +296,7 @@ uhid_snes_ioctl(struct usb_fifo *fifo, u_long cmd, void *data, int fflags) ugd->ugd_actlen = size; if (ugd->ugd_data == NULL) - break; /*desciptor length only*/ + break; /* descriptor length only*/ error = copyout(sc->sc_repdesc_ptr, ugd->ugd_data, size); break; diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index e81c027cf2cd..3a3490b7095c 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -1934,7 +1934,7 @@ vr_encap(struct vr_softc *sc, struct mbuf **m_head) desc = &sc->vr_rdata.vr_tx_ring[prod]; /* - * Set EOP on the last desciptor and reuqest Tx completion + * Set EOP on the last descriptor and reuqest Tx completion * interrupt for every VR_TX_INTR_THRESH-th frames. */ VR_INC(sc->vr_cdata.vr_tx_pkts, VR_TX_INTR_THRESH); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 18:23:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 57E8C677FD1; Sat, 28 Aug 2021 18:23: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 4GxlMk215rz3l2L; Sat, 28 Aug 2021 18:23: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 2D47D1C32C; Sat, 28 Aug 2021 18:23: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 17SINkrI041613; Sat, 28 Aug 2021 18:23:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SINkg2041612; Sat, 28 Aug 2021 18:23:46 GMT (envelope-from git) Date: Sat, 28 Aug 2021 18:23:46 GMT Message-Id: <202108281823.17SINkg2041612@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 9fae47666957 - main - Explicitly link zfsd with libspl to avoid undefined references MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9fae476669574792d75706a5401bbdc927ab2b9a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 18:23:46 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=9fae476669574792d75706a5401bbdc927ab2b9a commit 9fae476669574792d75706a5401bbdc927ab2b9a Author: Dimitry Andric AuthorDate: 2021-08-28 18:23:15 +0000 Commit: Dimitry Andric CommitDate: 2021-08-28 18:23:28 +0000 Explicitly link zfsd with libspl to avoid undefined references Because lld 13.0.0 is more strict about undefined references when linking to shared libraries, it produces the following errors for zfsd: ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libzfs_core.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libnvpair.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] ld: error: /home/dim/obj/home/dim/src/llvm-13-update/amd64.amd64/tmp/usr/lib/libavl.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] *** [zfsd.full] Error code 1 Fix this by adding libspl (where libspl_assertf lives) to zfsd's LIBADD. MFC after: 3 days --- cddl/usr.sbin/zfsd/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common index c09f47e733dc..c18c796ce0ed 100644 --- a/cddl/usr.sbin/zfsd/Makefile.common +++ b/cddl/usr.sbin/zfsd/Makefile.common @@ -26,7 +26,7 @@ CFLAGS+= -I${SRCTOP}/cddl/usr.sbin # use issetugid(2) CFLAGS+= -D_MACHINE_FLOAT_H_ -DHAVE_ISSETUGID -LIBADD+= devdctl zfs zfs_core util geom bsdxml sbuf nvpair avl uutil zutil +LIBADD+= devdctl zfs zfs_core util geom bsdxml sbuf nvpair avl spl uutil zutil cscope: find ${.CURDIR} -type f -a \( -name "*.[ch]" -o -name "*.cc" \) \ From owner-dev-commits-src-all@freebsd.org Sat Aug 28 19:55:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 699A46791A2; Sat, 28 Aug 2021 19:55: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 4GxnPV27Sbz4f6f; Sat, 28 Aug 2021 19:55: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 2C46A1CE74; Sat, 28 Aug 2021 19:55: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 17SJtQPq060405; Sat, 28 Aug 2021 19:55:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SJtQTQ060404; Sat, 28 Aug 2021 19:55:26 GMT (envelope-from git) Date: Sat, 28 Aug 2021 19:55:26 GMT Message-Id: <202108281955.17SJtQTQ060404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 7326e8589cc2 - main - fsetown: Avoid process group lock recursion MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7326e8589cc21431d62f25802eac7c5dd6f74122 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 19:55:26 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7326e8589cc21431d62f25802eac7c5dd6f74122 commit 7326e8589cc21431d62f25802eac7c5dd6f74122 Author: Mark Johnston AuthorDate: 2021-08-28 19:50:44 +0000 Commit: Mark Johnston CommitDate: 2021-08-28 19:50:44 +0000 fsetown: Avoid process group lock recursion Restore the pre-1d874ba4f8ba behaviour of disassociating the current SIGIO recipient before looking up the specified process or process group. This avoids a lock recursion in the scenario where a process group is configured to receive SIGIO for an fd when it has already been so configured. Reported by: pho Tested by: pho Reviewed by: kib MFC after: 3 days --- sys/kern/kern_descrip.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index f78e999ab3b5..ed7fe83cf02f 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1158,14 +1158,12 @@ fsetown(pid_t pgid, struct sigio **sigiop) sigio->sio_ucred = crhold(curthread->td_ucred); sigio->sio_myref = sigiop; - osigio = NULL; ret = 0; if (pgid > 0) { ret = pget(pgid, PGET_NOTWEXIT | PGET_NOTID | PGET_HOLD, &proc); SIGIO_LOCK(); + osigio = funsetown_locked(*sigiop); if (ret == 0) { - osigio = funsetown_locked(*sigiop); - PROC_LOCK(proc); _PRELE(proc); if ((proc->p_flag & P_WEXIT) != 0) { @@ -1191,12 +1189,11 @@ fsetown(pid_t pgid, struct sigio **sigiop) } else /* if (pgid < 0) */ { sx_slock(&proctree_lock); SIGIO_LOCK(); + osigio = funsetown_locked(*sigiop); pgrp = pgfind(-pgid); if (pgrp == NULL) { ret = ESRCH; } else { - osigio = funsetown_locked(*sigiop); - if (pgrp->pg_session != curthread->td_proc->p_session) { /* * Policy - Don't allow a process to FSETOWN a From owner-dev-commits-src-all@freebsd.org Sat Aug 28 20:39:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F419467956D; Sat, 28 Aug 2021 20:39: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 4GxpNB60TTz4rCP; Sat, 28 Aug 2021 20:39: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 B1E5D1D7FE; Sat, 28 Aug 2021 20:39: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 17SKdMGH014056; Sat, 28 Aug 2021 20:39:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SKdMMO014055; Sat, 28 Aug 2021 20:39:22 GMT (envelope-from git) Date: Sat, 28 Aug 2021 20:39:22 GMT Message-Id: <202108282039.17SKdMMO014055@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 31607861e2ea - main - Style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 31607861e2ea3adae26a4ce3f6fbd61dfbc37894 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 20:39:23 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=31607861e2ea3adae26a4ce3f6fbd61dfbc37894 commit 31607861e2ea3adae26a4ce3f6fbd61dfbc37894 Author: Konstantin Belousov AuthorDate: 2021-08-27 14:28:19 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-28 20:39:16 +0000 Style Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/i386/i386/elf_machdep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c index 3754b36d9e33..5d472e4db4a2 100644 --- a/sys/i386/i386/elf_machdep.c +++ b/sys/i386/i386/elf_machdep.c @@ -261,6 +261,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, if (*where != addr) *where = addr; break; + default: printf("kldload: unexpected relocation type %d, " "symbol index %d\n", rtype, symidx); From owner-dev-commits-src-all@freebsd.org Sat Aug 28 20:39:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0CB73679769; Sat, 28 Aug 2021 20:39:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxpNC6g72z4rFD; Sat, 28 Aug 2021 20:39: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 CC5631DA68; Sat, 28 Aug 2021 20:39: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 17SKdNaq014080; Sat, 28 Aug 2021 20:39:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17SKdNCc014079; Sat, 28 Aug 2021 20:39:23 GMT (envelope-from git) Date: Sat, 28 Aug 2021 20:39:23 GMT Message-Id: <202108282039.17SKdNCc014079@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 17fc43bc0101 - main - ldd: Remove non-functional -v option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 17fc43bc01011ed05f614f266350d37f7020a59d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 20:39:24 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=17fc43bc01011ed05f614f266350d37f7020a59d commit 17fc43bc01011ed05f614f266350d37f7020a59d Author: Konstantin Belousov AuthorDate: 2021-08-28 17:28:54 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-28 20:39:16 +0000 ldd: Remove non-functional -v option It seems -v only worked for a.out. Remove it, not even keeping the current nop for compat. Also remove more mentions of a.out format from the man page. Reviewed by: dim, emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31708 --- usr.bin/ldd/ldd.1 | 18 +----------------- usr.bin/ldd/ldd.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/usr.bin/ldd/ldd.1 b/usr.bin/ldd/ldd.1 index 2a90d5ac537d..d263eabcf4ff 100644 --- a/usr.bin/ldd/ldd.1 +++ b/usr.bin/ldd/ldd.1 @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd October 23, 2018 +.Dd August 28, 2021 .Dt LDD 1 .Os .Sh NAME @@ -9,7 +9,6 @@ .Sh SYNOPSIS .Nm .Op Fl a -.Op Fl v .Op Fl f Ar format .Ar program ... .Sh DESCRIPTION @@ -47,16 +46,6 @@ The .Fl a option displays the list of all objects that are needed by each loaded object. -This option does not work with -.Xr a.out 5 -binaries. -.Pp -The -.Fl v -option displays a verbose listing of the dynamic linking headers -encoded in the executable. -See the source code and include -files for the definitive meaning of all the fields. .Sh IMPLEMENTATION NOTES .Nm lists the dependencies of an executable by setting @@ -82,8 +71,3 @@ A .Nm utility first appeared in SunOS 4.0, it appeared in its current form in .Fx 1.1 . -.Pp -The -.Fl v -support is based on code written by -.An John Polstra Aq Mt jdp@polstra.com diff --git a/usr.bin/ldd/ldd.c b/usr.bin/ldd/ldd.c index f948b7312863..3353345d549d 100644 --- a/usr.bin/ldd/ldd.c +++ b/usr.bin/ldd/ldd.c @@ -83,7 +83,7 @@ static void usage(void); #define _PATH_LDD32 "/usr/bin/ldd32" static int -execldd32(char *file, char *fmt1, char *fmt2, int aflag, int vflag) +execldd32(char *file, char *fmt1, char *fmt2, int aflag) { char *argv[9]; int i, rval, status; @@ -94,8 +94,6 @@ execldd32(char *file, char *fmt1, char *fmt2, int aflag, int vflag) argv[i++] = strdup(_PATH_LDD32); if (aflag) argv[i++] = strdup("-a"); - if (vflag) - argv[i++] = strdup("-v"); if (fmt1 != NULL) { argv[i++] = strdup("-f"); argv[i++] = strdup(fmt1); @@ -136,12 +134,12 @@ int main(int argc, char *argv[]) { char *fmt1, *fmt2; - int rval, c, aflag, vflag; + int rval, c, aflag; - aflag = vflag = 0; + aflag = 0; fmt1 = fmt2 = NULL; - while ((c = getopt(argc, argv, "af:v")) != -1) { + while ((c = getopt(argc, argv, "af:")) != -1) { switch (c) { case 'a': aflag++; @@ -154,9 +152,6 @@ main(int argc, char *argv[]) } else fmt1 = optarg; break; - case 'v': - vflag++; - break; default: usage(); /* NOTREACHED */ @@ -165,9 +160,6 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (vflag && fmt1 != NULL) - errx(1, "-v may not be used with -f"); - if (argc <= 0) { usage(); /* NOTREACHED */ @@ -194,7 +186,7 @@ main(int argc, char *argv[]) break; #if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED) case TYPE_ELF32: - rval |= execldd32(*argv, fmt1, fmt2, aflag, vflag); + rval |= execldd32(*argv, fmt1, fmt2, aflag); continue; #endif case TYPE_UNKNOWN: @@ -259,7 +251,7 @@ static void usage(void) { - fprintf(stderr, "usage: ldd [-a] [-v] [-f format] program ...\n"); + fprintf(stderr, "usage: ldd [-a] [-f format] program ...\n"); exit(1); } From owner-dev-commits-src-all@freebsd.org Sun Aug 29 03:52:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 743A067E14C for ; Sun, 29 Aug 2021 03:52:19 +0000 (UTC) (envelope-from 0100017b90094508-5b42da7a-417b-48b9-8939-50ae6bd1543e-000000@amazonses.com) Received: from a8-56.smtp-out.amazonses.com (a8-56.smtp-out.amazonses.com [54.240.8.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gxzzk2jRWz4tP8 for ; Sun, 29 Aug 2021 03:52:18 +0000 (UTC) (envelope-from 0100017b90094508-5b42da7a-417b-48b9-8939-50ae6bd1543e-000000@amazonses.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=dqtolf56kk3wpt62c3jnwboqvr7iedax; d=tarsnap.com; t=1630209131; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=j1mGbeZKH/1uEWUFUYVupe8aFOPK+sKPM5mF3ECytGU=; b=JWfcGwJeMj1C6FwzUMBIpFfFto2thtfHvFKZER20kAd+ONz+zJveln57EHsSSpHb QHDOofgpEFm8TFVzaA0lP8/2GG+uJ7f3474iARb8NUPmfFj0QdvGrr6jsAq+DbSdU7N ULuVgfHeYm+HFzdKJbpvUp85Yt7YkXQD0DMw26Mw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1630209131; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=j1mGbeZKH/1uEWUFUYVupe8aFOPK+sKPM5mF3ECytGU=; b=kzY7BgB7f6jEECvZuz3x0oUYDW3YgpjoE7KS9G9as47xVxYbWPCjFhdrNgJfgsDE lxtlKlRh6Hn4OnIZ/Su2ha/pfdntHq6q+wEkAJX8ntkzCLSU88+0mKGnwyuIILZjPrR /OXwqQnvi1MrrYefqu8/gB/858/o9zy3gSMpM9rA= Subject: Re: git: 6c69c6bb4c7f - main - kvm_clock: KVM paravirtual clock support To: Konstantin Belousov , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202108141258.17ECwEWF031182@gitrepo.freebsd.org> From: Colin Percival Message-ID: <0100017b90094508-5b42da7a-417b-48b9-8939-50ae6bd1543e-000000@email.amazonses.com> Date: Sun, 29 Aug 2021 03:52:11 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <202108141258.17ECwEWF031182@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Feedback-ID: 1.us-east-1.Lv9FVjaNvvR5llaqfLoOVbo2VxOELl7cjN0AOyXnPlk=:AmazonSES X-SES-Outgoing: 2021.08.29-54.240.8.56 X-Rspamd-Queue-Id: 4Gxzzk2jRWz4tP8 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=tarsnap.com header.s=dqtolf56kk3wpt62c3jnwboqvr7iedax header.b=JWfcGwJe; dkim=pass header.d=amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=kzY7BgB7; dmarc=pass (policy=none) header.from=tarsnap.com; spf=pass (mx1.freebsd.org: domain of 0100017b90094508-5b42da7a-417b-48b9-8939-50ae6bd1543e-000000@amazonses.com designates 54.240.8.56 as permitted sender) smtp.mailfrom=0100017b90094508-5b42da7a-417b-48b9-8939-50ae6bd1543e-000000@amazonses.com X-Spamd-Result: default: False [-1.20 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[tarsnap.com:s=dqtolf56kk3wpt62c3jnwboqvr7iedax,amazonses.com:s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:54.240.0.0/18]; MIME_GOOD(-0.10)[text/plain]; DWL_DNSWL_NONE(0.00)[amazonses.com:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[tarsnap.com:+,amazonses.com:+]; DMARC_POLICY_ALLOW(-0.50)[tarsnap.com,none]; RCVD_IN_DNSWL_NONE(0.00)[54.240.8.56:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[cperciva@tarsnap.com,0100017b90094508-5b42da7a-417b-48b9-8939-50ae6bd1543e-000000@amazonses.com]; RCVD_COUNT_ZERO(0.00)[0]; RWL_MAILSPIKE_POSSIBLE(0.00)[54.240.8.56:from]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:14618, ipnet:54.240.8.0/21, country:US]; FORGED_MUA_THUNDERBIRD_MSGID_UNKNOWN(2.50)[]; FROM_NEQ_ENVFROM(0.00)[cperciva@tarsnap.com,0100017b90094508-5b42da7a-417b-48b9-8939-50ae6bd1543e-000000@amazonses.com]; MAILMAN_DEST(0.00)[dev-commits-src-all] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 03:52:19 -0000 Will this be MFCed to stable/13 ? I'd really really like to have it in 13.1 since it fixes a regression in EC2. Colin Percival On 8/14/21 5:58 AM, Konstantin Belousov wrote: > The branch main has been updated by kib: > > URL: https://cgit.FreeBSD.org/src/commit/?id=6c69c6bb4c7ffde48b130df707799d4eca21ca9f > > commit 6c69c6bb4c7ffde48b130df707799d4eca21ca9f > Author: Adam Fenn > AuthorDate: 2021-08-04 15:42:48 +0000 > Commit: Konstantin Belousov > CommitDate: 2021-08-14 12:57:54 +0000 > > kvm_clock: KVM paravirtual clock support > > Add support for the KVM paravirtual clock device. > > Sponsored by: Juniper Networks, Inc. > Sponsored by: Klara, Inc. > Reviewed by: kib > Differential Revision: https://reviews.freebsd.org/D29733 > --- > sys/amd64/conf/GENERIC | 3 + > sys/amd64/conf/MINIMAL | 3 + > sys/amd64/conf/NOTES | 3 + > sys/conf/files.x86 | 3 +- > sys/dev/kvm_clock/kvm_clock.c | 240 ++++++++++++++++++++++++++++++++++++++++++ > sys/i386/conf/GENERIC | 3 + > sys/i386/conf/MINIMAL | 3 + > sys/i386/conf/NOTES | 3 + > sys/x86/include/kvm.h | 80 ++++++++++++++ > 9 files changed, 340 insertions(+), 1 deletion(-) > > diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC > index f7b41919575d..78b5e0e299f6 100644 > --- a/sys/amd64/conf/GENERIC > +++ b/sys/amd64/conf/GENERIC > @@ -376,6 +376,9 @@ device virtio_blk # VirtIO Block device > device virtio_scsi # VirtIO SCSI device > device virtio_balloon # VirtIO Memory Balloon device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # HyperV drivers and enhancement support > device hyperv # HyperV drivers > > diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL > index 14f91e6c8eaf..f724cbd2e3f1 100644 > --- a/sys/amd64/conf/MINIMAL > +++ b/sys/amd64/conf/MINIMAL > @@ -131,6 +131,9 @@ device ether # Ethernet support > # Note that 'bpf' is required for DHCP. > device bpf # Berkeley packet filter > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # Xen HVM Guest Optimizations > # NOTE: XENHVM depends on xenpci and xentimer. > # They must be added or removed together. > diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES > index 501ceaedb222..c1db8ef7512f 100644 > --- a/sys/amd64/conf/NOTES > +++ b/sys/amd64/conf/NOTES > @@ -498,6 +498,9 @@ device virtio_balloon # VirtIO Memory Balloon device > device virtio_random # VirtIO Entropy device > device virtio_console # VirtIO Console device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # Microsoft Hyper-V enhancement support > device hyperv # HyperV drivers > > diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 > index d1fc234c4182..d0cda2da8580 100644 > --- a/sys/conf/files.x86 > +++ b/sys/conf/files.x86 > @@ -263,6 +263,7 @@ dev/isci/scil/scif_sas_task_request_state_handlers.c optional isci > dev/isci/scil/scif_sas_task_request_states.c optional isci > dev/isci/scil/scif_sas_timer.c optional isci > dev/itwd/itwd.c optional itwd > +dev/kvm_clock/kvm_clock.c optional kvm_clock > dev/qat/qat.c optional qat > dev/qat/qat_ae.c optional qat > dev/qat/qat_c2xxx.c optional qat > @@ -318,7 +319,7 @@ x86/x86/x86_mem.c optional mem > x86/x86/mp_x86.c optional smp > x86/x86/mp_watchdog.c optional mp_watchdog smp > x86/x86/nexus.c standard > -x86/x86/pvclock.c optional xenhvm > +x86/x86/pvclock.c optional kvm_clock | xenhvm > x86/x86/stack_machdep.c optional ddb | stack > x86/x86/tsc.c standard > x86/x86/ucode.c standard > diff --git a/sys/dev/kvm_clock/kvm_clock.c b/sys/dev/kvm_clock/kvm_clock.c > new file mode 100644 > index 000000000000..1a76432e417d > --- /dev/null > +++ b/sys/dev/kvm_clock/kvm_clock.c > @@ -0,0 +1,240 @@ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > + * > + * Copyright (c) 2014 Bryan Venteicher > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > + * Copyright (c) 2021 Juniper Networks, Inc. > + * Copyright (c) 2021 Klara, Inc. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + */ > + > +/* > + * Linux KVM paravirtual clock support > + * > + * References: > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#include > +#include > + > +#include "clock_if.h" > + > +#define KVM_CLOCK_DEVNAME "kvmclock" > +/* > + * Note: Chosen to be (1) above HPET's value (always 950), (2) above the TSC's > + * default value of 800, and (3) below the TSC's value when it supports the > + * "Invariant TSC" feature and is believed to be synchronized across all CPUs. > + */ > +#define KVM_CLOCK_TC_QUALITY 975 > + > +struct kvm_clock_softc { > + struct pvclock pvc; > + struct pvclock_wall_clock wc; > + struct pvclock_vcpu_time_info *timeinfos; > + u_int msr_tc; > + u_int msr_wc; > +}; > + > +static devclass_t kvm_clock_devclass; > + > +static struct pvclock_wall_clock *kvm_clock_get_wallclock(void *arg); > +static void kvm_clock_system_time_enable(struct kvm_clock_softc *sc); > +static void kvm_clock_system_time_enable_pcpu(void *arg); > + > +static struct pvclock_wall_clock * > +kvm_clock_get_wallclock(void *arg) > +{ > + struct kvm_clock_softc *sc = arg; > + > + wrmsr(sc->msr_wc, vtophys(&sc->wc)); > + return (&sc->wc); > +} > + > +static void > +kvm_clock_system_time_enable(struct kvm_clock_softc *sc) > +{ > + smp_rendezvous(NULL, kvm_clock_system_time_enable_pcpu, NULL, sc); > +} > + > +static void > +kvm_clock_system_time_enable_pcpu(void *arg) > +{ > + struct kvm_clock_softc *sc = arg; > + > + /* > + * See [2]; the lsb of this MSR is the system time enable bit. > + */ > + wrmsr(sc->msr_tc, vtophys(&(sc->timeinfos)[curcpu]) | 1); > +} > + > +static void > +kvm_clock_identify(driver_t *driver, device_t parent) > +{ > + u_int regs[4]; > + > + kvm_cpuid_get_features(regs); > + if ((regs[0] & > + (KVM_FEATURE_CLOCKSOURCE2 | KVM_FEATURE_CLOCKSOURCE)) == 0) > + return; > + if (device_find_child(parent, KVM_CLOCK_DEVNAME, -1)) > + return; > + BUS_ADD_CHILD(parent, 0, KVM_CLOCK_DEVNAME, 0); > +} > + > +static int > +kvm_clock_probe(device_t dev) > +{ > + device_set_desc(dev, "KVM paravirtual clock"); > + return (BUS_PROBE_DEFAULT); > +} > + > +static int > +kvm_clock_attach(device_t dev) > +{ > + u_int regs[4]; > + struct kvm_clock_softc *sc = device_get_softc(dev); > + bool stable_flag_supported; > + > + /* Process KVM "features" CPUID leaf content: */ > + kvm_cpuid_get_features(regs); > + if ((regs[0] & KVM_FEATURE_CLOCKSOURCE2) != 0) { > + sc->msr_tc = KVM_MSR_SYSTEM_TIME_NEW; > + sc->msr_wc = KVM_MSR_WALL_CLOCK_NEW; > + } else { > + KASSERT((regs[0] & KVM_FEATURE_CLOCKSOURCE) != 0, > + ("Clocksource feature flags disappeared since " > + "kvm_clock_identify: regs[0] %#0x.", regs[0])); > + sc->msr_tc = KVM_MSR_SYSTEM_TIME; > + sc->msr_wc = KVM_MSR_WALL_CLOCK; > + } > + stable_flag_supported = > + (regs[0] & KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) != 0; > + > + /* Set up 'struct pvclock_vcpu_time_info' page(s): */ > + sc->timeinfos = (struct pvclock_vcpu_time_info *)kmem_malloc(mp_ncpus * > + sizeof(struct pvclock_vcpu_time_info), M_WAITOK | M_ZERO); > + kvm_clock_system_time_enable(sc); > + > + /* > + * Init pvclock; register KVM clock wall clock, register KVM clock > + * timecounter, and set up the requisite infrastructure for vDSO access > + * to this timecounter. > + * Regarding 'tc_flags': Since the KVM MSR documentation does not > + * specifically discuss suspend/resume scenarios, conservatively > + * leave 'TC_FLAGS_SUSPEND_SAFE' cleared and assume that the system > + * time must be re-inited in such cases. > + */ > + sc->pvc.get_wallclock = kvm_clock_get_wallclock; > + sc->pvc.get_wallclock_arg = sc; > + sc->pvc.timeinfos = sc->timeinfos; > + sc->pvc.stable_flag_supported = stable_flag_supported; > + pvclock_init(&sc->pvc, dev, KVM_CLOCK_DEVNAME, KVM_CLOCK_TC_QUALITY, 0); > + return (0); > +} > + > +static int > +kvm_clock_detach(device_t dev) > +{ > + struct kvm_clock_softc *sc = device_get_softc(dev); > + > + return (pvclock_destroy(&sc->pvc)); > +} > + > +static int > +kvm_clock_suspend(device_t dev) > +{ > + return (0); > +} > + > +static int > +kvm_clock_resume(device_t dev) > +{ > + /* > + * See note in 'kvm_clock_attach()' regarding 'TC_FLAGS_SUSPEND_SAFE'; > + * conservatively assume that the system time must be re-inited in > + * suspend/resume scenarios. > + */ > + kvm_clock_system_time_enable(device_get_softc(dev)); > + pvclock_resume(); > + inittodr(time_second); > + return (0); > +} > + > +static int > +kvm_clock_gettime(device_t dev, struct timespec *ts) > +{ > + struct kvm_clock_softc *sc = device_get_softc(dev); > + > + pvclock_gettime(&sc->pvc, ts); > + return (0); > +} > + > +static int > +kvm_clock_settime(device_t dev, struct timespec *ts) > +{ > + /* > + * Even though it is not possible to set the KVM clock's wall clock, to > + * avoid the possibility of periodic benign error messages from > + * 'settime_task_func()', report success rather than, e.g., 'ENODEV'. > + */ > + return (0); > +} > + > +static device_method_t kvm_clock_methods[] = { > + DEVMETHOD(device_identify, kvm_clock_identify), > + DEVMETHOD(device_probe, kvm_clock_probe), > + DEVMETHOD(device_attach, kvm_clock_attach), > + DEVMETHOD(device_detach, kvm_clock_detach), > + DEVMETHOD(device_suspend, kvm_clock_suspend), > + DEVMETHOD(device_resume, kvm_clock_resume), > + /* clock interface */ > + DEVMETHOD(clock_gettime, kvm_clock_gettime), > + DEVMETHOD(clock_settime, kvm_clock_settime), > + > + DEVMETHOD_END > +}; > + > +static driver_t kvm_clock_driver = { > + KVM_CLOCK_DEVNAME, > + kvm_clock_methods, > + sizeof(struct kvm_clock_softc), > +}; > + > +DRIVER_MODULE(kvm_clock, nexus, kvm_clock_driver, kvm_clock_devclass, 0, 0); > diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC > index 86c062effd81..5447c452c4f7 100644 > --- a/sys/i386/conf/GENERIC > +++ b/sys/i386/conf/GENERIC > @@ -337,6 +337,9 @@ device virtio_blk # VirtIO Block device > device virtio_scsi # VirtIO SCSI device > device virtio_balloon # VirtIO Memory Balloon device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # HyperV drivers and enhancement support > # NOTE: HYPERV depends on hyperv. They must be added or removed together. > options HYPERV # Kernel support for HyperV drivers > diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL > index 37b8e074ac65..9d735dbb0580 100644 > --- a/sys/i386/conf/MINIMAL > +++ b/sys/i386/conf/MINIMAL > @@ -145,6 +145,9 @@ device gif # IPv6 and IPv4 tunneling > # Note that 'bpf' is required for DHCP. > device bpf # Berkeley packet filter > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > # Xen HVM Guest Optimizations > # NOTE: XENHVM depends on xenpci. They must be added or removed together. > options XENHVM # Xen HVM kernel infrastructure > diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES > index df9ff4fb3aed..27cebf0c48a0 100644 > --- a/sys/i386/conf/NOTES > +++ b/sys/i386/conf/NOTES > @@ -719,6 +719,9 @@ device virtio_balloon # VirtIO Memory Balloon device > device virtio_random # VirtIO Entropy device > device virtio_console # VirtIO Console device > > +# Linux KVM paravirtualization support > +device kvm_clock # KVM paravirtual clock driver > + > options HYPERV > device hyperv # HyperV drivers > > diff --git a/sys/x86/include/kvm.h b/sys/x86/include/kvm.h > new file mode 100644 > index 000000000000..beec6447d7d6 > --- /dev/null > +++ b/sys/x86/include/kvm.h > @@ -0,0 +1,80 @@ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > + * > + * Copyright (c) 2014 Bryan Venteicher > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > + * Copyright (c) 2021 Juniper Networks, Inc. > + * Copyright (c) 2021 Klara, Inc. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + * > + * $FreeBSD$ > + */ > + > +/* > + * Linux KVM paravirtualization: common definitions > + * > + * References: > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > + */ > + > +#ifndef _X86_KVM_H_ > +#define _X86_KVM_H_ > + > +#include > +#include > + > +#include > + > +#define KVM_CPUID_SIGNATURE 0x40000000 > +#define KVM_CPUID_FEATURES_LEAF 0x40000001 > + > +#define KVM_FEATURE_CLOCKSOURCE 0x00000001 > +#define KVM_FEATURE_CLOCKSOURCE2 0x00000008 > +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 0x01000000 > + > +/* Deprecated: for the CLOCKSOURCE feature. */ > +#define KVM_MSR_WALL_CLOCK 0x11 > +#define KVM_MSR_SYSTEM_TIME 0x12 > + > +#define KVM_MSR_WALL_CLOCK_NEW 0x4b564d00 > +#define KVM_MSR_SYSTEM_TIME_NEW 0x4b564d01 > + > +static inline bool > +kvm_cpuid_features_leaf_supported(void) > +{ > + return (vm_guest == VM_GUEST_KVM && > + KVM_CPUID_FEATURES_LEAF > hv_base && > + KVM_CPUID_FEATURES_LEAF <= hv_high); > +} > + > +static inline void > +kvm_cpuid_get_features(u_int *regs) > +{ > + if (!kvm_cpuid_features_leaf_supported()) > + regs[0] = regs[1] = regs[2] = regs[3] = 0; > + else > + do_cpuid(KVM_CPUID_FEATURES_LEAF, regs); > +} > + > +#endif /* !_X86_KVM_H_ */ > -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid From owner-dev-commits-src-all@freebsd.org Sun Aug 29 04:03:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4C4667EAD6; Sun, 29 Aug 2021 04:03:57 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy0F74Tp5z3DML; Sun, 29 Aug 2021 04:03:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 17T43kdQ018646 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 29 Aug 2021 07:03:49 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 17T43kdQ018646 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 17T43kGK018645; Sun, 29 Aug 2021 07:03:46 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 29 Aug 2021 07:03:46 +0300 From: Konstantin Belousov To: Colin Percival Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 6c69c6bb4c7f - main - kvm_clock: KVM paravirtual clock support Message-ID: References: <202108141258.17ECwEWF031182@gitrepo.freebsd.org> <0100017b90094507-d735fec4-16d5-4a6f-9851-9634d464e0aa-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0100017b90094507-d735fec4-16d5-4a6f-9851-9634d464e0aa-000000@email.amazonses.com> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4Gy0F74Tp5z3DML X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-1.00 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_SHORT(1.00)[0.999]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 04:03:58 -0000 On Sun, Aug 29, 2021 at 03:52:11AM +0000, Colin Percival wrote: > Will this be MFCed to stable/13 ? I'd really really like to have it in 13.1 > since it fixes a regression in EC2. Yes I plan to. I am not sure when: there was at least one report of a breakage under vbox, and I did not get any feedback on HEAD. The patches sit on my staging stable/13 branch FWIW. > > Colin Percival > > On 8/14/21 5:58 AM, Konstantin Belousov wrote: > > The branch main has been updated by kib: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=6c69c6bb4c7ffde48b130df707799d4eca21ca9f > > > > commit 6c69c6bb4c7ffde48b130df707799d4eca21ca9f > > Author: Adam Fenn > > AuthorDate: 2021-08-04 15:42:48 +0000 > > Commit: Konstantin Belousov > > CommitDate: 2021-08-14 12:57:54 +0000 > > > > kvm_clock: KVM paravirtual clock support > > > > Add support for the KVM paravirtual clock device. > > > > Sponsored by: Juniper Networks, Inc. > > Sponsored by: Klara, Inc. > > Reviewed by: kib > > Differential Revision: https://reviews.freebsd.org/D29733 > > --- > > sys/amd64/conf/GENERIC | 3 + > > sys/amd64/conf/MINIMAL | 3 + > > sys/amd64/conf/NOTES | 3 + > > sys/conf/files.x86 | 3 +- > > sys/dev/kvm_clock/kvm_clock.c | 240 ++++++++++++++++++++++++++++++++++++++++++ > > sys/i386/conf/GENERIC | 3 + > > sys/i386/conf/MINIMAL | 3 + > > sys/i386/conf/NOTES | 3 + > > sys/x86/include/kvm.h | 80 ++++++++++++++ > > 9 files changed, 340 insertions(+), 1 deletion(-) > > > > diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC > > index f7b41919575d..78b5e0e299f6 100644 > > --- a/sys/amd64/conf/GENERIC > > +++ b/sys/amd64/conf/GENERIC > > @@ -376,6 +376,9 @@ device virtio_blk # VirtIO Block device > > device virtio_scsi # VirtIO SCSI device > > device virtio_balloon # VirtIO Memory Balloon device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # HyperV drivers and enhancement support > > device hyperv # HyperV drivers > > > > diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL > > index 14f91e6c8eaf..f724cbd2e3f1 100644 > > --- a/sys/amd64/conf/MINIMAL > > +++ b/sys/amd64/conf/MINIMAL > > @@ -131,6 +131,9 @@ device ether # Ethernet support > > # Note that 'bpf' is required for DHCP. > > device bpf # Berkeley packet filter > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # Xen HVM Guest Optimizations > > # NOTE: XENHVM depends on xenpci and xentimer. > > # They must be added or removed together. > > diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES > > index 501ceaedb222..c1db8ef7512f 100644 > > --- a/sys/amd64/conf/NOTES > > +++ b/sys/amd64/conf/NOTES > > @@ -498,6 +498,9 @@ device virtio_balloon # VirtIO Memory Balloon device > > device virtio_random # VirtIO Entropy device > > device virtio_console # VirtIO Console device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # Microsoft Hyper-V enhancement support > > device hyperv # HyperV drivers > > > > diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 > > index d1fc234c4182..d0cda2da8580 100644 > > --- a/sys/conf/files.x86 > > +++ b/sys/conf/files.x86 > > @@ -263,6 +263,7 @@ dev/isci/scil/scif_sas_task_request_state_handlers.c optional isci > > dev/isci/scil/scif_sas_task_request_states.c optional isci > > dev/isci/scil/scif_sas_timer.c optional isci > > dev/itwd/itwd.c optional itwd > > +dev/kvm_clock/kvm_clock.c optional kvm_clock > > dev/qat/qat.c optional qat > > dev/qat/qat_ae.c optional qat > > dev/qat/qat_c2xxx.c optional qat > > @@ -318,7 +319,7 @@ x86/x86/x86_mem.c optional mem > > x86/x86/mp_x86.c optional smp > > x86/x86/mp_watchdog.c optional mp_watchdog smp > > x86/x86/nexus.c standard > > -x86/x86/pvclock.c optional xenhvm > > +x86/x86/pvclock.c optional kvm_clock | xenhvm > > x86/x86/stack_machdep.c optional ddb | stack > > x86/x86/tsc.c standard > > x86/x86/ucode.c standard > > diff --git a/sys/dev/kvm_clock/kvm_clock.c b/sys/dev/kvm_clock/kvm_clock.c > > new file mode 100644 > > index 000000000000..1a76432e417d > > --- /dev/null > > +++ b/sys/dev/kvm_clock/kvm_clock.c > > @@ -0,0 +1,240 @@ > > +/*- > > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > > + * > > + * Copyright (c) 2014 Bryan Venteicher > > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > > + * Copyright (c) 2021 Juniper Networks, Inc. > > + * Copyright (c) 2021 Klara, Inc. > > + * > > + * Redistribution and use in source and binary forms, with or without > > + * modification, are permitted provided that the following conditions > > + * are met: > > + * 1. Redistributions of source code must retain the above copyright > > + * notice, this list of conditions and the following disclaimer. > > + * 2. Redistributions in binary form must reproduce the above copyright > > + * notice, this list of conditions and the following disclaimer in the > > + * documentation and/or other materials provided with the distribution. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > > + * SUCH DAMAGE. > > + */ > > + > > +/* > > + * Linux KVM paravirtual clock support > > + * > > + * References: > > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > > + */ > > + > > +#include > > +__FBSDID("$FreeBSD$"); > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > + > > +#include "clock_if.h" > > + > > +#define KVM_CLOCK_DEVNAME "kvmclock" > > +/* > > + * Note: Chosen to be (1) above HPET's value (always 950), (2) above the TSC's > > + * default value of 800, and (3) below the TSC's value when it supports the > > + * "Invariant TSC" feature and is believed to be synchronized across all CPUs. > > + */ > > +#define KVM_CLOCK_TC_QUALITY 975 > > + > > +struct kvm_clock_softc { > > + struct pvclock pvc; > > + struct pvclock_wall_clock wc; > > + struct pvclock_vcpu_time_info *timeinfos; > > + u_int msr_tc; > > + u_int msr_wc; > > +}; > > + > > +static devclass_t kvm_clock_devclass; > > + > > +static struct pvclock_wall_clock *kvm_clock_get_wallclock(void *arg); > > +static void kvm_clock_system_time_enable(struct kvm_clock_softc *sc); > > +static void kvm_clock_system_time_enable_pcpu(void *arg); > > + > > +static struct pvclock_wall_clock * > > +kvm_clock_get_wallclock(void *arg) > > +{ > > + struct kvm_clock_softc *sc = arg; > > + > > + wrmsr(sc->msr_wc, vtophys(&sc->wc)); > > + return (&sc->wc); > > +} > > + > > +static void > > +kvm_clock_system_time_enable(struct kvm_clock_softc *sc) > > +{ > > + smp_rendezvous(NULL, kvm_clock_system_time_enable_pcpu, NULL, sc); > > +} > > + > > +static void > > +kvm_clock_system_time_enable_pcpu(void *arg) > > +{ > > + struct kvm_clock_softc *sc = arg; > > + > > + /* > > + * See [2]; the lsb of this MSR is the system time enable bit. > > + */ > > + wrmsr(sc->msr_tc, vtophys(&(sc->timeinfos)[curcpu]) | 1); > > +} > > + > > +static void > > +kvm_clock_identify(driver_t *driver, device_t parent) > > +{ > > + u_int regs[4]; > > + > > + kvm_cpuid_get_features(regs); > > + if ((regs[0] & > > + (KVM_FEATURE_CLOCKSOURCE2 | KVM_FEATURE_CLOCKSOURCE)) == 0) > > + return; > > + if (device_find_child(parent, KVM_CLOCK_DEVNAME, -1)) > > + return; > > + BUS_ADD_CHILD(parent, 0, KVM_CLOCK_DEVNAME, 0); > > +} > > + > > +static int > > +kvm_clock_probe(device_t dev) > > +{ > > + device_set_desc(dev, "KVM paravirtual clock"); > > + return (BUS_PROBE_DEFAULT); > > +} > > + > > +static int > > +kvm_clock_attach(device_t dev) > > +{ > > + u_int regs[4]; > > + struct kvm_clock_softc *sc = device_get_softc(dev); > > + bool stable_flag_supported; > > + > > + /* Process KVM "features" CPUID leaf content: */ > > + kvm_cpuid_get_features(regs); > > + if ((regs[0] & KVM_FEATURE_CLOCKSOURCE2) != 0) { > > + sc->msr_tc = KVM_MSR_SYSTEM_TIME_NEW; > > + sc->msr_wc = KVM_MSR_WALL_CLOCK_NEW; > > + } else { > > + KASSERT((regs[0] & KVM_FEATURE_CLOCKSOURCE) != 0, > > + ("Clocksource feature flags disappeared since " > > + "kvm_clock_identify: regs[0] %#0x.", regs[0])); > > + sc->msr_tc = KVM_MSR_SYSTEM_TIME; > > + sc->msr_wc = KVM_MSR_WALL_CLOCK; > > + } > > + stable_flag_supported = > > + (regs[0] & KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) != 0; > > + > > + /* Set up 'struct pvclock_vcpu_time_info' page(s): */ > > + sc->timeinfos = (struct pvclock_vcpu_time_info *)kmem_malloc(mp_ncpus * > > + sizeof(struct pvclock_vcpu_time_info), M_WAITOK | M_ZERO); > > + kvm_clock_system_time_enable(sc); > > + > > + /* > > + * Init pvclock; register KVM clock wall clock, register KVM clock > > + * timecounter, and set up the requisite infrastructure for vDSO access > > + * to this timecounter. > > + * Regarding 'tc_flags': Since the KVM MSR documentation does not > > + * specifically discuss suspend/resume scenarios, conservatively > > + * leave 'TC_FLAGS_SUSPEND_SAFE' cleared and assume that the system > > + * time must be re-inited in such cases. > > + */ > > + sc->pvc.get_wallclock = kvm_clock_get_wallclock; > > + sc->pvc.get_wallclock_arg = sc; > > + sc->pvc.timeinfos = sc->timeinfos; > > + sc->pvc.stable_flag_supported = stable_flag_supported; > > + pvclock_init(&sc->pvc, dev, KVM_CLOCK_DEVNAME, KVM_CLOCK_TC_QUALITY, 0); > > + return (0); > > +} > > + > > +static int > > +kvm_clock_detach(device_t dev) > > +{ > > + struct kvm_clock_softc *sc = device_get_softc(dev); > > + > > + return (pvclock_destroy(&sc->pvc)); > > +} > > + > > +static int > > +kvm_clock_suspend(device_t dev) > > +{ > > + return (0); > > +} > > + > > +static int > > +kvm_clock_resume(device_t dev) > > +{ > > + /* > > + * See note in 'kvm_clock_attach()' regarding 'TC_FLAGS_SUSPEND_SAFE'; > > + * conservatively assume that the system time must be re-inited in > > + * suspend/resume scenarios. > > + */ > > + kvm_clock_system_time_enable(device_get_softc(dev)); > > + pvclock_resume(); > > + inittodr(time_second); > > + return (0); > > +} > > + > > +static int > > +kvm_clock_gettime(device_t dev, struct timespec *ts) > > +{ > > + struct kvm_clock_softc *sc = device_get_softc(dev); > > + > > + pvclock_gettime(&sc->pvc, ts); > > + return (0); > > +} > > + > > +static int > > +kvm_clock_settime(device_t dev, struct timespec *ts) > > +{ > > + /* > > + * Even though it is not possible to set the KVM clock's wall clock, to > > + * avoid the possibility of periodic benign error messages from > > + * 'settime_task_func()', report success rather than, e.g., 'ENODEV'. > > + */ > > + return (0); > > +} > > + > > +static device_method_t kvm_clock_methods[] = { > > + DEVMETHOD(device_identify, kvm_clock_identify), > > + DEVMETHOD(device_probe, kvm_clock_probe), > > + DEVMETHOD(device_attach, kvm_clock_attach), > > + DEVMETHOD(device_detach, kvm_clock_detach), > > + DEVMETHOD(device_suspend, kvm_clock_suspend), > > + DEVMETHOD(device_resume, kvm_clock_resume), > > + /* clock interface */ > > + DEVMETHOD(clock_gettime, kvm_clock_gettime), > > + DEVMETHOD(clock_settime, kvm_clock_settime), > > + > > + DEVMETHOD_END > > +}; > > + > > +static driver_t kvm_clock_driver = { > > + KVM_CLOCK_DEVNAME, > > + kvm_clock_methods, > > + sizeof(struct kvm_clock_softc), > > +}; > > + > > +DRIVER_MODULE(kvm_clock, nexus, kvm_clock_driver, kvm_clock_devclass, 0, 0); > > diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC > > index 86c062effd81..5447c452c4f7 100644 > > --- a/sys/i386/conf/GENERIC > > +++ b/sys/i386/conf/GENERIC > > @@ -337,6 +337,9 @@ device virtio_blk # VirtIO Block device > > device virtio_scsi # VirtIO SCSI device > > device virtio_balloon # VirtIO Memory Balloon device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # HyperV drivers and enhancement support > > # NOTE: HYPERV depends on hyperv. They must be added or removed together. > > options HYPERV # Kernel support for HyperV drivers > > diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL > > index 37b8e074ac65..9d735dbb0580 100644 > > --- a/sys/i386/conf/MINIMAL > > +++ b/sys/i386/conf/MINIMAL > > @@ -145,6 +145,9 @@ device gif # IPv6 and IPv4 tunneling > > # Note that 'bpf' is required for DHCP. > > device bpf # Berkeley packet filter > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > # Xen HVM Guest Optimizations > > # NOTE: XENHVM depends on xenpci. They must be added or removed together. > > options XENHVM # Xen HVM kernel infrastructure > > diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES > > index df9ff4fb3aed..27cebf0c48a0 100644 > > --- a/sys/i386/conf/NOTES > > +++ b/sys/i386/conf/NOTES > > @@ -719,6 +719,9 @@ device virtio_balloon # VirtIO Memory Balloon device > > device virtio_random # VirtIO Entropy device > > device virtio_console # VirtIO Console device > > > > +# Linux KVM paravirtualization support > > +device kvm_clock # KVM paravirtual clock driver > > + > > options HYPERV > > device hyperv # HyperV drivers > > > > diff --git a/sys/x86/include/kvm.h b/sys/x86/include/kvm.h > > new file mode 100644 > > index 000000000000..beec6447d7d6 > > --- /dev/null > > +++ b/sys/x86/include/kvm.h > > @@ -0,0 +1,80 @@ > > +/*- > > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > > + * > > + * Copyright (c) 2014 Bryan Venteicher > > + * Copyright (c) 2021 Mathieu Chouquet-Stringer > > + * Copyright (c) 2021 Juniper Networks, Inc. > > + * Copyright (c) 2021 Klara, Inc. > > + * > > + * Redistribution and use in source and binary forms, with or without > > + * modification, are permitted provided that the following conditions > > + * are met: > > + * 1. Redistributions of source code must retain the above copyright > > + * notice, this list of conditions and the following disclaimer. > > + * 2. Redistributions in binary form must reproduce the above copyright > > + * notice, this list of conditions and the following disclaimer in the > > + * documentation and/or other materials provided with the distribution. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > > + * SUCH DAMAGE. > > + * > > + * $FreeBSD$ > > + */ > > + > > +/* > > + * Linux KVM paravirtualization: common definitions > > + * > > + * References: > > + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html > > + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html > > + */ > > + > > +#ifndef _X86_KVM_H_ > > +#define _X86_KVM_H_ > > + > > +#include > > +#include > > + > > +#include > > + > > +#define KVM_CPUID_SIGNATURE 0x40000000 > > +#define KVM_CPUID_FEATURES_LEAF 0x40000001 > > + > > +#define KVM_FEATURE_CLOCKSOURCE 0x00000001 > > +#define KVM_FEATURE_CLOCKSOURCE2 0x00000008 > > +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 0x01000000 > > + > > +/* Deprecated: for the CLOCKSOURCE feature. */ > > +#define KVM_MSR_WALL_CLOCK 0x11 > > +#define KVM_MSR_SYSTEM_TIME 0x12 > > + > > +#define KVM_MSR_WALL_CLOCK_NEW 0x4b564d00 > > +#define KVM_MSR_SYSTEM_TIME_NEW 0x4b564d01 > > + > > +static inline bool > > +kvm_cpuid_features_leaf_supported(void) > > +{ > > + return (vm_guest == VM_GUEST_KVM && > > + KVM_CPUID_FEATURES_LEAF > hv_base && > > + KVM_CPUID_FEATURES_LEAF <= hv_high); > > +} > > + > > +static inline void > > +kvm_cpuid_get_features(u_int *regs) > > +{ > > + if (!kvm_cpuid_features_leaf_supported()) > > + regs[0] = regs[1] = regs[2] = regs[3] = 0; > > + else > > + do_cpuid(KVM_CPUID_FEATURES_LEAF, regs); > > +} > > + > > +#endif /* !_X86_KVM_H_ */ > > > > -- > Colin Percival > Security Officer Emeritus, FreeBSD | The power to serve > Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid From owner-dev-commits-src-all@freebsd.org Sun Aug 29 06:12:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5F11967FF62; Sun, 29 Aug 2021 06:12: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 4Gy35R2HLwz4WPM; Sun, 29 Aug 2021 06: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 374D425651; Sun, 29 Aug 2021 06: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 17T6CR8F086404; Sun, 29 Aug 2021 06: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 17T6CR3d086403; Sun, 29 Aug 2021 06:12:27 GMT (envelope-from git) Date: Sun, 29 Aug 2021 06:12:27 GMT Message-Id: <202108290612.17T6CR3d086403@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: 3dc1a6c2a2e9 - stable/13 - ext2fs(5): Correct a typo in an error message MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3dc1a6c2a2e9ea82582fcff97079f201e7b31d10 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 06:12:27 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3dc1a6c2a2e9ea82582fcff97079f201e7b31d10 commit 3dc1a6c2a2e9ea82582fcff97079f201e7b31d10 Author: Gordon Bergling AuthorDate: 2021-08-22 05:58:22 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 06:12:08 +0000 ext2fs(5): Correct a typo in an error message - s/talbes/tables/ (cherry picked from commit 47f880ebeb3092b1b7bbc6d75e82532e43bbf010) --- sys/fs/ext2fs/ext2_vfsops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 3da8ca6331bc..5bc2e975d310 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -434,7 +434,7 @@ ext2_cg_validate(struct m_ext2fs *fs) } if (i_tables <= last_cg_block) { SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error, - "inode talbes overlaps gds", i); + "inode tables overlaps gds", i); return (EINVAL); } if (i_tables < first_block || From owner-dev-commits-src-all@freebsd.org Sun Aug 29 06:13:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDF8D67FB56; Sun, 29 Aug 2021 06:13: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 4Gy36h5PTHz4Wdd; Sun, 29 Aug 2021 06:13: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 A21BA25855; Sun, 29 Aug 2021 06:13: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 17T6DWmh086623; Sun, 29 Aug 2021 06:13:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T6DWZx086622; Sun, 29 Aug 2021 06:13:32 GMT (envelope-from git) Date: Sun, 29 Aug 2021 06:13:32 GMT Message-Id: <202108290613.17T6DWZx086622@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: e528b1429c51 - stable/12 - ext2fs(5): Correct a typo in an error message MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e528b1429c515cacd05eb0bb78462ebc44236ad0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 06:13:32 -0000 The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=e528b1429c515cacd05eb0bb78462ebc44236ad0 commit e528b1429c515cacd05eb0bb78462ebc44236ad0 Author: Gordon Bergling AuthorDate: 2021-08-22 05:58:22 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 06:13:13 +0000 ext2fs(5): Correct a typo in an error message - s/talbes/tables/ (cherry picked from commit 47f880ebeb3092b1b7bbc6d75e82532e43bbf010) --- sys/fs/ext2fs/ext2_vfsops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 7f9c9690d8a5..a9625ad8ed45 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -433,7 +433,7 @@ ext2_cg_validate(struct m_ext2fs *fs) } if (i_tables <= last_cg_block) { SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error, - "inode talbes overlaps gds", i); + "inode tables overlaps gds", i); return (EINVAL); } if (i_tables < first_block || From owner-dev-commits-src-all@freebsd.org Sun Aug 29 06:38:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 080BE658124; Sun, 29 Aug 2021 06:38: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 4Gy3gh6XF9z4d54; Sun, 29 Aug 2021 06:38: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 C8FFE25B8C; Sun, 29 Aug 2021 06:38: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 17T6cek5013144; Sun, 29 Aug 2021 06:38:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T6ceHv013143; Sun, 29 Aug 2021 06:38:40 GMT (envelope-from git) Date: Sun, 29 Aug 2021 06:38:40 GMT Message-Id: <202108290638.17T6ceHv013143@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 22f5f4a14e97 - main - stress2: Added new msdosfs rename() tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 22f5f4a14e976a9b322ea4abf8af5afe6520ff8e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 06:38:41 -0000 The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=22f5f4a14e976a9b322ea4abf8af5afe6520ff8e commit 22f5f4a14e976a9b322ea4abf8af5afe6520ff8e Author: Peter Holm AuthorDate: 2021-08-29 06:37:54 +0000 Commit: Peter Holm CommitDate: 2021-08-29 06:37:54 +0000 stress2: Added new msdosfs rename() tests --- tools/test/stress2/misc/msdos11.sh | 80 +++++++++++++++++++++++++ tools/test/stress2/misc/msdos12.sh | 89 +++++++++++++++++++++++++++ tools/test/stress2/misc/msdos13.sh | 97 ++++++++++++++++++++++++++++++ tools/test/stress2/misc/msdos14.sh | 119 +++++++++++++++++++++++++++++++++++++ tools/test/stress2/misc/nfs18.sh | 90 ++++++++++++++++++++++++++++ 5 files changed, 475 insertions(+) diff --git a/tools/test/stress2/misc/msdos11.sh b/tools/test/stress2/misc/msdos11.sh new file mode 100755 index 000000000000..af0958686118 --- /dev/null +++ b/tools/test/stress2/misc/msdos11.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257522 +# https://people.freebsd.org/~pho/stress/log/log0158.txt +# Original test scenario by trasz@FreeBSD.org + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +[ -x /sbin/mount_msdosfs ] || exit 0 +log=/tmp/msdos11.log +dir=/tmp +odir=`pwd` +cd $dir +cd $odir +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +set -e +mdconfig -a -t swap -s 4g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null +mount -t msdosfs /dev/md${mdstart}$part $mntpoint +set +e + +(cd $odir/../testcases/swap; ./swap -t 2m -i 20 -l 100) > /dev/null & +sleep 2 +cd $mntpoint +for i in `jot 2`; do + for i in `jot 10000`; do + mkdir a + mv a b + rmdir b + done > /dev/null 2>&1 & +done +wait +cd $odir + +while mount | grep "$mntpoint" | grep -q md$mdstart; do + umount $mntpoint || sleep 1 +done +fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + cat $log + s=1 + + mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 + ls -lR $mntpoint + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm $log +exit $s diff --git a/tools/test/stress2/misc/msdos12.sh b/tools/test/stress2/misc/msdos12.sh new file mode 100755 index 000000000000..0c1c518575e8 --- /dev/null +++ b/tools/test/stress2/misc/msdos12.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# Copy of rename15.sh, modified for msdosfs. + +. ../default.cfg + +[ -x /sbin/mount_msdosfs ] || exit 0 +log=/tmp/msdos12.log + +set -e +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 2g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -F 32 -b 8192 /dev/md$mdstart$part > /dev/null +mount -t msdosfs /dev/md$mdstart$part $mntpoint +mkdir $mntpoint/stressX +chmod 0777 $mntpoint/stressX +set +e + +export LOAD=80 +export MAXSWAPPCT=80 +export RUNDIR=$mntpoint/stressX +export dirnprenameLOAD=100 +export dirrenameLOAD=100 +export renameLOAD=100 +export runRUNTIME=5m +export rwLOAD=80 +export TESTPROGS=' +testcases/rename/rename +testcases/swap/swap +' + +su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' + +../tools/killall.sh +leftover=`find $mntpoint -type f | wc -l` +if [ $leftover -gt 0 ]; then + s=1 + find $mntpoint -type f | head -5 +fi +for i in `jot 6`; do + mount | grep -q "on $mntpoint " || break + umount $mntpoint && break || sleep 10 + [ $i -eq 6 ] && + { echo FATAL; fstat -mf $mntpoint; exit 1; } +done +fsck -t msdosfs -y /dev/md$mdstart$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + echo "fsck problems:" + cat $log + s=2 + + mount -t msdosfs /dev/md$mdstart$part $mntpoint || exit 1 + ls -lR $mntpoint | head -5 + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm -f $log +exit $s diff --git a/tools/test/stress2/misc/msdos13.sh b/tools/test/stress2/misc/msdos13.sh new file mode 100755 index 000000000000..1e6ee205e4f6 --- /dev/null +++ b/tools/test/stress2/misc/msdos13.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# Simple msdosfs rename example + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +[ -x /sbin/mount_msdosfs ] || exit 0 +log=/tmp/msdos13.log + +set -e +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 2g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -F 32 -b 8192 /dev/md$mdstart$part > /dev/null +mount -t msdosfs /dev/md$mdstart$part $mntpoint +mkdir $mntpoint/stressX +chmod 0777 $mntpoint/stressX +set +e + +here=`pwd` +cd $mntpoint/stressX +N=4000 +s=0 +sort /dev/zero & pid=$! +sleep 2 +for j in `jot $N`; do + touch f$i-$j +done +for j in `jot $N`; do + mv f$i-$j g$i-$j + [ -f f$i-$j ] && s=1 +done +for j in `jot $N`; do + mv g$i-$j f$i-$j +done +for j in `jot $N`; do + rm f$i-$j +done +kill $pid +wait +leftover=`find . -type f | wc -l` +if [ $leftover -gt 0 ]; then + echo "Unexpected leftover files:" + s=2 + find . -type f | head -5 +fi +cd $here + +for i in `jot 6`; do + mount | grep -q "on $mntpoint " || break + umount $mntpoint && break || sleep 10 + [ $i -eq 6 ] && + { echo FATAL; fstat -mf $mntpoint; exit 1; } +done +fsck -t msdosfs -y /dev/md$mdstart$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + echo "fsck problems:" + cat $log + s=3 + + mount -t msdosfs /dev/md$mdstart$part $mntpoint || exit 1 + ls -lR $mntpoint | head -5 + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm -f $log +exit $s diff --git a/tools/test/stress2/misc/msdos14.sh b/tools/test/stress2/misc/msdos14.sh new file mode 100755 index 000000000000..1a39d60f0781 --- /dev/null +++ b/tools/test/stress2/misc/msdos14.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# Rename(2) test with msdosfs(5) +# Test scenario by kib@ + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +[ -x /sbin/mount_msdosfs ] || exit 0 +dir=/tmp +odir=`pwd` +cd $dir +cat > /tmp/msdos14.c < +#include +#include +#include +#include +#include +#include + +int +main(void) +{ + struct stat sb; + uint64_t x; + int error, fd; + char from[64], to[64]; + + for (x = 0;; x++) { + snprintf(from, sizeof(from), "x.%" PRIu64 ".from", x); + snprintf(to, sizeof(to), "x.%" PRIu64 ".to", x); + + fd = open(from, O_CREAT | O_TRUNC | O_EXCL, 0666); + if (fd == -1) + err(1, "open %s", from); + close(fd); + error = rename(from, to); + if (error == -1) + err(1, "rename %s %s", from, to); + error = stat(to, &sb); + if (error == -1) + err(1, "stat %s", to); + error = unlink(to); + if (error == -1) + err(1, "unlink %s", to); + } +} + +EOF +cc -o msdos14 -Wall -Wextra -O2 msdos14.c || exit 1 +rm -f msdos14.c +cd $odir +log=/tmp/msdos14sh..log +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +set -e +mdconfig -a -t swap -s 4g -u $mdstart +bsdlabel -w md$mdstart auto +newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null +mount -t msdosfs /dev/md${mdstart}$part $mntpoint +set +e + +cp /tmp/msdos14 $mntpoint +cd $mntpoint + +(cd $odir/../testcases/swap; ./swap -t 5m -i 20 -l 100) > /dev/null & +sleep 2 +timeout 5m ./msdos14 +while pkill swap; do :; done +wait +cd $odir + +while mount | grep "$mntpoint" | grep -q md$mdstart; do + umount $mntpoint || sleep 1 +done +fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 +if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then + echo "fsck issues:" + cat $log + s=1 + + mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 + ls -lR $mntpoint + umount $mntpoint +fi +mdconfig -d -u $mdstart +rm /tmp/msdos14 $log +exit $s diff --git a/tools/test/stress2/misc/nfs18.sh b/tools/test/stress2/misc/nfs18.sh new file mode 100755 index 000000000000..bf9e0fc8010e --- /dev/null +++ b/tools/test/stress2/misc/nfs18.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# msdosfs rename test over nfs loopback mount +# This needs to be in /etc/exports: /mnt -maproot=root 127.0.0.1 + +. ../default.cfg + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +mp1=$mntpoint +mp2=$mntpoint$((mdstart + 1)) +grep -q $mp1 /etc/exports || + { echo "$mp1 missing from /etc/exports"; exit 0; } +[ -x /sbin/mount_msdosfs ] || exit + +mount | grep "$mp2 " | grep nfs > /dev/null && umount -f $mp2 +mount | grep "$mp1 " | grep /md > /dev/null && umount -f $mp1 +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +kill -HUP `pgrep mountd` # loopback workaround +mdconfig -a -t swap -s 1g -u $mdstart +set -e + +bsdlabel -w md$mdstart auto +newfs_msdos -F 32 -b 8192 /dev/md${mdstart}$part > /dev/null +mkdir -p $mp1; chmod 777 $mp1 +mount -t msdosfs -o rw /dev/md${mdstart}$part $mp1 +set +e + +mkdir $mp1/stressX +chmod 777 $mp1/stressX + +mkdir -p $mp2 +chmod 777 $mp2 + +mount -t nfs -o tcp -o retrycnt=3 -o rw \ + 127.0.0.1:$mp1 $mp2; s=$? + +export LOAD=80 +export renameLOAD=100 +export TESTPROGS=" +testcases/rename/rename +testcases/swap/swap +" +export INODES=9999 # No inodes on a msdos fs + +export RUNDIR=$mp2/stressX +export runRUNTIME=2m +if [ $s -eq 0 ]; then + su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' + + for i in `jot 10`; do + umount $mp2 && break + sleep 2 + done +fi +sleep .5 +for i in `jot 10`; do + umount $mp1 && break + sleep 2 +done +mount | grep -q "on $mp1 " && umount -f $mp1 +mdconfig -d -u $mdstart +exit 0 From owner-dev-commits-src-all@freebsd.org Sun Aug 29 07:37:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C951659086; Sun, 29 Aug 2021 07:37: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 4Gy4zp1MDgz4svk; Sun, 29 Aug 2021 07:37: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 1763C267FF; Sun, 29 Aug 2021 07:37: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 17T7bfL9092691; Sun, 29 Aug 2021 07:37:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T7bfhl092690; Sun, 29 Aug 2021 07:37:41 GMT (envelope-from git) Date: Sun, 29 Aug 2021 07:37:41 GMT Message-Id: <202108290737.17T7bfhl092690@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: 606d2063db87 - stable/13 - Enable rc.d/jail within jails 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: 606d2063db873fad4b061566973742ac5143e206 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 07:37:42 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=606d2063db873fad4b061566973742ac5143e206 commit 606d2063db873fad4b061566973742ac5143e206 Author: Dan Langille AuthorDate: 2021-08-15 16:53:16 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 07:37:13 +0000 Enable rc.d/jail within jails Jails with jails is a supported. This change allows the script to run upon startup with a jail. Without this, jails are not automatically started within jails. (cherry picked from commit 35cf9fecbd80f56e39524f480240acfd953c93e1) --- libexec/rc/rc.d/jail | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rc/rc.d/jail b/libexec/rc/rc.d/jail index 1a3b551c9a4c..ff4336131bc9 100755 --- a/libexec/rc/rc.d/jail +++ b/libexec/rc/rc.d/jail @@ -6,7 +6,7 @@ # PROVIDE: jail # REQUIRE: LOGIN FILESYSTEMS # BEFORE: securelevel -# KEYWORD: nojail shutdown +# KEYWORD: shutdown . /etc/rc.subr From owner-dev-commits-src-all@freebsd.org Sun Aug 29 07:37:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9904C659102; Sun, 29 Aug 2021 07:37: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 4Gy4zq1tg3z4t5X; Sun, 29 Aug 2021 07:37: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 14CFF264FD; Sun, 29 Aug 2021 07:37: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 17T7bgL7092777; Sun, 29 Aug 2021 07:37:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T7bgYe092776; Sun, 29 Aug 2021 07:37:42 GMT (envelope-from git) Date: Sun, 29 Aug 2021 07:37:42 GMT Message-Id: <202108290737.17T7bgYe092776@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: b5ead234dc25 - stable/12 - Enable rc.d/jail within jails 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: b5ead234dc25157f0540ed3991859136778616f5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 07:37:43 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b5ead234dc25157f0540ed3991859136778616f5 commit b5ead234dc25157f0540ed3991859136778616f5 Author: Dan Langille AuthorDate: 2021-08-15 16:53:16 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 07:37:32 +0000 Enable rc.d/jail within jails Jails with jails is a supported. This change allows the script to run upon startup with a jail. Without this, jails are not automatically started within jails. (cherry picked from commit 35cf9fecbd80f56e39524f480240acfd953c93e1) --- libexec/rc/rc.d/jail | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rc/rc.d/jail b/libexec/rc/rc.d/jail index 1a3b551c9a4c..ff4336131bc9 100755 --- a/libexec/rc/rc.d/jail +++ b/libexec/rc/rc.d/jail @@ -6,7 +6,7 @@ # PROVIDE: jail # REQUIRE: LOGIN FILESYSTEMS # BEFORE: securelevel -# KEYWORD: nojail shutdown +# KEYWORD: shutdown . /etc/rc.subr From owner-dev-commits-src-all@freebsd.org Sun Aug 29 07:55:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A4026594B3; Sun, 29 Aug 2021 07:55: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 4Gy5NY2K8Nz4yd5; Sun, 29 Aug 2021 07:55: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 2DB8526E04; Sun, 29 Aug 2021 07:55: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 17T7tffk019340; Sun, 29 Aug 2021 07:55:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T7tflB019339; Sun, 29 Aug 2021 07:55:41 GMT (envelope-from git) Date: Sun, 29 Aug 2021 07:55:41 GMT Message-Id: <202108290755.17T7tflB019339@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 2dfcc3a91dd4 - main - isci(4): Fix a common typo in src comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2dfcc3a91dd4d21c16269b7add3141c99dfa48ab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 07:55:41 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=2dfcc3a91dd4d21c16269b7add3141c99dfa48ab commit 2dfcc3a91dd4d21c16269b7add3141c99dfa48ab Author: Gordon Bergling AuthorDate: 2021-08-29 07:55:10 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 07:55:10 +0000 isci(4): Fix a common typo in src comments - s/exlusive/exclusive/ MFC after: 3 days --- sys/dev/isci/isci_timer.c | 2 +- sys/dev/isci/scil/scic_user_callback.h | 2 +- sys/dev/isci/scil/scif_user_callback.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/isci/isci_timer.c b/sys/dev/isci/isci_timer.c index 60dfb63d83eb..9bba29c85242 100644 --- a/sys/dev/isci/isci_timer.c +++ b/sys/dev/isci/isci_timer.c @@ -109,7 +109,7 @@ scif_cb_timer_stop(SCI_CONTROLLER_HANDLE_T controller, void *timer) * a handle for this timer for use in further timer interactions. * * @warning The "timer_callback" method should be executed in a mutually - * exlusive manner from the controller completion handler + * exclusive manner from the controller completion handler * handler (refer to scic_controller_get_handler_methods()). * * @param[in] timer_callback This parameter specifies the callback method diff --git a/sys/dev/isci/scil/scic_user_callback.h b/sys/dev/isci/scil/scic_user_callback.h index 292237062ae3..2260f14c2705 100644 --- a/sys/dev/isci/scil/scic_user_callback.h +++ b/sys/dev/isci/scil/scic_user_callback.h @@ -76,7 +76,7 @@ extern "C" { * a handle for this timer for use in further timer interactions. * * @warning The "timer_callback" method should be executed in a mutually - * exlusive manner from the controller completion handler + * exclusive manner from the controller completion handler * handler (refer to scic_controller_get_handler_methods()). * * @param[in] controller This parameter specifies the controller with diff --git a/sys/dev/isci/scil/scif_user_callback.h b/sys/dev/isci/scil/scif_user_callback.h index 39c6718b6f3e..3a44b772ae20 100644 --- a/sys/dev/isci/scil/scif_user_callback.h +++ b/sys/dev/isci/scil/scif_user_callback.h @@ -80,7 +80,7 @@ extern "C" { * a handle for this timer for use in further timer interactions. * * @warning The "timer_callback" method should be executed in a mutually - * exlusive manner from the controller completion handler + * exclusive manner from the controller completion handler * handler (refer to scic_controller_get_handler_methods()). * * @param[in] timer_callback This parameter specifies the callback method From owner-dev-commits-src-all@freebsd.org Sun Aug 29 08:10:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 039CE659B07; Sun, 29 Aug 2021 08:10: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 4Gy5jl6NMVz52M4; Sun, 29 Aug 2021 08:10: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 C056D2694E; Sun, 29 Aug 2021 08:10: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 17T8AZXN041750; Sun, 29 Aug 2021 08:10:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T8AZiJ041749; Sun, 29 Aug 2021 08:10:35 GMT (envelope-from git) Date: Sun, 29 Aug 2021 08:10:35 GMT Message-Id: <202108290810.17T8AZiJ041749@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 005fe24f2a4c - main - libsa: Fix a typo in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 005fe24f2a4c873a96f446604e0453cf99e9bcd7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 08:10:36 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=005fe24f2a4c873a96f446604e0453cf99e9bcd7 commit 005fe24f2a4c873a96f446604e0453cf99e9bcd7 Author: Gordon Bergling AuthorDate: 2021-08-29 08:09:58 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 08:09:58 +0000 libsa: Fix a typo in source code comments - s/mininum/minimum/ MFC after: 3 days --- stand/libsa/ext2fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/libsa/ext2fs.c b/stand/libsa/ext2fs.c index 068e307253a9..b81654552af3 100644 --- a/stand/libsa/ext2fs.c +++ b/stand/libsa/ext2fs.c @@ -127,8 +127,8 @@ struct fs_ops ext2fs_fsops = { #define EXT2_R0_ISIZE 128 /* inode size */ #define EXT2_R0_FIRSTINO 11 /* first inode */ -#define EXT2_MINBSHIFT 10 /* mininum block shift */ -#define EXT2_MINFSHIFT 10 /* mininum frag shift */ +#define EXT2_MINBSHIFT 10 /* minimum block shift */ +#define EXT2_MINFSHIFT 10 /* minimum frag shift */ #define EXT2_NDADDR 12 /* # of direct blocks */ #define EXT2_NIADDR 3 /* # of indirect blocks */ From owner-dev-commits-src-all@freebsd.org Sun Aug 29 08:26:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4A581659CBF; Sun, 29 Aug 2021 08:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy64G1P4Kz56pH; Sun, 29 Aug 2021 08:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 157B12738F; Sun, 29 Aug 2021 08:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17T8QbYg059863; Sun, 29 Aug 2021 08:26:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T8QbZM059862; Sun, 29 Aug 2021 08:26:37 GMT (envelope-from git) Date: Sun, 29 Aug 2021 08:26:37 GMT Message-Id: <202108290826.17T8QbZM059862@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: a58e222b3bcc - main - vfs: yield in vn_deallocate_impl() loop MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a58e222b3bcc5294ffbff88ff5f4c8d88b9dc324 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 08:26:38 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=a58e222b3bcc5294ffbff88ff5f4c8d88b9dc324 commit a58e222b3bcc5294ffbff88ff5f4c8d88b9dc324 Author: Ka Ho Ng AuthorDate: 2021-08-29 08:26:00 +0000 Commit: Ka Ho Ng CommitDate: 2021-08-29 08:26:00 +0000 vfs: yield in vn_deallocate_impl() loop Yield at the end of each loop iteration if there are remaining works as indicated by the value of *len updated by VOP_DEALLOCATE. Without this, when calling vop_stddeallocate to zero a large region, the implementation only zerofills a relatively small chunk and returns. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31705 --- sys/kern/vfs_vnops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3fce590519a8..bd512f73eae5 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3519,6 +3519,8 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, mp = NULL; } } + if (error == 0 && len != 0) + maybe_yield(); } out: if (rl_cookie != NULL) From owner-dev-commits-src-all@freebsd.org Sun Aug 29 09:45:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 19B3C65AFB7; Sun, 29 Aug 2021 09:45: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 4Gy7qK73K7z3lgR; Sun, 29 Aug 2021 09:45: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 DB74816F; Sun, 29 Aug 2021 09:45: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 17T9jX1n066009; Sun, 29 Aug 2021 09:45:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17T9jXLG066008; Sun, 29 Aug 2021 09:45:33 GMT (envelope-from git) Date: Sun, 29 Aug 2021 09:45:33 GMT Message-Id: <202108290945.17T9jXLG066008@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 5d785ad65e00 - main - Fix a common typo in source code comments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d785ad65e000f9ff636a777599bfa414b88d970 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 09:45:34 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5d785ad65e000f9ff636a777599bfa414b88d970 commit 5d785ad65e000f9ff636a777599bfa414b88d970 Author: Gordon Bergling AuthorDate: 2021-08-29 09:45:09 +0000 Commit: Gordon Bergling CommitDate: 2021-08-29 09:45:09 +0000 Fix a common typo in source code comments - s/concurently/concurrently/ MFC after: 3 days --- sys/dev/acpica/acpi_video.c | 2 +- sys/dev/aic7xxx/aic79xx.h | 2 +- sys/dev/gpio/gpiopps.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi_video.c b/sys/dev/acpica/acpi_video.c index dc4a4385f3b5..917c6548f3a2 100644 --- a/sys/dev/acpica/acpi_video.c +++ b/sys/dev/acpica/acpi_video.c @@ -233,7 +233,7 @@ acpi_video_push_evdev_event(struct evdev_dev *evdev, UINT32 notify) int i; uint16_t key; - /* Do not allow to execute 2 instances this routine concurently */ + /* Do not allow to execute 2 instances this routine concurrently */ ACPI_SERIAL_ASSERT(video_output); for (i = 0; i < nitems(acpi_video_evdev_map); i++) { diff --git a/sys/dev/aic7xxx/aic79xx.h b/sys/dev/aic7xxx/aic79xx.h index bb3949c5f749..42059a351271 100644 --- a/sys/dev/aic7xxx/aic79xx.h +++ b/sys/dev/aic7xxx/aic79xx.h @@ -288,7 +288,7 @@ typedef enum { */ AHD_NONPACKFIFO_BUG = 0x4000, /* - * Writing to a DFF SCBPTR register may fail if concurent with + * Writing to a DFF SCBPTR register may fail if concurrent with * a hardware write to the other DFF SCBPTR register. This is * not currently a concern in our sequencer since all chips with * this bug have the AHD_NONPACKFIFO_BUG and all writes of concern diff --git a/sys/dev/gpio/gpiopps.c b/sys/dev/gpio/gpiopps.c index 8a6f1a6a3f6b..4700acf19bcd 100644 --- a/sys/dev/gpio/gpiopps.c +++ b/sys/dev/gpio/gpiopps.c @@ -130,7 +130,7 @@ gpiopps_ifltr(void *arg) * written only by the pps_capture() routine and read only by the * pps_event() routine. We don't need lock-based management of access * to the capture area because we have time-based access management: we - * can't be reading and writing concurently because we can't be running + * can't be reading and writing concurrently because we can't be running * both the threaded and filter handlers concurrently (because a new * hardware interrupt can't happen until the threaded handler for the * current interrupt exits, after which the system does the EOI that From owner-dev-commits-src-all@freebsd.org Sun Aug 29 10:30:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFF0165BB83; Sun, 29 Aug 2021 10:30:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy8pq6Fh5z4TZh; Sun, 29 Aug 2021 10:30:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB3C5D20; Sun, 29 Aug 2021 10:30:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TAUBod023668; Sun, 29 Aug 2021 10:30:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TAUB7k023658; Sun, 29 Aug 2021 10:30:11 GMT (envelope-from git) Date: Sun, 29 Aug 2021 10:30:11 GMT Message-Id: <202108291030.17TAUB7k023658@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 38a2bbfa12b5 - stable/13 - googletest: Silence warnings about deprecated implicit copy constructors MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 38a2bbfa12b5a16a2bcbc6c57ae7cd4b66a1aa1c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 10:30:12 -0000 The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=38a2bbfa12b5a16a2bcbc6c57ae7cd4b66a1aa1c commit 38a2bbfa12b5a16a2bcbc6c57ae7cd4b66a1aa1c Author: Dimitry Andric AuthorDate: 2021-08-26 20:06:49 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 10:29:21 +0000 googletest: Silence warnings about deprecated implicit copy constructors Our copy of googletest is rather stale, and causes a number of -Werror warnings about implicit copy constructor definitions being deprecated, because several classes have user-declared copy assignment operators. Silence the warnings until we either upgrade or remove googletest. (cherry picked from commit d396c67f26b079c2808002c07212d9df9818a11b) --- lib/googletest/Makefile.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc index 36f7228c079b..b77322df4ee2 100644 --- a/lib/googletest/Makefile.inc +++ b/lib/googletest/Makefile.inc @@ -10,3 +10,6 @@ CXXFLAGS+= ${GTESTS_FLAGS} # Silence warnings about usage of deprecated std::auto_ptr CXXWARNFLAGS+= -Wno-deprecated-declarations + +# Silence warnings about usage of deprecated implicit copy constructors +CXXWARNFLAGS+= -Wno-deprecated-copy From owner-dev-commits-src-all@freebsd.org Sun Aug 29 10:30:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 457F065B7AB; Sun, 29 Aug 2021 10:30:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gy8ps0Lbqz4Thw; Sun, 29 Aug 2021 10:30: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 D2CF4B3C; Sun, 29 Aug 2021 10:30:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TAUCWw024164; Sun, 29 Aug 2021 10:30:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TAUC2Q024158; Sun, 29 Aug 2021 10:30:12 GMT (envelope-from git) Date: Sun, 29 Aug 2021 10:30:12 GMT Message-Id: <202108291030.17TAUC2Q024158@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: ab18f56db464 - stable/13 - Cleanup compiler warning flags in lib/libefivar/Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ab18f56db464707c8e1c4136e960edddb56cb925 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 10:30:13 -0000 The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=ab18f56db464707c8e1c4136e960edddb56cb925 commit ab18f56db464707c8e1c4136e960edddb56cb925 Author: Dimitry Andric AuthorDate: 2021-08-26 18:53:18 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 10:29:26 +0000 Cleanup compiler warning flags in lib/libefivar/Makefile There is no need to set -Wno-unused-parameter twice, and instead of appending to CFLAGS, append to CWARNFLAGS instead. While here, add -Wno-unused-but-set-variable for the sake of clang 13.0.0. (cherry picked from commit f643997a1761689ef9108d69b86d42881ea0ab1c) --- lib/libefivar/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libefivar/Makefile b/lib/libefivar/Makefile index 3c6b17333407..c1503f4e5b62 100644 --- a/lib/libefivar/Makefile +++ b/lib/libefivar/Makefile @@ -43,8 +43,7 @@ MAN= efivar.3 CFLAGS+= -I${EFIBOOT}/include CFLAGS+= -I${.CURDIR} -I${EDK2INC} - -CFLAGS.efivar-dp-format.c=-Wno-unused-parameter +CFLAGS+= -fno-strict-aliasing MLINKS+=efivar.3 efi_set_variables_supported.3 \ efivar.3 efi_del_variable.3 \ @@ -65,4 +64,9 @@ WARNS?= 9 .include -CFLAGS+= -fno-strict-aliasing -Wno-cast-align -Wno-unused-parameter +CWARNFLAGS+= -Wno-cast-align +CWARNFLAGS+= -Wno-unused-parameter + +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 130000 +CWARNFLAGS+= -Wno-unused-but-set-variable +.endif From owner-dev-commits-src-all@freebsd.org Sun Aug 29 10:50:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F96965B7ED; Sun, 29 Aug 2021 10:50: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 4Gy9Gc3YtQz4Z9y; Sun, 29 Aug 2021 10:50: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 62EB0102D; Sun, 29 Aug 2021 10:50: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 17TAomdG058132; Sun, 29 Aug 2021 10:50:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TAommP058131; Sun, 29 Aug 2021 10:50:48 GMT (envelope-from git) Date: Sun, 29 Aug 2021 10:50:48 GMT Message-Id: <202108291050.17TAommP058131@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: befc47822966 - stable/12 - Do a sweep and remove most WARNS=6 settings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: befc478229660bca9cbda38d73f6b9d7c8918ded Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 10:50:48 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=befc478229660bca9cbda38d73f6b9d7c8918ded commit befc478229660bca9cbda38d73f6b9d7c8918ded Author: Kyle Evans AuthorDate: 2020-10-01 01:10:51 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 10:49:28 +0000 Do a sweep and remove most WARNS=6 settings Repeating the default WARNS here makes it slightly more difficult to experiment with default WARNS changes, e.g. if we did something absolutely bananas and introduced a WARNS=7 and wanted to try lifting the default to that. Drop most of them; there is one in the blake2 kernel module, but I suspect it should be dropped -- the default WARNS in the rest of the build doesn't currently apply to kernel modules, and I haven't put too much thought into whether it makes sense to make it so. (cherry picked from commit 7cc42f6d25ef2e19059d088fa7d4853fe9afefb5) --- cddl/Makefile.inc | 2 - gnu/usr.bin/dialog/Makefile | 2 - lib/googletest/Makefile.inc | 2 - lib/libcam/tests/Makefile | 2 - lib/libcrypt/tests/Makefile | 1 - lib/libiconv_modules/Makefile.inc | 1 - lib/libkvm/Makefile | 2 - lib/libkvm/tests/Makefile | 2 - lib/libpathconv/tests/Makefile | 1 - lib/libproc/tests/Makefile | 1 - lib/libsbuf/tests/Makefile | 2 - libexec/Makefile.inc | 1 - libexec/getty/Makefile | 1 - libexec/rtld-elf/Makefile | 1 - libexec/rtld-elf/tests/libpythagoras/Makefile | 1 - libexec/tftpd/tests/Makefile | 1 - sbin/decryptcore/Makefile | 2 - sbin/ping/tests/Makefile | 2 - sbin/recoverdisk/Makefile | 2 + sys/teken/demo/Makefile | 2 - sys/teken/libteken/Makefile | 1 - sys/teken/stress/Makefile | 2 - tests/sys/Makefile.inc | 2 - tests/sys/aio/Makefile | 2 - tests/sys/audit/Makefile | 2 - tests/sys/auditpipe/Makefile | 2 +- tests/sys/capsicum/Makefile | 43 +++++++++++++++++++++- tests/sys/fs/fusefs/Makefile | 2 - tests/sys/kern/pipe/Makefile | 2 - tests/sys/mqueue/Makefile | 2 - tests/sys/net/Makefile | 2 +- tests/sys/netinet/Makefile | 2 - tests/sys/netmap/Makefile | 2 - tests/sys/opencrypto/Makefile | 2 - tests/sys/pjdfstest/pjdfstest/Makefile | 2 - tools/regression/aio/aiop/Makefile | 2 - tools/regression/bpf/bpf_filter/Makefile | 1 - tools/regression/doat/Makefile | 1 - tools/regression/geom_gpt/Makefile | 2 - tools/regression/include/stdatomic/Makefile | 1 - tools/regression/netinet/ipbroadcast/Makefile | 2 - tools/regression/rpcsec_gss/Makefile | 1 - tools/regression/sockets/accept_fd_leak/Makefile | 1 - tools/regression/sockets/accf_data_attach/Makefile | 1 - tools/regression/sockets/fstat/Makefile | 1 - tools/regression/sockets/kqueue/Makefile | 1 - tools/regression/sockets/listen_backlog/Makefile | 1 - tools/regression/sockets/listen_kqueue/Makefile | 1 - tools/regression/sockets/listenclose/Makefile | 1 - tools/regression/sockets/pr_atomic/Makefile | 1 - tools/regression/sockets/reconnect/Makefile | 1 - tools/regression/sockets/rtsocket/Makefile | 1 - tools/regression/sockets/sblock/Makefile | 1 - tools/regression/sockets/sendfile/Makefile | 1 - tools/regression/sockets/shutdown/Makefile | 1 - tools/regression/sockets/sigpipe/Makefile | 1 - tools/regression/sockets/so_setfib/Makefile | 1 - tools/regression/sockets/udp_pingpong/Makefile | 1 - tools/regression/sockets/unix_bindconnect/Makefile | 1 - tools/regression/sockets/unix_close_race/Makefile | 1 - tools/regression/sockets/unix_gc/Makefile | 1 - tools/regression/sockets/unix_sendtorace/Makefile | 1 - tools/regression/sockets/unix_socket/Makefile | 1 - tools/regression/sockets/unix_sorflush/Makefile | 1 - tools/regression/sockets/zerosend/Makefile | 1 - tools/test/auxinfo/Makefile | 1 - tools/test/iconv/posix/Makefile | 2 - tools/test/malloc/Makefile | 1 - tools/test/net/Makefile | 1 - tools/test/netfibs/Makefile | 1 - tools/test/ptrace/Makefile | 1 - tools/tools/aac/Makefile | 1 - tools/tools/cfi/Makefile | 1 - tools/tools/find-sb/Makefile | 1 - tools/tools/fixwhite/Makefile | 1 - tools/tools/gensnmpdef/Makefile | 2 - tools/tools/ifpifa/Makefile | 1 - tools/tools/ioat/Makefile | 2 - tools/tools/iwi/Makefile | 1 - tools/tools/ncpus/Makefile | 1 - tools/tools/pciroms/Makefile | 2 - tools/tools/syscall_timing/Makefile | 2 - tools/tools/tscdrift/Makefile | 1 - tools/tools/vt/mkkfont/Makefile | 4 +- usr.bin/dpv/Makefile | 2 - usr.bin/getconf/tests/Makefile | 2 - usr.bin/mkimg/Makefile | 2 - usr.bin/posixshmcontrol/Makefile | 1 - usr.bin/proccontrol/Makefile | 1 - usr.bin/protect/Makefile | 1 - usr.sbin/bsdinstall/distextract/Makefile | 1 - usr.sbin/bsdinstall/distfetch/Makefile | 1 - usr.sbin/bsnmpd/tools/Makefile.inc | 2 - usr.sbin/ctld/Makefile | 1 - usr.sbin/iovctl/Makefile | 2 - usr.sbin/mlx5tool/Makefile | 1 - usr.sbin/pw/tests/Makefile | 1 - 97 files changed, 48 insertions(+), 131 deletions(-) diff --git a/cddl/Makefile.inc b/cddl/Makefile.inc index 94a42492a4f0..687068d599e8 100644 --- a/cddl/Makefile.inc +++ b/cddl/Makefile.inc @@ -7,8 +7,6 @@ IGNORE_PRAGMA= YES CFLAGS+= -DNEED_SOLARIS_BOOLEAN -WARNS?= 6 - # Do not lint the CDDL stuff. It is all externally maintained and # lint output is wasteful noise here. diff --git a/gnu/usr.bin/dialog/Makefile b/gnu/usr.bin/dialog/Makefile index bcca9b353303..71496f774830 100644 --- a/gnu/usr.bin/dialog/Makefile +++ b/gnu/usr.bin/dialog/Makefile @@ -7,6 +7,4 @@ LIBADD= dialog ncursesw m CFLAGS+= -I${.CURDIR} -I${DIALOG} .PATH: ${DIALOG} -WARNS?= 6 - .include diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc index 319ce6ec7ec6..36f7228c079b 100644 --- a/lib/googletest/Makefile.inc +++ b/lib/googletest/Makefile.inc @@ -10,5 +10,3 @@ CXXFLAGS+= ${GTESTS_FLAGS} # Silence warnings about usage of deprecated std::auto_ptr CXXWARNFLAGS+= -Wno-deprecated-declarations - -WARNS?= 6 diff --git a/lib/libcam/tests/Makefile b/lib/libcam/tests/Makefile index 178c30805f92..89e59ca9932e 100644 --- a/lib/libcam/tests/Makefile +++ b/lib/libcam/tests/Makefile @@ -5,6 +5,4 @@ ATF_TESTS_C+= cam_test LIBADD+= cam -WARNS?= 6 - .include diff --git a/lib/libcrypt/tests/Makefile b/lib/libcrypt/tests/Makefile index 22b7fccccbba..15798b215d17 100644 --- a/lib/libcrypt/tests/Makefile +++ b/lib/libcrypt/tests/Makefile @@ -4,7 +4,6 @@ ATF_TESTS_C+= crypt_tests NETBSD_ATF_TESTS_C+= crypt_test -WARNS?= 6 CFLAGS+= -I${.CURDIR:H} LIBADD= crypt diff --git a/lib/libiconv_modules/Makefile.inc b/lib/libiconv_modules/Makefile.inc index d42473637534..556997404f99 100644 --- a/lib/libiconv_modules/Makefile.inc +++ b/lib/libiconv_modules/Makefile.inc @@ -3,7 +3,6 @@ .PATH: ${SRCTOP}/lib/libc/iconv SHLIB_MAJOR= 4 -WARNS?= 6 CFLAGS+= -I${SRCTOP}/lib/libc/iconv CFLAGS+= -Dbool=_Bool diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile index d934690d4355..6afb8c4ad2e1 100644 --- a/lib/libkvm/Makefile +++ b/lib/libkvm/Makefile @@ -8,8 +8,6 @@ SHLIBDIR?= /lib SHLIB_MAJOR= 7 CFLAGS+=-DNO__SCCSID -I${.CURDIR} -WARNS?= 6 - SRCS= kvm.c kvm_cptime.c kvm_getloadavg.c \ kvm_getswapinfo.c kvm_pcpu.c kvm_private.c kvm_proc.c kvm_vnet.c \ kvm_minidump_aarch64.c \ diff --git a/lib/libkvm/tests/Makefile b/lib/libkvm/tests/Makefile index 24caf9108883..1f74aec83f02 100644 --- a/lib/libkvm/tests/Makefile +++ b/lib/libkvm/tests/Makefile @@ -13,8 +13,6 @@ CFLAGS.kvm_read_test+= -I${.CURDIR:H} LIBADD+= kvm -WARNS?= 6 - BINDIR= ${TESTSDIR} .for t in kvm_geterr_test kvm_open_test kvm_open2_test kvm_read_test diff --git a/lib/libpathconv/tests/Makefile b/lib/libpathconv/tests/Makefile index f32db22c1db8..c7696c2d6c5d 100644 --- a/lib/libpathconv/tests/Makefile +++ b/lib/libpathconv/tests/Makefile @@ -3,7 +3,6 @@ TAP_TESTS_C+= abs2rel TAP_TESTS_C+= rel2abs -WARNS?= 6 #LIBADD+= pathconv #LDADD+= -L .. -lpathconv LDADD+= ../libpathconv.a diff --git a/lib/libproc/tests/Makefile b/lib/libproc/tests/Makefile index 8c7563a33ca6..93f50789c88c 100644 --- a/lib/libproc/tests/Makefile +++ b/lib/libproc/tests/Makefile @@ -6,7 +6,6 @@ PROGS= target_prog SRCS_target_prog= target_prog.c BINDIR_target_prog= ${TESTSDIR} -WARNS?= 6 LIBADD= elf proc rtld_db util # Ensure that symbols aren't stripped from the test program, as they're needed diff --git a/lib/libsbuf/tests/Makefile b/lib/libsbuf/tests/Makefile index d3532f01b7b6..b563ebfe1728 100644 --- a/lib/libsbuf/tests/Makefile +++ b/lib/libsbuf/tests/Makefile @@ -6,6 +6,4 @@ ATF_TESTS_C+= sbuf_string_test LIBADD+= sbuf util -WARNS?= 6 - .include diff --git a/libexec/Makefile.inc b/libexec/Makefile.inc index 7b6a65fc7172..5a94bbf52a4b 100644 --- a/libexec/Makefile.inc +++ b/libexec/Makefile.inc @@ -3,5 +3,4 @@ BINDIR?= /usr/libexec -WARNS?= 6 WFORMAT?= 1 diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile index ff4b91157511..a65d1d7da981 100644 --- a/libexec/getty/Makefile +++ b/libexec/getty/Makefile @@ -7,7 +7,6 @@ SRCS= main.c init.c subr.c chat.c LIBADD= util MAN= gettytab.5 ttys.5 getty.8 -WARNS?= 6 WFORMAT=0 .include diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index a51acf68068a..48fd4f6f01c0 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -42,7 +42,6 @@ LDFLAGS+= -nostdlib -e .rtld_start .endif NO_WCAST_ALIGN= yes -WARNS?= 6 INSTALLFLAGS= -C -b PRECIOUSPROG= BINDIR= /libexec diff --git a/libexec/rtld-elf/tests/libpythagoras/Makefile b/libexec/rtld-elf/tests/libpythagoras/Makefile index 7c9583960953..9ad4b883015c 100644 --- a/libexec/rtld-elf/tests/libpythagoras/Makefile +++ b/libexec/rtld-elf/tests/libpythagoras/Makefile @@ -10,7 +10,6 @@ SHLIBDIR= ${TESTSBASE}/libexec/rtld-elf SRCS= pythagoras.c -WARNS?= 6 LIBADD= m .include diff --git a/libexec/tftpd/tests/Makefile b/libexec/tftpd/tests/Makefile index 9aa420cec1a5..fb5212e2ad6f 100644 --- a/libexec/tftpd/tests/Makefile +++ b/libexec/tftpd/tests/Makefile @@ -9,7 +9,6 @@ TEST_METADATA.functional+= timeout=15 .endif LIBADD= util -WARNS?= 6 CSTD= c11 .include diff --git a/sbin/decryptcore/Makefile b/sbin/decryptcore/Makefile index 423bca9c454e..3a3a6a029f87 100644 --- a/sbin/decryptcore/Makefile +++ b/sbin/decryptcore/Makefile @@ -8,6 +8,4 @@ MAN= decryptcore.8 CFLAGS+=-I${SRCTOP}/lib/libpjdlog -WARNS?= 6 - .include diff --git a/sbin/ping/tests/Makefile b/sbin/ping/tests/Makefile index 678641562d93..2d5082ac839b 100644 --- a/sbin/ping/tests/Makefile +++ b/sbin/ping/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -WARNS?= 6 - ATF_TESTS_C+= in_cksum_test SRCS.in_cksum_test= in_cksum_test.c ../utils.c diff --git a/sbin/recoverdisk/Makefile b/sbin/recoverdisk/Makefile index 41ef1f3e4912..2094ad29d54b 100644 --- a/sbin/recoverdisk/Makefile +++ b/sbin/recoverdisk/Makefile @@ -3,6 +3,8 @@ PACKAGE=runtime PROG= recoverdisk +LDFLAGS += -lm + .include test: ${PROG} diff --git a/sys/teken/demo/Makefile b/sys/teken/demo/Makefile index 1ade690afe22..e39c5742bc96 100644 --- a/sys/teken/demo/Makefile +++ b/sys/teken/demo/Makefile @@ -4,6 +4,4 @@ PROG= teken_demo LDADD= -lncursesw -lteken -lutil MAN= -WARNS?= 6 - .include diff --git a/sys/teken/libteken/Makefile b/sys/teken/libteken/Makefile index d1c9d3c9da70..20ec0aff0faa 100644 --- a/sys/teken/libteken/Makefile +++ b/sys/teken/libteken/Makefile @@ -4,7 +4,6 @@ LIB= teken SHLIB_MAJOR= 0 CFLAGS+=-I. -WARNS?= 6 SRCDIR= ${.CURDIR}/.. .PATH: ${SRCDIR} diff --git a/sys/teken/stress/Makefile b/sys/teken/stress/Makefile index 7216da0bd60d..9a0257f02760 100644 --- a/sys/teken/stress/Makefile +++ b/sys/teken/stress/Makefile @@ -4,6 +4,4 @@ PROG= teken_stress LDADD= -lteken MAN= -WARNS?= 6 - .include diff --git a/tests/sys/Makefile.inc b/tests/sys/Makefile.inc index 0b336d3f3ef3..2cba822015ae 100644 --- a/tests/sys/Makefile.inc +++ b/tests/sys/Makefile.inc @@ -1,5 +1,3 @@ # $FreeBSD$ -WARNS?= 6 - .include "${SRCTOP}/tests/Makefile.inc0" diff --git a/tests/sys/aio/Makefile b/tests/sys/aio/Makefile index ef44036bf3d8..db9da144c43b 100644 --- a/tests/sys/aio/Makefile +++ b/tests/sys/aio/Makefile @@ -17,6 +17,4 @@ LIBADD.lio_test+= rt CFLAGS+= -I${.CURDIR:H:H} -WARNS?= 6 - .include diff --git a/tests/sys/audit/Makefile b/tests/sys/audit/Makefile index 6f70121da14f..01bdc6754ef7 100644 --- a/tests/sys/audit/Makefile +++ b/tests/sys/audit/Makefile @@ -51,8 +51,6 @@ TEST_METADATA+= required_user="root" TEST_METADATA+= is_exclusive="true" TEST_METADATA+= required_files="/etc/rc.d/auditd" -WARNS?= 6 - LDFLAGS+= -lbsm -lutil .include diff --git a/tests/sys/auditpipe/Makefile b/tests/sys/auditpipe/Makefile index 9610599a22b6..ac7715d57f5d 100644 --- a/tests/sys/auditpipe/Makefile +++ b/tests/sys/auditpipe/Makefile @@ -5,6 +5,6 @@ TESTSDIR= ${TESTSBASE}/sys/auditpipe ATF_TESTS_C= auditpipe_test TEST_METADATA+= required_user="root" -WARNS?= 6 +TEST_METADATA+= required_files="/dev/auditpipe" .include diff --git a/tests/sys/capsicum/Makefile b/tests/sys/capsicum/Makefile index 6b0e53fa0865..9c69b6ac856b 100644 --- a/tests/sys/capsicum/Makefile +++ b/tests/sys/capsicum/Makefile @@ -7,6 +7,47 @@ ATF_TESTS_C+= ioctls_test CFLAGS+= -I${SRCTOP}/tests -WARNS?= 6 +.if ${MK_GOOGLETEST} != no + +.PATH: ${SRCTOP}/contrib/capsicum-test + +GTESTS+= capsicum-test + +SRCS.capsicum-test+= \ + capsicum-test-main.cc \ + capsicum-test.cc \ + capability-fd.cc \ + fexecve.cc \ + procdesc.cc \ + capmode.cc \ + fcntl.cc \ + ioctl.cc \ + openat.cc \ + sysctl.cc \ + select.cc \ + mqueue.cc \ + socket.cc \ + sctp.cc \ + capability-fd-pair.cc \ + overhead.cc \ + rename.cc + +LIBADD.capsicum-test+= gtest pthread +TEST_METADATA.capsicum-test= required_user="unprivileged" + +.for p in mini-me mini-me.noexec mini-me.setuid +PROGS+= $p +NO_SHARED.$p= +SRCS.$p= mini-me.c +.endfor + +BINDIR= ${TESTSDIR} + +BINMODE.mini-me.noexec= ${NOBINMODE} +BINMODE.mini-me.setuid= 4555 + +WARNS.capsicum-test= 3 + +.endif .include diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile index c3cf1f14e5bf..413998950ee2 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -85,6 +85,4 @@ LIBADD+= pthread LIBADD+= gmock gtest LIBADD+= util -WARNS?= 6 - .include diff --git a/tests/sys/kern/pipe/Makefile b/tests/sys/kern/pipe/Makefile index 193676465aa3..9211700ada98 100644 --- a/tests/sys/kern/pipe/Makefile +++ b/tests/sys/kern/pipe/Makefile @@ -12,6 +12,4 @@ PLAIN_TESTS_C+= pipe_reverse2_test PLAIN_TESTS_C+= pipe_reverse_test PLAIN_TESTS_C+= pipe_wraparound_test -WARNS?= 6 - .include diff --git a/tests/sys/mqueue/Makefile b/tests/sys/mqueue/Makefile index 251c497e32e4..861694e0b353 100644 --- a/tests/sys/mqueue/Makefile +++ b/tests/sys/mqueue/Makefile @@ -16,6 +16,4 @@ PROGS+= mqtest5 LIBADD+= rt -WARNS?= 6 - .include diff --git a/tests/sys/net/Makefile b/tests/sys/net/Makefile index cccabd9fc775..b14d6cbf8253 100644 --- a/tests/sys/net/Makefile +++ b/tests/sys/net/Makefile @@ -28,6 +28,6 @@ ${PACKAGE}FILESMODE_stp.py= 0555 MAN= PROGS+= randsleep -WARNS?= 6 +CFLAGS+= -I${.CURDIR:H:H} .include diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index f5b465557282..3bb99af8b88b 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -14,6 +14,4 @@ PROGS= udp_dontroute tcp_user_cookie MAN= -WARNS?= 6 - .include diff --git a/tests/sys/netmap/Makefile b/tests/sys/netmap/Makefile index a1d61ddf8952..0228271dd668 100644 --- a/tests/sys/netmap/Makefile +++ b/tests/sys/netmap/Makefile @@ -11,6 +11,4 @@ PLAIN_TESTS_C+= ctrl-api-test CFLAGS+= -I${SRCTOP}/tests LIBADD+= pthread -WARNS?= 6 - .include diff --git a/tests/sys/opencrypto/Makefile b/tests/sys/opencrypto/Makefile index f9685b166afc..a0094091ecc6 100644 --- a/tests/sys/opencrypto/Makefile +++ b/tests/sys/opencrypto/Makefile @@ -21,6 +21,4 @@ PYMODULES= cryptodev.py cryptodevh.py cryptotest.py ${PACKAGE}FILES+= ${PYMODULES} -WARNS?= 6 - .include diff --git a/tests/sys/pjdfstest/pjdfstest/Makefile b/tests/sys/pjdfstest/pjdfstest/Makefile index e676cc036bad..53e29c3891fb 100644 --- a/tests/sys/pjdfstest/pjdfstest/Makefile +++ b/tests/sys/pjdfstest/pjdfstest/Makefile @@ -10,6 +10,4 @@ MAN= CFLAGS+= -I${.CURDIR:H} -WARNS?= 6 - .include diff --git a/tools/regression/aio/aiop/Makefile b/tools/regression/aio/aiop/Makefile index 38d9db62266a..aac9a3b89e45 100644 --- a/tools/regression/aio/aiop/Makefile +++ b/tools/regression/aio/aiop/Makefile @@ -3,6 +3,4 @@ PROG= aiop MAN= -WARNS= 6 - .include diff --git a/tools/regression/bpf/bpf_filter/Makefile b/tools/regression/bpf/bpf_filter/Makefile index d0038f915239..e01a54e26cb3 100644 --- a/tools/regression/bpf/bpf_filter/Makefile +++ b/tools/regression/bpf/bpf_filter/Makefile @@ -46,7 +46,6 @@ SRCS+= ${SYSDIR}/net/bpf_jitter.c \ ${SYSDIR}/${MACHINE_ARCH}/${MACHINE_ARCH}/bpf_jit_machdep.c CFLAGS+= -DBPF_JIT_COMPILER LIBS+= -lutil -WARNS?= 6 .else SRCS+= ${SYSDIR}/net/bpf_filter.c WARNS?= 2 diff --git a/tools/regression/doat/Makefile b/tools/regression/doat/Makefile index c04223bbfec8..c31ca53f4579 100644 --- a/tools/regression/doat/Makefile +++ b/tools/regression/doat/Makefile @@ -3,6 +3,5 @@ PROG= doat MAN= -WARNS?=6 .include diff --git a/tools/regression/geom_gpt/Makefile b/tools/regression/geom_gpt/Makefile index 92d1f020c916..eb5a9659ff4f 100644 --- a/tools/regression/geom_gpt/Makefile +++ b/tools/regression/geom_gpt/Makefile @@ -5,6 +5,4 @@ MAN= LIBADD+= geom -WARNS?= 6 - .include diff --git a/tools/regression/include/stdatomic/Makefile b/tools/regression/include/stdatomic/Makefile index ae9982ac1418..2bc346a7d6fc 100644 --- a/tools/regression/include/stdatomic/Makefile +++ b/tools/regression/include/stdatomic/Makefile @@ -1,7 +1,6 @@ # $FreeBSD$ PROG= logic -WARNS=6 MAN= .include diff --git a/tools/regression/netinet/ipbroadcast/Makefile b/tools/regression/netinet/ipbroadcast/Makefile index a1b497ae145c..c1e5bba93dcf 100644 --- a/tools/regression/netinet/ipbroadcast/Makefile +++ b/tools/regression/netinet/ipbroadcast/Makefile @@ -5,6 +5,4 @@ PROG= ipbroadcast MAN= -WARNS?= 6 - .include diff --git a/tools/regression/rpcsec_gss/Makefile b/tools/regression/rpcsec_gss/Makefile index bea9d9c10e21..6f9debb7c2c3 100644 --- a/tools/regression/rpcsec_gss/Makefile +++ b/tools/regression/rpcsec_gss/Makefile @@ -2,7 +2,6 @@ PROG= rpctest MAN= -WARNS?= 6 LIBADD= rpcsec_gss DEBUG_FLAGS= -g -O0 diff --git a/tools/regression/sockets/accept_fd_leak/Makefile b/tools/regression/sockets/accept_fd_leak/Makefile index e9bfba606c10..d3b3f42ce2a8 100644 --- a/tools/regression/sockets/accept_fd_leak/Makefile +++ b/tools/regression/sockets/accept_fd_leak/Makefile @@ -4,6 +4,5 @@ PROG= accept_fd_leak MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/accf_data_attach/Makefile b/tools/regression/sockets/accf_data_attach/Makefile index 4d337282eade..e7942ced5d02 100644 --- a/tools/regression/sockets/accf_data_attach/Makefile +++ b/tools/regression/sockets/accf_data_attach/Makefile @@ -4,6 +4,5 @@ PROG= accf_data_attach MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/fstat/Makefile b/tools/regression/sockets/fstat/Makefile index a583166d10c9..d5cb72419969 100644 --- a/tools/regression/sockets/fstat/Makefile +++ b/tools/regression/sockets/fstat/Makefile @@ -4,6 +4,5 @@ PROG= fstat MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/kqueue/Makefile b/tools/regression/sockets/kqueue/Makefile index 6771d25acf66..e37eadfbb203 100644 --- a/tools/regression/sockets/kqueue/Makefile +++ b/tools/regression/sockets/kqueue/Makefile @@ -4,6 +4,5 @@ PROG= kqueue MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/listen_backlog/Makefile b/tools/regression/sockets/listen_backlog/Makefile index e2eb1350710a..091d7a420c76 100644 --- a/tools/regression/sockets/listen_backlog/Makefile +++ b/tools/regression/sockets/listen_backlog/Makefile @@ -2,6 +2,5 @@ PROG= listen_backlog MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/listen_kqueue/Makefile b/tools/regression/sockets/listen_kqueue/Makefile index d49a597fc8f5..a506f262d06a 100644 --- a/tools/regression/sockets/listen_kqueue/Makefile +++ b/tools/regression/sockets/listen_kqueue/Makefile @@ -2,6 +2,5 @@ PROG= listen_kqueue MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/listenclose/Makefile b/tools/regression/sockets/listenclose/Makefile index 8f4dc4e922d4..ee147dad8cef 100644 --- a/tools/regression/sockets/listenclose/Makefile +++ b/tools/regression/sockets/listenclose/Makefile @@ -4,6 +4,5 @@ PROG= listenclose MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/pr_atomic/Makefile b/tools/regression/sockets/pr_atomic/Makefile index 1dc85ffbeff8..a52433c6ef26 100644 --- a/tools/regression/sockets/pr_atomic/Makefile +++ b/tools/regression/sockets/pr_atomic/Makefile @@ -2,6 +2,5 @@ PROG= pr_atomic MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/reconnect/Makefile b/tools/regression/sockets/reconnect/Makefile index d8fa5e09b502..285d075bca4b 100644 --- a/tools/regression/sockets/reconnect/Makefile +++ b/tools/regression/sockets/reconnect/Makefile @@ -4,6 +4,5 @@ PROG= reconnect MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/rtsocket/Makefile b/tools/regression/sockets/rtsocket/Makefile index f68b6c3a2e2c..fcb2e40acca1 100644 --- a/tools/regression/sockets/rtsocket/Makefile +++ b/tools/regression/sockets/rtsocket/Makefile @@ -2,6 +2,5 @@ PROG= rtsocket MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/sblock/Makefile b/tools/regression/sockets/sblock/Makefile index aa2f890bc447..1992a0a652ac 100644 --- a/tools/regression/sockets/sblock/Makefile +++ b/tools/regression/sockets/sblock/Makefile @@ -4,6 +4,5 @@ PROG= sblock MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/sendfile/Makefile b/tools/regression/sockets/sendfile/Makefile index 6e9c1ab70164..f1ba7a1cf596 100644 --- a/tools/regression/sockets/sendfile/Makefile +++ b/tools/regression/sockets/sendfile/Makefile @@ -4,7 +4,6 @@ PROG= sendfile MAN= -WARNS?= 6 LIBADD= md .include diff --git a/tools/regression/sockets/shutdown/Makefile b/tools/regression/sockets/shutdown/Makefile index 63045f5556ff..c36398c5af24 100644 --- a/tools/regression/sockets/shutdown/Makefile +++ b/tools/regression/sockets/shutdown/Makefile @@ -4,6 +4,5 @@ PROG= shutdown MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/sigpipe/Makefile b/tools/regression/sockets/sigpipe/Makefile index 51167011edb6..bd7720fbcbed 100644 --- a/tools/regression/sockets/sigpipe/Makefile +++ b/tools/regression/sockets/sigpipe/Makefile @@ -4,6 +4,5 @@ PROG= sigpipe MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/so_setfib/Makefile b/tools/regression/sockets/so_setfib/Makefile index 90111fb86bd5..eadb3efb1c36 100644 --- a/tools/regression/sockets/so_setfib/Makefile +++ b/tools/regression/sockets/so_setfib/Makefile @@ -4,7 +4,6 @@ PROG= so_setfib MAN= -WARNS?= 6 .if ${MK_INET} != "no" CFLAGS+= -DINET diff --git a/tools/regression/sockets/udp_pingpong/Makefile b/tools/regression/sockets/udp_pingpong/Makefile index 2ec5b209ce2c..61e92ed73ce8 100644 --- a/tools/regression/sockets/udp_pingpong/Makefile +++ b/tools/regression/sockets/udp_pingpong/Makefile @@ -2,6 +2,5 @@ PROG= udp_pingpong MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_bindconnect/Makefile b/tools/regression/sockets/unix_bindconnect/Makefile index 52cc8442be09..4bb4fc011ba4 100644 --- a/tools/regression/sockets/unix_bindconnect/Makefile +++ b/tools/regression/sockets/unix_bindconnect/Makefile @@ -2,6 +2,5 @@ PROG= unix_bindconnect MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_close_race/Makefile b/tools/regression/sockets/unix_close_race/Makefile index 370adc469896..690929edc2bc 100644 --- a/tools/regression/sockets/unix_close_race/Makefile +++ b/tools/regression/sockets/unix_close_race/Makefile @@ -2,6 +2,5 @@ PROG= unix_close_race MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_gc/Makefile b/tools/regression/sockets/unix_gc/Makefile index 184660965069..09ba07ae65ee 100644 --- a/tools/regression/sockets/unix_gc/Makefile +++ b/tools/regression/sockets/unix_gc/Makefile @@ -2,6 +2,5 @@ PROG= unix_gc MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_sendtorace/Makefile b/tools/regression/sockets/unix_sendtorace/Makefile index 75e7b9f0b606..7d26fc8b1383 100644 --- a/tools/regression/sockets/unix_sendtorace/Makefile +++ b/tools/regression/sockets/unix_sendtorace/Makefile @@ -2,6 +2,5 @@ PROG= unix_sendtorace MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_socket/Makefile b/tools/regression/sockets/unix_socket/Makefile index bb6045637ed1..7ebc03fc22f3 100644 --- a/tools/regression/sockets/unix_socket/Makefile +++ b/tools/regression/sockets/unix_socket/Makefile @@ -2,6 +2,5 @@ PROG= unix_socket MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_sorflush/Makefile b/tools/regression/sockets/unix_sorflush/Makefile index db0aa6ade00d..879dcc8ef533 100644 --- a/tools/regression/sockets/unix_sorflush/Makefile +++ b/tools/regression/sockets/unix_sorflush/Makefile @@ -2,6 +2,5 @@ PROG= unix_sorflush MAN= -WARNS?= 6 .include diff --git a/tools/regression/sockets/zerosend/Makefile b/tools/regression/sockets/zerosend/Makefile index 18f7dd3e649a..9706b25ea899 100644 --- a/tools/regression/sockets/zerosend/Makefile +++ b/tools/regression/sockets/zerosend/Makefile @@ -2,6 +2,5 @@ PROG= zerosend MAN= -WARNS?= 6 .include diff --git a/tools/test/auxinfo/Makefile b/tools/test/auxinfo/Makefile index 0e6d80992ad8..f40c81d87652 100644 --- a/tools/test/auxinfo/Makefile +++ b/tools/test/auxinfo/Makefile @@ -2,6 +2,5 @@ PROG= auxinfo MAN= -WARNS?= 6 .include diff --git a/tools/test/iconv/posix/Makefile b/tools/test/iconv/posix/Makefile index 891142412df8..aafaadebafe7 100644 --- a/tools/test/iconv/posix/Makefile +++ b/tools/test/iconv/posix/Makefile @@ -3,6 +3,4 @@ PROG= posix MAN= -WARNS?= 6 - .include diff --git a/tools/test/malloc/Makefile b/tools/test/malloc/Makefile index 455dec39920b..ac3fdd89486b 100644 --- a/tools/test/malloc/Makefile +++ b/tools/test/malloc/Makefile @@ -4,7 +4,6 @@ SRCS= main.c .PATH: ${.CURDIR}/../../../lib/libc/stdlib MAN= -WARNS?=6 test: malloc @echo diff --git a/tools/test/net/Makefile b/tools/test/net/Makefile index e4c525920d8c..4fe5fb155cd1 100644 --- a/tools/test/net/Makefile +++ b/tools/test/net/Makefile @@ -2,7 +2,6 @@ PROGS= listen connect MAN= -WARNS?= 6 test: ${PROGS} diff --git a/tools/test/netfibs/Makefile b/tools/test/netfibs/Makefile index 689d613616e1..7262a21356c8 100644 --- a/tools/test/netfibs/Makefile +++ b/tools/test/netfibs/Makefile @@ -2,6 +2,5 @@ PROG= reflect MAN= -WARNS?= 6 .include diff --git a/tools/test/ptrace/Makefile b/tools/test/ptrace/Makefile index a11b0a16a846..46e0aee6b53f 100644 --- a/tools/test/ptrace/Makefile +++ b/tools/test/ptrace/Makefile @@ -2,6 +2,5 @@ PROG= scescx MAN= -WARNS?= 6 .include diff --git a/tools/tools/aac/Makefile b/tools/tools/aac/Makefile index 03c5dcda9ed9..9f2f4a7249cd 100644 --- a/tools/tools/aac/Makefile +++ b/tools/tools/aac/Makefile @@ -2,7 +2,6 @@ PROG= aac_checkq MAN= -WARNS?=6 BINDIR?=/usr/local/bin .include diff --git a/tools/tools/cfi/Makefile b/tools/tools/cfi/Makefile index 5a49f2d38438..9f4dd10a2828 100644 --- a/tools/tools/cfi/Makefile *** 284 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Sun Aug 29 10:51:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CEDFC65BA70; Sun, 29 Aug 2021 10:51: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 4Gy9Hp56Wrz4ZtW; Sun, 29 Aug 2021 10:51: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 9801D133E; Sun, 29 Aug 2021 10:51: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 17TApoXf059199; Sun, 29 Aug 2021 10:51:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TApo3b059198; Sun, 29 Aug 2021 10:51:50 GMT (envelope-from git) Date: Sun, 29 Aug 2021 10:51:50 GMT Message-Id: <202108291051.17TApo3b059198@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 7f14439a3a78 - stable/12 - googletest: Silence warnings about deprecated implicit copy constructors MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7f14439a3a78f084f705e24a055c85044f35d39a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 10:51:50 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=7f14439a3a78f084f705e24a055c85044f35d39a commit 7f14439a3a78f084f705e24a055c85044f35d39a Author: Dimitry Andric AuthorDate: 2021-08-26 20:06:49 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 10:51:10 +0000 googletest: Silence warnings about deprecated implicit copy constructors Our copy of googletest is rather stale, and causes a number of -Werror warnings about implicit copy constructor definitions being deprecated, because several classes have user-declared copy assignment operators. Silence the warnings until we either upgrade or remove googletest. (cherry picked from commit d396c67f26b079c2808002c07212d9df9818a11b) --- lib/googletest/Makefile.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc index 36f7228c079b..b77322df4ee2 100644 --- a/lib/googletest/Makefile.inc +++ b/lib/googletest/Makefile.inc @@ -10,3 +10,6 @@ CXXFLAGS+= ${GTESTS_FLAGS} # Silence warnings about usage of deprecated std::auto_ptr CXXWARNFLAGS+= -Wno-deprecated-declarations + +# Silence warnings about usage of deprecated implicit copy constructors +CXXWARNFLAGS+= -Wno-deprecated-copy From owner-dev-commits-src-all@freebsd.org Sun Aug 29 10:51:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E60BA65BA75; Sun, 29 Aug 2021 10:51: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 4Gy9Hq66pPz4ZkF; Sun, 29 Aug 2021 10:51: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 BB6DDE51; Sun, 29 Aug 2021 10:51: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 17TAppkl059223; Sun, 29 Aug 2021 10:51:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TApp0M059222; Sun, 29 Aug 2021 10:51:51 GMT (envelope-from git) Date: Sun, 29 Aug 2021 10:51:51 GMT Message-Id: <202108291051.17TApp0M059222@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 729a19f2cd01 - stable/12 - Cleanup compiler warning flags in lib/libefivar/Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 729a19f2cd01aac78d08fb88d8467b1a2376d81b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 10:51:52 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=729a19f2cd01aac78d08fb88d8467b1a2376d81b commit 729a19f2cd01aac78d08fb88d8467b1a2376d81b Author: Dimitry Andric AuthorDate: 2021-08-26 18:53:18 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 10:51:27 +0000 Cleanup compiler warning flags in lib/libefivar/Makefile There is no need to set -Wno-unused-parameter twice, and instead of appending to CFLAGS, append to CWARNFLAGS instead. While here, add -Wno-unused-but-set-variable for the sake of clang 13.0.0. (cherry picked from commit f643997a1761689ef9108d69b86d42881ea0ab1c) --- lib/libefivar/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libefivar/Makefile b/lib/libefivar/Makefile index 3c6b17333407..c1503f4e5b62 100644 --- a/lib/libefivar/Makefile +++ b/lib/libefivar/Makefile @@ -43,8 +43,7 @@ MAN= efivar.3 CFLAGS+= -I${EFIBOOT}/include CFLAGS+= -I${.CURDIR} -I${EDK2INC} - -CFLAGS.efivar-dp-format.c=-Wno-unused-parameter +CFLAGS+= -fno-strict-aliasing MLINKS+=efivar.3 efi_set_variables_supported.3 \ efivar.3 efi_del_variable.3 \ @@ -65,4 +64,9 @@ WARNS?= 9 .include -CFLAGS+= -fno-strict-aliasing -Wno-cast-align -Wno-unused-parameter +CWARNFLAGS+= -Wno-cast-align +CWARNFLAGS+= -Wno-unused-parameter + +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 130000 +CWARNFLAGS+= -Wno-unused-but-set-variable +.endif From owner-dev-commits-src-all@freebsd.org Sun Aug 29 13:26:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85B2265E90C; Sun, 29 Aug 2021 13:26: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 4GyDkp3FbMz3mcg; Sun, 29 Aug 2021 13:26: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 5730C305F; Sun, 29 Aug 2021 13:26: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 17TDQwHL059660; Sun, 29 Aug 2021 13:26:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDQwt7059659; Sun, 29 Aug 2021 13:26:58 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:26:58 GMT Message-Id: <202108291326.17TDQwt7059659@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2b10cf85f868 - main - pf: Introduce nvlist variant of DIOCGETSTATUS 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/main X-Git-Reftype: branch X-Git-Commit: 2b10cf85f8684f822511d7b9377e256ab623abbc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:26:58 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2b10cf85f8684f822511d7b9377e256ab623abbc commit 2b10cf85f8684f822511d7b9377e256ab623abbc Author: Kristof Provost AuthorDate: 2021-08-16 19:55:27 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:04 +0000 pf: Introduce nvlist variant of DIOCGETSTATUS Make it possible to extend the GETSTATUS call (e.g. when we want to add new counters, such as for syncookie support) by introducing an nvlist-based alternative. MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31694 --- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf.h | 9 ++++ sys/netpfil/pf/pf_ioctl.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 17d1e8c1a047..47f7c1efbffd 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1667,6 +1667,7 @@ struct pfioc_iface { #define DIOCGETSTATENV _IOWR('D', 19, struct pfioc_nv) #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) #define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) +#define DIOCGETSTATUSNV _IOWR('D', 21, struct pfioc_nv) #define DIOCCLRSTATUS _IO ('D', 22) #define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook) #define DIOCSETDEBUG _IOWR('D', 24, u_int32_t) diff --git a/sys/netpfil/pf/pf.h b/sys/netpfil/pf/pf.h index d8ee43506d99..2fa76def4385 100644 --- a/sys/netpfil/pf/pf.h +++ b/sys/netpfil/pf/pf.h @@ -179,6 +179,15 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL, #define FCNT_STATE_REMOVALS 2 #define FCNT_MAX 3 +#ifdef _KERNEL +#define FCNT_NAMES { \ + "searches", \ + "inserts", \ + "removals", \ + NULL \ +} +#endif + /* src_node operation counters */ #define SCNT_SRC_NODE_SEARCH 0 #define SCNT_SRC_NODE_INSERT 1 diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index b2d7fc33d8b8..ec2c7108c1d2 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -208,6 +208,7 @@ static int pf_killstates_row(struct pf_kstate_kill *, static int pf_killstates_nv(struct pfioc_nv *); static int pf_clearstates_nv(struct pfioc_nv *); static int pf_getstate(struct pfioc_nv *); +static int pf_getstatus(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); @@ -2179,6 +2180,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCGETSTATENV: case DIOCSETSTATUSIF: case DIOCGETSTATUS: + case DIOCGETSTATUSNV: case DIOCCLRSTATUS: case DIOCNATLOOK: case DIOCSETDEBUG: @@ -2236,6 +2238,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCGETSTATE: case DIOCGETSTATENV: case DIOCGETSTATUS: + case DIOCGETSTATUSNV: case DIOCGETSTATES: case DIOCGETSTATESV2: case DIOCGETTIMEOUT: @@ -3096,6 +3099,11 @@ DIOCGETSTATESV2_full: break; } + case DIOCGETSTATUSNV: { + error = pf_getstatus((struct pfioc_nv *)addr); + break; + } + case DIOCSETSTATUSIF: { struct pfioc_if *pi = (struct pfioc_if *)addr; @@ -4887,6 +4895,131 @@ pf_tbladdr_copyout(struct pf_addr_wrap *aw) kt->pfrkt_cnt : -1; } +static int +pf_add_status_counters(nvlist_t *nvl, const char *name, counter_u64_t *counters, + size_t number, char **names) +{ + nvlist_t *nvc; + + nvc = nvlist_create(0); + if (nvc == NULL) + return (ENOMEM); + + for (int i = 0; i < number; i++) { + nvlist_append_number_array(nvc, "counters", + counter_u64_fetch(counters[i])); + nvlist_append_string_array(nvc, "names", + names[i]); + nvlist_append_number_array(nvc, "ids", + i); + } + nvlist_add_nvlist(nvl, name, nvc); + nvlist_destroy(nvc); + + return (0); +} + +static int +pf_getstatus(struct pfioc_nv *nv) +{ + nvlist_t *nvl = NULL, *nvc = NULL; + void *nvlpacked = NULL; + int error; + struct pf_status s; + char *pf_reasons[PFRES_MAX+1] = PFRES_NAMES; + char *pf_lcounter[LCNT_MAX+1] = LCNT_NAMES; + char *pf_fcounter[FCNT_MAX+1] = FCNT_NAMES; + PF_RULES_RLOCK_TRACKER; + +#define ERROUT(x) ERROUT_FUNCTION(errout, x) + + PF_RULES_RLOCK(); + + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvlist_add_bool(nvl, "running", V_pf_status.running); + nvlist_add_number(nvl, "since", V_pf_status.since); + nvlist_add_number(nvl, "debug", V_pf_status.debug); + nvlist_add_number(nvl, "hostid", V_pf_status.hostid); + nvlist_add_number(nvl, "states", V_pf_status.states); + nvlist_add_number(nvl, "src_nodes", V_pf_status.src_nodes); + + /* counters */ + error = pf_add_status_counters(nvl, "counters", V_pf_status.counters, + PFRES_MAX, pf_reasons); + if (error != 0) + ERROUT(error); + + /* lcounters */ + error = pf_add_status_counters(nvl, "lcounters", V_pf_status.lcounters, + LCNT_MAX, pf_lcounter); + if (error != 0) + ERROUT(error); + + /* fcounters */ + nvc = nvlist_create(0); + if (nvc == NULL) + ERROUT(ENOMEM); + + for (int i = 0; i < FCNT_MAX; i++) { + nvlist_append_number_array(nvc, "counters", + pf_counter_u64_fetch(&V_pf_status.fcounters[i])); + nvlist_append_string_array(nvc, "names", + pf_fcounter[i]); + nvlist_append_number_array(nvc, "ids", + i); + } + nvlist_add_nvlist(nvl, "fcounters", nvc); + nvlist_destroy(nvc); + nvc = NULL; + + /* scounters */ + error = pf_add_status_counters(nvl, "scounters", V_pf_status.scounters, + SCNT_MAX, pf_fcounter); + if (error != 0) + ERROUT(error); + + nvlist_add_string(nvl, "ifname", V_pf_status.ifname); + nvlist_add_binary(nvl, "chksum", V_pf_status.pf_chksum, + PF_MD5_DIGEST_LENGTH); + + pfi_update_status(V_pf_status.ifname, &s); + + /* pcounters / bcounters */ + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + for (int k = 0; k < 2; k++) { + nvlist_append_number_array(nvl, "pcounters", + s.pcounters[i][j][k]); + } + nvlist_append_number_array(nvl, "bcounters", + s.bcounters[i][j]); + } + } + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +#undef ERROUT +errout: + PF_RULES_RUNLOCK(); + free(nvlpacked, M_NVLIST); + nvlist_destroy(nvc); + nvlist_destroy(nvl); + + return (error); +} + /* * XXX - Check for version missmatch!!! */ From owner-dev-commits-src-all@freebsd.org Sun Aug 29 13:27:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EEC5D65E793; Sun, 29 Aug 2021 13:27: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 4GyDkr5Swhz3ml7; Sun, 29 Aug 2021 13:27: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 9AB542F39; Sun, 29 Aug 2021 13:27: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 17TDR0l9059715; Sun, 29 Aug 2021 13:27:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDR0bv059714; Sun, 29 Aug 2021 13:27:00 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:27:00 GMT Message-Id: <202108291327.17TDR0bv059714@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 46fb68b1de49 - main - libpfctl: Implement DIOCGETSTATUS wrappers 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/main X-Git-Reftype: branch X-Git-Commit: 46fb68b1de49c8d235024374b71c1249af9e62ef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:27:01 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=46fb68b1de49c8d235024374b71c1249af9e62ef commit 46fb68b1de49c8d235024374b71c1249af9e62ef Author: Kristof Provost AuthorDate: 2021-08-26 15:06:15 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:38 +0000 libpfctl: Implement DIOCGETSTATUS wrappers MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31696 --- lib/libpfctl/libpfctl.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/libpfctl/libpfctl.h | 30 +++++++++++++ 2 files changed, 145 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 7e6bc1b14a2a..3d52502f9ba8 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -121,6 +121,121 @@ pf_nvuint_64_array(const nvlist_t *nvl, const char *name, size_t maxelems, *nelems = elems; } +static void +_pfctl_get_status_counters(const nvlist_t *nvl, + struct pfctl_status_counters *counters) +{ + const uint64_t *ids, *counts; + const char *const *names; + size_t id_len, counter_len, names_len; + + ids = nvlist_get_number_array(nvl, "ids", &id_len); + counts = nvlist_get_number_array(nvl, "counters", &counter_len); + names = nvlist_get_string_array(nvl, "names", &names_len); + assert(id_len == counter_len); + assert(counter_len == names_len); + + TAILQ_INIT(counters); + + for (size_t i = 0; i < id_len; i++) { + struct pfctl_status_counter *c; + + c = malloc(sizeof(*c)); + + c->id = ids[i]; + c->counter = counts[i]; + c->name = strdup(names[i]); + + TAILQ_INSERT_TAIL(counters, c, entry); + } +} + +struct pfctl_status * +pfctl_get_status(int dev) +{ + struct pfioc_nv nv; + struct pfctl_status *status; + nvlist_t *nvl; + size_t len; + const void *chksum; + + status = calloc(1, sizeof(*status)); + if (status == NULL) + return (NULL); + + nv.data = malloc(4096); + nv.len = nv.size = 4096; + + if (ioctl(dev, DIOCGETSTATUSNV, &nv)) { + free(nv.data); + free(status); + return (NULL); + } + + nvl = nvlist_unpack(nv.data, nv.len, 0); + free(nv.data); + if (nvl == NULL) { + free(status); + return (NULL); + } + + status->running = nvlist_get_bool(nvl, "running"); + status->since = nvlist_get_number(nvl, "since"); + status->debug = nvlist_get_number(nvl, "debug"); + status->hostid = nvlist_get_number(nvl, "hostid"); + status->states = nvlist_get_number(nvl, "states"); + status->src_nodes = nvlist_get_number(nvl, "src_nodes"); + + strlcpy(status->ifname, nvlist_get_string(nvl, "ifname"), + IFNAMSIZ); + chksum = nvlist_get_binary(nvl, "chksum", &len); + assert(len == PF_MD5_DIGEST_LENGTH); + memcpy(status->pf_chksum, chksum, len); + + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "counters"), + &status->counters); + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "lcounters"), + &status->lcounters); + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "fcounters"), + &status->fcounters); + _pfctl_get_status_counters(nvlist_get_nvlist(nvl, "scounters"), + &status->scounters); + + pf_nvuint_64_array(nvl, "pcounters", 2 * 2 * 3, + (uint64_t *)status->pcounters, NULL); + pf_nvuint_64_array(nvl, "bcounters", 2 * 2, + (uint64_t *)status->bcounters, NULL); + + nvlist_destroy(nvl); + + return (status); +} + +void +pfctl_free_status(struct pfctl_status *status) +{ + struct pfctl_status_counter *c, *tmp; + + TAILQ_FOREACH_SAFE(c, &status->counters, entry, tmp) { + free(c->name); + free(c); + } + TAILQ_FOREACH_SAFE(c, &status->lcounters, entry, tmp) { + free(c->name); + free(c); + } + TAILQ_FOREACH_SAFE(c, &status->fcounters, entry, tmp) { + free(c->name); + free(c); + } + TAILQ_FOREACH_SAFE(c, &status->scounters, entry, tmp) { + free(c->name); + free(c); + } + + free(status); +} + static void pfctl_nv_add_addr(nvlist_t *nvparent, const char *name, const struct pf_addr *addr) diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index d57241dd59fd..70de7627f0a6 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -38,6 +38,33 @@ struct pfctl_anchor; +struct pfctl_status_counter { + uint64_t id; + uint64_t counter; + char *name; + + TAILQ_ENTRY(pfctl_status_counter) entry; +}; +TAILQ_HEAD(pfctl_status_counters, pfctl_status_counter); + +struct pfctl_status { + bool running; + uint32_t since; + uint32_t debug; + uint32_t hostid; + uint64_t states; + uint64_t src_nodes; + char ifname[IFNAMSIZ]; + uint8_t pf_chksum[PF_MD5_DIGEST_LENGTH]; + + struct pfctl_status_counters counters; + struct pfctl_status_counters lcounters; + struct pfctl_status_counters fcounters; + struct pfctl_status_counters scounters; + uint64_t pcounters[2][2][3]; + uint64_t bcounters[2][2]; +}; + struct pfctl_pool { struct pf_palist list; struct pf_pooladdr *cur; @@ -253,6 +280,9 @@ struct pfctl_syncookies { enum pfctl_syncookies_mode mode; }; +struct pfctl_status* pfctl_get_status(int dev); +void pfctl_free_status(struct pfctl_status *status); + int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, char *anchor_call); From owner-dev-commits-src-all@freebsd.org Sun Aug 29 13:26:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A343565E9CB; Sun, 29 Aug 2021 13:26:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyDkq47hyz3mcj; Sun, 29 Aug 2021 13:26:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 779052F38; Sun, 29 Aug 2021 13:26: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 17TDQxvk059684; Sun, 29 Aug 2021 13:26:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDQxFf059683; Sun, 29 Aug 2021 13:26:59 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:26:59 GMT Message-Id: <202108291326.17TDQxFf059683@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: b0ccc2e277ac - main - libpfctl: fix double free 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/main X-Git-Reftype: branch X-Git-Commit: b0ccc2e277acddd33c65b444e7841b780b3094d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:26:59 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b0ccc2e277acddd33c65b444e7841b780b3094d7 commit b0ccc2e277acddd33c65b444e7841b780b3094d7 Author: Kristof Provost AuthorDate: 2021-08-22 14:20:15 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:29 +0000 libpfctl: fix double free Reviewed by: donner MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31695 --- lib/libpfctl/libpfctl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 7f1e72513018..7e6bc1b14a2a 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -860,7 +860,6 @@ pfctl_get_syncookies(int dev, struct pfctl_syncookies *s) nvl = nvlist_unpack(nv.data, nv.len, 0); free(nv.data); if (nvl == NULL) { - free(nv.data); return (EIO); } From owner-dev-commits-src-all@freebsd.org Sun Aug 29 13:27:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56B6265E9D0; Sun, 29 Aug 2021 13:27: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 4GyDks6yM0z3mlJ; Sun, 29 Aug 2021 13:27: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 BEC4A2FEC; Sun, 29 Aug 2021 13:27: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 17TDR1Lh059739; Sun, 29 Aug 2021 13:27:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDR1hT059738; Sun, 29 Aug 2021 13:27:01 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:27:01 GMT Message-Id: <202108291327.17TDR1hT059738@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 80078d9d38fd - main - pfctl: use libpfctl to retrieve pf status 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/main X-Git-Reftype: branch X-Git-Commit: 80078d9d38fde6f146de28809640b2c7bff45a6c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:27:02 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=80078d9d38fde6f146de28809640b2c7bff45a6c commit 80078d9d38fde6f146de28809640b2c7bff45a6c Author: Kristof Provost AuthorDate: 2021-08-26 15:09:48 +0000 Commit: Kristof Provost CommitDate: 2021-08-29 12:59:38 +0000 pfctl: use libpfctl to retrieve pf status Rather than call DIOCGETSTATUS ourselves use the new libpfctl functions. MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31697 --- sbin/pfctl/pfctl.c | 20 +++++++++++++------- sbin/pfctl/pfctl_parser.c | 46 ++++++++++++++++++---------------------------- sbin/pfctl/pfctl_parser.h | 4 ++-- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 016075058b21..8f3698e398f6 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1307,35 +1307,41 @@ pfctl_show_states(int dev, const char *iface, int opts) int pfctl_show_status(int dev, int opts) { - struct pf_status status; + struct pfctl_status *status; struct pfctl_syncookies cookies; - if (ioctl(dev, DIOCGETSTATUS, &status)) { + if ((status = pfctl_get_status(dev)) == NULL) { warn("DIOCGETSTATUS"); return (-1); } if (pfctl_get_syncookies(dev, &cookies)) { + pfctl_free_status(status); warn("DIOCGETSYNCOOKIES"); return (-1); } if (opts & PF_OPT_SHOWALL) pfctl_print_title("INFO:"); - print_status(&status, &cookies, opts); + print_status(status, &cookies, opts); + pfctl_free_status(status); return (0); } int pfctl_show_running(int dev) { - struct pf_status status; + struct pfctl_status *status; + int running; - if (ioctl(dev, DIOCGETSTATUS, &status)) { + if ((status = pfctl_get_status(dev)) == NULL) { warn("DIOCGETSTATUS"); return (-1); } - print_running(&status); - return (!status.running); + running = status->running; + + print_running(status); + pfctl_free_status(status); + return (!running); } int diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 8991073ec693..e9a227630f28 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "pfctl_parser.h" @@ -497,8 +498,9 @@ const char * const pf_fcounters[FCNT_MAX+1] = FCNT_NAMES; const char * const pf_scounters[FCNT_MAX+1] = FCNT_NAMES; void -print_status(struct pf_status *s, struct pfctl_syncookies *cookies, int opts) +print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) { + struct pfctl_status_counter *c; char statline[80], *running; time_t runtime; int i; @@ -574,56 +576,44 @@ print_status(struct pf_status *s, struct pfctl_syncookies *cookies, int opts) (unsigned long long)s->pcounters[1][1][PF_DROP]); } printf("%-27s %14s %16s\n", "State Table", "Total", "Rate"); - printf(" %-25s %14u %14s\n", "current entries", s->states, ""); - for (i = 0; i < FCNT_MAX; i++) { - printf(" %-25s %14llu ", pf_fcounters[i], - (unsigned long long)s->fcounters[i]); + printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->states, ""); + TAILQ_FOREACH(c, &s->fcounters, entry) { + printf(" %-25s %14lu ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->fcounters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } if (opts & PF_OPT_VERBOSE) { printf("Source Tracking Table\n"); - printf(" %-25s %14u %14s\n", "current entries", + printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->src_nodes, ""); - for (i = 0; i < SCNT_MAX; i++) { - printf(" %-25s %14lld ", pf_scounters[i], -#ifdef __FreeBSD__ - (long long)s->scounters[i]); -#else - s->scounters[i]); -#endif + TAILQ_FOREACH(c, &s->scounters, entry) { + printf(" %-25s %14lu ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->scounters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } } printf("Counters\n"); - for (i = 0; i < PFRES_MAX; i++) { - printf(" %-25s %14llu ", pf_reasons[i], - (unsigned long long)s->counters[i]); + TAILQ_FOREACH(c, &s->counters, entry) { + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->counters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } if (opts & PF_OPT_VERBOSE) { printf("Limit Counters\n"); - for (i = 0; i < LCNT_MAX; i++) { - printf(" %-25s %14lld ", pf_lcounters[i], -#ifdef __FreeBSD__ - (unsigned long long)s->lcounters[i]); -#else - s->lcounters[i]); -#endif + TAILQ_FOREACH(c, &s->lcounters, entry) { + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", - (double)s->lcounters[i] / (double)runtime); + (double)c->counter / (double)runtime); else printf("%14s\n", ""); } @@ -636,7 +626,7 @@ print_status(struct pf_status *s, struct pfctl_syncookies *cookies, int opts) } void -print_running(struct pf_status *status) +print_running(struct pfctl_status *status) { printf("%s\n", status->running ? "Enabled" : "Disabled"); } diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 0c64238ecefa..12a66e1ae710 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -279,8 +279,8 @@ void print_pool(struct pfctl_pool *, u_int16_t, u_int16_t, sa_family_t, int); void print_src_node(struct pf_src_node *, int); void print_rule(struct pfctl_rule *, const char *, int, int); void print_tabledef(const char *, int, int, struct node_tinithead *); -void print_status(struct pf_status *, struct pfctl_syncookies *, int); -void print_running(struct pf_status *); +void print_status(struct pfctl_status *, struct pfctl_syncookies *, int); +void print_running(struct pfctl_status *); int eval_pfaltq(struct pfctl *, struct pf_altq *, struct node_queue_bw *, struct node_queue_opt *); From owner-dev-commits-src-all@freebsd.org Sun Aug 29 13:32:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75FFA65EBA6; Sun, 29 Aug 2021 13:32: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 4GyDsK2txgz3q5k; Sun, 29 Aug 2021 13:32: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 3F80734C8; Sun, 29 Aug 2021 13:32: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 17TDWbTx072544; Sun, 29 Aug 2021 13:32:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDWbNo072542; Sun, 29 Aug 2021 13:32:37 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:32:37 GMT Message-Id: <202108291332.17TDWbNo072542@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: e92630fc6829 - stable/12 - Revert "Do a sweep and remove most WARNS=6 settings" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e92630fc682954a7b4f724f4a8174d196d7d9cc5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:32:37 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=e92630fc682954a7b4f724f4a8174d196d7d9cc5 commit e92630fc682954a7b4f724f4a8174d196d7d9cc5 Author: Dimitry Andric AuthorDate: 2021-08-29 13:28:30 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 13:28:30 +0000 Revert "Do a sweep and remove most WARNS=6 settings" This reverts commit befc47822966, as it caused various CI build errors, and we never merged the prerequisite commit fe815331bb40 ("build: provide a default WARNS for all in-tree builds"). The latter is rather intrusive, so I will avoid it. Direct commit to stable/12 since the CI bots are broken. --- cddl/Makefile.inc | 2 + gnu/usr.bin/dialog/Makefile | 2 + lib/googletest/Makefile.inc | 2 + lib/libcam/tests/Makefile | 2 + lib/libcrypt/tests/Makefile | 1 + lib/libiconv_modules/Makefile.inc | 1 + lib/libkvm/Makefile | 2 + lib/libkvm/tests/Makefile | 2 + lib/libpathconv/tests/Makefile | 1 + lib/libproc/tests/Makefile | 1 + lib/libsbuf/tests/Makefile | 2 + libexec/Makefile.inc | 1 + libexec/getty/Makefile | 1 + libexec/rtld-elf/Makefile | 1 + libexec/rtld-elf/tests/libpythagoras/Makefile | 1 + libexec/tftpd/tests/Makefile | 1 + sbin/decryptcore/Makefile | 2 + sbin/ping/tests/Makefile | 2 + sbin/recoverdisk/Makefile | 2 - sys/teken/demo/Makefile | 2 + sys/teken/libteken/Makefile | 1 + sys/teken/stress/Makefile | 2 + tests/sys/Makefile.inc | 2 + tests/sys/aio/Makefile | 2 + tests/sys/audit/Makefile | 2 + tests/sys/auditpipe/Makefile | 2 +- tests/sys/capsicum/Makefile | 43 +--------------------- tests/sys/fs/fusefs/Makefile | 2 + tests/sys/kern/pipe/Makefile | 2 + tests/sys/mqueue/Makefile | 2 + tests/sys/net/Makefile | 2 +- tests/sys/netinet/Makefile | 2 + tests/sys/netmap/Makefile | 2 + tests/sys/opencrypto/Makefile | 2 + tests/sys/pjdfstest/pjdfstest/Makefile | 2 + tools/regression/aio/aiop/Makefile | 2 + tools/regression/bpf/bpf_filter/Makefile | 1 + tools/regression/doat/Makefile | 1 + tools/regression/geom_gpt/Makefile | 2 + tools/regression/include/stdatomic/Makefile | 1 + tools/regression/netinet/ipbroadcast/Makefile | 2 + tools/regression/rpcsec_gss/Makefile | 1 + tools/regression/sockets/accept_fd_leak/Makefile | 1 + tools/regression/sockets/accf_data_attach/Makefile | 1 + tools/regression/sockets/fstat/Makefile | 1 + tools/regression/sockets/kqueue/Makefile | 1 + tools/regression/sockets/listen_backlog/Makefile | 1 + tools/regression/sockets/listen_kqueue/Makefile | 1 + tools/regression/sockets/listenclose/Makefile | 1 + tools/regression/sockets/pr_atomic/Makefile | 1 + tools/regression/sockets/reconnect/Makefile | 1 + tools/regression/sockets/rtsocket/Makefile | 1 + tools/regression/sockets/sblock/Makefile | 1 + tools/regression/sockets/sendfile/Makefile | 1 + tools/regression/sockets/shutdown/Makefile | 1 + tools/regression/sockets/sigpipe/Makefile | 1 + tools/regression/sockets/so_setfib/Makefile | 1 + tools/regression/sockets/udp_pingpong/Makefile | 1 + tools/regression/sockets/unix_bindconnect/Makefile | 1 + tools/regression/sockets/unix_close_race/Makefile | 1 + tools/regression/sockets/unix_gc/Makefile | 1 + tools/regression/sockets/unix_sendtorace/Makefile | 1 + tools/regression/sockets/unix_socket/Makefile | 1 + tools/regression/sockets/unix_sorflush/Makefile | 1 + tools/regression/sockets/zerosend/Makefile | 1 + tools/test/auxinfo/Makefile | 1 + tools/test/iconv/posix/Makefile | 2 + tools/test/malloc/Makefile | 1 + tools/test/net/Makefile | 1 + tools/test/netfibs/Makefile | 1 + tools/test/ptrace/Makefile | 1 + tools/tools/aac/Makefile | 1 + tools/tools/cfi/Makefile | 1 + tools/tools/find-sb/Makefile | 1 + tools/tools/fixwhite/Makefile | 1 + tools/tools/gensnmpdef/Makefile | 2 + tools/tools/ifpifa/Makefile | 1 + tools/tools/ioat/Makefile | 2 + tools/tools/iwi/Makefile | 1 + tools/tools/ncpus/Makefile | 1 + tools/tools/pciroms/Makefile | 2 + tools/tools/syscall_timing/Makefile | 2 + tools/tools/tscdrift/Makefile | 1 + tools/tools/vt/mkkfont/Makefile | 4 +- usr.bin/dpv/Makefile | 2 + usr.bin/getconf/tests/Makefile | 2 + usr.bin/mkimg/Makefile | 2 + usr.bin/posixshmcontrol/Makefile | 1 + usr.bin/proccontrol/Makefile | 1 + usr.bin/protect/Makefile | 1 + usr.sbin/bsdinstall/distextract/Makefile | 1 + usr.sbin/bsdinstall/distfetch/Makefile | 1 + usr.sbin/bsnmpd/tools/Makefile.inc | 2 + usr.sbin/ctld/Makefile | 1 + usr.sbin/iovctl/Makefile | 2 + usr.sbin/mlx5tool/Makefile | 1 + usr.sbin/pw/tests/Makefile | 1 + 97 files changed, 131 insertions(+), 48 deletions(-) diff --git a/cddl/Makefile.inc b/cddl/Makefile.inc index 687068d599e8..94a42492a4f0 100644 --- a/cddl/Makefile.inc +++ b/cddl/Makefile.inc @@ -7,6 +7,8 @@ IGNORE_PRAGMA= YES CFLAGS+= -DNEED_SOLARIS_BOOLEAN +WARNS?= 6 + # Do not lint the CDDL stuff. It is all externally maintained and # lint output is wasteful noise here. diff --git a/gnu/usr.bin/dialog/Makefile b/gnu/usr.bin/dialog/Makefile index 71496f774830..bcca9b353303 100644 --- a/gnu/usr.bin/dialog/Makefile +++ b/gnu/usr.bin/dialog/Makefile @@ -7,4 +7,6 @@ LIBADD= dialog ncursesw m CFLAGS+= -I${.CURDIR} -I${DIALOG} .PATH: ${DIALOG} +WARNS?= 6 + .include diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc index b77322df4ee2..9e1d5553a149 100644 --- a/lib/googletest/Makefile.inc +++ b/lib/googletest/Makefile.inc @@ -13,3 +13,5 @@ CXXWARNFLAGS+= -Wno-deprecated-declarations # Silence warnings about usage of deprecated implicit copy constructors CXXWARNFLAGS+= -Wno-deprecated-copy + +WARNS?= 6 diff --git a/lib/libcam/tests/Makefile b/lib/libcam/tests/Makefile index 89e59ca9932e..178c30805f92 100644 --- a/lib/libcam/tests/Makefile +++ b/lib/libcam/tests/Makefile @@ -5,4 +5,6 @@ ATF_TESTS_C+= cam_test LIBADD+= cam +WARNS?= 6 + .include diff --git a/lib/libcrypt/tests/Makefile b/lib/libcrypt/tests/Makefile index 15798b215d17..22b7fccccbba 100644 --- a/lib/libcrypt/tests/Makefile +++ b/lib/libcrypt/tests/Makefile @@ -4,6 +4,7 @@ ATF_TESTS_C+= crypt_tests NETBSD_ATF_TESTS_C+= crypt_test +WARNS?= 6 CFLAGS+= -I${.CURDIR:H} LIBADD= crypt diff --git a/lib/libiconv_modules/Makefile.inc b/lib/libiconv_modules/Makefile.inc index 556997404f99..d42473637534 100644 --- a/lib/libiconv_modules/Makefile.inc +++ b/lib/libiconv_modules/Makefile.inc @@ -3,6 +3,7 @@ .PATH: ${SRCTOP}/lib/libc/iconv SHLIB_MAJOR= 4 +WARNS?= 6 CFLAGS+= -I${SRCTOP}/lib/libc/iconv CFLAGS+= -Dbool=_Bool diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile index 6afb8c4ad2e1..d934690d4355 100644 --- a/lib/libkvm/Makefile +++ b/lib/libkvm/Makefile @@ -8,6 +8,8 @@ SHLIBDIR?= /lib SHLIB_MAJOR= 7 CFLAGS+=-DNO__SCCSID -I${.CURDIR} +WARNS?= 6 + SRCS= kvm.c kvm_cptime.c kvm_getloadavg.c \ kvm_getswapinfo.c kvm_pcpu.c kvm_private.c kvm_proc.c kvm_vnet.c \ kvm_minidump_aarch64.c \ diff --git a/lib/libkvm/tests/Makefile b/lib/libkvm/tests/Makefile index 1f74aec83f02..24caf9108883 100644 --- a/lib/libkvm/tests/Makefile +++ b/lib/libkvm/tests/Makefile @@ -13,6 +13,8 @@ CFLAGS.kvm_read_test+= -I${.CURDIR:H} LIBADD+= kvm +WARNS?= 6 + BINDIR= ${TESTSDIR} .for t in kvm_geterr_test kvm_open_test kvm_open2_test kvm_read_test diff --git a/lib/libpathconv/tests/Makefile b/lib/libpathconv/tests/Makefile index c7696c2d6c5d..f32db22c1db8 100644 --- a/lib/libpathconv/tests/Makefile +++ b/lib/libpathconv/tests/Makefile @@ -3,6 +3,7 @@ TAP_TESTS_C+= abs2rel TAP_TESTS_C+= rel2abs +WARNS?= 6 #LIBADD+= pathconv #LDADD+= -L .. -lpathconv LDADD+= ../libpathconv.a diff --git a/lib/libproc/tests/Makefile b/lib/libproc/tests/Makefile index 93f50789c88c..8c7563a33ca6 100644 --- a/lib/libproc/tests/Makefile +++ b/lib/libproc/tests/Makefile @@ -6,6 +6,7 @@ PROGS= target_prog SRCS_target_prog= target_prog.c BINDIR_target_prog= ${TESTSDIR} +WARNS?= 6 LIBADD= elf proc rtld_db util # Ensure that symbols aren't stripped from the test program, as they're needed diff --git a/lib/libsbuf/tests/Makefile b/lib/libsbuf/tests/Makefile index b563ebfe1728..d3532f01b7b6 100644 --- a/lib/libsbuf/tests/Makefile +++ b/lib/libsbuf/tests/Makefile @@ -6,4 +6,6 @@ ATF_TESTS_C+= sbuf_string_test LIBADD+= sbuf util +WARNS?= 6 + .include diff --git a/libexec/Makefile.inc b/libexec/Makefile.inc index 5a94bbf52a4b..7b6a65fc7172 100644 --- a/libexec/Makefile.inc +++ b/libexec/Makefile.inc @@ -3,4 +3,5 @@ BINDIR?= /usr/libexec +WARNS?= 6 WFORMAT?= 1 diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile index a65d1d7da981..ff4b91157511 100644 --- a/libexec/getty/Makefile +++ b/libexec/getty/Makefile @@ -7,6 +7,7 @@ SRCS= main.c init.c subr.c chat.c LIBADD= util MAN= gettytab.5 ttys.5 getty.8 +WARNS?= 6 WFORMAT=0 .include diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index 48fd4f6f01c0..a51acf68068a 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -42,6 +42,7 @@ LDFLAGS+= -nostdlib -e .rtld_start .endif NO_WCAST_ALIGN= yes +WARNS?= 6 INSTALLFLAGS= -C -b PRECIOUSPROG= BINDIR= /libexec diff --git a/libexec/rtld-elf/tests/libpythagoras/Makefile b/libexec/rtld-elf/tests/libpythagoras/Makefile index 9ad4b883015c..7c9583960953 100644 --- a/libexec/rtld-elf/tests/libpythagoras/Makefile +++ b/libexec/rtld-elf/tests/libpythagoras/Makefile @@ -10,6 +10,7 @@ SHLIBDIR= ${TESTSBASE}/libexec/rtld-elf SRCS= pythagoras.c +WARNS?= 6 LIBADD= m .include diff --git a/libexec/tftpd/tests/Makefile b/libexec/tftpd/tests/Makefile index fb5212e2ad6f..9aa420cec1a5 100644 --- a/libexec/tftpd/tests/Makefile +++ b/libexec/tftpd/tests/Makefile @@ -9,6 +9,7 @@ TEST_METADATA.functional+= timeout=15 .endif LIBADD= util +WARNS?= 6 CSTD= c11 .include diff --git a/sbin/decryptcore/Makefile b/sbin/decryptcore/Makefile index 3a3a6a029f87..423bca9c454e 100644 --- a/sbin/decryptcore/Makefile +++ b/sbin/decryptcore/Makefile @@ -8,4 +8,6 @@ MAN= decryptcore.8 CFLAGS+=-I${SRCTOP}/lib/libpjdlog +WARNS?= 6 + .include diff --git a/sbin/ping/tests/Makefile b/sbin/ping/tests/Makefile index 2d5082ac839b..678641562d93 100644 --- a/sbin/ping/tests/Makefile +++ b/sbin/ping/tests/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +WARNS?= 6 + ATF_TESTS_C+= in_cksum_test SRCS.in_cksum_test= in_cksum_test.c ../utils.c diff --git a/sbin/recoverdisk/Makefile b/sbin/recoverdisk/Makefile index 2094ad29d54b..41ef1f3e4912 100644 --- a/sbin/recoverdisk/Makefile +++ b/sbin/recoverdisk/Makefile @@ -3,8 +3,6 @@ PACKAGE=runtime PROG= recoverdisk -LDFLAGS += -lm - .include test: ${PROG} diff --git a/sys/teken/demo/Makefile b/sys/teken/demo/Makefile index e39c5742bc96..1ade690afe22 100644 --- a/sys/teken/demo/Makefile +++ b/sys/teken/demo/Makefile @@ -4,4 +4,6 @@ PROG= teken_demo LDADD= -lncursesw -lteken -lutil MAN= +WARNS?= 6 + .include diff --git a/sys/teken/libteken/Makefile b/sys/teken/libteken/Makefile index 20ec0aff0faa..d1c9d3c9da70 100644 --- a/sys/teken/libteken/Makefile +++ b/sys/teken/libteken/Makefile @@ -4,6 +4,7 @@ LIB= teken SHLIB_MAJOR= 0 CFLAGS+=-I. +WARNS?= 6 SRCDIR= ${.CURDIR}/.. .PATH: ${SRCDIR} diff --git a/sys/teken/stress/Makefile b/sys/teken/stress/Makefile index 9a0257f02760..7216da0bd60d 100644 --- a/sys/teken/stress/Makefile +++ b/sys/teken/stress/Makefile @@ -4,4 +4,6 @@ PROG= teken_stress LDADD= -lteken MAN= +WARNS?= 6 + .include diff --git a/tests/sys/Makefile.inc b/tests/sys/Makefile.inc index 2cba822015ae..0b336d3f3ef3 100644 --- a/tests/sys/Makefile.inc +++ b/tests/sys/Makefile.inc @@ -1,3 +1,5 @@ # $FreeBSD$ +WARNS?= 6 + .include "${SRCTOP}/tests/Makefile.inc0" diff --git a/tests/sys/aio/Makefile b/tests/sys/aio/Makefile index db9da144c43b..ef44036bf3d8 100644 --- a/tests/sys/aio/Makefile +++ b/tests/sys/aio/Makefile @@ -17,4 +17,6 @@ LIBADD.lio_test+= rt CFLAGS+= -I${.CURDIR:H:H} +WARNS?= 6 + .include diff --git a/tests/sys/audit/Makefile b/tests/sys/audit/Makefile index 01bdc6754ef7..6f70121da14f 100644 --- a/tests/sys/audit/Makefile +++ b/tests/sys/audit/Makefile @@ -51,6 +51,8 @@ TEST_METADATA+= required_user="root" TEST_METADATA+= is_exclusive="true" TEST_METADATA+= required_files="/etc/rc.d/auditd" +WARNS?= 6 + LDFLAGS+= -lbsm -lutil .include diff --git a/tests/sys/auditpipe/Makefile b/tests/sys/auditpipe/Makefile index ac7715d57f5d..9610599a22b6 100644 --- a/tests/sys/auditpipe/Makefile +++ b/tests/sys/auditpipe/Makefile @@ -5,6 +5,6 @@ TESTSDIR= ${TESTSBASE}/sys/auditpipe ATF_TESTS_C= auditpipe_test TEST_METADATA+= required_user="root" -TEST_METADATA+= required_files="/dev/auditpipe" +WARNS?= 6 .include diff --git a/tests/sys/capsicum/Makefile b/tests/sys/capsicum/Makefile index 9c69b6ac856b..6b0e53fa0865 100644 --- a/tests/sys/capsicum/Makefile +++ b/tests/sys/capsicum/Makefile @@ -7,47 +7,6 @@ ATF_TESTS_C+= ioctls_test CFLAGS+= -I${SRCTOP}/tests -.if ${MK_GOOGLETEST} != no - -.PATH: ${SRCTOP}/contrib/capsicum-test - -GTESTS+= capsicum-test - -SRCS.capsicum-test+= \ - capsicum-test-main.cc \ - capsicum-test.cc \ - capability-fd.cc \ - fexecve.cc \ - procdesc.cc \ - capmode.cc \ - fcntl.cc \ - ioctl.cc \ - openat.cc \ - sysctl.cc \ - select.cc \ - mqueue.cc \ - socket.cc \ - sctp.cc \ - capability-fd-pair.cc \ - overhead.cc \ - rename.cc - -LIBADD.capsicum-test+= gtest pthread -TEST_METADATA.capsicum-test= required_user="unprivileged" - -.for p in mini-me mini-me.noexec mini-me.setuid -PROGS+= $p -NO_SHARED.$p= -SRCS.$p= mini-me.c -.endfor - -BINDIR= ${TESTSDIR} - -BINMODE.mini-me.noexec= ${NOBINMODE} -BINMODE.mini-me.setuid= 4555 - -WARNS.capsicum-test= 3 - -.endif +WARNS?= 6 .include diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile index 413998950ee2..c3cf1f14e5bf 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -85,4 +85,6 @@ LIBADD+= pthread LIBADD+= gmock gtest LIBADD+= util +WARNS?= 6 + .include diff --git a/tests/sys/kern/pipe/Makefile b/tests/sys/kern/pipe/Makefile index 9211700ada98..193676465aa3 100644 --- a/tests/sys/kern/pipe/Makefile +++ b/tests/sys/kern/pipe/Makefile @@ -12,4 +12,6 @@ PLAIN_TESTS_C+= pipe_reverse2_test PLAIN_TESTS_C+= pipe_reverse_test PLAIN_TESTS_C+= pipe_wraparound_test +WARNS?= 6 + .include diff --git a/tests/sys/mqueue/Makefile b/tests/sys/mqueue/Makefile index 861694e0b353..251c497e32e4 100644 --- a/tests/sys/mqueue/Makefile +++ b/tests/sys/mqueue/Makefile @@ -16,4 +16,6 @@ PROGS+= mqtest5 LIBADD+= rt +WARNS?= 6 + .include diff --git a/tests/sys/net/Makefile b/tests/sys/net/Makefile index b14d6cbf8253..cccabd9fc775 100644 --- a/tests/sys/net/Makefile +++ b/tests/sys/net/Makefile @@ -28,6 +28,6 @@ ${PACKAGE}FILESMODE_stp.py= 0555 MAN= PROGS+= randsleep -CFLAGS+= -I${.CURDIR:H:H} +WARNS?= 6 .include diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index 3bb99af8b88b..f5b465557282 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -14,4 +14,6 @@ PROGS= udp_dontroute tcp_user_cookie MAN= +WARNS?= 6 + .include diff --git a/tests/sys/netmap/Makefile b/tests/sys/netmap/Makefile index 0228271dd668..a1d61ddf8952 100644 --- a/tests/sys/netmap/Makefile +++ b/tests/sys/netmap/Makefile @@ -11,4 +11,6 @@ PLAIN_TESTS_C+= ctrl-api-test CFLAGS+= -I${SRCTOP}/tests LIBADD+= pthread +WARNS?= 6 + .include diff --git a/tests/sys/opencrypto/Makefile b/tests/sys/opencrypto/Makefile index a0094091ecc6..f9685b166afc 100644 --- a/tests/sys/opencrypto/Makefile +++ b/tests/sys/opencrypto/Makefile @@ -21,4 +21,6 @@ PYMODULES= cryptodev.py cryptodevh.py cryptotest.py ${PACKAGE}FILES+= ${PYMODULES} +WARNS?= 6 + .include diff --git a/tests/sys/pjdfstest/pjdfstest/Makefile b/tests/sys/pjdfstest/pjdfstest/Makefile index 53e29c3891fb..e676cc036bad 100644 --- a/tests/sys/pjdfstest/pjdfstest/Makefile +++ b/tests/sys/pjdfstest/pjdfstest/Makefile @@ -10,4 +10,6 @@ MAN= CFLAGS+= -I${.CURDIR:H} +WARNS?= 6 + .include diff --git a/tools/regression/aio/aiop/Makefile b/tools/regression/aio/aiop/Makefile index aac9a3b89e45..38d9db62266a 100644 --- a/tools/regression/aio/aiop/Makefile +++ b/tools/regression/aio/aiop/Makefile @@ -3,4 +3,6 @@ PROG= aiop MAN= +WARNS= 6 + .include diff --git a/tools/regression/bpf/bpf_filter/Makefile b/tools/regression/bpf/bpf_filter/Makefile index e01a54e26cb3..d0038f915239 100644 --- a/tools/regression/bpf/bpf_filter/Makefile +++ b/tools/regression/bpf/bpf_filter/Makefile @@ -46,6 +46,7 @@ SRCS+= ${SYSDIR}/net/bpf_jitter.c \ ${SYSDIR}/${MACHINE_ARCH}/${MACHINE_ARCH}/bpf_jit_machdep.c CFLAGS+= -DBPF_JIT_COMPILER LIBS+= -lutil +WARNS?= 6 .else SRCS+= ${SYSDIR}/net/bpf_filter.c WARNS?= 2 diff --git a/tools/regression/doat/Makefile b/tools/regression/doat/Makefile index c31ca53f4579..c04223bbfec8 100644 --- a/tools/regression/doat/Makefile +++ b/tools/regression/doat/Makefile @@ -3,5 +3,6 @@ PROG= doat MAN= +WARNS?=6 .include diff --git a/tools/regression/geom_gpt/Makefile b/tools/regression/geom_gpt/Makefile index eb5a9659ff4f..92d1f020c916 100644 --- a/tools/regression/geom_gpt/Makefile +++ b/tools/regression/geom_gpt/Makefile @@ -5,4 +5,6 @@ MAN= LIBADD+= geom +WARNS?= 6 + .include diff --git a/tools/regression/include/stdatomic/Makefile b/tools/regression/include/stdatomic/Makefile index 2bc346a7d6fc..ae9982ac1418 100644 --- a/tools/regression/include/stdatomic/Makefile +++ b/tools/regression/include/stdatomic/Makefile @@ -1,6 +1,7 @@ # $FreeBSD$ PROG= logic +WARNS=6 MAN= .include diff --git a/tools/regression/netinet/ipbroadcast/Makefile b/tools/regression/netinet/ipbroadcast/Makefile index c1e5bba93dcf..a1b497ae145c 100644 --- a/tools/regression/netinet/ipbroadcast/Makefile +++ b/tools/regression/netinet/ipbroadcast/Makefile @@ -5,4 +5,6 @@ PROG= ipbroadcast MAN= +WARNS?= 6 + .include diff --git a/tools/regression/rpcsec_gss/Makefile b/tools/regression/rpcsec_gss/Makefile index 6f9debb7c2c3..bea9d9c10e21 100644 --- a/tools/regression/rpcsec_gss/Makefile +++ b/tools/regression/rpcsec_gss/Makefile @@ -2,6 +2,7 @@ PROG= rpctest MAN= +WARNS?= 6 LIBADD= rpcsec_gss DEBUG_FLAGS= -g -O0 diff --git a/tools/regression/sockets/accept_fd_leak/Makefile b/tools/regression/sockets/accept_fd_leak/Makefile index d3b3f42ce2a8..e9bfba606c10 100644 --- a/tools/regression/sockets/accept_fd_leak/Makefile +++ b/tools/regression/sockets/accept_fd_leak/Makefile @@ -4,5 +4,6 @@ PROG= accept_fd_leak MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/accf_data_attach/Makefile b/tools/regression/sockets/accf_data_attach/Makefile index e7942ced5d02..4d337282eade 100644 --- a/tools/regression/sockets/accf_data_attach/Makefile +++ b/tools/regression/sockets/accf_data_attach/Makefile @@ -4,5 +4,6 @@ PROG= accf_data_attach MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/fstat/Makefile b/tools/regression/sockets/fstat/Makefile index d5cb72419969..a583166d10c9 100644 --- a/tools/regression/sockets/fstat/Makefile +++ b/tools/regression/sockets/fstat/Makefile @@ -4,5 +4,6 @@ PROG= fstat MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/kqueue/Makefile b/tools/regression/sockets/kqueue/Makefile index e37eadfbb203..6771d25acf66 100644 --- a/tools/regression/sockets/kqueue/Makefile +++ b/tools/regression/sockets/kqueue/Makefile @@ -4,5 +4,6 @@ PROG= kqueue MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/listen_backlog/Makefile b/tools/regression/sockets/listen_backlog/Makefile index 091d7a420c76..e2eb1350710a 100644 --- a/tools/regression/sockets/listen_backlog/Makefile +++ b/tools/regression/sockets/listen_backlog/Makefile @@ -2,5 +2,6 @@ PROG= listen_backlog MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/listen_kqueue/Makefile b/tools/regression/sockets/listen_kqueue/Makefile index a506f262d06a..d49a597fc8f5 100644 --- a/tools/regression/sockets/listen_kqueue/Makefile +++ b/tools/regression/sockets/listen_kqueue/Makefile @@ -2,5 +2,6 @@ PROG= listen_kqueue MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/listenclose/Makefile b/tools/regression/sockets/listenclose/Makefile index ee147dad8cef..8f4dc4e922d4 100644 --- a/tools/regression/sockets/listenclose/Makefile +++ b/tools/regression/sockets/listenclose/Makefile @@ -4,5 +4,6 @@ PROG= listenclose MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/pr_atomic/Makefile b/tools/regression/sockets/pr_atomic/Makefile index a52433c6ef26..1dc85ffbeff8 100644 --- a/tools/regression/sockets/pr_atomic/Makefile +++ b/tools/regression/sockets/pr_atomic/Makefile @@ -2,5 +2,6 @@ PROG= pr_atomic MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/reconnect/Makefile b/tools/regression/sockets/reconnect/Makefile index 285d075bca4b..d8fa5e09b502 100644 --- a/tools/regression/sockets/reconnect/Makefile +++ b/tools/regression/sockets/reconnect/Makefile @@ -4,5 +4,6 @@ PROG= reconnect MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/rtsocket/Makefile b/tools/regression/sockets/rtsocket/Makefile index fcb2e40acca1..f68b6c3a2e2c 100644 --- a/tools/regression/sockets/rtsocket/Makefile +++ b/tools/regression/sockets/rtsocket/Makefile @@ -2,5 +2,6 @@ PROG= rtsocket MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/sblock/Makefile b/tools/regression/sockets/sblock/Makefile index 1992a0a652ac..aa2f890bc447 100644 --- a/tools/regression/sockets/sblock/Makefile +++ b/tools/regression/sockets/sblock/Makefile @@ -4,5 +4,6 @@ PROG= sblock MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/sendfile/Makefile b/tools/regression/sockets/sendfile/Makefile index f1ba7a1cf596..6e9c1ab70164 100644 --- a/tools/regression/sockets/sendfile/Makefile +++ b/tools/regression/sockets/sendfile/Makefile @@ -4,6 +4,7 @@ PROG= sendfile MAN= +WARNS?= 6 LIBADD= md .include diff --git a/tools/regression/sockets/shutdown/Makefile b/tools/regression/sockets/shutdown/Makefile index c36398c5af24..63045f5556ff 100644 --- a/tools/regression/sockets/shutdown/Makefile +++ b/tools/regression/sockets/shutdown/Makefile @@ -4,5 +4,6 @@ PROG= shutdown MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/sigpipe/Makefile b/tools/regression/sockets/sigpipe/Makefile index bd7720fbcbed..51167011edb6 100644 --- a/tools/regression/sockets/sigpipe/Makefile +++ b/tools/regression/sockets/sigpipe/Makefile @@ -4,5 +4,6 @@ PROG= sigpipe MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/so_setfib/Makefile b/tools/regression/sockets/so_setfib/Makefile index eadb3efb1c36..90111fb86bd5 100644 --- a/tools/regression/sockets/so_setfib/Makefile +++ b/tools/regression/sockets/so_setfib/Makefile @@ -4,6 +4,7 @@ PROG= so_setfib MAN= +WARNS?= 6 .if ${MK_INET} != "no" CFLAGS+= -DINET diff --git a/tools/regression/sockets/udp_pingpong/Makefile b/tools/regression/sockets/udp_pingpong/Makefile index 61e92ed73ce8..2ec5b209ce2c 100644 --- a/tools/regression/sockets/udp_pingpong/Makefile +++ b/tools/regression/sockets/udp_pingpong/Makefile @@ -2,5 +2,6 @@ PROG= udp_pingpong MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_bindconnect/Makefile b/tools/regression/sockets/unix_bindconnect/Makefile index 4bb4fc011ba4..52cc8442be09 100644 --- a/tools/regression/sockets/unix_bindconnect/Makefile +++ b/tools/regression/sockets/unix_bindconnect/Makefile @@ -2,5 +2,6 @@ PROG= unix_bindconnect MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_close_race/Makefile b/tools/regression/sockets/unix_close_race/Makefile index 690929edc2bc..370adc469896 100644 --- a/tools/regression/sockets/unix_close_race/Makefile +++ b/tools/regression/sockets/unix_close_race/Makefile @@ -2,5 +2,6 @@ PROG= unix_close_race MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_gc/Makefile b/tools/regression/sockets/unix_gc/Makefile index 09ba07ae65ee..184660965069 100644 --- a/tools/regression/sockets/unix_gc/Makefile +++ b/tools/regression/sockets/unix_gc/Makefile @@ -2,5 +2,6 @@ PROG= unix_gc MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_sendtorace/Makefile b/tools/regression/sockets/unix_sendtorace/Makefile index 7d26fc8b1383..75e7b9f0b606 100644 --- a/tools/regression/sockets/unix_sendtorace/Makefile +++ b/tools/regression/sockets/unix_sendtorace/Makefile @@ -2,5 +2,6 @@ PROG= unix_sendtorace MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_socket/Makefile b/tools/regression/sockets/unix_socket/Makefile index 7ebc03fc22f3..bb6045637ed1 100644 --- a/tools/regression/sockets/unix_socket/Makefile +++ b/tools/regression/sockets/unix_socket/Makefile @@ -2,5 +2,6 @@ PROG= unix_socket MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/unix_sorflush/Makefile b/tools/regression/sockets/unix_sorflush/Makefile index 879dcc8ef533..db0aa6ade00d 100644 --- a/tools/regression/sockets/unix_sorflush/Makefile +++ b/tools/regression/sockets/unix_sorflush/Makefile @@ -2,5 +2,6 @@ PROG= unix_sorflush MAN= +WARNS?= 6 .include diff --git a/tools/regression/sockets/zerosend/Makefile b/tools/regression/sockets/zerosend/Makefile index 9706b25ea899..18f7dd3e649a 100644 --- a/tools/regression/sockets/zerosend/Makefile +++ b/tools/regression/sockets/zerosend/Makefile @@ -2,5 +2,6 @@ PROG= zerosend MAN= +WARNS?= 6 .include diff --git a/tools/test/auxinfo/Makefile b/tools/test/auxinfo/Makefile index f40c81d87652..0e6d80992ad8 100644 --- a/tools/test/auxinfo/Makefile +++ b/tools/test/auxinfo/Makefile @@ -2,5 +2,6 @@ PROG= auxinfo MAN= +WARNS?= 6 .include diff --git a/tools/test/iconv/posix/Makefile b/tools/test/iconv/posix/Makefile index aafaadebafe7..891142412df8 100644 --- a/tools/test/iconv/posix/Makefile +++ b/tools/test/iconv/posix/Makefile @@ -3,4 +3,6 @@ PROG= posix MAN= +WARNS?= 6 + .include diff --git a/tools/test/malloc/Makefile b/tools/test/malloc/Makefile index ac3fdd89486b..455dec39920b 100644 --- a/tools/test/malloc/Makefile +++ b/tools/test/malloc/Makefile @@ -4,6 +4,7 @@ SRCS= main.c .PATH: ${.CURDIR}/../../../lib/libc/stdlib MAN= +WARNS?=6 test: malloc @echo diff --git a/tools/test/net/Makefile b/tools/test/net/Makefile index 4fe5fb155cd1..e4c525920d8c 100644 --- a/tools/test/net/Makefile +++ b/tools/test/net/Makefile @@ -2,6 +2,7 @@ PROGS= listen connect MAN= +WARNS?= 6 test: ${PROGS} diff --git a/tools/test/netfibs/Makefile b/tools/test/netfibs/Makefile index 7262a21356c8..689d613616e1 100644 --- a/tools/test/netfibs/Makefile +++ b/tools/test/netfibs/Makefile @@ -2,5 +2,6 @@ PROG= reflect MAN= +WARNS?= 6 .include diff --git a/tools/test/ptrace/Makefile b/tools/test/ptrace/Makefile index 46e0aee6b53f..a11b0a16a846 100644 --- a/tools/test/ptrace/Makefile +++ b/tools/test/ptrace/Makefile @@ -2,5 +2,6 @@ PROG= scescx MAN= +WARNS?= 6 .include diff --git a/tools/tools/aac/Makefile b/tools/tools/aac/Makefile index 9f2f4a7249cd..03c5dcda9ed9 100644 --- a/tools/tools/aac/Makefile +++ b/tools/tools/aac/Makefile @@ -2,6 +2,7 @@ PROG= aac_checkq MAN= +WARNS?=6 BINDIR?=/usr/local/bin .include diff --git a/tools/tools/cfi/Makefile b/tools/tools/cfi/Makefile index 9f4dd10a2828..5a49f2d38438 100644 --- a/tools/tools/cfi/Makefile +++ b/tools/tools/cfi/Makefile @@ -3,5 +3,6 @@ PROG= cfi BINDIR= /usr/local/bin MAN= *** 279 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Sun Aug 29 13:54:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 15E1B65F1AC; Sun, 29 Aug 2021 13:54:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyFLJ6tdqz3vWt; Sun, 29 Aug 2021 13:54: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 D42793BED; Sun, 29 Aug 2021 13:54: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 17TDsGn1099674; Sun, 29 Aug 2021 13:54:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDsG20099673; Sun, 29 Aug 2021 13:54:16 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:54:16 GMT Message-Id: <202108291354.17TDsG20099673@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 22b8ab15c41a - main - Remove -simplifycfg-dup-ret from CLANG_OPT_SMALL flags for clang 13 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 22b8ab15c41a9efac201691b40e961b83698aa9c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:54:17 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=22b8ab15c41a9efac201691b40e961b83698aa9c commit 22b8ab15c41a9efac201691b40e961b83698aa9c Author: Dimitry Andric AuthorDate: 2021-08-29 13:39:16 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 13:39:16 +0000 Remove -simplifycfg-dup-ret from CLANG_OPT_SMALL flags for clang 13 After llvm/clang 13.0.0, the -simplifycfg-dup-ret backend flag is no longer supported. This was part of CLANG_OPT_SMALL, which is only still used for stand/i386/boot2 and stand/i386/isoboot, to achieve the very small binary size required. Luckily clang 13.0.0 does not need any additional flags for this (I get 240 bytes available when building boot2). MFC after: 3 days --- share/mk/bsd.sys.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 80cc3080e552..a4bb54e19890 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -228,8 +228,10 @@ CFLAGS+=-nobuiltininc -idirafter ${COMPILER_RESOURCE_DIR}/include .endif .endif -CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ - -mllvm -simplifycfg-dup-ret +CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3 +.if ${COMPILER_VERSION} < 130000 +CLANG_OPT_SMALL+= -mllvm -simplifycfg-dup-ret +.endif CLANG_OPT_SMALL+= -mllvm -enable-load-pre=false CFLAGS.clang+= -Qunused-arguments # The libc++ headers use c++11 extensions. These are normally silenced because From owner-dev-commits-src-all@freebsd.org Sun Aug 29 13:54:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C7FD65F06F; Sun, 29 Aug 2021 13:54: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 4GyFLL1HGrz3vRk; Sun, 29 Aug 2021 13:54: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 0262C38BB; Sun, 29 Aug 2021 13:54: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 17TDsHWx099698; Sun, 29 Aug 2021 13:54:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TDsH4L099697; Sun, 29 Aug 2021 13:54:17 GMT (envelope-from git) Date: Sun, 29 Aug 2021 13:54:17 GMT Message-Id: <202108291354.17TDsH4L099697@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 395d46caaed7 - main - Don't error out on unused but set variables with clang 13 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 395d46caaed73228b84dfaeb37c702304a46ba8f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 13:54:18 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=395d46caaed73228b84dfaeb37c702304a46ba8f commit 395d46caaed73228b84dfaeb37c702304a46ba8f Author: Dimitry Andric AuthorDate: 2021-08-29 13:53:40 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 13:53:40 +0000 Don't error out on unused but set variables with clang 13 Clang 13.0.0 now has a -Wunused-but-set-variable warning similar to the one gcc has had for quite a while. Since this triggers *very* often for our kernel builds, don't make it a hard error, but leave the warning visible so is some incentive to fix the instances. MFC after: 3 days --- sys/conf/kern.mk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 56bddb35398b..f6767ba76a46 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -25,6 +25,9 @@ NO_WUNNEEDED_INTERNAL_DECL= -Wno-error=unneeded-internal-declaration NO_WSOMETIMES_UNINITIALIZED= -Wno-error=sometimes-uninitialized NO_WCAST_QUAL= -Wno-error=cast-qual NO_WTAUTOLOGICAL_POINTER_COMPARE= -Wno-tautological-pointer-compare +.if ${COMPILER_VERSION} >= 100000 +NO_WMISLEADING_INDENTATION= -Wno-misleading-indentation +.endif # Several other warnings which might be useful in some cases, but not severe # enough to error out the whole kernel build. Display them anyway, so there is # some incentive to fix them eventually. @@ -33,8 +36,8 @@ CWARNEXTRA?= -Wno-error=tautological-compare -Wno-error=empty-body \ -Wno-error=pointer-sign CWARNEXTRA+= -Wno-error=shift-negative-value CWARNEXTRA+= -Wno-address-of-packed-member -.if ${COMPILER_VERSION} >= 100000 -NO_WMISLEADING_INDENTATION= -Wno-misleading-indentation +.if ${COMPILER_VERSION} >= 130000 +CWARNFLAGS+= -Wno-error=unused-but-set-variable .endif .endif # clang From owner-dev-commits-src-all@freebsd.org Sun Aug 29 15:31:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56CE96605C1; Sun, 29 Aug 2021 15:31: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 4GyHVt1sxRz4tgR; Sun, 29 Aug 2021 15:31: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 291CF50DA; Sun, 29 Aug 2021 15:31: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 17TFVoKa033311; Sun, 29 Aug 2021 15:31:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TFVoah033310; Sun, 29 Aug 2021 15:31:50 GMT (envelope-from git) Date: Sun, 29 Aug 2021 15:31:50 GMT Message-Id: <202108291531.17TFVoah033310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 5b8f07b12f84 - main - Fix -Wformat errors in pfctl on 32-bit architectures MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5b8f07b12f8477f1679013d6b3abdab8d33c7243 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 15:31:50 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5b8f07b12f8477f1679013d6b3abdab8d33c7243 commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 Author: Dimitry Andric AuthorDate: 2021-08-29 15:31:28 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 15:31:28 +0000 Fix -Wformat errors in pfctl on 32-bit architectures Use PRIu64 to printf(3) uint64_t quantities, otherwise this will result in "error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on 32-bit architectures. Fixes: 80078d9d38fd MFC after: 1 week --- sbin/pfctl/pfctl_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index e9a227630f28..9f955a8b1c96 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -578,7 +578,7 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) printf("%-27s %14s %16s\n", "State Table", "Total", "Rate"); printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->states, ""); TAILQ_FOREACH(c, &s->fcounters, entry) { - printf(" %-25s %14lu ", c->name, c->counter); + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", (double)c->counter / (double)runtime); @@ -590,7 +590,7 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) printf(" %-25s %14" PRIu64 " %14s\n", "current entries", s->src_nodes, ""); TAILQ_FOREACH(c, &s->scounters, entry) { - printf(" %-25s %14lu ", c->name, c->counter); + printf(" %-25s %14" PRIu64 " ", c->name, c->counter); if (runtime > 0) printf("%14.1f/s\n", (double)c->counter / (double)runtime); From owner-dev-commits-src-all@freebsd.org Sun Aug 29 16:00:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCC2C660C50; Sun, 29 Aug 2021 16:00:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyJ895ryfz3J2p; Sun, 29 Aug 2021 16:00:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.codepro.be", Issuer "R3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 98DBD259AE; Sun, 29 Aug 2021 16:00:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id C1D0228EAF; Sun, 29 Aug 2021 18:00:39 +0200 (CEST) From: Kristof Provost To: Dimitry Andric Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 5b8f07b12f84 - main - Fix -Wformat errors in pfctl on 32-bit architectures Date: Sun, 29 Aug 2021 18:00:38 +0200 X-Mailer: MailMate (1.14r5818) Message-ID: <6A084192-562D-404D-9833-51A708FA1BC0@FreeBSD.org> In-Reply-To: <202108291531.17TFVoah033310@gitrepo.freebsd.org> References: <202108291531.17TFVoah033310@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 16:00:41 -0000 On 29 Aug 2021, at 17:31, Dimitry Andric wrote: > The branch main has been updated by dim: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D5b8f07b12f8477f1679013d6= b3abdab8d33c7243 > > commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 > Author: Dimitry Andric > AuthorDate: 2021-08-29 15:31:28 +0000 > Commit: Dimitry Andric > CommitDate: 2021-08-29 15:31:28 +0000 > > Fix -Wformat errors in pfctl on 32-bit architectures > > Use PRIu64 to printf(3) uint64_t quantities, otherwise this will re= sult > in "error: format specifies type 'unsigned long' but the argument h= as > type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on 3= 2-bit > architectures. > > Fixes: 80078d9d38fd > MFC after: 1 week Thanks! I was running test builds for a fix, but it is so much more convenient wh= en other people fix my mistakes for me. Kristof From owner-dev-commits-src-all@freebsd.org Sun Aug 29 16:40:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D189661759; Sun, 29 Aug 2021 16:40: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 4GyK1Z0QbBz3jjh; Sun, 29 Aug 2021 16:40: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 E6EC95770; Sun, 29 Aug 2021 16:40: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 17TGe13O015372; Sun, 29 Aug 2021 16:40:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TGe1hY015369; Sun, 29 Aug 2021 16:40:01 GMT (envelope-from git) Date: Sun, 29 Aug 2021 16:40:01 GMT Message-Id: <202108291640.17TGe1hY015369@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: 9d3454e1e111 - stable/13 - pci: Add an ioctl to perform I/O to BARs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9d3454e1e111e8d3d5809085391db71c03d5dc24 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 16:40:02 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9d3454e1e111e8d3d5809085391db71c03d5dc24 commit 9d3454e1e111e8d3d5809085391db71c03d5dc24 Author: Mark Johnston AuthorDate: 2021-08-14 14:41:43 +0000 Commit: Mark Johnston CommitDate: 2021-08-29 16:39:42 +0000 pci: Add an ioctl to perform I/O to BARs This is useful for bhyve, which otherwise has to use /dev/io to handle accesses to I/O port BARs when PCI passthrough is in use. Reviewed by: imp, kib Discussed with: jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 7e14be0b0717105f4b3b8c62df82a1e883d8ebb6) --- share/man/man4/pci.4 | 36 +++++++++++++++++- sys/dev/pci/pci_user.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ sys/sys/pciio.h | 12 ++++++ 3 files changed, 147 insertions(+), 1 deletion(-) diff --git a/share/man/man4/pci.4 b/share/man/man4/pci.4 index 28a456d18179..3c2c08afe466 100644 --- a/share/man/man4/pci.4 +++ b/share/man/man4/pci.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 27, 2021 +.Dd August 13, 2021 .Dt PCI 4 .Os .Sh NAME @@ -430,6 +430,40 @@ even on reads. of mapping. Currently attempt to mmap an inactive BAR results in error. .El +.It PCIOCBARIO +This +.Xr ioctl 2 +command allows users to read from and write to BARs. +The I/O request parameters are passed in a +.Va struct pci_bar_ioreq +structure, which has the following fields: +.Bl -tag +.It Vt struct pcisel pbi_sel +Describes the device to operate on. +.It Vt int pbi_op +The operation to perform. +Currently supported values are +.Dv PCIBARIO_READ +and +.Dv PCIBARIO_WRITE . +.It Vt uint32_t pbi_bar +The index of the BAR on which to operate. +.It Vt uint32_t pbi_offset +The offset into the BAR at which to operate. +.It Vt uint32_t pbi_width +The size, in bytes, of the I/O operation. +1-byte, 2-byte, 4-byte and 8-byte perations are supported. +.It Vt uint32_t pbi_value +For reads, the value is returned in this field. +For writes, the caller specifies the value to be written in this field. +.Pp +Note that this operation maps and unmaps the corresponding resource and +so is relatively expensive for memory BARs. +The +.Va PCIOCBARMMAP +.Xr ioctl 2 +can be used to create a persistent userspace mapping for such BARs instead. +.El .El .Sh LOADER TUNABLES Tunables can be set at the diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 640a10abfeca..544cb83ece69 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -919,6 +919,92 @@ out: return (error); } +static int +pci_bar_io(device_t pcidev, struct pci_bar_ioreq *pbi) +{ + struct pci_map *pm; + struct resource *res; + uint32_t offset, width; + int bar, error, type; + + if (pbi->pbi_op != PCIBARIO_READ && + pbi->pbi_op != PCIBARIO_WRITE) + return (EINVAL); + + bar = PCIR_BAR(pbi->pbi_bar); + pm = pci_find_bar(pcidev, bar); + if (pm == NULL) + return (EINVAL); + + offset = pbi->pbi_offset; + width = pbi->pbi_width; + + if (offset + width < offset || + ((pci_addr_t)1 << pm->pm_size) < offset + width) + return (EINVAL); + + type = PCI_BAR_MEM(pm->pm_value) ? SYS_RES_MEMORY : SYS_RES_IOPORT; + + /* + * This will fail if a driver has allocated the resource. This could be + * worked around by detecting that case and using bus_map_resource() to + * populate the handle, but so far this is not needed. + */ + res = bus_alloc_resource_any(pcidev, type, &bar, RF_ACTIVE); + if (res == NULL) + return (ENOENT); + + error = 0; + switch (pbi->pbi_op) { + case PCIBARIO_READ: + switch (pbi->pbi_width) { + case 1: + pbi->pbi_value = bus_read_1(res, offset); + break; + case 2: + pbi->pbi_value = bus_read_2(res, offset); + break; + case 4: + pbi->pbi_value = bus_read_4(res, offset); + break; +#ifndef __i386__ + case 8: + pbi->pbi_value = bus_read_8(res, offset); + break; +#endif + default: + error = EINVAL; + break; + } + break; + case PCIBARIO_WRITE: + switch (pbi->pbi_width) { + case 1: + bus_write_1(res, offset, pbi->pbi_value); + break; + case 2: + bus_write_2(res, offset, pbi->pbi_value); + break; + case 4: + bus_write_4(res, offset, pbi->pbi_value); + break; +#ifndef __i386__ + case 8: + bus_write_8(res, offset, pbi->pbi_value); + break; +#endif + default: + error = EINVAL; + break; + } + break; + } + + bus_release_resource(pcidev, type, bar, res); + + return (error); +} + static int pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) { @@ -928,6 +1014,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t struct pci_conf_io *cio = NULL; struct pci_devinfo *dinfo; struct pci_io *io; + struct pci_bar_ioreq *pbi; struct pci_bar_io *bio; struct pci_list_vpd_io *lvio; struct pci_match_conf *pattern_buf; @@ -1303,6 +1390,19 @@ getconfexit: error = pcidev == NULL ? ENODEV : pci_bar_mmap(pcidev, pbm); break; + case PCIOCBARIO: + pbi = (struct pci_bar_ioreq *)data; + + pcidev = pci_find_dbsf(pbi->pbi_sel.pc_domain, + pbi->pbi_sel.pc_bus, pbi->pbi_sel.pc_dev, + pbi->pbi_sel.pc_func); + if (pcidev == NULL) { + error = ENODEV; + break; + } + error = pci_bar_io(pcidev, pbi); + break; + default: error = ENOTTY; break; diff --git a/sys/sys/pciio.h b/sys/sys/pciio.h index 50e9116d63d4..16635a884ca3 100644 --- a/sys/sys/pciio.h +++ b/sys/sys/pciio.h @@ -151,6 +151,17 @@ struct pci_bar_mmap { int pbm_memattr; }; +struct pci_bar_ioreq { + struct pcisel pbi_sel; /* device to operate on */ +#define PCIBARIO_READ 0x1 +#define PCIBARIO_WRITE 0x2 + int pbi_op; + uint32_t pbi_bar; + uint32_t pbi_offset; + uint32_t pbi_width; + uint32_t pbi_value; +}; + #define PCIIO_BAR_MMAP_FIXED 0x01 #define PCIIO_BAR_MMAP_EXCL 0x02 #define PCIIO_BAR_MMAP_RW 0x04 @@ -163,5 +174,6 @@ struct pci_bar_mmap { #define PCIOCGETBAR _IOWR('p', 6, struct pci_bar_io) #define PCIOCLISTVPD _IOWR('p', 7, struct pci_list_vpd_io) #define PCIOCBARMMAP _IOWR('p', 8, struct pci_bar_mmap) +#define PCIOCBARIO _IOWR('p', 9, struct pci_bar_ioreq) #endif /* !_SYS_PCIIO_H_ */ From owner-dev-commits-src-all@freebsd.org Sun Aug 29 16:40:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3FE05661A33; Sun, 29 Aug 2021 16:40: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 4GyK1b0nCjz3jsf; Sun, 29 Aug 2021 16:40:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F18365771; Sun, 29 Aug 2021 16:40: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 17TGe2oU015587; Sun, 29 Aug 2021 16:40:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TGe236015584; Sun, 29 Aug 2021 16:40:02 GMT (envelope-from git) Date: Sun, 29 Aug 2021 16:40:02 GMT Message-Id: <202108291640.17TGe236015584@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: c53f23984220 - stable/13 - bhyve: Use pci(4) to access I/O port BARs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c53f23984220bfd34c198966874c369006ea3246 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 16:40:03 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c53f23984220bfd34c198966874c369006ea3246 commit c53f23984220bfd34c198966874c369006ea3246 Author: Mark Johnston AuthorDate: 2021-08-14 14:42:34 +0000 Commit: Mark Johnston CommitDate: 2021-08-29 16:39:53 +0000 bhyve: Use pci(4) to access I/O port BARs This removes the dependency on /dev/io. PR: 251046 Reviewed by: jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 42375556e5b2e68746d999b43d124040b6affb91) --- usr.sbin/bhyve/pci_passthru.c | 65 ++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index 9028369217d4..2c6a2ebd8dd9 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -69,10 +69,6 @@ __FBSDID("$FreeBSD$"); #define _PATH_DEVPCI "/dev/pci" #endif -#ifndef _PATH_DEVIO -#define _PATH_DEVIO "/dev/io" -#endif - #ifndef _PATH_MEM #define _PATH_MEM "/dev/mem" #endif @@ -83,7 +79,6 @@ __FBSDID("$FreeBSD$"); #define MSIX_CAPLEN 12 static int pcifd = -1; -static int iofd = -1; static int memfd = -1; struct passthru_softc { @@ -649,8 +644,8 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) const char *value; #ifndef WITHOUT_CAPSICUM cap_rights_t rights; - cap_ioctl_t pci_ioctls[] = { PCIOCREAD, PCIOCWRITE, PCIOCGETBAR }; - cap_ioctl_t io_ioctls[] = { IODEV_PIO }; + cap_ioctl_t pci_ioctls[] = + { PCIOCREAD, PCIOCWRITE, PCIOCGETBAR, PCIOCBARIO }; #endif sc = NULL; @@ -681,21 +676,6 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) errx(EX_OSERR, "Unable to apply rights for sandbox"); #endif - if (iofd < 0) { - iofd = open(_PATH_DEVIO, O_RDWR, 0); - if (iofd < 0) { - warn("failed to open %s", _PATH_DEVIO); - return (error); - } - } - -#ifndef WITHOUT_CAPSICUM - if (caph_rights_limit(iofd, &rights) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); - if (caph_ioctls_limit(iofd, io_ioctls, nitems(io_ioctls)) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); -#endif - if (memfd < 0) { memfd = open(_PATH_MEM, O_RDWR, 0); if (memfd < 0) { @@ -910,7 +890,7 @@ passthru_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size, uint64_t value) { struct passthru_softc *sc; - struct iodev_pio_req pio; + struct pci_bar_ioreq pio; sc = pi->pi_arg; @@ -918,13 +898,18 @@ passthru_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, msix_table_write(ctx, vcpu, sc, offset, size, value); } else { assert(pi->pi_bar[baridx].type == PCIBAR_IO); - bzero(&pio, sizeof(struct iodev_pio_req)); - pio.access = IODEV_PIO_WRITE; - pio.port = sc->psc_bar[baridx].addr + offset; - pio.width = size; - pio.val = value; - - (void)ioctl(iofd, IODEV_PIO, &pio); + assert(size == 1 || size == 2 || size == 4); + assert(offset <= UINT32_MAX && offset + size <= UINT32_MAX); + + bzero(&pio, sizeof(pio)); + pio.pbi_sel = sc->psc_sel; + pio.pbi_op = PCIBARIO_WRITE; + pio.pbi_bar = baridx; + pio.pbi_offset = (uint32_t)offset; + pio.pbi_width = size; + pio.pbi_value = (uint32_t)value; + + (void)ioctl(pcifd, PCIOCBARIO, &pio); } } @@ -933,7 +918,7 @@ passthru_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size) { struct passthru_softc *sc; - struct iodev_pio_req pio; + struct pci_bar_ioreq pio; uint64_t val; sc = pi->pi_arg; @@ -942,15 +927,19 @@ passthru_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, val = msix_table_read(sc, offset, size); } else { assert(pi->pi_bar[baridx].type == PCIBAR_IO); - bzero(&pio, sizeof(struct iodev_pio_req)); - pio.access = IODEV_PIO_READ; - pio.port = sc->psc_bar[baridx].addr + offset; - pio.width = size; - pio.val = 0; + assert(size == 1 || size == 2 || size == 4); + assert(offset <= UINT32_MAX && offset + size <= UINT32_MAX); + + bzero(&pio, sizeof(pio)); + pio.pbi_sel = sc->psc_sel; + pio.pbi_op = PCIBARIO_READ; + pio.pbi_bar = baridx; + pio.pbi_offset = (uint32_t)offset; + pio.pbi_width = size; - (void)ioctl(iofd, IODEV_PIO, &pio); + (void)ioctl(pcifd, PCIOCBARIO, &pio); - val = pio.val; + val = pio.pbi_value; } return (val); From owner-dev-commits-src-all@freebsd.org Sun Aug 29 16:57:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 260C2661DE6; Sun, 29 Aug 2021 16:57: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 4GyKPG0BX7z3nPV; Sun, 29 Aug 2021 16:57: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 DF8236402; Sun, 29 Aug 2021 16:57: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 17TGv5MK040361; Sun, 29 Aug 2021 16:57:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TGv5aP040360; Sun, 29 Aug 2021 16:57:05 GMT (envelope-from git) Date: Sun, 29 Aug 2021 16:57:05 GMT Message-Id: <202108291657.17TGv5aP040360@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: c538903f7bec - stable/12 - freebsd-update: create a ZFS boot environment on install 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: c538903f7bec5bda540cf646841abe126d07193c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 16:57:06 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=c538903f7bec5bda540cf646841abe126d07193c commit c538903f7bec5bda540cf646841abe126d07193c Author: Dave Fullard AuthorDate: 2021-07-16 04:02:48 +0000 Commit: Kyle Evans CommitDate: 2021-08-29 16:56:17 +0000 freebsd-update: create a ZFS boot environment on install Updated freebsd-update to allow it to create boot environments using bectl should the system support it. The bectl utility was updated in r352211 (490e13c1403f) to support a 'check' to determine if the system supports boot environments. If UFS is used, the bectl check will fail then no attempt will be made to create the boot environment. If freebsd-update is run inside a jail, no attempt will be made to create a boot environment. The boot environment function will create a new environment using the format: current FreeBSD kernel version and date/timestamp, example: 12.0-RELEASE-p10_2019-10-03_185233 This functionality can be disabled by setting 'CreateBootEnv' in freebsd-update.conf to 'no'. (cherry picked from commit f28f138905416c45ebaa6429f44a0b88a72f54b1) --- usr.sbin/freebsd-update/freebsd-update.conf | 3 ++ usr.sbin/freebsd-update/freebsd-update.sh | 57 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/usr.sbin/freebsd-update/freebsd-update.conf b/usr.sbin/freebsd-update/freebsd-update.conf index 7f0917053750..62e6acf96cc8 100644 --- a/usr.sbin/freebsd-update/freebsd-update.conf +++ b/usr.sbin/freebsd-update/freebsd-update.conf @@ -74,3 +74,6 @@ MergeChanges /etc/ /boot/device.hints # When backing up a kernel also back up debug symbol files? # BackupKernelSymbolFiles no + +# Create a new boot environment when installing patches +# CreateBootEnv yes diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index f82ec7d7730c..4fbac58cb562 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -410,6 +410,23 @@ config_BackupKernelSymbolFiles () { fi } +config_CreateBootEnv () { + if [ -z ${BOOTENV} ]; then + case $1 in + [Yy][Ee][Ss]) + BOOTENV=yes + ;; + [Nn][Oo]) + BOOTENV=no + ;; + *) + return 1 + ;; + esac + else + return 1 + fi +} # Handle one line of configuration configline () { if [ $# -eq 0 ]; then @@ -586,6 +603,7 @@ default_params () { config_BackupKernel yes config_BackupKernelDir /boot/kernel.old config_BackupKernelSymbolFiles no + config_CreateBootEnv yes # Merge these defaults into the earlier-configured settings mergeconfig @@ -850,6 +868,44 @@ install_check_params () { fi } +# Creates a new boot environment +install_create_be () { + # Figure out if we're running in a jail and return if we are + if [ `sysctl -n security.jail.jailed` = 1 ]; then + return 1 + fi + # Create a boot environment if enabled + if [ ${BOOTENV} = yes ]; then + bectl check 2>/dev/null + case $? in + 0) + # Boot environment are supported + CREATEBE=yes + ;; + 255) + # Boot environments are not supported + CREATEBE=no + ;; + *) + # If bectl returns an unexpected exit code, don't create a BE + CREATEBE=no + ;; + esac + if [ ${CREATEBE} = yes ]; then + echo -n "Creating snapshot of existing boot environment... " + VERSION=`freebsd-version -k` + TIMESTAMP=`date +"%Y-%m-%d_%H%M%S"` + bectl create ${VERSION}_${TIMESTAMP} + if [ $? -eq 0 ]; then + echo "done."; + else + echo "failed." + exit 1 + fi + fi + fi +} + # Perform sanity checks and set some final parameters in # preparation for UNinstalling updates. rollback_check_params () { @@ -3366,6 +3422,7 @@ cmd_updatesready () { cmd_install () { finalize_components_config ${COMPONENTS} install_check_params + install_create_be install_run || exit 1 } From owner-dev-commits-src-all@freebsd.org Sun Aug 29 16:57:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B5E8A661FD1; Sun, 29 Aug 2021 16:57: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 4GyKPf4lF6z3nkD; Sun, 29 Aug 2021 16:57: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 89AEF615A; Sun, 29 Aug 2021 16:57:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TGvQfl040502; Sun, 29 Aug 2021 16:57:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TGvQMh040501; Sun, 29 Aug 2021 16:57:26 GMT (envelope-from git) Date: Sun, 29 Aug 2021 16:57:26 GMT Message-Id: <202108291657.17TGvQMh040501@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: 1420778e9ee6 - stable/13 - freebsd-update: create a ZFS boot environment on install 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: 1420778e9ee6486331dec3a1bf143c697cb72706 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 16:57:26 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=1420778e9ee6486331dec3a1bf143c697cb72706 commit 1420778e9ee6486331dec3a1bf143c697cb72706 Author: Dave Fullard AuthorDate: 2021-07-16 04:02:48 +0000 Commit: Kyle Evans CommitDate: 2021-08-29 16:55:55 +0000 freebsd-update: create a ZFS boot environment on install Updated freebsd-update to allow it to create boot environments using bectl should the system support it. The bectl utility was updated in r352211 (490e13c1403f) to support a 'check' to determine if the system supports boot environments. If UFS is used, the bectl check will fail then no attempt will be made to create the boot environment. If freebsd-update is run inside a jail, no attempt will be made to create a boot environment. The boot environment function will create a new environment using the format: current FreeBSD kernel version and date/timestamp, example: 12.0-RELEASE-p10_2019-10-03_185233 This functionality can be disabled by setting 'CreateBootEnv' in freebsd-update.conf to 'no'. (cherry picked from commit f28f138905416c45ebaa6429f44a0b88a72f54b1) --- usr.sbin/freebsd-update/freebsd-update.conf | 3 ++ usr.sbin/freebsd-update/freebsd-update.sh | 57 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/usr.sbin/freebsd-update/freebsd-update.conf b/usr.sbin/freebsd-update/freebsd-update.conf index 7f0917053750..62e6acf96cc8 100644 --- a/usr.sbin/freebsd-update/freebsd-update.conf +++ b/usr.sbin/freebsd-update/freebsd-update.conf @@ -74,3 +74,6 @@ MergeChanges /etc/ /boot/device.hints # When backing up a kernel also back up debug symbol files? # BackupKernelSymbolFiles no + +# Create a new boot environment when installing patches +# CreateBootEnv yes diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index f82ec7d7730c..4fbac58cb562 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -410,6 +410,23 @@ config_BackupKernelSymbolFiles () { fi } +config_CreateBootEnv () { + if [ -z ${BOOTENV} ]; then + case $1 in + [Yy][Ee][Ss]) + BOOTENV=yes + ;; + [Nn][Oo]) + BOOTENV=no + ;; + *) + return 1 + ;; + esac + else + return 1 + fi +} # Handle one line of configuration configline () { if [ $# -eq 0 ]; then @@ -586,6 +603,7 @@ default_params () { config_BackupKernel yes config_BackupKernelDir /boot/kernel.old config_BackupKernelSymbolFiles no + config_CreateBootEnv yes # Merge these defaults into the earlier-configured settings mergeconfig @@ -850,6 +868,44 @@ install_check_params () { fi } +# Creates a new boot environment +install_create_be () { + # Figure out if we're running in a jail and return if we are + if [ `sysctl -n security.jail.jailed` = 1 ]; then + return 1 + fi + # Create a boot environment if enabled + if [ ${BOOTENV} = yes ]; then + bectl check 2>/dev/null + case $? in + 0) + # Boot environment are supported + CREATEBE=yes + ;; + 255) + # Boot environments are not supported + CREATEBE=no + ;; + *) + # If bectl returns an unexpected exit code, don't create a BE + CREATEBE=no + ;; + esac + if [ ${CREATEBE} = yes ]; then + echo -n "Creating snapshot of existing boot environment... " + VERSION=`freebsd-version -k` + TIMESTAMP=`date +"%Y-%m-%d_%H%M%S"` + bectl create ${VERSION}_${TIMESTAMP} + if [ $? -eq 0 ]; then + echo "done."; + else + echo "failed." + exit 1 + fi + fi + fi +} + # Perform sanity checks and set some final parameters in # preparation for UNinstalling updates. rollback_check_params () { @@ -3366,6 +3422,7 @@ cmd_updatesready () { cmd_install () { finalize_components_config ${COMPONENTS} install_check_params + install_create_be install_run || exit 1 } From owner-dev-commits-src-all@freebsd.org Sun Aug 29 16:59:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 01142662214; Sun, 29 Aug 2021 16:59: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 4GyKSY6SScz3pPN; Sun, 29 Aug 2021 16:59: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 C3DD65E49; Sun, 29 Aug 2021 16:59: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 17TGxvwr040778; Sun, 29 Aug 2021 16:59:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TGxvXA040777; Sun, 29 Aug 2021 16:59:57 GMT (envelope-from git) Date: Sun, 29 Aug 2021 16:59:57 GMT Message-Id: <202108291659.17TGxvXA040777@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: 5a67aaf1fa2c - stable/13 - kern: mountroot: avoid fd leak in .md parsing 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: 5a67aaf1fa2cc4757d1cd62560563dcc2b88bdfc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 16:59:58 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=5a67aaf1fa2cc4757d1cd62560563dcc2b88bdfc commit 5a67aaf1fa2cc4757d1cd62560563dcc2b88bdfc Author: Kyle Evans AuthorDate: 2021-07-20 10:23:11 +0000 Commit: Kyle Evans CommitDate: 2021-08-29 16:58:24 +0000 kern: mountroot: avoid fd leak in .md parsing parse_dir_md() opens /dev/mdctl but only closes the resulting fd on success, not upon failure of the ioctl or when we exceed the md unit max. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #62 (cherry picked from commit 23ecfa9d5bc4f04eb58e26018c2d15f032d5d742) --- sys/kern/vfs_mountroot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c index a34ae3fe06e3..4f80104c311c 100644 --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -580,6 +580,7 @@ parse_dir_md(char **conf) int error, fd, len; td = curthread; + fd = -1; error = parse_token(conf, &tok); if (error) @@ -635,9 +636,9 @@ parse_dir_md(char **conf) root_mount_mddev = mdio->md_unit; printf(MD_NAME "%u attached to %s\n", root_mount_mddev, mdio->md_file); - error = kern_close(td, fd); - out: + if (fd >= 0) + (void)kern_close(td, fd); free(mdio, M_TEMP); return (error); } From owner-dev-commits-src-all@freebsd.org Sun Aug 29 17:00:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1A7C3662148; Sun, 29 Aug 2021 17: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 4GyKSh0FPLz3pnl; Sun, 29 Aug 2021 17: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 E45B862B4; Sun, 29 Aug 2021 17:00:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TH036F043862; Sun, 29 Aug 2021 17:00:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TH03DW043860; Sun, 29 Aug 2021 17:00:03 GMT (envelope-from git) Date: Sun, 29 Aug 2021 17:00:03 GMT Message-Id: <202108291700.17TH03DW043860@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: 99992f383bff - stable/12 - kern: mountroot: avoid fd leak in .md parsing 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: 99992f383bff2d3293018965c9c747fbdcdd8d7f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 17:00:04 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=99992f383bff2d3293018965c9c747fbdcdd8d7f commit 99992f383bff2d3293018965c9c747fbdcdd8d7f Author: Kyle Evans AuthorDate: 2021-07-20 10:23:11 +0000 Commit: Kyle Evans CommitDate: 2021-08-29 16:58:34 +0000 kern: mountroot: avoid fd leak in .md parsing parse_dir_md() opens /dev/mdctl but only closes the resulting fd on success, not upon failure of the ioctl or when we exceed the md unit max. Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #62 (cherry picked from commit 23ecfa9d5bc4f04eb58e26018c2d15f032d5d742) --- sys/kern/vfs_mountroot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c index ba83fc0b2c40..31420e661705 100644 --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -584,6 +584,7 @@ parse_dir_md(char **conf) int error, fd, len; td = curthread; + fd = -1; error = parse_token(conf, &tok); if (error) @@ -639,9 +640,9 @@ parse_dir_md(char **conf) root_mount_mddev = mdio->md_unit; printf(MD_NAME "%u attached to %s\n", root_mount_mddev, mdio->md_file); - error = kern_close(td, fd); - out: + if (fd >= 0) + (void)kern_close(td, fd); free(mdio, M_TEMP); return (error); } From owner-dev-commits-src-all@freebsd.org Sun Aug 29 17:40:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1640B662E05; Sun, 29 Aug 2021 17:40:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyLM96mwbz4W13; Sun, 29 Aug 2021 17:40:21 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id ADD3626395; Sun, 29 Aug 2021 17:40:21 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (unknown [IPv6:2001:470:7a58:0:5cbd:d688:6797:952]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 6186F5E3A8; Sun, 29 Aug 2021 19:40:19 +0200 (CEST) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: 5b8f07b12f84 - main - Fix -Wformat errors in pfctl on 32-bit architectures Date: Sun, 29 Aug 2021 19:40:09 +0200 In-Reply-To: <6A084192-562D-404D-9833-51A708FA1BC0@FreeBSD.org> Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" To: Kristof Provost References: <202108291531.17TFVoah033310@gitrepo.freebsd.org> <6A084192-562D-404D-9833-51A708FA1BC0@FreeBSD.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 17:40:22 -0000 --Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 29 Aug 2021, at 18:00, Kristof Provost wrote: >=20 > On 29 Aug 2021, at 17:31, Dimitry Andric wrote: >> The branch main has been updated by dim: >>=20 >> URL: = https://cgit.FreeBSD.org/src/commit/?id=3D5b8f07b12f8477f1679013d6b3abdab8= d33c7243 >>=20 >> commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 >> Author: Dimitry Andric >> AuthorDate: 2021-08-29 15:31:28 +0000 >> Commit: Dimitry Andric >> CommitDate: 2021-08-29 15:31:28 +0000 >>=20 >> Fix -Wformat errors in pfctl on 32-bit architectures >>=20 >> Use PRIu64 to printf(3) uint64_t quantities, otherwise this will = result >> in "error: format specifies type 'unsigned long' but the argument = has >> type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on = 32-bit >> architectures. >>=20 >> Fixes: 80078d9d38fd >> MFC after: 1 week >=20 > Thanks! >=20 > I was running test builds for a fix, but it is so much more convenient = when other people fix my mistakes for me. I was trying buildworld on i386 for something totally unrelated, and ran into these -Wformat errors so I took the liberty of patching them up quickly. :) -Dimitry --Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYSvGeQAKCRCwXqMKLiCW oypoAKDix9DoDSRfCE4vcpAZjSAQkIbL8wCeLJKDpgyR8w/axdbSsvA9xG/VTjU= =eLwf -----END PGP SIGNATURE----- --Apple-Mail=_7CE347AC-857C-4CBF-97A9-D02D66DCD0A5-- From owner-dev-commits-src-all@freebsd.org Sun Aug 29 17:44:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0F93662F31; Sun, 29 Aug 2021 17:44: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 4GyLSF67zyz4YTj; Sun, 29 Aug 2021 17:44: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 BB1326E22; Sun, 29 Aug 2021 17:44: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 17THijxs007117; Sun, 29 Aug 2021 17:44:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17THijbo007116; Sun, 29 Aug 2021 17:44:45 GMT (envelope-from git) Date: Sun, 29 Aug 2021 17:44:45 GMT Message-Id: <202108291744.17THijbo007116@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 8e3c56d6b676 - main - xen: Fix warning by adding KERNBASE to modlist_paddr before casting MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e3c56d6b676a175e974bad4c20797fb35017db8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 17:44:46 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=8e3c56d6b676a175e974bad4c20797fb35017db8 commit 8e3c56d6b676a175e974bad4c20797fb35017db8 Author: Dimitry Andric AuthorDate: 2021-08-29 14:02:31 +0000 Commit: Dimitry Andric CommitDate: 2021-08-29 17:43:00 +0000 xen: Fix warning by adding KERNBASE to modlist_paddr before casting Clang 13 produces the following warning for hammer_time_xen(): sys/x86/xen/pv.c:183:19: error: the pointer incremented by -2147483648 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements) [-Werror,-Warray-bounds] (vm_paddr_t)start_info->modlist_paddr + KERNBASE; ^ ~~~~~~~~ sys/xen/interface/arch-x86/hvm/start_info.h:131:5: note: array 'modlist_paddr' declared here uint64_t modlist_paddr; /* Physical address of an array of */ ^ This is because the expression first casts start_info->modlist_paddr to struct hvm_modlist_entry * (via vmpaddr_t), and *then* adds KERNBASE, which is then interpreted as KERNBASE * sizeof(struct hvm_modlist_entry). Instead, parenthesize the addition to get the intended result, and cast it to struct hvm_modlist_entry * afterwards. Also remove the cast to vmpaddr_t since it is not necessary. Reviewed by: royger MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D31711 --- sys/x86/xen/pv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 6e1bba691171..a316d4ee8857 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -180,7 +180,7 @@ hammer_time_xen(vm_paddr_t start_info_paddr) HYPERVISOR_shutdown(SHUTDOWN_crash); } mod = (struct hvm_modlist_entry *) - (vm_paddr_t)start_info->modlist_paddr + KERNBASE; + (start_info->modlist_paddr + KERNBASE); if (mod[0].paddr >= physfree) { xc_printf("ERROR: unexpected module memory address\n"); HYPERVISOR_shutdown(SHUTDOWN_crash); From owner-dev-commits-src-all@freebsd.org Sun Aug 29 19:25:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E60B665A1A; Sun, 29 Aug 2021 19:25: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 4GyNhM2LLlz3HNn; Sun, 29 Aug 2021 19:25: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 33DB51045D; Sun, 29 Aug 2021 19:25: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 17TJPNjd043204; Sun, 29 Aug 2021 19:25:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TJPN6W043203; Sun, 29 Aug 2021 19:25:23 GMT (envelope-from git) Date: Sun, 29 Aug 2021 19:25:23 GMT Message-Id: <202108291925.17TJPN6W043203@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: 0939f965d80d - main - Update a sysctl name to nbuffers_pcpu in hwpmc.4 and pmcstat.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0939f965d80d00e783b3319a57e7d71e0b3f202e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 19:25:23 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=0939f965d80d00e783b3319a57e7d71e0b3f202e commit 0939f965d80d00e783b3319a57e7d71e0b3f202e Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-28 08:01:19 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-29 19:24:50 +0000 Update a sysctl name to nbuffers_pcpu in hwpmc.4 and pmcstat.c This change was missed in r333509 (e6b475e0af). Differential Revision: https://reviews.freebsd.org/D31704 Reviewed by: mjg --- share/man/man4/hwpmc.4 | 2 +- sys/dev/hwpmc/hwpmc_logging.c | 2 +- usr.sbin/pmcstat/pmcstat.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/man/man4/hwpmc.4 b/share/man/man4/hwpmc.4 index d1bd576fcb9c..77fe4b9a075a 100644 --- a/share/man/man4/hwpmc.4 +++ b/share/man/man4/hwpmc.4 @@ -419,7 +419,7 @@ The default buffer size is 4KB. .It Va kern.hwpmc.mtxpoolsize Pq integer, read-only The size of the spin mutex pool used by the PMC driver. The default is 32. -.It Va kern.hwpmc.nbuffers Pq integer, read-only +.It Va kern.hwpmc.nbuffers_pcpu Pq integer, read-only The number of log buffers used by .Nm for logging. diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index c13b87f4165f..c16adff8c842 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -86,7 +86,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_RDTUN, &pmclog_buffer_size, 0, "size of log buffers in kilobytes"); /* - * kern.hwpmc.nbuffer -- number of global log buffers + * kern.hwpmc.nbuffers_pcpu -- number of global log buffers */ static int pmc_nlogbuffers_pcpu = PMC_NLOGBUFFERS_PCPU; diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c index 997005cec269..3e2d101ab113 100644 --- a/usr.sbin/pmcstat/pmcstat.c +++ b/usr.sbin/pmcstat/pmcstat.c @@ -1455,7 +1455,7 @@ main(int argc, char **argv) args.pa_verbosity > 0) warnx( "WARNING: at least %u event%s were discarded while running.\n" -"Please consider tuning the \"kern.hwpmc.nbuffers\" tunable.", +"Please consider tuning the \"kern.hwpmc.nbuffers_pcpu\" tunable.", ds_end.pm_buffer_requests_failed - ds_start.pm_buffer_requests_failed, ((ds_end.pm_buffer_requests_failed - From owner-dev-commits-src-all@freebsd.org Sun Aug 29 20:13:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 921136671FC; Sun, 29 Aug 2021 20:13:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GyPm83hdMz3lc8; Sun, 29 Aug 2021 20:13:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63CED110FA; Sun, 29 Aug 2021 20:13:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17TKDiJf011295; Sun, 29 Aug 2021 20:13:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TKDitd011294; Sun, 29 Aug 2021 20:13:44 GMT (envelope-from git) Date: Sun, 29 Aug 2021 20:13:44 GMT Message-Id: <202108292013.17TKDitd011294@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: d98954e22981 - main - routing: Bring back the ability to specify transmit interface via its name. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d98954e229812eee2fa6bf97714fecbbdcc56e4c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 20:13:44 -0000 The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=d98954e229812eee2fa6bf97714fecbbdcc56e4c commit d98954e229812eee2fa6bf97714fecbbdcc56e4c Author: Alexander V. Chernikov AuthorDate: 2021-08-29 19:51:28 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-08-29 20:05:14 +0000 routing: Bring back the ability to specify transmit interface via its name. Some software references outgoing interfaces by specifying name instead of index. Use rti_ifp from rt_addrinfo if provided instead of always using address interface when constructing nexthop. PR: 255678 Reported by: martin.larsson2 at gmail.com MFC after: 1 week --- sys/net/route.c | 45 ++++++++++++++++++++++++++++++++++++--------- sys/net/route/nhop_ctl.c | 2 +- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 4f7eb6f64210..e4ed7d1a2fd1 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -502,6 +502,38 @@ rt_flushifroutes(struct ifnet *ifp) rib_foreach_table_walk_del(AF_UNSPEC, rt_ifdelroute, ifp); } +/* + * Tries to extract interface from RTAX_IFP passed in rt_addrinfo. + * Interface can be specified ether as interface index (sdl_index) or + * the interface name (sdl_data). + * + * Returns found ifp or NULL + */ +static struct ifnet * +info_get_ifp(struct rt_addrinfo *info) +{ + const struct sockaddr_dl *sdl; + + sdl = (const struct sockaddr_dl *)info->rti_info[RTAX_IFP]; + if (sdl->sdl_family != AF_LINK) + return (NULL); + + if (sdl->sdl_index != 0) + return (ifnet_byindex(sdl->sdl_index)); + if (sdl->sdl_nlen > 0) { + char if_name[IF_NAMESIZE]; + if (sdl->sdl_nlen + offsetof(struct sockaddr_dl, sdl_data) > sdl->sdl_len) + return (NULL); + if (sdl->sdl_nlen >= IF_NAMESIZE) + return (NULL); + bzero(if_name, sizeof(if_name)); + memcpy(if_name, sdl->sdl_data, sdl->sdl_nlen); + return (ifunit(if_name)); + } + + return (NULL); +} + /* * Look up rt_addrinfo for a specific fib. * @@ -511,12 +543,11 @@ rt_flushifroutes(struct ifnet *ifp) int rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) { - const struct sockaddr *dst, *gateway, *ifpaddr, *ifaaddr; + const struct sockaddr *dst, *gateway, *ifaaddr; int error, flags; dst = info->rti_info[RTAX_DST]; gateway = info->rti_info[RTAX_GATEWAY]; - ifpaddr = info->rti_info[RTAX_IFP]; ifaaddr = info->rti_info[RTAX_IFA]; flags = info->rti_flags; @@ -526,13 +557,9 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) */ error = 0; - /* If we have interface specified by the ifindex in the address, use it */ - if (info->rti_ifp == NULL && ifpaddr != NULL && - ifpaddr->sa_family == AF_LINK) { - const struct sockaddr_dl *sdl = (const struct sockaddr_dl *)ifpaddr; - if (sdl->sdl_index != 0) - info->rti_ifp = ifnet_byindex(sdl->sdl_index); - } + /* If we have interface specified by RTAX_IFP address, try to use it */ + if ((info->rti_ifp == NULL) && (info->rti_info[RTAX_IFP] != NULL)) + info->rti_ifp = info_get_ifp(info); /* * If we have source address specified, try to find it * TODO: avoid enumerating all ifas on all interfaces. diff --git a/sys/net/route/nhop_ctl.c b/sys/net/route/nhop_ctl.c index 92b43871d604..21aefcc7a83b 100644 --- a/sys/net/route/nhop_ctl.c +++ b/sys/net/route/nhop_ctl.c @@ -286,7 +286,7 @@ fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info) if ((error = set_nhop_gw_from_info(nh, info)) != 0) return (error); - nh->nh_ifp = info->rti_ifa->ifa_ifp; + nh->nh_ifp = (info->rti_ifp != NULL) ? info->rti_ifp : info->rti_ifa->ifa_ifp; nh->nh_ifa = info->rti_ifa; /* depends on the gateway */ nh->nh_aifp = get_aifp(nh); From owner-dev-commits-src-all@freebsd.org Sun Aug 29 23:49:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7262766C803; Sun, 29 Aug 2021 23:49: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 4GyVYJ2Y8rz3v0C; Sun, 29 Aug 2021 23:49: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 3B4C213C48; Sun, 29 Aug 2021 23:49: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 17TNne4l090753; Sun, 29 Aug 2021 23:49:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17TNneFI090752; Sun, 29 Aug 2021 23:49:40 GMT (envelope-from git) Date: Sun, 29 Aug 2021 23:49:40 GMT Message-Id: <202108292349.17TNneFI090752@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 13914e51eb8d - main - nfsd: Make loop calling VOP_ALLOCATE() iterate until done MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 13914e51eb8de6fe9f627c9c1d48c09880b2607e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2021 23:49:40 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=13914e51eb8de6fe9f627c9c1d48c09880b2607e commit 13914e51eb8de6fe9f627c9c1d48c09880b2607e Author: Rick Macklem AuthorDate: 2021-08-29 23:46:27 +0000 Commit: Rick Macklem CommitDate: 2021-08-29 23:46:27 +0000 nfsd: Make loop calling VOP_ALLOCATE() iterate until done The NFSv4.2 Deallocate operation loops on VOP_DEALLOCATE() while progress is being made (remaining length decreasing). This patch changes the loop on VOP_ALLOCATE() for the NFSv4.2 Allocate operation do the same, instead of stopping after an arbitrary 20 iterations. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdport.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index d93c547c5530..9250c0ce0a23 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -6564,7 +6564,8 @@ int nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, NFSPROC_T *p) { - int error, trycnt; + int error; + off_t olen; ASSERT_VOP_ELOCKED(vp, "nfsvno_allocate vp"); /* @@ -6575,15 +6576,17 @@ nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, NULL, NULL, NULL, NULL, &len, 0, NULL); if (error != ENOENT) return (error); - error = 0; /* - * Do the actual VOP_ALLOCATE(), looping a reasonable number of - * times to achieve completion. + * Do the actual VOP_ALLOCATE(), looping so long as + * progress is being made, to achieve completion. */ - trycnt = 0; - while (error == 0 && len > 0 && trycnt++ < 20) + do { + olen = len; error = VOP_ALLOCATE(vp, &off, &len); + if (error == 0 && len > 0 && olen > len) + maybe_yield(); + } while (error == 0 && len > 0 && olen > len); if (error == 0 && len > 0) error = NFSERR_IO; NFSEXITCODE(error);