From owner-svn-src-all@freebsd.org Sun Nov 15 01:54:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 290B346D5F2; Sun, 15 Nov 2020 01:54:45 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYZyY0hN2z4hsj; Sun, 15 Nov 2020 01:54:45 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A7CB14404; Sun, 15 Nov 2020 01:54:45 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AF1siVl098895; Sun, 15 Nov 2020 01:54:44 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AF1sixk098893; Sun, 15 Nov 2020 01:54:44 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011150154.0AF1sixk098893@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 15 Nov 2020 01:54:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367700 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367700 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 01:54:45 -0000 Author: mjg Date: Sun Nov 15 01:54:44 2020 New Revision: 367700 URL: https://svnweb.freebsd.org/changeset/base/367700 Log: sched: fix an incorrect comparison in sched_lend_user_prio_cond Compare with sched_lend_user_prio. Modified: head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Sat Nov 14 20:45:12 2020 (r367699) +++ head/sys/kern/sched_4bsd.c Sun Nov 15 01:54:44 2020 (r367700) @@ -952,7 +952,7 @@ sched_lend_user_prio_cond(struct thread *td, u_char pr goto lend; if (td->td_user_pri != min(prio, td->td_base_user_pri)) goto lend; - if (td->td_priority >= td->td_user_pri) + if (td->td_priority != td->td_user_pri) goto lend; return; Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Sat Nov 14 20:45:12 2020 (r367699) +++ head/sys/kern/sched_ule.c Sun Nov 15 01:54:44 2020 (r367700) @@ -1900,7 +1900,7 @@ sched_lend_user_prio_cond(struct thread *td, u_char pr goto lend; if (td->td_user_pri != min(prio, td->td_base_user_pri)) goto lend; - if (td->td_priority >= td->td_user_pri) + if (td->td_priority != td->td_user_pri) goto lend; return; From owner-svn-src-all@freebsd.org Sun Nov 15 07:48:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 133412D6998; Sun, 15 Nov 2020 07:48:53 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYkq875QBz3G8k; Sun, 15 Nov 2020 07:48:52 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E4D8218339; Sun, 15 Nov 2020 07:48:52 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AF7mqUa016901; Sun, 15 Nov 2020 07:48:52 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AF7mqW3016900; Sun, 15 Nov 2020 07:48:52 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <202011150748.0AF7mqW3016900@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sun, 15 Nov 2020 07:48:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367701 - head/lib/libutil X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: head/lib/libutil X-SVN-Commit-Revision: 367701 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 07:48:53 -0000 Author: scottl Date: Sun Nov 15 07:48:52 2020 New Revision: 367701 URL: https://svnweb.freebsd.org/changeset/base/367701 Log: Because getlocalbase() returns -1 on error, it needs to use a signed type internally. Do that, and make sure that conversations between signed and unsigned don't overflow Modified: head/lib/libutil/getlocalbase.c Modified: head/lib/libutil/getlocalbase.c ============================================================================== --- head/lib/libutil/getlocalbase.c Sun Nov 15 01:54:44 2020 (r367700) +++ head/lib/libutil/getlocalbase.c Sun Nov 15 07:48:52 2020 (r367701) @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); ssize_t getlocalbase(char *path, size_t pathlen) { - size_t tmplen; + ssize_t tmplen; const char *tmppath; if ((pathlen == 0) || (path == NULL)) { @@ -49,13 +49,20 @@ getlocalbase(char *path, size_t pathlen) return (-1); } + /* It's unlikely that the buffer would be this big */ + if (pathlen > SSIZE_MAX) { + errno = ENOMEM; + return (-1); + } + tmppath = NULL; - tmplen = pathlen; + tmplen = (size_t)pathlen; if (issetugid() == 0) tmppath = getenv("LOCALBASE"); if ((tmppath == NULL) && - (sysctlbyname("user.localbase", path, &tmplen, NULL, 0) == 0)) { + (sysctlbyname("user.localbase", path, (size_t *)&tmplen, NULL, + 0) == 0)) { return (tmplen); } @@ -67,13 +74,13 @@ getlocalbase(char *path, size_t pathlen) #endif tmplen = strlcpy(path, tmppath, pathlen); - if ((tmplen < 0) || (tmplen >= pathlen)) { + if ((tmplen < 0) || (tmplen >= (ssize_t)pathlen)) { errno = ENOMEM; return (-1); } /* It's unlikely that the buffer would be this big */ - if (tmplen >= SSIZE_MAX) { + if (tmplen > SSIZE_MAX) { errno = ENOMEM; return (-1); } From owner-svn-src-all@freebsd.org Sun Nov 15 07:50:30 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9EEA2D6937; Sun, 15 Nov 2020 07:50:30 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYks24T0pz3GWh; Sun, 15 Nov 2020 07:50:30 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8C1F418252; Sun, 15 Nov 2020 07:50:30 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AF7oUUe017063; Sun, 15 Nov 2020 07:50:30 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AF7oUMx017060; Sun, 15 Nov 2020 07:50:30 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <202011150750.0AF7oUMx017060@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sun, 15 Nov 2020 07:50:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367702 - in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Commit-Revision: 367702 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 07:50:30 -0000 Author: scottl Date: Sun Nov 15 07:50:29 2020 New Revision: 367702 URL: https://svnweb.freebsd.org/changeset/base/367702 Log: Fix the previous revision, it suffered from an incomplete change to the getlocalbase API. Also don't erroneously subtract the lenth from the buffer a second time. Modified: head/sbin/nvmecontrol/nvmecontrol.c head/usr.sbin/mailwrapper/mailwrapper.c head/usr.sbin/pkg/pkg.c Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Sun Nov 15 07:48:52 2020 (r367701) +++ head/sbin/nvmecontrol/nvmecontrol.c Sun Nov 15 07:50:29 2020 (r367702) @@ -187,7 +187,7 @@ main(int argc, char *argv[]) snprintf(locallib, MAXPATHLEN, "/lib/nvmecontrol"); cmd_load_dir(locallib, NULL, NULL); if ((len = getlocalbase(locallib, MAXPATHLEN)) > 0) { - strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN - len); + strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN); cmd_load_dir(locallib, NULL, NULL); } Modified: head/usr.sbin/mailwrapper/mailwrapper.c ============================================================================== --- head/usr.sbin/mailwrapper/mailwrapper.c Sun Nov 15 07:48:52 2020 (r367701) +++ head/usr.sbin/mailwrapper/mailwrapper.c Sun Nov 15 07:50:29 2020 (r367702) @@ -105,10 +105,10 @@ main(int argc, char *argv[], char *envp[]) initarg(&al); addarg(&al, argv[0]); - if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) != 0) + if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) <= 0) err(EX_OSERR, "cannot determine local path"); - strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN - len); + strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN); mailerconf = localmailerconf; if ((config = fopen(localmailerconf, "r")) == NULL) Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Sun Nov 15 07:48:52 2020 (r367701) +++ head/usr.sbin/pkg/pkg.c Sun Nov 15 07:50:29 2020 (r367702) @@ -1047,11 +1047,11 @@ main(int argc, char *argv[]) pkgarg = NULL; yes = false; - if ((len = getlocalbase(pkgpath, MAXPATHLEN)) != 0) { + if ((len = getlocalbase(pkgpath, MAXPATHLEN)) <= 0) { fprintf(stderr, "Cannot determine local path\n"); exit(EXIT_FAILURE); } - strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN - len); + strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN); if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { bootstrap_only = true; From owner-svn-src-all@freebsd.org Sun Nov 15 09:48:30 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D17AD2E1756 for ; Sun, 15 Nov 2020 09:48:30 +0000 (UTC) (envelope-from igorkolesnik@posteo.net) Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.posteo.de", Issuer "StartCom Class 3 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYnTB4t0xz3NN6 for ; Sun, 15 Nov 2020 09:48:30 +0000 (UTC) (envelope-from igorkolesnik@posteo.net) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 90AE92400FC for ; Sun, 15 Nov 2020 10:48:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1605433708; bh=rvTJGSiw0ltosXOMYPHHqVttj3tSVTuH1tgLOk96YRo=; h=Subject:From:Date:Cc:To:From; b=F/FMiFyLS22rtLXnaS3DXs6WubCXX9iugjV4d7S+fVR5BIhhdpYCoPdBAqFg7M2x4 fTsD75u24vDovhVxo7wmpGmTGEWFndtuRP35C3YxCw0m9VAlWDymhsniFMokXu6GJU ziV+h9yc5S+SAPS1BB2JXKq/iROxGQ5ieNBUw49CH2t+8DX7TrG344E/ydhpK317ew pkEEkJdkZ1U++KKNJvTpCMC/bxuX5RrYA+1vBnRxw9l6wOgI52ZqZrKkpymCOmBslO J1SA2SK2I/LwhcOmpPMdt2rrsEB1kary2gnqnVUPzViLjQlJjkW59633k3n25yk/Ah ZdgDGTKHWer/g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CYnT76q94z6tmF; Sun, 15 Nov 2020 10:48:27 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Igor Kolesnik In-Reply-To: <202011150748.0AF7mqW3016900@repo.freebsd.org> Date: Sun, 15 Nov 2020 11:48:27 +0200 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <0FE37F7D-6878-40F2-B606-A8CADFF270BF@posteo.net> References: <202011150748.0AF7mqW3016900@repo.freebsd.org> To: Scott Long X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CYnTB4t0xz3NN6 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 09:48:30 -0000 > Modified: head/lib/libutil/getlocalbase.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/lib/libutil/getlocalbase.c Sun Nov 15 01:54:44 2020 = (r367700) > +++ head/lib/libutil/getlocalbase.c Sun Nov 15 07:48:52 2020 = (r367701) > @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); > ssize_t > getlocalbase(char *path, size_t pathlen) > { > - size_t tmplen; > + ssize_t tmplen; > const char *tmppath; >=20 > if ((pathlen =3D=3D 0) || (path =3D=3D NULL)) { > @@ -49,13 +49,20 @@ getlocalbase(char *path, size_t pathlen) > return (-1); > } >=20 > + /* It's unlikely that the buffer would be this big */ > + if (pathlen > SSIZE_MAX) { > + errno =3D ENOMEM; > + return (-1); > + } > + > tmppath =3D NULL; > - tmplen =3D pathlen; > + tmplen =3D (size_t)pathlen; Typo? Shouldn=E2=80=99t pathlen be cast to ssize_t? > if (issetugid() =3D=3D 0) > tmppath =3D getenv("LOCALBASE"); >=20 > if ((tmppath =3D=3D NULL) && > - (sysctlbyname("user.localbase", path, &tmplen, NULL, 0) =3D=3D= 0)) { > + (sysctlbyname("user.localbase", path, (size_t *)&tmplen, = NULL, > + 0) =3D=3D 0)) { > return (tmplen); > } >=20 > @@ -67,13 +74,13 @@ getlocalbase(char *path, size_t pathlen) > #endif >=20 > tmplen =3D strlcpy(path, tmppath, pathlen); > - if ((tmplen < 0) || (tmplen >=3D pathlen)) { > + if ((tmplen < 0) || (tmplen >=3D (ssize_t)pathlen)) { > errno =3D ENOMEM; > return (-1); > } >=20 > /* It's unlikely that the buffer would be this big */ > - if (tmplen >=3D SSIZE_MAX) { > + if (tmplen > SSIZE_MAX) { > errno =3D ENOMEM; > return (-1); > } From owner-svn-src-all@freebsd.org Sun Nov 15 11:28:03 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 22BE02E4D6C; Sun, 15 Nov 2020 11:28:03 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYqh30XY4z3l1m; Sun, 15 Nov 2020 11:28:03 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0535E1B0DD; Sun, 15 Nov 2020 11:28:03 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFBS2AH055316; Sun, 15 Nov 2020 11:28:02 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFBS2r9055315; Sun, 15 Nov 2020 11:28:02 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202011151128.0AFBS2r9055315@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 15 Nov 2020 11:28:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r367704 - in stable: 11/contrib/llvm-project/lld/ELF 12/contrib/llvm-project/lld/ELF X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/contrib/llvm-project/lld/ELF 12/contrib/llvm-project/lld/ELF X-SVN-Commit-Revision: 367704 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 11:28:03 -0000 Author: dim Date: Sun Nov 15 11:28:02 2020 New Revision: 367704 URL: https://svnweb.freebsd.org/changeset/base/367704 Log: MFC r367623: Merge commit 8df4e6094 from llvm git (by Fangrui Song): [ELF] Don't consider SHF_ALLOC ".debug*" sections debug sections Fixes PR48071 * The Rust compiler produces SHF_ALLOC `.debug_gdb_scripts` (which normally does not have the flag) * `.debug_gdb_scripts` sections are removed from `inputSections` due to --strip-debug/--strip-all * When processing --gc-sections, pieces of a SHF_MERGE section can be marked live separately `=>` segfault when marking liveness of a `.debug_gdb_scripts` which is not split into pieces (because it is not in `inputSections`) This patch circumvents the problem by not treating SHF_ALLOC ".debug*" as debug sections (to prevent --strip-debug's stripping) (which is still useful on its own). Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D91291 This should fix lld segfaulting when linking the rust-based parts of the devel/py-maturin port. Reported by: Nick Venenga PR: 250783 Modified: stable/11/contrib/llvm-project/lld/ELF/InputSection.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/contrib/llvm-project/lld/ELF/InputSection.h Directory Properties: stable/12/ (props changed) Modified: stable/11/contrib/llvm-project/lld/ELF/InputSection.h ============================================================================== --- stable/11/contrib/llvm-project/lld/ELF/InputSection.h Sun Nov 15 07:57:45 2020 (r367703) +++ stable/11/contrib/llvm-project/lld/ELF/InputSection.h Sun Nov 15 11:28:02 2020 (r367704) @@ -358,7 +358,8 @@ class InputSection : public InputSectionBase { (privat }; inline bool isDebugSection(const InputSectionBase &sec) { - return sec.name.startswith(".debug") || sec.name.startswith(".zdebug"); + return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 && + (sec.name.startswith(".debug") || sec.name.startswith(".zdebug")); } // The list of all input sections. From owner-svn-src-all@freebsd.org Sun Nov 15 11:28:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6A252E4D69; Sun, 15 Nov 2020 11:28:02 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYqh25hXQz3kvs; Sun, 15 Nov 2020 11:28:02 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AFA431B0DC; Sun, 15 Nov 2020 11:28:02 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFBS2j7055310; Sun, 15 Nov 2020 11:28:02 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFBS2JJ055309; Sun, 15 Nov 2020 11:28:02 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202011151128.0AFBS2JJ055309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 15 Nov 2020 11:28:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367704 - in stable: 11/contrib/llvm-project/lld/ELF 12/contrib/llvm-project/lld/ELF X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/contrib/llvm-project/lld/ELF 12/contrib/llvm-project/lld/ELF X-SVN-Commit-Revision: 367704 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 11:28:03 -0000 Author: dim Date: Sun Nov 15 11:28:02 2020 New Revision: 367704 URL: https://svnweb.freebsd.org/changeset/base/367704 Log: MFC r367623: Merge commit 8df4e6094 from llvm git (by Fangrui Song): [ELF] Don't consider SHF_ALLOC ".debug*" sections debug sections Fixes PR48071 * The Rust compiler produces SHF_ALLOC `.debug_gdb_scripts` (which normally does not have the flag) * `.debug_gdb_scripts` sections are removed from `inputSections` due to --strip-debug/--strip-all * When processing --gc-sections, pieces of a SHF_MERGE section can be marked live separately `=>` segfault when marking liveness of a `.debug_gdb_scripts` which is not split into pieces (because it is not in `inputSections`) This patch circumvents the problem by not treating SHF_ALLOC ".debug*" as debug sections (to prevent --strip-debug's stripping) (which is still useful on its own). Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D91291 This should fix lld segfaulting when linking the rust-based parts of the devel/py-maturin port. Reported by: Nick Venenga PR: 250783 Modified: stable/12/contrib/llvm-project/lld/ELF/InputSection.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/llvm-project/lld/ELF/InputSection.h Directory Properties: stable/11/ (props changed) Modified: stable/12/contrib/llvm-project/lld/ELF/InputSection.h ============================================================================== --- stable/12/contrib/llvm-project/lld/ELF/InputSection.h Sun Nov 15 07:57:45 2020 (r367703) +++ stable/12/contrib/llvm-project/lld/ELF/InputSection.h Sun Nov 15 11:28:02 2020 (r367704) @@ -358,7 +358,8 @@ class InputSection : public InputSectionBase { (privat }; inline bool isDebugSection(const InputSectionBase &sec) { - return sec.name.startswith(".debug") || sec.name.startswith(".zdebug"); + return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 && + (sec.name.startswith(".debug") || sec.name.startswith(".zdebug")); } // The list of all input sections. From owner-svn-src-all@freebsd.org Sun Nov 15 11:46:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 598462E5841; Sun, 15 Nov 2020 11:46:45 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYr5d1ssyz3lw6; Sun, 15 Nov 2020 11:46:45 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 320E81B27B; Sun, 15 Nov 2020 11:46:45 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFBkjKd068201; Sun, 15 Nov 2020 11:46:45 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFBkjKq068200; Sun, 15 Nov 2020 11:46:45 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202011151146.0AFBkjKq068200@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 15 Nov 2020 11:46:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367705 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 367705 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 11:46:45 -0000 Author: kp Date: Sun Nov 15 11:46:44 2020 New Revision: 367705 URL: https://svnweb.freebsd.org/changeset/base/367705 Log: bridge: epoch-ification Undo the revert (r363568). This commit still violates epoch rules by sleeping within NET_EPOCH. That will be resolved in the following commit. Modified: stable/12/sys/net/if_bridge.c Modified: stable/12/sys/net/if_bridge.c ============================================================================== --- stable/12/sys/net/if_bridge.c Sun Nov 15 11:28:02 2020 (r367704) +++ stable/12/sys/net/if_bridge.c Sun Nov 15 11:46:44 2020 (r367705) @@ -189,41 +189,14 @@ extern void nd6_setmtu(struct ifnet *); */ #define BRIDGE_LOCK_INIT(_sc) do { \ mtx_init(&(_sc)->sc_mtx, "if_bridge", NULL, MTX_DEF); \ - cv_init(&(_sc)->sc_cv, "if_bridge_cv"); \ } while (0) #define BRIDGE_LOCK_DESTROY(_sc) do { \ mtx_destroy(&(_sc)->sc_mtx); \ - cv_destroy(&(_sc)->sc_cv); \ } while (0) #define BRIDGE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) #define BRIDGE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) #define BRIDGE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) #define BRIDGE_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED) -#define BRIDGE_LOCK2REF(_sc, _err) do { \ - mtx_assert(&(_sc)->sc_mtx, MA_OWNED); \ - if ((_sc)->sc_iflist_xcnt > 0) \ - (_err) = EBUSY; \ - else \ - (_sc)->sc_iflist_ref++; \ - mtx_unlock(&(_sc)->sc_mtx); \ -} while (0) -#define BRIDGE_UNREF(_sc) do { \ - mtx_lock(&(_sc)->sc_mtx); \ - (_sc)->sc_iflist_ref--; \ - if (((_sc)->sc_iflist_xcnt > 0) && ((_sc)->sc_iflist_ref == 0)) \ - cv_broadcast(&(_sc)->sc_cv); \ - mtx_unlock(&(_sc)->sc_mtx); \ -} while (0) -#define BRIDGE_XLOCK(_sc) do { \ - mtx_assert(&(_sc)->sc_mtx, MA_OWNED); \ - (_sc)->sc_iflist_xcnt++; \ - while ((_sc)->sc_iflist_ref > 0) \ - cv_wait(&(_sc)->sc_cv, &(_sc)->sc_mtx); \ -} while (0) -#define BRIDGE_XDROP(_sc) do { \ - mtx_assert(&(_sc)->sc_mtx, MA_OWNED); \ - (_sc)->sc_iflist_xcnt--; \ -} while (0) /* * Bridge interface list entry. @@ -237,6 +210,8 @@ struct bridge_iflist { uint32_t bif_addrmax; /* max # of addresses */ uint32_t bif_addrcnt; /* cur. # of addresses */ uint32_t bif_addrexceeded;/* # of address violations */ + + struct epoch_context bif_epoch_ctx; }; /* @@ -250,6 +225,9 @@ struct bridge_rtnode { uint8_t brt_flags; /* address flags */ uint8_t brt_addr[ETHER_ADDR_LEN]; uint16_t brt_vlan; /* vlan id */ + + struct vnet *brt_vnet; + struct epoch_context brt_epoch_ctx; }; #define brt_ifp brt_dst->bif_ifp @@ -260,13 +238,10 @@ struct bridge_softc { struct ifnet *sc_ifp; /* make this an interface */ LIST_ENTRY(bridge_softc) sc_list; struct mtx sc_mtx; - struct cv sc_cv; uint32_t sc_brtmax; /* max # of addresses */ uint32_t sc_brtcnt; /* cur. # of addresses */ uint32_t sc_brttimeout; /* rt timeout in seconds */ struct callout sc_brcallout; /* bridge callout */ - uint32_t sc_iflist_ref; /* refcount for sc_iflist */ - uint32_t sc_iflist_xcnt; /* refcount for sc_iflist */ CK_LIST_HEAD(, bridge_iflist) sc_iflist; /* member interface list */ CK_LIST_HEAD(, bridge_rtnode) *sc_rthash; /* our forwarding table */ CK_LIST_HEAD(, bridge_rtnode) sc_rtlist; /* list version of above */ @@ -276,6 +251,8 @@ struct bridge_softc { uint32_t sc_brtexceeded; /* # of cache drops */ struct ifnet *sc_ifaddr; /* member mac copied from */ struct ether_addr sc_defaddr; /* Default MAC address */ + + struct epoch_context sc_epoch_ctx; }; VNET_DEFINE_STATIC(struct mtx, bridge_list_mtx); @@ -595,6 +572,11 @@ vnet_bridge_uninit(const void *unused __unused) if_clone_detach(V_bridge_cloner); V_bridge_cloner = NULL; BRIDGE_LIST_LOCK_DESTROY(); + + /* Before we can destroy the uma zone, because there are callbacks that + * use it. */ + epoch_drain_callbacks(net_epoch_preempt); + uma_zdestroy(V_bridge_rtnode_zone); } VNET_SYSUNINIT(vnet_bridge_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY, @@ -757,6 +739,17 @@ bridge_clone_create(struct if_clone *ifc, int unit, ca return (0); } +static void +bridge_clone_destroy_cb(struct epoch_context *ctx) +{ + struct bridge_softc *sc; + + sc = __containerof(ctx, struct bridge_softc, sc_epoch_ctx); + + BRIDGE_LOCK_DESTROY(sc); + free(sc, M_DEVBUF); +} + /* * bridge_clone_destroy: * @@ -767,7 +760,9 @@ bridge_clone_destroy(struct ifnet *ifp) { struct bridge_softc *sc = ifp->if_softc; struct bridge_iflist *bif; + struct epoch_tracker et; + NET_EPOCH_ENTER_ET(et); BRIDGE_LOCK(sc); bridge_stop(ifp, 1); @@ -792,11 +787,12 @@ bridge_clone_destroy(struct ifnet *ifp) BRIDGE_LIST_UNLOCK(); bstp_detach(&sc->sc_stp); + NET_EPOCH_EXIT_ET(et); + ether_ifdetach(ifp); if_free(ifp); - BRIDGE_LOCK_DESTROY(sc); - free(sc, M_DEVBUF); + epoch_call(net_epoch_preempt, &sc->sc_epoch_ctx, bridge_clone_destroy_cb); } /* @@ -822,7 +818,10 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da struct ifdrv *ifd = (struct ifdrv *) data; const struct bridge_control *bc; int error = 0, oldmtu; + struct epoch_tracker et; + NET_EPOCH_ENTER_ET(et); + switch (cmd) { case SIOCADDMULTI: @@ -943,6 +942,8 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da break; } + NET_EPOCH_EXIT_ET(et); + return (error); } @@ -957,6 +958,8 @@ bridge_mutecaps(struct bridge_softc *sc) struct bridge_iflist *bif; int enabled, mask; + BRIDGE_LOCK_ASSERT(sc); + /* Initial bitmask of capabilities to test */ mask = BRIDGE_IFCAPS_MASK; @@ -965,7 +968,6 @@ bridge_mutecaps(struct bridge_softc *sc) mask &= bif->bif_savedcaps; } - BRIDGE_XLOCK(sc); CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { enabled = bif->bif_ifp->if_capenable; enabled &= ~BRIDGE_IFCAPS_STRIP; @@ -976,8 +978,6 @@ bridge_mutecaps(struct bridge_softc *sc) bridge_set_ifcap(sc, bif, enabled); BRIDGE_LOCK(sc); } - BRIDGE_XDROP(sc); - } static void @@ -1018,7 +1018,7 @@ bridge_lookup_member(struct bridge_softc *sc, const ch struct bridge_iflist *bif; struct ifnet *ifp; - BRIDGE_LOCK_ASSERT(sc); + MPASS(in_epoch(net_epoch_preempt)); CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { ifp = bif->bif_ifp; @@ -1039,7 +1039,7 @@ bridge_lookup_member_if(struct bridge_softc *sc, struc { struct bridge_iflist *bif; - BRIDGE_LOCK_ASSERT(sc); + MPASS(in_epoch(net_epoch_preempt)); CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (bif->bif_ifp == member_ifp) @@ -1049,6 +1049,16 @@ bridge_lookup_member_if(struct bridge_softc *sc, struc return (NULL); } +static void +bridge_delete_member_cb(struct epoch_context *ctx) +{ + struct bridge_iflist *bif; + + bif = __containerof(ctx, struct bridge_iflist, bif_epoch_ctx); + + free(bif, M_DEVBUF); +} + /* * bridge_delete_member: * @@ -1068,9 +1078,7 @@ bridge_delete_member(struct bridge_softc *sc, struct b bstp_disable(&bif->bif_stp); ifs->if_bridge = NULL; - BRIDGE_XLOCK(sc); CK_LIST_REMOVE(bif, bif_next); - BRIDGE_XDROP(sc); /* * If removing the interface that gave the bridge its mac address, set @@ -1129,7 +1137,9 @@ bridge_delete_member(struct bridge_softc *sc, struct b } bstp_destroy(&bif->bif_stp); /* prepare to free */ BRIDGE_LOCK(sc); - free(bif, M_DEVBUF); + + epoch_call(net_epoch_preempt, &bif->bif_epoch_ctx, + bridge_delete_member_cb); } /* @@ -1146,7 +1156,9 @@ bridge_delete_span(struct bridge_softc *sc, struct bri ("%s: not a span interface", __func__)); CK_LIST_REMOVE(bif, bif_next); - free(bif, M_DEVBUF); + + epoch_call(net_epoch_preempt, &bif->bif_epoch_ctx, + bridge_delete_member_cb); } static int @@ -1202,7 +1214,6 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) * If any, remove all inet6 addresses from the member * interfaces. */ - BRIDGE_XLOCK(sc); CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (in6ifa_llaonifp(bif->bif_ifp)) { BRIDGE_UNLOCK(sc); @@ -1215,7 +1226,6 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) bif->bif_ifp->if_xname); } } - BRIDGE_XDROP(sc); if (in6ifa_llaonifp(ifs)) { BRIDGE_UNLOCK(sc); in6_ifdetach(ifs); @@ -1424,9 +1434,9 @@ bridge_ioctl_gifs(struct bridge_softc *sc, void *arg) bifc->ifbic_len = buflen; return (0); } - BRIDGE_UNLOCK(sc); - outbuf = malloc(buflen, M_TEMP, M_WAITOK | M_ZERO); - BRIDGE_LOCK(sc); + outbuf = malloc(buflen, M_TEMP, M_NOWAIT | M_ZERO); + if (outbuf == NULL) + return (ENOMEM); count = 0; buf = outbuf; @@ -1486,9 +1496,9 @@ bridge_ioctl_rts(struct bridge_softc *sc, void *arg) count++; buflen = sizeof(bareq) * count; - BRIDGE_UNLOCK(sc); - outbuf = malloc(buflen, M_TEMP, M_WAITOK | M_ZERO); - BRIDGE_LOCK(sc); + outbuf = malloc(buflen, M_TEMP, M_NOWAIT | M_ZERO); + if (outbuf == NULL) + return (ENOMEM); count = 0; buf = outbuf; @@ -1529,12 +1539,17 @@ bridge_ioctl_saddr(struct bridge_softc *sc, void *arg) struct bridge_iflist *bif; int error; + MPASS(in_epoch(net_epoch_preempt)); + bif = bridge_lookup_member(sc, req->ifba_ifsname); if (bif == NULL) return (ENOENT); + /* bridge_rtupdate() may acquire the lock. */ + BRIDGE_UNLOCK(sc); error = bridge_rtupdate(sc, req->ifba_dst, req->ifba_vlan, bif, 1, req->ifba_flags); + BRIDGE_LOCK(sc); return (error); } @@ -1809,9 +1824,9 @@ bridge_ioctl_gifsstp(struct bridge_softc *sc, void *ar return (0); } - BRIDGE_UNLOCK(sc); - outbuf = malloc(buflen, M_TEMP, M_WAITOK | M_ZERO); - BRIDGE_LOCK(sc); + outbuf = malloc(buflen, M_TEMP, M_NOWAIT | M_ZERO); + if (outbuf == NULL) + return (ENOMEM); count = 0; buf = outbuf; @@ -1873,6 +1888,7 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) { struct bridge_softc *sc = ifp->if_bridge; struct bridge_iflist *bif; + struct epoch_tracker et; if (ifp->if_flags & IFF_RENAMING) return; @@ -1883,6 +1899,7 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) */ return; } + NET_EPOCH_ENTER_ET(et); /* Check if the interface is a bridge member */ if (sc != NULL) { BRIDGE_LOCK(sc); @@ -1892,6 +1909,7 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) bridge_delete_member(sc, bif, 1); BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return; } @@ -1908,6 +1926,7 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) BRIDGE_UNLOCK(sc); } BRIDGE_LIST_UNLOCK(); + NET_EPOCH_EXIT_ET(et); } /* @@ -2062,23 +2081,26 @@ static int bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, struct rtentry *rt) { + struct epoch_tracker et; struct ether_header *eh; struct ifnet *dst_if; struct bridge_softc *sc; uint16_t vlan; + NET_EPOCH_ENTER_ET(et); + if (m->m_len < ETHER_HDR_LEN) { m = m_pullup(m, ETHER_HDR_LEN); - if (m == NULL) + if (m == NULL) { + NET_EPOCH_EXIT_ET(et); return (0); + } } eh = mtod(m, struct ether_header *); sc = ifp->if_bridge; vlan = VLANTAGOF(m); - BRIDGE_LOCK(sc); - /* * If bridge is down, but the original output interface is up, * go ahead and send out that interface. Otherwise, the packet @@ -2100,16 +2122,10 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struc if (dst_if == NULL) { struct bridge_iflist *bif; struct mbuf *mc; - int error = 0, used = 0; + int used = 0; bridge_span(sc, m); - BRIDGE_LOCK2REF(sc, error); - if (error) { - m_freem(m); - return (0); - } - CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { dst_if = bif->bif_ifp; @@ -2143,7 +2159,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struc } if (used == 0) m_freem(m); - BRIDGE_UNREF(sc); + NET_EPOCH_EXIT_ET(et); return (0); } @@ -2155,12 +2171,12 @@ sendunicast: bridge_span(sc, m); if ((dst_if->if_drv_flags & IFF_DRV_RUNNING) == 0) { m_freem(m); - BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return (0); } - BRIDGE_UNLOCK(sc); bridge_enqueue(sc, dst_if, m); + NET_EPOCH_EXIT_ET(et); return (0); } @@ -2173,25 +2189,28 @@ sendunicast: static int bridge_transmit(struct ifnet *ifp, struct mbuf *m) { + struct epoch_tracker et; struct bridge_softc *sc; struct ether_header *eh; struct ifnet *dst_if; int error = 0; + NET_EPOCH_ENTER_ET(et); + sc = ifp->if_softc; ETHER_BPF_MTAP(ifp, m); eh = mtod(m, struct ether_header *); - BRIDGE_LOCK(sc); if (((m->m_flags & (M_BCAST|M_MCAST)) == 0) && (dst_if = bridge_rtlookup(sc, eh->ether_dhost, 1)) != NULL) { - BRIDGE_UNLOCK(sc); error = bridge_enqueue(sc, dst_if, m); } else bridge_broadcast(sc, ifp, m, 0); + NET_EPOCH_EXIT_ET(et); + return (error); } @@ -2221,6 +2240,8 @@ bridge_forward(struct bridge_softc *sc, struct bridge_ uint8_t *dst; int error; + MPASS(in_epoch(net_epoch_preempt)); + src_if = m->m_pkthdr.rcvif; ifp = sc->sc_ifp; @@ -2299,12 +2320,10 @@ bridge_forward(struct bridge_softc *sc, struct bridge_ || PFIL_HOOKED(&V_inet6_pfil_hook) #endif ) { - BRIDGE_UNLOCK(sc); if (bridge_pfil(&m, ifp, src_if, PFIL_IN) != 0) return; if (m == NULL) return; - BRIDGE_LOCK(sc); } if (dst_if == NULL) { @@ -2332,8 +2351,6 @@ bridge_forward(struct bridge_softc *sc, struct bridge_ dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) goto drop; - BRIDGE_UNLOCK(sc); - if (PFIL_HOOKED(&V_inet_pfil_hook) #ifdef INET6 || PFIL_HOOKED(&V_inet6_pfil_hook) @@ -2349,7 +2366,6 @@ bridge_forward(struct bridge_softc *sc, struct bridge_ return; drop: - BRIDGE_UNLOCK(sc); m_freem(m); } @@ -2362,6 +2378,7 @@ drop: static struct mbuf * bridge_input(struct ifnet *ifp, struct mbuf *m) { + struct epoch_tracker et; struct bridge_softc *sc = ifp->if_bridge; struct bridge_iflist *bif, *bif2; struct ifnet *bifp; @@ -2370,8 +2387,12 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) uint16_t vlan; int error; - if ((sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + NET_EPOCH_ENTER_ET(et); + + if ((sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + NET_EPOCH_EXIT_ET(et); return (m); + } bifp = sc->sc_ifp; vlan = VLANTAGOF(m); @@ -2388,12 +2409,12 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) if_inc_counter(bifp, IFCOUNTER_IPACKETS, 1); if_inc_counter(bifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); m_freem(m); + NET_EPOCH_EXIT_ET(et); return (NULL); } - BRIDGE_LOCK(sc); bif = bridge_lookup_member_if(sc, ifp); if (bif == NULL) { - BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return (m); } @@ -2406,13 +2427,13 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) if (memcmp(eh->ether_dhost, bstp_etheraddr, ETHER_ADDR_LEN) == 0) { bstp_input(&bif->bif_stp, ifp, m); /* consumes mbuf */ - BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return (NULL); } if ((bif->bif_flags & IFBIF_STP) && bif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) { - BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return (m); } @@ -2423,7 +2444,7 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) */ mc = m_dup(m, M_NOWAIT); if (mc == NULL) { - BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return (m); } @@ -2450,12 +2471,13 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) } /* Return the original packet for local processing. */ + NET_EPOCH_EXIT_ET(et); return (m); } if ((bif->bif_flags & IFBIF_STP) && bif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) { - BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return (m); } @@ -2495,7 +2517,6 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) OR_PFIL_HOOKED_INET6)) { \ if (bridge_pfil(&m, NULL, ifp, \ PFIL_IN) != 0 || m == NULL) { \ - BRIDGE_UNLOCK(sc); \ return (NULL); \ } \ eh = mtod(m, struct ether_header *); \ @@ -2505,13 +2526,13 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) error = bridge_rtupdate(sc, eh->ether_shost, \ vlan, bif, 0, IFBAF_DYNAMIC); \ if (error && bif->bif_addrmax) { \ - BRIDGE_UNLOCK(sc); \ m_freem(m); \ + NET_EPOCH_EXIT_ET(et); \ return (NULL); \ } \ } \ m->m_pkthdr.rcvif = iface; \ - BRIDGE_UNLOCK(sc); \ + NET_EPOCH_EXIT_ET(et); \ return (m); \ } \ \ @@ -2519,8 +2540,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) if (memcmp(IF_LLADDR((iface)), eh->ether_shost, ETHER_ADDR_LEN) == 0 \ OR_CARP_CHECK_WE_ARE_SRC((iface)) \ ) { \ - BRIDGE_UNLOCK(sc); \ m_freem(m); \ + NET_EPOCH_EXIT_ET(et); \ return (NULL); \ } @@ -2551,6 +2572,7 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) /* Perform the bridge forwarding function. */ bridge_forward(sc, bif, m); + NET_EPOCH_EXIT_ET(et); return (NULL); } @@ -2570,16 +2592,12 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet struct bridge_iflist *dbif, *sbif; struct mbuf *mc; struct ifnet *dst_if; - int error = 0, used = 0, i; + int used = 0, i; + MPASS(in_epoch(net_epoch_preempt)); + sbif = bridge_lookup_member_if(sc, src_if); - BRIDGE_LOCK2REF(sc, error); - if (error) { - m_freem(m); - return; - } - /* Filter on the bridge interface before broadcasting */ if (runfilt && (PFIL_HOOKED(&V_inet_pfil_hook) #ifdef INET6 @@ -2587,9 +2605,9 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet #endif )) { if (bridge_pfil(&m, sc->sc_ifp, NULL, PFIL_OUT) != 0) - goto out; + return; if (m == NULL) - goto out; + return; } CK_LIST_FOREACH(dbif, &sc->sc_iflist, bif_next) { @@ -2652,9 +2670,6 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet } if (used == 0) m_freem(m); - -out: - BRIDGE_UNREF(sc); } /* @@ -2670,6 +2685,8 @@ bridge_span(struct bridge_softc *sc, struct mbuf *m) struct ifnet *dst_if; struct mbuf *mc; + MPASS(in_epoch(net_epoch_preempt)); + if (CK_LIST_EMPTY(&sc->sc_spanlist)) return; @@ -2701,7 +2718,8 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t struct bridge_rtnode *brt; int error; - BRIDGE_LOCK_ASSERT(sc); + MPASS(in_epoch(net_epoch_preempt)); + BRIDGE_UNLOCK_ASSERT(sc); /* Check the source address is valid and not multicast. */ if (ETHER_IS_MULTICAST(dst) || @@ -2718,13 +2736,24 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t * update it, otherwise create a new one. */ if ((brt = bridge_rtnode_lookup(sc, dst, vlan)) == NULL) { + BRIDGE_LOCK(sc); + + /* Check again, now that we have the lock. There could have + * been a race and we only want to insert this once. */ + if ((brt = bridge_rtnode_lookup(sc, dst, vlan)) != NULL) { + BRIDGE_UNLOCK(sc); + return (0); + } + if (sc->sc_brtcnt >= sc->sc_brtmax) { sc->sc_brtexceeded++; + BRIDGE_UNLOCK(sc); return (ENOSPC); } /* Check per interface address limits (if enabled) */ if (bif->bif_addrmax && bif->bif_addrcnt >= bif->bif_addrmax) { bif->bif_addrexceeded++; + BRIDGE_UNLOCK(sc); return (ENOSPC); } @@ -2734,8 +2763,11 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t * address. */ brt = uma_zalloc(V_bridge_rtnode_zone, M_NOWAIT | M_ZERO); - if (brt == NULL) + if (brt == NULL) { + BRIDGE_UNLOCK(sc); return (ENOMEM); + } + brt->brt_vnet = curvnet; if (bif->bif_flags & IFBIF_STICKY) brt->brt_flags = IFBAF_STICKY; @@ -2747,17 +2779,22 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t if ((error = bridge_rtnode_insert(sc, brt)) != 0) { uma_zfree(V_bridge_rtnode_zone, brt); + BRIDGE_UNLOCK(sc); return (error); } brt->brt_dst = bif; bif->bif_addrcnt++; + + BRIDGE_UNLOCK(sc); } if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC && brt->brt_dst != bif) { + BRIDGE_LOCK(sc); brt->brt_dst->bif_addrcnt--; brt->brt_dst = bif; brt->brt_dst->bif_addrcnt++; + BRIDGE_UNLOCK(sc); } if ((flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) @@ -2778,7 +2815,7 @@ bridge_rtlookup(struct bridge_softc *sc, const uint8_t { struct bridge_rtnode *brt; - BRIDGE_LOCK_ASSERT(sc); + MPASS(in_epoch(net_epoch_preempt)); if ((brt = bridge_rtnode_lookup(sc, addr, vlan)) == NULL) return (NULL); @@ -3017,7 +3054,7 @@ bridge_rtnode_lookup(struct bridge_softc *sc, const ui uint32_t hash; int dir; - BRIDGE_LOCK_ASSERT(sc); + MPASS(in_epoch(net_epoch_preempt)); hash = bridge_rthash(sc, addr); CK_LIST_FOREACH(brt, &sc->sc_rthash[hash], brt_hash) { @@ -3080,6 +3117,18 @@ out: return (0); } +static void +bridge_rtnode_destroy_cb(struct epoch_context *ctx) +{ + struct bridge_rtnode *brt; + + brt = __containerof(ctx, struct bridge_rtnode, brt_epoch_ctx); + + CURVNET_SET(brt->brt_vnet); + uma_zfree(V_bridge_rtnode_zone, brt); + CURVNET_RESTORE(); +} + /* * bridge_rtnode_destroy: * @@ -3095,7 +3144,9 @@ bridge_rtnode_destroy(struct bridge_softc *sc, struct CK_LIST_REMOVE(brt, brt_list); sc->sc_brtcnt--; brt->brt_dst->bif_addrcnt--; - uma_zfree(V_bridge_rtnode_zone, brt); + + epoch_call(net_epoch_preempt, &brt->brt_epoch_ctx, + bridge_rtnode_destroy_cb); } /* @@ -3640,17 +3691,20 @@ bridge_linkstate(struct ifnet *ifp) { struct bridge_softc *sc = ifp->if_bridge; struct bridge_iflist *bif; + struct epoch_tracker et; - BRIDGE_LOCK(sc); + NET_EPOCH_ENTER_ET(et); + bif = bridge_lookup_member_if(sc, ifp); if (bif == NULL) { - BRIDGE_UNLOCK(sc); + NET_EPOCH_EXIT_ET(et); return; } bridge_linkcheck(sc); - BRIDGE_UNLOCK(sc); bstp_linkstate(&bif->bif_stp); + + NET_EPOCH_EXIT_ET(et); } static void @@ -3659,7 +3713,8 @@ bridge_linkcheck(struct bridge_softc *sc) struct bridge_iflist *bif; int new_link, hasls; - BRIDGE_LOCK_ASSERT(sc); + MPASS(in_epoch(net_epoch_preempt)); + new_link = LINK_STATE_DOWN; hasls = 0; /* Our link is considered up if at least one of our ports is active */ From owner-svn-src-all@freebsd.org Sun Nov 15 11:56:16 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D72E72E5D43; Sun, 15 Nov 2020 11:56:16 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYrJc5gs1z3mQn; Sun, 15 Nov 2020 11:56:16 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B581B1B98A; Sun, 15 Nov 2020 11:56:16 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFBuG7U074320; Sun, 15 Nov 2020 11:56:16 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFBuGoo074319; Sun, 15 Nov 2020 11:56:16 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202011151156.0AFBuGoo074319@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 15 Nov 2020 11:56:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367706 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 367706 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 11:56:16 -0000 Author: kp Date: Sun Nov 15 11:56:16 2020 New Revision: 367706 URL: https://svnweb.freebsd.org/changeset/base/367706 Log: MFC r366500: bridge: call member interface ioctl() without NET_EPOCH We're not allowed to hold NET_EPOCH while sleeping, so when we call ioctl() handlers for member interfaces we cannot be in NET_EPOCH. We still need some protection of our CK_LISTs, so hold BRIDGE_LOCK instead. That requires changing BRIDGE_LOCK into a sleepable lock, and separating the BRIDGE_RT_LOCK, to protect bridge_rtnode lists. That lock is taken in the data path (while in NET_EPOCH), so it cannot be a sleepable lock. While here document the locking strategy. Modified: stable/12/sys/net/if_bridge.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/if_bridge.c ============================================================================== --- stable/12/sys/net/if_bridge.c Sun Nov 15 11:46:44 2020 (r367705) +++ stable/12/sys/net/if_bridge.c Sun Nov 15 11:56:16 2020 (r367706) @@ -186,17 +186,41 @@ extern void nd6_setmtu(struct ifnet *); /* * Bridge locking + * + * The bridge relies heavily on the epoch(9) system to protect its data + * structures. This means we can safely use CK_LISTs while in NET_EPOCH, but we + * must ensure there is only one writer at a time. + * + * That is: for read accesses we only need to be in NET_EPOCH, but for write + * accesses we must hold: + * + * - BRIDGE_RT_LOCK, for any change to bridge_rtnodes + * - BRIDGE_LOCK, for any other change + * + * The BRIDGE_LOCK is a sleepable lock, because it is held accross ioctl() + * calls to bridge member interfaces and these ioctl()s can sleep. + * The BRIDGE_RT_LOCK is a non-sleepable mutex, because it is sometimes + * required while we're in NET_EPOCH and then we're not allowed to sleep. */ #define BRIDGE_LOCK_INIT(_sc) do { \ - mtx_init(&(_sc)->sc_mtx, "if_bridge", NULL, MTX_DEF); \ + sx_init(&(_sc)->sc_sx, "if_bridge"); \ + mtx_init(&(_sc)->sc_rt_mtx, "if_bridge rt", NULL, MTX_DEF); \ } while (0) #define BRIDGE_LOCK_DESTROY(_sc) do { \ - mtx_destroy(&(_sc)->sc_mtx); \ + sx_destroy(&(_sc)->sc_sx); \ + mtx_destroy(&(_sc)->sc_rt_mtx); \ } while (0) -#define BRIDGE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) -#define BRIDGE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) -#define BRIDGE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) -#define BRIDGE_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED) +#define BRIDGE_LOCK(_sc) sx_xlock(&(_sc)->sc_sx) +#define BRIDGE_UNLOCK(_sc) sx_xunlock(&(_sc)->sc_sx) +#define BRIDGE_LOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SX_XLOCKED) +#define BRIDGE_LOCK_OR_NET_EPOCH_ASSERT(_sc) \ + MPASS(in_epoch(net_epoch_preempt) || sx_xlocked(&(_sc)->sc_sx)) +#define BRIDGE_UNLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SX_UNLOCKED) +#define BRIDGE_RT_LOCK(_sc) mtx_lock(&(_sc)->sc_rt_mtx) +#define BRIDGE_RT_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_rt_mtx) +#define BRIDGE_RT_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_rt_mtx, MA_OWNED) +#define BRIDGE_RT_LOCK_OR_NET_EPOCH_ASSERT(_sc) \ + MPASS(in_epoch(net_epoch_preempt) || mtx_owned(&(_sc)->sc_rt_mtx)) /* * Bridge interface list entry. @@ -237,7 +261,8 @@ struct bridge_rtnode { struct bridge_softc { struct ifnet *sc_ifp; /* make this an interface */ LIST_ENTRY(bridge_softc) sc_list; - struct mtx sc_mtx; + struct sx sc_sx; + struct mtx sc_rt_mtx; uint32_t sc_brtmax; /* max # of addresses */ uint32_t sc_brtcnt; /* cur. # of addresses */ uint32_t sc_brttimeout; /* rt timeout in seconds */ @@ -255,8 +280,8 @@ struct bridge_softc { struct epoch_context sc_epoch_ctx; }; -VNET_DEFINE_STATIC(struct mtx, bridge_list_mtx); -#define V_bridge_list_mtx VNET(bridge_list_mtx) +VNET_DEFINE_STATIC(struct sx, bridge_list_sx); +#define V_bridge_list_sx VNET(bridge_list_sx) static eventhandler_tag bridge_detach_cookie; int bridge_rtable_prune_period = BRIDGE_RTABLE_PRUNE_PERIOD; @@ -539,11 +564,11 @@ const int bridge_control_table_size = nitems(bridge_co VNET_DEFINE_STATIC(LIST_HEAD(, bridge_softc), bridge_list); #define V_bridge_list VNET(bridge_list) -#define BRIDGE_LIST_LOCK_INIT(x) mtx_init(&V_bridge_list_mtx, \ - "if_bridge list", NULL, MTX_DEF) -#define BRIDGE_LIST_LOCK_DESTROY(x) mtx_destroy(&V_bridge_list_mtx) -#define BRIDGE_LIST_LOCK(x) mtx_lock(&V_bridge_list_mtx) -#define BRIDGE_LIST_UNLOCK(x) mtx_unlock(&V_bridge_list_mtx) +#define BRIDGE_LIST_LOCK_INIT(x) sx_init(&V_bridge_list_sx, \ + "if_bridge list") +#define BRIDGE_LIST_LOCK_DESTROY(x) sx_destroy(&V_bridge_list_sx) +#define BRIDGE_LIST_LOCK(x) sx_xlock(&V_bridge_list_sx) +#define BRIDGE_LIST_UNLOCK(x) sx_xunlock(&V_bridge_list_sx) VNET_DEFINE_STATIC(struct if_clone *, bridge_cloner); #define V_bridge_cloner VNET(bridge_cloner) @@ -676,7 +701,7 @@ bridge_clone_create(struct if_clone *ifc, int unit, ca /* Initialize our routing table. */ bridge_rtable_init(sc); - callout_init_mtx(&sc->sc_brcallout, &sc->sc_mtx, 0); + callout_init_mtx(&sc->sc_brcallout, &sc->sc_rt_mtx, 0); CK_LIST_INIT(&sc->sc_iflist); CK_LIST_INIT(&sc->sc_spanlist); @@ -762,7 +787,6 @@ bridge_clone_destroy(struct ifnet *ifp) struct bridge_iflist *bif; struct epoch_tracker et; - NET_EPOCH_ENTER_ET(et); BRIDGE_LOCK(sc); bridge_stop(ifp, 1); @@ -780,6 +804,8 @@ bridge_clone_destroy(struct ifnet *ifp) BRIDGE_UNLOCK(sc); + NET_EPOCH_ENTER_ET(et); + callout_drain(&sc->sc_brcallout); BRIDGE_LIST_LOCK(); @@ -818,9 +844,8 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da struct ifdrv *ifd = (struct ifdrv *) data; const struct bridge_control *bc; int error = 0, oldmtu; - struct epoch_tracker et; - NET_EPOCH_ENTER_ET(et); + BRIDGE_LOCK(sc); switch (cmd) { @@ -867,9 +892,7 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da } oldmtu = ifp->if_mtu; - BRIDGE_LOCK(sc); error = (*bc->bc_func)(sc, &args); - BRIDGE_UNLOCK(sc); if (error) break; @@ -896,16 +919,16 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da * If interface is marked down and it is running, * then stop and disable it. */ - BRIDGE_LOCK(sc); bridge_stop(ifp, 1); - BRIDGE_UNLOCK(sc); } else if ((ifp->if_flags & IFF_UP) && !(ifp->if_drv_flags & IFF_DRV_RUNNING)) { /* * If interface is marked up and it is stopped, then * start it. */ + BRIDGE_UNLOCK(sc); (*ifp->if_init)(sc); + BRIDGE_LOCK(sc); } break; @@ -918,7 +941,6 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da sc->sc_ifp->if_mtu = ifr->ifr_mtu; break; } - BRIDGE_LOCK(sc); CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (bif->bif_ifp->if_mtu != ifr->ifr_mtu) { log(LOG_NOTICE, "%s: invalid MTU: %u(%s)" @@ -931,18 +953,19 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t da } if (!error) sc->sc_ifp->if_mtu = ifr->ifr_mtu; - BRIDGE_UNLOCK(sc); break; default: /* * drop the lock as ether_ioctl() will call bridge_start() and * cause the lock to be recursed. */ + BRIDGE_UNLOCK(sc); error = ether_ioctl(ifp, cmd, data); + BRIDGE_LOCK(sc); break; } - NET_EPOCH_EXIT_ET(et); + BRIDGE_UNLOCK(sc); return (error); } @@ -974,9 +997,7 @@ bridge_mutecaps(struct bridge_softc *sc) /* strip off mask bits and enable them again if allowed */ enabled &= ~BRIDGE_IFCAPS_MASK; enabled |= mask; - BRIDGE_UNLOCK(sc); bridge_set_ifcap(sc, bif, enabled); - BRIDGE_LOCK(sc); } } @@ -987,8 +1008,6 @@ bridge_set_ifcap(struct bridge_softc *sc, struct bridg struct ifreq ifr; int error, mask, stuck; - BRIDGE_UNLOCK_ASSERT(sc); - bzero(&ifr, sizeof(ifr)); ifr.ifr_reqcap = set; @@ -1018,7 +1037,7 @@ bridge_lookup_member(struct bridge_softc *sc, const ch struct bridge_iflist *bif; struct ifnet *ifp; - MPASS(in_epoch(net_epoch_preempt)); + BRIDGE_LOCK_OR_NET_EPOCH_ASSERT(sc); CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { ifp = bif->bif_ifp; @@ -1039,7 +1058,7 @@ bridge_lookup_member_if(struct bridge_softc *sc, struc { struct bridge_iflist *bif; - MPASS(in_epoch(net_epoch_preempt)); + BRIDGE_LOCK_OR_NET_EPOCH_ASSERT(sc); CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (bif->bif_ifp == member_ifp) @@ -1102,14 +1121,15 @@ bridge_delete_member(struct bridge_softc *sc, struct b bridge_linkcheck(sc); bridge_mutecaps(sc); /* recalcuate now this interface is removed */ + BRIDGE_RT_LOCK(sc); bridge_rtdelete(sc, ifs, IFBF_FLUSHALL); + BRIDGE_RT_UNLOCK(sc); KASSERT(bif->bif_addrcnt == 0, ("%s: %d bridge routes referenced", __func__, bif->bif_addrcnt)); ifs->if_bridge_output = NULL; ifs->if_bridge_input = NULL; ifs->if_bridge_linkstate = NULL; - BRIDGE_UNLOCK(sc); if (!gone) { switch (ifs->if_type) { case IFT_ETHER: @@ -1136,7 +1156,6 @@ bridge_delete_member(struct bridge_softc *sc, struct b bridge_set_ifcap(sc, bif, bif->bif_savedcaps); } bstp_destroy(&bif->bif_stp); /* prepare to free */ - BRIDGE_LOCK(sc); epoch_call(net_epoch_preempt, &bif->bif_epoch_ctx, bridge_delete_member_cb); @@ -1216,9 +1235,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) */ CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (in6ifa_llaonifp(bif->bif_ifp)) { - BRIDGE_UNLOCK(sc); in6_ifdetach(bif->bif_ifp); - BRIDGE_LOCK(sc); if_printf(sc->sc_ifp, "IPv6 addresses on %s have been removed " "before adding it as a member to prevent " @@ -1227,9 +1244,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) } } if (in6ifa_llaonifp(ifs)) { - BRIDGE_UNLOCK(sc); in6_ifdetach(ifs); - BRIDGE_LOCK(sc); if_printf(sc->sc_ifp, "IPv6 addresses on %s have been removed " "before adding it as a member to prevent " @@ -1287,9 +1302,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) switch (ifs->if_type) { case IFT_ETHER: case IFT_L2VLAN: - BRIDGE_UNLOCK(sc); error = ifpromisc(ifs, 1); - BRIDGE_LOCK(sc); break; } @@ -1471,10 +1484,8 @@ bridge_ioctl_gifs(struct bridge_softc *sc, void *arg) len -= sizeof(breq); } - BRIDGE_UNLOCK(sc); bifc->ifbic_len = sizeof(breq) * count; error = copyout(outbuf, bifc->ifbic_req, bifc->ifbic_len); - BRIDGE_LOCK(sc); free(outbuf, M_TEMP); return (error); } @@ -1524,10 +1535,8 @@ bridge_ioctl_rts(struct bridge_softc *sc, void *arg) len -= sizeof(bareq); } out: - BRIDGE_UNLOCK(sc); bac->ifbac_len = sizeof(bareq) * count; error = copyout(outbuf, bac->ifbac_req, bac->ifbac_len); - BRIDGE_LOCK(sc); free(outbuf, M_TEMP); return (error); } @@ -1537,19 +1546,21 @@ bridge_ioctl_saddr(struct bridge_softc *sc, void *arg) { struct ifbareq *req = arg; struct bridge_iflist *bif; + struct epoch_tracker et; int error; - MPASS(in_epoch(net_epoch_preempt)); + NET_EPOCH_ENTER_ET(et); bif = bridge_lookup_member(sc, req->ifba_ifsname); - if (bif == NULL) + if (bif == NULL) { + NET_EPOCH_EXIT_ET(et); return (ENOENT); + } /* bridge_rtupdate() may acquire the lock. */ - BRIDGE_UNLOCK(sc); error = bridge_rtupdate(sc, req->ifba_dst, req->ifba_vlan, bif, 1, req->ifba_flags); - BRIDGE_LOCK(sc); + NET_EPOCH_EXIT_ET(et); return (error); } @@ -1585,7 +1596,10 @@ bridge_ioctl_flush(struct bridge_softc *sc, void *arg) { struct ifbreq *req = arg; + BRIDGE_RT_LOCK(sc); bridge_rtflush(sc, req->ifbr_ifsflags); + BRIDGE_RT_UNLOCK(sc); + return (0); } @@ -1853,10 +1867,8 @@ bridge_ioctl_gifsstp(struct bridge_softc *sc, void *ar len -= sizeof(bpreq); } - BRIDGE_UNLOCK(sc); bifstp->ifbpstp_len = sizeof(bpreq) * count; error = copyout(outbuf, bifstp->ifbpstp_req, bifstp->ifbpstp_len); - BRIDGE_LOCK(sc); free(outbuf, M_TEMP); return (error); } @@ -1888,7 +1900,6 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) { struct bridge_softc *sc = ifp->if_bridge; struct bridge_iflist *bif; - struct epoch_tracker et; if (ifp->if_flags & IFF_RENAMING) return; @@ -1899,7 +1910,6 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) */ return; } - NET_EPOCH_ENTER_ET(et); /* Check if the interface is a bridge member */ if (sc != NULL) { BRIDGE_LOCK(sc); @@ -1909,7 +1919,6 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) bridge_delete_member(sc, bif, 1); BRIDGE_UNLOCK(sc); - NET_EPOCH_EXIT_ET(et); return; } @@ -1926,7 +1935,6 @@ bridge_ifdetach(void *arg __unused, struct ifnet *ifp) BRIDGE_UNLOCK(sc); } BRIDGE_LIST_UNLOCK(); - NET_EPOCH_EXIT_ET(et); } /* @@ -1968,10 +1976,13 @@ bridge_stop(struct ifnet *ifp, int disable) if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) return; + BRIDGE_RT_LOCK(sc); callout_stop(&sc->sc_brcallout); + bstp_stop(&sc->sc_stp); bridge_rtflush(sc, IFBF_FLUSHDYN); + BRIDGE_RT_UNLOCK(sc); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; } @@ -2718,8 +2729,7 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t struct bridge_rtnode *brt; int error; - MPASS(in_epoch(net_epoch_preempt)); - BRIDGE_UNLOCK_ASSERT(sc); + BRIDGE_LOCK_OR_NET_EPOCH_ASSERT(sc); /* Check the source address is valid and not multicast. */ if (ETHER_IS_MULTICAST(dst) || @@ -2736,24 +2746,24 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t * update it, otherwise create a new one. */ if ((brt = bridge_rtnode_lookup(sc, dst, vlan)) == NULL) { - BRIDGE_LOCK(sc); + BRIDGE_RT_LOCK(sc); /* Check again, now that we have the lock. There could have * been a race and we only want to insert this once. */ if ((brt = bridge_rtnode_lookup(sc, dst, vlan)) != NULL) { - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); return (0); } if (sc->sc_brtcnt >= sc->sc_brtmax) { sc->sc_brtexceeded++; - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); return (ENOSPC); } /* Check per interface address limits (if enabled) */ if (bif->bif_addrmax && bif->bif_addrcnt >= bif->bif_addrmax) { bif->bif_addrexceeded++; - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); return (ENOSPC); } @@ -2764,7 +2774,7 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t */ brt = uma_zalloc(V_bridge_rtnode_zone, M_NOWAIT | M_ZERO); if (brt == NULL) { - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); return (ENOMEM); } brt->brt_vnet = curvnet; @@ -2779,22 +2789,22 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t if ((error = bridge_rtnode_insert(sc, brt)) != 0) { uma_zfree(V_bridge_rtnode_zone, brt); - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); return (error); } brt->brt_dst = bif; bif->bif_addrcnt++; - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); } if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC && brt->brt_dst != bif) { - BRIDGE_LOCK(sc); + BRIDGE_RT_LOCK(sc); brt->brt_dst->bif_addrcnt--; brt->brt_dst = bif; brt->brt_dst->bif_addrcnt++; - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); } if ((flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) @@ -2835,7 +2845,8 @@ bridge_rttrim(struct bridge_softc *sc) { struct bridge_rtnode *brt, *nbrt; - BRIDGE_LOCK_ASSERT(sc); + MPASS(in_epoch(net_epoch_preempt)); + BRIDGE_RT_LOCK_ASSERT(sc); /* Make sure we actually need to do this. */ if (sc->sc_brtcnt <= sc->sc_brtmax) @@ -2865,7 +2876,7 @@ bridge_timer(void *arg) { struct bridge_softc *sc = arg; - BRIDGE_LOCK_ASSERT(sc); + BRIDGE_RT_LOCK_ASSERT(sc); /* Destruction of rtnodes requires a proper vnet context */ CURVNET_SET(sc->sc_ifp->if_vnet); @@ -2887,7 +2898,7 @@ bridge_rtage(struct bridge_softc *sc) { struct bridge_rtnode *brt, *nbrt; - BRIDGE_LOCK_ASSERT(sc); + BRIDGE_RT_LOCK_ASSERT(sc); CK_LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) { @@ -2907,7 +2918,7 @@ bridge_rtflush(struct bridge_softc *sc, int full) { struct bridge_rtnode *brt, *nbrt; - BRIDGE_LOCK_ASSERT(sc); + BRIDGE_RT_LOCK_ASSERT(sc); CK_LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { if (full || (brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) @@ -2926,7 +2937,7 @@ bridge_rtdaddr(struct bridge_softc *sc, const uint8_t struct bridge_rtnode *brt; int found = 0; - BRIDGE_LOCK_ASSERT(sc); + BRIDGE_RT_LOCK(sc); /* * If vlan is zero then we want to delete for all vlans so the lookup @@ -2937,6 +2948,8 @@ bridge_rtdaddr(struct bridge_softc *sc, const uint8_t found = 1; } + BRIDGE_RT_UNLOCK(sc); + return (found ? 0 : ENOENT); } @@ -2950,7 +2963,7 @@ bridge_rtdelete(struct bridge_softc *sc, struct ifnet { struct bridge_rtnode *brt, *nbrt; - BRIDGE_LOCK_ASSERT(sc); + BRIDGE_RT_LOCK_ASSERT(sc); CK_LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { if (brt->brt_ifp == ifp && (full || @@ -3054,7 +3067,7 @@ bridge_rtnode_lookup(struct bridge_softc *sc, const ui uint32_t hash; int dir; - MPASS(in_epoch(net_epoch_preempt)); + BRIDGE_RT_LOCK_OR_NET_EPOCH_ASSERT(sc); hash = bridge_rthash(sc, addr); CK_LIST_FOREACH(brt, &sc->sc_rthash[hash], brt_hash) { @@ -3081,7 +3094,7 @@ bridge_rtnode_insert(struct bridge_softc *sc, struct b uint32_t hash; int dir; - BRIDGE_LOCK_ASSERT(sc); + BRIDGE_RT_LOCK_ASSERT(sc); hash = bridge_rthash(sc, brt->brt_addr); @@ -3137,8 +3150,9 @@ bridge_rtnode_destroy_cb(struct epoch_context *ctx) static void bridge_rtnode_destroy(struct bridge_softc *sc, struct bridge_rtnode *brt) { - BRIDGE_LOCK_ASSERT(sc); + BRIDGE_RT_LOCK_ASSERT(sc); + CK_LIST_REMOVE(brt, brt_hash); CK_LIST_REMOVE(brt, brt_list); @@ -3161,7 +3175,7 @@ bridge_rtable_expire(struct ifnet *ifp, int age) struct bridge_rtnode *brt; CURVNET_SET(ifp->if_vnet); - BRIDGE_LOCK(sc); + BRIDGE_RT_LOCK(sc); /* * If the age is zero then flush, otherwise set all the expiry times to @@ -3178,7 +3192,7 @@ bridge_rtable_expire(struct ifnet *ifp, int age) brt->brt_expire = time_uptime + age; } } - BRIDGE_UNLOCK(sc); + BRIDGE_RT_UNLOCK(sc); CURVNET_RESTORE(); } @@ -3713,7 +3727,7 @@ bridge_linkcheck(struct bridge_softc *sc) struct bridge_iflist *bif; int new_link, hasls; - MPASS(in_epoch(net_epoch_preempt)); + BRIDGE_LOCK_OR_NET_EPOCH_ASSERT(sc); new_link = LINK_STATE_DOWN; hasls = 0; From owner-svn-src-all@freebsd.org Sun Nov 15 12:28:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B0B62E7559; Sun, 15 Nov 2020 12:28:58 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYs2L0GM9z3pfr; Sun, 15 Nov 2020 12:28:58 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFEB91BF4A; Sun, 15 Nov 2020 12:28:57 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFCSv5K093126; Sun, 15 Nov 2020 12:28:57 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFCSvgX093125; Sun, 15 Nov 2020 12:28:57 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011151228.0AFCSvgX093125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Sun, 15 Nov 2020 12:28:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367707 - stable/12/share/man/man7 X-SVN-Group: stable-12 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/12/share/man/man7 X-SVN-Commit-Revision: 367707 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 12:28:58 -0000 Author: 0mp (doc,ports committer) Date: Sun Nov 15 12:28:57 2020 New Revision: 367707 URL: https://svnweb.freebsd.org/changeset/base/367707 Log: MFC r367253: Document how to use sudo for SU_CMD It is rather common for the ports users to replace su(1) with sudo(8) within the SU_CMD variable. Let's document it in the manual page (so far it's been hidden in a comment within bsd.commands.mk). Modified: stable/12/share/man/man7/ports.7 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man7/ports.7 ============================================================================== --- stable/12/share/man/man7/ports.7 Sun Nov 15 11:56:16 2020 (r367706) +++ stable/12/share/man/man7/ports.7 Sun Nov 15 12:28:57 2020 (r367707) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 17, 2020 +.Dd November 1, 2020 .Dt PORTS 7 .Os .Sh NAME @@ -390,7 +390,10 @@ The unprivileged user must have write access to and .Va DISTDIR . The default is -.Ql /usr/bin/su root -c +.Ql /usr/bin/su root -c . +Many users set it to +.Ql /usr/local/bin/sudo -E sh -c +for convenience. .It Va PACKAGES Used only for the .Cm package From owner-svn-src-all@freebsd.org Sun Nov 15 12:31:11 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18D2A2E77A1; Sun, 15 Nov 2020 12:31:11 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYs4s6kYTz3q1j; Sun, 15 Nov 2020 12:31:09 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8B9C1BDB5; Sun, 15 Nov 2020 12:31:07 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFCV7n5095990; Sun, 15 Nov 2020 12:31:07 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFCV7aA095989; Sun, 15 Nov 2020 12:31:07 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011151231.0AFCV7aA095989@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Sun, 15 Nov 2020 12:31:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r367708 - stable/11/share/man/man7 X-SVN-Group: stable-11 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/11/share/man/man7 X-SVN-Commit-Revision: 367708 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 12:31:11 -0000 Author: 0mp (doc,ports committer) Date: Sun Nov 15 12:31:07 2020 New Revision: 367708 URL: https://svnweb.freebsd.org/changeset/base/367708 Log: MFC r367253: Document how to use sudo for SU_CMD It is rather common for the ports users to replace su(1) with sudo(8) within the SU_CMD variable. Let's document it in the manual page (so far it's been hidden in a comment within bsd.commands.mk). Modified: stable/11/share/man/man7/ports.7 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man7/ports.7 ============================================================================== --- stable/11/share/man/man7/ports.7 Sun Nov 15 12:28:57 2020 (r367707) +++ stable/11/share/man/man7/ports.7 Sun Nov 15 12:31:07 2020 (r367708) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 6, 2014 +.Dd November 1, 2020 .Dt PORTS 7 .Os .Sh NAME @@ -372,6 +372,17 @@ Where to find/put distfiles, normally .Pa distfiles/ in .Va PORTSDIR . +.It Va SU_CMD +Command used to elevate privilege to configure and install a port. +The unprivileged user must have write access to +.Va WRKDIRPREFIX +and +.Va DISTDIR . +The default is +.Ql /usr/bin/su root -c . +Many users set it to +.Ql /usr/local/bin/sudo -E sh -c +for convenience. .It Va PACKAGES Used only for the .Cm package From owner-svn-src-all@freebsd.org Sun Nov 15 12:59:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B31F2E805D; Sun, 15 Nov 2020 12:59:25 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYsjT2Y1rz3rL9; Sun, 15 Nov 2020 12:59:25 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A1A61C577; Sun, 15 Nov 2020 12:59:25 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFCxPCs012432; Sun, 15 Nov 2020 12:59:25 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFCxPQ8012431; Sun, 15 Nov 2020 12:59:25 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <202011151259.0AFCxPQ8012431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Sun, 15 Nov 2020 12:59:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367709 - head/usr.sbin/bhyve X-SVN-Group: head X-SVN-Commit-Author: grehan X-SVN-Commit-Paths: head/usr.sbin/bhyve X-SVN-Commit-Revision: 367709 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 12:59:25 -0000 Author: grehan Date: Sun Nov 15 12:59:24 2020 New Revision: 367709 URL: https://svnweb.freebsd.org/changeset/base/367709 Log: Fix regression in AHCI controller settings. When the AHCI code was reworked to use FreeBSD struct definitions, the valid element was mis-transcribed resulting in the UMDA capability being hidden. This prevented Illumos from using AHCI disk/cdrom drives. Fix by using definitions that match the code pre-rework. PR: 250924 Submitted by: Rolf Stalder Reported by: Rolf Stalder MFC after: 3 days Modified: head/usr.sbin/bhyve/pci_ahci.c Modified: head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- head/usr.sbin/bhyve/pci_ahci.c Sun Nov 15 12:31:07 2020 (r367708) +++ head/usr.sbin/bhyve/pci_ahci.c Sun Nov 15 12:59:24 2020 (r367709) @@ -1004,7 +1004,7 @@ ata_identify_init(struct ahci_port* p, int atapi) ata_ident->capabilities1 = ATA_SUPPORT_LBA | ATA_SUPPORT_DMA; ata_ident->capabilities2 = (1 << 14 | 1); - ata_ident->atavalid = ATA_FLAG_54_58 | ATA_FLAG_64_70; + ata_ident->atavalid = ATA_FLAG_64_70 | ATA_FLAG_88; ata_ident->obsolete62 = 0x3f; ata_ident->mwdmamodes = 7; if (p->xfermode & ATA_WDMA0) @@ -1053,8 +1053,7 @@ ata_identify_init(struct ahci_port* p, int atapi) ata_ident->capabilities1 = ATA_SUPPORT_DMA | ATA_SUPPORT_LBA | ATA_SUPPORT_IORDY; ata_ident->capabilities2 = (1 << 14); - ata_ident->atavalid = ATA_FLAG_54_58 | - ATA_FLAG_64_70; + ata_ident->atavalid = ATA_FLAG_64_70 | ATA_FLAG_88; if (p->mult_sectors) ata_ident->multi = (ATA_MULTI_VALID | p->mult_sectors); if (sectors <= 0x0fffffff) { From owner-svn-src-all@freebsd.org Sun Nov 15 14:04:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B9EE02E9D30; Sun, 15 Nov 2020 14:04:27 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYv8W4vy4z3w2b; Sun, 15 Nov 2020 14:04:27 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B9441D1AD; Sun, 15 Nov 2020 14:04:27 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFE4Rvx057178; Sun, 15 Nov 2020 14:04:27 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFE4RgS057177; Sun, 15 Nov 2020 14:04:27 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <202011151404.0AFE4RgS057177@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 15 Nov 2020 14:04:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367710 - head/stand/i386/zfsboot X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/i386/zfsboot X-SVN-Commit-Revision: 367710 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 14:04:27 -0000 Author: tsoome Date: Sun Nov 15 14:04:27 2020 New Revision: 367710 URL: https://svnweb.freebsd.org/changeset/base/367710 Log: zfsboot: add prototype for main() Some compilers are complaining about missing prototype. PR: 251150 Reported by: markiyan.kushnir@gmail.com Modified: head/stand/i386/zfsboot/zfsboot.c Modified: head/stand/i386/zfsboot/zfsboot.c ============================================================================== --- head/stand/i386/zfsboot/zfsboot.c Sun Nov 15 12:59:24 2020 (r367709) +++ head/stand/i386/zfsboot/zfsboot.c Sun Nov 15 14:04:27 2020 (r367710) @@ -161,6 +161,8 @@ ptov(uintptr_t x) return (PTOV(x)); } +int main(void); + int main(void) { From owner-svn-src-all@freebsd.org Sun Nov 15 16:42:14 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B5EA92ED458; Sun, 15 Nov 2020 16:42:14 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay107.isp.belgacom.be (mailrelay107.isp.belgacom.be [195.238.20.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign RSA OV SSL CA 2018" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CYyfY1bmnz4YWR; Sun, 15 Nov 2020 16:42:13 +0000 (UTC) (envelope-from tijl@freebsd.org) IronPort-SDR: 6cakD8YX+Y1P7eozdOx1j1d3w+Z38ntpFMkog70LkbumFclJIxMmQ9D+PAl8kN30v6njXjeNwe Iox2ykwN9suVwLtqUZdoVdGSev5RmdVHzAQiwKCakiLjUqsyjp41ONCxhWHBbq7NOaA/8HWms4 /TnvB+pah6XXt0T7hEnt0jCszXz9/RMl67BLtqfDiwFKsR8ctwtEOd5NuK0h5bv3Wsz8E7AMOS JEoV4GJ8sZ77vZIzaa3AnOlaVdVhy+WJzepaAiuaEsSd2HzFhNhXZ2MGGJsVjZYXx1hhQqveBj uZY= X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3AA39rThOi6GGdhiQVT34l6mtUPXoX/o7sNwtQ0K?= =?us-ascii?q?IMzox0K/3yr8bcNUDSrc9gkEXOFd2Cra4d1KyP6fGrCDRIyK3CmUhKSIZLWR?= =?us-ascii?q?4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBx?= =?us-ascii?q?rwKxd+KPjrFY7OlcS30P2594HObwlSizexfLF/IA+roQnPssQajo9vJroswR?= =?us-ascii?q?bVv3VEfPhby3l1LlyJhRb84cmw/J9n8ytOvv8q6tBNX6bncakmVLJUFDspPX?= =?us-ascii?q?w7683trhnDUBCA5mAAXWUMkxpHGBbK4RfnVZrsqCT6t+592C6HPc3qSL0/RD?= =?us-ascii?q?qv47t3RBLulSwKMSMy/mPKhcxqlK9VrhKvqQJizYDXYo6VOvVxcb/Sc94BWW?= =?us-ascii?q?pMXNxcWzBdDo+gcYcCCfcKM+ZCr4n6olsDtQWwBwyoBOjy1DJIgXj23bYk3O?= =?us-ascii?q?QkCw7G2hcgFM8JvXTIrdX1NqMSXPu1wqnS0zrMce5b1yrz5oTSdRAhu/6MUK?= =?us-ascii?q?t2fMHMxkYhCxnLgU+MqYz5ITyVzOINvnCH4udgVeyilm8qpx1srjWr2MsihJ?= =?us-ascii?q?TEi4IXx1za8Sh0wpo4KcG7RUB0fdKpH5RduS+EOoV4QM4vQW5ltiYmx7MJv5?= =?us-ascii?q?OwYSYEyJMixxHFavyHdZCF4hz5VOmPPzh3n2lld6+lixa160igxfXwVsi63V?= =?us-ascii?q?tJrydJiNnNtncQ1xHV98OJSeN981+i1DqSzQzf9O5JLV4umabGKZMt3KQ8m5?= =?us-ascii?q?UVvE/eBCH5gl/2g7WTdkg8/+io7Pnobav+q5+HMo90lhn+MqMzmsyjGeg4Mh?= =?us-ascii?q?YBX2yc+emk173s50n5QLRPjvIoiKnZt4rWJdgapq67Bw9ZyJos6xG4Dze9zt?= =?us-ascii?q?sYmGMILFReeB6diIjpIV7OLOj5Dfe5nVusjC9myvPbMrH7HJnAIWbPnK38cb?= =?us-ascii?q?t/9UJQ0gU+wcha551OC7EBJPzzWlX2tNzdFhI5Lw20w+TjCNhm2IMeQ3yADb?= =?us-ascii?q?GCP6PJrFCE/OUvI/ODZIMNojbyN+Al5+LyjX8+gVISY6yp0oEMaHCkAPtrOE?= =?us-ascii?q?uZYWDyjdgfCmgKpRcxQPbtiF2YXj5Zf2yyUL4k5jEnFIKmCp/ORpy3gLObxy?= =?us-ascii?q?e6H4ZbZm5cCl+SD3jnbJ6EVOoWZCKVOM9hnSQOVaK9RI85yRGuqAj6xqJ8Lu?= =?us-ascii?q?rK/C0UrInj1MJp6OHKlRE96yZ7ANmG3mGDVWF7gH0HSCQt3K9iu0B9zU2D0a?= =?us-ascii?q?dgifxCCdNT/+9JUhs9NZPE1Ox6FdbyVhvafteTVFmqW8+pATU1Tt8qzd8OeV?= =?us-ascii?q?hyFMu5gRDYwiWmGbgVl6aEBJYs6KLTw2DxJ9phy3bBzKQhlEMmTddWOWK6ga?= =?us-ascii?q?5/8g3TB4/Vk0WFiamqb78c0TXD9GeZ02WBolpXUBVtXqnfWnAffETWp8zj5k?= =?us-ascii?q?zeV7+uFagnMgxZxMGeNKRKb8bkjVtcRPj9JtvReHmxlHqqCRaP3LOMY9miR2?= =?us-ascii?q?JI9yLbEkEI2yUe7HucfVw1CyKJjXjTARZVORToeUy6taFisnqgXGca1QyHRX?= =?us-ascii?q?ZNkb2v9VpdiPmVUO8e9pwetSoLkBkyG0yyjPzMDN/Vm+1lNI5bZsgw5V5Bzi?= =?us-ascii?q?qNqw1/OrSONa1vrGUyNQNtsBW9hF1MFoxcnJ1y/zsRxw1oJPfA3Q=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2BOAQCBWbFf/wSs8lFiGwEBAQEBAQE?= =?us-ascii?q?BBQEBARIBAQEDAwEBAUAHgUgCgxxVAUkXjUGGCIIWiG+CJpEYCwEBAQEBAQE?= =?us-ascii?q?BASwMBAEBhEoCgh0mOBMCAwEBAQMCBQEBBgEBAQEBAQUEAYYYOQxDAQwBgWY?= =?us-ascii?q?igxoBBTo/EAsOBgQuVwYBEoMngwoLrHGBNIQ+AQsBgQyDYIEBBoE4AYkshC6?= =?us-ascii?q?CAIEQAYMSPoQ+hXYEmymBGptrgneJD5F3MaF5hguNR4p9kRWGVIF6TTAIgyR?= =?us-ascii?q?QGQ2XJIVFQAMwNwIGCgEBAwmDWopuAQE?= X-IPAS-Result: =?us-ascii?q?A2BOAQCBWbFf/wSs8lFiGwEBAQEBAQEBBQEBARIBAQEDA?= =?us-ascii?q?wEBAUAHgUgCgxxVAUkXjUGGCIIWiG+CJpEYCwEBAQEBAQEBASwMBAEBhEoCg?= =?us-ascii?q?h0mOBMCAwEBAQMCBQEBBgEBAQEBAQUEAYYYOQxDAQwBgWYigxoBBTo/EAsOB?= =?us-ascii?q?gQuVwYBEoMngwoLrHGBNIQ+AQsBgQyDYIEBBoE4AYkshC6CAIEQAYMSPoQ+h?= =?us-ascii?q?XYEmymBGptrgneJD5F3MaF5hguNR4p9kRWGVIF6TTAIgyRQGQ2XJIVFQAMwN?= =?us-ascii?q?wIGCgEBAwmDWopuAQE?= Received: from 4.172-242-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.242.172.4]) by relay.skynet.be with ESMTP; 15 Nov 2020 17:42:10 +0100 Received: from localhost (localhost [127.0.0.1]) by kalimero.tijl.coosemans.org (8.16.1/8.16.1) with ESMTP id 0AFGgASC001529; Sun, 15 Nov 2020 17:42:10 +0100 (CET) (envelope-from tijl@FreeBSD.org) Date: Sun, 15 Nov 2020 17:42:09 +0100 From: =?UTF-8?B?VMSzbA==?= Coosemans To: Conrad Meyer , trasz@FreeBSD.org, emaste@FreeBSD.org Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r367433 - in head/sys: compat/linux conf Message-ID: <20201115174209.43449ddd@FreeBSD.org> In-Reply-To: <202011062204.0A6M4vJT099797@repo.freebsd.org> References: <202011062204.0A6M4vJT099797@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4CYyfY1bmnz4YWR X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; ASN(0.00)[asn:5432, ipnet:195.238.0.0/19, country:BE]; local_wl_from(0.00)[freebsd.org] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 16:42:14 -0000 On Fri, 6 Nov 2020 22:04:57 +0000 (UTC) Conrad Meyer wrote: > Author: cem > Date: Fri Nov 6 22:04:57 2020 > New Revision: 367433 > URL: https://svnweb.freebsd.org/changeset/base/367433 > > Log: > linux(4): Fix loadable modules after r367395 > > Move dtrace SDT definitions into linux_common module code. Also, build > linux_dummy.c into the linux_common kld -- we don't need separate > versions of these stubs for 32- and 64-bit emulation. > > Reported by: several > PR: 250897 > Discussed with: emaste, trasz > Tested by: John Kennedy, Yasuhiro KIMURA, Oleg Sidorkin > X-MFC-With: r367395 > Differential Revision: https://reviews.freebsd.org/D27124 > > Modified: > head/sys/compat/linux/linux_common.c > head/sys/compat/linux/linux_dummy.c > head/sys/compat/linux/linux_misc.c > head/sys/conf/files.i386 > > Modified: head/sys/compat/linux/linux_common.c > ============================================================================== > --- head/sys/compat/linux/linux_common.c Fri Nov 6 21:33:59 2020 (r367432) > +++ head/sys/compat/linux/linux_common.c Fri Nov 6 22:04:57 2020 (r367433) > @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); > #include > > #include > +#include > #include > #include > #include > @@ -48,6 +49,20 @@ FEATURE(linuxulator_v4l, "V4L ioctl wrapper support in > FEATURE(linuxulator_v4l2, "V4L2 ioctl wrapper support in the linuxulator"); > > MODULE_VERSION(linux_common, 1); > + > +/** > + * Special DTrace provider for the linuxulator. > + * > + * In this file we define the provider for the entire linuxulator. All > + * modules (= files of the linuxulator) use it. > + * > + * We define a different name depending on the emulated bitsize, see > + * ../..//linux{,32}/linux.h, e.g.: > + * native bitsize = linuxulator > + * amd64, 32bit emulation = linuxulator32 > + */ > +LIN_SDT_PROVIDER_DEFINE(linuxulator); > +LIN_SDT_PROVIDER_DEFINE(linuxulator32); > > SET_DECLARE(linux_device_handler_set, struct linux_device_handler); > > > Modified: head/sys/compat/linux/linux_dummy.c > ============================================================================== > --- head/sys/compat/linux/linux_dummy.c Fri Nov 6 21:33:59 2020 (r367432) > +++ head/sys/compat/linux/linux_dummy.c Fri Nov 6 22:04:57 2020 (r367433) > @@ -29,21 +29,19 @@ > #include > __FBSDID("$FreeBSD$"); > > -#include "opt_compat.h" > - > #include > #include > #include > #include > #include > > -#ifdef COMPAT_LINUX32 > -#include > -#include > -#else > +/* > + * Including linux vs linux32 here is arbitrary -- the syscall args structures > + * (proto.h) are not dereferenced by the DUMMY stub implementations, and > + * suitable for use by both native and compat32 entrypoints. > + */ > #include > #include > -#endif > > #include > #include > > Modified: head/sys/compat/linux/linux_misc.c > ============================================================================== > --- head/sys/compat/linux/linux_misc.c Fri Nov 6 21:33:59 2020 (r367432) > +++ head/sys/compat/linux/linux_misc.c Fri Nov 6 22:04:57 2020 (r367433) > @@ -99,19 +99,6 @@ __FBSDID("$FreeBSD$"); > #include > #include > > -/** > - * Special DTrace provider for the linuxulator. > - * > - * In this file we define the provider for the entire linuxulator. All > - * modules (= files of the linuxulator) use it. > - * > - * We define a different name depending on the emulated bitsize, see > - * ../..//linux{,32}/linux.h, e.g.: > - * native bitsize = linuxulator > - * amd64, 32bit emulation = linuxulator32 > - */ > -LIN_SDT_PROVIDER_DEFINE(LINUX_DTRACE); > - > int stclohz; /* Statistics clock frequency */ > > static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = { > > Modified: head/sys/conf/files.i386 > ============================================================================== > --- head/sys/conf/files.i386 Fri Nov 6 21:33:59 2020 (r367432) > +++ head/sys/conf/files.i386 Fri Nov 6 22:04:57 2020 (r367433) > @@ -52,6 +52,7 @@ cddl/dev/dtrace/i386/dtrace_asm.S optional dtrace co > cddl/dev/dtrace/i386/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" > compat/linprocfs/linprocfs.c optional linprocfs > compat/linsysfs/linsysfs.c optional linsysfs > +compat/linux/linux_common.c optional compat_linux > compat/linux/linux_dummy.c optional compat_linux > compat/linux/linux_event.c optional compat_linux > compat/linux/linux_emul.c optional compat_linux linux_common.c defines the linux_common module which contains stuff that is common between 64 bit and 32 bit linux on amd64, but there's no such module on i386, which is why the file wasn't in files.i386. You should put LIN_SDT_PROVIDER_DEFINE in a file that is in modules/linux/Makefile for i386 but modules/linux_common/Makefile for amd64, like linux_util.c. From owner-svn-src-all@freebsd.org Sun Nov 15 18:12:33 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C43A3462131; Sun, 15 Nov 2020 18:12:33 +0000 (UTC) (envelope-from bdragon@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ0fm0F93z4s4r; Sun, 15 Nov 2020 18:12:31 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com [66.111.4.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bdragon/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id B707829A15; Sun, 15 Nov 2020 18:12:28 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 7ABF627C0054; Sun, 15 Nov 2020 13:12:26 -0500 (EST) Received: from imap1 ([10.202.2.51]) by compute3.internal (MEProxy); Sun, 15 Nov 2020 13:12:26 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculddutddmnecujfgurhepofgfggfkjghffffhvffutgesthdtredt reerjeenucfhrhhomhepfdeurhgrnhguohhnuceuvghrghhrvghnfdcuoegsughrrghgoh hnsefhrhgvvgeuufffrdhorhhgqeenucggtffrrghtthgvrhhnpeejhfeftddutdelgeek gedtgeejkeffvdejtddthefggfevuefggfefledvgefhgfenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsughrrghgohhnodhmvghsmhhtphgr uhhthhhpvghrshhonhgrlhhithihqddutdegvdefheekieegqddukedutdekheduqdgsug hrrghgohhnpeephfhrvggvuefuffdrohhrghesihhmrghprdgttg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1EEC5C200A5; Sun, 15 Nov 2020 13:12:26 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-570-gba0a262-fm-20201106.001-gba0a2623 Mime-Version: 1.0 Message-Id: In-Reply-To: <202011141801.0AEI1FCM000287@repo.freebsd.org> References: <202011141801.0AEI1FCM000287@repo.freebsd.org> Date: Sun, 15 Nov 2020 12:12:05 -0600 From: "Brandon Bergren" To: "Scott Long" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: =?UTF-8?Q?Re:_svn_commit:_r367687_-_in_head:_sbin/nvmecontrol_usr.sbin/m?= =?UTF-8?Q?ailwrapper_usr.sbin/pkg?= Content-Type: text/plain X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 18:12:34 -0000 > --- head/usr.sbin/pkg/pkg.c Sat Nov 14 17:57:50 2020 (r367686) > +++ head/usr.sbin/pkg/pkg.c Sat Nov 14 18:01:14 2020 (r367687) > @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -1037,6 +1038,7 @@ main(int argc, char *argv[]) > { > char pkgpath[MAXPATHLEN]; > const char *pkgarg; > + size_t len; > int i; > bool bootstrap_only, force, yes; > > @@ -1045,8 +1047,11 @@ main(int argc, char *argv[]) > pkgarg = NULL; > yes = false; > > - snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", > - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); > + if ((len = getlocalbase(pkgpath, MAXPATHLEN)) != 0) { > + fprintf(stderr, "Cannot determine local path\n"); > + exit(EXIT_FAILURE); > + } This logic is broken, it is failing on kernels that DO have user.localbase. > + strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN - len); > > if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { > bootstrap_only = true; > -- Brandon Bergren bdragon@FreeBSD.org From owner-svn-src-all@freebsd.org Sun Nov 15 18:16:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E786346290C; Sun, 15 Nov 2020 18:16:37 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ0lT0KC8z3Bm1; Sun, 15 Nov 2020 18:16:35 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 2FA4AE95; Sun, 15 Nov 2020 13:16:30 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 15 Nov 2020 13:16:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=s rm+4IR36vGlhvcQu6VeicD75CHP1neNn2HFw4D9aoQ=; b=NWj8AdSHUR2ZIMNlc JU3Z1sjGO2pRbm+dSsp28k2eCYsObY/WoavbTF1+PSY2kTiarbm0hsLTsfDtqirn tD3hHLegMcDkOYHTynemGuRiU1E3dB0BlbyEuwspCnqkw73keLzelea3ZzHT3KRZ xxFsjLvnprCDAod0CcGT7wdkR8NWtN56Mv9+tsvhCVfxC22EWRhuH2tfFi2a1Bab enOYAvymVfG7H2BJtEcD7/gDQW1Tj17byf5bzOM7HVroKgC3IV4n15WcvuZHRU2J V3pOGlP614NxqR4EOD1NzRc4+uAJxN1IsfPO1CwSh77Fm1ed/IvTGOdQVgpT4e/q nQYFA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=srm+4IR36vGlhvcQu6VeicD75CHP1neNn2HFw4D9a oQ=; b=iZyLz/upCi1c10XDBn1Uoj8HdZ+KuKUOZuwKEQI8Az28GjwKosQlrMX9N XSPdIxqgZ9DxbGOQEGppqYaQ4c96vCTad35JtzI0ALV6jAJJatoicsuvIIx+MauC 7YiZIR8cbt8SYT6YITffVC0kcn+zgFPy0i2sHVv7qc02+xKxtOvvNwtsjz70bA+w Mv1FRl7xonhbO81+Ig4s/TxL5NXTJlZKh3Nzn1G/VIo6qTX1lMObdTvj/mjoXR4+ qO4AmFUPhiU6B6vat9mZl2J9oGOupZA/zE6HnSB5KLpAuSaqv13Ezuv3JuIkPJ6k 2XEZ5N4x6UKgVnFtKRHqeR7vEp6Dg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledguddugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuufhorhhtvgguuchrvggtihhpshculdegtddmne cujfgurheptggguffhjgffgffkfhfvofesthejmhdthhdtvdenucfhrhhomhepufgtohht thcunfhonhhguceoshgtohhtthhlsehsrghmshgtohdrohhrgheqnecuggftrfgrthhtvg hrnhepffdvhfetfeehteekgefgtdelhfefieduleelteegvdfhueehfeegudegudffheeh necukfhppeekrdegiedrkeelrddvudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepshgtohhtthhlsehsrghmshgtohdrohhrgh X-ME-Proxy: Received: from [192.168.0.114] (unknown [8.46.89.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 3A6CD328005A; Sun, 15 Nov 2020 13:16:29 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367687 - in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg From: Scott Long In-Reply-To: Date: Sun, 15 Nov 2020 11:16:28 -0700 Cc: Scott Long , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: References: <202011141801.0AEI1FCM000287@repo.freebsd.org> To: Brandon Bergren X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ0lT0KC8z3Bm1 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 18:16:38 -0000 I fixed this in r367702, sorry for the breakage. Scott > On Nov 15, 2020, at 11:12 AM, Brandon Bergren wrote: > >> --- head/usr.sbin/pkg/pkg.c Sat Nov 14 17:57:50 2020 (r367686) >> +++ head/usr.sbin/pkg/pkg.c Sat Nov 14 18:01:14 2020 (r367687) >> @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -1037,6 +1038,7 @@ main(int argc, char *argv[]) >> { >> char pkgpath[MAXPATHLEN]; >> const char *pkgarg; >> + size_t len; >> int i; >> bool bootstrap_only, force, yes; >> >> @@ -1045,8 +1047,11 @@ main(int argc, char *argv[]) >> pkgarg = NULL; >> yes = false; >> >> - snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", >> - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); >> + if ((len = getlocalbase(pkgpath, MAXPATHLEN)) != 0) { >> + fprintf(stderr, "Cannot determine local path\n"); >> + exit(EXIT_FAILURE); >> + } > > This logic is broken, it is failing on kernels that DO have user.localbase. > >> + strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN - len); >> >> if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { >> bootstrap_only = true; >> > > -- > Brandon Bergren > bdragon@FreeBSD.org From owner-svn-src-all@freebsd.org Sun Nov 15 18:32:03 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1706463B55 for ; Sun, 15 Nov 2020 18:32:03 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ15H42Kkz3F8r for ; Sun, 15 Nov 2020 18:32:03 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f41.google.com with SMTP id h2so21816891wmm.0 for ; Sun, 15 Nov 2020 10:32:03 -0800 (PST) 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=XWvLvKZg0VA868mq218JtfPiGHbyzwuV7k8i+tTJ+/o=; b=Oo+Z7UlT6psBmeVbiVezvfAGFwfVv7ZNWm911MKh/ZoG9F3X8MCsigGmcfF+aca9/2 7mISM+6u9jf9ndZcF+yPBG2/Z91tDhojHjaTuK6m9qKWjQcIf5vghTPsdaN3r3oVardU YhAFMfODQjVz2Nuxk8RvZXP5POm3EaQyWlqIPITQZrdvSdPMnKYwFEIfxlxtbfjD5Ls4 epPh7gY6MiHMpZxRg3jUI9hp2m9mRpr1q3SQnzfKKsFt6hro5EHHtuFCJUOTRr5FxODw hdsvyUwRmdatzvn0oPVp4EKWgUgQMrjse6R8AMzf4Y6WcXJ6E13Dl06ri7pSSfw84zdr 0Yjw== X-Gm-Message-State: AOAM533dFerovSoZ7cgibRTTKwncJ9IuC2caH0KXpDD51W9SRAjIU2lM uYHh83y0ucpcQa775AsqiiyxbQ== X-Google-Smtp-Source: ABdhPJx+zhTO/PdA7wpUPFD0t9y5Pmmme3Wq5oGZnTf7kd4kLFV4XhN2H+NH1IHhvgrRDgLrTDwTkQ== X-Received: by 2002:a7b:c458:: with SMTP id l24mr11322094wmi.136.1605465121604; Sun, 15 Nov 2020 10:32:01 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id u5sm16181839wml.13.2020.11.15.10.32.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Nov 2020 10:32:00 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Jessica Clarke In-Reply-To: <202011150748.0AF7mqW3016900@repo.freebsd.org> Date: Sun, 15 Nov 2020 18:31:59 +0000 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011150748.0AF7mqW3016900@repo.freebsd.org> To: Scott Long X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ15H42Kkz3F8r X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 18:32:03 -0000 Hi Scott, I'm concerned by this diff; see my comments below. > On 15 Nov 2020, at 07:48, Scott Long wrote: >=20 > Author: scottl > Date: Sun Nov 15 07:48:52 2020 > New Revision: 367701 > URL: https://svnweb.freebsd.org/changeset/base/367701 >=20 > Log: > Because getlocalbase() returns -1 on error, it needs to use a signed = type > internally. Do that, and make sure that conversations between signed = and > unsigned don't overflow >=20 > Modified: > head/lib/libutil/getlocalbase.c >=20 > Modified: head/lib/libutil/getlocalbase.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/lib/libutil/getlocalbase.c Sun Nov 15 01:54:44 2020 = (r367700) > +++ head/lib/libutil/getlocalbase.c Sun Nov 15 07:48:52 2020 = (r367701) > @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); > ssize_t > getlocalbase(char *path, size_t pathlen) > { > - size_t tmplen; > + ssize_t tmplen; > const char *tmppath; >=20 > if ((pathlen =3D=3D 0) || (path =3D=3D NULL)) { > @@ -49,13 +49,20 @@ getlocalbase(char *path, size_t pathlen) > return (-1); > } >=20 > + /* It's unlikely that the buffer would be this big */ > + if (pathlen > SSIZE_MAX) { > + errno =3D ENOMEM; > + return (-1); > + } > + > tmppath =3D NULL; > - tmplen =3D pathlen; > + tmplen =3D (size_t)pathlen; > if (issetugid() =3D=3D 0) > tmppath =3D getenv("LOCALBASE"); >=20 > if ((tmppath =3D=3D NULL) && > - (sysctlbyname("user.localbase", path, &tmplen, NULL, 0) =3D=3D= 0)) { > + (sysctlbyname("user.localbase", path, (size_t *)&tmplen, = NULL, This is dangerous and generally a sign of something wrong. > + 0) =3D=3D 0)) { > return (tmplen); > } >=20 > @@ -67,13 +74,13 @@ getlocalbase(char *path, size_t pathlen) > #endif >=20 > tmplen =3D strlcpy(path, tmppath, pathlen); > - if ((tmplen < 0) || (tmplen >=3D pathlen)) { > + if ((tmplen < 0) || (tmplen >=3D (ssize_t)pathlen)) { As I commented on the previous commit (but which you do not appear to have picked up on), the LHS is impossible. Of course, now the types have changed so the compiler doesn't know that. I think tmplen should have remained a size_t, as everywhere it's used you're having to cast, which is generally a sign you've done something wrong. Only when you come to return from the function do you need a single cast to ssize_t (provided you've checked for overflow first). I strongly believe this entire commit should be reverted, and whatever bug you were trying to fixed be fixed in another way without using the wrong types and adding an array of unnecessary and/or dangerous casts. Jess From owner-svn-src-all@freebsd.org Sun Nov 15 18:46:38 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F20C446414B; Sun, 15 Nov 2020 18:46:38 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ1Q65npkz3G5F; Sun, 15 Nov 2020 18:46:38 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 3D975D3D; Sun, 15 Nov 2020 13:46:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 15 Nov 2020 13:46:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=v +KQUI76kLBZ2DxWgzRrqAsg3oDGrYCIrdO9xCASbeE=; b=Rwwjwm5ScTXqVzqor 41WhbAGVR+Jurpw1tVYGc5jg0BQ4wFe9S0koNws4GO0K+HGHoB3Sr8/dXsskisX8 VhX9eftOVNHsyfUZk4KlidU9udMiqxR2KCJhnLyScfdKa1LhBffwILVzw9F40p6v YOdq+cAhAocjFXy6MHyfKsnfYk7H2rxGDJGxwKi97ezJHUY5Q28nmOv6rldKuOZb EPNmWj+VsDXhfTLY6dsAUuZXG4cPz3P3nreJnEQWmovNibbkzC0aAL/frGp9JR4f 7Zb2iPADNFK7fbAxUWi2bAsZxGBmZWPvUsNDmYju6NFu6mEZzLZ+FEXZz0v0Rpxq U7Q7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=v+KQUI76kLBZ2DxWgzRrqAsg3oDGrYCIrdO9xCASb eE=; b=DT/+ag9jXoNA/YQiNIU30d2eqt+avePi0/ytG8y6MszUg6JjoMUbnEkFE dbVnfKM8AtRQslmB8I2+aVKVQh73mkZnwSDg+SLGvxMmH8YLJkN5Hws1hXtuVdYJ OLtr49Un07fqsThHAxhRdF60yDeX4AkVStPliZBexKN1HXCpcMtctlZO1IWdoOBa EKmYyBVffePlVcXRmtAiitvgOODQZm67vMcCNKX1b0RtCG97wpxN1WLRYSzLB4cr S7ui7RYHKoPBdzZSvqvU0EtVpeR9WPjikMWg8gu/RPa9jFX7OzYdqkaMxVp3jpaa wDq7zcdwWDevWPm0+5NEjXCbzUAbg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuufhorhhtvgguuchrvggtihhpshculdegtddmne cujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtjeenucfhrhhomhepufgtohht thcunfhonhhguceoshgtohhtthhlsehsrghmshgtohdrohhrgheqnecuggftrfgrthhtvg hrnhepudduveekheehiedukeekleelvedufeevfeetudfgtdffteffleehheffueffgfeh necuffhomhgrihhnpehfrhgvvggsshgurdhorhhgnecukfhppeekrdegiedrkeelrddvud efnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgt ohhtthhlsehsrghmshgtohdrohhrgh X-ME-Proxy: Received: from [192.168.0.114] (unknown [8.46.89.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 53AC63064AA7; Sun, 15 Nov 2020 13:46:36 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Scott Long In-Reply-To: Date: Sun, 15 Nov 2020 11:46:35 -0700 Cc: Scott Long , src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011150748.0AF7mqW3016900@repo.freebsd.org> To: Jessica Clarke X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ1Q65npkz3G5F X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 18:46:39 -0000 > On Nov 15, 2020, at 11:31 AM, Jessica Clarke = wrote: >=20 > Hi Scott, > I'm concerned by this diff; see my comments below. >=20 >> On 15 Nov 2020, at 07:48, Scott Long wrote: >>=20 >> Author: scottl >> Date: Sun Nov 15 07:48:52 2020 >> New Revision: 367701 >> URL: https://svnweb.freebsd.org/changeset/base/367701 >>=20 >> Log: >> Because getlocalbase() returns -1 on error, it needs to use a signed = type >> internally. Do that, and make sure that conversations between signed = and >> unsigned don't overflow >>=20 >> Modified: >> head/lib/libutil/getlocalbase.c >>=20 >> Modified: head/lib/libutil/getlocalbase.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/lib/libutil/getlocalbase.c Sun Nov 15 01:54:44 2020 = (r367700) >> +++ head/lib/libutil/getlocalbase.c Sun Nov 15 07:48:52 2020 = (r367701) >> @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); >> ssize_t >> getlocalbase(char *path, size_t pathlen) >> { >> - size_t tmplen; >> + ssize_t tmplen; >> const char *tmppath; >>=20 >> if ((pathlen =3D=3D 0) || (path =3D=3D NULL)) { >> @@ -49,13 +49,20 @@ getlocalbase(char *path, size_t pathlen) >> return (-1); >> } >>=20 >> + /* It's unlikely that the buffer would be this big */ >> + if (pathlen > SSIZE_MAX) { >> + errno =3D ENOMEM; >> + return (-1); >> + } >> + >> tmppath =3D NULL; >> - tmplen =3D pathlen; >> + tmplen =3D (size_t)pathlen; >> if (issetugid() =3D=3D 0) >> tmppath =3D getenv("LOCALBASE"); >>=20 >> if ((tmppath =3D=3D NULL) && >> - (sysctlbyname("user.localbase", path, &tmplen, NULL, 0) =3D=3D= 0)) { >> + (sysctlbyname("user.localbase", path, (size_t *)&tmplen, = NULL, >=20 > This is dangerous and generally a sign of something wrong. I think that the danger was mitigated by the overflow check above, but I agree that this is generally a poor pattern. >=20 >> + 0) =3D=3D 0)) { >> return (tmplen); >> } >>=20 >> @@ -67,13 +74,13 @@ getlocalbase(char *path, size_t pathlen) >> #endif >>=20 >> tmplen =3D strlcpy(path, tmppath, pathlen); >> - if ((tmplen < 0) || (tmplen >=3D pathlen)) { >> + if ((tmplen < 0) || (tmplen >=3D (ssize_t)pathlen)) { >=20 > As I commented on the previous commit (but which you do not appear to > have picked up on), the LHS is impossible. Of course, now the types > have changed so the compiler doesn't know that. >=20 The man page for strlcpy() made reference to the return value being equivalent to what snprintf() does. The man page for snprintf() states that negatve return values are possible, so I assumed the same was true for strlcpy(). However, now that I=E2=80=99ve looked at the = implementation of strlcpy(), I see that you=E2=80=99re correct. The man pages are = definitely confusing, and this isn=E2=80=99t the only place where I think there=E2=80= =99s inconsistency in the documentation, or at least poor wording choices. > I think tmplen should have remained a size_t, as everywhere it's used > you're having to cast, which is generally a sign you've done something > wrong. Only when you come to return from the function do you need a > single cast to ssize_t (provided you've checked for overflow first). I > strongly believe this entire commit should be reverted, and whatever > bug you were trying to fixed be fixed in another way without using the > wrong types and adding an array of unnecessary and/or dangerous casts. >=20 I felt similar concerns, but my misunderstanding of strlcpy() drove the result. Since the use case for getlocalbase() lends itself to also use strlcat()/strlcpy(), I was trying to replicate the API semantics of = those, at least to the limit of my understanding. Thanks for the feedback, = I=E2=80=99ll look at it some more. Scott From owner-svn-src-all@freebsd.org Sun Nov 15 19:01:04 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDBCC464D72 for ; Sun, 15 Nov 2020 19:01:04 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 4CZ1km5Lksz3H6M for ; Sun, 15 Nov 2020 19:01:04 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f48.google.com with SMTP id 10so21858517wml.2 for ; Sun, 15 Nov 2020 11:01:04 -0800 (PST) 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=l/scEbOq+GqM12vTmPSGPdm/L9AXpYo3gXsCXew+KvI=; b=Wr29mdgkMCgGvz8qyb/1gFkY+fs0xlyGPSBfZnpJsO0dSdlG9P8GkcMY/VW9B9KSqw QLCnOCL0sb0TiPEUXZSrYh/Hj+E18gn9SRPqn6QB5Ohd0TmICT1yfUkVaFi4ZiOseQJ/ gBVkBeohTaGmyLR12SUvZ1oqlIo4QQhhF4ccbw3JLWNRMF55KCsmQaS9EOgcFiT2hVl/ Tl/LRs4cM/hj4c8NiH+lUUHVOsfWrAgaQpilkIUTmmIWlpIZ4vTtZTUHwu/sT97rDDMN b2jo0AVAdjEiwfhzu2IwbNYG4riKRcb9P1PY1w6K6r0eUj7rPkJhTAqlZ70tFcebos/+ RVrg== X-Gm-Message-State: AOAM533xPfTF/vLfOHXiK/OdMJuIGva3qRs6g8uITEG8N2IjzrrZKfUo /95bXvPDeWc+I7aLWFZRIkO6ig== X-Google-Smtp-Source: ABdhPJxJyGOZgRnGm/p/qBVVZrLgPtqftI+VPxDW3zEFt05VKmxvKaljz+faAij+KZ7ZmvGgPqkHMA== X-Received: by 2002:a1c:a185:: with SMTP id k127mr11727518wme.23.1605466863257; Sun, 15 Nov 2020 11:01:03 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id n9sm16968667wmd.4.2020.11.15.11.01.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Nov 2020 11:01:02 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Jessica Clarke In-Reply-To: Date: Sun, 15 Nov 2020 19:01:01 +0000 Cc: Scott Long , src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: quoted-printable Message-Id: <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> References: <202011150748.0AF7mqW3016900@repo.freebsd.org> To: Scott Long X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ1km5Lksz3H6M X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:01:04 -0000 On 15 Nov 2020, at 18:46, Scott Long wrote: >> On Nov 15, 2020, at 11:31 AM, Jessica Clarke = wrote: >>=20 >> Hi Scott, >> I'm concerned by this diff; see my comments below. >>=20 >>> On 15 Nov 2020, at 07:48, Scott Long wrote: >>>=20 >>> Author: scottl >>> Date: Sun Nov 15 07:48:52 2020 >>> New Revision: 367701 >>> URL: https://svnweb.freebsd.org/changeset/base/367701 >>>=20 >>> Log: >>> Because getlocalbase() returns -1 on error, it needs to use a signed = type >>> internally. Do that, and make sure that conversations between = signed and >>> unsigned don't overflow >>>=20 >>> Modified: >>> head/lib/libutil/getlocalbase.c >>>=20 >>> Modified: head/lib/libutil/getlocalbase.c >>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>> --- head/lib/libutil/getlocalbase.c Sun Nov 15 01:54:44 2020 = (r367700) >>> +++ head/lib/libutil/getlocalbase.c Sun Nov 15 07:48:52 2020 = (r367701) >>> @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); >>> ssize_t >>> getlocalbase(char *path, size_t pathlen) >>> { >>> - size_t tmplen; >>> + ssize_t tmplen; >>> const char *tmppath; >>>=20 >>> if ((pathlen =3D=3D 0) || (path =3D=3D NULL)) { >>> @@ -49,13 +49,20 @@ getlocalbase(char *path, size_t pathlen) >>> return (-1); >>> } >>>=20 >>> + /* It's unlikely that the buffer would be this big */ >>> + if (pathlen > SSIZE_MAX) { >>> + errno =3D ENOMEM; >>> + return (-1); >>> + } >>> + >>> tmppath =3D NULL; >>> - tmplen =3D pathlen; >>> + tmplen =3D (size_t)pathlen; >>> if (issetugid() =3D=3D 0) >>> tmppath =3D getenv("LOCALBASE"); >>>=20 >>> if ((tmppath =3D=3D NULL) && >>> - (sysctlbyname("user.localbase", path, &tmplen, NULL, 0) =3D=3D= 0)) { >>> + (sysctlbyname("user.localbase", path, (size_t *)&tmplen, = NULL, >>=20 >> This is dangerous and generally a sign of something wrong. >=20 > I think that the danger was mitigated by the overflow check above, but = I > agree that this is generally a poor pattern. >=20 >>=20 >>> + 0) =3D=3D 0)) { >>> return (tmplen); >>> } >>>=20 >>> @@ -67,13 +74,13 @@ getlocalbase(char *path, size_t pathlen) >>> #endif >>>=20 >>> tmplen =3D strlcpy(path, tmppath, pathlen); >>> - if ((tmplen < 0) || (tmplen >=3D pathlen)) { >>> + if ((tmplen < 0) || (tmplen >=3D (ssize_t)pathlen)) { >>=20 >> As I commented on the previous commit (but which you do not appear to >> have picked up on), the LHS is impossible. Of course, now the types >> have changed so the compiler doesn't know that. >>=20 >=20 > The man page for strlcpy() made reference to the return value being > equivalent to what snprintf() does. The man page for snprintf() = states > that negatve return values are possible, so I assumed the same was > true for strlcpy(). However, now that I=E2=80=99ve looked at the = implementation > of strlcpy(), I see that you=E2=80=99re correct. The man pages are = definitely > confusing, and this isn=E2=80=99t the only place where I think = there=E2=80=99s > inconsistency in the documentation, or at least poor wording choices. >=20 >> I think tmplen should have remained a size_t, as everywhere it's used >> you're having to cast, which is generally a sign you've done = something >> wrong. Only when you come to return from the function do you need a >> single cast to ssize_t (provided you've checked for overflow first). = I >> strongly believe this entire commit should be reverted, and whatever >> bug you were trying to fixed be fixed in another way without using = the >> wrong types and adding an array of unnecessary and/or dangerous = casts. >>=20 >=20 > I felt similar concerns, but my misunderstanding of strlcpy() drove = the > result. Since the use case for getlocalbase() lends itself to also = use > strlcat()/strlcpy(), I was trying to replicate the API semantics of = those, > at least to the limit of my understanding. Thanks for the feedback, = I=E2=80=99ll > look at it some more. Thanks. ENOMEM also feels inappropriate as no allocation is taking place. Perhaps ENAMETOOLONG, which is used in similar cases for things like gethostbyname? Though sysctlbyname uses ENOMEM instead... sigh. Also, if pathlen has already been checked against SSIZE_MAX (giving EINVAL) and tmplen against pathlen there's no need to then check tmplen against SSIZE_MAX. I'd be happy to give a review on Phabricator if/when you have a new patch. Jess From owner-svn-src-all@freebsd.org Sun Nov 15 19:06:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 32152464E64; Sun, 15 Nov 2020 19:06:25 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ1rx0B94z3Hbd; Sun, 15 Nov 2020 19:06:24 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 7969ACAF; Sun, 15 Nov 2020 14:06:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 15 Nov 2020 14:06:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=5 VAFw7FqORNuQgPhtFHTtygZfwRHF+/0mGfWnQiUFjA=; b=wPhtz8uK/TKQ65bui +mjjxEv9ft+pwOLUCIRl+C0F4wRBo2NYRDJhtSX2hjfhGxf7deycCQUigcYm/9pT TmMWlEPe9qYA6obt4nFirFKKRCq100A2XO79VzA6h1o5FrfrLzbXkzPRx7eccNzc sXgKLayVYSmz0kW7ApS9ZmFftN4T4AO49ey6o1kLdNMHkm13PJGm3EBpVqKsFIfI gQPeRdFv5AK5PFGd7RSqh9gbnzHblvM/pTFv2+V9B76ejrMvL2WCXbJcasxpLWBj emO7U6xSh/gwZBjt9Qu/mckP5EhxmDxK9Zmf5erUOY7CpoU6xm7t+aF5uNq/1PwG 58rIw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=5VAFw7FqORNuQgPhtFHTtygZfwRHF+/0mGfWnQiUF jA=; b=Qca6O3bgGRd1d2xIOPl3igm+8GJdhgeb4nyrLqH4jA+y/PJKg1hS2I8hv Fquq6D6BsEJPSOZ/9oYfg9U4ZxFekwRwIt+aRRiFsuYHdTj50IXK8wUqHYvm8tUQ 5I/AfRCh2qsjktEJqjiTgdV53mKnYsYQvKxxMDB5OnHdMaurDsUY+s7ID4IOLsb+ gq1LwqH4M8AUZqb4e/nptOaphXUeV3Jk5vgKplGE1AFZRv6XwNbXqeTJs9pR5JiI 7iIh7rr9YY/SA2ddZZH9oMftlo4ZltfeItliEQ9UxJt8Aaq/FrZeTc5aFLdvIbNX Nab2YaL5UsbhzHx33tOHbH6rUK95Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuufhorhhtvgguuchrvggtihhpshculdegtddmne cujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtjeenucfhrhhomhepufgtohht thcunfhonhhguceoshgtohhtthhlsehsrghmshgtohdrohhrgheqnecuggftrfgrthhtvg hrnhepudduveekheehiedukeekleelvedufeevfeetudfgtdffteffleehheffueffgfeh necuffhomhgrihhnpehfrhgvvggsshgurdhorhhgnecukfhppeekrdegiedrkeelrddvud efnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgt ohhtthhlsehsrghmshgtohdrohhrgh X-ME-Proxy: Received: from [192.168.0.114] (unknown [8.46.89.213]) by mail.messagingengine.com (Postfix) with ESMTPA id A41C63064AA7; Sun, 15 Nov 2020 14:06:22 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Scott Long In-Reply-To: <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> Date: Sun, 15 Nov 2020 12:06:22 -0700 Cc: Scott Long , src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> To: Jessica Clarke X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ1rx0B94z3Hbd X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:06:25 -0000 > On Nov 15, 2020, at 12:01 PM, Jessica Clarke = wrote: >>=20 >> I felt similar concerns, but my misunderstanding of strlcpy() drove = the >> result. Since the use case for getlocalbase() lends itself to also = use >> strlcat()/strlcpy(), I was trying to replicate the API semantics of = those, >> at least to the limit of my understanding. Thanks for the feedback, = I=E2=80=99ll >> look at it some more. >=20 > Thanks. ENOMEM also feels inappropriate as no allocation is taking > place. Perhaps ENAMETOOLONG, which is used in similar cases for things > like gethostbyname? Though sysctlbyname uses ENOMEM instead... sigh. >=20 Yep, I wasn=E2=80=99t happy with ENOMEM either but I couldn=E2=80=99t = find anything better. > Also, if pathlen has already been checked against SSIZE_MAX (giving > EINVAL) and tmplen against pathlen there's no need to then check = tmplen > against SSIZE_MAX. >=20 Done. > I'd be happy to give a review on Phabricator if/when you have a new > patch. >=20 https://reviews.freebsd.org/D27227 Thanks, Scott From owner-svn-src-all@freebsd.org Sun Nov 15 19:10:40 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 17C574653A4; Sun, 15 Nov 2020 19:10:40 +0000 (UTC) (envelope-from bdragon@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ1xq70RKz3HvK; Sun, 15 Nov 2020 19:10:39 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com [66.111.4.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bdragon/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id D707F2A0DC; Sun, 15 Nov 2020 19:10:39 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id BA80927C0054; Sun, 15 Nov 2020 14:10:39 -0500 (EST) Received: from imap1 ([10.202.2.51]) by compute3.internal (MEProxy); Sun, 15 Nov 2020 14:10:39 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculddutddmnecujfgurhepofgfggfkjghffffhvffutgfgsehtqher tderreejnecuhfhrohhmpedfuehrrghnughonhcuuegvrhhgrhgvnhdfuceosggurhgrgh honheshfhrvggvuefuffdrohhrgheqnecuggftrfgrthhtvghrnhepieefgeeuveduffej teetjeejkeeftdetgffgieefgfetueegueekgeeutdduteejnecuffhomhgrihhnpehfrh gvvggsshgurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepsggurhgrghhonhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthi dquddtgedvfeehkeeigedqudekuddtkeehuddqsggurhgrghhonheppefhrhgvvgeuufff rdhorhhgsehimhgrphdrtggt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7EDAFC200A5; Sun, 15 Nov 2020 14:10:39 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-570-gba0a262-fm-20201106.001-gba0a2623 Mime-Version: 1.0 Message-Id: In-Reply-To: References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> Date: Sun, 15 Nov 2020 13:10:20 -0600 From: "Brandon Bergren" To: "Scott Long" , "Jessica Clarke" Cc: "Scott Long" , src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367701 - head/lib/libutil Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:10:40 -0000 On powerpc64 and powerpc64le, there is some really weird behavior happen= ing around the sysctl itself: root@crow:~ # pkg The package management tool is not yet installed on your system. Do you want to fetch and install it now? [y/N]: N root@crow:~ # sysctl user.localbase user.localbase: /usr/local root@crow:~ # pkg The package management tool is not yet installed on your system. Do you want to fetch and install it now? [y/N]: N root@crow:~ # sysctl user.localbase=3D/usr/local user.localbase: /usr/local -> /usr/local root@crow:~ # pkg pkg: not enough arguments Usage: pkg [-v] [-d] [-l] [-N] [-j |-c |-r= ] [-C ] [-R ] [-o var=3Dv= alue] [-4|-6] [] For more information on available commands and options see 'pkg help'. root@crow:~ #=20 I would double check very closely that the sysctl is being called correc= tly, the sysctl tool manages to read it out, but libutil does not. On Sun, Nov 15, 2020, at 1:06 PM, Scott Long wrote: >=20 > > On Nov 15, 2020, at 12:01 PM, Jessica Clarke wr= ote: > >>=20 > >> I felt similar concerns, but my misunderstanding of strlcpy() drove= the > >> result. Since the use case for getlocalbase() lends itself to also= use > >> strlcat()/strlcpy(), I was trying to replicate the API semantics of= those, > >> at least to the limit of my understanding. Thanks for the feedback= , I=E2=80=99ll > >> look at it some more. > >=20 > > Thanks. ENOMEM also feels inappropriate as no allocation is taking > > place. Perhaps ENAMETOOLONG, which is used in similar cases for thin= gs > > like gethostbyname? Though sysctlbyname uses ENOMEM instead... sigh.= > >=20 >=20 > Yep, I wasn=E2=80=99t happy with ENOMEM either but I couldn=E2=80=99t = find anything better. >=20 > > Also, if pathlen has already been checked against SSIZE_MAX (giving > > EINVAL) and tmplen against pathlen there's no need to then check tmp= len > > against SSIZE_MAX. > >=20 >=20 > Done. >=20 > > I'd be happy to give a review on Phabricator if/when you have a new > > patch. > >=20 >=20 > https://reviews.freebsd.org/D27227 >=20 > Thanks, > Scott >=20 > --=20 Brandon Bergren bdragon@FreeBSD.org From owner-svn-src-all@freebsd.org Sun Nov 15 19:26:03 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 585F5465F44 for ; Sun, 15 Nov 2020 19:26:03 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 4CZ2Hb1s8hz3Kjl for ; Sun, 15 Nov 2020 19:26:03 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f45.google.com with SMTP id h2so21928284wmm.0 for ; Sun, 15 Nov 2020 11:26:03 -0800 (PST) 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=CDK1bMDtYfutA3am4n4tQO/iDVAIp57hbj/GKZI31gw=; b=Yid27ir8yP9MbdMIAk9bGuvJJebKGFSul2zCd/QxSEpBXgdWufV3dA18x4aC+EdGD9 YztIk91Yzss6m5YwwA11ZvDzmO2V2Vz7FlOVX/qacsQyuVvany8hji8rV1cHEGsrBEfx WP/bld19EcpykmyC1tNssyI2POwP9XzDJj+nNROWdP70NEDR6ywxjaqIGzRuXXVZPuqV gLPTKx8mB8BMyhHSoEo6P7UryoaaeUSa9RT9P5tW7xickkUmbMAEHK3h3DS2y1spMTg3 nGvn6IGtc9QQdMlKXynUybFXMkixzQhDkkN4WR19N02+ZebXajyqFleHXl+3ur/XwGnw GfmQ== X-Gm-Message-State: AOAM532jU7+8ME938lVeimdkjIoVO3Utw5F3ELHHoz7PqSVrT2FK6e5F D/j2sMT/GbNQhASZiKvka7nTDQ== X-Google-Smtp-Source: ABdhPJwbKWomKOCbWgfmPbSqmOUEUkOaMUEjq4qN5QhFh5r8KqcBCXO0EyGWMfc3DvaZ/nNMzhkIgQ== X-Received: by 2002:a05:600c:255:: with SMTP id 21mr12194381wmj.69.1605468361960; Sun, 15 Nov 2020 11:26:01 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id q7sm21306922wrg.95.2020.11.15.11.26.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Nov 2020 11:26:01 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Jessica Clarke In-Reply-To: Date: Sun, 15 Nov 2020 19:26:00 +0000 Cc: Scott Long , Scott Long , src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: quoted-printable Message-Id: <44B80F15-2BE7-4B7C-BC3D-B65511480E58@freebsd.org> References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> To: Brandon Bergren X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ2Hb1s8hz3Kjl X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:26:03 -0000 On 15 Nov 2020, at 19:10, Brandon Bergren wrote: >=20 > On powerpc64 and powerpc64le, there is some really weird behavior = happening around the sysctl itself: >=20 > root@crow:~ # pkg > The package management tool is not yet installed on your system. > Do you want to fetch and install it now? [y/N]: N > root@crow:~ # sysctl user.localbase > user.localbase: /usr/local > root@crow:~ # pkg > The package management tool is not yet installed on your system. > Do you want to fetch and install it now? [y/N]: N > root@crow:~ # sysctl user.localbase=3D/usr/local > user.localbase: /usr/local -> /usr/local > root@crow:~ # pkg > pkg: not enough arguments > Usage: pkg [-v] [-d] [-l] [-N] [-j |-c |-r ] [-C ] [-R ] [-o = var=3Dvalue] [-4|-6] [] >=20 > For more information on available commands and options see 'pkg help'. > root@crow:~ #=20 >=20 >=20 > I would double check very closely that the sysctl is being called = correctly, the sysctl tool manages to read it out, but libutil does not. That's odd. What does truss say? Jess > On Sun, Nov 15, 2020, at 1:06 PM, Scott Long wrote: >>=20 >>> On Nov 15, 2020, at 12:01 PM, Jessica Clarke = wrote: >>>>=20 >>>> I felt similar concerns, but my misunderstanding of strlcpy() drove = the >>>> result. Since the use case for getlocalbase() lends itself to also = use >>>> strlcat()/strlcpy(), I was trying to replicate the API semantics of = those, >>>> at least to the limit of my understanding. Thanks for the = feedback, I=E2=80=99ll >>>> look at it some more. >>>=20 >>> Thanks. ENOMEM also feels inappropriate as no allocation is taking >>> place. Perhaps ENAMETOOLONG, which is used in similar cases for = things >>> like gethostbyname? Though sysctlbyname uses ENOMEM instead... sigh. >>>=20 >>=20 >> Yep, I wasn=E2=80=99t happy with ENOMEM either but I couldn=E2=80=99t = find anything better. >>=20 >>> Also, if pathlen has already been checked against SSIZE_MAX (giving >>> EINVAL) and tmplen against pathlen there's no need to then check = tmplen >>> against SSIZE_MAX. >>>=20 >>=20 >> Done. >>=20 >>> I'd be happy to give a review on Phabricator if/when you have a new >>> patch. >>>=20 >>=20 >> https://reviews.freebsd.org/D27227 >>=20 >> Thanks, >> Scott >>=20 >>=20 >=20 > --=20 > Brandon Bergren > bdragon@FreeBSD.org From owner-svn-src-all@freebsd.org Sun Nov 15 19:30:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B28A4663EE; Sun, 15 Nov 2020 19:30:55 +0000 (UTC) (envelope-from bdragon@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ2PC1LBRz3LPP; Sun, 15 Nov 2020 19:30:55 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com [66.111.4.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bdragon/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 1A58D2A1A5; Sun, 15 Nov 2020 19:30:55 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id C08C627C0054; Sun, 15 Nov 2020 14:30:54 -0500 (EST) Received: from imap1 ([10.202.2.51]) by compute3.internal (MEProxy); Sun, 15 Nov 2020 14:30:54 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculddutddmnecujfgurhepofgfggfkjghffffhvffutgfgsehtqher tderreejnecuhfhrohhmpedfuehrrghnughonhcuuegvrhhgrhgvnhdfuceosggurhgrgh honheshfhrvggvuefuffdrohhrgheqnecuggftrfgrthhtvghrnhepieefgeeuveduffej teetjeejkeeftdetgffgieefgfetueegueekgeeutdduteejnecuffhomhgrihhnpehfrh gvvggsshgurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepsggurhgrghhonhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthi dquddtgedvfeehkeeigedqudekuddtkeehuddqsggurhgrghhonheppefhrhgvvgeuufff rdhorhhgsehimhgrphdrtggt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 689E6C200A6; Sun, 15 Nov 2020 14:30:54 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-570-gba0a262-fm-20201106.001-gba0a2623 Mime-Version: 1.0 Message-Id: In-Reply-To: <44B80F15-2BE7-4B7C-BC3D-B65511480E58@freebsd.org> References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> <44B80F15-2BE7-4B7C-BC3D-B65511480E58@freebsd.org> Date: Sun, 15 Nov 2020 13:30:34 -0600 From: "Brandon Bergren" To: "Jessica Clarke" Cc: "Scott Long" , "Scott Long" , src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367701 - head/lib/libutil Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:30:55 -0000 I think the problem is that user.* is somehow magically namespaced, so d= oing a "dumb" sysctlbyname will get the wrong one. sysctl (the tool) does: __sysctl("sysctl.name2oid user.localbase",2,0xfffffbfffde98,0xfffffbfffd= a98,0x810809000,14) =3D 0 (0x0) __sysctl("sysctl.oidfmt user.localbase",4,0xfffffbfffdef8,0xfffffbfffd69= 0,0x0,0) =3D 0 (0x0) __sysctl("sysctl.name { 8.21 }",4,0xfffffbfffc8f8,0xfffffbfffc480,0x0,0)= =3D 0 (0x0) __sysctl("sysctl.oidfmt user.localbase",4,0xfffffbfffd0f8,0xfffffbfffc48= 8,0x0,0) =3D 0 (0x0) __sysctl("user.localbase",2,0x0,0xfffffbfffc480,0x0,0) =3D 0 (0x0) __sysctl("user.localbase",2,0x81080a000,0xfffffbfffd0f8,0x0,0) =3D 0 (0x= 0) and picks up /usr/local. whereas libutil is currently just doing __sysctlbyname("user.localbase",14,0xfffffbfffd4f8,0xfffffbfffd440,0x0,0= ) =3D 0 (0x0) which is returning the builtin "" from the static kernel variable. On Sun, Nov 15, 2020, at 1:26 PM, Jessica Clarke wrote: > On 15 Nov 2020, at 19:10, Brandon Bergren wrote:= > >=20 > > On powerpc64 and powerpc64le, there is some really weird behavior ha= ppening around the sysctl itself: > >=20 > > root@crow:~ # pkg > > The package management tool is not yet installed on your system. > > Do you want to fetch and install it now? [y/N]: N > > root@crow:~ # sysctl user.localbase > > user.localbase: /usr/local > > root@crow:~ # pkg > > The package management tool is not yet installed on your system. > > Do you want to fetch and install it now? [y/N]: N > > root@crow:~ # sysctl user.localbase=3D/usr/local > > user.localbase: /usr/local -> /usr/local > > root@crow:~ # pkg > > pkg: not enough arguments > > Usage: pkg [-v] [-d] [-l] [-N] [-j |-c |-r ] [-C ] [-R ] [-o var= =3Dvalue] [-4|-6] [] > >=20 > > For more information on available commands and options see 'pkg help= '. > > root@crow:~ #=20 > >=20 > >=20 > > I would double check very closely that the sysctl is being called co= rrectly, the sysctl tool manages to read it out, but libutil does not. >=20 > That's odd. What does truss say? >=20 > Jess >=20 > > On Sun, Nov 15, 2020, at 1:06 PM, Scott Long wrote: > >>=20 > >>> On Nov 15, 2020, at 12:01 PM, Jessica Clarke = wrote: > >>>>=20 > >>>> I felt similar concerns, but my misunderstanding of strlcpy() dro= ve the > >>>> result. Since the use case for getlocalbase() lends itself to al= so use > >>>> strlcat()/strlcpy(), I was trying to replicate the API semantics = of those, > >>>> at least to the limit of my understanding. Thanks for the feedba= ck, I=E2=80=99ll > >>>> look at it some more. > >>>=20 > >>> Thanks. ENOMEM also feels inappropriate as no allocation is taking= > >>> place. Perhaps ENAMETOOLONG, which is used in similar cases for th= ings > >>> like gethostbyname? Though sysctlbyname uses ENOMEM instead... sig= h. > >>>=20 > >>=20 > >> Yep, I wasn=E2=80=99t happy with ENOMEM either but I couldn=E2=80=99= t find anything better. > >>=20 > >>> Also, if pathlen has already been checked against SSIZE_MAX (givin= g > >>> EINVAL) and tmplen against pathlen there's no need to then check t= mplen > >>> against SSIZE_MAX. > >>>=20 > >>=20 > >> Done. > >>=20 > >>> I'd be happy to give a review on Phabricator if/when you have a ne= w > >>> patch. > >>>=20 > >>=20 > >> https://reviews.freebsd.org/D27227 > >>=20 > >> Thanks, > >> Scott > >>=20 > >>=20 > >=20 > > --=20 > > Brandon Bergren > > bdragon@FreeBSD.org >=20 > --=20 Brandon Bergren bdragon@FreeBSD.org From owner-svn-src-all@freebsd.org Sun Nov 15 19:34:16 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93A5346656E; Sun, 15 Nov 2020 19:34:16 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ2T42cQlz3Lwq; Sun, 15 Nov 2020 19:34:16 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 9E0F2B18; Sun, 15 Nov 2020 14:34:14 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 15 Nov 2020 14:34:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=v 2ZRpgfQPzO+P9OX4TNAsGHvCpvlWQArS5bESUFtnqg=; b=uiwirdxS56MPCGi4l cEANtY4zW5VKW9XK7iPP4ciaqGXlQvBUdsRLSnfS/uxkWlKv+n/Y1Pmv7UimCvXE fV4rQ0iya5WARxVMLEu1L0zvdXi5J2MKXk22XEEFbyp6iaHuXKQjKbjLfOniLvhy RQ0adf7ywyJsl6qjoX4l+hpVyTpwWPD9CeO8zoGebnOXplqQApnVg0ka8JtMJYS9 qHW9qUMDsr3grxeTKQDjphSWGEozTcWtXJk8q6cNgws333YJVRmW8coQRKFr2GOS hXFIUw3nwYGjACOQIAW4X64oSSKk9HNiwLGxihVMXB4ifexG7yQubTikTM/+3Je2 JDZbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=v2ZRpgfQPzO+P9OX4TNAsGHvCpvlWQArS5bESUFtn qg=; b=gCIbDhaKEPlfxdLB95VH6LT9RnlhX7uCkgjzfWuBkp44SeNZXyRzJ524p qwlSoJ2G2iRP+7GHctv/Ioq3jXk9JdISIfbYmMkw9xZOCfciJLz4otfTAwtsoJim gZd5eP2J3H1kA71X7V0uo86cufFftrfiIaiw3NxNqn8bKvCjfvNs2aULw6zMeJZh JlINObO3aOAXeA045dYDLqCikAFzrd2+HAJHQQ+HY7I6z8WxQr8Yu1bp1i+/L6jw c9Yc3eQupsFiL9oe4SnPHDwoEPp+GVXOJ6eZE7ODJBLMTxtIyjOSRnUAuQ30Uukj IG7roonf4POe2Nxf3/wRpbrwFQlnQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledgudeftdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuufhorhhtvgguuchrvggtihhpshculdegtddmne cujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtjeenucfhrhhomhepufgtohht thcunfhonhhguceoshgtohhtthhlsehsrghmshgtohdrohhrgheqnecuggftrfgrthhtvg hrnhepudduveekheehiedukeekleelvedufeevfeetudfgtdffteffleehheffueffgfeh necuffhomhgrihhnpehfrhgvvggsshgurdhorhhgnecukfhppeekrdegiedrkeelrddvud efnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgt ohhtthhlsehsrghmshgtohdrohhrgh X-ME-Proxy: Received: from [192.168.0.114] (unknown [8.46.89.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 9C0ED3280060; Sun, 15 Nov 2020 14:34:13 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Scott Long In-Reply-To: Date: Sun, 15 Nov 2020 12:34:13 -0700 Cc: Jessica Clarke , Scott Long , src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> <44B80F15-2BE7-4B7C-BC3D-B65511480E58@freebsd.org> To: Brandon Bergren X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ2T42cQlz3Lwq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:34:16 -0000 It is a magical namespace, in that it comes from libc, not from the = kernel. Please make sure that you=E2=80=99ve installed a more recent = libc, I guess? I just did a full build and install, and I=E2=80=99m = unable to replicate the problem. Maybe there=E2=80=99s a static-linked = pkg running around somewhere? I=E2=80=99m at a loss for better ideas. Scott > On Nov 15, 2020, at 12:30 PM, Brandon Bergren = wrote: >=20 > I think the problem is that user.* is somehow magically namespaced, so = doing a "dumb" sysctlbyname will get the wrong one. >=20 > sysctl (the tool) does: > __sysctl("sysctl.name2oid = user.localbase",2,0xfffffbfffde98,0xfffffbfffda98,0x810809000,14) =3D 0 = (0x0) > __sysctl("sysctl.oidfmt = user.localbase",4,0xfffffbfffdef8,0xfffffbfffd690,0x0,0) =3D 0 (0x0) > __sysctl("sysctl.name { 8.21 = }",4,0xfffffbfffc8f8,0xfffffbfffc480,0x0,0) =3D 0 (0x0) > __sysctl("sysctl.oidfmt = user.localbase",4,0xfffffbfffd0f8,0xfffffbfffc488,0x0,0) =3D 0 (0x0) > __sysctl("user.localbase",2,0x0,0xfffffbfffc480,0x0,0) =3D 0 (0x0) > __sysctl("user.localbase",2,0x81080a000,0xfffffbfffd0f8,0x0,0) =3D 0 = (0x0) >=20 > and picks up /usr/local. >=20 > whereas libutil is currently just doing > = __sysctlbyname("user.localbase",14,0xfffffbfffd4f8,0xfffffbfffd440,0x0,0) = =3D 0 (0x0) >=20 > which is returning the builtin "" from the static kernel variable. >=20 > On Sun, Nov 15, 2020, at 1:26 PM, Jessica Clarke wrote: >> On 15 Nov 2020, at 19:10, Brandon Bergren = wrote: >>>=20 >>> On powerpc64 and powerpc64le, there is some really weird behavior = happening around the sysctl itself: >>>=20 >>> root@crow:~ # pkg >>> The package management tool is not yet installed on your system. >>> Do you want to fetch and install it now? [y/N]: N >>> root@crow:~ # sysctl user.localbase >>> user.localbase: /usr/local >>> root@crow:~ # pkg >>> The package management tool is not yet installed on your system. >>> Do you want to fetch and install it now? [y/N]: N >>> root@crow:~ # sysctl user.localbase=3D/usr/local >>> user.localbase: /usr/local -> /usr/local >>> root@crow:~ # pkg >>> pkg: not enough arguments >>> Usage: pkg [-v] [-d] [-l] [-N] [-j |-c |-r ] [-C ] [-R ] [-o = var=3Dvalue] [-4|-6] [] >>>=20 >>> For more information on available commands and options see 'pkg = help'. >>> root@crow:~ #=20 >>>=20 >>>=20 >>> I would double check very closely that the sysctl is being called = correctly, the sysctl tool manages to read it out, but libutil does not. >>=20 >> That's odd. What does truss say? >>=20 >> Jess >>=20 >>> On Sun, Nov 15, 2020, at 1:06 PM, Scott Long wrote: >>>>=20 >>>>> On Nov 15, 2020, at 12:01 PM, Jessica Clarke = wrote: >>>>>>=20 >>>>>> I felt similar concerns, but my misunderstanding of strlcpy() = drove the >>>>>> result. Since the use case for getlocalbase() lends itself to = also use >>>>>> strlcat()/strlcpy(), I was trying to replicate the API semantics = of those, >>>>>> at least to the limit of my understanding. Thanks for the = feedback, I=E2=80=99ll >>>>>> look at it some more. >>>>>=20 >>>>> Thanks. ENOMEM also feels inappropriate as no allocation is taking >>>>> place. Perhaps ENAMETOOLONG, which is used in similar cases for = things >>>>> like gethostbyname? Though sysctlbyname uses ENOMEM instead... = sigh. >>>>>=20 >>>>=20 >>>> Yep, I wasn=E2=80=99t happy with ENOMEM either but I couldn=E2=80=99t= find anything better. >>>>=20 >>>>> Also, if pathlen has already been checked against SSIZE_MAX = (giving >>>>> EINVAL) and tmplen against pathlen there's no need to then check = tmplen >>>>> against SSIZE_MAX. >>>>>=20 >>>>=20 >>>> Done. >>>>=20 >>>>> I'd be happy to give a review on Phabricator if/when you have a = new >>>>> patch. >>>>>=20 >>>>=20 >>>> https://reviews.freebsd.org/D27227 >>>>=20 >>>> Thanks, >>>> Scott >>>>=20 >>>>=20 >>>=20 >>> --=20 >>> Brandon Bergren >>> bdragon@FreeBSD.org >>=20 >>=20 >=20 > --=20 > Brandon Bergren > bdragon@FreeBSD.org From owner-svn-src-all@freebsd.org Sun Nov 15 19:36:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1E7A346693F; Sun, 15 Nov 2020 19:36:22 +0000 (UTC) (envelope-from bdragon@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ2WV06WFz3LyR; Sun, 15 Nov 2020 19:36:22 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com [66.111.4.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bdragon/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id E4EBB2A428; Sun, 15 Nov 2020 19:36:21 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id BB32327C0054; Sun, 15 Nov 2020 14:36:21 -0500 (EST) Received: from imap1 ([10.202.2.51]) by compute3.internal (MEProxy); Sun, 15 Nov 2020 14:36:21 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledgudefudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculddutddmnecujfgurhepofgfggfkjghffffhvffutgfgsehtqher tderreejnecuhfhrohhmpedfuehrrghnughonhcuuegvrhhgrhgvnhdfuceosggurhgrgh honheshfhrvggvuefuffdrohhrgheqnecuggftrfgrthhtvghrnhepieefgeeuveduffej teetjeejkeeftdetgffgieefgfetueegueekgeeutdduteejnecuffhomhgrihhnpehfrh gvvggsshgurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepsggurhgrghhonhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthi dquddtgedvfeehkeeigedqudekuddtkeehuddqsggurhgrghhonheppefhrhgvvgeuufff rdhorhhgsehimhgrphdrtggt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 73FEBC200A5; Sun, 15 Nov 2020 14:36:21 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-570-gba0a262-fm-20201106.001-gba0a2623 Mime-Version: 1.0 Message-Id: <76667692-13ef-4522-ab23-240a1f6d57f3@www.fastmail.com> In-Reply-To: References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> <44B80F15-2BE7-4B7C-BC3D-B65511480E58@freebsd.org> Date: Sun, 15 Nov 2020 13:36:01 -0600 From: "Brandon Bergren" To: "Scott Long" Cc: "Jessica Clarke" , "Scott Long" , src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367701 - head/lib/libutil Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:36:22 -0000 That would explain why I see what I see -- I did not install an updated = libc yet. On Sun, Nov 15, 2020, at 1:34 PM, Scott Long wrote: > It is a magical namespace, in that it comes from libc, not from the=20= > kernel. Please make sure that you=E2=80=99ve installed a more recent = libc, I=20 > guess? I just did a full build and install, and I=E2=80=99m unable to= =20 > replicate the problem. Maybe there=E2=80=99s a static-linked pkg runn= ing=20 > around somewhere? I=E2=80=99m at a loss for better ideas. >=20 > Scott >=20 >=20 > > On Nov 15, 2020, at 12:30 PM, Brandon Bergren = wrote: > >=20 > > I think the problem is that user.* is somehow magically namespaced, = so doing a "dumb" sysctlbyname will get the wrong one. > >=20 > > sysctl (the tool) does: > > __sysctl("sysctl.name2oid user.localbase",2,0xfffffbfffde98,0xfffffb= fffda98,0x810809000,14) =3D 0 (0x0) > > __sysctl("sysctl.oidfmt user.localbase",4,0xfffffbfffdef8,0xfffffbff= fd690,0x0,0) =3D 0 (0x0) > > __sysctl("sysctl.name { 8.21 }",4,0xfffffbfffc8f8,0xfffffbfffc480,0x= 0,0) =3D 0 (0x0) > > __sysctl("sysctl.oidfmt user.localbase",4,0xfffffbfffd0f8,0xfffffbff= fc488,0x0,0) =3D 0 (0x0) > > __sysctl("user.localbase",2,0x0,0xfffffbfffc480,0x0,0) =3D 0 (0x0) > > __sysctl("user.localbase",2,0x81080a000,0xfffffbfffd0f8,0x0,0) =3D 0= (0x0) > >=20 > > and picks up /usr/local. > >=20 > > whereas libutil is currently just doing > > __sysctlbyname("user.localbase",14,0xfffffbfffd4f8,0xfffffbfffd440,0= x0,0) =3D 0 (0x0) > >=20 > > which is returning the builtin "" from the static kernel variable. > >=20 > > On Sun, Nov 15, 2020, at 1:26 PM, Jessica Clarke wrote: > >> On 15 Nov 2020, at 19:10, Brandon Bergren wro= te: > >>>=20 > >>> On powerpc64 and powerpc64le, there is some really weird behavior = happening around the sysctl itself: > >>>=20 > >>> root@crow:~ # pkg > >>> The package management tool is not yet installed on your system. > >>> Do you want to fetch and install it now? [y/N]: N > >>> root@crow:~ # sysctl user.localbase > >>> user.localbase: /usr/local > >>> root@crow:~ # pkg > >>> The package management tool is not yet installed on your system. > >>> Do you want to fetch and install it now? [y/N]: N > >>> root@crow:~ # sysctl user.localbase=3D/usr/local > >>> user.localbase: /usr/local -> /usr/local > >>> root@crow:~ # pkg > >>> pkg: not enough arguments > >>> Usage: pkg [-v] [-d] [-l] [-N] [-j |-c |-r ] [-C ] [-R ] [-o v= ar=3Dvalue] [-4|-6] [] > >>>=20 > >>> For more information on available commands and options see 'pkg he= lp'. > >>> root@crow:~ #=20 > >>>=20 > >>>=20 > >>> I would double check very closely that the sysctl is being called = correctly, the sysctl tool manages to read it out, but libutil does not.= > >>=20 > >> That's odd. What does truss say? > >>=20 > >> Jess > >>=20 > >>> On Sun, Nov 15, 2020, at 1:06 PM, Scott Long wrote: > >>>>=20 > >>>>> On Nov 15, 2020, at 12:01 PM, Jessica Clarke wrote: > >>>>>>=20 > >>>>>> I felt similar concerns, but my misunderstanding of strlcpy() d= rove the > >>>>>> result. Since the use case for getlocalbase() lends itself to = also use > >>>>>> strlcat()/strlcpy(), I was trying to replicate the API semantic= s of those, > >>>>>> at least to the limit of my understanding. Thanks for the feed= back, I=E2=80=99ll > >>>>>> look at it some more. > >>>>>=20 > >>>>> Thanks. ENOMEM also feels inappropriate as no allocation is taki= ng > >>>>> place. Perhaps ENAMETOOLONG, which is used in similar cases for = things > >>>>> like gethostbyname? Though sysctlbyname uses ENOMEM instead... s= igh. > >>>>>=20 > >>>>=20 > >>>> Yep, I wasn=E2=80=99t happy with ENOMEM either but I couldn=E2=80= =99t find anything better. > >>>>=20 > >>>>> Also, if pathlen has already been checked against SSIZE_MAX (giv= ing > >>>>> EINVAL) and tmplen against pathlen there's no need to then check= tmplen > >>>>> against SSIZE_MAX. > >>>>>=20 > >>>>=20 > >>>> Done. > >>>>=20 > >>>>> I'd be happy to give a review on Phabricator if/when you have a = new > >>>>> patch. > >>>>>=20 > >>>>=20 > >>>> https://reviews.freebsd.org/D27227 > >>>>=20 > >>>> Thanks, > >>>> Scott > >>>>=20 > >>>>=20 > >>>=20 > >>> --=20 > >>> Brandon Bergren > >>> bdragon@FreeBSD.org > >>=20 > >>=20 > >=20 > > --=20 > > Brandon Bergren > > bdragon@FreeBSD.org >=20 > --=20 Brandon Bergren bdragon@FreeBSD.org From owner-svn-src-all@freebsd.org Sun Nov 15 20:05:17 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 00CDE467747 for ; Sun, 15 Nov 2020 20:05:16 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) (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 4CZ38r62mdz3NvV for ; Sun, 15 Nov 2020 20:05:16 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qv1-xf35.google.com with SMTP id a15so5506903qvk.5 for ; Sun, 15 Nov 2020 12:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cNSIKxL7yT34XdthCJBQ4npO/ZnnJDBQ2xZQiyQ1rjw=; b=w0SgQfry+MM2FfDwK8RaTwMgfTmbWpFfdFk+PfA/8QGUSJ65CjF092OjiTk5gj23IX xUcEDZeKnvCLH3x38Ms/OA8D03DoXiIQIclBl7JkqASY85o3oPujDj1QiYSvzvBCfegv cQ3cNumoyTOzbUrCwBZyzoMItJDcBcJWumtJ4dHD8YA3ZZAKlerppcl3FRojDkAKDONy n17xO/BP681g+N3Uz9TPdh5LdIFA1z50/4Oq/5B3maUP6EZoBYTsyMou1BYzmCOnfISH 5Ck6aEeaJ1J2tTunBJvZBR+RmQriN5rgi/Af8nCv5xB3QYomCnT8TGxOZtlcLxlBq6mq qmgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cNSIKxL7yT34XdthCJBQ4npO/ZnnJDBQ2xZQiyQ1rjw=; b=YwjEGrLSzdtD69ECwaHXRTk4O5iOikBUIas0WYSS5bea1dTND8pihf4S5JTLrDSUUJ i74aPx8urHhED23g4BbxFpZb3o4L+blpiBEUIzQNRwxCZimQVKNIgS05A2TtwsBNhQrs AbqfyqKmAos0gjK8MTTGr4tOlyOoj83tr2JR8UrA7igNq8XkN3DX3vhMLt4MR4n2ALzP l2RN31TIUKhUFVtIrD8gc89IibGOkTDH8ANSIccYuWzcRBBzwwuW1R1nAEZTPezdf1YC ePY9XM/+Gzp3i/3oUh851NOuoNNRI2P8YdMrdPQaxsp9tbARp6XWDo8BCzxbz4l6WcYg 3z9g== X-Gm-Message-State: AOAM533a2Jerxr15euprILUBYg7jcgAo/mRLYThDZNvw2pSqItqhANJP 1DGF//jPo+N46P5bRiZBUA0z8le7yNpkSHSzK5CgbfKyqjLZ6xuz X-Google-Smtp-Source: ABdhPJwLVveo8ieAQDFiBc0MYwot9uGEDSRFxpujVJNILPgJc6LGd87BNe6iQfMYISMv7vw+uBmDGUnIiy7rtvxtJXw= X-Received: by 2002:ad4:4e13:: with SMTP id dl19mr11995588qvb.24.1605470715551; Sun, 15 Nov 2020 12:05:15 -0800 (PST) MIME-Version: 1.0 References: <202011150748.0AF7mqW3016900@repo.freebsd.org> In-Reply-To: From: Warner Losh Date: Sun, 15 Nov 2020 13:05:04 -0700 Message-ID: Subject: Re: svn commit: r367701 - head/lib/libutil To: Scott Long Cc: Jessica Clarke , Scott Long , src-committers , svn-src-all , svn-src-head X-Rspamd-Queue-Id: 4CZ38r62mdz3NvV X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 20:05:17 -0000 Hey Scott, On Sun, Nov 15, 2020 at 11:46 AM Scott Long wrote: > The man page for strlcpy() made reference to the return value being > equivalent to what snprintf() does. The man page for snprintf() states > that negatve return values are possible, so I assumed the same was > true for strlcpy(). However, now that I=E2=80=99ve looked at the impleme= ntation > of strlcpy(), I see that you=E2=80=99re correct. The man pages are defin= itely > confusing, and this isn=E2=80=99t the only place where I think there=E2= =80=99s > inconsistency in the documentation, or at least poor wording choices. Yea, it says both that it will never return a negative value (since size_t is never negative) and that it returns the same things as snprintf (which is true... except for that detail which it glosses over in return type differences). So this issue doesn't get lost, I've added a clarification to the examples in https://reviews.freebsd.org/D27228 . Please take a look and let me know what you think. If more extensive edits are needed, there's full context so you can at least flag those in the review as well. I've read these too many times to see the other places you're talking about, so a fresh set of eyes would be helpful. Warner From owner-svn-src-all@freebsd.org Sun Nov 15 20:13:23 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9A19467D3C; Sun, 15 Nov 2020 20:13:23 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ3LC3Tjnz3PSG; Sun, 15 Nov 2020 20:13:23 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 290D4A57; Sun, 15 Nov 2020 15:13:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 15 Nov 2020 15:13:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=c R03pZ73a6kXnvliYSrdRdWz42vyv0krtUeuI0Ut9m0=; b=Hxi7QP81Q2e+Xto1s 6DF+k9EnAzQ7j/lRdPHFn4iJkjEOy2xhHEzzbJu0A5dUjIhp6yAarXnhEZSu2Fyd ZB8isZmHsnfuCl/qZZHEBFM5wwO0oKxWfEhmFZ3RpzrgAkQKgRydNu8A7LBQwlH8 UrbafzK988g37OcQaVyqc76+Zhq0sfzQBanLicibtHegtNI93VrMCfj7KffxSe25 iBJci8W8vSGtg0CqPk1o3wyn+tJKlbdqDNU54p4wwATVQr+XWkhsEKkENR5Y0K8K Bk1jFOuhuso3BMZW3DF1tjvsbsBqTYIU+LCk5Ei4wgHk719QnzuCRSrx1kXybV1i Gmang== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=cR03pZ73a6kXnvliYSrdRdWz42vyv0krtUeuI0Ut9 m0=; b=iTFS37g+ad/LowvkfvjvoTFMwHUztdggQSrVc1wSv8NEufgRzQAk9zIIk 01AdtcgaXai1JrCPtDax4h0kUx5MQirfEYqgk7BbuRJOro7DnAXMOc/AZ7SA5WD3 XnphwbAe2B17U0QDr5af1bGvrwfxDtrzXIfz7GjlBjM/MfSQ/qZKM0QU37xwTULR CN4fr3c/w1Emhb9HBGWACxeF+kntYIzoCyzUGQx4QvqOniFNIuu9CvsBQEa2xZ4L y/zfW3eb6h+8r8EMG4qOBXV8SKPuv4ibzBD5BKickA8vmpyv+ZmvgP8wySuiGI5P 63gynz6hDESSyaBHX1uYfYfqaQn8w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledgudefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpegtggfuhfgjfffgkfhfvffosehtqhhmtdhhtdejnecuhfhrohhmpefutgho thhtucfnohhnghcuoehstghothhtlhesshgrmhhstghordhorhhgqeenucggtffrrghtth gvrhhnpeduudevkeehheeiudekkeelleevudefveeftedugfdtffetffelheehffeufffg heenucffohhmrghinhepfhhrvggvsghsugdrohhrghenucfkphepkedrgeeirdekledrvd dufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehs tghothhtlhesshgrmhhstghordhorhhg X-ME-Proxy: Received: from [192.168.0.114] (unknown [8.46.89.213]) by mail.messagingengine.com (Postfix) with ESMTPA id ED14D3064AA6; Sun, 15 Nov 2020 15:13:18 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Scott Long In-Reply-To: Date: Sun, 15 Nov 2020 13:13:18 -0700 Cc: Jessica Clarke , Scott Long , src-committers , svn-src-all , svn-src-head , Stefan Esser Content-Transfer-Encoding: quoted-printable Message-Id: <9578C457-F9C9-4B27-ACCE-1B66256B06A9@samsco.org> References: <202011150748.0AF7mqW3016900@repo.freebsd.org> To: Warner Losh X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ3LC3Tjnz3PSG X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 20:13:23 -0000 > On Nov 15, 2020, at 1:05 PM, Warner Losh wrote: >=20 > Hey Scott, >=20 > On Sun, Nov 15, 2020 at 11:46 AM Scott Long wrote: > The man page for strlcpy() made reference to the return value being > equivalent to what snprintf() does. The man page for snprintf() = states > that negatve return values are possible, so I assumed the same was > true for strlcpy(). However, now that I=E2=80=99ve looked at the = implementation > of strlcpy(), I see that you=E2=80=99re correct. The man pages are = definitely > confusing, and this isn=E2=80=99t the only place where I think = there=E2=80=99s > inconsistency in the documentation, or at least poor wording choices. >=20 > Yea, it says both that it will never return a negative value (since = size_t is never negative) and that it returns the same things as = snprintf (which is true... except for that detail which it glosses over = in return type differences). >=20 > So this issue doesn't get lost, I've added a clarification to the = examples in https://reviews.freebsd.org/D27228 . Please take a look and = let me know what you think. If more extensive edits are needed, there's = full context so you can at least flag those in the review as well. I've = read these too many times to see the other places you're talking about, = so a fresh set of eyes would be helpful. >=20 The wording on whether or not strlcpy and strlcat will provide NULL = termination is also inconsistent, hence my comments about it last = weekend. I=E2=80=99m going to revert all of this back to and including = r367075, since Stefan wants to do this a totally different way. Sorry = for the noise everyone and thanks for the help, I learned a lot through = this process. Scott From owner-svn-src-all@freebsd.org Sun Nov 15 20:25:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 334D5467D62; Sun, 15 Nov 2020 20:25:01 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ3bd0wjHz3Q1s; Sun, 15 Nov 2020 20:25:01 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 12A5221BEA; Sun, 15 Nov 2020 20:25:01 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFKP0xH018546; Sun, 15 Nov 2020 20:25:00 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFKOxTZ018524; Sun, 15 Nov 2020 20:24:59 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <202011152024.0AFKOxTZ018524@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sun, 15 Nov 2020 20:24:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367711 - in head: lib/libutil sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in head: lib/libutil sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Commit-Revision: 367711 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 20:25:01 -0000 Author: scottl Date: Sun Nov 15 20:24:59 2020 New Revision: 367711 URL: https://svnweb.freebsd.org/changeset/base/367711 Log: Revert the whole getlocalbase() set of changes while a different design is hashed out. Deleted: head/lib/libutil/getlocalbase.3 head/lib/libutil/getlocalbase.c Modified: head/lib/libutil/Makefile head/lib/libutil/libutil.h head/sbin/nvmecontrol/comnd.c head/sbin/nvmecontrol/comnd.h head/sbin/nvmecontrol/nvmecontrol.c head/usr.sbin/mailwrapper/mailwrapper.c head/usr.sbin/pkg/Makefile head/usr.sbin/pkg/pkg.c Modified: head/lib/libutil/Makefile ============================================================================== --- head/lib/libutil/Makefile Sun Nov 15 14:04:27 2020 (r367710) +++ head/lib/libutil/Makefile Sun Nov 15 20:24:59 2020 (r367711) @@ -12,8 +12,7 @@ PACKAGE= runtime LIB= util SHLIB_MAJOR= 9 -SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c \ - getlocalbase.c gr_util.c \ +SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \ hexdump.c humanize_number.c kinfo_getfile.c \ kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ kinfo_getvmobject.c kld.c \ @@ -31,7 +30,7 @@ CFLAGS+= -DINET6 CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ -MAN+= expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \ +MAN+= expand_number.3 flopen.3 fparseln.3 hexdump.3 \ humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ login_auth.3 login_cap.3 \ Modified: head/lib/libutil/libutil.h ============================================================================== --- head/lib/libutil/libutil.h Sun Nov 15 14:04:27 2020 (r367710) +++ head/lib/libutil/libutil.h Sun Nov 15 20:24:59 2020 (r367711) @@ -65,11 +65,6 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif -#ifndef _SSIZE_T_DECLARED -typedef __ssize_t ssize_t; -#define _SSIZE_T_DECLARED -#endif - #ifndef _UID_T_DECLARED typedef __uid_t uid_t; #define _UID_T_DECLARED @@ -103,7 +98,6 @@ int flopen(const char *_path, int _flags, ...); int flopenat(int _dirfd, const char *_path, int _flags, ...); int forkpty(int *_amaster, char *_name, struct termios *_termp, struct winsize *_winp); -ssize_t getlocalbase(char *path, size_t pathlen); void hexdump(const void *_ptr, int _length, const char *_hdr, int _flags); int humanize_number(char *_buf, size_t _len, int64_t _number, const char *_suffix, int _scale, int _flags); Modified: head/sbin/nvmecontrol/comnd.c ============================================================================== --- head/sbin/nvmecontrol/comnd.c Sun Nov 15 14:04:27 2020 (r367710) +++ head/sbin/nvmecontrol/comnd.c Sun Nov 15 20:24:59 2020 (r367711) @@ -287,7 +287,7 @@ bad_arg: * Loads all the .so's from the specified directory. */ void -cmd_load_dir(char *dir, cmd_load_cb_t cb, void *argp) +cmd_load_dir(const char *dir __unused, cmd_load_cb_t cb __unused, void *argp __unused) { DIR *d; struct dirent *dent; Modified: head/sbin/nvmecontrol/comnd.h ============================================================================== --- head/sbin/nvmecontrol/comnd.h Sun Nov 15 14:04:27 2020 (r367710) +++ head/sbin/nvmecontrol/comnd.h Sun Nov 15 20:24:59 2020 (r367711) @@ -96,7 +96,7 @@ void cmd_register(struct cmd *, struct cmd *); int arg_parse(int argc, char * const *argv, const struct cmd *f); void arg_help(int argc, char * const *argv, const struct cmd *f); void cmd_init(void); -void cmd_load_dir(char *dir, cmd_load_cb_t *cb, void *argp); +void cmd_load_dir(const char *dir, cmd_load_cb_t *cb, void *argp); int cmd_dispatch(int argc, char *argv[], const struct cmd *); #endif /* COMND_H */ Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Sun Nov 15 14:04:27 2020 (r367710) +++ head/sbin/nvmecontrol/nvmecontrol.c Sun Nov 15 20:24:59 2020 (r367711) @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -179,17 +178,11 @@ get_nsid(int fd, char **ctrlr_str, uint32_t *nsid) int main(int argc, char *argv[]) { - char locallib[MAXPATHLEN]; - size_t len; cmd_init(); - snprintf(locallib, MAXPATHLEN, "/lib/nvmecontrol"); - cmd_load_dir(locallib, NULL, NULL); - if ((len = getlocalbase(locallib, MAXPATHLEN)) > 0) { - strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN); - cmd_load_dir(locallib, NULL, NULL); - } + cmd_load_dir("/lib/nvmecontrol", NULL, NULL); + cmd_load_dir(_PATH_LOCALBASE "/lib/nvmecontrol", NULL, NULL); cmd_dispatch(argc, argv, NULL); Modified: head/usr.sbin/mailwrapper/mailwrapper.c ============================================================================== --- head/usr.sbin/mailwrapper/mailwrapper.c Sun Nov 15 14:04:27 2020 (r367710) +++ head/usr.sbin/mailwrapper/mailwrapper.c Sun Nov 15 20:24:59 2020 (r367711) @@ -105,10 +105,8 @@ main(int argc, char *argv[], char *envp[]) initarg(&al); addarg(&al, argv[0]); - if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) <= 0) - err(EX_OSERR, "cannot determine local path"); - - strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN); + snprintf(localmailerconf, MAXPATHLEN, "%s/etc/mail/mailer.conf", + getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); mailerconf = localmailerconf; if ((config = fopen(localmailerconf, "r")) == NULL) Modified: head/usr.sbin/pkg/Makefile ============================================================================== --- head/usr.sbin/pkg/Makefile Sun Nov 15 14:04:27 2020 (r367710) +++ head/usr.sbin/pkg/Makefile Sun Nov 15 20:24:59 2020 (r367711) @@ -25,6 +25,6 @@ MAN= pkg.7 CFLAGS+=-I${SRCTOP}/contrib/libucl/include .PATH: ${SRCTOP}/contrib/libucl/include -LIBADD= archive fetch ucl sbuf crypto ssl util +LIBADD= archive fetch ucl sbuf crypto ssl .include Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Sun Nov 15 14:04:27 2020 (r367710) +++ head/usr.sbin/pkg/pkg.c Sun Nov 15 20:24:59 2020 (r367711) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -1038,7 +1037,6 @@ main(int argc, char *argv[]) { char pkgpath[MAXPATHLEN]; const char *pkgarg; - size_t len; int i; bool bootstrap_only, force, yes; @@ -1047,11 +1045,8 @@ main(int argc, char *argv[]) pkgarg = NULL; yes = false; - if ((len = getlocalbase(pkgpath, MAXPATHLEN)) <= 0) { - fprintf(stderr, "Cannot determine local path\n"); - exit(EXIT_FAILURE); - } - strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN); + snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", + getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { bootstrap_only = true; From owner-svn-src-all@freebsd.org Sun Nov 15 20:49:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 055BF468EAE for ; Sun, 15 Nov 2020 20:49:12 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) (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 4CZ47W6JLZz3hH1 for ; Sun, 15 Nov 2020 20:49:10 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qv1-xf36.google.com with SMTP id b11so7700530qvr.9 for ; Sun, 15 Nov 2020 12:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gstb9q6Mqcgc03Cx91iDY2X+M+D579tJRyz/1MeJuRk=; b=rGDocxF8n33Vkq+r9JR6GVje/Av0WybDs/OGAvlegqAmoGK+k/E65J7jWtH7VyLMOH ddT40KzcH9883KV94zWqacrhEXRcVubQCYmv0Qg7nf5nRgJcSyonTgkT3c6wTp2d36GZ 5zLhNRAW9DzcXHxVC+xMRljpmsNcn12Z4vPNYswd6l7GOLsgc+DmiAhnSA7j8M+PyBks 6lWyj/Cx3JfVvCOYjYXeDgHRIlsQHoM08m9jg0ajJHfQzpQXtcgSiSSab6SgNejorxHX +ieufCjkkz3DkdtowTv6yywY3NmgJl4BbGrAUFQ0mC75it0wX8GeQKxIKPA/NW1nIQi0 B11w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gstb9q6Mqcgc03Cx91iDY2X+M+D579tJRyz/1MeJuRk=; b=eg3eEZMlQvP1WfTYvaQ+QfZmPV0Ta4sHe40yD6UETz4Dc5NWRuyS2uxBWuvzwRwOFc D2CT6yay/fwuH7iOdlp9XES31zGu9FhJf1sYv8ZcVhyIP1Qx6xbh9JGA2/9Hua7YIcN1 tyube9gjpfM9nwy5B0kXd6StrSDNTeRHo67TblH46oWfwRwKXlrqs2oh2W31gOZtcaAa SJcmRUn4XQb/TXMrI26g0MpNs0IPg7g7p5CuJwZai24rUF5PupMhlE16Qo37kN20TWSJ MTH6ox3O4F2yvJd4Kfej95z1E1xAzOSN6txbxFfbToDnKyRBlRP49On23+C2gjgCfUIS pbUg== X-Gm-Message-State: AOAM532bquJ+2Ah1dpBLdAcUwiTnArbAzJyqqjYgKZ2QGOJe00wUYB6O KQJ0nznI89rCRFOp4s0R17Mu6XuZJ3N6PmTysE4wDA== X-Google-Smtp-Source: ABdhPJw7EZP3wImjf6aHqIMeVssgue0bKYxV+CaXY4pzy4Z7mt8d8rOVu3I61vlPX5lgMc4xWSm6sN7aMjDOlXPHcXM= X-Received: by 2002:ad4:5b82:: with SMTP id 2mr2566140qvp.28.1605473349682; Sun, 15 Nov 2020 12:49:09 -0800 (PST) MIME-Version: 1.0 References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <9578C457-F9C9-4B27-ACCE-1B66256B06A9@samsco.org> In-Reply-To: <9578C457-F9C9-4B27-ACCE-1B66256B06A9@samsco.org> From: Warner Losh Date: Sun, 15 Nov 2020 13:48:58 -0700 Message-ID: Subject: Re: svn commit: r367701 - head/lib/libutil To: Scott Long Cc: Jessica Clarke , Scott Long , src-committers , svn-src-all , svn-src-head , Stefan Esser X-Rspamd-Queue-Id: 4CZ47W6JLZz3hH1 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 20:49:12 -0000 On Sun, Nov 15, 2020 at 1:13 PM Scott Long wrote: > > > On Nov 15, 2020, at 1:05 PM, Warner Losh wrote: > > > > Hey Scott, > > > > On Sun, Nov 15, 2020 at 11:46 AM Scott Long wrote: > > The man page for strlcpy() made reference to the return value being > > equivalent to what snprintf() does. The man page for snprintf() states > > that negatve return values are possible, so I assumed the same was > > true for strlcpy(). However, now that I=E2=80=99ve looked at the imple= mentation > > of strlcpy(), I see that you=E2=80=99re correct. The man pages are def= initely > > confusing, and this isn=E2=80=99t the only place where I think there=E2= =80=99s > > inconsistency in the documentation, or at least poor wording choices. > > > > Yea, it says both that it will never return a negative value (since > size_t is never negative) and that it returns the same things as snprintf > (which is true... except for that detail which it glosses over in return > type differences). > > > > So this issue doesn't get lost, I've added a clarification to the > examples in https://reviews.freebsd.org/D27228 . Please take a look and > let me know what you think. If more extensive edits are needed, there's > full context so you can at least flag those in the review as well. I've > read these too many times to see the other places you're talking about, s= o > a fresh set of eyes would be helpful. > > > > The wording on whether or not strlcpy and strlcat will provide NULL > termination is also inconsistent, hence my comments about it last weekend= . > I=E2=80=99m going to revert all of this back to and including r367075, si= nce Stefan > wants to do this a totally different way. Sorry for the noise everyone a= nd > thanks for the help, I learned a lot through this process. > OK. I'll update the man page to document the guaranteed behavior wrt NUL as well. I know what it's trying to say, but you are not the first person to stumble on these details. Thanks for pointing me at the ones that need improvement. And thanks for getting the localbase issue seen through. Warner From owner-svn-src-all@freebsd.org Sun Nov 15 22:49:29 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44DEF46BEBB; Sun, 15 Nov 2020 22:49:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ6pK1TjVz3pr1; Sun, 15 Nov 2020 22:49:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 213F02357E; Sun, 15 Nov 2020 22:49:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AFMnSre005764; Sun, 15 Nov 2020 22:49:28 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AFMnShE005763; Sun, 15 Nov 2020 22:49:28 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202011152249.0AFMnShE005763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 15 Nov 2020 22:49:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367712 - head/tools/build/mk X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head/tools/build/mk X-SVN-Commit-Revision: 367712 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 22:49:29 -0000 Author: dim Date: Sun Nov 15 22:49:28 2020 New Revision: 367712 URL: https://svnweb.freebsd.org/changeset/base/367712 Log: Ensure make delete-old does not unlink the llvm-cxxfilt and its manpage, after r367304 and r367324, when WITH_LLVM_CXXFILT is enabled. Noticed by: "Herbert J. Skuhra" MFC after: 3 days X-MFC-With: r367304 Modified: head/tools/build/mk/OptionalObsoleteFiles.inc Modified: head/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- head/tools/build/mk/OptionalObsoleteFiles.inc Sun Nov 15 20:24:59 2020 (r367711) +++ head/tools/build/mk/OptionalObsoleteFiles.inc Sun Nov 15 22:49:28 2020 (r367712) @@ -1538,7 +1538,6 @@ OLD_FILES+=usr/bin/lli OLD_FILES+=usr/bin/llvm-as OLD_FILES+=usr/bin/llvm-bcanalyzer OLD_FILES+=usr/bin/llvm-cxxdump -OLD_FILES+=usr/bin/llvm-cxxfilt OLD_FILES+=usr/bin/llvm-diff OLD_FILES+=usr/bin/llvm-dis OLD_FILES+=usr/bin/llvm-dwarfdump @@ -1562,7 +1561,6 @@ OLD_FILES+=usr/share/man/man1/llc.1.gz OLD_FILES+=usr/share/man/man1/lli.1.gz OLD_FILES+=usr/share/man/man1/llvm-as.1.gz OLD_FILES+=usr/share/man/man1/llvm-bcanalyzer.1.gz -OLD_FILES+=usr/share/man/man1/llvm-cxxfilt.1.gz OLD_FILES+=usr/share/man/man1/llvm-diff.1.gz OLD_FILES+=usr/share/man/man1/llvm-dis.1.gz OLD_FILES+=usr/share/man/man1/llvm-dwarfdump.1 @@ -1577,6 +1575,11 @@ OLD_FILES+=usr/share/man/man1/opt.1.gz .if ${MK_CLANG_EXTRAS} == no && ${MK_CLANG_FORMAT} == no OLD_FILES+=usr/bin/clang-format +.endif + +.if ${MK_CLANG_EXTRAS} == no && ${MK_LLVM_CXXFILT} == no +OLD_FILES+=usr/bin/llvm-cxxfilt +OLD_FILES+=usr/share/man/man1/llvm-cxxfilt.1.gz .endif .if ${MK_CPP} == no From owner-svn-src-all@freebsd.org Mon Nov 16 03:09:19 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F1002D0DAF; Mon, 16 Nov 2020 03:09:19 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZDZ71jDCz4W61; Mon, 16 Nov 2020 03:09:19 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D86726BAD; Mon, 16 Nov 2020 03:09:19 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AG39J2W067465; Mon, 16 Nov 2020 03:09:19 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AG39JmP067464; Mon, 16 Nov 2020 03:09:19 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011160309.0AG39JmP067464@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 16 Nov 2020 03:09:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367713 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367713 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 03:09:19 -0000 Author: mjg Date: Mon Nov 16 03:09:18 2020 New Revision: 367713 URL: https://svnweb.freebsd.org/changeset/base/367713 Log: select: replace reference counting with memory barriers in selfd Refcounting was added to combat a race between selfdfree and doselwakup, but it adds avoidable overhead. selfdfree detects it can free the object by ->sf_si == NULL, thus we can ensure that the condition only holds after all accesses are completed. Modified: head/sys/kern/sys_generic.c Modified: head/sys/kern/sys_generic.c ============================================================================== --- head/sys/kern/sys_generic.c Sun Nov 15 22:49:28 2020 (r367712) +++ head/sys/kern/sys_generic.c Mon Nov 16 03:09:18 2020 (r367713) @@ -156,7 +156,6 @@ struct selfd { struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ struct seltd *sf_td; /* (k) owning seltd. */ void *sf_cookie; /* (k) fd or pollfd. */ - u_int sf_refs; }; MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); @@ -1704,16 +1703,17 @@ static void selfdfree(struct seltd *stp, struct selfd *sfp) { STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); - if (sfp->sf_si != NULL) { + /* + * Paired with doselwakeup. + */ + if (atomic_load_acq_ptr((uintptr_t *)&sfp->sf_si) != (uintptr_t)NULL) { mtx_lock(sfp->sf_mtx); if (sfp->sf_si != NULL) { TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); - refcount_release(&sfp->sf_refs); } mtx_unlock(sfp->sf_mtx); } - if (refcount_release(&sfp->sf_refs)) - free(sfp, M_SELFD); + free(sfp, M_SELFD); } /* Drain the waiters tied to all the selfd belonging the specified selinfo. */ @@ -1766,7 +1766,6 @@ selrecord(struct thread *selector, struct selinfo *sip */ sfp->sf_si = sip; sfp->sf_mtx = mtxp; - refcount_init(&sfp->sf_refs, 2); STAILQ_INSERT_TAIL(&stp->st_selq, sfp, sf_link); /* * Now that we've locked the sip, check for initialization. @@ -1820,14 +1819,15 @@ doselwakeup(struct selinfo *sip, int pri) * sf_si seltdclear will know to ignore this si. */ TAILQ_REMOVE(&sip->si_tdlist, sfp, sf_threads); - sfp->sf_si = NULL; stp = sfp->sf_td; + /* + * Paired with selfdfree. + */ + atomic_store_rel_ptr((uintptr_t *)&sfp->sf_si, (uintptr_t)NULL); mtx_lock(&stp->st_mtx); stp->st_flags |= SELTD_PENDING; cv_broadcastpri(&stp->st_wait, pri); mtx_unlock(&stp->st_mtx); - if (refcount_release(&sfp->sf_refs)) - free(sfp, M_SELFD); } mtx_unlock(sip->si_mtx); } From owner-svn-src-all@freebsd.org Mon Nov 16 03:12:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 558872D0D7D; Mon, 16 Nov 2020 03:12:22 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZDdf1XV8z4WXG; Mon, 16 Nov 2020 03:12:22 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 282C526E45; Mon, 16 Nov 2020 03:12:22 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AG3CMiV073336; Mon, 16 Nov 2020 03:12:22 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AG3CLcm073334; Mon, 16 Nov 2020 03:12:21 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011160312.0AG3CLcm073334@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 16 Nov 2020 03:12:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367714 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367714 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 03:12:22 -0000 Author: mjg Date: Mon Nov 16 03:12:21 2020 New Revision: 367714 URL: https://svnweb.freebsd.org/changeset/base/367714 Log: select: call seltdfini on process and thread exit Since thread_zone is marked NOFREE the thread_fini callback is never executed, meaning memory allocated by seltdinit is never released. Adding the call to thread_dtor is not sufficient as exiting processes cache the main thread. Modified: head/sys/kern/kern_exit.c head/sys/kern/kern_thread.c Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Mon Nov 16 03:09:18 2020 (r367713) +++ head/sys/kern/kern_exit.c Mon Nov 16 03:12:21 2020 (r367714) @@ -355,6 +355,7 @@ exit1(struct thread *td, int rval, int signo) PROC_UNLOCK(p); umtx_thread_exit(td); + seltdfini(td); /* * Reset any sigio structures pointing to us as a result of Modified: head/sys/kern/kern_thread.c ============================================================================== --- head/sys/kern/kern_thread.c Mon Nov 16 03:09:18 2020 (r367713) +++ head/sys/kern/kern_thread.c Mon Nov 16 03:12:21 2020 (r367714) @@ -329,6 +329,7 @@ thread_ctor(void *mem, int size, void *arg, int flags) audit_thread_alloc(td); #endif umtx_thread_alloc(td); + MPASS(td->td_sel == NULL); return (0); } @@ -369,6 +370,7 @@ thread_dtor(void *mem, int size, void *arg) osd_thread_exit(td); td_softdep_cleanup(td); MPASS(td->td_su == NULL); + seltdfini(td); } /* @@ -405,7 +407,7 @@ thread_fini(void *mem, int size) turnstile_free(td->td_turnstile); sleepq_free(td->td_sleepqueue); umtx_thread_fini(td); - seltdfini(td); + MPASS(td->td_sel == NULL); } /* From owner-svn-src-all@freebsd.org Mon Nov 16 08:56:33 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 907872D6E3E; Mon, 16 Nov 2020 08:56:33 +0000 (UTC) (envelope-from zeising@freebsd.org) Received: from mail.daemonic.se (mail.daemonic.se [IPv6:2607:f740:d:20::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZNGn1S11z4m9L; Mon, 16 Nov 2020 08:56:33 +0000 (UTC) (envelope-from zeising@freebsd.org) Received: from cid.daemonic.se (localhost [IPv6:::1]) by mail.daemonic.se (Postfix) with ESMTP id 4CZNGc6Gx7z3nRM; Mon, 16 Nov 2020 08:56:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at daemonic.se Received: from mail.daemonic.se ([IPv6:::1]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256) by cid.daemonic.se (mailscanner.daemonic.se [IPv6:::1]) (amavisd-new, port 10587) with ESMTPS id 0sWBg1a6zhCG; Mon, 16 Nov 2020 08:56:23 +0000 (UTC) Received: from garnet.daemonic.se (host-95-194-83-230.mobileonline.telia.com [95.194.83.230]) by mail.daemonic.se (Postfix) with ESMTPSA id 4CZNGb2nyQz3nRf; Mon, 16 Nov 2020 08:56:23 +0000 (UTC) Subject: Re: svn commit: r367566 - stable/12/sys/compat/linuxkpi/common/include/linux To: Hans Petter Selasky , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <202011101336.0AADa7i0051738@repo.freebsd.org> From: Niclas Zeising Message-ID: Date: Mon, 16 Nov 2020 09:56:22 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <202011101336.0AADa7i0051738@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4CZNGn1S11z4m9L 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:36236, ipnet:2607:f740:d::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 08:56:33 -0000 On 2020-11-10 14:36, Hans Petter Selasky wrote: > Author: hselasky > Date: Tue Nov 10 13:36:07 2020 > New Revision: 367566 > URL: https://svnweb.freebsd.org/changeset/base/367566 > > Log: > MFC r366751: > Remove ifdefs around IS_ALIGNED() definition in the LinuxKPI. > There are reports that this broke drm-fbsd12.0-kmod in stable. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251163 for details. Can you have a look? Regards -- Niclas Zeising From owner-svn-src-all@freebsd.org Mon Nov 16 09:25:15 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 070162D7DB6; Mon, 16 Nov 2020 09:25:15 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.3 with cipher TLS_AES_256_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 4CZNvt6Fhkz4nxn; Mon, 16 Nov 2020 09:25:14 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 965C2260253; Mon, 16 Nov 2020 10:25:12 +0100 (CET) Subject: Re: svn commit: r367566 - stable/12/sys/compat/linuxkpi/common/include/linux To: Niclas Zeising , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <202011101336.0AADa7i0051738@repo.freebsd.org> From: Hans Petter Selasky Message-ID: <6e125eb7-dfd7-7306-00c7-1606ef0ce0cf@selasky.org> Date: Mon, 16 Nov 2020 10:25:07 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4CZNvt6Fhkz4nxn X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 09:25:15 -0000 On 11/16/20 9:56 AM, Niclas Zeising wrote: > On 2020-11-10 14:36, Hans Petter Selasky wrote: >> Author: hselasky >> Date: Tue Nov 10 13:36:07 2020 >> New Revision: 367566 >> URL: https://svnweb.freebsd.org/changeset/base/367566 >> >> Log: >>    MFC r366751: >>    Remove ifdefs around IS_ALIGNED() definition in the LinuxKPI. > > There are reports that this broke drm-fbsd12.0-kmod in stable.  See > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251163 for details. > Can you have a look? I'll update the port. Thank you! --HPS From owner-svn-src-all@freebsd.org Mon Nov 16 10:00:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 201702E9FAB; Mon, 16 Nov 2020 10:00:22 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZPhQ0TJjz4rkp; Mon, 16 Nov 2020 10:00:22 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0357E3F5B; Mon, 16 Nov 2020 10:00:22 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGA0LeW020722; Mon, 16 Nov 2020 10:00:21 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGA0LT3020721; Mon, 16 Nov 2020 10:00:21 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011161000.0AGA0LT3020721@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 16 Nov 2020 10:00:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367715 - head/sys/dev/mlx5/mlx5_ib X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/dev/mlx5/mlx5_ib X-SVN-Commit-Revision: 367715 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 10:00:22 -0000 Author: hselasky Date: Mon Nov 16 10:00:21 2020 New Revision: 367715 URL: https://svnweb.freebsd.org/changeset/base/367715 Log: Fix error handling order in create_kernel_qp in mlx5ib. Make sure order of cleanup is exactly the opposite of initialization. Linux commit: f4044dac63e952ac1137b6df02b233d37696e2f5 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c ============================================================================== --- head/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c Mon Nov 16 03:12:21 2020 (r367714) +++ head/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c Mon Nov 16 10:00:21 2020 (r367715) @@ -987,12 +987,12 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev, return 0; err_wrid: - mlx5_db_free(dev->mdev, &qp->db); kfree(qp->sq.wqe_head); kfree(qp->sq.w_list); kfree(qp->sq.wrid); kfree(qp->sq.wr_data); kfree(qp->rq.wrid); + mlx5_db_free(dev->mdev, &qp->db); err_free: kvfree(*in); @@ -1007,12 +1007,12 @@ err_uuar: static void destroy_qp_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp) { - mlx5_db_free(dev->mdev, &qp->db); kfree(qp->sq.wqe_head); kfree(qp->sq.w_list); kfree(qp->sq.wrid); kfree(qp->sq.wr_data); kfree(qp->rq.wrid); + mlx5_db_free(dev->mdev, &qp->db); mlx5_buf_free(dev->mdev, &qp->buf); free_uuar(&dev->mdev->priv.uuari, qp->bf->uuarn); } From owner-svn-src-all@freebsd.org Mon Nov 16 10:03:19 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1EDE52EA11A; Mon, 16 Nov 2020 10:03:19 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZPlq0Pbtz4sV9; Mon, 16 Nov 2020 10:03:19 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 003EF40A7; Mon, 16 Nov 2020 10:03:18 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGA3I3q026479; Mon, 16 Nov 2020 10:03:18 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGA3IFp026477; Mon, 16 Nov 2020 10:03:18 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011161003.0AGA3IFp026477@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 16 Nov 2020 10:03:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367716 - in head/sys/dev/mlx5: . mlx5_core X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/dev/mlx5: . mlx5_core X-SVN-Commit-Revision: 367716 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 10:03:19 -0000 Author: hselasky Date: Mon Nov 16 10:03:18 2020 New Revision: 367716 URL: https://svnweb.freebsd.org/changeset/base/367716 Log: Use mlx5core to create/destroy all Dynamically Connected Targets, DCTs. To prevent a hardware memory leak when a DEVX DCT object is destroyed without calling drain DCT before, (e.g. under cleanup flow), need to manage its creation and destruction via mlx5 core. Linux commit: c5ae1954c47d3fd8815bd5a592aba18702c93f33 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sys/dev/mlx5/mlx5_core/mlx5_qp.c head/sys/dev/mlx5/qp.h Modified: head/sys/dev/mlx5/mlx5_core/mlx5_qp.c ============================================================================== --- head/sys/dev/mlx5/mlx5_core/mlx5_qp.c Mon Nov 16 10:00:21 2020 (r367715) +++ head/sys/dev/mlx5/mlx5_core/mlx5_qp.c Mon Nov 16 10:03:18 2020 (r367716) @@ -349,19 +349,18 @@ EXPORT_SYMBOL_GPL(mlx5_core_xrcd_dealloc); int mlx5_core_create_dct(struct mlx5_core_dev *dev, struct mlx5_core_dct *dct, - u32 *in) + u32 *in, int inlen, + u32 *out, int outlen) { struct mlx5_qp_table *table = &dev->priv.qp_table; - u32 out[MLX5_ST_SZ_DW(create_dct_out)] = {0}; u32 dout[MLX5_ST_SZ_DW(destroy_dct_out)] = {0}; u32 din[MLX5_ST_SZ_DW(destroy_dct_in)] = {0}; - int inlen = MLX5_ST_SZ_BYTES(create_dct_in); int err; init_completion(&dct->drained); MLX5_SET(create_dct_in, in, opcode, MLX5_CMD_OP_CREATE_DCT); - err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); + err = mlx5_cmd_exec(dev, in, inlen, out, outlen); if (err) { mlx5_core_warn(dev, "create DCT failed, ret %d", err); return err; @@ -387,7 +386,7 @@ int mlx5_core_create_dct(struct mlx5_core_dev *dev, err_cmd: MLX5_SET(destroy_dct_in, din, opcode, MLX5_CMD_OP_DESTROY_DCT); MLX5_SET(destroy_dct_in, din, dctn, dct->dctn); - mlx5_cmd_exec(dev, &din, sizeof(din), &out, sizeof(dout)); + mlx5_cmd_exec(dev, &din, sizeof(din), dout, sizeof(dout)); return err; } Modified: head/sys/dev/mlx5/qp.h ============================================================================== --- head/sys/dev/mlx5/qp.h Mon Nov 16 10:00:21 2020 (r367715) +++ head/sys/dev/mlx5/qp.h Mon Nov 16 10:03:18 2020 (r367716) @@ -586,7 +586,8 @@ int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u3 int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn); int mlx5_core_create_dct(struct mlx5_core_dev *dev, struct mlx5_core_dct *dct, - u32 *in); + u32 *in, int inlen, + u32 *out, int outlen); int mlx5_core_destroy_dct(struct mlx5_core_dev *dev, struct mlx5_core_dct *dct); int mlx5_core_create_rq_tracked(struct mlx5_core_dev *dev, u32 *in, int inlen, From owner-svn-src-all@freebsd.org Mon Nov 16 10:06:11 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B98282EA297; Mon, 16 Nov 2020 10:06:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZPq74tMkz4sKG; Mon, 16 Nov 2020 10:06:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 994414191; Mon, 16 Nov 2020 10:06:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGA6B9C026662; Mon, 16 Nov 2020 10:06:11 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGA6AKP026658; Mon, 16 Nov 2020 10:06:10 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011161006.0AGA6AKP026658@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 16 Nov 2020 10:06:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367717 - in head/sys/dev/mlx5: . mlx5_core mlx5_en mlx5_ib X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/dev/mlx5: . mlx5_core mlx5_en mlx5_ib X-SVN-Commit-Revision: 367717 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 10:06:11 -0000 Author: hselasky Date: Mon Nov 16 10:06:10 2020 New Revision: 367717 URL: https://svnweb.freebsd.org/changeset/base/367717 Log: Enhance the mlx5_core_create_cq() function in mlx5core. Enhance mlx5_core_create_cq() to get the command out buffer from the callers to let them use the output. Linux commit: 38164b771947be9baf06e78ffdfb650f8f3e908e MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sys/dev/mlx5/cq.h head/sys/dev/mlx5/mlx5_core/mlx5_cq.c head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c Modified: head/sys/dev/mlx5/cq.h ============================================================================== --- head/sys/dev/mlx5/cq.h Mon Nov 16 10:03:18 2020 (r367716) +++ head/sys/dev/mlx5/cq.h Mon Nov 16 10:06:10 2020 (r367717) @@ -155,7 +155,7 @@ static inline void mlx5_cq_arm(struct mlx5_core_cq *cq int mlx5_init_cq_table(struct mlx5_core_dev *dev); void mlx5_cleanup_cq_table(struct mlx5_core_dev *dev); int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, - u32 *in, int inlen); + u32 *in, int inlen, u32 *out, int outlen); int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq); int mlx5_core_query_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, u32 *out, int outlen); Modified: head/sys/dev/mlx5/mlx5_core/mlx5_cq.c ============================================================================== --- head/sys/dev/mlx5/mlx5_core/mlx5_cq.c Mon Nov 16 10:03:18 2020 (r367716) +++ head/sys/dev/mlx5/mlx5_core/mlx5_cq.c Mon Nov 16 10:06:10 2020 (r367717) @@ -119,16 +119,16 @@ void mlx5_cq_event(struct mlx5_core_dev *dev, u32 cqn, } int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, - u32 *in, int inlen) + u32 *in, int inlen, u32 *out, int outlen) { struct mlx5_cq_table *table = &dev->priv.cq_table; - u32 out[MLX5_ST_SZ_DW(create_cq_out)] = {0}; u32 din[MLX5_ST_SZ_DW(destroy_cq_in)] = {0}; u32 dout[MLX5_ST_SZ_DW(destroy_cq_out)] = {0}; int err; + memset(out, 0, outlen); MLX5_SET(create_cq_in, in, opcode, MLX5_CMD_OP_CREATE_CQ); - err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); + err = mlx5_cmd_exec(dev, in, inlen, out, outlen); if (err) return err; Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Nov 16 10:03:18 2020 (r367716) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Nov 16 10:06:10 2020 (r367717) @@ -1989,6 +1989,7 @@ static int mlx5e_enable_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param, int eq_ix) { struct mlx5_core_cq *mcq = &cq->mcq; + u32 out[MLX5_ST_SZ_DW(create_cq_out)]; void *in; void *cqc; int inlen; @@ -2017,7 +2018,7 @@ mlx5e_enable_cq(struct mlx5e_cq *cq, struct mlx5e_cq_p PAGE_SHIFT); MLX5_SET64(cqc, cqc, dbr_addr, cq->wq_ctrl.db.dma); - err = mlx5_core_create_cq(cq->priv->mdev, mcq, in, inlen); + err = mlx5_core_create_cq(cq->priv->mdev, mcq, in, inlen, out, sizeof(out)); kvfree(in); Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c ============================================================================== --- head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c Mon Nov 16 10:03:18 2020 (r367716) +++ head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c Mon Nov 16 10:06:10 2020 (r367717) @@ -905,6 +905,7 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibde int entries = attr->cqe; int vector = attr->comp_vector; struct mlx5_ib_dev *dev = to_mdev(ibdev); + u32 out[MLX5_ST_SZ_DW(create_cq_out)]; struct mlx5_ib_cq *cq; int uninitialized_var(index); int uninitialized_var(inlen); @@ -969,7 +970,7 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibde if (cq->create_flags & IB_CQ_FLAGS_IGNORE_OVERRUN) MLX5_SET(cqc, cqc, oi, 1); - err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen); + err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen, out, sizeof(out)); if (err) goto err_cqb; From owner-svn-src-all@freebsd.org Mon Nov 16 10:10:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BED822EA42C; Mon, 16 Nov 2020 10:10:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZPwb4qBLz4snx; Mon, 16 Nov 2020 10:10:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 984EF42FD; Mon, 16 Nov 2020 10:10:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGAAt7H029272; Mon, 16 Nov 2020 10:10:55 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGAArDQ029261; Mon, 16 Nov 2020 10:10:53 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011161010.0AGAArDQ029261@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 16 Nov 2020 10:10:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367718 - in head/sys/dev/mlx5: . mlx5_core mlx5_en mlx5_ib X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/dev/mlx5: . mlx5_core mlx5_en mlx5_ib X-SVN-Commit-Revision: 367718 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 10:10:55 -0000 Author: hselasky Date: Mon Nov 16 10:10:53 2020 New Revision: 367718 URL: https://svnweb.freebsd.org/changeset/base/367718 Log: Report EQE data upon CQ completion in mlx5core. Report EQE data upon CQ completion to let upper layers use this data. Linux commit: 4e0e2ea1886afe8c001971ff767f6670312a9b04 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sys/dev/mlx5/cq.h head/sys/dev/mlx5/driver.h head/sys/dev/mlx5/mlx5_core/mlx5_cq.c head/sys/dev/mlx5/mlx5_core/mlx5_eq.c head/sys/dev/mlx5/mlx5_en/en.h head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c head/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c Modified: head/sys/dev/mlx5/cq.h ============================================================================== --- head/sys/dev/mlx5/cq.h Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/cq.h Mon Nov 16 10:10:53 2020 (r367718) @@ -32,7 +32,7 @@ #include #include - +struct mlx5_eqe; struct mlx5_core_cq { u32 cqn; int cqe_sz; @@ -40,7 +40,7 @@ struct mlx5_core_cq { __be32 *arm_db; unsigned vector; int irqn; - void (*comp) (struct mlx5_core_cq *); + void (*comp) (struct mlx5_core_cq *, struct mlx5_eqe *); void (*event) (struct mlx5_core_cq *, int); struct mlx5_uar *uar; u32 cons_index; Modified: head/sys/dev/mlx5/driver.h ============================================================================== --- head/sys/dev/mlx5/driver.h Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/driver.h Mon Nov 16 10:10:53 2020 (r367718) @@ -1021,7 +1021,7 @@ void mlx5_unregister_debugfs(void); int mlx5_eq_init(struct mlx5_core_dev *dev); void mlx5_eq_cleanup(struct mlx5_core_dev *dev); void mlx5_fill_page_array(struct mlx5_buf *buf, __be64 *pas); -void mlx5_cq_completion(struct mlx5_core_dev *dev, u32 cqn); +void mlx5_cq_completion(struct mlx5_core_dev *dev, struct mlx5_eqe *eqe); void mlx5_rsc_event(struct mlx5_core_dev *dev, u32 rsn, int event_type); void mlx5_srq_event(struct mlx5_core_dev *dev, u32 srqn, int event_type); struct mlx5_core_srq *mlx5_core_get_srq(struct mlx5_core_dev *dev, u32 srqn); Modified: head/sys/dev/mlx5/mlx5_core/mlx5_cq.c ============================================================================== --- head/sys/dev/mlx5/mlx5_core/mlx5_cq.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_core/mlx5_cq.c Mon Nov 16 10:10:53 2020 (r367718) @@ -55,13 +55,16 @@ mlx5_cq_table_write_unlock(struct mlx5_cq_table *table NET_EPOCH_WAIT(); } -void mlx5_cq_completion(struct mlx5_core_dev *dev, u32 cqn) +void mlx5_cq_completion(struct mlx5_core_dev *dev, struct mlx5_eqe *eqe) { struct mlx5_cq_table *table = &dev->priv.cq_table; struct mlx5_core_cq *cq; struct epoch_tracker et; + u32 cqn; bool do_lock; + cqn = be32_to_cpu(eqe->data.comp.cqn) & 0xffffff; + NET_EPOCH_ENTER(et); do_lock = atomic_read(&table->writercount) != 0; @@ -78,7 +81,7 @@ void mlx5_cq_completion(struct mlx5_core_dev *dev, u32 if (likely(cq != NULL)) { ++cq->arm_sn; - cq->comp(cq); + cq->comp(cq, eqe); } else { mlx5_core_warn(dev, "Completion event for bogus CQ 0x%x\n", cqn); Modified: head/sys/dev/mlx5/mlx5_core/mlx5_eq.c ============================================================================== --- head/sys/dev/mlx5/mlx5_core/mlx5_eq.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_core/mlx5_eq.c Mon Nov 16 10:10:53 2020 (r367718) @@ -246,8 +246,7 @@ static int mlx5_eq_int(struct mlx5_core_dev *dev, stru eq->eqn, eqe_type_str(eqe->type)); switch (eqe->type) { case MLX5_EVENT_TYPE_COMP: - cqn = be32_to_cpu(eqe->data.comp.cqn) & 0xffffff; - mlx5_cq_completion(dev, cqn); + mlx5_cq_completion(dev, eqe); break; case MLX5_EVENT_TYPE_PATH_MIG: Modified: head/sys/dev/mlx5/mlx5_en/en.h ============================================================================== --- head/sys/dev/mlx5/mlx5_en/en.h Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_en/en.h Mon Nov 16 10:10:53 2020 (r367718) @@ -149,7 +149,7 @@ MALLOC_DECLARE(M_MLX5EN); struct mlx5_core_dev; struct mlx5e_cq; -typedef void (mlx5e_cq_comp_t)(struct mlx5_core_cq *); +typedef void (mlx5e_cq_comp_t)(struct mlx5_core_cq *, struct mlx5_eqe *); #define mlx5_en_err(_dev, format, ...) \ if_printf(_dev, "ERR: ""%s:%d:(pid %d): " format, \ @@ -1107,8 +1107,8 @@ int mlx5e_open_locked(struct ifnet *); int mlx5e_close_locked(struct ifnet *); void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, int event); -void mlx5e_rx_cq_comp(struct mlx5_core_cq *); -void mlx5e_tx_cq_comp(struct mlx5_core_cq *); +mlx5e_cq_comp_t mlx5e_rx_cq_comp; +mlx5e_cq_comp_t mlx5e_tx_cq_comp; struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq); void mlx5e_dim_work(struct work_struct *); Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Nov 16 10:10:53 2020 (r367718) @@ -1898,7 +1898,7 @@ mlx5e_drain_sq(struct mlx5e_sq *sq) mdev->state != MLX5_DEVICE_STATE_INTERNAL_ERROR) { mtx_unlock(&sq->lock); msleep(1); - sq->cq.mcq.comp(&sq->cq.mcq); + sq->cq.mcq.comp(&sq->cq.mcq, NULL); mtx_lock(&sq->lock); } mtx_unlock(&sq->lock); @@ -1916,7 +1916,7 @@ mlx5e_drain_sq(struct mlx5e_sq *sq) mdev->state != MLX5_DEVICE_STATE_INTERNAL_ERROR) { mtx_unlock(&sq->lock); msleep(1); - sq->cq.mcq.comp(&sq->cq.mcq); + sq->cq.mcq.comp(&sq->cq.mcq, NULL); mtx_lock(&sq->lock); } mtx_unlock(&sq->lock); @@ -2229,7 +2229,7 @@ mlx5e_open_channel(struct mlx5e_priv *priv, /* poll receive queue initially */ NET_EPOCH_ENTER(et); - c->rq.cq.mcq.comp(&c->rq.cq.mcq); + c->rq.cq.mcq.comp(&c->rq.cq.mcq, NULL); NET_EPOCH_EXIT(et); return (0); @@ -3805,7 +3805,7 @@ mlx5e_disable_rx_dma(struct mlx5e_channel *ch) while (!mlx5_wq_ll_is_empty(&rq->wq)) { msleep(1); NET_EPOCH_ENTER(et); - rq->cq.mcq.comp(&rq->cq.mcq); + rq->cq.mcq.comp(&rq->cq.mcq, NULL); NET_EPOCH_EXIT(et); } @@ -3838,7 +3838,7 @@ mlx5e_enable_rx_dma(struct mlx5e_channel *ch) rq->enabled = 1; NET_EPOCH_ENTER(et); - rq->cq.mcq.comp(&rq->cq.mcq); + rq->cq.mcq.comp(&rq->cq.mcq, NULL); NET_EPOCH_EXIT(et); } Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c Mon Nov 16 10:10:53 2020 (r367718) @@ -232,7 +232,7 @@ mlx5e_rl_open_channel(struct mlx5e_rl_worker *rlw, int *ppsq = sq; /* poll TX queue initially */ - sq->cq.mcq.comp(&sq->cq.mcq); + sq->cq.mcq.comp(&sq->cq.mcq, NULL); return (0); Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Mon Nov 16 10:10:53 2020 (r367718) @@ -537,7 +537,7 @@ wq_ll_pop: } void -mlx5e_rx_cq_comp(struct mlx5_core_cq *mcq) +mlx5e_rx_cq_comp(struct mlx5_core_cq *mcq, struct mlx5_eqe *eqe __unused) { struct mlx5e_rq *rq = container_of(mcq, struct mlx5e_rq, cq.mcq); int i = 0; Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Mon Nov 16 10:10:53 2020 (r367718) @@ -871,7 +871,7 @@ select_queue: } void -mlx5e_tx_cq_comp(struct mlx5_core_cq *mcq) +mlx5e_tx_cq_comp(struct mlx5_core_cq *mcq, struct mlx5_eqe *eqe __unused) { struct mlx5e_sq *sq = container_of(mcq, struct mlx5e_sq, cq.mcq); Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c ============================================================================== --- head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c Mon Nov 16 10:10:53 2020 (r367718) @@ -31,7 +31,7 @@ #include #include "mlx5_ib.h" -static void mlx5_ib_cq_comp(struct mlx5_core_cq *cq) +static void mlx5_ib_cq_comp(struct mlx5_core_cq *cq, struct mlx5_eqe *eqe __unused) { struct ib_cq *ibcq = &to_mibcq(cq)->ibcq; Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c ============================================================================== --- head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c Mon Nov 16 10:06:10 2020 (r367717) +++ head/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c Mon Nov 16 10:10:53 2020 (r367718) @@ -2459,7 +2459,7 @@ static void mlx5_ib_handle_internal_error(struct mlx5_ * lock/unlock above locks Now need to arm all involved CQs. */ list_for_each_entry(mcq, &cq_armed_list, reset_notify) { - mcq->comp(mcq); + mcq->comp(mcq, NULL); } spin_unlock_irqrestore(&ibdev->reset_flow_resource_lock, flags); } From owner-svn-src-all@freebsd.org Mon Nov 16 10:15:04 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D6FDB2EA459; Mon, 16 Nov 2020 10:15:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZQ1N5nvWz4t3N; Mon, 16 Nov 2020 10:15:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA0C941E2; Mon, 16 Nov 2020 10:15:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGAF4pM033159; Mon, 16 Nov 2020 10:15:04 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGAF3OS033155; Mon, 16 Nov 2020 10:15:03 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011161015.0AGAF3OS033155@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 16 Nov 2020 10:15:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367719 - in head/sys/dev/mlx5: . mlx5_core mlx5_ib X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/dev/mlx5: . mlx5_core mlx5_ib X-SVN-Commit-Revision: 367719 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 10:15:04 -0000 Author: hselasky Date: Mon Nov 16 10:15:03 2020 New Revision: 367719 URL: https://svnweb.freebsd.org/changeset/base/367719 Log: Make mlx5_cmd_exec_cb() a safe API in mlx5core. APIs that have deferred callbacks should have some kind of cleanup function that callers can use to fence the callbacks. Otherwise things like module unloading can lead to dangling function pointers, or worse. The IB MR code is the only place that calls this function and had a really poor attempt at creating this fence. Provide a good version in the core code as future patches will add more places that need this fence. Linux commit: e355477ed9e4f401e3931043df97325d38552d54 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sys/dev/mlx5/driver.h head/sys/dev/mlx5/mlx5_core/mlx5_cmd.c head/sys/dev/mlx5/mlx5_core/mlx5_mr.c head/sys/dev/mlx5/mlx5_ib/mlx5_ib.h head/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c Modified: head/sys/dev/mlx5/driver.h ============================================================================== --- head/sys/dev/mlx5/driver.h Mon Nov 16 10:10:53 2020 (r367718) +++ head/sys/dev/mlx5/driver.h Mon Nov 16 10:15:03 2020 (r367719) @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -947,11 +948,30 @@ void mlx5_cmd_use_events(struct mlx5_core_dev *dev); void mlx5_cmd_use_polling(struct mlx5_core_dev *dev); void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome); int mlx5_core_get_caps(struct mlx5_core_dev *dev, enum mlx5_cap_type cap_type); + +struct mlx5_async_ctx { + struct mlx5_core_dev *dev; + atomic_t num_inflight; + struct wait_queue_head wait; +}; + +struct mlx5_async_work; + +typedef void (*mlx5_async_cbk_t)(int status, struct mlx5_async_work *context); + +struct mlx5_async_work { + struct mlx5_async_ctx *ctx; + mlx5_async_cbk_t user_callback; +}; + +void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev, + struct mlx5_async_ctx *ctx); +void mlx5_cmd_cleanup_async_ctx(struct mlx5_async_ctx *ctx); +int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size, + void *out, int out_size, mlx5_async_cbk_t callback, + struct mlx5_async_work *work); int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size); -int mlx5_cmd_exec_cb(struct mlx5_core_dev *dev, void *in, int in_size, - void *out, int out_size, mlx5_cmd_cbk_t callback, - void *context); int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size); int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn); @@ -986,9 +1006,10 @@ void mlx5_init_mr_table(struct mlx5_core_dev *dev); void mlx5_cleanup_mr_table(struct mlx5_core_dev *dev); int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev, struct mlx5_core_mr *mkey, - u32 *in, int inlen, - u32 *out, int outlen, - mlx5_cmd_cbk_t callback, void *context); + struct mlx5_async_ctx *async_ctx, u32 *in, + int inlen, u32 *out, int outlen, + mlx5_async_cbk_t callback, + struct mlx5_async_work *context); int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, u32 *in, int inlen); Modified: head/sys/dev/mlx5/mlx5_core/mlx5_cmd.c ============================================================================== --- head/sys/dev/mlx5/mlx5_core/mlx5_cmd.c Mon Nov 16 10:10:53 2020 (r367718) +++ head/sys/dev/mlx5/mlx5_core/mlx5_cmd.c Mon Nov 16 10:15:03 2020 (r367719) @@ -1353,11 +1353,57 @@ int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, } EXPORT_SYMBOL(mlx5_cmd_exec); -int mlx5_cmd_exec_cb(struct mlx5_core_dev *dev, void *in, int in_size, - void *out, int out_size, mlx5_cmd_cbk_t callback, - void *context) +void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev, + struct mlx5_async_ctx *ctx) { - return cmd_exec_helper(dev, in, in_size, out, out_size, callback, context, false); + ctx->dev = dev; + /* Starts at 1 to avoid doing wake_up if we are not cleaning up */ + atomic_set(&ctx->num_inflight, 1); + init_waitqueue_head(&ctx->wait); +} +EXPORT_SYMBOL(mlx5_cmd_init_async_ctx); + +/** + * mlx5_cmd_cleanup_async_ctx - Clean up an async_ctx + * @ctx: The ctx to clean + * + * Upon return all callbacks given to mlx5_cmd_exec_cb() have been called. The + * caller must ensure that mlx5_cmd_exec_cb() is not called during or after + * the call mlx5_cleanup_async_ctx(). + */ +void mlx5_cmd_cleanup_async_ctx(struct mlx5_async_ctx *ctx) +{ + atomic_dec(&ctx->num_inflight); + wait_event(ctx->wait, atomic_read(&ctx->num_inflight) == 0); +} +EXPORT_SYMBOL(mlx5_cmd_cleanup_async_ctx); + +static void mlx5_cmd_exec_cb_handler(int status, void *_work) +{ + struct mlx5_async_work *work = _work; + struct mlx5_async_ctx *ctx = work->ctx; + + work->user_callback(status, work); + if (atomic_dec_and_test(&ctx->num_inflight)) + wake_up(&ctx->wait); +} + +int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size, + void *out, int out_size, mlx5_async_cbk_t callback, + struct mlx5_async_work *work) +{ + int ret; + + work->ctx = ctx; + work->user_callback = callback; + if (WARN_ON(!atomic_inc_not_zero(&ctx->num_inflight))) + return -EIO; + ret = cmd_exec_helper(ctx->dev, in, in_size, out, out_size, + mlx5_cmd_exec_cb_handler, work, false); + if (ret && atomic_dec_and_test(&ctx->num_inflight)) + wake_up(&ctx->wait); + + return ret; } EXPORT_SYMBOL(mlx5_cmd_exec_cb); Modified: head/sys/dev/mlx5/mlx5_core/mlx5_mr.c ============================================================================== --- head/sys/dev/mlx5/mlx5_core/mlx5_mr.c Mon Nov 16 10:10:53 2020 (r367718) +++ head/sys/dev/mlx5/mlx5_core/mlx5_mr.c Mon Nov 16 10:15:03 2020 (r367719) @@ -50,9 +50,10 @@ void mlx5_cleanup_mr_table(struct mlx5_core_dev *dev) int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev, struct mlx5_core_mr *mkey, - u32 *in, int inlen, - u32 *out, int outlen, - mlx5_cmd_cbk_t callback, void *context) + struct mlx5_async_ctx *async_ctx, u32 *in, + int inlen, u32 *out, int outlen, + mlx5_async_cbk_t callback, + struct mlx5_async_work *context) { struct mlx5_mr_table *table = &dev->priv.mr_table; u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; @@ -77,7 +78,7 @@ int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev } if (callback) - return mlx5_cmd_exec_cb(dev, in, inlen, out, outlen, + return mlx5_cmd_exec_cb(async_ctx, in, inlen, out, outlen, callback, context); err = mlx5_cmd_exec(dev, in, inlen, lout, sizeof(lout)); @@ -113,7 +114,7 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mkey, u32 *in, int inlen) { - return mlx5_core_create_mkey_cb(dev, mkey, in, inlen, + return mlx5_core_create_mkey_cb(dev, mkey, NULL, in, inlen, NULL, 0, NULL, NULL); } EXPORT_SYMBOL(mlx5_core_create_mkey); Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib.h ============================================================================== --- head/sys/dev/mlx5/mlx5_ib/mlx5_ib.h Mon Nov 16 10:10:53 2020 (r367718) +++ head/sys/dev/mlx5/mlx5_ib/mlx5_ib.h Mon Nov 16 10:15:03 2020 (r367719) @@ -509,6 +509,7 @@ struct mlx5_ib_mr { int live; void *descs_alloc; int access_flags; /* Needed for rereg MR */ + struct mlx5_async_work cb_work; }; struct mlx5_ib_mw { @@ -693,6 +694,8 @@ struct mlx5_ib_dev { /* Array with num_ports elements */ struct mlx5_ib_port *port; struct mlx5_ib_congestion congestion; + + struct mlx5_async_ctx async_ctx; }; static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq) Modified: head/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c ============================================================================== --- head/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c Mon Nov 16 10:10:53 2020 (r367718) +++ head/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c Mon Nov 16 10:15:03 2020 (r367719) @@ -104,9 +104,10 @@ static void update_odp_mr(struct mlx5_ib_mr *mr) } #endif -static void reg_mr_callback(int status, void *context) +static void reg_mr_callback(int status, struct mlx5_async_work *context) { - struct mlx5_ib_mr *mr = context; + struct mlx5_ib_mr *mr = + container_of(context, struct mlx5_ib_mr, cb_work); struct mlx5_ib_dev *dev = mr->dev; struct mlx5_mr_cache *cache = &dev->cache; int c = order2idx(dev, mr->order); @@ -192,9 +193,9 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, in ent->pending++; spin_unlock_irq(&ent->lock); err = mlx5_core_create_mkey_cb(dev->mdev, &mr->mmkey, - in, inlen, + &dev->async_ctx, in, inlen, mr->out, sizeof(mr->out), - reg_mr_callback, mr); + reg_mr_callback, &mr->cb_work); if (err) { spin_lock_irq(&ent->lock); ent->pending--; @@ -429,6 +430,7 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) return -ENOMEM; } + mlx5_cmd_init_async_ctx(dev->mdev, &dev->async_ctx); setup_timer(&dev->delay_timer, delay_time_func, (unsigned long)dev); for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) { INIT_LIST_HEAD(&cache->ent[i].head); @@ -460,6 +462,7 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) dev->cache.stopped = 1; flush_workqueue(dev->cache.wq); + mlx5_cmd_cleanup_async_ctx(&dev->async_ctx); for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) clean_keys(dev, i); From owner-svn-src-all@freebsd.org Mon Nov 16 11:38:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4E09B2EC0ED; Mon, 16 Nov 2020 11:38:52 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZRt41m9lz3GP2; Mon, 16 Nov 2020 11:38:52 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F2B54EF2; Mon, 16 Nov 2020 11:38:52 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGBcq0L090681; Mon, 16 Nov 2020 11:38:52 GMT (envelope-from arichardson@FreeBSD.org) Received: (from arichardson@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGBcqco090680; Mon, 16 Nov 2020 11:38:52 GMT (envelope-from arichardson@FreeBSD.org) Message-Id: <202011161138.0AGBcqco090680@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arichardson set sender to arichardson@FreeBSD.org using -f From: Alex Richardson Date: Mon, 16 Nov 2020 11:38:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367720 - head/tools/build X-SVN-Group: head X-SVN-Commit-Author: arichardson X-SVN-Commit-Paths: head/tools/build X-SVN-Commit-Revision: 367720 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 11:38:52 -0000 Author: arichardson Date: Mon Nov 16 11:38:51 2020 New Revision: 367720 URL: https://svnweb.freebsd.org/changeset/base/367720 Log: Revert "When building on Ubuntu bootstrap bmake with bash as the default shell" This reverts r365950 since the latest bmake update includes fixes for the test failures that prompted the change. Modified: head/tools/build/make.py Modified: head/tools/build/make.py ============================================================================== --- head/tools/build/make.py Mon Nov 16 10:15:03 2020 (r367719) +++ head/tools/build/make.py Mon Nov 16 11:38:51 2020 (r367720) @@ -81,14 +81,6 @@ def bootstrap_bmake(source_root, objdir_prefix): "--with-default-sys-path=" + str(bmake_install_dir / "share/mk"), "--with-machine=amd64", # TODO? "--with-machine-arch=amd64", "--without-filemon", "--prefix=" + str(bmake_install_dir)] - - if Path("/bin/sh").resolve().name == "dash": - # Note: we have to avoid using dash as the default shell since it - # filters out variables containing characters such as '-' and that - # breaks the bmake bootstrap tests. - # TODO: remove this when the bootstrap tests have been fixed. - configure_args.append("--with-defshell=/bin/bash") - run(["sh", bmake_source_dir / "boot-strap"] + configure_args, cwd=str(bmake_build_dir), env=env) From owner-svn-src-all@freebsd.org Mon Nov 16 11:53:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6ECD12EC8BE; Mon, 16 Nov 2020 11:53:37 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZSC52ksLz3H9f; Mon, 16 Nov 2020 11:53:37 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 50AEA58CB; Mon, 16 Nov 2020 11:53:37 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGBrbv1002510; Mon, 16 Nov 2020 11:53:37 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGBrbft002509; Mon, 16 Nov 2020 11:53:37 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011161153.0AGBrbft002509@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 16 Nov 2020 11:53:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367721 - head/sys/dev/mmc/host X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/mmc/host X-SVN-Commit-Revision: 367721 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 11:53:37 -0000 Author: manu Date: Mon Nov 16 11:53:36 2020 New Revision: 367721 URL: https://svnweb.freebsd.org/changeset/base/367721 Log: dwmmc: dwmmc_switch_vccq is only used in MMCCAM kernel Silence the build for non MMCCAM kernel Modified: head/sys/dev/mmc/host/dwmmc.c Modified: head/sys/dev/mmc/host/dwmmc.c ============================================================================== --- head/sys/dev/mmc/host/dwmmc.c Mon Nov 16 11:38:51 2020 (r367720) +++ head/sys/dev/mmc/host/dwmmc.c Mon Nov 16 11:53:36 2020 (r367721) @@ -143,8 +143,8 @@ static int dma_stop(struct dwmmc_softc *); static void pio_read(struct dwmmc_softc *, struct mmc_command *); static void pio_write(struct dwmmc_softc *, struct mmc_command *); static void dwmmc_handle_card_present(struct dwmmc_softc *sc, bool is_present); -static int dwmmc_switch_vccq(device_t, device_t); #ifdef MMCCAM +static int dwmmc_switch_vccq(device_t, device_t); static void dwmmc_cam_action(struct cam_sim *, union ccb *); static void dwmmc_cam_poll(struct cam_sim *); static int dwmmc_cam_settran_settings(struct dwmmc_softc *, union ccb *); @@ -1418,6 +1418,7 @@ dwmmc_write_ivar(device_t bus, device_t child, int whi return (0); } +#ifdef MMCCAM /* Note: this function likely belongs to the specific driver impl */ static int dwmmc_switch_vccq(device_t dev, device_t child) @@ -1426,7 +1427,6 @@ dwmmc_switch_vccq(device_t dev, device_t child) return EINVAL; } -#ifdef MMCCAM static void dwmmc_cam_handle_mmcio(struct cam_sim *sim, union ccb *ccb) { From owner-svn-src-all@freebsd.org Mon Nov 16 11:54:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C7352ECA86; Mon, 16 Nov 2020 11:54:39 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZSDH109kz3Hb8; Mon, 16 Nov 2020 11:54:39 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1078B5901; Mon, 16 Nov 2020 11:54:39 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGBscG3002598; Mon, 16 Nov 2020 11:54:38 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGBsc0D002597; Mon, 16 Nov 2020 11:54:38 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011161154.0AGBsc0D002597@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 16 Nov 2020 11:54:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367722 - head/sys/arm64/freescale/imx X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm64/freescale/imx X-SVN-Commit-Revision: 367722 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 11:54:39 -0000 Author: manu Date: Mon Nov 16 11:54:38 2020 New Revision: 367722 URL: https://svnweb.freebsd.org/changeset/base/367722 Log: imx7gpc: Remove unused functions Modified: head/sys/arm64/freescale/imx/imx7gpc.c Modified: head/sys/arm64/freescale/imx/imx7gpc.c ============================================================================== --- head/sys/arm64/freescale/imx/imx7gpc.c Mon Nov 16 11:53:36 2020 (r367721) +++ head/sys/arm64/freescale/imx/imx7gpc.c Mon Nov 16 11:54:38 2020 (r367722) @@ -59,20 +59,6 @@ static struct ofw_compat_data compat_data[] = { { NULL, 0} }; -static inline uint32_t -imx7gpc_read_4(struct imx7gpc_softc *sc, int reg) -{ - - return (bus_read_4(sc->memres, reg)); -} - -static inline void -imx7gpc_write_4(struct imx7gpc_softc *sc, int reg, uint32_t val) -{ - - bus_write_4(sc->memres, reg, val); -} - static int imx7gpc_activate_intr(device_t dev, struct intr_irqsrc *isrc, struct resource *res, struct intr_map_data *data) From owner-svn-src-all@freebsd.org Mon Nov 16 11:57:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED20D2ECAFD; Mon, 16 Nov 2020 11:57:49 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZSHx6PV0z3Htj; Mon, 16 Nov 2020 11:57:49 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CA60C5734; Mon, 16 Nov 2020 11:57:49 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGBvn5l002972; Mon, 16 Nov 2020 11:57:49 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGBvns1002971; Mon, 16 Nov 2020 11:57:49 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011161157.0AGBvns1002971@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Mon, 16 Nov 2020 11:57:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367723 - stable/12/lib/libc/gen X-SVN-Group: stable-12 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/12/lib/libc/gen X-SVN-Commit-Revision: 367723 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 11:57:50 -0000 Author: 0mp (doc,ports committer) Date: Mon Nov 16 11:57:49 2020 New Revision: 367723 URL: https://svnweb.freebsd.org/changeset/base/367723 Log: MFC r367639: Reference setprogname(3) in setproctitle(3) The reference to setproctitle(3) in the setprogname(3) manual is already in place. Modified: stable/12/lib/libc/gen/setproctitle.3 Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/gen/setproctitle.3 ============================================================================== --- stable/12/lib/libc/gen/setproctitle.3 Mon Nov 16 11:54:38 2020 (r367722) +++ stable/12/lib/libc/gen/setproctitle.3 Mon Nov 16 11:57:49 2020 (r367723) @@ -20,7 +20,7 @@ .\" $FreeBSD$ .\" .\" The following requests are required for all man pages. -.Dd July 4, 2018 +.Dd November 13, 2020 .Dt SETPROCTITLE 3 .Os .Sh NAME @@ -69,6 +69,7 @@ setproctitle("talking to %s", inet_ntoa(addr)); .Sh SEE ALSO .Xr ps 1 , .Xr w 1 , +.Xr setprogname 3 , .Xr kvm 3 , .Xr kvm_getargv 3 , .Xr printf 3 From owner-svn-src-all@freebsd.org Mon Nov 16 11:58:23 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 097822ECE2E; Mon, 16 Nov 2020 11:58:23 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZSJZ6rg2z3HsW; Mon, 16 Nov 2020 11:58:22 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DDCF158CF; Mon, 16 Nov 2020 11:58:22 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGBwMUs003059; Mon, 16 Nov 2020 11:58:22 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGBwMAN003058; Mon, 16 Nov 2020 11:58:22 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011161158.0AGBwMAN003058@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Mon, 16 Nov 2020 11:58:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r367724 - stable/11/lib/libc/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/11/lib/libc/gen X-SVN-Commit-Revision: 367724 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 11:58:23 -0000 Author: 0mp (doc,ports committer) Date: Mon Nov 16 11:58:22 2020 New Revision: 367724 URL: https://svnweb.freebsd.org/changeset/base/367724 Log: MFC r367639: Reference setprogname(3) in setproctitle(3) The reference to setproctitle(3) in the setprogname(3) manual is already in place. Modified: stable/11/lib/libc/gen/setproctitle.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/setproctitle.3 ============================================================================== --- stable/11/lib/libc/gen/setproctitle.3 Mon Nov 16 11:57:49 2020 (r367723) +++ stable/11/lib/libc/gen/setproctitle.3 Mon Nov 16 11:58:22 2020 (r367724) @@ -20,7 +20,7 @@ .\" $FreeBSD$ .\" .\" The following requests are required for all man pages. -.Dd July 4, 2018 +.Dd November 13, 2020 .Dt SETPROCTITLE 3 .Os .Sh NAME @@ -69,6 +69,7 @@ setproctitle("talking to %s", inet_ntoa(addr)); .Sh SEE ALSO .Xr ps 1 , .Xr w 1 , +.Xr setprogname 3 , .Xr kvm 3 , .Xr kvm_getargv 3 , .Xr printf 3 From owner-svn-src-all@freebsd.org Mon Nov 16 15:29:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5DFB54698CE; Mon, 16 Nov 2020 15:29:53 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZY0d2GJ5z3ky9; Mon, 16 Nov 2020 15:29:53 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 40B357A74; Mon, 16 Nov 2020 15:29:53 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGFTrKN048905; Mon, 16 Nov 2020 15:29:53 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGFTqTh048902; Mon, 16 Nov 2020 15:29:52 GMT (envelope-from br@FreeBSD.org) Message-Id: <202011161529.0AGFTqTh048902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 16 Nov 2020 15:29:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367725 - in head/sys: dev/iommu x86/iommu X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/sys: dev/iommu x86/iommu X-SVN-Commit-Revision: 367725 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 15:29:53 -0000 Author: br Date: Mon Nov 16 15:29:52 2020 New Revision: 367725 URL: https://svnweb.freebsd.org/changeset/base/367725 Log: Add device_t member to struct iommu. This is needed on arm64 for the interface between iommu framework and iommu controller drivers. Reviewed by: kib Sponsored by: Innovate DSbD Differential Revision: https://reviews.freebsd.org/D27229 Modified: head/sys/dev/iommu/iommu.h head/sys/x86/iommu/intel_drv.c Modified: head/sys/dev/iommu/iommu.h ============================================================================== --- head/sys/dev/iommu/iommu.h Mon Nov 16 11:58:22 2020 (r367724) +++ head/sys/dev/iommu/iommu.h Mon Nov 16 15:29:52 2020 (r367725) @@ -67,6 +67,7 @@ struct iommu_map_entry { struct iommu_unit { struct mtx lock; + device_t dev; int unit; int dma_enabled; Modified: head/sys/x86/iommu/intel_drv.c ============================================================================== --- head/sys/x86/iommu/intel_drv.c Mon Nov 16 11:58:22 2020 (r367724) +++ head/sys/x86/iommu/intel_drv.c Mon Nov 16 15:29:52 2020 (r367725) @@ -411,6 +411,7 @@ dmar_attach(device_t dev) unit = device_get_softc(dev); unit->dev = dev; unit->iommu.unit = device_get_unit(dev); + unit->iommu.dev = dev; dmaru = dmar_find_by_index(unit->iommu.unit); if (dmaru == NULL) return (EINVAL); From owner-svn-src-all@freebsd.org Mon Nov 16 15:37:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69C86469F8D; Mon, 16 Nov 2020 15:37:10 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZY922c4Sz3lrq; Mon, 16 Nov 2020 15:37:10 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C5561017B; Mon, 16 Nov 2020 15:37:10 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGFbAe8055157; Mon, 16 Nov 2020 15:37:10 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGFbAru055156; Mon, 16 Nov 2020 15:37:10 GMT (envelope-from br@FreeBSD.org) Message-Id: <202011161537.0AGFbAru055156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 16 Nov 2020 15:37:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367726 - head/sys/dev/iommu X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: head/sys/dev/iommu X-SVN-Commit-Revision: 367726 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 15:37:10 -0000 Author: br Date: Mon Nov 16 15:37:09 2020 New Revision: 367726 URL: https://svnweb.freebsd.org/changeset/base/367726 Log: Fix a bug in assertion: entry flags also includes IOMMU_MAP_ENTRY_UNMAPPED. The entry->flags field is initialized in iommu_gas_init_domain(). Reviewed by: kib Sponsored by: Innovate DSbD Differential Revision: https://reviews.freebsd.org/D27235 Modified: head/sys/dev/iommu/iommu_gas.c Modified: head/sys/dev/iommu/iommu_gas.c ============================================================================== --- head/sys/dev/iommu/iommu_gas.c Mon Nov 16 15:29:52 2020 (r367725) +++ head/sys/dev/iommu/iommu_gas.c Mon Nov 16 15:37:09 2020 (r367726) @@ -258,7 +258,8 @@ iommu_gas_fini_domain(struct iommu_domain *domain) entry = RB_MIN(iommu_gas_entries_tree, &domain->rb_root); KASSERT(entry->start == 0, ("start entry start %p", domain)); KASSERT(entry->end == IOMMU_PAGE_SIZE, ("start entry end %p", domain)); - KASSERT(entry->flags == IOMMU_MAP_ENTRY_PLACE, + KASSERT(entry->flags == + (IOMMU_MAP_ENTRY_PLACE | IOMMU_MAP_ENTRY_UNMAPPED), ("start entry flags %p", domain)); RB_REMOVE(iommu_gas_entries_tree, &domain->rb_root, entry); iommu_gas_free_entry(domain, entry); @@ -266,7 +267,8 @@ iommu_gas_fini_domain(struct iommu_domain *domain) entry = RB_MAX(iommu_gas_entries_tree, &domain->rb_root); KASSERT(entry->start == domain->end, ("end entry start %p", domain)); KASSERT(entry->end == domain->end, ("end entry end %p", domain)); - KASSERT(entry->flags == IOMMU_MAP_ENTRY_PLACE, + KASSERT(entry->flags == + (IOMMU_MAP_ENTRY_PLACE | IOMMU_MAP_ENTRY_UNMAPPED), ("end entry flags %p", domain)); RB_REMOVE(iommu_gas_entries_tree, &domain->rb_root, entry); iommu_gas_free_entry(domain, entry); From owner-svn-src-all@freebsd.org Mon Nov 16 16:53:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2098446B5A4; Mon, 16 Nov 2020 16:53:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZZsS4LVDz3qpc; Mon, 16 Nov 2020 16:53:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D456011782; Mon, 16 Nov 2020 16:53:47 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGGrlqi005444; Mon, 16 Nov 2020 16:53:47 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGGrllo005442; Mon, 16 Nov 2020 16:53:47 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011161653.0AGGrllo005442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 16 Nov 2020 16:53:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367727 - stable/12/sys/dev/qat X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/dev/qat X-SVN-Commit-Revision: 367727 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 16:53:49 -0000 Author: markj Date: Mon Nov 16 16:53:46 2020 New Revision: 367727 URL: https://svnweb.freebsd.org/changeset/base/367727 Log: MFC r367617: qat: Fix nits reported by Coverity Modified: stable/12/sys/dev/qat/qat.c stable/12/sys/dev/qat/qat_ae.c stable/12/sys/dev/qat/qatvar.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/qat/qat.c ============================================================================== --- stable/12/sys/dev/qat/qat.c Mon Nov 16 15:37:09 2020 (r367726) +++ stable/12/sys/dev/qat/qat.c Mon Nov 16 16:53:46 2020 (r367727) @@ -573,7 +573,8 @@ qat_detach(device_t dev) sc->sc_ih_cookie = NULL; } if (sc->sc_ih != NULL) { - (void)bus_release_resource(dev, SYS_RES_IRQ, i + 1, sc->sc_ih); + (void)bus_release_resource(dev, SYS_RES_IRQ, + sc->sc_hw.qhw_num_banks + 1, sc->sc_ih); sc->sc_ih = NULL; } pci_release_msi(dev); Modified: stable/12/sys/dev/qat/qat_ae.c ============================================================================== --- stable/12/sys/dev/qat/qat_ae.c Mon Nov 16 15:37:09 2020 (r367726) +++ stable/12/sys/dev/qat/qat_ae.c Mon Nov 16 16:53:46 2020 (r367727) @@ -2616,7 +2616,7 @@ qat_aefw_suof_load(struct qat_softc *sc, struct qat_dm static int qat_aefw_suof_write(struct qat_softc *sc) { - struct qat_suof_image *qsi = NULL; + struct qat_suof_image *qsi; int i, error = 0; for (i = 0; i < sc->sc_aefw_suof.qafs_num_simgs; i++) { @@ -2626,21 +2626,20 @@ qat_aefw_suof_write(struct qat_softc *sc) if (error) return error; error = qat_aefw_auth(sc, &qsi->qsi_dma); - if (error) - goto fail; + if (error) { + qat_free_dmamem(sc, &qsi->qsi_dma); + return error; + } error = qat_aefw_suof_load(sc, &qsi->qsi_dma); - if (error) - goto fail; - + if (error) { + qat_free_dmamem(sc, &qsi->qsi_dma); + return error; + } qat_free_dmamem(sc, &qsi->qsi_dma); } qat_free_mem(sc->sc_aefw_suof.qafs_simg); return 0; -fail: - if (qsi != NULL) - qat_free_dmamem(sc, &qsi->qsi_dma); - return error; } static int Modified: stable/12/sys/dev/qat/qatvar.h ============================================================================== --- stable/12/sys/dev/qat/qatvar.h Mon Nov 16 15:37:09 2020 (r367726) +++ stable/12/sys/dev/qat/qatvar.h Mon Nov 16 16:53:46 2020 (r367727) @@ -596,7 +596,7 @@ struct qat_crypto_desc { bus_addr_t qcd_desc_paddr; bus_addr_t qcd_hash_state_paddr; - enum fw_slice qcd_slices[MAX_FW_SLICE]; + enum fw_slice qcd_slices[MAX_FW_SLICE + 1]; enum fw_la_cmd_id qcd_cmd_id; enum hw_cipher_dir qcd_cipher_dir; From owner-svn-src-all@freebsd.org Mon Nov 16 17:20:36 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 50E8046BDD4; Mon, 16 Nov 2020 17:20:36 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZbSN1tnYz3sPd; Mon, 16 Nov 2020 17:20:36 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 343AB117D6; Mon, 16 Nov 2020 17:20:36 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGHKatW018407; Mon, 16 Nov 2020 17:20:36 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGHKZjp018405; Mon, 16 Nov 2020 17:20:35 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202011161720.0AGHKZjp018405@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 16 Nov 2020 17:20:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367728 - in head: cddl/usr.bin/ztest usr.sbin/praudit X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head: cddl/usr.bin/ztest usr.sbin/praudit X-SVN-Commit-Revision: 367728 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 17:20:36 -0000 Author: brooks Date: Mon Nov 16 17:20:35 2020 New Revision: 367728 URL: https://svnweb.freebsd.org/changeset/base/367728 Log: Add missing includes of src.opts.mk Without this "SUBDIR.${MK_TESTS}=tests" would always expand to "SUBDIR.=tests" resulting in the tests not being built. Sponsored by: DARPA Modified: head/cddl/usr.bin/ztest/Makefile head/usr.sbin/praudit/Makefile Modified: head/cddl/usr.bin/ztest/Makefile ============================================================================== --- head/cddl/usr.bin/ztest/Makefile Mon Nov 16 16:53:46 2020 (r367727) +++ head/cddl/usr.bin/ztest/Makefile Mon Nov 16 17:20:35 2020 (r367728) @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/ztest Modified: head/usr.sbin/praudit/Makefile ============================================================================== --- head/usr.sbin/praudit/Makefile Mon Nov 16 16:53:46 2020 (r367727) +++ head/usr.sbin/praudit/Makefile Mon Nov 16 17:20:35 2020 (r367728) @@ -2,6 +2,8 @@ # $FreeBSD$ # +.include + OPENBSMDIR=${SRCTOP}/contrib/openbsm .PATH: ${OPENBSMDIR}/bin/praudit From owner-svn-src-all@freebsd.org Mon Nov 16 17:41:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B778346C35C; Mon, 16 Nov 2020 17:41:05 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZbw14n6sz3tXv; Mon, 16 Nov 2020 17:41:05 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 96E1B11F91; Mon, 16 Nov 2020 17:41:05 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGHf58u032102; Mon, 16 Nov 2020 17:41:05 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGHf5js032101; Mon, 16 Nov 2020 17:41:05 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011161741.0AGHf5js032101@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Mon, 16 Nov 2020 17:41:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367729 - stable/12/release/tools X-SVN-Group: stable-12 X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: stable/12/release/tools X-SVN-Commit-Revision: 367729 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 17:41:05 -0000 Author: mhorne Date: Mon Nov 16 17:41:05 2020 New Revision: 367729 URL: https://svnweb.freebsd.org/changeset/base/367729 Log: MFC r367175: Slight refactor in vmimage.subr Modified: stable/12/release/tools/vmimage.subr Directory Properties: stable/12/ (props changed) Modified: stable/12/release/tools/vmimage.subr ============================================================================== --- stable/12/release/tools/vmimage.subr Mon Nov 16 17:20:35 2020 (r367728) +++ stable/12/release/tools/vmimage.subr Mon Nov 16 17:41:05 2020 (r367729) @@ -21,32 +21,39 @@ write_partition_layout() { case "${TARGET}:${TARGET_ARCH}" in amd64:amd64 | i386:i386) - mkimg -s gpt -f ${VMFORMAT} \ - -b ${BOOTFILES}/i386/pmbr/pmbr \ - -p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \ - -p efi:=${BOOTFILES}/efi/boot1/boot1.efifat \ - ${SWAPOPT} \ - -p freebsd-ufs/rootfs:=${VMBASE} \ - -o ${VMIMAGE} + ESP=yes + SCHEME=gpt + BOOTPARTS="-b ${BOOTFILES}/i386/pmbr/pmbr \ + -p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot" + ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}" ;; arm64:aarch64) - mkimg -s mbr -f ${VMFORMAT} \ - -p efi:=${BOOTFILES}/efi/boot1/boot1.efifat \ - -p freebsd:=${VMBASE} \ - -o ${VMIMAGE} + ESP=yes + SCHEME=mbr + BOOTPARTS= + ROOTFSPART="-p freebsd:=${VMBASE}" ;; powerpc:powerpc*) - mkimg -s apm -f ${VMFORMAT} \ - -p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \ - ${SWAPOPT} \ - -p freebsd-ufs/rootfs:=${VMBASE} \ - -o ${VMIMAGE} + ESP=no + SCHEME=apm + BOOTPARTS="-p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs" + ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}" ;; *) # ENOTSUPP return 1 ;; esac + + if [ ${ESP} = "yes" ]; then + BOOTPARTS="${BOOTPARTS} -p efi:=${BOOTFILES}/efi/boot1/boot1.efifat" + fi + + mkimg -s ${SCHEME} -f ${VMFORMAT} \ + ${BOOTPARTS} \ + ${SWAPOPT} \ + ${ROOTFSPART} \ + -o ${VMIMAGE} return 0 } From owner-svn-src-all@freebsd.org Mon Nov 16 17:42:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B71E946C88A; Mon, 16 Nov 2020 17:42:22 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZbxV4rSDz3tpG; Mon, 16 Nov 2020 17:42:22 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 990BA11F43; Mon, 16 Nov 2020 17:42:22 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGHgMSZ036935; Mon, 16 Nov 2020 17:42:22 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGHgMKd036934; Mon, 16 Nov 2020 17:42:22 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011161742.0AGHgMKd036934@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Mon, 16 Nov 2020 17:42:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367730 - stable/12/release/tools X-SVN-Group: stable-12 X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: stable/12/release/tools X-SVN-Commit-Revision: 367730 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 17:42:22 -0000 Author: mhorne Date: Mon Nov 16 17:42:22 2020 New Revision: 367730 URL: https://svnweb.freebsd.org/changeset/base/367730 Log: MFC r367176: vmimage.subr: noisier failure for unsupported targets Modified: stable/12/release/tools/vmimage.subr Directory Properties: stable/12/ (props changed) Modified: stable/12/release/tools/vmimage.subr ============================================================================== --- stable/12/release/tools/vmimage.subr Mon Nov 16 17:41:05 2020 (r367729) +++ stable/12/release/tools/vmimage.subr Mon Nov 16 17:42:22 2020 (r367730) @@ -40,8 +40,8 @@ write_partition_layout() { ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}" ;; *) - # ENOTSUPP - return 1 + echo "vmimage.subr: unsupported target '${TARGET}:${TARGET_ARCH}'" >&2 + exit 1 ;; esac From owner-svn-src-all@freebsd.org Mon Nov 16 17:44:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20F7A46C7C5; Mon, 16 Nov 2020 17:44:35 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZc030NVcz3vDN; Mon, 16 Nov 2020 17:44:35 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFEF111FA9; Mon, 16 Nov 2020 17:44:34 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGHiYC9037101; Mon, 16 Nov 2020 17:44:34 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGHiYKv037099; Mon, 16 Nov 2020 17:44:34 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011161744.0AGHiYKv037099@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Mon, 16 Nov 2020 17:44:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367731 - in stable/12/release: scripts tools X-SVN-Group: stable-12 X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: in stable/12/release: scripts tools X-SVN-Commit-Revision: 367731 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 17:44:35 -0000 Author: mhorne Date: Mon Nov 16 17:44:34 2020 New Revision: 367731 URL: https://svnweb.freebsd.org/changeset/base/367731 Log: MFC r367177: arm64: convert virtual machine images to GPT Modified: stable/12/release/scripts/mk-vmimage.sh stable/12/release/tools/vmimage.subr Directory Properties: stable/12/ (props changed) Modified: stable/12/release/scripts/mk-vmimage.sh ============================================================================== --- stable/12/release/scripts/mk-vmimage.sh Mon Nov 16 17:42:22 2020 (r367730) +++ stable/12/release/scripts/mk-vmimage.sh Mon Nov 16 17:44:34 2020 (r367731) @@ -93,15 +93,7 @@ main() { . "${VMCONFIG}" fi - case ${TARGET}:${TARGET_ARCH} in - arm64:aarch64) - ROOTLABEL="ufs" - NOSWAP=1 - ;; - *) - ROOTLABEL="gpt" - ;; - esac + ROOTLABEL="gpt" vm_create_base vm_install_base Modified: stable/12/release/tools/vmimage.subr ============================================================================== --- stable/12/release/tools/vmimage.subr Mon Nov 16 17:42:22 2020 (r367730) +++ stable/12/release/tools/vmimage.subr Mon Nov 16 17:44:34 2020 (r367731) @@ -29,9 +29,9 @@ write_partition_layout() { ;; arm64:aarch64) ESP=yes - SCHEME=mbr + SCHEME=gpt BOOTPARTS= - ROOTFSPART="-p freebsd:=${VMBASE}" + ROOTFSPART="-p freebsd-ufs/rootfs:=${VMBASE}" ;; powerpc:powerpc*) ESP=no From owner-svn-src-all@freebsd.org Mon Nov 16 17:45:43 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 770B746C8DE; Mon, 16 Nov 2020 17:45:43 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZc1M2yvGz3v97; Mon, 16 Nov 2020 17:45:43 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5833E11CF1; Mon, 16 Nov 2020 17:45:43 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGHjh0x037213; Mon, 16 Nov 2020 17:45:43 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGHjhWK037212; Mon, 16 Nov 2020 17:45:43 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011161745.0AGHjhWK037212@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Mon, 16 Nov 2020 17:45:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367732 - stable/12/release/arm64 X-SVN-Group: stable-12 X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: stable/12/release/arm64 X-SVN-Commit-Revision: 367732 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 17:45:43 -0000 Author: mhorne Date: Mon Nov 16 17:45:42 2020 New Revision: 367732 URL: https://svnweb.freebsd.org/changeset/base/367732 Log: MFC r367178: arm64: set the correct partition type in make-memstick.sh Modified: stable/12/release/arm64/make-memstick.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/release/arm64/make-memstick.sh ============================================================================== --- stable/12/release/arm64/make-memstick.sh Mon Nov 16 17:44:34 2020 (r367731) +++ stable/12/release/arm64/make-memstick.sh Mon Nov 16 17:45:42 2020 (r367732) @@ -38,7 +38,7 @@ rm ${1}/etc/rc.conf.local mkimg -s gpt \ -p efi:=${1}/boot/boot1.efifat \ - -p freebsd:=${2}.part \ + -p freebsd-ufs:=${2}.part \ -o ${2} rm ${2}.part From owner-svn-src-all@freebsd.org Mon Nov 16 17:56:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1EDE146D191; Mon, 16 Nov 2020 17:56:59 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZcGM0NVxz3vl5; Mon, 16 Nov 2020 17:56:59 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F3D2E11C7F; Mon, 16 Nov 2020 17:56:58 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGHuwlE043447; Mon, 16 Nov 2020 17:56:58 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGHuwwH043446; Mon, 16 Nov 2020 17:56:58 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011161756.0AGHuwwH043446@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 16 Nov 2020 17:56:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367733 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367733 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 17:56:59 -0000 Author: mjg Date: Mon Nov 16 17:56:58 2020 New Revision: 367733 URL: https://svnweb.freebsd.org/changeset/base/367733 Log: malloc: make malloc_large closer to standalone This moves entire large alloc handling out of all consumers, apart from deciding to go there. This is a step towards creating a fast path. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D27198 Modified: head/sys/kern/kern_malloc.c Modified: head/sys/kern/kern_malloc.c ============================================================================== --- head/sys/kern/kern_malloc.c Mon Nov 16 17:45:42 2020 (r367732) +++ head/sys/kern/kern_malloc.c Mon Nov 16 17:56:58 2020 (r367733) @@ -110,6 +110,14 @@ dtrace_malloc_probe_func_t __read_mostly dtrace_malloc #define MALLOC_DEBUG 1 #endif +#ifdef DEBUG_REDZONE +#define DEBUG_REDZONE_ARG_DEF , unsigned long osize +#define DEBUG_REDZONE_ARG , osize +#else +#define DEBUG_REDZONE_ARG_DEF +#define DEBUG_REDZONE_ARG +#endif + /* * When realloc() is called, if the new size is sufficiently smaller than * the old size, realloc() will allocate a new, smaller block to avoid @@ -574,21 +582,33 @@ malloc_large_size(uma_slab_t slab) return (va >> 1); } -static caddr_t -malloc_large(size_t *size, struct domainset *policy, int flags) +static caddr_t __noinline +malloc_large(size_t *size, struct malloc_type *mtp, struct domainset *policy, + int flags DEBUG_REDZONE_ARG_DEF) { - vm_offset_t va; + vm_offset_t kva; + caddr_t va; size_t sz; sz = roundup(*size, PAGE_SIZE); - va = kmem_malloc_domainset(policy, sz, flags); - if (va != 0) { + kva = kmem_malloc_domainset(policy, sz, flags); + if (kva != 0) { /* The low bit is unused for slab pointers. */ - vsetzoneslab(va, NULL, (void *)((sz << 1) | 1)); + vsetzoneslab(kva, NULL, (void *)((sz << 1) | 1)); uma_total_inc(sz); *size = sz; } - return ((caddr_t)va); + va = (caddr_t)kva; + malloc_type_allocated(mtp, va == NULL ? 0 : sz); + if (__predict_false(va == NULL)) { + KASSERT((flags & M_WAITOK) == 0, + ("malloc(M_WAITOK) returned NULL")); + } +#ifdef DEBUG_REDZONE + if (va != NULL) + va = redzone_setup(va, osize); +#endif + return (va); } static void @@ -613,30 +633,30 @@ void * int indx; caddr_t va; uma_zone_t zone; -#if defined(DEBUG_REDZONE) +#ifdef DEBUG_REDZONE unsigned long osize = size; #endif MPASS((flags & M_EXEC) == 0); + #ifdef MALLOC_DEBUG va = NULL; if (malloc_dbg(&va, &size, mtp, flags) != 0) return (va); #endif - if (size <= kmem_zmax) { - if (size & KMEM_ZMASK) - size = (size & ~KMEM_ZMASK) + KMEM_ZBASE; - indx = kmemsize[size >> KMEM_ZSHIFT]; - zone = kmemzones[indx].kz_zone[mtp_get_subzone(mtp)]; - va = uma_zalloc(zone, flags); - if (va != NULL) - size = zone->uz_size; - malloc_type_zone_allocated(mtp, va == NULL ? 0 : size, indx); - } else { - va = malloc_large(&size, DOMAINSET_RR(), flags); - malloc_type_allocated(mtp, va == NULL ? 0 : size); - } + if (__predict_false(size > kmem_zmax)) + return (malloc_large(&size, mtp, DOMAINSET_RR(), flags + DEBUG_REDZONE_ARG)); + + if (size & KMEM_ZMASK) + size = (size & ~KMEM_ZMASK) + KMEM_ZBASE; + indx = kmemsize[size >> KMEM_ZSHIFT]; + zone = kmemzones[indx].kz_zone[mtp_get_subzone(mtp)]; + va = uma_zalloc(zone, flags); + if (va != NULL) + size = zone->uz_size; + malloc_type_zone_allocated(mtp, va == NULL ? 0 : size, indx); if (__predict_false(va == NULL)) { KASSERT((flags & M_WAITOK) == 0, ("malloc(M_WAITOK) returned NULL")); @@ -679,28 +699,27 @@ malloc_domainset(size_t size, struct malloc_type *mtp, caddr_t va; int domain; int indx; - -#if defined(DEBUG_REDZONE) +#ifdef DEBUG_REDZONE unsigned long osize = size; #endif + MPASS((flags & M_EXEC) == 0); + #ifdef MALLOC_DEBUG va = NULL; if (malloc_dbg(&va, &size, mtp, flags) != 0) return (va); #endif - if (size <= kmem_zmax) { - vm_domainset_iter_policy_init(&di, ds, &domain, &flags); - do { - va = malloc_domain(&size, &indx, mtp, domain, flags); - } while (va == NULL && - vm_domainset_iter_policy(&di, &domain) == 0); - malloc_type_zone_allocated(mtp, va == NULL ? 0 : size, indx); - } else { - /* Policy is handled by kmem. */ - va = malloc_large(&size, ds, flags); - malloc_type_allocated(mtp, va == NULL ? 0 : size); - } + + if (__predict_false(size > kmem_zmax)) + return (malloc_large(&size, mtp, DOMAINSET_RR(), flags + DEBUG_REDZONE_ARG)); + + vm_domainset_iter_policy_init(&di, ds, &domain, &flags); + do { + va = malloc_domain(&size, &indx, mtp, domain, flags); + } while (va == NULL && vm_domainset_iter_policy(&di, &domain) == 0); + malloc_type_zone_allocated(mtp, va == NULL ? 0 : size, indx); if (__predict_false(va == NULL)) { KASSERT((flags & M_WAITOK) == 0, ("malloc(M_WAITOK) returned NULL")); @@ -718,57 +737,30 @@ malloc_domainset(size_t size, struct malloc_type *mtp, void * malloc_exec(size_t size, struct malloc_type *mtp, int flags) { - caddr_t va; -#if defined(DEBUG_REDZONE) - unsigned long osize = size; -#endif - flags |= M_EXEC; -#ifdef MALLOC_DEBUG - va = NULL; - if (malloc_dbg(&va, &size, mtp, flags) != 0) - return (va); -#endif - va = malloc_large(&size, DOMAINSET_RR(), flags); - malloc_type_allocated(mtp, va == NULL ? 0 : size); - if (__predict_false(va == NULL)) { - KASSERT((flags & M_WAITOK) == 0, - ("malloc(M_WAITOK) returned NULL")); - } -#ifdef DEBUG_REDZONE - if (va != NULL) - va = redzone_setup(va, osize); -#endif - return ((void *) va); + return (malloc_domainset_exec(size, mtp, DOMAINSET_RR(), flags)); } void * malloc_domainset_exec(size_t size, struct malloc_type *mtp, struct domainset *ds, int flags) { - caddr_t va; -#if defined(DEBUG_REDZONE) +#ifdef DEBUG_REDZONE unsigned long osize = size; #endif +#ifdef MALLOC_DEBUG + caddr_t va; +#endif flags |= M_EXEC; + #ifdef MALLOC_DEBUG va = NULL; if (malloc_dbg(&va, &size, mtp, flags) != 0) return (va); #endif - /* Policy is handled by kmem. */ - va = malloc_large(&size, ds, flags); - malloc_type_allocated(mtp, va == NULL ? 0 : size); - if (__predict_false(va == NULL)) { - KASSERT((flags & M_WAITOK) == 0, - ("malloc(M_WAITOK) returned NULL")); - } -#ifdef DEBUG_REDZONE - if (va != NULL) - va = redzone_setup(va, osize); -#endif - return (va); + + return (malloc_large(&size, mtp, ds, flags DEBUG_REDZONE_ARG)); } void * From owner-svn-src-all@freebsd.org Mon Nov 16 18:41:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4EEC646DD5D; Mon, 16 Nov 2020 18:41:50 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZdG61r8fz4SMJ; Mon, 16 Nov 2020 18:41:50 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 32260129BC; Mon, 16 Nov 2020 18:41:50 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGIfoDn069764; Mon, 16 Nov 2020 18:41:50 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGIfo9f069763; Mon, 16 Nov 2020 18:41:50 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011161841.0AGIfo9f069763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Mon, 16 Nov 2020 18:41:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367734 - head/usr.bin/bsdiff/bsdiff X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/usr.bin/bsdiff/bsdiff X-SVN-Commit-Revision: 367734 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 18:41:50 -0000 Author: mhorne Date: Mon Nov 16 18:41:49 2020 New Revision: 367734 URL: https://svnweb.freebsd.org/changeset/base/367734 Log: bsdiff: fix off-by-one error The program reads oldsize bytes from oldfile, and proceeds to initialize a suffix array of oldsize elements using divsufsort(). As per the function's API [1], array indices 0 through n-1 are initialized. Later, search() is called, but with index bounds [0, n]. Depending on the contents of the malloc'd buffer, accessing this uninitialized index at the end of can result in a segmentation fault. Fix this by passing oldsize-1 to search(), limiting the search bounds to [0, n-1]. This bug is a result of r303285, which introduced divsufsort() as an alternate suffix sorting function to the existing qsufsort(). It seems that qsufsort() did initialize the final empty element, meaning it could be safely accessed. This difference in the implementations was missed at the time. [1] https://github.com/y-256/libdivsufsort Discussed with: cperciva MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26911 Modified: head/usr.bin/bsdiff/bsdiff/bsdiff.c Modified: head/usr.bin/bsdiff/bsdiff/bsdiff.c ============================================================================== --- head/usr.bin/bsdiff/bsdiff/bsdiff.c Mon Nov 16 17:56:58 2020 (r367733) +++ head/usr.bin/bsdiff/bsdiff/bsdiff.c Mon Nov 16 18:41:49 2020 (r367734) @@ -212,7 +212,7 @@ int main(int argc,char *argv[]) for(scsc=scan+=len;scan Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C102D46ED97; Mon, 16 Nov 2020 19:15:11 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZf0b55txz4VBH; Mon, 16 Nov 2020 19:15:11 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9D85C12F6D; Mon, 16 Nov 2020 19:15:11 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGJFB3e093516; Mon, 16 Nov 2020 19:15:11 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGJFBvk093515; Mon, 16 Nov 2020 19:15:11 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202011161915.0AGJFBvk093515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 16 Nov 2020 19:15:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367735 - head/share/mk X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/share/mk X-SVN-Commit-Revision: 367735 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 19:15:11 -0000 Author: brooks Date: Mon Nov 16 19:15:11 2020 New Revision: 367735 URL: https://svnweb.freebsd.org/changeset/base/367735 Log: Add a guard for broken SUBDIR.${MK_FOO} use Check for the variable SUBDIR. and error as it usually means someone forgot to include src.opts.mk. This guard from CheriBSD found the bugs in r367655 and r367728. Reviewed by: bdrewery, arichardson Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27211 Modified: head/share/mk/bsd.subdir.mk Modified: head/share/mk/bsd.subdir.mk ============================================================================== --- head/share/mk/bsd.subdir.mk Mon Nov 16 18:41:49 2020 (r367734) +++ head/share/mk/bsd.subdir.mk Mon Nov 16 19:15:11 2020 (r367735) @@ -127,6 +127,12 @@ SUBDIR:=${SUBDIR} ${SUBDIR.yes} ${SUBDIR.yes.yes} SUBDIR:=${SUBDIR:u} .endif +.if defined(SUBDIR.) +.error ${.CURDIR}: Found variable SUBDIR. with value "${SUBDIR.}". This was \ + probably caused by using SUBDIR.$${MK_FOO} without including \ + or by using an invalid $${MK_FOO} option. +.endif + # Subdir code shared among 'make ', 'make ' and SUBDIR_PARALLEL. _SUBDIR_SH= \ if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \ From owner-svn-src-all@freebsd.org Mon Nov 16 21:55:54 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 53DA047361D; Mon, 16 Nov 2020 21:55:54 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZjZ21wWsz4fYb; Mon, 16 Nov 2020 21:55:54 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 34A4714FC1; Mon, 16 Nov 2020 21:55:54 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AGLtsuB092475; Mon, 16 Nov 2020 21:55:54 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AGLtraG092469; Mon, 16 Nov 2020 21:55:53 GMT (envelope-from br@FreeBSD.org) Message-Id: <202011162155.0AGLtraG092469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 16 Nov 2020 21:55:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367736 - in head/sys: arm64/include arm64/iommu conf X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/sys: arm64/include arm64/iommu conf X-SVN-Commit-Revision: 367736 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 21:55:54 -0000 Author: br Date: Mon Nov 16 21:55:52 2020 New Revision: 367736 URL: https://svnweb.freebsd.org/changeset/base/367736 Log: Introduce IOMMU support for arm64 platform. This adds an arm64 iommu interface and a driver for Arm System Memory Management Unit version 3.2 (ARM SMMU v3.2) specified in ARM IHI 0070C document. Hardware overview is provided in the header of smmu.c file. The support is disabled by default. To enable add 'options IOMMU' to your kernel configuration file. The support was developed on Arm Neoverse N1 System Development Platform (ARM N1SDP), kindly provided by ARM Ltd. Currently, PCI-based devices and ACPI platforms are supported only. The support was tested on IOMMU-enabled Marvell SATA controller, Realtek Ethernet controller and a TI xHCI USB controller with a low to medium load only. Many thanks to Konstantin Belousov for help forming the generic IOMMU framework that is vital for this project; to Andrew Turner for adding IOMMU support to MSI interrupt code; to Mark Johnston for help with SMMU page management; to John Baldwin for explaining various IOMMU bits. Reviewed by: mmel Relnotes: yes Sponsored by: DARPA / AFRL Sponsored by: Innovate UK (Digital Security by Design programme) Differential Revision: https://reviews.freebsd.org/D24618 Added: head/sys/arm64/include/iommu.h (contents, props changed) head/sys/arm64/iommu/ head/sys/arm64/iommu/iommu.c (contents, props changed) head/sys/arm64/iommu/iommu.h (contents, props changed) head/sys/arm64/iommu/iommu_if.m (contents, props changed) head/sys/arm64/iommu/smmu.c (contents, props changed) head/sys/arm64/iommu/smmu_acpi.c (contents, props changed) head/sys/arm64/iommu/smmu_quirks.c (contents, props changed) head/sys/arm64/iommu/smmureg.h (contents, props changed) head/sys/arm64/iommu/smmuvar.h (contents, props changed) Modified: head/sys/conf/files.arm64 Added: head/sys/arm64/include/iommu.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/include/iommu.h Mon Nov 16 21:55:52 2020 (r367736) @@ -0,0 +1,11 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#ifndef _MACHINE_IOMMU_H_ +#define _MACHINE_IOMMU_H_ + +#include + +#endif /* !_MACHINE_IOMMU_H_ */ Added: head/sys/arm64/iommu/iommu.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/iommu/iommu.c Mon Nov 16 21:55:52 2020 (r367736) @@ -0,0 +1,397 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Ruslan Bukin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * Portions of this work was supported by Innovate UK project 105694, + * "Digital Security by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "opt_platform.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "iommu.h" +#include "iommu_if.h" + +static MALLOC_DEFINE(M_IOMMU, "IOMMU", "IOMMU framework"); + +#define IOMMU_LIST_LOCK() mtx_lock(&iommu_mtx) +#define IOMMU_LIST_UNLOCK() mtx_unlock(&iommu_mtx) +#define IOMMU_LIST_ASSERT_LOCKED() mtx_assert(&iommu_mtx, MA_OWNED) + +#define dprintf(fmt, ...) + +static struct mtx iommu_mtx; + +struct iommu_entry { + struct iommu_unit *iommu; + LIST_ENTRY(iommu_entry) next; +}; +static LIST_HEAD(, iommu_entry) iommu_list = LIST_HEAD_INITIALIZER(iommu_list); + +static int +iommu_domain_unmap_buf(struct iommu_domain *iodom, iommu_gaddr_t base, + iommu_gaddr_t size, int flags) +{ + struct iommu_unit *iommu; + int error; + + iommu = iodom->iommu; + + error = IOMMU_UNMAP(iommu->dev, iodom, base, size); + + return (error); +} + +static int +iommu_domain_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base, + iommu_gaddr_t size, vm_page_t *ma, uint64_t eflags, int flags) +{ + struct iommu_unit *iommu; + vm_prot_t prot; + vm_offset_t va; + int error; + + dprintf("%s: base %lx, size %lx\n", __func__, base, size); + + prot = 0; + if (eflags & IOMMU_MAP_ENTRY_READ) + prot |= VM_PROT_READ; + if (eflags & IOMMU_MAP_ENTRY_WRITE) + prot |= VM_PROT_WRITE; + + va = base; + + iommu = iodom->iommu; + + error = IOMMU_MAP(iommu->dev, iodom, va, ma, size, prot); + + return (0); +} + +static const struct iommu_domain_map_ops domain_map_ops = { + .map = iommu_domain_map_buf, + .unmap = iommu_domain_unmap_buf, +}; + +static struct iommu_domain * +iommu_domain_alloc(struct iommu_unit *iommu) +{ + struct iommu_domain *iodom; + + iodom = IOMMU_DOMAIN_ALLOC(iommu->dev, iommu); + if (iodom == NULL) + return (NULL); + + iommu_domain_init(iommu, iodom, &domain_map_ops); + iodom->end = VM_MAXUSER_ADDRESS; + iodom->iommu = iommu; + iommu_gas_init_domain(iodom); + + return (iodom); +} + +static int +iommu_domain_free(struct iommu_domain *iodom) +{ + struct iommu_unit *iommu; + + iommu = iodom->iommu; + + IOMMU_LOCK(iommu); + + if ((iodom->flags & IOMMU_DOMAIN_GAS_INITED) != 0) { + IOMMU_DOMAIN_LOCK(iodom); + iommu_gas_fini_domain(iodom); + IOMMU_DOMAIN_UNLOCK(iodom); + } + + iommu_domain_fini(iodom); + + IOMMU_DOMAIN_FREE(iommu->dev, iodom); + IOMMU_UNLOCK(iommu); + + return (0); +} + +static void +iommu_tag_init(struct bus_dma_tag_iommu *t) +{ + bus_addr_t maxaddr; + + maxaddr = BUS_SPACE_MAXADDR; + + t->common.ref_count = 0; + t->common.impl = &bus_dma_iommu_impl; + t->common.alignment = 1; + t->common.boundary = 0; + t->common.lowaddr = maxaddr; + t->common.highaddr = maxaddr; + t->common.maxsize = maxaddr; + t->common.nsegments = BUS_SPACE_UNRESTRICTED; + t->common.maxsegsz = maxaddr; +} + +static struct iommu_ctx * +iommu_ctx_alloc(device_t dev, struct iommu_domain *iodom, bool disabled) +{ + struct iommu_unit *iommu; + struct iommu_ctx *ioctx; + + iommu = iodom->iommu; + + ioctx = IOMMU_CTX_ALLOC(iommu->dev, iodom, dev, disabled); + if (ioctx == NULL) + return (NULL); + + /* + * iommu can also be used for non-PCI based devices. + * This should be reimplemented as new newbus method with + * pci_get_rid() as a default for PCI device class. + */ + ioctx->rid = pci_get_rid(dev); + + return (ioctx); +} + +struct iommu_ctx * +iommu_get_ctx(struct iommu_unit *iommu, device_t requester, + uint16_t rid, bool disabled, bool rmrr) +{ + struct iommu_ctx *ioctx; + struct iommu_domain *iodom; + struct bus_dma_tag_iommu *tag; + + IOMMU_LOCK(iommu); + ioctx = IOMMU_CTX_LOOKUP(iommu->dev, requester); + if (ioctx) { + IOMMU_UNLOCK(iommu); + return (ioctx); + } + IOMMU_UNLOCK(iommu); + + /* + * In our current configuration we have a domain per each ctx. + * So allocate a domain first. + */ + iodom = iommu_domain_alloc(iommu); + if (iodom == NULL) + return (NULL); + + ioctx = iommu_ctx_alloc(requester, iodom, disabled); + if (ioctx == NULL) { + iommu_domain_free(iodom); + return (NULL); + } + + tag = ioctx->tag = malloc(sizeof(struct bus_dma_tag_iommu), + M_IOMMU, M_WAITOK | M_ZERO); + tag->owner = requester; + tag->ctx = ioctx; + tag->ctx->domain = iodom; + + iommu_tag_init(tag); + + ioctx->domain = iodom; + + return (ioctx); +} + +void +iommu_free_ctx_locked(struct iommu_unit *iommu, struct iommu_ctx *ioctx) +{ + struct bus_dma_tag_iommu *tag; + + IOMMU_ASSERT_LOCKED(iommu); + + tag = ioctx->tag; + + IOMMU_CTX_FREE(iommu->dev, ioctx); + + free(tag, M_IOMMU); +} + +void +iommu_free_ctx(struct iommu_ctx *ioctx) +{ + struct iommu_unit *iommu; + struct iommu_domain *iodom; + int error; + + iodom = ioctx->domain; + iommu = iodom->iommu; + + IOMMU_LOCK(iommu); + iommu_free_ctx_locked(iommu, ioctx); + IOMMU_UNLOCK(iommu); + + /* Since we have a domain per each ctx, remove the domain too. */ + error = iommu_domain_free(iodom); + if (error) + device_printf(iommu->dev, "Could not free a domain\n"); +} + +static void +iommu_domain_free_entry(struct iommu_map_entry *entry, bool free) +{ + struct iommu_domain *iodom; + + iodom = entry->domain; + + IOMMU_DOMAIN_LOCK(iodom); + iommu_gas_free_space(iodom, entry); + IOMMU_DOMAIN_UNLOCK(iodom); + + if (free) + iommu_gas_free_entry(iodom, entry); + else + entry->flags = 0; +} + +void +iommu_domain_unload(struct iommu_domain *iodom, + struct iommu_map_entries_tailq *entries, bool cansleep) +{ + struct iommu_map_entry *entry, *entry1; + int error; + + TAILQ_FOREACH_SAFE(entry, entries, dmamap_link, entry1) { + KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0, + ("not mapped entry %p %p", iodom, entry)); + error = iodom->ops->unmap(iodom, entry->start, entry->end - + entry->start, cansleep ? IOMMU_PGF_WAITOK : 0); + KASSERT(error == 0, ("unmap %p error %d", iodom, error)); + TAILQ_REMOVE(entries, entry, dmamap_link); + iommu_domain_free_entry(entry, true); + } + + if (TAILQ_EMPTY(entries)) + return; + + panic("entries map is not empty"); +} + +int +iommu_register(struct iommu_unit *iommu) +{ + struct iommu_entry *entry; + + mtx_init(&iommu->lock, "IOMMU", NULL, MTX_DEF); + + entry = malloc(sizeof(struct iommu_entry), M_IOMMU, M_WAITOK | M_ZERO); + entry->iommu = iommu; + + IOMMU_LIST_LOCK(); + LIST_INSERT_HEAD(&iommu_list, entry, next); + IOMMU_LIST_UNLOCK(); + + iommu_init_busdma(iommu); + + return (0); +} + +int +iommu_unregister(struct iommu_unit *iommu) +{ + struct iommu_entry *entry, *tmp; + + IOMMU_LIST_LOCK(); + LIST_FOREACH_SAFE(entry, &iommu_list, next, tmp) { + if (entry->iommu == iommu) { + LIST_REMOVE(entry, next); + free(entry, M_IOMMU); + } + } + IOMMU_LIST_UNLOCK(); + + iommu_fini_busdma(iommu); + + mtx_destroy(&iommu->lock); + + return (0); +} + +struct iommu_unit * +iommu_find(device_t dev, bool verbose) +{ + struct iommu_entry *entry; + struct iommu_unit *iommu; + int error; + + IOMMU_LIST_LOCK(); + LIST_FOREACH(entry, &iommu_list, next) { + iommu = entry->iommu; + error = IOMMU_FIND(iommu->dev, dev); + if (error == 0) { + IOMMU_LIST_UNLOCK(); + return (entry->iommu); + } + } + IOMMU_LIST_UNLOCK(); + + return (NULL); +} + +void +iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free) +{ + + dprintf("%s\n", __func__); + + iommu_domain_free_entry(entry, free); +} + +static void +iommu_init(void) +{ + + mtx_init(&iommu_mtx, "IOMMU", NULL, MTX_DEF); +} + +SYSINIT(iommu, SI_SUB_DRIVERS, SI_ORDER_FIRST, iommu_init, NULL); Added: head/sys/arm64/iommu/iommu.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/iommu/iommu.h Mon Nov 16 21:55:52 2020 (r367736) @@ -0,0 +1,44 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Ruslan Bukin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * 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 _ARM64_IOMMU_IOMMU_H_ +#define _ARM64_IOMMU_IOMMU_H_ + +#define IOMMU_PAGE_SIZE 4096 +#define IOMMU_PAGE_MASK (IOMMU_PAGE_SIZE - 1) + +int iommu_unregister(struct iommu_unit *unit); +int iommu_register(struct iommu_unit *unit); + +#endif /* _ARM64_IOMMU_IOMMU_H_ */ Added: head/sys/arm64/iommu/iommu_if.m ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/iommu/iommu_if.m Mon Nov 16 21:55:52 2020 (r367736) @@ -0,0 +1,125 @@ +#- +# SPDX-License-Identifier: BSD-2-Clause +#: +# Copyright (c) 2020 Ruslan Bukin +# +# This software was developed by SRI International and the University of +# Cambridge Computer Laboratory (Department of Computer Science and +# Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the +# DARPA SSITH research programme. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +INTERFACE iommu; + +# +# Check if the iommu controller dev is responsible to serve traffic +# for a given child. +# +METHOD int find { + device_t dev; + device_t child; +}; + +# +# Map a virtual address VA to a physical address PA. +# +METHOD int map { + device_t dev; + struct iommu_domain *iodom; + vm_offset_t va; + vm_page_t *ma; + bus_size_t size; + vm_prot_t prot; +}; + +# +# Unmap a virtual address VA. +# +METHOD int unmap { + device_t dev; + struct iommu_domain *iodom; + vm_offset_t va; + bus_size_t size; +}; + +# +# Allocate an IOMMU domain. +# +METHOD struct iommu_domain * domain_alloc { + device_t dev; + struct iommu_unit *iommu; +}; + +# +# Release all the resources held by IOMMU domain. +# +METHOD void domain_free { + device_t dev; + struct iommu_domain *iodom; +}; + +# +# Find a domain allocated for a dev. +# +METHOD struct iommu_domain * domain_lookup { + device_t dev; +}; + +# +# Find an allocated context for a device. +# +METHOD struct iommu_ctx * ctx_lookup { + device_t dev; + device_t child; +}; + +# +# Allocate a new iommu context. +# +METHOD struct iommu_ctx * ctx_alloc { + device_t dev; + struct iommu_domain *iodom; + device_t child; + bool disabled; +}; + +# +# Free the iommu context. +# +METHOD void ctx_free { + device_t dev; + struct iommu_ctx *ioctx; +}; Added: head/sys/arm64/iommu/smmu.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/iommu/smmu.c Mon Nov 16 21:55:52 2020 (r367736) @@ -0,0 +1,1937 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019-2020 Ruslan Bukin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * 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. + */ + +/* + * Hardware overview. + * + * An incoming transaction from a peripheral device has an address, size, + * attributes and StreamID. + * + * In case of PCI-based devices, StreamID is a PCI rid. + * + * The StreamID is used to select a Stream Table Entry (STE) in a Stream table, + * which contains per-device configuration. + * + * Stream table is a linear or 2-level walk table (this driver supports both). + * Note that a linear table could occupy 1GB or more of memory depending on + * sid_bits value. + * + * STE is used to locate a Context Descriptor, which is a struct in memory + * that describes stages of translation, translation table type, pointer to + * level 0 of page tables, ASID, etc. + * + * Hardware supports two stages of translation: Stage1 (S1) and Stage2 (S2): + * o S1 is used for the host machine traffic translation + * o S2 is for a hypervisor + * + * This driver enables S1 stage with standard AArch64 page tables. + * + * Note that SMMU does not share TLB with a main CPU. + * Command queue is used by this driver to Invalidate SMMU TLB, STE cache. + * + * An arm64 SoC could have more than one SMMU instance. + * ACPI IORT table describes which SMMU unit is assigned for a particular + * peripheral device. + * + * Queues. + * + * Register interface and Memory-based circular buffer queues are used + * to inferface SMMU. + * + * These are a Command queue for commands to send to the SMMU and an Event + * queue for event/fault reports from the SMMU. Optionally PRI queue is + * designed for PCIe page requests reception. + * + * Note that not every hardware supports PRI services. For instance they were + * not found in Neoverse N1 SDP machine. + * (This drivers does not implement PRI queue.) + * + * All SMMU queues are arranged as circular buffers in memory. They are used + * in a producer-consumer fashion so that an output queue contains data + * produced by the SMMU and consumed by software. + * An input queue contains data produced by software, consumed by the SMMU. + * + * Interrupts. + * + * Interrupts are not required by this driver for normal operation. + * The standard wired interrupt is only triggered when an event comes from + * the SMMU, which is only in a case of errors (e.g. translation fault). + */ + +#include "opt_platform.h" +#include "opt_acpi.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if DEV_ACPI +#include +#include +#endif +#include +#include +#include + +#include "iommu.h" +#include "iommu_if.h" + +#include "smmureg.h" +#include "smmuvar.h" + +#define STRTAB_L1_SZ_SHIFT 20 +#define STRTAB_SPLIT 8 + +#define STRTAB_L1_DESC_L2PTR_M (0x3fffffffffff << 6) +#define STRTAB_L1_DESC_DWORDS 1 + +#define STRTAB_STE_DWORDS 8 + +#define CMDQ_ENTRY_DWORDS 2 +#define EVTQ_ENTRY_DWORDS 4 +#define PRIQ_ENTRY_DWORDS 2 + +#define CD_DWORDS 8 + +#define Q_WRP(q, p) ((p) & (1 << (q)->size_log2)) +#define Q_IDX(q, p) ((p) & ((1 << (q)->size_log2) - 1)) +#define Q_OVF(p) ((p) & (1 << 31)) /* Event queue overflowed */ + +#define SMMU_Q_ALIGN (64 * 1024) + +static struct resource_spec smmu_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 1, RF_ACTIVE }, + { SYS_RES_IRQ, 2, RF_ACTIVE }, + RESOURCE_SPEC_END +}; + +MALLOC_DEFINE(M_SMMU, "SMMU", SMMU_DEVSTR); + +#define dprintf(fmt, ...) + +struct smmu_event { + int ident; + char *str; + char *msg; +}; + +static struct smmu_event events[] = { + { 0x01, "F_UUT", + "Unsupported Upstream Transaction."}, + { 0x02, "C_BAD_STREAMID", + "Transaction StreamID out of range."}, + { 0x03, "F_STE_FETCH", + "Fetch of STE caused external abort."}, + { 0x04, "C_BAD_STE", + "Used STE invalid."}, + { 0x05, "F_BAD_ATS_TREQ", + "Address Translation Request disallowed for a StreamID " + "and a PCIe ATS Translation Request received."}, + { 0x06, "F_STREAM_DISABLED", + "The STE of a transaction marks non-substream transactions " + "disabled."}, + { 0x07, "F_TRANSL_FORBIDDEN", + "An incoming PCIe transaction is marked Translated but " + "SMMU bypass is disallowed for this StreamID."}, + { 0x08, "C_BAD_SUBSTREAMID", + "Incoming SubstreamID present, but configuration is invalid."}, + { 0x09, "F_CD_FETCH", + "Fetch of CD caused external abort."}, + { 0x0a, "C_BAD_CD", + "Fetched CD invalid."}, + { 0x0b, "F_WALK_EABT", + "An external abort occurred fetching (or updating) " + "a translation table descriptor."}, + { 0x10, "F_TRANSLATION", + "Translation fault."}, + { 0x11, "F_ADDR_SIZE", + "Address Size fault."}, + { 0x12, "F_ACCESS", + "Access flag fault due to AF == 0 in a page or block TTD."}, + { 0x13, "F_PERMISSION", + "Permission fault occurred on page access."}, + { 0x20, "F_TLB_CONFLICT", + "A TLB conflict occurred because of the transaction."}, + { 0x21, "F_CFG_CONFLICT", + "A configuration cache conflict occurred due to " + "the transaction."}, + { 0x24, "E_PAGE_REQUEST", + "Speculative page request hint."}, + { 0x25, "F_VMS_FETCH", + "Fetch of VMS caused external abort."}, + { 0, NULL, NULL }, +}; + +static int +smmu_q_has_space(struct smmu_queue *q) +{ + + /* + * See 6.3.27 SMMU_CMDQ_PROD + * + * There is space in the queue for additional commands if: + * SMMU_CMDQ_CONS.RD != SMMU_CMDQ_PROD.WR || + * SMMU_CMDQ_CONS.RD_WRAP == SMMU_CMDQ_PROD.WR_WRAP + */ + + if (Q_IDX(q, q->lc.cons) != Q_IDX(q, q->lc.prod) || + Q_WRP(q, q->lc.cons) == Q_WRP(q, q->lc.prod)) + return (1); + + return (0); +} + +static int +smmu_q_empty(struct smmu_queue *q) +{ + + if (Q_IDX(q, q->lc.cons) == Q_IDX(q, q->lc.prod) && + Q_WRP(q, q->lc.cons) == Q_WRP(q, q->lc.prod)) + return (1); + + return (0); +} + +static int __unused +smmu_q_consumed(struct smmu_queue *q, uint32_t prod) +{ + + if ((Q_WRP(q, q->lc.cons) == Q_WRP(q, prod)) && + (Q_IDX(q, q->lc.cons) >= Q_IDX(q, prod))) + return (1); + + if ((Q_WRP(q, q->lc.cons) != Q_WRP(q, prod)) && + (Q_IDX(q, q->lc.cons) <= Q_IDX(q, prod))) + return (1); + + return (0); +} + +static uint32_t +smmu_q_inc_cons(struct smmu_queue *q) +{ + uint32_t cons; + uint32_t val; + + cons = (Q_WRP(q, q->lc.cons) | Q_IDX(q, q->lc.cons)) + 1; + val = (Q_OVF(q->lc.cons) | Q_WRP(q, cons) | Q_IDX(q, cons)); + + return (val); +} + +static uint32_t +smmu_q_inc_prod(struct smmu_queue *q) +{ + uint32_t prod; + uint32_t val; + + prod = (Q_WRP(q, q->lc.prod) | Q_IDX(q, q->lc.prod)) + 1; + val = (Q_OVF(q->lc.prod) | Q_WRP(q, prod) | Q_IDX(q, prod)); + + return (val); +} + +static int +smmu_write_ack(struct smmu_softc *sc, uint32_t reg, + uint32_t reg_ack, uint32_t val) +{ + uint32_t v; + int timeout; + + timeout = 100000; + + bus_write_4(sc->res[0], reg, val); + + do { + v = bus_read_4(sc->res[0], reg_ack); + if (v == val) + break; + } while (timeout--); + + if (timeout <= 0) { + device_printf(sc->dev, "Failed to write reg.\n"); + return (-1); + } + + return (0); +} + +static inline int +ilog2(long x) +{ + + KASSERT(x > 0 && powerof2(x), ("%s: invalid arg %ld", __func__, x)); + + return (flsl(x) - 1); +} + +static int +smmu_init_queue(struct smmu_softc *sc, struct smmu_queue *q, + uint32_t prod_off, uint32_t cons_off, uint32_t dwords) +{ + int sz; + + sz = (1 << q->size_log2) * dwords * 8; + + /* Set up the command circular buffer */ + q->vaddr = contigmalloc(sz, M_SMMU, + M_WAITOK | M_ZERO, 0, (1ul << 48) - 1, SMMU_Q_ALIGN, 0); + if (q->vaddr == NULL) { + device_printf(sc->dev, "failed to allocate %d bytes\n", sz); + return (-1); + } + + q->prod_off = prod_off; + q->cons_off = cons_off; + q->paddr = vtophys(q->vaddr); + + q->base = CMDQ_BASE_RA | EVENTQ_BASE_WA | PRIQ_BASE_WA; + q->base |= q->paddr & Q_BASE_ADDR_M; + q->base |= q->size_log2 << Q_LOG2SIZE_S; + + return (0); +} + +static int +smmu_init_queues(struct smmu_softc *sc) +{ + int err; + + /* Command queue. */ + err = smmu_init_queue(sc, &sc->cmdq, + SMMU_CMDQ_PROD, SMMU_CMDQ_CONS, CMDQ_ENTRY_DWORDS); + if (err) + return (ENXIO); + + /* Event queue. */ + err = smmu_init_queue(sc, &sc->evtq, + SMMU_EVENTQ_PROD, SMMU_EVENTQ_CONS, EVTQ_ENTRY_DWORDS); + if (err) + return (ENXIO); + + if (!(sc->features & SMMU_FEATURE_PRI)) + return (0); + + /* PRI queue. */ + err = smmu_init_queue(sc, &sc->priq, + SMMU_PRIQ_PROD, SMMU_PRIQ_CONS, PRIQ_ENTRY_DWORDS); + if (err) + return (ENXIO); + + return (0); +} + +/* + * Dump 2LVL or linear STE. + */ +static void +smmu_dump_ste(struct smmu_softc *sc, int sid) +{ + struct smmu_strtab *strtab; + struct l1_desc *l1_desc; + uint64_t *ste, *l1; + int i; + + strtab = &sc->strtab; + + if (sc->features & SMMU_FEATURE_2_LVL_STREAM_TABLE) { + i = sid >> STRTAB_SPLIT; + l1 = (void *)((uint64_t)strtab->vaddr + + STRTAB_L1_DESC_DWORDS * 8 * i); + device_printf(sc->dev, "L1 ste == %lx\n", l1[0]); + + l1_desc = &strtab->l1[i]; + ste = l1_desc->va; + if (ste == NULL) /* L2 is not initialized */ + return; + } else { + ste = (void *)((uint64_t)strtab->vaddr + + sid * (STRTAB_STE_DWORDS << 3)); + } + + /* Dump L2 or linear STE. */ + for (i = 0; i < STRTAB_STE_DWORDS; i++) + device_printf(sc->dev, "ste[%d] == %lx\n", i, ste[i]); +} + +static void __unused +smmu_dump_cd(struct smmu_softc *sc, struct smmu_cd *cd) +{ + uint64_t *vaddr; + int i; + + device_printf(sc->dev, "%s\n", __func__); + + vaddr = cd->vaddr; + for (i = 0; i < CD_DWORDS; i++) + device_printf(sc->dev, "cd[%d] == %lx\n", i, vaddr[i]); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Nov 17 00:04:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 299FD4755D0; Tue, 17 Nov 2020 00:04:06 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZmPy0hLsz4m64; Tue, 17 Nov 2020 00:04:06 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A7B616AA2; Tue, 17 Nov 2020 00:04:06 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH045gZ073518; Tue, 17 Nov 2020 00:04:05 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH045QT073517; Tue, 17 Nov 2020 00:04:05 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011170004.0AH045QT073517@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 17 Nov 2020 00:04:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367737 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367737 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 00:04:06 -0000 Author: mjg Date: Tue Nov 17 00:04:05 2020 New Revision: 367737 URL: https://svnweb.freebsd.org/changeset/base/367737 Log: cpuset: refcount-clean Modified: head/sys/kern/kern_cpuset.c Modified: head/sys/kern/kern_cpuset.c ============================================================================== --- head/sys/kern/kern_cpuset.c Mon Nov 16 21:55:52 2020 (r367736) +++ head/sys/kern/kern_cpuset.c Tue Nov 17 00:04:05 2020 (r367737) @@ -1482,7 +1482,7 @@ cpuset_thread0(void) CPU_COPY(&all_cpus, &set->cs_mask); LIST_INIT(&set->cs_children); LIST_INSERT_HEAD(&cpuset_ids, set, cs_link); - set->cs_ref = 1; + refcount_init(&set->cs_ref, 1); set->cs_flags = CPU_SET_ROOT | CPU_SET_RDONLY; set->cs_domain = &domainset0; cpuset_zero = set; @@ -2281,7 +2281,7 @@ DB_SHOW_COMMAND(cpusets, db_show_cpusets) LIST_FOREACH(set, &cpuset_ids, cs_link) { db_printf("set=%p id=%-6u ref=%-6d flags=0x%04x parent id=%d\n", - set, set->cs_id, set->cs_ref, set->cs_flags, + set, set->cs_id, refcount_load(&set->cs_ref), set->cs_flags, (set->cs_parent != NULL) ? set->cs_parent->cs_id : 0); db_printf(" cpu mask="); ddb_display_cpuset(&set->cs_mask); From owner-svn-src-all@freebsd.org Tue Nov 17 00:04:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4CA594759AD; Tue, 17 Nov 2020 00:04:31 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZmQR1mbXz4mQF; Tue, 17 Nov 2020 00:04:31 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F8F7167EF; Tue, 17 Nov 2020 00:04:31 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH04Vbd073585; Tue, 17 Nov 2020 00:04:31 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH04VMx073584; Tue, 17 Nov 2020 00:04:31 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011170004.0AH04VMx073584@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 17 Nov 2020 00:04:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367738 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 367738 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 00:04:31 -0000 Author: mjg Date: Tue Nov 17 00:04:30 2020 New Revision: 367738 URL: https://svnweb.freebsd.org/changeset/base/367738 Log: cpuset: reorder so that cs_mask does not share cacheline with cs_ref Modified: head/sys/sys/cpuset.h Modified: head/sys/sys/cpuset.h ============================================================================== --- head/sys/sys/cpuset.h Tue Nov 17 00:04:05 2020 (r367737) +++ head/sys/sys/cpuset.h Tue Nov 17 00:04:30 2020 (r367738) @@ -111,15 +111,15 @@ LIST_HEAD(setlist, cpuset); * to deal with inconsistent results. */ struct cpuset { - cpuset_t cs_mask; /* bitmask of valid cpus. */ - struct domainset *cs_domain; /* (c) NUMA policy. */ volatile u_int cs_ref; /* (a) Reference count. */ int cs_flags; /* (s) Flags from below. */ - cpusetid_t cs_id; /* (s) Id or INVALID. */ - struct cpuset *cs_parent; /* (s) Pointer to our parent. */ LIST_ENTRY(cpuset) cs_link; /* (c) All identified sets. */ LIST_ENTRY(cpuset) cs_siblings; /* (c) Sibling set link. */ struct setlist cs_children; /* (c) List of children. */ + struct domainset *cs_domain; /* (c) NUMA policy. */ + cpusetid_t cs_id; /* (s) Id or INVALID. */ + struct cpuset *cs_parent; /* (s) Pointer to our parent. */ + cpuset_t cs_mask; /* bitmask of valid cpus. */ }; #define CPU_SET_ROOT 0x0001 /* Set is a root set. */ From owner-svn-src-all@freebsd.org Tue Nov 17 00:36:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54CB2476C90; Tue, 17 Nov 2020 00:36:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZn6m20Z3z4pJM; Tue, 17 Nov 2020 00:36:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3798E16E59; Tue, 17 Nov 2020 00:36:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH0a0nJ092728; Tue, 17 Nov 2020 00:36:00 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH0ZxmY092723; Tue, 17 Nov 2020 00:35:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011170035.0AH0ZxmY092723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 17 Nov 2020 00:35:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367739 - stable/12/sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/nvme X-SVN-Commit-Revision: 367739 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 00:36:00 -0000 Author: mav Date: Tue Nov 17 00:35:59 2020 New Revision: 367739 URL: https://svnweb.freebsd.org/changeset/base/367739 Log: MFC r367659: Add PMRCAP printing and fix earlier CAP_HI. Modified: stable/12/sys/dev/nvme/nvme.h stable/12/sys/dev/nvme/nvme_ctrlr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme.h ============================================================================== --- stable/12/sys/dev/nvme/nvme.h Tue Nov 17 00:04:30 2020 (r367738) +++ stable/12/sys/dev/nvme/nvme.h Tue Nov 17 00:35:59 2020 (r367739) @@ -150,6 +150,36 @@ #define NVME_AQA_REG_ACQS_SHIFT (16) #define NVME_AQA_REG_ACQS_MASK (0xFFF) +#define NVME_PMRCAP_REG_RDS_SHIFT (3) +#define NVME_PMRCAP_REG_RDS_MASK (0x1) +#define NVME_PMRCAP_REG_WDS_SHIFT (4) +#define NVME_PMRCAP_REG_WDS_MASK (0x1) +#define NVME_PMRCAP_REG_BIR_SHIFT (5) +#define NVME_PMRCAP_REG_BIR_MASK (0x7) +#define NVME_PMRCAP_REG_PMRTU_SHIFT (8) +#define NVME_PMRCAP_REG_PMRTU_MASK (0x3) +#define NVME_PMRCAP_REG_PMRWBM_SHIFT (10) +#define NVME_PMRCAP_REG_PMRWBM_MASK (0xf) +#define NVME_PMRCAP_REG_PMRTO_SHIFT (16) +#define NVME_PMRCAP_REG_PMRTO_MASK (0xff) +#define NVME_PMRCAP_REG_CMSS_SHIFT (24) +#define NVME_PMRCAP_REG_CMSS_MASK (0x1) + +#define NVME_PMRCAP_RDS(x) \ + (((x) >> NVME_PMRCAP_REG_RDS_SHIFT) & NVME_PMRCAP_REG_RDS_MASK) +#define NVME_PMRCAP_WDS(x) \ + (((x) >> NVME_PMRCAP_REG_WDS_SHIFT) & NVME_PMRCAP_REG_WDS_MASK) +#define NVME_PMRCAP_BIR(x) \ + (((x) >> NVME_PMRCAP_REG_BIR_SHIFT) & NVME_PMRCAP_REG_BIR_MASK) +#define NVME_PMRCAP_PMRTU(x) \ + (((x) >> NVME_PMRCAP_REG_PMRTU_SHIFT) & NVME_PMRCAP_REG_PMRTU_MASK) +#define NVME_PMRCAP_PMRWBM(x) \ + (((x) >> NVME_PMRCAP_REG_PMRWBM_SHIFT) & NVME_PMRCAP_REG_PMRWBM_MASK) +#define NVME_PMRCAP_PMRTO(x) \ + (((x) >> NVME_PMRCAP_REG_PMRTO_SHIFT) & NVME_PMRCAP_REG_PMRTO_MASK) +#define NVME_PMRCAP_CMSS(x) \ + (((x) >> NVME_PMRCAP_REG_CMSS_SHIFT) & NVME_PMRCAP_REG_CMSS_MASK) + /* Command field definitions */ #define NVME_CMD_FUSE_SHIFT (8) Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ctrlr.c Tue Nov 17 00:04:30 2020 (r367738) +++ stable/12/sys/dev/nvme/nvme_ctrlr.c Tue Nov 17 00:35:59 2020 (r367739) @@ -1329,7 +1329,7 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de struct make_dev_args md_args; uint32_t cap_lo; uint32_t cap_hi; - uint32_t to, vs; + uint32_t to, vs, pmrcap; uint8_t mpsmin; int status, timeout_period; @@ -1352,20 +1352,32 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de cap_hi = nvme_mmio_read_4(ctrlr, cap_hi); if (bootverbose) { device_printf(dev, "CapHi: 0x%08x: DSTRD %u%s, CSS %x%s, " - "MPSMIN %u, MPSMAX %u %s%s\n", cap_hi, + "MPSMIN %u, MPSMAX %u%s%s\n", cap_hi, NVME_CAP_HI_DSTRD(cap_hi), - NVME_CAP_HI_NSSRS(cap_lo) ? ", NSSRS" : "", + NVME_CAP_HI_NSSRS(cap_hi) ? ", NSSRS" : "", NVME_CAP_HI_CSS(cap_hi), - NVME_CAP_HI_BPS(cap_lo) ? ", BPS" : "", + NVME_CAP_HI_BPS(cap_hi) ? ", BPS" : "", NVME_CAP_HI_MPSMIN(cap_hi), NVME_CAP_HI_MPSMAX(cap_hi), - NVME_CAP_HI_PMRS(cap_lo) ? ", PMRS" : "", - NVME_CAP_HI_CMBS(cap_lo) ? ", CMBS" : ""); + NVME_CAP_HI_PMRS(cap_hi) ? ", PMRS" : "", + NVME_CAP_HI_CMBS(cap_hi) ? ", CMBS" : ""); } if (bootverbose) { vs = nvme_mmio_read_4(ctrlr, vs); device_printf(dev, "Version: 0x%08x: %d.%d\n", vs, NVME_MAJOR(vs), NVME_MINOR(vs)); + } + if (bootverbose && NVME_CAP_HI_PMRS(cap_hi)) { + pmrcap = nvme_mmio_read_4(ctrlr, pmrcap); + device_printf(dev, "PMRCap: 0x%08x: BIR %u%s%s, PMRTU %u, " + "PMRWBM %x, PMRTO %u%s\n", pmrcap, + NVME_PMRCAP_BIR(pmrcap), + NVME_PMRCAP_RDS(pmrcap) ? ", RDS" : "", + NVME_PMRCAP_WDS(pmrcap) ? ", WDS" : "", + NVME_PMRCAP_PMRTU(pmrcap), + NVME_PMRCAP_PMRWBM(pmrcap), + NVME_PMRCAP_PMRTO(pmrcap), + NVME_PMRCAP_CMSS(pmrcap) ? ", CMSS" : ""); } ctrlr->dstrd = NVME_CAP_HI_DSTRD(cap_hi) + 2; From owner-svn-src-all@freebsd.org Tue Nov 17 01:02:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3403B4771C0; Tue, 17 Nov 2020 01:02:01 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZnhn12X1z4qR5; Tue, 17 Nov 2020 01:02:01 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 15FE4174CD; Tue, 17 Nov 2020 01:02:01 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH1209P008486; Tue, 17 Nov 2020 01:02:00 GMT (envelope-from gnn@FreeBSD.org) Received: (from gnn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH120Ul008484; Tue, 17 Nov 2020 01:02:00 GMT (envelope-from gnn@FreeBSD.org) Message-Id: <202011170102.0AH120Ul008484@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gnn set sender to gnn@FreeBSD.org using -f From: "George V. Neville-Neil" Date: Tue, 17 Nov 2020 01:02:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367740 - stable/12/sys/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: gnn X-SVN-Commit-Paths: stable/12/sys/netinet X-SVN-Commit-Revision: 367740 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 01:02:01 -0000 Author: gnn Date: Tue Nov 17 01:02:00 2020 New Revision: 367740 URL: https://svnweb.freebsd.org/changeset/base/367740 Log: MFC: 367628, 367635, 367645 An earlier commit effectively turned out the fast forwading path due to its lack of support for ICMP redirects. The following commit adds redirects to the fastforward path, again allowing for decent forwarding performance in the kernel. Reviewed by: ae, melifaro (also helped with the MFC) Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate") Modified: stable/12/sys/netinet/ip_fastfwd.c stable/12/sys/netinet/ip_input.c stable/12/sys/netinet/ip_var.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet/ip_fastfwd.c ============================================================================== --- stable/12/sys/netinet/ip_fastfwd.c Tue Nov 17 00:35:59 2020 (r367739) +++ stable/12/sys/netinet/ip_fastfwd.c Tue Nov 17 01:02:00 2020 (r367740) @@ -110,6 +110,62 @@ __FBSDID("$FreeBSD$"); #include +#define V_ipsendredirects VNET(ipsendredirects) + +struct mbuf * +ip_redir_alloc(struct mbuf *m, struct ip *ip, struct in_addr dest, + in_addr_t *addr); + + +struct mbuf * +ip_redir_alloc(struct mbuf *m, struct ip *ip, struct in_addr dest, + in_addr_t *addr) +{ + struct sockaddr_in s; + struct nhop4_extended nh; + struct mbuf *mcopy = m_gethdr(M_NOWAIT, m->m_type); + + if (mcopy == NULL) + return (NULL); + + if (fib4_lookup_nh_ext(M_GETFIB(m), dest, 0, 0, &nh) != 0) + return (NULL); + + if (m_dup_pkthdr(mcopy, m, M_NOWAIT) == 0) { + /* + * It's probably ok if the pkthdr dup fails (because + * the deep copy of the tag chain failed), but for now + * be conservative and just discard the copy since + * code below may some day want the tags. + */ + m_free(mcopy); + return (NULL); + } + mcopy->m_len = min(ntohs(ip->ip_len), M_TRAILINGSPACE(mcopy)); + mcopy->m_pkthdr.len = mcopy->m_len; + m_copydata(m, 0, mcopy->m_len, mtod(mcopy, caddr_t)); + + s.sin_len = sizeof(struct sockaddr_in); + s.sin_family= AF_INET; + s.sin_addr = nh.nh_src; + + if (((nh.nh_flags & (NHF_REDIRECT|NHF_DEFAULT)) == 0)) { + struct in_ifaddr *nh_ia = (struct in_ifaddr *)ifaof_ifpforaddr((struct sockaddr *)&s, nh.nh_ifp); + u_long src = ntohl(ip->ip_src.s_addr); + + if (nh_ia != NULL && (src & nh_ia->ia_subnetmask) == nh_ia->ia_subnet) { + if (nh.nh_flags & NHF_GATEWAY) + *addr = nh.nh_addr.s_addr; + else + *addr = ip->ip_dst.s_addr; + } + } + + + return (mcopy); +} + + static int ip_findroute(struct nhop4_basic *pnh, struct in_addr dest, struct mbuf *m) { @@ -157,7 +213,8 @@ ip_tryforward(struct mbuf *m) uint16_t ip_len, ip_off; int error = 0; struct m_tag *fwd_tag = NULL; - + struct mbuf *mcopy = NULL; + struct in_addr redest; /* * Are we active and forwarding packets? */ @@ -381,6 +438,13 @@ passout: dst.sin_addr = nh.nh_addr; /* + * Handle redirect case. + */ + redest.s_addr = 0; + if (V_ipsendredirects && (nh.nh_ifp == m->m_pkthdr.rcvif)) + mcopy = ip_redir_alloc(m, ip, dest, &redest.s_addr); + + /* * Check if packet fits MTU or if hardware will fragment for us */ if (ip_len <= nh.nh_mtu) { @@ -450,7 +514,16 @@ passout: IPSTAT_INC(ips_forward); IPSTAT_INC(ips_fastforward); } + + /* Send required redirect */ + if (mcopy != NULL) { + icmp_error(mcopy, ICMP_REDIRECT, ICMP_REDIRECT_HOST, redest.s_addr, 0); + mcopy = NULL; /* Freed by caller */ + } + consumed: + if (mcopy != NULL) + m_freem(mcopy); return NULL; drop: if (m) Modified: stable/12/sys/netinet/ip_input.c ============================================================================== --- stable/12/sys/netinet/ip_input.c Tue Nov 17 00:35:59 2020 (r367739) +++ stable/12/sys/netinet/ip_input.c Tue Nov 17 01:02:00 2020 (r367740) @@ -109,8 +109,11 @@ SYSCTL_INT(_net_inet_ip, IPCTL_FORWARDING, forwarding, &VNET_NAME(ipforwarding), 0, "Enable IP forwarding between interfaces"); -VNET_DEFINE_STATIC(int, ipsendredirects) = 1; /* XXX */ -#define V_ipsendredirects VNET(ipsendredirects) +/* + * Respond with an ICMP host redirect when we forward a packet out of + * the same interface on which it was received. See RFC 792. + */ +VNET_DEFINE(int, ipsendredirects) = 1; SYSCTL_INT(_net_inet_ip, IPCTL_SENDREDIRECTS, redirect, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ipsendredirects), 0, "Enable sending IP redirects"); @@ -566,7 +569,7 @@ tooshort: * case skip another inbound firewall processing and update * ip pointer. */ - if (V_ipforwarding != 0 && V_ipsendredirects == 0 + if (V_ipforwarding != 0 #if defined(IPSEC) || defined(IPSEC_SUPPORT) && (!IPSEC_ENABLED(ipv4) || IPSEC_CAPS(ipv4, m, IPSEC_CAP_OPERABLE) == 0) Modified: stable/12/sys/netinet/ip_var.h ============================================================================== --- stable/12/sys/netinet/ip_var.h Tue Nov 17 00:35:59 2020 (r367739) +++ stable/12/sys/netinet/ip_var.h Tue Nov 17 01:02:00 2020 (r367740) @@ -181,6 +181,7 @@ struct inpcbinfo; VNET_DECLARE(int, ip_defttl); /* default IP ttl */ VNET_DECLARE(int, ipforwarding); /* ip forwarding */ +VNET_DECLARE(int, ipsendredirects); #ifdef IPSTEALTH VNET_DECLARE(int, ipstealth); /* stealth forwarding */ #endif @@ -196,6 +197,7 @@ extern struct pr_usrreqs rip_usrreqs; #define V_ip_id VNET(ip_id) #define V_ip_defttl VNET(ip_defttl) #define V_ipforwarding VNET(ipforwarding) +#define V_ipsendredirects VNET(ipsendredirects) #ifdef IPSTEALTH #define V_ipstealth VNET(ipstealth) #endif From owner-svn-src-all@freebsd.org Tue Nov 17 01:58:34 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1C4F47A5F8; Tue, 17 Nov 2020 01:58:34 +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 4CZpy22cK9z4vtf; Tue, 17 Nov 2020 01:58:33 +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 0AH1wQno055007 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 17 Nov 2020 03:58:29 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 0AH1wQno055007 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 0AH1wPkV055006; Tue, 17 Nov 2020 03:58:25 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 17 Nov 2020 03:58:25 +0200 From: Konstantin Belousov To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r367713 - head/sys/kern Message-ID: References: <202011160309.0AG39JmP067464@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202011160309.0AG39JmP067464@repo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4CZpy22cK9z4vtf X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 01:58:34 -0000 On Mon, Nov 16, 2020 at 03:09:19AM +0000, Mateusz Guzik wrote: > Author: mjg > Date: Mon Nov 16 03:09:18 2020 > New Revision: 367713 > URL: https://svnweb.freebsd.org/changeset/base/367713 > > Log: > select: replace reference counting with memory barriers in selfd > > Refcounting was added to combat a race between selfdfree and doselwakup, > but it adds avoidable overhead. > > selfdfree detects it can free the object by ->sf_si == NULL, thus we can > ensure that the condition only holds after all accesses are completed. > > Modified: > head/sys/kern/sys_generic.c > > Modified: head/sys/kern/sys_generic.c > ============================================================================== > --- head/sys/kern/sys_generic.c Sun Nov 15 22:49:28 2020 (r367712) > +++ head/sys/kern/sys_generic.c Mon Nov 16 03:09:18 2020 (r367713) > @@ -156,7 +156,6 @@ struct selfd { > struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ > struct seltd *sf_td; /* (k) owning seltd. */ > void *sf_cookie; /* (k) fd or pollfd. */ > - u_int sf_refs; > }; > > MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); > @@ -1704,16 +1703,17 @@ static void > selfdfree(struct seltd *stp, struct selfd *sfp) > { > STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); > - if (sfp->sf_si != NULL) { > + /* > + * Paired with doselwakeup. > + */ > + if (atomic_load_acq_ptr((uintptr_t *)&sfp->sf_si) != (uintptr_t)NULL) { This could be != 0. > mtx_lock(sfp->sf_mtx); > if (sfp->sf_si != NULL) { > TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); > - refcount_release(&sfp->sf_refs); > } > mtx_unlock(sfp->sf_mtx); > } > - if (refcount_release(&sfp->sf_refs)) > - free(sfp, M_SELFD); > + free(sfp, M_SELFD); What guarantees that doselwakeup() finished with sfp ? > } > > /* Drain the waiters tied to all the selfd belonging the specified selinfo. */ > @@ -1766,7 +1766,6 @@ selrecord(struct thread *selector, struct selinfo *sip > */ > sfp->sf_si = sip; > sfp->sf_mtx = mtxp; > - refcount_init(&sfp->sf_refs, 2); > STAILQ_INSERT_TAIL(&stp->st_selq, sfp, sf_link); > /* > * Now that we've locked the sip, check for initialization. > @@ -1820,14 +1819,15 @@ doselwakeup(struct selinfo *sip, int pri) > * sf_si seltdclear will know to ignore this si. > */ > TAILQ_REMOVE(&sip->si_tdlist, sfp, sf_threads); > - sfp->sf_si = NULL; > stp = sfp->sf_td; > + /* > + * Paired with selfdfree. > + */ > + atomic_store_rel_ptr((uintptr_t *)&sfp->sf_si, (uintptr_t)NULL); > mtx_lock(&stp->st_mtx); > stp->st_flags |= SELTD_PENDING; > cv_broadcastpri(&stp->st_wait, pri); > mtx_unlock(&stp->st_mtx); > - if (refcount_release(&sfp->sf_refs)) > - free(sfp, M_SELFD); > } > mtx_unlock(sip->si_mtx); > } From owner-svn-src-all@freebsd.org Tue Nov 17 02:18:34 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B46B847BA21; Tue, 17 Nov 2020 02:18:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZqP64cXjz3DbQ; Tue, 17 Nov 2020 02:18:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 914EF184C2; Tue, 17 Nov 2020 02:18:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH2IYkr054983; Tue, 17 Nov 2020 02:18:34 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH2IYqJ054982; Tue, 17 Nov 2020 02:18:34 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011170218.0AH2IYqJ054982@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 17 Nov 2020 02:18:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367741 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367741 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 02:18:34 -0000 Author: kib Date: Tue Nov 17 02:18:34 2020 New Revision: 367741 URL: https://svnweb.freebsd.org/changeset/base/367741 Log: vmem: trivial warning and style fixes. Add __unused to some args. Change type of the iterator variables to match loop control. Remove excessive {}. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27220 Modified: head/sys/kern/subr_vmem.c Modified: head/sys/kern/subr_vmem.c ============================================================================== --- head/sys/kern/subr_vmem.c Tue Nov 17 01:02:00 2020 (r367740) +++ head/sys/kern/subr_vmem.c Tue Nov 17 02:18:34 2020 (r367741) @@ -521,7 +521,7 @@ bt_insseg_tail(vmem_t *vm, bt_t *bt) } static void -bt_remfree(vmem_t *vm, bt_t *bt) +bt_remfree(vmem_t *vm __unused, bt_t *bt) { MPASS(bt->bt_type == BT_TYPE_FREE); @@ -734,10 +734,9 @@ static int vmem_rehash(vmem_t *vm, vmem_size_t newhashsize) { bt_t *bt; - int i; struct vmem_hashlist *newhashlist; struct vmem_hashlist *oldhashlist; - vmem_size_t oldhashsize; + vmem_size_t i, oldhashsize; MPASS(newhashsize > 0); @@ -766,9 +765,8 @@ vmem_rehash(vmem_t *vm, vmem_size_t newhashsize) } VMEM_UNLOCK(vm); - if (oldhashlist != vm->vm_hash0) { + if (oldhashlist != vm->vm_hash0) free(oldhashlist, M_VMEM); - } return 0; } @@ -1242,7 +1240,7 @@ vmem_t * vmem_init(vmem_t *vm, const char *name, vmem_addr_t base, vmem_size_t size, vmem_size_t quantum, vmem_size_t qcache_max, int flags) { - int i; + vmem_size_t i; MPASS(quantum > 0); MPASS((quantum & (quantum - 1)) == 0); @@ -1483,7 +1481,7 @@ vmem_free(vmem_t *vm, vmem_addr_t addr, vmem_size_t si } void -vmem_xfree(vmem_t *vm, vmem_addr_t addr, vmem_size_t size) +vmem_xfree(vmem_t *vm, vmem_addr_t addr, vmem_size_t size __unused) { bt_t *bt; bt_t *t; From owner-svn-src-all@freebsd.org Tue Nov 17 03:15:15 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 143FD47DBD7; Tue, 17 Nov 2020 03:15:15 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (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 4CZrfV745bz3JsH; Tue, 17 Nov 2020 03:15:14 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x443.google.com with SMTP id j7so21627355wrp.3; Mon, 16 Nov 2020 19:15:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fwnA28FacBsEwmca48e1CIxnICN/NvXjHaN4FR6U1zI=; b=Jj2Q/gXFpeHHLuvqNxKqN5+Q2WHqH5DVb3J+W8dEyeWzkurgVKEB8vtBXCd/R8Biv8 thHyWhNwh5mJ7wtM9lL6k1y/5ZgrjMAB7DJl6nkK4wUxGLYj/xpIUwr9fLXFjt9+UnXw gmyIswnezdltD3Vl9pV5QQNO71Aj6iuuL7g4Dy/BwiMhNam85Q8otw0UwmGVUipGQG1j B6bWSM9YoxlBDxuDMxA8HreJZovmJ/oMDUqPIjj2OqTfJPinqD51k+LYZYH7n8tMIin9 eRUxQrL6CfU6/IB8aHJj6fB95iBTsz1pCNzfoc7e852qqzTkhnGVOH7l0kIJYrzuNCV6 V3FQ== 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=fwnA28FacBsEwmca48e1CIxnICN/NvXjHaN4FR6U1zI=; b=rc5VjQ1BYht+RYF+zbBQwDE0U4XMohHMPqTSI3u9VgPkhjQu/j3x5iMgqbPOFcdKb6 E35e/ufqVFCAP33fD3Wu0f6anG979pE22je360/7uWlFcS+U/SE0D4REIzEMj2A92gCq H4JKAQEZcV1gojM7cm0b3jZglekYG2aNEJC4VZdgAdn3uS1bu1XyAmV99lkVMnqdQI/H qfhtcxeRb94qAnNE/IQCC0FSlHKpsk9C8LiGJwBxa6TRpMgq4AaJE4rlDlOnkKsx6dgb LH8/MWmlwD2u7IY5ETiL/UxGc8QbRqOxp2AHT+MSg8fwISpX+nA3cSfAepfP7DdQf2pe oYOw== X-Gm-Message-State: AOAM530zpDYDgBGK8G9F51HQM42czGKRRNamsenPAgEZfwz9Kk1exe4o fmanCJZmwW541BP9RODPwumGe+WJar/1lFxHmZL3QvYifkc= X-Google-Smtp-Source: ABdhPJyhnA1TVVpdA35ClSiY14RQ4R2WpFEkOzwuda/T+PikAcm3ph6Fy9H0O/s5StMSjANOJz9mZMQlcJYRW89JAcs= X-Received: by 2002:adf:9b98:: with SMTP id d24mr22266698wrc.17.1605582913402; Mon, 16 Nov 2020 19:15:13 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Mon, 16 Nov 2020 19:15:12 -0800 (PST) In-Reply-To: References: <202011160309.0AG39JmP067464@repo.freebsd.org> From: Mateusz Guzik Date: Tue, 17 Nov 2020 04:15:12 +0100 Message-ID: Subject: Re: svn commit: r367713 - head/sys/kern To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4CZrfV745bz3JsH X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 03:15:15 -0000 On 11/17/20, Konstantin Belousov wrote: > On Mon, Nov 16, 2020 at 03:09:19AM +0000, Mateusz Guzik wrote: >> Author: mjg >> Date: Mon Nov 16 03:09:18 2020 >> New Revision: 367713 >> URL: https://svnweb.freebsd.org/changeset/base/367713 >> >> Log: >> select: replace reference counting with memory barriers in selfd >> >> Refcounting was added to combat a race between selfdfree and >> doselwakup, >> but it adds avoidable overhead. >> >> selfdfree detects it can free the object by ->sf_si == NULL, thus we >> can >> ensure that the condition only holds after all accesses are completed. >> >> Modified: >> head/sys/kern/sys_generic.c >> >> Modified: head/sys/kern/sys_generic.c >> ============================================================================== >> --- head/sys/kern/sys_generic.c Sun Nov 15 22:49:28 2020 (r367712) >> +++ head/sys/kern/sys_generic.c Mon Nov 16 03:09:18 2020 (r367713) >> @@ -156,7 +156,6 @@ struct selfd { >> struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ >> struct seltd *sf_td; /* (k) owning seltd. */ >> void *sf_cookie; /* (k) fd or pollfd. */ >> - u_int sf_refs; >> }; >> >> MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); >> @@ -1704,16 +1703,17 @@ static void >> selfdfree(struct seltd *stp, struct selfd *sfp) >> { >> STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); >> - if (sfp->sf_si != NULL) { >> + /* >> + * Paired with doselwakeup. >> + */ >> + if (atomic_load_acq_ptr((uintptr_t *)&sfp->sf_si) != (uintptr_t)NULL) { > This could be != 0. > >> mtx_lock(sfp->sf_mtx); >> if (sfp->sf_si != NULL) { >> TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); >> - refcount_release(&sfp->sf_refs); >> } >> mtx_unlock(sfp->sf_mtx); >> } >> - if (refcount_release(&sfp->sf_refs)) >> - free(sfp, M_SELFD); >> + free(sfp, M_SELFD); > What guarantees that doselwakeup() finished with sfp ? > Release semantics provided by atomic_store_rel_ptr -- it means the NULL store is the last access, neither CPU nor the compiler are going to reorder preceding loads/stores past it. -- Mateusz Guzik From owner-svn-src-all@freebsd.org Tue Nov 17 03:21:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7CA7547E148; Tue, 17 Nov 2020 03:21:00 +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 4CZrn81vKHz3KMq; Tue, 17 Nov 2020 03:20:59 +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 0AH3Kp48075188 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 17 Nov 2020 05:20:54 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 0AH3Kp48075188 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 0AH3KpC5075187; Tue, 17 Nov 2020 05:20:51 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 17 Nov 2020 05:20:51 +0200 From: Konstantin Belousov To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r367713 - head/sys/kern Message-ID: References: <202011160309.0AG39JmP067464@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4CZrn81vKHz3KMq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 03:21:00 -0000 On Tue, Nov 17, 2020 at 04:15:12AM +0100, Mateusz Guzik wrote: > On 11/17/20, Konstantin Belousov wrote: > > On Mon, Nov 16, 2020 at 03:09:19AM +0000, Mateusz Guzik wrote: > >> Author: mjg > >> Date: Mon Nov 16 03:09:18 2020 > >> New Revision: 367713 > >> URL: https://svnweb.freebsd.org/changeset/base/367713 > >> > >> Log: > >> select: replace reference counting with memory barriers in selfd > >> > >> Refcounting was added to combat a race between selfdfree and > >> doselwakup, > >> but it adds avoidable overhead. > >> > >> selfdfree detects it can free the object by ->sf_si == NULL, thus we > >> can > >> ensure that the condition only holds after all accesses are completed. > >> > >> Modified: > >> head/sys/kern/sys_generic.c > >> > >> Modified: head/sys/kern/sys_generic.c > >> ============================================================================== > >> --- head/sys/kern/sys_generic.c Sun Nov 15 22:49:28 2020 (r367712) > >> +++ head/sys/kern/sys_generic.c Mon Nov 16 03:09:18 2020 (r367713) > >> @@ -156,7 +156,6 @@ struct selfd { > >> struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ > >> struct seltd *sf_td; /* (k) owning seltd. */ > >> void *sf_cookie; /* (k) fd or pollfd. */ > >> - u_int sf_refs; > >> }; > >> > >> MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); > >> @@ -1704,16 +1703,17 @@ static void > >> selfdfree(struct seltd *stp, struct selfd *sfp) > >> { > >> STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); > >> - if (sfp->sf_si != NULL) { > >> + /* > >> + * Paired with doselwakeup. > >> + */ > >> + if (atomic_load_acq_ptr((uintptr_t *)&sfp->sf_si) != (uintptr_t)NULL) { > > This could be != 0. > > > >> mtx_lock(sfp->sf_mtx); > >> if (sfp->sf_si != NULL) { > >> TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); > >> - refcount_release(&sfp->sf_refs); > >> } > >> mtx_unlock(sfp->sf_mtx); > >> } > >> - if (refcount_release(&sfp->sf_refs)) > >> - free(sfp, M_SELFD); > >> + free(sfp, M_SELFD); > > What guarantees that doselwakeup() finished with sfp ? > > > > Release semantics provided by atomic_store_rel_ptr -- it means the > NULL store is the last access, neither CPU nor the compiler are going > to reorder preceding loads/stores past it. It only guarantees that if we observed NULL as the result of load. From owner-svn-src-all@freebsd.org Tue Nov 17 03:26:57 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E9AB47E4A1; Tue, 17 Nov 2020 03:26:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZrw143R2z3KYk; Tue, 17 Nov 2020 03:26:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E3301942F; Tue, 17 Nov 2020 03:26:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH3QvXC000164; Tue, 17 Nov 2020 03:26:57 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH3QvSf000163; Tue, 17 Nov 2020 03:26:57 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202011170326.0AH3QvSf000163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 17 Nov 2020 03:26:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367742 - head/lib/libc/sys X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/lib/libc/sys X-SVN-Commit-Revision: 367742 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 03:26:57 -0000 Author: kevans Date: Tue Nov 17 03:26:56 2020 New Revision: 367742 URL: https://svnweb.freebsd.org/changeset/base/367742 Log: _umtx_op: document UMTX_OP_SEM2_WAIT copyout behavior This clever technique to get a time remaining back was added to support sem_clockwait_np. Reviewed by: kib, vangyzen MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27160 Modified: head/lib/libc/sys/_umtx_op.2 Modified: head/lib/libc/sys/_umtx_op.2 ============================================================================== --- head/lib/libc/sys/_umtx_op.2 Tue Nov 17 02:18:34 2020 (r367741) +++ head/lib/libc/sys/_umtx_op.2 Tue Nov 17 03:26:56 2020 (r367742) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 13, 2017 +.Dd November 16, 2020 .Dt _UMTX_OP 2 .Os .Sh NAME @@ -1101,6 +1101,15 @@ The arguments to the request are: .It Fa obj Pointer to the semaphore (of type .Vt struct _usem2 ) . +.It Fa uaddr +Size of the memory passed in via the +.Fa uaddr2 +argument. +.It Fa uaddr2 +Optional pointer to a structure of type +.Vt struct _umtx_time , +which may be followed by a structure of type +.Vt struct timespec . .El .Pp Put the requesting thread onto a sleep queue if the semaphore counter @@ -1124,6 +1133,18 @@ An unblocked signal delivered during such wait results interruption and .Er EINTR error. +.Pp +If +.Dv UMTX_ABSTIME +was not set, and the operation was interrupted and the caller passed in a +.Fa uaddr2 +large enough to hold a +.Vt struct timespec +following the initial +.Vt struct _umtx_time , +then the +.Vt struct timespec +is updated to contain the unslept amount. .It Dv UMTX_OP_SEM2_WAKE Wake up waiters on semaphore lock. The arguments to the request are: From owner-svn-src-all@freebsd.org Tue Nov 17 03:34:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CB8B47E7E3; Tue, 17 Nov 2020 03:34:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZs4B29Tkz3LBl; Tue, 17 Nov 2020 03:34:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3DCA5198A9; Tue, 17 Nov 2020 03:34:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH3Y2YU006279; Tue, 17 Nov 2020 03:34:02 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH3Y1Ya006276; Tue, 17 Nov 2020 03:34:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202011170334.0AH3Y1Ya006276@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 17 Nov 2020 03:34:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367743 - in head: lib/libthr/tests sys/kern X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: lib/libthr/tests sys/kern X-SVN-Commit-Revision: 367743 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 03:34:02 -0000 Author: kevans Date: Tue Nov 17 03:34:01 2020 New Revision: 367743 URL: https://svnweb.freebsd.org/changeset/base/367743 Log: _umtx_op: fix a compat32 bug in UMTX_OP_NWAKE_PRIVATE Specifically, if we're waking up some value n > BATCH_SIZE, then the copyin(9) is wrong on the second iteration due to upp being the wrong type. upp is currently a uint32_t**, so upp + pos advances it by twice as many elements as it should (host pointer size vs. compat32 pointer size). Fix it by just making upp a uint32_t*; it's still technically a double pointer, but the distinction doesn't matter all that much here since we're just doing arithmetic on it. Add a test case that demonstrates the problem, placed with the libthr tests since one messing with _umtx_op should be running these tests. Running under compat32, the new test case will hang as threads after the first 128 get missed in the wake. it's not immediately clear how to hit it in practice, since pthread_cond_broadcast() uses a smaller (sleepq batch?) size observed to be around ~50 -- I did not spend much time digging into it. The uintptr_t change makes no functional difference, but i've tossed it in since it's more accurate (semantically). Reported by: Andrew Gierth (andrew_tao173.riddles.org.uk, inspection) Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27231 Added: head/lib/libthr/tests/umtx_op_test.c (contents, props changed) Modified: head/lib/libthr/tests/Makefile head/sys/kern/kern_umtx.c Modified: head/lib/libthr/tests/Makefile ============================================================================== --- head/lib/libthr/tests/Makefile Tue Nov 17 03:26:56 2020 (r367742) +++ head/lib/libthr/tests/Makefile Tue Nov 17 03:34:01 2020 (r367743) @@ -35,6 +35,8 @@ NETBSD_ATF_TESTS_SH+= cancel_test NETBSD_ATF_TESTS_SH+= exit_test NETBSD_ATF_TESTS_SH+= resolv_test +ATF_TESTS_C+= umtx_op_test + LIBADD+= pthread LIBADD.fpu_test+= m LIBADD.sem_test+= rt Added: head/lib/libthr/tests/umtx_op_test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libthr/tests/umtx_op_test.c Tue Nov 17 03:34:01 2020 (r367743) @@ -0,0 +1,108 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Kyle Evans + * + * 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 + +/* + * This is an implementation detail of _umtx_op(2), pulled from + * sys/kern/kern_umtx.c. The relevant bug observed that requests above the + * batch side would not function as intended, so it's important that this + * reflects the BATCH_SIZE configured there. + */ +#define UMTX_OP_BATCH_SIZE 128 +#define THREAD_COUNT ((UMTX_OP_BATCH_SIZE * 3) / 2) + +static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER; + +static int batched_waiting; + +static void * +batching_threadfunc(void *arg) +{ + + pthread_mutex_lock(&static_mutex); + ++batched_waiting; + pthread_mutex_unlock(&static_mutex); + _umtx_op(arg, UMTX_OP_WAIT_UINT_PRIVATE, 0, NULL, NULL); + + return (NULL); +} + +ATF_TC(batching); +ATF_TC_HEAD(batching, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks batching of UMTX_OP_NWAKE_PRIVATE"); +} +ATF_TC_BODY(batching, tc) +{ + uintptr_t addrs[THREAD_COUNT]; + uint32_t vals[THREAD_COUNT]; + pthread_t threads[THREAD_COUNT]; + + for (int i = 0; i < THREAD_COUNT; i++) { + addrs[i] = (uintptr_t)&vals[i]; + vals[i] = 0; + pthread_create(&threads[i], NULL, batching_threadfunc, + &vals[i]); + } + + pthread_mutex_lock(&static_mutex); + while (batched_waiting != THREAD_COUNT) { + pthread_mutex_unlock(&static_mutex); + pthread_yield(); + pthread_mutex_lock(&static_mutex); + } + + /* + * Spin for another .50 seconds to make sure they're all safely in the + * kernel. + */ + usleep(500000); + + pthread_mutex_unlock(&static_mutex); + _umtx_op(addrs, UMTX_OP_NWAKE_PRIVATE, THREAD_COUNT, NULL, NULL); + + for (int i = 0; i < THREAD_COUNT; i++) { + ATF_REQUIRE_EQ(0, pthread_join(threads[i], NULL)); + } +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, batching); + return (atf_no_error()); +} Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Tue Nov 17 03:26:56 2020 (r367742) +++ head/sys/kern/kern_umtx.c Tue Nov 17 03:34:01 2020 (r367743) @@ -4370,10 +4370,10 @@ __umtx_op_sem2_wait_compat32(struct thread *td, struct static int __umtx_op_nwake_private32(struct thread *td, struct _umtx_op_args *uap) { - uint32_t uaddrs[BATCH_SIZE], **upp; + uint32_t uaddrs[BATCH_SIZE], *upp; int count, error, i, pos, tocopy; - upp = (uint32_t **)uap->obj; + upp = (uint32_t *)uap->obj; error = 0; for (count = uap->val, pos = 0; count > 0; count -= tocopy, pos += tocopy) { @@ -4382,7 +4382,7 @@ __umtx_op_nwake_private32(struct thread *td, struct _u if (error != 0) break; for (i = 0; i < tocopy; ++i) - kern_umtx_wake(td, (void *)(intptr_t)uaddrs[i], + kern_umtx_wake(td, (void *)(uintptr_t)uaddrs[i], INT_MAX, 1); maybe_yield(); } From owner-svn-src-all@freebsd.org Tue Nov 17 03:36:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0DC5547E88B; Tue, 17 Nov 2020 03:36:59 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZs7Z6yrSz3LCX; Tue, 17 Nov 2020 03:36:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D328E194F3; Tue, 17 Nov 2020 03:36:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH3awCe006486; Tue, 17 Nov 2020 03:36:58 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH3awYt006482; Tue, 17 Nov 2020 03:36:58 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202011170336.0AH3awYt006482@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 17 Nov 2020 03:36:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367744 - in head/sys: compat/freebsd32 kern sys X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head/sys: compat/freebsd32 kern sys X-SVN-Commit-Revision: 367744 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 03:36:59 -0000 Author: kevans Date: Tue Nov 17 03:36:58 2020 New Revision: 367744 URL: https://svnweb.freebsd.org/changeset/base/367744 Log: umtx_op: reduce redundancy required for compat32 All of the compat32 variants are substantially the same, save for copyin/copyout (mostly). Apply the same kind of technique used with kevent here by having the syscall routines supply a umtx_copyops describing the operations needed. umtx_copyops carries the bare minimum needed- size of timespec and _umtx_time are used for determining if copyout is needed in the sem2_wait case. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27222 Modified: head/sys/compat/freebsd32/freebsd32.h head/sys/compat/freebsd32/freebsd32_misc.c head/sys/kern/kern_umtx.c head/sys/sys/proc.h head/sys/sys/syscallsubr.h head/sys/sys/umtx.h Modified: head/sys/compat/freebsd32/freebsd32.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:34:01 2020 (r367743) +++ head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:36:58 2020 (r367744) @@ -94,6 +94,27 @@ struct itimerval32 { struct timeval32 it_value; }; +struct umtx_time32 { + struct timespec32 _timeout; + uint32_t _flags; + uint32_t _clockid; +}; + +struct umtx_robust_lists_params_compat32 { + uint32_t robust_list_offset; + uint32_t robust_priv_list_offset; + uint32_t robust_inact_offset; +}; + +struct umutex32 { + volatile __lwpid_t m_owner; /* Owner of the mutex */ + __uint32_t m_flags; /* Flags of the mutex */ + __uint32_t m_ceilings[2]; /* Priority protect ceiling */ + __uint32_t m_rb_lnk; /* Robust linkage */ + __uint32_t m_pad; + __uint32_t m_spare[2]; +}; + #define FREEBSD4_MFSNAMELEN 16 #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:34:01 2020 (r367743) +++ head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:36:58 2020 (r367744) @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -3764,4 +3765,12 @@ freebsd32_sched_rr_get_interval(struct thread *td, error = copyout(&ts32, uap->interval, sizeof(ts32)); } return (error); +} + +int +freebsd32__umtx_op(struct thread *td, struct freebsd32__umtx_op_args *uap) +{ + + return (kern__umtx_op(td, uap->obj, uap->op, uap->val, uap->uaddr, + uap->uaddr2, &umtx_native_ops32)); } Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Tue Nov 17 03:34:01 2020 (r367743) +++ head/sys/kern/kern_umtx.c Tue Nov 17 03:36:58 2020 (r367744) @@ -219,20 +219,9 @@ struct abs_timeout { struct timespec end; }; -#ifdef COMPAT_FREEBSD32 -struct umutex32 { - volatile __lwpid_t m_owner; /* Owner of the mutex */ - __uint32_t m_flags; /* Flags of the mutex */ - __uint32_t m_ceilings[2]; /* Priority protect ceiling */ - __uint32_t m_rb_lnk; /* Robust linkage */ - __uint32_t m_pad; - __uint32_t m_spare[2]; -}; - _Static_assert(sizeof(struct umutex) == sizeof(struct umutex32), "umutex32"); _Static_assert(__offsetof(struct umutex, m_spare[0]) == __offsetof(struct umutex32, m_spare[0]), "m_spare32"); -#endif int umtx_shm_vnobj_persistent = 0; SYSCTL_INT(_kern_ipc, OID_AUTO, umtx_vnode_persistent, CTLFLAG_RWTUN, @@ -3400,11 +3389,11 @@ do_sem2_wake(struct thread *td, struct _usem2 *sem) } inline int -umtx_copyin_timeout(const void *addr, struct timespec *tsp) +umtx_copyin_timeout(const void *uaddr, struct timespec *tsp) { int error; - error = copyin(addr, tsp, sizeof(struct timespec)); + error = copyin(uaddr, tsp, sizeof(*tsp)); if (error == 0) { if (tsp->tv_sec < 0 || tsp->tv_nsec >= 1000000000 || @@ -3415,16 +3404,16 @@ umtx_copyin_timeout(const void *addr, struct timespec } static inline int -umtx_copyin_umtx_time(const void *addr, size_t size, struct _umtx_time *tp) +umtx_copyin_umtx_time(const void *uaddr, size_t size, struct _umtx_time *tp) { int error; - if (size <= sizeof(struct timespec)) { + if (size <= sizeof(tp->_timeout)) { tp->_clockid = CLOCK_REALTIME; tp->_flags = 0; - error = copyin(addr, &tp->_timeout, sizeof(struct timespec)); + error = copyin(uaddr, &tp->_timeout, sizeof(tp->_timeout)); } else - error = copyin(addr, tp, sizeof(struct _umtx_time)); + error = copyin(uaddr, tp, sizeof(*tp)); if (error != 0) return (error); if (tp->_timeout.tv_sec < 0 || @@ -3434,14 +3423,41 @@ umtx_copyin_umtx_time(const void *addr, size_t size, s } static int -__umtx_op_unimpl(struct thread *td, struct _umtx_op_args *uap) +umtx_copyin_robust_lists(const void *uaddr, size_t size, + struct umtx_robust_lists_params *rb) { + if (size > sizeof(*rb)) + return (EINVAL); + return (copyin(uaddr, &rb, size)); +} + +static int +umtx_copyout_timeout(void *uaddr, size_t sz, struct timespec *tsp) +{ + + /* + * Should be guaranteed by the caller, sz == uaddr1 - sizeof(_umtx_time) + * and we're only called if sz >= sizeof(timespec) as supplied in the + * copyops. + */ + KASSERT(sz >= sizeof(*tsp), + ("umtx_copyops specifies incorrect sizes")); + + return (copyout(tsp, uaddr, sizeof(*tsp))); +} + +static int +__umtx_op_unimpl(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) +{ + return (EOPNOTSUPP); } static int -__umtx_op_wait(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_wait(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time timeout, *tm_p; int error; @@ -3449,17 +3465,18 @@ __umtx_op_wait(struct thread *td, struct _umtx_op_args if (uap->uaddr2 == NULL) tm_p = NULL; else { - error = umtx_copyin_umtx_time( + error = ops->copyin_umtx_time( uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); tm_p = &timeout; } - return (do_wait(td, uap->obj, uap->val, tm_p, 0, 0)); + return (do_wait(td, uap->obj, uap->val, tm_p, ops->compat32, 0)); } static int -__umtx_op_wait_uint(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_wait_uint(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time timeout, *tm_p; int error; @@ -3467,7 +3484,7 @@ __umtx_op_wait_uint(struct thread *td, struct _umtx_op if (uap->uaddr2 == NULL) tm_p = NULL; else { - error = umtx_copyin_umtx_time( + error = ops->copyin_umtx_time( uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -3477,7 +3494,8 @@ __umtx_op_wait_uint(struct thread *td, struct _umtx_op } static int -__umtx_op_wait_uint_private(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_wait_uint_private(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time *tm_p, timeout; int error; @@ -3485,7 +3503,7 @@ __umtx_op_wait_uint_private(struct thread *td, struct if (uap->uaddr2 == NULL) tm_p = NULL; else { - error = umtx_copyin_umtx_time( + error = ops->copyin_umtx_time( uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -3495,7 +3513,8 @@ __umtx_op_wait_uint_private(struct thread *td, struct } static int -__umtx_op_wake(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_wake(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (kern_umtx_wake(td, uap->obj, uap->val, 0)); @@ -3503,7 +3522,7 @@ __umtx_op_wake(struct thread *td, struct _umtx_op_args #define BATCH_SIZE 128 static int -__umtx_op_nwake_private(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_nwake_private_native(struct thread *td, struct _umtx_op_args *uap) { char *uaddrs[BATCH_SIZE], **upp; int count, error, i, pos, tocopy; @@ -3516,22 +3535,58 @@ __umtx_op_nwake_private(struct thread *td, struct _umt error = copyin(upp + pos, uaddrs, tocopy * sizeof(char *)); if (error != 0) break; - for (i = 0; i < tocopy; ++i) + for (i = 0; i < tocopy; ++i) { kern_umtx_wake(td, uaddrs[i], INT_MAX, 1); + } maybe_yield(); } return (error); } static int -__umtx_op_wake_private(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_nwake_private_compat32(struct thread *td, struct _umtx_op_args *uap) { + uint32_t uaddrs[BATCH_SIZE], *upp; + int count, error, i, pos, tocopy; + upp = (uint32_t *)uap->obj; + error = 0; + for (count = uap->val, pos = 0; count > 0; count -= tocopy, + pos += tocopy) { + tocopy = MIN(count, BATCH_SIZE); + error = copyin(upp + pos, uaddrs, tocopy * sizeof(uint32_t)); + if (error != 0) + break; + for (i = 0; i < tocopy; ++i) { + kern_umtx_wake(td, (void *)(uintptr_t)uaddrs[i], + INT_MAX, 1); + } + maybe_yield(); + } + return (error); +} + +static int +__umtx_op_nwake_private(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) +{ + + if (ops->compat32) + return (__umtx_op_nwake_private_compat32(td, uap)); + return (__umtx_op_nwake_private_native(td, uap)); +} + +static int +__umtx_op_wake_private(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) +{ + return (kern_umtx_wake(td, uap->obj, uap->val, 1)); } static int -__umtx_op_lock_umutex(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_lock_umutex(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time *tm_p, timeout; int error; @@ -3540,7 +3595,7 @@ __umtx_op_lock_umutex(struct thread *td, struct _umtx_ if (uap->uaddr2 == NULL) tm_p = NULL; else { - error = umtx_copyin_umtx_time( + error = ops->copyin_umtx_time( uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -3550,14 +3605,16 @@ __umtx_op_lock_umutex(struct thread *td, struct _umtx_ } static int -__umtx_op_trylock_umutex(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_trylock_umutex(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_lock_umutex(td, uap->obj, NULL, _UMUTEX_TRY)); } static int -__umtx_op_wait_umutex(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_wait_umutex(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time *tm_p, timeout; int error; @@ -3566,7 +3623,7 @@ __umtx_op_wait_umutex(struct thread *td, struct _umtx_ if (uap->uaddr2 == NULL) tm_p = NULL; else { - error = umtx_copyin_umtx_time( + error = ops->copyin_umtx_time( uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -3576,28 +3633,32 @@ __umtx_op_wait_umutex(struct thread *td, struct _umtx_ } static int -__umtx_op_wake_umutex(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_wake_umutex(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_wake_umutex(td, uap->obj)); } static int -__umtx_op_unlock_umutex(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_unlock_umutex(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_unlock_umutex(td, uap->obj, false)); } static int -__umtx_op_set_ceiling(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_set_ceiling(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_set_ceiling(td, uap->obj, uap->val, uap->uaddr1)); } static int -__umtx_op_cv_wait(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_cv_wait(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct timespec *ts, timeout; int error; @@ -3606,7 +3667,7 @@ __umtx_op_cv_wait(struct thread *td, struct _umtx_op_a if (uap->uaddr2 == NULL) ts = NULL; else { - error = umtx_copyin_timeout(uap->uaddr2, &timeout); + error = ops->copyin_timeout(uap->uaddr2, &timeout); if (error != 0) return (error); ts = &timeout; @@ -3615,21 +3676,24 @@ __umtx_op_cv_wait(struct thread *td, struct _umtx_op_a } static int -__umtx_op_cv_signal(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_cv_signal(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_cv_signal(td, uap->obj)); } static int -__umtx_op_cv_broadcast(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_cv_broadcast(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_cv_broadcast(td, uap->obj)); } static int -__umtx_op_rw_rdlock(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_rw_rdlock(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time timeout; int error; @@ -3638,7 +3702,7 @@ __umtx_op_rw_rdlock(struct thread *td, struct _umtx_op if (uap->uaddr2 == NULL) { error = do_rw_rdlock(td, uap->obj, uap->val, 0); } else { - error = umtx_copyin_umtx_time(uap->uaddr2, + error = ops->copyin_umtx_time(uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -3648,7 +3712,8 @@ __umtx_op_rw_rdlock(struct thread *td, struct _umtx_op } static int -__umtx_op_rw_wrlock(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_rw_wrlock(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time timeout; int error; @@ -3657,7 +3722,7 @@ __umtx_op_rw_wrlock(struct thread *td, struct _umtx_op if (uap->uaddr2 == NULL) { error = do_rw_wrlock(td, uap->obj, 0); } else { - error = umtx_copyin_umtx_time(uap->uaddr2, + error = ops->copyin_umtx_time(uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -3668,7 +3733,8 @@ __umtx_op_rw_wrlock(struct thread *td, struct _umtx_op } static int -__umtx_op_rw_unlock(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_rw_unlock(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_rw_unlock(td, uap->obj)); @@ -3676,7 +3742,8 @@ __umtx_op_rw_unlock(struct thread *td, struct _umtx_op #if defined(COMPAT_FREEBSD9) || defined(COMPAT_FREEBSD10) static int -__umtx_op_sem_wait(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_sem_wait(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time *tm_p, timeout; int error; @@ -3685,7 +3752,7 @@ __umtx_op_sem_wait(struct thread *td, struct _umtx_op_ if (uap->uaddr2 == NULL) tm_p = NULL; else { - error = umtx_copyin_umtx_time( + error = ops->copyin_umtx_time( uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -3695,7 +3762,8 @@ __umtx_op_sem_wait(struct thread *td, struct _umtx_op_ } static int -__umtx_op_sem_wake(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_sem_wake(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_sem_wake(td, uap->obj)); @@ -3703,14 +3771,16 @@ __umtx_op_sem_wake(struct thread *td, struct _umtx_op_ #endif static int -__umtx_op_wake2_umutex(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_wake2_umutex(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_wake2_umutex(td, uap->obj, uap->val)); } static int -__umtx_op_sem2_wait(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_sem2_wait(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { struct _umtx_time *tm_p, timeout; size_t uasize; @@ -3722,7 +3792,7 @@ __umtx_op_sem2_wait(struct thread *td, struct _umtx_op tm_p = NULL; } else { uasize = (size_t)uap->uaddr1; - error = umtx_copyin_umtx_time(uap->uaddr2, uasize, &timeout); + error = ops->copyin_umtx_time(uap->uaddr2, uasize, &timeout); if (error != 0) return (error); tm_p = &timeout; @@ -3730,10 +3800,10 @@ __umtx_op_sem2_wait(struct thread *td, struct _umtx_op error = do_sem2_wait(td, uap->obj, tm_p); if (error == EINTR && uap->uaddr2 != NULL && (timeout._flags & UMTX_ABSTIME) == 0 && - uasize >= sizeof(struct _umtx_time) + sizeof(struct timespec)) { - error = copyout(&timeout._timeout, - (struct _umtx_time *)uap->uaddr2 + 1, - sizeof(struct timespec)); + uasize >= ops->umtx_time_sz + ops->timespec_sz) { + error = ops->copyout_timeout( + (void *)((uintptr_t)uap->uaddr2 + ops->umtx_time_sz), + uasize - ops->umtx_time_sz, &timeout._timeout); if (error == 0) { error = EINTR; } @@ -3743,7 +3813,8 @@ __umtx_op_sem2_wait(struct thread *td, struct _umtx_op } static int -__umtx_op_sem2_wake(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_sem2_wake(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (do_sem2_wake(td, uap->obj)); @@ -4050,418 +4121,203 @@ umtx_shm(struct thread *td, void *addr, u_int flags) } static int -__umtx_op_shm(struct thread *td, struct _umtx_op_args *uap) +__umtx_op_shm(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops __unused) { return (umtx_shm(td, uap->uaddr1, uap->val)); } static int -umtx_robust_lists(struct thread *td, struct umtx_robust_lists_params *rbp) +__umtx_op_robust_lists(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *ops) { - - td->td_rb_list = rbp->robust_list_offset; - td->td_rbp_list = rbp->robust_priv_list_offset; - td->td_rb_inact = rbp->robust_inact_offset; - return (0); -} - -static int -__umtx_op_robust_lists(struct thread *td, struct _umtx_op_args *uap) -{ struct umtx_robust_lists_params rb; int error; - if (uap->val > sizeof(rb)) - return (EINVAL); bzero(&rb, sizeof(rb)); - error = copyin(uap->uaddr1, &rb, uap->val); + error = ops->copyin_robust_lists(uap->uaddr1, uap->val, &rb); if (error != 0) return (error); - return (umtx_robust_lists(td, &rb)); -} -typedef int (*_umtx_op_func)(struct thread *td, struct _umtx_op_args *uap); + if (ops->compat32) + td->td_pflags2 |= TDP2_COMPAT32RB; + else if ((td->td_pflags2 & TDP2_COMPAT32RB) != 0) + return (EINVAL); -static const _umtx_op_func op_table[] = { - [UMTX_OP_RESERVED0] = __umtx_op_unimpl, - [UMTX_OP_RESERVED1] = __umtx_op_unimpl, - [UMTX_OP_WAIT] = __umtx_op_wait, - [UMTX_OP_WAKE] = __umtx_op_wake, - [UMTX_OP_MUTEX_TRYLOCK] = __umtx_op_trylock_umutex, - [UMTX_OP_MUTEX_LOCK] = __umtx_op_lock_umutex, - [UMTX_OP_MUTEX_UNLOCK] = __umtx_op_unlock_umutex, - [UMTX_OP_SET_CEILING] = __umtx_op_set_ceiling, - [UMTX_OP_CV_WAIT] = __umtx_op_cv_wait, - [UMTX_OP_CV_SIGNAL] = __umtx_op_cv_signal, - [UMTX_OP_CV_BROADCAST] = __umtx_op_cv_broadcast, - [UMTX_OP_WAIT_UINT] = __umtx_op_wait_uint, - [UMTX_OP_RW_RDLOCK] = __umtx_op_rw_rdlock, - [UMTX_OP_RW_WRLOCK] = __umtx_op_rw_wrlock, - [UMTX_OP_RW_UNLOCK] = __umtx_op_rw_unlock, - [UMTX_OP_WAIT_UINT_PRIVATE] = __umtx_op_wait_uint_private, - [UMTX_OP_WAKE_PRIVATE] = __umtx_op_wake_private, - [UMTX_OP_MUTEX_WAIT] = __umtx_op_wait_umutex, - [UMTX_OP_MUTEX_WAKE] = __umtx_op_wake_umutex, -#if defined(COMPAT_FREEBSD9) || defined(COMPAT_FREEBSD10) - [UMTX_OP_SEM_WAIT] = __umtx_op_sem_wait, - [UMTX_OP_SEM_WAKE] = __umtx_op_sem_wake, -#else - [UMTX_OP_SEM_WAIT] = __umtx_op_unimpl, - [UMTX_OP_SEM_WAKE] = __umtx_op_unimpl, -#endif - [UMTX_OP_NWAKE_PRIVATE] = __umtx_op_nwake_private, - [UMTX_OP_MUTEX_WAKE2] = __umtx_op_wake2_umutex, - [UMTX_OP_SEM2_WAIT] = __umtx_op_sem2_wait, - [UMTX_OP_SEM2_WAKE] = __umtx_op_sem2_wake, - [UMTX_OP_SHM] = __umtx_op_shm, - [UMTX_OP_ROBUST_LISTS] = __umtx_op_robust_lists, -}; - -int -sys__umtx_op(struct thread *td, struct _umtx_op_args *uap) -{ - - if ((unsigned)uap->op < nitems(op_table)) - return (*op_table[uap->op])(td, uap); - return (EINVAL); + td->td_rb_list = rb.robust_list_offset; + td->td_rbp_list = rb.robust_priv_list_offset; + td->td_rb_inact = rb.robust_inact_offset; + return (0); } #ifdef COMPAT_FREEBSD32 - -struct umtx_time32 { - struct timespec32 timeout; - uint32_t flags; - uint32_t clockid; -}; - static inline int -umtx_copyin_timeout32(void *addr, struct timespec *tsp) +umtx_copyin_timeout32(const void *uaddr, struct timespec *tsp) { struct timespec32 ts32; int error; - error = copyin(addr, &ts32, sizeof(struct timespec32)); + error = copyin(uaddr, &ts32, sizeof(ts32)); if (error == 0) { if (ts32.tv_sec < 0 || ts32.tv_nsec >= 1000000000 || ts32.tv_nsec < 0) error = EINVAL; else { - tsp->tv_sec = ts32.tv_sec; - tsp->tv_nsec = ts32.tv_nsec; + CP(ts32, *tsp, tv_sec); + CP(ts32, *tsp, tv_nsec); } } return (error); } static inline int -umtx_copyin_umtx_time32(const void *addr, size_t size, struct _umtx_time *tp) +umtx_copyin_umtx_time32(const void *uaddr, size_t size, struct _umtx_time *tp) { struct umtx_time32 t32; int error; - t32.clockid = CLOCK_REALTIME; - t32.flags = 0; - if (size <= sizeof(struct timespec32)) - error = copyin(addr, &t32.timeout, sizeof(struct timespec32)); + t32._clockid = CLOCK_REALTIME; + t32._flags = 0; + if (size <= sizeof(t32._timeout)) + error = copyin(uaddr, &t32._timeout, sizeof(t32._timeout)); else - error = copyin(addr, &t32, sizeof(struct umtx_time32)); + error = copyin(uaddr, &t32, sizeof(t32)); if (error != 0) return (error); - if (t32.timeout.tv_sec < 0 || - t32.timeout.tv_nsec >= 1000000000 || t32.timeout.tv_nsec < 0) + if (t32._timeout.tv_sec < 0 || + t32._timeout.tv_nsec >= 1000000000 || t32._timeout.tv_nsec < 0) return (EINVAL); - tp->_timeout.tv_sec = t32.timeout.tv_sec; - tp->_timeout.tv_nsec = t32.timeout.tv_nsec; - tp->_flags = t32.flags; - tp->_clockid = t32.clockid; + TS_CP(t32, *tp, _timeout); + CP(t32, *tp, _flags); + CP(t32, *tp, _clockid); return (0); } static int -__umtx_op_wait_compat32(struct thread *td, struct _umtx_op_args *uap) +umtx_copyin_robust_lists32(const void *uaddr, size_t size, + struct umtx_robust_lists_params *rbp) { - struct _umtx_time *tm_p, timeout; + struct umtx_robust_lists_params_compat32 rb32; int error; - if (uap->uaddr2 == NULL) - tm_p = NULL; - else { - error = umtx_copyin_umtx_time32(uap->uaddr2, - (size_t)uap->uaddr1, &timeout); - if (error != 0) - return (error); - tm_p = &timeout; - } - return (do_wait(td, uap->obj, uap->val, tm_p, 1, 0)); + if (size > sizeof(rb32)) + return (EINVAL); + bzero(&rb32, sizeof(rb32)); + error = copyin(uaddr, &rb32, size); + if (error != 0) + return (error); + CP(rb32, *rbp, robust_list_offset); + CP(rb32, *rbp, robust_priv_list_offset); + CP(rb32, *rbp, robust_inact_offset); + return (0); } static int -__umtx_op_lock_umutex_compat32(struct thread *td, struct _umtx_op_args *uap) +umtx_copyout_timeout32(void *uaddr, size_t sz, struct timespec *tsp) { - struct _umtx_time *tm_p, timeout; - int error; + struct timespec32 remain32 = { + .tv_sec = tsp->tv_sec, + .tv_nsec = tsp->tv_nsec, + }; - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) - tm_p = NULL; - else { - error = umtx_copyin_umtx_time32(uap->uaddr2, - (size_t)uap->uaddr1, &timeout); - if (error != 0) - return (error); - tm_p = &timeout; - } - return (do_lock_umutex(td, uap->obj, tm_p, 0)); -} + /* + * Should be guaranteed by the caller, sz == uaddr1 - sizeof(_umtx_time) + * and we're only called if sz >= sizeof(timespec) as supplied in the + * copyops. + */ + KASSERT(sz >= sizeof(remain32), + ("umtx_copyops specifies incorrect sizes")); -static int -__umtx_op_wait_umutex_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct _umtx_time *tm_p, timeout; - int error; - - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) - tm_p = NULL; - else { - error = umtx_copyin_umtx_time32(uap->uaddr2, - (size_t)uap->uaddr1, &timeout); - if (error != 0) - return (error); - tm_p = &timeout; - } - return (do_lock_umutex(td, uap->obj, tm_p, _UMUTEX_WAIT)); + return (copyout(&remain32, uaddr, sizeof(remain32))); } +#endif /* COMPAT_FREEBSD32 */ -static int -__umtx_op_cv_wait_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct timespec *ts, timeout; - int error; +typedef int (*_umtx_op_func)(struct thread *td, struct _umtx_op_args *uap, + const struct umtx_copyops *umtx_ops); - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) - ts = NULL; - else { - error = umtx_copyin_timeout32(uap->uaddr2, &timeout); - if (error != 0) - return (error); - ts = &timeout; - } - return (do_cv_wait(td, uap->obj, uap->uaddr1, ts, uap->val)); -} - -static int -__umtx_op_rw_rdlock_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct _umtx_time timeout; - int error; - - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) { - error = do_rw_rdlock(td, uap->obj, uap->val, 0); - } else { - error = umtx_copyin_umtx_time32(uap->uaddr2, - (size_t)uap->uaddr1, &timeout); - if (error != 0) - return (error); - error = do_rw_rdlock(td, uap->obj, uap->val, &timeout); - } - return (error); -} - -static int -__umtx_op_rw_wrlock_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct _umtx_time timeout; - int error; - - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) { - error = do_rw_wrlock(td, uap->obj, 0); - } else { - error = umtx_copyin_umtx_time32(uap->uaddr2, - (size_t)uap->uaddr1, &timeout); - if (error != 0) - return (error); - error = do_rw_wrlock(td, uap->obj, &timeout); - } - return (error); -} - -static int -__umtx_op_wait_uint_private_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct _umtx_time *tm_p, timeout; - int error; - - if (uap->uaddr2 == NULL) - tm_p = NULL; - else { - error = umtx_copyin_umtx_time32( - uap->uaddr2, (size_t)uap->uaddr1,&timeout); - if (error != 0) - return (error); - tm_p = &timeout; - } - return (do_wait(td, uap->obj, uap->val, tm_p, 1, 1)); -} - -#if defined(COMPAT_FREEBSD9) || defined(COMPAT_FREEBSD10) -static int -__umtx_op_sem_wait_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct _umtx_time *tm_p, timeout; - int error; - - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) - tm_p = NULL; - else { - error = umtx_copyin_umtx_time32(uap->uaddr2, - (size_t)uap->uaddr1, &timeout); - if (error != 0) - return (error); - tm_p = &timeout; - } - return (do_sem_wait(td, uap->obj, tm_p)); -} -#endif - -static int -__umtx_op_sem2_wait_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct _umtx_time *tm_p, timeout; - size_t uasize; - int error; - - /* Allow a null timespec (wait forever). */ - if (uap->uaddr2 == NULL) { - uasize = 0; - tm_p = NULL; - } else { - uasize = (size_t)uap->uaddr1; - error = umtx_copyin_umtx_time32(uap->uaddr2, uasize, &timeout); - if (error != 0) - return (error); - tm_p = &timeout; - } - error = do_sem2_wait(td, uap->obj, tm_p); - if (error == EINTR && uap->uaddr2 != NULL && - (timeout._flags & UMTX_ABSTIME) == 0 && - uasize >= sizeof(struct umtx_time32) + sizeof(struct timespec32)) { - struct timespec32 remain32 = { - .tv_sec = timeout._timeout.tv_sec, - .tv_nsec = timeout._timeout.tv_nsec - }; - error = copyout(&remain32, - (struct umtx_time32 *)uap->uaddr2 + 1, - sizeof(struct timespec32)); - if (error == 0) { - error = EINTR; - } - } - - return (error); -} - -static int -__umtx_op_nwake_private32(struct thread *td, struct _umtx_op_args *uap) -{ - uint32_t uaddrs[BATCH_SIZE], *upp; - int count, error, i, pos, tocopy; - - upp = (uint32_t *)uap->obj; - error = 0; - for (count = uap->val, pos = 0; count > 0; count -= tocopy, - pos += tocopy) { - tocopy = MIN(count, BATCH_SIZE); - error = copyin(upp + pos, uaddrs, tocopy * sizeof(uint32_t)); - if (error != 0) - break; - for (i = 0; i < tocopy; ++i) - kern_umtx_wake(td, (void *)(uintptr_t)uaddrs[i], - INT_MAX, 1); - maybe_yield(); - } - return (error); -} - -struct umtx_robust_lists_params_compat32 { - uint32_t robust_list_offset; - uint32_t robust_priv_list_offset; - uint32_t robust_inact_offset; -}; - -static int -__umtx_op_robust_lists_compat32(struct thread *td, struct _umtx_op_args *uap) -{ - struct umtx_robust_lists_params rb; - struct umtx_robust_lists_params_compat32 rb32; - int error; - - if (uap->val > sizeof(rb32)) - return (EINVAL); - bzero(&rb, sizeof(rb)); - bzero(&rb32, sizeof(rb32)); - error = copyin(uap->uaddr1, &rb32, uap->val); - if (error != 0) - return (error); - rb.robust_list_offset = rb32.robust_list_offset; - rb.robust_priv_list_offset = rb32.robust_priv_list_offset; - rb.robust_inact_offset = rb32.robust_inact_offset; - return (umtx_robust_lists(td, &rb)); -} - -static const _umtx_op_func op_table_compat32[] = { +static const _umtx_op_func op_table[] = { [UMTX_OP_RESERVED0] = __umtx_op_unimpl, [UMTX_OP_RESERVED1] = __umtx_op_unimpl, - [UMTX_OP_WAIT] = __umtx_op_wait_compat32, + [UMTX_OP_WAIT] = __umtx_op_wait, [UMTX_OP_WAKE] = __umtx_op_wake, [UMTX_OP_MUTEX_TRYLOCK] = __umtx_op_trylock_umutex, - [UMTX_OP_MUTEX_LOCK] = __umtx_op_lock_umutex_compat32, + [UMTX_OP_MUTEX_LOCK] = __umtx_op_lock_umutex, [UMTX_OP_MUTEX_UNLOCK] = __umtx_op_unlock_umutex, [UMTX_OP_SET_CEILING] = __umtx_op_set_ceiling, - [UMTX_OP_CV_WAIT] = __umtx_op_cv_wait_compat32, + [UMTX_OP_CV_WAIT] = __umtx_op_cv_wait, [UMTX_OP_CV_SIGNAL] = __umtx_op_cv_signal, [UMTX_OP_CV_BROADCAST] = __umtx_op_cv_broadcast, - [UMTX_OP_WAIT_UINT] = __umtx_op_wait_compat32, - [UMTX_OP_RW_RDLOCK] = __umtx_op_rw_rdlock_compat32, - [UMTX_OP_RW_WRLOCK] = __umtx_op_rw_wrlock_compat32, + [UMTX_OP_WAIT_UINT] = __umtx_op_wait_uint, + [UMTX_OP_RW_RDLOCK] = __umtx_op_rw_rdlock, + [UMTX_OP_RW_WRLOCK] = __umtx_op_rw_wrlock, [UMTX_OP_RW_UNLOCK] = __umtx_op_rw_unlock, - [UMTX_OP_WAIT_UINT_PRIVATE] = __umtx_op_wait_uint_private_compat32, + [UMTX_OP_WAIT_UINT_PRIVATE] = __umtx_op_wait_uint_private, [UMTX_OP_WAKE_PRIVATE] = __umtx_op_wake_private, - [UMTX_OP_MUTEX_WAIT] = __umtx_op_wait_umutex_compat32, + [UMTX_OP_MUTEX_WAIT] = __umtx_op_wait_umutex, [UMTX_OP_MUTEX_WAKE] = __umtx_op_wake_umutex, #if defined(COMPAT_FREEBSD9) || defined(COMPAT_FREEBSD10) - [UMTX_OP_SEM_WAIT] = __umtx_op_sem_wait_compat32, + [UMTX_OP_SEM_WAIT] = __umtx_op_sem_wait, [UMTX_OP_SEM_WAKE] = __umtx_op_sem_wake, #else [UMTX_OP_SEM_WAIT] = __umtx_op_unimpl, [UMTX_OP_SEM_WAKE] = __umtx_op_unimpl, #endif - [UMTX_OP_NWAKE_PRIVATE] = __umtx_op_nwake_private32, + [UMTX_OP_NWAKE_PRIVATE] = __umtx_op_nwake_private, [UMTX_OP_MUTEX_WAKE2] = __umtx_op_wake2_umutex, - [UMTX_OP_SEM2_WAIT] = __umtx_op_sem2_wait_compat32, + [UMTX_OP_SEM2_WAIT] = __umtx_op_sem2_wait, [UMTX_OP_SEM2_WAKE] = __umtx_op_sem2_wake, [UMTX_OP_SHM] = __umtx_op_shm, - [UMTX_OP_ROBUST_LISTS] = __umtx_op_robust_lists_compat32, + [UMTX_OP_ROBUST_LISTS] = __umtx_op_robust_lists, }; +static const struct umtx_copyops umtx_native_ops = { + .copyin_timeout = umtx_copyin_timeout, + .copyin_umtx_time = umtx_copyin_umtx_time, + .copyin_robust_lists = umtx_copyin_robust_lists, + .copyout_timeout = umtx_copyout_timeout, + .timespec_sz = sizeof(struct timespec), + .umtx_time_sz = sizeof(struct _umtx_time), +}; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Nov 17 04:06:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9C6F47EA58; Tue, 17 Nov 2020 04:06:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZsnl4BtHz3MNh; Tue, 17 Nov 2020 04:06:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7EF5A19E89; Tue, 17 Nov 2020 04:06:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH46ZTt025034; Tue, 17 Nov 2020 04:06:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH46Zj0025033; Tue, 17 Nov 2020 04:06:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202011170406.0AH46Zj0025033@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 17 Nov 2020 04:06:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367745 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 367745 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 04:06:35 -0000 Author: kevans Date: Tue Nov 17 04:06:35 2020 New Revision: 367745 URL: https://svnweb.freebsd.org/changeset/base/367745 Log: sys/proc.h: improve comment for new TDP2 flag This was suggested by kib and integrated locally, but somehow did not make it into the committed version. Modified: head/sys/sys/proc.h Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Tue Nov 17 03:36:58 2020 (r367744) +++ head/sys/sys/proc.h Tue Nov 17 04:06:35 2020 (r367745) @@ -519,7 +519,7 @@ do { \ #define TDP_SIGFASTPENDING 0x80000000 /* Pending signal due to sigfastblock */ #define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */ -#define TDP2_COMPAT32RB 0x00000002 /* compat32 robust lists */ +#define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */ /* * Reasons that the current thread can not be run yet. From owner-svn-src-all@freebsd.org Tue Nov 17 04:22:11 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3AC2047EF7E; Tue, 17 Nov 2020 04:22:11 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZt7l1DZKz3N2W; Tue, 17 Nov 2020 04:22:11 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1D65319FA2; Tue, 17 Nov 2020 04:22:11 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH4MA3R036243; Tue, 17 Nov 2020 04:22:10 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH4MA29036242; Tue, 17 Nov 2020 04:22:10 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202011170422.0AH4MA29036242@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 17 Nov 2020 04:22:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367746 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367746 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 04:22:11 -0000 Author: kevans Date: Tue Nov 17 04:22:10 2020 New Revision: 367746 URL: https://svnweb.freebsd.org/changeset/base/367746 Log: Fix !COMPAT_FREEBSD32 kernel build One of the last shifts inadvertently moved these static assertions out of a COMPAT_FREEBSD32 block, which the relevant definitions are limited to. Fix it. Pointy hat: kevans Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Tue Nov 17 04:06:35 2020 (r367745) +++ head/sys/kern/kern_umtx.c Tue Nov 17 04:22:10 2020 (r367746) @@ -219,9 +219,11 @@ struct abs_timeout { struct timespec end; }; +#ifdef COMPAT_FREEBSD32 _Static_assert(sizeof(struct umutex) == sizeof(struct umutex32), "umutex32"); _Static_assert(__offsetof(struct umutex, m_spare[0]) == __offsetof(struct umutex32, m_spare[0]), "m_spare32"); +#endif int umtx_shm_vnobj_persistent = 0; SYSCTL_INT(_kern_ipc, OID_AUTO, umtx_vnode_persistent, CTLFLAG_RWTUN, From owner-svn-src-all@freebsd.org Tue Nov 17 05:00:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 21DA947FCF7; Tue, 17 Nov 2020 05:00:24 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZtzr0VFrz3PVx; Tue, 17 Nov 2020 05:00:24 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 03D561A0FF; Tue, 17 Nov 2020 05:00:24 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH50N3w056149; Tue, 17 Nov 2020 05:00:23 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH50NK7056148; Tue, 17 Nov 2020 05:00:23 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <202011170500.0AH50NK7056148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Tue, 17 Nov 2020 05:00:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367747 - stable/12/sys/netgraph X-SVN-Group: stable-12 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/12/sys/netgraph X-SVN-Commit-Revision: 367747 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 05:00:24 -0000 Author: eugen Date: Tue Nov 17 05:00:23 2020 New Revision: 367747 URL: https://svnweb.freebsd.org/changeset/base/367747 Log: MFC r367545: ng_nat: unbreak ABI The revision r342168 broke ABI of ng_nat needlessly and the change was merged to stable branches breaking ABI there, too. Unbreak it. PR: 250722 Modified: stable/12/sys/netgraph/ng_nat.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netgraph/ng_nat.h ============================================================================== --- stable/12/sys/netgraph/ng_nat.h Tue Nov 17 04:22:10 2020 (r367746) +++ stable/12/sys/netgraph/ng_nat.h Tue Nov 17 05:00:23 2020 (r367747) @@ -205,8 +205,6 @@ enum { NGM_NAT_SET_IPADDR = 1, NGM_NAT_SET_MODE, NGM_NAT_SET_TARGET, - NGM_NAT_SET_DLT, - NGM_NAT_GET_DLT, NGM_NAT_REDIRECT_PORT, NGM_NAT_REDIRECT_ADDR, NGM_NAT_REDIRECT_PROTO, @@ -216,4 +214,6 @@ enum { NGM_NAT_LIST_REDIRECTS, NGM_NAT_PROXY_RULE, NGM_NAT_LIBALIAS_INFO, + NGM_NAT_SET_DLT, + NGM_NAT_GET_DLT, }; From owner-svn-src-all@freebsd.org Tue Nov 17 05:01:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B646B47FEE3; Tue, 17 Nov 2020 05:01:55 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZv1b4rLtz3Q5S; Tue, 17 Nov 2020 05:01:55 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 98FC71A93E; Tue, 17 Nov 2020 05:01:55 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH51tue061770; Tue, 17 Nov 2020 05:01:55 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH51tlX061769; Tue, 17 Nov 2020 05:01:55 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <202011170501.0AH51tlX061769@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Tue, 17 Nov 2020 05:01:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r367748 - stable/11/sys/netgraph X-SVN-Group: stable-11 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/11/sys/netgraph X-SVN-Commit-Revision: 367748 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 05:01:55 -0000 Author: eugen Date: Tue Nov 17 05:01:55 2020 New Revision: 367748 URL: https://svnweb.freebsd.org/changeset/base/367748 Log: MFC r367545: ng_nat: unbreak ABI The revision r342168 broke ABI of ng_nat needlessly and the change was merged to stable branches breaking ABI there, too. Unbreak it. PR: 250722 Modified: stable/11/sys/netgraph/ng_nat.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netgraph/ng_nat.h ============================================================================== --- stable/11/sys/netgraph/ng_nat.h Tue Nov 17 05:00:23 2020 (r367747) +++ stable/11/sys/netgraph/ng_nat.h Tue Nov 17 05:01:55 2020 (r367748) @@ -203,8 +203,6 @@ enum { NGM_NAT_SET_IPADDR = 1, NGM_NAT_SET_MODE, NGM_NAT_SET_TARGET, - NGM_NAT_SET_DLT, - NGM_NAT_GET_DLT, NGM_NAT_REDIRECT_PORT, NGM_NAT_REDIRECT_ADDR, NGM_NAT_REDIRECT_PROTO, @@ -214,4 +212,6 @@ enum { NGM_NAT_LIST_REDIRECTS, NGM_NAT_PROXY_RULE, NGM_NAT_LIBALIAS_INFO, + NGM_NAT_SET_DLT, + NGM_NAT_GET_DLT, }; From owner-svn-src-all@freebsd.org Tue Nov 17 05:48:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F2F4A2D0D1A; Tue, 17 Nov 2020 05:48:01 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZw2n6YVsz3hq7; Tue, 17 Nov 2020 05:48:01 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF5B41ADEC; Tue, 17 Nov 2020 05:48:01 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH5m1Cg086682; Tue, 17 Nov 2020 05:48:01 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH5m1nB086679; Tue, 17 Nov 2020 05:48:01 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <202011170548.0AH5m1nB086679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 17 Nov 2020 05:48:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367749 - stable/12/sys/ufs/ffs X-SVN-Group: stable-12 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/12/sys/ufs/ffs X-SVN-Commit-Revision: 367749 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 05:48:02 -0000 Author: mckusick Date: Tue Nov 17 05:48:00 2020 New Revision: 367749 URL: https://svnweb.freebsd.org/changeset/base/367749 Log: MFC of 340927 and 367034. Move clear of UFS feature flags from ufs_mountfs() to ffs_sbget() to ensure that the appropriate feature flags get cleared by filesystem utilities as well as the kernel when they modify the filesystem. Note 340927 is relevant for this even though it was done for a different reason at the time. Sponsored by: Netflix Modified: stable/12/sys/ufs/ffs/ffs_subr.c stable/12/sys/ufs/ffs/ffs_vfsops.c stable/12/sys/ufs/ffs/fs.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/ufs/ffs/ffs_subr.c ============================================================================== --- stable/12/sys/ufs/ffs/ffs_subr.c Tue Nov 17 05:01:55 2020 (r367748) +++ stable/12/sys/ufs/ffs/ffs_subr.c Tue Nov 17 05:48:00 2020 (r367749) @@ -316,7 +316,20 @@ readsuper(void *devfd, struct fs **fsp, off_t sblocklo fs->fs_ncg >= 1 && fs->fs_bsize >= MINBSIZE && fs->fs_bsize <= MAXBSIZE && - fs->fs_bsize >= roundup(sizeof(struct fs), DEV_BSIZE)) { + fs->fs_bsize >= roundup(sizeof(struct fs), DEV_BSIZE) && + fs->fs_sbsize <= SBLOCKSIZE) { + /* + * If the filesystem has been run on a kernel without + * metadata check hashes, disable them. + */ + if ((fs->fs_flags & FS_METACKHASH) == 0) + fs->fs_metackhash = 0; + /* + * Clear any check-hashes that are not maintained + * by this kernel. Also clear any unsupported flags. + */ + fs->fs_metackhash &= CK_SUPPORTED; + fs->fs_flags &= FS_SUPPORTED; /* Have to set for old filesystems that predate this field */ fs->fs_sblockactualloc = sblockloc; /* Not yet any summary information */ Modified: stable/12/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/12/sys/ufs/ffs/ffs_vfsops.c Tue Nov 17 05:01:55 2020 (r367748) +++ stable/12/sys/ufs/ffs/ffs_vfsops.c Tue Nov 17 05:48:00 2020 (r367749) @@ -828,13 +828,6 @@ ffs_mountfs(devvp, mp, td) if ((error = ffs_sbget(devvp, &fs, -1, M_UFSMNT, ffs_use_bread)) != 0) goto out; fs->fs_fmod = 0; - /* if we ran on a kernel without metadata check hashes, disable them */ - if ((fs->fs_flags & FS_METACKHASH) == 0) - fs->fs_metackhash = 0; - /* none of these types of check-hashes are maintained by this kernel */ - fs->fs_metackhash &= ~(CK_SUPERBLOCK | CK_INODE | CK_INDIR | CK_DIR); - /* no support for any undefined flags */ - fs->fs_flags &= FS_SUPPORTED; fs->fs_flags &= ~FS_UNCLEAN; if (fs->fs_clean == 0) { fs->fs_flags |= FS_UNCLEAN; Modified: stable/12/sys/ufs/ffs/fs.h ============================================================================== --- stable/12/sys/ufs/ffs/fs.h Tue Nov 17 05:01:55 2020 (r367748) +++ stable/12/sys/ufs/ffs/fs.h Tue Nov 17 05:48:00 2020 (r367749) @@ -475,6 +475,7 @@ CTASSERT(sizeof(struct fs) == 1376); #define CK_INODE 0x0004 /* inodes */ #define CK_INDIR 0x0008 /* indirect blocks */ #define CK_DIR 0x0010 /* directory contents */ +#define CK_SUPPORTED 0x0002 /* supported flags, others cleared at mount */ /* * The BX_FSPRIV buffer b_xflags are used to track types of data in buffers. */ From owner-svn-src-all@freebsd.org Tue Nov 17 05:59:56 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 97C402D0FC1; Tue, 17 Nov 2020 05:59:56 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZwJX3rjJz3jXP; Tue, 17 Nov 2020 05:59:56 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6C3A51B1A1; Tue, 17 Nov 2020 05:59:56 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH5xuvI093135; Tue, 17 Nov 2020 05:59:56 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH5xtjw093133; Tue, 17 Nov 2020 05:59:55 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <202011170559.0AH5xtjw093133@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 17 Nov 2020 05:59:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367750 - in stable/12/sbin: fsirand growfs tunefs X-SVN-Group: stable-12 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: in stable/12/sbin: fsirand growfs tunefs X-SVN-Commit-Revision: 367750 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 05:59:56 -0000 Author: mckusick Date: Tue Nov 17 05:59:55 2020 New Revision: 367750 URL: https://svnweb.freebsd.org/changeset/base/367750 Log: MFC of 367035. Require clean superblock for tunefs, growfs, and fsirand Sponsored by: Netflix Modified: stable/12/sbin/fsirand/fsirand.c stable/12/sbin/growfs/growfs.c stable/12/sbin/tunefs/tunefs.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/fsirand/fsirand.c ============================================================================== --- stable/12/sbin/fsirand/fsirand.c Tue Nov 17 05:48:00 2020 (r367749) +++ stable/12/sbin/fsirand/fsirand.c Tue Nov 17 05:59:55 2020 (r367750) @@ -136,6 +136,12 @@ fsirand(char *device) return (1); } } + /* + * Check for unclean filesystem. + */ + if (sblock->fs_clean == 0 || + (sblock->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0) + errx(1, "%s is not clean - run fsck.\n", device); if (sblock->fs_magic == FS_UFS1_MAGIC && sblock->fs_old_inodefmt < FS_44INODEFMT) { Modified: stable/12/sbin/growfs/growfs.c ============================================================================== --- stable/12/sbin/growfs/growfs.c Tue Nov 17 05:48:00 2020 (r367749) +++ stable/12/sbin/growfs/growfs.c Tue Nov 17 05:59:55 2020 (r367750) @@ -1442,6 +1442,12 @@ main(int argc, char **argv) errc(1, ret, "unable to read superblock"); } } + /* + * Check for unclean filesystem. + */ + if (fs->fs_clean == 0 || + (fs->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0) + errx(1, "%s is not clean - run fsck.\n", *argv); memcpy(&osblock, fs, fs->fs_sbsize); free(fs); memcpy((void *)&fsun1, (void *)&fsun2, osblock.fs_sbsize); Modified: stable/12/sbin/tunefs/tunefs.c ============================================================================== --- stable/12/sbin/tunefs/tunefs.c Tue Nov 17 05:48:00 2020 (r367749) +++ stable/12/sbin/tunefs/tunefs.c Tue Nov 17 05:59:55 2020 (r367750) @@ -115,12 +115,12 @@ main(int argc, char *argv[]) switch (ch) { case 'A': - found_arg = 1; + found_arg++; Aflag++; break; case 'a': - found_arg = 1; + found_arg++; name = "POSIX.1e ACLs"; avalue = optarg; if (strcmp(avalue, "enable") && @@ -132,7 +132,7 @@ main(int argc, char *argv[]) break; case 'e': - found_arg = 1; + found_arg++; name = "maximum blocks per file in a cylinder group"; evalue = atoi(optarg); if (evalue < 1) @@ -142,7 +142,7 @@ main(int argc, char *argv[]) break; case 'f': - found_arg = 1; + found_arg++; name = "average file size"; fvalue = atoi(optarg); if (fvalue < 1) @@ -152,7 +152,7 @@ main(int argc, char *argv[]) break; case 'j': - found_arg = 1; + found_arg++; name = "softdep journaled file system"; jvalue = optarg; if (strcmp(jvalue, "enable") && @@ -164,7 +164,7 @@ main(int argc, char *argv[]) break; case 'J': - found_arg = 1; + found_arg++; name = "gjournaled file system"; Jvalue = optarg; if (strcmp(Jvalue, "enable") && @@ -176,7 +176,7 @@ main(int argc, char *argv[]) break; case 'k': - found_arg = 1; + found_arg++; name = "space to hold for metadata blocks"; kvalue = atoi(optarg); if (kvalue < 0) @@ -185,7 +185,7 @@ main(int argc, char *argv[]) break; case 'L': - found_arg = 1; + found_arg++; name = "volume label"; Lvalue = optarg; i = -1; @@ -205,7 +205,7 @@ main(int argc, char *argv[]) break; case 'l': - found_arg = 1; + found_arg++; name = "multilabel MAC file system"; lvalue = optarg; if (strcmp(lvalue, "enable") && @@ -217,7 +217,7 @@ main(int argc, char *argv[]) break; case 'm': - found_arg = 1; + found_arg++; name = "minimum percentage of free space"; mvalue = atoi(optarg); if (mvalue < 0 || mvalue > 99) @@ -226,7 +226,7 @@ main(int argc, char *argv[]) break; case 'N': - found_arg = 1; + found_arg++; name = "NFSv4 ACLs"; Nvalue = optarg; if (strcmp(Nvalue, "enable") && @@ -238,7 +238,7 @@ main(int argc, char *argv[]) break; case 'n': - found_arg = 1; + found_arg++; name = "soft updates"; nvalue = optarg; if (strcmp(nvalue, "enable") != 0 && @@ -250,7 +250,7 @@ main(int argc, char *argv[]) break; case 'o': - found_arg = 1; + found_arg++; name = "optimization preference"; if (strcmp(optarg, "space") == 0) ovalue = FS_OPTSPACE; @@ -264,12 +264,12 @@ main(int argc, char *argv[]) break; case 'p': - found_arg = 1; + found_arg++; pflag = 1; break; case 's': - found_arg = 1; + found_arg++; name = "expected number of files per directory"; svalue = atoi(optarg); if (svalue < 1) @@ -279,7 +279,7 @@ main(int argc, char *argv[]) break; case 'S': - found_arg = 1; + found_arg++; name = "Softdep Journal Size"; Svalue = atoi(optarg); if (Svalue < SUJ_MIN) @@ -288,7 +288,7 @@ main(int argc, char *argv[]) break; case 't': - found_arg = 1; + found_arg++; name = "trim"; tvalue = optarg; if (strcmp(tvalue, "enable") != 0 && @@ -310,6 +310,13 @@ main(int argc, char *argv[]) on = special = argv[0]; if (ufs_disk_fillout(&disk, special) == -1) goto err; + /* + * Check for unclean filesystem. + */ + if ((sblock.fs_clean == 0 || + (sblock.fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0) && + (found_arg > 1 || !pflag)) + errx(1, "%s is not clean - run fsck.\n", special); if (disk.d_name != special) { if (statfs(special, &stfs) != 0) warn("Can't stat %s", special); From owner-svn-src-all@freebsd.org Tue Nov 17 06:04:16 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF75C2D0FEB; Tue, 17 Nov 2020 06:04:16 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZwPX6VVRz3jcR; Tue, 17 Nov 2020 06:04:16 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D1E691B587; Tue, 17 Nov 2020 06:04:16 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH64G42000486; Tue, 17 Nov 2020 06:04:16 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH64GAd000485; Tue, 17 Nov 2020 06:04:16 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <202011170604.0AH64GAd000485@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 17 Nov 2020 06:04:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367751 - stable/12/sbin/fsck_ffs X-SVN-Group: stable-12 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/12/sbin/fsck_ffs X-SVN-Commit-Revision: 367751 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 06:04:17 -0000 Author: mckusick Date: Tue Nov 17 06:04:16 2020 New Revision: 367751 URL: https://svnweb.freebsd.org/changeset/base/367751 Log: MFC of 367045. Avoid improper sign extension in Pass5 inumber checks. Sponsored by: Netflix Modified: stable/12/sbin/fsck_ffs/pass5.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/fsck_ffs/pass5.c ============================================================================== --- stable/12/sbin/fsck_ffs/pass5.c Tue Nov 17 05:59:55 2020 (r367750) +++ stable/12/sbin/fsck_ffs/pass5.c Tue Nov 17 06:04:16 2020 (r367751) @@ -63,6 +63,7 @@ pass5(void) struct fs *fs = &sblock; ufs2_daddr_t d, dbase, dmax, start; int rewritecg = 0; + ino_t inum; struct csum *cs; struct csum_total cstotal; struct inodesc idesc[3]; @@ -236,9 +237,9 @@ pass5(void) } memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum); memset(cg_inosused(newcg), 0, (size_t)(mapsize)); - j = fs->fs_ipg * c; - for (i = 0; i < inostathead[c].il_numalloced; j++, i++) { - switch (inoinfo(j)->ino_state) { + inum = fs->fs_ipg * c; + for (i = 0; i < inostathead[c].il_numalloced; inum++, i++) { + switch (inoinfo(inum)->ino_state) { case USTATE: break; @@ -258,10 +259,10 @@ pass5(void) break; default: - if (j < (int)UFS_ROOTINO) + if (inum < UFS_ROOTINO) break; - errx(EEXIT, "BAD STATE %d FOR INODE I=%d", - inoinfo(j)->ino_state, j); + errx(EEXIT, "BAD STATE %d FOR INODE I=%ju", + inoinfo(inum)->ino_state, (uintmax_t)inum); } } if (c == 0) From owner-svn-src-all@freebsd.org Tue Nov 17 08:03:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 91C382D3EF9; Tue, 17 Nov 2020 08:03:50 +0000 (UTC) (envelope-from rscheff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZz3V3lXMz3ph8; Tue, 17 Nov 2020 08:03:50 +0000 (UTC) (envelope-from rscheff@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 73BA71CC81; Tue, 17 Nov 2020 08:03:50 +0000 (UTC) (envelope-from rscheff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH83oUP074119; Tue, 17 Nov 2020 08:03:50 GMT (envelope-from rscheff@FreeBSD.org) Received: (from rscheff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH83nug074115; Tue, 17 Nov 2020 08:03:49 GMT (envelope-from rscheff@FreeBSD.org) Message-Id: <202011170803.0AH83nug074115@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rscheff set sender to rscheff@FreeBSD.org using -f From: Richard Scheffenegger Date: Tue, 17 Nov 2020 08:03:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367752 - in stable/12/sys/netinet: . cc X-SVN-Group: stable-12 X-SVN-Commit-Author: rscheff X-SVN-Commit-Paths: in stable/12/sys/netinet: . cc X-SVN-Commit-Revision: 367752 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 08:03:50 -0000 Author: rscheff Date: Tue Nov 17 08:03:49 2020 New Revision: 367752 URL: https://svnweb.freebsd.org/changeset/base/367752 Log: MFC r367007: tcp: move cwnd and ssthresh updates into cc modules This will pave the way of setting ssthresh differently in TCP CUBIC, according to RFC8312 section 4.7. Use dynamic tcp_maxseg() adjusting for tcp options instead of static t_maxseg. Submitted by: chengc_netapp.com Reviewed by: rrs, tuexen, rscheff Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D26807 Modified: stable/12/sys/netinet/cc/cc_cubic.c stable/12/sys/netinet/cc/cc_dctcp.c stable/12/sys/netinet/cc/cc_htcp.c stable/12/sys/netinet/cc/cc_newreno.c stable/12/sys/netinet/tcp_input.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet/cc/cc_cubic.c ============================================================================== --- stable/12/sys/netinet/cc/cc_cubic.c Tue Nov 17 06:04:16 2020 (r367751) +++ stable/12/sys/netinet/cc/cc_cubic.c Tue Nov 17 08:03:49 2020 (r367752) @@ -265,8 +265,10 @@ static void cubic_cong_signal(struct cc_var *ccv, uint32_t type) { struct cubic *cubic_data; + u_int mss; cubic_data = ccv->cc_data; + mss = tcp_maxseg(ccv->ccvc.tcp); switch (type) { case CC_NDUPACK: @@ -293,6 +295,10 @@ cubic_cong_signal(struct cc_var *ccv, uint32_t type) break; case CC_RTO: + CCV(ccv, snd_ssthresh) = max(min(CCV(ccv, snd_wnd), + CCV(ccv, snd_cwnd)) / 2 / mss, + 2) * mss; + CCV(ccv, snd_cwnd) = mss; /* * Grab the current time and record it so we know when the * most recent congestion event was. Only record it when the Modified: stable/12/sys/netinet/cc/cc_dctcp.c ============================================================================== --- stable/12/sys/netinet/cc/cc_dctcp.c Tue Nov 17 06:04:16 2020 (r367751) +++ stable/12/sys/netinet/cc/cc_dctcp.c Tue Nov 17 08:03:49 2020 (r367752) @@ -235,7 +235,7 @@ dctcp_cong_signal(struct cc_var *ccv, uint32_t type) if (CCV(ccv, t_flags) & TF_ECN_PERMIT) { dctcp_data = ccv->cc_data; cwin = CCV(ccv, snd_cwnd); - mss = CCV(ccv, t_maxseg); + mss = tcp_maxseg(ccv->ccvc.tcp); switch (type) { case CC_NDUPACK: @@ -282,6 +282,10 @@ dctcp_cong_signal(struct cc_var *ccv, uint32_t type) dctcp_data->ece_curr = 1; break; case CC_RTO: + CCV(ccv, snd_ssthresh) = max(min(CCV(ccv, snd_wnd), + CCV(ccv, snd_cwnd)) / 2 / mss, + 2) * mss; + CCV(ccv, snd_cwnd) = mss; dctcp_update_alpha(ccv); dctcp_data->save_sndnxt += CCV(ccv, t_maxseg); dctcp_data->num_cong_events++; Modified: stable/12/sys/netinet/cc/cc_htcp.c ============================================================================== --- stable/12/sys/netinet/cc/cc_htcp.c Tue Nov 17 06:04:16 2020 (r367751) +++ stable/12/sys/netinet/cc/cc_htcp.c Tue Nov 17 08:03:49 2020 (r367752) @@ -271,8 +271,10 @@ static void htcp_cong_signal(struct cc_var *ccv, uint32_t type) { struct htcp *htcp_data; + u_int mss; htcp_data = ccv->cc_data; + mss = tcp_maxseg(ccv->ccvc.tcp); switch (type) { case CC_NDUPACK: @@ -311,6 +313,10 @@ htcp_cong_signal(struct cc_var *ccv, uint32_t type) break; case CC_RTO: + CCV(ccv, snd_ssthresh) = max(min(CCV(ccv, snd_wnd), + CCV(ccv, snd_cwnd)) / 2 / mss, + 2) * mss; + CCV(ccv, snd_cwnd) = mss; /* * Grab the current time and record it so we know when the * most recent congestion event was. Only record it when the Modified: stable/12/sys/netinet/cc/cc_newreno.c ============================================================================== --- stable/12/sys/netinet/cc/cc_newreno.c Tue Nov 17 06:04:16 2020 (r367751) +++ stable/12/sys/netinet/cc/cc_newreno.c Tue Nov 17 08:03:49 2020 (r367752) @@ -241,7 +241,7 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type) u_int mss; cwin = CCV(ccv, snd_cwnd); - mss = CCV(ccv, t_maxseg); + mss = tcp_maxseg(ccv->ccvc.tcp); nreno = ccv->cc_data; beta = (nreno == NULL) ? V_newreno_beta : nreno->beta; beta_ecn = (nreno == NULL) ? V_newreno_beta_ecn : nreno->beta_ecn; @@ -278,6 +278,12 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type) CCV(ccv, snd_cwnd) = cwin; ENTER_CONGRECOVERY(CCV(ccv, t_flags)); } + break; + case CC_RTO: + CCV(ccv, snd_ssthresh) = max(min(CCV(ccv, snd_wnd), + CCV(ccv, snd_cwnd)) / 2 / mss, + 2) * mss; + CCV(ccv, snd_cwnd) = mss; break; } } Modified: stable/12/sys/netinet/tcp_input.c ============================================================================== --- stable/12/sys/netinet/tcp_input.c Tue Nov 17 06:04:16 2020 (r367751) +++ stable/12/sys/netinet/tcp_input.c Tue Nov 17 08:03:49 2020 (r367752) @@ -403,8 +403,6 @@ cc_conn_init(struct tcpcb *tp) void inline cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type) { - u_int maxseg; - INP_WLOCK_ASSERT(tp->t_inpcb); switch(type) { @@ -430,13 +428,9 @@ cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, ui } break; case CC_RTO: - maxseg = tcp_maxseg(tp); tp->t_dupacks = 0; tp->t_bytes_acked = 0; EXIT_RECOVERY(tp->t_flags); - tp->snd_ssthresh = max(2, min(tp->snd_wnd, tp->snd_cwnd) / 2 / - maxseg) * maxseg; - tp->snd_cwnd = maxseg; if (tp->t_flags & TF_ECN_PERMIT) tp->t_flags |= TF_ECN_SND_CWR; break; From owner-svn-src-all@freebsd.org Tue Nov 17 08:11:17 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F165F2D4692; Tue, 17 Nov 2020 08:11:17 +0000 (UTC) (envelope-from rscheff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZzD56Ll2z3qPx; Tue, 17 Nov 2020 08:11:17 +0000 (UTC) (envelope-from rscheff@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CCF481C952; Tue, 17 Nov 2020 08:11:17 +0000 (UTC) (envelope-from rscheff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AH8BHlc078512; Tue, 17 Nov 2020 08:11:17 GMT (envelope-from rscheff@FreeBSD.org) Received: (from rscheff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AH8BHKs078511; Tue, 17 Nov 2020 08:11:17 GMT (envelope-from rscheff@FreeBSD.org) Message-Id: <202011170811.0AH8BHKs078511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rscheff set sender to rscheff@FreeBSD.org using -f From: Richard Scheffenegger Date: Tue, 17 Nov 2020 08:11:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367753 - stable/12/sys/netinet/cc X-SVN-Group: stable-12 X-SVN-Commit-Author: rscheff X-SVN-Commit-Paths: stable/12/sys/netinet/cc X-SVN-Commit-Revision: 367753 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 08:11:18 -0000 Author: rscheff Date: Tue Nov 17 08:11:17 2020 New Revision: 367753 URL: https://svnweb.freebsd.org/changeset/base/367753 Log: MFC r367008: TCP Cubic: improve reaction to (and rollback from) RTO fix compliancy issue of CUBIC RTO handling according to RFC8312 section 4.7 add CUBIC CC_RTO_ERR handling Submitted by: chengc_netapp.com Reviewed by: rrs, tuexen, rscheff Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D26808 Modified: stable/12/sys/netinet/cc/cc_cubic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet/cc/cc_cubic.c ============================================================================== --- stable/12/sys/netinet/cc/cc_cubic.c Tue Nov 17 08:03:49 2020 (r367752) +++ stable/12/sys/netinet/cc/cc_cubic.c Tue Nov 17 08:11:17 2020 (r367753) @@ -78,7 +78,7 @@ static void cubic_conn_init(struct cc_var *ccv); static int cubic_mod_init(void); static void cubic_post_recovery(struct cc_var *ccv); static void cubic_record_rtt(struct cc_var *ccv); -static void cubic_ssthresh_update(struct cc_var *ccv); +static void cubic_ssthresh_update(struct cc_var *ccv, uint32_t maxseg); static void cubic_after_idle(struct cc_var *ccv); struct cubic { @@ -90,19 +90,28 @@ struct cubic { unsigned long max_cwnd; /* cwnd at the previous congestion event. */ unsigned long prev_max_cwnd; + /* A copy of prev_max_cwnd. Used for CC_RTO_ERR */ + unsigned long prev_max_cwnd_cp; /* various flags */ uint32_t flags; #define CUBICFLAG_CONG_EVENT 0x00000001 /* congestion experienced */ #define CUBICFLAG_IN_SLOWSTART 0x00000002 /* in slow start */ #define CUBICFLAG_IN_APPLIMIT 0x00000004 /* application limited */ +#define CUBICFLAG_RTO_EVENT 0x00000008 /* RTO experienced */ /* Minimum observed rtt in ticks. */ int min_rtt_ticks; /* Mean observed rtt between congestion epochs. */ int mean_rtt_ticks; /* ACKs since last congestion event. */ int epoch_ack_count; - /* Time of last congestion event in ticks. */ + /* Timestamp (in ticks) of arriving in congestion avoidance from last + * congestion event. + */ int t_last_cong; + /* Timestamp (in ticks) of a previous congestion event. Used for + * CC_RTO_ERR. + */ + int t_last_cong_prev; }; static MALLOC_DEFINE(M_CUBIC, "cubic data", @@ -142,7 +151,14 @@ cubic_ack_received(struct cc_var *ccv, uint16_t type) cubic_data->flags |= CUBICFLAG_IN_SLOWSTART; newreno_cc_algo.ack_received(ccv, type); } else { - if (cubic_data->flags & (CUBICFLAG_IN_SLOWSTART | + if ((cubic_data->flags & CUBICFLAG_RTO_EVENT) && + (cubic_data->flags & CUBICFLAG_IN_SLOWSTART)) { + /* RFC8312 Section 4.7 */ + cubic_data->flags &= ~(CUBICFLAG_RTO_EVENT | + CUBICFLAG_IN_SLOWSTART); + cubic_data->max_cwnd = CCV(ccv, snd_cwnd); + cubic_data->K = 0; + } else if (cubic_data->flags & (CUBICFLAG_IN_SLOWSTART | CUBICFLAG_IN_APPLIMIT)) { cubic_data->flags &= ~(CUBICFLAG_IN_SLOWSTART | CUBICFLAG_IN_APPLIMIT); @@ -274,10 +290,10 @@ cubic_cong_signal(struct cc_var *ccv, uint32_t type) case CC_NDUPACK: if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) { if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { - cubic_ssthresh_update(ccv); + cubic_ssthresh_update(ccv, mss); cubic_data->flags |= CUBICFLAG_CONG_EVENT; cubic_data->t_last_cong = ticks; - cubic_data->K = cubic_k(cubic_data->max_cwnd / CCV(ccv, t_maxseg)); + cubic_data->K = cubic_k(cubic_data->max_cwnd / mss); } ENTER_RECOVERY(CCV(ccv, t_flags)); } @@ -285,37 +301,35 @@ cubic_cong_signal(struct cc_var *ccv, uint32_t type) case CC_ECN: if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { - cubic_ssthresh_update(ccv); + cubic_ssthresh_update(ccv, mss); cubic_data->flags |= CUBICFLAG_CONG_EVENT; cubic_data->t_last_cong = ticks; - cubic_data->K = cubic_k(cubic_data->max_cwnd / CCV(ccv, t_maxseg)); + cubic_data->K = cubic_k(cubic_data->max_cwnd / mss); CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh); ENTER_CONGRECOVERY(CCV(ccv, t_flags)); } break; case CC_RTO: - CCV(ccv, snd_ssthresh) = max(min(CCV(ccv, snd_wnd), - CCV(ccv, snd_cwnd)) / 2 / mss, - 2) * mss; - CCV(ccv, snd_cwnd) = mss; - /* - * Grab the current time and record it so we know when the - * most recent congestion event was. Only record it when the - * timeout has fired more than once, as there is a reasonable - * chance the first one is a false alarm and may not indicate - * congestion. - * This will put Cubic firmly into the concave / TCP friendly - * region, for a slower ramp-up after two consecutive RTOs. - */ - if (CCV(ccv, t_rxtshift) >= 2) { - cubic_data->flags |= CUBICFLAG_CONG_EVENT; - cubic_data->t_last_cong = ticks; - cubic_data->max_cwnd = CCV(ccv, snd_cwnd_prev); - cubic_data->K = cubic_k(cubic_data->max_cwnd / - CCV(ccv, t_maxseg)); + /* RFC8312 Section 4.7 */ + if (CCV(ccv, t_rxtshift) == 1) { + cubic_data->t_last_cong_prev = cubic_data->t_last_cong; + cubic_data->prev_max_cwnd_cp = cubic_data->prev_max_cwnd; } + cubic_data->flags |= CUBICFLAG_CONG_EVENT | CUBICFLAG_RTO_EVENT; + cubic_data->prev_max_cwnd = cubic_data->max_cwnd; + CCV(ccv, snd_ssthresh) = ((uint64_t)CCV(ccv, snd_cwnd) * + CUBIC_BETA) >> CUBIC_SHIFT; + CCV(ccv, snd_cwnd) = mss; break; + + case CC_RTO_ERR: + cubic_data->flags &= ~(CUBICFLAG_CONG_EVENT | CUBICFLAG_RTO_EVENT); + cubic_data->max_cwnd = cubic_data->prev_max_cwnd; + cubic_data->prev_max_cwnd = cubic_data->prev_max_cwnd_cp; + cubic_data->t_last_cong = cubic_data->t_last_cong_prev; + cubic_data->K = cubic_k(cubic_data->max_cwnd / mss); + break; } } @@ -437,7 +451,7 @@ cubic_record_rtt(struct cc_var *ccv) * Update the ssthresh in the event of congestion. */ static void -cubic_ssthresh_update(struct cc_var *ccv) +cubic_ssthresh_update(struct cc_var *ccv, uint32_t maxseg) { struct cubic *cubic_data; uint32_t ssthresh; @@ -467,7 +481,7 @@ cubic_ssthresh_update(struct cc_var *ccv) ssthresh = ((uint64_t)cwnd * CUBIC_BETA) >> CUBIC_SHIFT; } - CCV(ccv, snd_ssthresh) = max(ssthresh, 2 * CCV(ccv, t_maxseg)); + CCV(ccv, snd_ssthresh) = max(ssthresh, 2 * maxseg); } From owner-svn-src-all@freebsd.org Tue Nov 17 10:17:19 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 659DE2D7504; Tue, 17 Nov 2020 10:17:19 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb21W2Vdtz4Rkc; Tue, 17 Nov 2020 10:17:19 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 48CAD1E353; Tue, 17 Nov 2020 10:17:19 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHAHJtY055717; Tue, 17 Nov 2020 10:17:19 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHAHJk7055716; Tue, 17 Nov 2020 10:17:19 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202011171017.0AHAHJk7055716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 17 Nov 2020 10:17:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367754 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 367754 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 10:17:19 -0000 Author: andrew Date: Tue Nov 17 10:17:18 2020 New Revision: 367754 URL: https://svnweb.freebsd.org/changeset/base/367754 Log: Allow the GICv3 ACPI driver to attach to a GICv4 The same driver works on both, allow the driver to attach to a GICv4 controller with the ACPI attachment. Reported by: Andrey Fesenko Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/gic_v3_acpi.c Modified: head/sys/arm64/arm64/gic_v3_acpi.c ============================================================================== --- head/sys/arm64/arm64/gic_v3_acpi.c Tue Nov 17 08:11:17 2020 (r367753) +++ head/sys/arm64/arm64/gic_v3_acpi.c Tue Nov 17 10:17:18 2020 (r367754) @@ -168,9 +168,15 @@ gic_v3_acpi_identify(driver_t *driver, device_t parent "No gic interrupt or distributor table\n"); goto out; } - /* This is for the wrong GIC version */ - if (madt_data.dist->Version != ACPI_MADT_GIC_VERSION_V3) + + /* Check the GIC version is supported by thiss driver */ + switch(madt_data.dist->Version) { + case ACPI_MADT_GIC_VERSION_V3: + case ACPI_MADT_GIC_VERSION_V4: + break; + default: goto out; + } dev = BUS_ADD_CHILD(parent, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE, "gic", -1); @@ -199,6 +205,7 @@ gic_v3_acpi_probe(device_t dev) switch((uintptr_t)acpi_get_private(dev)) { case ACPI_MADT_GIC_VERSION_V3: + case ACPI_MADT_GIC_VERSION_V4: break; default: return (ENXIO); From owner-svn-src-all@freebsd.org Tue Nov 17 10:20:20 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 51F852D751C; Tue, 17 Nov 2020 10:20:20 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from fry.fubar.geek.nz (fry.fubar.geek.nz [139.59.165.16]) by mx1.freebsd.org (Postfix) with ESMTP id 4Cb24z6VJ7z4Rlj; Tue, 17 Nov 2020 10:20:19 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from [192.168.42.21] (cpc91232-cmbg18-2-0-cust554.5-4.cable.virginm.net [82.2.126.43]) by fry.fubar.geek.nz (Postfix) with ESMTPSA id E557A4E687; Tue, 17 Nov 2020 10:20:12 +0000 (UTC) From: Andrew Turner Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: svn commit: r367754 - head/sys/arm64/arm64 Date: Tue, 17 Nov 2020 10:20:11 +0000 References: <202011171017.0AHAHJk7055716@repo.freebsd.org> To: src-committers , svn-src-all , svn-src-head In-Reply-To: <202011171017.0AHAHJk7055716@repo.freebsd.org> Message-Id: <1DDB6A3F-363C-43D2-A081-97D6D95EAC6C@freebsd.org> X-Mailer: Apple Mail (2.3445.104.17) X-Rspamd-Queue-Id: 4Cb24z6VJ7z4Rlj 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:14061, ipnet:139.59.160.0/20, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 10:20:20 -0000 > On 17 Nov 2020, at 10:17, Andrew Turner wrote: > > Author: andrew > Date: Tue Nov 17 10:17:18 2020 > New Revision: 367754 > URL: https://svnweb.freebsd.org/changeset/base/367754 > > Log: > Allow the GICv3 ACPI driver to attach to a GICv4 > > The same driver works on both, allow the driver to attach to a GICv4 > controller with the ACPI attachment. > > Reported by: Andrey Fesenko > Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D27238 From owner-svn-src-all@freebsd.org Tue Nov 17 10:27:42 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A00E02D76C5; Tue, 17 Nov 2020 10:27:42 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb2FV482qz4S69; Tue, 17 Nov 2020 10:27:42 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 812141E618; Tue, 17 Nov 2020 10:27:42 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHARgGT061612; Tue, 17 Nov 2020 10:27:42 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHARgCt061611; Tue, 17 Nov 2020 10:27:42 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202011171027.0AHARgCt061611@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 17 Nov 2020 10:27:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367755 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 367755 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 10:27:42 -0000 Author: andrew Date: Tue Nov 17 10:27:42 2020 New Revision: 367755 URL: https://svnweb.freebsd.org/changeset/base/367755 Log: Stop calling gic_v3_detach when we haven't called gic_v3_attach The former tries to dereference memory allocated by the latter. If counting the redistributor fails it may try to dereference memory that was never allocated. Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/gic_v3_acpi.c Modified: head/sys/arm64/arm64/gic_v3_acpi.c ============================================================================== --- head/sys/arm64/arm64/gic_v3_acpi.c Tue Nov 17 10:17:18 2020 (r367754) +++ head/sys/arm64/arm64/gic_v3_acpi.c Tue Nov 17 10:27:42 2020 (r367755) @@ -262,7 +262,7 @@ gic_v3_acpi_attach(device_t dev) err = gic_v3_acpi_count_regions(dev); if (err != 0) - goto error; + goto count_error; err = gic_v3_attach(dev); if (err != 0) @@ -294,12 +294,13 @@ gic_v3_acpi_attach(device_t dev) return (0); error: + /* Failure so free resources */ + gic_v3_detach(dev); +count_error: if (bootverbose) { device_printf(dev, "Failed to attach. Error %d\n", err); } - /* Failure so free resources */ - gic_v3_detach(dev); return (err); } From owner-svn-src-all@freebsd.org Tue Nov 17 10:48:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 048D92D7E1B; Tue, 17 Nov 2020 10:48:02 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb2hx6l02z4TCZ; Tue, 17 Nov 2020 10:48:01 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5F7D1EC0B; Tue, 17 Nov 2020 10:48:01 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHAm109074210; Tue, 17 Nov 2020 10:48:01 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHAm1nq074209; Tue, 17 Nov 2020 10:48:01 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011171048.0AHAm1nq074209@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Tue, 17 Nov 2020 10:48:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367756 - head/usr.bin/chpass X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/usr.bin/chpass X-SVN-Commit-Revision: 367756 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 10:48:02 -0000 Author: 0mp (doc,ports committer) Date: Tue Nov 17 10:48:01 2020 New Revision: 367756 URL: https://svnweb.freebsd.org/changeset/base/367756 Log: Clean up the synopsis section & fix mandoc warnings The synopsis section had two very similar entries. The flags documented by the first one were a strict subset of the second one. Let's just keep only the second entry for simplicity. MFC after: 1 week Modified: head/usr.bin/chpass/chpass.1 Modified: head/usr.bin/chpass/chpass.1 ============================================================================== --- head/usr.bin/chpass/chpass.1 Tue Nov 17 10:27:42 2020 (r367755) +++ head/usr.bin/chpass/chpass.1 Tue Nov 17 10:48:01 2020 (r367756) @@ -28,7 +28,7 @@ .\" @(#)chpass.1 8.2 (Berkeley) 12/30/93 .\" $FreeBSD$ .\" -.Dd December 30, 1993 +.Dd November 17, 2020 .Dt CHPASS 1 .Os .Sh NAME @@ -41,19 +41,13 @@ .Nd add or change user database information .Sh SYNOPSIS .Nm +.Op Fl loy .Op Fl a Ar list -.Op Fl p Ar encpass +.Op Fl d Ar domain .Op Fl e Ar expiretime -.Op Fl s Ar newshell -.Op user -.Nm -.Op Fl oly -.Op Fl a Ar list +.Op Fl h Ar host .Op Fl p Ar encpass -.Op Fl e Ar expiretime .Op Fl s Ar newshell -.Op Fl d Ar domain -.Op Fl h Ar host .Op user .Sh DESCRIPTION The @@ -216,7 +210,7 @@ Note that .Xr finger 1 will display the office location and office phone together under the heading -.Ar Office: . +.Ar Office\&: . .Pp The user's .Ar home directory @@ -313,7 +307,7 @@ changing other fields could be added, this would lead compatibility problems with other NIS-capable systems. Even though the super-user may supply data for other fields while editing an entry, the extra information (other than the -password -- see below) will be silently discarded. +password \(em see below) will be silently discarded. .Pp Exception: the super-user on the NIS master server is permitted to change any field. From owner-svn-src-all@freebsd.org Tue Nov 17 10:57:29 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 248D02D7E76; Tue, 17 Nov 2020 10:57:29 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb2vs0L3gz4TvJ; Tue, 17 Nov 2020 10:57:29 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E83041ED43; Tue, 17 Nov 2020 10:57:28 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHAvS1Y080487; Tue, 17 Nov 2020 10:57:28 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHAvSv3080486; Tue, 17 Nov 2020 10:57:28 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011171057.0AHAvSv3080486@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Tue, 17 Nov 2020 10:57:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367757 - head/usr.bin/chpass X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/usr.bin/chpass X-SVN-Commit-Revision: 367757 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 10:57:29 -0000 Author: 0mp (doc,ports committer) Date: Tue Nov 17 10:57:28 2020 New Revision: 367757 URL: https://svnweb.freebsd.org/changeset/base/367757 Log: Improve readability of the lists of options - Sort options alphabetically - Add missing arguments (e.g., "list" to -a) - Adjust the width of Bl MFC after: 1 week Modified: head/usr.bin/chpass/chpass.1 Modified: head/usr.bin/chpass/chpass.1 ============================================================================== --- head/usr.bin/chpass/chpass.1 Tue Nov 17 10:48:01 2020 (r367756) +++ head/usr.bin/chpass/chpass.1 Tue Nov 17 10:57:28 2020 (r367757) @@ -74,8 +74,8 @@ The information is formatted and supplied to an editor Only the information that the user is allowed to change is displayed. .Pp The options are as follows: -.Bl -tag -width indent -.It Fl a +.Bl -tag -width "-e expiretime" +.It Fl a Ar list The super-user is allowed to directly supply a user database entry, in the format specified by .Xr passwd 5 , @@ -84,15 +84,15 @@ This argument must be a colon .Pq Dq \&: separated list of all the user database fields, although they may be empty. -.It Fl p -The super-user is allowed to directly supply an encrypted password field, -in the format used by -.Xr crypt 3 , -as an argument. .It Fl e Ar expiretime Change the account expire time. This option is used to set the expire time from a script as if it was done in the interactive editor. +.It Fl p Ar encpass +The super-user is allowed to directly supply an encrypted password field, +in the format used by +.Xr crypt 3 , +as an argument. .It Fl s Ar newshell Attempt to change the user's shell to .Ar newshell . @@ -376,19 +376,7 @@ change a user's NIS password with There are also a few extra option flags that are available when .Nm is compiled with NIS support: -.Bl -tag -width indent -.It Fl l -Force -.Nm -to modify the local copy of a user's password -information in the event that a user exists in both -the local and NIS databases. -.It Fl y -Opposite effect of -.Fl l . -This flag is largely redundant since -.Nm -operates on NIS entries by default if NIS is enabled. +.Bl -tag -width "-d domain" .It Fl d Ar domain Specify a particular NIS domain. The @@ -426,6 +414,12 @@ option can be used in conjunction with the .Fl d option, in which case the user-specified hostname will override the default. +.It Fl l +Force +.Nm +to modify the local copy of a user's password +information in the event that a user exists in both +the local and NIS databases. .It Fl o Force the use of RPC-based updates when communicating with .Xr rpc.yppasswdd 8 @@ -443,6 +437,12 @@ flag can be used to force to use the standard update mechanism instead. This option is provided mainly for testing purposes. +.It Fl y +Opposite effect of +.Fl l . +This flag is largely redundant since +.Nm +operates on NIS entries by default if NIS is enabled. .El .Sh FILES .Bl -tag -width /etc/master.passwd -compact From owner-svn-src-all@freebsd.org Tue Nov 17 11:08:56 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 726022E8711; Tue, 17 Nov 2020 11:08:56 +0000 (UTC) (envelope-from mpp302@gmail.com) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 4Cb3934YMMz4VYq; Tue, 17 Nov 2020 11:08:55 +0000 (UTC) (envelope-from mpp302@gmail.com) Received: by mail-ed1-f43.google.com with SMTP id l5so21956993edq.11; Tue, 17 Nov 2020 03:08:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=tf4G29hNJ1IcjMGsq50qR5tZoKPNtLZ/LBm7DjVayL0=; b=T25aJkRth3zT1ByVB6P0fbtYndAe4+InM5OxYY/g9VvAZOuhq8OsOOfemxFG/N7PSC cCN0PMANHZ3ZIHk1jaEjpoMlL+bqQAw13tmRKCjdJw9I+FFe2SibLzEzzTtmNVfhaG/r w8v5N1ynUpkd7HYioxmvtiWJwCBdi/9bRiFDxb7xY+d9SU8RW9c7RV7n1aTrI3Qga+9b TijB05euEijIhOjriS2NfkkXtJ84YD/9GAUQhg5YBj8HG59WMOi5+JaeiOLN00uAjvjZ GbEL18h7BL7dxHLj2zfTI9zjJ9TnAuxuFhffK/DNXKjYDQ7Qu4dcekLYr/e66RUNkU+b 2RTQ== X-Gm-Message-State: AOAM532zSrArxjy1tQ+oTVpSnhKeNU6qzDLAVY4gyw9HeRW2aGpPCSMJ PzkjGfAZPEBj69sVu2JizmziXRrnVXY= X-Google-Smtp-Source: ABdhPJwX8Wfdrrdt0x7P9E8UkZkrTeZ56UYVa6x2KU986ivm4WuNvz5Xf/FEAXv0SiqrNqNP03yEXw== X-Received: by 2002:a50:eb96:: with SMTP id y22mr20783351edr.116.1605611333256; Tue, 17 Nov 2020 03:08:53 -0800 (PST) Received: from ?IPv6:2a02:8109:98c0:1bc0:5e5f:67ff:fef4:ffd8? ([2a02:8109:98c0:1bc0:5e5f:67ff:fef4:ffd8]) by smtp.gmail.com with ESMTPSA id lf18sm8624078ejb.74.2020.11.17.03.08.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Nov 2020 03:08:52 -0800 (PST) Subject: Re: svn commit: r367756 - head/usr.bin/chpass From: Mateusz Piotrowski <0mp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011171048.0AHAm1nq074209@repo.freebsd.org> Message-ID: Date: Tue, 17 Nov 2020 12:08:58 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.4.1 MIME-Version: 1.0 In-Reply-To: <202011171048.0AHAm1nq074209@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Queue-Id: 4Cb3934YMMz4VYq X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mpp302@gmail.com designates 209.85.208.43 as permitted sender) smtp.mailfrom=mpp302@gmail.com X-Spamd-Result: default: False [-2.08 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.08)[-0.083]; FORGED_SENDER(0.30)[0mp@FreeBSD.org,mpp302@gmail.com]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MID_RHS_MATCH_FROM(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.208.43:from]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_NEQ_ENVFROM(0.00)[0mp@FreeBSD.org,mpp302@gmail.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[FreeBSD.org]; SPAMHAUS_ZRD(0.00)[209.85.208.43:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[209.85.208.43:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.208.43:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[svn-src-head,svn-src-all] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 11:08:56 -0000 On 11/17/20 11:48 AM, Mateusz Piotrowski wrote: > Author: 0mp (doc,ports committer) > Date: Tue Nov 17 10:48:01 2020 > New Revision: 367756 > URL: https://svnweb.freebsd.org/changeset/base/367756 > > Log: > Clean up the synopsis section & fix mandoc warnings > > The synopsis section had two very similar entries. The flags documented by > the first one were a strict subset of the second one. Let's just keep only > the second entry for simplicity. Uh, I think I get it now. The simpler one was referring to the chpass, while one second one was documenting ypchpass (passwd(1) has a similar synopsis). I guess I'll bring back both entries and will use "Nm ypchpass" for the entry listing NIS-specific flags. > MFC after: 1 week > > Modified: > head/usr.bin/chpass/chpass.1 > > Modified: head/usr.bin/chpass/chpass.1 > ============================================================================== > --- head/usr.bin/chpass/chpass.1 Tue Nov 17 10:27:42 2020 (r367755) > +++ head/usr.bin/chpass/chpass.1 Tue Nov 17 10:48:01 2020 (r367756) > @@ -28,7 +28,7 @@ > .\" @(#)chpass.1 8.2 (Berkeley) 12/30/93 > .\" $FreeBSD$ > .\" > -.Dd December 30, 1993 > +.Dd November 17, 2020 > .Dt CHPASS 1 > .Os > .Sh NAME > @@ -41,19 +41,13 @@ > .Nd add or change user database information > .Sh SYNOPSIS > .Nm > +.Op Fl loy > .Op Fl a Ar list > -.Op Fl p Ar encpass > +.Op Fl d Ar domain > .Op Fl e Ar expiretime > -.Op Fl s Ar newshell > -.Op user > -.Nm > -.Op Fl oly > -.Op Fl a Ar list > +.Op Fl h Ar host > .Op Fl p Ar encpass > -.Op Fl e Ar expiretime > .Op Fl s Ar newshell > -.Op Fl d Ar domain > -.Op Fl h Ar host > .Op user > .Sh DESCRIPTION > The > @@ -216,7 +210,7 @@ Note that > .Xr finger 1 > will display the office location and office phone together under the > heading > -.Ar Office: . > +.Ar Office\&: . > .Pp > The user's > .Ar home directory > @@ -313,7 +307,7 @@ changing other fields could be added, this would lead > compatibility problems with other NIS-capable systems. > Even though the super-user may supply data for other fields > while editing an entry, the extra information (other than the > -password -- see below) will be silently discarded. > +password \(em see below) will be silently discarded. > .Pp > Exception: the super-user on the NIS master server is permitted to > change any field. From owner-svn-src-all@freebsd.org Tue Nov 17 11:36:33 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 083682E8C42; Tue, 17 Nov 2020 11:36:33 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb3mw6qJpz4X9R; Tue, 17 Nov 2020 11:36:32 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCF601F340; Tue, 17 Nov 2020 11:36:32 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHBaWsO005493; Tue, 17 Nov 2020 11:36:32 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHBaWNZ005489; Tue, 17 Nov 2020 11:36:32 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <202011171136.0AHBaWNZ005489@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Tue, 17 Nov 2020 11:36:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367758 - in head/sys/powerpc: aim include powerpc X-SVN-Group: head X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: in head/sys/powerpc: aim include powerpc X-SVN-Commit-Revision: 367758 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 11:36:33 -0000 Author: luporl Date: Tue Nov 17 11:36:31 2020 New Revision: 367758 URL: https://svnweb.freebsd.org/changeset/base/367758 Log: [PowerPC] Don't overwrite vm.pmap sysctl node After r367417, both mmu_oea64 and mmu_radix were defining the vm.pmap sysctl node, resulting in the later definition hiding the properties of the previous one. Avoid this issue by defining vm.pmap in a common source file and declaring it where needed. This change also standardizes the tunable name used to enable superpages and change its default to disabled on radix MMU, because it still has some issues with superpages. Reviewed by: bdragon, jhibbits Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D27156 Modified: head/sys/powerpc/aim/mmu_oea64.c head/sys/powerpc/aim/mmu_radix.c head/sys/powerpc/include/pmap.h head/sys/powerpc/powerpc/pmap_dispatch.c Modified: head/sys/powerpc/aim/mmu_oea64.c ============================================================================== --- head/sys/powerpc/aim/mmu_oea64.c Tue Nov 17 10:57:28 2020 (r367757) +++ head/sys/powerpc/aim/mmu_oea64.c Tue Nov 17 11:36:31 2020 (r367758) @@ -319,13 +319,8 @@ static void moea64_remove_locked(pmap_t, vm_offset_t, /* MD page flag indicating that the page is a superpage. */ #define MDPG_ATTR_SP 0x40000000 -static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, - "VM/pmap parameters"); +SYSCTL_DECL(_vm_pmap); -static int superpages_enabled = 0; -SYSCTL_INT(_vm_pmap, OID_AUTO, superpages_enabled, CTLFLAG_RDTUN, - &superpages_enabled, 0, "Enable support for transparent superpages"); - static SYSCTL_NODE(_vm_pmap, OID_AUTO, sp, CTLFLAG_RD, 0, "SP page mapping counters"); @@ -1968,7 +1963,11 @@ moea64_init() /* * Are large page mappings enabled? + * + * While HPT superpages are not better tested, leave it disabled by + * default. */ + superpages_enabled = 0; TUNABLE_INT_FETCH("vm.pmap.superpages_enabled", &superpages_enabled); if (superpages_enabled) { KASSERT(MAXPAGESIZES > 1 && pagesizes[1] == 0, Modified: head/sys/powerpc/aim/mmu_radix.c ============================================================================== --- head/sys/powerpc/aim/mmu_radix.c Tue Nov 17 10:57:28 2020 (r367757) +++ head/sys/powerpc/aim/mmu_radix.c Tue Nov 17 11:36:31 2020 (r367758) @@ -385,11 +385,8 @@ SYSCTL_INT(_machdep, OID_AUTO, nkpt, CTLFLAG_RD, &nkpt vm_paddr_t dmaplimit; -SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); +SYSCTL_DECL(_vm_pmap); -static int pg_ps_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, - &pg_ps_enabled, 0, "Are large page mappings enabled?"); #ifdef INVARIANTS #define VERBOSE_PMAP 0 #define VERBOSE_PROTECT 0 @@ -904,7 +901,7 @@ mmu_radix_kenter(vm_offset_t va, vm_paddr_t pa) bool mmu_radix_ps_enabled(pmap_t pmap) { - return (pg_ps_enabled && (pmap->pm_flags & PMAP_PDE_SUPERPAGE) != 0); + return (superpages_enabled && (pmap->pm_flags & PMAP_PDE_SUPERPAGE) != 0); } static pt_entry_t * @@ -3609,8 +3606,8 @@ mmu_radix_init() /* * Are large page mappings enabled? */ - TUNABLE_INT_FETCH("vm.pmap.pg_ps_enabled", &pg_ps_enabled); - if (pg_ps_enabled) { + TUNABLE_INT_FETCH("vm.pmap.superpages_enabled", &superpages_enabled); + if (superpages_enabled) { KASSERT(MAXPAGESIZES > 1 && pagesizes[1] == 0, ("pmap_init: can't assign to pagesizes[1]")); pagesizes[1] = L3_PAGE_SIZE; Modified: head/sys/powerpc/include/pmap.h ============================================================================== --- head/sys/powerpc/include/pmap.h Tue Nov 17 10:57:28 2020 (r367757) +++ head/sys/powerpc/include/pmap.h Tue Nov 17 11:36:31 2020 (r367758) @@ -336,6 +336,7 @@ extern vm_offset_t msgbuf_phys; extern int pmap_bootstrapped; extern int radix_mmu; +extern int superpages_enabled; vm_offset_t pmap_early_io_map(vm_paddr_t pa, vm_size_t size); void pmap_early_io_unmap(vm_offset_t va, vm_size_t size); Modified: head/sys/powerpc/powerpc/pmap_dispatch.c ============================================================================== --- head/sys/powerpc/powerpc/pmap_dispatch.c Tue Nov 17 10:57:28 2020 (r367757) +++ head/sys/powerpc/powerpc/pmap_dispatch.c Tue Nov 17 11:36:31 2020 (r367758) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -79,6 +80,12 @@ caddr_t crashdumpmap; int pmap_bootstrapped; /* Default level 0 reservations consist of 512 pages (2MB superpage). */ int vm_level_0_order = 9; + +SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); + +int superpages_enabled = 0; +SYSCTL_INT(_vm_pmap, OID_AUTO, superpages_enabled, CTLFLAG_RDTUN, + &superpages_enabled, 0, "Enable support for transparent superpages"); #ifdef AIM int From owner-svn-src-all@freebsd.org Tue Nov 17 12:04:29 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7EA52EAA96; Tue, 17 Nov 2020 12:04:29 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb4P94t2yz4YyC; Tue, 17 Nov 2020 12:04:29 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9A32D1F73F; Tue, 17 Nov 2020 12:04:29 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHC4TE6024183; Tue, 17 Nov 2020 12:04:29 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHC4TAk024182; Tue, 17 Nov 2020 12:04:29 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011171204.0AHC4TAk024182@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Tue, 17 Nov 2020 12:04:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367759 - head/usr.bin/chpass X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/usr.bin/chpass X-SVN-Commit-Revision: 367759 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 12:04:29 -0000 Author: 0mp (doc,ports committer) Date: Tue Nov 17 12:04:29 2020 New Revision: 367759 URL: https://svnweb.freebsd.org/changeset/base/367759 Log: Add an example for the -s flag MFC after: 2 weeks Modified: head/usr.bin/chpass/chpass.1 Modified: head/usr.bin/chpass/chpass.1 ============================================================================== --- head/usr.bin/chpass/chpass.1 Tue Nov 17 11:36:31 2020 (r367758) +++ head/usr.bin/chpass/chpass.1 Tue Nov 17 12:04:29 2020 (r367759) @@ -455,6 +455,12 @@ temporary copy of the password file .It Pa /etc/shells the list of approved shells .El +.Sh EXAMPLES +Change the shell of the current user to +.Ql /usr/local/bin/zsh : +.Bd -literal -offset indent +chsh -s /usr/local/bin/zsh +.Ed .Sh SEE ALSO .Xr finger 1 , .Xr login 1 , From owner-svn-src-all@freebsd.org Tue Nov 17 12:33:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A96842EBA37; Tue, 17 Nov 2020 12:33:12 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb52J4RYPz4bTq; Tue, 17 Nov 2020 12:33:12 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B4F11FE38; Tue, 17 Nov 2020 12:33:12 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHCXCpR042939; Tue, 17 Nov 2020 12:33:12 GMT (envelope-from alfredo@FreeBSD.org) Received: (from alfredo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHCXCkR042938; Tue, 17 Nov 2020 12:33:12 GMT (envelope-from alfredo@FreeBSD.org) Message-Id: <202011171233.0AHCXCkR042938@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alfredo set sender to alfredo@FreeBSD.org using -f From: "Alfredo Dal'Ava Junior" Date: Tue, 17 Nov 2020 12:33:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367760 - head/sys/powerpc/powerpc X-SVN-Group: head X-SVN-Commit-Author: alfredo X-SVN-Commit-Paths: head/sys/powerpc/powerpc X-SVN-Commit-Revision: 367760 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 12:33:12 -0000 Author: alfredo Date: Tue Nov 17 12:33:12 2020 New Revision: 367760 URL: https://svnweb.freebsd.org/changeset/base/367760 Log: [POWERPC] fix signal race condition r367416 should have called save_fpu() before kern_sigprocmask to avoid race condition Thanks jhibbits and bdragon for pointing it out Reviewed by: jhibbits Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D27241 Modified: head/sys/powerpc/powerpc/exec_machdep.c Modified: head/sys/powerpc/powerpc/exec_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/exec_machdep.c Tue Nov 17 12:04:29 2020 (r367759) +++ head/sys/powerpc/powerpc/exec_machdep.c Tue Nov 17 12:33:12 2020 (r367760) @@ -334,8 +334,6 @@ sys_sigreturn(struct thread *td, struct sigreturn_args if (error != 0) return (error); - kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); - /* * Save FPU state if needed. User may have changed it on * signal handler @@ -343,6 +341,8 @@ sys_sigreturn(struct thread *td, struct sigreturn_args if (uc.uc_mcontext.mc_srr1 & PSL_FP) save_fpu(td); + kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); + CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x", td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]); @@ -836,8 +836,6 @@ freebsd32_sigreturn(struct thread *td, struct freebsd3 if (error != 0) return (error); - kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); - /* * Save FPU state if needed. User may have changed it on * signal handler @@ -845,6 +843,7 @@ freebsd32_sigreturn(struct thread *td, struct freebsd3 if (uc.uc_mcontext.mc_srr1 & PSL_FP) save_fpu(td); + kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x", td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]); From owner-svn-src-all@freebsd.org Tue Nov 17 12:37:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 25C512EBA76; Tue, 17 Nov 2020 12:37:00 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb56h0PnDz4bk9; Tue, 17 Nov 2020 12:37:00 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F07C820197; Tue, 17 Nov 2020 12:36:59 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHCaxLD043162; Tue, 17 Nov 2020 12:36:59 GMT (envelope-from alfredo@FreeBSD.org) Received: (from alfredo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHCaxUu043161; Tue, 17 Nov 2020 12:36:59 GMT (envelope-from alfredo@FreeBSD.org) Message-Id: <202011171236.0AHCaxUu043161@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alfredo set sender to alfredo@FreeBSD.org using -f From: "Alfredo Dal'Ava Junior" Date: Tue, 17 Nov 2020 12:36:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367761 - head/lib/msun/powerpc X-SVN-Group: head X-SVN-Commit-Author: alfredo X-SVN-Commit-Paths: head/lib/msun/powerpc X-SVN-Commit-Revision: 367761 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 12:37:00 -0000 Author: alfredo Date: Tue Nov 17 12:36:59 2020 New Revision: 367761 URL: https://svnweb.freebsd.org/changeset/base/367761 Log: [POWERPC] msun: fix incorrect flag in fesetexceptflag Fix incorrect mask being used when FE_INVALID bit is wanted by user. The problem was noticed thanks to msun fenv tests. Reviewed by: jhibbits, luporl Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D27201 Modified: head/lib/msun/powerpc/fenv.h Modified: head/lib/msun/powerpc/fenv.h ============================================================================== --- head/lib/msun/powerpc/fenv.h Tue Nov 17 12:33:12 2020 (r367760) +++ head/lib/msun/powerpc/fenv.h Tue Nov 17 12:36:59 2020 (r367761) @@ -148,7 +148,7 @@ fesetexceptflag(const fexcept_t *__flagp, int __except union __fpscr __r; if (__excepts & FE_INVALID) - __excepts |= FE_ALL_EXCEPT; + __excepts |= FE_ALL_INVALID; __mffs(&__r); __r.__bits.__reg &= ~__excepts; __r.__bits.__reg |= *__flagp & __excepts; From owner-svn-src-all@freebsd.org Tue Nov 17 13:14:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 818322ECA98; Tue, 17 Nov 2020 13:14:05 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb5xT3J1zz4dtD; Tue, 17 Nov 2020 13:14:05 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63ECB209A0; Tue, 17 Nov 2020 13:14:05 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHDE5l9067903; Tue, 17 Nov 2020 13:14:05 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHDE4Ed067898; Tue, 17 Nov 2020 13:14:04 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <202011171314.0AHDE4Ed067898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Tue, 17 Nov 2020 13:14:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367762 - head/usr.sbin/bhyve X-SVN-Group: head X-SVN-Commit-Author: grehan X-SVN-Commit-Paths: head/usr.sbin/bhyve X-SVN-Commit-Revision: 367762 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 13:14:05 -0000 Author: grehan Date: Tue Nov 17 13:14:04 2020 New Revision: 367762 URL: https://svnweb.freebsd.org/changeset/base/367762 Log: Add legacy debug/test interfaces for kvm unit tests. Implement the legacy debug/test interfaces expected by KVM-unit-tests' realmode, emulator, and ioapic tests. Submitted by: adam_fenn.io Reviewed by: markj, grehan Approved by: grehan (bhyve) MFC after: 3 weeks Relnotes: Yes Differential Revision: https://reviews.freebsd.org/D27130 Added: head/usr.sbin/bhyve/pctestdev.c (contents, props changed) head/usr.sbin/bhyve/pctestdev.h (contents, props changed) Modified: head/usr.sbin/bhyve/Makefile head/usr.sbin/bhyve/bhyve.8 head/usr.sbin/bhyve/pci_lpc.c Modified: head/usr.sbin/bhyve/Makefile ============================================================================== --- head/usr.sbin/bhyve/Makefile Tue Nov 17 12:36:59 2020 (r367761) +++ head/usr.sbin/bhyve/Makefile Tue Nov 17 13:14:04 2020 (r367762) @@ -56,6 +56,7 @@ SRCS= \ pci_virtio_scsi.c \ pci_uart.c \ pci_xhci.c \ + pctestdev.c \ pm.c \ post.c \ ps2kbd.c \ Modified: head/usr.sbin/bhyve/bhyve.8 ============================================================================== --- head/usr.sbin/bhyve/bhyve.8 Tue Nov 17 12:36:59 2020 (r367761) +++ head/usr.sbin/bhyve/bhyve.8 Tue Nov 17 13:14:04 2020 (r367762) @@ -169,9 +169,11 @@ Allow devices behind the LPC PCI-ISA bridge to be conf The only supported devices are the TTY-class devices .Ar com1 and -.Ar com2 -and the boot ROM device -.Ar bootrom . +.Ar com2 , +the boot ROM device +.Ar bootrom , +and the debug/test device +.Ar pc-testdev . .Pp .Ar help print a list of supported LPC devices. @@ -277,7 +279,8 @@ Intel e82545 network interface. .It Li uart PCI 16550 serial device. .It Li lpc -LPC PCI-ISA bridge with COM1 and COM2 16550 serial ports and a boot ROM. +LPC PCI-ISA bridge with COM1 and COM2 16550 serial ports, a boot ROM, and, +optionally, the debug/test device. The LPC bridge emulation can only be configured on bus 0. .It Li fbuf Raw framebuffer device attached to VNC server. Modified: head/usr.sbin/bhyve/pci_lpc.c ============================================================================== --- head/usr.sbin/bhyve/pci_lpc.c Tue Nov 17 12:36:59 2020 (r367761) +++ head/usr.sbin/bhyve/pci_lpc.c Tue Nov 17 13:14:04 2020 (r367762) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include "pci_emul.h" #include "pci_irq.h" #include "pci_lpc.h" +#include "pctestdev.h" #include "uart_emul.h" #define IO_ICU1 0x20 @@ -80,6 +81,8 @@ static struct lpc_uart_softc { static const char *lpc_uart_names[LPC_UART_NUM] = { "COM1", "COM2" }; +static bool pctestdev_present; + /* * LPC device configuration is in the following form: * [,] @@ -107,6 +110,18 @@ lpc_device_parse(const char *opts) goto done; } } + if (strcasecmp(lpcdev, pctestdev_getname()) == 0) { + if (pctestdev_present) { + EPRINTLN("More than one %s device conf is " + "specified; only one is allowed.", + pctestdev_getname()); + } else if (pctestdev_parse(str) == 0) { + pctestdev_present = true; + error = 0; + free(cpy); + goto done; + } + } } done: @@ -124,6 +139,7 @@ lpc_print_supported_devices() printf("bootrom\n"); for (i = 0; i < LPC_UART_NUM; i++) printf("%s\n", lpc_uart_names[i]); + printf("%s\n", pctestdev_getname()); } const char * @@ -230,6 +246,13 @@ lpc_init(struct vmctx *ctx) error = register_inout(&iop); assert(error == 0); sc->enabled = 1; + } + + /* pc-testdev */ + if (pctestdev_present) { + error = pctestdev_init(ctx); + if (error) + return (error); } return (0); Added: head/usr.sbin/bhyve/pctestdev.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bhyve/pctestdev.c Tue Nov 17 13:14:04 2020 (r367762) @@ -0,0 +1,270 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Adam Fenn + * + * 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 AUTHORS 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 AUTHORS 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. + */ + +/* + * Emulation of selected legacy test/debug interfaces expected by KVM-unit-tests + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "debug.h" +#include "inout.h" +#include "mem.h" +#include "pctestdev.h" + +#define DEBUGEXIT_BASE 0xf4 +#define DEBUGEXIT_LEN 4 +#define DEBUGEXIT_NAME "isa-debug-exit" + +#define IOMEM_BASE 0xff000000 +#define IOMEM_LEN 0x10000 +#define IOMEM_NAME "pc-testdev-iomem" + +#define IOPORT_BASE 0xe0 +#define IOPORT_LEN 4 +#define IOPORT_NAME "pc-testdev-ioport" + +#define IRQ_BASE 0x2000 +#define IRQ_IOAPIC_PINCOUNT_MIN 24 +#define IRQ_IOAPIC_PINCOUNT_MAX 32 +#define IRQ_NAME "pc-testdev-irq-line" + +#define PCTESTDEV_NAME "pc-testdev" + +static bool pctestdev_inited; +static uint8_t pctestdev_iomem_buf[IOMEM_LEN]; +static uint32_t pctestdev_ioport_data; + +static int pctestdev_debugexit_io(struct vmctx *ctx, int vcpu, int in, + int port, int bytes, uint32_t *eax, void *arg); +static int pctestdev_iomem_io(struct vmctx *ctx, int vcpu, int dir, + uint64_t addr, int size, uint64_t *val, void *arg1, + long arg2); +static int pctestdev_ioport_io(struct vmctx *ctx, int vcpu, int in, + int port, int bytes, uint32_t *eax, void *arg); +static int pctestdev_irq_io(struct vmctx *ctx, int vcpu, int in, + int port, int bytes, uint32_t *eax, void *arg); + +const char * +pctestdev_getname(void) +{ + return (PCTESTDEV_NAME); +} + +int +pctestdev_parse(const char *opts) +{ + if (opts != NULL && *opts != '\0') + return (-1); + + return (0); +} + +int +pctestdev_init(struct vmctx *ctx) +{ + struct mem_range iomem; + struct inout_port debugexit, ioport, irq; + int err, pincount; + + if (pctestdev_inited) { + EPRINTLN("Only one pc-testdev device is allowed."); + + return (-1); + } + + err = vm_ioapic_pincount(ctx, &pincount); + if (err != 0) { + EPRINTLN("pc-testdev: Failed to obtain IOAPIC pin count."); + + return (-1); + } + if (pincount < IRQ_IOAPIC_PINCOUNT_MIN || + pincount > IRQ_IOAPIC_PINCOUNT_MAX) { + EPRINTLN("pc-testdev: Unsupported IOAPIC pin count: %d.", + pincount); + + return (-1); + } + + debugexit.name = DEBUGEXIT_NAME; + debugexit.port = DEBUGEXIT_BASE; + debugexit.size = DEBUGEXIT_LEN; + debugexit.flags = IOPORT_F_INOUT; + debugexit.handler = pctestdev_debugexit_io; + debugexit.arg = NULL; + + iomem.name = IOMEM_NAME; + iomem.flags = MEM_F_RW | MEM_F_IMMUTABLE; + iomem.handler = pctestdev_iomem_io; + iomem.arg1 = NULL; + iomem.arg2 = 0; + iomem.base = IOMEM_BASE; + iomem.size = IOMEM_LEN; + + ioport.name = IOPORT_NAME; + ioport.port = IOPORT_BASE; + ioport.size = IOPORT_LEN; + ioport.flags = IOPORT_F_INOUT; + ioport.handler = pctestdev_ioport_io; + ioport.arg = NULL; + + irq.name = IRQ_NAME; + irq.port = IRQ_BASE; + irq.size = pincount; + irq.flags = IOPORT_F_INOUT; + irq.handler = pctestdev_irq_io; + irq.arg = NULL; + + err = register_inout(&debugexit); + if (err != 0) + goto fail; + + err = register_inout(&ioport); + if (err != 0) + goto fail_after_debugexit_reg; + + err = register_inout(&irq); + if (err != 0) + goto fail_after_ioport_reg; + + err = register_mem(&iomem); + if (err != 0) + goto fail_after_irq_reg; + + pctestdev_inited = true; + + return (0); + +fail_after_irq_reg: + (void)unregister_inout(&irq); + +fail_after_ioport_reg: + (void)unregister_inout(&ioport); + +fail_after_debugexit_reg: + (void)unregister_inout(&debugexit); + +fail: + return (err); +} + +static int +pctestdev_debugexit_io(struct vmctx *ctx, int vcpu, int in, int port, + int bytes, uint32_t *eax, void *arg) +{ + if (in) + *eax = 0; + else + exit((*eax << 1) | 1); + + return (0); +} + +static int +pctestdev_iomem_io(struct vmctx *ctx, int vcpu, int dir, uint64_t addr, + int size, uint64_t *val, void *arg1, long arg2) +{ + uint64_t offset; + + if (addr + size > IOMEM_BASE + IOMEM_LEN) + return (-1); + + offset = addr - IOMEM_BASE; + if (dir == MEM_F_READ) { + (void)memcpy(val, pctestdev_iomem_buf + offset, size); + } else { + assert(dir == MEM_F_WRITE); + (void)memcpy(pctestdev_iomem_buf + offset, val, size); + } + + return (0); +} + +static int +pctestdev_ioport_io(struct vmctx *ctx, int vcpu, int in, int port, + int bytes, uint32_t *eax, void *arg) +{ + uint32_t mask; + int lsb; + + if (port + bytes > IOPORT_BASE + IOPORT_LEN) + return (-1); + + lsb = (port & 0x3) * 8; + mask = (-1UL >> (32 - (bytes * 8))) << lsb; + + if (in) + *eax = (pctestdev_ioport_data & mask) >> lsb; + else { + pctestdev_ioport_data &= ~mask; + pctestdev_ioport_data |= *eax << lsb; + } + + return (0); +} + +static int +pctestdev_irq_io(struct vmctx *ctx, int vcpu, int in, int port, int bytes, + uint32_t *eax, void *arg) +{ + int irq; + + if (bytes != 1) + return (-1); + + if (in) { + *eax = 0; + return (0); + } else { + irq = port - IRQ_BASE; + if (irq < 16) { + if (*eax) + return (vm_isa_assert_irq(ctx, irq, irq)); + else + return (vm_isa_deassert_irq(ctx, irq, irq)); + } else { + if (*eax) + return (vm_ioapic_assert_irq(ctx, irq)); + else + return (vm_ioapic_deassert_irq(ctx, irq)); + } + } +} Added: head/usr.sbin/bhyve/pctestdev.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bhyve/pctestdev.h Tue Nov 17 13:14:04 2020 (r367762) @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Adam Fenn + * + * 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 AUTHORS 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 AUTHORS 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$ + */ + +/* + * Emulation of selected legacy test/debug interfaces expected by KVM-unit-tests + */ + +#ifndef _PCTESTDEV_H_ +#define _PCTESTDEV_H_ + +struct vmctx; + +const char *pctestdev_getname(void); +int pctestdev_init(struct vmctx *ctx); +int pctestdev_parse(const char *opts); + +#endif From owner-svn-src-all@freebsd.org Tue Nov 17 14:07:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E75B02EDDE1; Tue, 17 Nov 2020 14:07:27 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb7736F75z4j29; Tue, 17 Nov 2020 14:07:27 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA48D21348; Tue, 17 Nov 2020 14:07:27 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHE7RPE099171; Tue, 17 Nov 2020 14:07:27 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHE7ROZ099170; Tue, 17 Nov 2020 14:07:27 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <202011171407.0AHE7ROZ099170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Tue, 17 Nov 2020 14:07:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367763 - head/cddl/contrib/opensolaris/common/ctf X-SVN-Group: head X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: head/cddl/contrib/opensolaris/common/ctf X-SVN-Commit-Revision: 367763 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 14:07:28 -0000 Author: jtl Date: Tue Nov 17 14:07:27 2020 New Revision: 367763 URL: https://svnweb.freebsd.org/changeset/base/367763 Log: When copying types from one CTF container to another, ensure that we always copy intrinsic data types before copying bitfields which are based on those types. This ensures the type ordering in the destination CTF container matches the assumption made elsewhere in the CTF code that instrinsic data types will always appear before bitfields based on those types. This resolves the following error message some users have seen after r366908: "/usr/lib/dtrace/ipfw.d", line 121: failed to copy type of 'ip6p': Conflicting type is already defined Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27213 Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c ============================================================================== --- head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Tue Nov 17 13:14:04 2020 (r367762) +++ head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Tue Nov 17 14:07:27 2020 (r367763) @@ -1258,7 +1258,7 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, c uint_t kind, flag, vlen; ctf_bundle_t src, dst; - ctf_encoding_t src_en, dst_en; + ctf_encoding_t src_en, main_en, dst_en; ctf_arinfo_t src_ar, dst_ar; ctf_dtdef_t *dtd; @@ -1372,6 +1372,27 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, c case CTF_K_FLOAT: if (ctf_type_encoding(src_fp, src_type, &src_en) != 0) return (ctf_set_errno(dst_fp, ctf_errno(src_fp))); + + /* + * This could be a bitfield, and the CTF library assumes + * intrinsics will appear before bitfields. Therefore, + * try to copy over the intrinsic prior to copying the + * bitfield. + */ + if (dst_type == CTF_ERR && name[0] != '\0' && + (hep = ctf_hash_lookup(&src_fp->ctf_names, src_fp, name, + strlen(name))) != NULL && + src_type != (ctf_id_t)hep->h_type) { + if (ctf_type_encoding(src_fp, (ctf_id_t)hep->h_type, + &main_en) != 0) { + return (ctf_set_errno(dst_fp, + ctf_errno(src_fp))); + } + if (bcmp(&src_en, &main_en, sizeof (ctf_encoding_t)) && + ctf_add_type(dst_fp, src_fp, + (ctf_id_t)hep->h_type) == CTF_ERR) + return (CTF_ERR); /* errno is set for us */ + } if (dst_type != CTF_ERR) { if (ctf_type_encoding(dst_fp, dst_type, &dst_en) != 0) From owner-svn-src-all@freebsd.org Tue Nov 17 14:11:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E56BA2EE044; Tue, 17 Nov 2020 14:11:49 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 4Cb7D43j4xz4jBx; Tue, 17 Nov 2020 14:11:48 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: by mail-ej1-f47.google.com with SMTP id 7so29600657ejm.0; Tue, 17 Nov 2020 06:11:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=sxzQdwICp4u42GIA27NEi9RaRwGGP5hgTc57sdsfeA0=; b=Q1Spj6fiak3ziRWgx2MpiQL0dewQifKBTEoJHFZR2nGgO3CNftqefWC0pou8zdANWv b/C5GP8Yzugt6Ib8pqN/qXxnCAvpmmH2T5GuQFZ4tfmhkK31ssrBfbOjxW7RvHnFpSDQ MuESUbBkzRGyf3iHr09P1el4Zs/ohmsy+ZuFLSl9NG8rXC+kPrrmfFQSEPidmTyKFLeC Ezp58O0Awpt6eWkf5KmtZJn4Yi8ghDnDN8FRwnIZv02bxIXKAHu6M7vDf9lvwNKNfh97 Hzb4ICN3DjuEXNSHMyLYOIzq6f7WytEpijzksYHNBGJOhqGz00LYvZ5WCKoAwCVQofFC jwLQ== X-Gm-Message-State: AOAM5313NjSRdZvIN9iWl2Co1Nz0JiIOXU0xcm30U3vVpJp1j60gZVbQ /iPfHGPAcmY1z46wXg8Rp9mF+PR3w6A= X-Google-Smtp-Source: ABdhPJx9bbA7khE5L3cYPdzdMkTXOrrlZ4W8L0QWNuwPBQX1z9CetdmXwLtogR779ftQLOk2Qoz0Cg== X-Received: by 2002:a17:906:1f86:: with SMTP id t6mr19195864ejr.356.1605622306582; Tue, 17 Nov 2020 06:11:46 -0800 (PST) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com. [209.85.208.41]) by smtp.gmail.com with ESMTPSA id f23sm11917447eds.41.2020.11.17.06.11.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Nov 2020 06:11:46 -0800 (PST) Received: by mail-ed1-f41.google.com with SMTP id q16so7394153edv.10; Tue, 17 Nov 2020 06:11:46 -0800 (PST) X-Received: by 2002:a05:6402:144f:: with SMTP id d15mr21364850edx.300.1605622306191; Tue, 17 Nov 2020 06:11:46 -0800 (PST) MIME-Version: 1.0 References: <202011171407.0AHE7ROZ099170@repo.freebsd.org> In-Reply-To: <202011171407.0AHE7ROZ099170@repo.freebsd.org> From: "Jonathan T. Looney" Date: Tue, 17 Nov 2020 09:11:35 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r367763 - head/cddl/contrib/opensolaris/common/ctf To: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org X-Rspamd-Queue-Id: 4Cb7D43j4xz4jBx X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of jonlooney@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=jonlooney@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; DMARC_NA(0.00)[freebsd.org]; SPAMHAUS_ZRD(0.00)[209.85.218.47:from:127.0.2.255]; RCVD_COUNT_THREE(0.00)[4]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.218.47:from]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCVD_IN_DNSWL_NONE(0.00)[209.85.218.47:from]; FORGED_SENDER(0.30)[jtl@freebsd.org,jonlooney@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.218.47:from]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FROM_NEQ_ENVFROM(0.00)[jtl@freebsd.org,jonlooney@gmail.com]; MAILMAN_DEST(0.00)[svn-src-all,svn-src-head] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 14:11:50 -0000 On Tue, Nov 17, 2020 at 9:07 AM Jonathan T. Looney wrote: > Author: jtl > Date: Tue Nov 17 14:07:27 2020 > New Revision: 367763 > URL: https://svnweb.freebsd.org/changeset/base/367763 > > Log: > When copying types from one CTF container to another, ensure that we > always copy intrinsic data types before copying bitfields which are > based on those types. This ensures the type ordering in the destination > CTF container matches the assumption made elsewhere in the CTF code > that instrinsic data types will always appear before bitfields based on > those types. > > This resolves the following error message some users have seen after > r366908: > "/usr/lib/dtrace/ipfw.d", line 121: failed to copy type of 'ip6p': > Conflicting type is already defined > > Reviewed by: markj > Sponsored by: Netflix > Differential Revision: https://reviews.freebsd.org/D27213 FWIW, this should also have said: MFC after: 2 weeks From owner-svn-src-all@freebsd.org Tue Nov 17 14:36:34 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 779C82EE7A1; Tue, 17 Nov 2020 14:36:34 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (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 4Cb7mf2c9Fz4kHS; Tue, 17 Nov 2020 14:36:34 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x341.google.com with SMTP id w24so3452412wmi.0; Tue, 17 Nov 2020 06:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9GsqJsfYrii5z1WrNicZCaObgFeFUC9In8ZBB63VaVY=; b=mZLdAa/K0V5BRPIHeFcOflZpsNz0rxU4bQl3DsxcPySddWBPDCiZYRNWWCE8fhEJno Ms4UFDH3jAIamKnamXxeSaCPtc/gbq5sS/sffdjPu2rZgOMiUcikFk0JnYgeKx7zgjwX f/VIPV1GNqrhTHGnguSN1tzf4vYeQZxFesm+IaRjjgrBb9tdxmH9reMwhNyEguvrWMH1 pZONH49IUbzu3UpQ5UI637jEDcXfnVN7swCSLOTi/CEqZsgy9voGO5IHoOh8AjOIQRJN +8nM/LoOYdbDJ+J6ztGOaGaS9OEZ1TLPMiXFMrozMxXP5a5vyAJEWt8iVtJWDsNX9zIn +3Gg== 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=9GsqJsfYrii5z1WrNicZCaObgFeFUC9In8ZBB63VaVY=; b=p7V+lQhJ2Jtrtm4qV2tcq4xFKMev1nYvXAZVnv155C0TgxGS7Gsc3e7WDyjOWewa6F S8bKy56u97Efgi5EpFPm7OjzPVQVl1Wv71f3twmHzYkfYOBSOVLNdfAORj/Dqa/3Sc7O sLi9wXehFODkMkiNfrqW0lFPztM0PMf+cAvR7uVeDUQ2DFYxDlIFc0dg0JNkqcTST/mA avWLn14QTqL7Geb+81RXiZbKjhSko87HOn9QEYJkkvkQkINqcsJQ68LJV9q+J5lEl4no RaAxU3b+3U8wLlIQu+/qOO6ftL0BV1reOFdOO5JVn9kCdRxeE/6/CQ1Yd5Kkg21t1Bf4 vJVg== X-Gm-Message-State: AOAM5324uzSKUu4tBVR3sfIyou+kgpiXaIPlbCH4VOpvBwaLnWmGqfMI 8oQGuV6OfEPdqsGMjmapPnSpIdVjKoRFLxZ4Q3U= X-Google-Smtp-Source: ABdhPJwM0VdSOMBM7wggA9yLVXMUszi3G6JVOuYBm7tzwMhjAMzjVrVPdxQ7YKV06fI2pqOStLi6G6b2Kev5jpHMN3M= X-Received: by 2002:a7b:cd11:: with SMTP id f17mr4827516wmj.127.1605623792666; Tue, 17 Nov 2020 06:36:32 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Tue, 17 Nov 2020 06:36:31 -0800 (PST) In-Reply-To: References: <202011160309.0AG39JmP067464@repo.freebsd.org> From: Mateusz Guzik Date: Tue, 17 Nov 2020 15:36:31 +0100 Message-ID: Subject: Re: svn commit: r367713 - head/sys/kern To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Cb7mf2c9Fz4kHS X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 14:36:34 -0000 On 11/17/20, Konstantin Belousov wrote: > On Tue, Nov 17, 2020 at 04:15:12AM +0100, Mateusz Guzik wrote: >> On 11/17/20, Konstantin Belousov wrote: >> > On Mon, Nov 16, 2020 at 03:09:19AM +0000, Mateusz Guzik wrote: >> >> Author: mjg >> >> Date: Mon Nov 16 03:09:18 2020 >> >> New Revision: 367713 >> >> URL: https://svnweb.freebsd.org/changeset/base/367713 >> >> >> >> Log: >> >> select: replace reference counting with memory barriers in selfd >> >> >> >> Refcounting was added to combat a race between selfdfree and >> >> doselwakup, >> >> but it adds avoidable overhead. >> >> >> >> selfdfree detects it can free the object by ->sf_si == NULL, thus we >> >> can >> >> ensure that the condition only holds after all accesses are >> >> completed. >> >> >> >> Modified: >> >> head/sys/kern/sys_generic.c >> >> >> >> Modified: head/sys/kern/sys_generic.c >> >> ============================================================================== >> >> --- head/sys/kern/sys_generic.c Sun Nov 15 22:49:28 2020 (r367712) >> >> +++ head/sys/kern/sys_generic.c Mon Nov 16 03:09:18 2020 (r367713) >> >> @@ -156,7 +156,6 @@ struct selfd { >> >> struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ >> >> struct seltd *sf_td; /* (k) owning seltd. */ >> >> void *sf_cookie; /* (k) fd or pollfd. */ >> >> - u_int sf_refs; >> >> }; >> >> >> >> MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); >> >> @@ -1704,16 +1703,17 @@ static void >> >> selfdfree(struct seltd *stp, struct selfd *sfp) >> >> { >> >> STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); >> >> - if (sfp->sf_si != NULL) { >> >> + /* >> >> + * Paired with doselwakeup. >> >> + */ >> >> + if (atomic_load_acq_ptr((uintptr_t *)&sfp->sf_si) != (uintptr_t)NULL) >> >> { >> > This could be != 0. >> > >> >> mtx_lock(sfp->sf_mtx); >> >> if (sfp->sf_si != NULL) { >> >> TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); >> >> - refcount_release(&sfp->sf_refs); >> >> } >> >> mtx_unlock(sfp->sf_mtx); >> >> } >> >> - if (refcount_release(&sfp->sf_refs)) >> >> - free(sfp, M_SELFD); >> >> + free(sfp, M_SELFD); >> > What guarantees that doselwakeup() finished with sfp ? >> > >> >> Release semantics provided by atomic_store_rel_ptr -- it means the >> NULL store is the last access, neither CPU nor the compiler are going >> to reorder preceding loads/stores past it. > It only guarantees that if we observed NULL as the result of load. > If that did not happen selfdfree takes the lock. If the entry is still there, it removes it and doselwakeup will not see it after it takes the lock. If the entry is not there, doselwaekup is done with it because it released the lock. -- Mateusz Guzik From owner-svn-src-all@freebsd.org Tue Nov 17 14:41:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69B2E2EEA5A; Tue, 17 Nov 2020 14:41:24 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb7tD2Zw0z4l18; Tue, 17 Nov 2020 14:41:24 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C29F2157A; Tue, 17 Nov 2020 14:41:24 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHEfOlm021159; Tue, 17 Nov 2020 14:41:24 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHEfNgn021156; Tue, 17 Nov 2020 14:41:23 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011171441.0AHEfNgn021156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 17 Nov 2020 14:41:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367764 - in head/sys/contrib/vchiq/interface: compat vchiq_arm X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in head/sys/contrib/vchiq/interface: compat vchiq_arm X-SVN-Commit-Revision: 367764 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 14:41:24 -0000 Author: manu Date: Tue Nov 17 14:41:23 2020 New Revision: 367764 URL: https://svnweb.freebsd.org/changeset/base/367764 Log: vchiq: Rename timer func so they do not conflict with linuxkpi Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.c head/sys/contrib/vchiq/interface/compat/vchi_bsd.h head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.c ============================================================================== --- head/sys/contrib/vchiq/interface/compat/vchi_bsd.c Tue Nov 17 14:07:27 2020 (r367763) +++ head/sys/contrib/vchiq/interface/compat/vchi_bsd.c Tue Nov 17 14:41:23 2020 (r367764) @@ -77,7 +77,7 @@ run_timer(void *arg) } void -init_timer(struct timer_list *t) +vchiq_init_timer(struct timer_list *t) { mtx_init(&t->mtx, "dahdi timer lock", NULL, MTX_SPIN); callout_init(&t->callout, 1); @@ -89,15 +89,15 @@ init_timer(struct timer_list *t) } void -setup_timer(struct timer_list *t, void (*function)(unsigned long), unsigned long data) +vchiq_setup_timer(struct timer_list *t, void (*function)(unsigned long), unsigned long data) { t->function = function; t->data = data; - init_timer(t); + vchiq_init_timer(t); } void -mod_timer(struct timer_list *t, unsigned long expires) +vchiq_mod_timer(struct timer_list *t, unsigned long expires) { mtx_lock_spin(&t->mtx); callout_reset(&t->callout, expires - jiffies, run_timer, t); @@ -105,13 +105,13 @@ mod_timer(struct timer_list *t, unsigned long expires) } void -add_timer(struct timer_list *t) +vchiq_add_timer(struct timer_list *t) { - mod_timer(t, t->expires); + vchiq_mod_timer(t, t->expires); } int -del_timer_sync(struct timer_list *t) +vchiq_del_timer_sync(struct timer_list *t) { mtx_lock_spin(&t->mtx); callout_stop(&t->callout); @@ -122,9 +122,9 @@ del_timer_sync(struct timer_list *t) } int -del_timer(struct timer_list *t) +vchiq_del_timer(struct timer_list *t) { - del_timer_sync(t); + vchiq_del_timer_sync(t); return 0; } Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.h ============================================================================== --- head/sys/contrib/vchiq/interface/compat/vchi_bsd.h Tue Nov 17 14:07:27 2020 (r367763) +++ head/sys/contrib/vchiq/interface/compat/vchi_bsd.h Tue Nov 17 14:41:23 2020 (r367764) @@ -196,12 +196,12 @@ struct timer_list { unsigned long data; }; -void init_timer(struct timer_list *t); -void setup_timer(struct timer_list *t, void (*function)(unsigned long), unsigned long data); -void mod_timer(struct timer_list *t, unsigned long expires); -void add_timer(struct timer_list *t); -int del_timer(struct timer_list *t); -int del_timer_sync(struct timer_list *t); +void vchiq_init_timer(struct timer_list *t); +void vchiq_setup_timer(struct timer_list *t, void (*function)(unsigned long), unsigned long data); +void vchiq_mod_timer(struct timer_list *t, unsigned long expires); +void vchiq_add_timer(struct timer_list *t); +int vchiq_del_timer(struct timer_list *t); +int vchiq_del_timer_sync(struct timer_list *t); /* * Completion API Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c ============================================================================== --- head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c Tue Nov 17 14:07:27 2020 (r367763) +++ head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c Tue Nov 17 14:41:23 2020 (r367764) @@ -1754,7 +1754,7 @@ vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_S arm_state->suspend_timer_timeout = SUSPEND_TIMER_TIMEOUT_MS; arm_state->suspend_timer_running = 0; - init_timer(&arm_state->suspend_timer); + vchiq_init_timer(&arm_state->suspend_timer); arm_state->suspend_timer.data = (unsigned long)(state); arm_state->suspend_timer.function = suspend_timer_callback; @@ -1892,11 +1892,11 @@ set_resume_state(VCHIQ_ARM_STATE_T *arm_state, inline void start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) { - del_timer(&arm_state->suspend_timer); + vchiq_del_timer(&arm_state->suspend_timer); arm_state->suspend_timer.expires = jiffies + msecs_to_jiffies(arm_state-> suspend_timer_timeout); - add_timer(&arm_state->suspend_timer); + vchiq_add_timer(&arm_state->suspend_timer); arm_state->suspend_timer_running = 1; } @@ -1905,7 +1905,7 @@ static inline void stop_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) { if (arm_state->suspend_timer_running) { - del_timer(&arm_state->suspend_timer); + vchiq_del_timer(&arm_state->suspend_timer); arm_state->suspend_timer_running = 0; } } From owner-svn-src-all@freebsd.org Tue Nov 17 14:57:34 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9ACA92EED76; Tue, 17 Nov 2020 14:57:34 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb8Dt41k8z4ln3; Tue, 17 Nov 2020 14:57:34 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 78982218DA; Tue, 17 Nov 2020 14:57:34 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHEvYom030548; Tue, 17 Nov 2020 14:57:34 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHEvYPm030547; Tue, 17 Nov 2020 14:57:34 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011171457.0AHEvYPm030547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 17 Nov 2020 14:57:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367765 - head/sys/arm/allwinner/clkng X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner/clkng X-SVN-Commit-Revision: 367765 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 14:57:34 -0000 Author: manu Date: Tue Nov 17 14:57:34 2020 New Revision: 367765 URL: https://svnweb.freebsd.org/changeset/base/367765 Log: arm: allwinner: Add DE2 Clock support for H3 SoC While here also enable the clock and deassert the reset Modified: head/sys/arm/allwinner/clkng/ccu_de2.c Modified: head/sys/arm/allwinner/clkng/ccu_de2.c ============================================================================== --- head/sys/arm/allwinner/clkng/ccu_de2.c Tue Nov 17 14:41:23 2020 (r367764) +++ head/sys/arm/allwinner/clkng/ccu_de2.c Tue Nov 17 14:57:34 2020 (r367765) @@ -43,30 +43,52 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __aarch64__ #include "opt_soc.h" +#endif #include #include #include +#include + #include #include #include +enum CCU_DE2 { + H3_CCU = 1, + A64_CCU, +}; + /* Non exported clocks */ #define CLK_MIXER0_DIV 3 #define CLK_MIXER1_DIV 4 #define CLK_WB_DIV 5 -static struct aw_ccung_reset de2_ccu_resets[] = { +static struct aw_ccung_reset h3_de2_ccu_resets[] = { CCU_RESET(RST_MIXER0, 0x08, 0) + CCU_RESET(RST_WB, 0x08, 2) +}; + +static struct aw_ccung_reset a64_de2_ccu_resets[] = { + CCU_RESET(RST_MIXER0, 0x08, 0) CCU_RESET(RST_MIXER1, 0x08, 1) CCU_RESET(RST_WB, 0x08, 2) }; -static struct aw_ccung_gate de2_ccu_gates[] = { +static struct aw_ccung_gate h3_de2_ccu_gates[] = { CCU_GATE(CLK_BUS_MIXER0, "mixer0", "mixer0-div", 0x00, 0) + CCU_GATE(CLK_BUS_WB, "wb", "wb-div", 0x00, 2) + + CCU_GATE(CLK_MIXER0, "bus-mixer0", "bus-de", 0x04, 0) + CCU_GATE(CLK_WB, "bus-wb", "bus-de", 0x04, 2) +}; + +static struct aw_ccung_gate a64_de2_ccu_gates[] = { + CCU_GATE(CLK_BUS_MIXER0, "mixer0", "mixer0-div", 0x00, 0) CCU_GATE(CLK_BUS_MIXER1, "mixer1", "mixer1-div", 0x00, 1) CCU_GATE(CLK_BUS_WB, "wb", "wb-div", 0x00, 2) @@ -95,7 +117,7 @@ NM_CLK(mixer1_div_clk, 4, 4, 0, 0, /* M flags */ 0, 0, /* mux */ 0, /* gate */ - AW_CLK_SCALE_CHANGE); /* flags */ + AW_CLK_SCALE_CHANGE); /* flags */ NM_CLK(wb_div_clk, CLK_WB_DIV, /* id */ @@ -105,16 +127,22 @@ NM_CLK(wb_div_clk, 8, 4, 0, 0, /* M flags */ 0, 0, /* mux */ 0, /* gate */ - AW_CLK_SCALE_CHANGE); /* flags */ + AW_CLK_SCALE_CHANGE); /* flags */ -static struct aw_ccung_clk de2_ccu_clks[] = { +static struct aw_ccung_clk h3_de2_ccu_clks[] = { { .type = AW_CLK_NM, .clk.nm = &mixer0_div_clk}, + { .type = AW_CLK_NM, .clk.nm = &wb_div_clk}, +}; + +static struct aw_ccung_clk a64_de2_ccu_clks[] = { + { .type = AW_CLK_NM, .clk.nm = &mixer0_div_clk}, { .type = AW_CLK_NM, .clk.nm = &mixer1_div_clk}, { .type = AW_CLK_NM, .clk.nm = &wb_div_clk}, }; static struct ofw_compat_data compat_data[] = { - {"allwinner,sun50i-a64-de2-clk", 1}, + {"allwinner,sun8i-h3-de2-clk", H3_CCU}, + {"allwinner,sun50i-a64-de2-clk", A64_CCU}, {NULL, 0} }; @@ -136,15 +164,61 @@ static int ccu_de2_attach(device_t dev) { struct aw_ccung_softc *sc; + phandle_t node; + clk_t mod, bus; + hwreset_t rst_de; + enum CCU_DE2 type; sc = device_get_softc(dev); + node = ofw_bus_get_node(dev); - sc->resets = de2_ccu_resets; - sc->nresets = nitems(de2_ccu_resets); - sc->gates = de2_ccu_gates; - sc->ngates = nitems(de2_ccu_gates); - sc->clks = de2_ccu_clks; - sc->nclks = nitems(de2_ccu_clks); + type = (enum CCU_DE2)ofw_bus_search_compatible(dev, compat_data)->ocd_data; + + switch (type) { + case H3_CCU: + sc->resets = h3_de2_ccu_resets; + sc->nresets = nitems(h3_de2_ccu_resets); + sc->gates = h3_de2_ccu_gates; + sc->ngates = nitems(h3_de2_ccu_gates); + sc->clks = h3_de2_ccu_clks; + sc->nclks = nitems(h3_de2_ccu_clks); + break; + case A64_CCU: + sc->resets = a64_de2_ccu_resets; + sc->nresets = nitems(a64_de2_ccu_resets); + sc->gates = a64_de2_ccu_gates; + sc->ngates = nitems(a64_de2_ccu_gates); + sc->clks = a64_de2_ccu_clks; + sc->nclks = nitems(a64_de2_ccu_clks); + break; + } + + if (hwreset_get_by_ofw_idx(dev, node, 0, &rst_de) != 0) { + device_printf(dev, "Cannot get de reset\n"); + return (ENXIO); + } + if (hwreset_deassert(rst_de) != 0) { + device_printf(dev, "Cannot de-assert de reset\n"); + return (ENXIO); + } + + if (clk_get_by_ofw_name(dev, node, "mod", &mod) != 0) { + device_printf(dev, "Cannot get mod clock\n"); + return (ENXIO); + } + if (clk_enable(mod) != 0) { + device_printf(dev, "Cannot enable mod clock\n"); + return (ENXIO); + } + + if (clk_get_by_ofw_name(dev, node, "bus", &bus) != 0) { + device_printf(dev, "Cannot get bus clock\n"); + return (ENXIO); + } + if (clk_enable(bus) != 0) { + device_printf(dev, "Cannot enable bus clock\n"); + return (ENXIO); + } return (aw_ccung_attach(dev)); } From owner-svn-src-all@freebsd.org Tue Nov 17 14:58:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 621002EEF77; Tue, 17 Nov 2020 14:58:31 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb8Fz2MCjz4lwV; Tue, 17 Nov 2020 14:58:31 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43C03219DA; Tue, 17 Nov 2020 14:58:31 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHEwVP7030646; Tue, 17 Nov 2020 14:58:31 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHEwVCu030645; Tue, 17 Nov 2020 14:58:31 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011171458.0AHEwVCu030645@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 17 Nov 2020 14:58:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367766 - head/sys/arm/allwinner/clkng X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner/clkng X-SVN-Commit-Revision: 367766 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 14:58:31 -0000 Author: manu Date: Tue Nov 17 14:58:30 2020 New Revision: 367766 URL: https://svnweb.freebsd.org/changeset/base/367766 Log: arm64: allwinner: Init the Display Engine clock In case u-boot was compiled without video support set the PLL to 432Mhz (which allow us to use most of the HDMI resolution for tcon) and set it as the parent for the DE clock. Modified: head/sys/arm/allwinner/clkng/ccu_a64.c Modified: head/sys/arm/allwinner/clkng/ccu_a64.c ============================================================================== --- head/sys/arm/allwinner/clkng/ccu_a64.c Tue Nov 17 14:57:34 2020 (r367765) +++ head/sys/arm/allwinner/clkng/ccu_a64.c Tue Nov 17 14:58:30 2020 (r367766) @@ -789,6 +789,8 @@ static struct aw_clk_init a64_init_clks[] = { {"ahb1", "pll_periph0", 0, false}, {"ahb2", "pll_periph0", 0, false}, {"dram", "pll_ddr0", 0, false}, + {"pll_de", NULL, 432000000, true}, + {"de", "pll_de", 0, true}, }; static int From owner-svn-src-all@freebsd.org Tue Nov 17 14:59:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E8E452EF387; Tue, 17 Nov 2020 14:59:58 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cb8Hf6Ffnz4m7C; Tue, 17 Nov 2020 14:59:58 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C957E21946; Tue, 17 Nov 2020 14:59:58 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHExw4Z030765; Tue, 17 Nov 2020 14:59:58 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHExwZ9030762; Tue, 17 Nov 2020 14:59:58 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011171459.0AHExwZ9030762@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 17 Nov 2020 14:59:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367767 - head/sys/dev/extres/syscon X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/extres/syscon X-SVN-Commit-Revision: 367767 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 14:59:59 -0000 Author: manu Date: Tue Nov 17 14:59:58 2020 New Revision: 367767 URL: https://svnweb.freebsd.org/changeset/base/367767 Log: syscon: Add syscon_get_by_ofw_node This allow to get a syscon node defined under a specific fdt node (which isn't always the device one). Modified: head/sys/dev/extres/syscon/syscon.c head/sys/dev/extres/syscon/syscon.h Modified: head/sys/dev/extres/syscon/syscon.c ============================================================================== --- head/sys/dev/extres/syscon/syscon.c Tue Nov 17 14:58:30 2020 (r367766) +++ head/sys/dev/extres/syscon/syscon.c Tue Nov 17 14:59:58 2020 (r367767) @@ -264,6 +264,21 @@ syscon_get_ofw_node(struct syscon *syscon) } int +syscon_get_by_ofw_node(device_t cdev, phandle_t node, struct syscon **syscon) +{ + + SYSCON_TOPO_SLOCK(); + *syscon = syscon_find_by_ofw_node(node); + if (*syscon == NULL) { + SYSCON_TOPO_UNLOCK(); + device_printf(cdev, "Failed to find syscon node\n"); + return (ENODEV); + } + SYSCON_TOPO_UNLOCK(); + return (0); +} + +int syscon_get_by_ofw_property(device_t cdev, phandle_t cnode, char *name, struct syscon **syscon) { Modified: head/sys/dev/extres/syscon/syscon.h ============================================================================== --- head/sys/dev/extres/syscon/syscon.h Tue Nov 17 14:58:30 2020 (r367766) +++ head/sys/dev/extres/syscon/syscon.h Tue Nov 17 14:59:58 2020 (r367767) @@ -73,6 +73,7 @@ struct syscon *syscon_create_ofw_node(device_t pdev, phandle_t syscon_get_ofw_node(struct syscon *syscon); int syscon_get_by_ofw_property(device_t consumer, phandle_t node, char *name, struct syscon **syscon); +int syscon_get_by_ofw_node(device_t cdev, phandle_t node, struct syscon **syscon); #endif #endif /* DEV_SYSCON_H */ From owner-svn-src-all@freebsd.org Tue Nov 17 16:34:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CAC29468AAF; Tue, 17 Nov 2020 16:34:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbBPG5Pkjz4rpV; Tue, 17 Nov 2020 16:34:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AC8B82302D; Tue, 17 Nov 2020 16:34:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHGYw1E092499; Tue, 17 Nov 2020 16:34:58 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHGYwKR092497; Tue, 17 Nov 2020 16:34:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011171634.0AHGYwKR092497@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 17 Nov 2020 16:34:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367768 - in head/sbin/nvmecontrol: . modules/wdc X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head/sbin/nvmecontrol: . modules/wdc X-SVN-Commit-Revision: 367768 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 16:34:58 -0000 Author: mav Date: Tue Nov 17 16:34:58 2020 New Revision: 367768 URL: https://svnweb.freebsd.org/changeset/base/367768 Log: Stop using NVME_MAX_XFER_SIZE constant. This constant depends on MAXPHYS and does not respect device capabilities. Use proper dynamic ioctl(NVME_GET_MAX_XFER_SIZE) instead. MFC after: 1 month Modified: head/sbin/nvmecontrol/firmware.c head/sbin/nvmecontrol/modules/wdc/wdc.c Modified: head/sbin/nvmecontrol/firmware.c ============================================================================== --- head/sbin/nvmecontrol/firmware.c Tue Nov 17 14:59:58 2020 (r367767) +++ head/sbin/nvmecontrol/firmware.c Tue Nov 17 16:34:58 2020 (r367768) @@ -166,12 +166,10 @@ update_firmware(int fd, uint8_t *payload, int32_t payl off = 0; resid = payload_size; - if (fwug != 0 && fwug != 0xFF) - max_xfer_size = ((uint64_t)fwug << 12); - else if (ioctl(fd, NVME_GET_MAX_XFER_SIZE, &max_xfer_size) < 0) + if (ioctl(fd, NVME_GET_MAX_XFER_SIZE, &max_xfer_size) < 0) err(EX_IOERR, "query max transfer size failed"); - if (max_xfer_size > NVME_MAX_XFER_SIZE) - max_xfer_size = NVME_MAX_XFER_SIZE; + if (fwug != 0 && fwug != 0xFF) + max_xfer_size = MIN(max_xfer_size, (uint64_t)fwug << 12); if ((chunk = aligned_alloc(PAGE_SIZE, max_xfer_size)) == NULL) errx(EX_OSERR, "unable to malloc %zd bytes", (size_t)max_xfer_size); Modified: head/sbin/nvmecontrol/modules/wdc/wdc.c ============================================================================== --- head/sbin/nvmecontrol/modules/wdc/wdc.c Tue Nov 17 14:59:58 2020 (r367767) +++ head/sbin/nvmecontrol/modules/wdc/wdc.c Tue Nov 17 16:34:58 2020 (r367768) @@ -165,6 +165,7 @@ wdc_do_dump_e6(int fd, char *tmpl, const char *suffix, int first; int fd2; uint8_t *buf, *hdr; + uint64_t max_xfer_size; uint32_t len, offset; size_t resid; bool e6lg_flag = false; @@ -186,15 +187,17 @@ wdc_do_dump_e6(int fd, char *tmpl, const char *suffix, fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd2 < 0) err(EX_CANTCREAT, "open %s", tmpl); - buf = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE); + if (ioctl(fd, NVME_GET_MAX_XFER_SIZE, &max_xfer_size) < 0) + err(EX_IOERR, "query max transfer size failed"); + buf = aligned_alloc(PAGE_SIZE, max_xfer_size); if (buf == NULL) errx(EX_OSERR, "Can't get buffer to read dump"); offset = 0; - len = NVME_MAX_XFER_SIZE; + len = max_xfer_size; first = 1; do { - resid = len > NVME_MAX_XFER_SIZE ? NVME_MAX_XFER_SIZE : len; + resid = MIN(len, max_xfer_size); wdc_get_data(fd, opcode, resid, offset, cmd, buf, resid, e6lg_flag); if (first) { @@ -321,6 +324,7 @@ wdc_do_dump_dui(int fd, char *tmpl, uint8_t data_area, { int fd2, first; uint8_t *buf; + uint64_t max_xfer_size; uint16_t hdr_ver; uint64_t log_len, offset; size_t resid; @@ -332,14 +336,16 @@ wdc_do_dump_dui(int fd, char *tmpl, uint8_t data_area, fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd2 < 0) err(EX_CANTCREAT, "open %s", tmpl); - buf = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE); + if (ioctl(fd, NVME_GET_MAX_XFER_SIZE, &max_xfer_size) < 0) + err(EX_IOERR, "query max transfer size failed"); + buf = aligned_alloc(PAGE_SIZE, max_xfer_size); if (buf == NULL) errx(EX_OSERR, "Can't get buffer to read dump"); offset = 0; first = 1; while (log_len > 0) { - resid = log_len > NVME_MAX_XFER_SIZE ? NVME_MAX_XFER_SIZE : log_len; + resid = MIN(log_len, max_xfer_size); wdc_get_data_dui(fd, opcode, resid, offset, buf, resid); if (first) { hdr_ver = ((buf[len_off] & 0xF) != 0) ? From owner-svn-src-all@freebsd.org Tue Nov 17 16:54:13 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8467F469403; Tue, 17 Nov 2020 16:54:13 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbBqT3KMPz4sNN; Tue, 17 Nov 2020 16:54:13 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64D9723605; Tue, 17 Nov 2020 16:54:13 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHGsDlf005135; Tue, 17 Nov 2020 16:54:13 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHGsDiL005134; Tue, 17 Nov 2020 16:54:13 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011171654.0AHGsDiL005134@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Tue, 17 Nov 2020 16:54:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367769 - head/usr.bin/chpass X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/usr.bin/chpass X-SVN-Commit-Revision: 367769 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 16:54:13 -0000 Author: 0mp (doc,ports committer) Date: Tue Nov 17 16:54:12 2020 New Revision: 367769 URL: https://svnweb.freebsd.org/changeset/base/367769 Log: Partially revert r367756 (chpass(1) synopsis changes) Let's have two entries in the synopsis: - chpass now lists options which can be used for non-NIS-specific functionalities. - ypchpass additionally lists the NIS-specific flags. Technically, it is an artificial distinction, as chpass and ypchpass behave identically. Nevertheless, it might help navigating the synopsis section. Reviewed by: imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27251 Modified: head/usr.bin/chpass/chpass.1 Modified: head/usr.bin/chpass/chpass.1 ============================================================================== --- head/usr.bin/chpass/chpass.1 Tue Nov 17 16:34:58 2020 (r367768) +++ head/usr.bin/chpass/chpass.1 Tue Nov 17 16:54:12 2020 (r367769) @@ -40,7 +40,13 @@ .Nm ypchsh .Nd add or change user database information .Sh SYNOPSIS -.Nm +.Nm chpass +.Op Fl a Ar list +.Op Fl e Ar expiretime +.Op Fl p Ar encpass +.Op Fl s Ar newshell +.Op user +.Nm ypchpass .Op Fl loy .Op Fl a Ar list .Op Fl d Ar domain From owner-svn-src-all@freebsd.org Tue Nov 17 17:11:08 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5A81346978F; Tue, 17 Nov 2020 17:11:08 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbCC01nDLz4tXG; Tue, 17 Nov 2020 17:11:08 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 30860232D4; Tue, 17 Nov 2020 17:11:08 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHHB7qG014871; Tue, 17 Nov 2020 17:11:07 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHHB7XO014869; Tue, 17 Nov 2020 17:11:07 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <202011171711.0AHHB7XO014869@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 17 Nov 2020 17:11:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367770 - head/sys/cddl/contrib/opensolaris/common/lz4 X-SVN-Group: head X-SVN-Commit-Author: adrian X-SVN-Commit-Paths: head/sys/cddl/contrib/opensolaris/common/lz4 X-SVN-Commit-Revision: 367770 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 17:11:08 -0000 Author: adrian Date: Tue Nov 17 17:11:07 2020 New Revision: 367770 URL: https://svnweb.freebsd.org/changeset/base/367770 Log: [cddl] Fix lz4 function definitions to not tri pup compile. This tripped up in llvm compilation on amd64 noting that lz4_init/lz4_fini were lacking in being previously defined. Reviewed by: emaste, freqlabs, brooks Differential Revision: https://reviews.freebsd.org/D27240 Modified: head/sys/cddl/contrib/opensolaris/common/lz4/lz4.c head/sys/cddl/contrib/opensolaris/common/lz4/lz4.h Modified: head/sys/cddl/contrib/opensolaris/common/lz4/lz4.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/common/lz4/lz4.c Tue Nov 17 16:54:12 2020 (r367769) +++ head/sys/cddl/contrib/opensolaris/common/lz4/lz4.c Tue Nov 17 17:11:07 2020 (r367770) @@ -1024,7 +1024,7 @@ LZ4_uncompress_unknownOutputSize(const char *source, c } #if defined(_KERNEL) || defined(_FAKE_KERNEL) -extern void +void lz4_init(void) { @@ -1034,7 +1034,7 @@ lz4_init(void) #endif } -extern void +void lz4_fini(void) { Modified: head/sys/cddl/contrib/opensolaris/common/lz4/lz4.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/common/lz4/lz4.h Tue Nov 17 16:54:12 2020 (r367769) +++ head/sys/cddl/contrib/opensolaris/common/lz4/lz4.h Tue Nov 17 17:11:07 2020 (r367770) @@ -43,6 +43,11 @@ extern "C" { extern size_t lz4_compress(void *, void *, size_t, size_t, int); extern int lz4_decompress(void *, void *, size_t, size_t, int); +#if defined(_KERNEL) || defined(_FAKE_KERNEL) +extern void lz4_init(void); +extern void lz4_fini(void); +#endif + #ifdef __cplusplus } #endif From owner-svn-src-all@freebsd.org Tue Nov 17 17:11:21 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 72D3F469797; Tue, 17 Nov 2020 17:11:21 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbCCF0m49z4tZv; Tue, 17 Nov 2020 17:11:20 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id A957F3C0199; Tue, 17 Nov 2020 17:11:14 +0000 (UTC) Date: Tue, 17 Nov 2020 17:11:14 +0000 From: Brooks Davis To: Kyle Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r367744 - in head/sys: compat/freebsd32 kern sys Message-ID: <20201117171114.GA1158@spindle.one-eyed-alien.net> References: <202011170336.0AH3awYt006482@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline In-Reply-To: <202011170336.0AH3awYt006482@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4CbCCF0m49z4tZv X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 17:11:21 -0000 --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 17, 2020 at 03:36:58AM +0000, Kyle Evans wrote: > Modified: head/sys/compat/freebsd32/freebsd32.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:34:01 2020 (r3677= 43) > +++ head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:36:58 2020 (r3677= 44) > @@ -94,6 +94,27 @@ struct itimerval32 { > struct timeval32 it_value; > }; > =20 > +struct umtx_time32 { > + struct timespec32 _timeout; > + uint32_t _flags; > + uint32_t _clockid; > +}; > + > +struct umtx_robust_lists_params_compat32 { > + uint32_t robust_list_offset; > + uint32_t robust_priv_list_offset; > + uint32_t robust_inact_offset; > +}; > + > +struct umutex32 { > + volatile __lwpid_t m_owner; /* Owner of the mutex */ > + __uint32_t m_flags; /* Flags of the mutex */ > + __uint32_t m_ceilings[2]; /* Priority protect ceiling */ > + __uint32_t m_rb_lnk; /* Robust linkage */ > + __uint32_t m_pad; > + __uint32_t m_spare[2]; > +}; > + > #define FREEBSD4_MFSNAMELEN 16 > #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) > =20 >=20 > Modified: head/sys/compat/freebsd32/freebsd32_misc.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:34:01 2020 (= r367743) > +++ head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:36:58 2020 (= r367744) > @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -3764,4 +3765,12 @@ freebsd32_sched_rr_get_interval(struct thread *td, > error =3D copyout(&ts32, uap->interval, sizeof(ts32)); > } > return (error); > +} > + > +int > +freebsd32__umtx_op(struct thread *td, struct freebsd32__umtx_op_args *ua= p) > +{ > + > + return (kern__umtx_op(td, uap->obj, uap->op, uap->val, uap->uaddr, > + uap->uaddr2, &umtx_native_ops32)); > } >=20 Putting any of this under compat/freebsd32 seems like a somewhat odd choice since all the work is done in kern_umtx.h. In CheriBSD, everything just lives there so nothing has to be exposed in headers. -- Brooks --ZPt4rx8FFjLCG7dd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJftAQxAAoJEKzQXbSebgfA9tEH/jE8qO/Jbdhphf+OLFNz0aWo g/Xg8m+8exNtVsKuKDNgwikavj5mslQTzyGuP7NXDcZpug+rbIBVz5fLy/0QecmT GScA0B29Uw6h/5pv8NQlqcICsvqxVYATBHkhFaUIbq0dzJSYezmBPIcM+H87opih /sKBMxvlEnzUh8KrmmL/w1hc3k6BJrlE9aS3SYSuRrj0dRpIvWWg1NqwO7DvfVve rVsV3n4JmODxyn4t6GY/YCGA+JgNHTSthWz48pUGo86y/A1K7sQl6dn86yxoVhE4 KWBpmfUiUmNxuH2tP3S2L3TuX0vBfWe0oRDIJ3onYJZIohcNMX9Z0YBGmTHh7us= =z5PA -----END PGP SIGNATURE----- --ZPt4rx8FFjLCG7dd-- From owner-svn-src-all@freebsd.org Tue Nov 17 17:12:28 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8A6BC4697CB; Tue, 17 Nov 2020 17:12:28 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbCDX3YQGz4twg; Tue, 17 Nov 2020 17:12:28 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6D35123732; Tue, 17 Nov 2020 17:12:28 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHHCSii017392; Tue, 17 Nov 2020 17:12:28 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHHCS3V017391; Tue, 17 Nov 2020 17:12:28 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <202011171712.0AHHCS3V017391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 17 Nov 2020 17:12:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367771 - head/sbin/nvmecontrol X-SVN-Group: head X-SVN-Commit-Author: adrian X-SVN-Commit-Paths: head/sbin/nvmecontrol X-SVN-Commit-Revision: 367771 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 17:12:28 -0000 Author: adrian Date: Tue Nov 17 17:12:28 2020 New Revision: 367771 URL: https://svnweb.freebsd.org/changeset/base/367771 Log: [nvmecontrol] Fix type signedness warning-to-error on gcc-6.4 This fixes a type signedness comparison warning-to-error on gcc-6.4. The ternary operation casts it right but the actual assignment doesn't. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D26791 Modified: head/sbin/nvmecontrol/firmware.c Modified: head/sbin/nvmecontrol/firmware.c ============================================================================== --- head/sbin/nvmecontrol/firmware.c Tue Nov 17 17:11:07 2020 (r367770) +++ head/sbin/nvmecontrol/firmware.c Tue Nov 17 17:12:28 2020 (r367771) @@ -159,8 +159,9 @@ static void update_firmware(int fd, uint8_t *payload, int32_t payload_size, uint8_t fwug) { struct nvme_pt_command pt; - uint64_t max_xfer_size; - int32_t off, resid, size; + uint64_t max_xfer_size; + int32_t off; + uint32_t resid, size; void *chunk; off = 0; @@ -175,8 +176,7 @@ update_firmware(int fd, uint8_t *payload, int32_t payl errx(EX_OSERR, "unable to malloc %zd bytes", (size_t)max_xfer_size); while (resid > 0) { - size = (resid >= (int32_t)max_xfer_size) ? - max_xfer_size : resid; + size = (resid >= max_xfer_size) ? max_xfer_size : resid; memcpy(chunk, payload + off, size); memset(&pt, 0, sizeof(pt)); From owner-svn-src-all@freebsd.org Tue Nov 17 17:19:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D519469AC2; Tue, 17 Nov 2020 17:19:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbCN908Jbz4vJk; Tue, 17 Nov 2020 17:19:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 76094E9D8; Tue, 17 Nov 2020 17:19:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367694 - in head/sys: kern sys To: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011141921.0AEJLkAu055910@repo.freebsd.org> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Tue, 17 Nov 2020 09:19:03 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <202011141921.0AEJLkAu055910@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 17:19:05 -0000 On 11/14/20 11:21 AM, Mateusz Guzik wrote: > Author: mjg > Date: Sat Nov 14 19:21:46 2020 > New Revision: 367694 > URL: https://svnweb.freebsd.org/changeset/base/367694 > > Log: > thread: batch resource limit free calls > > Modified: > head/sys/kern/kern_resource.c > head/sys/kern/kern_thread.c > head/sys/sys/resourcevar.h > > Modified: head/sys/kern/kern_resource.c > ============================================================================== > --- head/sys/kern/kern_resource.c Sat Nov 14 19:20:58 2020 (r367693) > +++ head/sys/kern/kern_resource.c Sat Nov 14 19:21:46 2020 (r367694) > @@ -1236,6 +1236,14 @@ lim_free(struct plimit *limp) > free((void *)limp, M_PLIMIT); > } > > +void > +lim_freen(struct plimit *limp, int n) > +{ > + > + if (refcount_releasen(&limp->pl_refcnt, n)) > + free((void *)limp, M_PLIMIT); You don't need this cast. -- John Baldwin From owner-svn-src-all@freebsd.org Tue Nov 17 17:26:09 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CFDC6469E71; Tue, 17 Nov 2020 17:26:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbCXK5QTdz3BmT; Tue, 17 Nov 2020 17:26:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 31C0FF981; Tue, 17 Nov 2020 17:26:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367695 - in head/sys: kern sys To: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011141922.0AEJM2ld055995@repo.freebsd.org> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Tue, 17 Nov 2020 09:26:08 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <202011141922.0AEJM2ld055995@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 17:26:09 -0000 On 11/14/20 11:22 AM, Mateusz Guzik wrote: > Author: mjg > Date: Sat Nov 14 19:22:02 2020 > New Revision: 367695 > URL: https://svnweb.freebsd.org/changeset/base/367695 > > Log: > thread: batch credential freeing > > Modified: > head/sys/kern/kern_prot.c > head/sys/kern/kern_thread.c > head/sys/sys/ucred.h > > Modified: head/sys/kern/kern_prot.c > ============================================================================== > --- head/sys/kern/kern_prot.c Sat Nov 14 19:21:46 2020 (r367694) > +++ head/sys/kern/kern_prot.c Sat Nov 14 19:22:02 2020 (r367695) > @@ -2007,6 +2071,17 @@ crfree(struct ucred *cr) > mtx_unlock(&cr->cr_mtx); > return; > } > + crfree_final(cr); > +} > + > +static void > +crfree_final(struct ucred *cr) > +{ > + > + KASSERT(cr->cr_users == 0, ("%s: users %d not == 0 on cred %p", > + __func__, cr->cr_users, cr)); > + KASSERT(cr->cr_ref == 0, ("%s: ref %d not == 0 on cred %p", > + __func__, cr->cr_ref, cr)); > /* Please add blank lines before comments. It's in style(9) and I've noticed a pattern in your changes of not including them. > Modified: head/sys/sys/ucred.h > ============================================================================== > --- head/sys/sys/ucred.h Sat Nov 14 19:21:46 2020 (r367694) > +++ head/sys/sys/ucred.h Sat Nov 14 19:22:02 2020 (r367695) > @@ -114,6 +114,28 @@ struct xucred { > struct proc; > struct thread; > > +struct credbatch { > + struct ucred *cred; > + int users; > + int ref; > +}; > + > +static inline void > +credbatch_prep(struct credbatch *crb) > +{ > + crb->cred = NULL; > + crb->users = 0; > + crb->ref = 0; > +} > +void credbatch_add(struct credbatch *crb, struct thread *td); > +static inline void > +credbatch_process(struct credbatch *crb) > +{ > + > +} > +void credbatch_add(struct credbatch *crb, struct thread *td); > +void credbatch_final(struct credbatch *crb); > + Do not mix prototypes and inlines, especially without spaces around the prototype in the middle. Also, the kernel uses __inline rather than inline (for better or for worse). Better would be: static __inline void credbatch_prep() { ... } static __inline void credbatch_process() { ... } void credbatch_add(); void credbatch_final(); It seems you just have a duplicate credbatch_add() in fact. Also, why have an empty inline function? These changes would benefit from review. -- John Baldwin From owner-svn-src-all@freebsd.org Tue Nov 17 17:29:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4AD8D469F54 for ; Tue, 17 Nov 2020 17:29:52 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 4CbCcc1Z4lz4vnP for ; Tue, 17 Nov 2020 17:29:51 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f54.google.com with SMTP id p19so2492216wmg.0 for ; Tue, 17 Nov 2020 09:29:51 -0800 (PST) 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=jX6kARcgylLein7oAi3Wg8AfpwGEqF3HvfiPIcvXkxs=; b=KjYJWS/FhjjwXgOvFhmHfKIOItw5uLmAVPoxXzbpaA9gp7/9rULBIuRk7JL0hn8C4j 3OpldoWEkNzPwhGEBtg1mThGRiaiG610V+dxH8eaZT9DYSsleVbyQJvp3LCOfblgGDnU 92FdyOC4WgqjPLIin6kqAd7xrDZsjLPpbNOpNhT+e3HJZxAG0xaIVNTbQg2Rp5/njxhj W+luQx77HYWX2C/c8BStmIUBzGJDuuiYgs6VOJ2Mj26jRMfKtgZUeua0pn4Njz/Ng+R7 4gU47POBFvNyqCCtlzh3jugjXC/H1lpMWCi4va3d0fRh9NffcQr7ENRMEiOmpHwjPvS2 Ftvw== X-Gm-Message-State: AOAM531+p+OxWNSOvTsrqil0YmcCz0FRFHYDVSTHs2/Hv55SWOI987Lv SbNexgucxuUauZU0kc/hNRbn+rLBKMXnVTpz X-Google-Smtp-Source: ABdhPJyB6C7X+eW5ow9Huquyh1OUagRi0JPSeVqwp9xVbP9l2ImQJvBAseyzYhTS6XyK/Wp30tEemA== X-Received: by 2002:a1c:398a:: with SMTP id g132mr154761wma.51.1605634190533; Tue, 17 Nov 2020 09:29:50 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id z189sm4466129wme.23.2020.11.17.09.29.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2020 09:29:49 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367771 - head/sbin/nvmecontrol From: Jessica Clarke In-Reply-To: <202011171712.0AHHCS3V017391@repo.freebsd.org> Date: Tue, 17 Nov 2020 17:29:49 +0000 Cc: src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: 7bit Message-Id: <5C44DBA6-CBA2-49E9-8AFC-45C62664D2FD@freebsd.org> References: <202011171712.0AHHCS3V017391@repo.freebsd.org> To: Adrian Chadd X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CbCcc1Z4lz4vnP X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 17:29:52 -0000 On 17 Nov 2020, at 17:12, Adrian Chadd wrote: > @@ -175,8 +176,7 @@ update_firmware(int fd, uint8_t *payload, int32_t payl > errx(EX_OSERR, "unable to malloc %zd bytes", (size_t)max_xfer_size); > > while (resid > 0) { > - size = (resid >= (int32_t)max_xfer_size) ? > - max_xfer_size : resid; > + size = (resid >= max_xfer_size) ? max_xfer_size : resid; MIN from the already-included sys/param.h? (Otherwise: you have an extra space after ?) Jess From owner-svn-src-all@freebsd.org Tue Nov 17 17:32:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E3E046A4E6 for ; Tue, 17 Nov 2020 17:32:24 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 4CbCgW6ZKyz3C7h for ; Tue, 17 Nov 2020 17:32:23 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f52.google.com with SMTP id l1so23998050wrb.9 for ; Tue, 17 Nov 2020 09:32:23 -0800 (PST) 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=kSVocQRoGgFdGKekngWPmDyT0DiNuq7bTMj5Ua/gifM=; b=t6G6bNu+8GrqyTwsYWhf42vG/k2A+0hq5pg18CErw2yU3tmSgkY8RDYb5WAMhFyjgH sMGm8+uI/InKzxnDJxc4YrvNft+k+AVRXsK3191UdU0GqemWaKYco5AxhsGChy+j5ekl eQFNQWvbZlFT60QrDKMBeCWFuEIWrtmQrzRanoePq7MiQ4iyY0O5Rtsw8T+zhI4mM8h+ sKJ7SVJ8vwWnRQmeY9/8Letct33G0LOAzQfBDhwWVYjbk/AdPgdrcTlFJajUeFi6nLgn wuwsFeuR8GfajCiP/4g9cuTzalwQqsFCVG/guhOhcsXYkSiMZWwRnWceE2v7pUQn25O5 Hwtw== X-Gm-Message-State: AOAM530zUDt1K0zr+e9ZMQH5xJ7c2uKkyJr94ViXuOPTC0mnXiAVc9b3 uz34gTD+vcLcds5WSl4ydMHAoLzJzCLUr4lC X-Google-Smtp-Source: ABdhPJyZd6GK7z1fkwwUC83+Cc7SiB5FmZQxLEYBEd9uQDtdwLDslaYEC1MFGcsWNfsynQhtDFGCrA== X-Received: by 2002:adf:9d49:: with SMTP id o9mr580343wre.413.1605634342247; Tue, 17 Nov 2020 09:32:22 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id a17sm31002731wra.61.2020.11.17.09.32.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2020 09:32:21 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367771 - head/sbin/nvmecontrol From: Jessica Clarke In-Reply-To: <5C44DBA6-CBA2-49E9-8AFC-45C62664D2FD@freebsd.org> Date: Tue, 17 Nov 2020 17:32:21 +0000 Cc: src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: 7bit Message-Id: <5883B567-0E7D-475A-B04B-25774FB22A6C@freebsd.org> References: <202011171712.0AHHCS3V017391@repo.freebsd.org> <5C44DBA6-CBA2-49E9-8AFC-45C62664D2FD@freebsd.org> To: Adrian Chadd X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CbCgW6ZKyz3C7h 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.52 as permitted sender) smtp.mailfrom=jrtc27@jrtc27.com X-Spamd-Result: default: False [-2.50 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; 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)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.221.52:from]; FREEFALL_USER(0.00)[jrtc27]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-all@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; SPAMHAUS_ZRD(0.00)[209.85.221.52:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.221.52:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.221.52:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[svn-src-all] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 17:32:24 -0000 On 17 Nov 2020, at 17:29, Jessica Clarke wrote: > On 17 Nov 2020, at 17:12, Adrian Chadd wrote: >> @@ -175,8 +176,7 @@ update_firmware(int fd, uint8_t *payload, int32_t payl >> errx(EX_OSERR, "unable to malloc %zd bytes", (size_t)max_xfer_size); >> >> while (resid > 0) { >> - size = (resid >= (int32_t)max_xfer_size) ? >> - max_xfer_size : resid; >> + size = (resid >= max_xfer_size) ? max_xfer_size : resid; > > MIN from the already-included sys/param.h? > > (Otherwise: you have an extra space after ?) Also why is off signed when it counts up from 0? Jess From owner-svn-src-all@freebsd.org Tue Nov 17 18:00:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1705B46AEBD; Tue, 17 Nov 2020 18:00:05 +0000 (UTC) (envelope-from kevans@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbDHT08tjz3Ds6; Tue, 17 Nov 2020 18:00:05 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id E7A79FC16; Tue, 17 Nov 2020 18:00:04 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qt1-f175.google.com with SMTP id 3so16390219qtx.3; Tue, 17 Nov 2020 10:00:04 -0800 (PST) X-Gm-Message-State: AOAM533GI75F6QcxSmEn8go7JXhTEghUfIRcVOwGuR2VRwiqVk4OFA/D d+jEELb3otWwTYtr0AUmupUr4kxZcIh8DctZDDg= X-Google-Smtp-Source: ABdhPJwgtAZ0r9qA1SamyEd+VNWxSbuBJ4ZUuD9Mxcx/ySuv3qK47sk/WcL2DYWN3VHEtdu/dquveM0MVaKZHyJrGs8= X-Received: by 2002:ac8:4897:: with SMTP id i23mr349650qtq.211.1605636004421; Tue, 17 Nov 2020 10:00:04 -0800 (PST) MIME-Version: 1.0 References: <202011170336.0AH3awYt006482@repo.freebsd.org> <20201117171114.GA1158@spindle.one-eyed-alien.net> In-Reply-To: <20201117171114.GA1158@spindle.one-eyed-alien.net> From: Kyle Evans Date: Tue, 17 Nov 2020 11:59:50 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r367744 - in head/sys: compat/freebsd32 kern sys To: Brooks Davis Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 18:00:05 -0000 On Tue, Nov 17, 2020 at 11:11 AM Brooks Davis wrote: > > On Tue, Nov 17, 2020 at 03:36:58AM +0000, Kyle Evans wrote: > > Modified: head/sys/compat/freebsd32/freebsd32.h > > ============================================================================== > > --- head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:34:01 2020 (r367743) > > +++ head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:36:58 2020 (r367744) > > @@ -94,6 +94,27 @@ struct itimerval32 { > > struct timeval32 it_value; > > }; > > > > +struct umtx_time32 { > > + struct timespec32 _timeout; > > + uint32_t _flags; > > + uint32_t _clockid; > > +}; > > + > > +struct umtx_robust_lists_params_compat32 { > > + uint32_t robust_list_offset; > > + uint32_t robust_priv_list_offset; > > + uint32_t robust_inact_offset; > > +}; > > + > > +struct umutex32 { > > + volatile __lwpid_t m_owner; /* Owner of the mutex */ > > + __uint32_t m_flags; /* Flags of the mutex */ > > + __uint32_t m_ceilings[2]; /* Priority protect ceiling */ > > + __uint32_t m_rb_lnk; /* Robust linkage */ > > + __uint32_t m_pad; > > + __uint32_t m_spare[2]; > > +}; > > + > > #define FREEBSD4_MFSNAMELEN 16 > > #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) > > > > > > Modified: head/sys/compat/freebsd32/freebsd32_misc.c > > ============================================================================== > > --- head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:34:01 2020 (r367743) > > +++ head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:36:58 2020 (r367744) > > @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -3764,4 +3765,12 @@ freebsd32_sched_rr_get_interval(struct thread *td, > > error = copyout(&ts32, uap->interval, sizeof(ts32)); > > } > > return (error); > > +} > > + > > +int > > +freebsd32__umtx_op(struct thread *td, struct freebsd32__umtx_op_args *uap) > > +{ > > + > > + return (kern__umtx_op(td, uap->obj, uap->op, uap->val, uap->uaddr, > > + uap->uaddr2, &umtx_native_ops32)); > > } > > > > Putting any of this under compat/freebsd32 seems like a somewhat > odd choice since all the work is done in kern_umtx.h. In CheriBSD, > everything just lives there so nothing has to be exposed in headers. > I have no strong opinion here -- my initial impression of the suggestion to move the struct definitions into freebsd32 was that: 1.) One can then quickly reference the definition of, e.g., timespec32 when I'm looking at a umtx_time32, and 2.) It'd be 'cleaner', requiring less #ifdef soup in kern_umtx.c The follow-up patch muddies the waters a lot, as we end up using the compat32 definitions on all 64-bit platforms anyways even without compat32. I don't object to moving any/all of this back, if you think that's better. Thanks, Kyle Evans From owner-svn-src-all@freebsd.org Tue Nov 17 18:28:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5503B46BEBF; Tue, 17 Nov 2020 18:28:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbDw56zH4z3H4S; Tue, 17 Nov 2020 18:28:21 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DDEB324557; Tue, 17 Nov 2020 18:28:21 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHISLme061437; Tue, 17 Nov 2020 18:28:21 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHISLcQ061434; Tue, 17 Nov 2020 18:28:21 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202011171828.0AHISLcQ061434@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 17 Nov 2020 18:28:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367772 - in head: share/man/man4 sys/dev/usb sys/dev/usb/serial X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in head: share/man/man4 sys/dev/usb sys/dev/usb/serial X-SVN-Commit-Revision: 367772 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 18:28:22 -0000 Author: emaste Date: Tue Nov 17 18:28:20 2020 New Revision: 367772 URL: https://svnweb.freebsd.org/changeset/base/367772 Log: uplcom: add ATen/Prolific USB-232 Controller D USB ID PR: 251166 Submitted by: marcus MFC after: 2 weeks Modified: head/share/man/man4/uplcom.4 head/sys/dev/usb/serial/uplcom.c head/sys/dev/usb/usbdevs Modified: head/share/man/man4/uplcom.4 ============================================================================== --- head/share/man/man4/uplcom.4 Tue Nov 17 17:12:28 2020 (r367771) +++ head/share/man/man4/uplcom.4 Tue Nov 17 18:28:20 2020 (r367772) @@ -82,6 +82,8 @@ Anchor Serial adapter .It ATEN UC-232A .It +ATEN UC-232B +.It BAFO BF-800 and BF-810 .It Belkin F5U257 @@ -133,6 +135,8 @@ PLANEX USB-RS232 URS-03 Prolific Generic USB-Serial Adapters .It Prolific Pharos USB-Serial Adapter +.It +Prolific USB-Serial Controller D .It RATOC REX-USB60 .It Modified: head/sys/dev/usb/serial/uplcom.c ============================================================================== --- head/sys/dev/usb/serial/uplcom.c Tue Nov 17 17:12:28 2020 (r367771) +++ head/sys/dev/usb/serial/uplcom.c Tue Nov 17 18:28:20 2020 (r367772) @@ -260,6 +260,7 @@ static const STRUCT_USB_HOST_ID uplcom_devs[] = { UPLCOM_DEV(ALCOR, AU9720), /* Alcor AU9720 USB 2.0-RS232 */ UPLCOM_DEV(ANCHOR, SERIAL), /* Anchor Serial adapter */ UPLCOM_DEV(ATEN, UC232A), /* PLANEX USB-RS232 URS-03 */ + UPLCOM_DEV(ATEN, UC232B), /* Prolific USB-RS232 Controller D */ UPLCOM_DEV(BELKIN, F5U257), /* Belkin F5U257 USB to Serial */ UPLCOM_DEV(COREGA, CGUSBRS232R), /* Corega CG-USBRS232R */ UPLCOM_DEV(EPSON, CRESSI_EDY), /* Cressi Edy diving computer */ Modified: head/sys/dev/usb/usbdevs ============================================================================== --- head/sys/dev/usb/usbdevs Tue Nov 17 17:12:28 2020 (r367771) +++ head/sys/dev/usb/usbdevs Tue Nov 17 18:28:20 2020 (r367772) @@ -1275,6 +1275,7 @@ product ATEN UC1284 0x2001 Parallel printer product ATEN UC10T 0x2002 10Mbps Ethernet product ATEN UC110T 0x2007 UC-110T Ethernet product ATEN UC232A 0x2008 Serial +product ATEN UC232B 0x2022 Serial product ATEN UC210T 0x2009 UC-210T Ethernet product ATEN DSB650C 0x4000 DSB-650C From owner-svn-src-all@freebsd.org Tue Nov 17 19:51:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A534746DBB6; Tue, 17 Nov 2020 19:51:37 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbGm93bNLz3MZR; Tue, 17 Nov 2020 19:51:37 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id A13EB3C0199; Tue, 17 Nov 2020 19:51:36 +0000 (UTC) Date: Tue, 17 Nov 2020 19:51:36 +0000 From: Brooks Davis To: Kyle Evans Cc: src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367744 - in head/sys: compat/freebsd32 kern sys Message-ID: <20201117195136.GB1158@spindle.one-eyed-alien.net> References: <202011170336.0AH3awYt006482@repo.freebsd.org> <20201117171114.GA1158@spindle.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="uQr8t48UFsdbeI+V" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4CbGm93bNLz3MZR X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 19:51:37 -0000 --uQr8t48UFsdbeI+V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 17, 2020 at 11:59:50AM -0600, Kyle Evans wrote: > On Tue, Nov 17, 2020 at 11:11 AM Brooks Davis wrote: > > > > On Tue, Nov 17, 2020 at 03:36:58AM +0000, Kyle Evans wrote: > > > Modified: head/sys/compat/freebsd32/freebsd32.h > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > > --- head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:34:01 202= 0 (r367743) > > > +++ head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:36:58 202= 0 (r367744) > > > @@ -94,6 +94,27 @@ struct itimerval32 { > > > struct timeval32 it_value; > > > }; > > > > > > +struct umtx_time32 { > > > + struct timespec32 _timeout; > > > + uint32_t _flags; > > > + uint32_t _clockid; > > > +}; > > > + > > > +struct umtx_robust_lists_params_compat32 { > > > + uint32_t robust_list_offset; > > > + uint32_t robust_priv_list_offset; > > > + uint32_t robust_inact_offset; > > > +}; > > > + > > > +struct umutex32 { > > > + volatile __lwpid_t m_owner; /* Owner of the mutex */ > > > + __uint32_t m_flags; /* Flags of the mutex */ > > > + __uint32_t m_ceilings[2]; /* Priority protect cei= ling */ > > > + __uint32_t m_rb_lnk; /* Robust linkage */ > > > + __uint32_t m_pad; > > > + __uint32_t m_spare[2]; > > > +}; > > > + > > > #define FREEBSD4_MFSNAMELEN 16 > > > #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) > > > > > > > > > Modified: head/sys/compat/freebsd32/freebsd32_misc.c > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > > --- head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:3= 4:01 2020 (r367743) > > > +++ head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:3= 6:58 2020 (r367744) > > > @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -3764,4 +3765,12 @@ freebsd32_sched_rr_get_interval(struct thread = *td, > > > error =3D copyout(&ts32, uap->interval, sizeof(ts32)); > > > } > > > return (error); > > > +} > > > + > > > +int > > > +freebsd32__umtx_op(struct thread *td, struct freebsd32__umtx_op_args= *uap) > > > +{ > > > + > > > + return (kern__umtx_op(td, uap->obj, uap->op, uap->val, uap->uad= dr, > > > + uap->uaddr2, &umtx_native_ops32)); > > > } > > > > > > > Putting any of this under compat/freebsd32 seems like a somewhat > > odd choice since all the work is done in kern_umtx.h. In CheriBSD, > > everything just lives there so nothing has to be exposed in headers. > > >=20 > I have no strong opinion here -- my initial impression of the > suggestion to move the struct definitions into freebsd32 was that: >=20 > 1.) One can then quickly reference the definition of, e.g., timespec32 > when I'm looking at a umtx_time32, and > 2.) It'd be 'cleaner', requiring less #ifdef soup in kern_umtx.c >=20 > The follow-up patch muddies the waters a lot, as we end up using the > compat32 definitions on all 64-bit platforms anyways even without > compat32. I don't object to moving any/all of this back, if you think > that's better. (1) makes sense to me. I'm less convinced of (2) especially given the followup. As a rule, I've been removing compat bits from headers when they only need to be defined in a single .c file. If nothing else, I don't like that it presents a somewhat-false implication that the interfaces are public (and there have been quite a few cases where they weren't correctly guarded with _KERNEL). -- Brooks --uQr8t48UFsdbeI+V Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJftCnIAAoJEKzQXbSebgfANbsH/jvpZpsGATglpYvmk4Xldy3N CVw5ekoDOm3UqzaRC3wyYD1YENt74ePSzcoMZ9hrtCQyF6GkzEAt5LZMpT1eM/jI G/g9m2MmkVw02+PPgg971VMEZdIY9nHB5bMFxnlb0YUhExIWIhJhNPHnYUP3pkwf pVzzjVPM+kUY8dX6uMT5lckHeb9i9USvcKv0UMYQdx3cQ480+Ia29x52PyticZGf g/QSMcWbRSdWOlx9ZEbbZF+DZaGQFAXVY/kzE4rY/nZCfWF+hg8dSdlflkWRYhYW QP4dWwpSloYU39sjzzq7p8xuofBSSwq8+qM3QiDSJw7ljHurAZ4E3QaR19IGMfE= =JMLX -----END PGP SIGNATURE----- --uQr8t48UFsdbeI+V-- From owner-svn-src-all@freebsd.org Tue Nov 17 19:51:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C3AE546D665; Tue, 17 Nov 2020 19:51:49 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbGmP3z7dz3MkT; Tue, 17 Nov 2020 19:51:49 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6D587257AF; Tue, 17 Nov 2020 19:51:49 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHJpn4M015676; Tue, 17 Nov 2020 19:51:49 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHJplW4015667; Tue, 17 Nov 2020 19:51:47 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202011171951.0AHJplW4015667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 17 Nov 2020 19:51:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367773 - in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux kern sys X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux kern sys X-SVN-Commit-Revision: 367773 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 19:51:49 -0000 Author: cem Date: Tue Nov 17 19:51:47 2020 New Revision: 367773 URL: https://svnweb.freebsd.org/changeset/base/367773 Log: linux(4): Implement name_to_handle_at(), open_by_handle_at() They are similar to our getfhat(2) and fhopen(2) syscalls. Differential Revision: https://reviews.freebsd.org/D27111 Modified: head/sys/amd64/linux/syscalls.master head/sys/amd64/linux32/syscalls.master head/sys/arm64/linux/syscalls.master head/sys/compat/linux/linux_dummy.c head/sys/compat/linux/linux_file.c head/sys/compat/linux/linux_file.h head/sys/i386/linux/syscalls.master head/sys/kern/vfs_syscalls.c head/sys/sys/syscallsubr.h Modified: head/sys/amd64/linux/syscalls.master ============================================================================== --- head/sys/amd64/linux/syscalls.master Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/amd64/linux/syscalls.master Tue Nov 17 19:51:47 2020 (r367773) @@ -1792,10 +1792,20 @@ } ; Linux 2.6.39 (glibc 2.14): 303 AUE_NULL STD { - int linux_name_to_handle_at(void); + int linux_name_to_handle_at( + l_int dirfd, + const char *name, + struct l_file_handle *handle, + l_int *mnt_id, + l_int flags + ); } 304 AUE_NULL STD { - int linux_open_by_handle_at(void); + int linux_open_by_handle_at( + l_int mountdirfd, + struct l_file_handle *handle, + l_int flags + ); } 305 AUE_NULL STD { int linux_clock_adjtime(void); Modified: head/sys/amd64/linux32/syscalls.master ============================================================================== --- head/sys/amd64/linux32/syscalls.master Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/amd64/linux32/syscalls.master Tue Nov 17 19:51:47 2020 (r367773) @@ -1916,10 +1916,20 @@ } ; Linux 2.6.39: 341 AUE_NULL STD { - int linux_name_to_handle_at(void); + int linux_name_to_handle_at( + l_int dirfd, + const char *name, + struct l_file_handle *handle, + l_int *mnt_id, + l_int flags + ); } 342 AUE_NULL STD { - int linux_open_by_handle_at(void); + int linux_open_by_handle_at( + l_int mountdirfd, + struct l_file_handle *handle, + l_int flags + ); } 343 AUE_NULL STD { int linux_clock_adjtime(void); Modified: head/sys/arm64/linux/syscalls.master ============================================================================== --- head/sys/arm64/linux/syscalls.master Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/arm64/linux/syscalls.master Tue Nov 17 19:51:47 2020 (r367773) @@ -1473,10 +1473,20 @@ int linux_fanotify_mark(void); } 264 AUE_NULL STD { - int linux_name_to_handle_at(void); + int linux_name_to_handle_at( + l_int dirfd, + const char *name, + struct l_file_handle *handle, + l_int *mnt_id, + l_int flags + ); } 265 AUE_NULL STD { - int linux_open_by_handle_at(void); + int linux_open_by_handle_at( + l_int mountdirfd, + struct l_file_handle *handle, + l_int flags + ); } 266 AUE_NULL STD { int linux_clock_adjtime(void); Modified: head/sys/compat/linux/linux_dummy.c ============================================================================== --- head/sys/compat/linux/linux_dummy.c Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/compat/linux/linux_dummy.c Tue Nov 17 19:51:47 2020 (r367773) @@ -101,8 +101,6 @@ DUMMY(perf_event_open); DUMMY(fanotify_init); DUMMY(fanotify_mark); /* Linux 2.6.39: */ -DUMMY(name_to_handle_at); -DUMMY(open_by_handle_at); DUMMY(clock_adjtime); /* Linux 3.0: */ DUMMY(setns); Modified: head/sys/compat/linux/linux_file.c ============================================================================== --- head/sys/compat/linux/linux_file.c Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/compat/linux/linux_file.c Tue Nov 17 19:51:47 2020 (r367773) @@ -121,13 +121,9 @@ linux_creat(struct thread *td, struct linux_creat_args #endif static int -linux_common_open(struct thread *td, int dirfd, const char *path, int l_flags, - int mode, enum uio_seg seg) +linux_common_openflags(int l_flags) { - struct proc *p = td->td_proc; - struct file *fp; - int fd; - int bsd_flags, error; + int bsd_flags; bsd_flags = 0; switch (l_flags & LINUX_O_ACCMODE) { @@ -167,7 +163,19 @@ linux_common_open(struct thread *td, int dirfd, const if (l_flags & LINUX_O_DIRECTORY) bsd_flags |= O_DIRECTORY; /* XXX LINUX_O_NOATIME: unable to be easily implemented. */ + return (bsd_flags); +} +static int +linux_common_open(struct thread *td, int dirfd, const char *path, int l_flags, + int mode, enum uio_seg seg) +{ + struct proc *p = td->td_proc; + struct file *fp; + int fd; + int bsd_flags, error; + + bsd_flags = linux_common_openflags(l_flags); error = kern_openat(td, dirfd, path, seg, bsd_flags, mode); if (error != 0) { if (error == EMLINK) @@ -253,6 +261,102 @@ linux_open(struct thread *td, struct linux_open_args * return (error); } #endif + +int +linux_name_to_handle_at(struct thread *td, + struct linux_name_to_handle_at_args *args) +{ + static const l_int valid_flags = (LINUX_AT_SYMLINK_FOLLOW | + LINUX_AT_EMPTY_PATH); + static const l_uint fh_size = sizeof(fhandle_t); + + fhandle_t fh; + l_uint fh_bytes; + l_int mount_id; + int error, fd, bsd_flags; + + if (args->flags & ~valid_flags) + return (EINVAL); + if (args->flags & LINUX_AT_EMPTY_PATH) + /* XXX: not supported yet */ + return (EOPNOTSUPP); + + fd = args->dirfd; + if (fd == LINUX_AT_FDCWD) + fd = AT_FDCWD; + + bsd_flags = 0; + if (!(args->flags & LINUX_AT_SYMLINK_FOLLOW)) + bsd_flags |= AT_SYMLINK_NOFOLLOW; + + if (!LUSECONVPATH(td)) { + error = kern_getfhat(td, bsd_flags, fd, args->name, + UIO_USERSPACE, &fh, UIO_SYSSPACE); + } else { + char *path; + + LCONVPATH_AT(td, args->name, &path, 0, fd); + error = kern_getfhat(td, bsd_flags, fd, path, UIO_SYSSPACE, + &fh, UIO_SYSSPACE); + LFREEPATH(path); + } + if (error != 0) + return (error); + + /* Emit mount_id -- required before EOVERFLOW case. */ + mount_id = (fh.fh_fsid.val[0] ^ fh.fh_fsid.val[1]); + error = copyout(&mount_id, args->mnt_id, sizeof(mount_id)); + if (error != 0) + return (error); + + /* Check if there is room for handle. */ + error = copyin(&args->handle->handle_bytes, &fh_bytes, + sizeof(fh_bytes)); + if (error != 0) + return (error); + + if (fh_bytes < fh_size) { + error = copyout(&fh_size, &args->handle->handle_bytes, + sizeof(fh_size)); + if (error == 0) + error = EOVERFLOW; + return (error); + } + + /* Emit handle. */ + mount_id = 0; + /* + * We don't use handle_type for anything yet, but initialize a known + * value. + */ + error = copyout(&mount_id, &args->handle->handle_type, + sizeof(mount_id)); + if (error != 0) + return (error); + + error = copyout(&fh, &args->handle->f_handle, + sizeof(fh)); + return (error); +} + +int +linux_open_by_handle_at(struct thread *td, + struct linux_open_by_handle_at_args *args) +{ + l_uint fh_bytes; + int bsd_flags, error; + + error = copyin(&args->handle->handle_bytes, &fh_bytes, + sizeof(fh_bytes)); + if (error != 0) + return (error); + + if (fh_bytes < sizeof(fhandle_t)) + return (EINVAL); + + bsd_flags = linux_common_openflags(args->flags); + return (kern_fhopen(td, (void *)&args->handle->f_handle, bsd_flags)); +} int linux_lseek(struct thread *td, struct linux_lseek_args *args) Modified: head/sys/compat/linux/linux_file.h ============================================================================== --- head/sys/compat/linux/linux_file.h Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/compat/linux/linux_file.h Tue Nov 17 19:51:47 2020 (r367773) @@ -36,6 +36,7 @@ #define LINUX_AT_EACCESS 0x200 #define LINUX_AT_REMOVEDIR 0x200 #define LINUX_AT_SYMLINK_FOLLOW 0x400 +#define LINUX_AT_EMPTY_PATH 0x1000 /* * posix_fadvise advice @@ -173,5 +174,11 @@ #define LINUX_HUGETLB_FLAG_ENCODE_1GB (30 << LINUX_HUGETLB_FLAG_ENCODE_SHIFT) #define LINUX_HUGETLB_FLAG_ENCODE_2GB (31 << LINUX_HUGETLB_FLAG_ENCODE_SHIFT) #define LINUX_HUGETLB_FLAG_ENCODE_16GB (34U << LINUX_HUGETLB_FLAG_ENCODE_SHIFT) + +struct l_file_handle { + l_uint handle_bytes; + l_int handle_type; + unsigned char f_handle[0]; +}; #endif /* !_LINUX_FILE_H_ */ Modified: head/sys/i386/linux/syscalls.master ============================================================================== --- head/sys/i386/linux/syscalls.master Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/i386/linux/syscalls.master Tue Nov 17 19:51:47 2020 (r367773) @@ -1934,10 +1934,20 @@ } ; Linux 2.6.39: 341 AUE_NULL STD { - int linux_name_to_handle_at(void); + int linux_name_to_handle_at( + l_int dirfd, + const char *name, + struct l_file_handle *handle, + l_int *mnt_id, + l_int flags + ); } 342 AUE_NULL STD { - int linux_open_by_handle_at(void); + int linux_open_by_handle_at( + l_int mountdirfd, + struct l_file_handle *handle, + l_int flags + ); } 343 AUE_NULL STD { int linux_clock_adjtime(void); Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/kern/vfs_syscalls.c Tue Nov 17 19:51:47 2020 (r367773) @@ -105,8 +105,6 @@ static int vn_access(struct vnode *vp, int user_flags, struct thread *td); static int kern_fhlinkat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, fhandle_t *fhp); -static int kern_getfhat(struct thread *td, int flags, int fd, - const char *path, enum uio_seg pathseg, fhandle_t *fhp); static int kern_readlink_vp(struct vnode *vp, char *buf, enum uio_seg bufseg, size_t count, struct thread *td); static int kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, @@ -4315,7 +4313,7 @@ sys_lgetfh(struct thread *td, struct lgetfh_args *uap) { return (kern_getfhat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->fname, - UIO_USERSPACE, uap->fhp)); + UIO_USERSPACE, uap->fhp, UIO_USERSPACE)); } #ifndef _SYS_SYSPROTO_H_ @@ -4329,7 +4327,7 @@ sys_getfh(struct thread *td, struct getfh_args *uap) { return (kern_getfhat(td, 0, AT_FDCWD, uap->fname, UIO_USERSPACE, - uap->fhp)); + uap->fhp, UIO_USERSPACE)); } /* @@ -4355,12 +4353,12 @@ sys_getfhat(struct thread *td, struct getfhat_args *ua AT_RESOLVE_BENEATH)) != 0) return (EINVAL); return (kern_getfhat(td, uap->flags, uap->fd, uap->path, UIO_USERSPACE, - uap->fhp)); + uap->fhp, UIO_USERSPACE)); } -static int +int kern_getfhat(struct thread *td, int flags, int fd, const char *path, - enum uio_seg pathseg, fhandle_t *fhp) + enum uio_seg pathseg, fhandle_t *fhp, enum uio_seg fhseg) { struct nameidata nd; fhandle_t fh; @@ -4382,8 +4380,12 @@ kern_getfhat(struct thread *td, int flags, int fd, con fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VOP_VPTOFH(vp, &fh.fh_fid); vput(vp); - if (error == 0) - error = copyout(&fh, fhp, sizeof (fh)); + if (error == 0) { + if (fhseg == UIO_USERSPACE) + error = copyout(&fh, fhp, sizeof (fh)); + else + memcpy(fhp, &fh, sizeof(fh)); + } return (error); } @@ -4493,6 +4495,12 @@ struct fhopen_args { int sys_fhopen(struct thread *td, struct fhopen_args *uap) { + return (kern_fhopen(td, uap->u_fhp, uap->flags)); +} + +int +kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags) +{ struct mount *mp; struct vnode *vp; struct fhandle fhp; @@ -4504,11 +4512,11 @@ sys_fhopen(struct thread *td, struct fhopen_args *uap) if (error != 0) return (error); indx = -1; - fmode = FFLAGS(uap->flags); + fmode = FFLAGS(flags); /* why not allow a non-read/write open for our lockd? */ if (((fmode & (FREAD | FWRITE)) == 0) || (fmode & O_CREAT)) return (EINVAL); - error = copyin(uap->u_fhp, &fhp, sizeof(fhp)); + error = copyin(u_fhp, &fhp, sizeof(fhp)); if (error != 0) return(error); /* find the mount point */ Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Tue Nov 17 18:28:20 2020 (r367772) +++ head/sys/sys/syscallsubr.h Tue Nov 17 19:51:47 2020 (r367773) @@ -140,6 +140,7 @@ int kern_fchownat(struct thread *td, int fd, const cha enum uio_seg pathseg, int uid, int gid, int flag); int kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg); int kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg); +int kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags); int kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf); int kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf); int kern_fpathconf(struct thread *td, int fd, int name, long *valuep); @@ -153,6 +154,8 @@ int kern_futimens(struct thread *td, int fd, struct ti enum uio_seg tptrseg); int kern_getdirentries(struct thread *td, int fd, char *buf, size_t count, off_t *basep, ssize_t *residp, enum uio_seg bufseg); +int kern_getfhat(struct thread *td, int flags, int fd, const char *path, + enum uio_seg pathseg, fhandle_t *fhp, enum uio_seg fhseg); int kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, size_t *countp, enum uio_seg bufseg, int mode); int kern_getitimer(struct thread *, u_int, struct itimerval *); From owner-svn-src-all@freebsd.org Tue Nov 17 19:54:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AD1746DEDC; Tue, 17 Nov 2020 19:54:02 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbGpy35Gkz3MpG; Tue, 17 Nov 2020 19:54:02 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5CDA6257BD; Tue, 17 Nov 2020 19:54:02 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHJs2Nm017446; Tue, 17 Nov 2020 19:54:02 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHJrx29017430; Tue, 17 Nov 2020 19:53:59 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202011171953.0AHJrx29017430@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 17 Nov 2020 19:53:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367774 - in head/sys: amd64/linux amd64/linux32 arm64/linux i386/linux X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sys: amd64/linux amd64/linux32 arm64/linux i386/linux X-SVN-Commit-Revision: 367774 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 19:54:02 -0000 Author: cem Date: Tue Nov 17 19:53:59 2020 New Revision: 367774 URL: https://svnweb.freebsd.org/changeset/base/367774 Log: 'make sysent' for r367773 X-MFC-With: r367773 Modified: head/sys/amd64/linux/linux_proto.h head/sys/amd64/linux/linux_sysent.c head/sys/amd64/linux/linux_systrace_args.c head/sys/amd64/linux32/linux32_proto.h head/sys/amd64/linux32/linux32_sysent.c head/sys/amd64/linux32/linux32_systrace_args.c head/sys/arm64/linux/linux_proto.h head/sys/arm64/linux/linux_sysent.c head/sys/arm64/linux/linux_systrace_args.c head/sys/i386/linux/linux_proto.h head/sys/i386/linux/linux_sysent.c head/sys/i386/linux/linux_systrace_args.c Modified: head/sys/amd64/linux/linux_proto.h ============================================================================== --- head/sys/amd64/linux/linux_proto.h Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/amd64/linux/linux_proto.h Tue Nov 17 19:53:59 2020 (r367774) @@ -1143,10 +1143,16 @@ struct linux_prlimit64_args { char old_l_[PADL_(struct rlimit *)]; struct rlimit * old; char old_r_[PADR_(struct rlimit *)]; }; struct linux_name_to_handle_at_args { - register_t dummy; + char dirfd_l_[PADL_(l_int)]; l_int dirfd; char dirfd_r_[PADR_(l_int)]; + char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char mnt_id_l_[PADL_(l_int *)]; l_int * mnt_id; char mnt_id_r_[PADR_(l_int *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_open_by_handle_at_args { - register_t dummy; + char mountdirfd_l_[PADL_(l_int)]; l_int mountdirfd; char mountdirfd_r_[PADR_(l_int)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_clock_adjtime_args { register_t dummy; Modified: head/sys/amd64/linux/linux_sysent.c ============================================================================== --- head/sys/amd64/linux/linux_sysent.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/amd64/linux/linux_sysent.c Tue Nov 17 19:53:59 2020 (r367774) @@ -320,8 +320,8 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_init, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 300 = linux_fanotify_init */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_mark, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 301 = linux_fanotify_mark */ { .sy_narg = AS(linux_prlimit64_args), .sy_call = (sy_call_t *)linux_prlimit64, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 302 = linux_prlimit64 */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 303 = linux_name_to_handle_at */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 304 = linux_open_by_handle_at */ + { .sy_narg = AS(linux_name_to_handle_at_args), .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 303 = linux_name_to_handle_at */ + { .sy_narg = AS(linux_open_by_handle_at_args), .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 304 = linux_open_by_handle_at */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clock_adjtime, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 305 = linux_clock_adjtime */ { .sy_narg = AS(linux_syncfs_args), .sy_call = (sy_call_t *)linux_syncfs, .sy_auevent = AUE_SYNC, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 306 = linux_syncfs */ { .sy_narg = AS(linux_sendmmsg_args), .sy_call = (sy_call_t *)linux_sendmmsg, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 307 = linux_sendmmsg */ Modified: head/sys/amd64/linux/linux_systrace_args.c ============================================================================== --- head/sys/amd64/linux/linux_systrace_args.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/amd64/linux/linux_systrace_args.c Tue Nov 17 19:53:59 2020 (r367774) @@ -2321,12 +2321,22 @@ systrace_args(int sysnum, void *params, uint64_t *uarg } /* linux_name_to_handle_at */ case 303: { - *n_args = 0; + struct linux_name_to_handle_at_args *p = params; + iarg[0] = p->dirfd; /* l_int */ + uarg[1] = (intptr_t) p->name; /* const char * */ + uarg[2] = (intptr_t) p->handle; /* struct l_file_handle * */ + uarg[3] = (intptr_t) p->mnt_id; /* l_int * */ + iarg[4] = p->flags; /* l_int */ + *n_args = 5; break; } /* linux_open_by_handle_at */ case 304: { - *n_args = 0; + struct linux_open_by_handle_at_args *p = params; + iarg[0] = p->mountdirfd; /* l_int */ + uarg[1] = (intptr_t) p->handle; /* struct l_file_handle * */ + iarg[2] = p->flags; /* l_int */ + *n_args = 3; break; } /* linux_clock_adjtime */ @@ -6340,9 +6350,41 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; /* linux_name_to_handle_at */ case 303: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "userland struct l_file_handle *"; + break; + case 3: + p = "userland l_int *"; + break; + case 4: + p = "l_int"; + break; + default: + break; + }; break; /* linux_open_by_handle_at */ case 304: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland struct l_file_handle *"; + break; + case 2: + p = "l_int"; + break; + default: + break; + }; break; /* linux_clock_adjtime */ case 305: @@ -8153,8 +8195,14 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* linux_name_to_handle_at */ case 303: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_open_by_handle_at */ case 304: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_clock_adjtime */ case 305: /* linux_syncfs */ Modified: head/sys/amd64/linux32/linux32_proto.h ============================================================================== --- head/sys/amd64/linux32/linux32_proto.h Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/amd64/linux32/linux32_proto.h Tue Nov 17 19:53:59 2020 (r367774) @@ -1218,10 +1218,16 @@ struct linux_prlimit64_args { char old_l_[PADL_(struct rlimit *)]; struct rlimit * old; char old_r_[PADR_(struct rlimit *)]; }; struct linux_name_to_handle_at_args { - register_t dummy; + char dirfd_l_[PADL_(l_int)]; l_int dirfd; char dirfd_r_[PADR_(l_int)]; + char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char mnt_id_l_[PADL_(l_int *)]; l_int * mnt_id; char mnt_id_r_[PADR_(l_int *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_open_by_handle_at_args { - register_t dummy; + char mountdirfd_l_[PADL_(l_int)]; l_int mountdirfd; char mountdirfd_r_[PADR_(l_int)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_clock_adjtime_args { register_t dummy; Modified: head/sys/amd64/linux32/linux32_sysent.c ============================================================================== --- head/sys/amd64/linux32/linux32_sysent.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/amd64/linux32/linux32_sysent.c Tue Nov 17 19:53:59 2020 (r367774) @@ -358,8 +358,8 @@ struct sysent linux32_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_init, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 338 = linux_fanotify_init */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_mark, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 339 = linux_fanotify_mark */ { .sy_narg = AS(linux_prlimit64_args), .sy_call = (sy_call_t *)linux_prlimit64, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 340 = linux_prlimit64 */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 341 = linux_name_to_handle_at */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 342 = linux_open_by_handle_at */ + { .sy_narg = AS(linux_name_to_handle_at_args), .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 341 = linux_name_to_handle_at */ + { .sy_narg = AS(linux_open_by_handle_at_args), .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 342 = linux_open_by_handle_at */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clock_adjtime, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 343 = linux_clock_adjtime */ { .sy_narg = AS(linux_syncfs_args), .sy_call = (sy_call_t *)linux_syncfs, .sy_auevent = AUE_SYNC, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 344 = linux_syncfs */ { .sy_narg = AS(linux_sendmmsg_args), .sy_call = (sy_call_t *)linux_sendmmsg, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 345 = linux_sendmmsg */ Modified: head/sys/amd64/linux32/linux32_systrace_args.c ============================================================================== --- head/sys/amd64/linux32/linux32_systrace_args.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/amd64/linux32/linux32_systrace_args.c Tue Nov 17 19:53:59 2020 (r367774) @@ -2445,12 +2445,22 @@ systrace_args(int sysnum, void *params, uint64_t *uarg } /* linux_name_to_handle_at */ case 341: { - *n_args = 0; + struct linux_name_to_handle_at_args *p = params; + iarg[0] = p->dirfd; /* l_int */ + uarg[1] = (intptr_t) p->name; /* const char * */ + uarg[2] = (intptr_t) p->handle; /* struct l_file_handle * */ + uarg[3] = (intptr_t) p->mnt_id; /* l_int * */ + iarg[4] = p->flags; /* l_int */ + *n_args = 5; break; } /* linux_open_by_handle_at */ case 342: { - *n_args = 0; + struct linux_open_by_handle_at_args *p = params; + iarg[0] = p->mountdirfd; /* l_int */ + uarg[1] = (intptr_t) p->handle; /* struct l_file_handle * */ + iarg[2] = p->flags; /* l_int */ + *n_args = 3; break; } /* linux_clock_adjtime */ @@ -6970,9 +6980,41 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; /* linux_name_to_handle_at */ case 341: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "userland struct l_file_handle *"; + break; + case 3: + p = "userland l_int *"; + break; + case 4: + p = "l_int"; + break; + default: + break; + }; break; /* linux_open_by_handle_at */ case 342: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland struct l_file_handle *"; + break; + case 2: + p = "l_int"; + break; + default: + break; + }; break; /* linux_clock_adjtime */ case 343: @@ -9326,8 +9368,14 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* linux_name_to_handle_at */ case 341: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_open_by_handle_at */ case 342: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_clock_adjtime */ case 343: /* linux_syncfs */ Modified: head/sys/arm64/linux/linux_proto.h ============================================================================== --- head/sys/arm64/linux/linux_proto.h Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/arm64/linux/linux_proto.h Tue Nov 17 19:53:59 2020 (r367774) @@ -967,10 +967,16 @@ struct linux_fanotify_mark_args { register_t dummy; }; struct linux_name_to_handle_at_args { - register_t dummy; + char dirfd_l_[PADL_(l_int)]; l_int dirfd; char dirfd_r_[PADR_(l_int)]; + char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char mnt_id_l_[PADL_(l_int *)]; l_int * mnt_id; char mnt_id_r_[PADR_(l_int *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_open_by_handle_at_args { - register_t dummy; + char mountdirfd_l_[PADL_(l_int)]; l_int mountdirfd; char mountdirfd_r_[PADR_(l_int)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_clock_adjtime_args { register_t dummy; Modified: head/sys/arm64/linux/linux_sysent.c ============================================================================== --- head/sys/arm64/linux/linux_sysent.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/arm64/linux/linux_sysent.c Tue Nov 17 19:53:59 2020 (r367774) @@ -281,8 +281,8 @@ struct sysent linux_sysent[] = { { .sy_narg = AS(linux_prlimit64_args), .sy_call = (sy_call_t *)linux_prlimit64, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 261 = linux_prlimit64 */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_init, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 262 = linux_fanotify_init */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_mark, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 263 = linux_fanotify_mark */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 264 = linux_name_to_handle_at */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 265 = linux_open_by_handle_at */ + { .sy_narg = AS(linux_name_to_handle_at_args), .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 264 = linux_name_to_handle_at */ + { .sy_narg = AS(linux_open_by_handle_at_args), .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 265 = linux_open_by_handle_at */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clock_adjtime, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 266 = linux_clock_adjtime */ { .sy_narg = AS(linux_syncfs_args), .sy_call = (sy_call_t *)linux_syncfs, .sy_auevent = AUE_SYNC, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 267 = linux_syncfs */ { .sy_narg = AS(linux_setns_args), .sy_call = (sy_call_t *)linux_setns, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 268 = linux_setns */ Modified: head/sys/arm64/linux/linux_systrace_args.c ============================================================================== --- head/sys/arm64/linux/linux_systrace_args.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/arm64/linux/linux_systrace_args.c Tue Nov 17 19:53:59 2020 (r367774) @@ -1960,12 +1960,22 @@ systrace_args(int sysnum, void *params, uint64_t *uarg } /* linux_name_to_handle_at */ case 264: { - *n_args = 0; + struct linux_name_to_handle_at_args *p = params; + iarg[0] = p->dirfd; /* l_int */ + uarg[1] = (intptr_t) p->name; /* const char * */ + uarg[2] = (intptr_t) p->handle; /* struct l_file_handle * */ + uarg[3] = (intptr_t) p->mnt_id; /* l_int * */ + iarg[4] = p->flags; /* l_int */ + *n_args = 5; break; } /* linux_open_by_handle_at */ case 265: { - *n_args = 0; + struct linux_open_by_handle_at_args *p = params; + iarg[0] = p->mountdirfd; /* l_int */ + uarg[1] = (intptr_t) p->handle; /* struct l_file_handle * */ + iarg[2] = p->flags; /* l_int */ + *n_args = 3; break; } /* linux_clock_adjtime */ @@ -5408,9 +5418,41 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; /* linux_name_to_handle_at */ case 264: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "userland struct l_file_handle *"; + break; + case 3: + p = "userland l_int *"; + break; + case 4: + p = "l_int"; + break; + default: + break; + }; break; /* linux_open_by_handle_at */ case 265: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland struct l_file_handle *"; + break; + case 2: + p = "l_int"; + break; + default: + break; + }; break; /* linux_clock_adjtime */ case 266: @@ -6923,8 +6965,14 @@ systrace_return_setargdesc(int sysnum, int ndx, char * case 263: /* linux_name_to_handle_at */ case 264: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_open_by_handle_at */ case 265: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_clock_adjtime */ case 266: /* linux_syncfs */ Modified: head/sys/i386/linux/linux_proto.h ============================================================================== --- head/sys/i386/linux/linux_proto.h Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/i386/linux/linux_proto.h Tue Nov 17 19:53:59 2020 (r367774) @@ -1211,10 +1211,16 @@ struct linux_prlimit64_args { char old_l_[PADL_(struct rlimit *)]; struct rlimit * old; char old_r_[PADR_(struct rlimit *)]; }; struct linux_name_to_handle_at_args { - register_t dummy; + char dirfd_l_[PADL_(l_int)]; l_int dirfd; char dirfd_r_[PADR_(l_int)]; + char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char mnt_id_l_[PADL_(l_int *)]; l_int * mnt_id; char mnt_id_r_[PADR_(l_int *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_open_by_handle_at_args { - register_t dummy; + char mountdirfd_l_[PADL_(l_int)]; l_int mountdirfd; char mountdirfd_r_[PADR_(l_int)]; + char handle_l_[PADL_(struct l_file_handle *)]; struct l_file_handle * handle; char handle_r_[PADR_(struct l_file_handle *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_clock_adjtime_args { register_t dummy; Modified: head/sys/i386/linux/linux_sysent.c ============================================================================== --- head/sys/i386/linux/linux_sysent.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/i386/linux/linux_sysent.c Tue Nov 17 19:53:59 2020 (r367774) @@ -358,8 +358,8 @@ struct sysent linux_sysent[] = { { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_init, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 338 = linux_fanotify_init */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_fanotify_mark, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 339 = linux_fanotify_mark */ { .sy_narg = AS(linux_prlimit64_args), .sy_call = (sy_call_t *)linux_prlimit64, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 340 = linux_prlimit64 */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 341 = linux_name_to_handle_at */ - { .sy_narg = 0, .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 342 = linux_open_by_handle_at */ + { .sy_narg = AS(linux_name_to_handle_at_args), .sy_call = (sy_call_t *)linux_name_to_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 341 = linux_name_to_handle_at */ + { .sy_narg = AS(linux_open_by_handle_at_args), .sy_call = (sy_call_t *)linux_open_by_handle_at, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 342 = linux_open_by_handle_at */ { .sy_narg = 0, .sy_call = (sy_call_t *)linux_clock_adjtime, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 343 = linux_clock_adjtime */ { .sy_narg = AS(linux_syncfs_args), .sy_call = (sy_call_t *)linux_syncfs, .sy_auevent = AUE_SYNC, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 344 = linux_syncfs */ { .sy_narg = AS(linux_sendmmsg_args), .sy_call = (sy_call_t *)linux_sendmmsg, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 345 = linux_sendmmsg */ Modified: head/sys/i386/linux/linux_systrace_args.c ============================================================================== --- head/sys/i386/linux/linux_systrace_args.c Tue Nov 17 19:51:47 2020 (r367773) +++ head/sys/i386/linux/linux_systrace_args.c Tue Nov 17 19:53:59 2020 (r367774) @@ -2484,12 +2484,22 @@ systrace_args(int sysnum, void *params, uint64_t *uarg } /* linux_name_to_handle_at */ case 341: { - *n_args = 0; + struct linux_name_to_handle_at_args *p = params; + iarg[0] = p->dirfd; /* l_int */ + uarg[1] = (intptr_t) p->name; /* const char * */ + uarg[2] = (intptr_t) p->handle; /* struct l_file_handle * */ + uarg[3] = (intptr_t) p->mnt_id; /* l_int * */ + iarg[4] = p->flags; /* l_int */ + *n_args = 5; break; } /* linux_open_by_handle_at */ case 342: { - *n_args = 0; + struct linux_open_by_handle_at_args *p = params; + iarg[0] = p->mountdirfd; /* l_int */ + uarg[1] = (intptr_t) p->handle; /* struct l_file_handle * */ + iarg[2] = p->flags; /* l_int */ + *n_args = 3; break; } /* linux_clock_adjtime */ @@ -7047,9 +7057,41 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; /* linux_name_to_handle_at */ case 341: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "userland struct l_file_handle *"; + break; + case 3: + p = "userland l_int *"; + break; + case 4: + p = "l_int"; + break; + default: + break; + }; break; /* linux_open_by_handle_at */ case 342: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "userland struct l_file_handle *"; + break; + case 2: + p = "l_int"; + break; + default: + break; + }; break; /* linux_clock_adjtime */ case 343: @@ -9432,8 +9474,14 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* linux_name_to_handle_at */ case 341: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_open_by_handle_at */ case 342: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_clock_adjtime */ case 343: /* linux_syncfs */ From owner-svn-src-all@freebsd.org Tue Nov 17 19:56:48 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47D2246E002; Tue, 17 Nov 2020 19:56:48 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbGt81bBkz3NCV; Tue, 17 Nov 2020 19:56:48 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 295A925661; Tue, 17 Nov 2020 19:56:48 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHJumKh017644; Tue, 17 Nov 2020 19:56:48 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHJumRE017643; Tue, 17 Nov 2020 19:56:48 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202011171956.0AHJumRE017643@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 17 Nov 2020 19:56:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367775 - head/sys/compat/linprocfs X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/compat/linprocfs X-SVN-Commit-Revision: 367775 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 19:56:48 -0000 Author: cem Date: Tue Nov 17 19:56:47 2020 New Revision: 367775 URL: https://svnweb.freebsd.org/changeset/base/367775 Log: linprocfs(5): Add rudimentary /proc//mountinfo This is used by some Linux programs using filehandles (r367773) to locate the mountpoint for a given fsid. Differential Revision: https://reviews.freebsd.org/D27136 Modified: head/sys/compat/linprocfs/linprocfs.c Modified: head/sys/compat/linprocfs/linprocfs.c ============================================================================== --- head/sys/compat/linprocfs/linprocfs.c Tue Nov 17 19:53:59 2020 (r367774) +++ head/sys/compat/linprocfs/linprocfs.c Tue Nov 17 19:56:47 2020 (r367775) @@ -403,24 +403,85 @@ linprocfs_docpuinfo(PFS_FILL_ARGS) } #endif /* __i386__ || __amd64__ */ +static const char *path_slash_sys = "/sys"; +static const char *fstype_sysfs = "sysfs"; + +static int +_mtab_helper(const struct pfs_node *pn, const struct statfs *sp, + const char **mntfrom, const char **mntto, const char **fstype) +{ + /* determine device name */ + *mntfrom = sp->f_mntfromname; + + /* determine mount point */ + *mntto = sp->f_mntonname; + + /* determine fs type */ + *fstype = sp->f_fstypename; + if (strcmp(*fstype, pn->pn_info->pi_name) == 0) + *mntfrom = *fstype = "proc"; + else if (strcmp(*fstype, "procfs") == 0) + return (ECANCELED); + + if (strcmp(*fstype, "autofs") == 0) { + /* + * FreeBSD uses eg "map -hosts", whereas Linux + * expects just "-hosts". + */ + if (strncmp(*mntfrom, "map ", 4) == 0) + *mntfrom += 4; + } + + if (strcmp(*fstype, "linsysfs") == 0) { + *mntfrom = path_slash_sys; + *fstype = fstype_sysfs; + } else { + /* For Linux msdosfs is called vfat */ + if (strcmp(*fstype, "msdosfs") == 0) + *fstype = "vfat"; + } + return (0); +} + +static void +_sbuf_mntoptions_helper(struct sbuf *sb, uint64_t f_flags) +{ + sbuf_cat(sb, (f_flags & MNT_RDONLY) ? "ro" : "rw"); +#define ADD_OPTION(opt, name) \ + if (f_flags & (opt)) sbuf_cat(sb, "," name); + ADD_OPTION(MNT_SYNCHRONOUS, "sync"); + ADD_OPTION(MNT_NOEXEC, "noexec"); + ADD_OPTION(MNT_NOSUID, "nosuid"); + ADD_OPTION(MNT_UNION, "union"); + ADD_OPTION(MNT_ASYNC, "async"); + ADD_OPTION(MNT_SUIDDIR, "suiddir"); + ADD_OPTION(MNT_NOSYMFOLLOW, "nosymfollow"); + ADD_OPTION(MNT_NOATIME, "noatime"); +#undef ADD_OPTION +} + /* - * Filler function for proc/mtab + * Filler function for proc/mtab and proc//mounts. * - * This file doesn't exist in Linux' procfs, but is included here so + * /proc/mtab doesn't exist in Linux' procfs, but is included here so * users can symlink /compat/linux/etc/mtab to /proc/mtab */ static int linprocfs_domtab(PFS_FILL_ARGS) { struct nameidata nd; - const char *lep; - char *dlep, *flep, *mntto, *mntfrom, *fstype; + const char *lep, *mntto, *mntfrom, *fstype; + char *dlep, *flep; size_t lep_len; int error; struct statfs *buf, *sp; size_t count; /* resolve symlinks etc. in the emulation tree prefix */ + /* + * Ideally, this would use the current chroot rather than some + * hardcoded path. + */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, td); flep = NULL; error = namei(&nd); @@ -442,55 +503,112 @@ linprocfs_domtab(PFS_FILL_ARGS) } for (sp = buf; count > 0; sp++, count--) { - /* determine device name */ - mntfrom = sp->f_mntfromname; + error = _mtab_helper(pn, sp, &mntfrom, &mntto, &fstype); + if (error != 0) { + MPASS(error == ECANCELED); + continue; + } /* determine mount point */ - mntto = sp->f_mntonname; if (strncmp(mntto, lep, lep_len) == 0 && mntto[lep_len] == '/') mntto += lep_len; - /* determine fs type */ - fstype = sp->f_fstypename; - if (strcmp(fstype, pn->pn_info->pi_name) == 0) - mntfrom = fstype = "proc"; - else if (strcmp(fstype, "procfs") == 0) - continue; + sbuf_printf(sb, "%s %s %s ", mntfrom, mntto, fstype); + _sbuf_mntoptions_helper(sb, sp->f_flags); + /* a real Linux mtab will also show NFS options */ + sbuf_printf(sb, " 0 0\n"); + } - if (strcmp(fstype, "autofs") == 0) { - /* - * FreeBSD uses eg "map -hosts", whereas Linux - * expects just "-hosts". - */ - if (strncmp(mntfrom, "map ", 4) == 0) - mntfrom += 4; - } + free(buf, M_TEMP); + free(flep, M_TEMP); + return (error); +} - if (strcmp(fstype, "linsysfs") == 0) { - sbuf_printf(sb, "/sys %s sysfs %s", mntto, - sp->f_flags & MNT_RDONLY ? "ro" : "rw"); - } else { - /* For Linux msdosfs is called vfat */ - if (strcmp(fstype, "msdosfs") == 0) - fstype = "vfat"; - sbuf_printf(sb, "%s %s %s %s", mntfrom, mntto, fstype, - sp->f_flags & MNT_RDONLY ? "ro" : "rw"); +static int +linprocfs_doprocmountinfo(PFS_FILL_ARGS) +{ + struct nameidata nd; + const char *mntfrom, *mntto, *fstype; + const char *lep; + char *dlep, *flep; + struct statfs *buf, *sp; + size_t count, lep_len; + int error; + + /* + * Ideally, this would use the current chroot rather than some + * hardcoded path. + */ + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, td); + flep = NULL; + error = namei(&nd); + lep = linux_emul_path; + if (error == 0) { + if (vn_fullpath(nd.ni_vp, &dlep, &flep) == 0) + lep = dlep; + vrele(nd.ni_vp); + } + lep_len = strlen(lep); + + buf = NULL; + error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count, + UIO_SYSSPACE, MNT_WAIT); + if (error != 0) + goto out; + + for (sp = buf; count > 0; sp++, count--) { + error = _mtab_helper(pn, sp, &mntfrom, &mntto, &fstype); + if (error != 0) { + MPASS(error == ECANCELED); + continue; } -#define ADD_OPTION(opt, name) \ - if (sp->f_flags & (opt)) sbuf_printf(sb, "," name); - ADD_OPTION(MNT_SYNCHRONOUS, "sync"); - ADD_OPTION(MNT_NOEXEC, "noexec"); - ADD_OPTION(MNT_NOSUID, "nosuid"); - ADD_OPTION(MNT_UNION, "union"); - ADD_OPTION(MNT_ASYNC, "async"); - ADD_OPTION(MNT_SUIDDIR, "suiddir"); - ADD_OPTION(MNT_NOSYMFOLLOW, "nosymfollow"); - ADD_OPTION(MNT_NOATIME, "noatime"); -#undef ADD_OPTION - /* a real Linux mtab will also show NFS options */ - sbuf_printf(sb, " 0 0\n"); + + if (strncmp(mntto, lep, lep_len) == 0 && mntto[lep_len] == '/') + mntto += lep_len; +#if 0 + /* + * If the prefix is a chroot, and this mountpoint is not under + * the prefix, we should skip it. Leave it for now for + * consistency with procmtab above. + */ + else + continue; +#endif + + /* + * (1) mount id + * + * (2) parent mount id -- we don't have this cheaply, so + * provide a dummy value + * + * (3) major:minor -- ditto + * + * (4) root filesystem mount -- probably a namespaces thing + * + * (5) mountto path + */ + sbuf_printf(sb, "%u 0 0:0 / %s ", + sp->f_fsid.val[0] ^ sp->f_fsid.val[1], mntto); + /* (6) mount options */ + _sbuf_mntoptions_helper(sb, sp->f_flags); + /* + * (7) zero or more optional fields -- again, namespace related + * + * (8) End of variable length fields separator ("-") + * + * (9) fstype + * + * (10) mount from + * + * (11) "superblock" options -- like (6), but different + * semantics in Linux + */ + sbuf_printf(sb, " - %s %s %s\n", fstype, mntfrom, + (sp->f_flags & MNT_RDONLY) ? "ro" : "rw"); } + error = 0; +out: free(buf, M_TEMP); free(flep, M_TEMP); return (error); @@ -1889,6 +2007,8 @@ linprocfs_init(PFS_INIT_ARGS) NULL, NULL, NULL, PFS_RD | PFS_AUTODRAIN); pfs_create_file(dir, "mem", &linprocfs_doprocmem, procfs_attr_rw, &procfs_candebug, NULL, PFS_RDWR | PFS_RAW); + pfs_create_file(dir, "mountinfo", &linprocfs_doprocmountinfo, + NULL, NULL, NULL, PFS_RD); pfs_create_file(dir, "mounts", &linprocfs_domtab, NULL, NULL, NULL, PFS_RD); pfs_create_link(dir, "root", &linprocfs_doprocroot, From owner-svn-src-all@freebsd.org Tue Nov 17 20:01:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69C1F46DFC3; Tue, 17 Nov 2020 20:01:22 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbGzQ2Vtsz3NW3; Tue, 17 Nov 2020 20:01:22 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 48DD2257DA; Tue, 17 Nov 2020 20:01:22 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHK1MUr019407; Tue, 17 Nov 2020 20:01:22 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHK1Le8019403; Tue, 17 Nov 2020 20:01:21 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202011172001.0AHK1Le8019403@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 17 Nov 2020 20:01:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367776 - in head: share/man/man4 sys/compat/linux sys/kern sys/sys X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head: share/man/man4 sys/compat/linux sys/kern sys/sys X-SVN-Commit-Revision: 367776 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 20:01:22 -0000 Author: cem Date: Tue Nov 17 20:01:21 2020 New Revision: 367776 URL: https://svnweb.freebsd.org/changeset/base/367776 Log: unix(4): Enhance LOCAL_CREDS_PERSISTENT ABI As this ABI is still fresh (r367287), let's correct some mistakes now: - Version the structure to allow for future changes - Include sender's pid in control message structure - Use a distinct control message type from the cmsgcred / sockcred mess Discussed with: kib, markj, trasz Differential Revision: https://reviews.freebsd.org/D27084 Modified: head/share/man/man4/unix.4 head/sys/compat/linux/linux_socket.c head/sys/kern/uipc_usrreq.c head/sys/sys/socket.h Modified: head/share/man/man4/unix.4 ============================================================================== --- head/share/man/man4/unix.4 Tue Nov 17 19:56:47 2020 (r367775) +++ head/share/man/man4/unix.4 Tue Nov 17 20:01:21 2020 (r367776) @@ -28,7 +28,7 @@ .\" @(#)unix.4 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd November 2, 2020 +.Dd November 9, 2020 .Dt UNIX 4 .Os .Sh NAME @@ -295,6 +295,41 @@ except that socket credentials are passed on every rea or .Dv SOCK_SEQPACKET socket, instead of just the first read. +Additionally, the +.Va msg_control +field in the +.Vt msghdr +structure points to a buffer that contains a +.Vt cmsghdr +structure followed by a variable length +.Vt sockcred2 +structure, defined in +.In sys/socket.h +as follows: +.Bd -literal +struct sockcred2 { + int sc_version; /* version of this structure */ + pid_t sc_pid; /* PID of sending process */ + uid_t sc_uid; /* real user id */ + uid_t sc_euid; /* effective user id */ + gid_t sc_gid; /* real group id */ + gid_t sc_egid; /* effective group id */ + int sc_ngroups; /* number of supplemental groups */ + gid_t sc_groups[1]; /* variable length */ +}; +.Ed +.Pp +The current version is zero. +.Pp +The +.Vt cmsghdr +fields have the following values: +.Bd -literal +cmsg_len = CMSG_LEN(SOCKCRED2SIZE(ngroups)) +cmsg_level = SOL_SOCKET +cmsg_type = SCM_CREDS2 +.Ed +.Pp The .Dv LOCAL_CREDS and Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Tue Nov 17 19:56:47 2020 (r367775) +++ head/sys/compat/linux/linux_socket.c Tue Nov 17 20:01:21 2020 (r367776) @@ -644,6 +644,8 @@ bsd_to_linux_cmsg_type(int cmsg_type) return (LINUX_SCM_RIGHTS); case SCM_CREDS: return (LINUX_SCM_CREDENTIALS); + case SCM_CREDS2: + return (LINUX_SCM_CREDENTIALS); case SCM_TIMESTAMP: return (LINUX_SCM_TIMESTAMP); } @@ -1508,6 +1510,7 @@ linux_recvmsg_common(struct thread *td, l_int s, struc { struct cmsghdr *cm; struct cmsgcred *cmcred; + struct sockcred2 *scred; struct l_cmsghdr *linux_cmsg = NULL; struct l_ucred linux_ucred; socklen_t datalen, maxlen, outlen; @@ -1627,6 +1630,16 @@ linux_recvmsg_common(struct thread *td, l_int s, struc linux_ucred.pid = cmcred->cmcred_pid; linux_ucred.uid = cmcred->cmcred_uid; linux_ucred.gid = cmcred->cmcred_gid; + data = &linux_ucred; + datalen = sizeof(linux_ucred); + break; + + case SCM_CREDS2: + scred = data; + bzero(&linux_ucred, sizeof(linux_ucred)); + linux_ucred.pid = scred->sc_pid; + linux_ucred.uid = scred->sc_uid; + linux_ucred.gid = scred->sc_gid; data = &linux_ucred; datalen = sizeof(linux_ucred); break; Modified: head/sys/kern/uipc_usrreq.c ============================================================================== --- head/sys/kern/uipc_usrreq.c Tue Nov 17 19:56:47 2020 (r367775) +++ head/sys/kern/uipc_usrreq.c Tue Nov 17 20:01:21 2020 (r367776) @@ -308,7 +308,7 @@ static int unp_internalize(struct mbuf **, struct thre static void unp_internalize_fp(struct file *); static int unp_externalize(struct mbuf *, struct mbuf **, int); static int unp_externalize_fp(struct file *); -static struct mbuf *unp_addsockcred(struct thread *, struct mbuf *); +static struct mbuf *unp_addsockcred(struct thread *, struct mbuf *, int); static void unp_process_defers(void * __unused, int); static void @@ -1043,7 +1043,8 @@ uipc_send(struct socket *so, int flags, struct mbuf *m } if (unp2->unp_flags & UNP_WANTCRED_MASK) - control = unp_addsockcred(td, control); + control = unp_addsockcred(td, control, + unp2->unp_flags); if (unp->unp_addr != NULL) from = (struct sockaddr *)unp->unp_addr; else @@ -1102,8 +1103,8 @@ uipc_send(struct socket *so, int flags, struct mbuf *m * SOCK_SEQPACKET (LOCAL_CREDS => WANTCRED_ONESHOT), or * forever (LOCAL_CREDS_PERSISTENT => WANTCRED_ALWAYS). */ + control = unp_addsockcred(td, control, unp2->unp_flags); unp2->unp_flags &= ~UNP_WANTCRED_ONESHOT; - control = unp_addsockcred(td, control); } /* @@ -2383,34 +2384,58 @@ out: } static struct mbuf * -unp_addsockcred(struct thread *td, struct mbuf *control) +unp_addsockcred(struct thread *td, struct mbuf *control, int mode) { struct mbuf *m, *n, *n_prev; - struct sockcred *sc; const struct cmsghdr *cm; - int ngroups; - int i; + int ngroups, i, cmsgtype; + size_t ctrlsz; ngroups = MIN(td->td_ucred->cr_ngroups, CMGROUP_MAX); - m = sbcreatecontrol(NULL, SOCKCREDSIZE(ngroups), SCM_CREDS, SOL_SOCKET); + if (mode & UNP_WANTCRED_ALWAYS) { + ctrlsz = SOCKCRED2SIZE(ngroups); + cmsgtype = SCM_CREDS2; + } else { + ctrlsz = SOCKCREDSIZE(ngroups); + cmsgtype = SCM_CREDS; + } + + m = sbcreatecontrol(NULL, ctrlsz, cmsgtype, SOL_SOCKET); if (m == NULL) return (control); - sc = (struct sockcred *) CMSG_DATA(mtod(m, struct cmsghdr *)); - sc->sc_uid = td->td_ucred->cr_ruid; - sc->sc_euid = td->td_ucred->cr_uid; - sc->sc_gid = td->td_ucred->cr_rgid; - sc->sc_egid = td->td_ucred->cr_gid; - sc->sc_ngroups = ngroups; - for (i = 0; i < sc->sc_ngroups; i++) - sc->sc_groups[i] = td->td_ucred->cr_groups[i]; + if (mode & UNP_WANTCRED_ALWAYS) { + struct sockcred2 *sc; + sc = (void *)CMSG_DATA(mtod(m, struct cmsghdr *)); + sc->sc_version = 0; + sc->sc_pid = td->td_proc->p_pid; + sc->sc_uid = td->td_ucred->cr_ruid; + sc->sc_euid = td->td_ucred->cr_uid; + sc->sc_gid = td->td_ucred->cr_rgid; + sc->sc_egid = td->td_ucred->cr_gid; + sc->sc_ngroups = ngroups; + for (i = 0; i < sc->sc_ngroups; i++) + sc->sc_groups[i] = td->td_ucred->cr_groups[i]; + } else { + struct sockcred *sc; + + sc = (void *)CMSG_DATA(mtod(m, struct cmsghdr *)); + sc->sc_uid = td->td_ucred->cr_ruid; + sc->sc_euid = td->td_ucred->cr_uid; + sc->sc_gid = td->td_ucred->cr_rgid; + sc->sc_egid = td->td_ucred->cr_gid; + sc->sc_ngroups = ngroups; + for (i = 0; i < sc->sc_ngroups; i++) + sc->sc_groups[i] = td->td_ucred->cr_groups[i]; + } + /* * Unlink SCM_CREDS control messages (struct cmsgcred), since just * created SCM_CREDS control message (struct sockcred) has another * format. */ - if (control != NULL) + if (control != NULL && cmsgtype == SCM_CREDS) for (n = control, n_prev = NULL; n != NULL;) { cm = mtod(n, struct cmsghdr *); if (cm->cmsg_level == SOL_SOCKET && Modified: head/sys/sys/socket.h ============================================================================== --- head/sys/sys/socket.h Tue Nov 17 19:56:47 2020 (r367775) +++ head/sys/sys/socket.h Tue Nov 17 20:01:21 2020 (r367776) @@ -510,7 +510,7 @@ struct cmsgcred { }; /* - * Socket credentials. + * Socket credentials (LOCAL_CREDS). */ struct sockcred { uid_t sc_uid; /* real user id */ @@ -527,6 +527,22 @@ struct sockcred { #define SOCKCREDSIZE(ngrps) \ (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1))) +/* + * Socket credentials (LOCAL_CREDS_PERSISTENT). + */ +struct sockcred2 { + int sc_version; /* version of this structure */ + pid_t sc_pid; /* PID of sending process */ + uid_t sc_uid; /* real user id */ + uid_t sc_euid; /* effective user id */ + gid_t sc_gid; /* real group id */ + gid_t sc_egid; /* effective group id */ + int sc_ngroups; /* number of supplemental groups */ + gid_t sc_groups[1]; /* variable length */ +}; +#define SOCKCRED2SIZE(ngrps) \ + (sizeof(struct sockcred2) + (sizeof(gid_t) * ((ngrps) - 1))) + #endif /* __BSD_VISIBLE */ /* given pointer to struct cmsghdr, return pointer to data */ @@ -571,6 +587,7 @@ struct sockcred { #define SCM_REALTIME 0x05 /* timestamp (struct timespec) */ #define SCM_MONOTONIC 0x06 /* timestamp (struct timespec) */ #define SCM_TIME_INFO 0x07 /* timestamp info */ +#define SCM_CREDS2 0x08 /* process creds (struct sockcred2) */ struct sock_timestamp_info { __uint32_t st_info_flags; From owner-svn-src-all@freebsd.org Tue Nov 17 21:14:17 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 55F5246F233; Tue, 17 Nov 2020 21:14:17 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbJbY1kyQz3hfB; Tue, 17 Nov 2020 21:14:17 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2E840264DE; Tue, 17 Nov 2020 21:14:17 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHLEHDv068088; Tue, 17 Nov 2020 21:14:17 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHLEE7v068072; Tue, 17 Nov 2020 21:14:14 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202011172114.0AHLEE7v068072@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 17 Nov 2020 21:14:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367777 - in head: lib/libkvm lib/libprocstat sys/compat/cloudabi sys/fs/fuse sys/fs/unionfs sys/kern sys/sys X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head: lib/libkvm lib/libprocstat sys/compat/cloudabi sys/fs/fuse sys/fs/unionfs sys/kern sys/sys X-SVN-Commit-Revision: 367777 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 21:14:17 -0000 Author: cem Date: Tue Nov 17 21:14:13 2020 New Revision: 367777 URL: https://svnweb.freebsd.org/changeset/base/367777 Log: Split out cwd/root/jail, cmask state from filedesc table No functional change intended. Tracking these structures separately for each proc enables future work to correctly emulate clone(2) in linux(4). __FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof. Reviewed by: kib Discussed with: markj, mjg Differential Revision: https://reviews.freebsd.org/D27037 Modified: head/lib/libkvm/kvm_proc.c head/lib/libprocstat/libprocstat.c head/sys/compat/cloudabi/cloudabi_file.c head/sys/fs/fuse/fuse_internal.c head/sys/fs/fuse/fuse_vnops.c head/sys/fs/unionfs/union_subr.c head/sys/kern/imgact_elf.c head/sys/kern/init_main.c head/sys/kern/kern_descrip.c head/sys/kern/kern_exec.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_proc.c head/sys/kern/kern_thread.c head/sys/kern/uipc_mqueue.c head/sys/kern/uipc_sem.c head/sys/kern/uipc_shm.c head/sys/kern/uipc_usrreq.c head/sys/kern/vfs_syscalls.c head/sys/sys/filedesc.h head/sys/sys/param.h head/sys/sys/proc.h head/sys/sys/user.h Modified: head/lib/libkvm/kvm_proc.c ============================================================================== --- head/lib/libkvm/kvm_proc.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/lib/libkvm/kvm_proc.c Tue Nov 17 21:14:13 2020 (r367777) @@ -221,6 +221,7 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc kp->ki_tracep = proc.p_tracevp; kp->ki_textvp = proc.p_textvp; kp->ki_fd = proc.p_fd; + kp->ki_pd = proc.p_pd; kp->ki_vmspace = proc.p_vmspace; if (proc.p_sigacts != NULL) { if (KREAD(kd, (u_long)proc.p_sigacts, &sigacts)) { Modified: head/lib/libprocstat/libprocstat.c ============================================================================== --- head/lib/libprocstat/libprocstat.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/lib/libprocstat/libprocstat.c Tue Nov 17 21:14:13 2020 (r367777) @@ -460,6 +460,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struc { struct file file; struct filedesc filed; + struct pwddesc pathsd; struct fdescenttbl *fdt; struct pwd pwd; unsigned long pwd_addr; @@ -484,15 +485,20 @@ procstat_getfiles_kvm(struct procstat *procstat, struc kd = procstat->kd; if (kd == NULL) return (NULL); - if (kp->ki_fd == NULL) + if (kp->ki_fd == NULL || kp->ki_pd == NULL) return (NULL); if (!kvm_read_all(kd, (unsigned long)kp->ki_fd, &filed, sizeof(filed))) { warnx("can't read filedesc at %p", (void *)kp->ki_fd); return (NULL); } + if (!kvm_read_all(kd, (unsigned long)kp->ki_pd, &pathsd, + sizeof(pathsd))) { + warnx("can't read pwddesc at %p", (void *)kp->ki_pd); + return (NULL); + } haspwd = false; - pwd_addr = (unsigned long)(FILEDESC_KVM_LOAD_PWD(&filed)); + pwd_addr = (unsigned long)(PWDDESC_KVM_LOAD_PWD(&pathsd)); if (pwd_addr != 0) { if (!kvm_read_all(kd, pwd_addr, &pwd, sizeof(pwd))) { warnx("can't read fd_pwd at %p", (void *)pwd_addr); @@ -2086,18 +2092,18 @@ procstat_freegroups(struct procstat *procstat __unused static int procstat_getumask_kvm(kvm_t *kd, struct kinfo_proc *kp, unsigned short *maskp) { - struct filedesc fd; + struct pwddesc pd; assert(kd != NULL); assert(kp != NULL); - if (kp->ki_fd == NULL) + if (kp->ki_pd == NULL) return (-1); - if (!kvm_read_all(kd, (unsigned long)kp->ki_fd, &fd, sizeof(fd))) { - warnx("can't read filedesc at %p for pid %d", kp->ki_fd, + if (!kvm_read_all(kd, (unsigned long)kp->ki_pd, &pd, sizeof(pd))) { + warnx("can't read pwddesc at %p for pid %d", kp->ki_pd, kp->ki_pid); return (-1); } - *maskp = fd.fd_cmask; + *maskp = pd.pd_cmask; return (0); } Modified: head/sys/compat/cloudabi/cloudabi_file.c ============================================================================== --- head/sys/compat/cloudabi/cloudabi_file.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/compat/cloudabi/cloudabi_file.c Tue Nov 17 21:14:13 2020 (r367777) @@ -265,7 +265,7 @@ cloudabi_sys_file_open(struct thread *td, } NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, uap->dirfd.fd, &rights, td); - error = vn_open(&nd, &fflags, 0777 & ~td->td_proc->p_fd->fd_cmask, fp); + error = vn_open(&nd, &fflags, 0777 & ~td->td_proc->p_pd->pd_cmask, fp); cloudabi_freestr(path); if (error != 0) { /* Custom operations provided. */ Modified: head/sys/fs/fuse/fuse_internal.c ============================================================================== --- head/sys/fs/fuse/fuse_internal.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/fs/fuse/fuse_internal.c Tue Nov 17 21:14:13 2020 (r367777) @@ -497,7 +497,7 @@ fuse_internal_mknod(struct vnode *dvp, struct vnode ** fmni.rdev = vap->va_rdev; if (fuse_libabi_geq(data, 7, 12)) { insize = sizeof(fmni); - fmni.umask = curthread->td_proc->p_fd->fd_cmask; + fmni.umask = curthread->td_proc->p_pd->pd_cmask; } else { insize = FUSE_COMPAT_MKNOD_IN_SIZE; } Modified: head/sys/fs/fuse/fuse_vnops.c ============================================================================== --- head/sys/fs/fuse/fuse_vnops.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/fs/fuse/fuse_vnops.c Tue Nov 17 21:14:13 2020 (r367777) @@ -668,7 +668,7 @@ fuse_vnop_create(struct vop_create_args *ap) fci->flags = O_CREAT | flags; if (fuse_libabi_geq(data, 7, 12)) { insize = sizeof(*fci); - fci->umask = td->td_proc->p_fd->fd_cmask; + fci->umask = td->td_proc->p_pd->pd_cmask; } else { insize = sizeof(struct fuse_open_in); } @@ -1269,7 +1269,7 @@ fuse_vnop_mkdir(struct vop_mkdir_args *ap) return ENXIO; } fmdi.mode = MAKEIMODE(vap->va_type, vap->va_mode); - fmdi.umask = curthread->td_proc->p_fd->fd_cmask; + fmdi.umask = curthread->td_proc->p_pd->pd_cmask; return (fuse_internal_newentry(dvp, vpp, cnp, FUSE_MKDIR, &fmdi, sizeof(fmdi), VDIR)); Modified: head/sys/fs/unionfs/union_subr.c ============================================================================== --- head/sys/fs/unionfs/union_subr.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/fs/unionfs/union_subr.c Tue Nov 17 21:14:13 2020 (r367777) @@ -486,7 +486,7 @@ unionfs_create_uppervattr_core(struct unionfs_mount *u } break; default: /* UNIONFS_TRADITIONAL */ - uva->va_mode = 0777 & ~td->td_proc->p_fd->fd_cmask; + uva->va_mode = 0777 & ~td->td_proc->p_pd->pd_cmask; uva->va_uid = ump->um_uid; uva->va_gid = ump->um_gid; break; Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/imgact_elf.c Tue Nov 17 21:14:13 2020 (r367777) @@ -2507,12 +2507,12 @@ note_procstat_umask(void *arg, struct sbuf *sb, size_t int structsize; p = (struct proc *)arg; - size = sizeof(structsize) + sizeof(p->p_fd->fd_cmask); + size = sizeof(structsize) + sizeof(p->p_pd->pd_cmask); if (sb != NULL) { KASSERT(*sizep == size, ("invalid size")); - structsize = sizeof(p->p_fd->fd_cmask); + structsize = sizeof(p->p_pd->pd_cmask); sbuf_bcat(sb, &structsize, sizeof(structsize)); - sbuf_bcat(sb, &p->p_fd->fd_cmask, sizeof(p->p_fd->fd_cmask)); + sbuf_bcat(sb, &p->p_pd->pd_cmask, sizeof(p->p_pd->pd_cmask)); } *sizep = size; } Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/init_main.c Tue Nov 17 21:14:13 2020 (r367777) @@ -555,6 +555,7 @@ proc0_init(void *dummy __unused) siginit(&proc0); /* Create the file descriptor table. */ + p->p_pd = pdinit(NULL, false); p->p_fd = fdinit(NULL, false, NULL); p->p_fdtol = NULL; Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/kern_descrip.c Tue Nov 17 21:14:13 2020 (r367777) @@ -93,6 +93,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_FILEDESC, "filedesc", "Open file descriptor table"); static MALLOC_DEFINE(M_PWD, "pwd", "Descriptor table vnodes"); +static MALLOC_DEFINE(M_PWDDESC, "pwddesc", "Pwd descriptors"); static MALLOC_DEFINE(M_FILEDESC_TO_LEADER, "filedesc_to_leader", "file desc to leader structures"); static MALLOC_DEFINE(M_SIGIO, "sigio", "sigio structures"); @@ -2029,7 +2030,6 @@ finstall(struct thread *td, struct file *fp, int *fd, /* * Build a new filedesc structure from another. - * Copy the current, root, and jail root vnode references. * * If fdp is not NULL, return with it shared locked. */ @@ -2038,7 +2038,6 @@ fdinit(struct filedesc *fdp, bool prepfiles, int *last { struct filedesc0 *newfdp0; struct filedesc *newfdp; - struct pwd *newpwd; if (prepfiles) MPASS(lastfile != NULL); @@ -2052,20 +2051,14 @@ fdinit(struct filedesc *fdp, bool prepfiles, int *last FILEDESC_LOCK_INIT(newfdp); refcount_init(&newfdp->fd_refcnt, 1); refcount_init(&newfdp->fd_holdcnt, 1); - newfdp->fd_cmask = CMASK; newfdp->fd_map = newfdp0->fd_dmap; newfdp->fd_files = (struct fdescenttbl *)&newfdp0->fd_dfiles; newfdp->fd_files->fdt_nfiles = NDFILE; - if (fdp == NULL) { - newpwd = pwd_alloc(); - smr_serialized_store(&newfdp->fd_pwd, newpwd, true); + if (fdp == NULL) return (newfdp); - } FILEDESC_SLOCK(fdp); - newpwd = pwd_hold_filedesc(fdp); - smr_serialized_store(&newfdp->fd_pwd, newpwd, true); if (!prepfiles) { FILEDESC_SUNLOCK(fdp); return (newfdp); @@ -2083,6 +2076,38 @@ fdinit(struct filedesc *fdp, bool prepfiles, int *last return (newfdp); } +/* + * Build a pwddesc structure from another. + * Copy the current, root, and jail root vnode references. + * + * If pdp is not NULL, return with it shared locked. + */ +struct pwddesc * +pdinit(struct pwddesc *pdp, bool keeplock) +{ + struct pwddesc *newpdp; + struct pwd *newpwd; + + newpdp = malloc(sizeof(*newpdp), M_PWDDESC, M_WAITOK | M_ZERO); + + PWDDESC_LOCK_INIT(newpdp); + refcount_init(&newpdp->pd_refcount, 1); + newpdp->pd_cmask = CMASK; + + if (pdp == NULL) { + newpwd = pwd_alloc(); + smr_serialized_store(&newpdp->pd_pwd, newpwd, true); + return (newpdp); + } + + PWDDESC_XLOCK(pdp); + newpwd = pwd_hold_pwddesc(pdp); + smr_serialized_store(&newpdp->pd_pwd, newpwd, true); + if (!keeplock) + PWDDESC_XUNLOCK(pdp); + return (newpdp); +} + static struct filedesc * fdhold(struct proc *p) { @@ -2095,6 +2120,18 @@ fdhold(struct proc *p) return (fdp); } +static struct pwddesc * +pdhold(struct proc *p) +{ + struct pwddesc *pdp; + + PROC_LOCK_ASSERT(p, MA_OWNED); + pdp = p->p_pd; + if (pdp != NULL) + refcount_acquire(&pdp->pd_refcount); + return (pdp); +} + static void fddrop(struct filedesc *fdp) { @@ -2108,6 +2145,28 @@ fddrop(struct filedesc *fdp) uma_zfree(filedesc0_zone, fdp); } +static void +pddrop(struct pwddesc *pdp) +{ + struct pwd *pwd; + + if (refcount_release_if_not_last(&pdp->pd_refcount)) + return; + + PWDDESC_XLOCK(pdp); + if (refcount_release(&pdp->pd_refcount) == 0) { + PWDDESC_XUNLOCK(pdp); + return; + } + pwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); + pwd_set(pdp, NULL); + PWDDESC_XUNLOCK(pdp); + pwd_drop(pwd); + + PWDDESC_LOCK_DESTROY(pdp); + free(pdp, M_PWDDESC); +} + /* * Share a filedesc structure. */ @@ -2120,6 +2179,16 @@ fdshare(struct filedesc *fdp) } /* + * Share a pwddesc structure. + */ +struct pwddesc * +pdshare(struct pwddesc *pdp) +{ + refcount_acquire(&pdp->pd_refcount); + return (pdp); +} + +/* * Unshare a filedesc structure, if necessary by making a copy */ void @@ -2136,7 +2205,26 @@ fdunshare(struct thread *td) p->p_fd = tmp; } +/* + * Unshare a pwddesc structure. + */ void +pdunshare(struct thread *td) +{ + struct pwddesc *pdp; + struct proc *p; + + p = td->td_proc; + /* Not shared. */ + if (p->p_pd->pd_refcount == 1) + return; + + pdp = pdcopy(p->p_pd); + pdescfree(td); + p->p_pd = pdp; +} + +void fdinstall_remapped(struct thread *td, struct filedesc *fdp) { @@ -2176,12 +2264,27 @@ fdcopy(struct filedesc *fdp) } if (newfdp->fd_freefile == -1) newfdp->fd_freefile = i; - newfdp->fd_cmask = fdp->fd_cmask; FILEDESC_SUNLOCK(fdp); return (newfdp); } /* + * Copy a pwddesc structure. + */ +struct pwddesc * +pdcopy(struct pwddesc *pdp) +{ + struct pwddesc *newpdp; + + MPASS(pdp != NULL); + + newpdp = pdinit(pdp, true); + newpdp->pd_cmask = pdp->pd_cmask; + PWDDESC_XUNLOCK(pdp); + return (newpdp); +} + +/* * Copies a filedesc structure, while remapping all file descriptors * stored inside using a translation table. * @@ -2232,7 +2335,6 @@ fdcopy_remapped(struct filedesc *fdp, const int *fds, filecaps_copy(&ofde->fde_caps, &nfde->fde_caps, true); fdused_init(newfdp, i); } - newfdp->fd_cmask = fdp->fd_cmask; FILEDESC_SUNLOCK(fdp); *ret = newfdp; return (0); @@ -2366,7 +2468,6 @@ fdescfree(struct thread *td) { struct proc *p; struct filedesc *fdp; - struct pwd *pwd; p = td->td_proc; fdp = p->p_fd; @@ -2387,21 +2488,29 @@ fdescfree(struct thread *td) if (refcount_release(&fdp->fd_refcnt) == 0) return; - FILEDESC_XLOCK(fdp); - pwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); - pwd_set(fdp, NULL); - FILEDESC_XUNLOCK(fdp); + fdescfree_fds(td, fdp, 1); +} - pwd_drop(pwd); +void +pdescfree(struct thread *td) +{ + struct proc *p; + struct pwddesc *pdp; - fdescfree_fds(td, fdp, 1); + p = td->td_proc; + pdp = p->p_pd; + MPASS(pdp != NULL); + + PROC_LOCK(p); + p->p_pd = NULL; + PROC_UNLOCK(p); + + pddrop(pdp); } void fdescfree_remapped(struct filedesc *fdp) { - - pwd_drop(smr_serialized_load(&fdp->fd_pwd, true)); fdescfree_fds(curthread, fdp, 0); } @@ -3452,12 +3561,12 @@ pwd_fill(struct pwd *oldpwd, struct pwd *newpwd) } struct pwd * -pwd_hold_filedesc(struct filedesc *fdp) +pwd_hold_pwddesc(struct pwddesc *pdp) { struct pwd *pwd; - FILEDESC_LOCK_ASSERT(fdp); - pwd = FILEDESC_LOCKED_LOAD_PWD(fdp); + PWDDESC_ASSERT_XLOCKED(pdp); + pwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); if (pwd != NULL) refcount_acquire(&pwd->pwd_refcount); return (pwd); @@ -3477,22 +3586,22 @@ pwd_hold_smr(struct pwd *pwd) struct pwd * pwd_hold(struct thread *td) { - struct filedesc *fdp; + struct pwddesc *pdp; struct pwd *pwd; - fdp = td->td_proc->p_fd; + pdp = td->td_proc->p_pd; vfs_smr_enter(); - pwd = vfs_smr_entered_load(&fdp->fd_pwd); + pwd = vfs_smr_entered_load(&pdp->pd_pwd); if (pwd_hold_smr(pwd)) { vfs_smr_exit(); return (pwd); } vfs_smr_exit(); - FILEDESC_SLOCK(fdp); - pwd = pwd_hold_filedesc(fdp); + PWDDESC_XLOCK(pdp); + pwd = pwd_hold_pwddesc(pdp); MPASS(pwd != NULL); - FILEDESC_SUNLOCK(fdp); + PWDDESC_XUNLOCK(pdp); return (pwd); } @@ -3501,7 +3610,7 @@ pwd_get_smr(void) { struct pwd *pwd; - pwd = vfs_smr_entered_load(&curproc->p_fd->fd_pwd); + pwd = vfs_smr_entered_load(&curproc->p_pd->pd_pwd); MPASS(pwd != NULL); return (pwd); } @@ -3541,23 +3650,29 @@ pwd_drop(struct pwd *pwd) int pwd_chroot(struct thread *td, struct vnode *vp) { + struct pwddesc *pdp; struct filedesc *fdp; struct pwd *newpwd, *oldpwd; int error; fdp = td->td_proc->p_fd; + pdp = td->td_proc->p_pd; newpwd = pwd_alloc(); - FILEDESC_XLOCK(fdp); - oldpwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); + FILEDESC_SLOCK(fdp); + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); if (chroot_allow_open_directories == 0 || (chroot_allow_open_directories == 1 && oldpwd->pwd_rdir != rootvnode)) { error = chroot_refuse_vdir_fds(fdp); + FILEDESC_SUNLOCK(fdp); if (error != 0) { - FILEDESC_XUNLOCK(fdp); + PWDDESC_XUNLOCK(pdp); pwd_drop(newpwd); return (error); } + } else { + FILEDESC_SUNLOCK(fdp); } vrefact(vp); @@ -3567,8 +3682,8 @@ pwd_chroot(struct thread *td, struct vnode *vp) newpwd->pwd_jdir = vp; } pwd_fill(oldpwd, newpwd); - pwd_set(fdp, newpwd); - FILEDESC_XUNLOCK(fdp); + pwd_set(pdp, newpwd); + PWDDESC_XUNLOCK(pdp); pwd_drop(oldpwd); return (0); } @@ -3576,40 +3691,40 @@ pwd_chroot(struct thread *td, struct vnode *vp) void pwd_chdir(struct thread *td, struct vnode *vp) { - struct filedesc *fdp; + struct pwddesc *pdp; struct pwd *newpwd, *oldpwd; VNPASS(vp->v_usecount > 0, vp); newpwd = pwd_alloc(); - fdp = td->td_proc->p_fd; - FILEDESC_XLOCK(fdp); - oldpwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); + pdp = td->td_proc->p_pd; + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); newpwd->pwd_cdir = vp; pwd_fill(oldpwd, newpwd); - pwd_set(fdp, newpwd); - FILEDESC_XUNLOCK(fdp); + pwd_set(pdp, newpwd); + PWDDESC_XUNLOCK(pdp); pwd_drop(oldpwd); } void pwd_ensure_dirs(void) { - struct filedesc *fdp; + struct pwddesc *pdp; struct pwd *oldpwd, *newpwd; - fdp = curproc->p_fd; - FILEDESC_XLOCK(fdp); - oldpwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); + pdp = curproc->p_pd; + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); if (oldpwd->pwd_cdir != NULL && oldpwd->pwd_rdir != NULL) { - FILEDESC_XUNLOCK(fdp); + PWDDESC_XUNLOCK(pdp); return; } - FILEDESC_XUNLOCK(fdp); + PWDDESC_XUNLOCK(pdp); newpwd = pwd_alloc(); - FILEDESC_XLOCK(fdp); - oldpwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); pwd_fill(oldpwd, newpwd); if (newpwd->pwd_cdir == NULL) { vrefact(rootvnode); @@ -3619,29 +3734,29 @@ pwd_ensure_dirs(void) vrefact(rootvnode); newpwd->pwd_rdir = rootvnode; } - pwd_set(fdp, newpwd); - FILEDESC_XUNLOCK(fdp); + pwd_set(pdp, newpwd); + PWDDESC_XUNLOCK(pdp); pwd_drop(oldpwd); } void pwd_set_rootvnode(void) { - struct filedesc *fdp; + struct pwddesc *pdp; struct pwd *oldpwd, *newpwd; - fdp = curproc->p_fd; + pdp = curproc->p_pd; newpwd = pwd_alloc(); - FILEDESC_XLOCK(fdp); - oldpwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); vrefact(rootvnode); newpwd->pwd_cdir = rootvnode; vrefact(rootvnode); newpwd->pwd_rdir = rootvnode; pwd_fill(oldpwd, newpwd); - pwd_set(fdp, newpwd); - FILEDESC_XUNLOCK(fdp); + pwd_set(pdp, newpwd); + PWDDESC_XUNLOCK(pdp); pwd_drop(oldpwd); } @@ -3652,7 +3767,7 @@ pwd_set_rootvnode(void) void mountcheckdirs(struct vnode *olddp, struct vnode *newdp) { - struct filedesc *fdp; + struct pwddesc *pdp; struct pwd *newpwd, *oldpwd; struct prison *pr; struct proc *p; @@ -3665,18 +3780,18 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newd sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - fdp = fdhold(p); + pdp = pdhold(p); PROC_UNLOCK(p); - if (fdp == NULL) + if (pdp == NULL) continue; - FILEDESC_XLOCK(fdp); - oldpwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); if (oldpwd == NULL || (oldpwd->pwd_cdir != olddp && oldpwd->pwd_rdir != olddp && oldpwd->pwd_jdir != olddp)) { - FILEDESC_XUNLOCK(fdp); - fddrop(fdp); + PWDDESC_XUNLOCK(pdp); + pddrop(pdp); continue; } if (oldpwd->pwd_cdir == olddp) { @@ -3692,10 +3807,10 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newd newpwd->pwd_jdir = newdp; } pwd_fill(oldpwd, newpwd); - pwd_set(fdp, newpwd); - FILEDESC_XUNLOCK(fdp); + pwd_set(pdp, newpwd); + PWDDESC_XUNLOCK(pdp); pwd_drop(oldpwd); - fddrop(fdp); + pddrop(pdp); newpwd = pwd_alloc(); } sx_sunlock(&allproc_lock); @@ -3968,6 +4083,7 @@ export_vnode_to_kinfo(struct vnode *vp, int fd, int ff struct export_fd_buf { struct filedesc *fdp; + struct pwddesc *pdp; struct sbuf *sb; ssize_t remainder; struct kinfo_file kif; @@ -4015,12 +4131,12 @@ export_vnode_to_sb(struct vnode *vp, int fd, int fflag if (efbuf->remainder == 0) return (0); - if (efbuf->fdp != NULL) - FILEDESC_SUNLOCK(efbuf->fdp); + if (efbuf->pdp != NULL) + PWDDESC_XUNLOCK(efbuf->pdp); export_vnode_to_kinfo(vp, fd, fflags, &efbuf->kif, efbuf->flags); error = export_kinfo_to_sb(efbuf); - if (efbuf->fdp != NULL) - FILEDESC_SLOCK(efbuf->fdp); + if (efbuf->pdp != NULL) + PWDDESC_XLOCK(efbuf->pdp); return (error); } @@ -4035,6 +4151,7 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *s { struct file *fp; struct filedesc *fdp; + struct pwddesc *pdp; struct export_fd_buf *efbuf; struct vnode *cttyvp, *textvp, *tracevp; struct pwd *pwd; @@ -4059,9 +4176,11 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *s vrefact(cttyvp); } fdp = fdhold(p); + pdp = pdhold(p); PROC_UNLOCK(p); efbuf = malloc(sizeof(*efbuf), M_TEMP, M_WAITOK); efbuf->fdp = NULL; + efbuf->pdp = NULL; efbuf->sb = sb; efbuf->remainder = maxlen; efbuf->flags = flags; @@ -4074,11 +4193,12 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *s export_vnode_to_sb(cttyvp, KF_FD_TYPE_CTTY, FREAD | FWRITE, efbuf); error = 0; - if (fdp == NULL) + if (pdp == NULL || fdp == NULL) goto fail; efbuf->fdp = fdp; - FILEDESC_SLOCK(fdp); - pwd = pwd_hold_filedesc(fdp); + efbuf->pdp = pdp; + PWDDESC_XLOCK(pdp); + pwd = pwd_hold_pwddesc(pdp); if (pwd != NULL) { /* working directory */ if (pwd->pwd_cdir != NULL) { @@ -4096,6 +4216,10 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *s export_vnode_to_sb(pwd->pwd_jdir, KF_FD_TYPE_JAIL, FREAD, efbuf); } } + PWDDESC_XUNLOCK(pdp); + if (pwd != NULL) + pwd_drop(pwd); + FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) @@ -4116,10 +4240,11 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *s break; } FILEDESC_SUNLOCK(fdp); - if (pwd != NULL) - pwd_drop(pwd); - fddrop(fdp); fail: + if (fdp != NULL) + fddrop(fdp); + if (pdp != NULL) + pddrop(pdp); free(efbuf, M_TEMP); return (error); } @@ -4190,16 +4315,16 @@ kinfo_to_okinfo(struct kinfo_file *kif, struct kinfo_o static int export_vnode_for_osysctl(struct vnode *vp, int type, struct kinfo_file *kif, - struct kinfo_ofile *okif, struct filedesc *fdp, struct sysctl_req *req) + struct kinfo_ofile *okif, struct pwddesc *pdp, struct sysctl_req *req) { int error; vrefact(vp); - FILEDESC_SUNLOCK(fdp); + PWDDESC_XUNLOCK(pdp); export_vnode_to_kinfo(vp, type, 0, kif, KERN_FILEDESC_PACK_KINFO); kinfo_to_okinfo(kif, okif); error = SYSCTL_OUT(req, okif, sizeof(*okif)); - FILEDESC_SLOCK(fdp); + PWDDESC_XLOCK(pdp); return (error); } @@ -4212,6 +4337,7 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) struct kinfo_ofile *okif; struct kinfo_file *kif; struct filedesc *fdp; + struct pwddesc *pdp; struct pwd *pwd; int error, i, lastfile, *name; struct file *fp; @@ -4222,24 +4348,33 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); fdp = fdhold(p); + if (fdp != NULL) + pdp = pdhold(p); PROC_UNLOCK(p); - if (fdp == NULL) + if (fdp == NULL || pdp == NULL) { + if (fdp != NULL) + fddrop(fdp); return (ENOENT); + } kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK); okif = malloc(sizeof(*okif), M_TEMP, M_WAITOK); - FILEDESC_SLOCK(fdp); - pwd = pwd_hold_filedesc(fdp); + PWDDESC_XLOCK(pdp); + pwd = pwd_hold_pwddesc(pdp); if (pwd != NULL) { if (pwd->pwd_cdir != NULL) export_vnode_for_osysctl(pwd->pwd_cdir, KF_FD_TYPE_CWD, kif, - okif, fdp, req); + okif, pdp, req); if (pwd->pwd_rdir != NULL) export_vnode_for_osysctl(pwd->pwd_rdir, KF_FD_TYPE_ROOT, kif, - okif, fdp, req); + okif, pdp, req); if (pwd->pwd_jdir != NULL) export_vnode_for_osysctl(pwd->pwd_jdir, KF_FD_TYPE_JAIL, kif, - okif, fdp, req); + okif, pdp, req); } + PWDDESC_XUNLOCK(pdp); + if (pwd != NULL) + pwd_drop(pwd); + FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) @@ -4254,9 +4389,8 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) break; } FILEDESC_SUNLOCK(fdp); - if (pwd != NULL) - pwd_drop(pwd); fddrop(fdp); + pddrop(pdp); free(kif, M_TEMP); free(okif, M_TEMP); return (0); @@ -4308,7 +4442,7 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, fil int kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen) { - struct filedesc *fdp; + struct pwddesc *pdp; struct pwd *pwd; struct export_fd_buf *efbuf; struct vnode *cdir; @@ -4316,18 +4450,18 @@ kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ss PROC_LOCK_ASSERT(p, MA_OWNED); - fdp = fdhold(p); + pdp = pdhold(p); PROC_UNLOCK(p); - if (fdp == NULL) + if (pdp == NULL) return (EINVAL); efbuf = malloc(sizeof(*efbuf), M_TEMP, M_WAITOK); - efbuf->fdp = fdp; + efbuf->pdp = pdp; efbuf->sb = sb; efbuf->remainder = maxlen; - FILEDESC_SLOCK(fdp); - pwd = FILEDESC_LOCKED_LOAD_PWD(fdp); + PWDDESC_XLOCK(pdp); + pwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); cdir = pwd->pwd_cdir; if (cdir == NULL) { error = EINVAL; @@ -4335,8 +4469,8 @@ kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ss vrefact(cdir); error = export_vnode_to_sb(cdir, KF_FD_TYPE_CWD, FREAD, efbuf); } - FILEDESC_SUNLOCK(fdp); - fddrop(fdp); + PWDDESC_XUNLOCK(pdp); + pddrop(pdp); free(efbuf, M_TEMP); return (error); } Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/kern_exec.c Tue Nov 17 21:14:13 2020 (r367777) @@ -700,6 +700,7 @@ interpret: * cannot be shared after an exec. */ fdunshare(td); + pdunshare(td); /* close files on exec */ fdcloseexec(td); } Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/kern_exit.c Tue Nov 17 21:14:13 2020 (r367777) @@ -367,6 +367,7 @@ exit1(struct thread *td, int rval, int signo) * Close open files and release open-file table. * This may block! */ + pdescfree(td); fdescfree(td); /* Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/kern_fork.c Tue Nov 17 21:14:13 2020 (r367777) @@ -332,16 +332,22 @@ fork_norfproc(struct thread *td, int flags) */ if (flags & RFCFDG) { struct filedesc *fdtmp; + struct pwddesc *pdtmp; + pdtmp = pdinit(td->td_proc->p_pd, false); fdtmp = fdinit(td->td_proc->p_fd, false, NULL); + pdescfree(td); fdescfree(td); p1->p_fd = fdtmp; + p1->p_pd = pdtmp; } /* * Unshare file descriptors (from parent). */ - if (flags & RFFDG) + if (flags & RFFDG) { fdunshare(td); + pdunshare(td); + } fail: if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) && @@ -360,6 +366,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct struct proc *p1, *pptr; struct filedesc *fd; struct filedesc_to_leader *fdtol; + struct pwddesc *pd; struct sigacts *newsigacts; p1 = td->td_proc; @@ -403,12 +410,15 @@ do_fork(struct thread *td, struct fork_req *fr, struct * Copy filedesc. */ if (fr->fr_flags & RFCFDG) { + pd = pdinit(p1->p_pd, false); fd = fdinit(p1->p_fd, false, NULL); fdtol = NULL; } else if (fr->fr_flags & RFFDG) { + pd = pdcopy(p1->p_pd); fd = fdcopy(p1->p_fd); fdtol = NULL; } else { + pd = pdshare(p1->p_pd); fd = fdshare(p1->p_fd); if (p1->p_fdtol == NULL) p1->p_fdtol = filedesc_to_leader_alloc(NULL, NULL, @@ -498,6 +508,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct p2->p_textvp = p1->p_textvp; p2->p_fd = fd; p2->p_fdtol = fdtol; + p2->p_pd = pd; if (p1->p_flag2 & P2_INHERIT_PROTECTED) { p2->p_flag |= P_PROTECTED; Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/kern_proc.c Tue Nov 17 21:14:13 2020 (r367777) @@ -1144,6 +1144,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc kp->ki_traceflag = p->p_traceflag; #endif kp->ki_fd = p->p_fd; + kp->ki_pd = p->p_pd; kp->ki_vmspace = p->p_vmspace; kp->ki_flag = p->p_flag; kp->ki_flag2 = p->p_flag2; @@ -2967,7 +2968,7 @@ sysctl_kern_proc_umask(SYSCTL_HANDLER_ARGS) u_int namelen = arg2; struct proc *p; int error; - u_short fd_cmask; + u_short cmask; pid_t pid; if (namelen != 1) @@ -2976,7 +2977,7 @@ sysctl_kern_proc_umask(SYSCTL_HANDLER_ARGS) pid = (pid_t)name[0]; p = curproc; if (pid == p->p_pid || pid == 0) { - fd_cmask = p->p_fd->fd_cmask; + cmask = p->p_pd->pd_cmask; goto out; } @@ -2984,10 +2985,10 @@ sysctl_kern_proc_umask(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); - fd_cmask = p->p_fd->fd_cmask; + cmask = p->p_pd->pd_cmask; PRELE(p); out: - error = SYSCTL_OUT(req, &fd_cmask, sizeof(fd_cmask)); + error = SYSCTL_OUT(req, &cmask, sizeof(cmask)); return (error); } Modified: head/sys/kern/kern_thread.c ============================================================================== --- head/sys/kern/kern_thread.c Tue Nov 17 20:01:21 2020 (r367776) +++ head/sys/kern/kern_thread.c Tue Nov 17 21:14:13 2020 (r367777) @@ -88,15 +88,15 @@ _Static_assert(offsetof(struct thread, td_frame) == 0x "struct thread KBI td_frame"); _Static_assert(offsetof(struct thread, td_emuldata) == 0x6b0, "struct thread KBI td_emuldata"); -_Static_assert(offsetof(struct proc, p_flag) == 0xb0, +_Static_assert(offsetof(struct proc, p_flag) == 0xb8, "struct proc KBI p_flag"); -_Static_assert(offsetof(struct proc, p_pid) == 0xbc, +_Static_assert(offsetof(struct proc, p_pid) == 0xc4, "struct proc KBI p_pid"); -_Static_assert(offsetof(struct proc, p_filemon) == 0x3b8, +_Static_assert(offsetof(struct proc, p_filemon) == 0x3c0, "struct proc KBI p_filemon"); -_Static_assert(offsetof(struct proc, p_comm) == 0x3d0, +_Static_assert(offsetof(struct proc, p_comm) == 0x3d8, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b0, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, "struct proc KBI p_emuldata"); #endif *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Nov 17 21:20:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B2FDE46F9AE; Tue, 17 Nov 2020 21:20:12 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbJkN4l7wz3hk6; Tue, 17 Nov 2020 21:20:12 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 956D32693E; Tue, 17 Nov 2020 21:20:12 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AHLKCDB068443; Tue, 17 Nov 2020 21:20:12 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AHLKBQv068440; Tue, 17 Nov 2020 21:20:11 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202011172120.0AHLKBQv068440@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 17 Nov 2020 21:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367778 - in head/sys: compat/linux kern sys X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sys: compat/linux kern sys X-SVN-Commit-Revision: 367778 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 21:20:12 -0000 Author: cem Date: Tue Nov 17 21:20:11 2020 New Revision: 367778 URL: https://svnweb.freebsd.org/changeset/base/367778 Log: linux(4) clone(2): Correctly handle CLONE_FS and CLONE_FILES The two flags are distinct and it is impossible to correctly handle clone(2) without the assistance of fork1(). This change depends on the pwddesc split introduced in r367777. I've added a fork_req flag, FR2_SHARE_PATHS, which indicates that p_pd should be treated the opposite way p_fd is (based on RFFDG flag). This is a little ugly, but the benefit is that existing RFFDG API is preserved. Holding FR2_SHARE_PATHS disabled, RFFDG indicates both p_fd and p_pd are copied, while !RFFDG indicates both should be cloned. In Chrome, clone(2) is used with CLONE_FS, without CLONE_FILES, and expects independent fd tables. The previous conflation of CLONE_FS and CLONE_FILES was introduced in r163371 (2006). Discussed with: markj, trasz (earlier version) Differential Revision: https://reviews.freebsd.org/D27016 Modified: head/sys/compat/linux/linux_fork.c head/sys/kern/kern_fork.c head/sys/sys/proc.h Modified: head/sys/compat/linux/linux_fork.c ============================================================================== --- head/sys/compat/linux/linux_fork.c Tue Nov 17 21:14:13 2020 (r367777) +++ head/sys/compat/linux/linux_fork.c Tue Nov 17 21:20:11 2020 (r367778) @@ -131,12 +131,13 @@ static int linux_clone_proc(struct thread *td, struct linux_clone_args *args) { struct fork_req fr; - int error, ff = RFPROC | RFSTOPPED; + int error, ff = RFPROC | RFSTOPPED, f2; struct proc *p2; struct thread *td2; int exit_signal; struct linux_emuldata *em; + f2 = 0; exit_signal = args->flags & 0x000000ff; if (LINUX_SIG_VALID(exit_signal)) { exit_signal = linux_to_bsd_signal(exit_signal); @@ -147,14 +148,14 @@ linux_clone_proc(struct thread *td, struct linux_clone ff |= RFMEM; if (args->flags & LINUX_CLONE_SIGHAND) ff |= RFSIGSHARE; - /* - * XXX: In Linux, sharing of fs info (chroot/cwd/umask) - * and open files is independent. In FreeBSD, its in one - * structure but in reality it does not cause any problems - * because both of these flags are usually set together. - */ - if (!(args->flags & (LINUX_CLONE_FILES | LINUX_CLONE_FS))) + if (args->flags & LINUX_CLONE_FILES) { + if (!(args->flags & LINUX_CLONE_FS)) + f2 |= FR2_SHARE_PATHS; + } else { ff |= RFFDG; + if (args->flags & LINUX_CLONE_FS) + f2 |= FR2_SHARE_PATHS; + } if (args->flags & LINUX_CLONE_PARENT_SETTID) if (args->parent_tidptr == NULL) @@ -165,6 +166,7 @@ linux_clone_proc(struct thread *td, struct linux_clone bzero(&fr, sizeof(fr)); fr.fr_flags = ff; + fr.fr_flags2 = f2; fr.fr_procp = &p2; error = fork1(td, &fr); if (error) Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Tue Nov 17 21:14:13 2020 (r367777) +++ head/sys/kern/kern_fork.c Tue Nov 17 21:20:11 2020 (r367778) @@ -414,11 +414,17 @@ do_fork(struct thread *td, struct fork_req *fr, struct fd = fdinit(p1->p_fd, false, NULL); fdtol = NULL; } else if (fr->fr_flags & RFFDG) { - pd = pdcopy(p1->p_pd); + if (fr->fr_flags2 & FR2_SHARE_PATHS) + pd = pdshare(p1->p_pd); + else + pd = pdcopy(p1->p_pd); fd = fdcopy(p1->p_fd); fdtol = NULL; } else { - pd = pdshare(p1->p_pd); + if (fr->fr_flags2 & FR2_SHARE_PATHS) + pd = pdcopy(p1->p_pd); + else + pd = pdshare(p1->p_pd); fd = fdshare(p1->p_fd); if (p1->p_fdtol == NULL) p1->p_fdtol = filedesc_to_leader_alloc(NULL, NULL, Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Tue Nov 17 21:14:13 2020 (r367777) +++ head/sys/sys/proc.h Tue Nov 17 21:20:11 2020 (r367778) @@ -1017,7 +1017,8 @@ struct fork_req { int fr_pd_flags; struct filecaps *fr_pd_fcaps; int fr_flags2; -#define FR2_DROPSIG_CAUGHT 0x00001 /* Drop caught non-DFL signals */ +#define FR2_DROPSIG_CAUGHT 0x00000001 /* Drop caught non-DFL signals */ +#define FR2_SHARE_PATHS 0x00000002 /* Invert sense of RFFDG for paths */ }; /* From owner-svn-src-all@freebsd.org Tue Nov 17 22:18:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 73E0A4707D7; Tue, 17 Nov 2020 22:18:10 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbL1G2gYhz3mMJ; Tue, 17 Nov 2020 22:18:10 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id A17D121772; Tue, 17 Nov 2020 22:18:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367692 - head/sys/sys To: Warner Losh , Mateusz Guzik Cc: Shawn Webb , src-committers , svn-src-all , svn-src-head References: <202011141920.0AEJKbpO050396@repo.freebsd.org> <20201114205036.tnxvwarsddmu4shz@mutt-hbsd> <20201114205355.j2ejnhouipjr6yhk@mutt-hbsd> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <0015bc22-4568-93cc-5c77-e97c4f5e215c@FreeBSD.org> Date: Tue, 17 Nov 2020 14:18:07 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 22:18:10 -0000 On 11/14/20 2:34 PM, Warner Losh wrote: > true, but a version bump forces that and versions are cheap enough... Strictly speaking, version bumps don't force anything to recompile, they just ensure that newer modules won't load on older kernels. In this case, the change to sys/ucred.h will result in sys/ucred.h's mtime changing so that any kernel modules being built via NO_CLEAN=yes will rebuild ok. I'm not quite sure where this mantra that version bumps force rebuilds came from, but they don't. It's true that since it lives in and most things include that, it mostly forces a rebuild, but that's mostly a side effect, not due to explicit magic around __FreeBSD_version. -- John Baldwin From owner-svn-src-all@freebsd.org Tue Nov 17 22:32:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83904471146; Tue, 17 Nov 2020 22:32:53 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.138]) (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 4CbLLF0nXfz3nnd; Tue, 17 Nov 2020 22:32:52 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.229.168]) by shaw.ca with ESMTPA id f9Wqk0PpTbYg3f9Wsk71q3; Tue, 17 Nov 2020 15:32:51 -0700 X-Authority-Analysis: v=2.4 cv=Q4RsX66a c=1 sm=1 tr=0 ts=5fb44f93 a=7AlCcx2GqMg+lh9P3BclKA==:117 a=7AlCcx2GqMg+lh9P3BclKA==:17 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=nNwsprhYR40A:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=Hok_kDj2vMxL_LYshPwA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [IPv6:fc00:1:1:1::5b]) by spqr.komquats.com (Postfix) with ESMTPS id B42BA6E1; Tue, 17 Nov 2020 14:32:47 -0800 (PST) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 0AHMWl7L074816; Tue, 17 Nov 2020 14:32:47 -0800 (PST) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202011172232.0AHMWl7L074816@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: John Baldwin cc: Warner Losh , Mateusz Guzik , Shawn Webb , src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367692 - head/sys/sys In-reply-to: <0015bc22-4568-93cc-5c77-e97c4f5e215c@FreeBSD.org> References: <202011141920.0AEJKbpO050396@repo.freebsd.org> <20201114205036.tnxvwarsddmu4shz@mutt-hbsd> <20201114205355.j2ejnhouipjr6yhk@mutt-hbsd> <0015bc22-4568-93cc-5c77-e97c4f5e215c@FreeBSD.org> Comments: In-reply-to John Baldwin message dated "Tue, 17 Nov 2020 14:18:07 -0800." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 17 Nov 2020 14:32:47 -0800 X-CMAE-Envelope: MS4xfCyYtta2fscw02WxefoOwinutjOLhdXA4ezbxQOJQ5ApZvWQdmOziSISl3mkkPCfHIUdACXhgMJCSweWYqVkqyKndFLNziWYOyQgdc2LivIWhzgP9atZ hhzyJ05anX6l7O9HCl1Cn9oTgAAhT3pWF/H9OkgQ5sokyqIfHkBVwL1ooihSRkWmEAaew0O2mV8xB4SHEoCDbhXMj89+j7W1D5J2jaT7erdlFpfilvJOahQQ xiaBydmml3vLWG55ZrtSkdFYBr8EuW4sqfz0TbyF4ywrDXY+ceFGgyB70lMpxkYcfjO9F9/0pAVLu05SS6hOacKOhrAPSX+VjNHJoiwEghuXGWWbnTb/fjSx eVm9l9lpaqjN8ua6G5cDA510OW1kHhPHcPRgxKvh6v0IZAWP63Y= X-Rspamd-Queue-Id: 4CbLLF0nXfz3nnd X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 22:32:53 -0000 In message <0015bc22-4568-93cc-5c77-e97c4f5e215c@FreeBSD.org>, John Baldwin wri tes: > On 11/14/20 2:34 PM, Warner Losh wrote: > > true, but a version bump forces that and versions are cheap enough... > > Strictly speaking, version bumps don't force anything to recompile, they > just ensure that newer modules won't load on older kernels. In this case, > the change to sys/ucred.h will result in sys/ucred.h's mtime changing so > that any kernel modules being built via NO_CLEAN=yes will rebuild ok. > > I'm not quite sure where this mantra that version bumps force rebuilds > came from, but they don't. It's true that since it lives in > and most things include that, it mostly forces a rebuild, but that's > mostly a side effect, not due to explicit magic around __FreeBSD_version. Any update to sys/param.h causes the rebuild of any object that depends on the header file. It also causes any poudriere jail built on -CURRENT to delete all its packages and restart from scratch. Poudriere assumes it means ABI or API changes whereas version bumps could simply be markers of notable change that may not affect the ABI. In which case poudriere package rebuilds are gratuitous. -- 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-svn-src-all@freebsd.org Tue Nov 17 22:37:54 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C27BB4715AA for ; Tue, 17 Nov 2020 22:37:54 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) (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 4CbLS24wQKz3pFr for ; Tue, 17 Nov 2020 22:37:54 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qv1-xf30.google.com with SMTP id ek7so21709qvb.6 for ; Tue, 17 Nov 2020 14:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m2wn517wNjHq1/zPdKuyflo4WGHn7NMQqgyEGtj/9Vg=; b=yoXfCrvw5cEbK1EQVqULMkSKc9mybrAONc2006f3+B/LVgGyWTSS57ymPaemezyRia 6vw0C7LGByhesyz4aI+GjmUVNY422z2DZvbHqoLzBs1fE+yUXk8RhIh309ZB7iutGAb1 lfbxQvbUncrf20YQlyq/hayODQ4ks3i43iby5EQ491vrwbV781dimIUG0qqkdRG7rJX/ CMu58qXDKbLUc7yCnhlU3rDgMPAuWWk1ASpnAHx0ZKOIjS1EBah10IzGo1yo9GK+jdrD tdyeiyfLb3T4YJKUL+cDrrBX7o9mmZH9odbPeY2U5hGNHgHQeeLhlrVCDpr/u3IdgNVn T8zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m2wn517wNjHq1/zPdKuyflo4WGHn7NMQqgyEGtj/9Vg=; b=WXoS+22NEYqoPo9MwEXt/n5YrddofnAnWOtB2p7JBs0V4jW9llIcIlS4VWryNgnBCk KUYu2elvP/2UiL/bbHJiFregzRUmuylHtG+69OPVP2Yz+7+R+yyuseAd89NHjl4x3wwE +YLzY4pq03fW0LcaAyyg/7Yc9fowAoYVNzjEKPPTIddXZfbG6LGFK6mobFGMABr2dSCX aes87kPeIE+Q4thHlfF/EoIpDuET+jSi/1gUc2zUh5VJWOIFwaDfPyMPp5QNRrTVRzni Vl1MZh1pjI4dkTORqvyfhfa4Rm/5FzHE16wWrK/pJRoIVaXoqzMDwgROkiWdK9/dkbH6 /rgg== X-Gm-Message-State: AOAM531DrrRZJQS9/oIQuvWg97guMEP6qqbatE0wq17jgWGMk8uAA0nm unrgykbzBwPCXiKZRF8iTzNMH5v4abq//Z13FfwgCw== X-Google-Smtp-Source: ABdhPJw4MaVOJnhqRaNSktRoPUZvgWfmZxgweH/qBXD/xaBtyJrJhTFpQ94uxpdlUUi5xKit10DhAko0elcbHnzKUnk= X-Received: by 2002:ad4:4e13:: with SMTP id dl19mr2011060qvb.24.1605652673723; Tue, 17 Nov 2020 14:37:53 -0800 (PST) MIME-Version: 1.0 References: <202011141920.0AEJKbpO050396@repo.freebsd.org> <20201114205036.tnxvwarsddmu4shz@mutt-hbsd> <20201114205355.j2ejnhouipjr6yhk@mutt-hbsd> <0015bc22-4568-93cc-5c77-e97c4f5e215c@FreeBSD.org> In-Reply-To: <0015bc22-4568-93cc-5c77-e97c4f5e215c@FreeBSD.org> From: Warner Losh Date: Tue, 17 Nov 2020 15:37:42 -0700 Message-ID: Subject: Re: svn commit: r367692 - head/sys/sys To: John Baldwin Cc: Mateusz Guzik , Shawn Webb , src-committers , svn-src-all , svn-src-head X-Rspamd-Queue-Id: 4CbLS24wQKz3pFr X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 22:37:54 -0000 On Tue, Nov 17, 2020 at 3:18 PM John Baldwin wrote: > On 11/14/20 2:34 PM, Warner Losh wrote: > > true, but a version bump forces that and versions are cheap enough... > > Strictly speaking, version bumps don't force anything to recompile, they > just ensure that newer modules won't load on older kernels. In this case, > the change to sys/ucred.h will result in sys/ucred.h's mtime changing so > that any kernel modules being built via NO_CLEAN=yes will rebuild ok. > > I'm not quite sure where this mantra that version bumps force rebuilds > came from, but they don't. It's true that since it lives in > and most things include that, it mostly forces a rebuild, but that's > mostly a side effect, not due to explicit magic around __FreeBSD_version. > It's more that modules stop loading when there's a version bump. This is both good and bad. It's good when there's a legit, KBI change that's likely to affect modules. This one seems on the edge. ZFS is affected, but most drivers are not. It's bad when there's not really a problem since the last bump and you have to rebuild your kernel + modules to be a matched set. For production, you always want this, but sometimes you want to be able to run slightly newer modules than the kernel and that's oftentimes OK because some bumps don't affect KBI. Warner From owner-svn-src-all@freebsd.org Tue Nov 17 22:41:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3E6E24714FA; Tue, 17 Nov 2020 22:41:50 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbLXY12RCz3pwF; Tue, 17 Nov 2020 22:41:48 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 0AHMffQx086733; Tue, 17 Nov 2020 14:41:41 -0800 (PST) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 0AHMffWK086732; Tue, 17 Nov 2020 14:41:41 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202011172241.0AHMffWK086732@gndrsh.dnsmgr.net> Subject: Re: svn commit: r367678 - head/usr.sbin/freebsd-update In-Reply-To: To: Kyle Evans Date: Tue, 17 Nov 2020 14:41:41 -0800 (PST) CC: Mateusz Piotrowski <0mp@freebsd.org>, "Rodney W. Grimes" , src-committers , svn-src-all , svn-src-head Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4CbLXY12RCz3pwF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@gndrsh.dnsmgr.net has no SPF policy when checking 69.59.192.140) smtp.mailfrom=freebsd@gndrsh.dnsmgr.net X-Spamd-Result: default: False [-2.10 / 15.00]; HAS_REPLYTO(0.00)[rgrimes@freebsd.org]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[69.59.192.140:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; DMARC_NA(0.00)[dnsmgr.net]; AUTH_NA(1.00)[]; RCPT_COUNT_FIVE(0.00)[6]; SPAMHAUS_ZRD(0.00)[69.59.192.140:from:127.0.2.255]; RCVD_TLS_LAST(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.998]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13868, ipnet:69.59.192.0/19, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[svn-src-all,svn-src-head] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 22:41:50 -0000 > On Sat, Nov 14, 2020 at 11:20 AM Mateusz Piotrowski <0mp@freebsd.org> wrote: > > > > Hello Rodney, > > > > On 11/14/20 4:59 PM, Rodney W. Grimes wrote: > > >> Author: 0mp (doc,ports committer) > > >> Date: Sat Nov 14 13:07:41 2020 > > >> New Revision: 367678 > > >> URL: https://svnweb.freebsd.org/changeset/base/367678 > > >> > > >> Log: > > >> Document the PAGER environment variable > > >> > > >> Sometimes users want to use freebsd-update(8) in a non-interactive way and > > >> what they often miss is that they have to set PAGER to cat(1) in order to > > >> avoid interactive prompts from less(1). > > > Which was caused by the change of invoking more(1) as less(1) causing > > > this regression, as when invoked as more(1) it falls off the end of > > > empty input and causes no such interactive prompt. > > > > > > Setting PAGER to more(1) also fixes this. > > > > Mmm, I'm not sure if that would work. If I run "jot 1000 | more" in my terminal I still get an > > interactive prompt. Could it be that you are referring to a different more(1) implementation? I'm > > clearly missing something. > > Part of what your missing is freebsd-update(8) often outputs a 0 length file which less(1) well want you to respond Quit to before going to the next file. more(1) does not do that. jot 1000 produces 1 x 1000 line file, that is not whats causing the issues with freebsd-update and less(1), it is more like 1000 x 1 line files. > > more(1) is more or less like `less -E`, which is a default PAGER I had > advocated for back when it changed. It can be mostly non-interactive > as long as your diffs are small, but it's definitely much less > painful. Yes, that would of been less painful, note that iirc there are a few other places effected in similiar ways with 0 line output files sent to less(1) that cause a need to hit a bunch of q's to get the command completed. Since I am an aged more(1) user I just globally fix PAGER. It would of been far less painful had PAGER simply been changed to less rather than all the binary invokations beeing changed, but hind sight is amazing. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Tue Nov 17 22:49:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 57B594719C9; Tue, 17 Nov 2020 22:49:59 +0000 (UTC) (envelope-from mpp302@gmail.com) Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 4CbLjz1wx7z3qlG; Tue, 17 Nov 2020 22:49:59 +0000 (UTC) (envelope-from mpp302@gmail.com) Received: by mail-ed1-f53.google.com with SMTP id t9so24232577edq.8; Tue, 17 Nov 2020 14:49:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Y3qu8Wvw+NvWW7QYTzu/8iW2tJbVuJo3H3UtroIdkMg=; b=IbN+LK6pFJIbg16P9lykNgLPunkC5/yNo2c9IBVrxJDJsgeGoon4L9o5IiX7p9Z0iq V/y+KR+zfYQadkUxZPXZBvunCHUmOJk3Q3TpdcuIKz8MMWdBOKz2XmiItehSyjBhUY+s VpMT/1hEIdOuEsFrGIYSkqVaAfNvuCt0j/sGHv6KqAA01JkDU1iTUTaq/GpxqsP0QPPT EPo9KzDGNNUkdXUxhm0l3zee5gAMFlkKfQqyA8FFQD0aZVDprxkV0FKqduI7V9QnOIxm jYOHx2lc1u+L+/rjKuVnxtAaI6DvbhAFPem9BK8TuGyvayIkEKx8hbBNXP7vF/id7JeZ oKOg== X-Gm-Message-State: AOAM533lQXuIDikzApR+XeRNBSJpbo8fL+AgIqXRfOX7JBSq+I+vDl1/ rGKHqTMDz6noDcInZIwo5cbnC8YUSyk= X-Google-Smtp-Source: ABdhPJwHYUfIOyZpmI3uqcrVI1QpiB+Jz/ceW56jE8Me5S5A/A4KKHlMn63mjOCE5PCvRHJNTwK4Dg== X-Received: by 2002:a05:6402:1f1:: with SMTP id i17mr22676310edy.60.1605653397303; Tue, 17 Nov 2020 14:49:57 -0800 (PST) Received: from ?IPv6:2a02:8109:98c0:1bc0:5e5f:67ff:fef4:ffd8? ([2a02:8109:98c0:1bc0:5e5f:67ff:fef4:ffd8]) by smtp.gmail.com with ESMTPSA id e18sm12080538eja.124.2020.11.17.14.49.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Nov 2020 14:49:56 -0800 (PST) Subject: Re: svn commit: r367678 - head/usr.sbin/freebsd-update To: rgrimes@freebsd.org, Kyle Evans Cc: src-committers , svn-src-all , svn-src-head References: <202011172241.0AHMffWK086732@gndrsh.dnsmgr.net> From: Mateusz Piotrowski <0mp@FreeBSD.org> Message-ID: <4f517cd5-703a-2941-2abf-77c22c3c0514@FreeBSD.org> Date: Tue, 17 Nov 2020 23:50:01 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.4.1 MIME-Version: 1.0 In-Reply-To: <202011172241.0AHMffWK086732@gndrsh.dnsmgr.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Queue-Id: 4CbLjz1wx7z3qlG X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 22:49:59 -0000 On 11/17/20 11:41 PM, Rodney W. Grimes wrote: >> On Sat, Nov 14, 2020 at 11:20 AM Mateusz Piotrowski <0mp@freebsd.org> wrote: >>> On 11/14/20 4:59 PM, Rodney W. Grimes wrote: >>>>> Author: 0mp (doc,ports committer) >>>>> Date: Sat Nov 14 13:07:41 2020 >>>>> New Revision: 367678 >>>>> URL: https://svnweb.freebsd.org/changeset/base/367678 >>>>> >>>>> Log: >>>>> Document the PAGER environment variable >>>>> >>>>> Sometimes users want to use freebsd-update(8) in a non-interactive way and >>>>> what they often miss is that they have to set PAGER to cat(1) in order to >>>>> avoid interactive prompts from less(1). >>>> Which was caused by the change of invoking more(1) as less(1) causing >>>> this regression, as when invoked as more(1) it falls off the end of >>>> empty input and causes no such interactive prompt. >>>> >>>> Setting PAGER to more(1) also fixes this. >>> Mmm, I'm not sure if that would work. If I run "jot 1000 | more" in my terminal I still get an >>> interactive prompt. Could it be that you are referring to a different more(1) implementation? I'm >>> clearly missing something. >>> > Part of what your missing is freebsd-update(8) often outputs a 0 > length file which less(1) well want you to respond Quit to before > going to the next file. more(1) does not do that. Ah, now I see! I forgot about this case. Sure, in this case the old more(1) or the new less(1) with -E are sufficient as well. Thanks a lot, Rodney! I guess that I'll leave the "cat" in the manual for now as it offers fully non-interactive experience. Cheers, Mateusz From owner-svn-src-all@freebsd.org Tue Nov 17 23:28:18 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8B99E472611 for ; Tue, 17 Nov 2020 23:28:18 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound5a.ore.mailhop.org (outbound5a.ore.mailhop.org [44.233.67.66]) (using TLSv1.3 with cipher TLS_AES_256_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 4CbMZB2BXzz3sQ3 for ; Tue, 17 Nov 2020 23:28:18 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1605655696; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=nMhsc+azZGKbcT1E4wYYhz2XN7jVcZcF9ZM8SYyOANgX29wpkCRflBcC+T6aH8lmnWU0wM3XsxMgG 8qRu6T9DfCWmXLYfhDS7fQZAZhqFncxdudFT3/uGwbOm8hQ6/jBJsdjnjtrDcRMJpn5elCR7F1DoNa Ml/E1oIkJ011KgT87QSUHB4eBOMHbGG/TUVWhzEUlz9BMpq0tAx6vkbiQ/cs08lm81tP21cQLZCYxl YbsKN5DP4rlcRezoacBzTMPHPDpb7oX7WXWbbITxZxlpYIBgQ78w4KwejWfLFIUZhgKej4pkDKP1gk p6Nv94VghH9PZjI5aVPFEfcfh93KzYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:dkim-signature:from; bh=dBzJrZjg3SMon2nExhWYI/3FnlX+p3cXDmrPLkCA9Fg=; b=s4e1JD9W8/BVOOWpE/i9JiUIMl/H8nMfR6Q8DnAH67PF3Hf1SZfI87mfi3RpdBLDgv8tAariD7Zhj o+UvY0F45lCEzIiDjkd0ezptuwQXziKED0mCO3DSM2FemODGlGoU3E0lKi1hHK0jpW9UmSwdAJQm32 wNL0d9v7F4Ctgsjoo23w1L1a8mMBu8L/X/X1tYSM7PkpfDqQq4KjF6fj+hNYz4oGktKK+rHSllllEk /QBDT3xEht4lGHgLlFe5R3ES8He8hbWOmIoJqhiIUGFBkLwhInkHetsKwT1G4KucnXZSLMlnc3Y12E DxuRxnY8xBp1Lpj4hXMahJEyp+knyNw== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:from; bh=dBzJrZjg3SMon2nExhWYI/3FnlX+p3cXDmrPLkCA9Fg=; b=gcfS43/+fC7uu6QKNeomvzynzfk1Am5Kb0+4Ont4jbdqWItuFEpKxE90kPZWgCq2jJo9iLbMdtM5H eUiUHkat0E1aXwmsmOPg3YtijegGJrLx2fS7BDy+QA7Myc6xVRt7vliz+eu8jhumeR49fXNDU0NgG2 rhOHychNT+0dysXuO4XRz3rpTxKsSISociQUIYKU71r7tqRRf00qEO6EkhZZdHTCsbO3vSouQZOZtj qXgPGOnvqAE0tSxBGDQRCrY3xY6KbtaaM1kKlZxtCMMcXbAWwicquuYV6uOCvDlgp4n7SV68cKMF4Q SlNJmgkaiNgYcXE0gkyyxHuR3I1wdeQ== X-MHO-RoutePath: aGlwcGll X-MHO-User: 90404e9e-292c-11eb-8b38-614106969e8d X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-67-177-211-60.hsd1.co.comcast.net [67.177.211.60]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id 90404e9e-292c-11eb-8b38-614106969e8d; Tue, 17 Nov 2020 23:28:15 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 0AHNSDUl043174; Tue, 17 Nov 2020 16:28:13 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <41b3e36ec703b2f12632e9e194f132e64b3910a9.camel@freebsd.org> Subject: Re: svn commit: r367678 - head/usr.sbin/freebsd-update From: Ian Lepore To: rgrimes@freebsd.org Cc: src-committers , svn-src-all , svn-src-head Date: Tue, 17 Nov 2020 16:28:13 -0700 In-Reply-To: <202011172241.0AHMffWK086732@gndrsh.dnsmgr.net> References: <202011172241.0AHMffWK086732@gndrsh.dnsmgr.net> Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4CbMZB2BXzz3sQ3 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2020 23:28:18 -0000 On Tue, 2020-11-17 at 14:41 -0800, Rodney W. Grimes wrote: > > On Sat, Nov 14, 2020 at 11:20 AM Mateusz Piotrowski < > > 0mp@freebsd.org> wrote: > > > > > > Hello Rodney, > > > > > > On 11/14/20 4:59 PM, Rodney W. Grimes wrote: > > > > > Author: 0mp (doc,ports committer) > > > > > Date: Sat Nov 14 13:07:41 2020 > > > > > New Revision: 367678 > > > > > URL: https://svnweb.freebsd.org/changeset/base/367678 > > > > > > > > > > Log: > > > > > Document the PAGER environment variable > > > > > > > > > > Sometimes users want to use freebsd-update(8) in a non- > > > > > interactive way and > > > > > what they often miss is that they have to set PAGER to > > > > > cat(1) in order to > > > > > avoid interactive prompts from less(1). > > > > > > > > Which was caused by the change of invoking more(1) as less(1) > > > > causing > > > > this regression, as when invoked as more(1) it falls off the > > > > end of > > > > empty input and causes no such interactive prompt. > > > > > > > > Setting PAGER to more(1) also fixes this. > > > > > > Mmm, I'm not sure if that would work. If I run "jot 1000 | more" > > > in my terminal I still get an > > > interactive prompt. Could it be that you are referring to a > > > different more(1) implementation? I'm > > > clearly missing something. > > > > > Part of what your missing is freebsd-update(8) often outputs a 0 > length file which less(1) well want you to respond Quit to before > going to the next file. more(1) does not do that. > > jot 1000 produces 1 x 1000 line file, that is not whats causing > the issues with freebsd-update and less(1), it is more like > 1000 x 1 line files. > > > > > more(1) is more or less like `less -E`, which is a default PAGER I > > had > > advocated for back when it changed. It can be mostly non- > > interactive > > as long as your diffs are small, but it's definitely much less > > painful. > > Yes, that would of been less painful, note that iirc there are a > few other places effected in similiar ways with 0 line output > files sent to less(1) that cause a need to hit a bunch of q's > to get the command completed. > > Since I am an aged more(1) user I just globally fix PAGER. > It would of been far less painful had PAGER simply been > changed to less rather than all the binary invokations > beeing changed, but hind sight is amazing. > You might find some solace in the brave new world by adding to your .cshrc: setenv LESS -m -E -- Ian From owner-svn-src-all@freebsd.org Wed Nov 18 00:48:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 63EA0474162; Wed, 18 Nov 2020 00:48:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbPLv28LSz4RBs; Wed, 18 Nov 2020 00:48:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id A014422C7D; Wed, 18 Nov 2020 00:48:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367692 - head/sys/sys To: Warner Losh Cc: Mateusz Guzik , Shawn Webb , src-committers , svn-src-all , svn-src-head References: <202011141920.0AEJKbpO050396@repo.freebsd.org> <20201114205036.tnxvwarsddmu4shz@mutt-hbsd> <20201114205355.j2ejnhouipjr6yhk@mutt-hbsd> <0015bc22-4568-93cc-5c77-e97c4f5e215c@FreeBSD.org> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Tue, 17 Nov 2020 16:48:37 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 00:48:39 -0000 On 11/17/20 2:37 PM, Warner Losh wrote: > On Tue, Nov 17, 2020 at 3:18 PM John Baldwin wrote: > >> On 11/14/20 2:34 PM, Warner Losh wrote: >>> true, but a version bump forces that and versions are cheap enough... >> >> Strictly speaking, version bumps don't force anything to recompile, they >> just ensure that newer modules won't load on older kernels. In this case, >> the change to sys/ucred.h will result in sys/ucred.h's mtime changing so >> that any kernel modules being built via NO_CLEAN=yes will rebuild ok. >> >> I'm not quite sure where this mantra that version bumps force rebuilds >> came from, but they don't. It's true that since it lives in >> and most things include that, it mostly forces a rebuild, but that's >> mostly a side effect, not due to explicit magic around __FreeBSD_version. >> > > It's more that modules stop loading when there's a version bump. This is > both good and bad. It's good when there's a legit, KBI change that's likely > to affect modules. This one seems on the edge. ZFS is affected, but most > drivers are not. > > It's bad when there's not really a problem since the last bump and you have > to rebuild your kernel + modules to be a matched set. For production, you > always want this, but sometimes you want to be able to run slightly newer > modules than the kernel and that's oftentimes OK because some bumps don't > affect KBI. To be clear, it only blocks loading modules newer than the running kernel. This still doesn't "force" recompilation in that nothing in the base build system (I'm not counting ports here, but things in src/sys) compares __FreeBSD_version values and forces a clean if there is a mismatch. Only header mtimes force rebuilds. That is, you build by hand instead of using buildkernel, or you go ahead and run 'make reinstallkernel' and then load, or run 'make installkernel' and then go mess with the sysctl to undo the changes to rewrite your module path so you can load an old module. If you build a kernel from your development tree and boot that, then the module will load fine (it's what I generally do except in cases where I'm already running a kernel from said tree and have a module I can unload/load in which case I do the reinstallkernel route). -- John Baldwin From owner-svn-src-all@freebsd.org Wed Nov 18 01:18:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8D02D474D50; Wed, 18 Nov 2020 01:18:45 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbQ1d3bYrz4SZF; Wed, 18 Nov 2020 01:18:45 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6EC9D18FD; Wed, 18 Nov 2020 01:18:45 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI1Ij0b018565; Wed, 18 Nov 2020 01:18:45 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI1Ij82018564; Wed, 18 Nov 2020 01:18:45 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202011180118.0AI1Ij82018564@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 18 Nov 2020 01:18:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367779 - head/sys/contrib/openzfs/cmd/zpool X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/sys/contrib/openzfs/cmd/zpool X-SVN-Commit-Revision: 367779 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 01:18:45 -0000 Author: cy Date: Wed Nov 18 01:18:45 2020 New Revision: 367779 URL: https://svnweb.freebsd.org/changeset/base/367779 Log: Restore identification of VDEVs using non-native block size. NAME STATE READ WRITE CKSUM dsk02 ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 ada1s4a ONLINE 0 0 0 ada2s4a ONLINE 0 0 0 block size: 512B configured, 4096B native Reviewed by: tsoome (previous FreeBSD phab version) Differential Revision: https://reviews.freebsd.org/D26880 Upstream commit: 3928ec53395fcc26be7844dd6b63df757166c281 Reviewed-by: Matt Macy Reviewed-by: Toomas Soome Reviewed-by: Brian Behlendorf Signed off by: Cy Schubert Closes #11088 Modified: head/sys/contrib/openzfs/cmd/zpool/zpool_main.c Modified: head/sys/contrib/openzfs/cmd/zpool/zpool_main.c ============================================================================== --- head/sys/contrib/openzfs/cmd/zpool/zpool_main.c Tue Nov 17 21:20:11 2020 (r367778) +++ head/sys/contrib/openzfs/cmd/zpool/zpool_main.c Wed Nov 18 01:18:45 2020 (r367779) @@ -2254,6 +2254,13 @@ print_status_config(zpool_handle_t *zhp, status_cbdata break; } color_end(); + } else if (children == 0 && !isspare && + getenv("ZPOOL_STATUS_NON_NATIVE_ASHIFT_IGNORE") == NULL && + VDEV_STAT_VALID(vs_physical_ashift, vsc) && + vs->vs_configured_ashift < vs->vs_physical_ashift) { + (void) printf( + gettext(" block size: %dB configured, %dB native"), + 1 << vs->vs_configured_ashift, 1 << vs->vs_physical_ashift); } /* The root vdev has the scrub/resilver stats */ From owner-svn-src-all@freebsd.org Wed Nov 18 02:06:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FDF34757E1; Wed, 18 Nov 2020 02:06:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbR480xJWz4Vn1; Wed, 18 Nov 2020 02:06:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 12E8C2294; Wed, 18 Nov 2020 02:06:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI25xn6050085; Wed, 18 Nov 2020 02:05:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI25xCs050084; Wed, 18 Nov 2020 02:05:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011180205.0AI25xCs050084@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 18 Nov 2020 02:05:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367780 - stable/12/sys/cam/ctl X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam/ctl X-SVN-Commit-Revision: 367780 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 02:06:00 -0000 Author: mav Date: Wed Nov 18 02:05:59 2020 New Revision: 367780 URL: https://svnweb.freebsd.org/changeset/base/367780 Log: MFC r367600: Make CTL nicer to increased MAXPHYS. Before this CTL always allocated MAXPHYS-sized buffers, even for 4KB I/O, that is even more overkill for MAXPHYS of 1MB. This change limits maximum allocation to 512KB if MAXPHYS is bigger, plus if one is above 128KB, adds new 128KB UMA zone for smaller I/Os. The patch factors out alloc/free, so later we could make it use more zones or malloc() if we'd like. Modified: stable/12/sys/cam/ctl/ctl_backend_block.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/12/sys/cam/ctl/ctl_backend_block.c Wed Nov 18 01:18:45 2020 (r367779) +++ stable/12/sys/cam/ctl/ctl_backend_block.c Wed Nov 18 02:05:59 2020 (r367780) @@ -102,7 +102,7 @@ __FBSDID("$FreeBSD$"); */ #define CTLBLK_HALF_IO_SIZE (512 * 1024) #define CTLBLK_MAX_IO_SIZE (CTLBLK_HALF_IO_SIZE * 2) -#define CTLBLK_MAX_SEG MAXPHYS +#define CTLBLK_MAX_SEG MIN(CTLBLK_HALF_IO_SIZE, MAXPHYS) #define CTLBLK_HALF_SEGS MAX(CTLBLK_HALF_IO_SIZE / CTLBLK_MAX_SEG, 1) #define CTLBLK_MAX_SEGS (CTLBLK_HALF_SEGS * 2) @@ -190,6 +190,9 @@ struct ctl_be_block_softc { SLIST_HEAD(, ctl_be_block_lun) lun_list; uma_zone_t beio_zone; uma_zone_t buf_zone; +#if (CTLBLK_MAX_SEG > 131072) + uma_zone_t buf128_zone; +#endif }; static struct ctl_be_block_softc backend_block_softc; @@ -298,6 +301,32 @@ static struct ctl_backend_driver ctl_be_block_driver = MALLOC_DEFINE(M_CTLBLK, "ctlblock", "Memory used for CTL block backend"); CTL_BACKEND_DECLARE(cbb, ctl_be_block_driver); +static void +ctl_alloc_seg(struct ctl_be_block_softc *softc, struct ctl_sg_entry *sg, + size_t len) +{ + +#if (CTLBLK_MAX_SEG > 131072) + if (len <= 131072) + sg->addr = uma_zalloc(softc->buf128_zone, M_WAITOK); + else +#endif + sg->addr = uma_zalloc(softc->buf_zone, M_WAITOK); + sg->len = len; +} + +static void +ctl_free_seg(struct ctl_be_block_softc *softc, struct ctl_sg_entry *sg) +{ + +#if (CTLBLK_MAX_SEG > 131072) + if (sg->len <= 131072) + uma_zfree(softc->buf128_zone, sg->addr); + else +#endif + uma_zfree(softc->buf_zone, sg->addr); +} + static struct ctl_be_block_io * ctl_alloc_beio(struct ctl_be_block_softc *softc) { @@ -315,12 +344,12 @@ ctl_free_beio(struct ctl_be_block_io *beio) int i; for (i = 0; i < beio->num_segs; i++) { - uma_zfree(softc->buf_zone, beio->sg_segs[i].addr); + ctl_free_seg(softc, &beio->sg_segs[i]); /* For compare we had two equal S/G lists. */ if (beio->two_sglists) { - uma_zfree(softc->buf_zone, - beio->sg_segs[i + CTLBLK_HALF_SEGS].addr); + ctl_free_seg(softc, + &beio->sg_segs[i + CTLBLK_HALF_SEGS]); } } @@ -1132,8 +1161,7 @@ ctl_be_block_dispatch_dev(struct ctl_be_block_lun *be_ /* * We have to limit our I/O size to the maximum supported by the - * backend device. Hopefully it is MAXPHYS. If the driver doesn't - * set it properly, use DFLTPHYS. + * backend device. */ if (csw) { max_iosize = dev->si_iosize_max; @@ -1325,8 +1353,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_be_block_lun *b seglen -= seglen % cbe_lun->blocksize; } else seglen -= seglen % cbe_lun->blocksize; - beio->sg_segs[i].len = seglen; - beio->sg_segs[i].addr = uma_zalloc(softc->buf_zone, M_WAITOK); + ctl_alloc_seg(softc, &beio->sg_segs[i], seglen); DPRINTF("segment %d addr %p len %zd\n", i, beio->sg_segs[i].addr, beio->sg_segs[i].len); @@ -1598,18 +1625,17 @@ ctl_be_block_dispatch(struct ctl_be_block_lun *be_lun, /* * Setup the S/G entry for this chunk. */ - beio->sg_segs[i].len = min(CTLBLK_MAX_SEG, len_left); - beio->sg_segs[i].addr = uma_zalloc(softc->buf_zone, M_WAITOK); + ctl_alloc_seg(softc, &beio->sg_segs[i], + min(CTLBLK_MAX_SEG, len_left)); DPRINTF("segment %d addr %p len %zd\n", i, beio->sg_segs[i].addr, beio->sg_segs[i].len); /* Set up second segment for compare operation. */ if (beio->two_sglists) { - beio->sg_segs[i + CTLBLK_HALF_SEGS].len = - beio->sg_segs[i].len; - beio->sg_segs[i + CTLBLK_HALF_SEGS].addr = - uma_zalloc(softc->buf_zone, M_WAITOK); + ctl_alloc_seg(softc, + &beio->sg_segs[i + CTLBLK_HALF_SEGS], + beio->sg_segs[i].len); } beio->num_segs++; @@ -1925,8 +1951,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, maxio = dev->si_iosize_max; if (maxio <= 0) maxio = DFLTPHYS; - if (maxio > CTLBLK_MAX_IO_SIZE) - maxio = CTLBLK_MAX_IO_SIZE; + if (maxio > CTLBLK_MAX_SEG) + maxio = CTLBLK_MAX_SEG; } be_lun->lun_flush = ctl_be_block_flush_dev; be_lun->getattr = ctl_be_block_getattr_dev; @@ -2771,6 +2797,10 @@ ctl_be_block_init(void) NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); softc->buf_zone = uma_zcreate("ctlblock", CTLBLK_MAX_SEG, NULL, NULL, NULL, NULL, /*align*/ 0, /*flags*/0); +#if (CTLBLK_MAX_SEG > 131072) + softc->buf128_zone = uma_zcreate("ctlblock128", 131072, + NULL, NULL, NULL, NULL, /*align*/ 0, /*flags*/0); +#endif SLIST_INIT(&softc->lun_list); return (0); } @@ -2797,6 +2827,9 @@ ctl_be_block_shutdown(void) } mtx_unlock(&softc->lock); uma_zdestroy(softc->buf_zone); +#if (CTLBLK_MAX_SEG > 131072) + uma_zdestroy(softc->buf128_zone); +#endif uma_zdestroy(softc->beio_zone); mtx_destroy(&softc->lock); sx_destroy(&softc->modify_lock); From owner-svn-src-all@freebsd.org Wed Nov 18 02:12:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70B1B475ECB; Wed, 18 Nov 2020 02:12:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbRD42qfDz4W8G; Wed, 18 Nov 2020 02:12:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 542281FFE; Wed, 18 Nov 2020 02:12:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI2CqO6055882; Wed, 18 Nov 2020 02:12:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI2CqgI055881; Wed, 18 Nov 2020 02:12:52 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011180212.0AI2CqgI055881@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 18 Nov 2020 02:12:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367781 - head/sys/dev/isp X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/isp X-SVN-Commit-Revision: 367781 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 02:12:52 -0000 Author: mav Date: Wed Nov 18 02:12:51 2020 New Revision: 367781 URL: https://svnweb.freebsd.org/changeset/base/367781 Log: Don't allocate full XCMD_SIZE (512 bytes) on stack. We need only 24 bytes (fcp_rsp_iu_t) there for isp_put_fcp_rsp_iu(). MFC after: 1 month Modified: head/sys/dev/isp/isp_freebsd.c Modified: head/sys/dev/isp/isp_freebsd.c ============================================================================== --- head/sys/dev/isp/isp_freebsd.c Wed Nov 18 02:05:59 2020 (r367780) +++ head/sys/dev/isp/isp_freebsd.c Wed Nov 18 02:12:51 2020 (r367781) @@ -1285,8 +1285,7 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, } } else { bus_addr_t addr; - char buf[XCMD_SIZE]; - fcp_rsp_iu_t *rp; + fcp_rsp_iu_t rp; if (atp->ests == NULL) { atp->ests = isp_get_ecmd(isp); @@ -1295,29 +1294,28 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, break; } } - memset(buf, 0, sizeof (buf)); - rp = (fcp_rsp_iu_t *)buf; + memset(&rp, 0, sizeof(rp)); if (fctape) { cto->ct_flags |= CT7_CONFIRM|CT7_EXPLCT_CONF; - rp->fcp_rsp_bits |= FCP_CONF_REQ; + rp.fcp_rsp_bits |= FCP_CONF_REQ; } cto->ct_flags |= CT7_FLAG_MODE2; - rp->fcp_rsp_scsi_status = cso->scsi_status; + rp.fcp_rsp_scsi_status = cso->scsi_status; if (resid < 0) { - rp->fcp_rsp_resid = -resid; - rp->fcp_rsp_bits |= FCP_RESID_OVERFLOW; + rp.fcp_rsp_resid = -resid; + rp.fcp_rsp_bits |= FCP_RESID_OVERFLOW; } else if (resid > 0) { - rp->fcp_rsp_resid = resid; - rp->fcp_rsp_bits |= FCP_RESID_UNDERFLOW; + rp.fcp_rsp_resid = resid; + rp.fcp_rsp_bits |= FCP_RESID_UNDERFLOW; } if (sense_length) { - rp->fcp_rsp_snslen = sense_length; + rp.fcp_rsp_snslen = sense_length; cto->ct_senselen = sense_length; - rp->fcp_rsp_bits |= FCP_SNSLEN_VALID; - isp_put_fcp_rsp_iu(isp, rp, atp->ests); + rp.fcp_rsp_bits |= FCP_SNSLEN_VALID; + isp_put_fcp_rsp_iu(isp, &rp, atp->ests); memcpy(((fcp_rsp_iu_t *)atp->ests)->fcp_rsp_extra, &cso->sense_data, sense_length); } else { - isp_put_fcp_rsp_iu(isp, rp, atp->ests); + isp_put_fcp_rsp_iu(isp, &rp, atp->ests); } if (isp->isp_dblev & ISP_LOGTDEBUG1) { isp_print_bytes(isp, "FCP Response Frame After Swizzling", MIN_FCP_RESPONSE_SIZE + sense_length, atp->ests); @@ -1437,8 +1435,7 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, } } else { bus_addr_t addr; - char buf[XCMD_SIZE]; - fcp_rsp_iu_t *rp; + fcp_rsp_iu_t rp; if (atp->ests == NULL) { atp->ests = isp_get_ecmd(isp); @@ -1447,28 +1444,27 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, break; } } - memset(buf, 0, sizeof (buf)); - rp = (fcp_rsp_iu_t *)buf; + memset(&rp, 0, sizeof(rp)); if (fctape) { cto->ct_flags |= CT2_CONFIRM; - rp->fcp_rsp_bits |= FCP_CONF_REQ; + rp.fcp_rsp_bits |= FCP_CONF_REQ; } cto->ct_flags |= CT2_FLAG_MODE2; - rp->fcp_rsp_scsi_status = cso->scsi_status; + rp.fcp_rsp_scsi_status = cso->scsi_status; if (resid < 0) { - rp->fcp_rsp_resid = -resid; - rp->fcp_rsp_bits |= FCP_RESID_OVERFLOW; + rp.fcp_rsp_resid = -resid; + rp.fcp_rsp_bits |= FCP_RESID_OVERFLOW; } else if (resid > 0) { - rp->fcp_rsp_resid = resid; - rp->fcp_rsp_bits |= FCP_RESID_UNDERFLOW; + rp.fcp_rsp_resid = resid; + rp.fcp_rsp_bits |= FCP_RESID_UNDERFLOW; } if (sense_length) { - rp->fcp_rsp_snslen = sense_length; - rp->fcp_rsp_bits |= FCP_SNSLEN_VALID; - isp_put_fcp_rsp_iu(isp, rp, atp->ests); + rp.fcp_rsp_snslen = sense_length; + rp.fcp_rsp_bits |= FCP_SNSLEN_VALID; + isp_put_fcp_rsp_iu(isp, &rp, atp->ests); memcpy(((fcp_rsp_iu_t *)atp->ests)->fcp_rsp_extra, &cso->sense_data, sense_length); } else { - isp_put_fcp_rsp_iu(isp, rp, atp->ests); + isp_put_fcp_rsp_iu(isp, &rp, atp->ests); } if (isp->isp_dblev & ISP_LOGTDEBUG1) { isp_print_bytes(isp, "FCP Response Frame After Swizzling", MIN_FCP_RESPONSE_SIZE + sense_length, atp->ests); From owner-svn-src-all@freebsd.org Wed Nov 18 02:54:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA163476959; Wed, 18 Nov 2020 02:54:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbS7d68rJz4XtV; Wed, 18 Nov 2020 02:54:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BBC4224F9; Wed, 18 Nov 2020 02:54:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI2s5er080403; Wed, 18 Nov 2020 02:54:05 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI2s5xJ080402; Wed, 18 Nov 2020 02:54:05 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011180254.0AI2s5xJ080402@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 18 Nov 2020 02:54:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367782 - head/sys/dev/isp X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/isp X-SVN-Commit-Revision: 367782 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 02:54:06 -0000 Author: mav Date: Wed Nov 18 02:54:05 2020 New Revision: 367782 URL: https://svnweb.freebsd.org/changeset/base/367782 Log: Remove bus_dma locking/sleeping when not needed. MFC after: 1 month Modified: head/sys/dev/isp/isp_pci.c Modified: head/sys/dev/isp/isp_pci.c ============================================================================== --- head/sys/dev/isp/isp_pci.c Wed Nov 18 02:12:51 2020 (r367781) +++ head/sys/dev/isp/isp_pci.c Wed Nov 18 02:54:05 2020 (r367782) @@ -1520,8 +1520,7 @@ isp_pci_mbxdma(ispsoftc_t *isp) len += (N_XCMDS * XCMD_SIZE); if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, - &isp->isp_osinfo.reqdmat)) { + len, 1, len, 0, NULL, NULL, &isp->isp_osinfo.reqdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); goto bad; } @@ -1534,7 +1533,7 @@ isp_pci_mbxdma(ispsoftc_t *isp) isp->isp_rquest = base; im.error = 0; if (bus_dmamap_load(isp->isp_osinfo.reqdmat, isp->isp_osinfo.reqmap, - base, len, imc, &im, 0) || im.error) { + base, len, imc, &im, BUS_DMA_NOWAIT) || im.error) { isp_prt(isp, ISP_LOGERR, "error loading request DMA map %d", im.error); goto bad; } @@ -1562,8 +1561,7 @@ isp_pci_mbxdma(ispsoftc_t *isp) len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, - &isp->isp_osinfo.respdmat)) { + len, 1, len, 0, NULL, NULL, &isp->isp_osinfo.respdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); goto bad; } @@ -1576,7 +1574,7 @@ isp_pci_mbxdma(ispsoftc_t *isp) isp->isp_result = base; im.error = 0; if (bus_dmamap_load(isp->isp_osinfo.respdmat, isp->isp_osinfo.respmap, - base, len, imc, &im, 0) || im.error) { + base, len, imc, &im, BUS_DMA_NOWAIT) || im.error) { isp_prt(isp, ISP_LOGERR, "error loading response DMA map %d", im.error); goto bad; } @@ -1592,8 +1590,7 @@ isp_pci_mbxdma(ispsoftc_t *isp) len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, - &isp->isp_osinfo.atiodmat)) { + len, 1, len, 0, NULL, NULL, &isp->isp_osinfo.atiodmat)) { isp_prt(isp, ISP_LOGERR, "cannot create ATIO DMA tag"); goto bad; } @@ -1606,7 +1603,7 @@ isp_pci_mbxdma(ispsoftc_t *isp) isp->isp_atioq = base; im.error = 0; if (bus_dmamap_load(isp->isp_osinfo.atiodmat, isp->isp_osinfo.atiomap, - base, len, imc, &im, 0) || im.error) { + base, len, imc, &im, BUS_DMA_NOWAIT) || im.error) { isp_prt(isp, ISP_LOGERR, "error loading ATIO DMA map %d", im.error); goto bad; } @@ -1619,8 +1616,8 @@ isp_pci_mbxdma(ispsoftc_t *isp) if (IS_FC(isp)) { if (bus_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - 2*QENTRY_LEN, 1, 2*QENTRY_LEN, 0, busdma_lock_mutex, - &isp->isp_lock, &isp->isp_osinfo.iocbdmat)) { + 2*QENTRY_LEN, 1, 2*QENTRY_LEN, 0, NULL, NULL, + &isp->isp_osinfo.iocbdmat)) { goto bad; } if (bus_dmamem_alloc(isp->isp_osinfo.iocbdmat, @@ -1629,14 +1626,14 @@ isp_pci_mbxdma(ispsoftc_t *isp) isp->isp_iocb = base; im.error = 0; if (bus_dmamap_load(isp->isp_osinfo.iocbdmat, isp->isp_osinfo.iocbmap, - base, 2*QENTRY_LEN, imc, &im, 0) || im.error) + base, 2*QENTRY_LEN, imc, &im, BUS_DMA_NOWAIT) || im.error) goto bad; isp->isp_iocb_dma = im.maddr; if (bus_dma_tag_create(isp->isp_osinfo.dmat, 64, slim, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - ISP_FC_SCRLEN, 1, ISP_FC_SCRLEN, 0, busdma_lock_mutex, - &isp->isp_lock, &isp->isp_osinfo.scdmat)) + ISP_FC_SCRLEN, 1, ISP_FC_SCRLEN, 0, NULL, NULL, + &isp->isp_osinfo.scdmat)) goto bad; for (cmap = 0; cmap < isp->isp_nchan; cmap++) { struct isp_fc *fc = ISP_FC_PC(isp, cmap); @@ -1646,7 +1643,8 @@ isp_pci_mbxdma(ispsoftc_t *isp) FCPARAM(isp, cmap)->isp_scratch = base; im.error = 0; if (bus_dmamap_load(isp->isp_osinfo.scdmat, fc->scmap, - base, ISP_FC_SCRLEN, imc, &im, 0) || im.error) { + base, ISP_FC_SCRLEN, imc, &im, BUS_DMA_NOWAIT) || + im.error) { bus_dmamem_free(isp->isp_osinfo.scdmat, base, fc->scmap); FCPARAM(isp, cmap)->isp_scratch = NULL; From owner-svn-src-all@freebsd.org Wed Nov 18 03:30:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DBA7E477984; Wed, 18 Nov 2020 03:30:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbSxg5xVwz4ZgP; Wed, 18 Nov 2020 03:30:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEDEB3479; Wed, 18 Nov 2020 03:30:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI3UVWA000521; Wed, 18 Nov 2020 03:30:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI3UViM000520; Wed, 18 Nov 2020 03:30:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202011180330.0AI3UViM000520@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 18 Nov 2020 03:30:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367783 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367783 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 03:30:31 -0000 Author: kevans Date: Wed Nov 18 03:30:31 2020 New Revision: 367783 URL: https://svnweb.freebsd.org/changeset/base/367783 Log: _umtx_op: fix robust lists after r367744 A copy-pasto left us copying in 24-bytes at the address of the rb pointer instead of the intended target. Reported by: sigsys@gmail.com Sighing: kevans Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Wed Nov 18 02:54:05 2020 (r367782) +++ head/sys/kern/kern_umtx.c Wed Nov 18 03:30:31 2020 (r367783) @@ -3431,7 +3431,7 @@ umtx_copyin_robust_lists(const void *uaddr, size_t siz if (size > sizeof(*rb)) return (EINVAL); - return (copyin(uaddr, &rb, size)); + return (copyin(uaddr, rb, size)); } static int From owner-svn-src-all@freebsd.org Wed Nov 18 03:43:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 255744776E9; Wed, 18 Nov 2020 03:43:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbTD90Yz3z4bKF; Wed, 18 Nov 2020 03:43:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 031AB3921; Wed, 18 Nov 2020 03:43:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI3h4Vw012511; Wed, 18 Nov 2020 03:43:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI3h4tQ012508; Wed, 18 Nov 2020 03:43:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011180343.0AI3h4tQ012508@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 18 Nov 2020 03:43:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367784 - head/sys/dev/isp X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/isp X-SVN-Commit-Revision: 367784 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 03:43:05 -0000 Author: mav Date: Wed Nov 18 03:43:03 2020 New Revision: 367784 URL: https://svnweb.freebsd.org/changeset/base/367784 Log: Move ecmd memory allocation itto separate DMA tag. Ecmd memory is not directly related to the request queue, only referenced from it sometimes in target mode. Separate allocation should be easier in case of fragmented memory and can be skipped when target is not built. MFC after: 1 month Modified: head/sys/dev/isp/isp_freebsd.c head/sys/dev/isp/isp_freebsd.h head/sys/dev/isp/isp_pci.c Modified: head/sys/dev/isp/isp_freebsd.c ============================================================================== --- head/sys/dev/isp/isp_freebsd.c Wed Nov 18 03:30:31 2020 (r367783) +++ head/sys/dev/isp/isp_freebsd.c Wed Nov 18 03:43:03 2020 (r367784) @@ -1320,6 +1320,7 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, if (isp->isp_dblev & ISP_LOGTDEBUG1) { isp_print_bytes(isp, "FCP Response Frame After Swizzling", MIN_FCP_RESPONSE_SIZE + sense_length, atp->ests); } + bus_dmamap_sync(isp->isp_osinfo.ecmd_dmat, isp->isp_osinfo.ecmd_map, BUS_DMASYNC_PREWRITE); addr = isp->isp_osinfo.ecmd_dma; addr += ((((isp_ecmd_t *)atp->ests) - isp->isp_osinfo.ecmd_base) * XCMD_SIZE); isp_prt(isp, ISP_LOGTDEBUG0, "%s: ests base %p vaddr %p ecmd_dma %jx addr %jx len %u", __func__, isp->isp_osinfo.ecmd_base, atp->ests, @@ -1469,6 +1470,7 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, if (isp->isp_dblev & ISP_LOGTDEBUG1) { isp_print_bytes(isp, "FCP Response Frame After Swizzling", MIN_FCP_RESPONSE_SIZE + sense_length, atp->ests); } + bus_dmamap_sync(isp->isp_osinfo.ecmd_dmat, isp->isp_osinfo.ecmd_map, BUS_DMASYNC_PREWRITE); addr = isp->isp_osinfo.ecmd_dma; addr += ((((isp_ecmd_t *)atp->ests) - isp->isp_osinfo.ecmd_base) * XCMD_SIZE); isp_prt(isp, ISP_LOGTDEBUG0, "%s: ests base %p vaddr %p ecmd_dma %jx addr %jx len %u", __func__, isp->isp_osinfo.ecmd_base, atp->ests, @@ -4309,6 +4311,7 @@ isp_timer(void *arg) callout_reset(&isp->isp_osinfo.tmo, isp_timer_count, isp_timer, isp); } +#ifdef ISP_TARGET_MODE isp_ecmd_t * isp_get_ecmd(ispsoftc_t *isp) { @@ -4325,3 +4328,4 @@ isp_put_ecmd(ispsoftc_t *isp, isp_ecmd_t *ecmd) ecmd->next = isp->isp_osinfo.ecmd_free; isp->isp_osinfo.ecmd_free = ecmd; } +#endif Modified: head/sys/dev/isp/isp_freebsd.h ============================================================================== --- head/sys/dev/isp/isp_freebsd.h Wed Nov 18 03:30:31 2020 (r367783) +++ head/sys/dev/isp/isp_freebsd.h Wed Nov 18 03:43:03 2020 (r367784) @@ -75,6 +75,7 @@ #define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE +#ifdef ISP_TARGET_MODE #define N_XCMDS 64 #define XCMD_SIZE 512 struct ispsoftc; @@ -85,7 +86,6 @@ typedef union isp_ecmd { isp_ecmd_t * isp_get_ecmd(struct ispsoftc *); void isp_put_ecmd(struct ispsoftc *, isp_ecmd_t *); -#ifdef ISP_TARGET_MODE #define ATPDPSIZE 4096 #define ATPDPHASHSIZE 32 #define ATPDPHASH(x) ((((x) >> 24) ^ ((x) >> 16) ^ ((x) >> 8) ^ (x)) & \ @@ -305,9 +305,13 @@ struct isposinfo { int exec_throttle; int cont_max; +#ifdef ISP_TARGET_MODE + bus_dma_tag_t ecmd_dmat; + bus_dmamap_t ecmd_map; bus_addr_t ecmd_dma; isp_ecmd_t * ecmd_base; isp_ecmd_t * ecmd_free; +#endif /* * Per-type private storage... Modified: head/sys/dev/isp/isp_pci.c ============================================================================== --- head/sys/dev/isp/isp_pci.c Wed Nov 18 03:30:31 2020 (r367783) +++ head/sys/dev/isp/isp_pci.c Wed Nov 18 03:43:03 2020 (r367784) @@ -1476,7 +1476,6 @@ isp_pci_mbxdma(ispsoftc_t *isp) bus_addr_t llim; /* low limit of unavailable dma */ bus_addr_t hlim; /* high limit of unavailable dma */ struct imush im; - isp_ecmd_t *ecmd; /* Already been here? If so, leave... */ if (isp->isp_xflist != NULL) @@ -1512,12 +1511,9 @@ isp_pci_mbxdma(ispsoftc_t *isp) } /* - * Allocate and map the request queue and a region for external - * DMA addressable command/status structures (22XX and later). + * Allocate and map the request queue. */ len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - if (isp->isp_type >= ISP_HA_FC_2200) - len += (N_XCMDS * XCMD_SIZE); if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, len, 1, len, 0, NULL, NULL, &isp->isp_osinfo.reqdmat)) { @@ -1540,12 +1536,39 @@ isp_pci_mbxdma(ispsoftc_t *isp) isp_prt(isp, ISP_LOGDEBUG0, "request area @ 0x%jx/0x%jx", (uintmax_t)im.maddr, (uintmax_t)len); isp->isp_rquest_dma = im.maddr; - base += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - im.maddr += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); + +#ifdef ISP_TARGET_MODE + /* + * Allocate region for external DMA addressable command/status structures. + */ if (isp->isp_type >= ISP_HA_FC_2200) { + isp_ecmd_t *ecmd; + + len = N_XCMDS * XCMD_SIZE; + if (bus_dma_tag_create(isp->isp_osinfo.dmat, XCMD_SIZE, slim, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + len, 1, len, 0, NULL, NULL, &isp->isp_osinfo.ecmd_dmat)) { + isp_prt(isp, ISP_LOGERR, "cannot create ECMD DMA tag"); + goto bad; + } + if (bus_dmamem_alloc(isp->isp_osinfo.ecmd_dmat, (void **)&base, + BUS_DMA_COHERENT, &isp->isp_osinfo.ecmd_map) != 0) { + isp_prt(isp, ISP_LOGERR, "cannot allocate ECMD DMA memory"); + bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); + goto bad; + } + isp->isp_osinfo.ecmd_base = (isp_ecmd_t *)base; + im.error = 0; + if (bus_dmamap_load(isp->isp_osinfo.ecmd_dmat, isp->isp_osinfo.ecmd_map, + base, len, imc, &im, BUS_DMA_NOWAIT) || im.error) { + isp_prt(isp, ISP_LOGERR, "error loading ECMD DMA map %d", im.error); + goto bad; + } + isp_prt(isp, ISP_LOGDEBUG0, "ecmd area @ 0x%jx/0x%jx", + (uintmax_t)im.maddr, (uintmax_t)len); + isp->isp_osinfo.ecmd_dma = im.maddr; isp->isp_osinfo.ecmd_free = (isp_ecmd_t *)base; - isp->isp_osinfo.ecmd_base = isp->isp_osinfo.ecmd_free; for (ecmd = isp->isp_osinfo.ecmd_free; ecmd < &isp->isp_osinfo.ecmd_free[N_XCMDS]; ecmd++) { if (ecmd == &isp->isp_osinfo.ecmd_free[N_XCMDS - 1]) @@ -1554,6 +1577,7 @@ isp_pci_mbxdma(ispsoftc_t *isp) ecmd->next = ecmd + 1; } } +#endif /* * Allocate and map the result queue. @@ -1786,6 +1810,19 @@ isp_pci_mbxdmafree(ispsoftc_t *isp) bus_dma_tag_destroy(isp->isp_osinfo.respdmat); isp->isp_result = NULL; } +#ifdef ISP_TARGET_MODE + if (isp->isp_osinfo.ecmd_dma != 0) { + bus_dmamap_unload(isp->isp_osinfo.ecmd_dmat, + isp->isp_osinfo.ecmd_map); + isp->isp_osinfo.ecmd_dma = 0; + } + if (isp->isp_osinfo.ecmd_base != NULL) { + bus_dmamem_free(isp->isp_osinfo.ecmd_dmat, isp->isp_osinfo.ecmd_base, + isp->isp_osinfo.ecmd_map); + bus_dma_tag_destroy(isp->isp_osinfo.ecmd_dmat); + isp->isp_osinfo.ecmd_base = NULL; + } +#endif if (isp->isp_rquest_dma != 0) { bus_dmamap_unload(isp->isp_osinfo.reqdmat, isp->isp_osinfo.reqmap); From owner-svn-src-all@freebsd.org Wed Nov 18 04:32:57 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 990EC2E0FCF for ; Wed, 18 Nov 2020 04:32:57 +0000 (UTC) (envelope-from XFGGHJO25_npai+svn-src-all=freebsd.org.102154941@wedeo-news.com) Received: from wedeo-news.com (wedeo-news.com [212.83.132.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbVKg5lyqz4dq7 for ; Wed, 18 Nov 2020 04:32:55 +0000 (UTC) (envelope-from XFGGHJO25_npai+svn-src-all=freebsd.org.102154941@wedeo-news.com) Received: from sendmail_check (localhost [127.0.0.1]) by wedeo-news.com (Postfix) with SMTP id 78E132649D9 for ; Wed, 18 Nov 2020 05:32:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wedeo-news.com; s=oxidkim; t=1605673968; bh=hhOCfBViT1D+Kp17yTjYkuc1cEmLva9ERS2nRLSktRM=; h=List-Unsubscribe:From:To:Subject:Date:From; b=MQI4wByxpBwf1ILpeOUfieYH2N85x2cYwyVHNZBosEftUnSQ3dvOP3rni+jJB1jSU OOFlgHs7Z6n2VFbYGJaVGTWLHoeZcbDwnatSmYDPrx2dRc8zQ56b3jK2kNhe510QRU XSNB72ejVhYufKrTP5sjlDdRWPwfiUx5sK0mjyh8Aq1XtC6nbwh6KL/7C4LmOUHE3Y VDuAxKl6v9Wgo2F4TP4yLHbw3P56UmdAELPMs+7es57+JybaGWH29wCpsG5+GzjJQ4 QI7lkSWtIIjEjpvu+WW6kOhBSAR0vJrvRqUfv+0DXk5dYQxS+ohJh1TZcFt6rEfTwD 1+zCgXk+X+R7w== X-MessageId: 887071717274795053||8386784583826745657676647082696966836846798271||102154941||8||887071717274795053 Message-ID: <2c63cd7a4bafd6eba0c627903e5aa5da@wedeo-news.com> From: "Thierry" To: Subject: Suivi Date: Wed, 18 Nov 2020 05:26:09 +0100 X-Mailer: OxiMailing 8.5.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 4CbVKg5lyqz4dq7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=wedeo-news.com header.s=oxidkim header.b=MQI4wByx; dmarc=pass (policy=none) header.from=wedeo-news.com; spf=pass (mx1.freebsd.org: domain of XFGGHJO25_npai@wedeo-news.com designates 212.83.132.75 as permitted sender) smtp.mailfrom=XFGGHJO25_npai@wedeo-news.com X-Spamd-Result: default: False [-2.70 / 15.00]; RWL_MAILSPIKE_GOOD(0.00)[212.83.132.75:from]; R_SPF_ALLOW(-0.20)[+a]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[wedeo-news.com:+]; DMARC_POLICY_ALLOW(-0.50)[wedeo-news.com,none]; NEURAL_HAM_SHORT(-0.99)[-0.991]; FORGED_SENDER(0.30)[contact@wedeo-news.com,XFGGHJO25_npai@wedeo-news.com]; RCVD_TLS_LAST(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[212.83.132.75:from]; ASN(0.00)[asn:12876, ipnet:212.83.128.0/19, country:FR]; FROM_NEQ_ENVFROM(0.00)[contact@wedeo-news.com,XFGGHJO25_npai@wedeo-news.com]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:~,4:~]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[wedeo-news.com:s=oxidkim]; TAGGED_FROM(0.00)[svn-src-all=freebsd.org.102154941]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; HTML_SHORT_LINK_IMG_2(1.00)[]; MIME_GOOD(-0.10)[multipart/related,multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-all@freebsd.org]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[212.83.132.75:from:127.0.2.255]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[svn-src-all] Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 04:32:57 -0000 Accusez-vous..=2E Si vous ne voyez pas ce message correctement, [consultez-le en ligne] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZQ&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqlcmXn4+gnNmnk5Si0= GKMqqt8f4GDlZdiZnmqZJRhZ2NglWRglmpuknamamOYdm2VmWlofHaXqGuTZ5Re05mn&v=3D8)= =2E Bonjour,=20 Accusez-vous bonne r=C3=A9ception de mon mail ? Nous sommes d=C3=A9j=C3=A0 en Novembre et la p=C3=A9riode des f=C3=AAtes = approche !=20 Avez-vous pens=C3=A9 =C3=A0 vos v=C5=93ux ? Renforcez le sentiment d'appartenance et captivez l=E2=80=99attention de = vos collaborateurs et de votre client=C3=A8le. En savoir + : = [Contactez-nous] = (mailto:thierry@wedeo.fr?subject=3DEn%20savoir%20plus%20sur%20la%20vid%C3%A= 9o%20voeux) D=C3=A9couvrez 3 exemples de vid=C3=A9os pour les voeux : [(image)] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgqdGnq9eWyl+W0= qBj28Wpmp9z2Z+UqX3DdLudfqaIlQ&v=3D8) [(image)] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgqdGnq9eWyl+W0= qBj28Wpmp9z2Z+snYqoZMWKfpictg&v=3D8) [(image)] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgqdGnq9eWyl+W0= qBj28Wpmp9z2Z9so5i8gdGco4tjvg&v=3D8) Avez-vous un projet de vid=C3=A9o en dessins anim=C3=A9s ? Si vous souhaitez r=C3=A9aliser une vid=C3=A9o marketing, institutionnelle = ou tutorielle d=C3=A9couvrez toutes nos vid=C3=A9os sur notre cha=C3=AEne = Youtube : [Cliquez-ici] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgqdGnq9eWyl+W0= qBjx8yWpaWZz5GId429gbtmnHx5nXWgsJGOsX/ThnnFf5uTypqYq6nVx5c&v=3D8) [(image)] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgqdGnq9eWyl+W0= qBj28Wpmp9z2Z9rjJ+dlMWab2ZoyA&v=3D8) [(image)] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgqdGnq9eWyl+W0= qBj28Wpmp9z2Z+YiKeUYZinhKmqzA&v=3D8) [(image)] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgqdGnq9eWyl+W0= qBj28Wpmp9z2Z+daXnGodpoiWVl3A&v=3D8) Je suis =C3=A0 votre disposition pour =C3=A9changer=2E Thierry Maillard / CEO =E2=98=8E=EF=B8=8F 06.12.98.41.16 [Notre site] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgp8eWnNFiy6Ni&= v=3D8) Contactez-nous : [(image)] = (mailto:thierry@wedeo.fr?subject=3DEn%20savoir%20plus%20sur%20le%20motion%2= 0design) Un correspondant dans votre r=C3=A9gion : Agent =C3=AEle de france : 01.86.86.01.42 Agent Ouest : 02.52.68.36.82 Agent Est : 03.74.82.00.14 Agent Sud : 04.28.63.00.35 Agent Sud-Ouest : 05.36.28.10.79 Notre soci=C3=A9t=C3=A9 produit plus de 40 vid=C3=A9os motion design par = mois. Que vous soyez une TPE ou PME , nous vous accompagnons de A =C3=A0 Z = dans la r=C3=A9alisation de contenus attractives et captivants. = [Contactez-nous] = (https://wedeo-news.com/c6.php?ec=3D2&l=3Di3p9q3itgGlo&i=3DZGRolWWXamtk&t= =3DZA&e=3DpqqkkaPVlGSUnNFyltSXnMSnyV+i1Zo&u=3Dm6iq1KOdYGaqp9xgp8eWnNFiy6Nix= qKi2MWYq5yukNCiqamT&v=3D8) Si vous ne souhaitez plus recevoir nos messages, suivez ce lien : [Veuillez me retirer de votre liste de diffusion] = (https://wedeo-news.com/d6.php?ec=3D2&l=3Di3p9q3itgGlo&e=3DpqqkkaPVlGSUnNFy= ltSXnMSnyV+i1Zo&i=3DZGRolWWXamtk&v=3D8) From owner-svn-src-all@freebsd.org Wed Nov 18 04:35:51 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F41C82E0FE3; Wed, 18 Nov 2020 04:35:50 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbVP26bQdz4dyR; Wed, 18 Nov 2020 04:35:50 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D52A04067; Wed, 18 Nov 2020 04:35:50 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI4ZoET043956; Wed, 18 Nov 2020 04:35:50 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI4ZoFu043953; Wed, 18 Nov 2020 04:35:50 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202011180435.0AI4ZoFu043953@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 18 Nov 2020 04:35:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367785 - in head/sys: fs/nfs nfsserver X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in head/sys: fs/nfs nfsserver X-SVN-Commit-Revision: 367785 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 04:35:51 -0000 Author: asomers Date: Wed Nov 18 04:35:49 2020 New Revision: 367785 URL: https://svnweb.freebsd.org/changeset/base/367785 Log: nfs: Mark unused statistics variable as reserved FreeBSD's NFS exporter has long exported some unused statistics fields. Revision r366992 removed them from nfsstat. This revision renames those fields in the kernel's exported structures to make it clear to other consumers that they are unused. Reported by: emaste Reviewed by: emaste Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D27258 Modified: head/sys/fs/nfs/nfs_commonport.c head/sys/fs/nfs/nfsport.h head/sys/nfsserver/nfsrvstats.h Modified: head/sys/fs/nfs/nfs_commonport.c ============================================================================== --- head/sys/fs/nfs/nfs_commonport.c Wed Nov 18 03:43:03 2020 (r367784) +++ head/sys/fs/nfs/nfs_commonport.c Wed Nov 18 04:35:49 2020 (r367785) @@ -541,16 +541,15 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, i < NFSV42_NOPS + NFSV4OP_FAKENOPS; i++, j++) oldnfsstats.srvrpccnt[j] = nfsstatsv1.srvrpccnt[i]; - oldnfsstats.srvrpc_errs = nfsstatsv1.srvrpc_errs; - oldnfsstats.srv_errs = nfsstatsv1.srv_errs; + oldnfsstats.reserved_0 = 0; + oldnfsstats.reserved_1 = 0; oldnfsstats.rpcrequests = nfsstatsv1.rpcrequests; oldnfsstats.rpctimeouts = nfsstatsv1.rpctimeouts; oldnfsstats.rpcunexpected = nfsstatsv1.rpcunexpected; oldnfsstats.rpcinvalid = nfsstatsv1.rpcinvalid; oldnfsstats.srvcache_inproghits = nfsstatsv1.srvcache_inproghits; - oldnfsstats.srvcache_idemdonehits = - nfsstatsv1.srvcache_idemdonehits; + oldnfsstats.reserved_2 = 0; oldnfsstats.srvcache_nonidemdonehits = nfsstatsv1.srvcache_nonidemdonehits; oldnfsstats.srvcache_misses = @@ -636,10 +635,8 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, i++, j++) nfsstatsov1.srvrpccnt[j] = nfsstatsv1.srvrpccnt[i]; - nfsstatsov1.srvrpc_errs = - nfsstatsv1.srvrpc_errs; - nfsstatsov1.srv_errs = - nfsstatsv1.srv_errs; + nfsstatsov1.reserved_0 = 0; + nfsstatsov1.reserved_1 = 0; nfsstatsov1.rpcrequests = nfsstatsv1.rpcrequests; nfsstatsov1.rpctimeouts = @@ -650,8 +647,7 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, nfsstatsv1.rpcinvalid; nfsstatsov1.srvcache_inproghits = nfsstatsv1.srvcache_inproghits; - nfsstatsov1.srvcache_idemdonehits = - nfsstatsv1.srvcache_idemdonehits; + nfsstatsov1.reserved_2 = 0; nfsstatsov1.srvcache_nonidemdonehits = nfsstatsv1.srvcache_nonidemdonehits; nfsstatsov1.srvcache_misses = @@ -750,10 +746,7 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, sizeof(nfsstatsv1.rpccnt)); } if ((uap->flag & NFSSVC_ZEROSRVSTATS) != 0) { - nfsstatsv1.srvrpc_errs = 0; - nfsstatsv1.srv_errs = 0; nfsstatsv1.srvcache_inproghits = 0; - nfsstatsv1.srvcache_idemdonehits = 0; nfsstatsv1.srvcache_nonidemdonehits = 0; nfsstatsv1.srvcache_misses = 0; nfsstatsv1.srvcache_tcppeak = 0; Modified: head/sys/fs/nfs/nfsport.h ============================================================================== --- head/sys/fs/nfs/nfsport.h Wed Nov 18 03:43:03 2020 (r367784) +++ head/sys/fs/nfs/nfsport.h Wed Nov 18 04:35:49 2020 (r367785) @@ -447,14 +447,14 @@ struct nfsstatsv1 { uint64_t rpccnt[NFSV42_NPROCS + 15]; uint64_t rpcretries; uint64_t srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15]; - uint64_t srvrpc_errs; - uint64_t srv_errs; + uint64_t reserved_0; + uint64_t reserved_1; uint64_t rpcrequests; uint64_t rpctimeouts; uint64_t rpcunexpected; uint64_t rpcinvalid; uint64_t srvcache_inproghits; - uint64_t srvcache_idemdonehits; + uint64_t reserved_2; uint64_t srvcache_nonidemdonehits; uint64_t srvcache_misses; uint64_t srvcache_tcppeak; @@ -512,14 +512,14 @@ struct nfsstatsov1 { uint64_t rpccnt[NFSV42_NPROCS + 4]; uint64_t rpcretries; uint64_t srvrpccnt[NFSV42_PURENOPS + NFSV4OP_FAKENOPS]; - uint64_t srvrpc_errs; - uint64_t srv_errs; + uint64_t reserved_0; + uint64_t reserved_1; uint64_t rpcrequests; uint64_t rpctimeouts; uint64_t rpcunexpected; uint64_t rpcinvalid; uint64_t srvcache_inproghits; - uint64_t srvcache_idemdonehits; + uint64_t reserved_2; uint64_t srvcache_nonidemdonehits; uint64_t srvcache_misses; uint64_t srvcache_tcppeak; @@ -574,14 +574,14 @@ struct ext_nfsstats { int rpccnt[NFSV4_NPROCS]; int rpcretries; int srvrpccnt[NFSV4OP_NOPS + NFSV4OP_FAKENOPS]; - int srvrpc_errs; - int srv_errs; + int reserved_0; + int reserved_1; int rpcrequests; int rpctimeouts; int rpcunexpected; int rpcinvalid; int srvcache_inproghits; - int srvcache_idemdonehits; + int reserved_2; int srvcache_nonidemdonehits; int srvcache_misses; int srvcache_tcppeak; Modified: head/sys/nfsserver/nfsrvstats.h ============================================================================== --- head/sys/nfsserver/nfsrvstats.h Wed Nov 18 03:43:03 2020 (r367784) +++ head/sys/nfsserver/nfsrvstats.h Wed Nov 18 04:35:49 2020 (r367785) @@ -42,10 +42,10 @@ * Server stats structure */ struct nfsrvstats { - int srvrpc_errs; - int srv_errs; + int reserved_0; + int reserved_1; int srvcache_inproghits; - int srvcache_idemdonehits; + int reserved_2; int srvcache_nonidemdonehits; int srvcache_misses; int srvvop_writes; From owner-svn-src-all@freebsd.org Wed Nov 18 04:45:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 624E42E18F7; Wed, 18 Nov 2020 04:45:12 +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 4CbVbp0f4yz4fMn; Wed, 18 Nov 2020 04:45:09 +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 0AI4iwYf037400 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 18 Nov 2020 06:45:01 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 0AI4iwYf037400 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 0AI4iwVf037399; Wed, 18 Nov 2020 06:44:58 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 18 Nov 2020 06:44:58 +0200 From: Konstantin Belousov To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r367713 - head/sys/kern Message-ID: References: <202011160309.0AG39JmP067464@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4CbVbp0f4yz4fMn X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 04:45:12 -0000 On Tue, Nov 17, 2020 at 03:36:31PM +0100, Mateusz Guzik wrote: > On 11/17/20, Konstantin Belousov wrote: > > On Tue, Nov 17, 2020 at 04:15:12AM +0100, Mateusz Guzik wrote: > >> On 11/17/20, Konstantin Belousov wrote: > >> > On Mon, Nov 16, 2020 at 03:09:19AM +0000, Mateusz Guzik wrote: > >> >> Author: mjg > >> >> Date: Mon Nov 16 03:09:18 2020 > >> >> New Revision: 367713 > >> >> URL: https://svnweb.freebsd.org/changeset/base/367713 > >> >> > >> >> Log: > >> >> select: replace reference counting with memory barriers in selfd > >> >> > >> >> Refcounting was added to combat a race between selfdfree and > >> >> doselwakup, > >> >> but it adds avoidable overhead. > >> >> > >> >> selfdfree detects it can free the object by ->sf_si == NULL, thus we > >> >> can > >> >> ensure that the condition only holds after all accesses are > >> >> completed. > >> >> > >> >> Modified: > >> >> head/sys/kern/sys_generic.c > >> >> > >> >> Modified: head/sys/kern/sys_generic.c > >> >> ============================================================================== > >> >> --- head/sys/kern/sys_generic.c Sun Nov 15 22:49:28 2020 (r367712) > >> >> +++ head/sys/kern/sys_generic.c Mon Nov 16 03:09:18 2020 (r367713) > >> >> @@ -156,7 +156,6 @@ struct selfd { > >> >> struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ > >> >> struct seltd *sf_td; /* (k) owning seltd. */ > >> >> void *sf_cookie; /* (k) fd or pollfd. */ > >> >> - u_int sf_refs; > >> >> }; > >> >> > >> >> MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); > >> >> @@ -1704,16 +1703,17 @@ static void > >> >> selfdfree(struct seltd *stp, struct selfd *sfp) > >> >> { > >> >> STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); > >> >> - if (sfp->sf_si != NULL) { > >> >> + /* > >> >> + * Paired with doselwakeup. > >> >> + */ > >> >> + if (atomic_load_acq_ptr((uintptr_t *)&sfp->sf_si) != (uintptr_t)NULL) > >> >> { > >> > This could be != 0. > >> > > >> >> mtx_lock(sfp->sf_mtx); > >> >> if (sfp->sf_si != NULL) { > >> >> TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); > >> >> - refcount_release(&sfp->sf_refs); > >> >> } > >> >> mtx_unlock(sfp->sf_mtx); > >> >> } > >> >> - if (refcount_release(&sfp->sf_refs)) > >> >> - free(sfp, M_SELFD); > >> >> + free(sfp, M_SELFD); > >> > What guarantees that doselwakeup() finished with sfp ? > >> > > >> > >> Release semantics provided by atomic_store_rel_ptr -- it means the > >> NULL store is the last access, neither CPU nor the compiler are going > >> to reorder preceding loads/stores past it. > > It only guarantees that if we observed NULL as the result of load. > > > > If that did not happen selfdfree takes the lock. If the entry is still > there, it removes it and doselwakeup will not see it after it takes > the lock. If the entry is not there, doselwaekup is done with it > because it released the lock. I still do not understand it. selfdfree() indeed takes sf_mtx and rechecks sf_si. But what prevents doselwakeup() to store NULL into sf_si at any moment. e.g. after free() is done ? selfdfree() takes seltd mutex, not selinfo. From owner-svn-src-all@freebsd.org Wed Nov 18 09:00:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C4C7A2E8300; Wed, 18 Nov 2020 09:00:05 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbcFx5GQHz4rdq; Wed, 18 Nov 2020 09:00:05 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A7A6B746F; Wed, 18 Nov 2020 09:00:05 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AI905s1005954; Wed, 18 Nov 2020 09:00:05 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AI9056m005953; Wed, 18 Nov 2020 09:00:05 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011180900.0AI9056m005953@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Wed, 18 Nov 2020 09:00:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367786 - stable/12/share/man/man7 X-SVN-Group: stable-12 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/12/share/man/man7 X-SVN-Commit-Revision: 367786 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 09:00:05 -0000 Author: 0mp (doc,ports committer) Date: Wed Nov 18 09:00:05 2020 New Revision: 367786 URL: https://svnweb.freebsd.org/changeset/base/367786 Log: MFC r367552: Do not document MOTIFLIB in ports(7) Perhaps it made sense in 1998 (r32836), but now it feels a bit out of place. We tend to avoid documenting non-essential ports variables in the manual page (we try to document them in the Porter's Handbook instead). Modified: stable/12/share/man/man7/ports.7 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man7/ports.7 ============================================================================== --- stable/12/share/man/man7/ports.7 Wed Nov 18 04:35:49 2020 (r367785) +++ stable/12/share/man/man7/ports.7 Wed Nov 18 09:00:05 2020 (r367786) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2020 +.Dd November 10, 2020 .Dt PORTS 7 .Os .Sh NAME @@ -464,9 +464,6 @@ Normally .Xr fetch 1 . .It Va FORCE_PKG_REGISTER If set, overwrite any existing package registration on the system. -.It Va MOTIFLIB -Location of -.Pa "libXm\&." Ns Brq Pa a , Ns Pa so . .It Va INTERACTIVE If defined, only operate on a port if it requires interaction. .It Va BATCH From owner-svn-src-all@freebsd.org Wed Nov 18 13:22:23 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D04732EF857; Wed, 18 Nov 2020 13:22:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbk4b5Kd6z3P8y; Wed, 18 Nov 2020 13:22:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A82DC12858; Wed, 18 Nov 2020 13:22:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIDMN2v066713; Wed, 18 Nov 2020 13:22:23 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIDMMWC066709; Wed, 18 Nov 2020 13:22:22 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011181322.0AIDMMWC066709@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 18 Nov 2020 13:22:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367787 - in head: stand/kshim sys/dev/usb X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head: stand/kshim sys/dev/usb X-SVN-Commit-Revision: 367787 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 13:22:23 -0000 Author: hselasky Date: Wed Nov 18 13:22:22 2020 New Revision: 367787 URL: https://svnweb.freebsd.org/changeset/base/367787 Log: Fix build of USB bootloader code by adding checks for _STANDALONE being defined. Currently the USB bootloader code is not part of buildworld. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/stand/kshim/bsd_kernel.h head/sys/dev/usb/usb.h head/sys/dev/usb/usb_pf.h head/sys/dev/usb/usbdi.h head/sys/dev/usb/usbhid.h Modified: head/stand/kshim/bsd_kernel.h ============================================================================== --- head/stand/kshim/bsd_kernel.h Wed Nov 18 09:00:05 2020 (r367786) +++ head/stand/kshim/bsd_kernel.h Wed Nov 18 13:22:22 2020 (r367787) @@ -27,9 +27,12 @@ #ifndef _BSD_KERNEL_H_ #define _BSD_KERNEL_H_ -#define _KERNEL +#if !defined(_STANDALONE) +#error "_STANDALONE is not defined!" +#endif + #undef __FreeBSD_version -#define __FreeBSD_version 1100000 +#define __FreeBSD_version 1300000 #include #include Modified: head/sys/dev/usb/usb.h ============================================================================== --- head/sys/dev/usb/usb.h Wed Nov 18 09:00:05 2020 (r367786) +++ head/sys/dev/usb/usb.h Wed Nov 18 13:22:22 2020 (r367787) @@ -41,7 +41,7 @@ #ifndef _USB_STANDARD_H_ #define _USB_STANDARD_H_ -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_STANDALONE) #ifndef USB_GLOBAL_INCLUDE_FILE #include "opt_usb.h" #endif @@ -57,7 +57,7 @@ SYSCTL_DECL(_hw_usb); MALLOC_DECLARE(M_USB); MALLOC_DECLARE(M_USBDEV); -#endif /* _KERNEL */ +#endif /* _KERNEL || _STANDALONE */ #ifndef USB_GLOBAL_INCLUDE_FILE #include Modified: head/sys/dev/usb/usb_pf.h ============================================================================== --- head/sys/dev/usb/usb_pf.h Wed Nov 18 09:00:05 2020 (r367786) +++ head/sys/dev/usb/usb_pf.h Wed Nov 18 13:22:22 2020 (r367787) @@ -113,10 +113,10 @@ extern uint8_t usbpf_framehdr_size_ok[ #define USBPF_XFERTAP_SUBMIT 0 #define USBPF_XFERTAP_DONE 1 -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_STANDALONE) void usbpf_attach(struct usb_bus *); void usbpf_detach(struct usb_bus *); void usbpf_xfertap(struct usb_xfer *, int); -#endif +#endif /* _KERNEL || _STANDALONE */ +#endif /* _DEV_USB_PF_H */ -#endif Modified: head/sys/dev/usb/usbdi.h ============================================================================== --- head/sys/dev/usb/usbdi.h Wed Nov 18 09:00:05 2020 (r367786) +++ head/sys/dev/usb/usbdi.h Wed Nov 18 13:22:22 2020 (r367787) @@ -88,7 +88,7 @@ typedef enum { /* keep in sync with usb_errstr_table * #define USB_NO_TIMEOUT 0 #define USB_DEFAULT_TIMEOUT 5000 /* 5000 ms = 5 seconds */ -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_STANDALONE) /* typedefs */ typedef void (usb_callback_t)(struct usb_xfer *, usb_error_t); @@ -709,5 +709,5 @@ void *usb_fifo_softc(struct usb_fifo *fifo); void usb_fifo_set_close_zlp(struct usb_fifo *, uint8_t); void usb_fifo_set_write_defrag(struct usb_fifo *, uint8_t); void usb_fifo_free(struct usb_fifo *f); -#endif /* _KERNEL */ -#endif /* _USB_USBDI_H_ */ +#endif /* _KERNEL || _STANDALONE */ +#endif /* _USB_USBDI_H_ */ Modified: head/sys/dev/usb/usbhid.h ============================================================================== --- head/sys/dev/usb/usbhid.h Wed Nov 18 09:00:05 2020 (r367786) +++ head/sys/dev/usb/usbhid.h Wed Nov 18 13:22:22 2020 (r367787) @@ -205,7 +205,7 @@ struct usb_hid_descriptor { #define HUM_INCH 0x13 #define HUM_DEGREE 0x14 -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_STANDALONE) struct usb_config_descriptor; enum hid_kind { @@ -274,5 +274,5 @@ usb_error_t usbd_req_get_hid_desc(struct usb_device *u int32_t hid_item_resolution(struct hid_item *hi); int hid_is_mouse(const void *d_ptr, uint16_t d_len); int hid_is_keyboard(const void *d_ptr, uint16_t d_len); -#endif /* _KERNEL */ -#endif /* _USB_HID_H_ */ +#endif /* _KERNEL || _STANDALONE */ +#endif /* _USB_HID_H_ */ From owner-svn-src-all@freebsd.org Wed Nov 18 13:45:33 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3BB072EFCC6; Wed, 18 Nov 2020 13:45:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbkbK1GQdz3Pxk; Wed, 18 Nov 2020 13:45:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1DFC81302A; Wed, 18 Nov 2020 13:45:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIDjWkE079469; Wed, 18 Nov 2020 13:45:32 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIDjWR2079468; Wed, 18 Nov 2020 13:45:32 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011181345.0AIDjWR2079468@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 18 Nov 2020 13:45:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367788 - head/sys/modules/linuxkpi X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/modules/linuxkpi X-SVN-Commit-Revision: 367788 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 13:45:33 -0000 Author: hselasky Date: Wed Nov 18 13:45:32 2020 New Revision: 367788 URL: https://svnweb.freebsd.org/changeset/base/367788 Log: Add missing header file when building the LinuxKPI module separately. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sys/modules/linuxkpi/Makefile Modified: head/sys/modules/linuxkpi/Makefile ============================================================================== --- head/sys/modules/linuxkpi/Makefile Wed Nov 18 13:22:22 2020 (r367787) +++ head/sys/modules/linuxkpi/Makefile Wed Nov 18 13:45:32 2020 (r367788) @@ -25,7 +25,7 @@ SRCS= linux_compat.c \ .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "i386" -SRCS+= opt_acpi.h linux_acpi.c +SRCS+= opt_acpi.h acpi_if.h linux_acpi.c .endif SRCS+= ${LINUXKPI_GENSRCS} From owner-svn-src-all@freebsd.org Wed Nov 18 13:47:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0738E2EFFBA; Wed, 18 Nov 2020 13:47:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbkdC6rMKz3QNS; Wed, 18 Nov 2020 13:47:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCB6212DE8; Wed, 18 Nov 2020 13:47:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIDlBrB079531; Wed, 18 Nov 2020 13:47:11 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIDlBPr079529; Wed, 18 Nov 2020 13:47:11 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011181347.0AIDlBPr079529@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 18 Nov 2020 13:47:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367789 - in head/sys/compat/linuxkpi/common/include: asm linux X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/compat/linuxkpi/common/include: asm linux X-SVN-Commit-Revision: 367789 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 13:47:12 -0000 Author: hselasky Date: Wed Nov 18 13:47:11 2020 New Revision: 367789 URL: https://svnweb.freebsd.org/changeset/base/367789 Log: Allow LinuxKPI types to be used in bootloaders, by checking for the _STANDALONE definition. No functional change intended. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: head/sys/compat/linuxkpi/common/include/asm/types.h head/sys/compat/linuxkpi/common/include/linux/types.h Modified: head/sys/compat/linuxkpi/common/include/asm/types.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/asm/types.h Wed Nov 18 13:45:32 2020 (r367788) +++ head/sys/compat/linuxkpi/common/include/asm/types.h Wed Nov 18 13:47:11 2020 (r367789) @@ -31,7 +31,7 @@ #ifndef _ASM_TYPES_H_ #define _ASM_TYPES_H_ -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_STANDALONE) #include @@ -59,6 +59,6 @@ typedef vm_paddr_t dma64_addr_t; typedef unsigned short umode_t; -#endif /* _KERNEL */ +#endif /* _KERNEL || _STANDALONE */ #endif /* _ASM_TYPES_H_ */ Modified: head/sys/compat/linuxkpi/common/include/linux/types.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/types.h Wed Nov 18 13:45:32 2020 (r367788) +++ head/sys/compat/linuxkpi/common/include/linux/types.h Wed Nov 18 13:47:11 2020 (r367789) @@ -57,8 +57,10 @@ typedef uint16_t __aligned_u16 __aligned(sizeof(uint16 typedef uint32_t __aligned_u32 __aligned(sizeof(uint32_t)); typedef uint64_t __aligned_u64 __aligned(sizeof(uint64_t)); +#ifdef _KERNEL typedef unsigned short ushort; typedef unsigned int uint; +#endif typedef unsigned long ulong; typedef unsigned gfp_t; typedef off_t loff_t; @@ -67,7 +69,7 @@ typedef uint16_t __bitwise__ __sum16; typedef unsigned long pgoff_t; typedef unsigned __poll_t; -typedef u64 phys_addr_t; +typedef uint64_t phys_addr_t; typedef size_t __kernel_size_t; From owner-svn-src-all@freebsd.org Wed Nov 18 13:52:14 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 817A42EFDFD; Wed, 18 Nov 2020 13:52:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbkl23JsXz3Qjq; Wed, 18 Nov 2020 13:52:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64A0812E60; Wed, 18 Nov 2020 13:52:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIDqEiE085190; Wed, 18 Nov 2020 13:52:14 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIDqEAY085189; Wed, 18 Nov 2020 13:52:14 GMT (envelope-from ae@FreeBSD.org) Message-Id: <202011181352.0AIDqEAY085189@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 18 Nov 2020 13:52:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367790 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 367790 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 13:52:14 -0000 Author: ae Date: Wed Nov 18 13:52:13 2020 New Revision: 367790 URL: https://svnweb.freebsd.org/changeset/base/367790 Log: MFC r367594: Fix possible NULL pointer dereference. lagg(4) replaces if_output method of its child interfaces and expects that this method can be called only by child interfaces. But it is possible that lagg_port_output() could be called by children of child interfaces. In this case ifnet's if_lagg field is NULL. Add check that lp is not NULL. Modified: stable/12/sys/net/if_lagg.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/if_lagg.c ============================================================================== --- stable/12/sys/net/if_lagg.c Wed Nov 18 13:47:11 2020 (r367789) +++ stable/12/sys/net/if_lagg.c Wed Nov 18 13:52:13 2020 (r367790) @@ -1033,7 +1033,8 @@ lagg_port_output(struct ifnet *ifp, struct mbuf *m, switch (dst->sa_family) { case pseudo_AF_HDRCMPLT: case AF_UNSPEC: - return ((*lp->lp_output)(ifp, m, dst, ro)); + if (lp != NULL) + return ((*lp->lp_output)(ifp, m, dst, ro)); } /* drop any other frames */ From owner-svn-src-all@freebsd.org Wed Nov 18 14:27:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A7DDF468B2B; Wed, 18 Nov 2020 14:27:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CblWd48SLz3hN9; Wed, 18 Nov 2020 14:27:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C8B412FF2; Wed, 18 Nov 2020 14:27:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIERPkG003684; Wed, 18 Nov 2020 14:27:25 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIERO1o003680; Wed, 18 Nov 2020 14:27:24 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011181427.0AIERO1o003680@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 18 Nov 2020 14:27:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367791 - in stable/12/sys: kern sys X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys: kern sys X-SVN-Commit-Revision: 367791 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:27:25 -0000 Author: markj Date: Wed Nov 18 14:27:24 2020 New Revision: 367791 URL: https://svnweb.freebsd.org/changeset/base/367791 Log: MFC r367588: Fix a pair of races in SIGIO registration Modified: stable/12/sys/kern/kern_descrip.c stable/12/sys/kern/kern_exit.c stable/12/sys/kern/kern_proc.c stable/12/sys/sys/signalvar.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_descrip.c ============================================================================== --- stable/12/sys/kern/kern_descrip.c Wed Nov 18 13:52:13 2020 (r367790) +++ stable/12/sys/kern/kern_descrip.c Wed Nov 18 14:27:24 2020 (r367791) @@ -954,6 +954,40 @@ unlock: return (error); } +static void +sigiofree(struct sigio *sigio) +{ + crfree(sigio->sio_ucred); + free(sigio, M_SIGIO); +} + +static struct sigio * +funsetown_locked(struct sigio *sigio) +{ + struct proc *p; + struct pgrp *pg; + + SIGIO_ASSERT_LOCKED(); + + if (sigio == NULL) + return (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); + PGRP_UNLOCK(pg); + } else { + p = sigio->sio_proc; + PROC_LOCK(p); + SLIST_REMOVE(&sigio->sio_proc->p_sigiolst, sigio, + sigio, sio_pgsigio); + PROC_UNLOCK(p); + } + return (sigio); +} + /* * If sigio is on the list associated with a process or process group, * disable signalling from the device, remove sigio from the list and @@ -964,92 +998,82 @@ funsetown(struct sigio **sigiop) { struct sigio *sigio; + /* Racy check, consumers must provide synchronization. */ if (*sigiop == NULL) return; + SIGIO_LOCK(); - sigio = *sigiop; - if (sigio == NULL) { - SIGIO_UNLOCK(); - return; - } - *(sigio->sio_myref) = NULL; - if ((sigio)->sio_pgid < 0) { - struct pgrp *pg = (sigio)->sio_pgrp; - PGRP_LOCK(pg); - SLIST_REMOVE(&sigio->sio_pgrp->pg_sigiolst, sigio, - sigio, sio_pgsigio); - PGRP_UNLOCK(pg); - } else { - struct proc *p = (sigio)->sio_proc; - PROC_LOCK(p); - SLIST_REMOVE(&sigio->sio_proc->p_sigiolst, sigio, - sigio, sio_pgsigio); - PROC_UNLOCK(p); - } + sigio = funsetown_locked(*sigiop); SIGIO_UNLOCK(); - crfree(sigio->sio_ucred); - free(sigio, M_SIGIO); + if (sigio != NULL) + sigiofree(sigio); } /* - * Free a list of sigio structures. - * We only need to lock the SIGIO_LOCK because we have made ourselves - * inaccessible to callers of fsetown and therefore do not need to lock - * the proc or pgrp struct for the list manipulation. + * Free a list of sigio structures. The caller must ensure that new sigio + * structures cannot be added after this point. For process groups this is + * guaranteed using the proctree lock; for processes, the P_WEXIT flag serves + * as an interlock. */ void funsetownlst(struct sigiolst *sigiolst) { struct proc *p; struct pgrp *pg; - struct sigio *sigio; + struct sigio *sigio, *tmp; + /* Racy check. */ sigio = SLIST_FIRST(sigiolst); if (sigio == NULL) return; + p = NULL; pg = NULL; + SIGIO_LOCK(); + sigio = SLIST_FIRST(sigiolst); + if (sigio == NULL) { + SIGIO_UNLOCK(); + return; + } + /* - * Every entry of the list should belong - * to a single proc or pgrp. + * Every entry of the list should belong to a single proc or pgrp. */ if (sigio->sio_pgid < 0) { pg = sigio->sio_pgrp; - PGRP_LOCK_ASSERT(pg, MA_NOTOWNED); + sx_assert(&proctree_lock, SX_XLOCKED); + PGRP_LOCK(pg); } else /* if (sigio->sio_pgid > 0) */ { p = sigio->sio_proc; - PROC_LOCK_ASSERT(p, MA_NOTOWNED); + PROC_LOCK(p); + KASSERT((p->p_flag & P_WEXIT) != 0, + ("%s: process %p is not exiting", __func__, p)); } - SIGIO_LOCK(); - while ((sigio = SLIST_FIRST(sigiolst)) != NULL) { - *(sigio->sio_myref) = NULL; + SLIST_FOREACH(sigio, sigiolst, sio_pgsigio) { + *sigio->sio_myref = NULL; if (pg != NULL) { KASSERT(sigio->sio_pgid < 0, ("Proc sigio in pgrp sigio list")); KASSERT(sigio->sio_pgrp == pg, ("Bogus pgrp in sigio list")); - PGRP_LOCK(pg); - SLIST_REMOVE(&pg->pg_sigiolst, sigio, sigio, - sio_pgsigio); - PGRP_UNLOCK(pg); } else /* if (p != NULL) */ { KASSERT(sigio->sio_pgid > 0, ("Pgrp sigio in proc sigio list")); KASSERT(sigio->sio_proc == p, ("Bogus proc in sigio list")); - PROC_LOCK(p); - SLIST_REMOVE(&p->p_sigiolst, sigio, sigio, - sio_pgsigio); - PROC_UNLOCK(p); } - SIGIO_UNLOCK(); - crfree(sigio->sio_ucred); - free(sigio, M_SIGIO); - SIGIO_LOCK(); } + + if (pg != NULL) + PGRP_UNLOCK(pg); + else + PROC_UNLOCK(p); SIGIO_UNLOCK(); + + SLIST_FOREACH_SAFE(sigio, sigiolst, sio_pgsigio, tmp) + sigiofree(sigio); } /* @@ -1063,7 +1087,7 @@ fsetown(pid_t pgid, struct sigio **sigiop) { struct proc *proc; struct pgrp *pgrp; - struct sigio *sigio; + struct sigio *osigio, *sigio; int ret; if (pgid == 0) { @@ -1073,13 +1097,14 @@ fsetown(pid_t pgid, struct sigio **sigiop) ret = 0; - /* Allocate and fill in the new sigio out of locks. */ 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) { @@ -1095,20 +1120,21 @@ fsetown(pid_t pgid, struct sigio **sigiop) * restrict FSETOWN to the current process or process * group for maximum safety. */ - PROC_UNLOCK(proc); if (proc->p_session != curthread->td_proc->p_session) { + PROC_UNLOCK(proc); ret = EPERM; goto fail; } - pgrp = NULL; + sigio->sio_proc = proc; + SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, sio_pgsigio); + PROC_UNLOCK(proc); } else /* if (pgid < 0) */ { pgrp = pgfind(-pgid); if (pgrp == NULL) { ret = ESRCH; goto fail; } - PGRP_UNLOCK(pgrp); /* * Policy - Don't allow a process to FSETOWN a process @@ -1119,44 +1145,28 @@ fsetown(pid_t pgid, struct sigio **sigiop) * group for maximum safety. */ if (pgrp->pg_session != curthread->td_proc->p_session) { + PGRP_UNLOCK(pgrp); ret = EPERM; goto fail; } - proc = NULL; - } - funsetown(sigiop); - if (pgid > 0) { - PROC_LOCK(proc); - /* - * Since funsetownlst() is called without the proctree - * locked, we need to check for P_WEXIT. - * XXX: is ESRCH correct? - */ - if ((proc->p_flag & P_WEXIT) != 0) { - PROC_UNLOCK(proc); - ret = ESRCH; - goto fail; - } - SLIST_INSERT_HEAD(&proc->p_sigiolst, sigio, sio_pgsigio); - sigio->sio_proc = proc; - PROC_UNLOCK(proc); - } else { - PGRP_LOCK(pgrp); SLIST_INSERT_HEAD(&pgrp->pg_sigiolst, sigio, sio_pgsigio); sigio->sio_pgrp = pgrp; PGRP_UNLOCK(pgrp); } sx_sunlock(&proctree_lock); - SIGIO_LOCK(); *sigiop = sigio; SIGIO_UNLOCK(); + if (osigio != NULL) + sigiofree(osigio); return (0); fail: + SIGIO_UNLOCK(); sx_sunlock(&proctree_lock); - crfree(sigio->sio_ucred); - free(sigio, M_SIGIO); + sigiofree(sigio); + if (osigio != NULL) + sigiofree(osigio); return (ret); } Modified: stable/12/sys/kern/kern_exit.c ============================================================================== --- stable/12/sys/kern/kern_exit.c Wed Nov 18 13:52:13 2020 (r367790) +++ stable/12/sys/kern/kern_exit.c Wed Nov 18 14:27:24 2020 (r367791) @@ -355,7 +355,7 @@ exit1(struct thread *td, int rval, int signo) /* * Reset any sigio structures pointing to us as a result of - * F_SETOWN with our pid. + * F_SETOWN with our pid. The P_WEXIT flag interlocks with fsetown(). */ funsetownlst(&p->p_sigiolst); Modified: stable/12/sys/kern/kern_proc.c ============================================================================== --- stable/12/sys/kern/kern_proc.c Wed Nov 18 13:52:13 2020 (r367790) +++ stable/12/sys/kern/kern_proc.c Wed Nov 18 14:27:24 2020 (r367791) @@ -686,7 +686,8 @@ pgdelete(struct pgrp *pgrp) /* * Reset any sigio structures pointing to us as a result of - * F_SETOWN with our pgid. + * F_SETOWN with our pgid. The proctree lock ensures that + * new sigio structures will not be added after this point. */ funsetownlst(&pgrp->pg_sigiolst); Modified: stable/12/sys/sys/signalvar.h ============================================================================== --- stable/12/sys/sys/signalvar.h Wed Nov 18 13:52:13 2020 (r367790) +++ stable/12/sys/sys/signalvar.h Wed Nov 18 14:27:24 2020 (r367791) @@ -320,7 +320,7 @@ struct thread; #define SIGIO_TRYLOCK() mtx_trylock(&sigio_lock) #define SIGIO_UNLOCK() mtx_unlock(&sigio_lock) #define SIGIO_LOCKED() mtx_owned(&sigio_lock) -#define SIGIO_ASSERT(type) mtx_assert(&sigio_lock, type) +#define SIGIO_ASSERT_LOCKED(type) mtx_assert(&sigio_lock, MA_OWNED) extern struct mtx sigio_lock; From owner-svn-src-all@freebsd.org Wed Nov 18 14:27:48 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 22F24468C07; Wed, 18 Nov 2020 14:27:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CblX40VQzz3hbm; Wed, 18 Nov 2020 14:27:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 03D6E137B8; Wed, 18 Nov 2020 14:27:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIERlue003748; Wed, 18 Nov 2020 14:27:47 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIERlkM003747; Wed, 18 Nov 2020 14:27:47 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011181427.0AIERlkM003747@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 18 Nov 2020 14:27:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367792 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 367792 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:27:48 -0000 Author: markj Date: Wed Nov 18 14:27:47 2020 New Revision: 367792 URL: https://svnweb.freebsd.org/changeset/base/367792 Log: MFC r367596: iflib: Free full mbuf chains when draining transmit queues Modified: stable/12/sys/net/iflib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/iflib.c ============================================================================== --- stable/12/sys/net/iflib.c Wed Nov 18 14:27:24 2020 (r367791) +++ stable/12/sys/net/iflib.c Wed Nov 18 14:27:47 2020 (r367792) @@ -1860,7 +1860,7 @@ iflib_txsd_free(if_ctx_t ctx, iflib_txq_t txq, int i) bus_dmamap_unload(txq->ift_tso_buf_tag, txq->ift_sds.ifsd_tso_map[i]); } - m_free(*mp); + m_freem(*mp); DBG_COUNTER_INC(tx_frees); *mp = NULL; } @@ -3680,7 +3680,7 @@ iflib_txq_drain(struct ifmp_ring *r, uint32_t cidx, ui DBG_COUNTER_INC(txq_drain_flushing); for (i = 0; i < avail; i++) { if (__predict_true(r->items[(cidx + i) & (r->size-1)] != (void *)txq)) - m_free(r->items[(cidx + i) & (r->size-1)]); + m_freem(r->items[(cidx + i) & (r->size-1)]); r->items[(cidx + i) & (r->size-1)] = NULL; } return (avail); From owner-svn-src-all@freebsd.org Wed Nov 18 14:31:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3143E468A64; Wed, 18 Nov 2020 14:31:00 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cblbm0mvhz3hgh; Wed, 18 Nov 2020 14:31:00 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0D7B31352D; Wed, 18 Nov 2020 14:31:00 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIEUxWk007266; Wed, 18 Nov 2020 14:30:59 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIEUxK9007263; Wed, 18 Nov 2020 14:30:59 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181430.0AIEUxK9007263@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 14:30:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367793 - vendor-sys/ena-com/dist X-SVN-Group: vendor-sys X-SVN-Commit-Author: mw X-SVN-Commit-Paths: vendor-sys/ena-com/dist X-SVN-Commit-Revision: 367793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:31:00 -0000 Author: mw Date: Wed Nov 18 14:30:59 2020 New Revision: 367793 URL: https://svnweb.freebsd.org/changeset/base/367793 Log: ena-com: Fix ena-com to allocate cdesc aligned to 4k The latest generation hardware requires IO CQ (completion queue) descriptors memory to be aligned to a 4K. It needs that feature for the best performance. Allocating unaligned descriptors will have a big performance impact as the packet processing in a HW won't be optimized properly. It's a critical fix, especially for the arm64 EC2 instances. Modified: vendor-sys/ena-com/dist/ena_com.c vendor-sys/ena-com/dist/ena_com.h vendor-sys/ena-com/dist/ena_plat.h Modified: vendor-sys/ena-com/dist/ena_com.c ============================================================================== --- vendor-sys/ena-com/dist/ena_com.c Wed Nov 18 14:27:47 2020 (r367792) +++ vendor-sys/ena-com/dist/ena_com.c Wed Nov 18 14:30:59 2020 (r367793) @@ -449,19 +449,21 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_ size = io_cq->cdesc_entry_size_in_bytes * io_cq->q_depth; io_cq->bus = ena_dev->bus; - ENA_MEM_ALLOC_COHERENT_NODE(ena_dev->dmadev, - size, - io_cq->cdesc_addr.virt_addr, - io_cq->cdesc_addr.phys_addr, - io_cq->cdesc_addr.mem_handle, - ctx->numa_node, - prev_node); + ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(ena_dev->dmadev, + size, + io_cq->cdesc_addr.virt_addr, + io_cq->cdesc_addr.phys_addr, + io_cq->cdesc_addr.mem_handle, + ctx->numa_node, + prev_node, + ENA_CDESC_RING_SIZE_ALIGNMENT); if (!io_cq->cdesc_addr.virt_addr) { - ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, - size, - io_cq->cdesc_addr.virt_addr, - io_cq->cdesc_addr.phys_addr, - io_cq->cdesc_addr.mem_handle); + ENA_MEM_ALLOC_COHERENT_ALIGNED(ena_dev->dmadev, + size, + io_cq->cdesc_addr.virt_addr, + io_cq->cdesc_addr.phys_addr, + io_cq->cdesc_addr.mem_handle, + ENA_CDESC_RING_SIZE_ALIGNMENT); } if (!io_cq->cdesc_addr.virt_addr) { Modified: vendor-sys/ena-com/dist/ena_com.h ============================================================================== --- vendor-sys/ena-com/dist/ena_com.h Wed Nov 18 14:27:47 2020 (r367792) +++ vendor-sys/ena-com/dist/ena_com.h Wed Nov 18 14:30:59 2020 (r367793) @@ -51,6 +51,8 @@ #define ADMIN_CQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_acq_entry)) #define ADMIN_AENQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_aenq_entry)) +#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ + /*****************************************************************************/ /*****************************************************************************/ /* ENA adaptive interrupt moderation settings */ Modified: vendor-sys/ena-com/dist/ena_plat.h ============================================================================== --- vendor-sys/ena-com/dist/ena_plat.h Wed Nov 18 14:27:47 2020 (r367792) +++ vendor-sys/ena-com/dist/ena_plat.h Wed Nov 18 14:30:59 2020 (r367793) @@ -106,6 +106,8 @@ extern struct ena_bus_space ebs; #define ENA_ADMQ (1 << 8) /* Detailed info about admin queue. */ #define ENA_NETMAP (1 << 9) /* Detailed info about netmap. */ +#define DEFAULT_ALLOC_ALIGNMENT 8 + extern int ena_log_level; #define ena_trace_raw(level, fmt, args...) \ @@ -285,7 +287,7 @@ typedef uint64_t ena_time_t; void ena_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nseg, int error); int ena_dma_alloc(device_t dmadev, bus_size_t size, ena_mem_handle_t *dma, - int mapflags); + int mapflags, bus_size_t alignment); static inline uint32_t ena_reg_read32(struct ena_bus *bus, bus_size_t offset) @@ -313,19 +315,29 @@ ena_reg_read32(struct ena_bus *bus, bus_size_t offset) (void)(size); \ free(ptr, M_DEVBUF); \ } while (0) -#define ENA_MEM_ALLOC_COHERENT_NODE(dmadev, size, virt, phys, handle, node, \ - dev_node) \ +#define ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(dmadev, size, virt, phys, \ + handle, node, dev_node, alignment) \ do { \ ((virt) = NULL); \ (void)(dev_node); \ } while (0) -#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, dma) \ +#define ENA_MEM_ALLOC_COHERENT_NODE(dmadev, size, virt, phys, handle, \ + node, dev_node) \ + ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(dmadev, size, virt, \ + phys, handle, node, dev_node, DEFAULT_ALLOC_ALIGNMENT) + +#define ENA_MEM_ALLOC_COHERENT_ALIGNED(dmadev, size, virt, phys, dma, \ + alignment) \ do { \ - ena_dma_alloc((dmadev), (size), &(dma), 0); \ + ena_dma_alloc((dmadev), (size), &(dma), 0, alignment); \ (virt) = (void *)(dma).vaddr; \ (phys) = (dma).paddr; \ } while (0) + +#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, dma) \ + ENA_MEM_ALLOC_COHERENT_ALIGNED(dmadev, size, virt, \ + phys, dma, DEFAULT_ALLOC_ALIGNMENT) #define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, dma) \ do { \ From owner-svn-src-all@freebsd.org Wed Nov 18 14:32:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6113B468F88; Wed, 18 Nov 2020 14:32:49 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cblds2JLKz3j1R; Wed, 18 Nov 2020 14:32:49 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 376821375E; Wed, 18 Nov 2020 14:32:49 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIEWnTO009577; Wed, 18 Nov 2020 14:32:49 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIEWn1K009576; Wed, 18 Nov 2020 14:32:49 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181432.0AIEWn1K009576@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 14:32:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367794 - vendor-sys/ena-com/2.2.1 X-SVN-Group: vendor-sys X-SVN-Commit-Author: mw X-SVN-Commit-Paths: vendor-sys/ena-com/2.2.1 X-SVN-Commit-Revision: 367794 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:32:49 -0000 Author: mw Date: Wed Nov 18 14:32:48 2020 New Revision: 367794 URL: https://svnweb.freebsd.org/changeset/base/367794 Log: Upgrade ena-com to v2.2.1 An upgrade contains the cdesc allocation alignment fix. Obtained from: Amazon, Inc Added: vendor-sys/ena-com/2.2.1/ - copied from r367793, vendor-sys/ena-com/dist/ From owner-svn-src-all@freebsd.org Wed Nov 18 14:50:13 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AB0946934F; Wed, 18 Nov 2020 14:50:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbm1x2qL9z3jlH; Wed, 18 Nov 2020 14:50:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5424D1360F; Wed, 18 Nov 2020 14:50:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIEoDM7016189; Wed, 18 Nov 2020 14:50:13 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIEoCba016185; Wed, 18 Nov 2020 14:50:12 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181450.0AIEoCba016185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 14:50:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367795 - in head/sys: contrib/ena-com dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: contrib/ena-com dev/ena X-SVN-Commit-Revision: 367795 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:50:13 -0000 Author: mw Date: Wed Nov 18 14:50:12 2020 New Revision: 367795 URL: https://svnweb.freebsd.org/changeset/base/367795 Log: Fix completion descriptors alignment for the ENA The latest generation hardware requires IO CQ (completion queue) descriptors memory to be aligned to a 4K. It needs that feature for the best performance. Allocating unaligned descriptors will have a big performance impact as the packet processing in a HW won't be optimized properly. For that purpose adjust ena_dma_alloc() to support it. It's a critical fix, especially for the arm64 EC2 instances. Submitted by: Ido Segev Obtained from: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27114 Modified: head/sys/contrib/ena-com/ena_com.c head/sys/contrib/ena-com/ena_com.h head/sys/contrib/ena-com/ena_plat.h head/sys/dev/ena/ena.c Directory Properties: head/sys/contrib/ena-com/ (props changed) Modified: head/sys/contrib/ena-com/ena_com.c ============================================================================== --- head/sys/contrib/ena-com/ena_com.c Wed Nov 18 14:32:48 2020 (r367794) +++ head/sys/contrib/ena-com/ena_com.c Wed Nov 18 14:50:12 2020 (r367795) @@ -449,19 +449,21 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_ size = io_cq->cdesc_entry_size_in_bytes * io_cq->q_depth; io_cq->bus = ena_dev->bus; - ENA_MEM_ALLOC_COHERENT_NODE(ena_dev->dmadev, - size, - io_cq->cdesc_addr.virt_addr, - io_cq->cdesc_addr.phys_addr, - io_cq->cdesc_addr.mem_handle, - ctx->numa_node, - prev_node); + ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(ena_dev->dmadev, + size, + io_cq->cdesc_addr.virt_addr, + io_cq->cdesc_addr.phys_addr, + io_cq->cdesc_addr.mem_handle, + ctx->numa_node, + prev_node, + ENA_CDESC_RING_SIZE_ALIGNMENT); if (!io_cq->cdesc_addr.virt_addr) { - ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, - size, - io_cq->cdesc_addr.virt_addr, - io_cq->cdesc_addr.phys_addr, - io_cq->cdesc_addr.mem_handle); + ENA_MEM_ALLOC_COHERENT_ALIGNED(ena_dev->dmadev, + size, + io_cq->cdesc_addr.virt_addr, + io_cq->cdesc_addr.phys_addr, + io_cq->cdesc_addr.mem_handle, + ENA_CDESC_RING_SIZE_ALIGNMENT); } if (!io_cq->cdesc_addr.virt_addr) { Modified: head/sys/contrib/ena-com/ena_com.h ============================================================================== --- head/sys/contrib/ena-com/ena_com.h Wed Nov 18 14:32:48 2020 (r367794) +++ head/sys/contrib/ena-com/ena_com.h Wed Nov 18 14:50:12 2020 (r367795) @@ -51,6 +51,8 @@ #define ADMIN_CQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_acq_entry)) #define ADMIN_AENQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_aenq_entry)) +#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ + /*****************************************************************************/ /*****************************************************************************/ /* ENA adaptive interrupt moderation settings */ Modified: head/sys/contrib/ena-com/ena_plat.h ============================================================================== --- head/sys/contrib/ena-com/ena_plat.h Wed Nov 18 14:32:48 2020 (r367794) +++ head/sys/contrib/ena-com/ena_plat.h Wed Nov 18 14:50:12 2020 (r367795) @@ -106,6 +106,8 @@ extern struct ena_bus_space ebs; #define ENA_ADMQ (1 << 8) /* Detailed info about admin queue. */ #define ENA_NETMAP (1 << 9) /* Detailed info about netmap. */ +#define DEFAULT_ALLOC_ALIGNMENT 8 + extern int ena_log_level; #define ena_trace_raw(level, fmt, args...) \ @@ -285,7 +287,7 @@ typedef uint64_t ena_time_t; void ena_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nseg, int error); int ena_dma_alloc(device_t dmadev, bus_size_t size, ena_mem_handle_t *dma, - int mapflags); + int mapflags, bus_size_t alignment); static inline uint32_t ena_reg_read32(struct ena_bus *bus, bus_size_t offset) @@ -313,19 +315,29 @@ ena_reg_read32(struct ena_bus *bus, bus_size_t offset) (void)(size); \ free(ptr, M_DEVBUF); \ } while (0) -#define ENA_MEM_ALLOC_COHERENT_NODE(dmadev, size, virt, phys, handle, node, \ - dev_node) \ +#define ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(dmadev, size, virt, phys, \ + handle, node, dev_node, alignment) \ do { \ ((virt) = NULL); \ (void)(dev_node); \ } while (0) -#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, dma) \ +#define ENA_MEM_ALLOC_COHERENT_NODE(dmadev, size, virt, phys, handle, \ + node, dev_node) \ + ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(dmadev, size, virt, \ + phys, handle, node, dev_node, DEFAULT_ALLOC_ALIGNMENT) + +#define ENA_MEM_ALLOC_COHERENT_ALIGNED(dmadev, size, virt, phys, dma, \ + alignment) \ do { \ - ena_dma_alloc((dmadev), (size), &(dma), 0); \ + ena_dma_alloc((dmadev), (size), &(dma), 0, alignment); \ (virt) = (void *)(dma).vaddr; \ (phys) = (dma).paddr; \ } while (0) + +#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, dma) \ + ENA_MEM_ALLOC_COHERENT_ALIGNED(dmadev, size, virt, \ + phys, dma, DEFAULT_ALLOC_ALIGNMENT) #define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, dma) \ do { \ Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Wed Nov 18 14:32:48 2020 (r367794) +++ head/sys/dev/ena/ena.c Wed Nov 18 14:50:12 2020 (r367795) @@ -200,7 +200,7 @@ ena_dmamap_callback(void *arg, bus_dma_segment_t *segs int ena_dma_alloc(device_t dmadev, bus_size_t size, - ena_mem_handle_t *dma , int mapflags) + ena_mem_handle_t *dma, int mapflags, bus_size_t alignment) { struct ena_adapter* adapter = device_get_softc(dmadev); uint32_t maxsize; @@ -214,7 +214,7 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, dma_space_addr = BUS_SPACE_MAXADDR; error = bus_dma_tag_create(bus_get_dma_tag(dmadev), /* parent */ - 8, 0, /* alignment, bounds */ + alignment, 0, /* alignment, bounds */ dma_space_addr, /* lowaddr of exclusion window */ BUS_SPACE_MAXADDR,/* highaddr of exclusion window */ NULL, NULL, /* filter, filterarg */ From owner-svn-src-all@freebsd.org Wed Nov 18 14:54:56 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4382C469525; Wed, 18 Nov 2020 14:54:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbm7N1TZ5z3k3g; Wed, 18 Nov 2020 14:54:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1ABEF13B52; Wed, 18 Nov 2020 14:54:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIEsucR022277; Wed, 18 Nov 2020 14:54:56 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIEsub2022275; Wed, 18 Nov 2020 14:54:56 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181454.0AIEsub2022275@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 14:54:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367796 - in vendor-sys/ena-com/dist: . ena_defs X-SVN-Group: vendor-sys X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in vendor-sys/ena-com/dist: . ena_defs X-SVN-Commit-Revision: 367796 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:54:56 -0000 Author: mw Date: Wed Nov 18 14:54:55 2020 New Revision: 367796 URL: https://svnweb.freebsd.org/changeset/base/367796 Log: Upgrade ENA HAL to the latest version (26/10/20) Add support for the ENI metrics, bug fix for destroying wait event and also other minor bug fixes, improvements, etc. Submitted by: Ido Segev Obtained from: Amazon, Inc. Modified: vendor-sys/ena-com/dist/ena_com.c vendor-sys/ena-com/dist/ena_com.h vendor-sys/ena-com/dist/ena_defs/ena_admin_defs.h vendor-sys/ena-com/dist/ena_defs/ena_common_defs.h vendor-sys/ena-com/dist/ena_defs/ena_eth_io_defs.h vendor-sys/ena-com/dist/ena_defs/ena_gen_info.h vendor-sys/ena-com/dist/ena_defs/ena_regs_defs.h vendor-sys/ena-com/dist/ena_eth_com.c vendor-sys/ena-com/dist/ena_eth_com.h vendor-sys/ena-com/dist/ena_plat.h Modified: vendor-sys/ena-com/dist/ena_com.c ============================================================================== --- vendor-sys/ena-com/dist/ena_com.c Wed Nov 18 14:50:12 2020 (r367795) +++ vendor-sys/ena-com/dist/ena_com.c Wed Nov 18 14:54:55 2020 (r367796) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. @@ -70,9 +70,9 @@ #define ENA_REGS_ADMIN_INTR_MASK 1 -#define ENA_MIN_POLL_US 100 +#define ENA_MIN_ADMIN_POLL_US 100 -#define ENA_MAX_POLL_US 5000 +#define ENA_MAX_ADMIN_POLL_US 5000 /*****************************************************************************/ /*****************************************************************************/ @@ -106,7 +106,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *en dma_addr_t addr) { if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) { - ena_trc_err("dma address has more bits that the device supports\n"); + ena_trc_err(ena_dev, "DMA address has more bits that the device supports\n"); return ENA_COM_INVAL; } @@ -116,16 +116,17 @@ static int ena_com_mem_addr_set(struct ena_com_dev *en return 0; } -static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue) +static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue) { - struct ena_com_admin_sq *sq = &queue->sq; - u16 size = ADMIN_SQ_SIZE(queue->q_depth); + struct ena_com_dev *ena_dev = admin_queue->ena_dev; + struct ena_com_admin_sq *sq = &admin_queue->sq; + u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth); - ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, sq->entries, sq->dma_addr, + ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, sq->entries, sq->dma_addr, sq->mem_handle); if (!sq->entries) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -138,16 +139,17 @@ static int ena_com_admin_init_sq(struct ena_com_admin_ return 0; } -static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue) +static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue) { - struct ena_com_admin_cq *cq = &queue->cq; - u16 size = ADMIN_CQ_SIZE(queue->q_depth); + struct ena_com_dev *ena_dev = admin_queue->ena_dev; + struct ena_com_admin_cq *cq = &admin_queue->cq; + u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth); - ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, cq->entries, cq->dma_addr, + ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, cq->entries, cq->dma_addr, cq->mem_handle); if (!cq->entries) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -157,22 +159,22 @@ static int ena_com_admin_init_cq(struct ena_com_admin_ return 0; } -static int ena_com_admin_init_aenq(struct ena_com_dev *dev, +static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev, struct ena_aenq_handlers *aenq_handlers) { - struct ena_com_aenq *aenq = &dev->aenq; + struct ena_com_aenq *aenq = &ena_dev->aenq; u32 addr_low, addr_high, aenq_caps; u16 size; - dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH; + ena_dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH; size = ADMIN_AENQ_SIZE(ENA_ASYNC_QUEUE_DEPTH); - ENA_MEM_ALLOC_COHERENT(dev->dmadev, size, + ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, size, aenq->entries, aenq->dma_addr, aenq->mem_handle); if (!aenq->entries) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -182,18 +184,18 @@ static int ena_com_admin_init_aenq(struct ena_com_dev addr_low = ENA_DMA_ADDR_TO_UINT32_LOW(aenq->dma_addr); addr_high = ENA_DMA_ADDR_TO_UINT32_HIGH(aenq->dma_addr); - ENA_REG_WRITE32(dev->bus, addr_low, dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF); - ENA_REG_WRITE32(dev->bus, addr_high, dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF); + ENA_REG_WRITE32(ena_dev->bus, addr_low, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF); + ENA_REG_WRITE32(ena_dev->bus, addr_high, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF); aenq_caps = 0; - aenq_caps |= dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK; + aenq_caps |= ena_dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK; aenq_caps |= (sizeof(struct ena_admin_aenq_entry) << ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_SHIFT) & ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_MASK; - ENA_REG_WRITE32(dev->bus, aenq_caps, dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF); + ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF); if (unlikely(!aenq_handlers)) { - ena_trc_err("aenq handlers pointer is NULL\n"); + ena_trc_err(ena_dev, "AENQ handlers pointer is NULL\n"); return ENA_COM_INVAL; } @@ -209,31 +211,34 @@ static void comp_ctxt_release(struct ena_com_admin_que ATOMIC32_DEC(&queue->outstanding_cmds); } -static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *queue, +static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queue, u16 command_id, bool capture) { - if (unlikely(command_id >= queue->q_depth)) { - ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n", - command_id, queue->q_depth); + if (unlikely(command_id >= admin_queue->q_depth)) { + ena_trc_err(admin_queue->ena_dev, + "Command id is larger than the queue size. cmd_id: %u queue size %d\n", + command_id, admin_queue->q_depth); return NULL; } - if (unlikely(!queue->comp_ctx)) { - ena_trc_err("Completion context is NULL\n"); + if (unlikely(!admin_queue->comp_ctx)) { + ena_trc_err(admin_queue->ena_dev, + "Completion context is NULL\n"); return NULL; } - if (unlikely(queue->comp_ctx[command_id].occupied && capture)) { - ena_trc_err("Completion context is occupied\n"); + if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) { + ena_trc_err(admin_queue->ena_dev, + "Completion context is occupied\n"); return NULL; } if (capture) { - ATOMIC32_INC(&queue->outstanding_cmds); - queue->comp_ctx[command_id].occupied = true; + ATOMIC32_INC(&admin_queue->outstanding_cmds); + admin_queue->comp_ctx[command_id].occupied = true; } - return &queue->comp_ctx[command_id]; + return &admin_queue->comp_ctx[command_id]; } static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queue *admin_queue, @@ -254,7 +259,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd /* In case of queue FULL */ cnt = (u16)ATOMIC32_READ(&admin_queue->outstanding_cmds); if (cnt >= admin_queue->q_depth) { - ena_trc_dbg("admin queue is full.\n"); + ena_trc_dbg(admin_queue->ena_dev, "Admin queue is full.\n"); admin_queue->stats.out_of_space++; return ERR_PTR(ENA_COM_NO_SPACE); } @@ -296,20 +301,21 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd return comp_ctx; } -static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *queue) +static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue) { - size_t size = queue->q_depth * sizeof(struct ena_comp_ctx); + struct ena_com_dev *ena_dev = admin_queue->ena_dev; + size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx); struct ena_comp_ctx *comp_ctx; u16 i; - queue->comp_ctx = ENA_MEM_ALLOC(queue->q_dmadev, size); - if (unlikely(!queue->comp_ctx)) { - ena_trc_err("memory allocation failed\n"); + admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size); + if (unlikely(!admin_queue->comp_ctx)) { + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } - for (i = 0; i < queue->q_depth; i++) { - comp_ctx = get_comp_ctxt(queue, i, false); + for (i = 0; i < admin_queue->q_depth; i++) { + comp_ctx = get_comp_ctxt(admin_queue, i, false); if (comp_ctx) ENA_WAIT_EVENT_INIT(comp_ctx->wait_event); } @@ -377,7 +383,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_ } if (!io_sq->desc_addr.virt_addr) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } } @@ -402,7 +408,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_ io_sq->bounce_buf_ctrl.base_buffer = ENA_MEM_ALLOC(ena_dev->dmadev, size); if (!io_sq->bounce_buf_ctrl.base_buffer) { - ena_trc_err("bounce buffer memory allocation failed\n"); + ena_trc_err(ena_dev, "Bounce buffer memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -467,7 +473,7 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_ } if (!io_cq->cdesc_addr.virt_addr) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -488,7 +494,8 @@ static void ena_com_handle_single_admin_completion(str comp_ctx = get_comp_ctxt(admin_queue, cmd_id, false); if (unlikely(!comp_ctx)) { - ena_trc_err("comp_ctx is NULL. Changing the admin queue running state\n"); + ena_trc_err(admin_queue->ena_dev, + "comp_ctx is NULL. Changing the admin queue running state\n"); admin_queue->running_state = false; return; } @@ -540,10 +547,12 @@ static void ena_com_handle_admin_completion(struct ena admin_queue->stats.completed_cmd += comp_num; } -static int ena_com_comp_status_to_errno(u8 comp_status) +static int ena_com_comp_status_to_errno(struct ena_com_admin_queue *admin_queue, + u8 comp_status) { if (unlikely(comp_status != 0)) - ena_trc_err("admin command failed[%u]\n", comp_status); + ena_trc_err(admin_queue->ena_dev, + "Admin command failed[%u]\n", comp_status); switch (comp_status) { case ENA_ADMIN_SUCCESS: @@ -557,15 +566,17 @@ static int ena_com_comp_status_to_errno(u8 comp_status case ENA_ADMIN_ILLEGAL_PARAMETER: case ENA_ADMIN_UNKNOWN_ERROR: return ENA_COM_INVAL; + case ENA_ADMIN_RESOURCE_BUSY: + return ENA_COM_TRY_AGAIN; } return ENA_COM_INVAL; } -static inline void ena_delay_exponential_backoff_us(u32 exp, u32 delay_us) +static void ena_delay_exponential_backoff_us(u32 exp, u32 delay_us) { - delay_us = ENA_MAX32(ENA_MIN_POLL_US, delay_us); - delay_us = ENA_MIN32(delay_us * (1 << exp), ENA_MAX_POLL_US); + delay_us = ENA_MAX32(ENA_MIN_ADMIN_POLL_US, delay_us); + delay_us = ENA_MIN32(delay_us * (1U << exp), ENA_MAX_ADMIN_POLL_US); ENA_USLEEP(delay_us); } @@ -588,7 +599,8 @@ static int ena_com_wait_and_process_admin_cq_polling(s break; if (ENA_TIME_EXPIRE(timeout)) { - ena_trc_err("Wait for completion (polling) timeout\n"); + ena_trc_err(admin_queue->ena_dev, + "Wait for completion (polling) timeout\n"); /* ENA didn't have any completion */ ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags); admin_queue->stats.no_completion++; @@ -599,11 +611,12 @@ static int ena_com_wait_and_process_admin_cq_polling(s goto err; } - ena_delay_exponential_backoff_us(exp++, admin_queue->ena_dev->ena_min_poll_delay_us); + ena_delay_exponential_backoff_us(exp++, + admin_queue->ena_dev->ena_min_poll_delay_us); } if (unlikely(comp_ctx->status == ENA_CMD_ABORTED)) { - ena_trc_err("Command was aborted\n"); + ena_trc_err(admin_queue->ena_dev, "Command was aborted\n"); ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags); admin_queue->stats.aborted_cmd++; ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags); @@ -612,15 +625,16 @@ static int ena_com_wait_and_process_admin_cq_polling(s } ENA_WARN(comp_ctx->status != ENA_CMD_COMPLETED, - "Invalid comp status %d\n", comp_ctx->status); + admin_queue->ena_dev, "Invalid comp status %d\n", + comp_ctx->status); - ret = ena_com_comp_status_to_errno(comp_ctx->comp_status); + ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status); err: comp_ctxt_release(admin_queue, comp_ctx); return ret; } -/** +/* * Set the LLQ configurations of the firmware * * The driver provides only the enabled feature values to the device, @@ -645,14 +659,10 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev cmd.u.llq.desc_num_before_header_enabled = llq_info->descs_num_before_header; cmd.u.llq.descriptors_stride_ctrl_enabled = llq_info->desc_stride_ctrl; - if (llq_info->disable_meta_caching) - cmd.u.llq.accel_mode.u.set.enabled_flags |= - BIT(ENA_ADMIN_DISABLE_META_CACHING); + cmd.u.llq.accel_mode.u.set.enabled_flags = + BIT(ENA_ADMIN_DISABLE_META_CACHING) | + BIT(ENA_ADMIN_LIMIT_TX_BURST); - if (llq_info->max_entries_in_tx_burst) - cmd.u.llq.accel_mode.u.set.enabled_flags |= - BIT(ENA_ADMIN_LIMIT_TX_BURST); - ret = ena_com_execute_admin_command(admin_queue, (struct ena_admin_aq_entry *)&cmd, sizeof(cmd), @@ -660,7 +670,7 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev sizeof(resp)); if (unlikely(ret)) - ena_trc_err("Failed to set LLQ configurations: %d\n", ret); + ena_trc_err(ena_dev, "Failed to set LLQ configurations: %d\n", ret); return ret; } @@ -670,6 +680,7 @@ static int ena_com_config_llq_info(struct ena_com_dev struct ena_llq_configurations *llq_default_cfg) { struct ena_com_llq_info *llq_info = &ena_dev->llq_info; + struct ena_admin_accel_mode_get llq_accel_mode_get; u16 supported_feat; int rc; @@ -681,7 +692,7 @@ static int ena_com_config_llq_info(struct ena_com_dev llq_info->header_location_ctrl = llq_default_cfg->llq_header_location; } else { - ena_trc_err("Invalid header location control, supported: 0x%x\n", + ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n", supported_feat); return -EINVAL; } @@ -696,12 +707,12 @@ static int ena_com_config_llq_info(struct ena_com_dev } else if (supported_feat & ENA_ADMIN_SINGLE_DESC_PER_ENTRY) { llq_info->desc_stride_ctrl = ENA_ADMIN_SINGLE_DESC_PER_ENTRY; } else { - ena_trc_err("Invalid desc_stride_ctrl, supported: 0x%x\n", + ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n", supported_feat); return -EINVAL; } - ena_trc_err("Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", + ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", llq_default_cfg->llq_stride_ctrl, supported_feat, llq_info->desc_stride_ctrl); @@ -725,11 +736,12 @@ static int ena_com_config_llq_info(struct ena_com_dev llq_info->desc_list_entry_size_ctrl = ENA_ADMIN_LIST_ENTRY_SIZE_256B; llq_info->desc_list_entry_size = 256; } else { - ena_trc_err("Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat); + ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n", + supported_feat); return -EINVAL; } - ena_trc_err("Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", + ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", llq_default_cfg->llq_ring_entry_size, supported_feat, llq_info->desc_list_entry_size); @@ -738,7 +750,7 @@ static int ena_com_config_llq_info(struct ena_com_dev /* The desc list entry size should be whole multiply of 8 * This requirement comes from __iowrite64_copy() */ - ena_trc_err("illegal entry size %d\n", + ena_trc_err(ena_dev, "Illegal entry size %d\n", llq_info->desc_list_entry_size); return -EINVAL; } @@ -762,29 +774,31 @@ static int ena_com_config_llq_info(struct ena_com_dev } else if (supported_feat & ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8) { llq_info->descs_num_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8; } else { - ena_trc_err("Invalid descs_num_before_header, supported: 0x%x\n", + ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n", supported_feat); return -EINVAL; } - ena_trc_err("Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", + ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", llq_default_cfg->llq_num_decs_before_header, supported_feat, llq_info->descs_num_before_header); } /* Check for accelerated queue supported */ + llq_accel_mode_get = llq_features->accel_mode.u.get; + llq_info->disable_meta_caching = - llq_features->accel_mode.u.get.supported_flags & - BIT(ENA_ADMIN_DISABLE_META_CACHING); + !!(llq_accel_mode_get.supported_flags & + BIT(ENA_ADMIN_DISABLE_META_CACHING)); - if (llq_features->accel_mode.u.get.supported_flags & BIT(ENA_ADMIN_LIMIT_TX_BURST)) + if (llq_accel_mode_get.supported_flags & BIT(ENA_ADMIN_LIMIT_TX_BURST)) llq_info->max_entries_in_tx_burst = - llq_features->accel_mode.u.get.max_tx_burst_size / + llq_accel_mode_get.max_tx_burst_size / llq_default_cfg->llq_ring_entry_size_value; rc = ena_com_set_llq(ena_dev); if (rc) - ena_trc_err("Cannot set LLQ configuration: %d\n", rc); + ena_trc_err(ena_dev, "Cannot set LLQ configuration: %d\n", rc); return rc; } @@ -810,13 +824,15 @@ static int ena_com_wait_and_process_admin_cq_interrupt ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags); if (comp_ctx->status == ENA_CMD_COMPLETED) { - ena_trc_err("The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n", + ena_trc_err(admin_queue->ena_dev, + "The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n", comp_ctx->cmd_opcode, admin_queue->auto_polling ? "ON" : "OFF"); /* Check if fallback to polling is enabled */ if (admin_queue->auto_polling) admin_queue->polling = true; } else { - ena_trc_err("The ena device didn't send a completion for the admin cmd %d status %d\n", + ena_trc_err(admin_queue->ena_dev, + "The ena device didn't send a completion for the admin cmd %d status %d\n", comp_ctx->cmd_opcode, comp_ctx->status); } /* Check if shifted to polling mode. @@ -830,7 +846,7 @@ static int ena_com_wait_and_process_admin_cq_interrupt } } - ret = ena_com_comp_status_to_errno(comp_ctx->comp_status); + ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status); err: comp_ctxt_release(admin_queue, comp_ctx); return ret; @@ -878,7 +894,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev * } if (unlikely(i == timeout)) { - ena_trc_err("reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n", + ena_trc_err(ena_dev, "Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n", mmio_read->seq_num, offset, read_resp->req_id, @@ -888,7 +904,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev * } if (read_resp->reg_off != offset) { - ena_trc_err("Read failure: wrong offset provided\n"); + ena_trc_err(ena_dev, "Read failure: wrong offset provided\n"); ret = ENA_MMIO_READ_TIMEOUT; } else { ret = read_resp->reg_val; @@ -947,7 +963,7 @@ static int ena_com_destroy_io_sq(struct ena_com_dev *e sizeof(destroy_resp)); if (unlikely(ret && (ret != ENA_COM_NO_DEVICE))) - ena_trc_err("failed to destroy io sq error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to destroy io sq error: %d\n", ret); return ret; } @@ -1003,7 +1019,7 @@ static int wait_for_reset_state(struct ena_com_dev *en val = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF); if (unlikely(val == ENA_MMIO_READ_TIMEOUT)) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } @@ -1043,7 +1059,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev * int ret; if (!ena_com_check_supported_feature_id(ena_dev, feature_id)) { - ena_trc_dbg("Feature %d isn't supported\n", feature_id); + ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", feature_id); return ENA_COM_UNSUPPORTED; } @@ -1062,7 +1078,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev * &get_cmd.control_buffer.address, control_buf_dma_addr); if (unlikely(ret)) { - ena_trc_err("memory address set failed\n"); + ena_trc_err(ena_dev, "Memory address set failed\n"); return ret; } @@ -1079,7 +1095,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev * sizeof(*get_resp)); if (unlikely(ret)) - ena_trc_err("Failed to submit get_feature command %d error: %d\n", + ena_trc_err(ena_dev, "Failed to submit get_feature command %d error: %d\n", feature_id, ret); return ret; @@ -1110,13 +1126,9 @@ static void ena_com_hash_key_fill_default_key(struct e ENA_RSS_FILL_KEY(&hash_key->key, sizeof(hash_key->key)); /* The key buffer is stored in the device in an array of - * uint32 elements. Therefore the number of elements can be derived - * by dividing the buffer length by the size of each array element. - * In current implementation each element is sized at uint32_t - * so it's actually a division by 4 but if the element size changes, - * there is no need to rewrite this code. + * uint32 elements. */ - hash_key->keys_num = sizeof(hash_key->key) / sizeof(hash_key->key[0]); + hash_key->key_parts = ENA_ADMIN_RSS_KEY_PARTS; } static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev) @@ -1189,13 +1201,13 @@ static int ena_com_indirect_table_allocate(struct ena_ int ret; ret = ena_com_get_feature(ena_dev, &get_resp, - ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0); + ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0); if (unlikely(ret)) return ret; if ((get_resp.u.ind_table.min_size > log_size) || (get_resp.u.ind_table.max_size < log_size)) { - ena_trc_err("indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n", + ena_trc_err(ena_dev, "Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n", 1 << log_size, 1 << get_resp.u.ind_table.min_size, 1 << get_resp.u.ind_table.max_size); @@ -1299,7 +1311,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *en &create_cmd.sq_ba, io_sq->desc_addr.phys_addr); if (unlikely(ret)) { - ena_trc_err("memory address set failed\n"); + ena_trc_err(ena_dev, "Memory address set failed\n"); return ret; } } @@ -1310,7 +1322,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *en (struct ena_admin_acq_entry *)&cmd_completion, sizeof(cmd_completion)); if (unlikely(ret)) { - ena_trc_err("Failed to create IO SQ. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to create IO SQ. error: %d\n", ret); return ret; } @@ -1328,7 +1340,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *en cmd_completion.llq_descriptors_offset); } - ena_trc_dbg("created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth); + ena_trc_dbg(ena_dev, "Created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth); return ret; } @@ -1362,7 +1374,7 @@ static void ena_com_update_intr_delay_resolution(struc u16 prev_intr_delay_resolution = ena_dev->intr_delay_resolution; if (unlikely(!intr_delay_resolution)) { - ena_trc_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n"); + ena_trc_err(ena_dev, "Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n"); intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION; } @@ -1398,23 +1410,25 @@ int ena_com_execute_admin_command(struct ena_com_admin comp, comp_size); if (IS_ERR(comp_ctx)) { if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE)) - ena_trc_dbg("Failed to submit command [%ld]\n", + ena_trc_dbg(admin_queue->ena_dev, + "Failed to submit command [%ld]\n", PTR_ERR(comp_ctx)); else - ena_trc_err("Failed to submit command [%ld]\n", + ena_trc_err(admin_queue->ena_dev, + "Failed to submit command [%ld]\n", PTR_ERR(comp_ctx)); - return PTR_ERR(comp_ctx); + return (int)PTR_ERR(comp_ctx); } ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue); if (unlikely(ret)) { if (admin_queue->running_state) - ena_trc_err("Failed to process command. ret = %d\n", - ret); + ena_trc_err(admin_queue->ena_dev, + "Failed to process command. ret = %d\n", ret); else - ena_trc_dbg("Failed to process command. ret = %d\n", - ret); + ena_trc_dbg(admin_queue->ena_dev, + "Failed to process command. ret = %d\n", ret); } return ret; } @@ -1443,7 +1457,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev, &create_cmd.cq_ba, io_cq->cdesc_addr.phys_addr); if (unlikely(ret)) { - ena_trc_err("memory address set failed\n"); + ena_trc_err(ena_dev, "Memory address set failed\n"); return ret; } @@ -1453,7 +1467,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev, (struct ena_admin_acq_entry *)&cmd_completion, sizeof(cmd_completion)); if (unlikely(ret)) { - ena_trc_err("Failed to create IO CQ. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to create IO CQ. error: %d\n", ret); return ret; } @@ -1472,7 +1486,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev, (u32 __iomem *)((uintptr_t)ena_dev->reg_bar + cmd_completion.numa_node_register_offset); - ena_trc_dbg("created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth); + ena_trc_dbg(ena_dev, "Created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth); return ret; } @@ -1482,7 +1496,7 @@ int ena_com_get_io_handlers(struct ena_com_dev *ena_de struct ena_com_io_cq **io_cq) { if (qid >= ENA_TOTAL_NUM_QUEUES) { - ena_trc_err("Invalid queue number %d but the max is %d\n", + ena_trc_err(ena_dev, "Invalid queue number %d but the max is %d\n", qid, ENA_TOTAL_NUM_QUEUES); return ENA_COM_INVAL; } @@ -1548,7 +1562,7 @@ int ena_com_destroy_io_cq(struct ena_com_dev *ena_dev, sizeof(destroy_resp)); if (unlikely(ret && (ret != ENA_COM_NO_DEVICE))) - ena_trc_err("Failed to destroy IO CQ. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to destroy IO CQ. error: %d\n", ret); return ret; } @@ -1572,7 +1586,7 @@ void ena_com_admin_aenq_enable(struct ena_com_dev *ena { u16 depth = ena_dev->aenq.q_depth; - ENA_WARN(ena_dev->aenq.head != depth, "Invalid AENQ state\n"); + ENA_WARN(ena_dev->aenq.head != depth, ena_dev, "Invalid AENQ state\n"); /* Init head_db to mark that all entries in the queue * are initially available @@ -1590,12 +1604,12 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_de ret = ena_com_get_feature(ena_dev, &get_resp, ENA_ADMIN_AENQ_CONFIG, 0); if (ret) { - ena_trc_info("Can't get aenq configuration\n"); + ena_trc_info(ena_dev, "Can't get aenq configuration\n"); return ret; } if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) { - ena_trc_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n", + ena_trc_warn(ena_dev, "Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n", get_resp.u.aenq.supported_groups, groups_flag); return ENA_COM_UNSUPPORTED; @@ -1616,7 +1630,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_de sizeof(resp)); if (unlikely(ret)) - ena_trc_err("Failed to config AENQ ret: %d\n", ret); + ena_trc_err(ena_dev, "Failed to config AENQ ret: %d\n", ret); return ret; } @@ -1624,20 +1638,20 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_de int ena_com_get_dma_width(struct ena_com_dev *ena_dev) { u32 caps = ena_com_reg_bar_read32(ena_dev, ENA_REGS_CAPS_OFF); - int width; + u32 width; if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } width = (caps & ENA_REGS_CAPS_DMA_ADDR_WIDTH_MASK) >> ENA_REGS_CAPS_DMA_ADDR_WIDTH_SHIFT; - ena_trc_dbg("ENA dma width: %d\n", width); + ena_trc_dbg(ena_dev, "ENA dma width: %d\n", width); if ((width < 32) || width > ENA_MAX_PHYS_ADDR_SIZE_BITS) { - ena_trc_err("DMA width illegal value: %d\n", width); + ena_trc_err(ena_dev, "DMA width illegal value: %d\n", width); return ENA_COM_INVAL; } @@ -1661,16 +1675,16 @@ int ena_com_validate_version(struct ena_com_dev *ena_d if (unlikely((ver == ENA_MMIO_READ_TIMEOUT) || (ctrl_ver == ENA_MMIO_READ_TIMEOUT))) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } - ena_trc_info("ena device version: %d.%d\n", + ena_trc_info(ena_dev, "ENA device version: %d.%d\n", (ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >> ENA_REGS_VERSION_MAJOR_VERSION_SHIFT, ver & ENA_REGS_VERSION_MINOR_VERSION_MASK); - ena_trc_info("ena controller version: %d.%d.%d implementation version %d\n", + ena_trc_info(ena_dev, "ENA controller version: %d.%d.%d implementation version %d\n", (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK) >> ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT, (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK) @@ -1686,13 +1700,29 @@ int ena_com_validate_version(struct ena_com_dev *ena_d /* Validate the ctrl version without the implementation ID */ if (ctrl_ver_masked < MIN_ENA_CTRL_VER) { - ena_trc_err("ENA ctrl version is lower than the minimal ctrl version the driver supports\n"); + ena_trc_err(ena_dev, "ENA ctrl version is lower than the minimal ctrl version the driver supports\n"); return -1; } return 0; } +static void +ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev, + struct ena_com_admin_queue *admin_queue) + +{ + if (!admin_queue->comp_ctx) + return; + + ENA_WAIT_EVENTS_DESTROY(admin_queue); + ENA_MEM_FREE(ena_dev->dmadev, + admin_queue->comp_ctx, + (admin_queue->q_depth * sizeof(struct ena_comp_ctx))); + + admin_queue->comp_ctx = NULL; +} + void ena_com_admin_destroy(struct ena_com_dev *ena_dev) { struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue; @@ -1701,12 +1731,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev struct ena_com_aenq *aenq = &ena_dev->aenq; u16 size; - ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event); - if (admin_queue->comp_ctx) - ENA_MEM_FREE(ena_dev->dmadev, - admin_queue->comp_ctx, - (admin_queue->q_depth * sizeof(struct ena_comp_ctx))); - admin_queue->comp_ctx = NULL; + ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue); + size = ADMIN_SQ_SIZE(admin_queue->q_depth); if (sq->entries) ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries, @@ -1822,12 +1848,12 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev, dev_sts = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF); if (unlikely(dev_sts == ENA_MMIO_READ_TIMEOUT)) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } if (!(dev_sts & ENA_REGS_DEV_STS_READY_MASK)) { - ena_trc_err("Device isn't ready, abort com init\n"); + ena_trc_err(ena_dev, "Device isn't ready, abort com init\n"); return ENA_COM_NO_DEVICE; } @@ -1905,7 +1931,7 @@ int ena_com_create_io_queue(struct ena_com_dev *ena_de int ret; if (ctx->qid >= ENA_TOTAL_NUM_QUEUES) { - ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n", + ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n", ctx->qid, ENA_TOTAL_NUM_QUEUES); return ENA_COM_INVAL; } @@ -1964,7 +1990,7 @@ void ena_com_destroy_io_queue(struct ena_com_dev *ena_ struct ena_com_io_cq *io_cq; if (qid >= ENA_TOTAL_NUM_QUEUES) { - ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n", + ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n", qid, ENA_TOTAL_NUM_QUEUES); return; } @@ -1997,6 +2023,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_ memcpy(&get_feat_ctx->dev_attr, &get_resp.u.dev_attr, sizeof(get_resp.u.dev_attr)); + ena_dev->supported_features = get_resp.u.dev_attr.supported_features; if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) { @@ -2063,17 +2090,6 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_ else return rc; - rc = ena_com_get_feature(ena_dev, &get_resp, - ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0); - if (!rc) - memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table, - sizeof(get_resp.u.ind_table)); - else if (rc == ENA_COM_UNSUPPORTED) - memset(&get_feat_ctx->ind_table, 0x0, - sizeof(get_feat_ctx->ind_table)); - else - return rc; - return 0; } @@ -2085,10 +2101,10 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_ /* ena_handle_specific_aenq_event: * return the handler that is relevant to the specific event group */ -static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev, +static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *ena_dev, u16 group) { - struct ena_aenq_handlers *aenq_handlers = dev->aenq.aenq_handlers; + struct ena_aenq_handlers *aenq_handlers = ena_dev->aenq.aenq_handlers; if ((group < ENA_MAX_HANDLERS) && aenq_handlers->handlers[group]) return aenq_handlers->handlers[group]; @@ -2100,11 +2116,11 @@ static ena_aenq_handler ena_com_get_specific_aenq_cb(s * handles the aenq incoming events. * pop events from the queue and apply the specific handler */ -void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data) +void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data) { struct ena_admin_aenq_entry *aenq_e; struct ena_admin_aenq_common_desc *aenq_common; - struct ena_com_aenq *aenq = &dev->aenq; + struct ena_com_aenq *aenq = &ena_dev->aenq; u64 timestamp; ena_aenq_handler handler_cb; u16 masked_head, processed = 0; @@ -2125,13 +2141,14 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev timestamp = (u64)aenq_common->timestamp_low | ((u64)aenq_common->timestamp_high << 32); - ena_trc_dbg("AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n", + + ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIu64 "s]\n", aenq_common->group, - aenq_common->syndrom, + aenq_common->syndrome, timestamp); /* Handle specific event*/ - handler_cb = ena_com_get_specific_aenq_cb(dev, + handler_cb = ena_com_get_specific_aenq_cb(ena_dev, aenq_common->group); handler_cb(data, aenq_e); /* call the actual event handler*/ @@ -2156,8 +2173,8 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev /* write the aenq doorbell after all AENQ descriptors were read */ mb(); - ENA_REG_WRITE32_RELAXED(dev->bus, (u32)aenq->head, - dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); + ENA_REG_WRITE32_RELAXED(ena_dev->bus, (u32)aenq->head, + ena_dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); mmiowb(); } #ifdef ENA_EXTENDED_STATS @@ -2193,19 +2210,19 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev, if (unlikely((stat == ENA_MMIO_READ_TIMEOUT) || (cap == ENA_MMIO_READ_TIMEOUT))) { - ena_trc_err("Reg read32 timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read32 timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } if ((stat & ENA_REGS_DEV_STS_READY_MASK) == 0) { - ena_trc_err("Device isn't ready, can't reset device\n"); + ena_trc_err(ena_dev, "Device isn't ready, can't reset device\n"); return ENA_COM_INVAL; } timeout = (cap & ENA_REGS_CAPS_RESET_TIMEOUT_MASK) >> ENA_REGS_CAPS_RESET_TIMEOUT_SHIFT; if (timeout == 0) { - ena_trc_err("Invalid timeout value\n"); + ena_trc_err(ena_dev, "Invalid timeout value\n"); return ENA_COM_INVAL; } @@ -2221,7 +2238,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev, rc = wait_for_reset_state(ena_dev, timeout, ENA_REGS_DEV_STS_RESET_IN_PROGRESS_MASK); if (rc != 0) { - ena_trc_err("Reset indication didn't turn on\n"); + ena_trc_err(ena_dev, "Reset indication didn't turn on\n"); return rc; } @@ -2229,7 +2246,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev, ENA_REG_WRITE32(ena_dev->bus, 0, ena_dev->reg_bar + ENA_REGS_DEV_CTL_OFF); rc = wait_for_reset_state(ena_dev, timeout, 0); if (rc != 0) { - ena_trc_err("Reset indication didn't turn off\n"); + ena_trc_err(ena_dev, "Reset indication didn't turn off\n"); return rc; } @@ -2266,11 +2283,26 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_d sizeof(*get_resp)); if (unlikely(ret)) - ena_trc_err("Failed to get stats. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to get stats. error: %d\n", ret); return ret; } +int ena_com_get_eni_stats(struct ena_com_dev *ena_dev, + struct ena_admin_eni_stats *stats) +{ + struct ena_com_stats_ctx ctx; + int ret; + + memset(&ctx, 0x0, sizeof(ctx)); + ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_ENI); + if (likely(ret == 0)) + memcpy(stats, &ctx.get_resp.u.eni_stats, + sizeof(ctx.get_resp.u.eni_stats)); + + return ret; +} + int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev, struct ena_admin_basic_stats *stats) { @@ -2280,8 +2312,8 @@ int ena_com_get_dev_basic_stats(struct ena_com_dev *en memset(&ctx, 0x0, sizeof(ctx)); ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_BASIC); if (likely(ret == 0)) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Nov 18 14:55:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5955B469821; Wed, 18 Nov 2020 14:55:50 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbm8Q28hHz3kFq; Wed, 18 Nov 2020 14:55:50 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 330A41362C; Wed, 18 Nov 2020 14:55:50 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIEtoXM022441; Wed, 18 Nov 2020 14:55:50 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIEtoJ9022440; Wed, 18 Nov 2020 14:55:50 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181455.0AIEtoJ9022440@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 14:55:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367798 - vendor-sys/ena-com/2.3.0 X-SVN-Group: vendor-sys X-SVN-Commit-Author: mw X-SVN-Commit-Paths: vendor-sys/ena-com/2.3.0 X-SVN-Commit-Revision: 367798 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:55:50 -0000 Author: mw Date: Wed Nov 18 14:55:49 2020 New Revision: 367798 URL: https://svnweb.freebsd.org/changeset/base/367798 Log: Upgrade ENA HAL to v2.3.0 Sponsored by: Amazon, Inc. Added: vendor-sys/ena-com/2.3.0/ - copied from r367796, vendor-sys/ena-com/dist/ From owner-svn-src-all@freebsd.org Wed Nov 18 14:55:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4667C469473; Wed, 18 Nov 2020 14:55:50 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbm8Q1Zcyz3kSm; Wed, 18 Nov 2020 14:55:50 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 291C313D2B; Wed, 18 Nov 2020 14:55:50 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIEtoWo022439; Wed, 18 Nov 2020 14:55:50 GMT (envelope-from gallatin@FreeBSD.org) Received: (from gallatin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIEtnuV022417; Wed, 18 Nov 2020 14:55:49 GMT (envelope-from gallatin@FreeBSD.org) Message-Id: <202011181455.0AIEtnuV022417@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gallatin set sender to gallatin@FreeBSD.org using -f From: Andrew Gallatin Date: Wed, 18 Nov 2020 14:55:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367797 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: gallatin X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 367797 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:55:50 -0000 Author: gallatin Date: Wed Nov 18 14:55:49 2020 New Revision: 367797 URL: https://svnweb.freebsd.org/changeset/base/367797 Log: LACP: When suppressing distributing, return ENOBUFS When links come and go, lacp goes into a "suppress distributing" mode where it drops traffic for 3 seconds. When in this mode, lagg/lacp historiclally drops traffic with ENETDOWN. That return value causes TCP to close any connection where it gets that value back from the lower parts of the stack. This means that any TCP connection with active traffic during a 3-second windown when an LACP link comes or goes would get closed. TCP treats return values of ENOBUFS as transient errors, and re-schedules transmission later. So rather than returning ENETDOWN, lets return ENOBUFS instead. This allows TCP connections to be preserved. I've tested this by repeatedly bouncing links on a Netlfix CDN server under a moderate (20Gb/s) load and overved ENOBUFS reported back to the TCP stack (as reported by a RACK TCP sysctl). Reviewed by: jhb, jtl, rrs Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27188 Modified: head/sys/net/ieee8023ad_lacp.c head/sys/net/ieee8023ad_lacp.h head/sys/net/if_lagg.c Modified: head/sys/net/ieee8023ad_lacp.c ============================================================================== --- head/sys/net/ieee8023ad_lacp.c Wed Nov 18 14:54:55 2020 (r367796) +++ head/sys/net/ieee8023ad_lacp.c Wed Nov 18 14:55:49 2020 (r367797) @@ -832,7 +832,8 @@ lacp_stop(struct lagg_softc *sc) } struct lagg_port * -lacp_select_tx_port_by_hash(struct lagg_softc *sc, uint32_t hash, uint8_t numa_domain) +lacp_select_tx_port_by_hash(struct lagg_softc *sc, uint32_t hash, + uint8_t numa_domain, int *err) { struct lacp_softc *lsc = LACP_SOFTC(sc); struct lacp_portmap *pm; @@ -842,12 +843,14 @@ lacp_select_tx_port_by_hash(struct lagg_softc *sc, uin if (__predict_false(lsc->lsc_suppress_distributing)) { LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__)); + *err = ENOBUFS; return (NULL); } pm = &lsc->lsc_pmap[lsc->lsc_activemap]; if (pm->pm_count == 0) { LACP_DPRINTF((NULL, "%s: no active aggregator\n", __func__)); + *err = ENETDOWN; return (NULL); } @@ -879,7 +882,7 @@ lacp_select_tx_port_by_hash(struct lagg_softc *sc, uin } struct lagg_port * -lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m) +lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m, int *err) { struct lacp_softc *lsc = LACP_SOFTC(sc); uint32_t hash; @@ -892,7 +895,7 @@ lacp_select_tx_port(struct lagg_softc *sc, struct mbuf hash = m_ether_tcpip_hash(sc->sc_flags, m, lsc->lsc_hashkey); numa_domain = m->m_pkthdr.numa_domain; - return (lacp_select_tx_port_by_hash(sc, hash, numa_domain)); + return (lacp_select_tx_port_by_hash(sc, hash, numa_domain, err)); } /* Modified: head/sys/net/ieee8023ad_lacp.h ============================================================================== --- head/sys/net/ieee8023ad_lacp.h Wed Nov 18 14:54:55 2020 (r367796) +++ head/sys/net/ieee8023ad_lacp.h Wed Nov 18 14:55:49 2020 (r367797) @@ -292,8 +292,10 @@ struct lacp_softc { #define LACP_LOCK_ASSERT(_lsc) mtx_assert(&(_lsc)->lsc_mtx, MA_OWNED) struct mbuf *lacp_input(struct lagg_port *, struct mbuf *); -struct lagg_port *lacp_select_tx_port(struct lagg_softc *, struct mbuf *); -struct lagg_port *lacp_select_tx_port_by_hash(struct lagg_softc *, uint32_t, uint8_t); +struct lagg_port *lacp_select_tx_port(struct lagg_softc *, struct mbuf *, + int *); +struct lagg_port *lacp_select_tx_port_by_hash(struct lagg_softc *, uint32_t, + uint8_t, int *); void lacp_attach(struct lagg_softc *); void lacp_detach(void *); void lacp_init(struct lagg_softc *); Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Wed Nov 18 14:54:55 2020 (r367796) +++ head/sys/net/if_lagg.c Wed Nov 18 14:55:49 2020 (r367797) @@ -1763,6 +1763,7 @@ lookup_snd_tag_port(struct ifnet *ifp, uint32_t flowid struct lagg_port *lp; struct lagg_lb *lb; uint32_t hash, p; + int err; sc = ifp->if_softc; @@ -1783,7 +1784,7 @@ lookup_snd_tag_port(struct ifnet *ifp, uint32_t flowid flowtype == M_HASHTYPE_NONE) return (NULL); hash = flowid >> sc->flowid_shift; - return (lacp_select_tx_port_by_hash(sc, hash, numa_domain)); + return (lacp_select_tx_port_by_hash(sc, hash, numa_domain, &err)); default: return (NULL); } @@ -2580,12 +2581,13 @@ static int lagg_lacp_start(struct lagg_softc *sc, struct mbuf *m) { struct lagg_port *lp; + int err; - lp = lacp_select_tx_port(sc, m); + lp = lacp_select_tx_port(sc, m, &err); if (lp == NULL) { if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); m_freem(m); - return (ENETDOWN); + return (err); } /* Send mbuf */ From owner-svn-src-all@freebsd.org Wed Nov 18 14:59:23 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 62DEE469858; Wed, 18 Nov 2020 14:59:23 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbmDW2K99z3kmK; Wed, 18 Nov 2020 14:59:23 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3D7FD13DBD; Wed, 18 Nov 2020 14:59:23 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIExNeN022809; Wed, 18 Nov 2020 14:59:23 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIExN2I022807; Wed, 18 Nov 2020 14:59:23 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181459.0AIExN2I022807@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 14:59:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367799 - in head/sys: contrib/ena-com contrib/ena-com/ena_defs dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: contrib/ena-com contrib/ena-com/ena_defs dev/ena X-SVN-Commit-Revision: 367799 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 14:59:23 -0000 Author: mw Date: Wed Nov 18 14:59:22 2020 New Revision: 367799 URL: https://svnweb.freebsd.org/changeset/base/367799 Log: Adjust ENA driver files to latest ena-com changes * Use the new API of ena_trace_* * Fix typo syndrom --> syndrome * Remove validation of the Rx req ID (already performed in the ena-com) * Remove usage of deprecated ENA_ASSERT macro Submitted by: Ido Segev Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27115 Modified: head/sys/contrib/ena-com/ena_com.c head/sys/contrib/ena-com/ena_com.h head/sys/contrib/ena-com/ena_defs/ena_admin_defs.h head/sys/contrib/ena-com/ena_defs/ena_common_defs.h head/sys/contrib/ena-com/ena_defs/ena_eth_io_defs.h head/sys/contrib/ena-com/ena_defs/ena_gen_info.h head/sys/contrib/ena-com/ena_defs/ena_regs_defs.h head/sys/contrib/ena-com/ena_eth_com.c head/sys/contrib/ena-com/ena_eth_com.h head/sys/contrib/ena-com/ena_plat.h head/sys/dev/ena/ena.c head/sys/dev/ena/ena.h head/sys/dev/ena/ena_datapath.c head/sys/dev/ena/ena_netmap.c Directory Properties: head/sys/contrib/ena-com/ (props changed) Modified: head/sys/contrib/ena-com/ena_com.c ============================================================================== --- head/sys/contrib/ena-com/ena_com.c Wed Nov 18 14:55:49 2020 (r367798) +++ head/sys/contrib/ena-com/ena_com.c Wed Nov 18 14:59:22 2020 (r367799) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. @@ -70,9 +70,9 @@ #define ENA_REGS_ADMIN_INTR_MASK 1 -#define ENA_MIN_POLL_US 100 +#define ENA_MIN_ADMIN_POLL_US 100 -#define ENA_MAX_POLL_US 5000 +#define ENA_MAX_ADMIN_POLL_US 5000 /*****************************************************************************/ /*****************************************************************************/ @@ -106,7 +106,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *en dma_addr_t addr) { if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) { - ena_trc_err("dma address has more bits that the device supports\n"); + ena_trc_err(ena_dev, "DMA address has more bits that the device supports\n"); return ENA_COM_INVAL; } @@ -116,16 +116,17 @@ static int ena_com_mem_addr_set(struct ena_com_dev *en return 0; } -static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue) +static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue) { - struct ena_com_admin_sq *sq = &queue->sq; - u16 size = ADMIN_SQ_SIZE(queue->q_depth); + struct ena_com_dev *ena_dev = admin_queue->ena_dev; + struct ena_com_admin_sq *sq = &admin_queue->sq; + u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth); - ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, sq->entries, sq->dma_addr, + ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, sq->entries, sq->dma_addr, sq->mem_handle); if (!sq->entries) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -138,16 +139,17 @@ static int ena_com_admin_init_sq(struct ena_com_admin_ return 0; } -static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue) +static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue) { - struct ena_com_admin_cq *cq = &queue->cq; - u16 size = ADMIN_CQ_SIZE(queue->q_depth); + struct ena_com_dev *ena_dev = admin_queue->ena_dev; + struct ena_com_admin_cq *cq = &admin_queue->cq; + u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth); - ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, cq->entries, cq->dma_addr, + ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, cq->entries, cq->dma_addr, cq->mem_handle); if (!cq->entries) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -157,22 +159,22 @@ static int ena_com_admin_init_cq(struct ena_com_admin_ return 0; } -static int ena_com_admin_init_aenq(struct ena_com_dev *dev, +static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev, struct ena_aenq_handlers *aenq_handlers) { - struct ena_com_aenq *aenq = &dev->aenq; + struct ena_com_aenq *aenq = &ena_dev->aenq; u32 addr_low, addr_high, aenq_caps; u16 size; - dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH; + ena_dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH; size = ADMIN_AENQ_SIZE(ENA_ASYNC_QUEUE_DEPTH); - ENA_MEM_ALLOC_COHERENT(dev->dmadev, size, + ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, size, aenq->entries, aenq->dma_addr, aenq->mem_handle); if (!aenq->entries) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -182,18 +184,18 @@ static int ena_com_admin_init_aenq(struct ena_com_dev addr_low = ENA_DMA_ADDR_TO_UINT32_LOW(aenq->dma_addr); addr_high = ENA_DMA_ADDR_TO_UINT32_HIGH(aenq->dma_addr); - ENA_REG_WRITE32(dev->bus, addr_low, dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF); - ENA_REG_WRITE32(dev->bus, addr_high, dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF); + ENA_REG_WRITE32(ena_dev->bus, addr_low, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF); + ENA_REG_WRITE32(ena_dev->bus, addr_high, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF); aenq_caps = 0; - aenq_caps |= dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK; + aenq_caps |= ena_dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK; aenq_caps |= (sizeof(struct ena_admin_aenq_entry) << ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_SHIFT) & ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_MASK; - ENA_REG_WRITE32(dev->bus, aenq_caps, dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF); + ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF); if (unlikely(!aenq_handlers)) { - ena_trc_err("aenq handlers pointer is NULL\n"); + ena_trc_err(ena_dev, "AENQ handlers pointer is NULL\n"); return ENA_COM_INVAL; } @@ -209,31 +211,34 @@ static void comp_ctxt_release(struct ena_com_admin_que ATOMIC32_DEC(&queue->outstanding_cmds); } -static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *queue, +static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queue, u16 command_id, bool capture) { - if (unlikely(command_id >= queue->q_depth)) { - ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n", - command_id, queue->q_depth); + if (unlikely(command_id >= admin_queue->q_depth)) { + ena_trc_err(admin_queue->ena_dev, + "Command id is larger than the queue size. cmd_id: %u queue size %d\n", + command_id, admin_queue->q_depth); return NULL; } - if (unlikely(!queue->comp_ctx)) { - ena_trc_err("Completion context is NULL\n"); + if (unlikely(!admin_queue->comp_ctx)) { + ena_trc_err(admin_queue->ena_dev, + "Completion context is NULL\n"); return NULL; } - if (unlikely(queue->comp_ctx[command_id].occupied && capture)) { - ena_trc_err("Completion context is occupied\n"); + if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) { + ena_trc_err(admin_queue->ena_dev, + "Completion context is occupied\n"); return NULL; } if (capture) { - ATOMIC32_INC(&queue->outstanding_cmds); - queue->comp_ctx[command_id].occupied = true; + ATOMIC32_INC(&admin_queue->outstanding_cmds); + admin_queue->comp_ctx[command_id].occupied = true; } - return &queue->comp_ctx[command_id]; + return &admin_queue->comp_ctx[command_id]; } static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queue *admin_queue, @@ -254,7 +259,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd /* In case of queue FULL */ cnt = (u16)ATOMIC32_READ(&admin_queue->outstanding_cmds); if (cnt >= admin_queue->q_depth) { - ena_trc_dbg("admin queue is full.\n"); + ena_trc_dbg(admin_queue->ena_dev, "Admin queue is full.\n"); admin_queue->stats.out_of_space++; return ERR_PTR(ENA_COM_NO_SPACE); } @@ -296,20 +301,21 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd return comp_ctx; } -static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *queue) +static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue) { - size_t size = queue->q_depth * sizeof(struct ena_comp_ctx); + struct ena_com_dev *ena_dev = admin_queue->ena_dev; + size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx); struct ena_comp_ctx *comp_ctx; u16 i; - queue->comp_ctx = ENA_MEM_ALLOC(queue->q_dmadev, size); - if (unlikely(!queue->comp_ctx)) { - ena_trc_err("memory allocation failed\n"); + admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size); + if (unlikely(!admin_queue->comp_ctx)) { + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } - for (i = 0; i < queue->q_depth; i++) { - comp_ctx = get_comp_ctxt(queue, i, false); + for (i = 0; i < admin_queue->q_depth; i++) { + comp_ctx = get_comp_ctxt(admin_queue, i, false); if (comp_ctx) ENA_WAIT_EVENT_INIT(comp_ctx->wait_event); } @@ -377,7 +383,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_ } if (!io_sq->desc_addr.virt_addr) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } } @@ -402,7 +408,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_ io_sq->bounce_buf_ctrl.base_buffer = ENA_MEM_ALLOC(ena_dev->dmadev, size); if (!io_sq->bounce_buf_ctrl.base_buffer) { - ena_trc_err("bounce buffer memory allocation failed\n"); + ena_trc_err(ena_dev, "Bounce buffer memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -467,7 +473,7 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_ } if (!io_cq->cdesc_addr.virt_addr) { - ena_trc_err("memory allocation failed\n"); + ena_trc_err(ena_dev, "Memory allocation failed\n"); return ENA_COM_NO_MEM; } @@ -488,7 +494,8 @@ static void ena_com_handle_single_admin_completion(str comp_ctx = get_comp_ctxt(admin_queue, cmd_id, false); if (unlikely(!comp_ctx)) { - ena_trc_err("comp_ctx is NULL. Changing the admin queue running state\n"); + ena_trc_err(admin_queue->ena_dev, + "comp_ctx is NULL. Changing the admin queue running state\n"); admin_queue->running_state = false; return; } @@ -540,10 +547,12 @@ static void ena_com_handle_admin_completion(struct ena admin_queue->stats.completed_cmd += comp_num; } -static int ena_com_comp_status_to_errno(u8 comp_status) +static int ena_com_comp_status_to_errno(struct ena_com_admin_queue *admin_queue, + u8 comp_status) { if (unlikely(comp_status != 0)) - ena_trc_err("admin command failed[%u]\n", comp_status); + ena_trc_err(admin_queue->ena_dev, + "Admin command failed[%u]\n", comp_status); switch (comp_status) { case ENA_ADMIN_SUCCESS: @@ -557,15 +566,17 @@ static int ena_com_comp_status_to_errno(u8 comp_status case ENA_ADMIN_ILLEGAL_PARAMETER: case ENA_ADMIN_UNKNOWN_ERROR: return ENA_COM_INVAL; + case ENA_ADMIN_RESOURCE_BUSY: + return ENA_COM_TRY_AGAIN; } return ENA_COM_INVAL; } -static inline void ena_delay_exponential_backoff_us(u32 exp, u32 delay_us) +static void ena_delay_exponential_backoff_us(u32 exp, u32 delay_us) { - delay_us = ENA_MAX32(ENA_MIN_POLL_US, delay_us); - delay_us = ENA_MIN32(delay_us * (1 << exp), ENA_MAX_POLL_US); + delay_us = ENA_MAX32(ENA_MIN_ADMIN_POLL_US, delay_us); + delay_us = ENA_MIN32(delay_us * (1U << exp), ENA_MAX_ADMIN_POLL_US); ENA_USLEEP(delay_us); } @@ -588,7 +599,8 @@ static int ena_com_wait_and_process_admin_cq_polling(s break; if (ENA_TIME_EXPIRE(timeout)) { - ena_trc_err("Wait for completion (polling) timeout\n"); + ena_trc_err(admin_queue->ena_dev, + "Wait for completion (polling) timeout\n"); /* ENA didn't have any completion */ ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags); admin_queue->stats.no_completion++; @@ -599,11 +611,12 @@ static int ena_com_wait_and_process_admin_cq_polling(s goto err; } - ena_delay_exponential_backoff_us(exp++, admin_queue->ena_dev->ena_min_poll_delay_us); + ena_delay_exponential_backoff_us(exp++, + admin_queue->ena_dev->ena_min_poll_delay_us); } if (unlikely(comp_ctx->status == ENA_CMD_ABORTED)) { - ena_trc_err("Command was aborted\n"); + ena_trc_err(admin_queue->ena_dev, "Command was aborted\n"); ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags); admin_queue->stats.aborted_cmd++; ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags); @@ -612,15 +625,16 @@ static int ena_com_wait_and_process_admin_cq_polling(s } ENA_WARN(comp_ctx->status != ENA_CMD_COMPLETED, - "Invalid comp status %d\n", comp_ctx->status); + admin_queue->ena_dev, "Invalid comp status %d\n", + comp_ctx->status); - ret = ena_com_comp_status_to_errno(comp_ctx->comp_status); + ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status); err: comp_ctxt_release(admin_queue, comp_ctx); return ret; } -/** +/* * Set the LLQ configurations of the firmware * * The driver provides only the enabled feature values to the device, @@ -645,14 +659,10 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev cmd.u.llq.desc_num_before_header_enabled = llq_info->descs_num_before_header; cmd.u.llq.descriptors_stride_ctrl_enabled = llq_info->desc_stride_ctrl; - if (llq_info->disable_meta_caching) - cmd.u.llq.accel_mode.u.set.enabled_flags |= - BIT(ENA_ADMIN_DISABLE_META_CACHING); + cmd.u.llq.accel_mode.u.set.enabled_flags = + BIT(ENA_ADMIN_DISABLE_META_CACHING) | + BIT(ENA_ADMIN_LIMIT_TX_BURST); - if (llq_info->max_entries_in_tx_burst) - cmd.u.llq.accel_mode.u.set.enabled_flags |= - BIT(ENA_ADMIN_LIMIT_TX_BURST); - ret = ena_com_execute_admin_command(admin_queue, (struct ena_admin_aq_entry *)&cmd, sizeof(cmd), @@ -660,7 +670,7 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev sizeof(resp)); if (unlikely(ret)) - ena_trc_err("Failed to set LLQ configurations: %d\n", ret); + ena_trc_err(ena_dev, "Failed to set LLQ configurations: %d\n", ret); return ret; } @@ -670,6 +680,7 @@ static int ena_com_config_llq_info(struct ena_com_dev struct ena_llq_configurations *llq_default_cfg) { struct ena_com_llq_info *llq_info = &ena_dev->llq_info; + struct ena_admin_accel_mode_get llq_accel_mode_get; u16 supported_feat; int rc; @@ -681,7 +692,7 @@ static int ena_com_config_llq_info(struct ena_com_dev llq_info->header_location_ctrl = llq_default_cfg->llq_header_location; } else { - ena_trc_err("Invalid header location control, supported: 0x%x\n", + ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n", supported_feat); return -EINVAL; } @@ -696,12 +707,12 @@ static int ena_com_config_llq_info(struct ena_com_dev } else if (supported_feat & ENA_ADMIN_SINGLE_DESC_PER_ENTRY) { llq_info->desc_stride_ctrl = ENA_ADMIN_SINGLE_DESC_PER_ENTRY; } else { - ena_trc_err("Invalid desc_stride_ctrl, supported: 0x%x\n", + ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n", supported_feat); return -EINVAL; } - ena_trc_err("Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", + ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", llq_default_cfg->llq_stride_ctrl, supported_feat, llq_info->desc_stride_ctrl); @@ -725,11 +736,12 @@ static int ena_com_config_llq_info(struct ena_com_dev llq_info->desc_list_entry_size_ctrl = ENA_ADMIN_LIST_ENTRY_SIZE_256B; llq_info->desc_list_entry_size = 256; } else { - ena_trc_err("Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat); + ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n", + supported_feat); return -EINVAL; } - ena_trc_err("Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", + ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", llq_default_cfg->llq_ring_entry_size, supported_feat, llq_info->desc_list_entry_size); @@ -738,7 +750,7 @@ static int ena_com_config_llq_info(struct ena_com_dev /* The desc list entry size should be whole multiply of 8 * This requirement comes from __iowrite64_copy() */ - ena_trc_err("illegal entry size %d\n", + ena_trc_err(ena_dev, "Illegal entry size %d\n", llq_info->desc_list_entry_size); return -EINVAL; } @@ -762,29 +774,31 @@ static int ena_com_config_llq_info(struct ena_com_dev } else if (supported_feat & ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8) { llq_info->descs_num_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8; } else { - ena_trc_err("Invalid descs_num_before_header, supported: 0x%x\n", + ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n", supported_feat); return -EINVAL; } - ena_trc_err("Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", + ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", llq_default_cfg->llq_num_decs_before_header, supported_feat, llq_info->descs_num_before_header); } /* Check for accelerated queue supported */ + llq_accel_mode_get = llq_features->accel_mode.u.get; + llq_info->disable_meta_caching = - llq_features->accel_mode.u.get.supported_flags & - BIT(ENA_ADMIN_DISABLE_META_CACHING); + !!(llq_accel_mode_get.supported_flags & + BIT(ENA_ADMIN_DISABLE_META_CACHING)); - if (llq_features->accel_mode.u.get.supported_flags & BIT(ENA_ADMIN_LIMIT_TX_BURST)) + if (llq_accel_mode_get.supported_flags & BIT(ENA_ADMIN_LIMIT_TX_BURST)) llq_info->max_entries_in_tx_burst = - llq_features->accel_mode.u.get.max_tx_burst_size / + llq_accel_mode_get.max_tx_burst_size / llq_default_cfg->llq_ring_entry_size_value; rc = ena_com_set_llq(ena_dev); if (rc) - ena_trc_err("Cannot set LLQ configuration: %d\n", rc); + ena_trc_err(ena_dev, "Cannot set LLQ configuration: %d\n", rc); return rc; } @@ -810,13 +824,15 @@ static int ena_com_wait_and_process_admin_cq_interrupt ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags); if (comp_ctx->status == ENA_CMD_COMPLETED) { - ena_trc_err("The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n", + ena_trc_err(admin_queue->ena_dev, + "The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n", comp_ctx->cmd_opcode, admin_queue->auto_polling ? "ON" : "OFF"); /* Check if fallback to polling is enabled */ if (admin_queue->auto_polling) admin_queue->polling = true; } else { - ena_trc_err("The ena device didn't send a completion for the admin cmd %d status %d\n", + ena_trc_err(admin_queue->ena_dev, + "The ena device didn't send a completion for the admin cmd %d status %d\n", comp_ctx->cmd_opcode, comp_ctx->status); } /* Check if shifted to polling mode. @@ -830,7 +846,7 @@ static int ena_com_wait_and_process_admin_cq_interrupt } } - ret = ena_com_comp_status_to_errno(comp_ctx->comp_status); + ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status); err: comp_ctxt_release(admin_queue, comp_ctx); return ret; @@ -878,7 +894,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev * } if (unlikely(i == timeout)) { - ena_trc_err("reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n", + ena_trc_err(ena_dev, "Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n", mmio_read->seq_num, offset, read_resp->req_id, @@ -888,7 +904,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev * } if (read_resp->reg_off != offset) { - ena_trc_err("Read failure: wrong offset provided\n"); + ena_trc_err(ena_dev, "Read failure: wrong offset provided\n"); ret = ENA_MMIO_READ_TIMEOUT; } else { ret = read_resp->reg_val; @@ -947,7 +963,7 @@ static int ena_com_destroy_io_sq(struct ena_com_dev *e sizeof(destroy_resp)); if (unlikely(ret && (ret != ENA_COM_NO_DEVICE))) - ena_trc_err("failed to destroy io sq error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to destroy io sq error: %d\n", ret); return ret; } @@ -1003,7 +1019,7 @@ static int wait_for_reset_state(struct ena_com_dev *en val = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF); if (unlikely(val == ENA_MMIO_READ_TIMEOUT)) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } @@ -1043,7 +1059,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev * int ret; if (!ena_com_check_supported_feature_id(ena_dev, feature_id)) { - ena_trc_dbg("Feature %d isn't supported\n", feature_id); + ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", feature_id); return ENA_COM_UNSUPPORTED; } @@ -1062,7 +1078,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev * &get_cmd.control_buffer.address, control_buf_dma_addr); if (unlikely(ret)) { - ena_trc_err("memory address set failed\n"); + ena_trc_err(ena_dev, "Memory address set failed\n"); return ret; } @@ -1079,7 +1095,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev * sizeof(*get_resp)); if (unlikely(ret)) - ena_trc_err("Failed to submit get_feature command %d error: %d\n", + ena_trc_err(ena_dev, "Failed to submit get_feature command %d error: %d\n", feature_id, ret); return ret; @@ -1110,13 +1126,9 @@ static void ena_com_hash_key_fill_default_key(struct e ENA_RSS_FILL_KEY(&hash_key->key, sizeof(hash_key->key)); /* The key buffer is stored in the device in an array of - * uint32 elements. Therefore the number of elements can be derived - * by dividing the buffer length by the size of each array element. - * In current implementation each element is sized at uint32_t - * so it's actually a division by 4 but if the element size changes, - * there is no need to rewrite this code. + * uint32 elements. */ - hash_key->keys_num = sizeof(hash_key->key) / sizeof(hash_key->key[0]); + hash_key->key_parts = ENA_ADMIN_RSS_KEY_PARTS; } static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev) @@ -1189,13 +1201,13 @@ static int ena_com_indirect_table_allocate(struct ena_ int ret; ret = ena_com_get_feature(ena_dev, &get_resp, - ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0); + ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0); if (unlikely(ret)) return ret; if ((get_resp.u.ind_table.min_size > log_size) || (get_resp.u.ind_table.max_size < log_size)) { - ena_trc_err("indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n", + ena_trc_err(ena_dev, "Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n", 1 << log_size, 1 << get_resp.u.ind_table.min_size, 1 << get_resp.u.ind_table.max_size); @@ -1299,7 +1311,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *en &create_cmd.sq_ba, io_sq->desc_addr.phys_addr); if (unlikely(ret)) { - ena_trc_err("memory address set failed\n"); + ena_trc_err(ena_dev, "Memory address set failed\n"); return ret; } } @@ -1310,7 +1322,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *en (struct ena_admin_acq_entry *)&cmd_completion, sizeof(cmd_completion)); if (unlikely(ret)) { - ena_trc_err("Failed to create IO SQ. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to create IO SQ. error: %d\n", ret); return ret; } @@ -1328,7 +1340,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *en cmd_completion.llq_descriptors_offset); } - ena_trc_dbg("created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth); + ena_trc_dbg(ena_dev, "Created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth); return ret; } @@ -1362,7 +1374,7 @@ static void ena_com_update_intr_delay_resolution(struc u16 prev_intr_delay_resolution = ena_dev->intr_delay_resolution; if (unlikely(!intr_delay_resolution)) { - ena_trc_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n"); + ena_trc_err(ena_dev, "Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n"); intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION; } @@ -1398,23 +1410,25 @@ int ena_com_execute_admin_command(struct ena_com_admin comp, comp_size); if (IS_ERR(comp_ctx)) { if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE)) - ena_trc_dbg("Failed to submit command [%ld]\n", + ena_trc_dbg(admin_queue->ena_dev, + "Failed to submit command [%ld]\n", PTR_ERR(comp_ctx)); else - ena_trc_err("Failed to submit command [%ld]\n", + ena_trc_err(admin_queue->ena_dev, + "Failed to submit command [%ld]\n", PTR_ERR(comp_ctx)); - return PTR_ERR(comp_ctx); + return (int)PTR_ERR(comp_ctx); } ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue); if (unlikely(ret)) { if (admin_queue->running_state) - ena_trc_err("Failed to process command. ret = %d\n", - ret); + ena_trc_err(admin_queue->ena_dev, + "Failed to process command. ret = %d\n", ret); else - ena_trc_dbg("Failed to process command. ret = %d\n", - ret); + ena_trc_dbg(admin_queue->ena_dev, + "Failed to process command. ret = %d\n", ret); } return ret; } @@ -1443,7 +1457,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev, &create_cmd.cq_ba, io_cq->cdesc_addr.phys_addr); if (unlikely(ret)) { - ena_trc_err("memory address set failed\n"); + ena_trc_err(ena_dev, "Memory address set failed\n"); return ret; } @@ -1453,7 +1467,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev, (struct ena_admin_acq_entry *)&cmd_completion, sizeof(cmd_completion)); if (unlikely(ret)) { - ena_trc_err("Failed to create IO CQ. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to create IO CQ. error: %d\n", ret); return ret; } @@ -1472,7 +1486,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev, (u32 __iomem *)((uintptr_t)ena_dev->reg_bar + cmd_completion.numa_node_register_offset); - ena_trc_dbg("created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth); + ena_trc_dbg(ena_dev, "Created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth); return ret; } @@ -1482,7 +1496,7 @@ int ena_com_get_io_handlers(struct ena_com_dev *ena_de struct ena_com_io_cq **io_cq) { if (qid >= ENA_TOTAL_NUM_QUEUES) { - ena_trc_err("Invalid queue number %d but the max is %d\n", + ena_trc_err(ena_dev, "Invalid queue number %d but the max is %d\n", qid, ENA_TOTAL_NUM_QUEUES); return ENA_COM_INVAL; } @@ -1548,7 +1562,7 @@ int ena_com_destroy_io_cq(struct ena_com_dev *ena_dev, sizeof(destroy_resp)); if (unlikely(ret && (ret != ENA_COM_NO_DEVICE))) - ena_trc_err("Failed to destroy IO CQ. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to destroy IO CQ. error: %d\n", ret); return ret; } @@ -1572,7 +1586,7 @@ void ena_com_admin_aenq_enable(struct ena_com_dev *ena { u16 depth = ena_dev->aenq.q_depth; - ENA_WARN(ena_dev->aenq.head != depth, "Invalid AENQ state\n"); + ENA_WARN(ena_dev->aenq.head != depth, ena_dev, "Invalid AENQ state\n"); /* Init head_db to mark that all entries in the queue * are initially available @@ -1590,12 +1604,12 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_de ret = ena_com_get_feature(ena_dev, &get_resp, ENA_ADMIN_AENQ_CONFIG, 0); if (ret) { - ena_trc_info("Can't get aenq configuration\n"); + ena_trc_info(ena_dev, "Can't get aenq configuration\n"); return ret; } if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) { - ena_trc_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n", + ena_trc_warn(ena_dev, "Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n", get_resp.u.aenq.supported_groups, groups_flag); return ENA_COM_UNSUPPORTED; @@ -1616,7 +1630,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_de sizeof(resp)); if (unlikely(ret)) - ena_trc_err("Failed to config AENQ ret: %d\n", ret); + ena_trc_err(ena_dev, "Failed to config AENQ ret: %d\n", ret); return ret; } @@ -1624,20 +1638,20 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_de int ena_com_get_dma_width(struct ena_com_dev *ena_dev) { u32 caps = ena_com_reg_bar_read32(ena_dev, ENA_REGS_CAPS_OFF); - int width; + u32 width; if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } width = (caps & ENA_REGS_CAPS_DMA_ADDR_WIDTH_MASK) >> ENA_REGS_CAPS_DMA_ADDR_WIDTH_SHIFT; - ena_trc_dbg("ENA dma width: %d\n", width); + ena_trc_dbg(ena_dev, "ENA dma width: %d\n", width); if ((width < 32) || width > ENA_MAX_PHYS_ADDR_SIZE_BITS) { - ena_trc_err("DMA width illegal value: %d\n", width); + ena_trc_err(ena_dev, "DMA width illegal value: %d\n", width); return ENA_COM_INVAL; } @@ -1661,16 +1675,16 @@ int ena_com_validate_version(struct ena_com_dev *ena_d if (unlikely((ver == ENA_MMIO_READ_TIMEOUT) || (ctrl_ver == ENA_MMIO_READ_TIMEOUT))) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } - ena_trc_info("ena device version: %d.%d\n", + ena_trc_info(ena_dev, "ENA device version: %d.%d\n", (ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >> ENA_REGS_VERSION_MAJOR_VERSION_SHIFT, ver & ENA_REGS_VERSION_MINOR_VERSION_MASK); - ena_trc_info("ena controller version: %d.%d.%d implementation version %d\n", + ena_trc_info(ena_dev, "ENA controller version: %d.%d.%d implementation version %d\n", (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK) >> ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT, (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK) @@ -1686,13 +1700,29 @@ int ena_com_validate_version(struct ena_com_dev *ena_d /* Validate the ctrl version without the implementation ID */ if (ctrl_ver_masked < MIN_ENA_CTRL_VER) { - ena_trc_err("ENA ctrl version is lower than the minimal ctrl version the driver supports\n"); + ena_trc_err(ena_dev, "ENA ctrl version is lower than the minimal ctrl version the driver supports\n"); return -1; } return 0; } +static void +ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev, + struct ena_com_admin_queue *admin_queue) + +{ + if (!admin_queue->comp_ctx) + return; + + ENA_WAIT_EVENTS_DESTROY(admin_queue); + ENA_MEM_FREE(ena_dev->dmadev, + admin_queue->comp_ctx, + (admin_queue->q_depth * sizeof(struct ena_comp_ctx))); + + admin_queue->comp_ctx = NULL; +} + void ena_com_admin_destroy(struct ena_com_dev *ena_dev) { struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue; @@ -1701,12 +1731,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev struct ena_com_aenq *aenq = &ena_dev->aenq; u16 size; - ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event); - if (admin_queue->comp_ctx) - ENA_MEM_FREE(ena_dev->dmadev, - admin_queue->comp_ctx, - (admin_queue->q_depth * sizeof(struct ena_comp_ctx))); - admin_queue->comp_ctx = NULL; + ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue); + size = ADMIN_SQ_SIZE(admin_queue->q_depth); if (sq->entries) ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries, @@ -1822,12 +1848,12 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev, dev_sts = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF); if (unlikely(dev_sts == ENA_MMIO_READ_TIMEOUT)) { - ena_trc_err("Reg read timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } if (!(dev_sts & ENA_REGS_DEV_STS_READY_MASK)) { - ena_trc_err("Device isn't ready, abort com init\n"); + ena_trc_err(ena_dev, "Device isn't ready, abort com init\n"); return ENA_COM_NO_DEVICE; } @@ -1905,7 +1931,7 @@ int ena_com_create_io_queue(struct ena_com_dev *ena_de int ret; if (ctx->qid >= ENA_TOTAL_NUM_QUEUES) { - ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n", + ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n", ctx->qid, ENA_TOTAL_NUM_QUEUES); return ENA_COM_INVAL; } @@ -1964,7 +1990,7 @@ void ena_com_destroy_io_queue(struct ena_com_dev *ena_ struct ena_com_io_cq *io_cq; if (qid >= ENA_TOTAL_NUM_QUEUES) { - ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n", + ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n", qid, ENA_TOTAL_NUM_QUEUES); return; } @@ -1997,6 +2023,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_ memcpy(&get_feat_ctx->dev_attr, &get_resp.u.dev_attr, sizeof(get_resp.u.dev_attr)); + ena_dev->supported_features = get_resp.u.dev_attr.supported_features; if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) { @@ -2063,17 +2090,6 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_ else return rc; - rc = ena_com_get_feature(ena_dev, &get_resp, - ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0); - if (!rc) - memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table, - sizeof(get_resp.u.ind_table)); - else if (rc == ENA_COM_UNSUPPORTED) - memset(&get_feat_ctx->ind_table, 0x0, - sizeof(get_feat_ctx->ind_table)); - else - return rc; - return 0; } @@ -2085,10 +2101,10 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_ /* ena_handle_specific_aenq_event: * return the handler that is relevant to the specific event group */ -static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev, +static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *ena_dev, u16 group) { - struct ena_aenq_handlers *aenq_handlers = dev->aenq.aenq_handlers; + struct ena_aenq_handlers *aenq_handlers = ena_dev->aenq.aenq_handlers; if ((group < ENA_MAX_HANDLERS) && aenq_handlers->handlers[group]) return aenq_handlers->handlers[group]; @@ -2100,11 +2116,11 @@ static ena_aenq_handler ena_com_get_specific_aenq_cb(s * handles the aenq incoming events. * pop events from the queue and apply the specific handler */ -void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data) +void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data) { struct ena_admin_aenq_entry *aenq_e; struct ena_admin_aenq_common_desc *aenq_common; - struct ena_com_aenq *aenq = &dev->aenq; + struct ena_com_aenq *aenq = &ena_dev->aenq; u64 timestamp; ena_aenq_handler handler_cb; u16 masked_head, processed = 0; @@ -2125,13 +2141,14 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev timestamp = (u64)aenq_common->timestamp_low | ((u64)aenq_common->timestamp_high << 32); - ena_trc_dbg("AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n", + + ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIu64 "s]\n", aenq_common->group, - aenq_common->syndrom, + aenq_common->syndrome, timestamp); /* Handle specific event*/ - handler_cb = ena_com_get_specific_aenq_cb(dev, + handler_cb = ena_com_get_specific_aenq_cb(ena_dev, aenq_common->group); handler_cb(data, aenq_e); /* call the actual event handler*/ @@ -2156,8 +2173,8 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev /* write the aenq doorbell after all AENQ descriptors were read */ mb(); - ENA_REG_WRITE32_RELAXED(dev->bus, (u32)aenq->head, - dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); + ENA_REG_WRITE32_RELAXED(ena_dev->bus, (u32)aenq->head, + ena_dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF); mmiowb(); } #ifdef ENA_EXTENDED_STATS @@ -2193,19 +2210,19 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev, if (unlikely((stat == ENA_MMIO_READ_TIMEOUT) || (cap == ENA_MMIO_READ_TIMEOUT))) { - ena_trc_err("Reg read32 timeout occurred\n"); + ena_trc_err(ena_dev, "Reg read32 timeout occurred\n"); return ENA_COM_TIMER_EXPIRED; } if ((stat & ENA_REGS_DEV_STS_READY_MASK) == 0) { - ena_trc_err("Device isn't ready, can't reset device\n"); + ena_trc_err(ena_dev, "Device isn't ready, can't reset device\n"); return ENA_COM_INVAL; } timeout = (cap & ENA_REGS_CAPS_RESET_TIMEOUT_MASK) >> ENA_REGS_CAPS_RESET_TIMEOUT_SHIFT; if (timeout == 0) { - ena_trc_err("Invalid timeout value\n"); + ena_trc_err(ena_dev, "Invalid timeout value\n"); return ENA_COM_INVAL; } @@ -2221,7 +2238,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev, rc = wait_for_reset_state(ena_dev, timeout, ENA_REGS_DEV_STS_RESET_IN_PROGRESS_MASK); if (rc != 0) { - ena_trc_err("Reset indication didn't turn on\n"); + ena_trc_err(ena_dev, "Reset indication didn't turn on\n"); return rc; } @@ -2229,7 +2246,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev, ENA_REG_WRITE32(ena_dev->bus, 0, ena_dev->reg_bar + ENA_REGS_DEV_CTL_OFF); rc = wait_for_reset_state(ena_dev, timeout, 0); if (rc != 0) { - ena_trc_err("Reset indication didn't turn off\n"); + ena_trc_err(ena_dev, "Reset indication didn't turn off\n"); return rc; } @@ -2266,11 +2283,26 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_d sizeof(*get_resp)); if (unlikely(ret)) - ena_trc_err("Failed to get stats. error: %d\n", ret); + ena_trc_err(ena_dev, "Failed to get stats. error: %d\n", ret); return ret; } +int ena_com_get_eni_stats(struct ena_com_dev *ena_dev, + struct ena_admin_eni_stats *stats) +{ + struct ena_com_stats_ctx ctx; + int ret; + + memset(&ctx, 0x0, sizeof(ctx)); + ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_ENI); + if (likely(ret == 0)) + memcpy(stats, &ctx.get_resp.u.eni_stats, + sizeof(ctx.get_resp.u.eni_stats)); + + return ret; +} + int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev, struct ena_admin_basic_stats *stats) { @@ -2280,8 +2312,8 @@ int ena_com_get_dev_basic_stats(struct ena_com_dev *en memset(&ctx, 0x0, sizeof(ctx)); ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_BASIC); if (likely(ret == 0)) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Nov 18 15:02:13 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 800D0469879; Wed, 18 Nov 2020 15:02:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbmHn3Gs7z3lJP; Wed, 18 Nov 2020 15:02:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63C8E13CDF; Wed, 18 Nov 2020 15:02:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIF2D1G028433; Wed, 18 Nov 2020 15:02:13 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIF2Dx0028431; Wed, 18 Nov 2020 15:02:13 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181502.0AIF2Dx0028431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 15:02:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367800 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 367800 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:02:13 -0000 Author: mw Date: Wed Nov 18 15:02:12 2020 New Revision: 367800 URL: https://svnweb.freebsd.org/changeset/base/367800 Log: Add Rx offsets support for the ENA driver For the first descriptor in a chain the data may start at an offset. It is optional feature of some devices, so the driver must ack that it supports it. The data pointer of the mbuf is simply shifted by the given value. Submitted by: Maciej Bielski Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27116 Modified: head/sys/dev/ena/ena.c head/sys/dev/ena/ena_datapath.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Wed Nov 18 14:59:22 2020 (r367799) +++ head/sys/dev/ena/ena.c Wed Nov 18 15:02:12 2020 (r367800) @@ -2797,6 +2797,8 @@ ena_config_host_info(struct ena_com_dev *ena_dev, devi (DRV_MODULE_VER_MINOR << ENA_ADMIN_HOST_INFO_MINOR_SHIFT) | (DRV_MODULE_VER_SUBMINOR << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT); host_info->num_cpus = mp_ncpus; + host_info->driver_supported_features = + ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK; rc = ena_com_set_host_attributes(ena_dev); if (unlikely(rc != 0)) { Modified: head/sys/dev/ena/ena_datapath.c ============================================================================== --- head/sys/dev/ena/ena_datapath.c Wed Nov 18 14:59:22 2020 (r367799) +++ head/sys/dev/ena/ena_datapath.c Wed Nov 18 15:02:12 2020 (r367800) @@ -431,6 +431,10 @@ ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_r mbuf->m_flags |= M_PKTHDR; mbuf->m_pkthdr.len = len; mbuf->m_len = len; + // Only for the first segment the data starts at specific offset + mbuf->m_data = mtodo(mbuf, ena_rx_ctx->pkt_offset); + ena_trace(NULL, ENA_DBG | ENA_RXPTH, + "Mbuf data offset=%u\n", ena_rx_ctx->pkt_offset); mbuf->m_pkthdr.rcvif = rx_ring->que->adapter->ifp; /* Fill mbuf with hash key and it's interpretation for optimization */ @@ -575,6 +579,8 @@ ena_rx_cleanup(struct ena_ring *rx_ring) ena_rx_ctx.ena_bufs = rx_ring->ena_bufs; ena_rx_ctx.max_bufs = adapter->max_rx_sgl_size; ena_rx_ctx.descs = 0; + ena_rx_ctx.pkt_offset = 0; + bus_dmamap_sync(io_cq->cdesc_addr.mem_handle.tag, io_cq->cdesc_addr.mem_handle.map, BUS_DMASYNC_POSTREAD); rc = ena_com_rx_pkt(io_cq, io_sq, &ena_rx_ctx); From owner-svn-src-all@freebsd.org Wed Nov 18 15:07:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 37325469D09; Wed, 18 Nov 2020 15:07:37 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbmQ113XRz3l5r; Wed, 18 Nov 2020 15:07:37 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1250913F6B; Wed, 18 Nov 2020 15:07:37 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIF7abT028726; Wed, 18 Nov 2020 15:07:36 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIF7Ydd028716; Wed, 18 Nov 2020 15:07:34 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181507.0AIF7Ydd028716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 15:07:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367801 - in head: share/man/man4 sys/dev/ena sys/modules/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head: share/man/man4 sys/dev/ena sys/modules/ena X-SVN-Commit-Revision: 367801 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:07:37 -0000 Author: mw Date: Wed Nov 18 15:07:34 2020 New Revision: 367801 URL: https://svnweb.freebsd.org/changeset/base/367801 Log: Add SPDX license tag to the ENA driver files Refering to guide: https://wiki.freebsd.org/SPDX the SPDX tag should not replace the standard license text, however it should be added over the standard license text to make the automation easier. Because of that, the old license was kept, but the SPDX tag was added on top of every ENA driver file. Submited by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27117 Modified: head/share/man/man4/ena.4 head/sys/dev/ena/ena.c head/sys/dev/ena/ena.h head/sys/dev/ena/ena_datapath.c head/sys/dev/ena/ena_datapath.h head/sys/dev/ena/ena_netmap.c head/sys/dev/ena/ena_netmap.h head/sys/dev/ena/ena_sysctl.c head/sys/dev/ena/ena_sysctl.h head/sys/modules/ena/Makefile Modified: head/share/man/man4/ena.4 ============================================================================== --- head/share/man/man4/ena.4 Wed Nov 18 15:02:12 2020 (r367800) +++ head/share/man/man4/ena.4 Wed Nov 18 15:07:34 2020 (r367801) @@ -1,4 +1,6 @@ -.\" Copyright (c) 2015-2017 Amazon.com, Inc. or its affiliates. +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena.c Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/dev/ena/ena.h ============================================================================== --- head/sys/dev/ena/ena.h Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena.h Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/dev/ena/ena_datapath.c ============================================================================== --- head/sys/dev/ena/ena_datapath.c Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena_datapath.c Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/dev/ena/ena_datapath.h ============================================================================== --- head/sys/dev/ena/ena_datapath.h Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena_datapath.h Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/dev/ena/ena_netmap.c ============================================================================== --- head/sys/dev/ena/ena_netmap.c Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena_netmap.c Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/dev/ena/ena_netmap.h ============================================================================== --- head/sys/dev/ena/ena_netmap.h Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena_netmap.h Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/dev/ena/ena_sysctl.c ============================================================================== --- head/sys/dev/ena/ena_sysctl.c Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena_sysctl.c Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/dev/ena/ena_sysctl.h ============================================================================== --- head/sys/dev/ena/ena_sysctl.h Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/dev/ena/ena_sysctl.h Wed Nov 18 15:07:34 2020 (r367801) @@ -1,5 +1,5 @@ /*- - * BSD LICENSE + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. * All rights reserved. Modified: head/sys/modules/ena/Makefile ============================================================================== --- head/sys/modules/ena/Makefile Wed Nov 18 15:02:12 2020 (r367800) +++ head/sys/modules/ena/Makefile Wed Nov 18 15:07:34 2020 (r367801) @@ -1,7 +1,7 @@ # -# BSD LICENSE +# SPDX-License-Identifier: BSD-2-Clause # -# Copyright (c) 2015-2019 Amazon.com, Inc. or its affiliates. +# Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. # All rights reserved. # # Redistribution and use in source and binary forms, with or without From owner-svn-src-all@freebsd.org Wed Nov 18 15:17:56 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A7D7469D7D; Wed, 18 Nov 2020 15:17:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbmdw1GHVz3m1H; Wed, 18 Nov 2020 15:17:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E348141F4; Wed, 18 Nov 2020 15:17:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIFHuSX035006; Wed, 18 Nov 2020 15:17:56 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIFHtN9035003; Wed, 18 Nov 2020 15:17:55 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181517.0AIFHtN9035003@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 15:17:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367802 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 367802 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:17:56 -0000 Author: mw Date: Wed Nov 18 15:17:55 2020 New Revision: 367802 URL: https://svnweb.freebsd.org/changeset/base/367802 Log: Add ENI metrics for the ENA driver The new HAL allows the driver to read extra ENI stats. Exact meaning of each of them can be found in base/ena_defs/ena_admin_defs.h file and structure ena_admin_eni_stats. Those stats are being updated inside of the timer service, which is executed every second. ENI metrics are turned off by default. They can be enabled, using the sysctl node: dev.ena.X.eni_metrics.update_delay 0 value in this node means that the update is turned off. Other values determine how many seconds must pass, before ENI metrics will be updated. They can be acquired, using sysctl: sysctl dev.ena.X.eni_metrics Where X stands for the interface number. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27118 Modified: head/sys/dev/ena/ena.c head/sys/dev/ena/ena.h head/sys/dev/ena/ena_sysctl.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Wed Nov 18 15:07:34 2020 (r367801) +++ head/sys/dev/ena/ena.c Wed Nov 18 15:17:55 2020 (r367802) @@ -172,6 +172,7 @@ static int ena_enable_msix_and_set_admin_interrupts(st static void ena_update_on_link_change(void *, struct ena_admin_aenq_entry *); static void unimplemented_aenq_handler(void *, struct ena_admin_aenq_entry *); +static int ena_copy_eni_metrics(struct ena_adapter *); static void ena_timer_service(void *); static char ena_version[] = DEVICE_NAME DRV_MODULE_NAME " v" DRV_MODULE_VERSION; @@ -3215,6 +3216,44 @@ static void ena_update_hints(struct ena_adapter *adapt } } +/** + * ena_copy_eni_metrics - Get and copy ENI metrics from the HW. + * @adapter: ENA device adapter + * + * Returns 0 on success, EOPNOTSUPP if current HW doesn't support those metrics + * and other error codes on failure. + * + * This function can possibly cause a race with other calls to the admin queue. + * Because of that, the caller should either lock this function or make sure + * that there is no race in the current context. + */ +static int +ena_copy_eni_metrics(struct ena_adapter *adapter) +{ + static bool print_once = true; + int rc; + + rc = ena_com_get_eni_stats(adapter->ena_dev, &adapter->eni_metrics); + + if (rc != 0) { + if (rc == ENA_COM_UNSUPPORTED) { + if (print_once) { + device_printf(adapter->pdev, + "Retrieving ENI metrics is not supported.\n"); + print_once = false; + } else { + ena_trace(NULL, ENA_DBG, + "Retrieving ENI metrics is not supported.\n"); + } + } else { + device_printf(adapter->pdev, + "Failed to get ENI metrics: %d\n", rc); + } + } + + return (rc); +} + static void ena_timer_service(void *data) { @@ -3229,6 +3268,38 @@ ena_timer_service(void *data) check_for_missing_completions(adapter); check_for_empty_rx_ring(adapter); + + /* + * User controller update of the ENI metrics. + * If the delay was set to 0, then the stats shouldn't be updated at + * all. + * Otherwise, wait 'eni_metrics_sample_interval' seconds, before + * updating stats. + * As timer service is executed every second, it's enough to increment + * appropriate counter each time the timer service is executed. + */ + if ((adapter->eni_metrics_sample_interval != 0) && + (++adapter->eni_metrics_sample_interval_cnt >= + adapter->eni_metrics_sample_interval)) { + /* + * There is no race with other admin queue calls, as: + * - Timer service runs after interface is up, so all + * configuration calls to the admin queue are finished. + * - After interface is up, the driver doesn't use (at least + * for now) other functions writing to the admin queue. + * + * It may change in the future, so in that situation, the lock + * will be needed. ENA_LOCK_*() cannot be used for that purpose, + * as callout ena_timer_service is protected by them. It could + * lead to the deadlock if callout_drain() would hold the lock + * before ena_copy_eni_metrics() was executed. It's advised to + * use separate lock in that situation which will be used only + * for the admin queue. + */ + (void)ena_copy_eni_metrics(adapter); + adapter->eni_metrics_sample_interval_cnt = 0; + } + if (host_info != NULL) ena_update_host_info(host_info, adapter->ifp); Modified: head/sys/dev/ena/ena.h ============================================================================== --- head/sys/dev/ena/ena.h Wed Nov 18 15:07:34 2020 (r367801) +++ head/sys/dev/ena/ena.h Wed Nov 18 15:17:55 2020 (r367802) @@ -463,9 +463,13 @@ struct ena_adapter { uint32_t missing_tx_threshold; bool disable_meta_caching; + uint16_t eni_metrics_sample_interval; + uint16_t eni_metrics_sample_interval_cnt; + /* Statistics */ struct ena_stats_dev dev_stats; struct ena_hw_stats hw_stats; + struct ena_admin_eni_stats eni_metrics; enum ena_regs_reset_reason_types reset_reason; }; Modified: head/sys/dev/ena/ena_sysctl.c ============================================================================== --- head/sys/dev/ena/ena_sysctl.c Wed Nov 18 15:07:34 2020 (r367801) +++ head/sys/dev/ena/ena_sysctl.c Wed Nov 18 15:17:55 2020 (r367802) @@ -34,11 +34,16 @@ __FBSDID("$FreeBSD$"); static void ena_sysctl_add_wd(struct ena_adapter *); static void ena_sysctl_add_stats(struct ena_adapter *); +static void ena_sysctl_add_eni_metrics(struct ena_adapter *); static void ena_sysctl_add_tuneables(struct ena_adapter *); static int ena_sysctl_buf_ring_size(SYSCTL_HANDLER_ARGS); static int ena_sysctl_rx_queue_size(SYSCTL_HANDLER_ARGS); static int ena_sysctl_io_queues_nb(SYSCTL_HANDLER_ARGS); +static int ena_sysctl_eni_metrics_interval(SYSCTL_HANDLER_ARGS); +/* Limit max ENI sample rate to be an hour. */ +#define ENI_METRICS_MAX_SAMPLE_INTERVAL 3600 + static SYSCTL_NODE(_hw, OID_AUTO, ena, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "ENA driver parameters"); @@ -69,6 +74,7 @@ ena_sysctl_add_nodes(struct ena_adapter *adapter) { ena_sysctl_add_wd(adapter); ena_sysctl_add_stats(adapter); + ena_sysctl_add_eni_metrics(adapter); ena_sysctl_add_tuneables(adapter); } @@ -292,6 +298,58 @@ ena_sysctl_add_stats(struct ena_adapter *adapter) } static void +ena_sysctl_add_eni_metrics(struct ena_adapter *adapter) +{ + device_t dev; + struct ena_admin_eni_stats *eni_metrics; + + struct sysctl_ctx_list *ctx; + struct sysctl_oid *tree; + struct sysctl_oid_list *child; + + struct sysctl_oid *eni_node; + struct sysctl_oid_list *eni_list; + + dev = adapter->pdev; + + ctx = device_get_sysctl_ctx(dev); + tree = device_get_sysctl_tree(dev); + child = SYSCTL_CHILDREN(tree); + + eni_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "eni_metrics", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "ENA's ENI metrics"); + eni_list = SYSCTL_CHILDREN(eni_node); + + eni_metrics = &adapter->eni_metrics; + + SYSCTL_ADD_U64(ctx, eni_list, OID_AUTO, "bw_in_allowance_exceeded", + CTLFLAG_RD, &eni_metrics->bw_in_allowance_exceeded, 0, + "Inbound BW allowance exceeded"); + SYSCTL_ADD_U64(ctx, eni_list, OID_AUTO, "bw_out_allowance_exceeded", + CTLFLAG_RD, &eni_metrics->bw_out_allowance_exceeded, 0, + "Outbound BW allowance exceeded"); + SYSCTL_ADD_U64(ctx, eni_list, OID_AUTO, "pps_allowance_exceeded", + CTLFLAG_RD, &eni_metrics->pps_allowance_exceeded, 0, + "PPS allowance exceeded"); + SYSCTL_ADD_U64(ctx, eni_list, OID_AUTO, "conntrack_allowance_exceeded", + CTLFLAG_RD, &eni_metrics->conntrack_allowance_exceeded, 0, + "Connection tracking allowance exceeded"); + SYSCTL_ADD_U64(ctx, eni_list, OID_AUTO, "linklocal_allowance_exceeded", + CTLFLAG_RD, &eni_metrics->linklocal_allowance_exceeded, 0, + "Linklocal packet rate allowance exceeded"); + + /* + * Tuneable, which determines how often ENI metrics will be read. + * 0 means it's turned off. Maximum allowed value is limited by: + * ENI_METRICS_MAX_SAMPLE_INTERVAL. + */ + SYSCTL_ADD_PROC(ctx, eni_list, OID_AUTO, "sample_interval", + CTLTYPE_U16 | CTLFLAG_RW | CTLFLAG_MPSAFE, adapter, 0, + ena_sysctl_eni_metrics_interval, "SU", + "Interval in seconds for updating ENI emetrics. 0 turns off the update."); +} + +static void ena_sysctl_add_tuneables(struct ena_adapter *adapter) { device_t dev; @@ -336,7 +394,7 @@ ena_sysctl_buf_ring_size(SYSCTL_HANDLER_ARGS) error = sysctl_wire_old_buffer(req, sizeof(val)); if (error == 0) { val = adapter->buf_ring_size; - error = sysctl_handle_int(oidp, &val, 0, req); + error = sysctl_handle_32(oidp, &val, 0, req); } if (error != 0 || req->newptr == NULL) return (error); @@ -460,4 +518,41 @@ ena_sysctl_io_queues_nb(SYSCTL_HANDLER_ARGS) } return (error); +} + +static int +ena_sysctl_eni_metrics_interval(SYSCTL_HANDLER_ARGS) +{ + struct ena_adapter *adapter = arg1; + uint16_t interval; + int error; + + error = sysctl_wire_old_buffer(req, sizeof(interval)); + if (error == 0) { + interval = adapter->eni_metrics_sample_interval; + error = sysctl_handle_16(oidp, &interval, 0, req); + } + if (error != 0 || req->newptr == NULL) + return (error); + + if (interval > ENI_METRICS_MAX_SAMPLE_INTERVAL) { + device_printf(adapter->pdev, + "ENI metrics update interval is out of range - maximum allowed value: %d seconds\n", + ENI_METRICS_MAX_SAMPLE_INTERVAL); + return (EINVAL); + } + + if (interval == 0) { + device_printf(adapter->pdev, + "ENI metrics update is now turned off\n"); + bzero(&adapter->eni_metrics, sizeof(adapter->eni_metrics)); + } else { + device_printf(adapter->pdev, + "ENI metrics update interval is set to: %"PRIu16" seconds\n", + interval); + } + + adapter->eni_metrics_sample_interval = interval; + + return (0); } From owner-svn-src-all@freebsd.org Wed Nov 18 15:20:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 140FE46A28F; Wed, 18 Nov 2020 15:20:02 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbmhL05Tcz3m6w; Wed, 18 Nov 2020 15:20:02 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EA9D9141FC; Wed, 18 Nov 2020 15:20:01 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIFK1BZ035199; Wed, 18 Nov 2020 15:20:01 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIFK1S1035197; Wed, 18 Nov 2020 15:20:01 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181520.0AIFK1S1035197@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 15:20:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367803 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 367803 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:20:02 -0000 Author: mw Date: Wed Nov 18 15:20:01 2020 New Revision: 367803 URL: https://svnweb.freebsd.org/changeset/base/367803 Log: Rename descriptions of the supported ENA devices Some of the PCI ID were described as ENA with LLQ support - it's not fully accurate and because of that, their names were changed. Instead of LLQ, use RSERV0 for the description of those devices. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27119 Modified: head/sys/dev/ena/ena.c head/sys/dev/ena/ena.h Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Wed Nov 18 15:17:55 2020 (r367802) +++ head/sys/dev/ena/ena.c Wed Nov 18 15:20:01 2020 (r367803) @@ -179,9 +179,9 @@ static char ena_version[] = DEVICE_NAME DRV_MODULE_NAM static ena_vendor_info_t ena_vendor_info_array[] = { { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_PF, 0}, - { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_LLQ_PF, 0}, + { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_PF_RSERV0, 0}, { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_VF, 0}, - { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_LLQ_VF, 0}, + { PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_VF_RSERV0, 0}, /* Last entry */ { 0, 0, 0 } }; Modified: head/sys/dev/ena/ena.h ============================================================================== --- head/sys/dev/ena/ena.h Wed Nov 18 15:17:55 2020 (r367802) +++ head/sys/dev/ena/ena.h Wed Nov 18 15:20:01 2020 (r367803) @@ -150,10 +150,10 @@ */ #define PCI_VENDOR_ID_AMAZON 0x1d0f -#define PCI_DEV_ID_ENA_PF 0x0ec2 -#define PCI_DEV_ID_ENA_LLQ_PF 0x1ec2 -#define PCI_DEV_ID_ENA_VF 0xec20 -#define PCI_DEV_ID_ENA_LLQ_VF 0xec21 +#define PCI_DEV_ID_ENA_PF 0x0ec2 +#define PCI_DEV_ID_ENA_PF_RSERV0 0x1ec2 +#define PCI_DEV_ID_ENA_VF 0xec20 +#define PCI_DEV_ID_ENA_VF_RSERV0 0xec21 /* * Flags indicating current ENA driver state From owner-svn-src-all@freebsd.org Wed Nov 18 15:20:36 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 549E146A306; Wed, 18 Nov 2020 15:20:36 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 4Cbmj01n52z3mNy; Wed, 18 Nov 2020 15:20:36 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x442.google.com with SMTP id u12so2640726wrt.0; Wed, 18 Nov 2020 07:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NgX+vyM2d0eFDionULbFchaZ5NR+NrnZc8rFGiUHIZE=; b=MFXDASXEkYmyaIoe252jI4LnIsvC+biorpL41HE1C6hQKQ+DNwVGAKGsX6E8w9jIwj VAqZ4GZZpOL5/iVNu1us+oeiGxwG2ak4dE3JWTVxW6cl3Ip6aUSHkLi1agIQof1FzmOH nCJoKZ5x7N0NL0BlOGDANrIlj8U1cxDl90allMXrWdnZyTYaHf3kPS7ub/0HiYj7UlkA xy4SDDg6eYGquuIUKrFxMDwo9b0+ksxNr/h/6e0ZTz3Er0IK2J56ail+Z3uiUxRXBcvu qnS8/KxfiHnagNp7Qi2PhS037hrGpkcMmPS55+41qdSh1AmNmAP3EbEOtHrN0fO3AU0T I2mw== 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=NgX+vyM2d0eFDionULbFchaZ5NR+NrnZc8rFGiUHIZE=; b=IhC+URU7ZgVOpgrm+XqRG+XpuGBlOKw6KBZVFmrBbxkSdGaM3tZSsfs33ao+H1Qq/E /y1FLswuT+CmbJ46iDkej90yfIzMU2x/3DkGMjxBLsNlN6k5vzei+dU9zq4b9u0Nlvi5 m9eFseuxey2XUwraZlMp3HdOdjq9q1mG/2MSleJtn0XNqT8Ja/Iz4McJbOipXganODAB 0ttDMgAMGeKPuEq39ymgYQGv8Q26BvYCL8V1KdUyymVmAyarph4FZxJJdz1FgUCUuH0T QLUPONXlswWp9yh6akfjJF3bakV6W8+/MpIyNSCJFnuLbCdBfc8klEnslpZW74Zp3yZp Ltiw== X-Gm-Message-State: AOAM531rR5snyx0G8p1zFjg0a6dLDAdtYhsBSm9Vobmbxn6eAyk3/eH4 zF4de8Hq/Sw9b4oqIEhpfaj+5wZQLA4IcPOsSeQ= X-Google-Smtp-Source: ABdhPJxfCw1geN9Q+q3K5lTYwgBcYEUuQprM5yFK8wLY/oi43dEJGyObNaUQZ+CDl8nHHG43e6FBqiZKESENME5EsCQ= X-Received: by 2002:a5d:5146:: with SMTP id u6mr5668417wrt.66.1605712835169; Wed, 18 Nov 2020 07:20:35 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Wed, 18 Nov 2020 07:20:34 -0800 (PST) In-Reply-To: References: <202011160309.0AG39JmP067464@repo.freebsd.org> From: Mateusz Guzik Date: Wed, 18 Nov 2020 16:20:34 +0100 Message-ID: Subject: Re: svn commit: r367713 - head/sys/kern To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Cbmj01n52z3mNy X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:20:36 -0000 On 11/18/20, Konstantin Belousov wrote: > On Tue, Nov 17, 2020 at 03:36:31PM +0100, Mateusz Guzik wrote: >> On 11/17/20, Konstantin Belousov wrote: >> > On Tue, Nov 17, 2020 at 04:15:12AM +0100, Mateusz Guzik wrote: >> >> On 11/17/20, Konstantin Belousov wrote: >> >> > On Mon, Nov 16, 2020 at 03:09:19AM +0000, Mateusz Guzik wrote: >> >> >> Author: mjg >> >> >> Date: Mon Nov 16 03:09:18 2020 >> >> >> New Revision: 367713 >> >> >> URL: https://svnweb.freebsd.org/changeset/base/367713 >> >> >> >> >> >> Log: >> >> >> select: replace reference counting with memory barriers in selfd >> >> >> >> >> >> Refcounting was added to combat a race between selfdfree and >> >> >> doselwakup, >> >> >> but it adds avoidable overhead. >> >> >> >> >> >> selfdfree detects it can free the object by ->sf_si == NULL, thus >> >> >> we >> >> >> can >> >> >> ensure that the condition only holds after all accesses are >> >> >> completed. >> >> >> >> >> >> Modified: >> >> >> head/sys/kern/sys_generic.c >> >> >> >> >> >> Modified: head/sys/kern/sys_generic.c >> >> >> ============================================================================== >> >> >> --- head/sys/kern/sys_generic.c Sun Nov 15 22:49:28 2020 (r367712) >> >> >> +++ head/sys/kern/sys_generic.c Mon Nov 16 03:09:18 2020 (r367713) >> >> >> @@ -156,7 +156,6 @@ struct selfd { >> >> >> struct mtx *sf_mtx; /* Pointer to selinfo mtx. */ >> >> >> struct seltd *sf_td; /* (k) owning seltd. */ >> >> >> void *sf_cookie; /* (k) fd or pollfd. */ >> >> >> - u_int sf_refs; >> >> >> }; >> >> >> >> >> >> MALLOC_DEFINE(M_SELFD, "selfd", "selfd"); >> >> >> @@ -1704,16 +1703,17 @@ static void >> >> >> selfdfree(struct seltd *stp, struct selfd *sfp) >> >> >> { >> >> >> STAILQ_REMOVE(&stp->st_selq, sfp, selfd, sf_link); >> >> >> - if (sfp->sf_si != NULL) { >> >> >> + /* >> >> >> + * Paired with doselwakeup. >> >> >> + */ >> >> >> + if (atomic_load_acq_ptr((uintptr_t *)&sfp->sf_si) != >> >> >> (uintptr_t)NULL) >> >> >> { >> >> > This could be != 0. >> >> > >> >> >> mtx_lock(sfp->sf_mtx); >> >> >> if (sfp->sf_si != NULL) { >> >> >> TAILQ_REMOVE(&sfp->sf_si->si_tdlist, sfp, sf_threads); >> >> >> - refcount_release(&sfp->sf_refs); >> >> >> } >> >> >> mtx_unlock(sfp->sf_mtx); >> >> >> } >> >> >> - if (refcount_release(&sfp->sf_refs)) >> >> >> - free(sfp, M_SELFD); >> >> >> + free(sfp, M_SELFD); >> >> > What guarantees that doselwakeup() finished with sfp ? >> >> > >> >> >> >> Release semantics provided by atomic_store_rel_ptr -- it means the >> >> NULL store is the last access, neither CPU nor the compiler are going >> >> to reorder preceding loads/stores past it. >> > It only guarantees that if we observed NULL as the result of load. >> > >> >> If that did not happen selfdfree takes the lock. If the entry is still >> there, it removes it and doselwakeup will not see it after it takes >> the lock. If the entry is not there, doselwaekup is done with it >> because it released the lock. > > I still do not understand it. selfdfree() indeed takes sf_mtx and rechecks > sf_si. But what prevents doselwakeup() to store NULL into sf_si at any > moment. e.g. after free() is done ? selfdfree() takes seltd mutex, not > selinfo. > That's the same lock. In selrecord: mtxp = sip->si_mtx; if (mtxp == NULL) mtxp = mtx_pool_find(mtxpool_select, sip); /* * Initialize the sfp and queue it in the thread. */ sfp->sf_si = sip; sfp->sf_mtx = mtxp; STAILQ_INSERT_TAIL(&stp->st_selq, sfp, sf_link); /* * Now that we've locked the sip, check for initialization. */ mtx_lock(mtxp); if (sip->si_mtx == NULL) { sip->si_mtx = mtxp; TAILQ_INIT(&sip->si_tdlist); } Then doselwakeup mtx_lock(sip->si_mtx) serializes against mtx_lock(sfp->sf_mtx) -- Mateusz Guzik From owner-svn-src-all@freebsd.org Wed Nov 18 15:23:44 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7894546A059; Wed, 18 Nov 2020 15:23:44 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbmmc2YVJz3mdV; Wed, 18 Nov 2020 15:23:44 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4AD641434C; Wed, 18 Nov 2020 15:23:44 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIFNi6k040864; Wed, 18 Nov 2020 15:23:44 GMT (envelope-from n_hibma@FreeBSD.org) Received: (from n_hibma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIFNiwN040863; Wed, 18 Nov 2020 15:23:44 GMT (envelope-from n_hibma@FreeBSD.org) Message-Id: <202011181523.0AIFNiwN040863@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: n_hibma set sender to n_hibma@FreeBSD.org using -f From: Nick Hibma Date: Wed, 18 Nov 2020 15:23:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367804 - head/share/man/man4 X-SVN-Group: head X-SVN-Commit-Author: n_hibma X-SVN-Commit-Paths: head/share/man/man4 X-SVN-Commit-Revision: 367804 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:23:44 -0000 Author: n_hibma Date: Wed Nov 18 15:23:43 2020 New Revision: 367804 URL: https://svnweb.freebsd.org/changeset/base/367804 Log: Fix mandoc lint warnings. Modified: head/share/man/man4/ng_tag.4 Modified: head/share/man/man4/ng_tag.4 ============================================================================== --- head/share/man/man4/ng_tag.4 Wed Nov 18 15:20:01 2020 (r367803) +++ head/share/man/man4/ng_tag.4 Wed Nov 18 15:23:43 2020 (r367804) @@ -150,9 +150,7 @@ If .Va strip flag is non-zero, then found tag is deleted from list of packet tags. .It Dv NGM_TAG_GET_HOOKIN Pq Ic gethookin -This command takes an -.Tn ASCII -string argument, the hook name, and returns the +This command takes an ASCII string argument, the hook name, and returns the corresponding .Vt "struct ng_tag_hookin" as shown above. @@ -176,22 +174,16 @@ Other variables mean basically the same as in .Vt "struct ng_tag_hookin" shown above, except used for setting values in a new tag. .It Dv NGM_TAG_GET_HOOKOUT Pq Ic gethookout -This command takes an -.Tn ASCII -string argument, the hook name, and returns the +This command takes an ASCII string argument, the hook name, and returns the corresponding .Vt "struct ng_tag_hookout" as shown above. .It Dv NGM_TAG_GET_STATS Pq Ic getstats -This command takes an -.Tn ASCII -string argument, the hook name, and returns the +This command takes an ASCII string argument, the hook name, and returns the statistics associated with the hook as a .Vt "struct ng_tag_hookstat" . .It Dv NGM_TAG_CLR_STATS Pq Ic clrstats -This command takes an -.Tn ASCII -string argument, the hook name, and clears the +This command takes an ASCII string argument, the hook name, and clears the statistics associated with the hook. .It Dv NGM_TAG_GETCLR_STATS Pq Ic getclrstats This command is identical to @@ -199,7 +191,7 @@ This command is identical to except that the statistics are also atomically cleared. .El .Pp -.Em Note: +.Em Note : statistics counters as well as three statistics messages above work only if code was compiled with the .Dv NG_TAG_DEBUG From owner-svn-src-all@freebsd.org Wed Nov 18 15:25:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20D3C46A5DC; Wed, 18 Nov 2020 15:25:39 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbmpq0SzXz3my5; Wed, 18 Nov 2020 15:25:39 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 037F0140C0; Wed, 18 Nov 2020 15:25:39 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIFPcdv041026; Wed, 18 Nov 2020 15:25:38 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIFPclj041025; Wed, 18 Nov 2020 15:25:38 GMT (envelope-from mw@FreeBSD.org) Message-Id: <202011181525.0AIFPclj041025@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 18 Nov 2020 15:25:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367805 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 367805 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:25:39 -0000 Author: mw Date: Wed Nov 18 15:25:38 2020 New Revision: 367805 URL: https://svnweb.freebsd.org/changeset/base/367805 Log: Update ENA driver version to v2.3.0 The v2.3.0 introduces new ena_com layer, ENI metrics updates and SPDX license tags. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27120 Modified: head/sys/dev/ena/ena.h Modified: head/sys/dev/ena/ena.h ============================================================================== --- head/sys/dev/ena/ena.h Wed Nov 18 15:23:43 2020 (r367804) +++ head/sys/dev/ena/ena.h Wed Nov 18 15:25:38 2020 (r367805) @@ -40,7 +40,7 @@ #include "ena-com/ena_eth_com.h" #define DRV_MODULE_VER_MAJOR 2 -#define DRV_MODULE_VER_MINOR 2 +#define DRV_MODULE_VER_MINOR 3 #define DRV_MODULE_VER_SUBMINOR 0 #define DRV_MODULE_NAME "ena" From owner-svn-src-all@freebsd.org Wed Nov 18 15:56:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7C44046B68E; Wed, 18 Nov 2020 15:56:58 +0000 (UTC) (envelope-from kevans@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbnVy35D9z3pty; Wed, 18 Nov 2020 15:56:58 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 56FE029438; Wed, 18 Nov 2020 15:56:58 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qt1-f169.google.com with SMTP id g15so1889330qtq.13; Wed, 18 Nov 2020 07:56:58 -0800 (PST) X-Gm-Message-State: AOAM5331ZHtD7pK57leHowIREpqcxKYBMY4ymZbspmgq3U+dXtCI8aSh XJRKhWHXYMFvw2qOnNqj1DPJvsj93e/4CV0cPyo= X-Google-Smtp-Source: ABdhPJw6j4G807KpLhWiQr+p05y/3vvAbEihpm5+5HY+ThQ0V/u+GCDb1sFt9yH8PbfXXvOpfN/qnH0bKajCupTyVTM= X-Received: by 2002:ac8:4e87:: with SMTP id 7mr5084534qtp.310.1605715017819; Wed, 18 Nov 2020 07:56:57 -0800 (PST) MIME-Version: 1.0 References: <202011170336.0AH3awYt006482@repo.freebsd.org> <20201117171114.GA1158@spindle.one-eyed-alien.net> <20201117195136.GB1158@spindle.one-eyed-alien.net> In-Reply-To: <20201117195136.GB1158@spindle.one-eyed-alien.net> From: Kyle Evans Date: Wed, 18 Nov 2020 09:56:44 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r367744 - in head/sys: compat/freebsd32 kern sys To: Brooks Davis Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 15:56:58 -0000 On Tue, Nov 17, 2020 at 1:51 PM Brooks Davis wrote: > > On Tue, Nov 17, 2020 at 11:59:50AM -0600, Kyle Evans wrote: > > On Tue, Nov 17, 2020 at 11:11 AM Brooks Davis wrote: > > > > > > On Tue, Nov 17, 2020 at 03:36:58AM +0000, Kyle Evans wrote: > > > > Modified: head/sys/compat/freebsd32/freebsd32.h > > > > ============================================================================== > > > > --- head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:34:01 2020 (r367743) > > > > +++ head/sys/compat/freebsd32/freebsd32.h Tue Nov 17 03:36:58 2020 (r367744) > > > > @@ -94,6 +94,27 @@ struct itimerval32 { > > > > struct timeval32 it_value; > > > > }; > > > > > > > > +struct umtx_time32 { > > > > + struct timespec32 _timeout; > > > > + uint32_t _flags; > > > > + uint32_t _clockid; > > > > +}; > > > > + > > > > +struct umtx_robust_lists_params_compat32 { > > > > + uint32_t robust_list_offset; > > > > + uint32_t robust_priv_list_offset; > > > > + uint32_t robust_inact_offset; > > > > +}; > > > > + > > > > +struct umutex32 { > > > > + volatile __lwpid_t m_owner; /* Owner of the mutex */ > > > > + __uint32_t m_flags; /* Flags of the mutex */ > > > > + __uint32_t m_ceilings[2]; /* Priority protect ceiling */ > > > > + __uint32_t m_rb_lnk; /* Robust linkage */ > > > > + __uint32_t m_pad; > > > > + __uint32_t m_spare[2]; > > > > +}; > > > > + > > > > #define FREEBSD4_MFSNAMELEN 16 > > > > #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) > > > > > > > > > > > > Modified: head/sys/compat/freebsd32/freebsd32_misc.c > > > > ============================================================================== > > > > --- head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:34:01 2020 (r367743) > > > > +++ head/sys/compat/freebsd32/freebsd32_misc.c Tue Nov 17 03:36:58 2020 (r367744) > > > > @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -3764,4 +3765,12 @@ freebsd32_sched_rr_get_interval(struct thread *td, > > > > error = copyout(&ts32, uap->interval, sizeof(ts32)); > > > > } > > > > return (error); > > > > +} > > > > + > > > > +int > > > > +freebsd32__umtx_op(struct thread *td, struct freebsd32__umtx_op_args *uap) > > > > +{ > > > > + > > > > + return (kern__umtx_op(td, uap->obj, uap->op, uap->val, uap->uaddr, > > > > + uap->uaddr2, &umtx_native_ops32)); > > > > } > > > > > > > > > > Putting any of this under compat/freebsd32 seems like a somewhat > > > odd choice since all the work is done in kern_umtx.h. In CheriBSD, > > > everything just lives there so nothing has to be exposed in headers. > > > > > > > I have no strong opinion here -- my initial impression of the > > suggestion to move the struct definitions into freebsd32 was that: > > > > 1.) One can then quickly reference the definition of, e.g., timespec32 > > when I'm looking at a umtx_time32, and > > 2.) It'd be 'cleaner', requiring less #ifdef soup in kern_umtx.c > > > > The follow-up patch muddies the waters a lot, as we end up using the > > compat32 definitions on all 64-bit platforms anyways even without > > compat32. I don't object to moving any/all of this back, if you think > > that's better. > > (1) makes sense to me. I'm less convinced of (2) especially given the > followup. As a rule, I've been removing compat bits from headers when > they only need to be defined in a single .c file. If nothing else, I > don't like that it presents a somewhat-false implication that the > interfaces are public (and there have been quite a few cases where they > weren't correctly guarded with _KERNEL). > Sure- I've got this queued up: https://people.freebsd.org/~kevans/umtx32.diff -> the next diff in line will immediately remove that first COMPAT_FREEBSD32 block after umtx_copyops is defined. Thanks, Kyle Evans From owner-svn-src-all@freebsd.org Wed Nov 18 16:21:38 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6BB3D46BC37; Wed, 18 Nov 2020 16:21:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbp3Q2gFgz3r5l; Wed, 18 Nov 2020 16:21:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E66615062; Wed, 18 Nov 2020 16:21:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIGLcmK076483; Wed, 18 Nov 2020 16:21:38 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIGLcgg076482; Wed, 18 Nov 2020 16:21:38 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202011181621.0AIGLcgg076482@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 18 Nov 2020 16:21:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367806 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367806 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 16:21:38 -0000 Author: jhb Date: Wed Nov 18 16:21:37 2020 New Revision: 367806 URL: https://svnweb.freebsd.org/changeset/base/367806 Log: Fix a few nits in vn_printf(). - Mask out recently added VV_* bits to avoid printing them twice. - Keep VI_LOCKed on the same line as the rest of the flags. Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27261 Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Wed Nov 18 15:25:38 2020 (r367805) +++ head/sys/kern/vfs_subr.c Wed Nov 18 16:21:37 2020 (r367806) @@ -4080,8 +4080,9 @@ vn_printf(struct vnode *vp, const char *fmt, ...) if (vp->v_vflag & VV_READLINK) strlcat(buf, "|VV_READLINK", sizeof(buf)); flags = vp->v_vflag & ~(VV_ROOT | VV_ISTTY | VV_NOSYNC | VV_ETERNALDEV | - VV_CACHEDLABEL | VV_COPYONWRITE | VV_SYSTEM | VV_PROCDEP | - VV_NOKNOTE | VV_DELETED | VV_MD | VV_FORCEINSMQ); + VV_CACHEDLABEL | VV_VMSIZEVNLOCK | VV_COPYONWRITE | VV_SYSTEM | + VV_PROCDEP | VV_NOKNOTE | VV_DELETED | VV_MD | VV_FORCEINSMQ | + VV_READLINK); if (flags != 0) { snprintf(buf2, sizeof(buf2), "|VV(0x%lx)", flags); strlcat(buf, buf2, sizeof(buf)); @@ -4109,9 +4110,10 @@ vn_printf(struct vnode *vp, const char *fmt, ...) snprintf(buf2, sizeof(buf2), "|VMP(0x%lx)", flags); strlcat(buf, buf2, sizeof(buf)); } - printf(" flags (%s)\n", buf + 1); + printf(" flags (%s)", buf + 1); if (mtx_owned(VI_MTX(vp))) printf(" VI_LOCKed"); + printf("\n"); if (vp->v_object != NULL) printf(" v_object %p ref %d pages %d " "cleanbuf %d dirtybuf %d\n", From owner-svn-src-all@freebsd.org Wed Nov 18 17:37:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B15F246D8E5; Wed, 18 Nov 2020 17:37:01 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbqkP4hpJz3vlH; Wed, 18 Nov 2020 17:37:01 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F94A15D2E; Wed, 18 Nov 2020 17:37:01 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIHb1Le022220; Wed, 18 Nov 2020 17:37:01 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIHb1ho022219; Wed, 18 Nov 2020 17:37:01 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <202011181737.0AIHb1ho022219@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 18 Nov 2020 17:37:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367807 - head/sys/mips/cavium X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/mips/cavium X-SVN-Commit-Revision: 367807 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 17:37:01 -0000 Author: jhibbits Date: Wed Nov 18 17:37:01 2020 New Revision: 367807 URL: https://svnweb.freebsd.org/changeset/base/367807 Log: Fix octeon_pmc post-r334827 MFC after: 3 days Sponsored by: Juniper Networks, Inc Modified: head/sys/mips/cavium/octeon_pmc.c Modified: head/sys/mips/cavium/octeon_pmc.c ============================================================================== --- head/sys/mips/cavium/octeon_pmc.c Wed Nov 18 16:21:37 2020 (r367806) +++ head/sys/mips/cavium/octeon_pmc.c Wed Nov 18 17:37:01 2020 (r367807) @@ -111,7 +111,7 @@ octeon_pmc_intr(void *arg) struct trapframe *tf = PCPU_GET(curthread)->td_intr_frame; if (pmc_intr) - (*pmc_intr)(PCPU_GET(tf); + (*pmc_intr)(tf); return (FILTER_HANDLED); } From owner-svn-src-all@freebsd.org Wed Nov 18 17:50:36 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA8C946DA72; Wed, 18 Nov 2020 17:50:36 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbr236Jr1z3wBt; Wed, 18 Nov 2020 17:50:35 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6943E15E9F; Wed, 18 Nov 2020 17:50:34 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIHoYkO028590; Wed, 18 Nov 2020 17:50:34 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIHoYRl028589; Wed, 18 Nov 2020 17:50:34 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <202011181750.0AIHoYRl028589@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Wed, 18 Nov 2020 17:50:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367808 - vendor/NetBSD/bmake X-SVN-Group: vendor X-SVN-Commit-Author: sjg X-SVN-Commit-Paths: vendor/NetBSD/bmake X-SVN-Commit-Revision: 367808 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 17:50:37 -0000 Author: sjg Date: Wed Nov 18 17:50:33 2020 New Revision: 367808 URL: https://svnweb.freebsd.org/changeset/base/367808 Log: Retain missing/sys/cdefs.h to support build on non-FreeBSD Modified: vendor/NetBSD/bmake/import.sh Modified: vendor/NetBSD/bmake/import.sh ============================================================================== --- vendor/NetBSD/bmake/import.sh Wed Nov 18 17:37:01 2020 (r367807) +++ vendor/NetBSD/bmake/import.sh Wed Nov 18 17:50:33 2020 (r367808) @@ -65,7 +65,7 @@ tar zxf $TARBALL # steps unique to bmake VERSION=`grep '^_MAKE_VERSION' bmake/VERSION | sed 's,.*=[[:space:]]*,,'` -rm -rf bmake/missing +#rm -rf bmake/missing # the rest should be common ('cd' dist && $SVN list -R) | grep -v '/$' | sort > $TF.old From owner-svn-src-all@freebsd.org Wed Nov 18 18:41:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 02EFB46EDC7; Wed, 18 Nov 2020 18:41:00 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbs8C6jK4z4TKG; Wed, 18 Nov 2020 18:40:59 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D99D916465; Wed, 18 Nov 2020 18:40:59 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIIex1S060689; Wed, 18 Nov 2020 18:40:59 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIIexE0060686; Wed, 18 Nov 2020 18:40:59 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202011181840.0AIIexE0060686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 18 Nov 2020 18:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367809 - head/contrib/elftoolchain/elfcopy X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head/contrib/elftoolchain/elfcopy X-SVN-Commit-Revision: 367809 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 18:41:00 -0000 Author: dim Date: Wed Nov 18 18:40:58 2020 New Revision: 367809 URL: https://svnweb.freebsd.org/changeset/base/367809 Log: When elftoolchain's objcopy (or strip) is rewriting a file in-place, make it create the temporary file in the same directory as the source file by default, instead of always using $TMPDIR or /tmp. If creating that file fails because the directory is not writable, also fallback to $TMPDIR or /tmp. This has also been submitted upstream as: https://sourceforge.net/p/elftoolchain/tickets/597/ Reported by: cem PR: 250872 MFC after: 2 weeks Modified: head/contrib/elftoolchain/elfcopy/archive.c head/contrib/elftoolchain/elfcopy/elfcopy.h head/contrib/elftoolchain/elfcopy/main.c Modified: head/contrib/elftoolchain/elfcopy/archive.c ============================================================================== --- head/contrib/elftoolchain/elfcopy/archive.c Wed Nov 18 17:50:33 2020 (r367808) +++ head/contrib/elftoolchain/elfcopy/archive.c Wed Nov 18 18:40:58 2020 (r367809) @@ -68,7 +68,7 @@ process_ar_obj(struct elfcopy *ecp, struct ar_obj *obj int fd; /* Output to a temporary file. */ - create_tempfile(&tempfile, &fd); + create_tempfile(NULL, &tempfile, &fd); if ((ecp->eout = elf_begin(fd, ELF_C_WRITE, NULL)) == NULL) errx(EXIT_FAILURE, "elf_begin() failed: %s", elf_errmsg(-1)); Modified: head/contrib/elftoolchain/elfcopy/elfcopy.h ============================================================================== --- head/contrib/elftoolchain/elfcopy/elfcopy.h Wed Nov 18 17:50:33 2020 (r367808) +++ head/contrib/elftoolchain/elfcopy/elfcopy.h Wed Nov 18 18:40:58 2020 (r367809) @@ -298,7 +298,7 @@ void create_scn(struct elfcopy *_ecp); void create_srec(struct elfcopy *_ecp, int _ifd, int _ofd, const char *_ofn); void create_symtab(struct elfcopy *_ecp); void create_symtab_data(struct elfcopy *_ecp); -void create_tempfile(char **_fn, int *_fd); +void create_tempfile(const char *_src, char **_fn, int *_fd); void finalize_external_symtab(struct elfcopy *_ecp); void free_elf(struct elfcopy *_ecp); void free_sec_act(struct elfcopy *_ecp); Modified: head/contrib/elftoolchain/elfcopy/main.c ============================================================================== --- head/contrib/elftoolchain/elfcopy/main.c Wed Nov 18 17:50:33 2020 (r367808) +++ head/contrib/elftoolchain/elfcopy/main.c Wed Nov 18 18:40:58 2020 (r367809) @@ -512,44 +512,57 @@ free_elf(struct elfcopy *ecp) /* Create a temporary file. */ void -create_tempfile(char **fn, int *fd) +create_tempfile(const char *src, char **fn, int *fd) { + static const char _TEMPDIR[] = "/tmp/"; + static const char _TEMPFILE[] = "ecp.XXXXXXXX"; const char *tmpdir; - char *cp, *tmpf; - size_t tlen, plen; + char *tmpf; + size_t tlen, slen, plen; -#define _TEMPFILE "ecp.XXXXXXXX" -#define _TEMPFILEPATH "/tmp/ecp.XXXXXXXX" - if (fn == NULL || fd == NULL) return; - /* Repect TMPDIR environment variable. */ - tmpdir = getenv("TMPDIR"); - if (tmpdir != NULL && *tmpdir != '\0') { - tlen = strlen(tmpdir); - plen = strlen(_TEMPFILE); - tmpf = malloc(tlen + plen + 2); + for (;;) { + if (src == NULL) { + /* Respect TMPDIR environment variable. */ + tmpdir = getenv("TMPDIR"); + if (tmpdir == NULL || *tmpdir == '\0') + tmpdir = _TEMPDIR; + tlen = strlen(tmpdir); + slen = tmpdir[tlen - 1] == '/' ? 0 : 1; + } else { + /* Create temporary file relative to source file. */ + if ((tmpdir = strrchr(src, '/')) == NULL) { + /* No path, only use a template filename. */ + tlen = 0; + } else { + /* Append the template after the slash. */ + tlen = ++tmpdir - src; + tmpdir = src; + } + slen = 0; + } + plen = strlen(_TEMPFILE) + 1; + tmpf = malloc(tlen + slen + plen); if (tmpf == NULL) err(EXIT_FAILURE, "malloc failed"); - strncpy(tmpf, tmpdir, tlen); - cp = &tmpf[tlen - 1]; - if (*cp++ != '/') - *cp++ = '/'; - strncpy(cp, _TEMPFILE, plen); - cp[plen] = '\0'; - } else { - tmpf = strdup(_TEMPFILEPATH); - if (tmpf == NULL) - err(EXIT_FAILURE, "strdup failed"); + if (tlen > 0) + memcpy(tmpf, tmpdir, tlen); + if (slen > 0) + tmpf[tlen] = '/'; + /* Copy template filename including NUL terminator. */ + memcpy(tmpf + tlen + slen, _TEMPFILE, plen); + if ((*fd = mkstemp(tmpf)) != -1) + break; + if (errno != EACCES || src == NULL) + err(EXIT_FAILURE, "mkstemp %s failed", tmpf); + /* Permission denied, try again using TMPDIR or /tmp. */ + free(tmpf); + src = NULL; } - if ((*fd = mkstemp(tmpf)) == -1) - err(EXIT_FAILURE, "mkstemp %s failed", tmpf); if (fchmod(*fd, 0644) == -1) err(EXIT_FAILURE, "fchmod %s failed", tmpf); *fn = tmpf; - -#undef _TEMPFILE -#undef _TEMPFILEPATH } /* @@ -571,16 +584,16 @@ copy_from_tempfile(const char *src, const char *dst, i if (rename(src, dst) >= 0) { *outfd = infd; return (0); - } else if (errno != EXDEV) + } else if (errno != EXDEV && errno != EACCES) return (-1); - + /* * If the rename() failed due to 'src' and 'dst' residing in * two different file systems, invoke a helper function in * libelftc to do the copy. */ - if (unlink(dst) < 0) + if (errno != EACCES && unlink(dst) < 0) return (-1); } @@ -630,7 +643,7 @@ create_file(struct elfcopy *ecp, const char *src, cons err(EXIT_FAILURE, "fstat %s failed", src); if (dst == NULL) - create_tempfile(&tempfile, &ofd); + create_tempfile(src, &tempfile, &ofd); else if ((ofd = open(dst, O_RDWR|O_CREAT, 0755)) == -1) err(EXIT_FAILURE, "open %s failed", dst); @@ -663,7 +676,7 @@ create_file(struct elfcopy *ecp, const char *src, cons if (ecp->oed == ELFDATANONE) ecp->oed = ELFDATA2LSB; } - create_tempfile(&elftemp, &efd); + create_tempfile(src, &elftemp, &efd); if ((ecp->eout = elf_begin(efd, ELF_C_WRITE, NULL)) == NULL) errx(EXIT_FAILURE, "elf_begin() failed: %s", elf_errmsg(-1)); @@ -723,7 +736,7 @@ create_file(struct elfcopy *ecp, const char *src, cons tempfile); free(tempfile); } - create_tempfile(&tempfile, &ofd0); + create_tempfile(src, &tempfile, &ofd0); /* From owner-svn-src-all@freebsd.org Wed Nov 18 19:22:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7DD5146FFF7; Wed, 18 Nov 2020 19:22:27 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbt4324RWz4XGG; Wed, 18 Nov 2020 19:22:25 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BFEE1173F3; Wed, 18 Nov 2020 19:22:24 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIJMODk090582; Wed, 18 Nov 2020 19:22:24 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIJMObD090581; Wed, 18 Nov 2020 19:22:24 GMT (envelope-from imp@FreeBSD.org) Message-Id: <202011181922.0AIJMObD090581@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 18 Nov 2020 19:22:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367810 - head/usr.sbin/mergemaster X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/usr.sbin/mergemaster X-SVN-Commit-Revision: 367810 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 19:22:27 -0000 Author: imp Date: Wed Nov 18 19:22:24 2020 New Revision: 367810 URL: https://svnweb.freebsd.org/changeset/base/367810 Log: mergemaster: handle symbolic links during update. /etc/os-release is now a symbolic link to a generated file. Make mergemaster cope with symbolic links generically. I'm no longer a big mergemaster user, so this has only been lightly tested by me, though Kimura-san has ran it through its paces. Submitted by: Yasushiro KIMURA-san PR: 242212 MFC After: 2 weeks Modified: head/usr.sbin/mergemaster/mergemaster.sh Modified: head/usr.sbin/mergemaster/mergemaster.sh ============================================================================== --- head/usr.sbin/mergemaster/mergemaster.sh Wed Nov 18 18:40:58 2020 (r367809) +++ head/usr.sbin/mergemaster/mergemaster.sh Wed Nov 18 19:22:24 2020 (r367810) @@ -1093,6 +1093,7 @@ for COMPFILE in `find . | sort` ; do fi done +# Compare regular files for COMPFILE in `find . -type f | sort`; do # First, check to see if the file exists in DESTDIR. If not, the @@ -1182,6 +1183,119 @@ for COMPFILE in `find . -type f | sort`; do fi # Yes, the file still remains to be checked done # This is for the for way up there at the beginning of the comparison +ask_answer_for_symbolic_link () { + HANDLE_COMPSYMLINK='' + while true; do + echo " Use 'd' to delete the temporary ${COMPSYMLINK}" + echo " Use 'i' to install the temporary ${COMPSYMLINK}" + echo '' + echo " Default is to leave the temporary symbolic link to deal with by hand" + echo '' + echo -n "How should I deal with this? [Leave it for later] " + read HANDLE_COMPSYMLINK + case ${HANDLE_COMPSYMLINK} in + ''|[dDiI]) + break + ;; + *) + echo "invalid choice: ${HANDLE_COMPSYMLINK}" + echo '' + HANDLE_COMPSYMLINK='' + ;; + esac + done +} + +install_symbolic_link () { + rm -f ${DESTDIR}${COMPSYMLINK#.} > /dev/null 2>&1 + if [ -L ${DESTDIR}${COMPSYMLINK#.} ]; then + return 1 + fi + cp -a ${COMPSYMLINK} ${DESTDIR}${COMPSYMLINK#.} > /dev/null 2>&1 + if [ ! -L ${DESTDIR}${COMPSYMLINK#.} ]; then + return 1 + fi + return 0 +} + +handle_symbolic_link () { + case ${HANDLE_COMPSYMLINK} in + [dD]) + rm ${COMPSYMLINK} + echo '' + echo " *** Deleting ${COMPSYMLINK}" + echo '' + return 1 + ;; + [iI]) + echo '' + if install_symbolic_link; then + rm ${COMPSYMLINK} + echo " *** ${COMPSYMLINK} installed successfully" + return 2 + else + echo " *** Problem installing ${COMPSYMLINK}, it will remain to merge by hand" + return 3 + fi + echo '' + ;; + '') + echo '' + echo " *** ${COMPSYMLINK} will remain for your consideration" + echo '' + return 0 + ;; + esac +} + +# Compare symblic links +for COMPSYMLINK in `find . -type l | sort`; do + if [ ! -L "${DESTDIR}${COMPSYMLINK#.}" ]; then + if [ -n "${AUTO_RUN}" -a -z "${AUTO_INSTALL}" ]; then + echo " *** ${COMPSYMLINK} will remain for your consideration" + continue + else + echo '' + echo " *** There is no installed version of ${COMPSYMLINK}" + echo '' + if [ -n "${AUTO_INSTALL}" ]; then + HANDLE_COMPSYMLINK="i" + else + ask_answer_for_symbolic_link + fi + handle_symbolic_link + if [ -n "${AUTO_INSTALL}" -a $? -eq 2 ]; then + AUTO_INSTALLED_FILES="${AUTO_INSTALLED_FILES} ${DESTDIR}${COMPSYMLINK#.} +" + fi + fi + elif [ $(readlink ${COMPSYMLINK}) = $(readlink ${DESTDIR}${COMPSYMLINK#.}) ]; then + echo " *** Temp ${COMPSYMLINK} and installed are the same, deleting" + rm ${COMPSYMLINK} + else + if [ -n "${AUTO_RUN}" -a -z "${AUTO_UPGRADE}" ]; then + echo " *** ${COMPSYMLINK} will remain for your consideration" + continue + else + echo '' + echo " *** Target of temp symbolic link is differnt from that of installed one" + echo " Temp (${COMPSYMLINK}): $(readlink ${COMPSYMLINK})" + echo " Installed (${DESTDIR}${COMPSYMLINK#.})): $(readlink ${DESTDIR}${COMPSYMLINK#.})" + echo '' + if [ -n "${AUTO_UPGRADE}" ]; then + HANDLE_COMPSYMLINK="i" + else + ask_answer_for_symbolic_link + fi + handle_symbolic_link + if [ -n "${AUTO_UPGRADE}" -a $? -eq 2 ]; then + AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES} ${DESTDIR}${COMPSYMLINK#.} +" + fi + fi + fi +done + echo '' echo "*** Comparison complete" @@ -1193,10 +1307,10 @@ fi echo '' -TEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 2>/dev/null` +TEST_FOR_FILES=`find ${TEMPROOT} -type f -size +0 -or -type l 2>/dev/null` if [ -n "${TEST_FOR_FILES}" ]; then echo "*** Files that remain for you to merge by hand:" - find "${TEMPROOT}" -type f -size +0 | sort + find "${TEMPROOT}" -type f -size +0 -or -type l | sort echo '' case "${AUTO_RUN}" in From owner-svn-src-all@freebsd.org Wed Nov 18 19:23:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 30A2946FCF4; Wed, 18 Nov 2020 19:23:31 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbt5H0gSNz4XNN; Wed, 18 Nov 2020 19:23:31 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C72C917335; Wed, 18 Nov 2020 19:23:30 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIJNUfG090690; Wed, 18 Nov 2020 19:23:30 GMT (envelope-from alfredo@FreeBSD.org) Received: (from alfredo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIJNUMk090688; Wed, 18 Nov 2020 19:23:30 GMT (envelope-from alfredo@FreeBSD.org) Message-Id: <202011181923.0AIJNUMk090688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alfredo set sender to alfredo@FreeBSD.org using -f From: "Alfredo Dal'Ava Junior" Date: Wed, 18 Nov 2020 19:23:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367811 - head/lib/msun/tests X-SVN-Group: head X-SVN-Commit-Author: alfredo X-SVN-Commit-Paths: head/lib/msun/tests X-SVN-Commit-Revision: 367811 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 19:23:31 -0000 Author: alfredo Date: Wed Nov 18 19:23:30 2020 New Revision: 367811 URL: https://svnweb.freebsd.org/changeset/base/367811 Log: msun tests: use standard floating-point exception flags on lrint and fenv tests Some platforms have additional architecture-specific floating-point flags. Msun test cases lrint and test_fegsetenv (fenv) expects only standard flags, so make sure to mask them appropriately. This makes test pass on PowerPC64. Reviewed by: jhibbits, ngie Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D27202 Modified: head/lib/msun/tests/fenv_test.c head/lib/msun/tests/lrint_test.c Modified: head/lib/msun/tests/fenv_test.c ============================================================================== --- head/lib/msun/tests/fenv_test.c Wed Nov 18 19:22:24 2020 (r367810) +++ head/lib/msun/tests/fenv_test.c Wed Nov 18 19:23:30 2020 (r367811) @@ -43,13 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Implementations are permitted to define additional exception flags - * not specified in the standard, so it is not necessarily true that - * FE_ALL_EXCEPT == ALL_STD_EXCEPT. - */ -#define ALL_STD_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \ - FE_OVERFLOW | FE_UNDERFLOW) +#include "test-utils.h" #define NEXCEPTS (sizeof(std_excepts) / sizeof(std_excepts[0])) @@ -373,7 +367,13 @@ test_fegsetenv(void) assert(fegetround() == FE_TONEAREST); assert(fesetenv(&env2) == 0); - assert(fetestexcept(FE_ALL_EXCEPT) == excepts); + + /* + * Some platforms like powerpc may set extra exception bits. Since + * only standard exceptions are tested, mask against ALL_STD_EXCEPT + */ + assert((fetestexcept(FE_ALL_EXCEPT) & ALL_STD_EXCEPT) == excepts); + assert(fegetround() == FE_DOWNWARD); assert(fesetenv(&env1) == 0); assert(fetestexcept(FE_ALL_EXCEPT) == 0); Modified: head/lib/msun/tests/lrint_test.c ============================================================================== --- head/lib/msun/tests/lrint_test.c Wed Nov 18 19:22:24 2020 (r367810) +++ head/lib/msun/tests/lrint_test.c Wed Nov 18 19:23:30 2020 (r367811) @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); #include #endif +#include "test-utils.h" + /* * XXX The volatile here is to avoid gcc's bogus constant folding and work * around the lack of support for the FENV_ACCESS pragma. @@ -49,7 +51,8 @@ __FBSDID("$FreeBSD$"); volatile double _d = x; \ assert(feclearexcept(FE_ALL_EXCEPT) == 0); \ assert((func)(_d) == (result) || fetestexcept(FE_INVALID)); \ - assert(fetestexcept(FE_ALL_EXCEPT) == (excepts)); \ + assert((fetestexcept(FE_ALL_EXCEPT) & ALL_STD_EXCEPT) \ + == (excepts)); \ } while (0) #define testall(x, result, excepts) do { \ From owner-svn-src-all@freebsd.org Wed Nov 18 19:35:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6CB6F47089D; Wed, 18 Nov 2020 19:35:31 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbtM72kFvz4YT2; Wed, 18 Nov 2020 19:35:31 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C0331735E; Wed, 18 Nov 2020 19:35:31 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIJZV2J096840; Wed, 18 Nov 2020 19:35:31 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIJZVcn096839; Wed, 18 Nov 2020 19:35:31 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <202011181935.0AIJZVcn096839@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Wed, 18 Nov 2020 19:35:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367812 - head/sys/dev/usb/net X-SVN-Group: head X-SVN-Commit-Author: lwhsu X-SVN-Commit-Paths: head/sys/dev/usb/net X-SVN-Commit-Revision: 367812 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 19:35:31 -0000 Author: lwhsu Date: Wed Nov 18 19:35:30 2020 New Revision: 367812 URL: https://svnweb.freebsd.org/changeset/base/367812 Log: ipheth(4): Fix for iOS 14 Fix USB tethering for iOS 14. Inspired by: https://github.com/libimobiledevice/libimobiledevice/issues/1038 PR: 249979 Reviewed by: hselasky MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27250 Modified: head/sys/dev/usb/net/if_iphethvar.h Modified: head/sys/dev/usb/net/if_iphethvar.h ============================================================================== --- head/sys/dev/usb/net/if_iphethvar.h Wed Nov 18 19:23:30 2020 (r367811) +++ head/sys/dev/usb/net/if_iphethvar.h Wed Nov 18 19:35:30 2020 (r367812) @@ -39,7 +39,7 @@ #define IPHETH_USBINTF_SUBCLASS 253 #define IPHETH_USBINTF_PROTO 1 -#define IPHETH_BUF_SIZE 1516 +#define IPHETH_BUF_SIZE 1514 #define IPHETH_TX_TIMEOUT 5000 /* ms */ #define IPHETH_RX_FRAMES_MAX 1 From owner-svn-src-all@freebsd.org Wed Nov 18 19:44:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86846470E8B; Wed, 18 Nov 2020 19:44:31 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbtYW3NP0z4ZX6; Wed, 18 Nov 2020 19:44:31 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6741B17724; Wed, 18 Nov 2020 19:44:31 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIJiVjp003703; Wed, 18 Nov 2020 19:44:31 GMT (envelope-from se@FreeBSD.org) Received: (from se@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIJiUU3003699; Wed, 18 Nov 2020 19:44:30 GMT (envelope-from se@FreeBSD.org) Message-Id: <202011181944.0AIJiUU3003699@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: se set sender to se@FreeBSD.org using -f From: =?UTF-8?Q?Stefan_E=c3=9fer?= Date: Wed, 18 Nov 2020 19:44:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367813 - head/lib/libutil X-SVN-Group: head X-SVN-Commit-Author: se X-SVN-Commit-Paths: head/lib/libutil X-SVN-Commit-Revision: 367813 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 19:44:31 -0000 Author: se Date: Wed Nov 18 19:44:30 2020 New Revision: 367813 URL: https://svnweb.freebsd.org/changeset/base/367813 Log: Add function getlocalbase() to libutil. This function returns the path to the local software base directory, by default "/usr/local" (or the value of _PATH_LOCALBASE in include/paths.h when building the world). The value returned can be overridden by 2 methods: - the LOCALBASE environment variable (ignored by SUID programs) - else a non-default user.localbase sysctl value Reviewed by: hps (earlier version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27236 Added: head/lib/libutil/getlocalbase.3 (contents, props changed) head/lib/libutil/getlocalbase.c (contents, props changed) Modified: head/lib/libutil/Makefile head/lib/libutil/libutil.h Modified: head/lib/libutil/Makefile ============================================================================== --- head/lib/libutil/Makefile Wed Nov 18 19:35:30 2020 (r367812) +++ head/lib/libutil/Makefile Wed Nov 18 19:44:30 2020 (r367813) @@ -12,7 +12,8 @@ PACKAGE= runtime LIB= util SHLIB_MAJOR= 9 -SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \ +SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c \ + getlocalbase.c gr_util.c \ hexdump.c humanize_number.c kinfo_getfile.c \ kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ kinfo_getvmobject.c kld.c \ @@ -30,7 +31,7 @@ CFLAGS+= -DINET6 CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ -MAN+= expand_number.3 flopen.3 fparseln.3 hexdump.3 \ +MAN+= expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \ humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ login_auth.3 login_cap.3 \ Added: head/lib/libutil/getlocalbase.3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libutil/getlocalbase.3 Wed Nov 18 19:44:30 2020 (r367813) @@ -0,0 +1,99 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright 2020 Scott Long +.\" Copyright 2020 Stefan Eßer +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 18, 2020 +.Dt GETLOCALBASE 3 +.Os +.Sh NAME +.Nm getlocalbase +.Nd "return the path to the local software directory" +.Sh LIBRARY +.Lb libutil +.Sh SYNOPSIS +.In libutil.h +.Ft const char* +.Fn getlocalbase "void" +.Sh DESCRIPTION +The +.Fn getlocalbase +function returns the path to the local software base directory. +Normally this is the +.Pa /usr/local +directory. +First the +.Ev LOCALBASE +environment variable is checked. +If that does not exist then the +.Va user.localbase +sysctl is checked. +If that also does not exist then the value of the +.Dv _PATH_LOCALBASE +compile-time variable is used. +If that is undefined then the default of +.Pa /usr/local +is used. +.Pp +The value returned by the +.Fn getlocalbase +function shall not be modified. +.Sh IMPLEMENTATION NOTES +Calls to +.Fn getlocalbase +will perform a setugid check on the running binary before checking the +environment. +.Sh RETURN VALUES +The +.Fn getlocalbase +function always succeeds and returns a pointer to a string, whose length +may exceed MAXPATHLEN if it has been derived from the environment variable +LOCALBASE. +No length checks are performed on the result. +.Sh ENVIRONMENT +The +.Fn getlocalbase +library function retrieves the +.Ev LOCALBASE +environment variable. +.Sh ERRORS +The +.Fn getlocalbase +function always succeeds. +.Sh SEE ALSO +.Xr env 1 , +.Xr src.conf 5 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +library function first appeared in +.Fx 13.0 . +.Sh AUTHORS +This +manual page was written by +.An Scott Long Aq Mt scottl@FreeBSD.org and Stefan Eßer Aq Mt se@FreeBSD.org . Added: head/lib/libutil/getlocalbase.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libutil/getlocalbase.c Wed Nov 18 19:44:30 2020 (r367813) @@ -0,0 +1,74 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2020 Stefan Eßer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#ifndef _PATH_LOCALBASE +#define _PATH_LOCALBASE "/usr/local" +#endif + +const char * +getlocalbase(void) +{ + static const int localbase_oid[2] = {CTL_USER, USER_LOCALBASE}; + char *tmppath; + size_t tmplen; + static const char *localbase = NULL; + + if (issetugid() == 0) { + tmppath = getenv("LOCALBASE"); + if (tmppath != NULL && tmppath[0] != '\0') + return (tmppath); + } + if (sysctl(localbase_oid, 2, NULL, &tmplen, NULL, 0) == 0 && + (tmppath = malloc(tmplen)) != NULL && + sysctl(localbase_oid, 2, tmppath, &tmplen, NULL, 0) == 0) { + /* + * Check for some other thread already having + * set localbase - this should use atomic ops. + * The amount of memory allocated above may leak, + * if a parallel update in another thread is not + * detected and the non-NULL pointer is overwritten. + */ + if (tmppath[0] != '\0' && + (volatile const char*)localbase == NULL) + localbase = tmppath; + else + free((void*)tmppath); + return (localbase); + } + return (_PATH_LOCALBASE); +} Modified: head/lib/libutil/libutil.h ============================================================================== --- head/lib/libutil/libutil.h Wed Nov 18 19:35:30 2020 (r367812) +++ head/lib/libutil/libutil.h Wed Nov 18 19:44:30 2020 (r367813) @@ -98,6 +98,8 @@ int flopen(const char *_path, int _flags, ...); int flopenat(int _dirfd, const char *_path, int _flags, ...); int forkpty(int *_amaster, char *_name, struct termios *_termp, struct winsize *_winp); +const char * + getlocalbase(void); void hexdump(const void *_ptr, int _length, const char *_hdr, int _flags); int humanize_number(char *_buf, size_t _len, int64_t _number, const char *_suffix, int _scale, int _flags); From owner-svn-src-all@freebsd.org Wed Nov 18 19:47:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9DC04470F25; Wed, 18 Nov 2020 19:47:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbtcr44yHz4Zbj; Wed, 18 Nov 2020 19:47:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7F04017822; Wed, 18 Nov 2020 19:47:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIJlOHx003911; Wed, 18 Nov 2020 19:47:24 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIJlOXu003910; Wed, 18 Nov 2020 19:47:24 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011181947.0AIJlOXu003910@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 18 Nov 2020 19:47:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367814 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 367814 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 19:47:24 -0000 Author: mjg Date: Wed Nov 18 19:47:24 2020 New Revision: 367814 URL: https://svnweb.freebsd.org/changeset/base/367814 Log: fd: reorder struct file to reduce false sharing The size on LP64 is 80 bytes, which is just more than a cacheline, does not lend itself to easy shrinking and rounding up to 2 would be a huge waste given NOFREE marker. The least which can be done is to reorder it so that most commonly used fields are less likely to span different lines, and consequently suffer less false sharing. With the change at hand most commonly used fields land in the same line about 3/4 of the time, as opposed to 2/4. Modified: head/sys/sys/file.h Modified: head/sys/sys/file.h ============================================================================== --- head/sys/sys/file.h Wed Nov 18 19:44:30 2020 (r367813) +++ head/sys/sys/file.h Wed Nov 18 19:47:24 2020 (r367814) @@ -177,14 +177,14 @@ struct fadvise_info { }; struct file { + volatile u_int f_flag; /* see fcntl.h */ + volatile u_int f_count; /* reference count */ void *f_data; /* file descriptor specific data */ struct fileops *f_ops; /* File operations */ - struct ucred *f_cred; /* associated credentials. */ struct vnode *f_vnode; /* NULL or applicable vnode */ + struct ucred *f_cred; /* associated credentials. */ short f_type; /* descriptor type */ short f_vnread_flags; /* (f) Sleep lock for f_offset */ - volatile u_int f_flag; /* see fcntl.h */ - volatile u_int f_count; /* reference count */ /* * DTYPE_VNODE specific fields. */ From owner-svn-src-all@freebsd.org Wed Nov 18 19:55:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9F889470CFF; Wed, 18 Nov 2020 19:55:24 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbtp4494Zz4ZpV; Wed, 18 Nov 2020 19:55:24 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D70E1774A; Wed, 18 Nov 2020 19:55:24 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIJtOg9009807; Wed, 18 Nov 2020 19:55:24 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIJtOtV009806; Wed, 18 Nov 2020 19:55:24 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202011181955.0AIJtOtV009806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 18 Nov 2020 19:55:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367815 - head/contrib/llvm-project/llvm/lib/Support/Unix X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head/contrib/llvm-project/llvm/lib/Support/Unix X-SVN-Commit-Revision: 367815 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 19:55:24 -0000 Author: dim Date: Wed Nov 18 19:55:24 2020 New Revision: 367815 URL: https://svnweb.freebsd.org/changeset/base/367815 Log: For llvm's internal function which retrieves the number of available "hardware threads", use cpuset_getaffinity(2) on FreeBSD, so it will honor processor sets configured by the cpuset(1) command. This should make it possible to avoid e.g. lld creating a huge number of threads on a machine with many cores, even for linking simple programs. This will also be submitted upstream. Submitted by: mjg MFC after: 1 week Modified: head/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc Modified: head/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc ============================================================================== --- head/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc Wed Nov 18 19:47:24 2020 (r367814) +++ head/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc Wed Nov 18 19:55:24 2020 (r367815) @@ -26,6 +26,10 @@ #include // For pthread_getthreadid_np() / pthread_set_name_np() #endif +#if defined(__FreeBSD__) +#include +#endif + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include #include @@ -282,6 +286,13 @@ SetThreadPriorityResult llvm::set_thread_priority(Thre #include int computeHostNumHardwareThreads() { +#ifdef __FreeBSD__ + cpuset_t mask; + CPU_ZERO(&mask); + if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask), + &mask) == 0) + return CPU_COUNT(&mask); +#endif #ifdef __linux__ cpu_set_t Set; if (sched_getaffinity(0, sizeof(Set), &Set) == 0) From owner-svn-src-all@freebsd.org Wed Nov 18 20:00:57 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F6CE471390; Wed, 18 Nov 2020 20:00:57 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbtwT1MYZz4bSY; Wed, 18 Nov 2020 20:00:57 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 21B7217B03; Wed, 18 Nov 2020 20:00:57 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIK0vfW010208; Wed, 18 Nov 2020 20:00:57 GMT (envelope-from se@FreeBSD.org) Received: (from se@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIK0tDZ010202; Wed, 18 Nov 2020 20:00:55 GMT (envelope-from se@FreeBSD.org) Message-Id: <202011182000.0AIK0tDZ010202@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: se set sender to se@FreeBSD.org using -f From: =?UTF-8?Q?Stefan_E=c3=9fer?= Date: Wed, 18 Nov 2020 20:00:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367816 - in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Group: head X-SVN-Commit-Author: se X-SVN-Commit-Paths: in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Commit-Revision: 367816 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 20:00:57 -0000 Author: se Date: Wed Nov 18 20:00:55 2020 New Revision: 367816 URL: https://svnweb.freebsd.org/changeset/base/367816 Log: Make use of the getlocalbase() function for run-time adjustment of the local software base directory, as committed in SVN rev. 367813. The pkg and mailwrapper programs used the LOCALBASE environment variable for this purpose and this functionality is preserved by getlocalbase(). After this change, the value of the user.localbase sysctl variable is used if present (and not overridden in the environment). The nvmecontrol program gains support of a dynamic path to its plugin directory with this update. Differential Revision: https://reviews.freebsd.org/D27237 Modified: head/sbin/nvmecontrol/comnd.c head/sbin/nvmecontrol/nvmecontrol.c head/usr.sbin/mailwrapper/mailwrapper.c head/usr.sbin/pkg/Makefile head/usr.sbin/pkg/config.c head/usr.sbin/pkg/pkg.c Modified: head/sbin/nvmecontrol/comnd.c ============================================================================== --- head/sbin/nvmecontrol/comnd.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/sbin/nvmecontrol/comnd.c Wed Nov 18 20:00:55 2020 (r367816) @@ -287,7 +287,7 @@ bad_arg: * Loads all the .so's from the specified directory. */ void -cmd_load_dir(const char *dir __unused, cmd_load_cb_t cb __unused, void *argp __unused) +cmd_load_dir(const char *dir, cmd_load_cb_t cb, void *argp) { DIR *d; struct dirent *dent; Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/sbin/nvmecontrol/nvmecontrol.c Wed Nov 18 20:00:55 2020 (r367816) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -178,11 +179,13 @@ get_nsid(int fd, char **ctrlr_str, uint32_t *nsid) int main(int argc, char *argv[]) { + static char dir[MAXPATHLEN]; cmd_init(); cmd_load_dir("/lib/nvmecontrol", NULL, NULL); - cmd_load_dir(_PATH_LOCALBASE "/lib/nvmecontrol", NULL, NULL); + snprintf(dir, MAXPATHLEN, "%s/lib/nvmecontrol", getlocalbase()); + cmd_load_dir(dir, NULL, NULL); cmd_dispatch(argc, argv, NULL); Modified: head/usr.sbin/mailwrapper/mailwrapper.c ============================================================================== --- head/usr.sbin/mailwrapper/mailwrapper.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/mailwrapper/mailwrapper.c Wed Nov 18 20:00:55 2020 (r367816) @@ -106,7 +106,7 @@ main(int argc, char *argv[], char *envp[]) addarg(&al, argv[0]); snprintf(localmailerconf, MAXPATHLEN, "%s/etc/mail/mailer.conf", - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); + getlocalbase()); mailerconf = localmailerconf; if ((config = fopen(localmailerconf, "r")) == NULL) Modified: head/usr.sbin/pkg/Makefile ============================================================================== --- head/usr.sbin/pkg/Makefile Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/pkg/Makefile Wed Nov 18 20:00:55 2020 (r367816) @@ -25,6 +25,6 @@ MAN= pkg.7 CFLAGS+=-I${SRCTOP}/contrib/libucl/include .PATH: ${SRCTOP}/contrib/libucl/include -LIBADD= archive fetch ucl sbuf crypto ssl +LIBADD= archive fetch ucl sbuf crypto ssl util .include Modified: head/usr.sbin/pkg/config.c ============================================================================== --- head/usr.sbin/pkg/config.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/pkg/config.c Wed Nov 18 20:00:55 2020 (r367816) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -455,9 +456,8 @@ config_init(void) } /* Read LOCALBASE/etc/pkg.conf first. */ - localbase = getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE; - snprintf(confpath, sizeof(confpath), "%s/etc/pkg.conf", - localbase); + localbase = getlocalbase(); + snprintf(confpath, sizeof(confpath), "%s/etc/pkg.conf", localbase); if (access(confpath, F_OK) == 0 && read_conf_file(confpath, CONFFILE_PKG)) Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/pkg/pkg.c Wed Nov 18 20:00:55 2020 (r367816) @@ -43,12 +43,12 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -1045,8 +1045,7 @@ main(int argc, char *argv[]) pkgarg = NULL; yes = false; - snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); + snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", getlocalbase()); if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { bootstrap_only = true; From owner-svn-src-all@freebsd.org Wed Nov 18 20:20:04 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1CC88471562; Wed, 18 Nov 2020 20:20:04 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbvLX0NJnz4cQP; Wed, 18 Nov 2020 20:20:04 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF99817C5F; Wed, 18 Nov 2020 20:20:03 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIKK3pd022316; Wed, 18 Nov 2020 20:20:03 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIKK3Kx022315; Wed, 18 Nov 2020 20:20:03 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202011182020.0AIKK3Kx022315@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Wed, 18 Nov 2020 20:20:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367817 - head/sys/fs/msdosfs X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/fs/msdosfs X-SVN-Commit-Revision: 367817 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 20:20:04 -0000 Author: cem Date: Wed Nov 18 20:20:03 2020 New Revision: 367817 URL: https://svnweb.freebsd.org/changeset/base/367817 Log: msdosfs(5): Fix debug-only format string No functional change; MSDOSFS_DEBUG isn't a real build option, so this isn't covered by LINT kernels. Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_vfsops.c Wed Nov 18 20:00:55 2020 (r367816) +++ head/sys/fs/msdosfs/msdosfs_vfsops.c Wed Nov 18 20:20:03 2020 (r367817) @@ -792,7 +792,7 @@ msdosfs_unmount(struct mount *mp, int mntflags) printf("freef %p, freeb %p, mount %p\n", TAILQ_NEXT(vp, v_vnodelist), vp->v_vnodelist.tqe_prev, vp->v_mount); - printf("cleanblkhd %p, dirtyblkhd %p, numoutput %ld, type %d\n", + printf("cleanblkhd %p, dirtyblkhd %p, numoutput %d, type %d\n", TAILQ_FIRST(&vp->v_bufobj.bo_clean.bv_hd), TAILQ_FIRST(&vp->v_bufobj.bo_dirty.bv_hd), vp->v_bufobj.bo_numoutput, vp->v_type); From owner-svn-src-all@freebsd.org Wed Nov 18 20:59:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8459C47241D; Wed, 18 Nov 2020 20:59:59 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbwDb3G0kz4fBm; Wed, 18 Nov 2020 20:59:59 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E705181CD; Wed, 18 Nov 2020 20:59:59 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIKxxWs047107; Wed, 18 Nov 2020 20:59:59 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIKxwSg047105; Wed, 18 Nov 2020 20:59:58 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <202011182059.0AIKxwSg047105@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Wed, 18 Nov 2020 20:59:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367818 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367818 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 20:59:59 -0000 Author: oshogbo Date: Wed Nov 18 20:59:58 2020 New Revision: 367818 URL: https://svnweb.freebsd.org/changeset/base/367818 Log: Fix style nits. Modified: head/sys/kern/kern_jail.c head/sys/kern/kern_priv.c Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Wed Nov 18 20:20:03 2020 (r367817) +++ head/sys/kern/kern_jail.c Wed Nov 18 20:59:58 2020 (r367818) @@ -3739,9 +3739,9 @@ SYSCTL_JAIL_PARAM_STRING(, name, CTLFLAG_RW, MAXHOSTNA SYSCTL_JAIL_PARAM_STRING(, path, CTLFLAG_RDTUN, MAXPATHLEN, "Jail root path"); SYSCTL_JAIL_PARAM(, securelevel, CTLTYPE_INT | CTLFLAG_RW, "I", "Jail secure level"); -SYSCTL_JAIL_PARAM(, osreldate, CTLTYPE_INT | CTLFLAG_RDTUN, "I", +SYSCTL_JAIL_PARAM(, osreldate, CTLTYPE_INT | CTLFLAG_RDTUN, "I", "Jail value for kern.osreldate and uname -K"); -SYSCTL_JAIL_PARAM_STRING(, osrelease, CTLFLAG_RDTUN, OSRELEASELEN, +SYSCTL_JAIL_PARAM_STRING(, osrelease, CTLFLAG_RDTUN, OSRELEASELEN, "Jail value for kern.osrelease and uname -r"); SYSCTL_JAIL_PARAM(, enforce_statfs, CTLTYPE_INT | CTLFLAG_RW, "I", "Jail cannot see all mounted file systems"); Modified: head/sys/kern/kern_priv.c ============================================================================== --- head/sys/kern/kern_priv.c Wed Nov 18 20:20:03 2020 (r367817) +++ head/sys/kern/kern_priv.c Wed Nov 18 20:59:58 2020 (r367818) @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); * userland programs, and should not be done without careful consideration of * the consequences. */ -static int __read_mostly suser_enabled = 1; +static int __read_mostly suser_enabled = 1; SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RWTUN, &suser_enabled, 0, "processes with uid 0 have privilege"); From owner-svn-src-all@freebsd.org Wed Nov 18 21:07:09 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 987B8471ED0; Wed, 18 Nov 2020 21:07:09 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbwNs3hzZz4ftx; Wed, 18 Nov 2020 21:07:09 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6D9E818809; Wed, 18 Nov 2020 21:07:09 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIL79mP053578; Wed, 18 Nov 2020 21:07:09 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIL78pi053574; Wed, 18 Nov 2020 21:07:08 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <202011182107.0AIL78pi053574@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Wed, 18 Nov 2020 21:07:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367819 - in head: sys/kern sys/sys usr.sbin/jail X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: in head: sys/kern sys/sys usr.sbin/jail X-SVN-Commit-Revision: 367819 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:07:09 -0000 Author: oshogbo Date: Wed Nov 18 21:07:08 2020 New Revision: 367819 URL: https://svnweb.freebsd.org/changeset/base/367819 Log: jail: introduce per jail suser_enabled setting The suser_enable sysctl allows to remove a privileged rights from uid 0. This change introduce per jail setting which allow to make root a normal user. Reviewed by: jamie Previous version reviewed by: kevans, emaste, markj, me_igalic.co Discussed with: pjd Differential Revision: https://reviews.freebsd.org/D27128 Modified: head/sys/kern/kern_jail.c head/sys/kern/kern_priv.c head/sys/sys/jail.h head/usr.sbin/jail/jail.8 Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Wed Nov 18 20:59:58 2020 (r367818) +++ head/sys/kern/kern_jail.c Wed Nov 18 21:07:08 2020 (r367819) @@ -199,12 +199,14 @@ static struct bool_flags pr_flag_allow[NBBY * NBPW] = {"allow.read_msgbuf", "allow.noread_msgbuf", PR_ALLOW_READ_MSGBUF}, {"allow.unprivileged_proc_debug", "allow.nounprivileged_proc_debug", PR_ALLOW_UNPRIV_DEBUG}, + {"allow.suser", "allow.nosuser", PR_ALLOW_SUSER}, }; const size_t pr_flag_allow_size = sizeof(pr_flag_allow); #define JAIL_DEFAULT_ALLOW (PR_ALLOW_SET_HOSTNAME | \ PR_ALLOW_RESERVED_PORTS | \ - PR_ALLOW_UNPRIV_DEBUG) + PR_ALLOW_UNPRIV_DEBUG | \ + PR_ALLOW_SUSER) #define JAIL_DEFAULT_ENFORCE_STATFS 2 #define JAIL_DEFAULT_DEVFS_RSNUM 0 static unsigned jail_default_allow = JAIL_DEFAULT_ALLOW; @@ -3815,6 +3817,8 @@ SYSCTL_JAIL_PARAM(_allow, read_msgbuf, CTLTYPE_INT | C "B", "Jail may read the kernel message buffer"); SYSCTL_JAIL_PARAM(_allow, unprivileged_proc_debug, CTLTYPE_INT | CTLFLAG_RW, "B", "Unprivileged processes may use process debugging facilities"); +SYSCTL_JAIL_PARAM(_allow, suser, CTLTYPE_INT | CTLFLAG_RW, + "B", "Processes in jail with uid 0 have privilege"); SYSCTL_JAIL_PARAM_SUBNODE(allow, mount, "Jail mount/unmount permission flags"); SYSCTL_JAIL_PARAM(_allow_mount, , CTLTYPE_INT | CTLFLAG_RW, Modified: head/sys/kern/kern_priv.c ============================================================================== --- head/sys/kern/kern_priv.c Wed Nov 18 20:59:58 2020 (r367818) +++ head/sys/kern/kern_priv.c Wed Nov 18 21:07:08 2020 (r367819) @@ -3,6 +3,7 @@ * * Copyright (c) 2006 nCircle Network Security, Inc. * Copyright (c) 2009 Robert N. M. Watson + * Copyright (c) 2020 Mariusz Zaborski * All rights reserved. * * This software was developed by Robert N. M. Watson for the TrustedBSD @@ -36,6 +37,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include #include @@ -54,10 +58,58 @@ __FBSDID("$FreeBSD$"); * userland programs, and should not be done without careful consideration of * the consequences. */ -static int __read_mostly suser_enabled = 1; -SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RWTUN, - &suser_enabled, 0, "processes with uid 0 have privilege"); +static bool +suser_enabled(struct ucred *cred) +{ + + return (prison_allow(cred, PR_ALLOW_SUSER) ? true : false); +} + +static void inline +prison_suser_set(struct prison *pr, int enabled) +{ + + if (enabled) { + pr->pr_allow |= PR_ALLOW_SUSER; + } else { + pr->pr_allow &= ~PR_ALLOW_SUSER; + } +} + +static int +sysctl_kern_suser_enabled(SYSCTL_HANDLER_ARGS) +{ + struct prison *pr, *cpr; + struct ucred *cred; + int descend, error, enabled; + + cred = req->td->td_ucred; + enabled = suser_enabled(cred); + + error = sysctl_handle_int(oidp, &enabled, 0, req); + if (error || !req->newptr) + return (error); + + pr = cred->cr_prison; + sx_slock(&allprison_lock); + mtx_lock(&pr->pr_mtx); + + prison_suser_set(pr, enabled); + if (!enabled) { + FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) { + prison_suser_set(cpr, 0); + } + } + mtx_unlock(&pr->pr_mtx); + sx_sunlock(&allprison_lock); + return (0); +} + +SYSCTL_PROC(_security_bsd, OID_AUTO, suser_enabled, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_PRISON, 0, 0, &sysctl_kern_suser_enabled, "I", + "Processes with uid 0 have privilege"); + static int unprivileged_mlock = 1; SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RWTUN, &unprivileged_mlock, 0, "Allow non-root users to call mlock(2)"); @@ -186,7 +238,7 @@ priv_check_cred(struct ucred *cred, int priv) * superuser policy to be globally disabled, although this is * currenty of limited utility. */ - if (suser_enabled) { + if (suser_enabled(cred)) { switch (priv) { case PRIV_MAXFILES: case PRIV_MAXPROC: @@ -258,7 +310,7 @@ priv_check_cred_vfs_lookup_slow(struct ucred *cred) if (error) goto out; - if (cred->cr_uid == 0 && suser_enabled) { + if (cred->cr_uid == 0 && suser_enabled(cred)) { error = 0; goto out; } @@ -279,7 +331,7 @@ priv_check_cred_vfs_lookup(struct ucred *cred) return (priv_check_cred_vfs_lookup_slow(cred)); error = EPERM; - if (cred->cr_uid == 0 && suser_enabled) + if (cred->cr_uid == 0 && suser_enabled(cred)) error = 0; return (error); } @@ -294,7 +346,7 @@ priv_check_cred_vfs_lookup_nomac(struct ucred *cred) return (EAGAIN); error = EPERM; - if (cred->cr_uid == 0 && suser_enabled) + if (cred->cr_uid == 0 && suser_enabled(cred)) error = 0; return (error); } @@ -313,7 +365,7 @@ priv_check_cred_vfs_generation_slow(struct ucred *cred goto out; } - if (cred->cr_uid == 0 && suser_enabled) { + if (cred->cr_uid == 0 && suser_enabled(cred)) { error = 0; goto out; } @@ -334,7 +386,7 @@ priv_check_cred_vfs_generation(struct ucred *cred) return (priv_check_cred_vfs_generation_slow(cred)); error = EPERM; - if (!jailed(cred) && cred->cr_uid == 0 && suser_enabled) + if (!jailed(cred) && cred->cr_uid == 0 && suser_enabled(cred)) error = 0; return (error); } Modified: head/sys/sys/jail.h ============================================================================== --- head/sys/sys/jail.h Wed Nov 18 20:59:58 2020 (r367818) +++ head/sys/sys/jail.h Wed Nov 18 21:07:08 2020 (r367819) @@ -232,9 +232,10 @@ struct prison_racct { #define PR_ALLOW_MLOCK 0x00000080 #define PR_ALLOW_READ_MSGBUF 0x00000100 #define PR_ALLOW_UNPRIV_DEBUG 0x00000200 +#define PR_ALLOW_SUSER 0x00000400 #define PR_ALLOW_RESERVED_PORTS 0x00008000 #define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */ -#define PR_ALLOW_ALL_STATIC 0x000183ff +#define PR_ALLOW_ALL_STATIC 0x000187ff /* * PR_ALLOW_DIFFERENCES determines which flags are able to be Modified: head/usr.sbin/jail/jail.8 ============================================================================== --- head/usr.sbin/jail/jail.8 Wed Nov 18 20:59:58 2020 (r367818) +++ head/usr.sbin/jail/jail.8 Wed Nov 18 21:07:08 2020 (r367819) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 14, 2020 +.Dd November 18, 2020 .Dt JAIL 8 .Os .Sh NAME @@ -587,6 +587,13 @@ and resource limits. The jail root may bind to ports lower than 1024. .It Va allow.unprivileged_proc_debug Unprivileged processes in the jail may use debugging facilities. +.It Va allow.suser +The value of the jail's +.Va security.bsd.suser_enabled +sysctl. +The super-user will be disabled automatically if its parent system has it +disabled. +The super-user is enabled by default. .El .El .Pp @@ -1267,6 +1274,7 @@ Changes to these variables by a jailed process do not environment, only the jail environment. These variables are .Va kern.securelevel , +.Va security.bsd.suser_enabled , .Va kern.hostname , .Va kern.domainname , .Va kern.hostid , From owner-svn-src-all@freebsd.org Wed Nov 18 21:15:03 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1BE35472469; Wed, 18 Nov 2020 21:15:03 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (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 4CbwYz04pJz4ff8; Wed, 18 Nov 2020 21:15:02 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x42a.google.com with SMTP id d12so3523080wrr.13; Wed, 18 Nov 2020 13:15:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Mp/G6k12INNDTBHZ7JcZ2KE6sXmB16hdvUu08DYEtww=; b=JmxEJKtNL9lB9RkJHqEViy3CJwSEibp2+JWi01a7guCOpmGp/+jdRFlM+fZyTv7JLK vD5kmW0VBupFojSvrYWKkU4/kZGKD185Dl1IUmMRzrz/k4pofO9qyh3sk8wy9M7WPK4Z JSZMF6BqObBdHAQQBXf8C7c9GbBo2qrOoo4aMXPi9duFFqrsIbaGLG1arkD97IEalz94 5qh6CPQ4tpdCPqUhs+OG5kiAC24I7F6hd2ESm3vfMhot3xpMJsF8ONlCFNC8iJ+KEUwg /7G9RntHHW1uY4A9QWNRsG9C8rkp5LykahGSLFZZV0tfcVMgP33EfqqCBL5Qb6xSQQQK 1KJA== 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=Mp/G6k12INNDTBHZ7JcZ2KE6sXmB16hdvUu08DYEtww=; b=UOxYvGs2JckI/h+sLtyK4wpO/JNWd3V8t13uxJWvmvqZvs3Q3nUXctub46dWnTJyP5 0yPcX3keAGd3uY+mwSRJ3CmelwNMjhKDsvxkOTFsfj4ybLY0qYBYz5qMTzQ5BOlru2m+ kj/U9IgAJQ/57xr+DjKJDjKsLhMTqUtvQaIDkp4voxZGT4ukU8Gu2+1rKlzJO3IlMZ1q qMpTo19fu315jvDALJb1j/0lvDCdoFywliRcBataVxhBnuG610jH2zyo3m2gg5Kg4lyL x9qHya0mHOTSD2XywJPlR2Glf17mPpiH5GlQ1c0fF1nqMVtpK0au+J1CFlLQ/r/UHzqt Pabg== X-Gm-Message-State: AOAM532SOb5YfjWNmKeQSlvX+RI9iIeztX4NMfU0gLKgVIlrKSeDuwsS t4HrMFsEVb+dnVLfOwFnc9pgzdGTg19pfGbaZHn8O0yrF2Y= X-Google-Smtp-Source: ABdhPJwk4ugRDq6JkYa5ku8ssJ6Nwxo00Y7ttQ5FomKayxYXz64IMWZySzr8hnbRoPOhaZb5FSFRwwnMv/6TY2IV/H0= X-Received: by 2002:a5d:5146:: with SMTP id u6mr7142004wrt.66.1605734100203; Wed, 18 Nov 2020 13:15:00 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Wed, 18 Nov 2020 13:14:59 -0800 (PST) In-Reply-To: <202011182107.0AIL78pi053574@repo.freebsd.org> References: <202011182107.0AIL78pi053574@repo.freebsd.org> From: Mateusz Guzik Date: Wed, 18 Nov 2020 22:14:59 +0100 Message-ID: Subject: Re: svn commit: r367819 - in head: sys/kern sys/sys usr.sbin/jail To: Mariusz Zaborski Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4CbwYz04pJz4ff8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:15:03 -0000 On 11/18/20, Mariusz Zaborski wrote: > Author: oshogbo > Date: Wed Nov 18 21:07:08 2020 > New Revision: 367819 > URL: https://svnweb.freebsd.org/changeset/base/367819 > > Log: > jail: introduce per jail suser_enabled setting > > The suser_enable sysctl allows to remove a privileged rights from uid 0. > This change introduce per jail setting which allow to make root a > normal user. > > Reviewed by: jamie > Previous version reviewed by: kevans, emaste, markj, me_igalic.co > Discussed with: pjd > Differential Revision: https://reviews.freebsd.org/D27128 > > Modified: > head/sys/kern/kern_jail.c > head/sys/kern/kern_priv.c > head/sys/sys/jail.h > head/usr.sbin/jail/jail.8 > > Modified: head/sys/kern/kern_jail.c > ============================================================================== > --- head/sys/kern/kern_jail.c Wed Nov 18 20:59:58 2020 (r367818) > +++ head/sys/kern/kern_jail.c Wed Nov 18 21:07:08 2020 (r367819) > @@ -199,12 +199,14 @@ static struct bool_flags pr_flag_allow[NBBY * NBPW] = > > {"allow.read_msgbuf", "allow.noread_msgbuf", PR_ALLOW_READ_MSGBUF}, > {"allow.unprivileged_proc_debug", "allow.nounprivileged_proc_debug", > PR_ALLOW_UNPRIV_DEBUG}, > + {"allow.suser", "allow.nosuser", PR_ALLOW_SUSER}, > }; > const size_t pr_flag_allow_size = sizeof(pr_flag_allow); > > #define JAIL_DEFAULT_ALLOW (PR_ALLOW_SET_HOSTNAME | \ > PR_ALLOW_RESERVED_PORTS | \ > - PR_ALLOW_UNPRIV_DEBUG) > + PR_ALLOW_UNPRIV_DEBUG | \ > + PR_ALLOW_SUSER) > #define JAIL_DEFAULT_ENFORCE_STATFS 2 > #define JAIL_DEFAULT_DEVFS_RSNUM 0 > static unsigned jail_default_allow = JAIL_DEFAULT_ALLOW; > @@ -3815,6 +3817,8 @@ SYSCTL_JAIL_PARAM(_allow, read_msgbuf, CTLTYPE_INT | > C > "B", "Jail may read the kernel message buffer"); > SYSCTL_JAIL_PARAM(_allow, unprivileged_proc_debug, CTLTYPE_INT | > CTLFLAG_RW, > "B", "Unprivileged processes may use process debugging facilities"); > +SYSCTL_JAIL_PARAM(_allow, suser, CTLTYPE_INT | CTLFLAG_RW, > + "B", "Processes in jail with uid 0 have privilege"); > > SYSCTL_JAIL_PARAM_SUBNODE(allow, mount, "Jail mount/unmount permission > flags"); > SYSCTL_JAIL_PARAM(_allow_mount, , CTLTYPE_INT | CTLFLAG_RW, > > Modified: head/sys/kern/kern_priv.c > ============================================================================== > --- head/sys/kern/kern_priv.c Wed Nov 18 20:59:58 2020 (r367818) > +++ head/sys/kern/kern_priv.c Wed Nov 18 21:07:08 2020 (r367819) > @@ -3,6 +3,7 @@ > * > * Copyright (c) 2006 nCircle Network Security, Inc. > * Copyright (c) 2009 Robert N. M. Watson > + * Copyright (c) 2020 Mariusz Zaborski > * All rights reserved. > * > * This software was developed by Robert N. M. Watson for the TrustedBSD > @@ -36,6 +37,9 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > +#include > +#include > #include > #include > #include > @@ -54,10 +58,58 @@ __FBSDID("$FreeBSD$"); > * userland programs, and should not be done without careful consideration > of > * the consequences. > */ > -static int __read_mostly suser_enabled = 1; > -SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RWTUN, > - &suser_enabled, 0, "processes with uid 0 have privilege"); > > +static bool > +suser_enabled(struct ucred *cred) > +{ > + > + return (prison_allow(cred, PR_ALLOW_SUSER) ? true : false); > +} > + This converts a variable read into a function call to prison_allow. prison_allow should be converted into an inline func and put in a header. Also: /* This is an atomic read, so no locking is necessary. */ return (cred->cr_prison->pr_allow & flag); happens to probably work in practice, but is wrong. Short of atomic_store to modify and atomic_load to obtain the content can be arbitrarily mangled during concurrent concurrent write. > +static void inline > +prison_suser_set(struct prison *pr, int enabled) > +{ > + > + if (enabled) { > + pr->pr_allow |= PR_ALLOW_SUSER; > + } else { > + pr->pr_allow &= ~PR_ALLOW_SUSER; > + } > +} > + > +static int > +sysctl_kern_suser_enabled(SYSCTL_HANDLER_ARGS) > +{ > + struct prison *pr, *cpr; > + struct ucred *cred; > + int descend, error, enabled; > + > + cred = req->td->td_ucred; > + enabled = suser_enabled(cred); > + > + error = sysctl_handle_int(oidp, &enabled, 0, req); > + if (error || !req->newptr) > + return (error); > + > + pr = cred->cr_prison; > + sx_slock(&allprison_lock); > + mtx_lock(&pr->pr_mtx); > + > + prison_suser_set(pr, enabled); > + if (!enabled) { > + FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) { > + prison_suser_set(cpr, 0); > + } > + } > + mtx_unlock(&pr->pr_mtx); > + sx_sunlock(&allprison_lock); > + return (0); > +} > + > +SYSCTL_PROC(_security_bsd, OID_AUTO, suser_enabled, CTLTYPE_INT | > + CTLFLAG_RWTUN | CTLFLAG_PRISON, 0, 0, &sysctl_kern_suser_enabled, "I", > + "Processes with uid 0 have privilege"); > + This lacks CTLFLAG_MPSAFE. > static int unprivileged_mlock = 1; > SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RWTUN, > &unprivileged_mlock, 0, "Allow non-root users to call mlock(2)"); > @@ -186,7 +238,7 @@ priv_check_cred(struct ucred *cred, int priv) > * superuser policy to be globally disabled, although this is > * currenty of limited utility. > */ > - if (suser_enabled) { > + if (suser_enabled(cred)) { > switch (priv) { > case PRIV_MAXFILES: > case PRIV_MAXPROC: > @@ -258,7 +310,7 @@ priv_check_cred_vfs_lookup_slow(struct ucred *cred) > if (error) > goto out; > > - if (cred->cr_uid == 0 && suser_enabled) { > + if (cred->cr_uid == 0 && suser_enabled(cred)) { > error = 0; > goto out; > } > @@ -279,7 +331,7 @@ priv_check_cred_vfs_lookup(struct ucred *cred) > return (priv_check_cred_vfs_lookup_slow(cred)); > > error = EPERM; > - if (cred->cr_uid == 0 && suser_enabled) > + if (cred->cr_uid == 0 && suser_enabled(cred)) > error = 0; > return (error); > } > @@ -294,7 +346,7 @@ priv_check_cred_vfs_lookup_nomac(struct ucred *cred) > return (EAGAIN); > > error = EPERM; > - if (cred->cr_uid == 0 && suser_enabled) > + if (cred->cr_uid == 0 && suser_enabled(cred)) > error = 0; > return (error); > } > @@ -313,7 +365,7 @@ priv_check_cred_vfs_generation_slow(struct ucred *cred > goto out; > } > > - if (cred->cr_uid == 0 && suser_enabled) { > + if (cred->cr_uid == 0 && suser_enabled(cred)) { > error = 0; > goto out; > } > @@ -334,7 +386,7 @@ priv_check_cred_vfs_generation(struct ucred *cred) > return (priv_check_cred_vfs_generation_slow(cred)); > > error = EPERM; > - if (!jailed(cred) && cred->cr_uid == 0 && suser_enabled) > + if (!jailed(cred) && cred->cr_uid == 0 && suser_enabled(cred)) > error = 0; > return (error); > } > > Modified: head/sys/sys/jail.h > ============================================================================== > --- head/sys/sys/jail.h Wed Nov 18 20:59:58 2020 (r367818) > +++ head/sys/sys/jail.h Wed Nov 18 21:07:08 2020 (r367819) > @@ -232,9 +232,10 @@ struct prison_racct { > #define PR_ALLOW_MLOCK 0x00000080 > #define PR_ALLOW_READ_MSGBUF 0x00000100 > #define PR_ALLOW_UNPRIV_DEBUG 0x00000200 > +#define PR_ALLOW_SUSER 0x00000400 > #define PR_ALLOW_RESERVED_PORTS 0x00008000 > #define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */ > -#define PR_ALLOW_ALL_STATIC 0x000183ff > +#define PR_ALLOW_ALL_STATIC 0x000187ff > > /* > * PR_ALLOW_DIFFERENCES determines which flags are able to be > > Modified: head/usr.sbin/jail/jail.8 > ============================================================================== > --- head/usr.sbin/jail/jail.8 Wed Nov 18 20:59:58 2020 (r367818) > +++ head/usr.sbin/jail/jail.8 Wed Nov 18 21:07:08 2020 (r367819) > @@ -25,7 +25,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd May 14, 2020 > +.Dd November 18, 2020 > .Dt JAIL 8 > .Os > .Sh NAME > @@ -587,6 +587,13 @@ and resource limits. > The jail root may bind to ports lower than 1024. > .It Va allow.unprivileged_proc_debug > Unprivileged processes in the jail may use debugging facilities. > +.It Va allow.suser > +The value of the jail's > +.Va security.bsd.suser_enabled > +sysctl. > +The super-user will be disabled automatically if its parent system has it > +disabled. > +The super-user is enabled by default. > .El > .El > .Pp > @@ -1267,6 +1274,7 @@ Changes to these variables by a jailed process do not > > environment, only the jail environment. > These variables are > .Va kern.securelevel , > +.Va security.bsd.suser_enabled , > .Va kern.hostname , > .Va kern.domainname , > .Va kern.hostid , > -- Mateusz Guzik From owner-svn-src-all@freebsd.org Wed Nov 18 21:15:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1E4EE472805 for ; Wed, 18 Nov 2020 21:15:39 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 4CbwZg0Cg0z4gPs for ; Wed, 18 Nov 2020 21:15:38 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f49.google.com with SMTP id p22so4406700wmg.3 for ; Wed, 18 Nov 2020 13:15:38 -0800 (PST) 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=7q6Z5kiPC65Z+W7vidC70pjbWNC3E/ifFqXsTjHe8+A=; b=Jpe6JFkcx3TqM7OvVl4cVb9NyP/iJSh5p3v59pATYDRIRjTIi8iFfY48VkCBNGq8RH hXf/7sodpFx1+79hyN+8O0UQCMe6GccekU9Wn0rcnGD+yfCilumMdO61UMz8xvBdGYOg ntPVwqaMiJuZpc0jfuBbA7vmLTHHnx3O0tinWA6Yhd7rW4zYdqiGbKj3rqfYyEhPlqim lAkTU463NfYg8yo+BtDJOATpWRE3qTNu+VB9POugr6gTBXMjpXmBwtCmxTA414Ok8E9x uT5f3xMFQtb07lfp8OSJM69UZj0d1vLFQ722fDD6X4rVL0q06aK6QF67ThdA85EJzv1W Hwqw== X-Gm-Message-State: AOAM532guBiP4OZ9G4+y0y+Z266SpzM05UQLHhovPIskYjtKfFU+w28V dr1jv2AUdeTpvYUQSxD04fZVKA== X-Google-Smtp-Source: ABdhPJyRxPI9N2bkEyj5lppWIJlFnryiu5swx8W05zXBQt0Qy8KjhsdOZw/N8RV96ABmI3O9uYCVKg== X-Received: by 2002:a1c:5446:: with SMTP id p6mr954748wmi.167.1605734137286; Wed, 18 Nov 2020 13:15:37 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id a14sm5471600wmj.40.2020.11.18.13.15.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2020 13:15:36 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367813 - head/lib/libutil From: Jessica Clarke In-Reply-To: <202011181944.0AIJiUU3003699@repo.freebsd.org> Date: Wed, 18 Nov 2020 21:15:35 +0000 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> References: <202011181944.0AIJiUU3003699@repo.freebsd.org> To: =?utf-8?Q?Stefan_E=C3=9Fer?= X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CbwZg0Cg0z4gPs X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:15:39 -0000 On 18 Nov 2020, at 19:44, Stefan E=C3=9Fer wrote: > + /* > + * Check for some other thread already having=20 > + * set localbase - this should use atomic ops. > + * The amount of memory allocated above may leak, > + * if a parallel update in another thread is not > + * detected and the non-NULL pointer is overwritten. > + */ Why was this committed with a known racy/leaky implementation? What happens if I set the value with a sysctl and call this? Jess > + if (tmppath[0] !=3D '\0' && > + (volatile const char*)localbase =3D=3D NULL) > + localbase =3D tmppath; > + else > + free((void*)tmppath); > + return (localbase); > + } > + return (_PATH_LOCALBASE); > +} From owner-svn-src-all@freebsd.org Wed Nov 18 21:18:15 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3B2E0471EF3; Wed, 18 Nov 2020 21:18:15 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 4Cbwdg13gfz4gQt; Wed, 18 Nov 2020 21:18:15 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: by mail-lf1-f49.google.com with SMTP id e139so5122143lfd.1; Wed, 18 Nov 2020 13:18:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xBFuJ2zGOX03Npjl+fJ4SpnflPBlZnWsG9dAlG3PjZE=; b=LKdi23+xM7fSX/azEQXaGOV3rljPOTlXIlTnO3C1NRxUM5kNs2/lV3YnN2177DloZb 08oTATixKmAtkaeGdp+MzScB7aLg7EXKZz3Q9yD01dghXgn9LZ0sb+yD87QuTdyex+n/ bJ6HyrJD/SOGumyQGZ3chHo456F159uO1PdTToRPX1p3PMRu6hvG1p1yPsbuQuMAGA23 yeTLt+QMRppyEFMWSSsA/7waMnZr/ACGAD+gTSV/F3FgxbfmvqspzpDiCOVssa4x3/EA LjFGZwzhtNTnuDATES2HEbmKAhKeC0xgnVu22B/wHdQxRLLTJ5Kq0utJ3m7RbsZM5c04 Z0sQ== X-Gm-Message-State: AOAM532WodGHWuupUMU3oVl4sj3Em1b7Yqn3EXjlp3N+Mgd9WKv/Icgv mwe2nTdkGLmqtOdx65GIqWKibGITztJ/xYD71vFOfwehv3o= X-Google-Smtp-Source: ABdhPJybYbV2FdfEzEB2hBj2WPd1kgLFL845OlO25zP9z2j1MrjGjdBkjrsuGedqpacdDlr7puxm+1Xckp3wMouyQwI= X-Received: by 2002:ac2:52b3:: with SMTP id r19mr4303102lfm.140.1605734293313; Wed, 18 Nov 2020 13:18:13 -0800 (PST) MIME-Version: 1.0 References: <202011182107.0AIL78pi053574@repo.freebsd.org> In-Reply-To: From: Mariusz Zaborski Date: Wed, 18 Nov 2020 22:19:39 +0100 Message-ID: Subject: Re: svn commit: r367819 - in head: sys/kern sys/sys usr.sbin/jail To: Mateusz Guzik Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Cbwdg13gfz4gQt X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:18:15 -0000 Hello Mateusz, Thank you for pointing out this. I will fix those. Thanks, Mariusz On Wed, 18 Nov 2020 at 22:15, Mateusz Guzik wrote: > > On 11/18/20, Mariusz Zaborski wrote: > > Author: oshogbo > > Date: Wed Nov 18 21:07:08 2020 > > New Revision: 367819 > > URL: https://svnweb.freebsd.org/changeset/base/367819 > > > > Log: > > jail: introduce per jail suser_enabled setting > > > > The suser_enable sysctl allows to remove a privileged rights from uid 0. > > This change introduce per jail setting which allow to make root a > > normal user. > > > > Reviewed by: jamie > > Previous version reviewed by: kevans, emaste, markj, me_igalic.co > > Discussed with: pjd > > Differential Revision: https://reviews.freebsd.org/D27128 > > > > Modified: > > head/sys/kern/kern_jail.c > > head/sys/kern/kern_priv.c > > head/sys/sys/jail.h > > head/usr.sbin/jail/jail.8 > > > > Modified: head/sys/kern/kern_jail.c > > ============================================================================== > > --- head/sys/kern/kern_jail.c Wed Nov 18 20:59:58 2020 (r367818) > > +++ head/sys/kern/kern_jail.c Wed Nov 18 21:07:08 2020 (r367819) > > @@ -199,12 +199,14 @@ static struct bool_flags pr_flag_allow[NBBY * NBPW] = > > > > {"allow.read_msgbuf", "allow.noread_msgbuf", PR_ALLOW_READ_MSGBUF}, > > {"allow.unprivileged_proc_debug", "allow.nounprivileged_proc_debug", > > PR_ALLOW_UNPRIV_DEBUG}, > > + {"allow.suser", "allow.nosuser", PR_ALLOW_SUSER}, > > }; > > const size_t pr_flag_allow_size = sizeof(pr_flag_allow); > > > > #define JAIL_DEFAULT_ALLOW (PR_ALLOW_SET_HOSTNAME | \ > > PR_ALLOW_RESERVED_PORTS | \ > > - PR_ALLOW_UNPRIV_DEBUG) > > + PR_ALLOW_UNPRIV_DEBUG | \ > > + PR_ALLOW_SUSER) > > #define JAIL_DEFAULT_ENFORCE_STATFS 2 > > #define JAIL_DEFAULT_DEVFS_RSNUM 0 > > static unsigned jail_default_allow = JAIL_DEFAULT_ALLOW; > > @@ -3815,6 +3817,8 @@ SYSCTL_JAIL_PARAM(_allow, read_msgbuf, CTLTYPE_INT | > > C > > "B", "Jail may read the kernel message buffer"); > > SYSCTL_JAIL_PARAM(_allow, unprivileged_proc_debug, CTLTYPE_INT | > > CTLFLAG_RW, > > "B", "Unprivileged processes may use process debugging facilities"); > > +SYSCTL_JAIL_PARAM(_allow, suser, CTLTYPE_INT | CTLFLAG_RW, > > + "B", "Processes in jail with uid 0 have privilege"); > > > > SYSCTL_JAIL_PARAM_SUBNODE(allow, mount, "Jail mount/unmount permission > > flags"); > > SYSCTL_JAIL_PARAM(_allow_mount, , CTLTYPE_INT | CTLFLAG_RW, > > > > Modified: head/sys/kern/kern_priv.c > > ============================================================================== > > --- head/sys/kern/kern_priv.c Wed Nov 18 20:59:58 2020 (r367818) > > +++ head/sys/kern/kern_priv.c Wed Nov 18 21:07:08 2020 (r367819) > > @@ -3,6 +3,7 @@ > > * > > * Copyright (c) 2006 nCircle Network Security, Inc. > > * Copyright (c) 2009 Robert N. M. Watson > > + * Copyright (c) 2020 Mariusz Zaborski > > * All rights reserved. > > * > > * This software was developed by Robert N. M. Watson for the TrustedBSD > > @@ -36,6 +37,9 @@ __FBSDID("$FreeBSD$"); > > #include > > #include > > #include > > +#include > > +#include > > +#include > > #include > > #include > > #include > > @@ -54,10 +58,58 @@ __FBSDID("$FreeBSD$"); > > * userland programs, and should not be done without careful consideration > > of > > * the consequences. > > */ > > -static int __read_mostly suser_enabled = 1; > > -SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RWTUN, > > - &suser_enabled, 0, "processes with uid 0 have privilege"); > > > > +static bool > > +suser_enabled(struct ucred *cred) > > +{ > > + > > + return (prison_allow(cred, PR_ALLOW_SUSER) ? true : false); > > +} > > + > > This converts a variable read into a function call to prison_allow. > prison_allow should be converted into an inline func and put in a > header. > > Also: > /* This is an atomic read, so no locking is necessary. */ > return (cred->cr_prison->pr_allow & flag); > > happens to probably work in practice, but is wrong. Short of > atomic_store to modify and atomic_load to obtain the content can be > arbitrarily mangled during concurrent concurrent write. > > > +static void inline > > +prison_suser_set(struct prison *pr, int enabled) > > +{ > > + > > + if (enabled) { > > + pr->pr_allow |= PR_ALLOW_SUSER; > > + } else { > > + pr->pr_allow &= ~PR_ALLOW_SUSER; > > + } > > +} > > + > > +static int > > +sysctl_kern_suser_enabled(SYSCTL_HANDLER_ARGS) > > +{ > > + struct prison *pr, *cpr; > > + struct ucred *cred; > > + int descend, error, enabled; > > + > > + cred = req->td->td_ucred; > > + enabled = suser_enabled(cred); > > + > > + error = sysctl_handle_int(oidp, &enabled, 0, req); > > + if (error || !req->newptr) > > + return (error); > > + > > + pr = cred->cr_prison; > > + sx_slock(&allprison_lock); > > + mtx_lock(&pr->pr_mtx); > > + > > + prison_suser_set(pr, enabled); > > + if (!enabled) { > > + FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) { > > + prison_suser_set(cpr, 0); > > + } > > + } > > + mtx_unlock(&pr->pr_mtx); > > + sx_sunlock(&allprison_lock); > > + return (0); > > +} > > + > > +SYSCTL_PROC(_security_bsd, OID_AUTO, suser_enabled, CTLTYPE_INT | > > + CTLFLAG_RWTUN | CTLFLAG_PRISON, 0, 0, &sysctl_kern_suser_enabled, "I", > > + "Processes with uid 0 have privilege"); > > + > > This lacks CTLFLAG_MPSAFE. > > > static int unprivileged_mlock = 1; > > SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RWTUN, > > &unprivileged_mlock, 0, "Allow non-root users to call mlock(2)"); > > @@ -186,7 +238,7 @@ priv_check_cred(struct ucred *cred, int priv) > > * superuser policy to be globally disabled, although this is > > * currenty of limited utility. > > */ > > - if (suser_enabled) { > > + if (suser_enabled(cred)) { > > switch (priv) { > > case PRIV_MAXFILES: > > case PRIV_MAXPROC: > > @@ -258,7 +310,7 @@ priv_check_cred_vfs_lookup_slow(struct ucred *cred) > > if (error) > > goto out; > > > > - if (cred->cr_uid == 0 && suser_enabled) { > > + if (cred->cr_uid == 0 && suser_enabled(cred)) { > > error = 0; > > goto out; > > } > > @@ -279,7 +331,7 @@ priv_check_cred_vfs_lookup(struct ucred *cred) > > return (priv_check_cred_vfs_lookup_slow(cred)); > > > > error = EPERM; > > - if (cred->cr_uid == 0 && suser_enabled) > > + if (cred->cr_uid == 0 && suser_enabled(cred)) > > error = 0; > > return (error); > > } > > @@ -294,7 +346,7 @@ priv_check_cred_vfs_lookup_nomac(struct ucred *cred) > > return (EAGAIN); > > > > error = EPERM; > > - if (cred->cr_uid == 0 && suser_enabled) > > + if (cred->cr_uid == 0 && suser_enabled(cred)) > > error = 0; > > return (error); > > } > > @@ -313,7 +365,7 @@ priv_check_cred_vfs_generation_slow(struct ucred *cred > > goto out; > > } > > > > - if (cred->cr_uid == 0 && suser_enabled) { > > + if (cred->cr_uid == 0 && suser_enabled(cred)) { > > error = 0; > > goto out; > > } > > @@ -334,7 +386,7 @@ priv_check_cred_vfs_generation(struct ucred *cred) > > return (priv_check_cred_vfs_generation_slow(cred)); > > > > error = EPERM; > > - if (!jailed(cred) && cred->cr_uid == 0 && suser_enabled) > > + if (!jailed(cred) && cred->cr_uid == 0 && suser_enabled(cred)) > > error = 0; > > return (error); > > } > > > > Modified: head/sys/sys/jail.h > > ============================================================================== > > --- head/sys/sys/jail.h Wed Nov 18 20:59:58 2020 (r367818) > > +++ head/sys/sys/jail.h Wed Nov 18 21:07:08 2020 (r367819) > > @@ -232,9 +232,10 @@ struct prison_racct { > > #define PR_ALLOW_MLOCK 0x00000080 > > #define PR_ALLOW_READ_MSGBUF 0x00000100 > > #define PR_ALLOW_UNPRIV_DEBUG 0x00000200 > > +#define PR_ALLOW_SUSER 0x00000400 > > #define PR_ALLOW_RESERVED_PORTS 0x00008000 > > #define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */ > > -#define PR_ALLOW_ALL_STATIC 0x000183ff > > +#define PR_ALLOW_ALL_STATIC 0x000187ff > > > > /* > > * PR_ALLOW_DIFFERENCES determines which flags are able to be > > > > Modified: head/usr.sbin/jail/jail.8 > > ============================================================================== > > --- head/usr.sbin/jail/jail.8 Wed Nov 18 20:59:58 2020 (r367818) > > +++ head/usr.sbin/jail/jail.8 Wed Nov 18 21:07:08 2020 (r367819) > > @@ -25,7 +25,7 @@ > > .\" > > .\" $FreeBSD$ > > .\" > > -.Dd May 14, 2020 > > +.Dd November 18, 2020 > > .Dt JAIL 8 > > .Os > > .Sh NAME > > @@ -587,6 +587,13 @@ and resource limits. > > The jail root may bind to ports lower than 1024. > > .It Va allow.unprivileged_proc_debug > > Unprivileged processes in the jail may use debugging facilities. > > +.It Va allow.suser > > +The value of the jail's > > +.Va security.bsd.suser_enabled > > +sysctl. > > +The super-user will be disabled automatically if its parent system has it > > +disabled. > > +The super-user is enabled by default. > > .El > > .El > > .Pp > > @@ -1267,6 +1274,7 @@ Changes to these variables by a jailed process do not > > > > environment, only the jail environment. > > These variables are > > .Va kern.securelevel , > > +.Va security.bsd.suser_enabled , > > .Va kern.hostname , > > .Va kern.domainname , > > .Va kern.hostid , > > > > > -- > Mateusz Guzik From owner-svn-src-all@freebsd.org Wed Nov 18 21:26:15 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EDD3472B4F; Wed, 18 Nov 2020 21:26:15 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbwpv2x87z4ggJ; Wed, 18 Nov 2020 21:26:15 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 53C2818853; Wed, 18 Nov 2020 21:26:15 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AILQF8q065617; Wed, 18 Nov 2020 21:26:15 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AILQFCK065616; Wed, 18 Nov 2020 21:26:15 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <202011182126.0AILQFCK065616@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Wed, 18 Nov 2020 21:26:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367820 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367820 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:26:15 -0000 Author: oshogbo Date: Wed Nov 18 21:26:14 2020 New Revision: 367820 URL: https://svnweb.freebsd.org/changeset/base/367820 Log: Add CTLFLAG_MPSAFE to the suser_enabled sysctl. Pointed out by: mjg Modified: head/sys/kern/kern_priv.c Modified: head/sys/kern/kern_priv.c ============================================================================== --- head/sys/kern/kern_priv.c Wed Nov 18 21:07:08 2020 (r367819) +++ head/sys/kern/kern_priv.c Wed Nov 18 21:26:14 2020 (r367820) @@ -107,8 +107,8 @@ sysctl_kern_suser_enabled(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_security_bsd, OID_AUTO, suser_enabled, CTLTYPE_INT | - CTLFLAG_RWTUN | CTLFLAG_PRISON, 0, 0, &sysctl_kern_suser_enabled, "I", - "Processes with uid 0 have privilege"); + CTLFLAG_RWTUN | CTLFLAG_PRISON | CTLFLAG_MPSAFE, 0, 0, + &sysctl_kern_suser_enabled, "I", "Processes with uid 0 have privilege"); static int unprivileged_mlock = 1; SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RWTUN, From owner-svn-src-all@freebsd.org Wed Nov 18 21:27:17 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C238472C1A for ; Wed, 18 Nov 2020 21:27:17 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 4Cbwr41zFXz4gkg for ; Wed, 18 Nov 2020 21:27:15 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f46.google.com with SMTP id h21so4062493wmb.2 for ; Wed, 18 Nov 2020 13:27:15 -0800 (PST) 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=PnfasZAXsgl+ZGBcpSwcsQsBtbgWqlMKDy82wizn38w=; b=VHVlWugPf9KSDqliiMuugHqJtzgz0wM3LTCZtaFQYEiPXk8YS90BxGZ48jJOJ0QCS5 n+trgjFY2KCUy+V/K6A+fE6ltbteVxzMsnVPvzOev0g5arqNpR/oXPqnjp3Moaxp5NZ9 0zXxripaY6DQ4yROnTulNDuyk2SuRsjEGKXK0Zp+KGJeb4OtOxKDjIX1X6rqnfZxUEpC G5VlisZdpZ5ZTSGmp0ao6aGc5+SMmQoVt9Qco7aZDjtk1EsqohdZJjIZriJfogIbILLO rkPOvP1jUxYRzFgz3C8ldAch23C6eIWCv7Q4qN6TqtRe9kaXftlO/Hw5EGdOoqn5GtLz qfHg== X-Gm-Message-State: AOAM531n51zBraiBLXAH3n07Q0F25YY2Wk0xeYgK1qCvkEjOIW7ZlJOj U+9B+7WCxk1nVOVIrgbSb/pY/A== X-Google-Smtp-Source: ABdhPJwWSLYj4jb9/SoiC3aqYVM091O5OkgaXBzt2XEbES/z5OI/iXG3zNxGEQl6WAawj75TmompIA== X-Received: by 2002:a1c:7704:: with SMTP id t4mr1133538wmi.48.1605734834730; Wed, 18 Nov 2020 13:27:14 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id b124sm5921097wmh.13.2020.11.18.13.27.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2020 13:27:14 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367813 - head/lib/libutil From: Jessica Clarke In-Reply-To: <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> Date: Wed, 18 Nov 2020 21:27:13 +0000 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> To: =?utf-8?Q?Stefan_E=C3=9Fer?= X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4Cbwr41zFXz4gkg 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.128.46 as permitted sender) smtp.mailfrom=jrtc27@jrtc27.com X-Spamd-Result: default: False [-2.50 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.128.46:from]; 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)[-1.000]; FREEFALL_USER(0.00)[jrtc27]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-all@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; SPAMHAUS_ZRD(0.00)[209.85.128.46:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.128.46:from]; R_DKIM_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.128.46:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[svn-src-all] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:27:17 -0000 On 18 Nov 2020, at 21:15, Jessica Clarke wrote: >=20 > On 18 Nov 2020, at 19:44, Stefan E=C3=9Fer wrote: >> + /* >> + * Check for some other thread already having=20 >> + * set localbase - this should use atomic ops. >> + * The amount of memory allocated above may leak, >> + * if a parallel update in another thread is not >> + * detected and the non-NULL pointer is overwritten. >> + */ >=20 > Why was this committed with a known racy/leaky implementation? >=20 > What happens if I set the value with a sysctl and call this? Notably, you go to all this trouble to have a localbase variable that gets set, but you never actually use it properly as a cache since you do the full lookup and only then realise that you already had a (possibly stale) value cached. Jess From owner-svn-src-all@freebsd.org Wed Nov 18 21:40:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D544472F06; Wed, 18 Nov 2020 21:40:22 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 4Cbx7B0PWKz4h7p; Wed, 18 Nov 2020 21:40:21 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x32b.google.com with SMTP id s13so4106531wmh.4; Wed, 18 Nov 2020 13:40:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6FoiPQVafvvEdoMEiwZTYAY5/6nHgYTJJWVZ5tK7aUs=; b=WQnWYUp/s/c3l7lkERYX8CizTIOEiU5gyq7EF0Ia0DGdKzM5ntUomGR1UEb4wu8VMK 2QI3ma2Ku1uC+qFig/4W34Qomn/72dn+lZdDjMf6Qz076iAFpQde+Gfk48qgVX50RoD9 9L8nkBTHnYpMbj1eaubQ+kLMtV+k6dY+1B+mbScqplMnGnew+Un8eLAcCUe3UjNpiRxK P5NRgElKoVCh/H+coJRav/WUwBpqPZd1EyGC3Yuc5+CXs9X+Z9pI1fm4tjjXb5XoXnwt dPX9S5C6mw/nbRuGwgJYoutyfL+E2USkZchoBWwpQUSYyu35zCGrYYeNJlQS1+Bez800 uTBw== 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:content-transfer-encoding; bh=6FoiPQVafvvEdoMEiwZTYAY5/6nHgYTJJWVZ5tK7aUs=; b=uWou1AC1XRlMs0zTSTjw7q1Bw7mgkYKsuLuVJfSJI9FUYlAscgXfwU2jqjnZvzYUCi pNbt+U8MQKRWk5Sk0/GDdTpv3hu1cMJdi+D6xp8deENPV+oIGW5/j30sUzJciBMAGc2D Kgfllb7addEL69tbH9wRaKPmBZLKWdxc8lFk/ZrDxEqo8T2wVrzXCclugAgZAQYx6JQd 8lNUPVhovLGA9ToM8rrJNN8Gm/EUBEpbS35LiAEPANIg5SL3dtelHMNWIhUkal47DlPN cviRbA7a7BaFlKTwsYbHKsLA8n8NLzfJC31zuNNvIswOKcwbPnT2QP+2abZPlKtoK6jH GTqw== X-Gm-Message-State: AOAM530pkP6uXNWOgpS9DE2fPSeD56A5KkwqK/alM6WsbeF6d1oIMjJG GeZ+Do9A+sUF476sYgpqajAZad6jPnrf9vfBcGgPVxs6HbE= X-Google-Smtp-Source: ABdhPJy3iwixSjNlNxW0u5HkplMwTSpA8rIHRA38YNgSbNW/G0MP/jMS6EsH1AF0JLfKOeZXvvsvHDqI5EzLcSbkkD8= X-Received: by 2002:a05:600c:2110:: with SMTP id u16mr1104677wml.178.1605735619562; Wed, 18 Nov 2020 13:40:19 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Wed, 18 Nov 2020 13:40:18 -0800 (PST) In-Reply-To: <202011181944.0AIJiUU3003699@repo.freebsd.org> References: <202011181944.0AIJiUU3003699@repo.freebsd.org> From: Mateusz Guzik Date: Wed, 18 Nov 2020 22:40:18 +0100 Message-ID: Subject: Re: svn commit: r367813 - head/lib/libutil To: =?UTF-8?B?U3RlZmFuIEXDn2Vy?= Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4Cbx7B0PWKz4h7p X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:40:22 -0000 On 11/18/20, Stefan E=C3=9Fer wrote: > Author: se > Date: Wed Nov 18 19:44:30 2020 > New Revision: 367813 > URL: https://svnweb.freebsd.org/changeset/base/367813 > > Log: > Add function getlocalbase() to libutil. > > This function returns the path to the local software base directory, by > default "/usr/local" (or the value of _PATH_LOCALBASE in include/paths.= h > when building the world). > > The value returned can be overridden by 2 methods: > > - the LOCALBASE environment variable (ignored by SUID programs) > - else a non-default user.localbase sysctl value > > Reviewed by: hps (earlier version) > Relnotes: yes > Differential Revision: https://reviews.freebsd.org/D27236 > > Added: > head/lib/libutil/getlocalbase.3 (contents, props changed) > head/lib/libutil/getlocalbase.c (contents, props changed) > Modified: > head/lib/libutil/Makefile > head/lib/libutil/libutil.h > > Modified: head/lib/libutil/Makefile > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libutil/Makefile Wed Nov 18 19:35:30 2020 (r367812) > +++ head/lib/libutil/Makefile Wed Nov 18 19:44:30 2020 (r367813) > @@ -12,7 +12,8 @@ PACKAGE=3D runtime > LIB=3D util > SHLIB_MAJOR=3D 9 > > -SRCS=3D _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_uti= l.c > \ > +SRCS=3D _secure_path.c auth.c expand_number.c flopen.c fparseln.c \ > + getlocalbase.c gr_util.c \ > hexdump.c humanize_number.c kinfo_getfile.c \ > kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ > kinfo_getvmobject.c kld.c \ > @@ -30,7 +31,7 @@ CFLAGS+=3D -DINET6 > > CFLAGS+=3D -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ > > -MAN+=3D expand_number.3 flopen.3 fparseln.3 hexdump.3 \ > +MAN+=3D expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \ > humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ > kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ > login_auth.3 login_cap.3 \ > > Added: head/lib/libutil/getlocalbase.3 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/lib/libutil/getlocalbase.3 Wed Nov 18 19:44:30 2020 (r367813) > @@ -0,0 +1,99 @@ > +.\" > +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD > +.\" > +.\" Copyright 2020 Scott Long > +.\" Copyright 2020 Stefan E=C3=9Fer > +.\" > +.\" 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 t= he > +.\" documentation and/or other materials provided with the > distribution. > +.\" > +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' A= ND > +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH= E > +.\" 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 AN= Y > WAY > +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY = OF > +.\" SUCH DAMAGE. > +.\" > +.\" $FreeBSD$ > +.\" > +.Dd November 18, 2020 > +.Dt GETLOCALBASE 3 > +.Os > +.Sh NAME > +.Nm getlocalbase > +.Nd "return the path to the local software directory" > +.Sh LIBRARY > +.Lb libutil > +.Sh SYNOPSIS > +.In libutil.h > +.Ft const char* > +.Fn getlocalbase "void" > +.Sh DESCRIPTION > +The > +.Fn getlocalbase > +function returns the path to the local software base directory. > +Normally this is the > +.Pa /usr/local > +directory. > +First the > +.Ev LOCALBASE > +environment variable is checked. > +If that does not exist then the > +.Va user.localbase > +sysctl is checked. > +If that also does not exist then the value of the > +.Dv _PATH_LOCALBASE > +compile-time variable is used. > +If that is undefined then the default of > +.Pa /usr/local > +is used. > +.Pp > +The value returned by the > +.Fn getlocalbase > +function shall not be modified. > +.Sh IMPLEMENTATION NOTES > +Calls to > +.Fn getlocalbase > +will perform a setugid check on the running binary before checking the > +environment. > +.Sh RETURN VALUES > +The > +.Fn getlocalbase > +function always succeeds and returns a pointer to a string, whose length > +may exceed MAXPATHLEN if it has been derived from the environment variab= le > +LOCALBASE. > +No length checks are performed on the result. > +.Sh ENVIRONMENT > +The > +.Fn getlocalbase > +library function retrieves the > +.Ev LOCALBASE > +environment variable. > +.Sh ERRORS > +The > +.Fn getlocalbase > +function always succeeds. > +.Sh SEE ALSO > +.Xr env 1 , > +.Xr src.conf 5 , > +.Xr sysctl 8 > +.Sh HISTORY > +The > +.Nm > +library function first appeared in > +.Fx 13.0 . > +.Sh AUTHORS > +This > +manual page was written by > +.An Scott Long Aq Mt scottl@FreeBSD.org and Stefan E=C3=9Fer Aq Mt > se@FreeBSD.org . > > Added: head/lib/libutil/getlocalbase.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/lib/libutil/getlocalbase.c Wed Nov 18 19:44:30 2020 (r367813) > @@ -0,0 +1,74 @@ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause > + * > + * Copyright 2020 Stefan E=C3=9Fer > + * > + * 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 th= e > + * documentation and/or other materials provided with the distributio= n. > + * > + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' A= ND > + * 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 GOO= DS > + * 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 O= F > + * SUCH DAMAGE. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#ifndef _PATH_LOCALBASE > +#define _PATH_LOCALBASE "/usr/local" > +#endif > + > +const char * > +getlocalbase(void) > +{ > + static const int localbase_oid[2] =3D {CTL_USER, USER_LOCALBASE}; There is no use for this to be static. > + char *tmppath; > + size_t tmplen; > + static const char *localbase =3D NULL; > + > + if (issetugid() =3D=3D 0) { > + tmppath =3D getenv("LOCALBASE"); > + if (tmppath !=3D NULL && tmppath[0] !=3D '\0') > + return (tmppath); > + } > + if (sysctl(localbase_oid, 2, NULL, &tmplen, NULL, 0) =3D=3D 0 && > + (tmppath =3D malloc(tmplen)) !=3D NULL && > + sysctl(localbase_oid, 2, tmppath, &tmplen, NULL, 0) =3D=3D 0) { Apart from the concurrency issue mentioned in the comment this is just very wasteful. Instead you can have a small local buffer, say 128 bytes and pass that to be populated. The sysctl handler than can populate that and return an error if the size is too small. I don't know if sysclt api allows it to return the set size as it is. Worst case you can just retry with a bigger malloced buffer. Once you get the result you can malloc a buffer and atomic_cmpset_rel_ptr localbase to point to it. If this fails, another thread got the result, you free your buffer and return (localbase). Also the kernel counter part completely unnecessarily comes with a static 1KB buffer to hold what typically is going to be nothing. This should also be allocated as needed. Worst case you can add a trivial lock around it. > + /* > + * Check for some other thread already having > + * set localbase - this should use atomic ops. > + * The amount of memory allocated above may leak, > + * if a parallel update in another thread is not > + * detected and the non-NULL pointer is overwritten. > + */ > + if (tmppath[0] !=3D '\0' && > + (volatile const char*)localbase =3D=3D NULL) > + localbase =3D tmppath; > + else > + free((void*)tmppath); > + return (localbase); > + } > + return (_PATH_LOCALBASE); > +} > > Modified: head/lib/libutil/libutil.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libutil/libutil.h Wed Nov 18 19:35:30 2020 (r367812) > +++ head/lib/libutil/libutil.h Wed Nov 18 19:44:30 2020 (r367813) > @@ -98,6 +98,8 @@ int flopen(const char *_path, int _flags, ...); > int flopenat(int _dirfd, const char *_path, int _flags, ...); > int forkpty(int *_amaster, char *_name, > struct termios *_termp, struct winsize *_winp); > +const char * > + getlocalbase(void); > void hexdump(const void *_ptr, int _length, const char *_hdr, int _flags= ); > int humanize_number(char *_buf, size_t _len, int64_t _number, > const char *_suffix, int _scale, int _flags); > --=20 Mateusz Guzik From owner-svn-src-all@freebsd.org Wed Nov 18 21:46:44 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83C224730C5 for ; Wed, 18 Nov 2020 21:46:44 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 4CbxGX366hz4jBR for ; Wed, 18 Nov 2020 21:46:44 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f42.google.com with SMTP id a3so4154170wmb.5 for ; Wed, 18 Nov 2020 13:46:44 -0800 (PST) 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=sXfnZOYf5c21NAfoV0Jp0YCOfGUY++5NdASbcbP3Lzs=; b=hN9xrIZg3tU27gBRuFK1mjzB1X147T5HsZAJYIQDmE6QJ1xgfZz4TISZomEb4J0e/5 D/flfomPSHSWGASqSEHSvRNfif9MpxqtembUicQp5QNOBmy5DGUB6PH2SPxoGmynkI+H B0+RiHJrlo4M+Di8uSt28o2BJH8AK5WiuWRhS+Cu5/fjTgT12DOluKbIF+UTKr39F64R 37OSoXPhpnveudP+8HHAYoprujGNMrBlmKmXDEFJPgGmix9YgkkqbaoOyeMlVVww2tgC YLdqIR0RzS0kcdZIy01TdG2znF3tume/yWRODv+W55/nJynM4VNq/Xq9iY1W7ELHAT8M QITw== X-Gm-Message-State: AOAM533NNTIgCFS/cCweXNQTqbJ/TmbUQlDQlHiqmFSnr0JUZ0RoKow3 mmdk2sQx1PmOqqIHZlFEcuCM2Q== X-Google-Smtp-Source: ABdhPJwO9/mfSiOEMvOhLb6OYPb/CyFQVmHclImjah/ZoYFpBLFiT3Z/cBqOVb5hGAyov/lJJ4ukqw== X-Received: by 2002:a1c:1b12:: with SMTP id b18mr1122274wmb.119.1605736002930; Wed, 18 Nov 2020 13:46:42 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id s202sm5463500wme.39.2020.11.18.13.46.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2020 13:46:42 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367813 - head/lib/libutil From: Jessica Clarke In-Reply-To: Date: Wed, 18 Nov 2020 21:46:41 +0000 Cc: =?utf-8?Q?Stefan_E=C3=9Fer?= , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011181944.0AIJiUU3003699@repo.freebsd.org> To: Mateusz Guzik X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CbxGX366hz4jBR X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:46:44 -0000 On 18 Nov 2020, at 21:40, Mateusz Guzik wrote: >=20 > On 11/18/20, Stefan E=C3=9Fer wrote: >> Author: se >> Date: Wed Nov 18 19:44:30 2020 >> New Revision: 367813 >> URL: https://svnweb.freebsd.org/changeset/base/367813 >>=20 >> Log: >> Add function getlocalbase() to libutil. >>=20 >> This function returns the path to the local software base directory, = by >> default "/usr/local" (or the value of _PATH_LOCALBASE in = include/paths.h >> when building the world). >>=20 >> The value returned can be overridden by 2 methods: >>=20 >> - the LOCALBASE environment variable (ignored by SUID programs) >> - else a non-default user.localbase sysctl value >>=20 >> Reviewed by: hps (earlier version) >> Relnotes: yes >> Differential Revision: https://reviews.freebsd.org/D27236 >>=20 >> Added: >> head/lib/libutil/getlocalbase.3 (contents, props changed) >> head/lib/libutil/getlocalbase.c (contents, props changed) >> Modified: >> head/lib/libutil/Makefile >> head/lib/libutil/libutil.h >>=20 >> Modified: head/lib/libutil/Makefile >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/lib/libutil/Makefile Wed Nov 18 19:35:30 2020 = (r367812) >> +++ head/lib/libutil/Makefile Wed Nov 18 19:44:30 2020 = (r367813) >> @@ -12,7 +12,8 @@ PACKAGE=3D runtime >> LIB=3D util >> SHLIB_MAJOR=3D 9 >>=20 >> -SRCS=3D _secure_path.c auth.c expand_number.c flopen.c = fparseln.c gr_util.c >> \ >> +SRCS=3D _secure_path.c auth.c expand_number.c flopen.c = fparseln.c \ >> + getlocalbase.c gr_util.c \ >> hexdump.c humanize_number.c kinfo_getfile.c \ >> kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ >> kinfo_getvmobject.c kld.c \ >> @@ -30,7 +31,7 @@ CFLAGS+=3D -DINET6 >>=20 >> CFLAGS+=3D -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ >>=20 >> -MAN+=3D expand_number.3 flopen.3 fparseln.3 hexdump.3 \ >> +MAN+=3D expand_number.3 flopen.3 fparseln.3 getlocalbase.3 = hexdump.3 \ >> humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ >> kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ >> login_auth.3 login_cap.3 \ >>=20 >> Added: head/lib/libutil/getlocalbase.3 >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- /dev/null 00:00:00 1970 (empty, because file is newly = added) >> +++ head/lib/libutil/getlocalbase.3 Wed Nov 18 19:44:30 2020 = (r367813) >> @@ -0,0 +1,99 @@ >> +.\" >> +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD >> +.\" >> +.\" Copyright 2020 Scott Long >> +.\" Copyright 2020 Stefan E=C3=9Fer >> +.\" >> +.\" Redistribution and use in source and binary forms, with or = without >> +.\" modification, are permitted provided that the following = conditions >> +.\" are met: >> +.\" 1. Redistributions of source code must retain the above = copyright >> +.\" notice, this list of conditions and the following disclaimer. >> +.\" 2. Redistributions in binary form must reproduce the above = copyright >> +.\" notice, this list of conditions and the following disclaimer = in the >> +.\" documentation and/or other materials provided with the >> distribution. >> +.\" >> +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS = IS'' AND >> +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED = TO, THE >> +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A = PARTICULAR >> PURPOSE >> +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE >> LIABLE >> +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> CONSEQUENTIAL >> +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF = SUBSTITUTE >> GOODS >> +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS = INTERRUPTION) >> +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN = CONTRACT, >> STRICT >> +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING = IN ANY >> WAY >> +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE = POSSIBILITY OF >> +.\" SUCH DAMAGE. >> +.\" >> +.\" $FreeBSD$ >> +.\" >> +.Dd November 18, 2020 >> +.Dt GETLOCALBASE 3 >> +.Os >> +.Sh NAME >> +.Nm getlocalbase >> +.Nd "return the path to the local software directory" >> +.Sh LIBRARY >> +.Lb libutil >> +.Sh SYNOPSIS >> +.In libutil.h >> +.Ft const char* >> +.Fn getlocalbase "void" >> +.Sh DESCRIPTION >> +The >> +.Fn getlocalbase >> +function returns the path to the local software base directory. >> +Normally this is the >> +.Pa /usr/local >> +directory. >> +First the >> +.Ev LOCALBASE >> +environment variable is checked. >> +If that does not exist then the >> +.Va user.localbase >> +sysctl is checked. >> +If that also does not exist then the value of the >> +.Dv _PATH_LOCALBASE >> +compile-time variable is used. >> +If that is undefined then the default of >> +.Pa /usr/local >> +is used. >> +.Pp >> +The value returned by the >> +.Fn getlocalbase >> +function shall not be modified. >> +.Sh IMPLEMENTATION NOTES >> +Calls to >> +.Fn getlocalbase >> +will perform a setugid check on the running binary before checking = the >> +environment. >> +.Sh RETURN VALUES >> +The >> +.Fn getlocalbase >> +function always succeeds and returns a pointer to a string, whose = length >> +may exceed MAXPATHLEN if it has been derived from the environment = variable >> +LOCALBASE. >> +No length checks are performed on the result. >> +.Sh ENVIRONMENT >> +The >> +.Fn getlocalbase >> +library function retrieves the >> +.Ev LOCALBASE >> +environment variable. >> +.Sh ERRORS >> +The >> +.Fn getlocalbase >> +function always succeeds. >> +.Sh SEE ALSO >> +.Xr env 1 , >> +.Xr src.conf 5 , >> +.Xr sysctl 8 >> +.Sh HISTORY >> +The >> +.Nm >> +library function first appeared in >> +.Fx 13.0 . >> +.Sh AUTHORS >> +This >> +manual page was written by >> +.An Scott Long Aq Mt scottl@FreeBSD.org and Stefan E=C3=9Fer Aq Mt >> se@FreeBSD.org . >>=20 >> Added: head/lib/libutil/getlocalbase.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- /dev/null 00:00:00 1970 (empty, because file is newly = added) >> +++ head/lib/libutil/getlocalbase.c Wed Nov 18 19:44:30 2020 = (r367813) >> @@ -0,0 +1,74 @@ >> +/*- >> + * SPDX-License-Identifier: BSD-2-Clause >> + * >> + * Copyright 2020 Stefan E=C3=9Fer >> + * >> + * Redistribution and use in source and binary forms, with or = without >> + * modification, are permitted provided that the following = conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above = copyright >> + * notice, this list of conditions and the following disclaimer = in the >> + * documentation and/or other materials provided with the = distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS = IS'' AND >> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, = THE >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A = PARTICULAR >> PURPOSE >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE >> LIABLE >> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> CONSEQUENTIAL >> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE = GOODS >> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS = INTERRUPTION) >> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN = CONTRACT, >> STRICT >> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN = ANY >> WAY >> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE = POSSIBILITY OF >> + * SUCH DAMAGE. >> + */ >> + >> +#include >> +__FBSDID("$FreeBSD$"); >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#ifndef _PATH_LOCALBASE >> +#define _PATH_LOCALBASE "/usr/local" >> +#endif >> + >> +const char * >> +getlocalbase(void) >> +{ >> + static const int localbase_oid[2] =3D {CTL_USER, = USER_LOCALBASE}; >=20 > There is no use for this to be static. >=20 >> + char *tmppath; >> + size_t tmplen; >> + static const char *localbase =3D NULL; >> + >> + if (issetugid() =3D=3D 0) { >> + tmppath =3D getenv("LOCALBASE"); >> + if (tmppath !=3D NULL && tmppath[0] !=3D '\0') >> + return (tmppath); >> + } >> + if (sysctl(localbase_oid, 2, NULL, &tmplen, NULL, 0) =3D=3D 0 && >> + (tmppath =3D malloc(tmplen)) !=3D NULL && >> + sysctl(localbase_oid, 2, tmppath, &tmplen, NULL, 0) =3D=3D = 0) { >=20 > Apart from the concurrency issue mentioned in the comment this is just > very wasteful. Instead you can have a small local buffer, say 128 > bytes and pass that to be populated. The sysctl handler than can > populate that and return an error if the size is too small. I don't > know if sysclt api allows it to return the set size as it is. Worst > case you can just retry with a bigger malloced buffer. >=20 > Once you get the result you can malloc a buffer and > atomic_cmpset_rel_ptr localbase to point to it. If this fails, another > thread got the result, you free your buffer and return (localbase). That would still need to be an acquire load (if using C11 atomics, technically consume is fine, but in practice is no more efficient). Jess From owner-svn-src-all@freebsd.org Wed Nov 18 21:52:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B943473517; Wed, 18 Nov 2020 21:52:49 +0000 (UTC) (envelope-from se@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbxPY1zlMz4js9; Wed, 18 Nov 2020 21:52:49 +0000 (UTC) (envelope-from se@freebsd.org) Received: from Stefans-MBP-WLAN.fritz.box (p200300cd5f3b88002402e588537088de.dip0.t-ipconnect.de [IPv6:2003:cd:5f3b:8800:2402:e588:5370:88de]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 9595F2C7C2; Wed, 18 Nov 2020 21:52:48 +0000 (UTC) (envelope-from se@freebsd.org) To: Jessica Clarke Cc: src-committers , svn-src-all , svn-src-head@freebsd.org References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> From: Stefan Esser Subject: Re: svn commit: r367813 - head/lib/libutil Message-ID: <92a87ed8-4b22-4d03-9481-b02f92dcaaa0@freebsd.org> Date: Wed, 18 Nov 2020 22:52:45 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CiFDVtct0WzIbzaXzTqH2tzXmzhIreK1E" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 21:52:49 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CiFDVtct0WzIbzaXzTqH2tzXmzhIreK1E Content-Type: multipart/mixed; boundary="bMrkz2KlwWJC6Iq4vIixFPeZAagHYNYR2"; protected-headers="v1" From: Stefan Esser To: Jessica Clarke Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Message-ID: <92a87ed8-4b22-4d03-9481-b02f92dcaaa0@freebsd.org> Subject: Re: svn commit: r367813 - head/lib/libutil References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> In-Reply-To: <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> --bMrkz2KlwWJC6Iq4vIixFPeZAagHYNYR2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Am 18.11.20 um 22:15 schrieb Jessica Clarke: > On 18 Nov 2020, at 19:44, Stefan E=C3=9Fer wrote: >> + /* >> + * Check for some other thread already having >> + * set localbase - this should use atomic ops. >> + * The amount of memory allocated above may leak, >> + * if a parallel update in another thread is not >> + * detected and the non-NULL pointer is overwritten. >> + */ >=20 > Why was this committed with a known racy/leaky implementation? Because the alternatives that I offered for discussion were less acceptable. > What happens if I set the value with a sysctl and call this? You'll get the value set with sysctl, unless overridden by the environment variable. There is a window of a few nano-seconds where a thread executing in parallel on another core might be able to set the localbase variable (between the test for NULL in this function and the assignment to it). The value that will be returned by either thread will be identical, so there is no risk of corruption of the result. This unlikely case may actually leak a heap allocated string of typically tens of bytes (but with negligible probability). But this really is a non-issue, since there should never be a reason to invoke this function in a multi-threaded context. The result should be constant for the duration of execution of the process (expect severe inconsistencies if that was not the case) and all programs in base that are candidates for the use of this function are non-threaded (and if they were multi- threaded, then I'd expect this call to occur during start-up of the program before any further threads are created). So, this is a non-issue and the comment tries to explain it. Did I fail to make this clear in the comment? Maybe I should have written "could use atomic ops" instead? Use of atomics or locks could prevent the race-condition. But since I do not expect this function to be called from within threads (it just doesn't make sense), the tiny time window of a few nano-seconds which might lead to a double assignment to the target variable (with one pointer value being lost), and the worst case loss of 1KB of heap space in that case (more likely 10 to 20 bytes rounded up to a 16 or 32 byte chunk), I do not consider the complexities of either a lock or atomic ops to be justified. Regards, STefan --bMrkz2KlwWJC6Iq4vIixFPeZAagHYNYR2-- --CiFDVtct0WzIbzaXzTqH2tzXmzhIreK1E Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAl+1l60FAwAAAAAACgkQR+u171r99UT2 sQf9Hsal77Y3ZKWZj6rSm3lWzux2NDffFfSREpb+KPjetq2GHicAkG9jUQWal7TsqzTZvvYocx2j hiexE2qlyVhSyQ82VDgsNshVEYgZUhP0MsNyFdZt+xHfWeWdfaHDSSMZ0JRjGOt2/UkfdzAGPBkz /WUQ9Dc86ANY0SEYuG/RmBmhhV1JcwtDIAI637BWJwZwhwYB7AWlKdUBnaQ7MsRepLfNil9Gf+BU unFZWFutsDMR4fitw2odTJiF/f8AOv2hBAkhZHF8khHfEJdjo8vrCUzTxb7FCM+sscmwy8G5gBKx xNuOt1MHrTzeVy3MuGQboKvs7INEUXsccIFopwDiew== =4vAC -----END PGP SIGNATURE----- --CiFDVtct0WzIbzaXzTqH2tzXmzhIreK1E-- From owner-svn-src-all@freebsd.org Wed Nov 18 22:01:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CC54473808; Wed, 18 Nov 2020 22:01:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbxbg2F1Fz4kCh; Wed, 18 Nov 2020 22:01:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 357AA18DF6; Wed, 18 Nov 2020 22:01:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIM1ZTu089309; Wed, 18 Nov 2020 22:01:35 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIM1Y9E089305; Wed, 18 Nov 2020 22:01:34 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202011182201.0AIM1Y9E089305@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 18 Nov 2020 22:01:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367821 - head/lib/libc/string X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/lib/libc/string X-SVN-Commit-Revision: 367821 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 22:01:35 -0000 Author: emaste Date: Wed Nov 18 22:01:34 2020 New Revision: 367821 URL: https://svnweb.freebsd.org/changeset/base/367821 Log: clang-format libc string functions imported from musl We have adopted these and don't consider them 'contrib' code, so bring them closer to style(9). This is a followon to r315467 and r351700. MFC after: 1 week Sponsored by: The FreeBSD Foundation Modified: head/lib/libc/string/memchr.c head/lib/libc/string/memmem.c head/lib/libc/string/strstr.c Modified: head/lib/libc/string/memchr.c ============================================================================== --- head/lib/libc/string/memchr.c Wed Nov 18 21:26:14 2020 (r367820) +++ head/lib/libc/string/memchr.c Wed Nov 18 22:01:34 2020 (r367821) @@ -25,30 +25,35 @@ #include __FBSDID("$FreeBSD$"); -#include -#include #include +#include +#include #define SS (sizeof(size_t)) -#define ALIGN (sizeof(size_t)-1) -#define ONES ((size_t)-1/UCHAR_MAX) -#define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS) +#define ALIGN (sizeof(size_t) - 1) +#define ONES ((size_t)-1 / UCHAR_MAX) +#define HIGHS (ONES * (UCHAR_MAX / 2 + 1)) +#define HASZERO(x) (((x)-ONES) & ~(x)&HIGHS) -void *memchr(const void *src, int c, size_t n) +void * +memchr(const void *src, int c, size_t n) { const unsigned char *s = src; c = (unsigned char)c; #ifdef __GNUC__ - for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--); + for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--) + ; if (n && *s != c) { typedef size_t __attribute__((__may_alias__)) word; const word *w; size_t k = ONES * c; - for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS); + for (w = (const void *)s; n >= SS && !HASZERO(*w ^ k); + w++, n -= SS) + ; s = (const void *)w; } #endif - for (; n && *s != c; s++, n--); + for (; n && *s != c; s++, n--) + ; return n ? (void *)s : 0; } Modified: head/lib/libc/string/memmem.c ============================================================================== --- head/lib/libc/string/memmem.c Wed Nov 18 21:26:14 2020 (r367820) +++ head/lib/libc/string/memmem.c Wed Nov 18 22:01:34 2020 (r367821) @@ -25,40 +25,47 @@ #include __FBSDID("$FreeBSD$"); -#include #include +#include -static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +static char * +twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { - uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; - for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) - if (hw == nw) return (char *)h-2; - return hw == nw ? (char *)h-2 : 0; + uint16_t nw = n[0] << 8 | n[1], hw = h[0] << 8 | h[1]; + for (h += 2, k -= 2; k; k--, hw = hw << 8 | *h++) + if (hw == nw) + return (char *)h - 2; + return hw == nw ? (char *)h - 2 : 0; } -static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +static char * +threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; - for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) - if (hw == nw) return (char *)h-3; - return hw == nw ? (char *)h-3 : 0; + uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8; + uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8; + for (h += 3, k -= 3; k; k--, hw = (hw | *h++) << 8) + if (hw == nw) + return (char *)h - 3; + return hw == nw ? (char *)h - 3 : 0; } -static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) +static char * +fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; - for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) - if (hw == nw) return (char *)h-4; - return hw == nw ? (char *)h-4 : 0; + uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; + uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; + for (h += 4, k -= 4; k; k--, hw = hw << 8 | *h++) + if (hw == nw) + return (char *)h - 4; + return hw == nw ? (char *)h - 4 : 0; } -#define MAX(a,b) ((a)>(b)?(a):(b)) -#define MIN(a,b) ((a)<(b)?(a):(b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define BITOP(a,b,op) \ - ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) +#define BITOP(a, b, op) \ + ((a)[(size_t)(b) / (8 * sizeof *(a))] op \ + (size_t)1 << ((size_t)(b) % (8 * sizeof *(a)))) /* * Two Way string search algorithm, with a bad shift table applied to the last @@ -68,25 +75,30 @@ static char *fourbyte_memmem(const unsigned char *h, s * Reference: CROCHEMORE M., PERRIN D., 1991, Two-way string-matching, * Journal of the ACM 38(3):651-675 */ -static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const unsigned char *n, size_t l) +static char * +twoway_memmem(const unsigned char *h, const unsigned char *z, + const unsigned char *n, size_t l) { size_t i, ip, jp, k, p, ms, p0, mem, mem0; size_t byteset[32 / sizeof(size_t)] = { 0 }; size_t shift[256]; /* Computing length of needle and fill shift table */ - for (i=0; i n[jp+k]) { + } else + k++; + } else if (n[ip + k] > n[jp + k]) { jp += k; k = 1; p = jp - ip; @@ -99,14 +111,17 @@ static char *twoway_memmem(const unsigned char *h, con p0 = p; /* And with the opposite comparison */ - ip = -1; jp = 0; k = p = 1; - while (jp+k ms+1) ms = ip; - else p = p0; + if (ip + 1 > ms + 1) + ms = ip; + else + p = p0; /* Periodic needle? */ - if (memcmp(n, n+p, ms+1)) { + if (memcmp(n, n + p, ms + 1)) { mem0 = 0; - p = MAX(ms, l-ms-1) + 1; - } else mem0 = l-p; + p = MAX(ms, l - ms - 1) + 1; + } else + mem0 = l - p; mem = 0; /* Search loop */ for (;;) { /* If remainder of haystack is shorter than needle, done */ - if (z-h < l) return 0; + if (z - h < l) + return 0; /* Check last byte first; advance by shift on mismatch */ - if (BITOP(byteset, h[l-1], &)) { - k = l-shift[h[l-1]]; + if (BITOP(byteset, h[l - 1], &)) { + k = l - shift[h[l - 1]]; if (k) { - if (mem0 && mem && k < p) k = l-p; + if (mem0 && mem && k < p) + k = l - p; h += k; mem = 0; continue; @@ -146,38 +166,49 @@ static char *twoway_memmem(const unsigned char *h, con } /* Compare right half */ - for (k=MAX(ms+1,mem); kmem && n[k-1] == h[k-1]; k--); - if (k <= mem) return (char *)h; + for (k = ms + 1; k > mem && n[k - 1] == h[k - 1]; k--) + ; + if (k <= mem) + return (char *)h; h += p; mem = mem0; } } -void *memmem(const void *h0, size_t k, const void *n0, size_t l) +void * +memmem(const void *h0, size_t k, const void *n0, size_t l) { const unsigned char *h = h0, *n = n0; /* Return immediately on empty needle */ - if (!l) return (void *)h; + if (!l) + return (void *)h; /* Return immediately when needle is longer than haystack */ - if (k __FBSDID("$FreeBSD$"); -#include #include +#include -static char *twobyte_strstr(const unsigned char *h, const unsigned char *n) +static char * +twobyte_strstr(const unsigned char *h, const unsigned char *n) { - uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; - for (h++; *h && hw != nw; hw = hw<<8 | *++h); - return *h ? (char *)h-1 : 0; + uint16_t nw = n[0] << 8 | n[1], hw = h[0] << 8 | h[1]; + for (h++; *h && hw != nw; hw = hw << 8 | *++h) + ; + return *h ? (char *)h - 1 : 0; } -static char *threebyte_strstr(const unsigned char *h, const unsigned char *n) +static char * +threebyte_strstr(const unsigned char *h, const unsigned char *n) { - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; - for (h+=2; *h && hw != nw; hw = (hw|*++h)<<8); - return *h ? (char *)h-2 : 0; + uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8; + uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8; + for (h += 2; *h && hw != nw; hw = (hw | *++h) << 8) + ; + return *h ? (char *)h - 2 : 0; } -static char *fourbyte_strstr(const unsigned char *h, const unsigned char *n) +static char * +fourbyte_strstr(const unsigned char *h, const unsigned char *n) { - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; - for (h+=3; *h && hw != nw; hw = hw<<8 | *++h); - return *h ? (char *)h-3 : 0; + uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; + uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; + for (h += 3; *h && hw != nw; hw = hw << 8 | *++h) + ; + return *h ? (char *)h - 3 : 0; } -#define MAX(a,b) ((a)>(b)?(a):(b)) -#define MIN(a,b) ((a)<(b)?(a):(b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define BITOP(a,b,op) \ - ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) +#define BITOP(a, b, op) \ + ((a)[(size_t)(b) / (8 * sizeof *(a))] op \ + (size_t)1 << ((size_t)(b) % (8 * sizeof *(a)))) /* * Two Way string search algorithm, with a bad shift table applied to the last @@ -65,7 +72,8 @@ static char *fourbyte_strstr(const unsigned char *h, c * Reference: CROCHEMORE M., PERRIN D., 1991, Two-way string-matching, * Journal of the ACM 38(3):651-675 */ -static char *twoway_strstr(const unsigned char *h, const unsigned char *n) +static char * +twoway_strstr(const unsigned char *h, const unsigned char *n) { const unsigned char *z; size_t l, ip, jp, k, p, ms, p0, mem, mem0; @@ -73,19 +81,23 @@ static char *twoway_strstr(const unsigned char *h, con size_t shift[256]; /* Computing length of needle and fill shift table */ - for (l=0; n[l] && h[l]; l++) - BITOP(byteset, n[l], |=), shift[n[l]] = l+1; - if (n[l]) return 0; /* hit the end of h */ + for (l = 0; n[l] && h[l]; l++) + BITOP(byteset, n[l], |=), shift[n[l]] = l + 1; + if (n[l]) + return 0; /* hit the end of h */ /* Compute maximal suffix */ - ip = -1; jp = 0; k = p = 1; - while (jp+k n[jp+k]) { + } else + k++; + } else if (n[ip + k] > n[jp + k]) { jp += k; k = 1; p = jp - ip; @@ -98,14 +110,17 @@ static char *twoway_strstr(const unsigned char *h, con p0 = p; /* And with the opposite comparison */ - ip = -1; jp = 0; k = p = 1; - while (jp+k ms+1) ms = ip; - else p = p0; + if (ip + 1 > ms + 1) + ms = ip; + else + p = p0; /* Periodic needle? */ - if (memcmp(n, n+p, ms+1)) { + if (memcmp(n, n + p, ms + 1)) { mem0 = 0; - p = MAX(ms, l-ms-1) + 1; - } else mem0 = l-p; + p = MAX(ms, l - ms - 1) + 1; + } else + mem0 = l - p; mem = 0; /* Initialize incremental end-of-haystack pointer */ @@ -130,21 +148,24 @@ static char *twoway_strstr(const unsigned char *h, con /* Search loop */ for (;;) { /* Update incremental end-of-haystack pointer */ - if (z-h < l) { + if (z - h < l) { /* Fast estimate for MIN(l,63) */ size_t grow = l | 63; const unsigned char *z2 = memchr(z, 0, grow); if (z2) { z = z2; - if (z-h < l) return 0; - } else z += grow; + if (z - h < l) + return 0; + } else + z += grow; } /* Check last byte first; advance by shift on mismatch */ - if (BITOP(byteset, h[l-1], &)) { - k = l-shift[h[l-1]]; + if (BITOP(byteset, h[l - 1], &)) { + k = l - shift[h[l - 1]]; if (k) { - if (k < mem) k = mem; + if (k < mem) + k = mem; h += k; mem = 0; continue; @@ -156,34 +177,46 @@ static char *twoway_strstr(const unsigned char *h, con } /* Compare right half */ - for (k=MAX(ms+1,mem); n[k] && n[k] == h[k]; k++); + for (k = MAX(ms + 1, mem); n[k] && n[k] == h[k]; k++) + ; if (n[k]) { - h += k-ms; + h += k - ms; mem = 0; continue; } /* Compare left half */ - for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--); - if (k <= mem) return (char *)h; + for (k = ms + 1; k > mem && n[k - 1] == h[k - 1]; k--) + ; + if (k <= mem) + return (char *)h; h += p; mem = mem0; } } -char *strstr(const char *h, const char *n) +char * +strstr(const char *h, const char *n) { /* Return immediately on empty needle */ - if (!n[0]) return (char *)h; + if (!n[0]) + return (char *)h; /* Use faster algorithms for short needles */ h = strchr(h, *n); - if (!h || !n[1]) return (char *)h; - if (!h[1]) return 0; - if (!n[2]) return twobyte_strstr((void *)h, (void *)n); - if (!h[2]) return 0; - if (!n[3]) return threebyte_strstr((void *)h, (void *)n); - if (!h[3]) return 0; - if (!n[4]) return fourbyte_strstr((void *)h, (void *)n); + if (!h || !n[1]) + return (char *)h; + if (!h[1]) + return 0; + if (!n[2]) + return twobyte_strstr((void *)h, (void *)n); + if (!h[2]) + return 0; + if (!n[3]) + return threebyte_strstr((void *)h, (void *)n); + if (!h[3]) + return 0; + if (!n[4]) + return fourbyte_strstr((void *)h, (void *)n); return twoway_strstr((void *)h, (void *)n); } From owner-svn-src-all@freebsd.org Wed Nov 18 22:11:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E7C24737DC; Wed, 18 Nov 2020 22:11:58 +0000 (UTC) (envelope-from se@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbxqf40Nbz4kl5; Wed, 18 Nov 2020 22:11:58 +0000 (UTC) (envelope-from se@freebsd.org) Received: from Stefans-MBP-WLAN.fritz.box (p200300cd5f3b88002402e588537088de.dip0.t-ipconnect.de [IPv6:2003:cd:5f3b:8800:2402:e588:5370:88de]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id E05352C8BA; Wed, 18 Nov 2020 22:11:57 +0000 (UTC) (envelope-from se@freebsd.org) To: Jessica Clarke Cc: src-committers , svn-src-all , svn-src-head@freebsd.org References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> From: Stefan Esser Subject: Re: svn commit: r367813 - head/lib/libutil Message-ID: <0d844881-b3dd-a448-f33b-8268f40a4c94@freebsd.org> Date: Wed, 18 Nov 2020 23:11:56 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qMYyOR5Qn8FrF2dfMjfRouXT32PvaGURb" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 22:11:58 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qMYyOR5Qn8FrF2dfMjfRouXT32PvaGURb Content-Type: multipart/mixed; boundary="DHNTWTyb9XTzxIjO2X0W29YXL5HHvsDmj"; protected-headers="v1" From: Stefan Esser To: Jessica Clarke Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Message-ID: <0d844881-b3dd-a448-f33b-8268f40a4c94@freebsd.org> Subject: Re: svn commit: r367813 - head/lib/libutil References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> In-Reply-To: --DHNTWTyb9XTzxIjO2X0W29YXL5HHvsDmj Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Am 18.11.20 um 22:27 schrieb Jessica Clarke: > On 18 Nov 2020, at 21:15, Jessica Clarke wrote: >> >> On 18 Nov 2020, at 19:44, Stefan E=C3=9Fer wrote: >>> + /* >>> + * Check for some other thread already having >>> + * set localbase - this should use atomic ops. >>> + * The amount of memory allocated above may leak, >>> + * if a parallel update in another thread is not >>> + * detected and the non-NULL pointer is overwritten. >>> + */ >> >> Why was this committed with a known racy/leaky implementation? >> >> What happens if I set the value with a sysctl and call this? >=20 > Notably, you go to all this trouble to have a localbase variable that > gets set, but you never actually use it properly as a cache since you > do the full lookup and only then realise that you already had a > (possibly stale) value cached. Do you want to suggest a better implementation? As explained in another mail, this case should never happen, since the function is not called in a multi-threaded context and if it was, then the test before the assignment reduces the time window of vulnerability to a few nanoseconds, and if a collision did occur the amount of heap space lost is negligible. Or do you think, that the assignment should directly go to the localbase variable, not to tmppath? That would significantly enlarge the window of vulnerability, and the code that protects against this case (though not perfectly) seems worth it. To give some context (slightly simplified): if (tmppath =3D malloc(tmplen)) !=3D NULL && sysctl(localbase_oid, 2, tmppath, &tmplen, NULL, 0) =3D=3D 0= ) { if (tmppath[0] !=3D '\0' && (volatile const char*)localbase =3D=3D NULL) localbase =3D tmppath; else free((void*)tmppath); return (localbase); If localbase =3D=3D NULL then localbase is set to tmppath, but another co= re could execute exactly the same instructions in the same few nanoseconds. The assignment could also have been marked volatile to force the write to memory, but since this is a library function called from another compile unit and the value is returned into that other context, I think the write will happen immediately, anyway. I know about architectures with non-coherent caches and other issues that could increase the time window, but as said before, I do not expect this function to be called in a multi-threaded context, but thought the protection against a collision in the much larger time window covering the malloc and sysctl system call might still be worth the 1 extra line of code required to go through a stack allocated tmppath instead of directly assigning to localbase. Regards, STefan --DHNTWTyb9XTzxIjO2X0W29YXL5HHvsDmj-- --qMYyOR5Qn8FrF2dfMjfRouXT32PvaGURb Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAl+1nCwFAwAAAAAACgkQR+u171r99UQY EAf/aY0J0wmk2kElUAn4URBTFS3jWv7CRDhBI2l/RwRu3MzN+kIPCzXisBjI5A/JZbbkkw5aGOvX 3vwbrO0Od2McUYRnpe6lMxfiGBDbq9jAsZNFc9T1c3ZgCUpOHon/CP0c6AvKNaZDtNEJy8OFDdOz 7NHpTjW+sEFB/iX/F+TYxXJThzbkiMqf76+DqLhULrNY1qYWV5ZYXSJdh5IJFJd3GcZkLrZoosRv SYDqDOs+TZ1sKPW/tyId+YQjY5hQVwnPRyZkMHz1vlYSmNjIxq+Ui+FWzs8RM+arW9LnpxmiGIQ5 qTt9vKgzGtxkb6O+fhUtHP1A5kyVxjAIzvtUlObouw== =8FYQ -----END PGP SIGNATURE----- --qMYyOR5Qn8FrF2dfMjfRouXT32PvaGURb-- From owner-svn-src-all@freebsd.org Wed Nov 18 22:15:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3124473AB6 for ; Wed, 18 Nov 2020 22:15:02 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 4CbxvB4333z4kx4 for ; Wed, 18 Nov 2020 22:15:02 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f49.google.com with SMTP id a3so4384805wmb.5 for ; Wed, 18 Nov 2020 14:15:02 -0800 (PST) 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=oOQYEIyoPLRaenKexu+jdMHwK667HraHGyVAaSsV7mI=; b=D9V0AqYh37Feaa9NFPwjjhysr0W68SGGw7Tj6hh3FQNhFReLV3zfs3/7PXhPEMMmTy VlUD+3729rOTL4zm2Q2S6xsBh7m19kZRpODjb8rehq7QoxZvXX1IGaoaHE6RPXV7YECB HRhHTK3uFt9PscQ4NNjO2kVUxqAksSDNIy5tnappRtIsnFqszYKqPvUuUz6qJLCF0w6b GanD28xE7P3NWFP4x7tHeu8hF8v9j1qug8TylrDHOE9ltfeSqIoTiVkkd2zznR9mIkUV q23Iy1AVXmZuQ+8lWSQgmWElTsU4syPE5gqKc3Hqi7ebmCT8IQ+I0icjwD35kGO2VmRl MsOA== X-Gm-Message-State: AOAM533tbypG479gVV5p6jJSMBj+tU1W/kWJ0bwhCU2QFnAlDf+1NJTS 2dTsFp3ETOnWhCa3JJynw58pFg== X-Google-Smtp-Source: ABdhPJzULJAYFEyVtXEC1XKbKOo0CWKOJlostwvInbeQriFxcyy1swfd2sY1BF6X5vFbqWrlT7jNlg== X-Received: by 2002:a1c:27c2:: with SMTP id n185mr1261356wmn.102.1605737701073; Wed, 18 Nov 2020 14:15:01 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id f5sm36626242wrg.32.2020.11.18.14.15.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2020 14:15:00 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367813 - head/lib/libutil From: Jessica Clarke In-Reply-To: <92a87ed8-4b22-4d03-9481-b02f92dcaaa0@freebsd.org> Date: Wed, 18 Nov 2020 22:14:59 +0000 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> <92a87ed8-4b22-4d03-9481-b02f92dcaaa0@freebsd.org> To: Stefan Esser X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CbxvB4333z4kx4 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 22:15:02 -0000 On 18 Nov 2020, at 21:52, Stefan Esser wrote: > Am 18.11.20 um 22:15 schrieb Jessica Clarke: >> On 18 Nov 2020, at 19:44, Stefan E=C3=9Fer wrote: >>> + /* >>> + * Check for some other thread already having >>> + * set localbase - this should use atomic ops. >>> + * The amount of memory allocated above may leak, >>> + * if a parallel update in another thread is not >>> + * detected and the non-NULL pointer is overwritten. >>> + */ >> Why was this committed with a known racy/leaky implementation? >=20 > Because the alternatives that I offered for discussion were > less acceptable. That has no bearing over whether this one is. >> What happens if I set the value with a sysctl and call this? >=20 > You'll get the value set with sysctl, unless overridden by the > environment variable. There is a window of a few nano-seconds > where a thread executing in parallel on another core might be > able to set the localbase variable (between the test for NULL > in this function and the assignment to it). The value that will > be returned by either thread will be identical, so there is no > risk of corruption of the result. But if I call getlocalbase, then set it via sysctl, then call getlocalbase again, I see the old value. If, however, I omit the first getlocalbase, I see the new value. This differs from how getenv/setenv of the value work, where you always see the up-to-date value. Maybe you think that's a feature, but it's something to watch out for and explicitly call out in the documentation. You also misunderstand all the subtleties of multithreading here. There are no acquire/release pairs so it is entirely legal for Thread 2 to read Thread 1's initialised value for localbase before the contents of it are visible (i.e. the pointer is initialised but the data is garbage). The `(volatile const char*)localbase` cast is also a complete waste of time. You probably meant to write `(const char * volatile)localbase` but even then that does nothing useful as the cast is too late. What you really were trying to write was `*(const char * volatile *)&localbase`, but you need proper atomics anyway for this to be safe. > This unlikely case may actually leak a heap allocated string > of typically tens of bytes (but with negligible probability). >=20 > But this really is a non-issue, since there should never be a > reason to invoke this function in a multi-threaded context. Why not? There could easily be code out there calling getenv in a multi-threaded context so this is inadequate as a replacement. Yes it's inefficient but it's perfectly legal and imaginable. Also if malloc returns NULL I would quite like that to be an error for the function and not silently fall back on _PATH_LOCALBASE. > The result should be constant for the duration of execution > of the process (expect severe inconsistencies if that was not > the case) and all programs in base that are candidates for the > use of this function are non-threaded (and if they were multi- > threaded, then I'd expect this call to occur during start-up > of the program before any further threads are created). >=20 > So, this is a non-issue and the comment tries to explain it. > Did I fail to make this clear in the comment? Maybe I should > have written "could use atomic ops" instead? >=20 > Use of atomics or locks could prevent the race-condition. But > since I do not expect this function to be called from within > threads (it just doesn't make sense), the tiny time window of > a few nano-seconds which might lead to a double assignment to > the target variable (with one pointer value being lost), and > the worst case loss of 1KB of heap space in that case (more > likely 10 to 20 bytes rounded up to a 16 or 32 byte chunk), I > do not consider the complexities of either a lock or atomic ops > to be justified. >=20 > Regards, STefan >=20 From owner-svn-src-all@freebsd.org Wed Nov 18 22:16:38 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4005F473A33; Wed, 18 Nov 2020 22:16:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 4Cbxx039W2z4l3X; Wed, 18 Nov 2020 22:16:36 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x435.google.com with SMTP id u12so4031881wrt.0; Wed, 18 Nov 2020 14:16:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DolZsmvjrJyFalP6idbAlKkRI3OBSv0+f02qDDcVYkY=; b=mD9qOcZHrRgoPGE2Gv0rC83eB4M7ohpP+Cy41b6zZb5uL0fhbOayNr3sOaC8z95ZSV Rbiv+NZ1RosxXZlQZ6IUnrgF+m8A3lpMVntLHhp1ZwuuP7xYq0AxnOT7vyLDDptW47Xd YYcdQzr01yoL0e7ZXSdK5TFD4SiEaHVutkwelBw+7cKDtSfRTOdBAQiIDA8aaIPEX7jw gHT2IZ+gcTqJkAwwp6RR3vSiIGWO/uI7X6za1L1IwMHpdYekzZ/7i2W8sHifclRf7xAv lL2UxLnXR6id73usxRPj3W9rpMcEBmIece4SP3xj80himBgc6D8NRBlgszwVdWQnJPP2 Qn6A== 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=DolZsmvjrJyFalP6idbAlKkRI3OBSv0+f02qDDcVYkY=; b=O7bFjyR1Z3MAgZI9Q3nCyjv9ZJs7kWJ7ncP0+aGbh8q62s7ahp1eanZI4kpOaBVyIX izOq7NGv1SBwnrzZJN4MFgIi/P5qEVGgh0R/0B9oElSwQM+fVFF6dc3EN+2UMCTZ1E59 xhlyHaSHulIdj39wcCQgvi3btvEXw48k5V/SZZx5XfkDBSLevew6JElqbJFkjsNF9KQD yt9Xq42mMarFCAPG0HgF1f2V9r/vZfOYu6JGIbFo91mCVSxTAZucks5wiNgxUxdVTezm taqRk6th1hzL97Uj9CIQ+Pp7ej/x8XeN2186O/FkMnWCiWpvqO5i4aTkihYdmVAuyQG3 AslQ== X-Gm-Message-State: AOAM533aYZzGuTnl57iPYm+WefGwq8Jc64J4pFYo9Q6Seqn86EQOoqUh YqRCN29DrJZJFrbhDyrJeIYO0wF1RzoZhFvr2dDno/SCcUE= X-Google-Smtp-Source: ABdhPJwGphJgKGPy18xsdzqq7EmBYhTEX+Bbqm/MVEsqUa8TaBLg0M8MaND3dI9KQQLDZ+2G12z0BviAJ42D8SvkCa0= X-Received: by 2002:a5d:5146:: with SMTP id u6mr7336885wrt.66.1605737794365; Wed, 18 Nov 2020 14:16:34 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Wed, 18 Nov 2020 14:16:33 -0800 (PST) In-Reply-To: References: <202011141922.0AEJM2ld055995@repo.freebsd.org> From: Mateusz Guzik Date: Wed, 18 Nov 2020 23:16:33 +0100 Message-ID: Subject: Re: svn commit: r367695 - in head/sys: kern sys To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Cbxx039W2z4l3X X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=mD9qOcZH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::435 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.86 / 15.00]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::435:from]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_DN_SOME(0.00)[]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::435:from:127.0.2.255]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::435:from]; NEURAL_HAM_SHORT(-0.86)[-0.862]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[svn-src-all,svn-src-head]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 22:16:38 -0000 On 11/17/20, John Baldwin wrote: > On 11/14/20 11:22 AM, Mateusz Guzik wrote: >> Author: mjg >> Date: Sat Nov 14 19:22:02 2020 >> New Revision: 367695 >> URL: https://svnweb.freebsd.org/changeset/base/367695 >> >> Log: >> thread: batch credential freeing >> >> Modified: >> head/sys/kern/kern_prot.c >> head/sys/kern/kern_thread.c >> head/sys/sys/ucred.h >> >> Modified: head/sys/kern/kern_prot.c >> ============================================================================== >> --- head/sys/kern/kern_prot.c Sat Nov 14 19:21:46 2020 (r367694) >> +++ head/sys/kern/kern_prot.c Sat Nov 14 19:22:02 2020 (r367695) >> @@ -2007,6 +2071,17 @@ crfree(struct ucred *cr) >> mtx_unlock(&cr->cr_mtx); >> return; >> } >> + crfree_final(cr); >> +} >> + >> +static void >> +crfree_final(struct ucred *cr) >> +{ >> + >> + KASSERT(cr->cr_users == 0, ("%s: users %d not == 0 on cred %p", >> + __func__, cr->cr_users, cr)); >> + KASSERT(cr->cr_ref == 0, ("%s: ref %d not == 0 on cred %p", >> + __func__, cr->cr_ref, cr)); >> /* > > Please add blank lines before comments. It's in style(9) and I've noticed > a pattern in your changes of not including them. > Ok. >> Modified: head/sys/sys/ucred.h >> ============================================================================== >> --- head/sys/sys/ucred.h Sat Nov 14 19:21:46 2020 (r367694) >> +++ head/sys/sys/ucred.h Sat Nov 14 19:22:02 2020 (r367695) >> @@ -114,6 +114,28 @@ struct xucred { >> struct proc; >> struct thread; >> >> +struct credbatch { >> + struct ucred *cred; >> + int users; >> + int ref; >> +}; >> + >> +static inline void >> +credbatch_prep(struct credbatch *crb) >> +{ >> + crb->cred = NULL; >> + crb->users = 0; >> + crb->ref = 0; >> +} >> +void credbatch_add(struct credbatch *crb, struct thread *td); >> +static inline void >> +credbatch_process(struct credbatch *crb) >> +{ >> + >> +} >> +void credbatch_add(struct credbatch *crb, struct thread *td); >> +void credbatch_final(struct credbatch *crb); >> + > > Do not mix prototypes and inlines, especially without spaces > around the prototype in the middle. Also, the kernel uses __inline > rather than inline (for better or for worse). The kernel has a huge mix of inline and __inline, to the point where my impression was that __inline is obsolete. > Better would be: > > static __inline void > credbatch_prep() > { > ... > } > > static __inline void > credbatch_process() > { > ... > } > > void credbatch_add(); > void credbatch_final(); > I disagree. The current header order follows how these routines are used. > It seems you just have a duplicate credbatch_add() in fact. > Indeed, I'll whack it. > Also, why have an empty inline function? > Interested parties can check the consumer (also seen in the diff) to see this is for consistency. I don't think any comments are warranted in the header. > These changes would benefit from review. > I don't think it's feasible to ask for review for everything lest it degardes to rubber stamping and I don't think this change warranted it, regardless of the cosmetic issues which can always show up. > -- > John Baldwin > -- Mateusz Guzik From owner-svn-src-all@freebsd.org Wed Nov 18 22:32:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 73FDE473F20; Wed, 18 Nov 2020 22:32:22 +0000 (UTC) (envelope-from se@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbyHB2n7Hz4lmY; Wed, 18 Nov 2020 22:32:22 +0000 (UTC) (envelope-from se@freebsd.org) Received: from Stefans-MBP-WLAN.fritz.box (p200300cd5f3b88002402e588537088de.dip0.t-ipconnect.de [IPv6:2003:cd:5f3b:8800:2402:e588:5370:88de]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id B4E012CE0E; Wed, 18 Nov 2020 22:32:21 +0000 (UTC) (envelope-from se@freebsd.org) To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011181944.0AIJiUU3003699@repo.freebsd.org> From: Stefan Esser Subject: Re: svn commit: r367813 - head/lib/libutil Message-ID: Date: Wed, 18 Nov 2020 23:32:20 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M3Q0wLcC3m29rCmWvjFoU4rgXCMtZ0OW2" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 22:32:22 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --M3Q0wLcC3m29rCmWvjFoU4rgXCMtZ0OW2 Content-Type: multipart/mixed; boundary="qhZvkLNJvoMuwLdfz38cO6PhYXevwOiV6"; protected-headers="v1" From: Stefan Esser To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: Subject: Re: svn commit: r367813 - head/lib/libutil References: <202011181944.0AIJiUU3003699@repo.freebsd.org> In-Reply-To: --qhZvkLNJvoMuwLdfz38cO6PhYXevwOiV6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Am 18.11.20 um 22:40 schrieb Mateusz Guzik: >> +{ >> + static const int localbase_oid[2] =3D {CTL_USER, USER_LOCALBASE}; >=20 > There is no use for this to be static. Why not? This makes it part of the constant initialized data of the library, which is more efficient under run-time and memory space aspects than initializing them on the stack. What do I miss? >> + char *tmppath; >> + size_t tmplen; >> + static const char *localbase =3D NULL; >> + >> + if (issetugid() =3D=3D 0) { >> + tmppath =3D getenv("LOCALBASE"); >> + if (tmppath !=3D NULL && tmppath[0] !=3D '\0') >> + return (tmppath); >> + } >> + if (sysctl(localbase_oid, 2, NULL, &tmplen, NULL, 0) =3D=3D 0 && >> + (tmppath =3D malloc(tmplen)) !=3D NULL && >> + sysctl(localbase_oid, 2, tmppath, &tmplen, NULL, 0) =3D=3D 0) { >=20 > Apart from the concurrency issue mentioned in the comment this is just > very wasteful. Instead you can have a small local buffer, say 128 > bytes and pass that to be populated. The sysctl handler than can > populate that and return an error if the size is too small. I don't > know if sysclt api allows it to return the set size as it is. Worst > case you can just retry with a bigger malloced buffer. You obviously did not follow the development of this code in the review. It used to have such a buffer, but this was rejected, since only very few of the programs that link against this library are going to call this function. Allocating a small buffer and replacing it with a larger one if it was too small adds needless complexity to this program and needs more code. It is not sensible (IMHO) to reduce the number of system calls by 1 for the small number of programs that use this feature, and which perform at least tens of other system calls at start-up. > Once you get the result you can malloc a buffer and > atomic_cmpset_rel_ptr localbase to point to it. If this fails, another > thread got the result, you free your buffer and return (localbase). Yes, I wrote that I could use atomics, feel free to modify the program accordingly. It will not make a difference in practice, since there is no good reason to call this function from within a multi-threaded context at all, and none of the candidates to be modified to use this function in base do. > Also the kernel counter part completely unnecessarily comes with a > static 1KB buffer to hold what typically is going to be nothing. This > should also be allocated as needed. Worst case you can add a trivial > lock around it. The kernel buffer does already exist and you did not complain about that buffer, when it has been committed. A size of PATHNAMEMAX is used to allow for any valid path name to be set from the loader. If there is consensus that the value should be limited to e.g. 64 or 128 bytes, this is trivially changed in kern_mib.c. I'd be more worried, if this buffer existed not as a single instance in the kernel but e.g. per process, but this is not the case. Feel free to make this a dynamically allocated variable, but make sure that you do not increase the code size by as much as you reduce the static storage required. I do not need the dynamic assignment to localbase at all, and I have suggested to introduce a kernel build option (e.g. WITH_LOCALBASE_VAR) to control compilation of kernel and library with this function or to return just the constant string _PATH_LOCALBASE or "/usr/local". But there were very strong requests for this dynamically set localbase and I have provided an implementation that is functional and easy to use. Regards, STefan --qhZvkLNJvoMuwLdfz38cO6PhYXevwOiV6-- --M3Q0wLcC3m29rCmWvjFoU4rgXCMtZ0OW2 Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAl+1oPQFAwAAAAAACgkQR+u171r99UQX PAgAo740FH+YypU6B+NKSBLCZJfBUvA6VBDeOkN1YkoUW94SHTdG9raBIE1rXSZq0NDhqfpGAqDs RmJCVQlYHyom4Y3Rqk630fThlxYQz5OJGmMr0grSgHscKjA3tPk5KxnKWSjSnk1MuwTFim+4f8Be psDBAmzYaMh4M6mIgyROK+0qEtX6dBiaamOv8l3kLhf8Uwcs0KOvZo1lB3EgNEtbAUWa/2rZuJpD /hwM2aqKHxdUo5EZ3Wa6ng7tDAJKpnrBd0Utm1nvgH4tgfn/Qi8jvt0C/Tlk9edTALEwPkRW9R6o POXtzby+modCyjXKx/H7/ktu0RCUaTv0chyAviypIA== =t6Ok -----END PGP SIGNATURE----- --M3Q0wLcC3m29rCmWvjFoU4rgXCMtZ0OW2-- From owner-svn-src-all@freebsd.org Wed Nov 18 22:39:48 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44AAC473CEE for ; Wed, 18 Nov 2020 22:39:48 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 4CbyRl6tHKz4lqt for ; Wed, 18 Nov 2020 22:39:47 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f50.google.com with SMTP id s8so4070376wrw.10 for ; Wed, 18 Nov 2020 14:39:47 -0800 (PST) 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=N66VAkAocw1qZbK3eS/N9o9Tcvf/wwctRyqZleDwFY8=; b=HLNgMyzSh+XSqWkBf6Bgm+cSp/KVBqG4lMBjnfh86i0cOnJxhrs58TvxTtCkhvGiqB KjhK2YB9gH6vVJMkgHjs7tpQi2hsE2JYmWD39QMRKzG+wmUTQZrUGxrIS4/Xl+CYLgeU WiMNdeCK4j4bzptszKxm2DA4E4hGUc9KsrC4X+cpojeAsORiPdbQc1A/VszY/R350WS4 HLFTzoteMDOs4rylfBdw+nsnY9vNgvhkvJ+xg0ATj1bvEO6oPMYPoVliiWcngsfKdoqH dcVG0b5wodZ9Pk619AO/HDqLlR9aA7GDgFtTiHifmRwZLfKwkSCCOfqct4Ds62hjGKaD tNGg== X-Gm-Message-State: AOAM532WxZ917Gz0AXRY6WVlhVPLqv8WoIQDqO611JWoepSLURKxb+LY djMZQR88x954H+i2LXXEIDsjxg== X-Google-Smtp-Source: ABdhPJyCKs+Jr7LxHYgM3VGyAtFwUZUaQLUpekMEeBgt+GgVbsyG6/hMh6/+KIb/n2zjJdJ9wUgYyA== X-Received: by 2002:adf:e788:: with SMTP id n8mr6833057wrm.84.1605739186246; Wed, 18 Nov 2020 14:39:46 -0800 (PST) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id t13sm36710644wru.67.2020.11.18.14.39.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2020 14:39:45 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367813 - head/lib/libutil From: Jessica Clarke In-Reply-To: Date: Wed, 18 Nov 2020 22:39:44 +0000 Cc: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: References: <202011181944.0AIJiUU3003699@repo.freebsd.org> To: Stefan Esser X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CbyRl6tHKz4lqt X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 22:39:48 -0000 On 18 Nov 2020, at 22:32, Stefan Esser wrote: > > Am 18.11.20 um 22:40 schrieb Mateusz Guzik: >>> +{ >>> + static const int localbase_oid[2] = {CTL_USER, USER_LOCALBASE}; >> There is no use for this to be static. > > Why not? This makes it part of the constant initialized data of > the library, which is more efficient under run-time and memory > space aspects than initializing them on the stack. > > What do I miss? What is more efficient is not so clear-cut, it depends on things like the architecture, microarchitecture and ABI. Allocating a small buffer on the stack is extremely cheap (the memory will almost certainly be in the L1 cache), whereas globally-allocated storage is less likely to be in the cache due to being spread out, and on some architecture/ABI combinations will incur additional indirection through the GOT. Also, 8 bytes of additional stack use is lost in the noise. Jess From owner-svn-src-all@freebsd.org Wed Nov 18 23:05:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B603F474553; Wed, 18 Nov 2020 23:05:53 +0000 (UTC) (envelope-from se@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cbz1s4cQfz4mYV; Wed, 18 Nov 2020 23:05:53 +0000 (UTC) (envelope-from se@freebsd.org) Received: from Stefans-MBP-WLAN.fritz.box (p200300cd5f3b88002402e588537088de.dip0.t-ipconnect.de [IPv6:2003:cd:5f3b:8800:2402:e588:5370:88de]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id EEAE22D27D; Wed, 18 Nov 2020 23:05:52 +0000 (UTC) (envelope-from se@freebsd.org) To: Jessica Clarke References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> <92a87ed8-4b22-4d03-9481-b02f92dcaaa0@freebsd.org> From: Stefan Esser Cc: src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367813 - head/lib/libutil Message-ID: <9f719272-f1e4-5668-02d2-bd2fbd0e5d6a@freebsd.org> Date: Thu, 19 Nov 2020 00:05:51 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pluecdo9FMtq9TgEdev51iMzFYslnfLvb" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 23:05:53 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pluecdo9FMtq9TgEdev51iMzFYslnfLvb Content-Type: multipart/mixed; boundary="Wmw5wadY4r4IyARbwXccjPLs8sY45i0Ho"; protected-headers="v1" From: Stefan Esser To: Jessica Clarke Cc: src-committers , svn-src-all , svn-src-head Message-ID: <9f719272-f1e4-5668-02d2-bd2fbd0e5d6a@freebsd.org> Subject: Re: svn commit: r367813 - head/lib/libutil References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> <92a87ed8-4b22-4d03-9481-b02f92dcaaa0@freebsd.org> In-Reply-To: --Wmw5wadY4r4IyARbwXccjPLs8sY45i0Ho Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Am 18.11.20 um 23:14 schrieb Jessica Clarke: > On 18 Nov 2020, at 21:52, Stefan Esser wrote: >> Am 18.11.20 um 22:15 schrieb Jessica Clarke: >>> On 18 Nov 2020, at 19:44, Stefan E=C3=9Fer wrote: >>>> + /* >>>> + * Check for some other thread already having >>>> + * set localbase - this should use atomic ops. >>>> + * The amount of memory allocated above may leak, >>>> + * if a parallel update in another thread is not >>>> + * detected and the non-NULL pointer is overwritten. >>>> + */ >>> Why was this committed with a known racy/leaky implementation? >> >> Because the alternatives that I offered for discussion were >> less acceptable. >=20 > That has no bearing over whether this one is. Three alternatives have been discussed: 1) static buffer of size MAXPATHLEN 2) dynamically allocated buffer (as committed) 3) dynamically allocated buffer filled by a constructor 1) has been rejected, since it adds 1 KB of bss to each program that is linked with libutil, whether it uses getlocalbase() or not. 3) has been rejected since it causes 1 getenv() and 2 sysctl() calls when the program linked with libutil starts, independently of whether getlocalbase() is used or not. 2) has been selected, since it is only called when needed and it does not pre-allocate a large buffer. Which other alternative do you want to suggest? Did you have a look at the review announced on the -current list and mentioned in the commit? >>> What happens if I set the value with a sysctl and call this? >> >> You'll get the value set with sysctl, unless overridden by the >> environment variable. There is a window of a few nano-seconds >> where a thread executing in parallel on another core might be >> able to set the localbase variable (between the test for NULL >> in this function and the assignment to it). The value that will >> be returned by either thread will be identical, so there is no >> risk of corruption of the result. >=20 > But if I call getlocalbase, then set it via sysctl, then call > getlocalbase again, I see the old value. If, however, I omit the first > getlocalbase, I see the new value. This differs from how getenv/setenv > of the value work, where you always see the up-to-date value. Maybe you= > think that's a feature, but it's something to watch out for and > explicitly call out in the documentation. Actual programs call getlocalbase() exactly once and create the required pathes from the value returned. It is possible to copy the value from the environment to a buffer, but at added complexity and introducing another race condition. The program itself might have modified its environment and then use an inconsistent value when it calls getlocalbase() again thereafter. But why would you want to do this - it seems to be a complicated way lof foot-shooting to me. I'm not a native speaker of English and not best qualified to clearly express this in the man-page. Feel free to commit any clarification or suggest an addition for me to commit. > You also misunderstand all the subtleties of multithreading here. There= > are no acquire/release pairs so it is entirely legal for Thread 2 to > read Thread 1's initialised value for localbase before the contents of > it are visible (i.e. the pointer is initialised but the data is > garbage). Yes, and thread 2's value will be identical to the one from thread 1, just in a different heap location, unless there is a write to the sysctl variable in the kernel at just the same time. And you cannot protect against this race and you'll get either the old or new value. > The `(volatile const char*)localbase` cast is also a complete waste of > time. You probably meant to write `(const char * volatile)localbase` > but even then that does nothing useful as the cast is too late. What > you really were trying to write was > `*(const char * volatile *)&localbase`, but you need proper atomics > anyway for this to be safe. I was not sure about the correct volatile declaration, I've got to admit. It was in the review and I did not get any comments regarding that specific modifier. The goal was to enforce the access to the localbase pointer in memory after returning from the sysctl to shorten the window. Perhaps I should just have completely ignore any multi-threading issues and accepted that an overlapping execution of this function would allocate multiple sysctl destination buffers but loose all references but one in the assignment to localbase. It will not happen in practice, it just does not make sense to call this function more than once in a program. >> This unlikely case may actually leak a heap allocated string >> of typically tens of bytes (but with negligible probability). >> >> But this really is a non-issue, since there should never be a >> reason to invoke this function in a multi-threaded context. >=20 > Why not? There could easily be code out there calling getenv in a > multi-threaded context so this is inadequate as a replacement. Yes it's= > inefficient but it's perfectly legal and imaginable. Yes, calling getenv() might occur, but getlocalbase() is generally called before configuration files are accessed, and the resulting path is saved in the program. Other uses are possible, but this is the recurring pattern. And unless the program modifies its own environment at run-time, all invocsations of getlocalbase() are guaranteed to return the same result again and again. > Also if malloc returns NULL I would quite like that to be an error for > the function and not silently fall back on _PATH_LOCALBASE. The function is specifically specified to always succeed. Else there is extra code required at each invocation to check for errors. Not being able to allocate the required buffer of at most 1 KB will cause every non-trivial program to fail anyway. Returning the compiled in default value will direct the program to access files in /usr/local, which is an administrator controlled path, even on systems with non-default localbase. Returning NULL is possible in that case, but the only ways a program could deal with this case is to either crash, sue the default path, or ignore the accesses to files in localbase. In either case it will not operate as intended, but I consider directing accesses to the FreeBSD default location (or the modified _PATH_LOCALBASE) to be a reasonable fall-back. But this will not happen unless provoked (by not allowing the program to allocate any memory from the heap, which will cause it to fail as soon as any other library function or start-up code tries to allocate heap-space). I had put this code up for review and it has been discussed before (and another implementation has been reverted after several iterations of changes). If there had been consensus to return NULL, I could have committed that - it is a trivial change and ENOMEM would have been set after a malloc failure. I have written about this possibility and I had appreciated if comments had been made on Phabricator before the commit. Regards, STefan --Wmw5wadY4r4IyARbwXccjPLs8sY45i0Ho-- --pluecdo9FMtq9TgEdev51iMzFYslnfLvb Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAl+1qM8FAwAAAAAACgkQR+u171r99US5 DAf/b+xunZK6AfbbAawlLu7QfLx7QQrplIaD7rQw7Yn80AH1PJe3uyqp1yitqHgpEXwpmBuhaILP Oa5kGfXpju0f8ipSAesNv+FfVO2r4YG65eTUftV6fCQPSjFTYX8yNZMSpPtal+tp9fLyvTliZJKQ PLVXu3GqICFajeO2Bk0+TRWfgbiwJ5dLcT3PsX3p9fc0inwGfu3lhsO9ReDEXrFbCKMCY6sEOFMv 4Q3r4MyGUOfvBdv+aIZUH27zfiBnSOMk08E0qBYAHH2MHYWVHuiSsCF82I1HVPQM19/v7G/BE7Eo +VEg6ulgJL/L7q0+2gOqzA/X6HMaS8ttBl2ZIDCBYw== =8Tf8 -----END PGP SIGNATURE----- --pluecdo9FMtq9TgEdev51iMzFYslnfLvb-- From owner-svn-src-all@freebsd.org Wed Nov 18 23:20:41 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D11A2474A58; Wed, 18 Nov 2020 23:20:41 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbzLx5bfFz4nks; Wed, 18 Nov 2020 23:20:41 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 0AD993C0199; Wed, 18 Nov 2020 23:20:35 +0000 (UTC) Date: Wed, 18 Nov 2020 23:20:34 +0000 From: Brooks Davis To: Stefan Esser Cc: Jessica Clarke , src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r367813 - head/lib/libutil Message-ID: <20201118232034.GE1158@spindle.one-eyed-alien.net> References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <25465269-5497-4981-A1E4-CC1FFAB68CF4@freebsd.org> <92a87ed8-4b22-4d03-9481-b02f92dcaaa0@freebsd.org> <9f719272-f1e4-5668-02d2-bd2fbd0e5d6a@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mvpLiMfbWzRoNl4x" Content-Disposition: inline In-Reply-To: <9f719272-f1e4-5668-02d2-bd2fbd0e5d6a@freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4CbzLx5bfFz4nks X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 23:20:41 -0000 --mvpLiMfbWzRoNl4x Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 19, 2020 at 12:05:51AM +0100, Stefan Esser wrote: > Am 18.11.20 um 23:14 schrieb Jessica Clarke: > > On 18 Nov 2020, at 21:52, Stefan Esser wrote: > >> Am 18.11.20 um 22:15 schrieb Jessica Clarke: > >>> On 18 Nov 2020, at 19:44, Stefan E??er wrote: > >>>> + /* > >>>> + * Check for some other thread already having > >>>> + * set localbase - this should use atomic ops. > >>>> + * The amount of memory allocated above may leak, > >>>> + * if a parallel update in another thread is not > >>>> + * detected and the non-NULL pointer is overwritten. > >>>> + */ > >>> Why was this committed with a known racy/leaky implementation? > >> > >> Because the alternatives that I offered for discussion were > >> less acceptable. > >=20 > > That has no bearing over whether this one is. >=20 > Three alternatives have been discussed: >=20 > 1) static buffer of size MAXPATHLEN > 2) dynamically allocated buffer (as committed) > 3) dynamically allocated buffer filled by a constructor >=20 > 1) has been rejected, since it adds 1 KB of bss to each program > that is linked with libutil, whether it uses getlocalbase() or > not. >=20 > 3) has been rejected since it causes 1 getenv() and 2 sysctl() > calls when the program linked with libutil starts, independently > of whether getlocalbase() is used or not. >=20 > 2) has been selected, since it is only called when needed and it > does not pre-allocate a large buffer. >=20 > Which other alternative do you want to suggest? >=20 > Did you have a look at the review announced on the -current list > and mentioned in the commit? >=20 > >>> What happens if I set the value with a sysctl and call this? > >> > >> You'll get the value set with sysctl, unless overridden by the > >> environment variable. There is a window of a few nano-seconds > >> where a thread executing in parallel on another core might be > >> able to set the localbase variable (between the test for NULL > >> in this function and the assignment to it). The value that will > >> be returned by either thread will be identical, so there is no > >> risk of corruption of the result. > >=20 > > But if I call getlocalbase, then set it via sysctl, then call > > getlocalbase again, I see the old value. If, however, I omit the first > > getlocalbase, I see the new value. This differs from how getenv/setenv > > of the value work, where you always see the up-to-date value. Maybe you > > think that's a feature, but it's something to watch out for and > > explicitly call out in the documentation. >=20 > Actual programs call getlocalbase() exactly once and create the > required pathes from the value returned. >=20 > It is possible to copy the value from the environment to a buffer, > but at added complexity and introducing another race condition. >=20 > The program itself might have modified its environment and then > use an inconsistent value when it calls getlocalbase() again > thereafter. But why would you want to do this - it seems to be > a complicated way lof foot-shooting to me. >=20 > I'm not a native speaker of English and not best qualified to > clearly express this in the man-page. Feel free to commit any > clarification or suggest an addition for me to commit. >=20 > > You also misunderstand all the subtleties of multithreading here. There > > are no acquire/release pairs so it is entirely legal for Thread 2 to > > read Thread 1's initialised value for localbase before the contents of > > it are visible (i.e. the pointer is initialised but the data is > > garbage). >=20 > Yes, and thread 2's value will be identical to the one from > thread 1, just in a different heap location, unless there is a > write to the sysctl variable in the kernel at just the same > time. And you cannot protect against this race and you'll get > either the old or new value. >=20 > > The `(volatile const char*)localbase` cast is also a complete waste of > > time. You probably meant to write `(const char * volatile)localbase` > > but even then that does nothing useful as the cast is too late. What > > you really were trying to write was > > `*(const char * volatile *)&localbase`, but you need proper atomics > > anyway for this to be safe. >=20 > I was not sure about the correct volatile declaration, I've got > to admit. It was in the review and I did not get any comments > regarding that specific modifier. The goal was to enforce the > access to the localbase pointer in memory after returning from > the sysctl to shorten the window. >=20 > Perhaps I should just have completely ignore any multi-threading > issues and accepted that an overlapping execution of this function > would allocate multiple sysctl destination buffers but loose all > references but one in the assignment to localbase. >=20 > It will not happen in practice, it just does not make sense to > call this function more than once in a program. >=20 > >> This unlikely case may actually leak a heap allocated string > >> of typically tens of bytes (but with negligible probability). > >> > >> But this really is a non-issue, since there should never be a > >> reason to invoke this function in a multi-threaded context. > >=20 > > Why not? There could easily be code out there calling getenv in a > > multi-threaded context so this is inadequate as a replacement. Yes it's > > inefficient but it's perfectly legal and imaginable. >=20 > Yes, calling getenv() might occur, but getlocalbase() is generally > called before configuration files are accessed, and the resulting > path is saved in the program. Other uses are possible, but this is > the recurring pattern. This seems like a very naive assumption. I could easily see libraries wanting to know where localbase is and calling this completely without knowledge of the application programmer. > And unless the program modifies its own environment at run-time, > all invocsations of getlocalbase() are guaranteed to return the > same result again and again. >=20 > > Also if malloc returns NULL I would quite like that to be an error for > > the function and not silently fall back on _PATH_LOCALBASE. >=20 > The function is specifically specified to always succeed. Else > there is extra code required at each invocation to check for > errors. Not being able to allocate the required buffer of at > most 1 KB will cause every non-trivial program to fail anyway. >=20 > Returning the compiled in default value will direct the program > to access files in /usr/local, which is an administrator controlled > path, even on systems with non-default localbase. >=20 > Returning NULL is possible in that case, but the only ways a > program could deal with this case is to either crash, sue the > default path, or ignore the accesses to files in localbase. >=20 > In either case it will not operate as intended, but I consider > directing accesses to the FreeBSD default location (or the > modified _PATH_LOCALBASE) to be a reasonable fall-back. >=20 > But this will not happen unless provoked (by not allowing the > program to allocate any memory from the heap, which will cause > it to fail as soon as any other library function or start-up > code tries to allocate heap-space). >=20 > I had put this code up for review and it has been discussed > before (and another implementation has been reverted after > several iterations of changes). >=20 > If there had been consensus to return NULL, I could have > committed that - it is a trivial change and ENOMEM would have > been set after a malloc failure. >=20 > I have written about this possibility and I had appreciated > if comments had been made on Phabricator before the commit. Don't mistake posting something for review with obtaining consensus. I glanced at the review, but it contained no use cases or justification for the feature so it was impossible to comment on the implementation in the time I had. I still don't understand what you aim to support and why (except that your implementation fails to support things like per-jail or per-ABI localbase which both seem like things people might want.) -- Brooks --mvpLiMfbWzRoNl4x Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJftaxCAAoJEKzQXbSebgfANd8H/3qF115Nw0JRvd7zwOpp9nAP njbdKJ+Pkc0NBYv2BV+up8cPVkKpp0vAtA+Hn7Aekbkqw2sOUW8ZDkHn+CiUEk95 gOVlaSfPLL9bSheVcYnw8iQeRR3vV+VTlpr+HTYwJjnncETpF/YF/8aES0izisK0 PJW7cxSkS29QPuTQf/gH5x7OcOcaAGfr3b4vWGWF4EsDvsWT2htzfZuIyKYzEGJf G3trYlY5xRDeVY3sC6COS1lzjMYM5wHX0VTAo12bFFDSBtfbQSCVh6tIFUHkx7hD xezSX+HiwWyMdrz0fEa1llIjeB7qhidlqMrDDaZKvFg7N9BVgFMkaHE3OuhqSVk= =SXLv -----END PGP SIGNATURE----- --mvpLiMfbWzRoNl4x-- From owner-svn-src-all@freebsd.org Wed Nov 18 23:25:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85977474E12; Wed, 18 Nov 2020 23:25:35 +0000 (UTC) (envelope-from se@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbzSb3Brzz4nmv; Wed, 18 Nov 2020 23:25:35 +0000 (UTC) (envelope-from se@freebsd.org) Received: from Stefans-MBP-WLAN.fritz.box (p200300cd5f3b88002402e588537088de.dip0.t-ipconnect.de [IPv6:2003:cd:5f3b:8800:2402:e588:5370:88de]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id A81442D6BE; Wed, 18 Nov 2020 23:25:34 +0000 (UTC) (envelope-from se@freebsd.org) To: Jessica Clarke Cc: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011181944.0AIJiUU3003699@repo.freebsd.org> From: Stefan Esser Subject: Re: svn commit: r367813 - head/lib/libutil Message-ID: <81fd2ce6-b5b1-7f05-c575-6b233e78b739@freebsd.org> Date: Thu, 19 Nov 2020 00:25:33 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Hluk95MNiLLfA4Hay0ZfEgF1ONiy0Z68x" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 23:25:35 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Hluk95MNiLLfA4Hay0ZfEgF1ONiy0Z68x Content-Type: multipart/mixed; boundary="Z9ii1UL5laaUE7Rl1xeqBhfUJAMDSx3PN"; protected-headers="v1" From: Stefan Esser To: Jessica Clarke Cc: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <81fd2ce6-b5b1-7f05-c575-6b233e78b739@freebsd.org> Subject: Re: svn commit: r367813 - head/lib/libutil References: <202011181944.0AIJiUU3003699@repo.freebsd.org> In-Reply-To: --Z9ii1UL5laaUE7Rl1xeqBhfUJAMDSx3PN Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Am 18.11.20 um 23:39 schrieb Jessica Clarke: > On 18 Nov 2020, at 22:32, Stefan Esser wrote: >> >> Am 18.11.20 um 22:40 schrieb Mateusz Guzik: >>>> +{ >>>> + static const int localbase_oid[2] =3D {CTL_USER, USER_LOCALBASE}; >>> There is no use for this to be static. >> >> Why not? This makes it part of the constant initialized data of >> the library, which is more efficient under run-time and memory >> space aspects than initializing them on the stack. >> >> What do I miss? >=20 > What is more efficient is not so clear-cut, it depends on things like > the architecture, microarchitecture and ABI. Allocating a small buffer > on the stack is extremely cheap (the memory will almost certainly be in= > the L1 cache), whereas globally-allocated storage is less likely to be > in the cache due to being spread out, and on some architecture/ABI > combinations will incur additional indirection through the GOT. Also, 8= > bytes of additional stack use is lost in the noise. The memory latency of the extra access to the constant will be hidden in = the noise. The data will probably be in a page that has already been accessed (so no TLB load penalty) and modern CPUs will be able to deal with the cache miss (if any, because the cache line may already be loaded depending on other data near-by). Yes, I do agree that a stack local variable could have been used and it could have been created with little effort by a modern multi-issue CPU. The code size would have been larger, though, by some 10 to 20 bytes, I'd assume - but I doubt a single path through this code is measurable, much less observable in practice. We are talking about nano-seconds here (even if the cache line did not contain the constant data, it would probably be accessed just a few instructions further down and incur the same latency then). I have followed CPU development over more than 45 years and know many architectures and their specifics, but the time were I have programmed drivers in assembly and counted instruction cycles is long gone. This is nitpicking at a level that I do not want to continue. I'm not opposed to achieving efficiency where it is relevant. This function is providing useful functionality and I do not mind a wasted microsecond, it is not relevant here. (This was different if it was wasted within a tight loop - but it is not, it is typically called once if at all). Feel free to replace my code with your implementation, if you think it is not acceptable as written by me. I just wanted to provide an implementation of this functionality to be used in a number of programs where other developers had expressed interest in such a feature (and one of these programs has been worked on by me in recent weeks, so I'm now able to make use of it myself). Regards, STefan --Z9ii1UL5laaUE7Rl1xeqBhfUJAMDSx3PN-- --Hluk95MNiLLfA4Hay0ZfEgF1ONiy0Z68x Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAl+1rW0FAwAAAAAACgkQR+u171r99UTD YwgArC2xVFaz75Gki89FtOWYeDRJnYYxrRkuiDbj8IvErAafuELHv7vKhF9EsbndPYvUXBCvB3hW bp9pq4lcQ7OtpIthCmZAy+KPABD4zBysbyEM/7/FVjOOLvXj9NKOe94gTDj5VxrD7ZgxC3+pVmBb IkvE3sYwjuOfOU6BLIWqatNIEbqk+xqSjm6RYX3vlXeGcOwkH2YN19JZOvTG/SuP2K5EhAA8Qdfr 3Z7csXZ/dz9AZkSkvWEexPcAvWQv+Pir2UpLdhto6EXF5QPs8E81F/E+Xd2LGf2F9Vxzvj2ZbdiE wVhVn+vD1IjlUJPLPYuilr7NHkvd80oxM0sYxRdLkA== =W8FB -----END PGP SIGNATURE----- --Hluk95MNiLLfA4Hay0ZfEgF1ONiy0Z68x-- From owner-svn-src-all@freebsd.org Wed Nov 18 23:37:38 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE353474BDD; Wed, 18 Nov 2020 23:37:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbzkV4py6z4pCS; Wed, 18 Nov 2020 23:37:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 25B102C8EB; Wed, 18 Nov 2020 23:37:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367695 - in head/sys: kern sys To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011141922.0AEJM2ld055995@repo.freebsd.org> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> Date: Wed, 18 Nov 2020 15:37:36 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 23:37:38 -0000 On 11/18/20 2:16 PM, Mateusz Guzik wrote: > On 11/17/20, John Baldwin wrote: >> On 11/14/20 11:22 AM, Mateusz Guzik wrote: > Interested parties can check the consumer (also seen in the diff) to > see this is for consistency. I don't think any comments are warranted > in the header. I did read the consumer, and there didn't seem tremendous value in the extra line there. >> These changes would benefit from review. >> > > I don't think it's feasible to ask for review for everything lest it > degardes to rubber stamping and I don't think this change warranted > it, regardless of the cosmetic issues which can always show up. That is not consistent with the direction the project is moving. If you check the commit logs of other high-volume committers such as markj@, kib@, or myself, you will find that a substantial number of those commits are reviewed (typically in phabricator) without preventing us from making useful progress. Also, while the previous core did not mandate reviews, we moved closer to it when the Pre-Commit Review chapter was added to the Committer's Guide: https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/pre-commit-review.html In the related thread on developers@ we indicated that while weren't yet making pre-commit review mandatory, we collectively want to move in that direction. -- John Baldwin From owner-svn-src-all@freebsd.org Wed Nov 18 23:49:36 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4622C4751CF for ; Wed, 18 Nov 2020 23:49:36 +0000 (UTC) (envelope-from bounces-de@aproximeo.fr) Received: from emailing-de.aproximeo.fr (emailing-de.aproximeo.fr [212.129.33.118]) by mx1.freebsd.org (Postfix) with ESMTP id 4Cc00H2vZvz4ptn for ; Wed, 18 Nov 2020 23:49:35 +0000 (UTC) (envelope-from bounces-de@aproximeo.fr) Received: by emailing-de.aproximeo.fr (Postfix, from userid 33) id 712772E648BF; Thu, 19 Nov 2020 00:42:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=aproximeo.fr; s=dkim; t=1605742922; bh=Zu+LNC6V6Eq2E7FMWwBn/cSrOI54s89UldXdurjbpFY=; h=To:Subject:Date:From:List-Help:List-Unsubscribe:List-Subscribe: List-Owner:From; b=zpbSTIclvKwljMD8Gy9TSylJw9o70X+63oR5nz0x9ckuQg8GFZfMYBsJlfS4iPXTh AhVqgVzhJO7t3aN/BYhaxzeqhBo+e9a5CqaleuTYxFdMYvL/8gCwKhUbKwgG4kJ/cX W8YNZpUR0JKRzU1WMuWU6N5rbrNiEJKxs4QwhGmw= To: svn-src-all@freebsd.org Subject: Trouver des nouveaux clients X-PHP-Originating-Script: 33:class.phpmailer.php Date: Thu, 19 Nov 2020 00:42:02 +0100 From: "luc@aproximeo.fr" Message-ID: <7ac59efc51a05d5cf0c65643170e27c2@emailing-de.aproximeo.fr> X-Priority: 3 X-Mailer: PHPMailer 5.2.9 (https://github.com/PHPMailer/PHPMailer/) X-phpList-version: 3.0.10 X-MessageID: 35 X-ListMember: svn-src-all@freebsd.org Precedence: bulk Bounces-To: bounces-de@aproximeo.fr List-Owner: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4Cc00H2vZvz4ptn X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=aproximeo.fr header.s=dkim header.b=zpbSTIcl; dmarc=pass (policy=none) header.from=aproximeo.fr; spf=pass (mx1.freebsd.org: domain of bounces-de@aproximeo.fr designates 212.129.33.118 as permitted sender) smtp.mailfrom=bounces-de@aproximeo.fr X-Spamd-Result: default: False [-2.11 / 15.00]; R_SPF_ALLOW(-0.20)[+a:emailing-de.aproximeo.fr]; HAS_X_POS(0.00)[]; TO_DN_NONE(0.00)[]; URI_COUNT_ODD(1.00)[11]; DKIM_TRACE(0.00)[aproximeo.fr:+]; DMARC_POLICY_ALLOW(-0.50)[aproximeo.fr,none]; HAS_X_PRIO_THREE(0.00)[3]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MAILLIST(-0.10)[generic]; RCVD_COUNT_ZERO(0.00)[0]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[212.129.33.118:from]; ASN(0.00)[asn:12876, ipnet:212.129.0.0/18, country:FR]; FROM_NEQ_ENVFROM(0.00)[luc@aproximeo.fr,bounces-de@aproximeo.fr]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[aproximeo.fr:s=dkim]; FROM_DN_EQ_ADDR(1.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; PRECEDENCE_BULK(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; HAS_PHPMAILER_SIG(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[212.129.33.118:from:127.0.2.255]; FORGED_SENDER_MAILLIST(0.00)[]; MAILMAN_DEST(0.00)[svn-src-all] Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2020 23:49:36 -0000 Bonjour, Pour votre information, vous pouvez gratuitement trouver plein de nouveaux clients en vous inscrivant sur la 1=C3=A8re plateforme de proximit=C3=A9 en cliquant ici=0A . Plus d'infos en cliquant ici=0A . Excellente journ=C3=A9e ! Luc HIDOUX Responsable Commercial=20 -- This message was sent to svn-src-all@freebsd.org by luc@aproximeo.fr To forward this message, please do not use the forward button of your email application, because this message was made specifically for you only. Instead use the forward page=0A in our newsletter system. To change your details and to choose which lists to be subscribed to, visit your personal preferences page=0A Or you can opt-out completely=0A from all future mailings. =20 -- powered by phpList, www.phplist.com -- From owner-svn-src-all@freebsd.org Thu Nov 19 00:02:13 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4E25E475B15; Thu, 19 Nov 2020 00:02:13 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc0Gs1bbdz4qZC; Thu, 19 Nov 2020 00:02:13 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 29AE41A5E9; Thu, 19 Nov 2020 00:02:13 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ02D9K064718; Thu, 19 Nov 2020 00:02:13 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ02DJ3064717; Thu, 19 Nov 2020 00:02:13 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202011190002.0AJ02DJ3064717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 19 Nov 2020 00:02:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367822 - head/lib/libc/string X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/lib/libc/string X-SVN-Commit-Revision: 367822 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 00:02:13 -0000 Author: emaste Date: Thu Nov 19 00:02:12 2020 New Revision: 367822 URL: https://svnweb.freebsd.org/changeset/base/367822 Log: libc: optimize memmem two-way bad character shift first, the condition (mem && k < p) is redundant, because mem being nonzero implies the needle is periodic with period exactly p, in which case any byte that appears in the needle must appear in the last p bytes of the needle, bounding the shift (k) by p. second, the whole point of replacing the shift k by mem (=l-p) is to prevent shifting by less than mem when discarding the memory on shift, in which case linear time could not be guaranteed. but as written, the check also replaced shifts greater than mem by mem, reducing the benefit of the shift. there is no possible benefit to this reduction of the shift; since mem is being cleared, the full shift is valid and more optimal. so only replace the shift by mem when it would be less than mem. musl commits: 8f5a820d147da36bcdbddd201b35d293699dacd8 122d67f846cb0be2c9e1c3880db9eb9545bbe38c Obtained from: musl MFC after: 2 weeks Modified: head/lib/libc/string/memmem.c Modified: head/lib/libc/string/memmem.c ============================================================================== --- head/lib/libc/string/memmem.c Wed Nov 18 22:01:34 2020 (r367821) +++ head/lib/libc/string/memmem.c Thu Nov 19 00:02:12 2020 (r367822) @@ -153,8 +153,8 @@ twoway_memmem(const unsigned char *h, const unsigned c if (BITOP(byteset, h[l - 1], &)) { k = l - shift[h[l - 1]]; if (k) { - if (mem0 && mem && k < p) - k = l - p; + if (k < mem) + k = mem; h += k; mem = 0; continue; From owner-svn-src-all@freebsd.org Thu Nov 19 00:03:15 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6F624755F9; Thu, 19 Nov 2020 00:03:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc0J366rSz4qYJ; Thu, 19 Nov 2020 00:03:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C507E1A8A8; Thu, 19 Nov 2020 00:03:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ03F05066256; Thu, 19 Nov 2020 00:03:15 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ03FLI066255; Thu, 19 Nov 2020 00:03:15 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202011190003.0AJ03FLI066255@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 19 Nov 2020 00:03:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367823 - head/lib/libc/string X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/lib/libc/string X-SVN-Commit-Revision: 367823 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 00:03:16 -0000 Author: emaste Date: Thu Nov 19 00:03:15 2020 New Revision: 367823 URL: https://svnweb.freebsd.org/changeset/base/367823 Log: libc: fix undefined behavior from signed overflow in strstr and memmem unsigned char promotes to int, which can overflow when shifted left by 24 bits or more. this has been reported multiple times but then forgotten. it's expected to be benign UB, but can trap when built with explicit overflow catching (ubsan or similar). fix it now. note that promotion to uint32_t is safe and portable even outside of the assumptions usually made in musl, since either uint32_t has rank at least unsigned int, so that no further default promotions happen, or int is wide enough that the shift can't overflow. this is a desirable property to have in case someone wants to reuse the code elsewhere. musl commit: 593caa456309714402ca4cb77c3770f4c24da9da Obtained from: musl Modified: head/lib/libc/string/memmem.c head/lib/libc/string/strstr.c Modified: head/lib/libc/string/memmem.c ============================================================================== --- head/lib/libc/string/memmem.c Thu Nov 19 00:02:12 2020 (r367822) +++ head/lib/libc/string/memmem.c Thu Nov 19 00:03:15 2020 (r367823) @@ -41,8 +41,8 @@ twobyte_memmem(const unsigned char *h, size_t k, const static char * threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { - uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8; - uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8; + uint32_t nw = (uint32_t)n[0] << 24 | n[1] << 16 | n[2] << 8; + uint32_t hw = (uint32_t)h[0] << 24 | h[1] << 16 | h[2] << 8; for (h += 3, k -= 3; k; k--, hw = (hw | *h++) << 8) if (hw == nw) return (char *)h - 3; @@ -52,8 +52,8 @@ threebyte_memmem(const unsigned char *h, size_t k, con static char * fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { - uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; - uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; + uint32_t nw = (uint32_t)n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; + uint32_t hw = (uint32_t)h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; for (h += 4, k -= 4; k; k--, hw = hw << 8 | *h++) if (hw == nw) return (char *)h - 4; Modified: head/lib/libc/string/strstr.c ============================================================================== --- head/lib/libc/string/strstr.c Thu Nov 19 00:02:12 2020 (r367822) +++ head/lib/libc/string/strstr.c Thu Nov 19 00:03:15 2020 (r367823) @@ -40,8 +40,8 @@ twobyte_strstr(const unsigned char *h, const unsigned static char * threebyte_strstr(const unsigned char *h, const unsigned char *n) { - uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8; - uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8; + uint32_t nw = (uint32_t)n[0] << 24 | n[1] << 16 | n[2] << 8; + uint32_t hw = (uint32_t)h[0] << 24 | h[1] << 16 | h[2] << 8; for (h += 2; *h && hw != nw; hw = (hw | *++h) << 8) ; return *h ? (char *)h - 2 : 0; @@ -50,8 +50,8 @@ threebyte_strstr(const unsigned char *h, const unsigne static char * fourbyte_strstr(const unsigned char *h, const unsigned char *n) { - uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; - uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; + uint32_t nw = (uint32_t)n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; + uint32_t hw = (uint32_t)h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; for (h += 3; *h && hw != nw; hw = hw << 8 | *++h) ; return *h ? (char *)h - 3 : 0; From owner-svn-src-all@freebsd.org Thu Nov 19 00:08:26 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7BAC5475CB2 for ; Thu, 19 Nov 2020 00:08:26 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2k.ore.mailhop.org (outbound2k.ore.mailhop.org [54.148.219.64]) (using TLSv1.3 with cipher TLS_AES_256_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 4Cc0Q21WrFz4r22 for ; Thu, 19 Nov 2020 00:08:26 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1605744505; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=VQQRwc0ozeXp/GKZQ5jQ/jvaMFMkyRqHimhCL9AuYmxH0+a59cYmu0oGseAVN2dS760VctwxVsVZm 0BrNcex0z1sz0PDOa8ARBqR21VY4pH1lgUUlThgVamH2TQerujlj1x1xcray+MhfL3V1vLyS8qJuf6 dsYdl/s1xXdYOuBFu7uQAiG3IDAzXUcrrIDwvIEbBQ3tF2r/MO9AH0oEczyANxH3uQYh8ZfMef5b5n 08aTni8IcPxQCKDbcXwvcCqeItGQ2ftXN7z6JfRdfDGh2P/WqnLxF8gjXKsPCJMBkXTFngiuRcessm ipv2zBcWJ9IQdDoX1wsYIV0vW9OkjDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:dkim-signature:from; bh=eauvmwF1teDTlEE083sn4Uyabu8ySaNnL4klz00ZG2M=; b=katMpEudWgHSOsIPhCZJubieGBv/s07Ajt0vdyQO1gB9Eg1pL8jSijWp/2Xc3qZ7lu1hD//h/Z8kt s3rMwFD3RzH52OK3H9NS5xO02Aevezg0hBGdjCNzlk+3/wZJmtEckS/+iBXMOvyGku4TeNXM0d01y2 ruAcL2+m8ditvyKNkktMIycWM2R0gmVIOByjahC8YF+quW5NPXKBcqilNcD4K3UWWajinAbxAd1Npk RdUw2mQT1ulkymKzXmn/CXHjUvbg9XpwomYXJqeKjxwIoLA16x+mj1rPuLyoW+Z/EJmcy3idbdoX/8 iLoLcVSY9t5HuVPTYJtqif+tq4VD2dw== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:from; bh=eauvmwF1teDTlEE083sn4Uyabu8ySaNnL4klz00ZG2M=; b=IBFWv0i2O35oN+U/+Q2RnwFvVZUEhdVbhxbdairyj57uTQAaWI+UanmDc+0D299uxStAgLGyDDStv 7/cA7c1/VgSjwxJ5cHHweZJJW5fODkVwnedaXxnj8XK1KyfdXG/m3GMW0L955KWqPCljV3fC6a7I9J IceMbKkSyCPMFGG2bhaSTx3pskdubsDJtRy4SDzgCTkWwKdOhFEbLcuY3UfgnMAYGW/JlUTx3bIDEC CItfUJUz2mIhIqcYggMwsk7ypdE3Cp0+heFg2kta4UJpnuL2hggAEVd5DGVtEuzIs+sy79b64RnKP+ n8F3uVFivr0AsXgeJl8nETTMKtP5h0A== X-MHO-RoutePath: aGlwcGll X-MHO-User: 5621484a-29fb-11eb-9e11-df46ed8f892f X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-67-177-211-60.hsd1.co.comcast.net [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id 5621484a-29fb-11eb-9e11-df46ed8f892f; Thu, 19 Nov 2020 00:08:23 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 0AJ08MYX047491; Wed, 18 Nov 2020 17:08:22 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <96d3f81c1f992aab16bf4e0228250f24bf79fc8a.camel@freebsd.org> Subject: Re: svn commit: r367695 - in head/sys: kern sys From: Ian Lepore To: John Baldwin , Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Wed, 18 Nov 2020 17:08:22 -0700 In-Reply-To: <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> References: <202011141922.0AEJM2ld055995@repo.freebsd.org> <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Cc0Q21WrFz4r22 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 00:08:26 -0000 On Wed, 2020-11-18 at 15:37 -0800, John Baldwin wrote: > On 11/18/20 2:16 PM, Mateusz Guzik wrote: > > On 11/17/20, John Baldwin wrote: > > > On 11/14/20 11:22 AM, Mateusz Guzik wrote: > > > > Interested parties can check the consumer (also seen in the diff) > > to > > see this is for consistency. I don't think any comments are > > warranted > > in the header. > > I did read the consumer, and there didn't seem tremendous value in > the > extra line there. > > > > These changes would benefit from review. > > > > > > > I don't think it's feasible to ask for review for everything lest > > it > > degardes to rubber stamping and I don't think this change warranted > > it, regardless of the cosmetic issues which can always show up. > > That is not consistent with the direction the project is moving. If > you > check the commit logs of other high-volume committers such as markj@, > kib@, or myself, you will find that a substantial number of those > commits > are reviewed (typically in phabricator) without preventing us from > making useful progress. Also, while the previous core did not > mandate > reviews, we moved closer to it when the Pre-Commit Review chapter was > added to the Committer's Guide: > > https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/pre-commit-review.html > > In the related thread on developers@ we indicated that while weren't > yet > making pre-commit review mandatory, we collectively want to move in > that > direction. > Yeah, the direction the project is moving is to drive away the few remaining prolific contributors with policies that take all the satisfaction out of working on freebsd. There's a reason I've gone from being in the top ten commiters list in 2019 to having around a dozen commits in 2020. (Harrison Bergeron lives, it seems, but the world has so many more Diana Moon Glampers to counter with.) -- Ian From owner-svn-src-all@freebsd.org Thu Nov 19 00:37:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 082174762BC; Thu, 19 Nov 2020 00:37:58 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (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 4Cc1456fRdz4shC; Thu, 19 Nov 2020 00:37:57 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x429.google.com with SMTP id k2so4668970wrx.2; Wed, 18 Nov 2020 16:37:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=C9z7TbRsPRCO8jmyzl+/J+k/UrJWz7WMf25SE8al9Xk=; b=VqPIEyIkcENFgidVXbqW9FUdpfAWwa3aiGmRPiSNV6eNg1/mN3mfCA3bWx4wvxeahD u5ywOcIowRcUC7L6v12KOieAPpIr8YacFCKHi3n671Fo8gKdx5+5rL3KG3UbY3UGYUOp fqyS4ibUtsP2tsCH4Qeoh6uG6U+iT4MJX0yw6H2WF773bx5UJ5a0BuUiJYEgrJJa66tW dJKeQEZs2x59zQS1/d6cpYO0eXyE2soSKtDpKp5tP2KLL4huDkVyc7JiIR2hDF5es4c/ WGjulKMYHk1Ku5kwxW10v1BOVghzWdsdWVJFTNHzdL4n/YBqCUyXJP8GQ3cIDYI0ofDI DB3w== 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=C9z7TbRsPRCO8jmyzl+/J+k/UrJWz7WMf25SE8al9Xk=; b=DULgMaAbLazmIc6AJQQWFpwtFN+Mdoq5HCYAhxV+TgtAMoe24rdR0ZWbuj8v5V0IjK hJBWwPVjZAGYt0TCihIpAB52V9Qafotx1MzOEgFQSyI0KuIZI4Pes/x3u7nL0gTy0aow JoHs2DLkJQMga6O3GQ8jrkW6OFoMqO8uC8gBGXyXWaFrzajXo4jBoLyNUr5/aipfxC7D +v5vktdWVr/yk84oyCgztHaJ9z71xX8IYJP+Rr145By0psn9FGPQp/o/SAv50xB5jrc5 a80OZBJ4Z4j4HV9034oGm4lTAa/Zg/x/XINH6bFz51Qd/jcTeTmRFdQZqx5GSWU1AS2o aFDg== X-Gm-Message-State: AOAM531RtrVoT0m+bCI375rO7+FKpZlXYTOxkLb7dL7QzJTlJfiW7ekr N7Qdb8as8vgCkp8BWaLMYCX8/DiF4ymeoHpb2R24iXibFlI= X-Google-Smtp-Source: ABdhPJyGx7kjwmjpuWWO1AnfWhLVXze/Jx5lqn3Y8MKH4sTbQv7XX2r1hprJPXrCmOPsYsRTkwmKVH/b5VawdytWlMo= X-Received: by 2002:a5d:5146:: with SMTP id u6mr7763612wrt.66.1605746275469; Wed, 18 Nov 2020 16:37:55 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Wed, 18 Nov 2020 16:37:54 -0800 (PST) In-Reply-To: <81fd2ce6-b5b1-7f05-c575-6b233e78b739@freebsd.org> References: <202011181944.0AIJiUU3003699@repo.freebsd.org> <81fd2ce6-b5b1-7f05-c575-6b233e78b739@freebsd.org> From: Mateusz Guzik Date: Thu, 19 Nov 2020 01:37:54 +0100 Message-ID: Subject: Re: svn commit: r367813 - head/lib/libutil To: Stefan Esser Cc: Jessica Clarke , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Cc1456fRdz4shC X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 00:37:58 -0000 On 11/19/20, Stefan Esser wrote: > Am 18.11.20 um 23:39 schrieb Jessica Clarke: >> On 18 Nov 2020, at 22:32, Stefan Esser wrote: >>> >>> Am 18.11.20 um 22:40 schrieb Mateusz Guzik: >>>>> +{ >>>>> + static const int localbase_oid[2] = {CTL_USER, USER_LOCALBASE}; >>>> There is no use for this to be static. >>> >>> Why not? This makes it part of the constant initialized data of >>> the library, which is more efficient under run-time and memory >>> space aspects than initializing them on the stack. >>> >>> What do I miss? >> >> What is more efficient is not so clear-cut, it depends on things like >> the architecture, microarchitecture and ABI. Allocating a small buffer >> on the stack is extremely cheap (the memory will almost certainly be in >> the L1 cache), whereas globally-allocated storage is less likely to be >> in the cache due to being spread out, and on some architecture/ABI >> combinations will incur additional indirection through the GOT. Also, 8 >> bytes of additional stack use is lost in the noise. > > The memory latency of the extra access to the constant will be hidden in > the noise. The data will probably be in a page that has already been > accessed (so no TLB load penalty) and modern CPUs will be able to deal > with the cache miss (if any, because the cache line may already be > loaded depending on other data near-by). > > Yes, I do agree that a stack local variable could have been used and > it could have been created with little effort by a modern multi-issue > CPU. The code size would have been larger, though, by some 10 to 20 > bytes, I'd assume - but I doubt a single path through this code is > measurable, much less observable in practice. > > We are talking about nano-seconds here (even if the cache line did > not contain the constant data, it would probably be accessed just a > few instructions further down and incur the same latency then). > > I have followed CPU development over more than 45 years and know many > architectures and their specifics, but the time were I have programmed > drivers in assembly and counted instruction cycles is long gone. > > This is nitpicking at a level that I do not want to continue. I'm not > opposed to achieving efficiency where it is relevant. This function is > providing useful functionality and I do not mind a wasted microsecond, > it is not relevant here. (This was different if it was wasted within > a tight loop - but it is not, it is typically called once if at all). > > Feel free to replace my code with your implementation, if you think it > is not acceptable as written by me. > > I just wanted to provide an implementation of this functionality to > be used in a number of programs where other developers had expressed > interest in such a feature (and one of these programs has been worked > on by me in recent weeks, so I'm now able to make use of it myself). > The entire localbase saga is getting way out of hand. To address this e-mail and things you wrote in another reply, my comlaints are very simple and are not getting less valid for not being raised sooner. I just was not watching any of this until recent fallout. For the change at hand, there has to be a reason to use a static symbol. Standard example is catching otherwise expensive to obtain data. For that the static localbase pointer makes perfect sense, while the static lookup array does not have any justification that I see. Bringing cache, TLB or whatever microarchitectural details into the discussion is beyond not warranted. More importantly though the commit comes with a self-confessed memory leak and is a show stopper. That said, I'll see about patching this up. -- Mateusz Guzik From owner-svn-src-all@freebsd.org Thu Nov 19 02:20:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D290E47BB00; Thu, 19 Nov 2020 02:20:39 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc3Lb2Zt2z3JLv; Thu, 19 Nov 2020 02:20:39 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 466D01C54F; Thu, 19 Nov 2020 02:20:39 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ2KdD7049995; Thu, 19 Nov 2020 02:20:39 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ2Kc2k049840; Thu, 19 Nov 2020 02:20:38 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <202011190220.0AJ2Kc2k049840@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 19 Nov 2020 02:20:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367824 - head/sbin/savecore X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sbin/savecore X-SVN-Commit-Revision: 367824 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 02:20:40 -0000 Author: glebius Date: Thu Nov 19 02:20:38 2020 New Revision: 367824 URL: https://svnweb.freebsd.org/changeset/base/367824 Log: Add '-u' switch that would uncompress cores that were compressed by kernel during dump time. A real life scenario is that cores are compressed to reduce size of dumpon partition, but we either don't care about space in the /var/crash or we have a filesystem level compression of /var/crash. And we want cores to be uncompressed in /var/crash because we'd like to instantily read them with kgdb. In this case we want kernel to write cores compressed, but savecore(1) write them uncompressed. Reviewed by: markj, gallatin Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27245 Modified: head/sbin/savecore/Makefile head/sbin/savecore/savecore.8 head/sbin/savecore/savecore.c Modified: head/sbin/savecore/Makefile ============================================================================== --- head/sbin/savecore/Makefile Thu Nov 19 00:03:15 2020 (r367823) +++ head/sbin/savecore/Makefile Thu Nov 19 02:20:38 2020 (r367824) @@ -6,8 +6,10 @@ VAR_CRASH= /var/crash VAR_CRASH_MODE= 0750 CONFSDIR= VAR_CRASH PROG= savecore -LIBADD= xo z +LIBADD= xo z zstd MAN= savecore.8 + +CFLAGS+= -I${SRCTOP}/sys/contrib/zstd/lib .include Modified: head/sbin/savecore/savecore.8 ============================================================================== --- head/sbin/savecore/savecore.8 Thu Nov 19 00:03:15 2020 (r367823) +++ head/sbin/savecore/savecore.8 Thu Nov 19 02:20:38 2020 (r367824) @@ -28,7 +28,7 @@ .\" From: @(#)savecore.8 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd March 17, 2018 +.Dd November 17, 2020 .Dt SAVECORE 8 .Os .Sh NAME @@ -45,7 +45,7 @@ .Op Ar device ... .Nm .Op Fl -libxo -.Op Fl fkvz +.Op Fl fkuvz .Op Fl m Ar maxdumps .Op Ar directory Op Ar device ... .Sh DESCRIPTION @@ -92,6 +92,8 @@ Once the number of stored dumps is equal to .Ar maxdumps the counter will restart from .Dv 0 . +.It Fl u +Uncompress the dump in case it was compressed by the kernel. .It Fl v Print out some additional debugging information. Specify twice for more information. Modified: head/sbin/savecore/savecore.c ============================================================================== --- head/sbin/savecore/savecore.c Thu Nov 19 00:03:15 2020 (r367823) +++ head/sbin/savecore/savecore.c Thu Nov 19 02:20:38 2020 (r367824) @@ -86,6 +86,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#define Z_SOLO +#include +#include #include #include @@ -102,7 +105,7 @@ __FBSDID("$FreeBSD$"); static cap_channel_t *capsyslog; static fileargs_t *capfa; -static bool checkfor, compress, clear, force, keep; /* flags */ +static bool checkfor, compress, uncompress, clear, force, keep; /* flags */ static int verbose; static int nfound, nsaved, nerr; /* statistics */ static int maxdumps; @@ -441,22 +444,155 @@ compare_magic(const struct kerneldumpheader *kdh, cons #define BLOCKSIZE (1<<12) #define BLOCKMASK (~(BLOCKSIZE-1)) +static size_t +sparsefwrite(const char *buf, size_t nr, FILE *fp) +{ + size_t nw, he, hs; + + for (nw = 0; nw < nr; nw = he) { + /* find a contiguous block of zeroes */ + for (hs = nw; hs < nr; hs += BLOCKSIZE) { + for (he = hs; he < nr && buf[he] == 0; ++he) + /* nothing */ ; + /* is the hole long enough to matter? */ + if (he >= hs + BLOCKSIZE) + break; + } + + /* back down to a block boundary */ + he &= BLOCKMASK; + + /* + * 1) Don't go beyond the end of the buffer. + * 2) If the end of the buffer is less than + * BLOCKSIZE bytes away, we're at the end + * of the file, so just grab what's left. + */ + if (hs + BLOCKSIZE > nr) + hs = he = nr; + + /* + * At this point, we have a partial ordering: + * nw <= hs <= he <= nr + * If hs > nw, buf[nw..hs] contains non-zero + * data. If he > hs, buf[hs..he] is all zeroes. + */ + if (hs > nw) + if (fwrite(buf + nw, hs - nw, 1, fp) != 1) + break; + if (he > hs) + if (fseeko(fp, he - hs, SEEK_CUR) == -1) + break; + } + + return (nw); +} + +static char *zbuf; +static size_t zbufsize; + +static size_t +GunzipWrite(z_stream *z, char *in, size_t insize, FILE *fp) +{ + static bool firstblock = true; /* XXX not re-entrable/usable */ + const size_t hdrlen = 10; + size_t nw = 0; + int rv; + + z->next_in = in; + z->avail_in = insize; + /* + * Since contrib/zlib for some reason is compiled + * without GUNZIP define, we need to skip the gzip + * header manually. Kernel puts minimal 10 byte + * header, see sys/kern/subr_compressor.c:gz_reset(). + */ + if (firstblock) { + z->next_in += hdrlen; + z->avail_in -= hdrlen; + firstblock = false; + } + do { + z->next_out = zbuf; + z->avail_out = zbufsize; + rv = inflate(z, Z_NO_FLUSH); + if (rv != Z_OK && rv != Z_STREAM_END) { + logmsg(LOG_ERR, "decompression failed: %s", z->msg); + return (-1); + } + nw += sparsefwrite(zbuf, zbufsize - z->avail_out, fp); + } while (z->avail_in > 0 && rv != Z_STREAM_END); + + return (nw); +} + +static size_t +ZstdWrite(ZSTD_DCtx *Zctx, char *in, size_t insize, FILE *fp) +{ + ZSTD_inBuffer Zin; + ZSTD_outBuffer Zout; + size_t nw = 0; + int rv; + + Zin.src = in; + Zin.size = insize; + Zin.pos = 0; + do { + Zout.dst = zbuf; + Zout.size = zbufsize; + Zout.pos = 0; + rv = ZSTD_decompressStream(Zctx, &Zout, &Zin); + if (ZSTD_isError(rv)) { + logmsg(LOG_ERR, "decompression failed: %s", + ZSTD_getErrorName(rv)); + return (-1); + } + nw += sparsefwrite(zbuf, Zout.pos, fp); + } while (Zin.pos < Zin.size && rv != 0); + + return (nw); +} + static int -DoRegularFile(int fd, off_t dumpsize, u_int sectorsize, bool sparse, char *buf, - const char *device, const char *filename, FILE *fp) +DoRegularFile(int fd, off_t dumpsize, u_int sectorsize, bool sparse, + uint8_t compression, char *buf, const char *device, + const char *filename, FILE *fp) { - int he, hs, nr, nw, wl; + size_t nr, nw, wl; off_t dmpcnt, origsize; + z_stream z; /* gzip */ + ZSTD_DCtx *Zctx; /* zstd */ dmpcnt = 0; origsize = dumpsize; - he = 0; + if (compression == KERNELDUMP_COMP_GZIP) { + memset(&z, 0, sizeof(z)); + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + if (inflateInit2(&z, -MAX_WBITS) != Z_OK) { + logmsg(LOG_ERR, "failed to initialize zlib: %s", z.msg); + return (-1); + } + zbufsize = BUFFERSIZE; + } else if (compression == KERNELDUMP_COMP_ZSTD) { + if ((Zctx = ZSTD_createDCtx()) == NULL) { + logmsg(LOG_ERR, "failed to initialize zstd"); + return (-1); + } + zbufsize = ZSTD_DStreamOutSize(); + } + if (zbufsize > 0) + if ((zbuf = malloc(zbufsize)) == NULL) { + logmsg(LOG_ERR, "failed to alloc decompression buffer"); + return (-1); + } + while (dumpsize > 0) { wl = BUFFERSIZE; - if (wl > dumpsize) + if (wl > (size_t)dumpsize) wl = dumpsize; nr = read(fd, buf, roundup(wl, sectorsize)); - if (nr != (int)roundup(wl, sectorsize)) { + if (nr != roundup(wl, sectorsize)) { if (nr == 0) logmsg(LOG_WARNING, "WARNING: EOF on dump device"); @@ -465,48 +601,16 @@ DoRegularFile(int fd, off_t dumpsize, u_int sectorsize nerr++; return (-1); } - if (!sparse) { + if (compression == KERNELDUMP_COMP_GZIP) + nw = GunzipWrite(&z, buf, nr, fp); + else if (compression == KERNELDUMP_COMP_ZSTD) + nw = ZstdWrite(Zctx, buf, nr, fp); + else if (!sparse) nw = fwrite(buf, 1, wl, fp); - } else { - for (nw = 0; nw < nr; nw = he) { - /* find a contiguous block of zeroes */ - for (hs = nw; hs < nr; hs += BLOCKSIZE) { - for (he = hs; he < nr && buf[he] == 0; - ++he) - /* nothing */ ; - /* is the hole long enough to matter? */ - if (he >= hs + BLOCKSIZE) - break; - } - - /* back down to a block boundary */ - he &= BLOCKMASK; - - /* - * 1) Don't go beyond the end of the buffer. - * 2) If the end of the buffer is less than - * BLOCKSIZE bytes away, we're at the end - * of the file, so just grab what's left. - */ - if (hs + BLOCKSIZE > nr) - hs = he = nr; - - /* - * At this point, we have a partial ordering: - * nw <= hs <= he <= nr - * If hs > nw, buf[nw..hs] contains non-zero - * data. If he > hs, buf[hs..he] is all zeroes. - */ - if (hs > nw) - if (fwrite(buf + nw, hs - nw, 1, fp) - != 1) - break; - if (he > hs) - if (fseeko(fp, he - hs, SEEK_CUR) == -1) - break; - } - } - if (nw != wl) { + else + nw = sparsefwrite(buf, wl, fp); + if ((compression == KERNELDUMP_COMP_NONE && nw != wl) || + (compression != KERNELDUMP_COMP_NONE && nw < 0)) { logmsg(LOG_ERR, "write error on %s file: %m", filename); logmsg(LOG_WARNING, @@ -692,11 +796,14 @@ DoFile(const char *savedir, int savedirfd, const char } switch (kdhl.compression) { case KERNELDUMP_COMP_NONE: + uncompress = false; break; case KERNELDUMP_COMP_GZIP: case KERNELDUMP_COMP_ZSTD: if (compress && verbose) printf("dump is already compressed\n"); + if (uncompress && verbose) + printf("dump to be uncompressed\n"); compress = false; iscompressed = true; break; @@ -820,7 +927,7 @@ DoFile(const char *savedir, int savedirfd, const char snprintf(corename, sizeof(corename), "%s.%d.gz", istextdump ? "textdump.tar" : (isencrypted ? "vmcore_encrypted" : "vmcore"), bounds); - else if (iscompressed && !isencrypted) + else if (iscompressed && !isencrypted && !uncompress) snprintf(corename, sizeof(corename), "vmcore.%d.%s", bounds, (kdhl.compression == KERNELDUMP_COMP_GZIP) ? "gz" : "zst"); else @@ -901,8 +1008,9 @@ DoFile(const char *savedir, int savedirfd, const char goto closeall; } else { if (DoRegularFile(fddev, dumplength, sectorsize, - !(compress || iscompressed || isencrypted), buf, device, - corename, core) < 0) { + !(compress || iscompressed || isencrypted), + uncompress ? kdhl.compression : KERNELDUMP_COMP_NONE, + buf, device, corename, core) < 0) { goto closeall; } } @@ -927,7 +1035,7 @@ DoFile(const char *savedir, int savedirfd, const char "key.last"); } } - if (compress || iscompressed) { + if ((iscompressed && !uncompress) || compress) { snprintf(linkname, sizeof(linkname), "%s.last.%s", istextdump ? "textdump.tar" : (isencrypted ? "vmcore_encrypted" : "vmcore"), @@ -1123,7 +1231,7 @@ main(int argc, char **argv) if (argc < 0) exit(1); - while ((ch = getopt(argc, argv, "Ccfkm:vz")) != -1) + while ((ch = getopt(argc, argv, "Ccfkm:uvz")) != -1) switch(ch) { case 'C': checkfor = true; @@ -1144,6 +1252,9 @@ main(int argc, char **argv) exit(1); } break; + case 'u': + uncompress = true; + break; case 'v': verbose++; break; @@ -1159,6 +1270,8 @@ main(int argc, char **argv) if (clear && (compress || keep)) usage(); if (maxdumps > 0 && (checkfor || clear)) + usage(); + if (compress && uncompress) usage(); argc -= optind; argv += optind; From owner-svn-src-all@freebsd.org Thu Nov 19 02:44:08 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F2FFB47CC0D; Thu, 19 Nov 2020 02:44:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc3sh6VLzz3L95; Thu, 19 Nov 2020 02:44:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D1F0F1CF0C; Thu, 19 Nov 2020 02:44:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ2i8iZ067172; Thu, 19 Nov 2020 02:44:08 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ2i8hc067170; Thu, 19 Nov 2020 02:44:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011190244.0AJ2i8hc067170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Nov 2020 02:44:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367825 - stable/12/sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/nvme X-SVN-Commit-Revision: 367825 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 02:44:09 -0000 Author: mav Date: Thu Nov 19 02:44:08 2020 New Revision: 367825 URL: https://svnweb.freebsd.org/changeset/base/367825 Log: MFC r367625: Fix panic if NVMe is detached before the intrhook call. Modified: stable/12/sys/dev/nvme/nvme.c stable/12/sys/dev/nvme/nvme_ctrlr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme.c ============================================================================== --- stable/12/sys/dev/nvme/nvme.c Thu Nov 19 02:20:38 2020 (r367824) +++ stable/12/sys/dev/nvme/nvme.c Thu Nov 19 02:44:08 2020 (r367825) @@ -145,9 +145,14 @@ nvme_attach(device_t dev) } int -nvme_detach (device_t dev) +nvme_detach(device_t dev) { struct nvme_controller *ctrlr = DEVICE2SOFTC(dev); + + if (ctrlr->config_hook.ich_arg != NULL) { + config_intrhook_disestablish(&ctrlr->config_hook); + ctrlr->config_hook.ich_arg = NULL; + } nvme_ctrlr_destruct(ctrlr, dev); return (0); Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ctrlr.c Thu Nov 19 02:20:38 2020 (r367824) +++ stable/12/sys/dev/nvme/nvme_ctrlr.c Thu Nov 19 02:44:08 2020 (r367825) @@ -1099,6 +1099,7 @@ nvme_ctrlr_start_config_hook(void *arg) fail: nvme_ctrlr_fail(ctrlr); config_intrhook_disestablish(&ctrlr->config_hook); + ctrlr->config_hook.ich_arg = NULL; return; } @@ -1116,6 +1117,7 @@ fail: nvme_sysctl_initialize_ctrlr(ctrlr); config_intrhook_disestablish(&ctrlr->config_hook); + ctrlr->config_hook.ich_arg = NULL; ctrlr->is_initialized = 1; nvme_notify_new_controller(ctrlr); From owner-svn-src-all@freebsd.org Thu Nov 19 02:50:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 225C847CBE2; Thu, 19 Nov 2020 02:50:50 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc41P6YmXz3LdR; Thu, 19 Nov 2020 02:50:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D41281CBC1; Thu, 19 Nov 2020 02:50:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ2oni2068299; Thu, 19 Nov 2020 02:50:49 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ2omAt068294; Thu, 19 Nov 2020 02:50:48 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011190250.0AJ2omAt068294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Nov 2020 02:50:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367826 - in head/sys: arm/arm arm/include conf kern X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head/sys: arm/arm arm/include conf kern X-SVN-Commit-Revision: 367826 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 02:50:50 -0000 Author: markj Date: Thu Nov 19 02:50:48 2020 New Revision: 367826 URL: https://svnweb.freebsd.org/changeset/base/367826 Log: Remove NO_EVENTTIMERS support The arm configs that required it have been removed from the tree. Removing this option makes the callout code easier to read and discourages developers from adding new configs without eventtimer drivers. Reviewed by: ian, imp, mav Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27270 Modified: head/sys/arm/arm/machdep.c head/sys/arm/include/machdep.h head/sys/conf/options head/sys/conf/options.arm head/sys/kern/kern_et.c head/sys/kern/kern_timeout.c Modified: head/sys/arm/arm/machdep.c ============================================================================== --- head/sys/arm/arm/machdep.c Thu Nov 19 02:44:08 2020 (r367825) +++ head/sys/arm/arm/machdep.c Thu Nov 19 02:50:48 2020 (r367826) @@ -48,7 +48,6 @@ #include "opt_kstack_pages.h" #include "opt_platform.h" #include "opt_sched.h" -#include "opt_timer.h" #include __FBSDID("$FreeBSD$"); @@ -304,16 +303,12 @@ cpu_idle(int busy) CTR2(KTR_SPARE2, "cpu_idle(%d) at %d", busy, curcpu); spinlock_enter(); -#ifndef NO_EVENTTIMERS if (!busy) cpu_idleclock(); -#endif if (!sched_runnable()) cpu_sleep(0); -#ifndef NO_EVENTTIMERS if (!busy) cpu_activeclock(); -#endif spinlock_exit(); CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done", busy, curcpu); } @@ -325,22 +320,7 @@ cpu_idle_wakeup(int cpu) return (0); } -#ifdef NO_EVENTTIMERS -/* - * Most ARM platforms don't need to do anything special to init their clocks - * (they get intialized during normal device attachment), and by not defining a - * cpu_initclocks() function they get this generic one. Any platform that needs - * to do something special can just provide their own implementation, which will - * override this one due to the weak linkage. - */ void -arm_generic_initclocks(void) -{ -} -__weak_reference(arm_generic_initclocks, cpu_initclocks); - -#else -void cpu_initclocks(void) { @@ -353,7 +333,6 @@ cpu_initclocks(void) cpu_initclocks_bsp(); #endif } -#endif #ifdef PLATFORM void Modified: head/sys/arm/include/machdep.h ============================================================================== --- head/sys/arm/include/machdep.h Thu Nov 19 02:44:08 2020 (r367825) +++ head/sys/arm/include/machdep.h Thu Nov 19 02:50:48 2020 (r367826) @@ -39,7 +39,6 @@ vm_offset_t parse_boot_param(struct arm_boot_params *a void arm_parse_fdt_bootargs(void); void arm_print_kenv(void); -void arm_generic_initclocks(void); int arm_get_vfpstate(struct thread *td, void *args); /* Board-specific attributes */ Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Thu Nov 19 02:44:08 2020 (r367825) +++ head/sys/conf/options Thu Nov 19 02:50:48 2020 (r367826) @@ -180,7 +180,6 @@ NEW_PCIB opt_global.h NO_ADAPTIVE_MUTEXES opt_adaptive_mutexes.h NO_ADAPTIVE_RWLOCKS NO_ADAPTIVE_SX -NO_EVENTTIMERS opt_timer.h NO_OBSOLETE_CODE opt_global.h NO_SYSCTL_DESCR opt_global.h NSWBUF_MIN opt_param.h Modified: head/sys/conf/options.arm ============================================================================== --- head/sys/conf/options.arm Thu Nov 19 02:44:08 2020 (r367825) +++ head/sys/conf/options.arm Thu Nov 19 02:50:48 2020 (r367826) @@ -6,7 +6,6 @@ ARM_KERN_DIRECTMAP opt_vm.h ARM_L2_PIPT opt_global.h ARM_MANY_BOARD opt_global.h ARM_WANT_TP_ADDRESS opt_global.h -COUNTS_PER_SEC opt_timer.h CPSW_ETHERSWITCH opt_cpsw.h CPU_ARM9E opt_global.h CPU_ARM1176 opt_global.h @@ -61,7 +60,6 @@ SOC_ROCKCHIP_RK3188 opt_global.h SOC_TI_AM335X opt_global.h SOC_TEGRA2 opt_global.h XSCALE_CACHE_READ_WRITE_ALLOCATE opt_global.h -XSACLE_DISABLE_CCNT opt_timer.h VERBOSE_INIT_ARM opt_global.h VM_MAXUSER_ADDRESS opt_global.h GFB_DEBUG opt_gfb.h Modified: head/sys/kern/kern_et.c ============================================================================== --- head/sys/kern/kern_et.c Thu Nov 19 02:44:08 2020 (r367825) +++ head/sys/kern/kern_et.c Thu Nov 19 02:50:48 2020 (r367826) @@ -37,8 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "opt_timer.h" - SLIST_HEAD(et_eventtimers_list, eventtimer); static struct et_eventtimers_list eventtimers = SLIST_HEAD_INITIALIZER(et_eventtimers); @@ -130,9 +128,7 @@ void et_change_frequency(struct eventtimer *et, uint64_t newfreq) { -#ifndef NO_EVENTTIMERS cpu_et_frequency(et, newfreq); -#endif } /* Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Thu Nov 19 02:44:08 2020 (r367825) +++ head/sys/kern/kern_timeout.c Thu Nov 19 02:50:48 2020 (r367826) @@ -41,9 +41,6 @@ __FBSDID("$FreeBSD$"); #include "opt_callout_profiling.h" #include "opt_ddb.h" -#if defined(__arm__) -#include "opt_timer.h" -#endif #include "opt_rss.h" #include @@ -74,9 +71,7 @@ __FBSDID("$FreeBSD$"); #include #endif -#ifndef NO_EVENTTIMERS DPCPU_DECLARE(sbintime_t, hardclocktime); -#endif SDT_PROVIDER_DEFINE(callout_execute); SDT_PROBE_DEFINE1(callout_execute, , , callout__start, "struct callout *"); @@ -527,9 +522,8 @@ next: */ } while (((int)(firstb - lastb)) <= 0); cc->cc_firstevent = last; -#ifndef NO_EVENTTIMERS cpu_new_callout(curcpu, last, first); -#endif + #ifdef CALLOUT_PROFILING avg_depth_dir += (depth_dir * 1000 - avg_depth_dir) >> 8; avg_mpcalls_dir += (mpcalls_dir * 1000 - avg_mpcalls_dir) >> 8; @@ -594,7 +588,7 @@ callout_cc_add(struct callout *c, struct callout_cpu * LIST_INSERT_HEAD(&cc->cc_callwheel[bucket], c, c_links.le); if (cc->cc_bucket == bucket) cc_exec_next(cc) = c; -#ifndef NO_EVENTTIMERS + /* * Inform the eventtimers(4) subsystem there's a new callout * that has been inserted, but only if really required. @@ -606,7 +600,6 @@ callout_cc_add(struct callout *c, struct callout_cpu * cc->cc_firstevent = sbt; cpu_new_callout(cpu, sbt, c->c_time); } -#endif } static void @@ -851,15 +844,7 @@ callout_when(sbintime_t sbt, sbintime_t precision, int } if ((flags & C_HARDCLOCK) != 0 && sbt < tick_sbt) sbt = tick_sbt; - if ((flags & C_HARDCLOCK) != 0 || -#ifdef NO_EVENTTIMERS - sbt >= sbt_timethreshold) { - to_sbt = getsbinuptime(); - - /* Add safety belt for the case of hz > 1000. */ - to_sbt += tc_tick_sbt - tick_sbt; -#else - sbt >= sbt_tickthreshold) { + if ((flags & C_HARDCLOCK) != 0 || sbt >= sbt_tickthreshold) { /* * Obtain the time of the last hardclock() call on * this CPU directly from the kern_clocksource.c. @@ -872,7 +857,6 @@ callout_when(sbintime_t sbt, sbintime_t precision, int spinlock_enter(); to_sbt = DPCPU_GET(hardclocktime); spinlock_exit(); -#endif #endif if (cold && to_sbt == 0) to_sbt = sbinuptime(); From owner-svn-src-all@freebsd.org Thu Nov 19 02:53:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 334B647CF31; Thu, 19 Nov 2020 02:53:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc44W0lNQz3M59; Thu, 19 Nov 2020 02:53:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0CDAF1D08B; Thu, 19 Nov 2020 02:53:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ2rU1A073407; Thu, 19 Nov 2020 02:53:30 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ2rTwC073396; Thu, 19 Nov 2020 02:53:29 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011190253.0AJ2rTwC073396@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Nov 2020 02:53:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367827 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 367827 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 02:53:31 -0000 Author: markj Date: Thu Nov 19 02:53:29 2020 New Revision: 367827 URL: https://svnweb.freebsd.org/changeset/base/367827 Log: Move kern_clocksource.c to sys/conf/files Sponsored by: The FreeBSD Foundation Modified: head/sys/conf/files head/sys/conf/files.amd64 head/sys/conf/files.arm head/sys/conf/files.arm64 head/sys/conf/files.i386 head/sys/conf/files.mips head/sys/conf/files.powerpc head/sys/conf/files.riscv Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files Thu Nov 19 02:53:29 2020 (r367827) @@ -3777,6 +3777,7 @@ kern/ksched.c optional _kposix_priority_scheduling kern/kern_acct.c standard kern/kern_alq.c optional alq kern/kern_clock.c standard +kern/kern_clocksource.c standard kern/kern_condvar.c standard kern/kern_conf.c standard kern/kern_cons.c standard Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files.amd64 Thu Nov 19 02:53:29 2020 (r367827) @@ -388,7 +388,6 @@ dev/xen/pci/xen_acpi_pci.c optional xenhvm dev/xen/pci/xen_pci.c optional xenhvm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga -kern/kern_clocksource.c standard kern/imgact_aout.c optional compat_aout kern/link_elf_obj.c standard # Modified: head/sys/conf/files.arm ============================================================================== --- head/sys/conf/files.arm Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files.arm Thu Nov 19 02:53:29 2020 (r367827) @@ -1,7 +1,5 @@ # $FreeBSD$ -kern/kern_clocksource.c standard - arm/arm/autoconf.c standard arm/arm/bcopy_page.S standard arm/arm/bcopyinout.S standard Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files.arm64 Thu Nov 19 02:53:29 2020 (r367827) @@ -367,7 +367,6 @@ dev/vnic/thunder_bgx.c optional vnic pci dev/vnic/thunder_mdio_fdt.c optional vnic fdt dev/vnic/thunder_mdio.c optional vnic dev/vnic/lmac_if.m optional inet | inet6 | vnic -kern/kern_clocksource.c standard kern/msi_if.m optional intrng kern/pic_if.m optional intrng kern/subr_devmap.c standard Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files.i386 Thu Nov 19 02:53:29 2020 (r367827) @@ -211,7 +211,6 @@ i386/pci/pci_cfgreg.c optional pci i386/pci/pci_pir.c optional pci isa/syscons_isa.c optional sc isa/vga_isa.c optional vga -kern/kern_clocksource.c standard kern/imgact_aout.c optional compat_aout kern/subr_sfbuf.c standard libkern/divdi3.c standard Modified: head/sys/conf/files.mips ============================================================================== --- head/sys/conf/files.mips Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files.mips Thu Nov 19 02:53:29 2020 (r367827) @@ -48,7 +48,6 @@ mips/mips/uma_machdep.c standard mips/mips/vm_machdep.c standard # misc opt-in bits -kern/kern_clocksource.c standard kern/link_elf_obj.c standard kern/subr_atomic64.c optional mips | mipsel | mipshf | mipselhf kern/subr_busdma_bufalloc.c standard Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files.powerpc Thu Nov 19 02:53:29 2020 (r367827) @@ -110,7 +110,6 @@ dev/tsec/if_tsec_fdt.c optional tsec dev/uart/uart_cpu_powerpc.c optional uart dev/usb/controller/ehci_fsl.c optional ehci mpc85xx dev/vt/hw/ofwfb/ofwfb.c optional vt aim -kern/kern_clocksource.c standard kern/subr_atomic64.c optional powerpc | powerpcspe kern/subr_dummy_vdso_tc.c standard kern/syscalls.c optional ktr Modified: head/sys/conf/files.riscv ============================================================================== --- head/sys/conf/files.riscv Thu Nov 19 02:50:48 2020 (r367826) +++ head/sys/conf/files.riscv Thu Nov 19 02:53:29 2020 (r367827) @@ -13,7 +13,6 @@ dev/xilinx/axi_quad_spi.c optional xilinx_spi dev/xilinx/axidma.c optional axidma xdma dev/xilinx/if_xae.c optional xae dev/xilinx/xlnx_pcib.c optional pci fdt xlnx_pcib -kern/kern_clocksource.c standard kern/msi_if.m standard kern/pic_if.m standard kern/subr_devmap.c standard From owner-svn-src-all@freebsd.org Thu Nov 19 03:59:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5FC2D47E537; Thu, 19 Nov 2020 03:59:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc5XY2BbLz3Ppm; Thu, 19 Nov 2020 03:59:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3E0DF1DC8D; Thu, 19 Nov 2020 03:59:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ3xP0n012038; Thu, 19 Nov 2020 03:59:25 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ3xMA8012024; Thu, 19 Nov 2020 03:59:22 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011190359.0AJ3xMA8012024@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Nov 2020 03:59:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367828 - in head/sys: amd64/amd64 dev/mem powerpc/aim vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head/sys: amd64/amd64 dev/mem powerpc/aim vm X-SVN-Commit-Revision: 367828 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 03:59:25 -0000 Author: markj Date: Thu Nov 19 03:59:21 2020 New Revision: 367828 URL: https://svnweb.freebsd.org/changeset/base/367828 Log: vm_phys: Try to clean up NUMA KPIs It can useful for code outside the VM system to look up the NUMA domain of a page backing a virtual or physical address, specifically when creating NUMA-aware data structures. We have _vm_phys_domain() for this, but the leading underscore implies that it's an internal function, and vm_phys.h has dependencies on a number of other headers. Rename vm_phys_domain() to vm_page_domain(), and _vm_phys_domain() to vm_phys_domain(). Make the latter an inline function. Add _vm_phys.h and define struct vm_phys_seg there so that it's easier to use in other headers. Include it from vm_page.h so that vm_page_domain() can be defined there. Include machine/vmparam.h from _vm_phys.h since it depends directly on some constants defined there. Reviewed by: alc Reviewed by: dougm, kib (earlier versions) Differential Revision: https://reviews.freebsd.org/D27207 Added: head/sys/vm/_vm_phys.h (contents, props changed) Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/amd64/pmap.c head/sys/dev/mem/memdev.c head/sys/powerpc/aim/mmu_oea64.c head/sys/powerpc/aim/mmu_radix.c head/sys/vm/uma_core.c head/sys/vm/vm_kern.c head/sys/vm/vm_page.c head/sys/vm/vm_page.h head/sys/vm/vm_pagequeue.h head/sys/vm/vm_phys.c head/sys/vm/vm_phys.h head/sys/vm/vm_reserv.c Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/amd64/amd64/mp_machdep.c Thu Nov 19 03:59:21 2020 (r367828) @@ -380,7 +380,7 @@ mp_realloc_pcpu(int cpuid, int domain) vm_offset_t oa, na; oa = (vm_offset_t)&__pcpu[cpuid]; - if (_vm_phys_domain(pmap_kextract(oa)) == domain) + if (vm_phys_domain(pmap_kextract(oa)) == domain) return; m = vm_page_alloc_domain(NULL, 0, domain, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ); Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/amd64/amd64/pmap.c Thu Nov 19 03:59:21 2020 (r367828) @@ -452,7 +452,7 @@ static __inline int pc_to_domain(struct pv_chunk *pc) { - return (_vm_phys_domain(DMAP_TO_PHYS((vm_offset_t)pc))); + return (vm_phys_domain(DMAP_TO_PHYS((vm_offset_t)pc))); } #else static __inline int @@ -4611,7 +4611,7 @@ pmap_page_array_startup(long pages) end = start + pages * sizeof(struct vm_page); for (va = start; va < end; va += NBPDR) { pfn = first_page + (va - start) / sizeof(struct vm_page); - domain = _vm_phys_domain(ptoa(pfn)); + domain = vm_phys_domain(ptoa(pfn)); pdpe = pmap_pdpe(kernel_pmap, va); if ((*pdpe & X86_PG_V) == 0) { pa = vm_phys_early_alloc(domain, PAGE_SIZE); @@ -5147,7 +5147,7 @@ retry: pc->pc_map[0] = PC_FREE0 & ~1ul; /* preallocated bit 0 */ pc->pc_map[1] = PC_FREE1; pc->pc_map[2] = PC_FREE2; - pvc = &pv_chunks[_vm_phys_domain(m->phys_addr)]; + pvc = &pv_chunks[vm_phys_domain(m->phys_addr)]; mtx_lock(&pvc->pvc_lock); TAILQ_INSERT_TAIL(&pvc->pvc_list, pc, pc_lru); mtx_unlock(&pvc->pvc_lock); Modified: head/sys/dev/mem/memdev.c ============================================================================== --- head/sys/dev/mem/memdev.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/dev/mem/memdev.c Thu Nov 19 03:59:21 2020 (r367828) @@ -111,7 +111,7 @@ memioctl(struct cdev *dev, u_long cmd, caddr_t data, i &td->td_proc->p_vmspace->vm_pmap, me->me_vaddr); if (me->me_paddr != 0) { me->me_state = ME_STATE_MAPPED; - me->me_domain = _vm_phys_domain(me->me_paddr); + me->me_domain = vm_phys_domain(me->me_paddr); } else { me->me_state = ME_STATE_VALID; } Modified: head/sys/powerpc/aim/mmu_oea64.c ============================================================================== --- head/sys/powerpc/aim/mmu_oea64.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/powerpc/aim/mmu_oea64.c Thu Nov 19 03:59:21 2020 (r367828) @@ -3470,7 +3470,7 @@ moea64_page_array_startup(long pages) } for (i = 0; phys_avail[i + 1] != 0; i+= 2) { - domain = _vm_phys_domain(phys_avail[i]); + domain = vm_phys_domain(phys_avail[i]); KASSERT(domain < MAXMEMDOM, ("Invalid phys_avail NUMA domain %d!\n", domain)); size = btoc(phys_avail[i + 1] - phys_avail[i]); Modified: head/sys/powerpc/aim/mmu_radix.c ============================================================================== --- head/sys/powerpc/aim/mmu_radix.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/powerpc/aim/mmu_radix.c Thu Nov 19 03:59:21 2020 (r367828) @@ -6312,7 +6312,7 @@ mmu_radix_page_array_startup(long pages) /* TODO: NUMA vm_page_array. Blocked out until then (copied from amd64). */ for (va = start; va < end; va += L3_PAGE_SIZE) { pfn = first_page + (va - start) / sizeof(struct vm_page); - domain = _vm_phys_domain(ptoa(pfn)); + domain = vm_phys_domain(ptoa(pfn)); l2e = pmap_pml2e(kernel_pmap, va); if ((be64toh(*l2e) & PG_V) == 0) { pa = vm_phys_early_alloc(domain, PAGE_SIZE); Added: head/sys/vm/_vm_phys.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/vm/_vm_phys.h Thu Nov 19 03:59:21 2020 (r367828) @@ -0,0 +1,73 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2002-2006 Rice University + * Copyright (c) 2007 Alan L. Cox + * All rights reserved. + * + * This software was developed for the FreeBSD Project by Alan L. Cox, + * Olivier Crameri, Peter Druschel, Sitaram Iyer, and Juan Navarro. + * + * 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 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 + * HOLDERS 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 __VM_PHYS_H_ +#define __VM_PHYS_H_ + +#include + +#ifndef VM_NFREEORDER_MAX +#define VM_NFREEORDER_MAX VM_NFREEORDER +#endif + +struct vm_page; +#ifndef VM_PAGE_HAVE_PGLIST +TAILQ_HEAD(pglist, vm_page); +#define VM_PAGE_HAVE_PGLIST +#endif + +struct vm_freelist { + struct pglist pl; + int lcnt; +}; + +struct vm_phys_seg { + vm_paddr_t start; + vm_paddr_t end; + vm_page_t first_page; +#if VM_NRESERVLEVEL > 0 + vm_reserv_t first_reserv; +#endif +#ifdef __aarch64__ + void *md_first; +#endif + int domain; + struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER_MAX]; +}; + +extern struct vm_phys_seg vm_phys_segs[]; +extern int vm_phys_nsegs; + +#endif /* !__VM_PHYS_H_ */ Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/uma_core.c Thu Nov 19 03:59:21 2020 (r367828) @@ -3254,7 +3254,7 @@ item_domain(void *item) { int domain; - domain = _vm_phys_domain(vtophys(item)); + domain = vm_phys_domain(vtophys(item)); KASSERT(domain >= 0 && domain < vm_ndomains, ("%s: unknown domain for item %p", __func__, item)); return (domain); Modified: head/sys/vm/vm_kern.c ============================================================================== --- head/sys/vm/vm_kern.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/vm_kern.c Thu Nov 19 03:59:21 2020 (r367828) @@ -91,8 +91,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include #include #include @@ -236,9 +236,9 @@ kmem_alloc_attr_domain(int domain, vm_size_t size, int vmem_free(vmem, addr, size); return (0); } - KASSERT(vm_phys_domain(m) == domain, + KASSERT(vm_page_domain(m) == domain, ("kmem_alloc_attr_domain: Domain mismatch %d != %d", - vm_phys_domain(m), domain)); + vm_page_domain(m), domain)); if ((flags & M_ZERO) && (m->flags & PG_ZERO) == 0) pmap_zero_page(m); vm_page_valid(m); @@ -313,9 +313,9 @@ kmem_alloc_contig_domain(int domain, vm_size_t size, i vmem_free(vmem, addr, size); return (0); } - KASSERT(vm_phys_domain(m) == domain, + KASSERT(vm_page_domain(m) == domain, ("kmem_alloc_contig_domain: Domain mismatch %d != %d", - vm_phys_domain(m), domain)); + vm_page_domain(m), domain)); end_m = m + npages; tmp = addr; for (; m < end_m; m++) { @@ -489,9 +489,9 @@ retry: kmem_unback(object, addr, i); return (KERN_NO_SPACE); } - KASSERT(vm_phys_domain(m) == domain, + KASSERT(vm_page_domain(m) == domain, ("kmem_back_domain: Domain mismatch %d != %d", - vm_phys_domain(m), domain)); + vm_page_domain(m), domain)); if (flags & M_ZERO && (m->flags & PG_ZERO) == 0) pmap_zero_page(m); KASSERT((m->oflags & VPO_UNMANAGED) != 0, @@ -573,7 +573,7 @@ _kmem_unback(vm_object_t object, vm_offset_t addr, vm_ end = offset + size; VM_OBJECT_WLOCK(object); m = vm_page_lookup(object, atop(offset)); - domain = vm_phys_domain(m); + domain = vm_page_domain(m); if (__predict_true((m->oflags & VPO_KMEM_EXEC) == 0)) arena = vm_dom[domain].vmd_kernel_arena; else Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/vm_page.c Thu Nov 19 03:59:21 2020 (r367828) @@ -2892,7 +2892,7 @@ vm_page_reclaim_run(int req_class, int domain, u_long unlock: VM_OBJECT_WUNLOCK(object); } else { - MPASS(vm_phys_domain(m) == domain); + MPASS(vm_page_domain(m) == domain); vmd = VM_DOMAIN(domain); vm_domain_free_lock(vmd); order = m->order; @@ -2923,7 +2923,7 @@ unlock: cnt = 0; vm_domain_free_lock(vmd); do { - MPASS(vm_phys_domain(m) == domain); + MPASS(vm_page_domain(m) == domain); SLIST_REMOVE_HEAD(&free, plinks.s.ss); vm_phys_free_pages(m, 0); cnt++; @@ -3597,7 +3597,7 @@ vm_page_pqbatch_submit(vm_page_t m, uint8_t queue) ("page %p is unmanaged", m)); KASSERT(queue < PQ_COUNT, ("invalid queue %d", queue)); - domain = vm_phys_domain(m); + domain = vm_page_domain(m); pq = &vm_pagequeue_domain(m)->vmd_pagequeues[queue]; critical_enter(); Modified: head/sys/vm/vm_page.h ============================================================================== --- head/sys/vm/vm_page.h Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/vm_page.h Thu Nov 19 03:59:21 2020 (r367828) @@ -70,6 +70,7 @@ #define _VM_PAGE_ #include +#include /* * Management of resident (logical) pages. @@ -993,6 +994,22 @@ vm_page_none_valid(vm_page_t m) { return (m->valid == 0); +} + +static inline int +vm_page_domain(vm_page_t m) +{ +#ifdef NUMA + int domn, segind; + + segind = m->segind; + KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m)); + domn = vm_phys_segs[segind].domain; + KASSERT(domn >= 0 && domn < vm_ndomains, ("domain %d m %p", domn, m)); + return (domn); +#else + return (0); +#endif } #endif /* _KERNEL */ Modified: head/sys/vm/vm_pagequeue.h ============================================================================== --- head/sys/vm/vm_pagequeue.h Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/vm_pagequeue.h Thu Nov 19 03:59:21 2020 (r367828) @@ -389,7 +389,7 @@ static inline struct vm_domain * vm_pagequeue_domain(vm_page_t m) { - return (VM_DOMAIN(vm_phys_domain(m))); + return (VM_DOMAIN(vm_page_domain(m))); } /* Modified: head/sys/vm/vm_phys.c ============================================================================== --- head/sys/vm/vm_phys.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/vm_phys.c Thu Nov 19 03:59:21 2020 (r367828) @@ -649,24 +649,6 @@ vm_phys_register_domains(int ndomains, struct mem_affi #endif } -int -_vm_phys_domain(vm_paddr_t pa) -{ -#ifdef NUMA - int i; - - if (vm_ndomains == 1) - return (0); - for (i = 0; mem_affinity[i].end != 0; i++) - if (mem_affinity[i].start <= pa && - mem_affinity[i].end >= pa) - return (mem_affinity[i].domain); - return (-1); -#else - return (0); -#endif -} - /* * Split a contiguous, power of two-sized set of physical pages. * Modified: head/sys/vm/vm_phys.h ============================================================================== --- head/sys/vm/vm_phys.h Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/vm_phys.h Thu Nov 19 03:59:21 2020 (r367828) @@ -42,12 +42,8 @@ #ifdef _KERNEL -#ifndef VM_NFREEORDER_MAX -#define VM_NFREEORDER_MAX VM_NFREEORDER -#endif +extern vm_paddr_t phys_avail[]; -extern vm_paddr_t phys_avail[PHYS_AVAIL_COUNT]; - /* Domains must be dense (non-sparse) and zero-based. */ struct mem_affinity { vm_paddr_t start; @@ -59,28 +55,6 @@ extern struct mem_affinity *mem_affinity; extern int *mem_locality; #endif -struct vm_freelist { - struct pglist pl; - int lcnt; -}; - -struct vm_phys_seg { - vm_paddr_t start; - vm_paddr_t end; - vm_page_t first_page; -#if VM_NRESERVLEVEL > 0 - vm_reserv_t first_reserv; -#endif -#ifdef __aarch64__ - void *md_first; -#endif - int domain; - struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER_MAX]; -}; - -extern struct vm_phys_seg vm_phys_segs[]; -extern int vm_phys_nsegs; - /* * The following functions are only to be used by the virtual memory system. */ @@ -114,29 +88,23 @@ void vm_phys_early_startup(void); int vm_phys_avail_largest(void); vm_paddr_t vm_phys_avail_size(int i); -/* - * - * vm_phys_domain: - * - * Return the index of the domain the page belongs to. - */ static inline int -vm_phys_domain(vm_page_t m) +vm_phys_domain(vm_paddr_t pa) { #ifdef NUMA - int domn, segind; + int i; - /* XXXKIB try to assert that the page is managed */ - segind = m->segind; - KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m)); - domn = vm_phys_segs[segind].domain; - KASSERT(domn < vm_ndomains, ("domain %d m %p", domn, m)); - return (domn); + if (vm_ndomains == 1) + return (0); + for (i = 0; mem_affinity[i].end != 0; i++) + if (mem_affinity[i].start <= pa && + mem_affinity[i].end >= pa) + return (mem_affinity[i].domain); + return (-1); #else return (0); #endif } -int _vm_phys_domain(vm_paddr_t pa); #endif /* _KERNEL */ #endif /* !_VM_PHYS_H_ */ Modified: head/sys/vm/vm_reserv.c ============================================================================== --- head/sys/vm/vm_reserv.c Thu Nov 19 02:53:29 2020 (r367827) +++ head/sys/vm/vm_reserv.c Thu Nov 19 03:59:21 2020 (r367828) @@ -63,8 +63,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include #include @@ -780,7 +780,7 @@ out: } } else return (NULL); - KASSERT(vm_phys_domain(m) == domain, + KASSERT(vm_page_domain(m) == domain, ("vm_reserv_alloc_contig: Page domain does not match requested.")); /* From owner-svn-src-all@freebsd.org Thu Nov 19 04:27:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7799547E8E5; Thu, 19 Nov 2020 04:27:52 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc69N30Lfz3R4Z; Thu, 19 Nov 2020 04:27:52 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5516A1E285; Thu, 19 Nov 2020 04:27:52 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ4RqYO030477; Thu, 19 Nov 2020 04:27:52 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ4RqTd030476; Thu, 19 Nov 2020 04:27:52 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011190427.0AJ4RqTd030476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 19 Nov 2020 04:27:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367829 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367829 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 04:27:52 -0000 Author: mjg Date: Thu Nov 19 04:27:51 2020 New Revision: 367829 URL: https://svnweb.freebsd.org/changeset/base/367829 Log: smp: fix smp_rendezvous_cpus_retry usage before smp starts Since none of the other CPUs are running there is nobody to clear their entries and the routine spins indefinitely. Modified: head/sys/kern/subr_smp.c Modified: head/sys/kern/subr_smp.c ============================================================================== --- head/sys/kern/subr_smp.c Thu Nov 19 03:59:21 2020 (r367828) +++ head/sys/kern/subr_smp.c Thu Nov 19 04:27:51 2020 (r367829) @@ -896,6 +896,21 @@ smp_rendezvous_cpus_retry(cpuset_t map, int cpu; /* + * Only one CPU to execute on. + */ + if (!smp_started) { + spinlock_enter(); + if (setup_func != NULL) + setup_func(arg); + if (action_func != NULL) + action_func(arg); + if (teardown_func != NULL) + teardown_func(arg); + spinlock_exit(); + return; + } + + /* * Execute an action on all specified CPUs while retrying until they * all acknowledge completion. */ From owner-svn-src-all@freebsd.org Thu Nov 19 04:28:40 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69BA147EDD2; Thu, 19 Nov 2020 04:28:40 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc6BJ2XJpz3RD1; Thu, 19 Nov 2020 04:28:40 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A0951E307; Thu, 19 Nov 2020 04:28:40 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ4SeQj030560; Thu, 19 Nov 2020 04:28:40 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ4SeL0030559; Thu, 19 Nov 2020 04:28:40 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011190428.0AJ4SeL0030559@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 19 Nov 2020 04:28:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367830 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 367830 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 04:28:40 -0000 Author: mjg Date: Thu Nov 19 04:28:39 2020 New Revision: 367830 URL: https://svnweb.freebsd.org/changeset/base/367830 Log: cred: fix minor nits in r367695 Noted by: jhb Modified: head/sys/kern/kern_prot.c head/sys/sys/ucred.h Modified: head/sys/kern/kern_prot.c ============================================================================== --- head/sys/kern/kern_prot.c Thu Nov 19 04:27:51 2020 (r367829) +++ head/sys/kern/kern_prot.c Thu Nov 19 04:28:39 2020 (r367830) @@ -2082,6 +2082,7 @@ crfree_final(struct ucred *cr) __func__, cr->cr_users, cr)); KASSERT(cr->cr_ref == 0, ("%s: ref %d not == 0 on cred %p", __func__, cr->cr_ref, cr)); + /* * Some callers of crget(), such as nfs_statfs(), allocate a temporary * credential, but don't allocate a uidinfo structure. Modified: head/sys/sys/ucred.h ============================================================================== --- head/sys/sys/ucred.h Thu Nov 19 04:27:51 2020 (r367829) +++ head/sys/sys/ucred.h Thu Nov 19 04:28:39 2020 (r367830) @@ -128,12 +128,13 @@ credbatch_prep(struct credbatch *crb) crb->ref = 0; } void credbatch_add(struct credbatch *crb, struct thread *td); + static inline void credbatch_process(struct credbatch *crb __unused) { } -void credbatch_add(struct credbatch *crb, struct thread *td); + void credbatch_final(struct credbatch *crb); void change_egid(struct ucred *newcred, gid_t egid); From owner-svn-src-all@freebsd.org Thu Nov 19 04:51:36 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08BE147F0CC; Thu, 19 Nov 2020 04:51:36 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (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 4Cc6hl6H9Vz3hks; Thu, 19 Nov 2020 04:51:35 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x42e.google.com with SMTP id b6so5084777wrt.4; Wed, 18 Nov 2020 20:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Ek+mp1wwqiO0LhiE01djxEyUAuiPJ5Wh4dvDrJOusPI=; b=PxLIKnLavVn/H/tQWIrwLEvWbI4vGi2jviOn5zSciA8D50RQl/kqThhvBL3hBMu7Vw ayRfQO/A9L8sBXojVPpeOOjOgJm2KrrocAHC+liS+UGvu021KSPvrNpyi95wCM3ADBMm q8B65mLneFTqFzIixYpJAk1Fpz7/dADQLk2RehdTMe73iq9cIrz9p+g4qGgmGtDAvscV IUrVXG7VBtFiQfS2XceZotzFI+Njb06eXRBRsd2JkcHW1w+jNtlEUgGZUfnxFjiABljG V3uh0Cnb1Iw+PoZ0xpLT9M78fdD0zQEa6PJ2WZITRUbWF3U4jZy76x+Gg8CHTQ2BUBSt DbnA== 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=Ek+mp1wwqiO0LhiE01djxEyUAuiPJ5Wh4dvDrJOusPI=; b=tXaaCvYeI/DO+1tY9qednUeEL14Z/FaQ9ctKA44o7FbHs0fIElwD/xm32DhpBYLr+h 0nvBqLCg3f063fTzJxAeiEro9UKh4ovtmcQpeGZZVZ+nJNosDPcM6VejGWaNjxNHNR7R qh5v1wbphgDCCtLSL8qRNDbzJIiCMa5gRrL8tOfNA3IzGYk6Qs6OhvXbMOdrGK72R5+t GzxtiubnFegqyXzrt++sXvflEkKu37fhOQqlStGfY3nvhIsBmPpuH3jAtk9mtF0rayLE Fuz1AjVc+gwQ0AYRiVzE+D+9pxF/RH0N4qgWLg+CUsGjqwcDXZtgOWDtiJGLQB9p36in MXIA== X-Gm-Message-State: AOAM532+5UFCa35kjHzXw/nQBFdsYzSC6tmwriovX0kZGrThQuzCgvG3 m69S19hWdha4Ob6F/rdSIkCzEsaqmLDkcLMjXEAHqM6rE4s= X-Google-Smtp-Source: ABdhPJyArgCIHMADRb8H259QJski/VY4MzEyv9wvOe9LYplwq5DM0wdSsdzKfn2k3uO9UojpB57pysxb1JasgnpjrY4= X-Received: by 2002:adf:9b98:: with SMTP id d24mr7856501wrc.17.1605761493870; Wed, 18 Nov 2020 20:51:33 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:dec7:0:0:0:0:0 with HTTP; Wed, 18 Nov 2020 20:51:32 -0800 (PST) In-Reply-To: <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> References: <202011141922.0AEJM2ld055995@repo.freebsd.org> <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> From: Mateusz Guzik Date: Thu, 19 Nov 2020 05:51:32 +0100 Message-ID: Subject: Re: svn commit: r367695 - in head/sys: kern sys To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Cc6hl6H9Vz3hks X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 04:51:36 -0000 On 11/19/20, John Baldwin wrote: > On 11/18/20 2:16 PM, Mateusz Guzik wrote: >> On 11/17/20, John Baldwin wrote: >>> On 11/14/20 11:22 AM, Mateusz Guzik wrote: >> Interested parties can check the consumer (also seen in the diff) to >> see this is for consistency. I don't think any comments are warranted >> in the header. > > I did read the consumer, and there didn't seem tremendous value in the > extra line there. > One thing to note is that there are more thing to batch than currently implemented, meaning the established pattern is going get more users. With everyone implementing the same routines, even if nops, it is pretty clear what's going on. In contrast if random calls are missing the reader is left wondering if there is a bug. Either way I see no reason to either comment add a comment in the header nor to remove the nop func. >>> These changes would benefit from review. >>> >> >> I don't think it's feasible to ask for review for everything lest it >> degardes to rubber stamping and I don't think this change warranted >> it, regardless of the cosmetic issues which can always show up. > > That is not consistent with the direction the project is moving. If you > check the commit logs of other high-volume committers such as markj@, > kib@, or myself, you will find that a substantial number of those commits > are reviewed (typically in phabricator) without preventing us from > making useful progress. Also, while the previous core did not mandate > reviews, we moved closer to it when the Pre-Commit Review chapter was > added to the Committer's Guide: > > https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/pre-commit-review.html > > In the related thread on developers@ we indicated that while weren't yet > making pre-commit review mandatory, we collectively want to move in that > direction. > If you exclude bite-size commits, you will see I am getting reviews for thing which are outside of my work area or which include design choices. Past that other people keep committing without reviews anyway. That said, it may be this patch indeed should have been reviewed, but as it is I don't think this is the case. -- Mateusz Guzik From owner-svn-src-all@freebsd.org Thu Nov 19 04:53:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 237A047F514; Thu, 19 Nov 2020 04:53:02 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) (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 4Cc6kQ0Bl2z3hrf; Thu, 19 Nov 2020 04:53:01 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf42.google.com with SMTP id b11so2267596qvr.9; Wed, 18 Nov 2020 20:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jW5rxoUTZfm+CegqOObnIauwX5H1l1yqCAIjj76wE68=; b=V2fa/DildPT21R464aR7E3bNf/IZVYBPJA6eYL797J2SyCQ+d6KJs7WJCSnE2hWz70 6gqkXXAZbObalChL6KhfManI+9CzerECsOeJxryEmW9qgIOGn6agVPwHxjaKhTsV4cv1 PF0abN2rbMWa/I//6//NGOcyCgyMT25NQ2uNcWV5xGSEi0Al4l5xZLPccr1xaEaYaEBM /SLsjxUUdhL0uwtUhEqj5mmsd5shA4qqCFMsHNlL5kinXIiDE0uDVSGkvmRQO6QB93H6 XWon5vxfS8uOnUbTcggRYNN8ggr7NQlh/z+hT5OUQdupwY0apgkyJsVHgnwGASiJqMNt 8mNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=jW5rxoUTZfm+CegqOObnIauwX5H1l1yqCAIjj76wE68=; b=S+vPgxepeE3H2ZSFBDFnsM6M+lTYnDfRT5TTkJqh+/o2zA4rEqrlQy2hg75VqUAX80 xrDRBmZbXV1ohmXkTm2dR7wnI03Ruy8ZNOZGFaMrzhW1ogOuBHlX749EG1RLTpzu3Aaj TB0dXVnXusqpLdPz/RkWrMLqwVhK5ZzZkqXLkwrsRAJaYEyrz+wDgIx9OwEwIgrkl/QZ Br4qoVymcoJGbZuqtPNNe8DG5Plc6ZH2eJyJMdGvKB0OLtvZuvMpK7H1+t+YPGXN6UgG YDP6MizEbbd7fWiU8koZVtn6+O2klUZiXQZw1+Th+jgAyXyR5pn8WvaVp3j8LSrjisry RIeQ== X-Gm-Message-State: AOAM530uoDPkv+pfxBdoWkzvjPuk4eaEKJtbZg2wpTvgdQsiomtek1WQ /ebLuR/0o7bw2IW89MgmHcJxkBDWLts= X-Google-Smtp-Source: ABdhPJzRexCsaRrpMPiu1MTJFbls9pEuLKoppycmchcCr7DPB6aE54wqdzXo+F/s+LoJAXg1KOAP3A== X-Received: by 2002:a0c:b34a:: with SMTP id a10mr9305790qvf.15.1605761580461; Wed, 18 Nov 2020 20:53:00 -0800 (PST) Received: from raichu ([142.126.164.150]) by smtp.gmail.com with ESMTPSA id t205sm8063364qke.35.2020.11.18.20.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 20:52:59 -0800 (PST) Sender: Mark Johnston Date: Wed, 18 Nov 2020 23:52:57 -0500 From: Mark Johnston To: John Baldwin Cc: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r367695 - in head/sys: kern sys Message-ID: References: <202011141922.0AEJM2ld055995@repo.freebsd.org> <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> X-Rspamd-Queue-Id: 4Cc6kQ0Bl2z3hrf X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 04:53:02 -0000 On Wed, Nov 18, 2020 at 03:37:36PM -0800, John Baldwin wrote: > On 11/18/20 2:16 PM, Mateusz Guzik wrote: > > On 11/17/20, John Baldwin wrote: > >> On 11/14/20 11:22 AM, Mateusz Guzik wrote: > > Interested parties can check the consumer (also seen in the diff) to > > see this is for consistency. I don't think any comments are warranted > > in the header. > > I did read the consumer, and there didn't seem tremendous value in the > extra line there. > > >> These changes would benefit from review. > >> > > > > I don't think it's feasible to ask for review for everything lest it > > degardes to rubber stamping and I don't think this change warranted > > it, regardless of the cosmetic issues which can always show up. > > That is not consistent with the direction the project is moving. If you > check the commit logs of other high-volume committers such as markj@, > kib@, or myself, you will find that a substantial number of those commits > are reviewed (typically in phabricator) without preventing us from > making useful progress. Also, while the previous core did not mandate > reviews, we moved closer to it when the Pre-Commit Review chapter was > added to the Committer's Guide: > > https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/pre-commit-review.html > > In the related thread on developers@ we indicated that while weren't yet > making pre-commit review mandatory, we collectively want to move in that > direction. So, I personally don't really like the idea of mandatory reviews. It's a drag, especially for volunteers. It works ok in areas that have active maintainers, but lots of FreeBSD does not. For instance, pretty much every change to sys/vm gets a review, but only by convention. It's not perfect, and in particular it discourages me from making some changes both because getting review is a hassle and because I don't want to spam other VM developers (especially volunteers) with minor things. If all changes require some sort of sign-off, even if it's effectively rubber-stamping, I fear it'll discourage a lot of small, worthwhile contributions while also burning out reviewers. Meanwhile, we had issues for a long time where changes to the CSPRNG code were blocked for lack of review, and we have some problems with the LOCALBASE changes despite review. For better or worse, FreeBSD has no sole technical authority to direct development. More than many other projects, we rely on consensus and more broadly the ability of developers to engage with each other even when their communication styles differ. Since Phabricator was introduced it's been a lot easier to get feedback on patches, and non-committers have a better vehicle to propose patches. No edict was needed for that. On the other hand, FCP doesn't seem to have been successful. I suspect that mailing lists are sufficient for the same purpose that FCP is for; if someone doesn't care to socialize some changes on the lists, it's unlikely that they'll do so in a FCP, and because FreeBSD has no one who can really mandate development process, FCP doesn't buy us much. I tried adding RELNOTES so that it's easier for us to advertise our work to users; it's worked so-so, and I suspect that a lot of developers don't care about advertising their work or just don't know about RELNOTES. Our development processes end up being largely dictated by social norms, which are influenced by the most prolific committers. Mateusz is making a lot of commits to the kernel without any review. Most other committers would try to get a review for similar changes. For what it's worth I personally trust Mateusz to make well-reasoned changes, and to own his bugs. He does regularly ask for review and testing and I don't spend as much time as I should on his reviews. The problem, though, is the default assumption that most changes are not worth reviewing at all because they're small, mechanical, no one cares, whatever. It's worth soliciting review if only so that at least one other person has an idea of what's changing in the tree, because there _will_ come a time when it helps that person make changes of their own, or find a bug. Even if a reviewer doesn't deeply understand a diff, they might suggest stylistic changes that make the code more readable, or comment on related code in a way that's useful later. Similarly, verbose commit logs can seem pointless but are a huge help down the road. I know this is a common observation but it comes up all the time for me. With regard to the future direction of src development, I would propose a middle ground. Most, if not all, changes should get a Phabricator review. There should be some minimum period between creation of that review and a commit. The developer should make some effort to cc active committers to the code. Some areas of the tree will have stricter rules, but in general absence of feedback means that it's ok to commit. Exceptions might apply to build fixes, etc.. This still imposes some friction on the development process, but I have trouble seeing why someone's contibution might be gated on their ability to commit at a moment's notice. There are some technical issues around Phabricator that would need to be ironed out before this is really doable. For me, the main one is that email notifications are all-or-nothing: I would very much like to be able to get email for each new review without automatically being subscribed. From owner-svn-src-all@freebsd.org Thu Nov 19 05:44:42 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 667802E8218; Thu, 19 Nov 2020 05:44:42 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc7t16gr5z3kt9; Thu, 19 Nov 2020 05:44:41 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D7DBE1F207; Thu, 19 Nov 2020 05:44:41 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ5ifLH080013; Thu, 19 Nov 2020 05:44:41 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ5ifFi080011; Thu, 19 Nov 2020 05:44:41 GMT (envelope-from des@FreeBSD.org) Message-Id: <202011190544.0AJ5ifFi080011@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Thu, 19 Nov 2020 05:44:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367831 - in vendor/openpam/dist: . lib/libpam X-SVN-Group: vendor X-SVN-Commit-Author: des X-SVN-Commit-Paths: in vendor/openpam/dist: . lib/libpam X-SVN-Commit-Revision: 367831 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 05:44:42 -0000 Author: des Date: Thu Nov 19 05:44:41 2020 New Revision: 367831 URL: https://svnweb.freebsd.org/changeset/base/367831 Log: Merge upstream r948: fix race condition in openpam_ttyconv(3). Modified: vendor/openpam/dist/CREDITS vendor/openpam/dist/lib/libpam/openpam_ttyconv.c Modified: vendor/openpam/dist/CREDITS ============================================================================== --- vendor/openpam/dist/CREDITS Thu Nov 19 04:28:39 2020 (r367830) +++ vendor/openpam/dist/CREDITS Thu Nov 19 05:44:41 2020 (r367831) @@ -18,6 +18,7 @@ ideas: Ankita Pal Baptiste Daroussin Brian Fundakowski Feldman + Brooks Davis Christos Zoulas Daniel Richard G. Darren J. Moffat Modified: vendor/openpam/dist/lib/libpam/openpam_ttyconv.c ============================================================================== --- vendor/openpam/dist/lib/libpam/openpam_ttyconv.c Thu Nov 19 04:28:39 2020 (r367830) +++ vendor/openpam/dist/lib/libpam/openpam_ttyconv.c Thu Nov 19 05:44:41 2020 (r367831) @@ -94,12 +94,6 @@ prompt_tty(int ifd, int ofd, const char *message, char int pos, ret; char ch; - /* write prompt */ - if (write(ofd, message, strlen(message)) < 0) { - openpam_log(PAM_LOG_ERROR, "write(): %m"); - return (-1); - } - /* turn echo off if requested */ slflag = 0; /* prevent bogus uninitialized variable warning */ if (!echo) { @@ -113,6 +107,12 @@ prompt_tty(int ifd, int ofd, const char *message, char openpam_log(PAM_LOG_ERROR, "tcsetattr(): %m"); return (-1); } + } + + /* write prompt */ + if (write(ofd, message, strlen(message)) < 0) { + openpam_log(PAM_LOG_ERROR, "write(): %m"); + return (-1); } /* install signal handlers */ From owner-svn-src-all@freebsd.org Thu Nov 19 05:47:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ACFC12E8030; Thu, 19 Nov 2020 05:47:00 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc7wh4WRFz3lGM; Thu, 19 Nov 2020 05:47:00 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E06C1EF2E; Thu, 19 Nov 2020 05:47:00 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ5l03t080179; Thu, 19 Nov 2020 05:47:00 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ5l0Ef080177; Thu, 19 Nov 2020 05:47:00 GMT (envelope-from des@FreeBSD.org) Message-Id: <202011190547.0AJ5l0Ef080177@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Thu, 19 Nov 2020 05:47:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367832 - in head/contrib/openpam: . lib/libpam X-SVN-Group: head X-SVN-Commit-Author: des X-SVN-Commit-Paths: in head/contrib/openpam: . lib/libpam X-SVN-Commit-Revision: 367832 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 05:47:00 -0000 Author: des Date: Thu Nov 19 05:46:59 2020 New Revision: 367832 URL: https://svnweb.freebsd.org/changeset/base/367832 Log: Merge upstream r948: fix race condition in openpam_ttyconv(3). Modified: head/contrib/openpam/CREDITS head/contrib/openpam/lib/libpam/openpam_ttyconv.c Directory Properties: head/contrib/openpam/ (props changed) Modified: head/contrib/openpam/CREDITS ============================================================================== --- head/contrib/openpam/CREDITS Thu Nov 19 05:44:41 2020 (r367831) +++ head/contrib/openpam/CREDITS Thu Nov 19 05:46:59 2020 (r367832) @@ -18,6 +18,7 @@ ideas: Ankita Pal Baptiste Daroussin Brian Fundakowski Feldman + Brooks Davis Christos Zoulas Daniel Richard G. Darren J. Moffat Modified: head/contrib/openpam/lib/libpam/openpam_ttyconv.c ============================================================================== --- head/contrib/openpam/lib/libpam/openpam_ttyconv.c Thu Nov 19 05:44:41 2020 (r367831) +++ head/contrib/openpam/lib/libpam/openpam_ttyconv.c Thu Nov 19 05:46:59 2020 (r367832) @@ -94,12 +94,6 @@ prompt_tty(int ifd, int ofd, const char *message, char int pos, ret; char ch; - /* write prompt */ - if (write(ofd, message, strlen(message)) < 0) { - openpam_log(PAM_LOG_ERROR, "write(): %m"); - return (-1); - } - /* turn echo off if requested */ slflag = 0; /* prevent bogus uninitialized variable warning */ if (!echo) { @@ -113,6 +107,12 @@ prompt_tty(int ifd, int ofd, const char *message, char openpam_log(PAM_LOG_ERROR, "tcsetattr(): %m"); return (-1); } + } + + /* write prompt */ + if (write(ofd, message, strlen(message)) < 0) { + openpam_log(PAM_LOG_ERROR, "write(): %m"); + return (-1); } /* install signal handlers */ From owner-svn-src-all@freebsd.org Thu Nov 19 06:30:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1E3FD2E91DB; Thu, 19 Nov 2020 06:30:27 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cc8tq0Jr1z3mp4; Thu, 19 Nov 2020 06:30:27 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED8061F2FA; Thu, 19 Nov 2020 06:30:26 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ6UQoC004829; Thu, 19 Nov 2020 06:30:26 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ6UPvR004824; Thu, 19 Nov 2020 06:30:25 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011190630.0AJ6UPvR004824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 19 Nov 2020 06:30:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367833 - in head/sys: kern security/mac sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern security/mac sys X-SVN-Commit-Revision: 367833 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 06:30:27 -0000 Author: mjg Date: Thu Nov 19 06:30:25 2020 New Revision: 367833 URL: https://svnweb.freebsd.org/changeset/base/367833 Log: pipe: allow for lockless pipe_stat pipes get stated all thet time and this avoidably contributed to contention. The pipe lock is only held to accomodate MAC and to check the type. Since normally there is no probe for pipe stat depessimize this by having the flag. The pipe_state field gets modified with locks held all the time and it's not feasible to convert them to use atomic store. Move the type flag away to a separate variable as a simple cleanup and to provide stable field to read. Use short for both fields to avoid growing the struct. While here short-circuit MAC for pipe_poll as well. Modified: head/sys/kern/sys_pipe.c head/sys/security/mac/mac_framework.c head/sys/security/mac/mac_framework.h head/sys/security/mac/mac_pipe.c head/sys/sys/pipe.h Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Thu Nov 19 05:46:59 2020 (r367832) +++ head/sys/kern/sys_pipe.c Thu Nov 19 06:30:25 2020 (r367833) @@ -140,7 +140,7 @@ __FBSDID("$FreeBSD$"); /* #define PIPE_NODIRECT */ #define PIPE_PEER(pipe) \ - (((pipe)->pipe_state & PIPE_NAMED) ? (pipe) : ((pipe)->pipe_peer)) + (((pipe)->pipe_type & PIPE_TYPE_NAMED) ? (pipe) : ((pipe)->pipe_peer)) /* * interfaces to the outside world @@ -403,7 +403,7 @@ pipe_named_ctor(struct pipe **ppipe, struct thread *td error = pipe_paircreate(td, &pp); if (error != 0) return (error); - pp->pp_rpipe.pipe_state |= PIPE_NAMED; + pp->pp_rpipe.pipe_type |= PIPE_TYPE_NAMED; *ppipe = &pp->pp_rpipe; return (0); } @@ -413,7 +413,7 @@ pipe_dtor(struct pipe *dpipe) { struct pipe *peer; - peer = (dpipe->pipe_state & PIPE_NAMED) != 0 ? dpipe->pipe_peer : NULL; + peer = (dpipe->pipe_type & PIPE_TYPE_NAMED) != 0 ? dpipe->pipe_peer : NULL; funsetown(&dpipe->pipe_sigio); pipeclose(dpipe); if (peer != NULL) { @@ -1328,7 +1328,7 @@ pipe_truncate(struct file *fp, off_t length, struct uc int error; cpipe = fp->f_data; - if (cpipe->pipe_state & PIPE_NAMED) + if (cpipe->pipe_type & PIPE_TYPE_NAMED) error = vnops.fo_truncate(fp, length, active_cred, td); else error = invfo_truncate(fp, length, active_cred, td); @@ -1443,7 +1443,7 @@ pipe_poll(struct file *fp, int events, struct ucred *a levents = events & (POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND); - if (rpipe->pipe_state & PIPE_NAMED && fp->f_flag & FREAD && levents && + if (rpipe->pipe_type & PIPE_TYPE_NAMED && fp->f_flag & FREAD && levents && fp->f_pipegen == rpipe->pipe_wgen) events |= POLLINIGNEOF; @@ -1496,23 +1496,22 @@ pipe_stat(struct file *fp, struct stat *ub, struct ucr #endif pipe = fp->f_data; - PIPE_LOCK(pipe); #ifdef MAC - error = mac_pipe_check_stat(active_cred, pipe->pipe_pair); - if (error) { + if (mac_pipe_check_stat_enabled()) { + PIPE_LOCK(pipe); + error = mac_pipe_check_stat(active_cred, pipe->pipe_pair); PIPE_UNLOCK(pipe); - return (error); + if (error) { + return (error); + } } #endif /* For named pipes ask the underlying filesystem. */ - if (pipe->pipe_state & PIPE_NAMED) { - PIPE_UNLOCK(pipe); + if (pipe->pipe_type & PIPE_TYPE_NAMED) { return (vnops.fo_stat(fp, ub, active_cred, td)); } - PIPE_UNLOCK(pipe); - bzero(ub, sizeof(*ub)); ub->st_mode = S_IFIFO; ub->st_blksize = PAGE_SIZE; @@ -1554,7 +1553,7 @@ pipe_chmod(struct file *fp, mode_t mode, struct ucred int error; cpipe = fp->f_data; - if (cpipe->pipe_state & PIPE_NAMED) + if (cpipe->pipe_type & PIPE_TYPE_NAMED) error = vn_chmod(fp, mode, active_cred, td); else error = invfo_chmod(fp, mode, active_cred, td); @@ -1569,7 +1568,7 @@ pipe_chown(struct file *fp, uid_t uid, gid_t gid, stru int error; cpipe = fp->f_data; - if (cpipe->pipe_state & PIPE_NAMED) + if (cpipe->pipe_type & PIPE_TYPE_NAMED) error = vn_chown(fp, uid, gid, active_cred, td); else error = invfo_chown(fp, uid, gid, active_cred, td); @@ -1758,7 +1757,7 @@ filt_piperead(struct knote *kn, long hint) kn->kn_data = rpipe->pipe_pages.cnt; if ((rpipe->pipe_state & PIPE_EOF) != 0 && - ((rpipe->pipe_state & PIPE_NAMED) == 0 || + ((rpipe->pipe_type & PIPE_TYPE_NAMED) == 0 || fp->f_pipegen != rpipe->pipe_wgen)) { kn->kn_flags |= EV_EOF; return (1); @@ -1778,7 +1777,7 @@ filt_pipewrite(struct knote *kn, long hint) * knlist and the list lock (i.e., the pipe lock) is therefore not held. */ if (wpipe->pipe_present == PIPE_ACTIVE || - (wpipe->pipe_state & PIPE_NAMED) != 0) { + (wpipe->pipe_type & PIPE_TYPE_NAMED) != 0) { PIPE_LOCK_ASSERT(wpipe, MA_OWNED); if (wpipe->pipe_state & PIPE_DIRECTW) { Modified: head/sys/security/mac/mac_framework.c ============================================================================== --- head/sys/security/mac/mac_framework.c Thu Nov 19 05:46:59 2020 (r367832) +++ head/sys/security/mac/mac_framework.c Thu Nov 19 06:30:25 2020 (r367833) @@ -141,6 +141,8 @@ FPFLAG(vnode_check_mmap); FPFLAG_RARE(vnode_check_poll); FPFLAG_RARE(vnode_check_rename_from); FPFLAG_RARE(vnode_check_access); +FPFLAG_RARE(pipe_check_stat); +FPFLAG_RARE(pipe_check_poll); #undef FPFLAG #undef FPFLAG_RARE @@ -433,6 +435,10 @@ struct mac_policy_fastpath_elem mac_policy_fastpath_ar .flag = &mac_vnode_check_rename_from_fp_flag }, { .offset = FPO(vnode_check_access), .flag = &mac_vnode_check_access_fp_flag }, + { .offset = FPO(pipe_check_stat), + .flag = &mac_pipe_check_stat_fp_flag }, + { .offset = FPO(pipe_check_poll), + .flag = &mac_pipe_check_poll_fp_flag }, }; static void Modified: head/sys/security/mac/mac_framework.h ============================================================================== --- head/sys/security/mac/mac_framework.h Thu Nov 19 05:46:59 2020 (r367832) +++ head/sys/security/mac/mac_framework.h Thu Nov 19 06:30:25 2020 (r367833) @@ -208,9 +208,30 @@ void mac_netinet6_nd6_send(struct ifnet *ifp, struct m int mac_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, unsigned long cmd, void *data); -int mac_pipe_check_poll(struct ucred *cred, struct pipepair *pp); -int mac_pipe_check_read(struct ucred *cred, struct pipepair *pp); +int mac_pipe_check_poll_impl(struct ucred *cred, struct pipepair *pp); +#ifdef MAC +extern bool mac_pipe_check_poll_fp_flag; +#else +#define mac_pipe_check_poll_fp_flag 0 +#endif +#define mac_pipe_check_poll_enabled() __predict_false(mac_pipe_check_poll_fp_flag) +static inline int +mac_pipe_check_poll(struct ucred *cred, struct pipepair *pp) +{ + + if (mac_pipe_check_poll_enabled()) + return (mac_pipe_check_poll_impl(cred, pp)); + return (0); +} + +#ifdef MAC +extern bool mac_pipe_check_stat_fp_flag; +#else +#define mac_pipe_check_stat_fp_flag 0 +#endif +#define mac_pipe_check_stat_enabled() __predict_false(mac_pipe_check_stat_fp_flag) int mac_pipe_check_stat(struct ucred *cred, struct pipepair *pp); +int mac_pipe_check_read(struct ucred *cred, struct pipepair *pp); int mac_pipe_check_write(struct ucred *cred, struct pipepair *pp); void mac_pipe_create(struct ucred *cred, struct pipepair *pp); void mac_pipe_destroy(struct pipepair *); Modified: head/sys/security/mac/mac_pipe.c ============================================================================== --- head/sys/security/mac/mac_pipe.c Thu Nov 19 05:46:59 2020 (r367832) +++ head/sys/security/mac/mac_pipe.c Thu Nov 19 06:30:25 2020 (r367833) @@ -163,7 +163,7 @@ MAC_CHECK_PROBE_DEFINE2(pipe_check_poll, "struct ucred "struct pipepair *"); int -mac_pipe_check_poll(struct ucred *cred, struct pipepair *pp) +mac_pipe_check_poll_impl(struct ucred *cred, struct pipepair *pp) { int error; Modified: head/sys/sys/pipe.h ============================================================================== --- head/sys/sys/pipe.h Thu Nov 19 05:46:59 2020 (r367832) +++ head/sys/sys/pipe.h Thu Nov 19 06:30:25 2020 (r367833) @@ -95,9 +95,13 @@ struct pipemapping { #define PIPE_LWANT 0x200 /* Process wants exclusive access to pointers/data. */ #define PIPE_DIRECTW 0x400 /* Pipe direct write active. */ #define PIPE_DIRECTOK 0x800 /* Direct mode ok. */ -#define PIPE_NAMED 0x1000 /* Is a named pipe. */ /* + * Bits in pipe_type. + */ +#define PIPE_TYPE_NAMED 0x001 /* Is a named pipe. */ + +/* * Per-pipe data structure. * Two of these are linked together to produce bi-directional pipes. */ @@ -111,7 +115,8 @@ struct pipe { struct sigio *pipe_sigio; /* information for async I/O */ struct pipe *pipe_peer; /* link with other direction */ struct pipepair *pipe_pair; /* container structure pointer */ - u_int pipe_state; /* pipe status info */ + u_short pipe_state; /* pipe status info */ + u_short pipe_type; /* pipe type info */ int pipe_busy; /* busy flag, mostly to handle rundown sanely */ int pipe_present; /* still present? */ int pipe_wgen; /* writer generation for named pipe */ From owner-svn-src-all@freebsd.org Thu Nov 19 07:23:40 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2CC372E9CBE; Thu, 19 Nov 2020 07:23:40 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcB4D0ZgSz3q22; Thu, 19 Nov 2020 07:23:40 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 06ADF20501; Thu, 19 Nov 2020 07:23:40 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ7Ndp1042005; Thu, 19 Nov 2020 07:23:39 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ7Ndqx042004; Thu, 19 Nov 2020 07:23:39 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <202011190723.0AJ7Ndqx042004@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Thu, 19 Nov 2020 07:23:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367834 - head/usr.sbin/bhyve X-SVN-Group: head X-SVN-Commit-Author: grehan X-SVN-Commit-Paths: head/usr.sbin/bhyve X-SVN-Commit-Revision: 367834 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 07:23:40 -0000 Author: grehan Date: Thu Nov 19 07:23:39 2020 New Revision: 367834 URL: https://svnweb.freebsd.org/changeset/base/367834 Log: Advance RIP after userspace instruction decode Add update to RIP after a userspace instruction decode (as is done for the in-kernel counterpart of this case). Submitted by: adam_fenn.io Reviewed by: cem, markj Approved by: grehan (bhyve) MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D27243 Modified: head/usr.sbin/bhyve/bhyverun.c Modified: head/usr.sbin/bhyve/bhyverun.c ============================================================================== --- head/usr.sbin/bhyve/bhyverun.c Thu Nov 19 06:30:25 2020 (r367833) +++ head/usr.sbin/bhyve/bhyverun.c Thu Nov 19 07:23:39 2020 (r367834) @@ -766,7 +766,11 @@ vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vm vie_restart(vie); mode = vmexit->u.inst_emul.paging.cpu_mode; cs_d = vmexit->u.inst_emul.cs_d; - (void)vmm_decode_instruction(mode, cs_d, vie); + if (vmm_decode_instruction(mode, cs_d, vie) != 0) + goto fail; + if (vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RIP, + vmexit->rip + vie->num_processed) != 0) + goto fail; } err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa, @@ -777,15 +781,17 @@ vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vm EPRINTLN("Unhandled memory access to 0x%lx\n", vmexit->u.inst_emul.gpa); } - - fprintf(stderr, "Failed to emulate instruction sequence [ "); - for (i = 0; i < vie->num_valid; i++) - fprintf(stderr, "%02x", vie->inst[i]); - FPRINTLN(stderr, " ] at 0x%lx", vmexit->rip); - return (VMEXIT_ABORT); + goto fail; } return (VMEXIT_CONTINUE); + +fail: + fprintf(stderr, "Failed to emulate instruction sequence [ "); + for (i = 0; i < vie->num_valid; i++) + fprintf(stderr, "%02x", vie->inst[i]); + FPRINTLN(stderr, " ] at 0x%lx", vmexit->rip); + return (VMEXIT_ABORT); } static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER; From owner-svn-src-all@freebsd.org Thu Nov 19 08:16:46 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70FF22EB411; Thu, 19 Nov 2020 08:16:46 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcCFV2nHnz3sd3; Thu, 19 Nov 2020 08:16:46 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5219220E86; Thu, 19 Nov 2020 08:16:46 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ8GkNp073486; Thu, 19 Nov 2020 08:16:46 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ8GkS5073485; Thu, 19 Nov 2020 08:16:46 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011190816.0AJ8GkS5073485@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 19 Nov 2020 08:16:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367835 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367835 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 08:16:46 -0000 Author: mjg Date: Thu Nov 19 08:16:45 2020 New Revision: 367835 URL: https://svnweb.freebsd.org/changeset/base/367835 Log: pipe: tidy up pipelock Modified: head/sys/kern/sys_pipe.c Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Thu Nov 19 07:23:39 2020 (r367834) +++ head/sys/kern/sys_pipe.c Thu Nov 19 08:16:45 2020 (r367835) @@ -614,14 +614,17 @@ pipespace(struct pipe *cpipe, int size) static __inline int pipelock(struct pipe *cpipe, int catch) { - int error; + int error, prio; PIPE_LOCK_ASSERT(cpipe, MA_OWNED); + + prio = PRIBIO; + if (catch) + prio |= PCATCH; while (cpipe->pipe_state & PIPE_LOCKFL) { cpipe->pipe_state |= PIPE_LWANT; error = msleep(cpipe, PIPE_MTX(cpipe), - catch ? (PRIBIO | PCATCH) : PRIBIO, - "pipelk", 0); + prio, "pipelk", 0); if (error != 0) return (error); } From owner-svn-src-all@freebsd.org Thu Nov 19 09:09:20 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 962E62EC1EB; Thu, 19 Nov 2020 09:09:20 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcDQ83vlMz3vwD; Thu, 19 Nov 2020 09:09:20 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 78DB3215C1; Thu, 19 Nov 2020 09:09:20 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ99KWN004148; Thu, 19 Nov 2020 09:09:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ99JCX004145; Thu, 19 Nov 2020 09:09:19 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011190909.0AJ99JCX004145@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 19 Nov 2020 09:09:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367836 - in stable/12/sys: dev/acpica dev/xen/control kern sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: dev/acpica dev/xen/control kern sys X-SVN-Commit-Revision: 367836 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 09:09:20 -0000 Author: kib Date: Thu Nov 19 09:09:19 2020 New Revision: 367836 URL: https://svnweb.freebsd.org/changeset/base/367836 Log: MFC r367398: Suspend all writeable local filesystems on power suspend. Modified: stable/12/sys/dev/acpica/acpi.c stable/12/sys/dev/xen/control/control.c stable/12/sys/kern/vfs_mount.c stable/12/sys/sys/mount.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/acpica/acpi.c ============================================================================== --- stable/12/sys/dev/acpica/acpi.c Thu Nov 19 08:16:45 2020 (r367835) +++ stable/12/sys/dev/acpica/acpi.c Thu Nov 19 09:09:19 2020 (r367836) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -3045,6 +3046,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state) EVENTHANDLER_INVOKE(power_suspend_early); stop_all_proc(); + suspend_all_fs(); EVENTHANDLER_INVOKE(power_suspend); #ifdef EARLY_AP_STARTUP @@ -3204,6 +3206,7 @@ backout: } #endif + resume_all_fs(); resume_all_proc(); EVENTHANDLER_INVOKE(power_resume); Modified: stable/12/sys/dev/xen/control/control.c ============================================================================== --- stable/12/sys/dev/xen/control/control.c Thu Nov 19 08:16:45 2020 (r367835) +++ stable/12/sys/dev/xen/control/control.c Thu Nov 19 09:09:19 2020 (r367836) @@ -113,6 +113,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -204,6 +205,7 @@ xctrl_suspend() xs_lock(); stop_all_proc(); xs_unlock(); + suspend_all_fs(); EVENTHANDLER_INVOKE(power_suspend); #ifdef EARLY_AP_STARTUP @@ -317,6 +319,7 @@ xctrl_suspend() } #endif + resume_all_fs(); resume_all_proc(); EVENTHANDLER_INVOKE(power_resume); Modified: stable/12/sys/kern/vfs_mount.c ============================================================================== --- stable/12/sys/kern/vfs_mount.c Thu Nov 19 08:16:45 2020 (r367835) +++ stable/12/sys/kern/vfs_mount.c Thu Nov 19 09:09:19 2020 (r367836) @@ -2057,3 +2057,67 @@ vfs_oexport_conv(const struct oexport_args *oexp, stru bcopy(oexp, exp, sizeof(*oexp)); exp->ex_numsecflavors = 0; } + +/* + * Suspend write operations on all local writeable filesystems. Does + * full sync of them in the process. + * + * Iterate over the mount points in reverse order, suspending most + * recently mounted filesystems first. It handles a case where a + * filesystem mounted from a md(4) vnode-backed device should be + * suspended before the filesystem that owns the vnode. + */ +void +suspend_all_fs(void) +{ + struct mount *mp; + int error; + + mtx_lock(&mountlist_mtx); + TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) { + error = vfs_busy(mp, MBF_MNTLSTLOCK | MBF_NOWAIT); + if (error != 0) + continue; + if ((mp->mnt_flag & (MNT_RDONLY | MNT_LOCAL)) != MNT_LOCAL || + (mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { + mtx_lock(&mountlist_mtx); + vfs_unbusy(mp); + continue; + } + error = vfs_write_suspend(mp, 0); + if (error == 0) { + MNT_ILOCK(mp); + MPASS((mp->mnt_kern_flag & MNTK_SUSPEND_ALL) == 0); + mp->mnt_kern_flag |= MNTK_SUSPEND_ALL; + MNT_IUNLOCK(mp); + mtx_lock(&mountlist_mtx); + } else { + printf("suspend of %s failed, error %d\n", + mp->mnt_stat.f_mntonname, error); + mtx_lock(&mountlist_mtx); + vfs_unbusy(mp); + } + } + mtx_unlock(&mountlist_mtx); +} + +void +resume_all_fs(void) +{ + struct mount *mp; + + mtx_lock(&mountlist_mtx); + TAILQ_FOREACH(mp, &mountlist, mnt_list) { + if ((mp->mnt_kern_flag & MNTK_SUSPEND_ALL) == 0) + continue; + mtx_unlock(&mountlist_mtx); + MNT_ILOCK(mp); + MPASS((mp->mnt_kern_flag & MNTK_SUSPEND) != 0); + mp->mnt_kern_flag &= ~MNTK_SUSPEND_ALL; + MNT_IUNLOCK(mp); + vfs_write_resume(mp, 0); + mtx_lock(&mountlist_mtx); + vfs_unbusy(mp); + } + mtx_unlock(&mountlist_mtx); +} Modified: stable/12/sys/sys/mount.h ============================================================================== --- stable/12/sys/sys/mount.h Thu Nov 19 08:16:45 2020 (r367835) +++ stable/12/sys/sys/mount.h Thu Nov 19 09:09:19 2020 (r367836) @@ -402,6 +402,7 @@ void __mnt_vnode_markerfree_active(struct vno #define MNTK_USES_BCACHE 0x00004000 /* FS uses the buffer cache. */ #define MNTK_TEXT_REFS 0x00008000 /* Keep use ref for text */ #define MNTK_VMSETSIZE_BUG 0x00010000 +#define MNTK_SUSPEND_ALL 0x00080000 /* Suspended by all-fs suspension */ #define MNTK_NOASYNC 0x00800000 /* disable async */ #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ @@ -972,6 +973,9 @@ vfs_sysctl_t vfs_stdsysctl; void syncer_suspend(void); void syncer_resume(void); + +void suspend_all_fs(void); +void resume_all_fs(void); #else /* !_KERNEL */ From owner-svn-src-all@freebsd.org Thu Nov 19 09:13:23 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CEA242EC88F; Thu, 19 Nov 2020 09:13:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcDVq5Yfcz3wPd; Thu, 19 Nov 2020 09:13:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B16EA2191B; Thu, 19 Nov 2020 09:13:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ9DN0f010259; Thu, 19 Nov 2020 09:13:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ9DNfA010258; Thu, 19 Nov 2020 09:13:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011190913.0AJ9DNfA010258@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 19 Nov 2020 09:13:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367837 - stable/12/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 367837 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 09:13:23 -0000 Author: kib Date: Thu Nov 19 09:13:23 2020 New Revision: 367837 URL: https://svnweb.freebsd.org/changeset/base/367837 Log: MFC r367609: mlx5en: Refactor repeated code to register media type to mlx5e_ifm_add(). Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:09:19 2020 (r367836) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:13:23 2020 (r367837) @@ -4135,6 +4135,14 @@ mlx5e_snd_tag_free(struct m_snd_tag *pmt) } } +static void +mlx5e_ifm_add(struct mlx5e_priv *priv, int type) +{ + ifmedia_add(&priv->media, type | IFM_ETHER, 0, NULL); + ifmedia_add(&priv->media, type | IFM_ETHER | IFM_FDX | + IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL); +} + static void * mlx5e_create_ifp(struct mlx5_core_dev *mdev) { @@ -4322,21 +4330,12 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) mlx5e_mode_table[i][j]; if (media_entry.baudrate == 0) continue; - if (MLX5E_PROT_MASK(i) & eth_proto_cap) { - ifmedia_add(&priv->media, - media_entry.subtype | - IFM_ETHER, 0, NULL); - ifmedia_add(&priv->media, - media_entry.subtype | - IFM_ETHER | IFM_FDX | - IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL); - } + if (MLX5E_PROT_MASK(i) & eth_proto_cap) + mlx5e_ifm_add(priv, media_entry.subtype); } } - ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO | IFM_FDX | - IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL); + mlx5e_ifm_add(priv, IFM_AUTO); /* Set autoselect by default */ ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO | IFM_FDX | From owner-svn-src-all@freebsd.org Thu Nov 19 09:15:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 14DAF2EC768; Thu, 19 Nov 2020 09:15:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcDXn04D9z3wVd; Thu, 19 Nov 2020 09:15:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9CDD21475; Thu, 19 Nov 2020 09:15:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ9F47u010404; Thu, 19 Nov 2020 09:15:04 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ9F4Pw010403; Thu, 19 Nov 2020 09:15:04 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011190915.0AJ9F4Pw010403@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 19 Nov 2020 09:15:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367838 - stable/12/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 367838 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 09:15:05 -0000 Author: kib Date: Thu Nov 19 09:15:04 2020 New Revision: 367838 URL: https://svnweb.freebsd.org/changeset/base/367838 Log: MFC r367610: mlx5en: Register all combinations of FDX/RXPAUSE/TXPAUSE as valid media types. Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:13:23 2020 (r367837) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:15:04 2020 (r367838) @@ -4139,6 +4139,15 @@ static void mlx5e_ifm_add(struct mlx5e_priv *priv, int type) { ifmedia_add(&priv->media, type | IFM_ETHER, 0, NULL); + ifmedia_add(&priv->media, type | IFM_ETHER | + IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL); + ifmedia_add(&priv->media, type | IFM_ETHER | IFM_ETH_RXPAUSE, 0, NULL); + ifmedia_add(&priv->media, type | IFM_ETHER | IFM_ETH_TXPAUSE, 0, NULL); + ifmedia_add(&priv->media, type | IFM_ETHER | IFM_FDX, 0, NULL); + ifmedia_add(&priv->media, type | IFM_ETHER | IFM_FDX | + IFM_ETH_RXPAUSE, 0, NULL); + ifmedia_add(&priv->media, type | IFM_ETHER | IFM_FDX | + IFM_ETH_TXPAUSE, 0, NULL); ifmedia_add(&priv->media, type | IFM_ETHER | IFM_FDX | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL); } From owner-svn-src-all@freebsd.org Thu Nov 19 09:16:23 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6AF1E2EC8A4; Thu, 19 Nov 2020 09:16:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcDZH2bvYz4QrL; Thu, 19 Nov 2020 09:16:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C0112191C; Thu, 19 Nov 2020 09:16:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ9GNCD010522; Thu, 19 Nov 2020 09:16:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ9GNSZ010521; Thu, 19 Nov 2020 09:16:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011190916.0AJ9GNSZ010521@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 19 Nov 2020 09:16:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367839 - stable/12/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 367839 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 09:16:23 -0000 Author: kib Date: Thu Nov 19 09:16:22 2020 New Revision: 367839 URL: https://svnweb.freebsd.org/changeset/base/367839 Log: MFC r367611: mlx5en: stop ignoring pauses and flow in the media reqs. Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:15:04 2020 (r367838) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:16:22 2020 (r367839) @@ -4308,8 +4308,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) /* Set default media status */ priv->media_status_last = IFM_AVALID; - priv->media_active_last = IFM_ETHER | IFM_AUTO | - IFM_ETH_RXPAUSE | IFM_FDX; + priv->media_active_last = IFM_ETHER | IFM_AUTO | IFM_FDX; /* setup default pauseframes configuration */ mlx5e_setup_pauseframes(priv); @@ -4329,7 +4328,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) mlx5_en_err(ifp, "Query port media capability failed, %d\n", err); } - ifmedia_init(&priv->media, IFM_IMASK | IFM_ETH_FMASK, + ifmedia_init(&priv->media, IFM_IMASK, mlx5e_media_change, mlx5e_media_status); speeds_num = ext ? MLX5E_EXT_LINK_SPEEDS_NUMBER : MLX5E_LINK_SPEEDS_NUMBER; From owner-svn-src-all@freebsd.org Thu Nov 19 09:17:41 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D68462EC77D; Thu, 19 Nov 2020 09:17:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcDbn5nQtz3wRh; Thu, 19 Nov 2020 09:17:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B959321476; Thu, 19 Nov 2020 09:17:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ9HfG7010636; Thu, 19 Nov 2020 09:17:41 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ9HfYB010635; Thu, 19 Nov 2020 09:17:41 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011190917.0AJ9HfYB010635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 19 Nov 2020 09:17:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367840 - stable/12/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 367840 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 09:17:41 -0000 Author: kib Date: Thu Nov 19 09:17:41 2020 New Revision: 367840 URL: https://svnweb.freebsd.org/changeset/base/367840 Log: MFC r367612: mlx5en: Set ifmr_current same as ifmr_active. Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:16:22 2020 (r367839) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Nov 19 09:17:41 2020 (r367840) @@ -492,7 +492,7 @@ mlx5e_media_status(struct ifnet *dev, struct ifmediare struct mlx5e_priv *priv = dev->if_softc; ifmr->ifm_status = priv->media_status_last; - ifmr->ifm_active = priv->media_active_last | + ifmr->ifm_current = ifmr->ifm_active = priv->media_active_last | (priv->params.rx_pauseframe_control ? IFM_ETH_RXPAUSE : 0) | (priv->params.tx_pauseframe_control ? IFM_ETH_TXPAUSE : 0); From owner-svn-src-all@freebsd.org Thu Nov 19 09:26:51 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0C4D2ECD1F; Thu, 19 Nov 2020 09:26:51 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcDpM6WRfz4R78; Thu, 19 Nov 2020 09:26:51 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D27992194F; Thu, 19 Nov 2020 09:26:51 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJ9Qp70016791; Thu, 19 Nov 2020 09:26:51 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJ9QpNi016790; Thu, 19 Nov 2020 09:26:51 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202011190926.0AJ9QpNi016790@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 19 Nov 2020 09:26:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367841 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 367841 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 09:26:52 -0000 Author: andrew Date: Thu Nov 19 09:26:51 2020 New Revision: 367841 URL: https://svnweb.freebsd.org/changeset/base/367841 Log: Fall back to use the GICR address from the generic interrupt struct When there is no ACPI redistributor sub-table in the MADT we need to fall back to use the GICR base address from the GIC CPU interface structure. Handle this fallback when adding memory to the device and when counting the number of redistributors. PR: 251171 Reported by: Andrey Fesenko Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D27247 Modified: head/sys/arm64/arm64/gic_v3_acpi.c Modified: head/sys/arm64/arm64/gic_v3_acpi.c ============================================================================== --- head/sys/arm64/arm64/gic_v3_acpi.c Thu Nov 19 09:17:41 2020 (r367840) +++ head/sys/arm64/arm64/gic_v3_acpi.c Thu Nov 19 09:26:51 2020 (r367841) @@ -88,6 +88,7 @@ struct madt_table_data { device_t dev; ACPI_MADT_GENERIC_DISTRIBUTOR *dist; int count; + bool rdist_use_gicc; }; static void @@ -120,12 +121,16 @@ static void rdist_map(ACPI_SUBTABLE_HEADER *entry, void *arg) { ACPI_MADT_GENERIC_REDISTRIBUTOR *redist; + ACPI_MADT_GENERIC_INTERRUPT *intr; struct madt_table_data *madt_data; + rman_res_t count; madt_data = (struct madt_table_data *)arg; switch(entry->Type) { case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + if (madt_data->rdist_use_gicc) + break; redist = (ACPI_MADT_GENERIC_REDISTRIBUTOR *)entry; madt_data->count++; @@ -134,6 +139,23 @@ rdist_map(ACPI_SUBTABLE_HEADER *entry, void *arg) redist->Length); break; + case ACPI_MADT_TYPE_GENERIC_INTERRUPT: + if (!madt_data->rdist_use_gicc) + break; + + intr = (ACPI_MADT_GENERIC_INTERRUPT *)entry; + + madt_data->count++; + /* + * Map the two 64k redistributor frames. + */ + count = GICR_RD_BASE_SIZE + GICR_SGI_BASE_SIZE; + if (madt_data->dist->Version == ACPI_MADT_GIC_VERSION_V4) + count += GICR_VLPI_BASE_SIZE + GICR_RESERVED_SIZE; + BUS_SET_RESOURCE(madt_data->parent, madt_data->dev, + SYS_RES_MEMORY, madt_data->count, intr->GicrBaseAddress, + count); + default: break; } @@ -190,8 +212,18 @@ gic_v3_acpi_identify(driver_t *driver, device_t parent madt_data.dist->BaseAddress, 128 * 1024); madt_data.dev = dev; + madt_data.rdist_use_gicc = false; acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, rdist_map, &madt_data); + if (madt_data.count == 0) { + /* + * No redistributors found, fall back to use the GICR + * address from the GICC sub-table. + */ + madt_data.rdist_use_gicc = true; + acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, + rdist_map, &madt_data); + } acpi_set_private(dev, (void *)(uintptr_t)madt_data.dist->Version); @@ -224,6 +256,15 @@ madt_count_redistrib(ACPI_SUBTABLE_HEADER *entry, void sc->gic_redists.nregions++; } +static void +madt_count_gicc_redistrib(ACPI_SUBTABLE_HEADER *entry, void *arg) +{ + struct gic_v3_softc *sc = arg; + + if (entry->Type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) + sc->gic_redists.nregions++; +} + static int gic_v3_acpi_count_regions(device_t dev) { @@ -245,6 +286,12 @@ gic_v3_acpi_count_regions(device_t dev) acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, madt_count_redistrib, sc); + /* Fall back to use the distributor GICR base address */ + if (sc->gic_redists.nregions == 0) { + acpi_walk_subtables(madt + 1, + (char *)madt + madt->Header.Length, + madt_count_gicc_redistrib, sc); + } acpi_unmap_table(madt); return (sc->gic_redists.nregions > 0 ? 0 : ENXIO); From owner-svn-src-all@freebsd.org Thu Nov 19 10:00:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 26BB72ED4F8; Thu, 19 Nov 2020 10:00:49 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcFYX6V9Sz4Sp2; Thu, 19 Nov 2020 10:00:48 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D1EA221EFF; Thu, 19 Nov 2020 10:00:48 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJA0mqj036192; Thu, 19 Nov 2020 10:00:48 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJA0mfp036191; Thu, 19 Nov 2020 10:00:48 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011191000.0AJA0mfp036191@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 19 Nov 2020 10:00:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367842 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367842 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 10:00:49 -0000 Author: mjg Date: Thu Nov 19 10:00:48 2020 New Revision: 367842 URL: https://svnweb.freebsd.org/changeset/base/367842 Log: thread: numa-aware zombie reaping The current global list is a significant problem, in particular induces a lot of cross-domain thread frees. When running poudriere on a 2 domain box about half of all frees were of that nature. Patch below introduces per-domain thread data containing zombie lists and domain-aware reaping. By default it only reaps from the current domain, only reaping from others if there is free TID shortage. A dedicated callout is introduced to reap lingering threads if there happens to be no activity. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D27185 Modified: head/sys/kern/kern_thread.c Modified: head/sys/kern/kern_thread.c ============================================================================== --- head/sys/kern/kern_thread.c Thu Nov 19 09:26:51 2020 (r367841) +++ head/sys/kern/kern_thread.c Thu Nov 19 10:00:48 2020 (r367842) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -64,9 +65,11 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include +#include #include /* @@ -128,9 +131,20 @@ SDT_PROBE_DEFINE(proc, , , lwp__exit); */ static uma_zone_t thread_zone; -static __exclusive_cache_line struct thread *thread_zombies; +struct thread_domain_data { + struct thread *tdd_zombies; + int tdd_reapticks; +} __aligned(CACHE_LINE_SIZE); +static struct thread_domain_data thread_domain_data[MAXMEMDOM]; + +static struct task thread_reap_task; +static struct callout thread_reap_callout; + static void thread_zombie(struct thread *); +static void thread_reap_all(void); +static void thread_reap_task_cb(void *, int); +static void thread_reap_callout_cb(void *); static int thread_unsuspend_one(struct thread *td, struct proc *p, bool boundary); static void thread_free_batched(struct thread *td); @@ -159,30 +173,45 @@ EVENTHANDLER_LIST_DEFINE(thread_init); EVENTHANDLER_LIST_DEFINE(thread_fini); static bool -thread_count_inc(void) +thread_count_inc_try(void) { - static struct timeval lastfail; - static int curfail; int nthreads_new; - thread_reap(); - nthreads_new = atomic_fetchadd_int(&nthreads, 1) + 1; if (nthreads_new >= maxthread - 100) { if (priv_check_cred(curthread->td_ucred, PRIV_MAXPROC) != 0 || nthreads_new >= maxthread) { atomic_subtract_int(&nthreads, 1); - if (ppsratecheck(&lastfail, &curfail, 1)) { - printf("maxthread limit exceeded by uid %u " - "(pid %d); consider increasing kern.maxthread\n", - curthread->td_ucred->cr_ruid, curproc->p_pid); - } return (false); } } return (true); } +static bool +thread_count_inc(void) +{ + static struct timeval lastfail; + static int curfail; + + thread_reap(); + if (thread_count_inc_try()) { + return (true); + } + + thread_reap_all(); + if (thread_count_inc_try()) { + return (true); + } + + if (ppsratecheck(&lastfail, &curfail, 1)) { + printf("maxthread limit exceeded by uid %u " + "(pid %d); consider increasing kern.maxthread\n", + curthread->td_ucred->cr_ruid, curproc->p_pid); + } + return (false); +} + static void thread_count_sub(int n) { @@ -500,6 +529,10 @@ threadinit(void) M_TIDHASH, M_WAITOK | M_ZERO); for (i = 0; i < tidhashlock + 1; i++) rw_init(&tidhashtbl_lock[i], "tidhash"); + + TASK_INIT(&thread_reap_task, 0, thread_reap_task_cb, NULL); + callout_init(&thread_reap_callout, 1); + callout_reset(&thread_reap_callout, 5 * hz, thread_reap_callout_cb, NULL); } /* @@ -508,12 +541,14 @@ threadinit(void) void thread_zombie(struct thread *td) { + struct thread_domain_data *tdd; struct thread *ztd; - ztd = atomic_load_ptr(&thread_zombies); + tdd = &thread_domain_data[vm_phys_domain(vtophys(td))]; + ztd = atomic_load_ptr(&tdd->tdd_zombies); for (;;) { td->td_zombie = ztd; - if (atomic_fcmpset_rel_ptr((uintptr_t *)&thread_zombies, + if (atomic_fcmpset_rel_ptr((uintptr_t *)&tdd->tdd_zombies, (uintptr_t *)&ztd, (uintptr_t)td)) break; continue; @@ -531,10 +566,10 @@ thread_stash(struct thread *td) } /* - * Reap zombie threads. + * Reap zombies from passed domain. */ -void -thread_reap(void) +static void +thread_reap_domain(struct thread_domain_data *tdd) { struct thread *itd, *ntd; struct tidbatch tidbatch; @@ -547,19 +582,26 @@ thread_reap(void) * Reading upfront is pessimal if followed by concurrent atomic_swap, * but most of the time the list is empty. */ - if (thread_zombies == NULL) + if (tdd->tdd_zombies == NULL) return; - itd = (struct thread *)atomic_swap_ptr((uintptr_t *)&thread_zombies, + itd = (struct thread *)atomic_swap_ptr((uintptr_t *)&tdd->tdd_zombies, (uintptr_t)NULL); if (itd == NULL) return; + /* + * Multiple CPUs can get here, the race is fine as ticks is only + * advisory. + */ + tdd->tdd_reapticks = ticks; + tidbatch_prep(&tidbatch); credbatch_prep(&credbatch); tdcount = 0; lim = NULL; limcount = 0; + while (itd != NULL) { ntd = itd->td_zombie; EVENTHANDLER_DIRECT_INVOKE(thread_dtor, itd); @@ -592,6 +634,68 @@ thread_reap(void) } MPASS(limcount != 0); lim_freen(lim, limcount); +} + +/* + * Reap zombies from all domains. + */ +static void +thread_reap_all(void) +{ + struct thread_domain_data *tdd; + int i, domain; + + domain = PCPU_GET(domain); + for (i = 0; i < vm_ndomains; i++) { + tdd = &thread_domain_data[(i + domain) % vm_ndomains]; + thread_reap_domain(tdd); + } +} + +/* + * Reap zombies from local domain. + */ +void +thread_reap(void) +{ + struct thread_domain_data *tdd; + int domain; + + domain = PCPU_GET(domain); + tdd = &thread_domain_data[domain]; + + thread_reap_domain(tdd); +} + +static void +thread_reap_task_cb(void *arg __unused, int pending __unused) +{ + + thread_reap_all(); +} + +static void +thread_reap_callout_cb(void *arg __unused) +{ + struct thread_domain_data *tdd; + int i, cticks, lticks; + bool wantreap; + + wantreap = false; + cticks = atomic_load_int(&ticks); + for (i = 0; i < vm_ndomains; i++) { + tdd = &thread_domain_data[i]; + lticks = tdd->tdd_reapticks; + if (tdd->tdd_zombies != NULL && + (u_int)(cticks - lticks) > 5 * hz) { + wantreap = true; + break; + } + } + + if (wantreap) + taskqueue_enqueue(taskqueue_thread, &thread_reap_task); + callout_reset(&thread_reap_callout, 5 * hz, thread_reap_callout_cb, NULL); } /* From owner-svn-src-all@freebsd.org Thu Nov 19 14:27:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0CBD46D160; Thu, 19 Nov 2020 14:27:02 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcMSk66WTz4jl4; Thu, 19 Nov 2020 14:27:02 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA22025695; Thu, 19 Nov 2020 14:27:02 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJER2v1001471; Thu, 19 Nov 2020 14:27:02 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJER2QC001469; Thu, 19 Nov 2020 14:27:02 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011191427.0AJER2QC001469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Thu, 19 Nov 2020 14:27:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367843 - head/release/arm64 X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/release/arm64 X-SVN-Commit-Revision: 367843 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 14:27:03 -0000 Author: manu Date: Thu Nov 19 14:27:01 2020 New Revision: 367843 URL: https://svnweb.freebsd.org/changeset/base/367843 Log: release: Switch the Allwinner board to GPT Allwinner bootrom have an alternate location for u-boot at 128k. Work was made recently in u-boot to relocate correctly if loaded from there. The advantage of this offset is that we can now use a GPT scheme. Modified: head/release/arm64/PINE64-LTS.conf head/release/arm64/PINE64.conf head/release/arm64/PINEBOOK.conf Modified: head/release/arm64/PINE64-LTS.conf ============================================================================== --- head/release/arm64/PINE64-LTS.conf Thu Nov 19 10:00:48 2020 (r367842) +++ head/release/arm64/PINE64-LTS.conf Thu Nov 19 14:27:01 2020 (r367843) @@ -13,7 +13,7 @@ IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" NODOC=1 -PART_SCHEME="MBR" +PART_SCHEME="GPT" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINE64-LTS" @@ -21,7 +21,7 @@ arm_install_uboot() { UBOOT_DIR="/usr/local/share/u-boot/u-boot-pine64-lts" UBOOT_FILES="u-boot-sunxi-with-spl.bin" chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \ - of=/dev/${mddev} bs=1k seek=8 conv=sync + of=/dev/${mddev} bs=128k seek=1 conv=sync return 0 } Modified: head/release/arm64/PINE64.conf ============================================================================== --- head/release/arm64/PINE64.conf Thu Nov 19 10:00:48 2020 (r367842) +++ head/release/arm64/PINE64.conf Thu Nov 19 14:27:01 2020 (r367843) @@ -13,7 +13,7 @@ IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" NODOC=1 -PART_SCHEME="MBR" +PART_SCHEME="GPT" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINE64" @@ -21,7 +21,7 @@ arm_install_uboot() { UBOOT_DIR="/usr/local/share/u-boot/u-boot-pine64" UBOOT_FILES="u-boot-sunxi-with-spl.bin" chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \ - of=/dev/${mddev} bs=1k seek=8 conv=sync + of=/dev/${mddev} bs=128k seek=1 conv=sync return 0 } Modified: head/release/arm64/PINEBOOK.conf ============================================================================== --- head/release/arm64/PINEBOOK.conf Thu Nov 19 10:00:48 2020 (r367842) +++ head/release/arm64/PINEBOOK.conf Thu Nov 19 14:27:01 2020 (r367843) @@ -13,7 +13,7 @@ IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" NODOC=1 -PART_SCHEME="MBR" +PART_SCHEME="GPT" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINEBOOK" @@ -21,7 +21,7 @@ arm_install_uboot() { UBOOT_DIR="/usr/local/share/u-boot/u-boot-pinebook" UBOOT_FILES="u-boot-sunxi-with-spl.bin" chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \ - of=/dev/${mddev} bs=1k seek=8 conv=sync + of=/dev/${mddev} bs=128k seek=1 conv=sync return 0 } From owner-svn-src-all@freebsd.org Thu Nov 19 15:40:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 616CA46E985; Thu, 19 Nov 2020 15:40:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcP632LRmz4nPl; Thu, 19 Nov 2020 15:40:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 435D9264A1; Thu, 19 Nov 2020 15:40:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJFexur048764; Thu, 19 Nov 2020 15:40:59 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJFexN0048763; Thu, 19 Nov 2020 15:40:59 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011191540.0AJFexN0048763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Nov 2020 15:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367844 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 367844 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 15:40:59 -0000 Author: markj Date: Thu Nov 19 15:40:58 2020 New Revision: 367844 URL: https://svnweb.freebsd.org/changeset/base/367844 Log: Micro-optimize vm_page_pqbatch_submit() Avoid calling vm_page_domain() twice. Discussed with: alc (in D27207) Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Thu Nov 19 14:27:01 2020 (r367843) +++ head/sys/vm/vm_page.c Thu Nov 19 15:40:58 2020 (r367844) @@ -3598,8 +3598,6 @@ vm_page_pqbatch_submit(vm_page_t m, uint8_t queue) KASSERT(queue < PQ_COUNT, ("invalid queue %d", queue)); domain = vm_page_domain(m); - pq = &vm_pagequeue_domain(m)->vmd_pagequeues[queue]; - critical_enter(); bq = DPCPU_PTR(pqbatch[domain][queue]); if (vm_batchqueue_insert(bq, m)) { @@ -3607,6 +3605,8 @@ vm_page_pqbatch_submit(vm_page_t m, uint8_t queue) return; } critical_exit(); + + pq = &VM_DOMAIN(domain)->vmd_pagequeues[queue]; vm_pagequeue_lock(pq); critical_enter(); bq = DPCPU_PTR(pqbatch[domain][queue]); From owner-svn-src-all@freebsd.org Thu Nov 19 15:41:43 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 484BF46E8EB; Thu, 19 Nov 2020 15:41:43 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcP6v1gRlz4nmw; Thu, 19 Nov 2020 15:41:43 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2CB1126363; Thu, 19 Nov 2020 15:41:43 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJFfhWU051142; Thu, 19 Nov 2020 15:41:43 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJFfhlG051141; Thu, 19 Nov 2020 15:41:43 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011191541.0AJFfhlG051141@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Nov 2020 15:41:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367845 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 367845 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 15:41:43 -0000 Author: markj Date: Thu Nov 19 15:41:42 2020 New Revision: 367845 URL: https://svnweb.freebsd.org/changeset/base/367845 Log: Wrap a long line in vm_pqbatch_process_page() Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Thu Nov 19 15:40:58 2020 (r367844) +++ head/sys/vm/vm_page.c Thu Nov 19 15:41:42 2020 (r367845) @@ -3545,7 +3545,8 @@ vm_pqbatch_process_page(struct vm_pagequeue *pq, vm_pa counter_u64_add(queue_nops, 1); break; } - KASSERT(old.queue != PQ_NONE || (old.flags & PGA_QUEUE_STATE_MASK) == 0, + KASSERT(old.queue != PQ_NONE || + (old.flags & PGA_QUEUE_STATE_MASK) == 0, ("%s: page %p has unexpected queue state", __func__, m)); new = old; From owner-svn-src-all@freebsd.org Thu Nov 19 16:57:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CF3934700D3; Thu, 19 Nov 2020 16:57:45 +0000 (UTC) (envelope-from debdrup@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcQpd5Zfbz4t50; Thu, 19 Nov 2020 16:57:45 +0000 (UTC) (envelope-from debdrup@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B26D82754C; Thu, 19 Nov 2020 16:57:45 +0000 (UTC) (envelope-from debdrup@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJGvjPq096068; Thu, 19 Nov 2020 16:57:45 GMT (envelope-from debdrup@FreeBSD.org) Received: (from debdrup@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJGvjB3096067; Thu, 19 Nov 2020 16:57:45 GMT (envelope-from debdrup@FreeBSD.org) Message-Id: <202011191657.0AJGvjB3096067@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: debdrup set sender to debdrup@FreeBSD.org using -f From: Daniel Ebdrup Jensen Date: Thu, 19 Nov 2020 16:57:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367846 - head/share/man/man7 X-SVN-Group: head X-SVN-Commit-Author: debdrup X-SVN-Commit-Paths: head/share/man/man7 X-SVN-Commit-Revision: 367846 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 16:57:45 -0000 Author: debdrup (doc committer) Date: Thu Nov 19 16:57:45 2020 New Revision: 367846 URL: https://svnweb.freebsd.org/changeset/base/367846 Log: intro.7: Add missing manual page Section 7 of the manual pages contain lots of very useful information, but finding the pages is not always obvious - to assist people in finding the information, add missing cross-references. Reviewed by: 0mp (mentor), mhorne, yuripv Approved by: 0mp (mentor Differential Revision: https://reviews.freebsd.org/D27284 Modified: head/share/man/man7/intro.7 Modified: head/share/man/man7/intro.7 ============================================================================== --- head/share/man/man7/intro.7 Thu Nov 19 15:41:42 2020 (r367845) +++ head/share/man/man7/intro.7 Thu Nov 19 16:57:45 2020 (r367846) @@ -28,7 +28,7 @@ .\" @(#)intro.7 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd May 3, 2020 +.Dd November 19, 2020 .Dt INTRO 7 .Os .Sh NAME @@ -37,12 +37,29 @@ .Sh DESCRIPTION This section contains miscellaneous documentation. .Bl -tag -width "mdoc.samples(7)" -offset indent +.It Xr arch 7 +supported CPU architectures and platforms .It Xr ascii 7 map of ASCII character set +.It Xr build 7 +build instructions for +.Fx .It Xr c 7 the C programming language +.It Xr clocks 7 +system timekeeping clocks available in +.Fx +.It Xr crypto 7 +cryptographic algorithms provided by OpenCrypto in +.Fx +.It Xr development 7 +development introduction to +.Fx .It Xr environ 7 user environment +.It Xr ffs 7 +commonly used filesystem in +.Fx .It Xr firewall 7 simple firewalls under .Fx @@ -61,6 +78,13 @@ introduction to the ports infrastructure of .It Xr security 7 security features available in .Fx +.It Xr stats 7 +statistics utilities available in +.Fx +.It Xr tests 7 +introduction to the +.Fx +Test Suite .It Xr tuning 7 general advice on tuning .Fx From owner-svn-src-all@freebsd.org Thu Nov 19 17:54:42 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A36D2470ABA; Thu, 19 Nov 2020 17:54:42 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcS4L4JKJz3C8Z; Thu, 19 Nov 2020 17:54:42 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 86756149; Thu, 19 Nov 2020 17:54:42 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJHsg0B033334; Thu, 19 Nov 2020 17:54:42 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJHsgGB033332; Thu, 19 Nov 2020 17:54:42 GMT (envelope-from imp@FreeBSD.org) Message-Id: <202011191754.0AJHsgGB033332@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 19 Nov 2020 17:54:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367847 - head/share/man/man4 X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/share/man/man4 X-SVN-Commit-Revision: 367847 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 17:54:42 -0000 Author: imp Date: Thu Nov 19 17:54:41 2020 New Revision: 367847 URL: https://svnweb.freebsd.org/changeset/base/367847 Log: Document disk ioctl First stab at documenting the different disk ioctl commands defined in sys/disk.h. Reviewed by: phk (prior version) Differential Revision: https://reviews.freebsd.org/D26994 Added: head/share/man/man4/disk.4 (contents, props changed) Modified: head/share/man/man4/Makefile Modified: head/share/man/man4/Makefile ============================================================================== --- head/share/man/man4/Makefile Thu Nov 19 16:57:45 2020 (r367846) +++ head/share/man/man4/Makefile Thu Nov 19 17:54:41 2020 (r367847) @@ -130,6 +130,7 @@ MAN= aac.4 \ ddb.4 \ devctl.4 \ disc.4 \ + disk.4 \ divert.4 \ ${_dpms.4} \ ds1307.4 \ Added: head/share/man/man4/disk.4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/disk.4 Thu Nov 19 17:54:41 2020 (r367847) @@ -0,0 +1,210 @@ +.\" Copyright (c) 2020 M. Warner Losh +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 20, 2020 +.Dt disk 4 +.Os +.Sh NAME +.Nm disk +.Nd common disk interfaces +.Sh SYNOPSIS +.Cd device cd +.Sh DESCRIPTION +Common block device IOCTLs +.Pp +All the block devices in the system should support these disk +.Xr ioctl 2 +commands defined here. +Much of this information is also available via the +.Xr geom 2 +attributes. +.Sh IOCTLS +The following +.Xr ioctl 2 +calls apply to disk drives, and are defined +in the +.In sys/disk.h +header file. +.Bl -tag -width DIOCGPROVIDERNAME +.It Dv DIOCGSECTORSIZE +.Pq Li "u_int" +Get the sector or block size of the device in bytes. +The sector size is the smallest unit of data which can be transferred +from this device. +This is usually a power of 2 but it might not be (e.g. CDROM audio). +Operations to block devices such as +.Xr lseek 2 , +.Xr read 2 , +and +.Xr write +may only be performed at file offsets that are integral multiple of +this size. +.It Dv DIOCGMEDIASIZE +.Pq Li "off_t" +Get the size of the entire device in bytes. +This should be a multiple of the sector size. +.It Dv DIOCGFWSECTORS +.Pq Li "u_int" +Return the firmware's notion of number of sectors per track. +This value is mostly used for compatibility with various ill designed +disk label formats. +Use this value only when absolutely required. +Its interpretation and use is largely obsolete. +.It Dv DIOCGFWHEADS +.Pq Li "u_int" +Return the firmware's notion of number of heads per cylinder. +This value is mostly used for compatibility with various ill designed +disk label formats. +Use this value only when absolutely required. +Its interpretation and use is largely obsolete. +.It Dv DIOCGFLUSH +Flush write cache of the device. +.It Dv DIOCGDELETE +.Pq Li "off_t[2]" +Mark data on the device as unused. +The first element is the offset to start deleting. +The second element is the length to delete. +Providers may use this information to free storage or instruct storage +devices the contents can be discarded. +.It Dv DIOCGIDENT +.Pq Li "char[DISK_IDENT_SIZE]" +Get the ident for this provider. +Ident is a unique and fixed identifier for this provider. +Ident's properties are as follow: +.Bl -bullet +.It +preserved between reboots, +.It +preserved across a provider being detached/attached, +.It +provider's name can change - ident can't, +.It +ident value should not be based on on-disk metadata; in other +words, copying whole data from one disk to another should not +yield the same ident for the other disk, +.It +there can be more than one provider with the same ident, but +only if they point at exactly the same physical storage, this is +the case for multipathing for example, +.It +GEOM classes that consume a single provider and provide single +provider, like +.Xr geli 8 , +and +.Xr gbde 8 , +the identifier should be formed by attaching that provider's class +name to the ident of the underlying provider, +.It +ident is an NUL-terminated ASCII string (is printable), +.It +ident is optional and applications can't relay on its presence. +.El +.It Dv DIOCGPROVIDERNAME +.Pq Li "char[MAXPATHLEN]" +Store the provider name for the device in a buffer. +The buffer must be at least MAXPATHLEN bytes long. +.It Dv DIOCGSTRIPESIZE +.Pq Li "off_t" +Get the size of the device's optimal access block in bytes. +This should be a multiple of the sector size. +.It Dv DIOCGSTRIPEOFFSET +.Pq Li "off_t" +Get the offset of the first device's optimal access block in bytes. +This should be a multiple of the sector size. +.It Dv DIOCGPHYSPATH +.Pq Li "char[MAXPATHLEN]" +Get a string defining the physical path for a given provider. +This has similar rules to ident, but is intended to uniquely +identify the physical location of the device, not the current +occupant of that location. +The buffer must be at least MAXPATHLEN bytes long. +.It Dv DIOCGATTR +.Pq Li "struct diocgattr_arg" +.Bd -literal -offset indent +struct diocgattr_arg { + char name[64]; + int len; + union { + char str[DISK_IDENT_SIZE]; + off_t off; + int i; + uint16_t u16; + } value; +}; +.Ed +Get a geom attribute from the provider. +Format of the returned data is specific to the attribute. +.It Dv DIOCZONECMD +.Pq Li "struct disk_zone_arg" +Send disk zone commands. +.It Dv DIOCSKERNELDUMP +.Pq Li "struct diocskerneldump_arg" +Enable/Disable the device for kernel core dumps. +.It Dv DIOCGKERNELDUMP +.Pq Li "struct diocskerneldump_arg" +Get current kernel netdump configuration details for a given index. +.Bd -literal -offset indent +/* + * Sentinel values for kda_index. + * + * If kda_index is KDA_REMOVE_ALL, all dump configurations are cleared. + * + * If kda_index is KDA_REMOVE_DEV, all dump configurations for the specified + * device are cleared. + * + * If kda_index is KDA_REMOVE, only the specified dump configuration for the + * given device is removed from the list of fallback dump configurations. + * + * If kda_index is KDA_APPEND, the dump configuration is added after all + * existing dump configurations. + * + * Otherwise, the new configuration is inserted into the fallback dump list at + * index 'kda_index'. + */ +#define KDA_REMOVE UINT8_MAX +#define KDA_REMOVE_ALL (UINT8_MAX - 1) +#define KDA_REMOVE_DEV (UINT8_MAX - 2) +#define KDA_APPEND (UINT8_MAX - 3) +struct diocskerneldump_arg { + uint8_t kda_index; + uint8_t kda_compression; + uint8_t kda_encryption; + uint8_t kda_key[KERNELDUMP_KEY_MAX_SIZE]; + uint32_t kda_encryptedkeysize; + uint8_t *kda_encryptedkey; + char kda_iface[IFNAMSIZ]; + union kd_ip kda_server; + union kd_ip kda_client; + union kd_ip kda_gateway; + uint8_t kda_af; +}; +.Ed +.El +.Sh HISTORY +The manual page was written by +.An M Warner Losh Aq Mt imp@FreeBSD.org +from text largely derived from +.In sys/disk.h . From owner-svn-src-all@freebsd.org Thu Nov 19 18:03:41 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A947047132D; Thu, 19 Nov 2020 18:03:41 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcSGj4JDZz3D4d; Thu, 19 Nov 2020 18:03:41 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 853B916A; Thu, 19 Nov 2020 18:03:41 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJI3fDV039668; Thu, 19 Nov 2020 18:03:41 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJI3fS7039667; Thu, 19 Nov 2020 18:03:41 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011191803.0AJI3fS7039667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Thu, 19 Nov 2020 18:03:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367848 - in head: share/man/man4 sys/kern X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: in head: share/man/man4 sys/kern X-SVN-Commit-Revision: 367848 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 18:03:41 -0000 Author: mhorne Date: Thu Nov 19 18:03:40 2020 New Revision: 367848 URL: https://svnweb.freebsd.org/changeset/base/367848 Log: Add an option for entering KDB on recursive panics There are many cases where one would choose avoid entering the debugger on a normal panic, opting instead to reboot and possibly save a kernel dump. However, recursive kernel panics are an unusual case that might warrant attention from a human, so provide a secondary tunable, debug.debugger_on_recursive_panic, to allow entering the debugger only when this occurs. For for simplicity in maintaining existing behaviour, the tunable defaults to zero. Reviewed by: cem, markj Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D27271 Modified: head/share/man/man4/ddb.4 head/sys/kern/kern_shutdown.c Modified: head/share/man/man4/ddb.4 ============================================================================== --- head/share/man/man4/ddb.4 Thu Nov 19 17:54:41 2020 (r367847) +++ head/share/man/man4/ddb.4 Thu Nov 19 18:03:40 2020 (r367848) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 17, 2019 +.Dd November 19, 2020 .Dt DDB 4 .Os .Sh NAME @@ -87,6 +87,16 @@ which is the default unless the .Dv KDB_UNATTENDED option is specified. +Similarly, if the +.Va debug.debugger_on_recursive_panic +variable is set to +.Dv 1 , +then the debugger will be invoked on a recursive kernel panic. +This variable has a default value of +.Dv 0 , +and has no effect if +.Va debug.debugger_on_panic +is already set non-zero. .Pp The current location is called .Va dot . Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Thu Nov 19 17:54:41 2020 (r367847) +++ head/sys/kern/kern_shutdown.c Thu Nov 19 18:03:40 2020 (r367848) @@ -127,6 +127,11 @@ SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RWTUN | CTLFLAG_SECURE, &debugger_on_panic, 0, "Run debugger on kernel panic"); +static bool debugger_on_recursive_panic = false; +SYSCTL_BOOL(_debug, OID_AUTO, debugger_on_recursive_panic, + CTLFLAG_RWTUN | CTLFLAG_SECURE, + &debugger_on_recursive_panic, 0, "Run debugger on recursive kernel panic"); + int debugger_on_trap = 0; SYSCTL_INT(_debug, OID_AUTO, debugger_on_trap, CTLFLAG_RWTUN | CTLFLAG_SECURE, @@ -899,6 +904,8 @@ vpanic(const char *fmt, va_list ap) kdb_backtrace(); if (debugger_on_panic) kdb_enter(KDB_WHY_PANIC, "panic"); + else if (!newpanic && debugger_on_recursive_panic) + kdb_enter(KDB_WHY_PANIC, "re-panic"); #endif /*thread_lock(td); */ td->td_flags |= TDF_INPANIC; From owner-svn-src-all@freebsd.org Thu Nov 19 18:13:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 892F747134E; Thu, 19 Nov 2020 18:13:10 +0000 (UTC) (envelope-from luporl@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcSTf36lLz3DkX; Thu, 19 Nov 2020 18:13:10 +0000 (UTC) (envelope-from luporl@freebsd.org) Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: luporl/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 55DAD6534; Thu, 19 Nov 2020 18:13:10 +0000 (UTC) (envelope-from luporl@freebsd.org) Received: by mail-il1-f182.google.com with SMTP id q1so6198776ilt.6; Thu, 19 Nov 2020 10:13:10 -0800 (PST) X-Gm-Message-State: AOAM532FKNSAYxfsd7kkikZSEbsEiUcIfvRqvXiPL2QwAG5WAl7gFg6a Bf02sfu/F//t6pIvfGhRgI6cain7WdI9oGPg/ks= X-Google-Smtp-Source: ABdhPJx11nzoJSPj6OUTNkjG4P/7alx1LKX8yord3v/iwfoSYN2QXuUBddLt8cnzcCPWw2dem5uMVu9HHM+t0GOQGro= X-Received: by 2002:a05:6e02:ec2:: with SMTP id i2mr21835141ilk.209.1605809589486; Thu, 19 Nov 2020 10:13:09 -0800 (PST) MIME-Version: 1.0 References: <202011191000.0AJA0mfp036191@repo.freebsd.org> In-Reply-To: <202011191000.0AJA0mfp036191@repo.freebsd.org> From: luporl Date: Thu, 19 Nov 2020 15:12:57 -0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r367842 - head/sys/kern To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 18:13:10 -0000 This causes a panic on PowerPC64: panic: mtx_lock() by idle thread 0xc008000006437100 on sleep mutex kernelpmap @ /usr/home/luporl/git/master/sys/powerpc/aim/mmu_oea64.c:2237 cpuid = 31 time = 1605806644 KDB: stack backtrace: 0xc0080000014d91e0: at kdb_backtrace+0x60 0xc0080000014d92f0: at vpanic+0x1e0 0xc0080000014d93a0: at panic+0x40 0xc0080000014d93d0: at __mtx_lock_flags+0x23c 0xc0080000014d9480: at moea64_kextract+0x68 0xc0080000014d9560: at thread_stash+0x48 0xc0080000014d95a0: at mi_switch+0x1fc 0xc0080000014d9620: at critical_exit_preempt+0x88 0xc0080000014d9650: at cpu_idle+0xd4 0xc0080000014d96c0: at sched_idletd+0x440 0xc0080000014d9820: at fork_exit+0xc4 0xc0080000014d98c0: at fork_trampoline+0x18 0xc0080000014d98f0: at cpu_reset_handler+0x64 It seems the problem is the vtophys() call in thread_zombie(), as PPC64's pmap_kextract() will try to acquire a pmap lock for addresses out of DMAP range. On Thu, Nov 19, 2020 at 7:01 AM Mateusz Guzik wrote: > Author: mjg > Date: Thu Nov 19 10:00:48 2020 > New Revision: 367842 > URL: https://svnweb.freebsd.org/changeset/base/367842 > > Log: > thread: numa-aware zombie reaping > > The current global list is a significant problem, in particular induces > a lot > of cross-domain thread frees. When running poudriere on a 2 domain box > about > half of all frees were of that nature. > > Patch below introduces per-domain thread data containing zombie lists and > domain-aware reaping. By default it only reaps from the current domain, > only > reaping from others if there is free TID shortage. > > A dedicated callout is introduced to reap lingering threads if there > happens > to be no activity. > > Reviewed by: kib, markj > Differential Revision: https://reviews.freebsd.org/D27185 > > Modified: > head/sys/kern/kern_thread.c > > Modified: head/sys/kern/kern_thread.c > > ============================================================================== > --- head/sys/kern/kern_thread.c Thu Nov 19 09:26:51 2020 (r367841) > +++ head/sys/kern/kern_thread.c Thu Nov 19 10:00:48 2020 (r367842) > @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -64,9 +65,11 @@ __FBSDID("$FreeBSD$"); > > #include > > +#include > #include > #include > #include > +#include > #include > > /* > @@ -128,9 +131,20 @@ SDT_PROBE_DEFINE(proc, , , lwp__exit); > */ > static uma_zone_t thread_zone; > > -static __exclusive_cache_line struct thread *thread_zombies; > +struct thread_domain_data { > + struct thread *tdd_zombies; > + int tdd_reapticks; > +} __aligned(CACHE_LINE_SIZE); > > +static struct thread_domain_data thread_domain_data[MAXMEMDOM]; > + > +static struct task thread_reap_task; > +static struct callout thread_reap_callout; > + > static void thread_zombie(struct thread *); > +static void thread_reap_all(void); > +static void thread_reap_task_cb(void *, int); > +static void thread_reap_callout_cb(void *); > static int thread_unsuspend_one(struct thread *td, struct proc *p, > bool boundary); > static void thread_free_batched(struct thread *td); > @@ -159,30 +173,45 @@ EVENTHANDLER_LIST_DEFINE(thread_init); > EVENTHANDLER_LIST_DEFINE(thread_fini); > > static bool > -thread_count_inc(void) > +thread_count_inc_try(void) > { > - static struct timeval lastfail; > - static int curfail; > int nthreads_new; > > - thread_reap(); > - > nthreads_new = atomic_fetchadd_int(&nthreads, 1) + 1; > if (nthreads_new >= maxthread - 100) { > if (priv_check_cred(curthread->td_ucred, PRIV_MAXPROC) != > 0 || > nthreads_new >= maxthread) { > atomic_subtract_int(&nthreads, 1); > - if (ppsratecheck(&lastfail, &curfail, 1)) { > - printf("maxthread limit exceeded by uid %u > " > - "(pid %d); consider increasing > kern.maxthread\n", > - curthread->td_ucred->cr_ruid, > curproc->p_pid); > - } > return (false); > } > } > return (true); > } > > +static bool > +thread_count_inc(void) > +{ > + static struct timeval lastfail; > + static int curfail; > + > + thread_reap(); > + if (thread_count_inc_try()) { > + return (true); > + } > + > + thread_reap_all(); > + if (thread_count_inc_try()) { > + return (true); > + } > + > + if (ppsratecheck(&lastfail, &curfail, 1)) { > + printf("maxthread limit exceeded by uid %u " > + "(pid %d); consider increasing kern.maxthread\n", > + curthread->td_ucred->cr_ruid, curproc->p_pid); > + } > + return (false); > +} > + > static void > thread_count_sub(int n) > { > @@ -500,6 +529,10 @@ threadinit(void) > M_TIDHASH, M_WAITOK | M_ZERO); > for (i = 0; i < tidhashlock + 1; i++) > rw_init(&tidhashtbl_lock[i], "tidhash"); > + > + TASK_INIT(&thread_reap_task, 0, thread_reap_task_cb, NULL); > + callout_init(&thread_reap_callout, 1); > + callout_reset(&thread_reap_callout, 5 * hz, > thread_reap_callout_cb, NULL); > } > > /* > @@ -508,12 +541,14 @@ threadinit(void) > void > thread_zombie(struct thread *td) > { > + struct thread_domain_data *tdd; > struct thread *ztd; > > - ztd = atomic_load_ptr(&thread_zombies); > + tdd = &thread_domain_data[vm_phys_domain(vtophys(td))]; > + ztd = atomic_load_ptr(&tdd->tdd_zombies); > for (;;) { > td->td_zombie = ztd; > - if (atomic_fcmpset_rel_ptr((uintptr_t *)&thread_zombies, > + if (atomic_fcmpset_rel_ptr((uintptr_t *)&tdd->tdd_zombies, > (uintptr_t *)&ztd, (uintptr_t)td)) > break; > continue; > @@ -531,10 +566,10 @@ thread_stash(struct thread *td) > } > > /* > - * Reap zombie threads. > + * Reap zombies from passed domain. > */ > -void > -thread_reap(void) > +static void > +thread_reap_domain(struct thread_domain_data *tdd) > { > struct thread *itd, *ntd; > struct tidbatch tidbatch; > @@ -547,19 +582,26 @@ thread_reap(void) > * Reading upfront is pessimal if followed by concurrent > atomic_swap, > * but most of the time the list is empty. > */ > - if (thread_zombies == NULL) > + if (tdd->tdd_zombies == NULL) > return; > > - itd = (struct thread *)atomic_swap_ptr((uintptr_t > *)&thread_zombies, > + itd = (struct thread *)atomic_swap_ptr((uintptr_t > *)&tdd->tdd_zombies, > (uintptr_t)NULL); > if (itd == NULL) > return; > > + /* > + * Multiple CPUs can get here, the race is fine as ticks is only > + * advisory. > + */ > + tdd->tdd_reapticks = ticks; > + > tidbatch_prep(&tidbatch); > credbatch_prep(&credbatch); > tdcount = 0; > lim = NULL; > limcount = 0; > + > while (itd != NULL) { > ntd = itd->td_zombie; > EVENTHANDLER_DIRECT_INVOKE(thread_dtor, itd); > @@ -592,6 +634,68 @@ thread_reap(void) > } > MPASS(limcount != 0); > lim_freen(lim, limcount); > +} > + > +/* > + * Reap zombies from all domains. > + */ > +static void > +thread_reap_all(void) > +{ > + struct thread_domain_data *tdd; > + int i, domain; > + > + domain = PCPU_GET(domain); > + for (i = 0; i < vm_ndomains; i++) { > + tdd = &thread_domain_data[(i + domain) % vm_ndomains]; > + thread_reap_domain(tdd); > + } > +} > + > +/* > + * Reap zombies from local domain. > + */ > +void > +thread_reap(void) > +{ > + struct thread_domain_data *tdd; > + int domain; > + > + domain = PCPU_GET(domain); > + tdd = &thread_domain_data[domain]; > + > + thread_reap_domain(tdd); > +} > + > +static void > +thread_reap_task_cb(void *arg __unused, int pending __unused) > +{ > + > + thread_reap_all(); > +} > + > +static void > +thread_reap_callout_cb(void *arg __unused) > +{ > + struct thread_domain_data *tdd; > + int i, cticks, lticks; > + bool wantreap; > + > + wantreap = false; > + cticks = atomic_load_int(&ticks); > + for (i = 0; i < vm_ndomains; i++) { > + tdd = &thread_domain_data[i]; > + lticks = tdd->tdd_reapticks; > + if (tdd->tdd_zombies != NULL && > + (u_int)(cticks - lticks) > 5 * hz) { > + wantreap = true; > + break; > + } > + } > + > + if (wantreap) > + taskqueue_enqueue(taskqueue_thread, &thread_reap_task); > + callout_reset(&thread_reap_callout, 5 * hz, > thread_reap_callout_cb, NULL); > } > > /* > From owner-svn-src-all@freebsd.org Thu Nov 19 18:37:29 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 530214718CC; Thu, 19 Nov 2020 18:37:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcT1j1xcjz3Fc5; Thu, 19 Nov 2020 18:37:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 312ECB9C; Thu, 19 Nov 2020 18:37:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJIbS6e058379; Thu, 19 Nov 2020 18:37:28 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJIbS2E058378; Thu, 19 Nov 2020 18:37:28 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202011191837.0AJIbS2E058378@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Nov 2020 18:37:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367849 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367849 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 18:37:29 -0000 Author: markj Date: Thu Nov 19 18:37:28 2020 New Revision: 367849 URL: https://svnweb.freebsd.org/changeset/base/367849 Log: callout(9): Fix a race between CPU migration and callout_drain() Suppose a running callout re-arms itself, and before the callout finishes running another CPU calls callout_drain() and goes to sleep. softclock_call_cc() will wake up the draining thread, which may not run immediately if there is a lot of CPU load. Furthermore, the callout is still in the callout wheel so it can continue to run and re-arm itself. Then, suppose that the callout migrates to another CPU before the draining thread gets a chance to run. The draining thread is in this loop in _callout_stop_safe(): while (cc_exec_curr(cc) == c) { CC_UNLOCK(cc); sleep(); CC_LOCK(cc); } but after the migration, cc points to the wrong CPU's callout state. Then the draining thread goes off and removes the callout from the wheel, but does so using the wrong lock and per-CPU callout state. Fix the problem by doing a re-lookup of the callout CPU after sleeping. Reported by: syzbot+79569cd4d76636b2cc1c@syzkaller.appspotmail.com Reported by: syzbot+1b27e0237aa22d8adffa@syzkaller.appspotmail.com Reported by: syzbot+e21aa5b85a9aff90ef3e@syzkaller.appspotmail.com Reviewed by: emaste, hselasky Tested by: pho MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27266 Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Thu Nov 19 18:03:40 2020 (r367848) +++ head/sys/kern/kern_timeout.c Thu Nov 19 18:37:28 2020 (r367849) @@ -1145,7 +1145,7 @@ again: * just wait for the current invocation to * finish. */ - while (cc_exec_curr(cc, direct) == c) { + if (cc_exec_curr(cc, direct) == c) { /* * Use direct calls to sleepqueue interface * instead of cv/msleep in order to avoid @@ -1193,7 +1193,7 @@ again: /* Reacquire locks previously released. */ PICKUP_GIANT(); - CC_LOCK(cc); + goto again; } c->c_flags &= ~CALLOUT_ACTIVE; } else if (use_lock && From owner-svn-src-all@freebsd.org Thu Nov 19 18:58:16 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C2F7471E43; Thu, 19 Nov 2020 18:58:16 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcTTh2cDLz3H0x; Thu, 19 Nov 2020 18:58:16 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 47FAADCC; Thu, 19 Nov 2020 18:58:16 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJIwGdA070801; Thu, 19 Nov 2020 18:58:16 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJIwGPC070800; Thu, 19 Nov 2020 18:58:16 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202011191858.0AJIwGPC070800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Thu, 19 Nov 2020 18:58:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367850 - head/usr.bin/grep X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/usr.bin/grep X-SVN-Commit-Revision: 367850 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 18:58:16 -0000 Author: fernape (ports committer) Date: Thu Nov 19 18:58:15 2020 New Revision: 367850 URL: https://svnweb.freebsd.org/changeset/base/367850 Log: grep(1): Add more EXAMPLES * Add more EXAMPLES covering flags: -A, -B, -c, -f, -i, -H, -l, -q, -R, -w * While here, change existing wording to use the imperative (remove "To find") * Reword first example to be consistent with how grep(1) understand words (-w) Approved by: manpages (bcr@) Differential Revision: https://reviews.freebsd.org/D27264 Modified: head/usr.bin/grep/grep.1 Modified: head/usr.bin/grep/grep.1 ============================================================================== --- head/usr.bin/grep/grep.1 Thu Nov 19 18:37:28 2020 (r367849) +++ head/usr.bin/grep/grep.1 Thu Nov 19 18:58:15 2020 (r367850) @@ -30,7 +30,7 @@ .\" .\" @(#)grep.1 8.3 (Berkeley) 4/18/94 .\" -.Dd August 7, 2020 +.Dd November 19, 2020 .Dt GREP 1 .Os .Sh NAME @@ -456,13 +456,27 @@ An error occurred. .Sh EXAMPLES .Bl -dash .It -To find all occurrences of the word +Find all occurrences of the pattern .Sq patricia in a file: .Pp .Dl $ grep 'patricia' myfile .It -To find all occurrences of the pattern +Same as above but looking only for complete words: +.Pp +.Dl $ grep -w 'patricia' myfile +.It +Count occurrences of the exact pattern +.Sq FOO +: +.Pp +.Dl $ grep -c FOO myfile +.It +Same as above but ignoring case: +.Pp +.Dl $ grep -c -i FOO myfile +.It +Find all occurrences of the pattern .Ql .Pp at the beginning of a line: .Pp @@ -480,20 +494,55 @@ escapes the .Ql \&. , which would otherwise match any character. .It -To find all lines in a file which do not contain the words +Find all lines in a file which do not contain the words .Sq foo or .Sq bar : .Pp .Dl $ grep -v -e 'foo' -e 'bar' myfile .It -A simple example of an extended regular expression: +Peruse the file +.Sq calendar +looking for either 19, 20, or 25 using extended regular expressions: .Pp .Dl $ egrep '19|20|25' calendar +.It +Show matching lines and the name of the +.Sq *.h +files which contain the pattern +.Sq FIXME . +Do the search recursively from the +.Pa /usr/src/sys/arm +directory .Pp -Peruses the file -.Sq calendar -looking for either 19, 20, or 25. +.Dl $ grep -H -R FIXME --include=*.h /usr/src/sys/arm/ +.It +Same as above but show only the name of the matching file: +.Pp +.Dl $ grep -l -R FIXME --include=*.h /usr/src/sys/arm/ +.It +Show lines containing the text +.Sq foo . +The matching part of the output is colored and every line is prefixed with +the line number and the offset in the file for those lines that matched. +.Pp +.Dl $ grep -b --colour -n foo myfile +.It +Show lines that match the extended regular expression patterns read from the +standard input: +.Pp +.Dl $ echo -e 'Free\enBSD\enAll.*reserved' | grep -E -f - myfile +.It +Show lines from the output of the +.Xr pciconf 8 +command matching the specified extended regular expression along with +three lines of leading context and one line of trailing context: +.Pp +.Dl $ pciconf -lv | grep -B3 -A1 -E 'class.*=.*storage' +.It +Suppress any output and use the exit status to show an appropriate message: +.Pp +.Dl $ grep -q foo myfile && echo File matches .El .Sh SEE ALSO .Xr ed 1 , From owner-svn-src-all@freebsd.org Thu Nov 19 19:00:28 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 935D2472393; Thu, 19 Nov 2020 19:00:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcTXD3Z7tz3HJG; Thu, 19 Nov 2020 19:00:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id C26DA6A00; Thu, 19 Nov 2020 19:00:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367695 - in head/sys: kern sys To: Mark Johnston Cc: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011141922.0AEJM2ld055995@repo.freebsd.org> <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <617c0b5a-8295-8c53-ff18-6c7a5ace8a68@FreeBSD.org> Date: Thu, 19 Nov 2020 11:00:26 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 19:00:28 -0000 On 11/18/20 8:52 PM, Mark Johnston wrote: > On Wed, Nov 18, 2020 at 03:37:36PM -0800, John Baldwin wrote: >> On 11/18/20 2:16 PM, Mateusz Guzik wrote: >>> On 11/17/20, John Baldwin wrote: >>>> On 11/14/20 11:22 AM, Mateusz Guzik wrote: >>> Interested parties can check the consumer (also seen in the diff) to >>> see this is for consistency. I don't think any comments are warranted >>> in the header. >> >> I did read the consumer, and there didn't seem tremendous value in the >> extra line there. >> >>>> These changes would benefit from review. >>>> >>> >>> I don't think it's feasible to ask for review for everything lest it >>> degardes to rubber stamping and I don't think this change warranted >>> it, regardless of the cosmetic issues which can always show up. >> >> That is not consistent with the direction the project is moving. If you >> check the commit logs of other high-volume committers such as markj@, >> kib@, or myself, you will find that a substantial number of those commits >> are reviewed (typically in phabricator) without preventing us from >> making useful progress. Also, while the previous core did not mandate >> reviews, we moved closer to it when the Pre-Commit Review chapter was >> added to the Committer's Guide: >> >> https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/pre-commit-review.html >> >> In the related thread on developers@ we indicated that while weren't yet >> making pre-commit review mandatory, we collectively want to move in that >> direction. > > With regard to the future direction of src development, I would propose > a middle ground. Most, if not all, changes should get a Phabricator > review. There should be some minimum period between creation of that > review and a commit. The developer should make some effort to cc active > committers to the code. Some areas of the tree will have stricter > rules, but in general absence of feedback means that it's ok to commit. > Exceptions might apply to build fixes, etc.. This still imposes some > friction on the development process, but I have trouble seeing why > someone's contibution might be gated on their ability to commit at a > moment's notice. Mmm, I think I agree fully with this, and that perhaps the terminology is not clear as different folks have different perceptions of what "mandatory reviews" means perhaps. I know that some projects I work with have a fully "mandatory" requirement (OpenSSL seems to), and others have some exceptions (the "obvious" rule in FSF projects like GDB which the note in the committers guide does include a variant of). It is true though that in practice sometimes changes just time out due to lack of review (the OCF refactor is one of those in which I was able to get some partial review of some pieces or some of the concepts, but not the change as a whole). I do think we want to be in a place where we do at least seek review for most changes with an understanding that a change can "timeout" on review and be merged without always having review approval. > There are some technical issues around Phabricator that would need to be > ironed out before this is really doable. For me, the main one is that > email notifications are all-or-nothing: I would very much like to be > able to get email for each new review without automatically being > subscribed. That would indeed be interesting. In all of the Projects I've worked with using GH or e-mail, it does seem to be all-or-nothing if you are on the notify list. Hmm, looks like you can create a Herald rule to do this btw. Let's see if this works: https://reviews.freebsd.org/H138 -- John Baldwin From owner-svn-src-all@freebsd.org Thu Nov 19 19:05:17 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3DCA04725C0; Thu, 19 Nov 2020 19:05:17 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcTdn0tR7z3HqH; Thu, 19 Nov 2020 19:05:17 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 06A6FBE9; Thu, 19 Nov 2020 19:05:17 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJJ5Gs5077226; Thu, 19 Nov 2020 19:05:16 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJJ5GDZ077225; Thu, 19 Nov 2020 19:05:16 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202011191905.0AJJ5GDZ077225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Thu, 19 Nov 2020 19:05:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367851 - head/usr.bin/fstat X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/usr.bin/fstat X-SVN-Commit-Revision: 367851 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 19:05:17 -0000 Author: fernape (ports committer) Date: Thu Nov 19 19:05:16 2020 New Revision: 367851 URL: https://svnweb.freebsd.org/changeset/base/367851 Log: fstat(1): Add EXAMPLES section * Add examples covering -f, -m and -p flags. While here, extend the initial description paragraph to note that fstat(1) will report on all opened files, belonging to processes the user has access to. The current paragraph may lead to understand that you can get information on opened files from processes belonging to other users. Reviewed by: bjk@, danfe@, gbe@ Approved by: manpages (gbe@) Differential Revision: https://reviews.freebsd.org/D26949 Modified: head/usr.bin/fstat/fstat.1 Modified: head/usr.bin/fstat/fstat.1 ============================================================================== --- head/usr.bin/fstat/fstat.1 Thu Nov 19 18:58:15 2020 (r367850) +++ head/usr.bin/fstat/fstat.1 Thu Nov 19 19:05:16 2020 (r367851) @@ -28,7 +28,7 @@ .\" @(#)fstat.1 8.3 (Berkeley) 2/25/94 .\" $FreeBSD$ .\" -.Dd June 17, 2020 +.Dd November 19, 2020 .Dt FSTAT 1 .Os .Sh NAME @@ -51,7 +51,7 @@ is the working directory, root directory, jail root di active executable text, or kernel trace file for that process. If no options are specified, .Nm -reports on all open files in the system. +reports on all open files in the system for processes the user has access to. .Pp The following options are available: .Bl -tag -width "-N system" @@ -118,7 +118,7 @@ The process id. The file number in the per-process open file table or one of the following special names: .Pp -.Bl -tag -offset indent -compact +.Bl -tag -width jail -offset indent -compact .It Sy jail jail root directory .It Sy mmap @@ -235,6 +235,93 @@ a double arrow .Pq Ql <-> . For UNIX/local sockets either the local or remote address is shown, depending on which one is available. +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +Show all open files except those opened by +.Nm +itself: +.Bd -literal -offset indent +$ fstat | awk '$2 != "fstat"' +USER CMD PID FD MOUNT INUM MODE SZ|DV R/W +alice bash 469 text /usr/local 143355 -rwxr-xr-x 1166448 r +alice bash 469 ctty /dev 346 crw--w---- pts/81 rw +\&... +.Ed +.Pp +Report all files opened by the current shell in the same file system as +.Pa /usr/local +including memory-mapped files: +.Bd -literal -offset indent +$ fstat -m -p $$ -f /usr/local +USER CMD PID FD MOUNT INUM MODE SZ|DV R/W +bob bash 469 text /usr/local 143355 -rwxr-xr-x 1166448 r +bob bash 469 mmap /usr/local 143355 -rwxr-xr-x 1166448 r +\&... +.Ed +.Pp +Requesting information about a file that is not opened results in just a +header line instead of an error: +.Bd -literal -offset indent +$ fstat /etc/rc.conf +USER CMD PID FD MOUNT INUM MODE SZ|DV R/W NAME +.Ed +.Pp +All parameters after +.Fl f +will be interpreted as files, so the following will not work as expected: +.Bd -literal -offset indent +$ fstat -f /usr/local -m -p $$ +fstat: -m: No such file or directory +fstat: -p: No such file or directory +fstat: 469: No such file or directory +\&... +.Ed +.Pp +Show number of pipes opened by firefox processes: +.Bd -literal -offset indent +$ fstat | awk '$2=="firefox" && $5=="pipe"' | wc -l +.Ed +.Pp +Show processes belonging to user +.Dq bob +whose standard error descriptor is opened in ttyv0: +.Bd -literal -offset indent +$ fstat -u bob | awk '$4 == 2 && $8 == "ttyv0"' +bob firefox 77842 2 /dev 103 crw------- ttyv0 rw +bob xinit 1194 2 /dev 103 crw------- ttyv0 rw +\&... +.Ed +.Pp +Show opened TCP sockets. +This output resembles the one produced by +.Ql netstat -A -p tcp +: +.Bd -literal -offset indent +$ fstat | awk '$7 == "tcp"' +alice firefox 77991 32* internet stream tcp fffff800b7f147a0 +alice firefox 77991 137* internet stream tcp fffff800b7f12b70 +\&... +.Ed +.Pp +Show a list of processes with files opened in the current directory +mimicking the output of +.Xr fuser 1 +: +.Bd -literal -offset indent +$ fstat . | awk 'NR > 1 {printf "%d%s(%s) ", $3, $4, $1;}' +2133wd(alice) 2132wd(alice) 1991wd(alice) +.Ed +.Pp +Create a list of processes sorted by number of opened files in desdencing order: +.Bd -literal -offset indent +$ fstat | awk 'NR > 1 {print $2;}' | sort | uniq -c | sort -r + 728 firefox + 23 bash + 14 sort + 8 fstat + 7 awk +.Ed .Sh SEE ALSO .Xr fuser 1 , .Xr netstat 1 , From owner-svn-src-all@freebsd.org Thu Nov 19 19:25:48 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 642EE472F23; Thu, 19 Nov 2020 19:25:48 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcV5S2QV5z3Jqn; Thu, 19 Nov 2020 19:25:48 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3741E1596; Thu, 19 Nov 2020 19:25:48 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJJPmDT089605; Thu, 19 Nov 2020 19:25:48 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJJPlDc089603; Thu, 19 Nov 2020 19:25:47 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011191925.0AJJPlDc089603@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 19 Nov 2020 19:25:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367852 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 367852 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 19:25:48 -0000 Author: mjg Date: Thu Nov 19 19:25:47 2020 New Revision: 367852 URL: https://svnweb.freebsd.org/changeset/base/367852 Log: pipe: thundering herd problem in pipelock All reads and writes are serialized with a hand-rolled lock, but unlocking it always wakes up all waiters. Existing flag fields get resized to make room for introduction of waiter counter without growing the struct. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D27273 Modified: head/sys/kern/sys_pipe.c head/sys/sys/pipe.h Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Thu Nov 19 19:05:16 2020 (r367851) +++ head/sys/kern/sys_pipe.c Thu Nov 19 19:25:47 2020 (r367852) @@ -622,9 +622,13 @@ pipelock(struct pipe *cpipe, int catch) if (catch) prio |= PCATCH; while (cpipe->pipe_state & PIPE_LOCKFL) { - cpipe->pipe_state |= PIPE_LWANT; + KASSERT(cpipe->pipe_waiters >= 0, + ("%s: bad waiter count %d", __func__, + cpipe->pipe_waiters)); + cpipe->pipe_waiters++; error = msleep(cpipe, PIPE_MTX(cpipe), prio, "pipelk", 0); + cpipe->pipe_waiters--; if (error != 0) return (error); } @@ -642,10 +646,12 @@ pipeunlock(struct pipe *cpipe) PIPE_LOCK_ASSERT(cpipe, MA_OWNED); KASSERT(cpipe->pipe_state & PIPE_LOCKFL, ("Unlocked pipe passed to pipeunlock")); + KASSERT(cpipe->pipe_waiters >= 0, + ("%s: bad waiter count %d", __func__, + cpipe->pipe_waiters)); cpipe->pipe_state &= ~PIPE_LOCKFL; - if (cpipe->pipe_state & PIPE_LWANT) { - cpipe->pipe_state &= ~PIPE_LWANT; - wakeup(cpipe); + if (cpipe->pipe_waiters > 0) { + wakeup_one(cpipe); } } Modified: head/sys/sys/pipe.h ============================================================================== --- head/sys/sys/pipe.h Thu Nov 19 19:05:16 2020 (r367851) +++ head/sys/sys/pipe.h Thu Nov 19 19:25:47 2020 (r367852) @@ -116,9 +116,10 @@ struct pipe { struct pipe *pipe_peer; /* link with other direction */ struct pipepair *pipe_pair; /* container structure pointer */ u_short pipe_state; /* pipe status info */ - u_short pipe_type; /* pipe type info */ + u_char pipe_type; /* pipe type info */ + u_char pipe_present; /* still present? */ + int pipe_waiters; /* pipelock waiters */ int pipe_busy; /* busy flag, mostly to handle rundown sanely */ - int pipe_present; /* still present? */ int pipe_wgen; /* writer generation for named pipe */ ino_t pipe_ino; /* fake inode for stat(2) */ }; From owner-svn-src-all@freebsd.org Thu Nov 19 20:29:21 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE668473F97; Thu, 19 Nov 2020 20:29:21 +0000 (UTC) (envelope-from lwhsu@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcWVn5vfCz3MwM; Thu, 19 Nov 2020 20:29:21 +0000 (UTC) (envelope-from lwhsu@freebsd.org) Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: lwhsu/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id B8B287485; Thu, 19 Nov 2020 20:29:21 +0000 (UTC) (envelope-from lwhsu@freebsd.org) Received: by mail-yb1-f172.google.com with SMTP id r127so2683536yba.10; Thu, 19 Nov 2020 12:29:21 -0800 (PST) X-Gm-Message-State: AOAM533BSMb1GxDp6xPeNrYbQmKBTJzcrp0VDSBKxKOSOVa65dsgk0Yf tL5upW0YlzeIFr537k4KK4TjrO+9PpDVeVYsHXo= X-Google-Smtp-Source: ABdhPJxvEPHTbwnLrVsOgy9drG7T9jCCz6m0XSfvq+Z1whiUI3ZSohPpQLHYKgJgsDs4XH/cQeRdfZgOQnx1jrno51o= X-Received: by 2002:a25:fc01:: with SMTP id v1mr19648900ybd.241.1605817761312; Thu, 19 Nov 2020 12:29:21 -0800 (PST) MIME-Version: 1.0 References: <202011141922.0AEJM2ld055995@repo.freebsd.org> <4f6f6b0a-e71c-a286-507e-abf2522c142c@FreeBSD.org> <617c0b5a-8295-8c53-ff18-6c7a5ace8a68@FreeBSD.org> In-Reply-To: <617c0b5a-8295-8c53-ff18-6c7a5ace8a68@FreeBSD.org> From: Li-Wen Hsu Date: Fri, 20 Nov 2020 04:29:09 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r367695 - in head/sys: kern sys To: John Baldwin Cc: Mark Johnston , Mateusz Guzik , src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 20:29:21 -0000 On Fri, Nov 20, 2020 at 3:00 AM John Baldwin wrote: > On 11/18/20 8:52 PM, Mark Johnston wrote: > > There are some technical issues around Phabricator that would need to be > > ironed out before this is really doable. For me, the main one is that > > email notifications are all-or-nothing: I would very much like to be > > able to get email for each new review without automatically being > > subscribed. > > That would indeed be interesting. In all of the Projects I've worked > with using GH or e-mail, it does seem to be all-or-nothing if you are > on the notify list. > > Hmm, looks like you can create a Herald rule to do this btw. Let's > see if this works: > > https://reviews.freebsd.org/H138 Hmm, this reminds me there is an item on my TODO list: complete the setup of dev-reviews@ list: https://lists.freebsd.org/mailman/listinfo/dev-reviews The purpose of it is exactly to let people (only) subscribe to the newly created review. And thanks for your rule and I just realized there is a "mailing list" type of Phabricator user, Let's see if this works: https://reviews.freebsd.org/H139 Best, Li-Wen From owner-svn-src-all@freebsd.org Thu Nov 19 21:10:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1487E474F9C; Thu, 19 Nov 2020 21:10:37 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcXQP07R6z3Q7W; Thu, 19 Nov 2020 21:10:37 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EB6C626D9; Thu, 19 Nov 2020 21:10:36 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AJLAaLE052504; Thu, 19 Nov 2020 21:10:36 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AJLAaa0052503; Thu, 19 Nov 2020 21:10:36 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202011192110.0AJLAaa0052503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 19 Nov 2020 21:10:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367853 - head/contrib/elftoolchain/addr2line X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/contrib/elftoolchain/addr2line X-SVN-Commit-Revision: 367853 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 21:10:37 -0000 Author: emaste Date: Thu Nov 19 21:10:36 2020 New Revision: 367853 URL: https://svnweb.freebsd.org/changeset/base/367853 Log: addr2line: swap if conditions for diff reduction in upcoming change No functional change intended. Modified: head/contrib/elftoolchain/addr2line/addr2line.c Modified: head/contrib/elftoolchain/addr2line/addr2line.c ============================================================================== --- head/contrib/elftoolchain/addr2line/addr2line.c Thu Nov 19 19:25:47 2020 (r367852) +++ head/contrib/elftoolchain/addr2line/addr2line.c Thu Nov 19 21:10:36 2020 (r367853) @@ -436,30 +436,7 @@ check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsi in_range = false; ret = dwarf_attrval_unsigned(die, DW_AT_ranges, &ranges_off, &de); - if (ret == DW_DLV_NO_ENTRY) { - if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) == - DW_DLV_OK) { - if (lopc == curlopc) - return (DW_DLV_ERROR); - if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, - &de) == DW_DLV_OK) { - /* - * Check if the address falls into the PC - * range of this CU. - */ - if (handle_high_pc(die, lopc, &hipc) != - DW_DLV_OK) - return (DW_DLV_ERROR); - } else { - /* Assume ~0ULL if DW_AT_high_pc not present */ - hipc = ~0ULL; - } - - if (addr >= lopc && addr < hipc) { - in_range = true; - } - } - } else if (ret == DW_DLV_OK) { + if (ret == DW_DLV_OK) { ret = dwarf_get_ranges(dbg, ranges_off, &ranges, &ranges_cnt, NULL, &de); if (ret != DW_DLV_OK) @@ -488,6 +465,29 @@ check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsi if (addr >= lopc && addr < hipc){ in_range = true; break; + } + } + } else if (ret == DW_DLV_NO_ENTRY) { + if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) == + DW_DLV_OK) { + if (lopc == curlopc) + return (DW_DLV_ERROR); + if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, + &de) == DW_DLV_OK) { + /* + * Check if the address falls into the PC + * range of this CU. + */ + if (handle_high_pc(die, lopc, &hipc) != + DW_DLV_OK) + return (DW_DLV_ERROR); + } else { + /* Assume ~0ULL if DW_AT_high_pc not present */ + hipc = ~0ULL; + } + + if (addr >= lopc && addr < hipc) { + in_range = true; } } } else { From owner-svn-src-all@freebsd.org Thu Nov 19 22:55:16 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78A124769BD; Thu, 19 Nov 2020 22:55:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcZl82mwqz3lMW; Thu, 19 Nov 2020 22:55:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id D43C97F5D; Thu, 19 Nov 2020 22:55:15 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367530 - in head/sys/netinet: . tcp_stacks To: Michael Tuexen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011092149.0A9Lnfmh069050@repo.freebsd.org> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <9fd00098-0ce9-627e-0163-7ede5aa18d6f@FreeBSD.org> Date: Thu, 19 Nov 2020 14:55:13 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <202011092149.0A9Lnfmh069050@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 22:55:16 -0000 On 11/9/20 1:49 PM, Michael Tuexen wrote: > Author: tuexen > Date: Mon Nov 9 21:49:40 2020 > New Revision: 367530 > URL: https://svnweb.freebsd.org/changeset/base/367530 > > Log: > RFC 7323 specifies that: > * TCP segments without timestamps should be dropped when support for > the timestamp option has been negotiated. > * TCP segments with timestamps should be processed normally if support > for the timestamp option has not been negotiated. > This patch enforces the above. > > PR: 250499 > Reviewed by: gnn, rrs > MFC after: 1 week > Sponsored by: Netflix, Inc > Differential Revision: https://reviews.freebsd.org/D27148 > > Modified: > head/sys/netinet/tcp_input.c > head/sys/netinet/tcp_stacks/bbr.c > head/sys/netinet/tcp_stacks/rack.c > head/sys/netinet/tcp_syncache.c > head/sys/netinet/tcp_timewait.c > > Modified: head/sys/netinet/tcp_timewait.c > ============================================================================== > --- head/sys/netinet/tcp_timewait.c Mon Nov 9 21:19:17 2020 (r367529) > +++ head/sys/netinet/tcp_timewait.c Mon Nov 9 21:49:40 2020 (r367530) > @@ -376,7 +376,7 @@ tcp_twstart(struct tcpcb *tp) > * looking for a pcb in the listen state. Returns 0 otherwise. > */ > int > -tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unused, struct tcphdr *th, > +tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, > struct mbuf *m, int tlen) > { > struct tcptw *tw; > @@ -410,6 +410,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unu > */ > if (thflags & TH_RST) > goto drop; > + > + /* > + * If timestamps were negotiated during SYN/ACK and a > + * segment without a timestamp is received, silently drop > + * the segment. > + * See section 3.2 of RFC 7323. > + */ > + if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) { > + goto drop; > + } This causes an insta-panic with TOE because toe_4tuple_check() passes in a NULL pointer for 'to'. I'm working on a fix for that, but perhaps wait to MFC until the fix is ready so they can be merged together? That said, TOE only calls this in the case that it has gotten a new SYN, so I wonder if it makes sense to apply this check on a new SYN. For a new SYN, shouldn't we not care if the new connection is using a different timestamp option from the old connection? The language in RFC 7323 3.2 is all about segments on an existing connection, not segments from a new connection I think? That is, I think we should perhaps move this check after the TH_SYN check so that a mismatch doesn't prevent recycling? -- John Baldwin From owner-svn-src-all@freebsd.org Thu Nov 19 23:13:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC140476E42; Thu, 19 Nov 2020 23:13:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ccb8755L2z3lh6; Thu, 19 Nov 2020 23:13:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 145F78809; Thu, 19 Nov 2020 23:13:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r367530 - in head/sys/netinet: . tcp_stacks From: John Baldwin To: Michael Tuexen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202011092149.0A9Lnfmh069050@repo.freebsd.org> <9fd00098-0ce9-627e-0163-7ede5aa18d6f@FreeBSD.org> Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <00fb0227-efd3-e1a2-4178-15bdf6f26712@FreeBSD.org> Date: Thu, 19 Nov 2020 15:13:25 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <9fd00098-0ce9-627e-0163-7ede5aa18d6f@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 23:13:27 -0000 On 11/19/20 2:55 PM, John Baldwin wrote: > On 11/9/20 1:49 PM, Michael Tuexen wrote: >> Author: tuexen >> Date: Mon Nov 9 21:49:40 2020 >> New Revision: 367530 >> URL: https://svnweb.freebsd.org/changeset/base/367530 >> >> Log: >> RFC 7323 specifies that: >> * TCP segments without timestamps should be dropped when support for >> the timestamp option has been negotiated. >> * TCP segments with timestamps should be processed normally if support >> for the timestamp option has not been negotiated. >> This patch enforces the above. >> >> PR: 250499 >> Reviewed by: gnn, rrs >> MFC after: 1 week >> Sponsored by: Netflix, Inc >> Differential Revision: https://reviews.freebsd.org/D27148 >> >> Modified: >> head/sys/netinet/tcp_input.c >> head/sys/netinet/tcp_stacks/bbr.c >> head/sys/netinet/tcp_stacks/rack.c >> head/sys/netinet/tcp_syncache.c >> head/sys/netinet/tcp_timewait.c >> >> Modified: head/sys/netinet/tcp_timewait.c >> ============================================================================== >> --- head/sys/netinet/tcp_timewait.c Mon Nov 9 21:19:17 2020 (r367529) >> +++ head/sys/netinet/tcp_timewait.c Mon Nov 9 21:49:40 2020 (r367530) >> @@ -376,7 +376,7 @@ tcp_twstart(struct tcpcb *tp) >> * looking for a pcb in the listen state. Returns 0 otherwise. >> */ >> int >> -tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unused, struct tcphdr *th, >> +tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, >> struct mbuf *m, int tlen) >> { >> struct tcptw *tw; >> @@ -410,6 +410,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unu >> */ >> if (thflags & TH_RST) >> goto drop; >> + >> + /* >> + * If timestamps were negotiated during SYN/ACK and a >> + * segment without a timestamp is received, silently drop >> + * the segment. >> + * See section 3.2 of RFC 7323. >> + */ >> + if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) { >> + goto drop; >> + } > > This causes an insta-panic with TOE because toe_4tuple_check() passes in a NULL > pointer for 'to'. I'm working on a fix for that, but perhaps wait to MFC until > the fix is ready so they can be merged together? > > That said, TOE only calls this in the case that it has gotten a new SYN, so I > wonder if it makes sense to apply this check on a new SYN. For a new SYN, > shouldn't we not care if the new connection is using a different timestamp > option from the old connection? The language in RFC 7323 3.2 is all about > segments on an existing connection, not segments from a new connection I think? > > That is, I think we should perhaps move this check after the TH_SYN check so > that a mismatch doesn't prevent recycling? Actually, we move the check below requiring TH_ACK, I think this would fix the TOE case and also DTRT for plain SYNs for non-TOE: diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index c52eab956303..85f1ccbe40f9 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -411,16 +411,6 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, if (thflags & TH_RST) goto drop; - /* - * If timestamps were negotiated during SYN/ACK and a - * segment without a timestamp is received, silently drop - * the segment. - * See section 3.2 of RFC 7323. - */ - if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) { - goto drop; - } - #if 0 /* PAWS not needed at the moment */ /* @@ -455,6 +445,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, if ((thflags & TH_ACK) == 0) goto drop; + /* + * If timestamps were negotiated during SYN/ACK and a + * segment without a timestamp is received, silently drop + * the segment. + * See section 3.2 of RFC 7323. + */ + if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) { + goto drop; + } + /* * Reset the 2MSL timer if this is a duplicate FIN. */ The commented out PAWS bits would also seem to not be relevant for SYN-only packets? However, I'm less sure of if that bit should be moved later as well. (Or perhaps it should just be removed. It has been #if 0'd since the timewait structure was first added back in 2003 by jlemon@) -- John Baldwin From owner-svn-src-all@freebsd.org Thu Nov 19 23:39:47 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AB9B477500; Thu, 19 Nov 2020 23:39:47 +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 4CcbkV6F1xz3mmG; Thu, 19 Nov 2020 23:39:46 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from [IPv6:2a02:8109:1140:c3d:bc38:8d5c:8c97:55c4] (unknown [IPv6:2a02:8109:1140:c3d:bc38:8d5c:8c97:55c4]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTPSA id 2FDDB7220B805; Fri, 20 Nov 2020 00:39:43 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.20.0.2.21\)) Subject: Re: svn commit: r367530 - in head/sys/netinet: . tcp_stacks From: Michael Tuexen In-Reply-To: <00fb0227-efd3-e1a2-4178-15bdf6f26712@FreeBSD.org> Date: Fri, 20 Nov 2020 00:39:42 +0100 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <96A00DDE-2E94-4F6D-AD66-4DCA822F8E7D@freebsd.org> References: <202011092149.0A9Lnfmh069050@repo.freebsd.org> <9fd00098-0ce9-627e-0163-7ede5aa18d6f@FreeBSD.org> <00fb0227-efd3-e1a2-4178-15bdf6f26712@FreeBSD.org> To: John Baldwin X-Mailer: Apple Mail (2.3654.20.0.2.21) 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: 4CcbkV6F1xz3mmG X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 23:39:47 -0000 > On 20. Nov 2020, at 00:13, John Baldwin wrote: >=20 > On 11/19/20 2:55 PM, John Baldwin wrote: >> On 11/9/20 1:49 PM, Michael Tuexen wrote: >>> Author: tuexen >>> Date: Mon Nov 9 21:49:40 2020 >>> New Revision: 367530 >>> URL: https://svnweb.freebsd.org/changeset/base/367530 >>>=20 >>> Log: >>> RFC 7323 specifies that: >>> * TCP segments without timestamps should be dropped when support = for >>> the timestamp option has been negotiated. >>> * TCP segments with timestamps should be processed normally if = support >>> for the timestamp option has not been negotiated. >>> This patch enforces the above. >>>=20 >>> PR: 250499 >>> Reviewed by: gnn, rrs >>> MFC after: 1 week >>> Sponsored by: Netflix, Inc >>> Differential Revision: https://reviews.freebsd.org/D27148 >>>=20 >>> Modified: >>> head/sys/netinet/tcp_input.c >>> head/sys/netinet/tcp_stacks/bbr.c >>> head/sys/netinet/tcp_stacks/rack.c >>> head/sys/netinet/tcp_syncache.c >>> head/sys/netinet/tcp_timewait.c >>>=20 >>> Modified: head/sys/netinet/tcp_timewait.c >>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>> --- head/sys/netinet/tcp_timewait.c Mon Nov 9 21:19:17 2020 = (r367529) >>> +++ head/sys/netinet/tcp_timewait.c Mon Nov 9 21:49:40 2020 = (r367530) >>> @@ -376,7 +376,7 @@ tcp_twstart(struct tcpcb *tp) >>> * looking for a pcb in the listen state. Returns 0 otherwise. >>> */ >>> int >>> -tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unused, struct = tcphdr *th, >>> +tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr = *th, >>> struct mbuf *m, int tlen) >>> { >>> struct tcptw *tw; >>> @@ -410,6 +410,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt = *to __unu >>> */ >>> if (thflags & TH_RST) >>> goto drop; >>> + >>> + /* >>> + * If timestamps were negotiated during SYN/ACK and a >>> + * segment without a timestamp is received, silently drop >>> + * the segment. >>> + * See section 3.2 of RFC 7323. >>> + */ >>> + if (((to->to_flags & TOF_TS) =3D=3D 0) && (tw->t_recent !=3D 0)) = { >>> + goto drop; >>> + } >>=20 >> This causes an insta-panic with TOE because toe_4tuple_check() passes = in a NULL >> pointer for 'to'. I'm working on a fix for that, but perhaps wait to = MFC until >> the fix is ready so they can be merged together? >>=20 >> That said, TOE only calls this in the case that it has gotten a new = SYN, so I >> wonder if it makes sense to apply this check on a new SYN. For a new = SYN, >> shouldn't we not care if the new connection is using a different = timestamp >> option from the old connection? The language in RFC 7323 3.2 is all = about >> segments on an existing connection, not segments from a new = connection I think? >>=20 >> That is, I think we should perhaps move this check after the TH_SYN = check so >> that a mismatch doesn't prevent recycling? >=20 > Actually, we move the check below requiring TH_ACK, I think this would = fix the TOE > case and also DTRT for plain SYNs for non-TOE: Let me have a look tomorrow morning... Best regards Michael >=20 > diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c > index c52eab956303..85f1ccbe40f9 100644 > --- a/sys/netinet/tcp_timewait.c > +++ b/sys/netinet/tcp_timewait.c > @@ -411,16 +411,6 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, = struct tcphdr *th, > if (thflags & TH_RST) > goto drop; >=20 > - /* > - * If timestamps were negotiated during SYN/ACK and a > - * segment without a timestamp is received, silently drop > - * the segment. > - * See section 3.2 of RFC 7323. > - */ > - if (((to->to_flags & TOF_TS) =3D=3D 0) && (tw->t_recent !=3D 0)) = { > - goto drop; > - } > - > #if 0 > /* PAWS not needed at the moment */ > /* > @@ -455,6 +445,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, = struct tcphdr *th, > if ((thflags & TH_ACK) =3D=3D 0) > goto drop; >=20 > + /* > + * If timestamps were negotiated during SYN/ACK and a > + * segment without a timestamp is received, silently drop > + * the segment. > + * See section 3.2 of RFC 7323. > + */ > + if (((to->to_flags & TOF_TS) =3D=3D 0) && (tw->t_recent !=3D 0)) = { > + goto drop; > + } > + > /* > * Reset the 2MSL timer if this is a duplicate FIN. > */ >=20 > The commented out PAWS bits would also seem to not be relevant for = SYN-only > packets? However, I'm less sure of if that bit should be moved later = as > well. (Or perhaps it should just be removed. It has been #if 0'd = since the > timewait structure was first added back in 2003 by jlemon@) >=20 > --=20 > John Baldwin From owner-svn-src-all@freebsd.org Fri Nov 20 00:13:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C07B6477F54; Fri, 20 Nov 2020 00:13:31 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CccTR4y2cz3pjM; Fri, 20 Nov 2020 00:13:31 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9CCDA5031; Fri, 20 Nov 2020 00:13:31 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK0DVsL070215; Fri, 20 Nov 2020 00:13:31 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK0DV4B070211; Fri, 20 Nov 2020 00:13:31 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <202011200013.0AK0DV4B070211@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Fri, 20 Nov 2020 00:13:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367854 - head/sys/dev/atkbdc X-SVN-Group: head X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: head/sys/dev/atkbdc X-SVN-Commit-Revision: 367854 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 00:13:31 -0000 Author: wulf Date: Fri Nov 20 00:13:30 2020 New Revision: 367854 URL: https://svnweb.freebsd.org/changeset/base/367854 Log: psm(4): Disable AUX multiplexer probing on all Lenovo laptops. Rudimentary AUX multiplexing support was added to kernel to make possible touchpad initialization on some HP EliteBook laptops with trackpoint. Disable multiplexer probing on all Lenovo laptops now as they use touchpad pass-through port rather than AUX multiplexer to connect trackpoint and at least two model (X120e and X121e) is known for getting PS/2 AUX port dysfunctional after switching back to hidden multiplexing mode. AUX MUX probing can be reenabled with setting of hw.psm.mux_disabled loader tunable to 0. PR: 249987 Reported by: jwb MFC after: 2 weeks Modified: head/sys/dev/atkbdc/atkbdc.c head/sys/dev/atkbdc/atkbdcreg.h head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/atkbdc.c ============================================================================== --- head/sys/dev/atkbdc/atkbdc.c Thu Nov 19 21:10:36 2020 (r367853) +++ head/sys/dev/atkbdc/atkbdc.c Fri Nov 20 00:13:30 2020 (r367854) @@ -117,6 +117,8 @@ static struct atkbdc_quirks quirks[] = { {"coreboot", NULL, NULL, KBDC_QUIRK_KEEP_ACTIVATED | KBDC_QUIRK_IGNORE_PROBE_RESULT | KBDC_QUIRK_RESET_AFTER_PROBE | KBDC_QUIRK_SETLEDS_ON_INIT}, + /* KBDC hangs on Lenovo X120e and X121e after disabling AUX MUX */ + {NULL, "LENOVO", NULL, KBDC_QUIRK_DISABLE_MUX_PROBE}, {NULL, NULL, NULL, 0} }; Modified: head/sys/dev/atkbdc/atkbdcreg.h ============================================================================== --- head/sys/dev/atkbdc/atkbdcreg.h Thu Nov 19 21:10:36 2020 (r367853) +++ head/sys/dev/atkbdc/atkbdcreg.h Fri Nov 20 00:13:30 2020 (r367854) @@ -211,6 +211,7 @@ typedef struct atkbdc_softc { #define KBDC_QUIRK_IGNORE_PROBE_RESULT (1 << 1) #define KBDC_QUIRK_RESET_AFTER_PROBE (1 << 2) #define KBDC_QUIRK_SETLEDS_ON_INIT (1 << 3) +#define KBDC_QUIRK_DISABLE_MUX_PROBE (1 << 4) int aux_mux_enabled; /* active PS/2 multiplexing is enabled */ int aux_mux_port; /* current aux mux port */ } atkbdc_softc_t; Modified: head/sys/dev/atkbdc/psm.c ============================================================================== --- head/sys/dev/atkbdc/psm.c Thu Nov 19 21:10:36 2020 (r367853) +++ head/sys/dev/atkbdc/psm.c Fri Nov 20 00:13:30 2020 (r367854) @@ -517,7 +517,7 @@ static int verbose = PSM_DEBUG; static int synaptics_support = 1; static int trackpoint_support = 1; static int elantech_support = 1; -static int mux_disabled = 0; +static int mux_disabled = -1; /* for backward compatibility */ #define OLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_t) @@ -6292,7 +6292,8 @@ enable_synaptics_mux(struct psm_softc *sc, enum probea int active_ports_count = 0; int active_ports_mask = 0; - if (mux_disabled != 0) + if (mux_disabled == 1 || (mux_disabled == -1 && + (kbdc->quirks & KBDC_QUIRK_DISABLE_MUX_PROBE) != 0)) return (FALSE); version = enable_aux_mux(kbdc); From owner-svn-src-all@freebsd.org Fri Nov 20 00:30:07 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E88F3478674; Fri, 20 Nov 2020 00:30:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cccrb6Fdbz3qTc; Fri, 20 Nov 2020 00:30:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C51CD5581; Fri, 20 Nov 2020 00:30:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK0U7BK077108; Fri, 20 Nov 2020 00:30:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK0U72R077107; Fri, 20 Nov 2020 00:30:07 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011200030.0AK0U72R077107@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Nov 2020 00:30:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367855 - stable/12/sbin/nvmecontrol/modules/wdc X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sbin/nvmecontrol/modules/wdc X-SVN-Commit-Revision: 367855 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 00:30:08 -0000 Author: mav Date: Fri Nov 20 00:30:07 2020 New Revision: 367855 URL: https://svnweb.freebsd.org/changeset/base/367855 Log: MFC r366506, r366511: nvmecontrol: Update wdc module for newer WDC NVMe products Update the to log fetch operation for latest WDC NVMe products. Tested on HGST SN100 (a few years old) and WDC SN720 (more recent). Submitted by: Akhilesh Rn (minor style tweak by me) Github PR: 435 Modified: stable/12/sbin/nvmecontrol/modules/wdc/wdc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/nvmecontrol/modules/wdc/wdc.c ============================================================================== --- stable/12/sbin/nvmecontrol/modules/wdc/wdc.c Fri Nov 20 00:13:30 2020 (r367854) +++ stable/12/sbin/nvmecontrol/modules/wdc/wdc.c Fri Nov 20 00:30:07 2020 (r367855) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "nvmecontrol.h" @@ -61,14 +62,18 @@ static struct options { const char *template; const char *dev; + uint8_t data_area; } opt = { .template = NULL, .dev = NULL, + .data_area = 0, }; static const struct opts opts[] = { OPT("template", 'o', arg_string, opt, template, "Template for paths to use for different logs"), + OPT("data-area", 'd', arg_uint8, opt, data_area, + "Data-area to retrieve up to"), OPT_END }; @@ -88,11 +93,27 @@ static struct cmd cap_diag_cmd = { CMD_SUBCOMMAND(wdc_cmd, cap_diag_cmd); -#define WDC_NVME_TOC_SIZE 8 +#define WDC_NVME_VID 0x1c58 +#define WDC_NVME_VID_2 0x1b96 +#define WDC_NVME_VID_3 0x15b7 -#define WDC_NVME_CAP_DIAG_OPCODE 0xe6 -#define WDC_NVME_CAP_DIAG_CMD 0x0000 +#define WDC_NVME_TOC_SIZE 0x8 +#define WDC_NVME_LOG_SIZE_HDR_LEN 0x8 +#define WDC_NVME_CAP_DIAG_OPCODE_E6 0xe6 +#define WDC_NVME_CAP_DIAG_CMD 0x0000 +#define WDC_NVME_CAP_DIAG_OPCODE_FA 0xfa +#define WDC_NVME_DUI_MAX_SECTIONS_V0 0x3c +#define WDC_NVME_DUI_MAX_SECTIONS_V1 0x3a +#define WDC_NVME_DUI_MAX_SECTIONS_V2 0x26 +#define WDC_NVME_DUI_MAX_SECTIONS_V3 0x23 +typedef enum wdc_dui_header { + WDC_DUI_HEADER_VER_0 = 0, + WDC_DUI_HEADER_VER_1, + WDC_DUI_HEADER_VER_2, + WDC_DUI_HEADER_VER_3, +} wdc_dui_header; + static void wdc_append_serial_name(int fd, char *buf, size_t len, const char *suffix) { @@ -108,25 +129,26 @@ wdc_append_serial_name(int fd, char *buf, size_t len, while (walker > sn && *walker == ' ') walker--; *++walker = '\0'; - snprintf(buf, len, "%s%s.bin", sn, suffix); + snprintf(buf, len, "_%s_%s.bin", sn, suffix); } static void wdc_get_data(int fd, uint32_t opcode, uint32_t len, uint32_t off, uint32_t cmd, - uint8_t *buffer, size_t buflen) + uint8_t *buffer, size_t buflen, bool e6lg_flag) { struct nvme_pt_command pt; memset(&pt, 0, sizeof(pt)); pt.cmd.opc = opcode; - pt.cmd.cdw10 = htole32(len / sizeof(uint32_t)); /* - 1 like all the others ??? */ - pt.cmd.cdw11 = htole32(off / sizeof(uint32_t)); + pt.cmd.cdw10 = htole32(len / sizeof(uint32_t)); pt.cmd.cdw12 = htole32(cmd); + if (e6lg_flag) + pt.cmd.cdw11 = htole32(off / sizeof(uint32_t)); + else + pt.cmd.cdw13 = htole32(off / sizeof(uint32_t)); pt.buf = buffer; pt.len = buflen; pt.is_read = 1; -// printf("opcode %#x cdw10(len) %#x cdw11(offset?) %#x cdw12(cmd/sub) %#x buflen %zd\n", -// (int)opcode, (int)cdw10, (int)cdw11, (int)cdw12, buflen); if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) err(1, "wdc_get_data request failed"); @@ -135,17 +157,29 @@ wdc_get_data(int fd, uint32_t opcode, uint32_t len, ui } static void -wdc_do_dump(int fd, char *tmpl, const char *suffix, uint32_t opcode, +wdc_do_dump_e6(int fd, char *tmpl, const char *suffix, uint32_t opcode, uint32_t cmd, int len_off) { int first; int fd2; - uint8_t *buf; + uint8_t *buf, *hdr; uint32_t len, offset; size_t resid; + bool e6lg_flag = false; wdc_append_serial_name(fd, tmpl, MAXPATHLEN, suffix); + /* Read Log Dump header */ + len = WDC_NVME_LOG_SIZE_HDR_LEN; + offset = 0; + hdr = malloc(len); + if (hdr == NULL) + errx(1, "Can't get buffer to read dump"); + wdc_get_data(fd, opcode, len, offset, cmd, hdr, len, false); + if (memcmp("E6LG", hdr, 4) == 0) { + e6lg_flag = true; + } + /* XXX overwrite protection? */ fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd2 < 0) @@ -159,15 +193,13 @@ wdc_do_dump(int fd, char *tmpl, const char *suffix, ui do { resid = len > NVME_MAX_XFER_SIZE ? NVME_MAX_XFER_SIZE : len; - wdc_get_data(fd, opcode, resid, offset, cmd, buf, resid); + wdc_get_data(fd, opcode, resid, offset, cmd, buf, resid, e6lg_flag); if (first) { len = be32dec(buf + len_off); if (len == 0) errx(1, "No data for %s", suffix); - if (memcmp("E6LG", buf, 4) != 0) - printf("Expected header of E6LG, found '%4.4s' instead\n", - buf); + printf("Dumping %d bytes of version %d.%d log to %s\n", len, buf[8], buf[9], tmpl); /* @@ -184,15 +216,153 @@ wdc_do_dump(int fd, char *tmpl, const char *suffix, ui offset += resid; len -= resid; } while (len > 0); + free(hdr); free(buf); close(fd2); } static void +wdc_get_data_dui(int fd, uint32_t opcode, uint32_t len, uint64_t off, + uint8_t *buffer, size_t buflen) +{ + struct nvme_pt_command pt; + + memset(&pt, 0, sizeof(pt)); + pt.cmd.opc = opcode; + pt.cmd.nsid = NONE; + pt.cmd.cdw10 = htole32((len / sizeof(uint32_t)) - 1) ; + pt.cmd.cdw12 = htole32(off & 0xFFFFFFFFu); + pt.cmd.cdw13 = htole32(off >> 32); + pt.buf = buffer; + pt.len = buflen; + pt.is_read = 1; + + if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) + err(1, "wdc_get_data_dui request failed"); + if (nvme_completion_is_error(&pt.cpl)) + errx(1, "wdc_get_data_dui request returned error"); +} + +static uint8_t +wdc_get_dui_max_sections(uint16_t header_ver) +{ + switch (header_ver) { + case WDC_DUI_HEADER_VER_0: + return WDC_NVME_DUI_MAX_SECTIONS_V0; + case WDC_DUI_HEADER_VER_1: + return WDC_NVME_DUI_MAX_SECTIONS_V1; + case WDC_DUI_HEADER_VER_2: + return WDC_NVME_DUI_MAX_SECTIONS_V2; + case WDC_DUI_HEADER_VER_3: + return WDC_NVME_DUI_MAX_SECTIONS_V3; + } + return 0; +} + +static void +wdc_get_dui_log_size(int fd, uint32_t opcode, uint8_t data_area, + uint64_t *log_size, int len_off) +{ + uint8_t *hdr; + uint8_t max_sections; + int i, j; + uint16_t hdr_ver; + uint16_t len; + uint64_t dui_size; + + dui_size = 0; + len = 1024; + hdr = (uint8_t*)malloc(len); + if (hdr == NULL) + errx(1, "Can't get buffer to read header"); + wdc_get_data_dui(fd, opcode, len, 0, hdr, len); + + hdr += len_off; + hdr_ver = ((*hdr & 0xF) != 0)? *hdr : le16dec(hdr); + max_sections = wdc_get_dui_max_sections(hdr_ver); + + if (hdr_ver == 0 || hdr_ver == 1) { + dui_size = (uint64_t)le32dec(hdr + 4); + if (dui_size == 0) { + hdr += 8; + for (i = 0, j = 0; i < (int)max_sections; i++, j+=8) + dui_size += (uint64_t)le32dec(hdr + j + 4); + } + } else if (hdr_ver == 2 || hdr_ver == 3) { + if (data_area == 0) { + dui_size = le64dec(hdr + 4); + if (dui_size == 0) { + hdr += 12; + for (i = 0, j = 0 ; i < (int)max_sections; i++, j+=12) + dui_size += le64dec(hdr + j + 4); + } + } else { + hdr += 12; + for (i = 0, j = 0; i < (int)max_sections; i++, j+=12) { + if (le16dec(hdr + j + 2) <= data_area) + dui_size += le64dec(hdr + j + 4); + else + break; + } + } + } + else + errx(1, "ERROR : No valid header "); + + *log_size = dui_size; + free(hdr); +} + +static void +wdc_do_dump_dui(int fd, char *tmpl, uint8_t data_area, + const char *suffix, uint32_t opcode, int len_off) +{ + int fd2, first; + uint8_t *buf; + uint16_t hdr_ver; + uint64_t log_len, offset; + size_t resid; + + wdc_append_serial_name(fd, tmpl, MAXPATHLEN, suffix); + wdc_get_dui_log_size(fd, opcode, data_area, &log_len, len_off); + if (log_len == 0) + errx(1, "No data for %s", suffix); + fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd2 < 0) + err(1, "open %s", tmpl); + buf = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE); + if (buf == NULL) + errx(1, "Can't get buffer to read dump"); + offset = 0; + first = 1; + + while (log_len > 0) { + resid = log_len > NVME_MAX_XFER_SIZE ? NVME_MAX_XFER_SIZE : log_len; + wdc_get_data_dui(fd, opcode, resid, offset, buf, resid); + if (first) { + hdr_ver = ((buf[len_off] & 0xF) != 0) ? + (buf[len_off]) : (le16dec(buf + len_off)); + printf("Dumping %jd bytes of version %d log to %s\n", + (uintmax_t)log_len, hdr_ver, tmpl); + first = 0; + } + if (write(fd2, buf, resid) != (ssize_t)resid) + err(1, "write"); + offset += resid; + log_len -= resid; + } + + free(buf); + close(fd2); +} + +static void wdc_cap_diag(const struct cmd *f, int argc, char *argv[]) { char tmpl[MAXPATHLEN]; int fd; + struct nvme_controller_data cdata; + uint32_t vid; if (arg_parse(argc, argv, f)) return; @@ -200,11 +370,28 @@ wdc_cap_diag(const struct cmd *f, int argc, char *argv fprintf(stderr, "Missing template arg.\n"); arg_help(argc, argv, f); } + if (opt.data_area > 4) { + fprintf(stderr, "Data area range 1-4, supplied %d.\n", opt.data_area); + arg_help(argc, argv, f); + } strlcpy(tmpl, opt.template, sizeof(tmpl)); open_dev(opt.dev, &fd, 1, 1); - wdc_do_dump(fd, tmpl, "cap_diag", WDC_NVME_CAP_DIAG_OPCODE, - WDC_NVME_CAP_DIAG_CMD, 4); + read_controller_data(fd, &cdata); + vid = cdata.vid; + switch (vid) { + case WDC_NVME_VID : + case WDC_NVME_VID_2 : + wdc_do_dump_e6(fd, tmpl, "cap_diag", WDC_NVME_CAP_DIAG_OPCODE_E6, + WDC_NVME_CAP_DIAG_CMD, 4); + break; + case WDC_NVME_VID_3 : + wdc_do_dump_dui(fd, tmpl, opt.data_area, "cap_diag", + WDC_NVME_CAP_DIAG_OPCODE_FA, 512); + break; + default: + errx(1, "ERROR : WDC: unsupported device (%#x) for this command", vid); + } close(fd); exit(1); From owner-svn-src-all@freebsd.org Fri Nov 20 00:31:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BCEE4478A1C; Fri, 20 Nov 2020 00:31:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cccsc4wj9z3r4v; Fri, 20 Nov 2020 00:31:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B8D15514; Fri, 20 Nov 2020 00:31:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK0V0Nv078201; Fri, 20 Nov 2020 00:31:00 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK0UwEl078175; Fri, 20 Nov 2020 00:30:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011200030.0AK0UwEl078175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Nov 2020 00:30:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367856 - in stable/12/sbin/nvmecontrol: . modules/wdc X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sbin/nvmecontrol: . modules/wdc X-SVN-Commit-Revision: 367856 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 00:31:00 -0000 Author: mav Date: Fri Nov 20 00:30:58 2020 New Revision: 367856 URL: https://svnweb.freebsd.org/changeset/base/367856 Log: MFC r367630: Improve nvmecontrol error reporting. Modified: stable/12/sbin/nvmecontrol/comnd.c stable/12/sbin/nvmecontrol/devlist.c stable/12/sbin/nvmecontrol/firmware.c stable/12/sbin/nvmecontrol/format.c stable/12/sbin/nvmecontrol/identify.c stable/12/sbin/nvmecontrol/logpage.c stable/12/sbin/nvmecontrol/modules/wdc/wdc.c stable/12/sbin/nvmecontrol/ns.c stable/12/sbin/nvmecontrol/nvmecontrol.c stable/12/sbin/nvmecontrol/nvmecontrol.h stable/12/sbin/nvmecontrol/passthru.c stable/12/sbin/nvmecontrol/perftest.c stable/12/sbin/nvmecontrol/power.c stable/12/sbin/nvmecontrol/reset.c stable/12/sbin/nvmecontrol/resv.c stable/12/sbin/nvmecontrol/sanitize.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/nvmecontrol/comnd.c ============================================================================== --- stable/12/sbin/nvmecontrol/comnd.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/comnd.c Fri Nov 20 00:30:58 2020 (r367856) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "comnd.h" @@ -77,7 +78,7 @@ gen_usage(const struct cmd *t) SLIST_FOREACH(walker, &t->subcmd, link) { print_usage(walker); } - exit(1); + exit(EX_USAGE); } int @@ -158,7 +159,7 @@ arg_help(int argc __unused, char * const *argv, const fprintf(stderr, "%-30.30s - %s\n", buf, opts[i].descr); } } - exit(1); + exit(EX_USAGE); } static int @@ -188,10 +189,10 @@ arg_parse(int argc, char * const * argv, const struct n++; lopts = malloc((n + 2) * sizeof(struct option)); if (lopts == NULL) - err(1, "option memory"); + err(EX_OSERR, "option memory"); p = shortopts = malloc((2 * n + 3) * sizeof(char)); if (shortopts == NULL) - err(1, "shortopts memory"); + err(EX_OSERR, "shortopts memory"); idx = 0; for (i = 0; i < n; i++) { lopts[i].name = opts[i].long_arg; @@ -279,7 +280,7 @@ bad_arg: fprintf(stderr, "Bad value to --%s: %s\n", opts[idx].long_arg, optarg); free(lopts); free(shortopts); - exit(1); + exit(EX_USAGE); } /* @@ -301,7 +302,7 @@ cmd_load_dir(const char *dir __unused, cmd_load_cb_t c continue; asprintf(&path, "%s/%s", dir, dent->d_name); if (path == NULL) - err(1, "Can't malloc for path, giving up."); + err(EX_OSERR, "Can't malloc for path, giving up."); if ((h = dlopen(path, RTLD_NOW | RTLD_GLOBAL)) == NULL) warnx("Can't load %s: %s", path, dlerror()); else { Modified: stable/12/sbin/nvmecontrol/devlist.c ============================================================================== --- stable/12/sbin/nvmecontrol/devlist.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/devlist.c Fri Nov 20 00:30:58 2020 (r367856) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -102,12 +103,14 @@ devlist(const struct cmd *f, int argc, char *argv[]) continue; found++; - read_controller_data(fd, &cdata); + if (read_controller_data(fd, &cdata)) + continue; nvme_strvis(mn, cdata.mn, sizeof(mn), NVME_MODEL_NUMBER_LENGTH); printf("%6s: %s\n", name, mn); for (i = 0; i < cdata.nn; i++) { - read_namespace_data(fd, i + 1, &nsdata); + if (read_namespace_data(fd, i + 1, &nsdata)) + continue; if (nsdata.nsze == 0) continue; sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr, @@ -124,7 +127,7 @@ devlist(const struct cmd *f, int argc, char *argv[]) if (found == 0) { printf("No NVMe controllers found.\n"); - exit(1); + exit(EX_UNAVAILABLE); } exit(0); Modified: stable/12/sbin/nvmecontrol/firmware.c ============================================================================== --- stable/12/sbin/nvmecontrol/firmware.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/firmware.c Fri Nov 20 00:30:58 2020 (r367856) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -123,9 +124,9 @@ read_image_file(const char *path, void **buf, int32_t *buf = NULL; if ((fd = open(path, O_RDONLY)) < 0) - err(1, "unable to open '%s'", path); + err(EX_NOINPUT, "unable to open '%s'", path); if (fstat(fd, &sb) < 0) - err(1, "unable to stat '%s'", path); + err(EX_NOINPUT, "unable to stat '%s'", path); /* * The NVMe spec does not explicitly state a maximum firmware image @@ -139,16 +140,16 @@ read_image_file(const char *path, void **buf, int32_t * a bit. */ if (sb.st_size > INT32_MAX) - errx(1, "size of file '%s' is too large (%jd bytes)", + errx(EX_USAGE, "size of file '%s' is too large (%jd bytes)", path, (intmax_t)sb.st_size); filesize = (int32_t)sb.st_size; if ((*buf = malloc(filesize)) == NULL) - errx(1, "unable to malloc %d bytes", filesize); + errx(EX_OSERR, "unable to malloc %d bytes", filesize); if ((*size = read(fd, *buf, filesize)) < 0) - err(1, "error reading '%s'", path); + err(EX_IOERR, "error reading '%s'", path); /* XXX assuming no short reads */ if (*size != filesize) - errx(1, + errx(EX_IOERR, "error reading '%s' (read %d bytes, requested %d bytes)", path, *size, filesize); close(fd); @@ -168,12 +169,12 @@ update_firmware(int fd, uint8_t *payload, int32_t payl if (fwug != 0 && fwug != 0xFF) max_xfer_size = ((uint64_t)fwug << 12); else if (ioctl(fd, NVME_GET_MAX_XFER_SIZE, &max_xfer_size) < 0) - err(1, "query max transfer size failed"); + err(EX_IOERR, "query max transfer size failed"); if (max_xfer_size > NVME_MAX_XFER_SIZE) max_xfer_size = NVME_MAX_XFER_SIZE; if ((chunk = aligned_alloc(PAGE_SIZE, max_xfer_size)) == NULL) - errx(1, "unable to malloc %zd bytes", (size_t)max_xfer_size); + errx(EX_OSERR, "unable to malloc %zd bytes", (size_t)max_xfer_size); while (resid > 0) { size = (resid >= (int32_t)max_xfer_size) ? @@ -189,10 +190,10 @@ update_firmware(int fd, uint8_t *payload, int32_t payl pt.is_read = 0; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "firmware download request failed"); + err(EX_IOERR, "firmware download request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "firmware download request returned error"); + errx(EX_IOERR, "firmware download request returned error"); resid -= size; off += size; @@ -212,7 +213,7 @@ activate_firmware(int fd, int slot, int activate_actio pt.is_read = 0; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "firmware activate request failed"); + err(EX_IOERR, "firmware activate request failed"); sct = NVME_STATUS_GET_SCT(pt.cpl.status); sc = NVME_STATUS_GET_SC(pt.cpl.status); @@ -222,7 +223,7 @@ activate_firmware(int fd, int slot, int activate_actio return 1; if (nvme_completion_is_error(&pt.cpl)) - errx(1, "firmware activate request returned error"); + errx(EX_IOERR, "firmware activate request returned error"); return 0; } @@ -278,32 +279,33 @@ firmware(const struct cmd *f, int argc, char *argv[]) } free(path); - read_controller_data(fd, &cdata); + if (read_controller_data(fd, &cdata)) + errx(EX_IOERR, "Identify request failed"); oacs_fw = (cdata.oacs >> NVME_CTRLR_DATA_OACS_FIRMWARE_SHIFT) & NVME_CTRLR_DATA_OACS_FIRMWARE_MASK; if (oacs_fw == 0) - errx(1, + errx(EX_UNAVAILABLE, "controller does not support firmware activate/download"); fw_slot1_ro = (cdata.frmw >> NVME_CTRLR_DATA_FRMW_SLOT1_RO_SHIFT) & NVME_CTRLR_DATA_FRMW_SLOT1_RO_MASK; if (opt.fw_img && opt.slot == 1 && fw_slot1_ro) - errx(1, "slot %d is marked as read only", opt.slot); + errx(EX_UNAVAILABLE, "slot %d is marked as read only", opt.slot); fw_num_slots = (cdata.frmw >> NVME_CTRLR_DATA_FRMW_NUM_SLOTS_SHIFT) & NVME_CTRLR_DATA_FRMW_NUM_SLOTS_MASK; if (opt.slot > fw_num_slots) - errx(1, + errx(EX_UNAVAILABLE, "slot %d specified but controller only supports %d slots", opt.slot, fw_num_slots); if (opt.activate && opt.fw_img == NULL && !slot_has_valid_firmware(fd, opt.slot)) - errx(1, + errx(EX_UNAVAILABLE, "slot %d does not contain valid firmware,\n" "try 'nvmecontrol logpage -p 3 %s' to get a list " "of available images\n", @@ -336,7 +338,7 @@ firmware(const struct cmd *f, int argc, char *argv[]) if (strncasecmp(prompt, "yes", 3) == 0) break; if (strncasecmp(prompt, "no", 2) == 0) - exit(1); + exit(EX_DATAERR); printf("Please answer \"yes\" or \"no\". "); } Modified: stable/12/sbin/nvmecontrol/format.c ============================================================================== --- stable/12/sbin/nvmecontrol/format.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/format.c Fri Nov 20 00:30:58 2020 (r367856) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -159,29 +160,31 @@ format(const struct cmd *f, int argc, char *argv[]) free(path); /* Check that controller can execute this command. */ - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); if (((cd.oacs >> NVME_CTRLR_DATA_OACS_FORMAT_SHIFT) & NVME_CTRLR_DATA_OACS_FORMAT_MASK) == 0) - errx(1, "controller does not support format"); + errx(EX_UNAVAILABLE, "controller does not support format"); if (((cd.fna >> NVME_CTRLR_DATA_FNA_CRYPTO_ERASE_SHIFT) & NVME_CTRLR_DATA_FNA_CRYPTO_ERASE_MASK) == 0 && ses == SES_CRYPTO) - errx(1, "controller does not support cryptographic erase"); + errx(EX_UNAVAILABLE, "controller does not support cryptographic erase"); if (nsid != NVME_GLOBAL_NAMESPACE_TAG) { if (((cd.fna >> NVME_CTRLR_DATA_FNA_FORMAT_ALL_SHIFT) & NVME_CTRLR_DATA_FNA_FORMAT_ALL_MASK) && ses == SES_NONE) - errx(1, "controller does not support per-NS format"); + errx(EX_UNAVAILABLE, "controller does not support per-NS format"); if (((cd.fna >> NVME_CTRLR_DATA_FNA_ERASE_ALL_SHIFT) & NVME_CTRLR_DATA_FNA_ERASE_ALL_MASK) && ses != SES_NONE) - errx(1, "controller does not support per-NS erase"); + errx(EX_UNAVAILABLE, "controller does not support per-NS erase"); /* Try to keep previous namespace parameters. */ - read_namespace_data(fd, nsid, &nsd); + if (read_namespace_data(fd, nsid, &nsd)) + errx(EX_IOERR, "Identify request failed"); if (lbaf < 0) lbaf = (nsd.flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) & NVME_NS_DATA_FLBAS_FORMAT_MASK; if (lbaf > nsd.nlbaf) - errx(1, "LBA format is out of range"); + errx(EX_USAGE, "LBA format is out of range"); if (ms < 0) ms = (nsd.flbas >> NVME_NS_DATA_FLBAS_EXTENDED_SHIFT) & NVME_NS_DATA_FLBAS_EXTENDED_MASK; @@ -211,10 +214,10 @@ format(const struct cmd *f, int argc, char *argv[]) (ms << 4) + lbaf); if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "format request failed"); + err(EX_IOERR, "format request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "format request returned error"); + errx(EX_IOERR, "format request returned error"); close(fd); exit(0); } Modified: stable/12/sbin/nvmecontrol/identify.c ============================================================================== --- stable/12/sbin/nvmecontrol/identify.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/identify.c Fri Nov 20 00:30:58 2020 (r367856) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -191,7 +192,8 @@ identify_ctrlr(int fd) struct nvme_controller_data cdata; int hexlength; - read_controller_data(fd, &cdata); + if (read_controller_data(fd, &cdata)) + errx(EX_IOERR, "Identify request failed"); close(fd); if (opt.hex) { @@ -214,7 +216,8 @@ identify_ns(int fd, uint32_t nsid) struct nvme_namespace_data nsdata; int hexlength; - read_namespace_data(fd, nsid, &nsdata); + if (read_namespace_data(fd, nsid, &nsdata)) + errx(EX_IOERR, "Identify request failed"); close(fd); if (opt.hex) { Modified: stable/12/sbin/nvmecontrol/logpage.c ============================================================================== --- stable/12/sbin/nvmecontrol/logpage.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/logpage.c Fri Nov 20 00:30:58 2020 (r367856) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -183,7 +184,7 @@ get_log_buffer(uint32_t size) void *buf; if ((buf = malloc(size)) == NULL) - errx(1, "unable to malloc %u bytes", size); + errx(EX_OSERR, "unable to malloc %u bytes", size); memset(buf, 0, size); return (buf); @@ -217,7 +218,7 @@ read_logpage(int fd, uint8_t log_page, uint32_t nsid, pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "get log page request failed"); + err(EX_IOERR, "get log page request failed"); /* Convert data to host endian */ switch (log_page) { @@ -259,7 +260,7 @@ read_logpage(int fd, uint8_t log_page, uint32_t nsid, } if (nvme_completion_is_error(&pt.cpl)) - errx(1, "get log page request returned error"); + errx(EX_IOERR, "get log page request returned error"); } static void @@ -659,7 +660,7 @@ logpage_help(void) fprintf(stderr, "0x%02x %-10s %s\n", f->log_page, v, f->name); } - exit(1); + exit(EX_USAGE); } static void @@ -697,7 +698,8 @@ logpage(const struct cmd *f, int argc, char *argv[]) } free(path); - read_controller_data(fd, &cdata); + if (read_controller_data(fd, &cdata)) + errx(EX_IOERR, "Identify request failed"); ns_smart = (cdata.lpa >> NVME_CTRLR_DATA_LPA_NS_SMART_SHIFT) & NVME_CTRLR_DATA_LPA_NS_SMART_MASK; @@ -709,10 +711,10 @@ logpage(const struct cmd *f, int argc, char *argv[]) */ if (nsid != NVME_GLOBAL_NAMESPACE_TAG) { if (opt.page != NVME_LOG_HEALTH_INFORMATION) - errx(1, "log page %d valid only at controller level", + errx(EX_USAGE, "log page %d valid only at controller level", opt.page); if (ns_smart == 0) - errx(1, + errx(EX_UNAVAILABLE, "controller does not support per namespace " "smart/health information"); } Modified: stable/12/sbin/nvmecontrol/modules/wdc/wdc.c ============================================================================== --- stable/12/sbin/nvmecontrol/modules/wdc/wdc.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/modules/wdc/wdc.c Fri Nov 20 00:30:58 2020 (r367856) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -123,7 +124,8 @@ wdc_append_serial_name(int fd, char *buf, size_t len, len -= strlen(buf); buf += strlen(buf); - read_controller_data(fd, &cdata); + if (read_controller_data(fd, &cdata)) + errx(EX_IOERR, "Identify request failed"); memcpy(sn, cdata.sn, NVME_SERIAL_NUMBER_LENGTH); walker = sn + NVME_SERIAL_NUMBER_LENGTH - 1; while (walker > sn && *walker == ' ') @@ -151,9 +153,9 @@ wdc_get_data(int fd, uint32_t opcode, uint32_t len, ui pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "wdc_get_data request failed"); + err(EX_IOERR, "wdc_get_data request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "wdc_get_data request returned error"); + errx(EX_IOERR, "wdc_get_data request returned error"); } static void @@ -174,7 +176,7 @@ wdc_do_dump_e6(int fd, char *tmpl, const char *suffix, offset = 0; hdr = malloc(len); if (hdr == NULL) - errx(1, "Can't get buffer to read dump"); + errx(EX_OSERR, "Can't get buffer to read dump"); wdc_get_data(fd, opcode, len, offset, cmd, hdr, len, false); if (memcmp("E6LG", hdr, 4) == 0) { e6lg_flag = true; @@ -183,10 +185,10 @@ wdc_do_dump_e6(int fd, char *tmpl, const char *suffix, /* XXX overwrite protection? */ fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd2 < 0) - err(1, "open %s", tmpl); + err(EX_CANTCREAT, "open %s", tmpl); buf = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE); if (buf == NULL) - errx(1, "Can't get buffer to read dump"); + errx(EX_OSERR, "Can't get buffer to read dump"); offset = 0; len = NVME_MAX_XFER_SIZE; first = 1; @@ -198,7 +200,7 @@ wdc_do_dump_e6(int fd, char *tmpl, const char *suffix, if (first) { len = be32dec(buf + len_off); if (len == 0) - errx(1, "No data for %s", suffix); + errx(EX_PROTOCOL, "No data for %s", suffix); printf("Dumping %d bytes of version %d.%d log to %s\n", len, buf[8], buf[9], tmpl); @@ -212,7 +214,7 @@ wdc_do_dump_e6(int fd, char *tmpl, const char *suffix, first = 0; } if (write(fd2, buf, resid) != (ssize_t)resid) - err(1, "write"); + err(EX_IOERR, "write"); offset += resid; len -= resid; } while (len > 0); @@ -238,9 +240,9 @@ wdc_get_data_dui(int fd, uint32_t opcode, uint32_t len pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "wdc_get_data_dui request failed"); + err(EX_IOERR, "wdc_get_data_dui request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "wdc_get_data_dui request returned error"); + errx(EX_IOERR, "wdc_get_data_dui request returned error"); } static uint8_t @@ -274,7 +276,7 @@ wdc_get_dui_log_size(int fd, uint32_t opcode, uint8_t len = 1024; hdr = (uint8_t*)malloc(len); if (hdr == NULL) - errx(1, "Can't get buffer to read header"); + errx(EX_OSERR, "Can't get buffer to read header"); wdc_get_data_dui(fd, opcode, len, 0, hdr, len); hdr += len_off; @@ -307,7 +309,7 @@ wdc_get_dui_log_size(int fd, uint32_t opcode, uint8_t } } else - errx(1, "ERROR : No valid header "); + errx(EX_PROTOCOL, "ERROR : No valid header "); *log_size = dui_size; free(hdr); @@ -326,13 +328,13 @@ wdc_do_dump_dui(int fd, char *tmpl, uint8_t data_area, wdc_append_serial_name(fd, tmpl, MAXPATHLEN, suffix); wdc_get_dui_log_size(fd, opcode, data_area, &log_len, len_off); if (log_len == 0) - errx(1, "No data for %s", suffix); + errx(EX_PROTOCOL, "No data for %s", suffix); fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd2 < 0) - err(1, "open %s", tmpl); + err(EX_CANTCREAT, "open %s", tmpl); buf = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE); if (buf == NULL) - errx(1, "Can't get buffer to read dump"); + errx(EX_OSERR, "Can't get buffer to read dump"); offset = 0; first = 1; @@ -347,7 +349,7 @@ wdc_do_dump_dui(int fd, char *tmpl, uint8_t data_area, first = 0; } if (write(fd2, buf, resid) != (ssize_t)resid) - err(1, "write"); + err(EX_IOERR, "write"); offset += resid; log_len -= resid; } @@ -376,7 +378,8 @@ wdc_cap_diag(const struct cmd *f, int argc, char *argv } strlcpy(tmpl, opt.template, sizeof(tmpl)); open_dev(opt.dev, &fd, 1, 1); - read_controller_data(fd, &cdata); + if (read_controller_data(fd, &cdata)) + errx(EX_IOERR, "Identify request failed"); vid = cdata.vid; switch (vid) { @@ -390,11 +393,10 @@ wdc_cap_diag(const struct cmd *f, int argc, char *argv WDC_NVME_CAP_DIAG_OPCODE_FA, 512); break; default: - errx(1, "ERROR : WDC: unsupported device (%#x) for this command", vid); + errx(EX_UNAVAILABLE, "ERROR : WDC: unsupported device (%#x) for this command", vid); } close(fd); - - exit(1); + exit(0); } static void Modified: stable/12/sbin/nvmecontrol/ns.c ============================================================================== --- stable/12/sbin/nvmecontrol/ns.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/ns.c Fri Nov 20 00:30:58 2020 (r367856) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -414,12 +415,13 @@ nsactive(const struct cmd *f, int argc, char *argv[]) open_dev(path, &fd, 0, 1); } free(path); - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); memset(&pt, 0, sizeof(pt)); pt.cmd.opc = NVME_OPC_IDENTIFY; @@ -429,9 +431,9 @@ nsactive(const struct cmd *f, int argc, char *argv[]) pt.len = sizeof(list); pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + err(EX_IOERR, "identify request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + errx(EX_IOERR, "identify request returned error"); printf("Active namespaces:\n"); for (i = 0; list[i] != 0; i++) @@ -459,12 +461,13 @@ nsallocated(const struct cmd *f, int argc, char *argv[ open_dev(path, &fd, 0, 1); } free(path); - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); memset(&pt, 0, sizeof(pt)); pt.cmd.opc = NVME_OPC_IDENTIFY; @@ -474,9 +477,9 @@ nsallocated(const struct cmd *f, int argc, char *argv[ pt.len = sizeof(list); pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + err(EX_IOERR, "identify request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + errx(EX_IOERR, "identify request returned error"); printf("Allocated namespaces:\n"); for (i = 0; list[i] != 0; i++) @@ -504,12 +507,13 @@ nscontrollers(const struct cmd *f, int argc, char *arg open_dev(path, &fd, 0, 1); } free(path); - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); memset(&pt, 0, sizeof(pt)); pt.cmd.opc = NVME_OPC_IDENTIFY; @@ -518,9 +522,9 @@ nscontrollers(const struct cmd *f, int argc, char *arg pt.len = sizeof(clist); pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + err(EX_IOERR, "identify request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + errx(EX_IOERR, "identify request returned error"); n = le16toh(clist[0]); printf("NVM subsystem includes %d controller(s):\n", n); @@ -565,12 +569,13 @@ nscreate(const struct cmd *f, int argc, char *argv[]) open_dev(path, &fd, 1, 1); } free(path); - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); /* Allow namespaces sharing if Multi-Path I/O is supported. */ if (create_opt.nmic == NONE) { @@ -605,10 +610,10 @@ nscreate(const struct cmd *f, int argc, char *argv[]) pt.len = sizeof(struct nvme_namespace_data); pt.is_read = 0; /* passthrough writes data to ctrlr */ if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0) - errx(1, "ioctl request to %s failed: %d", create_opt.dev, result); + errx(EX_IOERR, "ioctl request to %s failed: %d", create_opt.dev, result); if (nvme_completion_is_error(&pt.cpl)) { - errx(1, "namespace creation failed: %s", + errx(EX_IOERR, "namespace creation failed: %s", get_res_str((pt.cpl.status >> NVME_STATUS_SC_SHIFT) & NVME_STATUS_SC_MASK)); } @@ -642,12 +647,13 @@ nsdelete(const struct cmd *f, int argc, char *argv[]) if (delete_opt.nsid != NONE) nsid = delete_opt.nsid; free(path); - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); memset(&pt, 0, sizeof(pt)); pt.cmd.opc = NVME_OPC_NAMESPACE_MANAGEMENT; @@ -658,10 +664,10 @@ nsdelete(const struct cmd *f, int argc, char *argv[]) pt.cmd.nsid = nsid; if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0) - errx(1, "ioctl request to %s failed: %d", delete_opt.dev, result); + errx(EX_IOERR, "ioctl request to %s failed: %d", delete_opt.dev, result); if (nvme_completion_is_error(&pt.cpl)) { - errx(1, "namespace deletion failed: %s", + errx(EX_IOERR, "namespace deletion failed: %s", get_res_str((pt.cpl.status >> NVME_STATUS_SC_SHIFT) & NVME_STATUS_SC_MASK)); } @@ -708,12 +714,13 @@ nsattach(const struct cmd *f, int argc, char *argv[]) } if (attach_opt.nsid != NONE) nsid = attach_opt.nsid; - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); if (attach_opt.ctrlrid == NONE) { /* Get full list of controllers to attach to. */ @@ -724,9 +731,9 @@ nsattach(const struct cmd *f, int argc, char *argv[]) pt.len = sizeof(clist); pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + err(EX_IOERR, "identify request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + errx(EX_IOERR, "identify request returned error"); } else { /* By default attach to this controller. */ if (attach_opt.ctrlrid == NONE - 1) @@ -744,10 +751,10 @@ nsattach(const struct cmd *f, int argc, char *argv[]) pt.len = sizeof(clist); if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0) - errx(1, "ioctl request to %s failed: %d", attach_opt.dev, result); + errx(EX_IOERR, "ioctl request to %s failed: %d", attach_opt.dev, result); if (nvme_completion_is_error(&pt.cpl)) { - errx(1, "namespace attach failed: %s", + errx(EX_IOERR, "namespace attach failed: %s", get_res_str((pt.cpl.status >> NVME_STATUS_SC_SHIFT) & NVME_STATUS_SC_MASK)); } @@ -779,12 +786,13 @@ nsdetach(const struct cmd *f, int argc, char *argv[]) } if (detach_opt.nsid != NONE) nsid = detach_opt.nsid; - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); if (detach_opt.ctrlrid == NONE) { /* Get list of controllers this namespace attached to. */ @@ -796,9 +804,9 @@ nsdetach(const struct cmd *f, int argc, char *argv[]) pt.len = sizeof(clist); pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + err(EX_IOERR, "identify request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + errx(EX_IOERR, "identify request returned error"); if (clist[0] == 0) { detach_opt.ctrlrid = cd.ctrlr_id; memset(&clist, 0, sizeof(clist)); @@ -822,10 +830,10 @@ nsdetach(const struct cmd *f, int argc, char *argv[]) pt.len = sizeof(clist); if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0) - errx(1, "ioctl request to %s failed: %d", detach_opt.dev, result); + errx(EX_IOERR, "ioctl request to %s failed: %d", detach_opt.dev, result); if (nvme_completion_is_error(&pt.cpl)) { - errx(1, "namespace detach failed: %s", + errx(EX_IOERR, "namespace detach failed: %s", get_res_str((pt.cpl.status >> NVME_STATUS_SC_SHIFT) & NVME_STATUS_SC_MASK)); } @@ -857,12 +865,13 @@ nsattached(const struct cmd *f, int argc, char *argv[] } if (attached_opt.nsid != NONE) nsid = attached_opt.nsid; - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); memset(&pt, 0, sizeof(pt)); pt.cmd.opc = NVME_OPC_IDENTIFY; @@ -872,9 +881,9 @@ nsattached(const struct cmd *f, int argc, char *argv[] pt.len = sizeof(clist); pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + err(EX_IOERR, "identify request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + errx(EX_IOERR, "identify request returned error"); n = le16toh(clist[0]); printf("Attached %d controller(s):\n", n); @@ -910,12 +919,13 @@ nsidentify(const struct cmd *f, int argc, char *argv[] } if (identify_opt.nsid != NONE) nsid = identify_opt.nsid; - read_controller_data(fd, &cd); + if (read_controller_data(fd, &cd)) + errx(EX_IOERR, "Identify request failed"); /* Check that controller can execute this command. */ if (((cd.oacs >> NVME_CTRLR_DATA_OACS_NSMGMT_SHIFT) & NVME_CTRLR_DATA_OACS_NSMGMT_MASK) == 0) - errx(1, "controller does not support namespace management"); + errx(EX_UNAVAILABLE, "controller does not support namespace management"); memset(&pt, 0, sizeof(pt)); pt.cmd.opc = NVME_OPC_IDENTIFY; @@ -926,10 +936,10 @@ nsidentify(const struct cmd *f, int argc, char *argv[] pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + err(EX_IOERR, "identify request failed"); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + errx(EX_IOERR, "identify request returned error"); close(fd); @@ -939,7 +949,7 @@ nsidentify(const struct cmd *f, int argc, char *argv[] break; } if (i == sizeof(nsdata)) - errx(1, "namespace %d is not allocated", nsid); + errx(EX_UNAVAILABLE, "namespace %d is not allocated", nsid); /* Convert data to host endian */ nvme_namespace_data_swapbytes(&nsdata); Modified: stable/12/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- stable/12/sbin/nvmecontrol/nvmecontrol.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/nvmecontrol.c Fri Nov 20 00:30:58 2020 (r367856) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -96,7 +97,7 @@ print_hex(void *data, uint32_t length) print_bytes(data, length); } -void +int read_controller_data(int fd, struct nvme_controller_data *cdata) { struct nvme_pt_command pt; @@ -109,16 +110,17 @@ read_controller_data(int fd, struct nvme_controller_da pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + return (errno); /* Convert data to host endian */ nvme_controller_data_swapbytes(cdata); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + return (EIO); + return (0); } -void +int read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata) { struct nvme_pt_command pt; @@ -132,13 +134,14 @@ read_namespace_data(int fd, uint32_t nsid, struct nvme pt.is_read = 1; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "identify request failed"); + return (errno); /* Convert data to host endian */ nvme_namespace_data_swapbytes(nsdata); if (nvme_completion_is_error(&pt.cpl)) - errx(1, "identify request returned error"); + return (EIO); + return (0); } int @@ -150,7 +153,7 @@ open_dev(const char *str, int *fd, int write, int exit *fd = open(full_path, write ? O_RDWR : O_RDONLY); if (*fd < 0) { if (exit_on_error) { - err(1, "could not open %s%s", full_path, + err(EX_OSFILE, "could not open %s%s", full_path, write ? " for write" : ""); } else return (errno); @@ -165,7 +168,7 @@ get_nsid(int fd, char **ctrlr_str, uint32_t *nsid) struct nvme_get_nsid gnsid; if (ioctl(fd, NVME_GET_NSID, &gnsid) < 0) - err(1, "NVME_GET_NSID ioctl failed"); + err(EX_OSERR, "NVME_GET_NSID ioctl failed"); if (ctrlr_str != NULL) *ctrlr_str = strndup(gnsid.cdev, sizeof(gnsid.cdev)); if (nsid != NULL) Modified: stable/12/sbin/nvmecontrol/nvmecontrol.h ============================================================================== --- stable/12/sbin/nvmecontrol/nvmecontrol.h Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/nvmecontrol.h Fri Nov 20 00:30:58 2020 (r367856) @@ -70,8 +70,8 @@ void logpage_register(struct logpage_function *p); int open_dev(const char *str, int *fd, int write, int exit_on_error); void get_nsid(int fd, char **ctrlr_str, uint32_t *nsid); -void read_controller_data(int fd, struct nvme_controller_data *cdata); -void read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata); +int read_controller_data(int fd, struct nvme_controller_data *cdata); +int read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata); void print_hex(void *data, uint32_t length); void print_namespace(struct nvme_namespace_data *nsdata); void read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp, Modified: stable/12/sbin/nvmecontrol/passthru.c ============================================================================== --- stable/12/sbin/nvmecontrol/passthru.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/passthru.c Fri Nov 20 00:30:58 2020 (r367856) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -167,9 +168,9 @@ passthru(const struct cmd *f, int argc, char *argv[]) open_dev(opt.dev, &fd, 1, 1); if (opt.read && opt.write) - errx(1, "need exactly one of --read or --write"); + errx(EX_USAGE, "need exactly one of --read or --write"); if (opt.data_len != 0 && !opt.read && !opt.write) - errx(1, "need exactly one of --read or --write"); + errx(EX_USAGE, "need exactly one of --read or --write"); if (*opt.ifn && (ifd = open(opt.ifn, O_RDONLY)) == -1) { warn("open %s", opt.ifn); goto cleanup; @@ -183,7 +184,7 @@ passthru(const struct cmd *f, int argc, char *argv[]) } #else if (opt.metadata_len != 0) - errx(1, "metadata not supported on FreeBSD"); + errx(EX_UNAVAILABLE, "metadata not supported on FreeBSD"); #endif if (opt.data_len) { if (posix_memalign(&data, getpagesize(), opt.data_len)) { @@ -244,7 +245,7 @@ passthru(const struct cmd *f, int argc, char *argv[]) errno = 0; if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) - err(1, "passthrough request failed"); + err(EX_IOERR, "passthrough request failed"); /* XXX report status */ if (opt.read) { if (opt.binary) @@ -260,7 +261,7 @@ cleanup: if (ifd > -1) close(ifd); if (errno) - exit(1); + exit(EX_IOERR); } static void Modified: stable/12/sbin/nvmecontrol/perftest.c ============================================================================== --- stable/12/sbin/nvmecontrol/perftest.c Fri Nov 20 00:30:07 2020 (r367855) +++ stable/12/sbin/nvmecontrol/perftest.c Fri Nov 20 00:30:58 2020 (r367856) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "nvmecontrol.h" @@ -180,7 +181,7 @@ perftest(const struct cmd *f, int argc, char *argv[]) io_test.size = opt.size; open_dev(opt.dev, &fd, 1, 1); if (ioctl(fd, ioctl_cmd, &io_test) < 0) - err(1, "ioctl NVME_IO_TEST failed"); + err(EX_IOERR, "ioctl NVME_IO_TEST failed"); close(fd); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Nov 20 01:15:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2EE4F4793D5; Fri, 20 Nov 2020 01:15:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcdsK0pmPz3sXW; Fri, 20 Nov 2020 01:15:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E8E075BAB; Fri, 20 Nov 2020 01:15:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK1FmYZ007898; Fri, 20 Nov 2020 01:15:48 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK1FmpG007894; Fri, 20 Nov 2020 01:15:48 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011200115.0AK1FmpG007894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Nov 2020 01:15:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367857 - in head: share/man/man4 sys/dev/isp sys/dev/ispfw sys/modules/ispfw sys/modules/ispfw/isp_1000 sys/modules/ispfw/isp_1040 sys/modules/ispfw/isp_1080 sys/modules/ispfw/isp_1216... X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head: share/man/man4 sys/dev/isp sys/dev/ispfw sys/modules/ispfw sys/modules/ispfw/isp_1000 sys/modules/ispfw/isp_1040 sys/modules/ispfw/isp_1080 sys/modules/ispfw/isp_12160 sys/modules/ispfw/isp_2... X-SVN-Commit-Revision: 367857 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 01:15:49 -0000 Author: mav Date: Fri Nov 20 01:15:48 2020 New Revision: 367857 URL: https://svnweb.freebsd.org/changeset/base/367857 Log: Remove parallel SCSI and 1/2Gb FC support from isp(4). This removes 288KB (36%) of the driver code and zillions of hacks and workarounds, making single driver uniformly support several different generations of hardware interfaces, not counting minor card variations. After years of the hopeless fight, I don't think it worth to continue support for hardware obsolete for 15-20 years. Instead much cleaner now code should allow to move forward toward better locking, multiple queues and other cool features. All the remaining Qlogic cards starting from 4Gb 24xx to 32Gb 27xx use the same hardware/firmware interface with minor incremental improvements, so it seems to be a good new starting point. Except one PCI-X model all all of them are PCIe and so still usable in modern systems. Discussed with: ken, scottl, jpaetzel, imp Relnotes: yes Deleted: head/sys/dev/ispfw/asm_1040.h head/sys/dev/ispfw/asm_1080.h head/sys/dev/ispfw/asm_12160.h head/sys/dev/ispfw/asm_2100.h head/sys/dev/ispfw/asm_2200.h head/sys/dev/ispfw/asm_2300.h head/sys/dev/ispfw/asm_2322.h head/sys/modules/ispfw/isp_1000/ head/sys/modules/ispfw/isp_1040/ head/sys/modules/ispfw/isp_1080/ head/sys/modules/ispfw/isp_12160/ head/sys/modules/ispfw/isp_2100/ head/sys/modules/ispfw/isp_2200/ head/sys/modules/ispfw/isp_2300/ head/sys/modules/ispfw/isp_2322/ Modified: head/share/man/man4/isp.4 head/share/man/man4/ispfw.4 head/sys/dev/isp/isp.c head/sys/dev/isp/isp_freebsd.c head/sys/dev/isp/isp_freebsd.h head/sys/dev/isp/isp_library.c head/sys/dev/isp/isp_library.h head/sys/dev/isp/isp_pci.c head/sys/dev/isp/isp_target.c head/sys/dev/isp/ispmbox.h head/sys/dev/isp/ispreg.h head/sys/dev/isp/ispvar.h head/sys/dev/ispfw/ispfw.c head/sys/modules/ispfw/Makefile Modified: head/share/man/man4/isp.4 ============================================================================== --- head/share/man/man4/isp.4 Fri Nov 20 00:30:58 2020 (r367856) +++ head/share/man/man4/isp.4 Fri Nov 20 01:15:48 2020 (r367857) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2009-2018 Alexander Motin +.\" Copyright (c) 2009-2020 Alexander Motin .\" Copyright (c) 2006 Marcus Alves Grando .\" Copyright (c) 1998-2001 Matthew Jacob, for NASA/Ames Research Center .\" @@ -26,12 +26,12 @@ .\" .\" $FreeBSD$ .\" -.Dd February 28, 2019 +.Dd November 19, 2020 .Dt ISP 4 .Os .Sh NAME .Nm isp -.Nd Qlogic based SPI and FibreChannel SCSI Host Adapters +.Nd Qlogic FibreChannel SCSI Host Adapters driver .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -51,23 +51,16 @@ ispfw_load="YES" .Ed .Sh DESCRIPTION This driver provides access to -.Tn SPI -or .Tn FibreChannel SCSI devices. .Pp -SPI supports initiator mode for Ultra SCSI and wide mode transactions for -.Tn SCSI , -Ultra2 LVD (1080, 1280), and Ultra3 LVD (10160, 12160). -.Pp -Fibre Channel supports initiator and target modes of FCP SCSI profile, -utilizing Class 3 and Class 2 (2200 and later) connections. +It supports initiator and target modes of FCP SCSI profile, +utilizing Class 3 and Class 2 connections. Support is available for Public and Private loops, Point-to-Point and Fabric connections. .Pp -FC-Tape is supported on 4Gb (2400) and newer controllers. -FC-Tape is highly recommended for connections to tape drives that support -it. +Supported FC-Tape functionality is highly recommended for connections +to tape drives that support it. It encompasses four elements from the T-10 FCP-4 specification: .Bl -bullet -offset indent .It @@ -100,39 +93,8 @@ Cards supported by the .Nm driver include: .Bl -tag -width xxxxxx -offset indent -.It Qlogic 1000 -Fast Wide, Ultra Fast Wide cards, Single Ended or Differential SBus cards. -.It Qlogic 1020 -Fast Wide and Differential Fast Wide SCSI PCI cards. -.It Qlogic 1040 -Ultra Wide and Differential Ultra Wide SCSI PCI cards. -Also known as the DEC KZPBA-CA (single ended) and KZPBA-CB (HVD differential). -.It Qlogic 1080 -LVD Ultra2 Wide SCSI PCI cards. -.It Qlogic 10160 -LVD Ultra3 Wide SCSI PCI cards. -.It Qlogic 1240 -Dual Bus Ultra Wide and Differential Ultra Wide SCSI PCI cards. -.It Qlogic 1280 -Dual Bus LVD Ultra2 Wide SCSI PCI cards. -.It Qlogic 12160 -Dual Bus LVD Ultra3 Wide SCSI PCI cards. -.It Qlogic 210X -Copper and Optical Fibre Channel Arbitrated Loop PCI cards (single, dual). -.It Qlogic 220X -Copper and Optical Fibre Channel Arbitrated Loop PCI cards (single, dual, quad). -.It Qlogic 2300 -Optical 2Gb Fibre Channel PCI cards. -.It Qlogic 2312 -Optical 2Gb Fibre Channel PCI cards. -.It Qlogic 234X -Optical 2Gb Fibre Channel PCI cards (2312 chipset, single and dual attach). -.It Qlogic 2322 -Optical 2Gb Fibre Channel PCIe cards. -.It Qlogic 200 -Dell branded version of the QLogic 2312. .It Qlogic 2422 -Optical 4Gb Fibre Channel PCI cards. +Optical 4Gb Fibre Channel PCI-X cards. .It Qlogic 246x (aka 2432) Optical 4Gb Fibre Channel PCIe cards. .It Qlogic 256x (aka 2532) @@ -260,6 +222,3 @@ Later improvement was done by .An Alexander Motin Aq Mt mav@FreeBSD.org . .Sh BUGS The driver currently ignores some NVRAM settings. -.Pp -Fabric support for 2100 cards has been so problematic, and these cards are so -old now that it is just not worth your time to try it. Modified: head/share/man/man4/ispfw.4 ============================================================================== --- head/share/man/man4/ispfw.4 Fri Nov 20 00:30:58 2020 (r367856) +++ head/share/man/man4/ispfw.4 Fri Nov 20 01:15:48 2020 (r367857) @@ -1,5 +1,5 @@ -.\" Copyright (c) 2000 -.\" Matthew Jacob +.\" Copyright (c) 2009-2020 Alexander Motin +.\" Copyright (c) 2000 Matthew Jacob .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -22,12 +22,12 @@ .\" .\" $FreeBSD$ .\" -.Dd November 30, 2015 +.Dd November 19, 2020 .Dt ISPFW 4 .Os .Sh NAME .Nm ispfw -.Nd "Firmware for Qlogic based SPI and FibreChannel SCSI Host Adapters" +.Nd "Firmware for Qlogic FibreChannel SCSI Host Adapters" .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your @@ -44,7 +44,7 @@ ispfw_load="YES" .Ed .Sh DESCRIPTION This trivial driver provides access to firmware sets for the Qlogic -based SPI and FibreChannel SCSI Host Adapters. +FibreChannel SCSI Host Adapters. It may either be statically linked into the kernel, or loaded as a module. In either @@ -58,3 +58,5 @@ This will kick the f/w into getting unstuck. .Sh AUTHORS This driver was written by .An Matthew Jacob . +Later improvement was done by +.An Alexander Motin Aq Mt mav@FreeBSD.org . Modified: head/sys/dev/isp/isp.c ============================================================================== --- head/sys/dev/isp/isp.c Fri Nov 20 00:30:58 2020 (r367856) +++ head/sys/dev/isp/isp.c Fri Nov 20 01:15:48 2020 (r367857) @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2009-2018 Alexander Motin + * Copyright (c) 2009-2020 Alexander Motin * Copyright (c) 1997-2009 by Matthew Jacob * All rights reserved. * @@ -98,21 +98,11 @@ static const uint8_t alpa_map[] = { /* * Local function prototypes. */ -static void isp_parse_async(ispsoftc_t *, uint16_t); -static void isp_parse_async_fc(ispsoftc_t *, uint16_t); static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *); -static void isp_parse_status(ispsoftc_t *, ispstatusreq_t *, XS_T *, uint32_t *); static void isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, uint32_t *); -static void isp_fastpost_complete(ispsoftc_t *, uint32_t); -static void isp_scsi_init(ispsoftc_t *); -static void isp_scsi_channel_init(ispsoftc_t *, int); -static void isp_fibre_init(ispsoftc_t *); -static void isp_fibre_init_2400(ispsoftc_t *); static void isp_clear_portdb(ispsoftc_t *, int); static void isp_mark_portdb(ispsoftc_t *, int); static int isp_plogx(ispsoftc_t *, int, uint16_t, uint32_t, int); -static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t); -static int isp_port_logout(ispsoftc_t *, uint16_t, uint32_t); static int isp_getpdb(ispsoftc_t *, int, uint16_t, isp_pdb_t *); static int isp_gethandles(ispsoftc_t *, int, uint16_t *, int *, int); static void isp_dump_chip_portdb(ispsoftc_t *, int); @@ -123,7 +113,6 @@ static int isp_scan_loop(ispsoftc_t *, int); static int isp_gid_pt(ispsoftc_t *, int); static int isp_scan_fabric(ispsoftc_t *, int); static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *); -static int isp_send_change_request(ispsoftc_t *, int); static int isp_register_fc4_type(ispsoftc_t *, int); static int isp_register_fc4_features_24xx(ispsoftc_t *, int); static int isp_register_port_name_24xx(ispsoftc_t *, int); @@ -132,17 +121,10 @@ static uint16_t isp_next_handle(ispsoftc_t *, uint16_t static int isp_fw_state(ispsoftc_t *, int); static void isp_mboxcmd(ispsoftc_t *, mbreg_t *); -static void isp_spi_update(ispsoftc_t *, int); -static void isp_setdfltsdparm(ispsoftc_t *); static void isp_setdfltfcparm(ispsoftc_t *, int); static int isp_read_nvram(ispsoftc_t *, int); -static int isp_read_nvram_2400(ispsoftc_t *, uint8_t *); -static void isp_rdnvram_word(ispsoftc_t *, int, uint16_t *); +static int isp_read_nvram_2400(ispsoftc_t *); static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *); -static void isp_parse_nvram_1020(ispsoftc_t *, uint8_t *); -static void isp_parse_nvram_1080(ispsoftc_t *, int, uint8_t *); -static void isp_parse_nvram_12160(ispsoftc_t *, int, uint8_t *); -static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *); static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *); static void @@ -177,16 +159,6 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) const char *btype = "????"; static const char dcrc[] = "Downloaded RISC Code Checksum Failure"; - /* - * Basic types (SCSI, FibreChannel and PCI or SBus) - * have been set in the MD code. We figure out more - * here. Possibly more refined types based upon PCI - * identification. Chip revision has been gathered. - * - * After we've fired this chip up, zero out the conf1 register - * for SCSI adapters and do other settings for the 2100. - */ - isp->isp_state = ISP_NILSTATE; ISP_DISABLE_INTS(isp); @@ -194,229 +166,25 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) * Put the board into PAUSE mode (so we can read the SXP registers * or write FPM/FBM registers). */ - if (IS_24XX(isp)) { - ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_HOST_INT); - ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT); - ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE); - } else { - ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); - } + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_HOST_INT); + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT); + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE); - if (IS_FC(isp)) { - switch (isp->isp_type) { - case ISP_HA_FC_2100: - btype = "2100"; - break; - case ISP_HA_FC_2200: - btype = "2200"; - break; - case ISP_HA_FC_2300: - btype = "2300"; - break; - case ISP_HA_FC_2312: - btype = "2312"; - break; - case ISP_HA_FC_2322: - btype = "2322"; - break; - case ISP_HA_FC_2400: - btype = "2422"; - break; - case ISP_HA_FC_2500: - btype = "2532"; - break; - case ISP_HA_FC_2600: - btype = "2600"; - break; - case ISP_HA_FC_2700: - btype = "2700"; - break; - default: - break; - } - - if (!IS_24XX(isp)) { - /* - * While we're paused, reset the FPM module and FBM - * fifos. - */ - ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS); - ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET); - ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS); - ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL); - ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS); - } - } else if (IS_1240(isp)) { - sdparam *sdp; - - btype = "1240"; - isp->isp_clock = 60; - sdp = SDPARAM(isp, 0); - sdp->isp_ultramode = 1; - sdp = SDPARAM(isp, 1); - sdp->isp_ultramode = 1; - /* - * XXX: Should probably do some bus sensing. - */ - } else if (IS_ULTRA3(isp)) { - sdparam *sdp = isp->isp_param; - - isp->isp_clock = 100; - - if (IS_10160(isp)) - btype = "10160"; - else if (IS_12160(isp)) - btype = "12160"; - else - btype = ""; - sdp->isp_lvdmode = 1; - - if (IS_DUALBUS(isp)) { - sdp++; - sdp->isp_lvdmode = 1; - } - } else if (IS_ULTRA2(isp)) { - static const char m[] = "bus %d is in %s Mode"; - uint16_t l; - sdparam *sdp = SDPARAM(isp, 0); - - isp->isp_clock = 100; - - if (IS_1280(isp)) - btype = "1280"; - else if (IS_1080(isp)) - btype = "1080"; - else - btype = ""; - - l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK; - switch (l) { - case ISP1080_LVD_MODE: - sdp->isp_lvdmode = 1; - isp_prt(isp, ISP_LOGCONFIG, m, 0, "LVD"); - break; - case ISP1080_HVD_MODE: - sdp->isp_diffmode = 1; - isp_prt(isp, ISP_LOGCONFIG, m, 0, "Differential"); - break; - case ISP1080_SE_MODE: - sdp->isp_ultramode = 1; - isp_prt(isp, ISP_LOGCONFIG, m, 0, "Single-Ended"); - break; - default: - isp_prt(isp, ISP_LOGERR, - "unknown mode on bus %d (0x%x)", 0, l); - break; - } - - if (IS_DUALBUS(isp)) { - sdp = SDPARAM(isp, 1); - l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT); - l &= ISP1080_MODE_MASK; - switch (l) { - case ISP1080_LVD_MODE: - sdp->isp_lvdmode = 1; - isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD"); - break; - case ISP1080_HVD_MODE: - sdp->isp_diffmode = 1; - isp_prt(isp, ISP_LOGCONFIG, - m, 1, "Differential"); - break; - case ISP1080_SE_MODE: - sdp->isp_ultramode = 1; - isp_prt(isp, ISP_LOGCONFIG, - m, 1, "Single-Ended"); - break; - default: - isp_prt(isp, ISP_LOGERR, - "unknown mode on bus %d (0x%x)", 1, l); - break; - } - } - } else { - sdparam *sdp = SDPARAM(isp, 0); - i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK; - switch (i) { - default: - isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i); - /* FALLTHROUGH */ - case 1: - btype = "1020"; - isp->isp_type = ISP_HA_SCSI_1020; - isp->isp_clock = 40; - break; - case 2: - /* - * Some 1020A chips are Ultra Capable, but don't - * run the clock rate up for that unless told to - * do so by the Ultra Capable bits being set. - */ - btype = "1020A"; - isp->isp_type = ISP_HA_SCSI_1020A; - isp->isp_clock = 40; - break; - case 3: - btype = "1040"; - isp->isp_type = ISP_HA_SCSI_1040; - isp->isp_clock = 60; - break; - case 4: - btype = "1040A"; - isp->isp_type = ISP_HA_SCSI_1040A; - isp->isp_clock = 60; - break; - case 5: - btype = "1040B"; - isp->isp_type = ISP_HA_SCSI_1040B; - isp->isp_clock = 60; - break; - case 6: - btype = "1040C"; - isp->isp_type = ISP_HA_SCSI_1040C; - isp->isp_clock = 60; - break; - } - /* - * Now, while we're at it, gather info about ultra - * and/or differential mode. - */ - if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) { - isp_prt(isp, ISP_LOGCONFIG, "Differential Mode"); - sdp->isp_diffmode = 1; - } else { - sdp->isp_diffmode = 0; - } - i = ISP_READ(isp, RISC_PSR); - if (isp->isp_bustype == ISP_BT_SBUS) { - i &= RISC_PSR_SBUS_ULTRA; - } else { - i &= RISC_PSR_PCI_ULTRA; - } - if (i != 0) { - isp_prt(isp, ISP_LOGCONFIG, "Ultra Mode Capable"); - sdp->isp_ultramode = 1; - /* - * If we're in Ultra Mode, we have to be 60MHz clock- - * even for the SBus version. - */ - isp->isp_clock = 60; - } else { - sdp->isp_ultramode = 0; - /* - * Clock is known. Gronk. - */ - } - - /* - * Machine dependent clock (if set) overrides - * our generic determinations. - */ - if (isp->isp_mdvec->dv_clock) { - if (isp->isp_mdvec->dv_clock < isp->isp_clock) { - isp->isp_clock = isp->isp_mdvec->dv_clock; - } - } + switch (isp->isp_type) { + case ISP_HA_FC_2400: + btype = "2422"; + break; + case ISP_HA_FC_2500: + btype = "2532"; + break; + case ISP_HA_FC_2600: + btype = "2600"; + break; + case ISP_HA_FC_2700: + btype = "2700"; + break; + default: + break; } /* @@ -424,87 +192,48 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) * and give it a chance to recover. */ - if (IS_SCSI(isp)) { - ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET); - /* - * A slight delay... - */ - ISP_DELAY(100); - - /* - * Clear data && control DMA engines. - */ - ISP_WRITE(isp, CDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); - ISP_WRITE(isp, DDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); - - - } else if (IS_24XX(isp)) { - /* - * Stop DMA and wait for it to stop. - */ - ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4)); - for (val = loops = 0; loops < 30000; loops++) { - ISP_DELAY(10); - val = ISP_READ(isp, BIU2400_CSR); - if ((val & BIU2400_DMA_ACTIVE) == 0) { - break; - } + /* + * Stop DMA and wait for it to stop. + */ + ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4)); + for (val = loops = 0; loops < 30000; loops++) { + ISP_DELAY(10); + val = ISP_READ(isp, BIU2400_CSR); + if ((val & BIU2400_DMA_ACTIVE) == 0) { + break; } - if (val & BIU2400_DMA_ACTIVE) { - isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset"); - return; + } + if (val & BIU2400_DMA_ACTIVE) { + isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset"); + return; + } + /* + * Hold it in SOFT_RESET and STOP state for 100us. + */ + ISP_WRITE(isp, BIU2400_CSR, BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4)); + ISP_DELAY(100); + for (loops = 0; loops < 10000; loops++) { + ISP_DELAY(5); + val = ISP_READ(isp, OUTMAILBOX0); + } + for (val = loops = 0; loops < 500000; loops ++) { + val = ISP_READ(isp, BIU2400_CSR); + if ((val & BIU2400_SOFT_RESET) == 0) { + break; } - /* - * Hold it in SOFT_RESET and STOP state for 100us. - */ - ISP_WRITE(isp, BIU2400_CSR, BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4)); - ISP_DELAY(100); - for (loops = 0; loops < 10000; loops++) { - ISP_DELAY(5); - val = ISP_READ(isp, OUTMAILBOX0); - } - for (val = loops = 0; loops < 500000; loops ++) { - val = ISP_READ(isp, BIU2400_CSR); - if ((val & BIU2400_SOFT_RESET) == 0) { - break; - } - } - if (val & BIU2400_SOFT_RESET) { - isp_prt(isp, ISP_LOGERR, "Failed to come out of reset"); - return; - } - } else { - ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET); - /* - * A slight delay... - */ - ISP_DELAY(100); - - /* - * Clear data && control DMA engines. - */ - ISP_WRITE(isp, CDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT); - ISP_WRITE(isp, TDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT); - ISP_WRITE(isp, RDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT); } + if (val & BIU2400_SOFT_RESET) { + isp_prt(isp, ISP_LOGERR, "Failed to come out of reset"); + return; + } /* * Wait for ISP to be ready to go... */ loops = MBOX_DELAY_COUNT; for (;;) { - if (IS_SCSI(isp)) { - if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET)) { - break; - } - } else if (IS_24XX(isp)) { - if (ISP_READ(isp, OUTMAILBOX0) == 0) { - break; - } - } else { - if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET)) - break; - } + if (ISP_READ(isp, OUTMAILBOX0) == 0) + break; ISP_DELAY(100); if (--loops < 0) { ISP_DUMPREGS(isp, "chip reset timed out"); @@ -513,136 +242,47 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) } /* - * After we've fired this chip up, zero out the conf1 register - * for SCSI adapters and other settings for the 2100. - */ - - if (IS_SCSI(isp)) { - ISP_WRITE(isp, BIU_CONF1, 0); - } else if (!IS_24XX(isp)) { - ISP_WRITE(isp, BIU2100_CSR, 0); - } - - /* * Reset RISC Processor */ - if (IS_24XX(isp)) { - ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET); - ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE); - ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET); - } else { - ISP_WRITE(isp, HCCR, HCCR_CMD_RESET); - ISP_DELAY(100); - ISP_WRITE(isp, BIU_SEMA, 0); - } + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET); + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE); + ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET); /* * Post-RISC Reset stuff. */ - if (IS_24XX(isp)) { - for (val = loops = 0; loops < 5000000; loops++) { - ISP_DELAY(5); - val = ISP_READ(isp, OUTMAILBOX0); - if (val == 0) { - break; - } + for (val = loops = 0; loops < 5000000; loops++) { + ISP_DELAY(5); + val = ISP_READ(isp, OUTMAILBOX0); + if (val == 0) { + break; } - if (val != 0) { - isp_prt(isp, ISP_LOGERR, "reset didn't clear"); - return; - } - } else if (IS_SCSI(isp)) { - uint16_t tmp = isp->isp_mdvec->dv_conf1; - /* - * Busted FIFO. Turn off all but burst enables. - */ - if (isp->isp_type == ISP_HA_SCSI_1040A) { - tmp &= BIU_BURST_ENABLE; - } - ISP_SETBITS(isp, BIU_CONF1, tmp); - if (tmp & BIU_BURST_ENABLE) { - ISP_SETBITS(isp, CDMA_CONF, DMA_ENABLE_BURST); - ISP_SETBITS(isp, DDMA_CONF, DMA_ENABLE_BURST); - } - if (SDPARAM(isp, 0)->isp_ptisp) { - if (SDPARAM(isp, 0)->isp_ultramode) { - while (ISP_READ(isp, RISC_MTR) != 0x1313) { - ISP_WRITE(isp, RISC_MTR, 0x1313); - ISP_WRITE(isp, HCCR, HCCR_CMD_STEP); - } - } else { - ISP_WRITE(isp, RISC_MTR, 0x1212); - } - /* - * PTI specific register - */ - ISP_WRITE(isp, RISC_EMB, DUAL_BANK); - } else { - ISP_WRITE(isp, RISC_MTR, 0x1212); - } - ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); - } else { - ISP_WRITE(isp, RISC_MTR2100, 0x1212); - if (IS_2200(isp) || IS_23XX(isp)) { - ISP_WRITE(isp, HCCR, HCCR_2X00_DISABLE_PARITY_PAUSE); - } - ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); } - - /* - * Set up default request/response queue in-pointer/out-pointer - * register indices. - */ - if (IS_24XX(isp)) { - isp->isp_rqstinrp = BIU2400_REQINP; - isp->isp_rqstoutrp = BIU2400_REQOUTP; - isp->isp_respinrp = BIU2400_RSPINP; - isp->isp_respoutrp = BIU2400_RSPOUTP; - } else if (IS_23XX(isp)) { - isp->isp_rqstinrp = BIU_REQINP; - isp->isp_rqstoutrp = BIU_REQOUTP; - isp->isp_respinrp = BIU_RSPINP; - isp->isp_respoutrp = BIU_RSPOUTP; - } else { - isp->isp_rqstinrp = INMAILBOX4; - isp->isp_rqstoutrp = OUTMAILBOX4; - isp->isp_respinrp = OUTMAILBOX5; - isp->isp_respoutrp = INMAILBOX5; + if (val != 0) { + isp_prt(isp, ISP_LOGERR, "reset didn't clear"); + return; } - ISP_WRITE(isp, isp->isp_rqstinrp, 0); - ISP_WRITE(isp, isp->isp_rqstoutrp, 0); - ISP_WRITE(isp, isp->isp_respinrp, 0); - ISP_WRITE(isp, isp->isp_respoutrp, 0); - if (IS_24XX(isp)) { - if (!IS_26XX(isp)) { - ISP_WRITE(isp, BIU2400_PRI_REQINP, 0); - ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0); - } - ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0); - ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0); - } - if (!IS_24XX(isp) && isp->isp_bustype == ISP_BT_PCI) { - /* Make sure the BIOS is disabled */ - ISP_WRITE(isp, HCCR, PCI_HCCR_CMD_BIOS); + ISP_WRITE(isp, BIU2400_REQINP, 0); + ISP_WRITE(isp, BIU2400_REQOUTP, 0); + ISP_WRITE(isp, BIU2400_RSPINP, 0); + ISP_WRITE(isp, BIU2400_RSPOUTP, 0); + if (!IS_26XX(isp)) { + ISP_WRITE(isp, BIU2400_PRI_REQINP, 0); + ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0); } + ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0); + ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0); /* * Wait for everything to finish firing up. - * - * Avoid doing this on early 2312s because you can generate a PCI - * parity error (chip breakage). */ - if (IS_2312(isp) && isp->isp_revision < 2) { + loops = MBOX_DELAY_COUNT; + while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) { ISP_DELAY(100); - } else { - loops = MBOX_DELAY_COUNT; - while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) { - ISP_DELAY(100); - if (--loops < 0) { - isp_prt(isp, ISP_LOGERR, "MBOX_BUSY never cleared on reset"); - return; - } + if (--loops < 0) { + isp_prt(isp, ISP_LOGERR, "MBOX_BUSY never cleared on reset"); + return; } } @@ -666,7 +306,7 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) /* * Do some operational tests */ - if (IS_SCSI(isp) || IS_24XX(isp)) { + { static const uint16_t patterns[MAX_MAILBOX] = { 0x0000, 0xdead, 0xbeef, 0xffff, 0xa5a5, 0x5a5a, 0x7f7f, 0x7ff7, @@ -678,8 +318,6 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) 0x0000, 0x0001, 0x1000, 0x1010, }; int nmbox = ISP_NMBOX(isp); - if (IS_SCSI(isp)) - nmbox = 6; MBSINIT(&mbs, MBOX_MAILBOX_REG_TEST, MBLOGALL, 0); for (i = 1; i < nmbox; i++) { mbs.param[i] = patterns[i]; @@ -720,16 +358,9 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) } } - if (IS_24XX(isp)) { - code_org = ISP_CODE_ORG_2400; - } else if (IS_23XX(isp)) { - code_org = ISP_CODE_ORG_2300; - } else { - code_org = ISP_CODE_ORG; - } - + code_org = ISP_CODE_ORG_2400; isp->isp_loaded_fw = 0; - if (dodnld && IS_24XX(isp)) { + if (dodnld) { const uint32_t *ptr = isp->isp_mdvec->dv_ispfw; uint32_t la, wi, wl; @@ -737,9 +368,7 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) * Keep loading until we run out of f/w. */ code_org = ptr[2]; /* 1st load address is our start addr */ - for (;;) { - isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], ptr[2]); wi = 0; @@ -780,101 +409,6 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) ptr += ptr[3]; } isp->isp_loaded_fw = 1; - } else if (dodnld && IS_23XX(isp)) { - const uint16_t *ptr = isp->isp_mdvec->dv_ispfw; - uint16_t wi, wl, segno; - uint32_t la; - - la = code_org; - segno = 0; - - for (;;) { - uint32_t nxtaddr; - - isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], la); - - wi = 0; - wl = ptr[3]; - - while (wi < ptr[3]) { - uint16_t *cp; - uint16_t nw; - - nw = min(wl, min((1 << 15), ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) / 2)); - cp = isp->isp_rquest; - for (i = 0; i < nw; i++) - ISP_IOXPUT_16(isp, ptr[wi + i], &cp[i]); - MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)), -1); - MBSINIT(&mbs, 0, MBLOGALL, 0); - if (la < 0x10000) { - mbs.param[0] = MBOX_LOAD_RISC_RAM_2100; - mbs.param[1] = la; - mbs.param[2] = DMA_WD1(isp->isp_rquest_dma); - mbs.param[3] = DMA_WD0(isp->isp_rquest_dma); - mbs.param[4] = nw; - mbs.param[6] = DMA_WD3(isp->isp_rquest_dma); - mbs.param[7] = DMA_WD2(isp->isp_rquest_dma); - isp_prt(isp, ISP_LOGDEBUG1, "LOAD RISC RAM 2100 %u words at load address 0x%x\n", nw, la); - } else { - mbs.param[0] = MBOX_LOAD_RISC_RAM; - mbs.param[1] = la; - mbs.param[2] = DMA_WD1(isp->isp_rquest_dma); - mbs.param[3] = DMA_WD0(isp->isp_rquest_dma); - mbs.param[4] = nw; - mbs.param[6] = DMA_WD3(isp->isp_rquest_dma); - mbs.param[7] = DMA_WD2(isp->isp_rquest_dma); - mbs.param[8] = la >> 16; - isp_prt(isp, ISP_LOGDEBUG1, "LOAD RISC RAM %u words at load address 0x%x\n", nw, la); - } - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, "F/W download failed"); - return; - } - la += nw; - wi += nw; - wl -= nw; - } - - if (!IS_2322(isp)) { - break; - } - - if (++segno == 3) { - break; - } - - /* - * If we're a 2322, the firmware actually comes in - * three chunks. We loaded the first at the code_org - * address. The other two chunks, which follow right - * after each other in memory here, get loaded at - * addresses specfied at offset 0x9..0xB. - */ - - nxtaddr = ptr[3]; - ptr = &ptr[nxtaddr]; - la = ptr[5] | ((ptr[4] & 0x3f) << 16); - } - isp->isp_loaded_fw = 1; - } else if (dodnld) { - const uint16_t *ptr = isp->isp_mdvec->dv_ispfw; - u_int i, wl; - - wl = ptr[3]; - isp_prt(isp, ISP_LOGDEBUG1, - "WRITE RAM %u words at load address 0x%x", wl, code_org); - for (i = 0; i < wl; i++) { - MBSINIT(&mbs, MBOX_WRITE_RAM_WORD, MBLOGNONE, 0); - mbs.param[1] = code_org + i; - mbs.param[2] = ptr[i]; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, - "F/W download failed at word %d", i); - return; - } - } } else if (IS_26XX(isp)) { isp_prt(isp, ISP_LOGDEBUG1, "loading firmware from flash"); MBSINIT(&mbs, MBOX_LOAD_FLASH_FIRMWARE, MBLOGALL, 5000000); @@ -894,12 +428,8 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) */ if (isp->isp_loaded_fw) { MBSINIT(&mbs, MBOX_VERIFY_CHECKSUM, MBLOGNONE, 0); - if (IS_24XX(isp)) { - mbs.param[1] = code_org >> 16; - mbs.param[2] = code_org; - } else { - mbs.param[1] = code_org; - } + mbs.param[1] = code_org >> 16; + mbs.param[2] = code_org; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { isp_prt(isp, ISP_LOGERR, dcrc); @@ -917,43 +447,18 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) if (IS_26XX(isp)) { mbs.param[1] = code_org >> 16; mbs.param[2] = code_org; - } else if (IS_24XX(isp)) { + } else { mbs.param[1] = code_org >> 16; mbs.param[2] = code_org; - if (isp->isp_loaded_fw) { + if (isp->isp_loaded_fw) mbs.param[3] = 0; - } else { + else mbs.param[3] = 1; - } - } else if (IS_2322(isp)) { - mbs.param[1] = code_org; - if (isp->isp_loaded_fw) { - mbs.param[2] = 0; - } else { - mbs.param[2] = 1; - } - } else { - mbs.param[1] = code_org; } isp_mboxcmd(isp, &mbs); - if (IS_2322(isp) || IS_24XX(isp)) { - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return; - } - } + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) + return; - if (IS_SCSI(isp)) { - /* - * Set CLOCK RATE, but only if asked to. - */ - if (isp->isp_clock) { - MBSINIT(&mbs, MBOX_SET_CLOCK_RATE, MBLOGALL, 0); - mbs.param[1] = isp->isp_clock; - isp_mboxcmd(isp, &mbs); - /* we will try not to care if this fails */ - } - } - /* * Ask the chip for the current firmware version. * This should prove that the new firmware is working. @@ -964,211 +469,116 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults) return; } - /* - * The SBus firmware that we are using apparently does not return - * major, minor, micro revisions in the mailbox registers, which - * is really, really, annoying. - */ - if (ISP_SBUS_SUPPORTED && isp->isp_bustype == ISP_BT_SBUS) { - if (dodnld) { -#ifdef ISP_TARGET_MODE - isp->isp_fwrev[0] = 7; - isp->isp_fwrev[1] = 55; -#else - isp->isp_fwrev[0] = 1; - isp->isp_fwrev[1] = 37; -#endif - isp->isp_fwrev[2] = 0; - } - } else { - isp->isp_fwrev[0] = mbs.param[1]; - isp->isp_fwrev[1] = mbs.param[2]; - isp->isp_fwrev[2] = mbs.param[3]; + isp->isp_fwrev[0] = mbs.param[1]; + isp->isp_fwrev[1] = mbs.param[2]; + isp->isp_fwrev[2] = mbs.param[3]; + isp->isp_fwattr = mbs.param[6]; + isp->isp_fwattr |= ((uint64_t) mbs.param[15]) << 16; + if (isp->isp_fwattr & ISP2400_FW_ATTR_EXTNDED) { + isp->isp_fwattr |= + (((uint64_t) mbs.param[16]) << 32) | + (((uint64_t) mbs.param[17]) << 48); } - if (IS_FC(isp)) { - /* - * We do not believe firmware attributes for 2100 code less - * than 1.17.0, unless it's the firmware we specifically - * are loading. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Nov 20 02:03:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8E3CA47A845; Fri, 20 Nov 2020 02:03:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ccfwt3g5Mz3wSv; Fri, 20 Nov 2020 02:03:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7091C61D5; Fri, 20 Nov 2020 02:03:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK23wcN038407; Fri, 20 Nov 2020 02:03:58 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK23wPe038406; Fri, 20 Nov 2020 02:03:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011200203.0AK23wPe038406@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Nov 2020 02:03:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367858 - head/sys/dev/isp X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/isp X-SVN-Commit-Revision: 367858 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 02:03:58 -0000 Author: mav Date: Fri Nov 20 02:03:58 2020 New Revision: 367858 URL: https://svnweb.freebsd.org/changeset/base/367858 Log: Fix r367857 build without ISP_TARGET_MODE. Modified: head/sys/dev/isp/isp_pci.c Modified: head/sys/dev/isp/isp_pci.c ============================================================================== --- head/sys/dev/isp/isp_pci.c Fri Nov 20 01:15:48 2020 (r367857) +++ head/sys/dev/isp/isp_pci.c Fri Nov 20 02:03:58 2020 (r367858) @@ -893,7 +893,9 @@ isp_pci_mbxdma(ispsoftc_t *isp) int i, error, cmap = 0; bus_size_t slim; /* segment size */ struct imush im; +#ifdef ISP_TARGET_MODE isp_ecmd_t *ecmd; +#endif /* Already been here? If so, leave... */ if (isp->isp_xflist != NULL) From owner-svn-src-all@freebsd.org Fri Nov 20 03:33:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B00847C5D0; Fri, 20 Nov 2020 03:33:31 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CchwC0lzKz4WB3; Fri, 20 Nov 2020 03:33:31 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0CD457719; Fri, 20 Nov 2020 03:33:31 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK3XUGc095737; Fri, 20 Nov 2020 03:33:30 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK3XUYD095736; Fri, 20 Nov 2020 03:33:30 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <202011200333.0AK3XUYD095736@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Fri, 20 Nov 2020 03:33:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367859 - stable/12/usr.sbin/bhyve X-SVN-Group: stable-12 X-SVN-Commit-Author: grehan X-SVN-Commit-Paths: stable/12/usr.sbin/bhyve X-SVN-Commit-Revision: 367859 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 03:33:31 -0000 Author: grehan Date: Fri Nov 20 03:33:30 2020 New Revision: 367859 URL: https://svnweb.freebsd.org/changeset/base/367859 Log: MFC r367709 Fix regression in AHCI controller settings. PR: 250924 Submitted by: Rolf Stalder Reported by: Rolf Stalder Relnotes: Yes Modified: stable/12/usr.sbin/bhyve/pci_ahci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- stable/12/usr.sbin/bhyve/pci_ahci.c Fri Nov 20 02:03:58 2020 (r367858) +++ stable/12/usr.sbin/bhyve/pci_ahci.c Fri Nov 20 03:33:30 2020 (r367859) @@ -1000,7 +1000,7 @@ ata_identify_init(struct ahci_port* p, int atapi) ata_ident->capabilities1 = ATA_SUPPORT_LBA | ATA_SUPPORT_DMA; ata_ident->capabilities2 = (1 << 14 | 1); - ata_ident->atavalid = ATA_FLAG_54_58 | ATA_FLAG_64_70; + ata_ident->atavalid = ATA_FLAG_64_70 | ATA_FLAG_88; ata_ident->obsolete62 = 0x3f; ata_ident->mwdmamodes = 7; if (p->xfermode & ATA_WDMA0) @@ -1049,8 +1049,7 @@ ata_identify_init(struct ahci_port* p, int atapi) ata_ident->capabilities1 = ATA_SUPPORT_DMA | ATA_SUPPORT_LBA | ATA_SUPPORT_IORDY; ata_ident->capabilities2 = (1 << 14); - ata_ident->atavalid = ATA_FLAG_54_58 | - ATA_FLAG_64_70; + ata_ident->atavalid = ATA_FLAG_64_70 | ATA_FLAG_88; if (p->mult_sectors) ata_ident->multi = (ATA_MULTI_VALID | p->mult_sectors); if (sectors <= 0x0fffffff) { From owner-svn-src-all@freebsd.org Fri Nov 20 03:54:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9B8BE47CB0D; Fri, 20 Nov 2020 03:54:39 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcjNb3sq4z4WK5; Fri, 20 Nov 2020 03:54:39 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6CA727952; Fri, 20 Nov 2020 03:54:39 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK3sdX6008224; Fri, 20 Nov 2020 03:54:39 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK3scrC008217; Fri, 20 Nov 2020 03:54:38 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <202011200354.0AK3scrC008217@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Fri, 20 Nov 2020 03:54:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367860 - in vendor/NetBSD/bmake/dist: . filemon missing missing/sys mk unit-tests X-SVN-Group: vendor X-SVN-Commit-Author: sjg X-SVN-Commit-Paths: in vendor/NetBSD/bmake/dist: . filemon missing missing/sys mk unit-tests X-SVN-Commit-Revision: 367860 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 03:54:39 -0000 Author: sjg Date: Fri Nov 20 03:54:37 2020 New Revision: 367860 URL: https://svnweb.freebsd.org/changeset/base/367860 Log: Import bmake-20201117 o allow env var MAKE_OBJDIR_CHECK_WRITABLE=no to skip writable checks in InitObjdir. Explicit .OBJDIR target always allows read-only directory. o Fix building and unit-tests on non-BSD. o More code cleanup and refactoring. o More unit tests Added: vendor/NetBSD/bmake/dist/missing/ vendor/NetBSD/bmake/dist/missing/sys/ vendor/NetBSD/bmake/dist/missing/sys/cdefs.h (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/cmd-errors-lint.exp vendor/NetBSD/bmake/dist/unit-tests/cmd-errors-lint.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/cmd-errors.exp vendor/NetBSD/bmake/dist/unit-tests/cmd-errors.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/cmdline-undefined.exp vendor/NetBSD/bmake/dist/unit-tests/cmdline-undefined.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/cond-op-and-lint.exp vendor/NetBSD/bmake/dist/unit-tests/cond-op-and-lint.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/cond-op-or-lint.exp vendor/NetBSD/bmake/dist/unit-tests/cond-op-or-lint.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/directive-if-nested.exp vendor/NetBSD/bmake/dist/unit-tests/directive-if-nested.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/gnode-submake.exp vendor/NetBSD/bmake/dist/unit-tests/gnode-submake.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/job-flags.exp vendor/NetBSD/bmake/dist/unit-tests/job-flags.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/objdir-writable.exp vendor/NetBSD/bmake/dist/unit-tests/objdir-writable.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/opt-touch-jobs.exp vendor/NetBSD/bmake/dist/unit-tests/opt-touch-jobs.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/suff-self.exp vendor/NetBSD/bmake/dist/unit-tests/suff-self.mk (contents, props changed) vendor/NetBSD/bmake/dist/unit-tests/varparse-errors.exp vendor/NetBSD/bmake/dist/unit-tests/varparse-errors.mk (contents, props changed) Deleted: vendor/NetBSD/bmake/dist/unit-tests/directives.exp vendor/NetBSD/bmake/dist/unit-tests/directives.mk vendor/NetBSD/bmake/dist/unit-tests/varshell.exp vendor/NetBSD/bmake/dist/unit-tests/varshell.mk Modified: vendor/NetBSD/bmake/dist/ChangeLog vendor/NetBSD/bmake/dist/FILES vendor/NetBSD/bmake/dist/Makefile vendor/NetBSD/bmake/dist/Makefile.config.in vendor/NetBSD/bmake/dist/VERSION vendor/NetBSD/bmake/dist/arch.c vendor/NetBSD/bmake/dist/bmake.1 vendor/NetBSD/bmake/dist/bmake.cat1 vendor/NetBSD/bmake/dist/boot-strap vendor/NetBSD/bmake/dist/buf.c vendor/NetBSD/bmake/dist/buf.h vendor/NetBSD/bmake/dist/compat.c vendor/NetBSD/bmake/dist/cond.c vendor/NetBSD/bmake/dist/configure vendor/NetBSD/bmake/dist/configure.in vendor/NetBSD/bmake/dist/dir.c vendor/NetBSD/bmake/dist/dir.h vendor/NetBSD/bmake/dist/filemon/filemon_dev.c vendor/NetBSD/bmake/dist/filemon/filemon_ktrace.c vendor/NetBSD/bmake/dist/for.c vendor/NetBSD/bmake/dist/hash.c vendor/NetBSD/bmake/dist/hash.h vendor/NetBSD/bmake/dist/job.c vendor/NetBSD/bmake/dist/job.h vendor/NetBSD/bmake/dist/lst.c vendor/NetBSD/bmake/dist/lst.h vendor/NetBSD/bmake/dist/main.c vendor/NetBSD/bmake/dist/make-bootstrap.sh.in vendor/NetBSD/bmake/dist/make.1 vendor/NetBSD/bmake/dist/make.c vendor/NetBSD/bmake/dist/make.h vendor/NetBSD/bmake/dist/make_malloc.h vendor/NetBSD/bmake/dist/meta.c vendor/NetBSD/bmake/dist/metachar.h vendor/NetBSD/bmake/dist/mk/ChangeLog vendor/NetBSD/bmake/dist/mk/install-mk vendor/NetBSD/bmake/dist/mk/meta.autodep.mk vendor/NetBSD/bmake/dist/mk/meta2deps.sh vendor/NetBSD/bmake/dist/nonints.h vendor/NetBSD/bmake/dist/parse.c vendor/NetBSD/bmake/dist/str.c vendor/NetBSD/bmake/dist/suff.c vendor/NetBSD/bmake/dist/targ.c vendor/NetBSD/bmake/dist/unit-tests/Makefile vendor/NetBSD/bmake/dist/unit-tests/archive-suffix.mk vendor/NetBSD/bmake/dist/unit-tests/archive.mk vendor/NetBSD/bmake/dist/unit-tests/cmd-interrupt.mk vendor/NetBSD/bmake/dist/unit-tests/cmdline.mk vendor/NetBSD/bmake/dist/unit-tests/comment.mk vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-numeric-eq.exp vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-numeric-eq.mk vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-numeric.exp vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-numeric.mk vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-string.exp vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-string.mk vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-unary.exp vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-unary.mk vendor/NetBSD/bmake/dist/unit-tests/cond-func-commands.mk vendor/NetBSD/bmake/dist/unit-tests/cond-func-defined.exp vendor/NetBSD/bmake/dist/unit-tests/cond-func-defined.mk vendor/NetBSD/bmake/dist/unit-tests/cond-func-empty.exp vendor/NetBSD/bmake/dist/unit-tests/cond-func-empty.mk vendor/NetBSD/bmake/dist/unit-tests/cond-func.exp vendor/NetBSD/bmake/dist/unit-tests/cond-func.mk vendor/NetBSD/bmake/dist/unit-tests/cond-late.mk vendor/NetBSD/bmake/dist/unit-tests/cond-op-not.exp vendor/NetBSD/bmake/dist/unit-tests/cond-op-not.mk vendor/NetBSD/bmake/dist/unit-tests/cond-op-parentheses.exp vendor/NetBSD/bmake/dist/unit-tests/cond-op-parentheses.mk vendor/NetBSD/bmake/dist/unit-tests/cond-op.exp vendor/NetBSD/bmake/dist/unit-tests/cond-op.mk vendor/NetBSD/bmake/dist/unit-tests/cond-short.mk vendor/NetBSD/bmake/dist/unit-tests/cond-token-number.exp vendor/NetBSD/bmake/dist/unit-tests/cond-token-number.mk vendor/NetBSD/bmake/dist/unit-tests/cond-token-plain.mk vendor/NetBSD/bmake/dist/unit-tests/cond-token-string.exp vendor/NetBSD/bmake/dist/unit-tests/cond-token-string.mk vendor/NetBSD/bmake/dist/unit-tests/cond-token-var.exp vendor/NetBSD/bmake/dist/unit-tests/cond-token-var.mk vendor/NetBSD/bmake/dist/unit-tests/cond-undef-lint.exp vendor/NetBSD/bmake/dist/unit-tests/cond-undef-lint.mk vendor/NetBSD/bmake/dist/unit-tests/cond1.exp vendor/NetBSD/bmake/dist/unit-tests/cond1.mk vendor/NetBSD/bmake/dist/unit-tests/dep-double-colon.mk vendor/NetBSD/bmake/dist/unit-tests/dep-exclam.mk vendor/NetBSD/bmake/dist/unit-tests/depsrc-ignore.mk vendor/NetBSD/bmake/dist/unit-tests/depsrc-make.mk vendor/NetBSD/bmake/dist/unit-tests/depsrc-optional.exp vendor/NetBSD/bmake/dist/unit-tests/depsrc-optional.mk vendor/NetBSD/bmake/dist/unit-tests/depsrc-precious.mk vendor/NetBSD/bmake/dist/unit-tests/depsrc-usebefore.mk vendor/NetBSD/bmake/dist/unit-tests/depsrc.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt-begin.exp vendor/NetBSD/bmake/dist/unit-tests/deptgt-begin.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt-error.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt-ignore.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt-interrupt.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt-main.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt-makeflags.exp vendor/NetBSD/bmake/dist/unit-tests/deptgt-makeflags.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt-silent.exp vendor/NetBSD/bmake/dist/unit-tests/deptgt-silent.mk vendor/NetBSD/bmake/dist/unit-tests/deptgt.exp vendor/NetBSD/bmake/dist/unit-tests/deptgt.mk vendor/NetBSD/bmake/dist/unit-tests/dir.mk vendor/NetBSD/bmake/dist/unit-tests/directive-elif.exp vendor/NetBSD/bmake/dist/unit-tests/directive-elif.mk vendor/NetBSD/bmake/dist/unit-tests/directive-else.exp vendor/NetBSD/bmake/dist/unit-tests/directive-else.mk vendor/NetBSD/bmake/dist/unit-tests/directive-endif.mk vendor/NetBSD/bmake/dist/unit-tests/directive-export-env.mk vendor/NetBSD/bmake/dist/unit-tests/directive-export-gmake.mk vendor/NetBSD/bmake/dist/unit-tests/directive-export-literal.mk vendor/NetBSD/bmake/dist/unit-tests/directive-export.exp vendor/NetBSD/bmake/dist/unit-tests/directive-export.mk vendor/NetBSD/bmake/dist/unit-tests/directive-for.exp vendor/NetBSD/bmake/dist/unit-tests/directive-for.mk vendor/NetBSD/bmake/dist/unit-tests/directive-if.exp vendor/NetBSD/bmake/dist/unit-tests/directive-if.mk vendor/NetBSD/bmake/dist/unit-tests/directive-ifdef.exp vendor/NetBSD/bmake/dist/unit-tests/directive-ifdef.mk vendor/NetBSD/bmake/dist/unit-tests/directive-ifmake.exp vendor/NetBSD/bmake/dist/unit-tests/directive-ifmake.mk vendor/NetBSD/bmake/dist/unit-tests/directive-include.exp vendor/NetBSD/bmake/dist/unit-tests/directive-include.mk vendor/NetBSD/bmake/dist/unit-tests/directive-info.exp vendor/NetBSD/bmake/dist/unit-tests/directive-info.mk vendor/NetBSD/bmake/dist/unit-tests/directive-sinclude.mk vendor/NetBSD/bmake/dist/unit-tests/directive-undef.exp vendor/NetBSD/bmake/dist/unit-tests/directive-undef.mk vendor/NetBSD/bmake/dist/unit-tests/directive-unexport-env.mk vendor/NetBSD/bmake/dist/unit-tests/directive-unexport.exp vendor/NetBSD/bmake/dist/unit-tests/directive-unexport.mk vendor/NetBSD/bmake/dist/unit-tests/directive-warning.exp vendor/NetBSD/bmake/dist/unit-tests/directive-warning.mk vendor/NetBSD/bmake/dist/unit-tests/directive.exp vendor/NetBSD/bmake/dist/unit-tests/directive.mk vendor/NetBSD/bmake/dist/unit-tests/dollar.exp vendor/NetBSD/bmake/dist/unit-tests/dollar.mk vendor/NetBSD/bmake/dist/unit-tests/envfirst.mk vendor/NetBSD/bmake/dist/unit-tests/error.exp vendor/NetBSD/bmake/dist/unit-tests/error.mk vendor/NetBSD/bmake/dist/unit-tests/escape.mk vendor/NetBSD/bmake/dist/unit-tests/forloop.exp vendor/NetBSD/bmake/dist/unit-tests/forloop.mk vendor/NetBSD/bmake/dist/unit-tests/forsubst.mk vendor/NetBSD/bmake/dist/unit-tests/include-sub.mk vendor/NetBSD/bmake/dist/unit-tests/moderrs.mk vendor/NetBSD/bmake/dist/unit-tests/modmisc.mk vendor/NetBSD/bmake/dist/unit-tests/modts.mk vendor/NetBSD/bmake/dist/unit-tests/modword.mk vendor/NetBSD/bmake/dist/unit-tests/opt-chdir.exp vendor/NetBSD/bmake/dist/unit-tests/opt-chdir.mk vendor/NetBSD/bmake/dist/unit-tests/opt-debug-jobs.exp vendor/NetBSD/bmake/dist/unit-tests/opt-debug-jobs.mk vendor/NetBSD/bmake/dist/unit-tests/opt-ignore.mk vendor/NetBSD/bmake/dist/unit-tests/opt-keep-going.mk vendor/NetBSD/bmake/dist/unit-tests/opt-no-action.mk vendor/NetBSD/bmake/dist/unit-tests/opt-query.mk vendor/NetBSD/bmake/dist/unit-tests/opt-touch.exp vendor/NetBSD/bmake/dist/unit-tests/opt-touch.mk vendor/NetBSD/bmake/dist/unit-tests/opt-var-expanded.mk vendor/NetBSD/bmake/dist/unit-tests/opt-var-literal.mk vendor/NetBSD/bmake/dist/unit-tests/opt-warnings-as-errors.exp vendor/NetBSD/bmake/dist/unit-tests/opt-warnings-as-errors.mk vendor/NetBSD/bmake/dist/unit-tests/opt.exp vendor/NetBSD/bmake/dist/unit-tests/opt.mk vendor/NetBSD/bmake/dist/unit-tests/order.mk vendor/NetBSD/bmake/dist/unit-tests/recursive.exp vendor/NetBSD/bmake/dist/unit-tests/recursive.mk vendor/NetBSD/bmake/dist/unit-tests/sh-leading-at.exp vendor/NetBSD/bmake/dist/unit-tests/sh-leading-at.mk vendor/NetBSD/bmake/dist/unit-tests/sh-leading-hyphen.mk vendor/NetBSD/bmake/dist/unit-tests/sh-leading-plus.mk vendor/NetBSD/bmake/dist/unit-tests/sh-meta-chars.mk vendor/NetBSD/bmake/dist/unit-tests/use-inference.mk vendor/NetBSD/bmake/dist/unit-tests/var-class-local.exp vendor/NetBSD/bmake/dist/unit-tests/var-class-local.mk vendor/NetBSD/bmake/dist/unit-tests/var-op-assign.exp vendor/NetBSD/bmake/dist/unit-tests/var-op-assign.mk vendor/NetBSD/bmake/dist/unit-tests/var-op-expand.exp vendor/NetBSD/bmake/dist/unit-tests/var-op-expand.mk vendor/NetBSD/bmake/dist/unit-tests/var-op-shell.exp vendor/NetBSD/bmake/dist/unit-tests/var-op-shell.mk vendor/NetBSD/bmake/dist/unit-tests/var-op-sunsh.mk vendor/NetBSD/bmake/dist/unit-tests/vardebug.exp vendor/NetBSD/bmake/dist/unit-tests/varmisc.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-defined.exp vendor/NetBSD/bmake/dist/unit-tests/varmod-defined.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-exclam-shell.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-ifelse.exp vendor/NetBSD/bmake/dist/unit-tests/varmod-ifelse.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-loop.exp vendor/NetBSD/bmake/dist/unit-tests/varmod-loop.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-match.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-order-shuffle.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-shell.exp vendor/NetBSD/bmake/dist/unit-tests/varmod-shell.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-subst.exp vendor/NetBSD/bmake/dist/unit-tests/varmod-subst.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-to-abs.exp vendor/NetBSD/bmake/dist/unit-tests/varmod-to-abs.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-to-lower.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-to-separator.mk vendor/NetBSD/bmake/dist/unit-tests/varmod-undefined.mk vendor/NetBSD/bmake/dist/unit-tests/varmod.exp vendor/NetBSD/bmake/dist/unit-tests/varmod.mk vendor/NetBSD/bmake/dist/unit-tests/varname-dot-shell.exp vendor/NetBSD/bmake/dist/unit-tests/varname-empty.exp vendor/NetBSD/bmake/dist/unit-tests/varname-makefile.exp vendor/NetBSD/bmake/dist/unit-tests/varname-makefile.mk vendor/NetBSD/bmake/dist/unit-tests/varname-vpath.exp vendor/NetBSD/bmake/dist/unit-tests/varname-vpath.mk vendor/NetBSD/bmake/dist/unit-tests/varname.exp vendor/NetBSD/bmake/dist/unit-tests/varname.mk vendor/NetBSD/bmake/dist/unit-tests/varparse-undef-partial.mk vendor/NetBSD/bmake/dist/util.c vendor/NetBSD/bmake/dist/var.c Modified: vendor/NetBSD/bmake/dist/ChangeLog ============================================================================== --- vendor/NetBSD/bmake/dist/ChangeLog Fri Nov 20 03:33:30 2020 (r367859) +++ vendor/NetBSD/bmake/dist/ChangeLog Fri Nov 20 03:54:37 2020 (r367860) @@ -1,3 +1,78 @@ +2020-11-17 Simon J Gerraty + + * VERSION (_MAKE_VERSION): 20201117 + Merge with NetBSD make, pick up + o fix some unit-tests when dash is .SHELL + o rename Targ_NewGN to GNode_New + o make some GNode functions const + o main.c: call Targ_Init before Var_Init + cleanup PrintOnError, getTmpdir and ParseBoolean + o var.c: fix error message of failed :!cmd! modifier + +2020-11-14 Simon J Gerraty + + * VERSION (_MAKE_VERSION): 20201114 + Merge with NetBSD make, pick up + o replace a few HashTable_CreateEntry with HashTable_Set + o clean up cached_stats + o rename DEFAULT to defaultNode + o remove redundant struct make_stat + o cond.c: in lint mode, check for ".else " + use bitset for IfState + replace large switch with if-else in Cond_EvalLine + o job.c: clean up JobExec, JobStart, JobDoOutput + use stderr for error message about failed touch + clean up Job_Touch + replace macro DBPRINTF with JobPrintln + rename JobState to JobStatus + main.c: switch cache for realpath from GNode to HashTable + clean up Fatal + clean up InitDefSysIncPath + use progname instead of hard-coded 'make' in warning + rename Main_SetVarObjdir to SetVarObjdir + make.1: document the -S option + make.c: fix debug output for GNode details + use symbolic names in debug output of GNodes + +2020-11-12 Simon J Gerraty + + * configure.in: fix --with-force-machine-arch + + * VERSION (_MAKE_VERSION): 20201112 + Merge with NetBSD make, pick up + o allow env var MAKE_OBJDIR_CHECK_WRITABLE=no to skip writable + checks in InitObjdir. Explicit .OBJDIR target always allows + read-only directory. + o cond.c: clean up Cond_EvalLine + +2020-11-11 Simon J Gerraty + + * VERSION (_MAKE_VERSION): 20201111 + Merge with NetBSD make, pick up + o more unit-tests + o style cleanup + remove redundant parentheses from sizeof operator + replace character literal 0 with '\0'. + replace pointer literal 0 with NULL. + remove redundant parentheses. + replace (expr & mask) == 0 with !(expr & mask). + use strict typing in conditions of the form !var + o rename Make_OODate to GNode_IsOODate + o rename Make_TimeStamp to GNode_UpdateYoungestChild + o rename Var_Set_with_flags to Var_SetWithFlags + o rename dieQuietly to shouldDieQuietly + o buf.c: make API of Buf_Init simpler + o compat.c: clean up Compat_Make, Compat_RunCommand, + CompatDeleteTarget and CompatInterrupt + o cond.c: in lint mode, only allow '&&' and '||', not '&' and '|' + clean up CondParser_Comparison + o main.c: rename getBoolean and s2Boolean + rename MAKEFILE_PREFERENCE for consistency + o parse.c: replace strstr in ParseMaybeSubMake with optimized code + o var.c: rename VARE_ASSIGN to VARE_KEEP_DOLLAR + replace emptyString with allocated empty string + error out on unclosed expressions after the colon + 2020-11-01 Simon J Gerraty * VERSION (_MAKE_VERSION): 20201101 Modified: vendor/NetBSD/bmake/dist/FILES ============================================================================== --- vendor/NetBSD/bmake/dist/FILES Fri Nov 20 03:33:30 2020 (r367859) +++ vendor/NetBSD/bmake/dist/FILES Fri Nov 20 03:54:37 2020 (r367860) @@ -75,8 +75,14 @@ unit-tests/archive-suffix.exp unit-tests/archive-suffix.mk unit-tests/archive.exp unit-tests/archive.mk +unit-tests/cmd-errors-lint.exp +unit-tests/cmd-errors-lint.mk +unit-tests/cmd-errors.exp +unit-tests/cmd-errors.mk unit-tests/cmd-interrupt.exp unit-tests/cmd-interrupt.mk +unit-tests/cmdline-undefined.exp +unit-tests/cmdline-undefined.mk unit-tests/cmdline.exp unit-tests/cmdline.mk unit-tests/comment.exp @@ -115,10 +121,14 @@ unit-tests/cond-func.exp unit-tests/cond-func.mk unit-tests/cond-late.exp unit-tests/cond-late.mk +unit-tests/cond-op-and-lint.exp +unit-tests/cond-op-and-lint.mk unit-tests/cond-op-and.exp unit-tests/cond-op-and.mk unit-tests/cond-op-not.exp unit-tests/cond-op-not.mk +unit-tests/cond-op-or-lint.exp +unit-tests/cond-op-or-lint.mk unit-tests/cond-op-or.exp unit-tests/cond-op-or.mk unit-tests/cond-op-parentheses.exp @@ -287,6 +297,8 @@ unit-tests/directive-for.exp unit-tests/directive-for.mk unit-tests/directive-hyphen-include.exp unit-tests/directive-hyphen-include.mk +unit-tests/directive-if-nested.exp +unit-tests/directive-if-nested.mk unit-tests/directive-if.exp unit-tests/directive-if.mk unit-tests/directive-ifdef.exp @@ -315,8 +327,6 @@ unit-tests/directive-warning.exp unit-tests/directive-warning.mk unit-tests/directive.exp unit-tests/directive.mk -unit-tests/directives.exp -unit-tests/directives.mk unit-tests/dollar.exp unit-tests/dollar.mk unit-tests/doterror.exp @@ -341,6 +351,8 @@ unit-tests/forloop.exp unit-tests/forloop.mk unit-tests/forsubst.exp unit-tests/forsubst.mk +unit-tests/gnode-submake.exp +unit-tests/gnode-submake.mk unit-tests/hanoi-include.exp unit-tests/hanoi-include.mk unit-tests/impsrc.exp @@ -349,6 +361,8 @@ unit-tests/include-main.exp unit-tests/include-main.mk unit-tests/include-sub.mk unit-tests/include-subsub.mk +unit-tests/job-flags.exp +unit-tests/job-flags.mk unit-tests/job-output-long-lines.exp unit-tests/job-output-long-lines.mk unit-tests/lint.exp @@ -365,6 +379,8 @@ unit-tests/modts.exp unit-tests/modts.mk unit-tests/modword.exp unit-tests/modword.mk +unit-tests/objdir-writable.exp +unit-tests/objdir-writable.mk unit-tests/opt-backwards.exp unit-tests/opt-backwards.mk unit-tests/opt-chdir.exp @@ -447,6 +463,8 @@ unit-tests/opt-raw.exp unit-tests/opt-raw.mk unit-tests/opt-silent.exp unit-tests/opt-silent.mk +unit-tests/opt-touch-jobs.exp +unit-tests/opt-touch-jobs.mk unit-tests/opt-touch.exp unit-tests/opt-touch.mk unit-tests/opt-tracefile.exp @@ -517,6 +535,8 @@ unit-tests/suff-main.exp unit-tests/suff-main.mk unit-tests/suff-rebuild.exp unit-tests/suff-rebuild.mk +unit-tests/suff-self.exp +unit-tests/suff-self.mk unit-tests/suff-transform-endless.exp unit-tests/suff-transform-endless.mk unit-tests/suff-transform-expand.exp @@ -737,14 +757,14 @@ unit-tests/varname.exp unit-tests/varname.mk unit-tests/varparse-dynamic.exp unit-tests/varparse-dynamic.mk +unit-tests/varparse-errors.exp +unit-tests/varparse-errors.mk unit-tests/varparse-mod.exp unit-tests/varparse-mod.mk unit-tests/varparse-undef-partial.exp unit-tests/varparse-undef-partial.mk unit-tests/varquote.exp unit-tests/varquote.mk -unit-tests/varshell.exp -unit-tests/varshell.mk util.c var.c wait.h Modified: vendor/NetBSD/bmake/dist/Makefile ============================================================================== --- vendor/NetBSD/bmake/dist/Makefile Fri Nov 20 03:33:30 2020 (r367859) +++ vendor/NetBSD/bmake/dist/Makefile Fri Nov 20 03:54:37 2020 (r367860) @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.113 2020/10/26 17:55:09 sjg Exp $ +# $Id: Makefile,v 1.114 2020/11/13 21:47:25 sjg Exp $ PROG= bmake @@ -48,6 +48,12 @@ CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\" CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}} COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" + +.for x in FORCE_MACHINE FORCE_MACHINE_ARCH +.ifdef $x +COPTS.main.c+= "-D$x=\"${$x}\"" +.endif +.endfor # meta mode can be useful even without filemon # should be set by now Modified: vendor/NetBSD/bmake/dist/Makefile.config.in ============================================================================== --- vendor/NetBSD/bmake/dist/Makefile.config.in Fri Nov 20 03:33:30 2020 (r367859) +++ vendor/NetBSD/bmake/dist/Makefile.config.in Fri Nov 20 03:54:37 2020 (r367860) @@ -5,8 +5,8 @@ _MAKE_VERSION?=@_MAKE_VERSION@ prefix?= @prefix@ srcdir= @srcdir@ CC?= @CC@ -MACHINE?= @machine@ -MACHINE_ARCH?= @machine_arch@ +@force_machine@MACHINE?= @machine@ +@force_machine_arch@MACHINE_ARCH?= @machine_arch@ DEFAULT_SYS_PATH?= @default_sys_path@ CPPFLAGS+= @CPPFLAGS@ Modified: vendor/NetBSD/bmake/dist/VERSION ============================================================================== --- vendor/NetBSD/bmake/dist/VERSION Fri Nov 20 03:33:30 2020 (r367859) +++ vendor/NetBSD/bmake/dist/VERSION Fri Nov 20 03:54:37 2020 (r367860) @@ -1,2 +1,2 @@ # keep this compatible with sh and make -_MAKE_VERSION=20201101 +_MAKE_VERSION=20201117 Modified: vendor/NetBSD/bmake/dist/arch.c ============================================================================== --- vendor/NetBSD/bmake/dist/arch.c Fri Nov 20 03:33:30 2020 (r367859) +++ vendor/NetBSD/bmake/dist/arch.c Fri Nov 20 03:54:37 2020 (r367860) @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.151 2020/10/31 18:41:07 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.177 2020/11/14 21:29:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -68,38 +68,38 @@ * SUCH DAMAGE. */ -/*- - * arch.c -- - * Functions to manipulate libraries, archives and their members. +/* Manipulate libraries, archives and their members. * - * Once again, cacheing/hashing comes into play in the manipulation - * of archives. The first time an archive is referenced, all of its members' - * headers are read and hashed and the archive closed again. All hashed - * archives are kept on a list which is searched each time an archive member - * is referenced. + * The first time an archive is referenced, all of its members' headers are + * read and cached and the archive closed again. All cached archives are kept + * on a list which is searched each time an archive member is referenced. * * The interface to this module is: + * + * Arch_Init Initialize this module. + * + * Arch_End Clean up this module. + * * Arch_ParseArchive - * Given an archive specification, return a list - * of GNode's, one for each member in the spec. - * FALSE is returned if the specification is - * invalid for some reason. + * Parse an archive specification such as + * "archive.a(member1 member2)". * * Arch_Touch Alter the modification time of the archive * member described by the given node to be - * the current time. + * the time when make was started. * * Arch_TouchLib Update the modification time of the library * described by the given node. This is special * because it also updates the modification time * of the library's table of contents. * - * Arch_MTime Find the modification time of a member of - * an archive *in the archive*. The time is also - * placed in the member's GNode. Returns the - * modification time. + * Arch_UpdateMTime + * Find the modification time of a member of + * an archive *in the archive* and place it in the + * member's GNode. * - * Arch_MemTime Find the modification time of a member of + * Arch_UpdateMemberMTime + * Find the modification time of a member of * an archive. Called when the member doesn't * already exist. Looks in the archive for the * modification time. Returns the modification @@ -109,12 +109,7 @@ * library name in the GNode should be in * -l format. * - * Arch_LibOODate Special function to decide if a library node - * is out-of-date. - * - * Arch_Init Initialize this module. - * - * Arch_End Clean up this module. + * Arch_LibOODate Decide if a library node is out-of-date. */ #ifdef HAVE_CONFIG_H @@ -151,17 +146,8 @@ struct ar_hdr { #include "dir.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.151 2020/10/31 18:41:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.177 2020/11/14 21:29:44 rillig Exp $"); -#ifdef TARGET_MACHINE -#undef MAKE_MACHINE -#define MAKE_MACHINE TARGET_MACHINE -#endif -#ifdef TARGET_MACHINE_ARCH -#undef MAKE_MACHINE_ARCH -#define MAKE_MACHINE_ARCH TARGET_MACHINE_ARCH -#endif - typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -230,39 +216,37 @@ ArchFree(void *ap) #endif -/*- - *----------------------------------------------------------------------- - * Arch_ParseArchive -- - * Parse the archive specification in the given line and find/create - * the nodes for the specified archive members, placing their nodes - * on the given list. +/* + * Parse an archive specification such as "archive.a(member1 member2.${EXT})", + * adding nodes for the expanded members to nodeLst. Nodes are created as + * necessary. * * Input: - * linePtr Pointer to start of specification - * nodeLst Lst on which to place the nodes - * ctxt Context in which to expand variables + * pp The start of the specification. + * nodeLst The list on which to place the nodes. + * ctxt The context in which to expand variables. * - * Results: - * TRUE if it was a valid specification. The linePtr is updated - * to point to the first non-space after the archive spec. The - * nodes for the members are placed on the given list. - *----------------------------------------------------------------------- + * Output: + * return TRUE if it was a valid specification. + * *pp Points to the first non-space after the archive spec. + * *nodeLst Nodes for the members have been added. */ Boolean -Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, GNode *ctxt) +Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt) { char *cp; /* Pointer into line */ GNode *gn; /* New node */ char *libName; /* Library-part of specification */ + char *libName_freeIt = NULL; char *memName; /* Member-part of specification */ char saveChar; /* Ending delimiter of member-name */ - Boolean subLibName; /* TRUE if libName should have/had - * variable substitution performed on it */ + Boolean expandLibName; /* Whether the parsed libName contains + * variable expressions that need to be + * expanded */ - libName = *linePtr; + libName = *pp; + expandLibName = FALSE; - subLibName = FALSE; - for (cp = libName; *cp != '(' && *cp != '\0';) { if (*cp == '$') { /* @@ -274,7 +258,8 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, const char *result; Boolean isError; - (void)Var_Parse(&nested_p, ctxt, VARE_UNDEFERR|VARE_WANTRES, + /* XXX: is expanded twice: once here and once below */ + (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR, &result, &result_freeIt); /* TODO: handle errors */ isError = result == var_Error; @@ -282,16 +267,17 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, if (isError) return FALSE; - subLibName = TRUE; + expandLibName = TRUE; cp += nested_p - cp; } else cp++; } *cp++ = '\0'; - if (subLibName) { - (void)Var_Subst(libName, ctxt, VARE_UNDEFERR|VARE_WANTRES, &libName); + if (expandLibName) { + (void)Var_Subst(libName, ctxt, VARE_WANTRES | VARE_UNDEFERR, &libName); /* TODO: handle errors */ + libName_freeIt = libName; } @@ -317,7 +303,7 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, Boolean isError; const char *nested_p = cp; - (void)Var_Parse(&nested_p, ctxt, VARE_UNDEFERR|VARE_WANTRES, + (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR, &result, &freeIt); /* TODO: handle errors */ isError = result == var_Error; @@ -339,7 +325,7 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, * so it's better to return failure than allow such things to happen */ if (*cp == '\0') { - printf("No closing parenthesis in archive specification\n"); + Parse_Error(PARSE_FATAL, "No closing parenthesis in archive specification"); return FALSE; } @@ -370,7 +356,7 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, char *sacrifice; char *oldMemName = memName; - (void)Var_Subst(memName, ctxt, VARE_UNDEFERR|VARE_WANTRES, + (void)Var_Subst(memName, ctxt, VARE_WANTRES | VARE_UNDEFERR, &memName); /* TODO: handle errors */ @@ -381,7 +367,8 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, */ buf = sacrifice = str_concat4(libName, "(", memName, ")"); - if (strchr(memName, '$') && strcmp(memName, oldMemName) == 0) { + if (strchr(memName, '$') != NULL && + strcmp(memName, oldMemName) == 0) { /* * Must contain dynamic sources, so we can't deal with it now. * Just create an ARCHV node for the thing and let @@ -437,17 +424,12 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, *cp = saveChar; } - /* - * If substituted libName, free it now, since we need it no longer. - */ - if (subLibName) { - free(libName); - } + free(libName_freeIt); cp++; /* skip the ')' */ - /* We promised that linePtr would be set up at the next non-space. */ + /* We promised that pp would be set up at the next non-space. */ pp_skip_whitespace(&cp); - *linePtr = cp; + *pp = cp; return TRUE; } @@ -457,15 +439,17 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, * Input: * archive Path to the archive * member Name of member; only its basename is used. - * hash TRUE if archive should be hashed if not already so. + * addToCache TRUE if archive should be cached if not already so. * * Results: - * The ar_hdr for the member. + * The ar_hdr for the member, or NULL. + * + * See ArchFindMember for an almost identical copy of this code. */ static struct ar_hdr * -ArchStatMember(const char *archive, const char *member, Boolean hash) +ArchStatMember(const char *archive, const char *member, Boolean addToCache) { -#define AR_MAX_NAME_LEN (sizeof(arh.AR_NAME) - 1) +#define AR_MAX_NAME_LEN (sizeof arh.AR_NAME - 1) FILE *arch; /* Stream to archive */ size_t size; /* Size of archive member */ char magic[SARMAG]; @@ -484,8 +468,8 @@ ArchStatMember(const char *archive, const char *member member = lastSlash + 1; for (ln = archives->first; ln != NULL; ln = ln->next) { - const Arch *archPtr = ln->datum; - if (strcmp(archPtr->name, archive) == 0) + const Arch *a = ln->datum; + if (strcmp(a->name, archive) == 0) break; } @@ -505,17 +489,17 @@ ArchStatMember(const char *archive, const char *member if (len > AR_MAX_NAME_LEN) { len = AR_MAX_NAME_LEN; snprintf(copy, sizeof copy, "%s", member); + hdr = HashTable_FindValue(&ar->members, copy); } - hdr = HashTable_FindValue(&ar->members, copy); return hdr; } } - if (!hash) { + if (!addToCache) { /* - * Caller doesn't want the thing hashed, just use ArchFindMember + * Caller doesn't want the thing cached, just use ArchFindMember * to read the header for the member out and close down the stream - * again. Since the archive is not to be hashed, we assume there's + * again. Since the archive is not to be cached, we assume there's * no need to allocate extra room for the header we're returning, * so just declare it static. */ @@ -541,98 +525,92 @@ ArchStatMember(const char *archive, const char *member * We use the ARMAG string to make sure this is an archive we * can handle... */ - if ((fread(magic, SARMAG, 1, arch) != 1) || - (strncmp(magic, ARMAG, SARMAG) != 0)) { - fclose(arch); + if (fread(magic, SARMAG, 1, arch) != 1 || + strncmp(magic, ARMAG, SARMAG) != 0) { + (void)fclose(arch); return NULL; } - ar = bmake_malloc(sizeof(Arch)); + ar = bmake_malloc(sizeof *ar); ar->name = bmake_strdup(archive); ar->fnametab = NULL; ar->fnamesize = 0; HashTable_Init(&ar->members); memName[AR_MAX_NAME_LEN] = '\0'; - while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) { - if (strncmp(arh.AR_FMAG, ARFMAG, sizeof(arh.AR_FMAG)) != 0) { - /* - * The header is bogus, so the archive is bad - * and there's no way we can recover... - */ + while (fread(&arh, sizeof arh, 1, arch) == 1) { + char *nameend; + + /* If the header is bogus, there's no way we can recover. */ + if (strncmp(arh.AR_FMAG, ARFMAG, sizeof arh.AR_FMAG) != 0) goto badarch; - } else { - char *nameend; - /* - * We need to advance the stream's pointer to the start of the - * next header. Files are padded with newlines to an even-byte - * boundary, so we need to extract the size of the file from the - * 'size' field of the header and round it up during the seek. - */ - arh.AR_SIZE[sizeof(arh.AR_SIZE) - 1] = '\0'; - size = (size_t)strtol(arh.ar_size, NULL, 10); + /* + * We need to advance the stream's pointer to the start of the + * next header. Files are padded with newlines to an even-byte + * boundary, so we need to extract the size of the file from the + * 'size' field of the header and round it up during the seek. + */ + arh.AR_SIZE[sizeof arh.AR_SIZE - 1] = '\0'; + size = (size_t)strtol(arh.AR_SIZE, NULL, 10); - memcpy(memName, arh.AR_NAME, sizeof(arh.AR_NAME)); - nameend = memName + AR_MAX_NAME_LEN; - while (*nameend == ' ') { - nameend--; - } - nameend[1] = '\0'; + memcpy(memName, arh.AR_NAME, sizeof arh.AR_NAME); + nameend = memName + AR_MAX_NAME_LEN; + while (nameend > memName && *nameend == ' ') + nameend--; + nameend[1] = '\0'; #ifdef SVR4ARCHIVES + /* + * svr4 names are slash terminated. Also svr4 extended AR format. + */ + if (memName[0] == '/') { /* - * svr4 names are slash terminated. Also svr4 extended AR format. + * svr4 magic mode; handle it */ - if (memName[0] == '/') { - /* - * svr4 magic mode; handle it - */ - switch (ArchSVR4Entry(ar, memName, size, arch)) { - case -1: /* Invalid data */ - goto badarch; - case 0: /* List of files entry */ - continue; - default: /* Got the entry */ - break; - } - } else { - if (nameend[0] == '/') - nameend[0] = '\0'; + switch (ArchSVR4Entry(ar, memName, size, arch)) { + case -1: /* Invalid data */ + goto badarch; + case 0: /* List of files entry */ + continue; + default: /* Got the entry */ + break; } + } else { + if (nameend[0] == '/') + nameend[0] = '\0'; + } #endif #ifdef AR_EFMT1 - /* - * BSD 4.4 extended AR format: #1/, with name as the - * first bytes of the file - */ - if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 && - ch_isdigit(memName[sizeof(AR_EFMT1) - 1])) { + /* + * BSD 4.4 extended AR format: #1/, with name as the + * first bytes of the file + */ + if (strncmp(memName, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 && + ch_isdigit(memName[sizeof AR_EFMT1 - 1])) { - int elen = atoi(&memName[sizeof(AR_EFMT1) - 1]); + int elen = atoi(memName + sizeof AR_EFMT1 - 1); - if ((unsigned int)elen > MAXPATHLEN) - goto badarch; - if (fread(memName, (size_t)elen, 1, arch) != 1) - goto badarch; - memName[elen] = '\0'; - if (fseek(arch, -elen, SEEK_CUR) != 0) - goto badarch; - if (DEBUG(ARCH) || DEBUG(MAKE)) { - debug_printf("ArchStat: Extended format entry for %s\n", - memName); - } - } + if ((unsigned int)elen > MAXPATHLEN) + goto badarch; + if (fread(memName, (size_t)elen, 1, arch) != 1) + goto badarch; + memName[elen] = '\0'; + if (fseek(arch, -elen, SEEK_CUR) != 0) + goto badarch; + if (DEBUG(ARCH) || DEBUG(MAKE)) + debug_printf("ArchStatMember: Extended format entry for %s\n", + memName); + } #endif - { - HashEntry *he; - he = HashTable_CreateEntry(&ar->members, memName, NULL); - HashEntry_Set(he, bmake_malloc(sizeof(struct ar_hdr))); - memcpy(HashEntry_Get(he), &arh, sizeof(struct ar_hdr)); - } + { + struct ar_hdr *cached_hdr = bmake_malloc(sizeof *cached_hdr); + memcpy(cached_hdr, &arh, sizeof arh); + HashTable_Set(&ar->members, memName, cached_hdr); } + if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0) goto badarch; } @@ -643,7 +621,7 @@ ArchStatMember(const char *archive, const char *member /* * Now that the archive has been read and cached, we can look into - * the hash table to find the desired member's header. + * the addToCache table to find the desired member's header. */ return HashTable_FindValue(&ar->members, member); @@ -674,15 +652,15 @@ badarch: *----------------------------------------------------------------------- */ static int -ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch) +ArchSVR4Entry(Arch *ar, char *inout_name, size_t size, FILE *arch) { #define ARLONGNAMES1 "//" #define ARLONGNAMES2 "/ARFILENAMES" size_t entry; char *ptr, *eptr; - if (strncmp(name, ARLONGNAMES1, sizeof(ARLONGNAMES1) - 1) == 0 || - strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) { + if (strncmp(inout_name, ARLONGNAMES1, sizeof ARLONGNAMES1 - 1) == 0 || + strncmp(inout_name, ARLONGNAMES2, sizeof ARLONGNAMES2 - 1) == 0) { if (ar->fnametab != NULL) { DEBUG0(ARCH, "Attempted to redefine an SVR4 name table\n"); @@ -711,51 +689,74 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE return 0; } - if (name[1] == ' ' || name[1] == '\0') + if (inout_name[1] == ' ' || inout_name[1] == '\0') return 2; - entry = (size_t)strtol(&name[1], &eptr, 0); - if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) { - DEBUG1(ARCH, "Could not parse SVR4 name %s\n", name); + entry = (size_t)strtol(&inout_name[1], &eptr, 0); + if ((*eptr != ' ' && *eptr != '\0') || eptr == &inout_name[1]) { + DEBUG1(ARCH, "Could not parse SVR4 name %s\n", inout_name); return 2; } if (entry >= ar->fnamesize) { DEBUG2(ARCH, "SVR4 entry offset %s is greater than %lu\n", - name, (unsigned long)ar->fnamesize); + inout_name, (unsigned long)ar->fnamesize); return 2; } - DEBUG2(ARCH, "Replaced %s with %s\n", name, &ar->fnametab[entry]); + DEBUG2(ARCH, "Replaced %s with %s\n", inout_name, &ar->fnametab[entry]); - snprintf(name, MAXPATHLEN + 1, "%s", &ar->fnametab[entry]); + snprintf(inout_name, MAXPATHLEN + 1, "%s", &ar->fnametab[entry]); return 1; } #endif -/*- - *----------------------------------------------------------------------- - * ArchFindMember -- - * Locate a member of an archive, given the path of the archive and - * the path of the desired member. If the archive is to be modified, - * the mode should be "r+", if not, it should be "r". - * The passed struct ar_hdr structure is filled in. +static Boolean +ArchiveMember_HasName(const struct ar_hdr *hdr, + const char *name, size_t namelen) +{ + const size_t ar_name_len = sizeof hdr->AR_NAME; + const char *ar_name = hdr->AR_NAME; + + if (strncmp(ar_name, name, namelen) != 0) + return FALSE; + + if (namelen >= ar_name_len) + return namelen == ar_name_len; + + /* hdr->AR_NAME is space-padded to the right. */ + if (ar_name[namelen] == ' ') + return TRUE; + + /* In archives created by GNU binutils 2.27, the member names end with + * a slash. */ + if (ar_name[namelen] == '/' && + (namelen == ar_name_len || ar_name[namelen + 1] == ' ')) + return TRUE; + + return FALSE; +} + +/* Locate a member of an archive, given the path of the archive and the path + * of the desired member. * * Input: * archive Path to the archive * member Name of member. If it is a path, only the last * component is used. - * arhPtr Pointer to header structure to be filled in - * mode The mode for opening the stream + * out_arh Archive header to be filled in + * mode "r" for read-only access, "r+" for read-write access * - * Results: - * An FILE *, opened for reading and writing, positioned at the - * start of the member's struct ar_hdr, or NULL if the member was - * nonexistent. The current struct ar_hdr for member. - *----------------------------------------------------------------------- + * Output: + * return The archive file, positioned at the start of the + * member's struct ar_hdr, or NULL if the member doesn't + * exist. + * *out_arh The current struct ar_hdr for member. + * + * See ArchStatMember for an almost identical copy of this code. */ static FILE * -ArchFindMember(const char *archive, const char *member, struct ar_hdr *arhPtr, +ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh, const char *mode) { FILE *arch; /* Stream to archive */ @@ -772,8 +773,8 @@ ArchFindMember(const char *archive, const char *member * We use the ARMAG string to make sure this is an archive we * can handle... */ - if ((fread(magic, SARMAG, 1, arch) != 1) || - (strncmp(magic, ARMAG, SARMAG) != 0)) { + if (fread(magic, SARMAG, 1, arch) != 1 || + strncmp(magic, ARMAG, SARMAG) != 0) { fclose(arch); return NULL; } @@ -787,13 +788,13 @@ ArchFindMember(const char *archive, const char *member member = lastSlash + 1; len = tlen = strlen(member); - if (len > sizeof(arhPtr->AR_NAME)) { - tlen = sizeof(arhPtr->AR_NAME); + if (len > sizeof out_arh->AR_NAME) { + tlen = sizeof out_arh->AR_NAME; } - while (fread((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) { + while (fread(out_arh, sizeof *out_arh, 1, arch) == 1) { - if (strncmp(arhPtr->AR_FMAG, ARFMAG, sizeof(arhPtr->AR_FMAG)) != 0) { + if (strncmp(out_arh->AR_FMAG, ARFMAG, sizeof out_arh->AR_FMAG) != 0) { /* * The header is bogus, so the archive is bad * and there's no way we can recover... @@ -802,25 +803,21 @@ ArchFindMember(const char *archive, const char *member return NULL; } - if (strncmp(member, arhPtr->AR_NAME, tlen) == 0) { - /* - * If the member's name doesn't take up the entire 'name' field, - * we have to be careful of matching prefixes. Names are space- - * padded to the right, so if the character in 'name' at the end - * of the matched string is anything but a space, this isn't the - * member we sought. - */ - if (tlen != sizeof arhPtr->AR_NAME && arhPtr->AR_NAME[tlen] != ' ') - goto skip; + DEBUG5(ARCH, "Reading archive %s member %.*s mtime %.*s\n", + archive, + (int)sizeof out_arh->AR_NAME, out_arh->AR_NAME, + (int)sizeof out_arh->ar_date, out_arh->ar_date); + if (ArchiveMember_HasName(out_arh, member, len)) { /* - * To make life easier, we reposition the file at the start + * To make life easier for callers that want to update the + * archive, we reposition the file at the start * of the header we just read before we return the stream. * In a more general situation, it might be better to leave * the file at the actual member, rather than its header, but - * not here... + * not here. */ - if (fseek(arch, -(long)sizeof(struct ar_hdr), SEEK_CUR) != 0) { + if (fseek(arch, -(long)sizeof *out_arh, SEEK_CUR) != 0) { fclose(arch); return NULL; } @@ -832,10 +829,10 @@ ArchFindMember(const char *archive, const char *member * BSD 4.4 extended AR format: #1/, with name as the * first bytes of the file */ - if (strncmp(arhPtr->AR_NAME, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 && - ch_isdigit(arhPtr->AR_NAME[sizeof(AR_EFMT1) - 1])) + if (strncmp(out_arh->AR_NAME, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 && + ch_isdigit(out_arh->AR_NAME[sizeof AR_EFMT1 - 1])) { - int elen = atoi(&arhPtr->AR_NAME[sizeof(AR_EFMT1) - 1]); + int elen = atoi(&out_arh->AR_NAME[sizeof AR_EFMT1 - 1]); char ename[MAXPATHLEN + 1]; if ((unsigned int)elen > MAXPATHLEN) { @@ -847,9 +844,9 @@ ArchFindMember(const char *archive, const char *member return NULL; } ename[elen] = '\0'; - if (DEBUG(ARCH) || DEBUG(MAKE)) { - debug_printf("ArchFind: Extended format entry for %s\n", ename); - } + if (DEBUG(ARCH) || DEBUG(MAKE)) + debug_printf("ArchFindMember: Extended format entry for %s\n", + ename); if (strncmp(ename, member, len) == 0) { /* Found as extended name */ if (fseek(arch, -(long)sizeof(struct ar_hdr) - elen, @@ -866,7 +863,6 @@ ArchFindMember(const char *archive, const char *member } #endif -skip: /* * This isn't the member we're after, so we need to advance the * stream's pointer to the start of the next header. Files are @@ -874,113 +870,89 @@ skip: * extract the size of the file from the 'size' field of the * header and round it up during the seek. */ - arhPtr->ar_size[sizeof(arhPtr->ar_size) - 1] = '\0'; - size = (int)strtol(arhPtr->ar_size, NULL, 10); + out_arh->AR_SIZE[sizeof out_arh->AR_SIZE - 1] = '\0'; + size = (int)strtol(out_arh->AR_SIZE, NULL, 10); if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) { fclose(arch); return NULL; } } - /* - * We've looked everywhere, but the member is not to be found. Close the - * archive and return NULL -- an error. - */ fclose(arch); return NULL; } -/*- - *----------------------------------------------------------------------- - * Arch_Touch -- - * Touch a member of an archive. - * The modification time of the entire archive is also changed. - * For a library, this could necessitate the re-ranlib'ing of the - * whole thing. +/* Touch a member of an archive, on disk. + * The GNode's modification time is left as-is. * + * The st_mtime of the entire archive is also changed. + * For a library, it may be required to run ranlib after this. + * * Input: * gn Node of member to touch * * Results: * The 'time' field of the member's header is updated. - *----------------------------------------------------------------------- */ void Arch_Touch(GNode *gn) { - FILE *arch; /* Stream open to archive, positioned properly */ - struct ar_hdr arh; /* Current header describing member */ + FILE *f; + struct ar_hdr arh; - arch = ArchFindMember(GNode_VarArchive(gn), GNode_VarMember(gn), - &arh, "r+"); + f = ArchFindMember(GNode_VarArchive(gn), GNode_VarMember(gn), &arh, "r+"); + if (f == NULL) + return; - snprintf(arh.AR_DATE, sizeof(arh.AR_DATE), "%-12ld", (long)now); - - if (arch != NULL) { - (void)fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch); - fclose(arch); - } + snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now); + (void)fwrite(&arh, sizeof arh, 1, f); + fclose(f); /* TODO: handle errors */ } /* Given a node which represents a library, touch the thing, making sure that - * the table of contents also is touched. + * the table of contents is also touched. * * Both the modification time of the library and of the RANLIBMAG member are - * set to 'now'. - * - * Input: - * gn The node of the library to touch - */ + * set to 'now'. */ void -Arch_TouchLib(GNode *gn) +Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED) { #ifdef RANLIBMAG *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Nov 20 03:54:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7E9B547C942; Fri, 20 Nov 2020 03:54:50 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcjNn1phZz4X4L; Fri, 20 Nov 2020 03:54:48 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F193D7CA2; Fri, 20 Nov 2020 03:54:46 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK3skFh008271; Fri, 20 Nov 2020 03:54:46 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK3skGX008270; Fri, 20 Nov 2020 03:54:46 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <202011200354.0AK3skGX008270@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Fri, 20 Nov 2020 03:54:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r367861 - vendor/NetBSD/bmake/20201117 X-SVN-Group: vendor X-SVN-Commit-Author: sjg X-SVN-Commit-Paths: vendor/NetBSD/bmake/20201117 X-SVN-Commit-Revision: 367861 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 03:54:50 -0000 Author: sjg Date: Fri Nov 20 03:54:46 2020 New Revision: 367861 URL: https://svnweb.freebsd.org/changeset/base/367861 Log: tag bmake-20201117 Added: vendor/NetBSD/bmake/20201117/ - copied from r367860, vendor/NetBSD/bmake/dist/ From owner-svn-src-all@freebsd.org Fri Nov 20 05:46:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E7FA747E0A7; Fri, 20 Nov 2020 05:46:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cclsb62XWz4bVT; Fri, 20 Nov 2020 05:46:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BD21010FE2; Fri, 20 Nov 2020 05:46:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK5kRQT076077; Fri, 20 Nov 2020 05:46:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK5kRu0076076; Fri, 20 Nov 2020 05:46:27 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011200546.0AK5kRu0076076@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Nov 2020 05:46:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367862 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 367862 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 05:46:28 -0000 Author: mav Date: Fri Nov 20 05:46:27 2020 New Revision: 367862 URL: https://svnweb.freebsd.org/changeset/base/367862 Log: Microoptimize cam_num_doneqs math in xpt_done(). MFC after: 1 week Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Fri Nov 20 03:54:46 2020 (r367861) +++ head/sys/cam/cam_xpt.c Fri Nov 20 05:46:27 2020 (r367862) @@ -178,7 +178,7 @@ struct cam_doneq { }; static struct cam_doneq cam_doneqs[MAXCPU]; -static int cam_num_doneqs; +static u_int __read_mostly cam_num_doneqs; static struct proc *cam_proc; SYSCTL_INT(_kern_cam, OID_AUTO, num_doneqs, CTLFLAG_RDTUN, @@ -4620,7 +4620,7 @@ xpt_done(union ccb *done_ccb) /* Store the time the ccb was in the sim */ done_ccb->ccb_h.qos.periph_data = cam_iosched_delta_t(done_ccb->ccb_h.qos.periph_data); - hash = (done_ccb->ccb_h.path_id + done_ccb->ccb_h.target_id + + hash = (u_int)(done_ccb->ccb_h.path_id + done_ccb->ccb_h.target_id + done_ccb->ccb_h.target_lun) % cam_num_doneqs; queue = &cam_doneqs[hash]; mtx_lock(&queue->cam_doneq_mtx); From owner-svn-src-all@freebsd.org Fri Nov 20 06:02:33 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 571C047E4D6; Fri, 20 Nov 2020 06:02:33 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcmD91ps6z4cHZ; Fri, 20 Nov 2020 06:02:33 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 30D21116A6; Fri, 20 Nov 2020 06:02:33 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK62XWa088136; Fri, 20 Nov 2020 06:02:33 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK62Wx2088129; Fri, 20 Nov 2020 06:02:32 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <202011200602.0AK62Wx2088129@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Fri, 20 Nov 2020 06:02:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367863 - in head: contrib/bmake contrib/bmake/filemon contrib/bmake/missing contrib/bmake/mk contrib/bmake/unit-tests usr.bin/bmake usr.bin/bmake/unit-tests X-SVN-Group: head X-SVN-Commit-Author: sjg X-SVN-Commit-Paths: in head: contrib/bmake contrib/bmake/filemon contrib/bmake/missing contrib/bmake/mk contrib/bmake/unit-tests usr.bin/bmake usr.bin/bmake/unit-tests X-SVN-Commit-Revision: 367863 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 06:02:33 -0000 Author: sjg Date: Fri Nov 20 06:02:31 2020 New Revision: 367863 URL: https://svnweb.freebsd.org/changeset/base/367863 Log: Merge bmake-20201117 o allow env var MAKE_OBJDIR_CHECK_WRITABLE=no to skip writable checks in InitObjdir. Explicit .OBJDIR target always allows read-only directory. o More code cleanup and refactoring. o More unit tests MFC after: 1 week Added: head/contrib/bmake/missing/ - copied from r367861, vendor/NetBSD/bmake/dist/missing/ head/contrib/bmake/unit-tests/cmd-errors-lint.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cmd-errors-lint.exp head/contrib/bmake/unit-tests/cmd-errors-lint.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cmd-errors-lint.mk head/contrib/bmake/unit-tests/cmd-errors.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cmd-errors.exp head/contrib/bmake/unit-tests/cmd-errors.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cmd-errors.mk head/contrib/bmake/unit-tests/cmdline-undefined.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cmdline-undefined.exp head/contrib/bmake/unit-tests/cmdline-undefined.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cmdline-undefined.mk head/contrib/bmake/unit-tests/cond-op-and-lint.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cond-op-and-lint.exp head/contrib/bmake/unit-tests/cond-op-and-lint.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cond-op-and-lint.mk head/contrib/bmake/unit-tests/cond-op-or-lint.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cond-op-or-lint.exp head/contrib/bmake/unit-tests/cond-op-or-lint.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/cond-op-or-lint.mk head/contrib/bmake/unit-tests/directive-if-nested.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/directive-if-nested.exp head/contrib/bmake/unit-tests/directive-if-nested.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/directive-if-nested.mk head/contrib/bmake/unit-tests/gnode-submake.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/gnode-submake.exp head/contrib/bmake/unit-tests/gnode-submake.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/gnode-submake.mk head/contrib/bmake/unit-tests/job-flags.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/job-flags.exp head/contrib/bmake/unit-tests/job-flags.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/job-flags.mk head/contrib/bmake/unit-tests/objdir-writable.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/objdir-writable.exp head/contrib/bmake/unit-tests/objdir-writable.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/objdir-writable.mk head/contrib/bmake/unit-tests/opt-touch-jobs.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/opt-touch-jobs.exp head/contrib/bmake/unit-tests/opt-touch-jobs.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/opt-touch-jobs.mk head/contrib/bmake/unit-tests/suff-self.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/suff-self.exp head/contrib/bmake/unit-tests/suff-self.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/suff-self.mk head/contrib/bmake/unit-tests/varparse-errors.exp - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/varparse-errors.exp head/contrib/bmake/unit-tests/varparse-errors.mk - copied unchanged from r367861, vendor/NetBSD/bmake/dist/unit-tests/varparse-errors.mk Deleted: head/contrib/bmake/unit-tests/directives.exp head/contrib/bmake/unit-tests/directives.mk head/contrib/bmake/unit-tests/varshell.exp head/contrib/bmake/unit-tests/varshell.mk Modified: head/contrib/bmake/ChangeLog head/contrib/bmake/FILES head/contrib/bmake/Makefile head/contrib/bmake/Makefile.config.in head/contrib/bmake/VERSION head/contrib/bmake/arch.c head/contrib/bmake/bmake.1 head/contrib/bmake/bmake.cat1 head/contrib/bmake/boot-strap head/contrib/bmake/buf.c head/contrib/bmake/buf.h head/contrib/bmake/compat.c head/contrib/bmake/cond.c head/contrib/bmake/configure head/contrib/bmake/configure.in head/contrib/bmake/dir.c head/contrib/bmake/dir.h head/contrib/bmake/filemon/filemon_dev.c head/contrib/bmake/filemon/filemon_ktrace.c head/contrib/bmake/for.c head/contrib/bmake/hash.c head/contrib/bmake/hash.h head/contrib/bmake/job.c head/contrib/bmake/job.h head/contrib/bmake/lst.c head/contrib/bmake/lst.h head/contrib/bmake/main.c head/contrib/bmake/make-bootstrap.sh.in head/contrib/bmake/make.1 head/contrib/bmake/make.c head/contrib/bmake/make.h head/contrib/bmake/make_malloc.h head/contrib/bmake/meta.c head/contrib/bmake/metachar.h head/contrib/bmake/mk/ChangeLog head/contrib/bmake/mk/install-mk head/contrib/bmake/mk/meta.autodep.mk head/contrib/bmake/mk/meta2deps.sh head/contrib/bmake/nonints.h head/contrib/bmake/parse.c head/contrib/bmake/str.c head/contrib/bmake/suff.c head/contrib/bmake/targ.c head/contrib/bmake/unit-tests/Makefile head/contrib/bmake/unit-tests/archive-suffix.mk head/contrib/bmake/unit-tests/archive.mk head/contrib/bmake/unit-tests/cmd-interrupt.mk head/contrib/bmake/unit-tests/cmdline.mk head/contrib/bmake/unit-tests/comment.mk head/contrib/bmake/unit-tests/cond-cmp-numeric-eq.exp head/contrib/bmake/unit-tests/cond-cmp-numeric-eq.mk head/contrib/bmake/unit-tests/cond-cmp-numeric.exp head/contrib/bmake/unit-tests/cond-cmp-numeric.mk head/contrib/bmake/unit-tests/cond-cmp-string.exp head/contrib/bmake/unit-tests/cond-cmp-string.mk head/contrib/bmake/unit-tests/cond-cmp-unary.exp head/contrib/bmake/unit-tests/cond-cmp-unary.mk head/contrib/bmake/unit-tests/cond-func-commands.mk head/contrib/bmake/unit-tests/cond-func-defined.exp head/contrib/bmake/unit-tests/cond-func-defined.mk head/contrib/bmake/unit-tests/cond-func-empty.exp head/contrib/bmake/unit-tests/cond-func-empty.mk head/contrib/bmake/unit-tests/cond-func.exp head/contrib/bmake/unit-tests/cond-func.mk head/contrib/bmake/unit-tests/cond-late.mk head/contrib/bmake/unit-tests/cond-op-not.exp head/contrib/bmake/unit-tests/cond-op-not.mk head/contrib/bmake/unit-tests/cond-op-parentheses.exp head/contrib/bmake/unit-tests/cond-op-parentheses.mk head/contrib/bmake/unit-tests/cond-op.exp head/contrib/bmake/unit-tests/cond-op.mk head/contrib/bmake/unit-tests/cond-short.mk head/contrib/bmake/unit-tests/cond-token-number.exp head/contrib/bmake/unit-tests/cond-token-number.mk head/contrib/bmake/unit-tests/cond-token-plain.mk head/contrib/bmake/unit-tests/cond-token-string.exp head/contrib/bmake/unit-tests/cond-token-string.mk head/contrib/bmake/unit-tests/cond-token-var.exp head/contrib/bmake/unit-tests/cond-token-var.mk head/contrib/bmake/unit-tests/cond-undef-lint.exp head/contrib/bmake/unit-tests/cond-undef-lint.mk head/contrib/bmake/unit-tests/cond1.exp head/contrib/bmake/unit-tests/cond1.mk head/contrib/bmake/unit-tests/dep-double-colon.mk head/contrib/bmake/unit-tests/dep-exclam.mk head/contrib/bmake/unit-tests/depsrc-ignore.mk head/contrib/bmake/unit-tests/depsrc-make.mk head/contrib/bmake/unit-tests/depsrc-optional.exp head/contrib/bmake/unit-tests/depsrc-optional.mk head/contrib/bmake/unit-tests/depsrc-precious.mk head/contrib/bmake/unit-tests/depsrc-usebefore.mk head/contrib/bmake/unit-tests/depsrc.mk head/contrib/bmake/unit-tests/deptgt-begin.exp head/contrib/bmake/unit-tests/deptgt-begin.mk head/contrib/bmake/unit-tests/deptgt-error.mk head/contrib/bmake/unit-tests/deptgt-ignore.mk head/contrib/bmake/unit-tests/deptgt-interrupt.mk head/contrib/bmake/unit-tests/deptgt-main.mk head/contrib/bmake/unit-tests/deptgt-makeflags.exp head/contrib/bmake/unit-tests/deptgt-makeflags.mk head/contrib/bmake/unit-tests/deptgt-silent.exp head/contrib/bmake/unit-tests/deptgt-silent.mk head/contrib/bmake/unit-tests/deptgt.exp head/contrib/bmake/unit-tests/deptgt.mk head/contrib/bmake/unit-tests/dir.mk head/contrib/bmake/unit-tests/directive-elif.exp head/contrib/bmake/unit-tests/directive-elif.mk head/contrib/bmake/unit-tests/directive-else.exp head/contrib/bmake/unit-tests/directive-else.mk head/contrib/bmake/unit-tests/directive-endif.mk head/contrib/bmake/unit-tests/directive-export-env.mk head/contrib/bmake/unit-tests/directive-export-gmake.mk head/contrib/bmake/unit-tests/directive-export-literal.mk head/contrib/bmake/unit-tests/directive-export.exp head/contrib/bmake/unit-tests/directive-export.mk head/contrib/bmake/unit-tests/directive-for.exp head/contrib/bmake/unit-tests/directive-for.mk head/contrib/bmake/unit-tests/directive-if.exp head/contrib/bmake/unit-tests/directive-if.mk head/contrib/bmake/unit-tests/directive-ifdef.exp head/contrib/bmake/unit-tests/directive-ifdef.mk head/contrib/bmake/unit-tests/directive-ifmake.exp head/contrib/bmake/unit-tests/directive-ifmake.mk head/contrib/bmake/unit-tests/directive-include.exp head/contrib/bmake/unit-tests/directive-include.mk head/contrib/bmake/unit-tests/directive-info.exp head/contrib/bmake/unit-tests/directive-info.mk head/contrib/bmake/unit-tests/directive-sinclude.mk head/contrib/bmake/unit-tests/directive-undef.exp head/contrib/bmake/unit-tests/directive-undef.mk head/contrib/bmake/unit-tests/directive-unexport-env.mk head/contrib/bmake/unit-tests/directive-unexport.exp head/contrib/bmake/unit-tests/directive-unexport.mk head/contrib/bmake/unit-tests/directive-warning.exp head/contrib/bmake/unit-tests/directive-warning.mk head/contrib/bmake/unit-tests/directive.exp head/contrib/bmake/unit-tests/directive.mk head/contrib/bmake/unit-tests/dollar.exp head/contrib/bmake/unit-tests/dollar.mk head/contrib/bmake/unit-tests/envfirst.mk head/contrib/bmake/unit-tests/error.exp head/contrib/bmake/unit-tests/error.mk head/contrib/bmake/unit-tests/escape.mk head/contrib/bmake/unit-tests/forloop.exp head/contrib/bmake/unit-tests/forloop.mk head/contrib/bmake/unit-tests/forsubst.mk head/contrib/bmake/unit-tests/include-sub.mk head/contrib/bmake/unit-tests/moderrs.mk head/contrib/bmake/unit-tests/modmisc.mk head/contrib/bmake/unit-tests/modts.mk head/contrib/bmake/unit-tests/modword.mk head/contrib/bmake/unit-tests/opt-chdir.exp head/contrib/bmake/unit-tests/opt-chdir.mk head/contrib/bmake/unit-tests/opt-debug-jobs.exp head/contrib/bmake/unit-tests/opt-debug-jobs.mk head/contrib/bmake/unit-tests/opt-ignore.mk head/contrib/bmake/unit-tests/opt-keep-going.mk head/contrib/bmake/unit-tests/opt-no-action.mk head/contrib/bmake/unit-tests/opt-query.mk head/contrib/bmake/unit-tests/opt-touch.exp head/contrib/bmake/unit-tests/opt-touch.mk head/contrib/bmake/unit-tests/opt-var-expanded.mk head/contrib/bmake/unit-tests/opt-var-literal.mk head/contrib/bmake/unit-tests/opt-warnings-as-errors.exp head/contrib/bmake/unit-tests/opt-warnings-as-errors.mk head/contrib/bmake/unit-tests/opt.exp head/contrib/bmake/unit-tests/opt.mk head/contrib/bmake/unit-tests/order.mk head/contrib/bmake/unit-tests/recursive.exp head/contrib/bmake/unit-tests/recursive.mk head/contrib/bmake/unit-tests/sh-leading-at.exp head/contrib/bmake/unit-tests/sh-leading-at.mk head/contrib/bmake/unit-tests/sh-leading-hyphen.mk head/contrib/bmake/unit-tests/sh-leading-plus.mk head/contrib/bmake/unit-tests/sh-meta-chars.mk head/contrib/bmake/unit-tests/use-inference.mk head/contrib/bmake/unit-tests/var-class-local.exp head/contrib/bmake/unit-tests/var-class-local.mk head/contrib/bmake/unit-tests/var-op-assign.exp head/contrib/bmake/unit-tests/var-op-assign.mk head/contrib/bmake/unit-tests/var-op-expand.exp head/contrib/bmake/unit-tests/var-op-expand.mk head/contrib/bmake/unit-tests/var-op-shell.exp head/contrib/bmake/unit-tests/var-op-shell.mk head/contrib/bmake/unit-tests/var-op-sunsh.mk head/contrib/bmake/unit-tests/vardebug.exp head/contrib/bmake/unit-tests/varmisc.mk head/contrib/bmake/unit-tests/varmod-defined.exp head/contrib/bmake/unit-tests/varmod-defined.mk head/contrib/bmake/unit-tests/varmod-exclam-shell.mk head/contrib/bmake/unit-tests/varmod-ifelse.exp head/contrib/bmake/unit-tests/varmod-ifelse.mk head/contrib/bmake/unit-tests/varmod-loop.exp head/contrib/bmake/unit-tests/varmod-loop.mk head/contrib/bmake/unit-tests/varmod-match.mk head/contrib/bmake/unit-tests/varmod-order-shuffle.mk head/contrib/bmake/unit-tests/varmod-shell.exp head/contrib/bmake/unit-tests/varmod-shell.mk head/contrib/bmake/unit-tests/varmod-subst.exp head/contrib/bmake/unit-tests/varmod-subst.mk head/contrib/bmake/unit-tests/varmod-to-abs.exp head/contrib/bmake/unit-tests/varmod-to-abs.mk head/contrib/bmake/unit-tests/varmod-to-lower.mk head/contrib/bmake/unit-tests/varmod-to-separator.mk head/contrib/bmake/unit-tests/varmod-undefined.mk head/contrib/bmake/unit-tests/varmod.exp head/contrib/bmake/unit-tests/varmod.mk head/contrib/bmake/unit-tests/varname-dot-shell.exp head/contrib/bmake/unit-tests/varname-empty.exp head/contrib/bmake/unit-tests/varname-makefile.exp head/contrib/bmake/unit-tests/varname-makefile.mk head/contrib/bmake/unit-tests/varname-vpath.exp head/contrib/bmake/unit-tests/varname-vpath.mk head/contrib/bmake/unit-tests/varname.exp head/contrib/bmake/unit-tests/varname.mk head/contrib/bmake/unit-tests/varparse-undef-partial.mk head/contrib/bmake/util.c head/contrib/bmake/var.c head/usr.bin/bmake/Makefile head/usr.bin/bmake/Makefile.config head/usr.bin/bmake/config.h head/usr.bin/bmake/unit-tests/Makefile Directory Properties: head/contrib/bmake/ (props changed) Modified: head/contrib/bmake/ChangeLog ============================================================================== --- head/contrib/bmake/ChangeLog Fri Nov 20 05:46:27 2020 (r367862) +++ head/contrib/bmake/ChangeLog Fri Nov 20 06:02:31 2020 (r367863) @@ -1,3 +1,78 @@ +2020-11-17 Simon J Gerraty + + * VERSION (_MAKE_VERSION): 20201117 + Merge with NetBSD make, pick up + o fix some unit-tests when dash is .SHELL + o rename Targ_NewGN to GNode_New + o make some GNode functions const + o main.c: call Targ_Init before Var_Init + cleanup PrintOnError, getTmpdir and ParseBoolean + o var.c: fix error message of failed :!cmd! modifier + +2020-11-14 Simon J Gerraty + + * VERSION (_MAKE_VERSION): 20201114 + Merge with NetBSD make, pick up + o replace a few HashTable_CreateEntry with HashTable_Set + o clean up cached_stats + o rename DEFAULT to defaultNode + o remove redundant struct make_stat + o cond.c: in lint mode, check for ".else " + use bitset for IfState + replace large switch with if-else in Cond_EvalLine + o job.c: clean up JobExec, JobStart, JobDoOutput + use stderr for error message about failed touch + clean up Job_Touch + replace macro DBPRINTF with JobPrintln + rename JobState to JobStatus + main.c: switch cache for realpath from GNode to HashTable + clean up Fatal + clean up InitDefSysIncPath + use progname instead of hard-coded 'make' in warning + rename Main_SetVarObjdir to SetVarObjdir + make.1: document the -S option + make.c: fix debug output for GNode details + use symbolic names in debug output of GNodes + +2020-11-12 Simon J Gerraty + + * configure.in: fix --with-force-machine-arch + + * VERSION (_MAKE_VERSION): 20201112 + Merge with NetBSD make, pick up + o allow env var MAKE_OBJDIR_CHECK_WRITABLE=no to skip writable + checks in InitObjdir. Explicit .OBJDIR target always allows + read-only directory. + o cond.c: clean up Cond_EvalLine + +2020-11-11 Simon J Gerraty + + * VERSION (_MAKE_VERSION): 20201111 + Merge with NetBSD make, pick up + o more unit-tests + o style cleanup + remove redundant parentheses from sizeof operator + replace character literal 0 with '\0'. + replace pointer literal 0 with NULL. + remove redundant parentheses. + replace (expr & mask) == 0 with !(expr & mask). + use strict typing in conditions of the form !var + o rename Make_OODate to GNode_IsOODate + o rename Make_TimeStamp to GNode_UpdateYoungestChild + o rename Var_Set_with_flags to Var_SetWithFlags + o rename dieQuietly to shouldDieQuietly + o buf.c: make API of Buf_Init simpler + o compat.c: clean up Compat_Make, Compat_RunCommand, + CompatDeleteTarget and CompatInterrupt + o cond.c: in lint mode, only allow '&&' and '||', not '&' and '|' + clean up CondParser_Comparison + o main.c: rename getBoolean and s2Boolean + rename MAKEFILE_PREFERENCE for consistency + o parse.c: replace strstr in ParseMaybeSubMake with optimized code + o var.c: rename VARE_ASSIGN to VARE_KEEP_DOLLAR + replace emptyString with allocated empty string + error out on unclosed expressions after the colon + 2020-11-01 Simon J Gerraty * VERSION (_MAKE_VERSION): 20201101 Modified: head/contrib/bmake/FILES ============================================================================== --- head/contrib/bmake/FILES Fri Nov 20 05:46:27 2020 (r367862) +++ head/contrib/bmake/FILES Fri Nov 20 06:02:31 2020 (r367863) @@ -75,8 +75,14 @@ unit-tests/archive-suffix.exp unit-tests/archive-suffix.mk unit-tests/archive.exp unit-tests/archive.mk +unit-tests/cmd-errors-lint.exp +unit-tests/cmd-errors-lint.mk +unit-tests/cmd-errors.exp +unit-tests/cmd-errors.mk unit-tests/cmd-interrupt.exp unit-tests/cmd-interrupt.mk +unit-tests/cmdline-undefined.exp +unit-tests/cmdline-undefined.mk unit-tests/cmdline.exp unit-tests/cmdline.mk unit-tests/comment.exp @@ -115,10 +121,14 @@ unit-tests/cond-func.exp unit-tests/cond-func.mk unit-tests/cond-late.exp unit-tests/cond-late.mk +unit-tests/cond-op-and-lint.exp +unit-tests/cond-op-and-lint.mk unit-tests/cond-op-and.exp unit-tests/cond-op-and.mk unit-tests/cond-op-not.exp unit-tests/cond-op-not.mk +unit-tests/cond-op-or-lint.exp +unit-tests/cond-op-or-lint.mk unit-tests/cond-op-or.exp unit-tests/cond-op-or.mk unit-tests/cond-op-parentheses.exp @@ -287,6 +297,8 @@ unit-tests/directive-for.exp unit-tests/directive-for.mk unit-tests/directive-hyphen-include.exp unit-tests/directive-hyphen-include.mk +unit-tests/directive-if-nested.exp +unit-tests/directive-if-nested.mk unit-tests/directive-if.exp unit-tests/directive-if.mk unit-tests/directive-ifdef.exp @@ -315,8 +327,6 @@ unit-tests/directive-warning.exp unit-tests/directive-warning.mk unit-tests/directive.exp unit-tests/directive.mk -unit-tests/directives.exp -unit-tests/directives.mk unit-tests/dollar.exp unit-tests/dollar.mk unit-tests/doterror.exp @@ -341,6 +351,8 @@ unit-tests/forloop.exp unit-tests/forloop.mk unit-tests/forsubst.exp unit-tests/forsubst.mk +unit-tests/gnode-submake.exp +unit-tests/gnode-submake.mk unit-tests/hanoi-include.exp unit-tests/hanoi-include.mk unit-tests/impsrc.exp @@ -349,6 +361,8 @@ unit-tests/include-main.exp unit-tests/include-main.mk unit-tests/include-sub.mk unit-tests/include-subsub.mk +unit-tests/job-flags.exp +unit-tests/job-flags.mk unit-tests/job-output-long-lines.exp unit-tests/job-output-long-lines.mk unit-tests/lint.exp @@ -365,6 +379,8 @@ unit-tests/modts.exp unit-tests/modts.mk unit-tests/modword.exp unit-tests/modword.mk +unit-tests/objdir-writable.exp +unit-tests/objdir-writable.mk unit-tests/opt-backwards.exp unit-tests/opt-backwards.mk unit-tests/opt-chdir.exp @@ -447,6 +463,8 @@ unit-tests/opt-raw.exp unit-tests/opt-raw.mk unit-tests/opt-silent.exp unit-tests/opt-silent.mk +unit-tests/opt-touch-jobs.exp +unit-tests/opt-touch-jobs.mk unit-tests/opt-touch.exp unit-tests/opt-touch.mk unit-tests/opt-tracefile.exp @@ -517,6 +535,8 @@ unit-tests/suff-main.exp unit-tests/suff-main.mk unit-tests/suff-rebuild.exp unit-tests/suff-rebuild.mk +unit-tests/suff-self.exp +unit-tests/suff-self.mk unit-tests/suff-transform-endless.exp unit-tests/suff-transform-endless.mk unit-tests/suff-transform-expand.exp @@ -737,14 +757,14 @@ unit-tests/varname.exp unit-tests/varname.mk unit-tests/varparse-dynamic.exp unit-tests/varparse-dynamic.mk +unit-tests/varparse-errors.exp +unit-tests/varparse-errors.mk unit-tests/varparse-mod.exp unit-tests/varparse-mod.mk unit-tests/varparse-undef-partial.exp unit-tests/varparse-undef-partial.mk unit-tests/varquote.exp unit-tests/varquote.mk -unit-tests/varshell.exp -unit-tests/varshell.mk util.c var.c wait.h Modified: head/contrib/bmake/Makefile ============================================================================== --- head/contrib/bmake/Makefile Fri Nov 20 05:46:27 2020 (r367862) +++ head/contrib/bmake/Makefile Fri Nov 20 06:02:31 2020 (r367863) @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.113 2020/10/26 17:55:09 sjg Exp $ +# $Id: Makefile,v 1.114 2020/11/13 21:47:25 sjg Exp $ PROG= bmake @@ -48,6 +48,12 @@ CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\" CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}} COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" + +.for x in FORCE_MACHINE FORCE_MACHINE_ARCH +.ifdef $x +COPTS.main.c+= "-D$x=\"${$x}\"" +.endif +.endfor # meta mode can be useful even without filemon # should be set by now Modified: head/contrib/bmake/Makefile.config.in ============================================================================== --- head/contrib/bmake/Makefile.config.in Fri Nov 20 05:46:27 2020 (r367862) +++ head/contrib/bmake/Makefile.config.in Fri Nov 20 06:02:31 2020 (r367863) @@ -5,8 +5,8 @@ _MAKE_VERSION?=@_MAKE_VERSION@ prefix?= @prefix@ srcdir= @srcdir@ CC?= @CC@ -MACHINE?= @machine@ -MACHINE_ARCH?= @machine_arch@ +@force_machine@MACHINE?= @machine@ +@force_machine_arch@MACHINE_ARCH?= @machine_arch@ DEFAULT_SYS_PATH?= @default_sys_path@ CPPFLAGS+= @CPPFLAGS@ Modified: head/contrib/bmake/VERSION ============================================================================== --- head/contrib/bmake/VERSION Fri Nov 20 05:46:27 2020 (r367862) +++ head/contrib/bmake/VERSION Fri Nov 20 06:02:31 2020 (r367863) @@ -1,2 +1,2 @@ # keep this compatible with sh and make -_MAKE_VERSION=20201101 +_MAKE_VERSION=20201117 Modified: head/contrib/bmake/arch.c ============================================================================== --- head/contrib/bmake/arch.c Fri Nov 20 05:46:27 2020 (r367862) +++ head/contrib/bmake/arch.c Fri Nov 20 06:02:31 2020 (r367863) @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.151 2020/10/31 18:41:07 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.177 2020/11/14 21:29:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -68,38 +68,38 @@ * SUCH DAMAGE. */ -/*- - * arch.c -- - * Functions to manipulate libraries, archives and their members. +/* Manipulate libraries, archives and their members. * - * Once again, cacheing/hashing comes into play in the manipulation - * of archives. The first time an archive is referenced, all of its members' - * headers are read and hashed and the archive closed again. All hashed - * archives are kept on a list which is searched each time an archive member - * is referenced. + * The first time an archive is referenced, all of its members' headers are + * read and cached and the archive closed again. All cached archives are kept + * on a list which is searched each time an archive member is referenced. * * The interface to this module is: + * + * Arch_Init Initialize this module. + * + * Arch_End Clean up this module. + * * Arch_ParseArchive - * Given an archive specification, return a list - * of GNode's, one for each member in the spec. - * FALSE is returned if the specification is - * invalid for some reason. + * Parse an archive specification such as + * "archive.a(member1 member2)". * * Arch_Touch Alter the modification time of the archive * member described by the given node to be - * the current time. + * the time when make was started. * * Arch_TouchLib Update the modification time of the library * described by the given node. This is special * because it also updates the modification time * of the library's table of contents. * - * Arch_MTime Find the modification time of a member of - * an archive *in the archive*. The time is also - * placed in the member's GNode. Returns the - * modification time. + * Arch_UpdateMTime + * Find the modification time of a member of + * an archive *in the archive* and place it in the + * member's GNode. * - * Arch_MemTime Find the modification time of a member of + * Arch_UpdateMemberMTime + * Find the modification time of a member of * an archive. Called when the member doesn't * already exist. Looks in the archive for the * modification time. Returns the modification @@ -109,12 +109,7 @@ * library name in the GNode should be in * -l format. * - * Arch_LibOODate Special function to decide if a library node - * is out-of-date. - * - * Arch_Init Initialize this module. - * - * Arch_End Clean up this module. + * Arch_LibOODate Decide if a library node is out-of-date. */ #ifdef HAVE_CONFIG_H @@ -151,17 +146,8 @@ struct ar_hdr { #include "dir.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.151 2020/10/31 18:41:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.177 2020/11/14 21:29:44 rillig Exp $"); -#ifdef TARGET_MACHINE -#undef MAKE_MACHINE -#define MAKE_MACHINE TARGET_MACHINE -#endif -#ifdef TARGET_MACHINE_ARCH -#undef MAKE_MACHINE_ARCH -#define MAKE_MACHINE_ARCH TARGET_MACHINE_ARCH -#endif - typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -230,39 +216,37 @@ ArchFree(void *ap) #endif -/*- - *----------------------------------------------------------------------- - * Arch_ParseArchive -- - * Parse the archive specification in the given line and find/create - * the nodes for the specified archive members, placing their nodes - * on the given list. +/* + * Parse an archive specification such as "archive.a(member1 member2.${EXT})", + * adding nodes for the expanded members to nodeLst. Nodes are created as + * necessary. * * Input: - * linePtr Pointer to start of specification - * nodeLst Lst on which to place the nodes - * ctxt Context in which to expand variables + * pp The start of the specification. + * nodeLst The list on which to place the nodes. + * ctxt The context in which to expand variables. * - * Results: - * TRUE if it was a valid specification. The linePtr is updated - * to point to the first non-space after the archive spec. The - * nodes for the members are placed on the given list. - *----------------------------------------------------------------------- + * Output: + * return TRUE if it was a valid specification. + * *pp Points to the first non-space after the archive spec. + * *nodeLst Nodes for the members have been added. */ Boolean -Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, GNode *ctxt) +Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt) { char *cp; /* Pointer into line */ GNode *gn; /* New node */ char *libName; /* Library-part of specification */ + char *libName_freeIt = NULL; char *memName; /* Member-part of specification */ char saveChar; /* Ending delimiter of member-name */ - Boolean subLibName; /* TRUE if libName should have/had - * variable substitution performed on it */ + Boolean expandLibName; /* Whether the parsed libName contains + * variable expressions that need to be + * expanded */ - libName = *linePtr; + libName = *pp; + expandLibName = FALSE; - subLibName = FALSE; - for (cp = libName; *cp != '(' && *cp != '\0';) { if (*cp == '$') { /* @@ -274,7 +258,8 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, const char *result; Boolean isError; - (void)Var_Parse(&nested_p, ctxt, VARE_UNDEFERR|VARE_WANTRES, + /* XXX: is expanded twice: once here and once below */ + (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR, &result, &result_freeIt); /* TODO: handle errors */ isError = result == var_Error; @@ -282,16 +267,17 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, if (isError) return FALSE; - subLibName = TRUE; + expandLibName = TRUE; cp += nested_p - cp; } else cp++; } *cp++ = '\0'; - if (subLibName) { - (void)Var_Subst(libName, ctxt, VARE_UNDEFERR|VARE_WANTRES, &libName); + if (expandLibName) { + (void)Var_Subst(libName, ctxt, VARE_WANTRES | VARE_UNDEFERR, &libName); /* TODO: handle errors */ + libName_freeIt = libName; } @@ -317,7 +303,7 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, Boolean isError; const char *nested_p = cp; - (void)Var_Parse(&nested_p, ctxt, VARE_UNDEFERR|VARE_WANTRES, + (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR, &result, &freeIt); /* TODO: handle errors */ isError = result == var_Error; @@ -339,7 +325,7 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, * so it's better to return failure than allow such things to happen */ if (*cp == '\0') { - printf("No closing parenthesis in archive specification\n"); + Parse_Error(PARSE_FATAL, "No closing parenthesis in archive specification"); return FALSE; } @@ -370,7 +356,7 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, char *sacrifice; char *oldMemName = memName; - (void)Var_Subst(memName, ctxt, VARE_UNDEFERR|VARE_WANTRES, + (void)Var_Subst(memName, ctxt, VARE_WANTRES | VARE_UNDEFERR, &memName); /* TODO: handle errors */ @@ -381,7 +367,8 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, */ buf = sacrifice = str_concat4(libName, "(", memName, ")"); - if (strchr(memName, '$') && strcmp(memName, oldMemName) == 0) { + if (strchr(memName, '$') != NULL && + strcmp(memName, oldMemName) == 0) { /* * Must contain dynamic sources, so we can't deal with it now. * Just create an ARCHV node for the thing and let @@ -437,17 +424,12 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, *cp = saveChar; } - /* - * If substituted libName, free it now, since we need it no longer. - */ - if (subLibName) { - free(libName); - } + free(libName_freeIt); cp++; /* skip the ')' */ - /* We promised that linePtr would be set up at the next non-space. */ + /* We promised that pp would be set up at the next non-space. */ pp_skip_whitespace(&cp); - *linePtr = cp; + *pp = cp; return TRUE; } @@ -457,15 +439,17 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, * Input: * archive Path to the archive * member Name of member; only its basename is used. - * hash TRUE if archive should be hashed if not already so. + * addToCache TRUE if archive should be cached if not already so. * * Results: - * The ar_hdr for the member. + * The ar_hdr for the member, or NULL. + * + * See ArchFindMember for an almost identical copy of this code. */ static struct ar_hdr * -ArchStatMember(const char *archive, const char *member, Boolean hash) +ArchStatMember(const char *archive, const char *member, Boolean addToCache) { -#define AR_MAX_NAME_LEN (sizeof(arh.AR_NAME) - 1) +#define AR_MAX_NAME_LEN (sizeof arh.AR_NAME - 1) FILE *arch; /* Stream to archive */ size_t size; /* Size of archive member */ char magic[SARMAG]; @@ -484,8 +468,8 @@ ArchStatMember(const char *archive, const char *member member = lastSlash + 1; for (ln = archives->first; ln != NULL; ln = ln->next) { - const Arch *archPtr = ln->datum; - if (strcmp(archPtr->name, archive) == 0) + const Arch *a = ln->datum; + if (strcmp(a->name, archive) == 0) break; } @@ -505,17 +489,17 @@ ArchStatMember(const char *archive, const char *member if (len > AR_MAX_NAME_LEN) { len = AR_MAX_NAME_LEN; snprintf(copy, sizeof copy, "%s", member); + hdr = HashTable_FindValue(&ar->members, copy); } - hdr = HashTable_FindValue(&ar->members, copy); return hdr; } } - if (!hash) { + if (!addToCache) { /* - * Caller doesn't want the thing hashed, just use ArchFindMember + * Caller doesn't want the thing cached, just use ArchFindMember * to read the header for the member out and close down the stream - * again. Since the archive is not to be hashed, we assume there's + * again. Since the archive is not to be cached, we assume there's * no need to allocate extra room for the header we're returning, * so just declare it static. */ @@ -541,98 +525,92 @@ ArchStatMember(const char *archive, const char *member * We use the ARMAG string to make sure this is an archive we * can handle... */ - if ((fread(magic, SARMAG, 1, arch) != 1) || - (strncmp(magic, ARMAG, SARMAG) != 0)) { - fclose(arch); + if (fread(magic, SARMAG, 1, arch) != 1 || + strncmp(magic, ARMAG, SARMAG) != 0) { + (void)fclose(arch); return NULL; } - ar = bmake_malloc(sizeof(Arch)); + ar = bmake_malloc(sizeof *ar); ar->name = bmake_strdup(archive); ar->fnametab = NULL; ar->fnamesize = 0; HashTable_Init(&ar->members); memName[AR_MAX_NAME_LEN] = '\0'; - while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) { - if (strncmp(arh.AR_FMAG, ARFMAG, sizeof(arh.AR_FMAG)) != 0) { - /* - * The header is bogus, so the archive is bad - * and there's no way we can recover... - */ + while (fread(&arh, sizeof arh, 1, arch) == 1) { + char *nameend; + + /* If the header is bogus, there's no way we can recover. */ + if (strncmp(arh.AR_FMAG, ARFMAG, sizeof arh.AR_FMAG) != 0) goto badarch; - } else { - char *nameend; - /* - * We need to advance the stream's pointer to the start of the - * next header. Files are padded with newlines to an even-byte - * boundary, so we need to extract the size of the file from the - * 'size' field of the header and round it up during the seek. - */ - arh.AR_SIZE[sizeof(arh.AR_SIZE) - 1] = '\0'; - size = (size_t)strtol(arh.ar_size, NULL, 10); + /* + * We need to advance the stream's pointer to the start of the + * next header. Files are padded with newlines to an even-byte + * boundary, so we need to extract the size of the file from the + * 'size' field of the header and round it up during the seek. + */ + arh.AR_SIZE[sizeof arh.AR_SIZE - 1] = '\0'; + size = (size_t)strtol(arh.AR_SIZE, NULL, 10); - memcpy(memName, arh.AR_NAME, sizeof(arh.AR_NAME)); - nameend = memName + AR_MAX_NAME_LEN; - while (*nameend == ' ') { - nameend--; - } - nameend[1] = '\0'; + memcpy(memName, arh.AR_NAME, sizeof arh.AR_NAME); + nameend = memName + AR_MAX_NAME_LEN; + while (nameend > memName && *nameend == ' ') + nameend--; + nameend[1] = '\0'; #ifdef SVR4ARCHIVES + /* + * svr4 names are slash terminated. Also svr4 extended AR format. + */ + if (memName[0] == '/') { /* - * svr4 names are slash terminated. Also svr4 extended AR format. + * svr4 magic mode; handle it */ - if (memName[0] == '/') { - /* - * svr4 magic mode; handle it - */ - switch (ArchSVR4Entry(ar, memName, size, arch)) { - case -1: /* Invalid data */ - goto badarch; - case 0: /* List of files entry */ - continue; - default: /* Got the entry */ - break; - } - } else { - if (nameend[0] == '/') - nameend[0] = '\0'; + switch (ArchSVR4Entry(ar, memName, size, arch)) { + case -1: /* Invalid data */ + goto badarch; + case 0: /* List of files entry */ + continue; + default: /* Got the entry */ + break; } + } else { + if (nameend[0] == '/') + nameend[0] = '\0'; + } #endif #ifdef AR_EFMT1 - /* - * BSD 4.4 extended AR format: #1/, with name as the - * first bytes of the file - */ - if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 && - ch_isdigit(memName[sizeof(AR_EFMT1) - 1])) { + /* + * BSD 4.4 extended AR format: #1/, with name as the + * first bytes of the file + */ + if (strncmp(memName, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 && + ch_isdigit(memName[sizeof AR_EFMT1 - 1])) { - int elen = atoi(&memName[sizeof(AR_EFMT1) - 1]); + int elen = atoi(memName + sizeof AR_EFMT1 - 1); - if ((unsigned int)elen > MAXPATHLEN) - goto badarch; - if (fread(memName, (size_t)elen, 1, arch) != 1) - goto badarch; - memName[elen] = '\0'; - if (fseek(arch, -elen, SEEK_CUR) != 0) - goto badarch; - if (DEBUG(ARCH) || DEBUG(MAKE)) { - debug_printf("ArchStat: Extended format entry for %s\n", - memName); - } - } + if ((unsigned int)elen > MAXPATHLEN) + goto badarch; + if (fread(memName, (size_t)elen, 1, arch) != 1) + goto badarch; + memName[elen] = '\0'; + if (fseek(arch, -elen, SEEK_CUR) != 0) + goto badarch; + if (DEBUG(ARCH) || DEBUG(MAKE)) + debug_printf("ArchStatMember: Extended format entry for %s\n", + memName); + } #endif - { - HashEntry *he; - he = HashTable_CreateEntry(&ar->members, memName, NULL); - HashEntry_Set(he, bmake_malloc(sizeof(struct ar_hdr))); - memcpy(HashEntry_Get(he), &arh, sizeof(struct ar_hdr)); - } + { + struct ar_hdr *cached_hdr = bmake_malloc(sizeof *cached_hdr); + memcpy(cached_hdr, &arh, sizeof arh); + HashTable_Set(&ar->members, memName, cached_hdr); } + if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0) goto badarch; } @@ -643,7 +621,7 @@ ArchStatMember(const char *archive, const char *member /* * Now that the archive has been read and cached, we can look into - * the hash table to find the desired member's header. + * the addToCache table to find the desired member's header. */ return HashTable_FindValue(&ar->members, member); @@ -674,15 +652,15 @@ badarch: *----------------------------------------------------------------------- */ static int -ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch) +ArchSVR4Entry(Arch *ar, char *inout_name, size_t size, FILE *arch) { #define ARLONGNAMES1 "//" #define ARLONGNAMES2 "/ARFILENAMES" size_t entry; char *ptr, *eptr; - if (strncmp(name, ARLONGNAMES1, sizeof(ARLONGNAMES1) - 1) == 0 || - strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) { + if (strncmp(inout_name, ARLONGNAMES1, sizeof ARLONGNAMES1 - 1) == 0 || + strncmp(inout_name, ARLONGNAMES2, sizeof ARLONGNAMES2 - 1) == 0) { if (ar->fnametab != NULL) { DEBUG0(ARCH, "Attempted to redefine an SVR4 name table\n"); @@ -711,51 +689,74 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE return 0; } - if (name[1] == ' ' || name[1] == '\0') + if (inout_name[1] == ' ' || inout_name[1] == '\0') return 2; - entry = (size_t)strtol(&name[1], &eptr, 0); - if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) { - DEBUG1(ARCH, "Could not parse SVR4 name %s\n", name); + entry = (size_t)strtol(&inout_name[1], &eptr, 0); + if ((*eptr != ' ' && *eptr != '\0') || eptr == &inout_name[1]) { + DEBUG1(ARCH, "Could not parse SVR4 name %s\n", inout_name); return 2; } if (entry >= ar->fnamesize) { DEBUG2(ARCH, "SVR4 entry offset %s is greater than %lu\n", - name, (unsigned long)ar->fnamesize); + inout_name, (unsigned long)ar->fnamesize); return 2; } - DEBUG2(ARCH, "Replaced %s with %s\n", name, &ar->fnametab[entry]); + DEBUG2(ARCH, "Replaced %s with %s\n", inout_name, &ar->fnametab[entry]); - snprintf(name, MAXPATHLEN + 1, "%s", &ar->fnametab[entry]); + snprintf(inout_name, MAXPATHLEN + 1, "%s", &ar->fnametab[entry]); return 1; } #endif -/*- - *----------------------------------------------------------------------- - * ArchFindMember -- - * Locate a member of an archive, given the path of the archive and - * the path of the desired member. If the archive is to be modified, - * the mode should be "r+", if not, it should be "r". - * The passed struct ar_hdr structure is filled in. +static Boolean +ArchiveMember_HasName(const struct ar_hdr *hdr, + const char *name, size_t namelen) +{ + const size_t ar_name_len = sizeof hdr->AR_NAME; + const char *ar_name = hdr->AR_NAME; + + if (strncmp(ar_name, name, namelen) != 0) + return FALSE; + + if (namelen >= ar_name_len) + return namelen == ar_name_len; + + /* hdr->AR_NAME is space-padded to the right. */ + if (ar_name[namelen] == ' ') + return TRUE; + + /* In archives created by GNU binutils 2.27, the member names end with + * a slash. */ + if (ar_name[namelen] == '/' && + (namelen == ar_name_len || ar_name[namelen + 1] == ' ')) + return TRUE; + + return FALSE; +} + +/* Locate a member of an archive, given the path of the archive and the path + * of the desired member. * * Input: * archive Path to the archive * member Name of member. If it is a path, only the last * component is used. - * arhPtr Pointer to header structure to be filled in - * mode The mode for opening the stream + * out_arh Archive header to be filled in + * mode "r" for read-only access, "r+" for read-write access * - * Results: - * An FILE *, opened for reading and writing, positioned at the - * start of the member's struct ar_hdr, or NULL if the member was - * nonexistent. The current struct ar_hdr for member. - *----------------------------------------------------------------------- + * Output: + * return The archive file, positioned at the start of the + * member's struct ar_hdr, or NULL if the member doesn't + * exist. + * *out_arh The current struct ar_hdr for member. + * + * See ArchStatMember for an almost identical copy of this code. */ static FILE * -ArchFindMember(const char *archive, const char *member, struct ar_hdr *arhPtr, +ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh, const char *mode) { FILE *arch; /* Stream to archive */ @@ -772,8 +773,8 @@ ArchFindMember(const char *archive, const char *member * We use the ARMAG string to make sure this is an archive we * can handle... */ - if ((fread(magic, SARMAG, 1, arch) != 1) || - (strncmp(magic, ARMAG, SARMAG) != 0)) { + if (fread(magic, SARMAG, 1, arch) != 1 || + strncmp(magic, ARMAG, SARMAG) != 0) { fclose(arch); return NULL; } @@ -787,13 +788,13 @@ ArchFindMember(const char *archive, const char *member member = lastSlash + 1; len = tlen = strlen(member); - if (len > sizeof(arhPtr->AR_NAME)) { - tlen = sizeof(arhPtr->AR_NAME); + if (len > sizeof out_arh->AR_NAME) { + tlen = sizeof out_arh->AR_NAME; } - while (fread((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) { + while (fread(out_arh, sizeof *out_arh, 1, arch) == 1) { - if (strncmp(arhPtr->AR_FMAG, ARFMAG, sizeof(arhPtr->AR_FMAG)) != 0) { + if (strncmp(out_arh->AR_FMAG, ARFMAG, sizeof out_arh->AR_FMAG) != 0) { /* * The header is bogus, so the archive is bad * and there's no way we can recover... @@ -802,25 +803,21 @@ ArchFindMember(const char *archive, const char *member return NULL; } - if (strncmp(member, arhPtr->AR_NAME, tlen) == 0) { - /* - * If the member's name doesn't take up the entire 'name' field, - * we have to be careful of matching prefixes. Names are space- - * padded to the right, so if the character in 'name' at the end - * of the matched string is anything but a space, this isn't the - * member we sought. - */ - if (tlen != sizeof arhPtr->AR_NAME && arhPtr->AR_NAME[tlen] != ' ') - goto skip; + DEBUG5(ARCH, "Reading archive %s member %.*s mtime %.*s\n", + archive, + (int)sizeof out_arh->AR_NAME, out_arh->AR_NAME, + (int)sizeof out_arh->ar_date, out_arh->ar_date); + if (ArchiveMember_HasName(out_arh, member, len)) { /* - * To make life easier, we reposition the file at the start + * To make life easier for callers that want to update the + * archive, we reposition the file at the start * of the header we just read before we return the stream. * In a more general situation, it might be better to leave * the file at the actual member, rather than its header, but - * not here... + * not here. */ - if (fseek(arch, -(long)sizeof(struct ar_hdr), SEEK_CUR) != 0) { + if (fseek(arch, -(long)sizeof *out_arh, SEEK_CUR) != 0) { fclose(arch); return NULL; } @@ -832,10 +829,10 @@ ArchFindMember(const char *archive, const char *member * BSD 4.4 extended AR format: #1/, with name as the * first bytes of the file */ - if (strncmp(arhPtr->AR_NAME, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 && - ch_isdigit(arhPtr->AR_NAME[sizeof(AR_EFMT1) - 1])) + if (strncmp(out_arh->AR_NAME, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 && + ch_isdigit(out_arh->AR_NAME[sizeof AR_EFMT1 - 1])) { - int elen = atoi(&arhPtr->AR_NAME[sizeof(AR_EFMT1) - 1]); + int elen = atoi(&out_arh->AR_NAME[sizeof AR_EFMT1 - 1]); char ename[MAXPATHLEN + 1]; if ((unsigned int)elen > MAXPATHLEN) { @@ -847,9 +844,9 @@ ArchFindMember(const char *archive, const char *member return NULL; } ename[elen] = '\0'; - if (DEBUG(ARCH) || DEBUG(MAKE)) { - debug_printf("ArchFind: Extended format entry for %s\n", ename); - } + if (DEBUG(ARCH) || DEBUG(MAKE)) + debug_printf("ArchFindMember: Extended format entry for %s\n", + ename); if (strncmp(ename, member, len) == 0) { /* Found as extended name */ if (fseek(arch, -(long)sizeof(struct ar_hdr) - elen, @@ -866,7 +863,6 @@ ArchFindMember(const char *archive, const char *member } #endif -skip: /* * This isn't the member we're after, so we need to advance the * stream's pointer to the start of the next header. Files are @@ -874,113 +870,89 @@ skip: * extract the size of the file from the 'size' field of the * header and round it up during the seek. */ - arhPtr->ar_size[sizeof(arhPtr->ar_size) - 1] = '\0'; - size = (int)strtol(arhPtr->ar_size, NULL, 10); + out_arh->AR_SIZE[sizeof out_arh->AR_SIZE - 1] = '\0'; + size = (int)strtol(out_arh->AR_SIZE, NULL, 10); if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) { fclose(arch); return NULL; } } - /* - * We've looked everywhere, but the member is not to be found. Close the - * archive and return NULL -- an error. - */ fclose(arch); return NULL; } -/*- - *----------------------------------------------------------------------- - * Arch_Touch -- - * Touch a member of an archive. - * The modification time of the entire archive is also changed. - * For a library, this could necessitate the re-ranlib'ing of the - * whole thing. +/* Touch a member of an archive, on disk. + * The GNode's modification time is left as-is. * + * The st_mtime of the entire archive is also changed. + * For a library, it may be required to run ranlib after this. + * * Input: * gn Node of member to touch * * Results: * The 'time' field of the member's header is updated. - *----------------------------------------------------------------------- */ void Arch_Touch(GNode *gn) { - FILE *arch; /* Stream open to archive, positioned properly */ - struct ar_hdr arh; /* Current header describing member */ + FILE *f; + struct ar_hdr arh; - arch = ArchFindMember(GNode_VarArchive(gn), GNode_VarMember(gn), - &arh, "r+"); + f = ArchFindMember(GNode_VarArchive(gn), GNode_VarMember(gn), &arh, "r+"); + if (f == NULL) + return; - snprintf(arh.AR_DATE, sizeof(arh.AR_DATE), "%-12ld", (long)now); - - if (arch != NULL) { - (void)fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch); - fclose(arch); - } + snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now); + (void)fwrite(&arh, sizeof arh, 1, f); + fclose(f); /* TODO: handle errors */ } /* Given a node which represents a library, touch the thing, making sure that - * the table of contents also is touched. + * the table of contents is also touched. * * Both the modification time of the library and of the RANLIBMAG member are - * set to 'now'. - * - * Input: - * gn The node of the library to touch - */ + * set to 'now'. */ void -Arch_TouchLib(GNode *gn) +Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED) { #ifdef RANLIBMAG *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Nov 20 09:05:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 288122C2304; Fri, 20 Nov 2020 09:05:37 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcrHP0Tr5z4mWk; Fri, 20 Nov 2020 09:05:37 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 037051383A; Fri, 20 Nov 2020 09:05:37 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK95aPY002314; Fri, 20 Nov 2020 09:05:36 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK95a1V002313; Fri, 20 Nov 2020 09:05:36 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202011200905.0AK95a1V002313@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Fri, 20 Nov 2020 09:05:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367865 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367865 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 09:05:37 -0000 Author: mmel Date: Fri Nov 20 09:05:36 2020 New Revision: 367865 URL: https://svnweb.freebsd.org/changeset/base/367865 Log: Also pass interrupt binding request to non-root interrupt controllers. There are message based controllers that can bind interrupts even if they are not implemented as root controllers (such as the ITS subblock of GIC). MFC after: 3 weeks Modified: head/sys/kern/subr_intr.c Modified: head/sys/kern/subr_intr.c ============================================================================== --- head/sys/kern/subr_intr.c Fri Nov 20 08:07:29 2020 (r367864) +++ head/sys/kern/subr_intr.c Fri Nov 20 09:05:36 2020 (r367865) @@ -588,9 +588,6 @@ intr_isrc_assign_cpu(void *arg, int cpu) struct intr_irqsrc *isrc = arg; int error; - if (isrc->isrc_dev != intr_irq_root_dev) - return (EINVAL); - mtx_lock(&isrc_table_lock); if (cpu == NOCPU) { CPU_ZERO(&isrc->isrc_cpu); From owner-svn-src-all@freebsd.org Fri Nov 20 09:56:46 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C55332C2BD3; Fri, 20 Nov 2020 09:56:46 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcsQQ58wSz4pV6; Fri, 20 Nov 2020 09:56:46 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A425613ED5; Fri, 20 Nov 2020 09:56:46 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AK9uk7o032799; Fri, 20 Nov 2020 09:56:46 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AK9ukFs032798; Fri, 20 Nov 2020 09:56:46 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <202011200956.0AK9ukFs032798@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Fri, 20 Nov 2020 09:56:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367866 - head/usr.bin/grep X-SVN-Group: head X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: head/usr.bin/grep X-SVN-Commit-Revision: 367866 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 09:56:46 -0000 Author: eugen Date: Fri Nov 20 09:56:46 2020 New Revision: 367866 URL: https://svnweb.freebsd.org/changeset/base/367866 Log: bzgrep: make flag --no-filename work PR: 248813 MFC after: 1 week Modified: head/usr.bin/grep/zgrep.sh Modified: head/usr.bin/grep/zgrep.sh ============================================================================== --- head/usr.bin/grep/zgrep.sh Fri Nov 20 09:05:36 2020 (r367865) +++ head/usr.bin/grep/zgrep.sh Fri Nov 20 09:56:46 2020 (r367866) @@ -90,6 +90,10 @@ do pattern_found=1 shift ;; + -h|--no-filename) + silent=1 + shift + ;; --*) grep_args="${grep_args} $1" shift @@ -118,10 +122,6 @@ do ;; -) hyphen=1 - shift - ;; - -h) - silent=1 shift ;; -r|-R) From owner-svn-src-all@freebsd.org Fri Nov 20 10:08:34 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 573CD2C4231; Fri, 20 Nov 2020 10:08:34 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ccsh222j4z4qSR; Fri, 20 Nov 2020 10:08:34 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38FA81462C; Fri, 20 Nov 2020 10:08:34 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKA8YVr039381; Fri, 20 Nov 2020 10:08:34 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKA8YSm039380; Fri, 20 Nov 2020 10:08:34 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202011201008.0AKA8YSm039380@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 20 Nov 2020 10:08:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367867 - head/sys/netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/sys/netpfil/pf X-SVN-Commit-Revision: 367867 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 10:08:34 -0000 Author: kp Date: Fri Nov 20 10:08:33 2020 New Revision: 367867 URL: https://svnweb.freebsd.org/changeset/base/367867 Log: pf: Fix incorrect assertion We never set PFRULE_RULESRCTRACK when calling pf_insert_src_node(). We do set PFRULE_SRCTRACK, so update the assertion to match. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27254 Modified: head/sys/netpfil/pf/pf.c Modified: head/sys/netpfil/pf/pf.c ============================================================================== --- head/sys/netpfil/pf/pf.c Fri Nov 20 09:56:46 2020 (r367866) +++ head/sys/netpfil/pf/pf.c Fri Nov 20 10:08:33 2020 (r367867) @@ -705,7 +705,7 @@ pf_insert_src_node(struct pf_src_node **sn, struct pf_ struct pf_addr *src, sa_family_t af) { - KASSERT((rule->rule_flag & PFRULE_RULESRCTRACK || + KASSERT((rule->rule_flag & PFRULE_SRCTRACK || rule->rpool.opts & PF_POOL_STICKYADDR), ("%s for non-tracking rule %p", __func__, rule)); From owner-svn-src-all@freebsd.org Fri Nov 20 10:09:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B1AE2C42E4; Fri, 20 Nov 2020 10:09:49 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcsjT0SgCz4qs8; Fri, 20 Nov 2020 10:09:49 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 02A7E143DE; Fri, 20 Nov 2020 10:09:49 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKA9mn4039488; Fri, 20 Nov 2020 10:09:48 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKA9mRs039487; Fri, 20 Nov 2020 10:09:48 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011201009.0AKA9mRs039487@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Fri, 20 Nov 2020 10:09:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367868 - stable/12/sbin/mdconfig X-SVN-Group: stable-12 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/12/sbin/mdconfig X-SVN-Commit-Revision: 367868 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 10:09:49 -0000 Author: 0mp (doc,ports committer) Date: Fri Nov 20 10:09:48 2020 New Revision: 367868 URL: https://svnweb.freebsd.org/changeset/base/367868 Log: MFC r367419: Fix a typo and remove Xr's to vn(4) and vnconfig(4) "mandoc -Tlint" complained about the Xr to vnconfig, which was removed in r238202. I am not sure but maybe it's time to do the same to vn(4). Modified: stable/12/sbin/mdconfig/mdconfig.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/mdconfig/mdconfig.8 ============================================================================== --- stable/12/sbin/mdconfig/mdconfig.8 Fri Nov 20 10:08:33 2020 (r367867) +++ stable/12/sbin/mdconfig/mdconfig.8 Fri Nov 20 10:09:48 2020 (r367868) @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 28, 2017 +.Dd November 6, 2020 .Dt MDCONFIG 8 .Os .Sh NAME @@ -235,7 +235,7 @@ checksums or cryptographic signatures. Request a specific unit number or device name for the .Xr md 4 device instead of automatic allocation. -If a device name is specified, it must be start with +If a device name is specified, it must start with .Dq md followed by the unit number. .El @@ -324,11 +324,8 @@ The .Nm utility first appeared in .Fx 5.0 -as a cleaner replacement for the -.Xr vn 4 -and -.Xr vnconfig 8 -combo. +as a cleaner replacement for the vn kernel module +and the vnconfig utility combo. .Sh AUTHORS The .Nm From owner-svn-src-all@freebsd.org Fri Nov 20 10:11:04 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 782E52C4585; Fri, 20 Nov 2020 10:11:04 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ccskw33Zfz4qqc; Fri, 20 Nov 2020 10:11:04 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 51865142D4; Fri, 20 Nov 2020 10:11:04 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKAB4Bq040414; Fri, 20 Nov 2020 10:11:04 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKAB43i040413; Fri, 20 Nov 2020 10:11:04 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202011201011.0AKAB43i040413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 20 Nov 2020 10:11:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367869 - head/tests/sys/netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/tests/sys/netpfil/pf X-SVN-Commit-Revision: 367869 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 10:11:04 -0000 Author: kp Date: Fri Nov 20 10:11:03 2020 New Revision: 367869 URL: https://svnweb.freebsd.org/changeset/base/367869 Log: pf tests: Basic source tracking test MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27255 Added: head/tests/sys/netpfil/pf/src_track.sh (contents, props changed) Modified: head/tests/sys/netpfil/pf/Makefile Modified: head/tests/sys/netpfil/pf/Makefile ============================================================================== --- head/tests/sys/netpfil/pf/Makefile Fri Nov 20 10:09:48 2020 (r367868) +++ head/tests/sys/netpfil/pf/Makefile Fri Nov 20 10:11:03 2020 (r367869) @@ -12,6 +12,7 @@ ATF_TESTS_SH+= anchor \ names \ nat \ set_tos \ + src_track \ rdr \ route_to \ synproxy \ Added: head/tests/sys/netpfil/pf/src_track.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/netpfil/pf/src_track.sh Fri Nov 20 10:11:03 2020 (r367869) @@ -0,0 +1,66 @@ +# $FreeBSD$ +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2020 Kristof Provost +# +# 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. + +. $(atf_get_srcdir)/utils.subr + +atf_test_case "source_track" "cleanup" +source_track_head() +{ + atf_set descr 'Basic source tracking test' + atf_set require.user root +} + +source_track_body() +{ + pft_init + + epair=$(vnet_mkepair) + + vnet_mkjail alcatraz ${epair}b + + ifconfig ${epair}a 192.0.2.2/24 up + jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up + + # Enable pf! + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "pass in keep state (source-track)" \ + "pass out keep state (source-track)" + + ping -c 3 192.0.2.1 + jexec alcatraz pfctl -s all -v +} + +source_track_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "source_track" +} From owner-svn-src-all@freebsd.org Fri Nov 20 10:12:04 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD7522C4744; Fri, 20 Nov 2020 10:12:04 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ccsm45WCzz4r2h; Fri, 20 Nov 2020 10:12:04 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B0110143FE; Fri, 20 Nov 2020 10:12:04 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKAC4tR044459; Fri, 20 Nov 2020 10:12:04 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKAC4nP044458; Fri, 20 Nov 2020 10:12:04 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011201012.0AKAC4nP044458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Fri, 20 Nov 2020 10:12:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r367870 - stable/11/sbin/mdconfig X-SVN-Group: stable-11 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/11/sbin/mdconfig X-SVN-Commit-Revision: 367870 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 10:12:04 -0000 Author: 0mp (doc,ports committer) Date: Fri Nov 20 10:12:04 2020 New Revision: 367870 URL: https://svnweb.freebsd.org/changeset/base/367870 Log: MFC r367419: Fix a typo and remove Xr's to vn(4) and vnconfig(4) "mandoc -Tlint" complained about the Xr to vnconfig, which was removed in r238202. I am not sure but maybe it's time to do the same to vn(4). Modified: stable/11/sbin/mdconfig/mdconfig.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mdconfig/mdconfig.8 ============================================================================== --- stable/11/sbin/mdconfig/mdconfig.8 Fri Nov 20 10:11:03 2020 (r367869) +++ stable/11/sbin/mdconfig/mdconfig.8 Fri Nov 20 10:12:04 2020 (r367870) @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 10, 2015 +.Dd November 6, 2020 .Dt MDCONFIG 8 .Os .Sh NAME @@ -220,7 +220,7 @@ Enable/disable readonly mode. Request a specific unit number or device name for the .Xr md 4 device instead of automatic allocation. -If a device name is specified, it must be start with +If a device name is specified, it must start with .Dq md followed by the unit number. .El @@ -308,11 +308,8 @@ The .Nm utility first appeared in .Fx 5.0 -as a cleaner replacement for the -.Xr vn 4 -and -.Xr vnconfig 8 -combo. +as a cleaner replacement for the vn kernel module +and the vnconfig utility combo. .Sh AUTHORS The .Nm From owner-svn-src-all@freebsd.org Fri Nov 20 10:27:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 07E0A2C4560; Fri, 20 Nov 2020 10:27:55 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cct6L6fJQz4s5d; Fri, 20 Nov 2020 10:27:54 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D6FA814B8F; Fri, 20 Nov 2020 10:27:54 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKARs43051615; Fri, 20 Nov 2020 10:27:54 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKARsau051614; Fri, 20 Nov 2020 10:27:54 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011201027.0AKARsau051614@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Fri, 20 Nov 2020 10:27:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367871 - stable/12/usr.bin/uname X-SVN-Group: stable-12 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/12/usr.bin/uname X-SVN-Commit-Revision: 367871 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 10:27:55 -0000 Author: 0mp (doc,ports committer) Date: Fri Nov 20 10:27:54 2020 New Revision: 367871 URL: https://svnweb.freebsd.org/changeset/base/367871 Log: MFC r367640: Explicitly note in the EXAMPLES section that uname(3) contains more details Modified: stable/12/usr.bin/uname/uname.1 Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/uname/uname.1 ============================================================================== --- stable/12/usr.bin/uname/uname.1 Fri Nov 20 10:12:04 2020 (r367870) +++ stable/12/usr.bin/uname/uname.1 Fri Nov 20 10:27:54 2020 (r367871) @@ -28,7 +28,7 @@ .\" @(#)uname.1 8.3 (Berkeley) 4/8/94 .\" $FreeBSD$ .\" -.Dd May 31, 2017 +.Dd Novermber 13, 2020 .Dt UNAME 1 .Os .Sh NAME @@ -114,6 +114,9 @@ utility (except for .Fl a ) will allow the corresponding data to be set to the contents of the environment variable. +See +.Xr uname 3 +for more information. .Sh EXIT STATUS .Ex -std .Sh EXAMPLES From owner-svn-src-all@freebsd.org Fri Nov 20 10:48:19 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F279F2C4CEF; Fri, 20 Nov 2020 10:48:19 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CctYv6Y1zz4tHL; Fri, 20 Nov 2020 10:48:19 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D3C02149DD; Fri, 20 Nov 2020 10:48:19 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKAmJcG064761; Fri, 20 Nov 2020 10:48:19 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKAmJV4064759; Fri, 20 Nov 2020 10:48:19 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011201048.0AKAmJV4064759@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Fri, 20 Nov 2020 10:48:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r367872 - stable/11/usr.bin/uname X-SVN-Group: stable-11 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/11/usr.bin/uname X-SVN-Commit-Revision: 367872 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 10:48:20 -0000 Author: 0mp (doc,ports committer) Date: Fri Nov 20 10:48:19 2020 New Revision: 367872 URL: https://svnweb.freebsd.org/changeset/base/367872 Log: MFC r367640: Explicitly note in the EXAMPLES section that uname(3) contains more details Modified: stable/11/usr.bin/uname/uname.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/uname/uname.1 ============================================================================== --- stable/11/usr.bin/uname/uname.1 Fri Nov 20 10:27:54 2020 (r367871) +++ stable/11/usr.bin/uname/uname.1 Fri Nov 20 10:48:19 2020 (r367872) @@ -28,7 +28,7 @@ .\" @(#)uname.1 8.3 (Berkeley) 4/8/94 .\" $FreeBSD$ .\" -.Dd May 31, 2017 +.Dd Novermber 13, 2020 .Dt UNAME 1 .Os .Sh NAME @@ -114,6 +114,9 @@ utility (except for .Fl a ) will allow the corresponding data to be set to the contents of the environment variable. +See +.Xr uname 3 +for more information. .Sh EXIT STATUS .Ex -std .Sh EXAMPLES From owner-svn-src-all@freebsd.org Fri Nov 20 11:25:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0FF32C65B9; Fri, 20 Nov 2020 11:25:55 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvPH3QdQz3CD2; Fri, 20 Nov 2020 11:25:55 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63D62155A7; Fri, 20 Nov 2020 11:25:55 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBPtot089444; Fri, 20 Nov 2020 11:25:55 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBPtFk089443; Fri, 20 Nov 2020 11:25:55 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201125.0AKBPtFk089443@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:25:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367873 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 367873 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:25:55 -0000 Author: manu Date: Fri Nov 20 11:25:54 2020 New Revision: 367873 URL: https://svnweb.freebsd.org/changeset/base/367873 Log: if_awg: Remove the taskqueue for miibus_statchg I guess it was added so we can obtain the device lock but we already have it when the function is called. No functional changes intended Modified: head/sys/arm/allwinner/if_awg.c Modified: head/sys/arm/allwinner/if_awg.c ============================================================================== --- head/sys/arm/allwinner/if_awg.c Fri Nov 20 10:48:19 2020 (r367872) +++ head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:25:54 2020 (r367873) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -199,7 +198,6 @@ struct awg_softc { device_t dev; device_t miibus; struct callout stat_ch; - struct task link_task; void *ih; u_int mdc_div_ratio_m; int link; @@ -284,11 +282,14 @@ awg_miibus_writereg(device_t dev, int phy, int reg, in } static void -awg_update_link_locked(struct awg_softc *sc) +awg_miibus_statchg(device_t dev) { + struct awg_softc *sc; struct mii_data *mii; uint32_t val; + sc = device_get_softc(dev); + AWG_ASSERT_LOCKED(sc); if ((if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) == 0) @@ -346,28 +347,6 @@ awg_update_link_locked(struct awg_softc *sc) } static void -awg_link_task(void *arg, int pending) -{ - struct awg_softc *sc; - - sc = arg; - - AWG_LOCK(sc); - awg_update_link_locked(sc); - AWG_UNLOCK(sc); -} - -static void -awg_miibus_statchg(device_t dev) -{ - struct awg_softc *sc; - - sc = device_get_softc(dev); - - taskqueue_enqueue(taskqueue_swi, &sc->link_task); -} - -static void awg_media_status(if_t ifp, struct ifmediareq *ifmr) { struct awg_softc *sc; @@ -1873,7 +1852,6 @@ awg_attach(device_t dev) mtx_init(&sc->mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); callout_init_mtx(&sc->stat_ch, &sc->mtx, 0); - TASK_INIT(&sc->link_task, 0, awg_link_task, sc); /* Setup clocks and regulators */ error = awg_setup_extres(dev); From owner-svn-src-all@freebsd.org Fri Nov 20 11:26:21 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5E9292C65D0; Fri, 20 Nov 2020 11:26:21 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvPn2KHwz3C2w; Fri, 20 Nov 2020 11:26:21 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4230A15782; Fri, 20 Nov 2020 11:26:21 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBQL67089517; Fri, 20 Nov 2020 11:26:21 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBQL7f089516; Fri, 20 Nov 2020 11:26:21 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201126.0AKBQL7f089516@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:26:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367874 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 367874 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:26:21 -0000 Author: manu Date: Fri Nov 20 11:26:20 2020 New Revision: 367874 URL: https://svnweb.freebsd.org/changeset/base/367874 Log: if_awg: Split init code into sub function Be clear of what we enable or init. No functional changes intended Modified: head/sys/arm/allwinner/if_awg.c Modified: head/sys/arm/allwinner/if_awg.c ============================================================================== --- head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:25:54 2020 (r367873) +++ head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:26:20 2020 (r367874) @@ -705,50 +705,55 @@ awg_setup_rxfilter(struct awg_softc *sc) } static void -awg_enable_intr(struct awg_softc *sc) +awg_setup_core(struct awg_softc *sc) { + uint32_t val; + + AWG_ASSERT_LOCKED(sc); + /* Configure DMA burst length and priorities */ + val = awg_burst_len << BASIC_CTL_BURST_LEN_SHIFT; + if (awg_rx_tx_pri) + val |= BASIC_CTL_RX_TX_PRI; + WR4(sc, EMAC_BASIC_CTL_1, val); + + /* Enable transmitter */ + val = RD4(sc, EMAC_TX_CTL_0); + WR4(sc, EMAC_TX_CTL_0, val | TX_EN); + + /* Enable receiver */ + val = RD4(sc, EMAC_RX_CTL_0); + WR4(sc, EMAC_RX_CTL_0, val | RX_EN | CHECK_CRC); +} + +static void +awg_enable_dma_intr(struct awg_softc *sc) +{ /* Enable interrupts */ WR4(sc, EMAC_INT_EN, RX_INT_EN | TX_INT_EN | TX_BUF_UA_INT_EN); } static void -awg_disable_intr(struct awg_softc *sc) +awg_disable_dma_intr(struct awg_softc *sc) { /* Disable interrupts */ WR4(sc, EMAC_INT_EN, 0); } static void -awg_init_locked(struct awg_softc *sc) +awg_init_dma(struct awg_softc *sc) { - struct mii_data *mii; uint32_t val; - if_t ifp; - mii = device_get_softc(sc->miibus); - ifp = sc->ifp; - AWG_ASSERT_LOCKED(sc); - if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) - return; - - awg_setup_rxfilter(sc); - - /* Configure DMA burst length and priorities */ - val = awg_burst_len << BASIC_CTL_BURST_LEN_SHIFT; - if (awg_rx_tx_pri) - val |= BASIC_CTL_RX_TX_PRI; - WR4(sc, EMAC_BASIC_CTL_1, val); - /* Enable interrupts */ #ifdef DEVICE_POLLING - if ((if_getcapenable(ifp) & IFCAP_POLLING) == 0) - awg_enable_intr(sc); + if ((if_getcapenable(sc->ifp) & IFCAP_POLLING) == 0) + awg_enable_dma_intr(sc); else - awg_disable_intr(sc); + awg_disable_dma_intr(sc); #else - awg_enable_intr(sc); + awg_enable_dma_intr(sc); #endif /* Enable transmit DMA */ @@ -758,15 +763,26 @@ awg_init_locked(struct awg_softc *sc) /* Enable receive DMA */ val = RD4(sc, EMAC_RX_CTL_1); WR4(sc, EMAC_RX_CTL_1, val | RX_DMA_EN | RX_MD); +} - /* Enable transmitter */ - val = RD4(sc, EMAC_TX_CTL_0); - WR4(sc, EMAC_TX_CTL_0, val | TX_EN); +static void +awg_init_locked(struct awg_softc *sc) +{ + struct mii_data *mii; + if_t ifp; - /* Enable receiver */ - val = RD4(sc, EMAC_RX_CTL_0); - WR4(sc, EMAC_RX_CTL_0, val | RX_EN | CHECK_CRC); + mii = device_get_softc(sc->miibus); + ifp = sc->ifp; + AWG_ASSERT_LOCKED(sc); + + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) + return; + + awg_setup_rxfilter(sc); + awg_setup_core(sc); + awg_init_dma(sc); + if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); mii_mediachg(mii); @@ -813,7 +829,7 @@ awg_stop(struct awg_softc *sc) WR4(sc, EMAC_RX_CTL_0, val & ~RX_EN); /* Disable interrupts */ - awg_disable_intr(sc); + awg_disable_dma_intr(sc); /* Disable transmit DMA */ val = RD4(sc, EMAC_TX_CTL_1); @@ -1101,13 +1117,13 @@ awg_ioctl(if_t ifp, u_long cmd, caddr_t data) if (error != 0) break; AWG_LOCK(sc); - awg_disable_intr(sc); + awg_disable_dma_intr(sc); if_setcapenablebit(ifp, IFCAP_POLLING, 0); AWG_UNLOCK(sc); } else { error = ether_poll_deregister(ifp); AWG_LOCK(sc); - awg_enable_intr(sc); + awg_enable_dma_intr(sc); if_setcapenablebit(ifp, 0, IFCAP_POLLING); AWG_UNLOCK(sc); } From owner-svn-src-all@freebsd.org Fri Nov 20 11:26:46 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C75232C65E2; Fri, 20 Nov 2020 11:26:46 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvQG4yH9z3C3Y; Fri, 20 Nov 2020 11:26:46 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9D1B215783; Fri, 20 Nov 2020 11:26:46 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBQkuL089578; Fri, 20 Nov 2020 11:26:46 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBQknE089577; Fri, 20 Nov 2020 11:26:46 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201126.0AKBQknE089577@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:26:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367875 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367875 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:26:46 -0000 Author: manu Date: Fri Nov 20 11:26:46 2020 New Revision: 367875 URL: https://svnweb.freebsd.org/changeset/base/367875 Log: if_dwc: Split init code into sub function Be clear of what we enable or init. No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:26:20 2020 (r367874) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:26:46 2020 (r367875) @@ -211,6 +211,8 @@ static void dwc_txfinish_locked(struct dwc_softc *sc); static void dwc_rxfinish_locked(struct dwc_softc *sc); static void dwc_stop_locked(struct dwc_softc *sc); static void dwc_setup_rxfilter(struct dwc_softc *sc); +static void dwc_setup_core(struct dwc_softc *sc); +static void dwc_init_dma(struct dwc_softc *sc); static inline uint32_t next_rxidx(struct dwc_softc *sc, uint32_t curidx) @@ -473,7 +475,6 @@ static void dwc_init_locked(struct dwc_softc *sc) { struct ifnet *ifp = sc->ifp; - uint32_t reg; DWC_ASSERT_LOCKED(sc); @@ -483,27 +484,9 @@ dwc_init_locked(struct dwc_softc *sc) ifp->if_drv_flags |= IFF_DRV_RUNNING; dwc_setup_rxfilter(sc); + dwc_setup_core(sc); + dwc_init_dma(sc); - /* Initializa DMA and enable transmitters */ - reg = READ4(sc, OPERATION_MODE); - reg |= (MODE_TSF | MODE_OSF | MODE_FUF); - reg &= ~(MODE_RSF); - reg |= (MODE_RTC_LEV32 << MODE_RTC_SHIFT); - WRITE4(sc, OPERATION_MODE, reg); - - WRITE4(sc, INTERRUPT_ENABLE, INT_EN_DEFAULT); - - /* Start DMA */ - reg = READ4(sc, OPERATION_MODE); - reg |= (MODE_ST | MODE_SR); - WRITE4(sc, OPERATION_MODE, reg); - - /* Enable transmitters */ - reg = READ4(sc, MAC_CONFIGURATION); - reg |= (CONF_JD | CONF_ACS | CONF_BE); - reg |= (CONF_TE | CONF_RE); - WRITE4(sc, MAC_CONFIGURATION, reg); - /* * Call mii_mediachg() which will call back into dwc_miibus_statchg() * to set up the remaining config registers based on current media. @@ -786,6 +769,42 @@ dwc_setup_rxfilter(struct dwc_softc *sc) for (i = 0; i < nhash; i++) WRITE4(sc, HASH_TABLE_REG(i), ctx.hash[i]); } +} + +static void +dwc_setup_core(struct dwc_softc *sc) +{ + uint32_t reg; + + DWC_ASSERT_LOCKED(sc); + + /* Enable transmitters */ + reg = READ4(sc, MAC_CONFIGURATION); + reg |= (CONF_JD | CONF_ACS | CONF_BE); + reg |= (CONF_TE | CONF_RE); + WRITE4(sc, MAC_CONFIGURATION, reg); +} + +static void +dwc_init_dma(struct dwc_softc *sc) +{ + uint32_t reg; + + DWC_ASSERT_LOCKED(sc); + + /* Initializa DMA and enable transmitters */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_TSF | MODE_OSF | MODE_FUF); + reg &= ~(MODE_RSF); + reg |= (MODE_RTC_LEV32 << MODE_RTC_SHIFT); + WRITE4(sc, OPERATION_MODE, reg); + + WRITE4(sc, INTERRUPT_ENABLE, INT_EN_DEFAULT); + + /* Start DMA */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_ST | MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); } static int From owner-svn-src-all@freebsd.org Fri Nov 20 11:27:08 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A332E2C680A; Fri, 20 Nov 2020 11:27:08 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvQh4FBpz3CYZ; Fri, 20 Nov 2020 11:27:08 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 84D591537E; Fri, 20 Nov 2020 11:27:08 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBR8wB089642; Fri, 20 Nov 2020 11:27:08 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBR8LG089641; Fri, 20 Nov 2020 11:27:08 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201127.0AKBR8LG089641@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:27:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367876 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367876 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:27:08 -0000 Author: manu Date: Fri Nov 20 11:27:08 2020 New Revision: 367876 URL: https://svnweb.freebsd.org/changeset/base/367876 Log: if_dwc: Use if_setdrvflagbits to notify that we are running No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:26:46 2020 (r367875) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:27:08 2020 (r367876) @@ -481,11 +481,11 @@ dwc_init_locked(struct dwc_softc *sc) if (ifp->if_drv_flags & IFF_DRV_RUNNING) return; - ifp->if_drv_flags |= IFF_DRV_RUNNING; - dwc_setup_rxfilter(sc); dwc_setup_core(sc); dwc_init_dma(sc); + + if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); /* * Call mii_mediachg() which will call back into dwc_miibus_statchg() From owner-svn-src-all@freebsd.org Fri Nov 20 11:27:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 395F02C6472; Fri, 20 Nov 2020 11:27:27 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvR319LSz3CqF; Fri, 20 Nov 2020 11:27:27 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1B45A1537F; Fri, 20 Nov 2020 11:27:27 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBRQw2089701; Fri, 20 Nov 2020 11:27:26 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBRQr4089700; Fri, 20 Nov 2020 11:27:26 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201127.0AKBRQr4089700@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:27:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367877 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 367877 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:27:27 -0000 Author: manu Date: Fri Nov 20 11:27:26 2020 New Revision: 367877 URL: https://svnweb.freebsd.org/changeset/base/367877 Log: if_awg: Add a function to enable/disable the mac tx/rx No functional changes intended Modified: head/sys/arm/allwinner/if_awg.c Modified: head/sys/arm/allwinner/if_awg.c ============================================================================== --- head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:27:08 2020 (r367876) +++ head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:27:26 2020 (r367877) @@ -716,15 +716,30 @@ awg_setup_core(struct awg_softc *sc) val |= BASIC_CTL_RX_TX_PRI; WR4(sc, EMAC_BASIC_CTL_1, val); - /* Enable transmitter */ - val = RD4(sc, EMAC_TX_CTL_0); - WR4(sc, EMAC_TX_CTL_0, val | TX_EN); +} - /* Enable receiver */ - val = RD4(sc, EMAC_RX_CTL_0); - WR4(sc, EMAC_RX_CTL_0, val | RX_EN | CHECK_CRC); +static void +awg_enable_mac(struct awg_softc *sc, bool enable) +{ + uint32_t tx, rx; + + AWG_ASSERT_LOCKED(sc); + + tx = RD4(sc, EMAC_TX_CTL_0); + rx = RD4(sc, EMAC_RX_CTL_0); + if (enable) { + tx |= TX_EN; + rx |= RX_EN | CHECK_CRC; + } else { + tx &= ~TX_EN; + rx &= ~(RX_EN | CHECK_CRC); + } + + WR4(sc, EMAC_TX_CTL_0, tx); + WR4(sc, EMAC_RX_CTL_0, rx); } + static void awg_enable_dma_intr(struct awg_softc *sc) { @@ -781,6 +796,7 @@ awg_init_locked(struct awg_softc *sc) awg_setup_rxfilter(sc); awg_setup_core(sc); + awg_enable_mac(sc, true); awg_init_dma(sc); if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); @@ -820,13 +836,7 @@ awg_stop(struct awg_softc *sc) val |= FLUSH_TX_FIFO; WR4(sc, EMAC_TX_CTL_1, val); - /* Disable transmitter */ - val = RD4(sc, EMAC_TX_CTL_0); - WR4(sc, EMAC_TX_CTL_0, val & ~TX_EN); - - /* Disable receiver */ - val = RD4(sc, EMAC_RX_CTL_0); - WR4(sc, EMAC_RX_CTL_0, val & ~RX_EN); + awg_enable_mac(sc, false); /* Disable interrupts */ awg_disable_dma_intr(sc); From owner-svn-src-all@freebsd.org Fri Nov 20 11:27:44 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 42AE02C67C1; Fri, 20 Nov 2020 11:27:44 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvRN1VVLz3Cs3; Fri, 20 Nov 2020 11:27:44 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2651315784; Fri, 20 Nov 2020 11:27:44 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBRik1089766; Fri, 20 Nov 2020 11:27:44 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBRito089765; Fri, 20 Nov 2020 11:27:44 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201127.0AKBRito089765@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:27:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367878 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367878 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:27:44 -0000 Author: manu Date: Fri Nov 20 11:27:43 2020 New Revision: 367878 URL: https://svnweb.freebsd.org/changeset/base/367878 Log: if_dwc: Add a function to enable/disable the mac tx/rx No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:27:26 2020 (r367877) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:27:43 2020 (r367878) @@ -212,6 +212,7 @@ static void dwc_rxfinish_locked(struct dwc_softc *sc); static void dwc_stop_locked(struct dwc_softc *sc); static void dwc_setup_rxfilter(struct dwc_softc *sc); static void dwc_setup_core(struct dwc_softc *sc); +static void dwc_enable_mac(struct dwc_softc *sc, bool enable); static void dwc_init_dma(struct dwc_softc *sc); static inline uint32_t @@ -483,6 +484,7 @@ dwc_init_locked(struct dwc_softc *sc) dwc_setup_rxfilter(sc); dwc_setup_core(sc); + dwc_enable_mac(sc, true); dwc_init_dma(sc); if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); @@ -778,10 +780,23 @@ dwc_setup_core(struct dwc_softc *sc) DWC_ASSERT_LOCKED(sc); - /* Enable transmitters */ + /* Enable core */ reg = READ4(sc, MAC_CONFIGURATION); reg |= (CONF_JD | CONF_ACS | CONF_BE); - reg |= (CONF_TE | CONF_RE); + WRITE4(sc, MAC_CONFIGURATION, reg); +} + +static void +dwc_enable_mac(struct dwc_softc *sc, bool enable) +{ + uint32_t reg; + + DWC_ASSERT_LOCKED(sc); + reg = READ4(sc, MAC_CONFIGURATION); + if (enable) + reg |= CONF_TE | CONF_RE; + else + reg &= ~(CONF_TE | CONF_RE); WRITE4(sc, MAC_CONFIGURATION, reg); } From owner-svn-src-all@freebsd.org Fri Nov 20 11:28:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93A782C6A34; Fri, 20 Nov 2020 11:28:06 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvRp3V1yz3D3f; Fri, 20 Nov 2020 11:28:06 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6AA3C15785; Fri, 20 Nov 2020 11:28:06 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBS6xS089829; Fri, 20 Nov 2020 11:28:06 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBS65v089828; Fri, 20 Nov 2020 11:28:06 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201128.0AKBS65v089828@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:28:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367879 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367879 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:28:06 -0000 Author: manu Date: Fri Nov 20 11:28:06 2020 New Revision: 367879 URL: https://svnweb.freebsd.org/changeset/base/367879 Log: if_dwc: Use dwc_enable_mac in dwc_stop_locked No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:27:43 2020 (r367878) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:28:06 2020 (r367879) @@ -380,10 +380,7 @@ dwc_stop_locked(struct dwc_softc *sc) reg |= (MODE_FTF); WRITE4(sc, OPERATION_MODE, reg); - /* Stop transmitters */ - reg = READ4(sc, MAC_CONFIGURATION); - reg &= ~(CONF_TE | CONF_RE); - WRITE4(sc, MAC_CONFIGURATION, reg); + dwc_enable_mac(sc, false); /* Stop DMA RX */ reg = READ4(sc, OPERATION_MODE); From owner-svn-src-all@freebsd.org Fri Nov 20 11:28:23 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C93AB2C67F0; Fri, 20 Nov 2020 11:28:23 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvS75P4Fz3D4d; Fri, 20 Nov 2020 11:28:23 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABD34150EA; Fri, 20 Nov 2020 11:28:23 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBSN00089882; Fri, 20 Nov 2020 11:28:23 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBSNdD089881; Fri, 20 Nov 2020 11:28:23 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201128.0AKBSNdD089881@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367880 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 367880 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:28:23 -0000 Author: manu Date: Fri Nov 20 11:28:23 2020 New Revision: 367880 URL: https://svnweb.freebsd.org/changeset/base/367880 Log: if_awg: Add awg_stop_dma and use it in awg_stop No functional changes intended Modified: head/sys/arm/allwinner/if_awg.c Modified: head/sys/arm/allwinner/if_awg.c ============================================================================== --- head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:28:06 2020 (r367879) +++ head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:28:23 2020 (r367880) @@ -781,6 +781,31 @@ awg_init_dma(struct awg_softc *sc) } static void +awg_stop_dma(struct awg_softc *sc) +{ + uint32_t val; + + AWG_ASSERT_LOCKED(sc); + + /* Stop transmit DMA and flush data in the TX FIFO */ + val = RD4(sc, EMAC_TX_CTL_1); + val &= ~TX_DMA_EN; + val |= FLUSH_TX_FIFO; + WR4(sc, EMAC_TX_CTL_1, val); + + /* Disable interrupts */ + awg_disable_dma_intr(sc); + + /* Disable transmit DMA */ + val = RD4(sc, EMAC_TX_CTL_1); + WR4(sc, EMAC_TX_CTL_1, val & ~TX_DMA_EN); + + /* Disable receive DMA */ + val = RD4(sc, EMAC_RX_CTL_1); + WR4(sc, EMAC_RX_CTL_1, val & ~RX_DMA_EN); +} + +static void awg_init_locked(struct awg_softc *sc) { struct mii_data *mii; @@ -830,24 +855,8 @@ awg_stop(struct awg_softc *sc) callout_stop(&sc->stat_ch); - /* Stop transmit DMA and flush data in the TX FIFO */ - val = RD4(sc, EMAC_TX_CTL_1); - val &= ~TX_DMA_EN; - val |= FLUSH_TX_FIFO; - WR4(sc, EMAC_TX_CTL_1, val); - + awg_stop_dma(sc); awg_enable_mac(sc, false); - - /* Disable interrupts */ - awg_disable_dma_intr(sc); - - /* Disable transmit DMA */ - val = RD4(sc, EMAC_TX_CTL_1); - WR4(sc, EMAC_TX_CTL_1, val & ~TX_DMA_EN); - - /* Disable receive DMA */ - val = RD4(sc, EMAC_RX_CTL_1); - WR4(sc, EMAC_RX_CTL_1, val & ~RX_DMA_EN); sc->link = 0; From owner-svn-src-all@freebsd.org Fri Nov 20 11:29:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A5FB2C6879; Fri, 20 Nov 2020 11:29:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvSs2f7bz3DNW; Fri, 20 Nov 2020 11:29:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4DE6A15708; Fri, 20 Nov 2020 11:29:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBT1rp089954; Fri, 20 Nov 2020 11:29:01 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBT1oE089953; Fri, 20 Nov 2020 11:29:01 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201129.0AKBT1oE089953@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:29:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367881 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367881 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:29:01 -0000 Author: manu Date: Fri Nov 20 11:29:00 2020 New Revision: 367881 URL: https://svnweb.freebsd.org/changeset/base/367881 Log: if_dwc: Add dwc_stop_dma and use it in dwc_stop_locked No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:28:23 2020 (r367880) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:29:00 2020 (r367881) @@ -214,6 +214,7 @@ static void dwc_setup_rxfilter(struct dwc_softc *sc); static void dwc_setup_core(struct dwc_softc *sc); static void dwc_enable_mac(struct dwc_softc *sc, bool enable); static void dwc_init_dma(struct dwc_softc *sc); +static void dwc_stop_dma(struct dwc_softc *sc); static inline uint32_t next_rxidx(struct dwc_softc *sc, uint32_t curidx) @@ -359,7 +360,6 @@ static void dwc_stop_locked(struct dwc_softc *sc) { struct ifnet *ifp; - uint32_t reg; DWC_ASSERT_LOCKED(sc); @@ -370,22 +370,8 @@ dwc_stop_locked(struct dwc_softc *sc) callout_stop(&sc->dwc_callout); - /* Stop DMA TX */ - reg = READ4(sc, OPERATION_MODE); - reg &= ~(MODE_ST); - WRITE4(sc, OPERATION_MODE, reg); - - /* Flush TX */ - reg = READ4(sc, OPERATION_MODE); - reg |= (MODE_FTF); - WRITE4(sc, OPERATION_MODE, reg); - + dwc_stop_dma(sc); dwc_enable_mac(sc, false); - - /* Stop DMA RX */ - reg = READ4(sc, OPERATION_MODE); - reg &= ~(MODE_SR); - WRITE4(sc, OPERATION_MODE, reg); } static void dwc_clear_stats(struct dwc_softc *sc) @@ -816,6 +802,29 @@ dwc_init_dma(struct dwc_softc *sc) /* Start DMA */ reg = READ4(sc, OPERATION_MODE); reg |= (MODE_ST | MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); +} + +static void +dwc_stop_dma(struct dwc_softc *sc) +{ + uint32_t reg; + + DWC_ASSERT_LOCKED(sc); + + /* Stop DMA TX */ + reg = READ4(sc, OPERATION_MODE); + reg &= ~(MODE_ST); + WRITE4(sc, OPERATION_MODE, reg); + + /* Flush TX */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_FTF); + WRITE4(sc, OPERATION_MODE, reg); + + /* Stop DMA RX */ + reg = READ4(sc, OPERATION_MODE); + reg &= ~(MODE_SR); WRITE4(sc, OPERATION_MODE, reg); } From owner-svn-src-all@freebsd.org Fri Nov 20 11:29:21 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 24E652C69D8; Fri, 20 Nov 2020 11:29:21 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvTF0G7xz3DGk; Fri, 20 Nov 2020 11:29:21 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F070415709; Fri, 20 Nov 2020 11:29:20 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBTK10090010; Fri, 20 Nov 2020 11:29:20 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBTKRI090009; Fri, 20 Nov 2020 11:29:20 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201129.0AKBTKRI090009@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:29:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367882 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367882 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:29:21 -0000 Author: manu Date: Fri Nov 20 11:29:20 2020 New Revision: 367882 URL: https://svnweb.freebsd.org/changeset/base/367882 Log: if_dwc: dwc_get_hwaddr cannot fail, change return to void No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:29:00 2020 (r367881) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:29:20 2020 (r367882) @@ -1153,7 +1153,7 @@ out: return (0); } -static int +static void dwc_get_hwaddr(struct dwc_softc *sc, uint8_t *hwaddr) { uint32_t hi, lo, rnd; @@ -1185,8 +1185,6 @@ dwc_get_hwaddr(struct dwc_softc *sc, uint8_t *hwaddr) hwaddr[4] = rnd >> 8; hwaddr[5] = rnd >> 0; } - - return (0); } #define GPIO_ACTIVE_LOW 1 @@ -1336,10 +1334,7 @@ dwc_attach(device_t dev) } /* Read MAC before reset */ - if (dwc_get_hwaddr(sc, macaddr)) { - device_printf(sc->dev, "can't get mac\n"); - return (ENXIO); - } + dwc_get_hwaddr(sc, macaddr); /* Reset the PHY if needed */ if (dwc_reset(dev) != 0) { From owner-svn-src-all@freebsd.org Fri Nov 20 11:29:38 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1360A2C6B99; Fri, 20 Nov 2020 11:29:38 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvTZ0512z3DKk; Fri, 20 Nov 2020 11:29:38 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DF352156F1; Fri, 20 Nov 2020 11:29:37 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBTbQN090069; Fri, 20 Nov 2020 11:29:37 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBTbbo090068; Fri, 20 Nov 2020 11:29:37 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201129.0AKBTbbo090068@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:29:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367883 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 367883 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:29:38 -0000 Author: manu Date: Fri Nov 20 11:29:37 2020 New Revision: 367883 URL: https://svnweb.freebsd.org/changeset/base/367883 Log: if_awg: Reorder functions and sort them by usage No functional changes intended Modified: head/sys/arm/allwinner/if_awg.c Modified: head/sys/arm/allwinner/if_awg.c ============================================================================== --- head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:29:20 2020 (r367882) +++ head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:29:37 2020 (r367883) @@ -217,7 +217,10 @@ static struct resource_spec awg_spec[] = { }; static void awg_txeof(struct awg_softc *sc); +static void awg_start_locked(struct awg_softc *sc); +static void awg_tick(void *softc); + static int awg_parse_delay(device_t dev, uint32_t *tx_delay, uint32_t *rx_delay); static uint32_t syscon_read_emac_clk_reg(device_t dev); @@ -225,6 +228,10 @@ static void syscon_write_emac_clk_reg(device_t dev, ui static phandle_t awg_get_phy_node(device_t dev); static bool awg_has_internal_phy(device_t dev); +/* + * MII functions + */ + static int awg_miibus_readreg(device_t dev, int phy, int reg) { @@ -346,6 +353,10 @@ awg_miibus_statchg(device_t dev) WR4(sc, EMAC_TX_FLOW_CTL, val); } +/* + * Media functions + */ + static void awg_media_status(if_t ifp, struct ifmediareq *ifmr) { @@ -379,6 +390,217 @@ awg_media_change(if_t ifp) return (error); } +/* + * Core functions + */ + +/* Bit Reversal - http://aggregate.org/MAGIC/#Bit%20Reversal */ +static uint32_t +bitrev32(uint32_t x) +{ + x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); + x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); + x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); + x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); + + return (x >> 16) | (x << 16); +} + +static u_int +awg_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t crc, hashreg, hashbit, *hash = arg; + + crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0x7f; + crc = bitrev32(~crc) >> 26; + hashreg = (crc >> 5); + hashbit = (crc & 0x1f); + hash[hashreg] |= (1 << hashbit); + + return (1); +} + +static void +awg_setup_rxfilter(struct awg_softc *sc) +{ + uint32_t val, hash[2], machi, maclo; + uint8_t *eaddr; + if_t ifp; + + AWG_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + val = 0; + hash[0] = hash[1] = 0; + + if (if_getflags(ifp) & IFF_PROMISC) + val |= DIS_ADDR_FILTER; + else if (if_getflags(ifp) & IFF_ALLMULTI) { + val |= RX_ALL_MULTICAST; + hash[0] = hash[1] = ~0; + } else if (if_foreach_llmaddr(ifp, awg_hash_maddr, hash) > 0) + val |= HASH_MULTICAST; + + /* Write our unicast address */ + eaddr = IF_LLADDR(ifp); + machi = (eaddr[5] << 8) | eaddr[4]; + maclo = (eaddr[3] << 24) | (eaddr[2] << 16) | (eaddr[1] << 8) | + (eaddr[0] << 0); + WR4(sc, EMAC_ADDR_HIGH(0), machi); + WR4(sc, EMAC_ADDR_LOW(0), maclo); + + /* Multicast hash filters */ + WR4(sc, EMAC_RX_HASH_0, hash[1]); + WR4(sc, EMAC_RX_HASH_1, hash[0]); + + /* RX frame filter config */ + WR4(sc, EMAC_RX_FRM_FLT, val); +} + +static void +awg_setup_core(struct awg_softc *sc) +{ + uint32_t val; + + AWG_ASSERT_LOCKED(sc); + /* Configure DMA burst length and priorities */ + val = awg_burst_len << BASIC_CTL_BURST_LEN_SHIFT; + if (awg_rx_tx_pri) + val |= BASIC_CTL_RX_TX_PRI; + WR4(sc, EMAC_BASIC_CTL_1, val); + +} + +static void +awg_enable_mac(struct awg_softc *sc, bool enable) +{ + uint32_t tx, rx; + + AWG_ASSERT_LOCKED(sc); + + tx = RD4(sc, EMAC_TX_CTL_0); + rx = RD4(sc, EMAC_RX_CTL_0); + if (enable) { + tx |= TX_EN; + rx |= RX_EN | CHECK_CRC; + } else { + tx &= ~TX_EN; + rx &= ~(RX_EN | CHECK_CRC); + } + + WR4(sc, EMAC_TX_CTL_0, tx); + WR4(sc, EMAC_RX_CTL_0, rx); +} + +static void +awg_get_eaddr(device_t dev, uint8_t *eaddr) +{ + struct awg_softc *sc; + uint32_t maclo, machi, rnd; + u_char rootkey[16]; + uint32_t rootkey_size; + + sc = device_get_softc(dev); + + machi = RD4(sc, EMAC_ADDR_HIGH(0)) & 0xffff; + maclo = RD4(sc, EMAC_ADDR_LOW(0)); + + rootkey_size = sizeof(rootkey); + if (maclo == 0xffffffff && machi == 0xffff) { + /* MAC address in hardware is invalid, create one */ + if (aw_sid_get_fuse(AW_SID_FUSE_ROOTKEY, rootkey, + &rootkey_size) == 0 && + (rootkey[3] | rootkey[12] | rootkey[13] | rootkey[14] | + rootkey[15]) != 0) { + /* MAC address is derived from the root key in SID */ + maclo = (rootkey[13] << 24) | (rootkey[12] << 16) | + (rootkey[3] << 8) | 0x02; + machi = (rootkey[15] << 8) | rootkey[14]; + } else { + /* Create one */ + rnd = arc4random(); + maclo = 0x00f2 | (rnd & 0xffff0000); + machi = rnd & 0xffff; + } + } + + eaddr[0] = maclo & 0xff; + eaddr[1] = (maclo >> 8) & 0xff; + eaddr[2] = (maclo >> 16) & 0xff; + eaddr[3] = (maclo >> 24) & 0xff; + eaddr[4] = machi & 0xff; + eaddr[5] = (machi >> 8) & 0xff; +} + +/* + * DMA functions + */ + +static void +awg_enable_dma_intr(struct awg_softc *sc) +{ + /* Enable interrupts */ + WR4(sc, EMAC_INT_EN, RX_INT_EN | TX_INT_EN | TX_BUF_UA_INT_EN); +} + +static void +awg_disable_dma_intr(struct awg_softc *sc) +{ + /* Disable interrupts */ + WR4(sc, EMAC_INT_EN, 0); +} + +static void +awg_init_dma(struct awg_softc *sc) +{ + uint32_t val; + + AWG_ASSERT_LOCKED(sc); + + /* Enable interrupts */ +#ifdef DEVICE_POLLING + if ((if_getcapenable(sc->ifp) & IFCAP_POLLING) == 0) + awg_enable_dma_intr(sc); + else + awg_disable_dma_intr(sc); +#else + awg_enable_dma_intr(sc); +#endif + + /* Enable transmit DMA */ + val = RD4(sc, EMAC_TX_CTL_1); + WR4(sc, EMAC_TX_CTL_1, val | TX_DMA_EN | TX_MD | TX_NEXT_FRAME); + + /* Enable receive DMA */ + val = RD4(sc, EMAC_RX_CTL_1); + WR4(sc, EMAC_RX_CTL_1, val | RX_DMA_EN | RX_MD); +} + +static void +awg_stop_dma(struct awg_softc *sc) +{ + uint32_t val; + + AWG_ASSERT_LOCKED(sc); + + /* Stop transmit DMA and flush data in the TX FIFO */ + val = RD4(sc, EMAC_TX_CTL_1); + val &= ~TX_DMA_EN; + val |= FLUSH_TX_FIFO; + WR4(sc, EMAC_TX_CTL_1, val); + + /* Disable interrupts */ + awg_disable_dma_intr(sc); + + /* Disable transmit DMA */ + val = RD4(sc, EMAC_TX_CTL_1); + WR4(sc, EMAC_TX_CTL_1, val & ~TX_DMA_EN); + + /* Disable receive DMA */ + val = RD4(sc, EMAC_RX_CTL_1); + WR4(sc, EMAC_RX_CTL_1, val & ~RX_DMA_EN); +} + static int awg_encap(struct awg_softc *sc, struct mbuf **mp) { @@ -560,6 +782,170 @@ awg_newbuf_rx(struct awg_softc *sc, int index) } static void +awg_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) +{ + if (error != 0) + return; + *(bus_addr_t *)arg = segs[0].ds_addr; +} + +static int +awg_setup_dma(device_t dev) +{ + struct awg_softc *sc; + int error, i; + + sc = device_get_softc(dev); + + /* Setup TX ring */ + error = bus_dma_tag_create( + bus_get_dma_tag(dev), /* Parent tag */ + DESC_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + TX_DESC_SIZE, 1, /* maxsize, nsegs */ + TX_DESC_SIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->tx.desc_tag); + if (error != 0) { + device_printf(dev, "cannot create TX descriptor ring tag\n"); + return (error); + } + + error = bus_dmamem_alloc(sc->tx.desc_tag, (void **)&sc->tx.desc_ring, + BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->tx.desc_map); + if (error != 0) { + device_printf(dev, "cannot allocate TX descriptor ring\n"); + return (error); + } + + error = bus_dmamap_load(sc->tx.desc_tag, sc->tx.desc_map, + sc->tx.desc_ring, TX_DESC_SIZE, awg_dmamap_cb, + &sc->tx.desc_ring_paddr, 0); + if (error != 0) { + device_printf(dev, "cannot load TX descriptor ring\n"); + return (error); + } + + for (i = 0; i < TX_DESC_COUNT; i++) + sc->tx.desc_ring[i].next = + htole32(sc->tx.desc_ring_paddr + DESC_OFF(TX_NEXT(i))); + + error = bus_dma_tag_create( + bus_get_dma_tag(dev), /* Parent tag */ + 1, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MCLBYTES, TX_MAX_SEGS, /* maxsize, nsegs */ + MCLBYTES, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->tx.buf_tag); + if (error != 0) { + device_printf(dev, "cannot create TX buffer tag\n"); + return (error); + } + + sc->tx.queued = 0; + for (i = 0; i < TX_DESC_COUNT; i++) { + error = bus_dmamap_create(sc->tx.buf_tag, 0, + &sc->tx.buf_map[i].map); + if (error != 0) { + device_printf(dev, "cannot create TX buffer map\n"); + return (error); + } + } + + /* Setup RX ring */ + error = bus_dma_tag_create( + bus_get_dma_tag(dev), /* Parent tag */ + DESC_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + RX_DESC_SIZE, 1, /* maxsize, nsegs */ + RX_DESC_SIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->rx.desc_tag); + if (error != 0) { + device_printf(dev, "cannot create RX descriptor ring tag\n"); + return (error); + } + + error = bus_dmamem_alloc(sc->rx.desc_tag, (void **)&sc->rx.desc_ring, + BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->rx.desc_map); + if (error != 0) { + device_printf(dev, "cannot allocate RX descriptor ring\n"); + return (error); + } + + error = bus_dmamap_load(sc->rx.desc_tag, sc->rx.desc_map, + sc->rx.desc_ring, RX_DESC_SIZE, awg_dmamap_cb, + &sc->rx.desc_ring_paddr, 0); + if (error != 0) { + device_printf(dev, "cannot load RX descriptor ring\n"); + return (error); + } + + error = bus_dma_tag_create( + bus_get_dma_tag(dev), /* Parent tag */ + 1, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MCLBYTES, 1, /* maxsize, nsegs */ + MCLBYTES, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->rx.buf_tag); + if (error != 0) { + device_printf(dev, "cannot create RX buffer tag\n"); + return (error); + } + + error = bus_dmamap_create(sc->rx.buf_tag, 0, &sc->rx.buf_spare_map); + if (error != 0) { + device_printf(dev, + "cannot create RX buffer spare map\n"); + return (error); + } + + for (i = 0; i < RX_DESC_COUNT; i++) { + sc->rx.desc_ring[i].next = + htole32(sc->rx.desc_ring_paddr + DESC_OFF(RX_NEXT(i))); + + error = bus_dmamap_create(sc->rx.buf_tag, 0, + &sc->rx.buf_map[i].map); + if (error != 0) { + device_printf(dev, "cannot create RX buffer map\n"); + return (error); + } + sc->rx.buf_map[i].mbuf = NULL; + error = awg_newbuf_rx(sc, i); + if (error != 0) { + device_printf(dev, "cannot create RX buffer\n"); + return (error); + } + } + bus_dmamap_sync(sc->rx.desc_tag, sc->rx.desc_map, + BUS_DMASYNC_PREWRITE); + + /* Write transmit and receive descriptor base address registers */ + WR4(sc, EMAC_TX_DMA_LIST, sc->tx.desc_ring_paddr); + WR4(sc, EMAC_RX_DMA_LIST, sc->rx.desc_ring_paddr); + + return (0); +} + +/* + * if_ functions + */ + +static void awg_start_locked(struct awg_softc *sc) { struct mbuf *m; @@ -617,195 +1003,6 @@ awg_start(if_t ifp) } static void -awg_tick(void *softc) -{ - struct awg_softc *sc; - struct mii_data *mii; - if_t ifp; - int link; - - sc = softc; - ifp = sc->ifp; - mii = device_get_softc(sc->miibus); - - AWG_ASSERT_LOCKED(sc); - - if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) - return; - - link = sc->link; - mii_tick(mii); - if (sc->link && !link) - awg_start_locked(sc); - - callout_reset(&sc->stat_ch, hz, awg_tick, sc); -} - -/* Bit Reversal - http://aggregate.org/MAGIC/#Bit%20Reversal */ -static uint32_t -bitrev32(uint32_t x) -{ - x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); - x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); - x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); - x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); - - return (x >> 16) | (x << 16); -} - -static u_int -awg_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) -{ - uint32_t crc, hashreg, hashbit, *hash = arg; - - crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0x7f; - crc = bitrev32(~crc) >> 26; - hashreg = (crc >> 5); - hashbit = (crc & 0x1f); - hash[hashreg] |= (1 << hashbit); - - return (1); -} - -static void -awg_setup_rxfilter(struct awg_softc *sc) -{ - uint32_t val, hash[2], machi, maclo; - uint8_t *eaddr; - if_t ifp; - - AWG_ASSERT_LOCKED(sc); - - ifp = sc->ifp; - val = 0; - hash[0] = hash[1] = 0; - - if (if_getflags(ifp) & IFF_PROMISC) - val |= DIS_ADDR_FILTER; - else if (if_getflags(ifp) & IFF_ALLMULTI) { - val |= RX_ALL_MULTICAST; - hash[0] = hash[1] = ~0; - } else if (if_foreach_llmaddr(ifp, awg_hash_maddr, hash) > 0) - val |= HASH_MULTICAST; - - /* Write our unicast address */ - eaddr = IF_LLADDR(ifp); - machi = (eaddr[5] << 8) | eaddr[4]; - maclo = (eaddr[3] << 24) | (eaddr[2] << 16) | (eaddr[1] << 8) | - (eaddr[0] << 0); - WR4(sc, EMAC_ADDR_HIGH(0), machi); - WR4(sc, EMAC_ADDR_LOW(0), maclo); - - /* Multicast hash filters */ - WR4(sc, EMAC_RX_HASH_0, hash[1]); - WR4(sc, EMAC_RX_HASH_1, hash[0]); - - /* RX frame filter config */ - WR4(sc, EMAC_RX_FRM_FLT, val); -} - -static void -awg_setup_core(struct awg_softc *sc) -{ - uint32_t val; - - AWG_ASSERT_LOCKED(sc); - /* Configure DMA burst length and priorities */ - val = awg_burst_len << BASIC_CTL_BURST_LEN_SHIFT; - if (awg_rx_tx_pri) - val |= BASIC_CTL_RX_TX_PRI; - WR4(sc, EMAC_BASIC_CTL_1, val); - -} - -static void -awg_enable_mac(struct awg_softc *sc, bool enable) -{ - uint32_t tx, rx; - - AWG_ASSERT_LOCKED(sc); - - tx = RD4(sc, EMAC_TX_CTL_0); - rx = RD4(sc, EMAC_RX_CTL_0); - if (enable) { - tx |= TX_EN; - rx |= RX_EN | CHECK_CRC; - } else { - tx &= ~TX_EN; - rx &= ~(RX_EN | CHECK_CRC); - } - - WR4(sc, EMAC_TX_CTL_0, tx); - WR4(sc, EMAC_RX_CTL_0, rx); -} - - -static void -awg_enable_dma_intr(struct awg_softc *sc) -{ - /* Enable interrupts */ - WR4(sc, EMAC_INT_EN, RX_INT_EN | TX_INT_EN | TX_BUF_UA_INT_EN); -} - -static void -awg_disable_dma_intr(struct awg_softc *sc) -{ - /* Disable interrupts */ - WR4(sc, EMAC_INT_EN, 0); -} - -static void -awg_init_dma(struct awg_softc *sc) -{ - uint32_t val; - - AWG_ASSERT_LOCKED(sc); - - /* Enable interrupts */ -#ifdef DEVICE_POLLING - if ((if_getcapenable(sc->ifp) & IFCAP_POLLING) == 0) - awg_enable_dma_intr(sc); - else - awg_disable_dma_intr(sc); -#else - awg_enable_dma_intr(sc); -#endif - - /* Enable transmit DMA */ - val = RD4(sc, EMAC_TX_CTL_1); - WR4(sc, EMAC_TX_CTL_1, val | TX_DMA_EN | TX_MD | TX_NEXT_FRAME); - - /* Enable receive DMA */ - val = RD4(sc, EMAC_RX_CTL_1); - WR4(sc, EMAC_RX_CTL_1, val | RX_DMA_EN | RX_MD); -} - -static void -awg_stop_dma(struct awg_softc *sc) -{ - uint32_t val; - - AWG_ASSERT_LOCKED(sc); - - /* Stop transmit DMA and flush data in the TX FIFO */ - val = RD4(sc, EMAC_TX_CTL_1); - val &= ~TX_DMA_EN; - val |= FLUSH_TX_FIFO; - WR4(sc, EMAC_TX_CTL_1, val); - - /* Disable interrupts */ - awg_disable_dma_intr(sc); - - /* Disable transmit DMA */ - val = RD4(sc, EMAC_TX_CTL_1); - WR4(sc, EMAC_TX_CTL_1, val & ~TX_DMA_EN); - - /* Disable receive DMA */ - val = RD4(sc, EMAC_RX_CTL_1); - WR4(sc, EMAC_RX_CTL_1, val & ~RX_DMA_EN); -} - -static void awg_init_locked(struct awg_softc *sc) { struct mii_data *mii; @@ -897,6 +1094,92 @@ awg_stop(struct awg_softc *sc) } static int +awg_ioctl(if_t ifp, u_long cmd, caddr_t data) +{ + struct awg_softc *sc; + struct mii_data *mii; + struct ifreq *ifr; + int flags, mask, error; + + sc = if_getsoftc(ifp); + mii = device_get_softc(sc->miibus); + ifr = (struct ifreq *)data; + error = 0; + + switch (cmd) { + case SIOCSIFFLAGS: + AWG_LOCK(sc); + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { + flags = if_getflags(ifp) ^ sc->if_flags; + if ((flags & (IFF_PROMISC|IFF_ALLMULTI)) != 0) + awg_setup_rxfilter(sc); + } else + awg_init_locked(sc); + } else { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) + awg_stop(sc); + } + sc->if_flags = if_getflags(ifp); + AWG_UNLOCK(sc); + break; + case SIOCADDMULTI: + case SIOCDELMULTI: + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { + AWG_LOCK(sc); + awg_setup_rxfilter(sc); + AWG_UNLOCK(sc); + } + break; + case SIOCSIFMEDIA: + case SIOCGIFMEDIA: + error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); + break; + case SIOCSIFCAP: + mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); +#ifdef DEVICE_POLLING + if (mask & IFCAP_POLLING) { + if ((ifr->ifr_reqcap & IFCAP_POLLING) != 0) { + error = ether_poll_register(awg_poll, ifp); + if (error != 0) + break; + AWG_LOCK(sc); + awg_disable_dma_intr(sc); + if_setcapenablebit(ifp, IFCAP_POLLING, 0); + AWG_UNLOCK(sc); + } else { + error = ether_poll_deregister(ifp); + AWG_LOCK(sc); + awg_enable_dma_intr(sc); + if_setcapenablebit(ifp, 0, IFCAP_POLLING); + AWG_UNLOCK(sc); + } + } +#endif + if (mask & IFCAP_VLAN_MTU) + if_togglecapenable(ifp, IFCAP_VLAN_MTU); + if (mask & IFCAP_RXCSUM) + if_togglecapenable(ifp, IFCAP_RXCSUM); + if (mask & IFCAP_TXCSUM) + if_togglecapenable(ifp, IFCAP_TXCSUM); + if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0) + if_sethwassistbits(ifp, CSUM_IP | CSUM_UDP | CSUM_TCP, 0); + else + if_sethwassistbits(ifp, 0, CSUM_IP | CSUM_UDP | CSUM_TCP); + break; + default: + error = ether_ioctl(ifp, cmd, data); + break; + } + + return (error); +} + +/* + * Interrupts functions + */ + +static int awg_rxintr(struct awg_softc *sc) { if_t ifp; @@ -1085,88 +1368,9 @@ awg_poll(if_t ifp, enum poll_cmd cmd, int count) } #endif -static int -awg_ioctl(if_t ifp, u_long cmd, caddr_t data) -{ - struct awg_softc *sc; - struct mii_data *mii; - struct ifreq *ifr; - int flags, mask, error; - - sc = if_getsoftc(ifp); - mii = device_get_softc(sc->miibus); - ifr = (struct ifreq *)data; - error = 0; - - switch (cmd) { - case SIOCSIFFLAGS: - AWG_LOCK(sc); - if (if_getflags(ifp) & IFF_UP) { - if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { - flags = if_getflags(ifp) ^ sc->if_flags; - if ((flags & (IFF_PROMISC|IFF_ALLMULTI)) != 0) - awg_setup_rxfilter(sc); - } else - awg_init_locked(sc); - } else { - if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) - awg_stop(sc); - } - sc->if_flags = if_getflags(ifp); - AWG_UNLOCK(sc); - break; - case SIOCADDMULTI: - case SIOCDELMULTI: - if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { - AWG_LOCK(sc); - awg_setup_rxfilter(sc); - AWG_UNLOCK(sc); - } - break; - case SIOCSIFMEDIA: - case SIOCGIFMEDIA: - error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); - break; - case SIOCSIFCAP: - mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); -#ifdef DEVICE_POLLING - if (mask & IFCAP_POLLING) { - if ((ifr->ifr_reqcap & IFCAP_POLLING) != 0) { - error = ether_poll_register(awg_poll, ifp); - if (error != 0) - break; - AWG_LOCK(sc); - awg_disable_dma_intr(sc); - if_setcapenablebit(ifp, IFCAP_POLLING, 0); - AWG_UNLOCK(sc); - } else { - error = ether_poll_deregister(ifp); - AWG_LOCK(sc); - awg_enable_dma_intr(sc); - if_setcapenablebit(ifp, 0, IFCAP_POLLING); - AWG_UNLOCK(sc); - } - } -#endif - if (mask & IFCAP_VLAN_MTU) - if_togglecapenable(ifp, IFCAP_VLAN_MTU); - if (mask & IFCAP_RXCSUM) - if_togglecapenable(ifp, IFCAP_RXCSUM); - if (mask & IFCAP_TXCSUM) - if_togglecapenable(ifp, IFCAP_TXCSUM); - if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0) - if_sethwassistbits(ifp, CSUM_IP | CSUM_UDP | CSUM_TCP, 0); - else - if_sethwassistbits(ifp, 0, CSUM_IP | CSUM_UDP | CSUM_TCP); - break; - default: - error = ether_ioctl(ifp, cmd, data); - break; - } - - return (error); -} - +/* + * syscon functions + */ static uint32_t syscon_read_emac_clk_reg(device_t dev) { @@ -1193,6 +1397,10 @@ syscon_write_emac_clk_reg(device_t dev, uint32_t val) bus_write_4(sc->res[_RES_SYSCON], 0, val); } +/* + * PHY functions + */ + static phandle_t awg_get_phy_node(device_t dev) { @@ -1532,46 +1740,6 @@ fail: return (error); } -static void -awg_get_eaddr(device_t dev, uint8_t *eaddr) -{ - struct awg_softc *sc; - uint32_t maclo, machi, rnd; - u_char rootkey[16]; - uint32_t rootkey_size; - - sc = device_get_softc(dev); - - machi = RD4(sc, EMAC_ADDR_HIGH(0)) & 0xffff; - maclo = RD4(sc, EMAC_ADDR_LOW(0)); - - rootkey_size = sizeof(rootkey); - if (maclo == 0xffffffff && machi == 0xffff) { - /* MAC address in hardware is invalid, create one */ - if (aw_sid_get_fuse(AW_SID_FUSE_ROOTKEY, rootkey, - &rootkey_size) == 0 && - (rootkey[3] | rootkey[12] | rootkey[13] | rootkey[14] | - rootkey[15]) != 0) { - /* MAC address is derived from the root key in SID */ - maclo = (rootkey[13] << 24) | (rootkey[12] << 16) | - (rootkey[3] << 8) | 0x02; - machi = (rootkey[15] << 8) | rootkey[14]; - } else { - /* Create one */ - rnd = arc4random(); - maclo = 0x00f2 | (rnd & 0xffff0000); - machi = rnd & 0xffff; - } - } - - eaddr[0] = maclo & 0xff; - eaddr[1] = (maclo >> 8) & 0xff; - eaddr[2] = (maclo >> 16) & 0xff; - eaddr[3] = (maclo >> 24) & 0xff; - eaddr[4] = machi & 0xff; - eaddr[5] = (machi >> 8) & 0xff; -} - #ifdef AWG_DEBUG static void awg_dump_regs(device_t dev) @@ -1696,165 +1864,38 @@ awg_reset(device_t dev) return (0); } +/* + * Stats + */ + static void -awg_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) +awg_tick(void *softc) { - if (error != 0) - return; - *(bus_addr_t *)arg = segs[0].ds_addr; -} - -static int -awg_setup_dma(device_t dev) -{ struct awg_softc *sc; - int error, i; + struct mii_data *mii; + if_t ifp; + int link; - sc = device_get_softc(dev); + sc = softc; + ifp = sc->ifp; + mii = device_get_softc(sc->miibus); - /* Setup TX ring */ - error = bus_dma_tag_create( - bus_get_dma_tag(dev), /* Parent tag */ - DESC_ALIGN, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - TX_DESC_SIZE, 1, /* maxsize, nsegs */ - TX_DESC_SIZE, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->tx.desc_tag); - if (error != 0) { - device_printf(dev, "cannot create TX descriptor ring tag\n"); - return (error); - } + AWG_ASSERT_LOCKED(sc); - error = bus_dmamem_alloc(sc->tx.desc_tag, (void **)&sc->tx.desc_ring, - BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->tx.desc_map); - if (error != 0) { - device_printf(dev, "cannot allocate TX descriptor ring\n"); - return (error); - } + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) + return; - error = bus_dmamap_load(sc->tx.desc_tag, sc->tx.desc_map, - sc->tx.desc_ring, TX_DESC_SIZE, awg_dmamap_cb, - &sc->tx.desc_ring_paddr, 0); - if (error != 0) { - device_printf(dev, "cannot load TX descriptor ring\n"); - return (error); - } + link = sc->link; + mii_tick(mii); + if (sc->link && !link) + awg_start_locked(sc); - for (i = 0; i < TX_DESC_COUNT; i++) - sc->tx.desc_ring[i].next = - htole32(sc->tx.desc_ring_paddr + DESC_OFF(TX_NEXT(i))); - - error = bus_dma_tag_create( - bus_get_dma_tag(dev), /* Parent tag */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MCLBYTES, TX_MAX_SEGS, /* maxsize, nsegs */ - MCLBYTES, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->tx.buf_tag); - if (error != 0) { - device_printf(dev, "cannot create TX buffer tag\n"); - return (error); - } - - sc->tx.queued = 0; - for (i = 0; i < TX_DESC_COUNT; i++) { - error = bus_dmamap_create(sc->tx.buf_tag, 0, - &sc->tx.buf_map[i].map); - if (error != 0) { - device_printf(dev, "cannot create TX buffer map\n"); - return (error); - } - } - - /* Setup RX ring */ - error = bus_dma_tag_create( - bus_get_dma_tag(dev), /* Parent tag */ - DESC_ALIGN, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - RX_DESC_SIZE, 1, /* maxsize, nsegs */ - RX_DESC_SIZE, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->rx.desc_tag); - if (error != 0) { - device_printf(dev, "cannot create RX descriptor ring tag\n"); - return (error); - } - - error = bus_dmamem_alloc(sc->rx.desc_tag, (void **)&sc->rx.desc_ring, - BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->rx.desc_map); - if (error != 0) { - device_printf(dev, "cannot allocate RX descriptor ring\n"); - return (error); - } - - error = bus_dmamap_load(sc->rx.desc_tag, sc->rx.desc_map, - sc->rx.desc_ring, RX_DESC_SIZE, awg_dmamap_cb, - &sc->rx.desc_ring_paddr, 0); - if (error != 0) { - device_printf(dev, "cannot load RX descriptor ring\n"); - return (error); - } - - error = bus_dma_tag_create( - bus_get_dma_tag(dev), /* Parent tag */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Nov 20 11:30:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C27222C698D; Fri, 20 Nov 2020 11:30:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvV159pCz3Dgy; Fri, 20 Nov 2020 11:30:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9A87D156F2; Fri, 20 Nov 2020 11:30:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBU1Ba090170; Fri, 20 Nov 2020 11:30:01 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBU1nj090169; Fri, 20 Nov 2020 11:30:01 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201130.0AKBU1nj090169@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:30:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367884 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367884 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:30:01 -0000 Author: manu Date: Fri Nov 20 11:30:01 2020 New Revision: 367884 URL: https://svnweb.freebsd.org/changeset/base/367884 Log: if_dwc: Reorder functions and sort them by usage No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:29:37 2020 (r367883) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:30:01 2020 (r367884) @@ -195,6 +195,12 @@ struct dwc_hwdesc uint32_t addr2; /* ptr to next descriptor / second buffer data*/ }; + +struct dwc_hash_maddr_ctx { + struct dwc_softc *sc; + uint32_t hash[8]; +}; + /* * The hardware imposes alignment restrictions on various objects involved in * DMA transfers. These values are expressed in bytes (not bits). @@ -216,281 +222,461 @@ static void dwc_enable_mac(struct dwc_softc *sc, bool static void dwc_init_dma(struct dwc_softc *sc); static void dwc_stop_dma(struct dwc_softc *sc); -static inline uint32_t -next_rxidx(struct dwc_softc *sc, uint32_t curidx) -{ +static void dwc_tick(void *arg); - return ((curidx + 1) % RX_DESC_COUNT); -} +/* + * MIIBUS functions + */ -static inline uint32_t -next_txidx(struct dwc_softc *sc, uint32_t curidx) +static int +dwc_miibus_read_reg(device_t dev, int phy, int reg) { + struct dwc_softc *sc; + uint16_t mii; + size_t cnt; + int rv = 0; - return ((curidx + 1) % TX_DESC_COUNT); -} + sc = device_get_softc(dev); -static void -dwc_get1paddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) -{ + mii = ((phy & GMII_ADDRESS_PA_MASK) << GMII_ADDRESS_PA_SHIFT) + | ((reg & GMII_ADDRESS_GR_MASK) << GMII_ADDRESS_GR_SHIFT) + | (sc->mii_clk << GMII_ADDRESS_CR_SHIFT) + | GMII_ADDRESS_GB; /* Busy flag */ - if (error != 0) - return; - *(bus_addr_t *)arg = segs[0].ds_addr; -} + WRITE4(sc, GMII_ADDRESS, mii); -inline static void -dwc_setup_txdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr, - uint32_t len) -{ - uint32_t desc0, desc1; - - /* Addr/len 0 means we're clearing the descriptor after xmit done. */ - if (paddr == 0 || len == 0) { - desc0 = 0; - desc1 = 0; - --sc->txcount; - } else { - if (sc->mactype != DWC_GMAC_EXT_DESC) { - desc0 = 0; - desc1 = NTDESC1_TCH | NTDESC1_FS | NTDESC1_LS | - NTDESC1_IC | len; - } else { - desc0 = ETDESC0_TCH | ETDESC0_FS | ETDESC0_LS | - ETDESC0_IC; - desc1 = len; + for (cnt = 0; cnt < 1000; cnt++) { + if (!(READ4(sc, GMII_ADDRESS) & GMII_ADDRESS_GB)) { + rv = READ4(sc, GMII_DATA); + break; } - ++sc->txcount; + DELAY(10); } - sc->txdesc_ring[idx].addr1 = (uint32_t)(paddr); - sc->txdesc_ring[idx].desc0 = desc0; - sc->txdesc_ring[idx].desc1 = desc1; - - if (paddr && len) { - wmb(); - sc->txdesc_ring[idx].desc0 |= TDESC0_OWN; - wmb(); - } + return rv; } static int -dwc_setup_txbuf(struct dwc_softc *sc, int idx, struct mbuf **mp) +dwc_miibus_write_reg(device_t dev, int phy, int reg, int val) { - struct bus_dma_segment seg; - int error, nsegs; - struct mbuf * m; + struct dwc_softc *sc; + uint16_t mii; + size_t cnt; - if ((m = m_defrag(*mp, M_NOWAIT)) == NULL) - return (ENOMEM); - *mp = m; + sc = device_get_softc(dev); - error = bus_dmamap_load_mbuf_sg(sc->txbuf_tag, sc->txbuf_map[idx].map, - m, &seg, &nsegs, 0); - if (error != 0) { - return (ENOMEM); - } + mii = ((phy & GMII_ADDRESS_PA_MASK) << GMII_ADDRESS_PA_SHIFT) + | ((reg & GMII_ADDRESS_GR_MASK) << GMII_ADDRESS_GR_SHIFT) + | (sc->mii_clk << GMII_ADDRESS_CR_SHIFT) + | GMII_ADDRESS_GB | GMII_ADDRESS_GW; - KASSERT(nsegs == 1, ("%s: %d segments returned!", __func__, nsegs)); + WRITE4(sc, GMII_DATA, val); + WRITE4(sc, GMII_ADDRESS, mii); - bus_dmamap_sync(sc->txbuf_tag, sc->txbuf_map[idx].map, - BUS_DMASYNC_PREWRITE); + for (cnt = 0; cnt < 1000; cnt++) { + if (!(READ4(sc, GMII_ADDRESS) & GMII_ADDRESS_GB)) { + break; + } + DELAY(10); + } - sc->txbuf_map[idx].mbuf = m; - - dwc_setup_txdesc(sc, idx, seg.ds_addr, seg.ds_len); - return (0); } static void -dwc_txstart_locked(struct dwc_softc *sc) +dwc_miibus_statchg(device_t dev) { - struct ifnet *ifp; - struct mbuf *m; - int enqueued; + struct dwc_softc *sc; + struct mii_data *mii; + uint32_t reg; - DWC_ASSERT_LOCKED(sc); + /* + * Called by the MII bus driver when the PHY establishes + * link to set the MAC interface registers. + */ - if (!sc->link_is_up) - return; + sc = device_get_softc(dev); - ifp = sc->ifp; + DWC_ASSERT_LOCKED(sc); - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) - return; + mii = sc->mii_softc; - enqueued = 0; + if (mii->mii_media_status & IFM_ACTIVE) + sc->link_is_up = true; + else + sc->link_is_up = false; - for (;;) { - if (sc->txcount == (TX_DESC_COUNT - 1)) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - break; - } - - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) - break; - if (dwc_setup_txbuf(sc, sc->tx_idx_head, &m) != 0) { - IFQ_DRV_PREPEND(&ifp->if_snd, m); - break; - } - BPF_MTAP(ifp, m); - sc->tx_idx_head = next_txidx(sc, sc->tx_idx_head); - ++enqueued; + reg = READ4(sc, MAC_CONFIGURATION); + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_1000_T: + case IFM_1000_SX: + reg &= ~(CONF_FES | CONF_PS); + break; + case IFM_100_TX: + reg |= (CONF_FES | CONF_PS); + break; + case IFM_10_T: + reg &= ~(CONF_FES); + reg |= (CONF_PS); + break; + case IFM_NONE: + sc->link_is_up = false; + return; + default: + sc->link_is_up = false; + device_printf(dev, "Unsupported media %u\n", + IFM_SUBTYPE(mii->mii_media_active)); + return; } + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) + reg |= (CONF_DM); + else + reg &= ~(CONF_DM); + WRITE4(sc, MAC_CONFIGURATION, reg); - if (enqueued != 0) { - WRITE4(sc, TRANSMIT_POLL_DEMAND, 0x1); - sc->tx_watchdog_count = WATCHDOG_TIMEOUT_SECS; - } + IF_DWC_SET_SPEED(dev, IFM_SUBTYPE(mii->mii_media_active)); + } +/* + * Media functions + */ + static void -dwc_txstart(struct ifnet *ifp) +dwc_media_status(struct ifnet * ifp, struct ifmediareq *ifmr) { - struct dwc_softc *sc = ifp->if_softc; + struct dwc_softc *sc; + struct mii_data *mii; + sc = ifp->if_softc; + mii = sc->mii_softc; DWC_LOCK(sc); - dwc_txstart_locked(sc); + mii_pollstat(mii); + ifmr->ifm_active = mii->mii_media_active; + ifmr->ifm_status = mii->mii_media_status; DWC_UNLOCK(sc); } -static void -dwc_stop_locked(struct dwc_softc *sc) +static int +dwc_media_change_locked(struct dwc_softc *sc) { - struct ifnet *ifp; - DWC_ASSERT_LOCKED(sc); + return (mii_mediachg(sc->mii_softc)); +} - ifp = sc->ifp; - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - sc->tx_watchdog_count = 0; - sc->stats_harvest_count = 0; +static int +dwc_media_change(struct ifnet * ifp) +{ + struct dwc_softc *sc; + int error; - callout_stop(&sc->dwc_callout); + sc = ifp->if_softc; - dwc_stop_dma(sc); - dwc_enable_mac(sc, false); + DWC_LOCK(sc); + error = dwc_media_change_locked(sc); + DWC_UNLOCK(sc); + return (error); } -static void dwc_clear_stats(struct dwc_softc *sc) +/* + * Core functions + */ + +static const uint8_t nibbletab[] = { + /* 0x0 0000 -> 0000 */ 0x0, + /* 0x1 0001 -> 1000 */ 0x8, + /* 0x2 0010 -> 0100 */ 0x4, + /* 0x3 0011 -> 1100 */ 0xc, + /* 0x4 0100 -> 0010 */ 0x2, + /* 0x5 0101 -> 1010 */ 0xa, + /* 0x6 0110 -> 0110 */ 0x6, + /* 0x7 0111 -> 1110 */ 0xe, + /* 0x8 1000 -> 0001 */ 0x1, + /* 0x9 1001 -> 1001 */ 0x9, + /* 0xa 1010 -> 0101 */ 0x5, + /* 0xb 1011 -> 1101 */ 0xd, + /* 0xc 1100 -> 0011 */ 0x3, + /* 0xd 1101 -> 1011 */ 0xb, + /* 0xe 1110 -> 0111 */ 0x7, + /* 0xf 1111 -> 1111 */ 0xf, }; + +static uint8_t +bitreverse(uint8_t x) { - uint32_t reg; - reg = READ4(sc, MMC_CONTROL); - reg |= (MMC_CONTROL_CNTRST); - WRITE4(sc, MMC_CONTROL, reg); + return (nibbletab[x & 0xf] << 4) | nibbletab[x >> 4]; } +static u_int +dwc_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + struct dwc_hash_maddr_ctx *ctx = arg; + uint32_t crc, hashbit, hashreg; + uint8_t val; + + crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN); + /* Take lower 8 bits and reverse it */ + val = bitreverse(~crc & 0xff); + if (ctx->sc->mactype != DWC_GMAC_EXT_DESC) + val >>= 2; /* Only need lower 6 bits */ + hashreg = (val >> 5); + hashbit = (val & 31); + ctx->hash[hashreg] |= (1 << hashbit); + + return (1); +} + static void -dwc_harvest_stats(struct dwc_softc *sc) +dwc_setup_rxfilter(struct dwc_softc *sc) { + struct dwc_hash_maddr_ctx ctx; struct ifnet *ifp; + uint8_t *eaddr; + uint32_t ffval, hi, lo; + int nhash, i; - /* We don't need to harvest too often. */ - if (++sc->stats_harvest_count < STATS_HARVEST_INTERVAL) - return; + DWC_ASSERT_LOCKED(sc); - sc->stats_harvest_count = 0; ifp = sc->ifp; + nhash = sc->mactype != DWC_GMAC_EXT_DESC ? 2 : 8; - if_inc_counter(ifp, IFCOUNTER_IPACKETS, READ4(sc, RXFRAMECOUNT_GB)); - if_inc_counter(ifp, IFCOUNTER_IMCASTS, READ4(sc, RXMULTICASTFRAMES_G)); - if_inc_counter(ifp, IFCOUNTER_IERRORS, - READ4(sc, RXOVERSIZE_G) + READ4(sc, RXUNDERSIZE_G) + - READ4(sc, RXCRCERROR) + READ4(sc, RXALIGNMENTERROR) + - READ4(sc, RXRUNTERROR) + READ4(sc, RXJABBERERROR) + - READ4(sc, RXLENGTHERROR)); + /* + * Set the multicast (group) filter hash. + */ + if ((ifp->if_flags & IFF_ALLMULTI) != 0) { + ffval = (FRAME_FILTER_PM); + for (i = 0; i < nhash; i++) + ctx.hash[i] = ~0; + } else { + ffval = (FRAME_FILTER_HMC); + for (i = 0; i < nhash; i++) + ctx.hash[i] = 0; + ctx.sc = sc; + if_foreach_llmaddr(ifp, dwc_hash_maddr, &ctx); + } - if_inc_counter(ifp, IFCOUNTER_OPACKETS, READ4(sc, TXFRAMECOUNT_G)); - if_inc_counter(ifp, IFCOUNTER_OMCASTS, READ4(sc, TXMULTICASTFRAMES_G)); - if_inc_counter(ifp, IFCOUNTER_OERRORS, - READ4(sc, TXOVERSIZE_G) + READ4(sc, TXEXCESSDEF) + - READ4(sc, TXCARRIERERR) + READ4(sc, TXUNDERFLOWERROR)); + /* + * Set the individual address filter hash. + */ + if (ifp->if_flags & IFF_PROMISC) + ffval |= (FRAME_FILTER_PR); - if_inc_counter(ifp, IFCOUNTER_COLLISIONS, - READ4(sc, TXEXESSCOL) + READ4(sc, TXLATECOL)); - - dwc_clear_stats(sc); + /* + * Set the primary address. + */ + eaddr = IF_LLADDR(ifp); + lo = eaddr[0] | (eaddr[1] << 8) | (eaddr[2] << 16) | + (eaddr[3] << 24); + hi = eaddr[4] | (eaddr[5] << 8); + WRITE4(sc, MAC_ADDRESS_LOW(0), lo); + WRITE4(sc, MAC_ADDRESS_HIGH(0), hi); + WRITE4(sc, MAC_FRAME_FILTER, ffval); + if (sc->mactype != DWC_GMAC_EXT_DESC) { + WRITE4(sc, GMAC_MAC_HTLOW, ctx.hash[0]); + WRITE4(sc, GMAC_MAC_HTHIGH, ctx.hash[1]); + } else { + for (i = 0; i < nhash; i++) + WRITE4(sc, HASH_TABLE_REG(i), ctx.hash[i]); + } } static void -dwc_tick(void *arg) +dwc_setup_core(struct dwc_softc *sc) { - struct dwc_softc *sc; - struct ifnet *ifp; - int link_was_up; + uint32_t reg; - sc = arg; - DWC_ASSERT_LOCKED(sc); - ifp = sc->ifp; + /* Enable core */ + reg = READ4(sc, MAC_CONFIGURATION); + reg |= (CONF_JD | CONF_ACS | CONF_BE); + WRITE4(sc, MAC_CONFIGURATION, reg); +} - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) - return; +static void +dwc_enable_mac(struct dwc_softc *sc, bool enable) +{ + uint32_t reg; + DWC_ASSERT_LOCKED(sc); + reg = READ4(sc, MAC_CONFIGURATION); + if (enable) + reg |= CONF_TE | CONF_RE; + else + reg &= ~(CONF_TE | CONF_RE); + WRITE4(sc, MAC_CONFIGURATION, reg); +} + +static void +dwc_get_hwaddr(struct dwc_softc *sc, uint8_t *hwaddr) +{ + uint32_t hi, lo, rnd; + /* - * Typical tx watchdog. If this fires it indicates that we enqueued - * packets for output and never got a txdone interrupt for them. Maybe - * it's a missed interrupt somehow, just pretend we got one. + * Try to recover a MAC address from the running hardware. If there's + * something non-zero there, assume the bootloader did the right thing + * and just use it. + * + * Otherwise, set the address to a convenient locally assigned address, + * 'bsd' + random 24 low-order bits. 'b' is 0x62, which has the locally + * assigned bit set, and the broadcast/multicast bit clear. */ - if (sc->tx_watchdog_count > 0) { - if (--sc->tx_watchdog_count == 0) { - dwc_txfinish_locked(sc); - } + lo = READ4(sc, MAC_ADDRESS_LOW(0)); + hi = READ4(sc, MAC_ADDRESS_HIGH(0)) & 0xffff; + if ((lo != 0xffffffff) || (hi != 0xffff)) { + hwaddr[0] = (lo >> 0) & 0xff; + hwaddr[1] = (lo >> 8) & 0xff; + hwaddr[2] = (lo >> 16) & 0xff; + hwaddr[3] = (lo >> 24) & 0xff; + hwaddr[4] = (hi >> 0) & 0xff; + hwaddr[5] = (hi >> 8) & 0xff; + } else { + rnd = arc4random() & 0x00ffffff; + hwaddr[0] = 'b'; + hwaddr[1] = 's'; + hwaddr[2] = 'd'; + hwaddr[3] = rnd >> 16; + hwaddr[4] = rnd >> 8; + hwaddr[5] = rnd >> 0; } +} - /* Gather stats from hardware counters. */ - dwc_harvest_stats(sc); +/* + * DMA functions + */ - /* Check the media status. */ - link_was_up = sc->link_is_up; - mii_tick(sc->mii_softc); - if (sc->link_is_up && !link_was_up) - dwc_txstart_locked(sc); +static void +dwc_init_dma(struct dwc_softc *sc) +{ + uint32_t reg; - /* Schedule another check one second from now. */ - callout_reset(&sc->dwc_callout, hz, dwc_tick, sc); + DWC_ASSERT_LOCKED(sc); + + /* Initializa DMA and enable transmitters */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_TSF | MODE_OSF | MODE_FUF); + reg &= ~(MODE_RSF); + reg |= (MODE_RTC_LEV32 << MODE_RTC_SHIFT); + WRITE4(sc, OPERATION_MODE, reg); + + WRITE4(sc, INTERRUPT_ENABLE, INT_EN_DEFAULT); + + /* Start DMA */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_ST | MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); } static void -dwc_init_locked(struct dwc_softc *sc) +dwc_stop_dma(struct dwc_softc *sc) { - struct ifnet *ifp = sc->ifp; + uint32_t reg; DWC_ASSERT_LOCKED(sc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - return; + /* Stop DMA TX */ + reg = READ4(sc, OPERATION_MODE); + reg &= ~(MODE_ST); + WRITE4(sc, OPERATION_MODE, reg); - dwc_setup_rxfilter(sc); - dwc_setup_core(sc); - dwc_enable_mac(sc, true); - dwc_init_dma(sc); + /* Flush TX */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_FTF); + WRITE4(sc, OPERATION_MODE, reg); - if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); + /* Stop DMA RX */ + reg = READ4(sc, OPERATION_MODE); + reg &= ~(MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); +} - /* - * Call mii_mediachg() which will call back into dwc_miibus_statchg() - * to set up the remaining config registers based on current media. - */ - mii_mediachg(sc->mii_softc); - callout_reset(&sc->dwc_callout, hz, dwc_tick, sc); +static inline uint32_t +next_rxidx(struct dwc_softc *sc, uint32_t curidx) +{ + + return ((curidx + 1) % RX_DESC_COUNT); } +static inline uint32_t +next_txidx(struct dwc_softc *sc, uint32_t curidx) +{ + + return ((curidx + 1) % TX_DESC_COUNT); +} + static void -dwc_init(void *if_softc) +dwc_get1paddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) { - struct dwc_softc *sc = if_softc; - DWC_LOCK(sc); - dwc_init_locked(sc); - DWC_UNLOCK(sc); + if (error != 0) + return; + *(bus_addr_t *)arg = segs[0].ds_addr; } +inline static void +dwc_setup_txdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr, + uint32_t len) +{ + uint32_t desc0, desc1; + /* Addr/len 0 means we're clearing the descriptor after xmit done. */ + if (paddr == 0 || len == 0) { + desc0 = 0; + desc1 = 0; + --sc->txcount; + } else { + if (sc->mactype != DWC_GMAC_EXT_DESC) { + desc0 = 0; + desc1 = NTDESC1_TCH | NTDESC1_FS | NTDESC1_LS | + NTDESC1_IC | len; + } else { + desc0 = ETDESC0_TCH | ETDESC0_FS | ETDESC0_LS | + ETDESC0_IC; + desc1 = len; + } + ++sc->txcount; + } + + sc->txdesc_ring[idx].addr1 = (uint32_t)(paddr); + sc->txdesc_ring[idx].desc0 = desc0; + sc->txdesc_ring[idx].desc1 = desc1; + + if (paddr && len) { + wmb(); + sc->txdesc_ring[idx].desc0 |= TDESC0_OWN; + wmb(); + } +} + +static int +dwc_setup_txbuf(struct dwc_softc *sc, int idx, struct mbuf **mp) +{ + struct bus_dma_segment seg; + int error, nsegs; + struct mbuf * m; + + if ((m = m_defrag(*mp, M_NOWAIT)) == NULL) + return (ENOMEM); + *mp = m; + + error = bus_dmamap_load_mbuf_sg(sc->txbuf_tag, sc->txbuf_map[idx].map, + m, &seg, &nsegs, 0); + if (error != 0) { + return (ENOMEM); + } + + KASSERT(nsegs == 1, ("%s: %d segments returned!", __func__, nsegs)); + + bus_dmamap_sync(sc->txbuf_tag, sc->txbuf_map[idx].map, + BUS_DMASYNC_PREWRITE); + + sc->txbuf_map[idx].mbuf = m; + + dwc_setup_txdesc(sc, idx, seg.ds_addr, seg.ds_len); + + return (0); +} + inline static uint32_t dwc_setup_rxdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr) { @@ -617,215 +803,276 @@ dwc_rxfinish_one(struct dwc_softc *sc, struct dwc_hwde return (m0); } -static void -dwc_media_status(struct ifnet * ifp, struct ifmediareq *ifmr) +static int +setup_dma(struct dwc_softc *sc) { - struct dwc_softc *sc; - struct mii_data *mii; + struct mbuf *m; + int error; + int nidx; + int idx; - sc = ifp->if_softc; - mii = sc->mii_softc; - DWC_LOCK(sc); - mii_pollstat(mii); - ifmr->ifm_active = mii->mii_media_active; - ifmr->ifm_status = mii->mii_media_status; - DWC_UNLOCK(sc); -} + /* + * Set up TX descriptor ring, descriptors, and dma maps. + */ + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + DWC_DESC_RING_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + TX_DESC_SIZE, 1, /* maxsize, nsegments */ + TX_DESC_SIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->txdesc_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create TX ring DMA tag.\n"); + goto out; + } -static int -dwc_media_change_locked(struct dwc_softc *sc) -{ + error = bus_dmamem_alloc(sc->txdesc_tag, (void**)&sc->txdesc_ring, + BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, + &sc->txdesc_map); + if (error != 0) { + device_printf(sc->dev, + "could not allocate TX descriptor ring.\n"); + goto out; + } - return (mii_mediachg(sc->mii_softc)); -} + error = bus_dmamap_load(sc->txdesc_tag, sc->txdesc_map, + sc->txdesc_ring, TX_DESC_SIZE, dwc_get1paddr, + &sc->txdesc_ring_paddr, 0); + if (error != 0) { + device_printf(sc->dev, + "could not load TX descriptor ring map.\n"); + goto out; + } -static int -dwc_media_change(struct ifnet * ifp) -{ - struct dwc_softc *sc; - int error; + for (idx = 0; idx < TX_DESC_COUNT; idx++) { + nidx = next_txidx(sc, idx); + sc->txdesc_ring[idx].addr2 = sc->txdesc_ring_paddr + + (nidx * sizeof(struct dwc_hwdesc)); + } - sc = ifp->if_softc; + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + 1, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MCLBYTES, 1, /* maxsize, nsegments */ + MCLBYTES, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->txbuf_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create TX ring DMA tag.\n"); + goto out; + } - DWC_LOCK(sc); - error = dwc_media_change_locked(sc); - DWC_UNLOCK(sc); - return (error); -} + for (idx = 0; idx < TX_DESC_COUNT; idx++) { + error = bus_dmamap_create(sc->txbuf_tag, BUS_DMA_COHERENT, + &sc->txbuf_map[idx].map); + if (error != 0) { + device_printf(sc->dev, + "could not create TX buffer DMA map.\n"); + goto out; + } + dwc_setup_txdesc(sc, idx, 0, 0); + } -static const uint8_t nibbletab[] = { - /* 0x0 0000 -> 0000 */ 0x0, - /* 0x1 0001 -> 1000 */ 0x8, - /* 0x2 0010 -> 0100 */ 0x4, - /* 0x3 0011 -> 1100 */ 0xc, - /* 0x4 0100 -> 0010 */ 0x2, - /* 0x5 0101 -> 1010 */ 0xa, - /* 0x6 0110 -> 0110 */ 0x6, - /* 0x7 0111 -> 1110 */ 0xe, - /* 0x8 1000 -> 0001 */ 0x1, - /* 0x9 1001 -> 1001 */ 0x9, - /* 0xa 1010 -> 0101 */ 0x5, - /* 0xb 1011 -> 1101 */ 0xd, - /* 0xc 1100 -> 0011 */ 0x3, - /* 0xd 1101 -> 1011 */ 0xb, - /* 0xe 1110 -> 0111 */ 0x7, - /* 0xf 1111 -> 1111 */ 0xf, }; + /* + * Set up RX descriptor ring, descriptors, dma maps, and mbufs. + */ + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + DWC_DESC_RING_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + RX_DESC_SIZE, 1, /* maxsize, nsegments */ + RX_DESC_SIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->rxdesc_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create RX ring DMA tag.\n"); + goto out; + } -static uint8_t -bitreverse(uint8_t x) -{ + error = bus_dmamem_alloc(sc->rxdesc_tag, (void **)&sc->rxdesc_ring, + BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, + &sc->rxdesc_map); + if (error != 0) { + device_printf(sc->dev, + "could not allocate RX descriptor ring.\n"); + goto out; + } - return (nibbletab[x & 0xf] << 4) | nibbletab[x >> 4]; -} + error = bus_dmamap_load(sc->rxdesc_tag, sc->rxdesc_map, + sc->rxdesc_ring, RX_DESC_SIZE, dwc_get1paddr, + &sc->rxdesc_ring_paddr, 0); + if (error != 0) { + device_printf(sc->dev, + "could not load RX descriptor ring map.\n"); + goto out; + } -struct dwc_hash_maddr_ctx { - struct dwc_softc *sc; - uint32_t hash[8]; -}; + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + 1, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MCLBYTES, 1, /* maxsize, nsegments */ + MCLBYTES, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->rxbuf_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create RX buf DMA tag.\n"); + goto out; + } -static u_int -dwc_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) -{ - struct dwc_hash_maddr_ctx *ctx = arg; - uint32_t crc, hashbit, hashreg; - uint8_t val; + for (idx = 0; idx < RX_DESC_COUNT; idx++) { + error = bus_dmamap_create(sc->rxbuf_tag, BUS_DMA_COHERENT, + &sc->rxbuf_map[idx].map); + if (error != 0) { + device_printf(sc->dev, + "could not create RX buffer DMA map.\n"); + goto out; + } + if ((m = dwc_alloc_mbufcl(sc)) == NULL) { + device_printf(sc->dev, "Could not alloc mbuf\n"); + error = ENOMEM; + goto out; + } + if ((error = dwc_setup_rxbuf(sc, idx, m)) != 0) { + device_printf(sc->dev, + "could not create new RX buffer.\n"); + goto out; + } + } - crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN); - /* Take lower 8 bits and reverse it */ - val = bitreverse(~crc & 0xff); - if (ctx->sc->mactype != DWC_GMAC_EXT_DESC) - val >>= 2; /* Only need lower 6 bits */ - hashreg = (val >> 5); - hashbit = (val & 31); - ctx->hash[hashreg] |= (1 << hashbit); +out: + if (error != 0) + return (ENXIO); - return (1); + return (0); } +/* + * if_ functions + */ + static void -dwc_setup_rxfilter(struct dwc_softc *sc) +dwc_txstart_locked(struct dwc_softc *sc) { - struct dwc_hash_maddr_ctx ctx; struct ifnet *ifp; - uint8_t *eaddr; - uint32_t ffval, hi, lo; - int nhash, i; + struct mbuf *m; + int enqueued; DWC_ASSERT_LOCKED(sc); + if (!sc->link_is_up) + return; + ifp = sc->ifp; - nhash = sc->mactype != DWC_GMAC_EXT_DESC ? 2 : 8; - /* - * Set the multicast (group) filter hash. - */ - if ((ifp->if_flags & IFF_ALLMULTI) != 0) { - ffval = (FRAME_FILTER_PM); - for (i = 0; i < nhash; i++) - ctx.hash[i] = ~0; - } else { - ffval = (FRAME_FILTER_HMC); - for (i = 0; i < nhash; i++) - ctx.hash[i] = 0; - ctx.sc = sc; - if_foreach_llmaddr(ifp, dwc_hash_maddr, &ctx); - } + if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + return; - /* - * Set the individual address filter hash. - */ - if (ifp->if_flags & IFF_PROMISC) - ffval |= (FRAME_FILTER_PR); + enqueued = 0; - /* - * Set the primary address. - */ - eaddr = IF_LLADDR(ifp); - lo = eaddr[0] | (eaddr[1] << 8) | (eaddr[2] << 16) | - (eaddr[3] << 24); - hi = eaddr[4] | (eaddr[5] << 8); - WRITE4(sc, MAC_ADDRESS_LOW(0), lo); - WRITE4(sc, MAC_ADDRESS_HIGH(0), hi); - WRITE4(sc, MAC_FRAME_FILTER, ffval); - if (sc->mactype != DWC_GMAC_EXT_DESC) { - WRITE4(sc, GMAC_MAC_HTLOW, ctx.hash[0]); - WRITE4(sc, GMAC_MAC_HTHIGH, ctx.hash[1]); - } else { - for (i = 0; i < nhash; i++) - WRITE4(sc, HASH_TABLE_REG(i), ctx.hash[i]); + for (;;) { + if (sc->txcount == (TX_DESC_COUNT - 1)) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } + + IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + if (m == NULL) + break; + if (dwc_setup_txbuf(sc, sc->tx_idx_head, &m) != 0) { + IFQ_DRV_PREPEND(&ifp->if_snd, m); + break; + } + BPF_MTAP(ifp, m); + sc->tx_idx_head = next_txidx(sc, sc->tx_idx_head); + ++enqueued; } + + if (enqueued != 0) { + WRITE4(sc, TRANSMIT_POLL_DEMAND, 0x1); + sc->tx_watchdog_count = WATCHDOG_TIMEOUT_SECS; + } } static void -dwc_setup_core(struct dwc_softc *sc) +dwc_txstart(struct ifnet *ifp) { - uint32_t reg; + struct dwc_softc *sc = ifp->if_softc; - DWC_ASSERT_LOCKED(sc); - - /* Enable core */ - reg = READ4(sc, MAC_CONFIGURATION); - reg |= (CONF_JD | CONF_ACS | CONF_BE); - WRITE4(sc, MAC_CONFIGURATION, reg); + DWC_LOCK(sc); + dwc_txstart_locked(sc); + DWC_UNLOCK(sc); } static void *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Nov 20 11:30:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 493CE2C6D1E; Fri, 20 Nov 2020 11:30:24 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvVS1bXgz3Dhl; Fri, 20 Nov 2020 11:30:24 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2A395150EC; Fri, 20 Nov 2020 11:30:24 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBUOo5090232; Fri, 20 Nov 2020 11:30:24 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBUOJY090231; Fri, 20 Nov 2020 11:30:24 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201130.0AKBUOJY090231@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:30:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367885 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367885 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:30:24 -0000 Author: manu Date: Fri Nov 20 11:30:23 2020 New Revision: 367885 URL: https://svnweb.freebsd.org/changeset/base/367885 Log: if_dwc: Use if_ function where appropriate No functional changes intended Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:30:01 2020 (r367884) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:30:23 2020 (r367885) @@ -983,25 +983,26 @@ dwc_txstart_locked(struct dwc_softc *sc) ifp = sc->ifp; - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) return; enqueued = 0; for (;;) { if (sc->txcount == (TX_DESC_COUNT - 1)) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); break; } - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + m = if_dequeue(ifp); if (m == NULL) break; if (dwc_setup_txbuf(sc, sc->tx_idx_head, &m) != 0) { - IFQ_DRV_PREPEND(&ifp->if_snd, m); + if_sendq_prepend(ifp, m); break; } - BPF_MTAP(ifp, m); + if_bpfmtap(ifp, m); sc->tx_idx_head = next_txidx(sc, sc->tx_idx_head); ++enqueued; } @@ -1029,7 +1030,7 @@ dwc_init_locked(struct dwc_softc *sc) DWC_ASSERT_LOCKED(sc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) return; dwc_setup_rxfilter(sc); @@ -1065,7 +1066,7 @@ dwc_stop_locked(struct dwc_softc *sc) DWC_ASSERT_LOCKED(sc); ifp = sc->ifp; - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING | IFF_DRV_OACTIVE); sc->tx_watchdog_count = 0; sc->stats_harvest_count = 0; @@ -1081,7 +1082,7 @@ dwc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct dwc_softc *sc; struct mii_data *mii; struct ifreq *ifr; - int mask, error; + int flags, mask, error; sc = ifp->if_softc; ifr = (struct ifreq *)data; @@ -1090,25 +1091,25 @@ dwc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) switch (cmd) { case SIOCSIFFLAGS: DWC_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - if ((ifp->if_flags ^ sc->if_flags) & - (IFF_PROMISC | IFF_ALLMULTI)) + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { + flags = if_getflags(ifp) ^ sc->if_flags; + if ((flags & (IFF_PROMISC|IFF_ALLMULTI)) != 0) dwc_setup_rxfilter(sc); } else { if (!sc->is_detaching) dwc_init_locked(sc); } } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) dwc_stop_locked(sc); } - sc->if_flags = ifp->if_flags; + sc->if_flags = if_getflags(ifp); DWC_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { DWC_LOCK(sc); dwc_setup_rxfilter(sc); DWC_UNLOCK(sc); @@ -1120,10 +1121,10 @@ dwc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); break; case SIOCSIFCAP: - mask = ifp->if_capenable ^ ifr->ifr_reqcap; + mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); if (mask & IFCAP_VLAN_MTU) { /* No work to do except acknowledge the change took */ - ifp->if_capenable ^= IFCAP_VLAN_MTU; + if_togglecapenable(ifp, IFCAP_VLAN_MTU); } break; @@ -1161,7 +1162,7 @@ dwc_txfinish_locked(struct dwc_softc *sc) bmap->mbuf = NULL; dwc_setup_txdesc(sc, sc->tx_idx_tail, 0, 0); sc->tx_idx_tail = next_txidx(sc, sc->tx_idx_tail); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } @@ -1300,7 +1301,7 @@ dwc_tick(void *arg) ifp = sc->ifp; - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) return; /* @@ -1541,15 +1542,14 @@ dwc_attach(device_t dev) ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_capabilities = IFCAP_VLAN_MTU; - ifp->if_capenable = ifp->if_capabilities; - ifp->if_start = dwc_txstart; - ifp->if_ioctl = dwc_ioctl; - ifp->if_init = dwc_init; - IFQ_SET_MAXLEN(&ifp->if_snd, TX_DESC_COUNT - 1); - ifp->if_snd.ifq_drv_maxlen = TX_DESC_COUNT - 1; - IFQ_SET_READY(&ifp->if_snd); + if_setflags(sc->ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setstartfn(ifp, dwc_txstart); + if_setioctlfn(ifp, dwc_ioctl); + if_setinitfn(ifp, dwc_init); + if_setsendqlen(ifp, TX_DESC_COUNT - 1); + if_setsendqready(sc->ifp); + if_setcapabilities(sc->ifp, IFCAP_VLAN_MTU); + if_setcapenable(sc->ifp, if_getcapabilities(sc->ifp)); /* Attach the mii driver. */ error = mii_attach(dev, &sc->miibus, ifp, dwc_media_change, From owner-svn-src-all@freebsd.org Fri Nov 20 11:30:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 920902C6AF9; Fri, 20 Nov 2020 11:30:45 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvVs3PxYz3DjG; Fri, 20 Nov 2020 11:30:45 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 686DE1557F; Fri, 20 Nov 2020 11:30:45 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBUjcG090294; Fri, 20 Nov 2020 11:30:45 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBUjsZ090293; Fri, 20 Nov 2020 11:30:45 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201130.0AKBUjsZ090293@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:30:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367886 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 367886 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:30:45 -0000 Author: manu Date: Fri Nov 20 11:30:44 2020 New Revision: 367886 URL: https://svnweb.freebsd.org/changeset/base/367886 Log: if_awg: Add a awg_dma_start_tx function that trigger dma engine No functional changes intended Modified: head/sys/arm/allwinner/if_awg.c Modified: head/sys/arm/allwinner/if_awg.c ============================================================================== --- head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:30:23 2020 (r367885) +++ head/sys/arm/allwinner/if_awg.c Fri Nov 20 11:30:44 2020 (r367886) @@ -941,6 +941,18 @@ awg_setup_dma(device_t dev) return (0); } +static void +awg_dma_start_tx(struct awg_softc *sc) +{ + uint32_t val; + + AWG_ASSERT_LOCKED(sc); + + /* Start and run TX DMA */ + val = RD4(sc, EMAC_TX_CTL_1); + WR4(sc, EMAC_TX_CTL_1, val | TX_DMA_START); +} + /* * if_ functions */ @@ -949,7 +961,6 @@ static void awg_start_locked(struct awg_softc *sc) { struct mbuf *m; - uint32_t val; if_t ifp; int cnt, err; @@ -984,9 +995,7 @@ awg_start_locked(struct awg_softc *sc) bus_dmamap_sync(sc->tx.desc_tag, sc->tx.desc_map, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); - /* Start and run TX DMA */ - val = RD4(sc, EMAC_TX_CTL_1); - WR4(sc, EMAC_TX_CTL_1, val | TX_DMA_START); + awg_dma_start_tx(sc); } } From owner-svn-src-all@freebsd.org Fri Nov 20 11:31:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 13E602C6BED; Fri, 20 Nov 2020 11:31:05 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvWD74F3z3FDk; Fri, 20 Nov 2020 11:31:04 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E5A8D15712; Fri, 20 Nov 2020 11:31:04 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBV4jW092680; Fri, 20 Nov 2020 11:31:04 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBV4lf092678; Fri, 20 Nov 2020 11:31:04 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201131.0AKBV4lf092678@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:31:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367887 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367887 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:31:05 -0000 Author: manu Date: Fri Nov 20 11:31:04 2020 New Revision: 367887 URL: https://svnweb.freebsd.org/changeset/base/367887 Log: if_dwc: Add flow control support Modified: head/sys/dev/dwc/if_dwc.c head/sys/dev/dwc/if_dwc.h Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:30:44 2020 (r367886) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:31:04 2020 (r367887) @@ -224,6 +224,10 @@ static void dwc_stop_dma(struct dwc_softc *sc); static void dwc_tick(void *arg); +/* Pause time field in the transmitted control frame */ +static int dwc_pause_time = 0xffff; +TUNABLE_INT("hw.dwc.pause_time", &dwc_pause_time); + /* * MIIBUS functions */ @@ -333,6 +337,15 @@ dwc_miibus_statchg(device_t dev) else reg &= ~(CONF_DM); WRITE4(sc, MAC_CONFIGURATION, reg); + + reg = FLOW_CONTROL_UP; + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0) + reg |= FLOW_CONTROL_TX; + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0) + reg |= FLOW_CONTROL_RX; + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) + reg |= dwc_pause_time << FLOW_CONTROL_PT_SHIFT; + WRITE4(sc, FLOW_CONTROL, reg); IF_DWC_SET_SPEED(dev, IFM_SUBTYPE(mii->mii_media_active)); Modified: head/sys/dev/dwc/if_dwc.h ============================================================================== --- head/sys/dev/dwc/if_dwc.h Fri Nov 20 11:30:44 2020 (r367886) +++ head/sys/dev/dwc/if_dwc.h Fri Nov 20 11:31:04 2020 (r367887) @@ -70,6 +70,10 @@ #define GMII_ADDRESS_GB (1 << 0) /* Busy */ #define GMII_DATA 0x14 #define FLOW_CONTROL 0x18 +#define FLOW_CONTROL_PT_SHIFT 16 +#define FLOW_CONTROL_UP (1 << 3) /* Unicast pause enable */ +#define FLOW_CONTROL_RX (1 << 2) /* RX Flow control enable */ +#define FLOW_CONTROL_TX (1 << 1) /* TX Flow control enable */ #define GMAC_VLAN_TAG 0x1C #define VERSION 0x20 #define DEBUG 0x24 From owner-svn-src-all@freebsd.org Fri Nov 20 11:31:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9C5022C69E3; Fri, 20 Nov 2020 11:31:25 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvWd427dz3FCh; Fri, 20 Nov 2020 11:31:25 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D32F1578F; Fri, 20 Nov 2020 11:31:25 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBVPYC093743; Fri, 20 Nov 2020 11:31:25 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBVPqG093741; Fri, 20 Nov 2020 11:31:25 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011201131.0AKBVPqG093741@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 20 Nov 2020 11:31:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367888 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367888 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:31:25 -0000 Author: manu Date: Fri Nov 20 11:31:25 2020 New Revision: 367888 URL: https://svnweb.freebsd.org/changeset/base/367888 Log: if_dwc: Add checksum offloading support Modified: head/sys/dev/dwc/if_dwc.c Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:31:04 2020 (r367887) +++ head/sys/dev/dwc/if_dwc.c Fri Nov 20 11:31:25 2020 (r367888) @@ -155,7 +155,6 @@ __FBSDID("$FreeBSD$"); #define RDESC0_FS (1U << 9) /* First Descriptor */ #define RDESC0_LS (1U << 8) /* Last Descriptor */ #define RDESC0_ICE (1U << 7) /* IPC Checksum Error */ -#define RDESC0_GF (1U << 7) /* Giant Frame */ #define RDESC0_LC (1U << 6) /* Late Collision */ #define RDESC0_FT (1U << 5) /* Frame Type */ #define RDESC0_RWT (1U << 4) /* Receive Watchdog Timeout */ @@ -628,7 +627,7 @@ dwc_get1paddr(void *arg, bus_dma_segment_t *segs, int inline static void dwc_setup_txdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr, - uint32_t len) + uint32_t len, uint32_t flags) { uint32_t desc0, desc1; @@ -641,10 +640,10 @@ dwc_setup_txdesc(struct dwc_softc *sc, int idx, bus_ad if (sc->mactype != DWC_GMAC_EXT_DESC) { desc0 = 0; desc1 = NTDESC1_TCH | NTDESC1_FS | NTDESC1_LS | - NTDESC1_IC | len; + NTDESC1_IC | len | flags; } else { desc0 = ETDESC0_TCH | ETDESC0_FS | ETDESC0_LS | - ETDESC0_IC; + ETDESC0_IC | flags; desc1 = len; } ++sc->txcount; @@ -667,6 +666,7 @@ dwc_setup_txbuf(struct dwc_softc *sc, int idx, struct struct bus_dma_segment seg; int error, nsegs; struct mbuf * m; + uint32_t flags = 0; if ((m = m_defrag(*mp, M_NOWAIT)) == NULL) return (ENOMEM); @@ -685,8 +685,22 @@ dwc_setup_txbuf(struct dwc_softc *sc, int idx, struct sc->txbuf_map[idx].mbuf = m; - dwc_setup_txdesc(sc, idx, seg.ds_addr, seg.ds_len); + if ((m->m_pkthdr.csum_flags & CSUM_IP) != 0) { + if ((m->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP)) != 0) { + if (sc->mactype != DWC_GMAC_EXT_DESC) + flags = NTDESC1_CIC_FULL; + else + flags = ETDESC0_CIC_FULL; + } else { + if (sc->mactype != DWC_GMAC_EXT_DESC) + flags = NTDESC1_CIC_HDR; + else + flags = ETDESC0_CIC_HDR; + } + } + dwc_setup_txdesc(sc, idx, seg.ds_addr, seg.ds_len, flags); + return (0); } @@ -807,6 +821,18 @@ dwc_rxfinish_one(struct dwc_softc *sc, struct dwc_hwde m->m_len = len; if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0 && + (rdesc0 & RDESC0_FT) != 0) { + m->m_pkthdr.csum_flags = CSUM_IP_CHECKED; + if ((rdesc0 & RDESC0_ICE) == 0) + m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + if ((rdesc0 & RDESC0_PCE) == 0) { + m->m_pkthdr.csum_flags |= + CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_data = 0xffff; + } + } + /* Remove trailing FCS */ m_adj(m, -ETHER_CRC_LEN); @@ -893,7 +919,7 @@ setup_dma(struct dwc_softc *sc) "could not create TX buffer DMA map.\n"); goto out; } - dwc_setup_txdesc(sc, idx, 0, 0); + dwc_setup_txdesc(sc, idx, 0, 0, 0); } /* @@ -1139,6 +1165,14 @@ dwc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* No work to do except acknowledge the change took */ if_togglecapenable(ifp, IFCAP_VLAN_MTU); } + if (mask & IFCAP_RXCSUM) + if_togglecapenable(ifp, IFCAP_RXCSUM); + if (mask & IFCAP_TXCSUM) + if_togglecapenable(ifp, IFCAP_TXCSUM); + if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0) + if_sethwassistbits(ifp, CSUM_IP | CSUM_UDP | CSUM_TCP, 0); + else + if_sethwassistbits(ifp, 0, CSUM_IP | CSUM_UDP | CSUM_TCP); break; default: @@ -1173,7 +1207,7 @@ dwc_txfinish_locked(struct dwc_softc *sc) bus_dmamap_unload(sc->txbuf_tag, bmap->map); m_freem(bmap->mbuf); bmap->mbuf = NULL; - dwc_setup_txdesc(sc, sc->tx_idx_tail, 0, 0); + dwc_setup_txdesc(sc, sc->tx_idx_tail, 0, 0, 0); sc->tx_idx_tail = next_txidx(sc, sc->tx_idx_tail); if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); @@ -1212,6 +1246,7 @@ dwc_rxfinish_locked(struct dwc_softc *sc) if (error != 0) panic("dwc_setup_rxbuf failed: error %d\n", error); + } sc->rx_idx = next_rxidx(sc, sc->rx_idx); } @@ -1561,7 +1596,8 @@ dwc_attach(device_t dev) if_setinitfn(ifp, dwc_init); if_setsendqlen(ifp, TX_DESC_COUNT - 1); if_setsendqready(sc->ifp); - if_setcapabilities(sc->ifp, IFCAP_VLAN_MTU); + if_sethwassist(sc->ifp, CSUM_IP | CSUM_UDP | CSUM_TCP); + if_setcapabilities(sc->ifp, IFCAP_VLAN_MTU | IFCAP_HWCSUM); if_setcapenable(sc->ifp, if_getcapabilities(sc->ifp)); /* Attach the mii driver. */ From owner-svn-src-all@freebsd.org Fri Nov 20 11:45:08 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C38BA2C7323; Fri, 20 Nov 2020 11:45:08 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcvqS54Hkz3GFV; Fri, 20 Nov 2020 11:45:08 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C80E15C09; Fri, 20 Nov 2020 11:45:08 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKBj8Do002574; Fri, 20 Nov 2020 11:45:08 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKBj8B3002573; Fri, 20 Nov 2020 11:45:08 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201145.0AKBj8B3002573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 11:45:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367889 - head/sbin/camcontrol X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/sbin/camcontrol X-SVN-Commit-Revision: 367889 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 11:45:08 -0000 Author: gbe (doc committer) Date: Fri Nov 20 11:45:08 2020 New Revision: 367889 URL: https://svnweb.freebsd.org/changeset/base/367889 Log: camcontrol(8): Fix some warnings spotted by mandoc - skipping paragraph macro: Pp before Bl Modified: head/sbin/camcontrol/camcontrol.8 Modified: head/sbin/camcontrol/camcontrol.8 ============================================================================== --- head/sbin/camcontrol/camcontrol.8 Fri Nov 20 11:31:25 2020 (r367888) +++ head/sbin/camcontrol/camcontrol.8 Fri Nov 20 11:45:08 2020 (r367889) @@ -2276,7 +2276,6 @@ These zones must be written sequentially. If they are not written sequentially, starting at the write pointer, the command will fail. .El -.Pp .Bl -tag -width 12n .It Fl c Ar cmd Specify the zone subcommand: @@ -2831,7 +2830,6 @@ This will read and decode the attribute values from pa in tape drive sa0, and will display any .Tn SCSI errors that result. -.Pp .Bd -literal -offset indent camcontrol zone da0 -v -c rz -P summary .Ed @@ -2842,7 +2840,6 @@ summary of the zone parameters, and display any or .Tn ATA errors that result. -.Pp .Bd -literal -offset indent camcontrol zone da0 -v -c rz -o reset .Ed @@ -2853,7 +2850,6 @@ pointer reset from the disk da0, and display any or .Tn ATA errors that result. -.Pp .Bd -literal -offset indent camcontrol zone da0 -v -c rwp -l 0x2c80000 .Ed @@ -2864,7 +2860,6 @@ that starts at LBA 0x2c80000 and display any or .Tn ATA errors that result. -.Pp .Bd -literal -offset indent camcontrol epc ada0 -c timer -T 60.1 -p Idle_a -e -s .Ed @@ -2873,7 +2868,6 @@ Set the timer for the Idle_a power condition on drive .Pa ada0 to 60.1 seconds, enable that particular power condition, and save the timer value and the enabled state of the power condition. -.Pp .Bd -literal -offset indent camcontrol epc da4 -c goto -p Standby_z -H .Ed @@ -2885,7 +2879,6 @@ the drive's lowest power state) and hold in that state explicitly released by another .Cm goto command. -.Pp .Bd -literal -offset indent camcontrol epc da2 -c status -P .Ed @@ -2903,7 +2896,6 @@ to only send the .Tn ATA CHECK POWER MODE command, which should not trigger a change in the drive's power state. -.Pp .Bd -literal -offset indent camcontrol epc ada0 -c list .Ed @@ -2911,7 +2903,6 @@ camcontrol epc ada0 -c list Display the ATA Power Conditions log (Log Address 0x08) for drive .Pa ada0 . -.Pp .Bd -literal -offset indent camcontrol timestamp sa0 -s -f "%a, %d %b %Y %T %z" \e -T "Wed, 26 Oct 2016 21:43:57 -0600" From owner-svn-src-all@freebsd.org Fri Nov 20 12:31:03 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 526D72E93BD; Fri, 20 Nov 2020 12:31:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcwrR1rS8z3K1j; Fri, 20 Nov 2020 12:31:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 31F4B15DE3; Fri, 20 Nov 2020 12:31:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKCV3qO028514; Fri, 20 Nov 2020 12:31:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKCV2mq028512; Fri, 20 Nov 2020 12:31:02 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011201231.0AKCV2mq028512@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 20 Nov 2020 12:31:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367890 - head/sys/fs/msdosfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/msdosfs X-SVN-Commit-Revision: 367890 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 12:31:03 -0000 Author: kib Date: Fri Nov 20 12:31:02 2020 New Revision: 367890 URL: https://svnweb.freebsd.org/changeset/base/367890 Log: msdosfs: Add trivial support for suspension. Tested by: pho (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27269 Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c head/sys/fs/msdosfs/msdosfs_vnops.c Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_vfsops.c Fri Nov 20 11:45:08 2020 (r367889) +++ head/sys/fs/msdosfs/msdosfs_vfsops.c Fri Nov 20 12:31:02 2020 (r367890) @@ -950,6 +950,12 @@ loop: error = msdosfs_fsiflush(pmp, waitfor); if (error != 0) allerror = error; + + if (allerror == 0 && waitfor == MNT_SUSPEND) { + MNT_ILOCK(mp); + mp->mnt_kern_flag |= MNTK_SUSPEND2 | MNTK_SUSPENDED; + MNT_IUNLOCK(mp); + } return (allerror); } Modified: head/sys/fs/msdosfs/msdosfs_vnops.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_vnops.c Fri Nov 20 11:45:08 2020 (r367889) +++ head/sys/fs/msdosfs/msdosfs_vnops.c Fri Nov 20 12:31:02 2020 (r367890) @@ -848,7 +848,7 @@ msdosfs_fsync(struct vop_fsync_args *ap) * Non-critical metadata for associated directory entries only * gets synced accidentally, as in most file systems. */ - if (ap->a_waitfor == MNT_WAIT) { + if (ap->a_waitfor != MNT_NOWAIT) { devvp = VTODE(ap->a_vp)->de_pmp->pm_devvp; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); allerror = VOP_FSYNC(devvp, MNT_WAIT, ap->a_td); @@ -856,7 +856,7 @@ msdosfs_fsync(struct vop_fsync_args *ap) } else allerror = 0; - error = deupdat(VTODE(ap->a_vp), ap->a_waitfor == MNT_WAIT); + error = deupdat(VTODE(ap->a_vp), ap->a_waitfor != MNT_NOWAIT); if (allerror == 0) allerror = error; return (allerror); From owner-svn-src-all@freebsd.org Fri Nov 20 13:00:29 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 57F522E9FA5; Fri, 20 Nov 2020 13:00:29 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcxVP235tz3LDq; Fri, 20 Nov 2020 13:00:29 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 394A0163C9; Fri, 20 Nov 2020 13:00:29 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKD0T0h046563; Fri, 20 Nov 2020 13:00:29 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKD0TDW046562; Fri, 20 Nov 2020 13:00:29 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <202011201300.0AKD0TDW046562@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Fri, 20 Nov 2020 13:00:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367891 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 367891 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 13:00:29 -0000 Author: tuexen Date: Fri Nov 20 13:00:28 2020 New Revision: 367891 URL: https://svnweb.freebsd.org/changeset/base/367891 Log: Fix an issue I introuced in r367530: tcp_twcheck() can be called with to == NULL for SYN segments. So don't assume tp != NULL. Thanks to jhb@ for reporting and suggesting a fix. PR: 250499 MFC after: 1 week XMFC-with: r367530 Sponsored by: Netflix, Inc. Modified: head/sys/netinet/tcp_timewait.c Modified: head/sys/netinet/tcp_timewait.c ============================================================================== --- head/sys/netinet/tcp_timewait.c Fri Nov 20 12:31:02 2020 (r367890) +++ head/sys/netinet/tcp_timewait.c Fri Nov 20 13:00:28 2020 (r367891) @@ -374,6 +374,7 @@ tcp_twstart(struct tcpcb *tp) /* * Returns 1 if the TIME_WAIT state was killed and we should start over, * looking for a pcb in the listen state. Returns 0 otherwise. + * It be called with to == NULL only for pure SYN-segments. */ int tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, @@ -397,6 +398,8 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, stru goto drop; thflags = th->th_flags; + KASSERT(to != NULL || (thflags & (TH_SYN | TH_ACK)) == TH_SYN, + ("tcp_twcheck: called without options on a non-SYN segment")); /* * NOTE: for FIN_WAIT_2 (to be added later), @@ -411,16 +414,6 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, stru if (thflags & TH_RST) goto drop; - /* - * If timestamps were negotiated during SYN/ACK and a - * segment without a timestamp is received, silently drop - * the segment. - * See section 3.2 of RFC 7323. - */ - if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) { - goto drop; - } - #if 0 /* PAWS not needed at the moment */ /* @@ -454,6 +447,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, stru */ if ((thflags & TH_ACK) == 0) goto drop; + + /* + * If timestamps were negotiated during SYN/ACK and a + * segment without a timestamp is received, silently drop + * the segment. + * See section 3.2 of RFC 7323. + */ + if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) { + goto drop; + } /* * Reset the 2MSL timer if this is a duplicate FIN. From owner-svn-src-all@freebsd.org Fri Nov 20 13:03:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C65F72EA200; Fri, 20 Nov 2020 13:03:39 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from drew.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) (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 4CcxZ34KmCz3Lm5; Fri, 20 Nov 2020 13:03:39 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from [IPv6:2a02:8109:1140:c3d:54e:ecc9:f43c:4649] (unknown [IPv6:2a02:8109:1140:c3d:54e:ecc9:f43c:4649]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTPSA id D795F7220CCE2; Fri, 20 Nov 2020 14:03:29 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.20.0.2.21\)) Subject: Re: svn commit: r367530 - in head/sys/netinet: . tcp_stacks From: Michael Tuexen In-Reply-To: <00fb0227-efd3-e1a2-4178-15bdf6f26712@FreeBSD.org> Date: Fri, 20 Nov 2020 14:03:29 +0100 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011092149.0A9Lnfmh069050@repo.freebsd.org> <9fd00098-0ce9-627e-0163-7ede5aa18d6f@FreeBSD.org> <00fb0227-efd3-e1a2-4178-15bdf6f26712@FreeBSD.org> To: John Baldwin X-Mailer: Apple Mail (2.3654.20.0.2.21) 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: 4CcxZ34KmCz3Lm5 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 13:03:39 -0000 On 20. Nov 2020, at 00:13, John Baldwin wrote: >=20 > On 11/19/20 2:55 PM, John Baldwin wrote: >> On 11/9/20 1:49 PM, Michael Tuexen wrote: >>> Author: tuexen >>> Date: Mon Nov 9 21:49:40 2020 >>> New Revision: 367530 >>> URL: https://svnweb.freebsd.org/changeset/base/367530 >>>=20 >>> Log: >>> RFC 7323 specifies that: >>> * TCP segments without timestamps should be dropped when support = for >>> the timestamp option has been negotiated. >>> * TCP segments with timestamps should be processed normally if = support >>> for the timestamp option has not been negotiated. >>> This patch enforces the above. >>>=20 >>> PR: 250499 >>> Reviewed by: gnn, rrs >>> MFC after: 1 week >>> Sponsored by: Netflix, Inc >>> Differential Revision: https://reviews.freebsd.org/D27148 >>>=20 >>> Modified: >>> head/sys/netinet/tcp_input.c >>> head/sys/netinet/tcp_stacks/bbr.c >>> head/sys/netinet/tcp_stacks/rack.c >>> head/sys/netinet/tcp_syncache.c >>> head/sys/netinet/tcp_timewait.c >>>=20 >>> Modified: head/sys/netinet/tcp_timewait.c >>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>> --- head/sys/netinet/tcp_timewait.c Mon Nov 9 21:19:17 2020 = (r367529) >>> +++ head/sys/netinet/tcp_timewait.c Mon Nov 9 21:49:40 2020 = (r367530) >>> @@ -376,7 +376,7 @@ tcp_twstart(struct tcpcb *tp) >>> * looking for a pcb in the listen state. Returns 0 otherwise. >>> */ >>> int >>> -tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unused, struct = tcphdr *th, >>> +tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr = *th, >>> struct mbuf *m, int tlen) >>> { >>> struct tcptw *tw; >>> @@ -410,6 +410,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt = *to __unu >>> */ >>> if (thflags & TH_RST) >>> goto drop; >>> + >>> + /* >>> + * If timestamps were negotiated during SYN/ACK and a >>> + * segment without a timestamp is received, silently drop >>> + * the segment. >>> + * See section 3.2 of RFC 7323. >>> + */ >>> + if (((to->to_flags & TOF_TS) =3D=3D 0) && (tw->t_recent !=3D 0)) = { >>> + goto drop; >>> + } >>=20 >> This causes an insta-panic with TOE because toe_4tuple_check() passes = in a NULL >> pointer for 'to'. I'm working on a fix for that, but perhaps wait to = MFC until >> the fix is ready so they can be merged together? >>=20 >> That said, TOE only calls this in the case that it has gotten a new = SYN, so I >> wonder if it makes sense to apply this check on a new SYN. For a new = SYN, >> shouldn't we not care if the new connection is using a different = timestamp >> option from the old connection? The language in RFC 7323 3.2 is all = about >> segments on an existing connection, not segments from a new = connection I think? >>=20 >> That is, I think we should perhaps move this check after the TH_SYN = check so >> that a mismatch doesn't prevent recycling? >=20 > Actually, we move the check below requiring TH_ACK, I think this would = fix the TOE > case and also DTRT for plain SYNs for non-TOE: Yes, I committed this in = https://svnweb.freebsd.org/changeset/base/367891 and also added a comment and a KASSERT. >=20 > diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c > index c52eab956303..85f1ccbe40f9 100644 > --- a/sys/netinet/tcp_timewait.c > +++ b/sys/netinet/tcp_timewait.c > @@ -411,16 +411,6 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, = struct tcphdr *th, > if (thflags & TH_RST) > goto drop; >=20 > - /* > - * If timestamps were negotiated during SYN/ACK and a > - * segment without a timestamp is received, silently drop > - * the segment. > - * See section 3.2 of RFC 7323. > - */ > - if (((to->to_flags & TOF_TS) =3D=3D 0) && (tw->t_recent !=3D 0)) = { > - goto drop; > - } > - > #if 0 > /* PAWS not needed at the moment */ > /* > @@ -455,6 +445,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, = struct tcphdr *th, > if ((thflags & TH_ACK) =3D=3D 0) > goto drop; >=20 > + /* > + * If timestamps were negotiated during SYN/ACK and a > + * segment without a timestamp is received, silently drop > + * the segment. > + * See section 3.2 of RFC 7323. > + */ > + if (((to->to_flags & TOF_TS) =3D=3D 0) && (tw->t_recent !=3D 0)) = { > + goto drop; > + } > + > /* > * Reset the 2MSL timer if this is a duplicate FIN. > */ >=20 > The commented out PAWS bits would also seem to not be relevant for = SYN-only > packets? However, I'm less sure of if that bit should be moved later = as > well. (Or perhaps it should just be removed. It has been #if 0'd = since the > timewait structure was first added back in 2003 by jlemon@) Yes, I saw that also. Will deal with it in a separate issue... Thanks for reporting the issue and sorry for breaking the code. I didn't = know about this use of tcp_twcheck() and have no hardware to test this... Best regards Michael >=20 > --=20 > John Baldwin From owner-svn-src-all@freebsd.org Fri Nov 20 14:02:44 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2895D2EBC4B; Fri, 20 Nov 2020 14:02:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CcytD0dJZz3Pw7; Fri, 20 Nov 2020 14:02:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 08A2817261; Fri, 20 Nov 2020 14:02:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKE2hpF088718; Fri, 20 Nov 2020 14:02:43 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKE2hG8088717; Fri, 20 Nov 2020 14:02:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011201402.0AKE2hG8088717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 20 Nov 2020 14:02:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367892 - head/sys/dev/sound/pcm X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/dev/sound/pcm X-SVN-Commit-Revision: 367892 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 14:02:44 -0000 Author: kib Date: Fri Nov 20 14:02:43 2020 New Revision: 367892 URL: https://svnweb.freebsd.org/changeset/base/367892 Log: Unlock channels when any of them are locked, when returning for non-busy state. Reported and tested by: "Wall, Stephen" Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/dev/sound/pcm/dsp.c Modified: head/sys/dev/sound/pcm/dsp.c ============================================================================== --- head/sys/dev/sound/pcm/dsp.c Fri Nov 20 13:00:28 2020 (r367891) +++ head/sys/dev/sound/pcm/dsp.c Fri Nov 20 14:02:43 2020 (r367892) @@ -857,6 +857,8 @@ dsp_io_ops(struct cdev *i_dev, struct uio *buf) getchns(i_dev, &rdch, &wrch, prio); if (*ch == NULL || !((*ch)->flags & CHN_F_BUSY)) { + if (rdch != NULL || wrch != NULL) + relchns(i_dev, rdch, wrch, prio); PCM_GIANT_EXIT(d); return (EBADF); } From owner-svn-src-all@freebsd.org Fri Nov 20 14:37:08 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 82C652EC549; Fri, 20 Nov 2020 14:37:08 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cczdw3HRQz3jV2; Fri, 20 Nov 2020 14:37:08 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 639C3171FF; Fri, 20 Nov 2020 14:37:08 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKEb8vw007675; Fri, 20 Nov 2020 14:37:08 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKEb8r0007674; Fri, 20 Nov 2020 14:37:08 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202011201437.0AKEb8r0007674@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Fri, 20 Nov 2020 14:37:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367893 - head/libexec/rc/rc.d X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/libexec/rc/rc.d X-SVN-Commit-Revision: 367893 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 14:37:08 -0000 Author: 0mp (doc,ports committer) Date: Fri Nov 20 14:37:07 2020 New Revision: 367893 URL: https://svnweb.freebsd.org/changeset/base/367893 Log: Revert r367291 (KEYWORD: shutdown for rc.d/zfs) The problem is that zfs is asked to stop too early in the shutdown sequence. Other services, such as syslog may still be running and have some files open (e.g., under /var/log). This of course causes the messages like: cannot unmount '/var/run': umount failed cannot unmount '/var/log': umount failed cannot unmount '/var': umount failed cannot unmount '/usr/home': umount failed cannot unmount '/usr': umount failed cannot unmount '/': umount failed For now, let's remove the shutdown KEYWORD from the zfs service, as people are reporting problems in their setups: https://lists.freebsd.org/pipermail/freebsd-current/2020-November/077559.html In the future, we may think of stopping zfs on shutdown after all the other services and just before init(8) exits. Another interesting option might be to a new rcorder(8) KEYWORD like "shutdownjail", but this idea would need to be discussed a bit. Reported by: Johan Hendriks Reported by: Yasuhiro KIMURA Reported by: Tomoaki AOKI Approved by: kevans (src) MFC: 3 days Differential Revision: https://reviews.freebsd.org/D27263 Modified: head/libexec/rc/rc.d/zfs Modified: head/libexec/rc/rc.d/zfs ============================================================================== --- head/libexec/rc/rc.d/zfs Fri Nov 20 14:02:43 2020 (r367892) +++ head/libexec/rc/rc.d/zfs Fri Nov 20 14:37:07 2020 (r367893) @@ -6,7 +6,6 @@ # PROVIDE: zfs # REQUIRE: zfsbe # BEFORE: FILESYSTEMS var -# KEYWORD: shutdown . /etc/rc.subr From owner-svn-src-all@freebsd.org Fri Nov 20 14:45:46 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 543ED2EC7EA; Fri, 20 Nov 2020 14:45:46 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cczqt1zj7z3k2Q; Fri, 20 Nov 2020 14:45:46 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3703E178E0; Fri, 20 Nov 2020 14:45:46 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKEjkUm014022; Fri, 20 Nov 2020 14:45:46 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKEjkH3014021; Fri, 20 Nov 2020 14:45:46 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011201445.0AKEjkH3014021@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Fri, 20 Nov 2020 14:45:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367894 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 367894 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 14:45:46 -0000 Author: mhorne Date: Fri Nov 20 14:45:45 2020 New Revision: 367894 URL: https://svnweb.freebsd.org/changeset/base/367894 Log: Make net/ifq.h C++ friendly Don't use "new" as an identifier, and add explicit casts from void *. As a general policy, FreeBSD doesn't make any C++ compatibility guarantees for kernel headers like it does for userland, but it is a small effort to do so in this case, to the benefit of a downstream consumer (NetApp). Reviewed by: rscheff Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D27286 Modified: head/sys/net/ifq.h Modified: head/sys/net/ifq.h ============================================================================== --- head/sys/net/ifq.h Fri Nov 20 14:37:07 2020 (r367893) +++ head/sys/net/ifq.h Fri Nov 20 14:45:45 2020 (r367894) @@ -336,7 +336,7 @@ drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, s } static __inline void -drbr_putback(struct ifnet *ifp, struct buf_ring *br, struct mbuf *new) +drbr_putback(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m_new) { /* * The top of the list needs to be swapped @@ -348,11 +348,11 @@ drbr_putback(struct ifnet *ifp, struct buf_ring *br, s * Peek in altq case dequeued it * so put it back. */ - IFQ_DRV_PREPEND(&ifp->if_snd, new); + IFQ_DRV_PREPEND(&ifp->if_snd, m_new); return; } #endif - buf_ring_putback_sc(br, new); + buf_ring_putback_sc(br, m_new); } static __inline struct mbuf * @@ -371,7 +371,7 @@ drbr_peek(struct ifnet *ifp, struct buf_ring *br) return (m); } #endif - return(buf_ring_peek_clear_sc(br)); + return ((struct mbuf *)buf_ring_peek_clear_sc(br)); } static __inline void @@ -383,7 +383,7 @@ drbr_flush(struct ifnet *ifp, struct buf_ring *br) if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) IFQ_PURGE(&ifp->if_snd); #endif - while ((m = buf_ring_dequeue_sc(br)) != NULL) + while ((m = (struct mbuf *)buf_ring_dequeue_sc(br)) != NULL) m_freem(m); } @@ -406,7 +406,7 @@ drbr_dequeue(struct ifnet *ifp, struct buf_ring *br) return (m); } #endif - return (buf_ring_dequeue_sc(br)); + return ((struct mbuf *)buf_ring_dequeue_sc(br)); } static __inline void @@ -438,11 +438,11 @@ drbr_dequeue_cond(struct ifnet *ifp, struct buf_ring * return (m); } #endif - m = buf_ring_peek(br); + m = (struct mbuf *)buf_ring_peek(br); if (m == NULL || func(m, arg) == 0) return (NULL); - return (buf_ring_dequeue_sc(br)); + return ((struct mbuf *)buf_ring_dequeue_sc(br)); } static __inline int From owner-svn-src-all@freebsd.org Fri Nov 20 15:19:30 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2BDB2ED93B; Fri, 20 Nov 2020 15:19:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd0Zp5Dxrz3m01; Fri, 20 Nov 2020 15:19:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 999E51840B; Fri, 20 Nov 2020 15:19:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKFJUVX032983; Fri, 20 Nov 2020 15:19:30 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKFJU42032982; Fri, 20 Nov 2020 15:19:30 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011201519.0AKFJU42032982@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 20 Nov 2020 15:19:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367895 - head/sys/fs/msdosfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/msdosfs X-SVN-Commit-Revision: 367895 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 15:19:31 -0000 Author: kib Date: Fri Nov 20 15:19:30 2020 New Revision: 367895 URL: https://svnweb.freebsd.org/changeset/base/367895 Log: msdosfs: suspend around unmount or remount rw->ro. This also eliminates unsafe use of VFS_SYNC(MNT_WAIT). Requested by: mckusick Discussed with: imp Tested by: pho (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D27269 Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_vfsops.c Fri Nov 20 14:45:45 2020 (r367894) +++ head/sys/fs/msdosfs/msdosfs_vfsops.c Fri Nov 20 15:19:30 2020 (r367895) @@ -248,22 +248,28 @@ msdosfs_mount(struct mount *mp) pmp = VFSTOMSDOSFS(mp); if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) { - error = VFS_SYNC(mp, MNT_WAIT); - if (error) + if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0) return (error); + error = vfs_write_suspend_umnt(mp); + if (error != 0) + return (error); + flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; error = vflush(mp, 0, flags, td); - if (error) + if (error != 0) { + vfs_write_resume(mp, 0); return (error); + } /* * Now the volume is clean. Mark it so while the * device is still rw. */ error = markvoldirty(pmp, 0); - if (error) { + if (error != 0) { + vfs_write_resume(mp, 0); (void)markvoldirty(pmp, 1); return (error); } @@ -273,6 +279,7 @@ msdosfs_mount(struct mount *mp) error = g_access(pmp->pm_cp, 0, -1, 0); g_topology_unlock(); if (error) { + vfs_write_resume(mp, 0); (void)markvoldirty(pmp, 1); return (error); } @@ -286,6 +293,7 @@ msdosfs_mount(struct mount *mp) MNT_ILOCK(mp); mp->mnt_flag |= MNT_RDONLY; MNT_IUNLOCK(mp); + vfs_write_resume(mp, 0); } else if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && !vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) { /* @@ -749,21 +757,31 @@ msdosfs_unmount(struct mount *mp, int mntflags) { struct msdosfsmount *pmp; int error, flags; + bool susp; error = flags = 0; pmp = VFSTOMSDOSFS(mp); - if ((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0) - error = msdosfs_sync(mp, MNT_WAIT); + susp = (pmp->pm_flags & MSDOSFSMNT_RONLY) == 0; + + if (susp) { + error = vfs_write_suspend_umnt(mp); + if (error != 0) + return (error); + } + if ((mntflags & MNT_FORCE) != 0) flags |= FORCECLOSE; - else if (error != 0) - return (error); error = vflush(mp, 0, flags, curthread); - if (error != 0 && error != ENXIO) + if (error != 0 && error != ENXIO) { + if (susp) + vfs_write_resume(mp, VR_START_WRITE); return (error); - if ((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0) { + } + if (susp) { error = markvoldirty(pmp, 0); - if (error && error != ENXIO) { + if (error != 0 && error != ENXIO) { + if (susp) + vfs_write_resume(mp, VR_START_WRITE); (void)markvoldirty(pmp, 1); return (error); } @@ -800,6 +818,9 @@ msdosfs_unmount(struct mount *mp, int mntflags) BO_UNLOCK(bo); } #endif + if (susp) + vfs_write_resume(mp, VR_START_WRITE); + g_topology_lock(); g_vfs_close(pmp->pm_cp); g_topology_unlock(); From owner-svn-src-all@freebsd.org Fri Nov 20 15:21:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4DDE2EDBAE; Fri, 20 Nov 2020 15:21:10 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd0ck6CkQz3mDw; Fri, 20 Nov 2020 15:21:10 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C883B17C77; Fri, 20 Nov 2020 15:21:10 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKFLAYF036551; Fri, 20 Nov 2020 15:21:10 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKFLAQx036541; Fri, 20 Nov 2020 15:21:10 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011201521.0AKFLAQx036541@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Fri, 20 Nov 2020 15:21:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367896 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 367896 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 15:21:11 -0000 Author: mhorne Date: Fri Nov 20 15:21:10 2020 New Revision: 367896 URL: https://svnweb.freebsd.org/changeset/base/367896 Log: riscv: always initialize the static kernel environment Ensure we initialize the static environment when not booting via loader(8), and provide a static buffer if this is the case. This fixes two issues. First, performing the initialization ensures that kenv variables set in the kernel's config file are honored. Previously, any new or overridden values were ignored. Second, providing the static buffer allows variables to be set in the device tree's bootargs property of the chosen node. This can be set by u-boot or by QEMU's '-append' flag. Attempting to this prior to this change resulted in an early panic, since the static environment had no buffer backing it. Submitted by: syrinx (earlier version) Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D25034 Modified: head/sys/riscv/riscv/machdep.c Modified: head/sys/riscv/riscv/machdep.c ============================================================================== --- head/sys/riscv/riscv/machdep.c Fri Nov 20 15:19:30 2020 (r367895) +++ head/sys/riscv/riscv/machdep.c Fri Nov 20 15:21:10 2020 (r367896) @@ -130,6 +130,8 @@ cpuset_t all_harts; extern int *end; +static char static_kenv[PAGE_SIZE]; + static void cpu_startup(void *dummy) { @@ -836,6 +838,8 @@ parse_metadata(void) kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); if (kern_envp != NULL) init_static_kenv(kern_envp, 0); + else + init_static_kenv(static_kenv, sizeof(static_kenv)); #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); From owner-svn-src-all@freebsd.org Fri Nov 20 16:34:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7181D2EF51D; Fri, 20 Nov 2020 16:34:02 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd2Dp2ryhz3qpr; Fri, 20 Nov 2020 16:34:02 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 54FD218CDE; Fri, 20 Nov 2020 16:34:02 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKGY2Bf082542; Fri, 20 Nov 2020 16:34:02 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKGY2S3082541; Fri, 20 Nov 2020 16:34:02 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201634.0AKGY2S3082541@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 16:34:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367897 - head/sbin/devmatch X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/sbin/devmatch X-SVN-Commit-Revision: 367897 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 16:34:02 -0000 Author: gbe (doc committer) Date: Fri Nov 20 16:34:01 2020 New Revision: 367897 URL: https://svnweb.freebsd.org/changeset/base/367897 Log: devmatch(8): Fix section ordering - sections out of conventional order: Sh HISTORY Modified: head/sbin/devmatch/devmatch.8 Modified: head/sbin/devmatch/devmatch.8 ============================================================================== --- head/sbin/devmatch/devmatch.8 Fri Nov 20 15:21:10 2020 (r367896) +++ head/sbin/devmatch/devmatch.8 Fri Nov 20 16:34:01 2020 (r367897) @@ -69,6 +69,10 @@ Produce more verbose output. .Sh SEE ALSO .Xr devinfo 8 , .Xr MODULE_PNP_INFO 9 +.Sh HISTORY +.Nm +first appeared in +.Fx 12.0 . .Sh AUTHORS .An Warner Losh Aq Mt imp@FreeBSD.org .Sh BUGS @@ -94,7 +98,3 @@ logical equivalent in USB, PCI, and others. .Pp Many drivers currently lack proper PNP table decorations and need to be updated. -.Sh HISTORY -.Nm -first appeared in -.Fx 12.0 . From owner-svn-src-all@freebsd.org Fri Nov 20 16:41:32 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 98C622EF557; Fri, 20 Nov 2020 16:41:32 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd2PS40MYz3rK3; Fri, 20 Nov 2020 16:41:32 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C16819588; Fri, 20 Nov 2020 16:41:32 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKGfWxR084378; Fri, 20 Nov 2020 16:41:32 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKGfW9W084377; Fri, 20 Nov 2020 16:41:32 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201641.0AKGfW9W084377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 16:41:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367898 - head/usr.bin/iscsictl X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/usr.bin/iscsictl X-SVN-Commit-Revision: 367898 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 16:41:32 -0000 Author: gbe (doc committer) Date: Fri Nov 20 16:41:32 2020 New Revision: 367898 URL: https://svnweb.freebsd.org/changeset/base/367898 Log: iscsi.conf(5): Fix a mandoc warning - new sentence, new line Modified: head/usr.bin/iscsictl/iscsi.conf.5 Modified: head/usr.bin/iscsictl/iscsi.conf.5 ============================================================================== --- head/usr.bin/iscsictl/iscsi.conf.5 Fri Nov 20 16:34:01 2020 (r367897) +++ head/usr.bin/iscsictl/iscsi.conf.5 Fri Nov 20 16:41:32 2020 (r367898) @@ -146,9 +146,9 @@ for iSCSI over RDMA, or Default is .Qq Ar iSCSI . .It Cm dscp -The DiffServ Codepoint used for sending data. The DSCP can be -set to numeric, or hexadecimal values directly, as well as the -well-defined +The DiffServ Codepoint used for sending data. +The DSCP can be set to numeric, or hexadecimal values directly, +as well as the well-defined .Qq Ar cs and .Qq Ar af From owner-svn-src-all@freebsd.org Fri Nov 20 16:46:51 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F28F52EF83C; Fri, 20 Nov 2020 16:46:51 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd2Wb6bYtz3rhB; Fri, 20 Nov 2020 16:46:51 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CAAE619337; Fri, 20 Nov 2020 16:46:51 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKGkpN1088623; Fri, 20 Nov 2020 16:46:51 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKGkpBd088622; Fri, 20 Nov 2020 16:46:51 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201646.0AKGkpBd088622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 16:46:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367899 - head/usr.sbin/bsnmpd/modules/snmp_wlan X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/usr.sbin/bsnmpd/modules/snmp_wlan X-SVN-Commit-Revision: 367899 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 16:46:52 -0000 Author: gbe (doc committer) Date: Fri Nov 20 16:46:51 2020 New Revision: 367899 URL: https://svnweb.freebsd.org/changeset/base/367899 Log: snmp_wlan(3): Fix mandoc warnings - new sentence, new line Modified: head/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3 Modified: head/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3 ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3 Fri Nov 20 16:41:32 2020 (r367898) +++ head/usr.sbin/bsnmpd/modules/snmp_wlan/snmp_wlan.3 Fri Nov 20 16:46:51 2020 (r367899) @@ -41,8 +41,8 @@ The .Nm snmp_wlan module implements a private BEGEMOT-WIRELESS-MIB, which allows -management of virtual wireless interfaces. The MIB defines objects similar to the -state data and configuration capabilities of +management of virtual wireless interfaces. +The MIB defines objects similar to the state data and configuration capabilities of .Xr ifconfig 8 for configuring virtual wireless interfaces. Therefore one should consider adding write communities or loading the @@ -52,15 +52,15 @@ module on systems where security is crucial. A short description of the Tables and interesting objects in the MIB follows. .Bl -tag -width "XXXXXXXXX" .It Va wlanInterfaceTable -The table is used for creation and deletion of virtual wireless interfaces. To -add a new interface, a SET should be executed on the +The table is used for creation and deletion of virtual wireless interfaces. +To add a new interface, a SET should be executed on the .Va wlanIfaceName column with -value the desired name of the interface. Next the parent interface must be set -via +value the desired name of the interface. +Next the parent interface must be set via .Va wlanParentIfName -column. Any optional parameters may be set -via the +column. +Any optional parameters may be set via the .Va wlanIfaceOperatingMode , .Va wlanIfaceFlags , .Va wlanIfaceBssid @@ -78,9 +78,9 @@ The table contains information about the hardware capa a wireless interface. .It Va wlanIfaceConfigTable The table is used to get or set various configuration parameters for a virtual -wireless interface. Depending on the operating mode of the interface and the -hardware capabilities of the underlying hardware interface, not all parameters -and values may be supported. +wireless interface. +Depending on the operating mode of the interface and the hardware capabilities +of the underlying hardware interface, not all parameters and values may be supported. .It Va wlanIfacePeerTable The table contains information about the associated stations for interfaces operating as access points, or the stations identified as neighbors in the IBSS @@ -106,8 +106,9 @@ Access Control configuration for wireless interfaces o The table with Access Control MAC entries for which the configured Access Control Policy on wireless interfaces operating in Host AP mode is applied. .Va wlanMACAccessControlMACStatus -column is used to add or delete MAC ACL entries. A set with value createAndGo(4) -will add new entry, while with value destroy(6) will delete an existing one. +column is used to add or delete MAC ACL entries. +A set with value createAndGo(4) will add new entry, while with value destroy(6) +will delete an existing one. .It Va wlanMeshRoutingConfig The subtree contains system configuration related to Wireless Mesh Routing. .It Va wlanMeshInterfaceTable @@ -121,8 +122,9 @@ The mesh routing table for interfaces operating as mes forwarding packets on a mesh network. .Va wlanMeshRouteStatus column is used to add or delete entries in the mesh routing table for an -interface. A set with value createAndGo(4) will add new entry, while with value -destroy(6) will delete an existing one. +interface. +A set with value createAndGo(4) will add new entry, while with value destroy(6) +will delete an existing one. .It Va wlanMeshStatsTable Summary statistics for each virtual wireless interface operating as mesh point. .It Va wlanMeshHWMPConfig From owner-svn-src-all@freebsd.org Fri Nov 20 16:50:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC7A02EF8B7; Fri, 20 Nov 2020 16:50:52 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd2cD5jN3z3ryn; Fri, 20 Nov 2020 16:50:52 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6DD2191FA; Fri, 20 Nov 2020 16:50:52 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKGoqB8091794; Fri, 20 Nov 2020 16:50:52 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKGoqJD091793; Fri, 20 Nov 2020 16:50:52 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201650.0AKGoqJD091793@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 16:50:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367900 - head/usr.sbin/syslogd X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/usr.sbin/syslogd X-SVN-Commit-Revision: 367900 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 16:50:52 -0000 Author: gbe (doc committer) Date: Fri Nov 20 16:50:52 2020 New Revision: 367900 URL: https://svnweb.freebsd.org/changeset/base/367900 Log: syslog.conf(5): Fix a few mandoc warnings - new sentence, new line - skipping paragraph macro: Pp at the end of Sh Modified: head/usr.sbin/syslogd/syslog.conf.5 Modified: head/usr.sbin/syslogd/syslog.conf.5 ============================================================================== --- head/usr.sbin/syslogd/syslog.conf.5 Fri Nov 20 16:46:51 2020 (r367899) +++ head/usr.sbin/syslogd/syslog.conf.5 Fri Nov 20 16:50:52 2020 (r367900) @@ -245,7 +245,8 @@ specification is a line beginning with or .Ql \&: and the following blocks will be applied only when filter value -matches given filter propertie's value. See +matches given filter propertie's value. +See .Sx PROPERTY-BASED FILTERS section for more details. .Pp @@ -464,8 +465,8 @@ or .Ql \&: followed by three comma-separated fields .Em property , operator , \&"value\&" . -Value must be double-quoted. A double quote and backslash must be escaped by -a backslash. +Value must be double-quoted. +A double quote and backslash must be escaped by a backslash. .Pp Following .Em properties @@ -521,7 +522,6 @@ Operator may be prefixed by .Ql icase_ - to make comparison function case insensitive .El -.Pp .Sh IMPLEMENTATION NOTES The .Dq kern From owner-svn-src-all@freebsd.org Fri Nov 20 16:57:07 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 59A8C2EFC9B; Fri, 20 Nov 2020 16:57:07 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd2lR293Xz3sPv; Fri, 20 Nov 2020 16:57:07 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38D1419541; Fri, 20 Nov 2020 16:57:07 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKGv76p094397; Fri, 20 Nov 2020 16:57:07 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKGv7th094396; Fri, 20 Nov 2020 16:57:07 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201657.0AKGv7th094396@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 16:57:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367901 - head/usr.sbin/wpa/hostapd X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/usr.sbin/wpa/hostapd X-SVN-Commit-Revision: 367901 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 16:57:07 -0000 Author: gbe (doc committer) Date: Fri Nov 20 16:57:06 2020 New Revision: 367901 URL: https://svnweb.freebsd.org/changeset/base/367901 Log: hostapd.conf(5): Fix a mandoc warning - new sentence, new line Modified: head/usr.sbin/wpa/hostapd/hostapd.conf.5 Modified: head/usr.sbin/wpa/hostapd/hostapd.conf.5 ============================================================================== --- head/usr.sbin/wpa/hostapd/hostapd.conf.5 Fri Nov 20 16:50:52 2020 (r367900) +++ head/usr.sbin/wpa/hostapd/hostapd.conf.5 Fri Nov 20 16:57:06 2020 (r367901) @@ -67,8 +67,9 @@ The following parameters are recognized: Interface name. Should be set in .Dq hostap -mode. Make certain that there are no spaces after the interface name, -or hostapd will complain that the interface does not exist. +mode. +Make certain that there are no spaces after the interface name, or hostapd wil +complain that the interface does not exist. .It Va debug Debugging mode: 0 = no, 1 = minimal, 2 = verbose, 3 = msg dumps, 4 = excessive. From owner-svn-src-all@freebsd.org Fri Nov 20 16:59:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C65B2EF8DF; Fri, 20 Nov 2020 16:59:52 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd2pc2j6Tz3sQr; Fri, 20 Nov 2020 16:59:52 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B5F6196B5; Fri, 20 Nov 2020 16:59:52 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKGxqfD094506; Fri, 20 Nov 2020 16:59:52 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKGxqf2094505; Fri, 20 Nov 2020 16:59:52 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201659.0AKGxqf2094505@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 16:59:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367902 - head/usr.sbin/crashinfo X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/usr.sbin/crashinfo X-SVN-Commit-Revision: 367902 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 16:59:52 -0000 Author: gbe (doc committer) Date: Fri Nov 20 16:59:51 2020 New Revision: 367902 URL: https://svnweb.freebsd.org/changeset/base/367902 Log: crashinfo(8): Fix a few mandoc warnings - new sentence, new line Modified: head/usr.sbin/crashinfo/crashinfo.8 Modified: head/usr.sbin/crashinfo/crashinfo.8 ============================================================================== --- head/usr.sbin/crashinfo/crashinfo.8 Fri Nov 20 16:57:06 2020 (r367901) +++ head/usr.sbin/crashinfo/crashinfo.8 Fri Nov 20 16:59:51 2020 (r367902) @@ -89,9 +89,11 @@ and The options are as follows: .Bl -tag -width indent .It Fl b -Run in batch mode. Write most messages to the +Run in batch mode. +Write most messages to the .Pa core.txt.XX -file instead of the terminal. This flag is used when +file instead of the terminal. +This flag is used when .Nm is run during boot. .It Fl d Ar crashdir From owner-svn-src-all@freebsd.org Fri Nov 20 17:04:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 50E24468021; Fri, 20 Nov 2020 17:04:50 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd2wL1sYCz3t04; Fri, 20 Nov 2020 17:04:50 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2849F19B0B; Fri, 20 Nov 2020 17:04:50 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKH4orU001052; Fri, 20 Nov 2020 17:04:50 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKH4o5J001051; Fri, 20 Nov 2020 17:04:50 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201704.0AKH4o5J001051@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 17:04:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367903 - head/usr.sbin/moused X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/usr.sbin/moused X-SVN-Commit-Revision: 367903 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 17:04:50 -0000 Author: gbe (doc committer) Date: Fri Nov 20 17:04:49 2020 New Revision: 367903 URL: https://svnweb.freebsd.org/changeset/base/367903 Log: moused(8): Fix a few mandoc warnings - new sentence, new line Modified: head/usr.sbin/moused/moused.8 Modified: head/usr.sbin/moused/moused.8 ============================================================================== --- head/usr.sbin/moused/moused.8 Fri Nov 20 16:59:51 2020 (r367902) +++ head/usr.sbin/moused/moused.8 Fri Nov 20 17:04:49 2020 (r367903) @@ -147,7 +147,8 @@ is enabled, the option can be used to set the .Ar distance (in pixels) that the mouse must move before a scroll event -is generated. This effectively controls the scrolling speed. +is generated. +This effectively controls the scrolling speed. The default .Ar distance is 2 pixels. @@ -240,20 +241,21 @@ drive the pointer quickly across the screen. The .Ar exp value specifies the exponent, which is basically -the amount of acceleration. Useful values are in the -range 1.1 to 2.0, but it depends on your mouse hardware -and your personal preference. A value of 1.0 means no -exponential acceleration. A value of 2.0 means squared -acceleration (i.e. if you move the mouse twice as fast, -the pointer will move four times as fast on the screen). +the amount of acceleration. +Useful values are in the range 1.1 to 2.0, but it depends on +your mouse hardware and your personal preference. +A value of 1.0 means no exponential acceleration. +A value of 2.0 means squared acceleration (i.e. if +you move the mouse twice as fast, the pointer will move +four times as fast on the screen). Values beyond 2.0 are possible but not recommended. A good value to start is probably 1.5. .Pp The optional .Ar offset -value specifies the distance at which the acceleration -begins. The default is 1.0, which means that the -acceleration is applied to movements larger than one unit. +value specifies the distance at which the acceleration begins. +The default is 1.0, which means that the acceleration is applied +to movements larger than one unit. If you specify a larger value, it takes more speed for the acceleration to kick in, i.e. the speed range for small and accurate movements is wider. @@ -263,8 +265,8 @@ not satisfied with the behaviour, try a value of 2.0. Note that the .Fl A option interacts badly with the X server's own acceleration, -which doesn't work very well anyway. Therefore it is -recommended to switch it off if necessary: +which doesn't work very well anyway. +Therefore it is recommended to switch it off if necessary: .Dq xset m 1 . .It Fl a Ar X Ns Op , Ns Ar Y Accelerate or decelerate the mouse input. From owner-svn-src-all@freebsd.org Fri Nov 20 17:13:14 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08289468589; Fri, 20 Nov 2020 17:13:14 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd3616pxjz3th2; Fri, 20 Nov 2020 17:13:13 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCAB919A63; Fri, 20 Nov 2020 17:13:13 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKHDDd4006752; Fri, 20 Nov 2020 17:13:13 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKHDD8x006751; Fri, 20 Nov 2020 17:13:13 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202011201713.0AKHDD8x006751@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Fri, 20 Nov 2020 17:13:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367904 - head/usr.sbin/wpa/hostapd X-SVN-Group: head X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: head/usr.sbin/wpa/hostapd X-SVN-Commit-Revision: 367904 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 17:13:14 -0000 Author: gbe (doc committer) Date: Fri Nov 20 17:13:13 2020 New Revision: 367904 URL: https://svnweb.freebsd.org/changeset/base/367904 Log: hostapd.conf(5): Add missing 'l' In r367901 I accidentally deleted the 'l' while fixing a few mandoc erros. Spotted by: Yuri Pankov Modified: head/usr.sbin/wpa/hostapd/hostapd.conf.5 Modified: head/usr.sbin/wpa/hostapd/hostapd.conf.5 ============================================================================== --- head/usr.sbin/wpa/hostapd/hostapd.conf.5 Fri Nov 20 17:04:49 2020 (r367903) +++ head/usr.sbin/wpa/hostapd/hostapd.conf.5 Fri Nov 20 17:13:13 2020 (r367904) @@ -68,7 +68,7 @@ Interface name. Should be set in .Dq hostap mode. -Make certain that there are no spaces after the interface name, or hostapd wil +Make certain that there are no spaces after the interface name, or hostapd will complain that the interface does not exist. .It Va debug Debugging mode: 0 = no, 1 = minimal, 2 = verbose, 3 = msg dumps, 4 = From owner-svn-src-all@freebsd.org Fri Nov 20 17:26:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B01324687CE; Fri, 20 Nov 2020 17:26:02 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd3Np4brrz3vNN; Fri, 20 Nov 2020 17:26:02 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 90F4D19EEC; Fri, 20 Nov 2020 17:26:02 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKHQ2Vl012969; Fri, 20 Nov 2020 17:26:02 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKHQ2tl012968; Fri, 20 Nov 2020 17:26:02 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <202011201726.0AKHQ2tl012968@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Fri, 20 Nov 2020 17:26:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367905 - head/cddl/contrib/opensolaris/common/ctf X-SVN-Group: head X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: head/cddl/contrib/opensolaris/common/ctf X-SVN-Commit-Revision: 367905 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 17:26:02 -0000 Author: jtl Date: Fri Nov 20 17:26:02 2020 New Revision: 367905 URL: https://svnweb.freebsd.org/changeset/base/367905 Log: When copying types from one CTF container to another, ensure that we encode 0-length (i.e. "") structure and union member names as offset 0. This ensures that we don't confuse other parts of the CTF code which expect this encoding. This resolves a Dtrace error resolving members of anonymous structs/unions within the (struct mbuf) type which some users were seeing after r366908. While here, update the code in ctf_add_generic() to encode 0-length type names as offset 0. Reviewed by: markj MFC after: 2 weeks Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27246 Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c ============================================================================== --- head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Fri Nov 20 17:13:13 2020 (r367904) +++ head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Fri Nov 20 17:26:02 2020 (r367905) @@ -615,7 +615,7 @@ ctf_add_generic(ctf_file_t *fp, uint_t flag, const cha if ((dtd = ctf_alloc(sizeof (ctf_dtdef_t))) == NULL) return (ctf_set_errno(fp, EAGAIN)); - if (name != NULL && (s = ctf_strdup(name)) == NULL) { + if (name != NULL && *name != '\0' && (s = ctf_strdup(name)) == NULL) { ctf_free(dtd, sizeof (ctf_dtdef_t)); return (ctf_set_errno(fp, EAGAIN)); } @@ -1217,7 +1217,7 @@ membadd(const char *name, ctf_id_t type, ulong_t offse if ((dmd = ctf_alloc(sizeof (ctf_dmdef_t))) == NULL) return (ctf_set_errno(ctb->ctb_file, EAGAIN)); - if (name != NULL && (s = ctf_strdup(name)) == NULL) { + if (name != NULL && *name != '\0' && (s = ctf_strdup(name)) == NULL) { ctf_free(dmd, sizeof (ctf_dmdef_t)); return (ctf_set_errno(ctb->ctb_file, EAGAIN)); } From owner-svn-src-all@freebsd.org Fri Nov 20 18:02:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6761B468F40; Fri, 20 Nov 2020 18:02:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd4BQ2XJpz4R2F; Fri, 20 Nov 2020 18:02:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 498461A699; Fri, 20 Nov 2020 18:02:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKI26Qq036543; Fri, 20 Nov 2020 18:02:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKI24tL036535; Fri, 20 Nov 2020 18:02:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011201802.0AKI24tL036535@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Nov 2020 18:02:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367906 - head/sys/dev/isp X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/isp X-SVN-Commit-Revision: 367906 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 18:02:06 -0000 Author: mav Date: Fri Nov 20 18:02:04 2020 New Revision: 367906 URL: https://svnweb.freebsd.org/changeset/base/367906 Log: Cleanup DMA handling. - Make isp_start() to set all the IOCB fields aside of S/G list, removing extra information from isp_send_cmd(), now only doing S/G lists and sending. - Turn DMA setup/free from being card and PCI-specific into OS-specific, instead add new card-specific method for isp_send_cmd(). Previously this function was a monster handling all the cards. - Remove double error code translation. Modified: head/sys/dev/isp/isp.c head/sys/dev/isp/isp_freebsd.c head/sys/dev/isp/isp_freebsd.h head/sys/dev/isp/isp_library.c head/sys/dev/isp/isp_library.h head/sys/dev/isp/isp_pci.c head/sys/dev/isp/isp_target.c head/sys/dev/isp/ispvar.h Modified: head/sys/dev/isp/isp.c ============================================================================== --- head/sys/dev/isp/isp.c Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/isp.c Fri Nov 20 18:02:04 2020 (r367906) @@ -2822,35 +2822,31 @@ isp_start(XS_T *xs) goto start_again; } - reqp->req_header.rqs_entry_count = 1; - reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS; - /* - * Set task attributes - */ - if (XS_TAG_P(xs)) - reqp->req_task_attribute = XS_TAG_TYPE(xs); - else - reqp->req_task_attribute = FCP_CMND_TASK_ATTR_SIMPLE; - reqp->req_task_attribute |= (XS_PRIORITY(xs) << FCP_CMND_PRIO_SHIFT) & - FCP_CMND_PRIO_MASK; - - /* * NB: we do not support long CDBs (yet) */ cdblen = XS_CDBLEN(xs); - if (cdblen > sizeof (reqp->req_cdb)) { isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen); XS_SETERR(xs, HBA_REQINVAL); return (CMD_COMPLETE); } + reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS; + reqp->req_header.rqs_entry_count = 1; reqp->req_nphdl = lp->handle; - reqp->req_tidlo = lp->portid; - reqp->req_tidhi = lp->portid >> 16; - reqp->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs)); + reqp->req_time = XS_TIME(xs); be64enc(reqp->req_lun, CAM_EXTLUN_BYTE_SWIZZLE(XS_LUN(xs))); + if (XS_XFRIN(xs)) + reqp->req_alen_datadir = FCP_CMND_DATA_READ; + else if (XS_XFROUT(xs)) + reqp->req_alen_datadir = FCP_CMND_DATA_WRITE; + if (XS_TAG_P(xs)) + reqp->req_task_attribute = XS_TAG_TYPE(xs); + else + reqp->req_task_attribute = FCP_CMND_TASK_ATTR_SIMPLE; + reqp->req_task_attribute |= (XS_PRIORITY(xs) << FCP_CMND_PRIO_SHIFT) & + FCP_CMND_PRIO_MASK; if (FCPARAM(isp, XS_CHANNEL(xs))->fctape_enabled && (lp->prli_word3 & PRLI_WD3_RETRY)) { if (FCP_NEXT_CRN(isp, &reqp->req_crn, xs)) { isp_prt(isp, ISP_LOG_WARN1, @@ -2860,8 +2856,11 @@ isp_start(XS_T *xs) return (CMD_EAGAIN); } } - reqp->req_time = XS_TIME(xs); ISP_MEMCPY(reqp->req_cdb, XS_CDBP(xs), cdblen); + reqp->req_dl = XS_XFRLEN(xs); + reqp->req_tidlo = lp->portid; + reqp->req_tidhi = lp->portid >> 16; + reqp->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs)); /* Whew. Thankfully the same for type 7 requests */ reqp->req_handle = isp_allocate_handle(isp, xs, ISP_HANDLE_INITIATOR); @@ -2878,7 +2877,7 @@ isp_start(XS_T *xs) * The callee is responsible for adding all requests at this point. */ dmaresult = ISP_DMASETUP(isp, xs, reqp); - if (dmaresult != CMD_QUEUED) { + if (dmaresult != 0) { isp_destroy_handle(isp, reqp->req_handle); /* * dmasetup sets actual error in packet, and @@ -2887,7 +2886,7 @@ isp_start(XS_T *xs) return (dmaresult); } isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "START cmd cdb[0]=0x%x datalen %ld", XS_CDBP(xs)[0], (long) XS_XFRLEN(xs)); - return (CMD_QUEUED); + return (0); } /* @@ -3442,8 +3441,7 @@ isp_intr_respq(ispsoftc_t *isp) isp_prt(isp, ISP_LOGDEBUG2, "asked for %lu got raw resid %lu settled for %lu", (u_long)XS_XFRLEN(xs), (u_long)resid, (u_long)XS_GET_RESID(xs)); - if (XS_XFRLEN(xs)) - ISP_DMAFREE(isp, xs, sp->req_handle); + ISP_DMAFREE(isp, xs); isp_destroy_handle(isp, sp->req_handle); ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */ Modified: head/sys/dev/isp/isp_freebsd.c ============================================================================== --- head/sys/dev/isp/isp_freebsd.c Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/isp_freebsd.c Fri Nov 20 18:02:04 2020 (r367906) @@ -1270,7 +1270,7 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, */ cto->ct_syshandle = handle; dmaresult = ISP_DMASETUP(isp, cso, cto); - if (dmaresult != CMD_QUEUED) { + if (dmaresult != 0) { isp_destroy_handle(isp, handle); isp_free_pcmd(isp, ccb); if (dmaresult == CMD_EAGAIN) { @@ -2033,9 +2033,7 @@ isp_watchdog(void *arg) /* * After this point, the command is really dead. */ - if (XS_XFRLEN(xs)) { - ISP_DMAFREE(isp, xs, handle); - } + ISP_DMAFREE(isp, xs); isp_destroy_handle(isp, handle); isp_prt(isp, ISP_LOGERR, "%s: timeout for handle 0x%x", __func__, handle); XS_SETERR(xs, CAM_CMD_TIMEOUT); @@ -2234,9 +2232,7 @@ isp_loop_dead(ispsoftc_t *isp, int chan) continue; } - if (XS_XFRLEN(xs)) { - ISP_DMAFREE(isp, xs, isp->isp_xflist[i].handle); - } + ISP_DMAFREE(isp, xs); isp_destroy_handle(isp, isp->isp_xflist[i].handle); isp_prt(isp, ISP_LOGWARN, "command handle 0x%x for %d.%d.%jx could not be aborted and was destroyed", isp->isp_xflist[i].handle, chan, XS_TGT(xs), @@ -2457,7 +2453,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) break; } } - ccb->csio.req_map = NULL; #ifdef DIAGNOSTIC if (ccb->ccb_h.target_id >= ISP_MAX_TARGETS(isp)) { xpt_print(ccb->ccb_h.path, "invalid target\n"); @@ -2479,7 +2474,7 @@ isp_action(struct cam_sim *sim, union ccb *ccb) } error = isp_start((XS_T *) ccb); switch (error) { - case CMD_QUEUED: + case 0: ccb->ccb_h.status |= CAM_SIM_QUEUED; if (ccb->ccb_h.timeout == CAM_TIME_INFINITY) break; @@ -2541,8 +2536,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb) xpt_done(ccb); break; } - ccb->ccb_h.spriv_field0 = 0; - ccb->ccb_h.spriv_ptr1 = isp; if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { ccb->atio.tag_id = 0; @@ -3444,14 +3437,91 @@ isp_platform_intr_atio(void *arg) ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT); } -void -isp_common_dmateardown(ispsoftc_t *isp, struct ccb_scsiio *csio, uint32_t hdl) +typedef struct { + ispsoftc_t *isp; + struct ccb_scsiio *csio; + void *qe; + int error; +} mush_t; + +static void +isp_dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) { - if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { - bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, BUS_DMASYNC_POSTREAD); + mush_t *mp = (mush_t *) arg; + ispsoftc_t *isp= mp->isp; + struct ccb_scsiio *csio = mp->csio; + bus_dmasync_op_t op; + + if (error) { + mp->error = error; + return; + } + if ((csio->ccb_h.func_code == XPT_CONT_TARGET_IO) ^ + ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)) + op = BUS_DMASYNC_PREREAD; + else + op = BUS_DMASYNC_PREWRITE; + bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, op); + + mp->error = ISP_SEND_CMD(isp, mp->qe, dm_segs, nseg); + if (mp->error) + isp_dmafree(isp, csio); +} + +int +isp_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *qe) +{ + mush_t mp; + int error; + + if (XS_XFRLEN(csio)) { + mp.isp = isp; + mp.csio = csio; + mp.qe = qe; + mp.error = 0; + error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, + (union ccb *)csio, isp_dma2, &mp, BUS_DMA_NOWAIT); + if (error == 0) + error = mp.error; } else { - bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, BUS_DMASYNC_POSTWRITE); + error = ISP_SEND_CMD(isp, qe, NULL, 0); } + switch (error) { + case 0: + case CMD_COMPLETE: + case CMD_EAGAIN: + case CMD_RQLATER: + break; + case ENOMEM: + error = CMD_EAGAIN; + break; + case EINVAL: + case EFBIG: + csio->ccb_h.status = CAM_REQ_INVALID; + error = CMD_COMPLETE; + break; + default: + csio->ccb_h.status = CAM_UNREC_HBA_ERROR; + error = CMD_COMPLETE; + break; + } + return (error); +} + +void +isp_dmafree(ispsoftc_t *isp, struct ccb_scsiio *csio) +{ + bus_dmasync_op_t op; + + if (XS_XFRLEN(csio) == 0) + return; + + if ((csio->ccb_h.func_code == XPT_CONT_TARGET_IO) ^ + ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)) + op = BUS_DMASYNC_POSTREAD; + else + op = BUS_DMASYNC_POSTWRITE; + bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, op); bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap); } Modified: head/sys/dev/isp/isp_freebsd.h ============================================================================== --- head/sys/dev/isp/isp_freebsd.h Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/isp_freebsd.h Fri Nov 20 18:02:04 2020 (r367906) @@ -341,6 +341,9 @@ struct isposinfo { #define ISP_INLINE #endif +#define ISP_DMASETUP(isp, xs, req) isp_dmasetup(isp, xs, req) +#define ISP_DMAFREE(isp, xs) isp_dmafree(isp, xs) + #define NANOTIME_T struct timespec #define GET_NANOTIME nanotime #define GET_NANOSEC(x) ((x)->tv_sec * 1000000000 + (x)->tv_nsec) @@ -472,6 +475,8 @@ default: \ #define XS_CDBLEN(ccb) (ccb)->cdb_len #define XS_XFRLEN(ccb) (ccb)->dxfer_len +#define XS_XFRIN(ccb) (((ccb)->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) +#define XS_XFROUT(ccb) (((ccb)->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) #define XS_TIME(ccb) \ (((ccb)->ccb_h.timeout > 0xffff * 1000 - 999) ? 0 : \ (((ccb)->ccb_h.timeout + 999) / 1000)) @@ -638,7 +643,8 @@ int isp_fc_scratch_acquire(ispsoftc_t *, int); void isp_platform_intr(void *); void isp_platform_intr_resp(void *); void isp_platform_intr_atio(void *); -void isp_common_dmateardown(ispsoftc_t *, struct ccb_scsiio *, uint32_t); +int isp_dmasetup(ispsoftc_t *, XS_T *, void *); +void isp_dmafree(ispsoftc_t *, struct ccb_scsiio *); void isp_fcp_reset_crn(ispsoftc_t *, int, uint32_t, int); int isp_fcp_next_crn(ispsoftc_t *, uint8_t *, XS_T *); Modified: head/sys/dev/isp/isp_library.c ============================================================================== --- head/sys/dev/isp/isp_library.c Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/isp_library.c Fri Nov 20 18:02:04 2020 (r367906) @@ -61,30 +61,25 @@ const char *isp_class3_roles[4] = { * Called with the first queue entry at least partially filled out. */ int -isp_send_cmd(ispsoftc_t *isp, void *fqe, void *segp, uint32_t nsegs, uint32_t totalcnt, isp_ddir_t ddir, ispds64_t *ecmd) +isp_send_cmd(ispsoftc_t *isp, void *fqe, void *segp, uint32_t nsegs) { ispcontreq64_t crq; - uint8_t type, nqe; - uint32_t seg, seglim, nxt, nxtnxt, ddf; + uint8_t type, nqe = 1; + uint32_t seg, seglim, nxt, nxtnxt; ispds64_t *dsp64 = NULL; void *qe0, *qe1; qe0 = isp_getrqentry(isp); - if (qe0 == NULL) { + if (qe0 == NULL) return (CMD_EAGAIN); - } nxt = ISP_NXT_QENTRY(isp->isp_reqidx, RQUEST_QUEUE_LEN(isp)); - type = ((isphdr_t *)fqe)->rqs_entry_type; - nqe = 1; /* * If we have no data to transmit, just copy the first IOCB and start it up. */ - if (ddir == ISP_NOXFR) { - ddf = 0; + if (nsegs == 0) goto copy_and_sync; - } /* * First figure out how many pieces of data to transfer, what @@ -92,7 +87,6 @@ isp_send_cmd(ispsoftc_t *isp, void *fqe, void *segp, u */ switch (type) { case RQSTYPE_T7RQS: - ddf = (ddir == ISP_TO_DEVICE)? FCP_CMND_DATA_WRITE : FCP_CMND_DATA_READ; dsp64 = &((ispreqt7_t *)fqe)->req_dataseg; seglim = 1; break; @@ -103,7 +97,7 @@ isp_send_cmd(ispsoftc_t *isp, void *fqe, void *segp, u break; #endif default: - return (CMD_COMPLETE); + panic("%s: unsupported IOCB type 0x%x\n", __func__, type); } if (seglim > nsegs) seglim = nsegs; @@ -146,9 +140,7 @@ copy_and_sync: ((isphdr_t *)fqe)->rqs_entry_count = nqe; switch (type) { case RQSTYPE_T7RQS: - ((ispreqt7_t *)fqe)->req_alen_datadir = ddf; ((ispreqt7_t *)fqe)->req_seg_count = nsegs; - ((ispreqt7_t *)fqe)->req_dl = totalcnt; isp_put_request_t7(isp, fqe, qe0); break; #ifdef ISP_TARGET_MODE @@ -162,13 +154,13 @@ copy_and_sync: break; #endif default: - return (CMD_COMPLETE); + panic("%s: unsupported IOCB type 0x%x\n", __func__, type); } if (isp->isp_dblev & ISP_LOGDEBUG1) { isp_print_bytes(isp, "first queue entry", QENTRY_LEN, qe0); } ISP_ADD_REQUEST(isp, nxt); - return (CMD_QUEUED); + return (0); } uint32_t @@ -500,13 +492,9 @@ isp_clear_commands(ispsoftc_t *isp) switch (ISP_H2HT(hdp->handle)) { case ISP_HANDLE_INITIATOR: { XS_T *xs = hdp->cmd; - if (XS_XFRLEN(xs)) { - ISP_DMAFREE(isp, xs, hdp->handle); - XS_SET_RESID(xs, XS_XFRLEN(xs)); - } else { - XS_SET_RESID(xs, 0); - } + ISP_DMAFREE(isp, xs); isp_destroy_handle(isp, hdp->handle); + XS_SET_RESID(xs, XS_XFRLEN(xs)); XS_SETERR(xs, HBA_BUSRESET); isp_done(xs); break; @@ -515,7 +503,7 @@ isp_clear_commands(ispsoftc_t *isp) case ISP_HANDLE_TARGET: { ct7_entry_t ctio; - ISP_DMAFREE(isp, hdp->cmd, hdp->handle); + ISP_DMAFREE(isp, hdp->cmd); ISP_MEMZERO(&ctio, sizeof(ct7_entry_t)); ctio.ct_syshandle = hdp->handle; ctio.ct_nphdl = CT_HBA_RESET; Modified: head/sys/dev/isp/isp_library.h ============================================================================== --- head/sys/dev/isp/isp_library.h Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/isp_library.h Fri Nov 20 18:02:04 2020 (r367906) @@ -38,8 +38,7 @@ * This used to be platform specific, but basically once you get the segment * stuff figured out, you can make all the code in one spot. */ -typedef enum { ISP_TO_DEVICE, ISP_FROM_DEVICE, ISP_NOXFR} isp_ddir_t; -int isp_send_cmd(ispsoftc_t *, void *, void *, uint32_t, uint32_t, isp_ddir_t, ispds64_t *); +int isp_send_cmd(ispsoftc_t *, void *, void *, uint32_t); /* * Handle management functions. Modified: head/sys/dev/isp/isp_pci.c ============================================================================== --- head/sys/dev/isp/isp_pci.c Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/isp_pci.c Fri Nov 20 18:02:04 2020 (r367906) @@ -57,7 +57,6 @@ static void isp_pci_wr_reg_2600(ispsoftc_t *, int, uin static void isp_pci_run_isr_2400(ispsoftc_t *); static int isp_pci_mbxdma(ispsoftc_t *); static void isp_pci_mbxdmafree(ispsoftc_t *); -static int isp_pci_dmasetup(ispsoftc_t *, XS_T *, void *); static int isp_pci_irqsetup(ispsoftc_t *); static struct ispmdvec mdvec_2400 = { @@ -65,8 +64,7 @@ static struct ispmdvec mdvec_2400 = { isp_pci_rd_reg_2400, isp_pci_wr_reg_2400, isp_pci_mbxdma, - isp_pci_dmasetup, - isp_common_dmateardown, + isp_send_cmd, isp_pci_irqsetup, NULL }; @@ -76,8 +74,7 @@ static struct ispmdvec mdvec_2500 = { isp_pci_rd_reg_2400, isp_pci_wr_reg_2400, isp_pci_mbxdma, - isp_pci_dmasetup, - isp_common_dmateardown, + isp_send_cmd, isp_pci_irqsetup, NULL }; @@ -87,8 +84,7 @@ static struct ispmdvec mdvec_2600 = { isp_pci_rd_reg_2600, isp_pci_wr_reg_2600, isp_pci_mbxdma, - isp_pci_dmasetup, - isp_common_dmateardown, + isp_send_cmd, isp_pci_irqsetup, NULL }; @@ -98,8 +94,7 @@ static struct ispmdvec mdvec_2700 = { isp_pci_rd_reg_2600, isp_pci_wr_reg_2600, isp_pci_mbxdma, - isp_pci_dmasetup, - isp_common_dmateardown, + isp_send_cmd, isp_pci_irqsetup, NULL }; @@ -1230,96 +1225,6 @@ isp_pci_mbxdmafree(ispsoftc_t *isp) bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); isp->isp_rquest = NULL; } -} - -typedef struct { - ispsoftc_t *isp; - void *cmd_token; - void *rq; /* original request */ - int error; -} mush_t; - -#define MUSHERR_NOQENTRIES -2 - -static void -dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) -{ - mush_t *mp = (mush_t *) arg; - ispsoftc_t *isp= mp->isp; - struct ccb_scsiio *csio = mp->cmd_token; - isp_ddir_t ddir; - int sdir; - - if (error) { - mp->error = error; - return; - } - if (nseg == 0) { - ddir = ISP_NOXFR; - } else { - if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { - ddir = ISP_FROM_DEVICE; - } else { - ddir = ISP_TO_DEVICE; - } - if ((csio->ccb_h.func_code == XPT_CONT_TARGET_IO) ^ - ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)) { - sdir = BUS_DMASYNC_PREREAD; - } else { - sdir = BUS_DMASYNC_PREWRITE; - } - bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, - sdir); - } - - error = isp_send_cmd(isp, mp->rq, dm_segs, nseg, XS_XFRLEN(csio), - ddir, (ispds64_t *)csio->req_map); - switch (error) { - case CMD_EAGAIN: - mp->error = MUSHERR_NOQENTRIES; - break; - case CMD_QUEUED: - break; - default: - mp->error = EIO; - break; - } -} - -static int -isp_pci_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff) -{ - mush_t mush, *mp; - int error; - - mp = &mush; - mp->isp = isp; - mp->cmd_token = csio; - mp->rq = ff; - mp->error = 0; - - error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, - (union ccb *)csio, dma2, mp, BUS_DMA_NOWAIT); - if (error && mp->error == 0) { -#ifdef DIAGNOSTIC - isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error); -#endif - mp->error = error; - } - if (mp->error) { - int retval = CMD_COMPLETE; - if (mp->error == MUSHERR_NOQENTRIES) { - retval = CMD_EAGAIN; - } else if (mp->error == EFBIG) { - csio->ccb_h.status = CAM_REQ_TOO_BIG; - } else if (mp->error == EINVAL) { - csio->ccb_h.status = CAM_REQ_INVALID; - } else { - csio->ccb_h.status = CAM_UNREC_HBA_ERROR; - } - return (retval); - } - return (CMD_QUEUED); } static int Modified: head/sys/dev/isp/isp_target.c ============================================================================== --- head/sys/dev/isp/isp_target.c Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/isp_target.c Fri Nov 20 18:02:04 2020 (r367906) @@ -730,9 +730,7 @@ isp_handle_ctio7(ispsoftc_t *isp, ct7_entry_t *ct) isp_prt(isp, pl, "NO xs for CTIO (handle 0x%x) status 0x%x", ct->ct_syshandle, ct->ct_nphdl); } } else { - if ((ct->ct_flags & CT7_DATAMASK) != CT7_NO_DATA) { - ISP_DMAFREE(isp, xs, ct->ct_syshandle); - } + ISP_DMAFREE(isp, xs); if (ct->ct_flags & CT7_SENDSTATUS) { /* * Sent status and command complete. Modified: head/sys/dev/isp/ispvar.h ============================================================================== --- head/sys/dev/isp/ispvar.h Fri Nov 20 17:26:02 2020 (r367905) +++ head/sys/dev/isp/ispvar.h Fri Nov 20 18:02:04 2020 (r367906) @@ -65,8 +65,7 @@ struct ispmdvec { uint32_t (*dv_rd_reg) (ispsoftc_t *, int); void (*dv_wr_reg) (ispsoftc_t *, int, uint32_t); int (*dv_mbxdma) (ispsoftc_t *); - int (*dv_dmaset) (ispsoftc_t *, XS_T *, void *); - void (*dv_dmaclr) (ispsoftc_t *, XS_T *, uint32_t); + int (*dv_send_cmd) (ispsoftc_t *, void *, void *, uint32_t); int (*dv_irqsetup) (ispsoftc_t *); void (*dv_dregs) (ispsoftc_t *, const char *); const void * dv_ispfw; /* ptr to f/w */ @@ -98,13 +97,9 @@ struct ispmdvec { #define ISP_MBOXDMASETUP(isp) \ (*(isp)->isp_mdvec->dv_mbxdma)((isp)) -#define ISP_DMASETUP(isp, xs, req) \ - (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req)) +#define ISP_SEND_CMD(isp, qe, segp, nseg) \ + (*(isp)->isp_mdvec->dv_send_cmd)((isp), (qe), (segp), (nseg)) -#define ISP_DMAFREE(isp, xs, hndl) \ - if ((isp)->isp_mdvec->dv_dmaclr) \ - (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) - #define ISP_IRQSETUP(isp) \ (((isp)->isp_mdvec->dv_irqsetup) ? (*(isp)->isp_mdvec->dv_irqsetup)(isp) : 0) #define ISP_DUMPREGS(isp, m) \ @@ -683,8 +678,7 @@ int isp_start(XS_T *); /* these values are what isp_start returns */ #define CMD_COMPLETE 101 /* command completed */ #define CMD_EAGAIN 102 /* busy- maybe retry later */ -#define CMD_QUEUED 103 /* command has been queued for execution */ -#define CMD_RQLATER 104 /* requeue this command later */ +#define CMD_RQLATER 103 /* requeue this command later */ /* * Command Completion Point- Core layers call out from this with completed cmds @@ -867,6 +861,8 @@ void isp_async(ispsoftc_t *, ispasync_t, ...); * XS_CDBP(xs) gets a pointer to the scsi CDB "" * XS_CDBLEN(xs) gets the CDB's length "" * XS_XFRLEN(xs) gets the associated data transfer length "" + * XS_XFRIN(xs) gets IN direction + * XS_XFROUT(xs) gets OUT direction * XS_TIME(xs) gets the time (in seconds) for this command * XS_GET_RESID(xs) gets the current residual count * XS_GET_RESID(xs, resid) sets the current residual count From owner-svn-src-all@freebsd.org Fri Nov 20 18:42:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75A2046A062; Fri, 20 Nov 2020 18:42:02 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd54V2gLYz4TQN; Fri, 20 Nov 2020 18:42:02 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E9501AACB; Fri, 20 Nov 2020 18:42:02 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKIg27Z058353; Fri, 20 Nov 2020 18:42:02 GMT (envelope-from alfredo@FreeBSD.org) Received: (from alfredo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKIg2Fu058352; Fri, 20 Nov 2020 18:42:02 GMT (envelope-from alfredo@FreeBSD.org) Message-Id: <202011201842.0AKIg2Fu058352@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alfredo set sender to alfredo@FreeBSD.org using -f From: "Alfredo Dal'Ava Junior" Date: Fri, 20 Nov 2020 18:42:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367907 - head X-SVN-Group: head X-SVN-Commit-Author: alfredo X-SVN-Commit-Paths: head X-SVN-Commit-Revision: 367907 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 18:42:02 -0000 Author: alfredo Date: Fri Nov 20 18:42:01 2020 New Revision: 367907 URL: https://svnweb.freebsd.org/changeset/base/367907 Log: [POWERPC64LE,POWEPCSPE] set default kernel config for powerpc64le and powerpcspe variants Default KERNCONF for powerpc64le should be GENERIC64, and powerpcspe should select MPC85XXSPE Reviewed by: bdragon,emaste Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D27257 Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Nov 20 18:02:04 2020 (r367906) +++ head/Makefile.inc1 Fri Nov 20 18:42:01 2020 (r367907) @@ -1591,6 +1591,10 @@ KERNCONF=${KERNFAST} .endif .if ${TARGET_ARCH} == "powerpc64" KERNCONF?= GENERIC64 +.elif ${TARGET_ARCH} == "powerpc64le" +KERNCONF?= GENERIC64LE +.elif ${TARGET_ARCH} == "powerpcspe" +KERNCONF?= MPC85XXSPE .else KERNCONF?= GENERIC .endif From owner-svn-src-all@freebsd.org Fri Nov 20 18:52:38 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 898CB46A7B4; Fri, 20 Nov 2020 18:52:38 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd5Jk3R5sz4Tvl; Fri, 20 Nov 2020 18:52:38 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 68CBA1AEB5; Fri, 20 Nov 2020 18:52:38 +0000 (UTC) (envelope-from alfredo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKIqcKY065866; Fri, 20 Nov 2020 18:52:38 GMT (envelope-from alfredo@FreeBSD.org) Received: (from alfredo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKIqcIv065865; Fri, 20 Nov 2020 18:52:38 GMT (envelope-from alfredo@FreeBSD.org) Message-Id: <202011201852.0AKIqcIv065865@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alfredo set sender to alfredo@FreeBSD.org using -f From: "Alfredo Dal'Ava Junior" Date: Fri, 20 Nov 2020 18:52:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367908 - head/sys/powerpc/powerpc X-SVN-Group: head X-SVN-Commit-Author: alfredo X-SVN-Commit-Paths: head/sys/powerpc/powerpc X-SVN-Commit-Revision: 367908 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 18:52:38 -0000 Author: alfredo Date: Fri Nov 20 18:52:37 2020 New Revision: 367908 URL: https://svnweb.freebsd.org/changeset/base/367908 Log: [POWERPC] print uprintf_signal 'type' field in hex Print 'type' field in hex to improve readability Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D27294 Modified: head/sys/powerpc/powerpc/trap.c Modified: head/sys/powerpc/powerpc/trap.c ============================================================================== --- head/sys/powerpc/powerpc/trap.c Fri Nov 20 18:42:01 2020 (r367907) +++ head/sys/powerpc/powerpc/trap.c Fri Nov 20 18:52:37 2020 (r367908) @@ -503,7 +503,7 @@ trap(struct trapframe *frame) ksi.ksi_addr = (void *)addr; ksi.ksi_trapno = type; if (uprintf_signal) { - uprintf("pid %d comm %s: signal %d code %d type %d " + uprintf("pid %d comm %s: signal %d code %d type 0x%x " "addr 0x%lx r1 0x%lx srr0 0x%lx srr1 0x%lx\n", p->p_pid, p->p_comm, sig, ucode, type, (u_long)addr, (u_long)frame->fixreg[1], From owner-svn-src-all@freebsd.org Fri Nov 20 19:36:35 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C838E46C0A1; Fri, 20 Nov 2020 19:36:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd6HR5HrGz4X1h; Fri, 20 Nov 2020 19:36:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A88F51B611; Fri, 20 Nov 2020 19:36:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKJaZxH090773; Fri, 20 Nov 2020 19:36:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKJaYOD090768; Fri, 20 Nov 2020 19:36:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011201936.0AKJaYOD090768@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 20 Nov 2020 19:36:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367909 - head/sys/dev/isp X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/isp X-SVN-Commit-Revision: 367909 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 19:36:35 -0000 Author: mav Date: Fri Nov 20 19:36:34 2020 New Revision: 367909 URL: https://svnweb.freebsd.org/changeset/base/367909 Log: Increase queue depths from 1024/256 to 8192/1024 IOCBs. Qlogic chips store S/G lists in the same queue as requests themselves. In the worst case 1MB I/O may require up to 52 IOCBs, that means queue of 1024 IOCBs can store only 19 of such requests. The increase reduces chances of overflow, while we should be able to afford additional 512KB of RAM per HBA. The Linux driver uses comparable numbers. While there, decouple ATIO queue size from response queue size. There is no reason for them to be equal. Modified: head/sys/dev/isp/isp.c head/sys/dev/isp/isp_freebsd.h head/sys/dev/isp/isp_pci.c head/sys/dev/isp/isp_target.c head/sys/dev/isp/ispvar.h Modified: head/sys/dev/isp/isp.c ============================================================================== --- head/sys/dev/isp/isp.c Fri Nov 20 18:52:37 2020 (r367908) +++ head/sys/dev/isp/isp.c Fri Nov 20 19:36:34 2020 (r367909) @@ -98,7 +98,7 @@ static const uint8_t alpa_map[] = { /* * Local function prototypes. */ -static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *); +static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *, uint16_t); static void isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, uint32_t *); static void isp_clear_portdb(ispsoftc_t *, int); static void isp_mark_portdb(ispsoftc_t *, int); @@ -912,7 +912,7 @@ isp_init(ispsoftc_t *isp) #ifdef ISP_TARGET_MODE /* unconditionally set up the ATIO queue if we support target mode */ - icbp->icb_atioqlen = RESULT_QUEUE_LEN(isp); + icbp->icb_atioqlen = ATIO_QUEUE_LEN(isp); if (icbp->icb_atioqlen < 8) { isp_prt(isp, ISP_LOGERR, "bad ATIO queue length %d", icbp->icb_atioqlen); return; @@ -3179,14 +3179,15 @@ isp_intr_atioq(ispsoftc_t *isp) case RQSTYPE_ATIO: case RQSTYPE_NOTIFY_ACK: /* Can be set to ATIO queue.*/ case RQSTYPE_ABTS_RCVD: /* Can be set to ATIO queue.*/ - (void) isp_target_notify(isp, addr, &oop); + (void) isp_target_notify(isp, addr, &oop, + ATIO_QUEUE_LEN(isp)); break; case RQSTYPE_RPT_ID_ACQ: /* Can be set to ATIO queue.*/ default: isp_print_qentry(isp, "?ATIOQ entry?", oop, addr); break; } - optr = ISP_NXT_QENTRY(oop, RESULT_QUEUE_LEN(isp)); + optr = ISP_NXT_QENTRY(oop, ATIO_QUEUE_LEN(isp)); } if (isp->isp_atioodx != optr) { ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, optr); @@ -3287,7 +3288,8 @@ isp_intr_respq(ispsoftc_t *isp) } ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */ continue; - } else if (isp_handle_other_response(isp, etype, hp, &cptr)) { + } else if (isp_handle_other_response(isp, etype, hp, + &cptr, RESULT_QUEUE_LEN(isp))) { /* More then one IOCB could be consumed. */ while (sptr != cptr) { ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */ @@ -3729,7 +3731,7 @@ isp_intr_async(ispsoftc_t *isp, uint16_t mbox) */ static int -isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *optrp) +isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *optrp, uint16_t ql) { isp_ridacq_t rid; int chan, c; @@ -3794,7 +3796,7 @@ isp_handle_other_response(ispsoftc_t *isp, int type, i case RQSTYPE_ABTS_RCVD: /* Can be set to ATIO queue. */ case RQSTYPE_ABTS_RSP: #ifdef ISP_TARGET_MODE - return (isp_target_notify(isp, hp, optrp)); + return (isp_target_notify(isp, hp, optrp, ql)); #endif /* FALLTHROUGH */ default: Modified: head/sys/dev/isp/isp_freebsd.h ============================================================================== --- head/sys/dev/isp/isp_freebsd.h Fri Nov 20 18:52:37 2020 (r367908) +++ head/sys/dev/isp/isp_freebsd.h Fri Nov 20 19:36:34 2020 (r367909) @@ -349,8 +349,6 @@ struct isposinfo { #define GET_NANOSEC(x) ((x)->tv_sec * 1000000000 + (x)->tv_nsec) #define NANOTIME_SUB isp_nanotime_sub -#define MAXISPREQUEST(isp) 1024 - #define MEMORYBARRIER(isp, type, offset, size, chan) \ switch (type) { \ case SYNC_REQUEST: \ Modified: head/sys/dev/isp/isp_pci.c ============================================================================== --- head/sys/dev/isp/isp_pci.c Fri Nov 20 18:52:37 2020 (r367908) +++ head/sys/dev/isp/isp_pci.c Fri Nov 20 19:36:34 2020 (r367909) @@ -1009,9 +1009,9 @@ isp_pci_mbxdma(ispsoftc_t *isp) #ifdef ISP_TARGET_MODE /* - * Allocate and map ATIO queue on 24xx with target mode. + * Allocate and map ATIO queue. */ - len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); + len = ISP_QUEUE_SIZE(ATIO_QUEUE_LEN(isp)); if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, slim, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, len, 1, len, 0, NULL, NULL, &isp->isp_osinfo.atiodmat)) { Modified: head/sys/dev/isp/isp_target.c ============================================================================== --- head/sys/dev/isp/isp_target.c Fri Nov 20 18:52:37 2020 (r367908) +++ head/sys/dev/isp/isp_target.c Fri Nov 20 19:36:34 2020 (r367909) @@ -109,7 +109,7 @@ static void isp_handle_notify_24xx(ispsoftc_t *, in_fc */ int -isp_target_notify(ispsoftc_t *isp, void *vptr, uint32_t *optrp) +isp_target_notify(ispsoftc_t *isp, void *vptr, uint32_t *optrp, uint16_t ql) { union { at7_entry_t *at7iop; @@ -149,7 +149,7 @@ isp_target_notify(ispsoftc_t *isp, void *vptr, uint32_ len -= (QENTRY_LEN - 8); isp_prt(isp, ISP_LOGINFO, "long IU length (%d) ignored", len); while (len > 0) { - *optrp = ISP_NXT_QENTRY(*optrp, RESULT_QUEUE_LEN(isp)); + *optrp = ISP_NXT_QENTRY(*optrp, ql); len -= QENTRY_LEN; } } Modified: head/sys/dev/isp/ispvar.h ============================================================================== --- head/sys/dev/isp/ispvar.h Fri Nov 20 18:52:37 2020 (r367908) +++ head/sys/dev/isp/ispvar.h Fri Nov 20 19:36:34 2020 (r367909) @@ -128,20 +128,15 @@ struct ispmdvec { /* * Request/Response Queue defines and macros. - * The maximum is defined per platform (and can be based on board type). */ /* This is the size of a queue entry (request and response) */ #define QENTRY_LEN 64 -/* Both request and result queue length must be a power of two */ -#define RQUEST_QUEUE_LEN(x) MAXISPREQUEST(x) -#ifdef ISP_TARGET_MODE -#define RESULT_QUEUE_LEN(x) MAXISPREQUEST(x) -#else -#define RESULT_QUEUE_LEN(x) \ - (((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2) -#endif -#define ISP_QUEUE_ENTRY(q, idx) (((uint8_t *)q) + ((idx) * QENTRY_LEN)) -#define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) +/* Queue lengths must be a power of two and at least 8 elements. */ +#define RQUEST_QUEUE_LEN(x) 8192 +#define RESULT_QUEUE_LEN(x) 1024 +#define ATIO_QUEUE_LEN(x) 1024 +#define ISP_QUEUE_ENTRY(q, idx) (((uint8_t *)q) + ((size_t)(idx) * QENTRY_LEN)) +#define ISP_QUEUE_SIZE(n) ((size_t)(n) * QENTRY_LEN) #define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) #define ISP_QFREE(in, out, qlen) \ ((in == out)? (qlen - 1) : ((in > out)? \ @@ -944,7 +939,7 @@ void isp_async(ispsoftc_t *, ispasync_t, ...); /* * This function handles new response queue entry appropriate for target mode. */ -int isp_target_notify(ispsoftc_t *, void *, uint32_t *); +int isp_target_notify(ispsoftc_t *, void *, uint32_t *, uint16_t); /* * This function externalizes the ability to acknowledge an Immediate Notify request. From owner-svn-src-all@freebsd.org Fri Nov 20 20:12:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B93B046CAA3; Fri, 20 Nov 2020 20:12:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd74J3j1wz4ZC3; Fri, 20 Nov 2020 20:12:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 672241BE91; Fri, 20 Nov 2020 20:12:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKKC0qT015518; Fri, 20 Nov 2020 20:12:00 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKKC0Uw015515; Fri, 20 Nov 2020 20:12:00 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <202011202012.0AKKC0Uw015515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 20 Nov 2020 20:12:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367910 - in head: . share/man/man7 X-SVN-Group: head X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: in head: . share/man/man7 X-SVN-Commit-Revision: 367910 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 20:12:00 -0000 Author: bdrewery Date: Fri Nov 20 20:11:59 2020 New Revision: 367910 URL: https://svnweb.freebsd.org/changeset/base/367910 Log: Add lists for customizing legacy and bootstrap-tools. Reviewed by: arichardson Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27200 Modified: head/Makefile.inc1 head/share/man/man7/build.7 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Nov 20 19:36:34 2020 (r367909) +++ head/Makefile.inc1 Fri Nov 20 20:11:59 2020 (r367910) @@ -20,8 +20,12 @@ # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target # LOCAL_MTREE="list of mtree files" to process to allow local directories # to be created before files are installed +# LOCAL_LEGACY_DIRS="list of dirs" to add additional dirs to the legacy +# target +# LOCAL_BSTOOL_DIRS="list of dirs" to add additional dirs to the +# bootstrap-tools target # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools -# list +# target # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the # cross-tools target # METALOG="path to metadata log" to write permission and ownership @@ -2127,7 +2131,9 @@ legacy: .PHONY false .endif -.for _tool in tools/build +.for _tool in \ + tools/build \ + ${LOCAL_LEGACY_DIRS} ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \ cd ${.CURDIR}/${_tool}; \ if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ @@ -2458,7 +2464,8 @@ bootstrap-tools: ${_bt}-links .PHONY ${_crunchgen} \ ${_nmtree} \ ${_vtfontcvt} \ - ${_localedef} + ${_localedef} \ + ${LOCAL_BSTOOL_DIRS} ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ cd ${.CURDIR}/${_tool}; \ Modified: head/share/man/man7/build.7 ============================================================================== --- head/share/man/man7/build.7 Fri Nov 20 19:36:34 2020 (r367909) +++ head/share/man/man7/build.7 Fri Nov 20 20:11:59 2020 (r367910) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 3, 2020 +.Dd November 12, 2020 .Dt BUILD 7 .Os .Sh NAME @@ -571,6 +571,16 @@ may also be used as needed elsewhere within the list. If set, this variable supplies a list of additional mtrees relative to the root of the source tree to use as part of the .Cm hierarchy +target. +.It Va LOCAL_LEGACY_DIRS +If set, this variable supplies a list of additional directories relative to +the root of the source tree to build as part of the +.Cm legacy +target. +.It Va LOCAL_BSTOOL_DIRS +If set, this variable supplies a list of additional directories relative to +the root of the source tree to build as part of the +.Cm bootstrap-tools target. .It Va LOCAL_TOOL_DIRS If set, this variable supplies a list of additional directories relative to From owner-svn-src-all@freebsd.org Fri Nov 20 20:22:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C17A46CC33; Fri, 20 Nov 2020 20:22:02 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd7Ht2b77z4ZW6; Fri, 20 Nov 2020 20:22:02 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B8E31BCEE; Fri, 20 Nov 2020 20:22:02 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKKM2gV020815; Fri, 20 Nov 2020 20:22:02 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKKM2TJ020812; Fri, 20 Nov 2020 20:22:02 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <202011202022.0AKKM2TJ020812@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Fri, 20 Nov 2020 20:22:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367911 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367911 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 20:22:02 -0000 Author: mckusick Date: Fri Nov 20 20:22:01 2020 New Revision: 367911 URL: https://svnweb.freebsd.org/changeset/base/367911 Log: Only attempt a VOP_UNLOCK() when the vn_lock() has been successful. No MFC as this code is not present in 12-stable. Reported by: Peter Holm Reviewed by: Mateusz Guzik Tested by: Peter Holm Sponsored by: Netflix Modified: head/sys/kern/vfs_vnops.c Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Fri Nov 20 20:11:59 2020 (r367910) +++ head/sys/kern/vfs_vnops.c Fri Nov 20 20:22:01 2020 (r367911) @@ -3007,8 +3007,8 @@ vn_write_outvp(struct vnode *outvp, char *dat, off_t o curthread->td_ucred, cred, NULL, curthread); outoff += xfer2; xfer -= xfer2; + VOP_UNLOCK(outvp); } - VOP_UNLOCK(outvp); } if (mp != NULL) vn_finished_write(mp); From owner-svn-src-all@freebsd.org Fri Nov 20 22:14:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 460FB46F85B; Fri, 20 Nov 2020 22:14:52 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd9p41YBwz4hMc; Fri, 20 Nov 2020 22:14:52 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 281CD1D430; Fri, 20 Nov 2020 22:14:52 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKMEq2F091007; Fri, 20 Nov 2020 22:14:52 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKMEqTx091006; Fri, 20 Nov 2020 22:14:52 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <202011202214.0AKMEqTx091006@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 20 Nov 2020 22:14:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367912 - head/usr.sbin/mountd X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/usr.sbin/mountd X-SVN-Commit-Revision: 367912 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 22:14:52 -0000 Author: rmacklem Date: Fri Nov 20 22:14:51 2020 New Revision: 367912 URL: https://svnweb.freebsd.org/changeset/base/367912 Log: Update man page for new TLS export options. NFS over TLS uses three new export options, added by r364979. This patch updates the exports.5 man page for these new options. Once assigned by IETF, "NNNN" will be replaced with the RFC number. This is a content change. Reviewed by: gbe Differential Revision: https://review.freebsd.org/D26241 Modified: head/usr.sbin/mountd/exports.5 Modified: head/usr.sbin/mountd/exports.5 ============================================================================== --- head/usr.sbin/mountd/exports.5 Fri Nov 20 20:22:01 2020 (r367911) +++ head/usr.sbin/mountd/exports.5 Fri Nov 20 22:14:51 2020 (r367912) @@ -28,7 +28,7 @@ .\" @(#)exports.5 8.3 (Berkeley) 3/29/95 .\" $FreeBSD$ .\" -.Dd February 11, 2019 +.Dd November 20, 2020 .Dt EXPORTS 5 .Os .Sh NAME @@ -117,9 +117,13 @@ exported to the host set. The option flags specify whether the file system is exported read-only or read-write and how the client UID is mapped to user credentials on the server. -For the NFSv4 tree root, the only option that can be specified in this -section is -.Fl sec . +For the NFSv4 tree root, the only options that can be specified in this +section are ones related to security: +.Fl sec , +.Fl tls , +.Fl tlscert +and +.Fl tlscertuser . .Pp Export options are specified as follows: .Pp @@ -241,6 +245,48 @@ or .Fl webnfs flags. .Pp +The +.Fl tls , +.Fl tlscert +and +.Fl tlscertuser +export options are used to require the client to use TLS for the mount(s) +per RFC NNNN. +For NFS mounts using TLS to work, +.Xr rpc.tlsservd 8 +must be running on the server. +.Bd -filled -offset indent +.Fl tls +requires that the client use TLS. +.br +.Fl tlscert +requires that the client use TLS and provide a verifiable X.509 certificate +during TLS handshake. +.br +.Fl tlscertuser +requires that the client use TLS and provide a verifiable X.509 certificate. +The otherName component of the certificate's subjAltName must have a +an OID of 1.3.6.1.4.1.2238.1.1.1 and a UTF8 string of the form +.Dq user@domain . +.Dq user@domain +will be translated to the credentials of the specified user in the same +manner as +.Xr nfsuserd 8 , +where +.Dq user +is normally a username is the server's password database and +.Dq domain +is the DNS domain name for the server. +All RPCs will be performed using these credentials instead of the +ones in the RPC header in a manner similar to +.Sm off +.Fl mapall Li = Sy user . +.Sm on +.Ed +.Pp +If none of these three flags are specified, TLS mounts are permitted but +not required. +.Pp Specifying the .Fl quiet option will inhibit some of the syslog diagnostics for bad lines in @@ -541,7 +587,15 @@ afterwards, whereas NFSv3 rejects the mount request. .Xr netgroup 5 , .Xr mountd 8 , .Xr nfsd 8 , +.Xr rpc.tlsservd 8 , .Xr showmount 8 +.Sh STANDARDS +The implementation is based on the specification in +.Rs +.%T "Network File System Protocol Specification, Appendix A, RFC 1094" +.%T "NFS: Network File System Version 3, Appendix I, RFC 1813" +.%T "Towards Remote Procedure Call Encryption By Default, RFC nnnn" +.Re .Sh BUGS The export options are tied to the local mount points in the kernel and must be non-contradictory for any exported subdirectory of the local From owner-svn-src-all@freebsd.org Fri Nov 20 22:29:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6848646FEAB; Fri, 20 Nov 2020 22:29:39 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdB77200vz4j9x; Fri, 20 Nov 2020 22:29:39 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 333031D456; Fri, 20 Nov 2020 22:29:39 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKMTdlI098253; Fri, 20 Nov 2020 22:29:39 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKMTdpI098252; Fri, 20 Nov 2020 22:29:39 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <202011202229.0AKMTdpI098252@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 20 Nov 2020 22:29:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367913 - head/sbin/mount_nfs X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sbin/mount_nfs X-SVN-Commit-Revision: 367913 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 22:29:39 -0000 Author: rmacklem Date: Fri Nov 20 22:29:38 2020 New Revision: 367913 URL: https://svnweb.freebsd.org/changeset/base/367913 Log: Document the new "tls" NFS mount option. Recent commits to head have added support for NFS over TLS to the FreeBSD kernel. To enable use of this for an NFS mount, the "tls" mount_nfs option has been added. Once the IETF has assigned an RFC number, I will replace "NNNN" with the number. This is a content change. Reviewed by: gbe Differential Revision: https://reviews.freebsd.org/D26262 Modified: head/sbin/mount_nfs/mount_nfs.8 Modified: head/sbin/mount_nfs/mount_nfs.8 ============================================================================== --- head/sbin/mount_nfs/mount_nfs.8 Fri Nov 20 22:14:51 2020 (r367912) +++ head/sbin/mount_nfs/mount_nfs.8 Fri Nov 20 22:29:38 2020 (r367913) @@ -28,7 +28,7 @@ .\" @(#)mount_nfs.8 8.3 (Berkeley) 3/29/95 .\" $FreeBSD$ .\" -.Dd December 14, 2019 +.Dd November 20, 2020 .Dt MOUNT_NFS 8 .Os .Sh NAME @@ -403,6 +403,12 @@ interval.) .It Cm timeo Ns = Ns Aq Ar value Alias for .Cm timeout . +.It Cm tls +This option specifies that the connection to the server must use TLS +per RFC NNNN. +TLS is only supported for TCP connections and the +.Xr rpc.tlsclntd 8 +daemon must be running for an NFS over TCP connection to use TLS. .It Cm udp Use UDP transport. .It Cm vers Ns = Ns Aq Ar vers_number @@ -537,6 +543,7 @@ Same as .Xr mount 8 , .Xr nfsd 8 , .Xr nfsiod 8 , +.Xr rpc.tlsclntd 8 , .Xr showmount 8 .Sh HISTORY A version of the From owner-svn-src-all@freebsd.org Sat Nov 21 00:41:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E9813471F25; Sat, 21 Nov 2020 00:41:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdF2j5JtCz4pYF; Sat, 21 Nov 2020 00:41:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9F4FE1F137; Sat, 21 Nov 2020 00:41:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AL0f1fY079448; Sat, 21 Nov 2020 00:41:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AL0f0tX079441; Sat, 21 Nov 2020 00:41:00 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011210041.0AL0f0tX079441@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 21 Nov 2020 00:41:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367914 - in stable/12: sys/dev/iscsi usr.sbin/iscsid X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12: sys/dev/iscsi usr.sbin/iscsid X-SVN-Commit-Revision: 367914 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 00:41:02 -0000 Author: mav Date: Sat Nov 21 00:40:59 2020 New Revision: 367914 URL: https://svnweb.freebsd.org/changeset/base/367914 Log: MFC r366953: Negotiate iSCSIProtocolLevel of 2 (RFC 7144) in initiator. It does not change anything immediately, but allows further support of Command Priority, Status Qualifier and new task management functions. Modified: stable/12/sys/dev/iscsi/iscsi.c stable/12/sys/dev/iscsi/iscsi.h stable/12/sys/dev/iscsi/iscsi_ioctl.h stable/12/sys/dev/iscsi/iscsi_proto.h stable/12/usr.sbin/iscsid/iscsid.c stable/12/usr.sbin/iscsid/iscsid.h stable/12/usr.sbin/iscsid/login.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iscsi/iscsi.c ============================================================================== --- stable/12/sys/dev/iscsi/iscsi.c Fri Nov 20 22:29:38 2020 (r367913) +++ stable/12/sys/dev/iscsi/iscsi.c Sat Nov 21 00:40:59 2020 (r367914) @@ -1426,6 +1426,7 @@ iscsi_ioctl_daemon_handoff(struct iscsi_softc *sc, sizeof(is->is_target_alias)); is->is_tsih = handoff->idh_tsih; is->is_statsn = handoff->idh_statsn; + is->is_protocol_level = handoff->idh_protocol_level; is->is_initial_r2t = handoff->idh_initial_r2t; is->is_immediate_data = handoff->idh_immediate_data; Modified: stable/12/sys/dev/iscsi/iscsi.h ============================================================================== --- stable/12/sys/dev/iscsi/iscsi.h Fri Nov 20 22:29:38 2020 (r367913) +++ stable/12/sys/dev/iscsi/iscsi.h Sat Nov 21 00:40:59 2020 (r367914) @@ -61,8 +61,7 @@ struct iscsi_session { uint32_t is_expcmdsn; uint32_t is_maxcmdsn; uint32_t is_initiator_task_tag; - int is_header_digest; - int is_data_digest; + int is_protocol_level; int is_initial_r2t; int is_max_burst_length; int is_first_burst_length; Modified: stable/12/sys/dev/iscsi/iscsi_ioctl.h ============================================================================== --- stable/12/sys/dev/iscsi/iscsi_ioctl.h Fri Nov 20 22:29:38 2020 (r367913) +++ stable/12/sys/dev/iscsi/iscsi_ioctl.h Sat Nov 21 00:40:59 2020 (r367914) @@ -124,7 +124,8 @@ struct iscsi_daemon_handoff { unsigned int idh_session_id; int idh_socket; char idh_target_alias[ISCSI_ALIAS_LEN]; - uint8_t idh_spare_isid[6]; + int idh_protocol_level; + uint16_t idh_spare; uint16_t idh_tsih; uint16_t idh_spare_cid; uint32_t idh_statsn; Modified: stable/12/sys/dev/iscsi/iscsi_proto.h ============================================================================== --- stable/12/sys/dev/iscsi/iscsi_proto.h Fri Nov 20 22:29:38 2020 (r367913) +++ stable/12/sys/dev/iscsi/iscsi_proto.h Sat Nov 21 00:40:59 2020 (r367914) @@ -90,10 +90,14 @@ CTASSERT(sizeof(struct iscsi_bhs) == ISCSI_BHS_SIZE); #define BHSSC_FLAGS_ATTR_HOQ 3 #define BHSSC_FLAGS_ATTR_ACA 4 +#define BHSSC_PRI_MASK 0xf0 +#define BHSSC_PRI_SHIFT 4 + struct iscsi_bhs_scsi_command { uint8_t bhssc_opcode; uint8_t bhssc_flags; - uint8_t bhssc_reserved[2]; + uint8_t bhssc_pri; + uint8_t bhssc_reserved; uint8_t bhssc_total_ahs_len; uint8_t bhssc_data_segment_len[3]; uint64_t bhssc_lun; Modified: stable/12/usr.sbin/iscsid/iscsid.c ============================================================================== --- stable/12/usr.sbin/iscsid/iscsid.c Fri Nov 20 22:29:38 2020 (r367913) +++ stable/12/usr.sbin/iscsid/iscsid.c Sat Nov 21 00:40:59 2020 (r367914) @@ -171,6 +171,7 @@ connection_new(int iscsi_fd, const struct iscsi_daemon /* * Default values, from RFC 3720, section 12. */ + conn->conn_protocol_level = 0; conn->conn_header_digest = CONN_DIGEST_NONE; conn->conn_data_digest = CONN_DIGEST_NONE; conn->conn_initial_r2t = true; @@ -328,6 +329,7 @@ handoff(struct connection *conn) sizeof(idh.idh_target_alias)); idh.idh_tsih = conn->conn_tsih; idh.idh_statsn = conn->conn_statsn; + idh.idh_protocol_level = conn->conn_protocol_level; idh.idh_header_digest = conn->conn_header_digest; idh.idh_data_digest = conn->conn_data_digest; idh.idh_initial_r2t = conn->conn_initial_r2t; Modified: stable/12/usr.sbin/iscsid/iscsid.h ============================================================================== --- stable/12/usr.sbin/iscsid/iscsid.h Fri Nov 20 22:29:38 2020 (r367913) +++ stable/12/usr.sbin/iscsid/iscsid.h Sat Nov 21 00:40:59 2020 (r367914) @@ -57,6 +57,7 @@ struct connection { uint8_t conn_isid[6]; uint16_t conn_tsih; uint32_t conn_statsn; + int conn_protocol_level; int conn_header_digest; int conn_data_digest; bool conn_initial_r2t; Modified: stable/12/usr.sbin/iscsid/login.c ============================================================================== --- stable/12/usr.sbin/iscsid/login.c Fri Nov 20 22:29:38 2020 (r367913) +++ stable/12/usr.sbin/iscsid/login.c Sat Nov 21 00:40:59 2020 (r367914) @@ -341,6 +341,11 @@ login_negotiate_key(struct connection *conn, const cha sizeof(conn->conn_target_alias)); } else if (strcmp(value, "Irrelevant") == 0) { /* Ignore. */ + } else if (strcmp(name, "iSCSIProtocolLevel") == 0) { + tmp = strtoul(value, NULL, 10); + if (tmp < 0 || tmp > 31) + log_errx(1, "received invalid iSCSIProtocolLevel"); + conn->conn_protocol_level = tmp; } else if (strcmp(name, "HeaderDigest") == 0) { which = login_list_prefers(value, "CRC32C", "None"); switch (which) { @@ -500,6 +505,7 @@ login_negotiate(struct connection *conn) * The following keys are irrelevant for discovery sessions. */ if (conn->conn_conf.isc_discovery == 0) { + keys_add(request_keys, "iSCSIProtocolLevel", "2"); if (conn->conn_conf.isc_header_digest != 0) keys_add(request_keys, "HeaderDigest", "CRC32C"); else From owner-svn-src-all@freebsd.org Sat Nov 21 00:51:40 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B198472B43; Sat, 21 Nov 2020 00:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdFH027h5z4qK4; Sat, 21 Nov 2020 00:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C8891F331; Sat, 21 Nov 2020 00:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AL0peHX085152; Sat, 21 Nov 2020 00:51:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AL0pdEb085150; Sat, 21 Nov 2020 00:51:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011210051.0AL0pdEb085150@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 21 Nov 2020 00:51:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367915 - in head/sys/dev: ahci siis X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head/sys/dev: ahci siis X-SVN-Commit-Revision: 367915 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 00:51:40 -0000 Author: mav Date: Sat Nov 21 00:51:39 2020 New Revision: 367915 URL: https://svnweb.freebsd.org/changeset/base/367915 Log: Fix stupid math mistake in r366922. MFC after: 3 days Modified: head/sys/dev/ahci/ahci.c head/sys/dev/siis/siis.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Sat Nov 21 00:40:59 2020 (r367914) +++ head/sys/dev/ahci/ahci.c Sat Nov 21 00:51:39 2020 (r367915) @@ -2580,7 +2580,7 @@ ahci_setup_fis(struct ahci_channel *ch, struct ahci_cm fis[11] = ccb->ataio.cmd.features_exp; fis[12] = ccb->ataio.cmd.sector_count; if (ccb->ataio.cmd.flags & CAM_ATAIO_FPDMA) { - fis[12] &= 0xf8; + fis[12] &= 0x07; fis[12] |= tag << 3; } fis[13] = ccb->ataio.cmd.sector_count_exp; Modified: head/sys/dev/siis/siis.c ============================================================================== --- head/sys/dev/siis/siis.c Sat Nov 21 00:40:59 2020 (r367914) +++ head/sys/dev/siis/siis.c Sat Nov 21 00:51:39 2020 (r367915) @@ -1725,7 +1725,7 @@ siis_setup_fis(device_t dev, struct siis_cmd *ctp, uni fis[11] = ccb->ataio.cmd.features_exp; fis[12] = ccb->ataio.cmd.sector_count; if (ccb->ataio.cmd.flags & CAM_ATAIO_FPDMA) { - fis[12] &= 0xf8; + fis[12] &= 0x03; fis[12] |= tag << 3; } fis[13] = ccb->ataio.cmd.sector_count_exp; From owner-svn-src-all@freebsd.org Sat Nov 21 00:53:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF490472A75; Sat, 21 Nov 2020 00:53:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdFK76SrZz4qvx; Sat, 21 Nov 2020 00:53:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D0D791F172; Sat, 21 Nov 2020 00:53:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AL0rVtC090885; Sat, 21 Nov 2020 00:53:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AL0rV7p090884; Sat, 21 Nov 2020 00:53:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202011210053.0AL0rV7p090884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 21 Nov 2020 00:53:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367916 - head/sys/dev/siis X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/siis X-SVN-Commit-Revision: 367916 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 00:53:32 -0000 Author: mav Date: Sat Nov 21 00:53:31 2020 New Revision: 367916 URL: https://svnweb.freebsd.org/changeset/base/367916 Log: Unlucky change... MFC after: 3 days Modified: head/sys/dev/siis/siis.c Modified: head/sys/dev/siis/siis.c ============================================================================== --- head/sys/dev/siis/siis.c Sat Nov 21 00:51:39 2020 (r367915) +++ head/sys/dev/siis/siis.c Sat Nov 21 00:53:31 2020 (r367916) @@ -1725,7 +1725,7 @@ siis_setup_fis(device_t dev, struct siis_cmd *ctp, uni fis[11] = ccb->ataio.cmd.features_exp; fis[12] = ccb->ataio.cmd.sector_count; if (ccb->ataio.cmd.flags & CAM_ATAIO_FPDMA) { - fis[12] &= 0x03; + fis[12] &= 0x07; fis[12] |= tag << 3; } fis[13] = ccb->ataio.cmd.sector_count_exp; From owner-svn-src-all@freebsd.org Sat Nov 21 03:27:33 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AD9A1479A31; Sat, 21 Nov 2020 03:27:33 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdJks4bXbz3JDd; Sat, 21 Nov 2020 03:27:33 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 903B7215BB; Sat, 21 Nov 2020 03:27:33 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AL3RXOR084831; Sat, 21 Nov 2020 03:27:33 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AL3RXRh084830; Sat, 21 Nov 2020 03:27:33 GMT (envelope-from np@FreeBSD.org) Message-Id: <202011210327.0AL3RXRh084830@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Sat, 21 Nov 2020 03:27:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367917 - head/sys/dev/cxgbe X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe X-SVN-Commit-Revision: 367917 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 03:27:33 -0000 Author: np Date: Sat Nov 21 03:27:32 2020 New Revision: 367917 URL: https://svnweb.freebsd.org/changeset/base/367917 Log: cxgbe(4): Catch up with in-flight netmap rx before destroying queues. The netmap application using the driver is responsible for replenishing the receive freelists and they may be totally depleted when the application exits. Packets in flight, if any, might block the pipeline in case there aren't enough buffers left in the freelist. Avoid this by filling up the freelists with a driver allocated buffer. MFC after: 1 week Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/t4_netmap.c Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Sat Nov 21 00:53:31 2020 (r367916) +++ head/sys/dev/cxgbe/adapter.h Sat Nov 21 03:27:32 2020 (r367917) @@ -749,6 +749,9 @@ struct sge_nm_rxq { bus_dma_tag_t fl_desc_tag; bus_dmamap_t fl_desc_map; bus_addr_t fl_ba; + + void *bb; /* bit bucket for packets with nowhere to go. */ + uma_zone_t bb_zone; }; #define INVALID_NM_TXQ_CNTXT_ID ((u_int)(-1)) Modified: head/sys/dev/cxgbe/t4_netmap.c ============================================================================== --- head/sys/dev/cxgbe/t4_netmap.c Sat Nov 21 00:53:31 2020 (r367916) +++ head/sys/dev/cxgbe/t4_netmap.c Sat Nov 21 03:27:32 2020 (r367917) @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -586,6 +588,8 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi alloc_nm_rxq_hwq(vi, nm_rxq, tnl_cong(vi->pi, nm_cong_drop)); nm_rxq->fl_hwidx = hwidx; + nm_rxq->bb_zone = rxb->zone; + nm_rxq->bb = uma_zalloc(nm_rxq->bb_zone, M_WAITOK); slot = netmap_reset(na, NR_RX, i, 0); MPASS(slot != NULL); /* XXXNM: error check, not assert */ @@ -628,6 +632,31 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi return (cxgbe_netmap_rss(sc, vi, ifp, na)); } +static void +flush_nm_rxq(struct adapter *sc, struct vi_info *vi, struct sge_nm_rxq *nm_rxq) +{ + int i, n; + u_int fl_pidx, fl_pidx_target, hw_cidx_desc; + const uint64_t ba = pmap_kextract((vm_offset_t)nm_rxq->bb); + + hw_cidx_desc = nm_rxq->fl_cidx / 8; + if (hw_cidx_desc == 0) + fl_pidx_target = nm_rxq->fl_sidx2 - 8; + else + fl_pidx_target = (hw_cidx_desc - 1) * 8; + MPASS((fl_pidx_target & 7) == 0); + + fl_pidx = nm_rxq->fl_pidx; + MPASS((fl_pidx & 7) == 0); + for (n = 0; fl_pidx != fl_pidx_target; n++) { + for (i = 0; i < 8; i++, fl_pidx++) + nm_rxq->fl_desc[fl_pidx] = htobe64(ba | nm_rxq->fl_hwidx); + if (__predict_false(fl_pidx == nm_rxq->fl_sidx2)) + fl_pidx = 0; + } + t4_write_reg(sc, sc->sge_kdoorbell_reg, nm_rxq->fl_db_val | V_PIDX(n)); +} + static int cxgbe_netmap_off(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, struct netmap_adapter *na) @@ -652,6 +681,23 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *v if (rc != 0) return (rc); /* error message logged already. */ + /* + * First pass over the rx queues to make sure they're all caught up. + * + * The freelists could be out of buffers and we may need to arrange + * things so that any packets still in flight (after TP's cong_drop + * logic but not yet DMA'd) have somewhere to go and do not block the + * pipeline. Do this before trying to free any queue. + */ + for_each_nm_rxq(vi, i, nm_rxq) { + nm_state = atomic_load_int(&nm_rxq->nm_state); + kring = na->rx_rings[nm_rxq->nid]; + if (nm_state == NM_OFF || !nm_kring_pending_off(kring)) + continue; + MPASS(nm_rxq->iq_cntxt_id != INVALID_NM_RXQ_CNTXT_ID); + flush_nm_rxq(sc, vi, nm_rxq); + } + for_each_nm_txq(vi, i, nm_txq) { struct sge_qstat *spg = (void *)&nm_txq->desc[nm_txq->sidx]; @@ -688,6 +734,8 @@ cxgbe_netmap_off(struct adapter *sc, struct vi_info *v pause("nmst", 1); free_nm_rxq_hwq(vi, nm_rxq); + uma_zfree(nm_rxq->bb_zone, nm_rxq->bb); + nm_rxq->bb = NULL; /* XXX: netmap, not the driver, should do this. */ kring->rhead = kring->rcur = kring->nr_hwcur = 0; From owner-svn-src-all@freebsd.org Sat Nov 21 10:32:41 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6DD1D2EA96F; Sat, 21 Nov 2020 10:32:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdV9P2ZZGz4XrG; Sat, 21 Nov 2020 10:32:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B32C26BBB; Sat, 21 Nov 2020 10:32:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0ALAWfka058190; Sat, 21 Nov 2020 10:32:41 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0ALAWevY058187; Sat, 21 Nov 2020 10:32:40 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011211032.0ALAWevY058187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 21 Nov 2020 10:32:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367918 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 367918 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 10:32:41 -0000 Author: kib Date: Sat Nov 21 10:32:40 2020 New Revision: 367918 URL: https://svnweb.freebsd.org/changeset/base/367918 Log: Stop using eventhandler to invoke umtx_exec hook. There is no point in dynamic registration, umtx hook is there always. Reviewed by: mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27303 Modified: head/sys/kern/kern_exec.c head/sys/kern/kern_umtx.c head/sys/sys/umtx.h Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Sat Nov 21 03:27:32 2020 (r367917) +++ head/sys/kern/kern_exec.c Sat Nov 21 10:32:40 2020 (r367918) @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #ifdef KTRACE @@ -1047,8 +1048,8 @@ exec_new_vmspace(struct image_params *imgp, struct sys imgp->sysent = sv; sigfastblock_clear(td); + umtx_exec(p); - /* May be called with Giant held */ EVENTHANDLER_DIRECT_INVOKE(process_exec, p, imgp); /* Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Sat Nov 21 03:27:32 2020 (r367917) +++ head/sys/kern/kern_umtx.c Sat Nov 21 10:32:40 2020 (r367918) @@ -446,8 +446,6 @@ umtxq_sysinit(void *arg __unused) umtx_init_profiling(); #endif mtx_init(&umtx_lock, "umtx lock", NULL, MTX_DEF); - EVENTHANDLER_REGISTER(process_exec, umtx_exec_hook, NULL, - EVENTHANDLER_PRI_ANY); umtx_shm_init(); } @@ -4356,12 +4354,11 @@ umtx_thread_alloc(struct thread *td) * exec() hook. * * Clear robust lists for all process' threads, not delaying the - * cleanup to thread_exit hook, since the relevant address space is + * cleanup to thread exit, since the relevant address space is * destroyed right now. */ -static void -umtx_exec_hook(void *arg __unused, struct proc *p, - struct image_params *imgp __unused) +void +umtx_exec(struct proc *p) { struct thread *td; @@ -4383,7 +4380,7 @@ umtx_exec_hook(void *arg __unused, struct proc *p, } /* - * thread_exit() hook. + * thread exit hook. */ void umtx_thread_exit(struct thread *td) Modified: head/sys/sys/umtx.h ============================================================================== --- head/sys/sys/umtx.h Sat Nov 21 03:27:32 2020 (r367917) +++ head/sys/sys/umtx.h Sat Nov 21 10:32:40 2020 (r367918) @@ -188,6 +188,7 @@ umtx_key_match(const struct umtx_key *k1, const struct } int umtx_copyin_timeout(const void *, struct timespec *); +void umtx_exec(struct proc *p); int umtx_key_get(const void *, int, int, struct umtx_key *); void umtx_key_release(struct umtx_key *); struct umtx_q *umtxq_alloc(void); From owner-svn-src-all@freebsd.org Sat Nov 21 10:58:20 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 105212EAD9D; Sat, 21 Nov 2020 10:58:20 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdVkz723Vz4Z47; Sat, 21 Nov 2020 10:58:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E41CB26B7A; Sat, 21 Nov 2020 10:58:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0ALAwJvg071008; Sat, 21 Nov 2020 10:58:19 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0ALAwJMc071007; Sat, 21 Nov 2020 10:58:19 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011211058.0ALAwJMc071007@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 21 Nov 2020 10:58:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367919 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367919 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 10:58:20 -0000 Author: kib Date: Sat Nov 21 10:58:19 2020 New Revision: 367919 URL: https://svnweb.freebsd.org/changeset/base/367919 Log: Remove unused prototype. Missed part of r367918. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Sat Nov 21 10:32:40 2020 (r367918) +++ head/sys/kern/kern_umtx.c Sat Nov 21 10:58:19 2020 (r367919) @@ -274,8 +274,6 @@ static void umtx_pi_free(struct umtx_pi *pi); static int do_unlock_pp(struct thread *td, struct umutex *m, uint32_t flags, bool rb); static void umtx_thread_cleanup(struct thread *td); -static void umtx_exec_hook(void *arg __unused, struct proc *p __unused, - struct image_params *imgp __unused); SYSINIT(umtx, SI_SUB_EVENTHANDLER+1, SI_ORDER_MIDDLE, umtxq_sysinit, NULL); #define umtxq_signal(key, nwake) umtxq_signal_queue((key), (nwake), UMTX_SHARED_QUEUE) From owner-svn-src-all@freebsd.org Sat Nov 21 18:20:22 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56BAE46D423; Sat, 21 Nov 2020 18:20:22 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdhY225WTz3GM4; Sat, 21 Nov 2020 18:20:22 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B2D24B09; Sat, 21 Nov 2020 18:20:22 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0ALIKM76050434; Sat, 21 Nov 2020 18:20:22 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0ALIKMsI050433; Sat, 21 Nov 2020 18:20:22 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <202011211820.0ALIKMsI050433@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sat, 21 Nov 2020 18:20:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367920 - head/tools/tools/netmap X-SVN-Group: head X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: head/tools/tools/netmap X-SVN-Commit-Revision: 367920 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 18:20:22 -0000 Author: vmaffione Date: Sat Nov 21 18:20:21 2020 New Revision: 367920 URL: https://svnweb.freebsd.org/changeset/base/367920 Log: netmap: bridge: update man page with more information Update the man page to describe how it is necessary to enable promiscuous mode and/or disable offloads. Modified: head/tools/tools/netmap/bridge.8 Modified: head/tools/tools/netmap/bridge.8 ============================================================================== --- head/tools/tools/netmap/bridge.8 Sat Nov 21 10:58:19 2020 (r367919) +++ head/tools/tools/netmap/bridge.8 Sat Nov 21 18:20:21 2020 (r367920) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 28, 2018 +.Dd November 21, 2020 .Dt BRIDGE 8 .Os .Sh NAME @@ -49,6 +49,20 @@ forwards packets without copying the packets payload ( explicitly prevented by the .Fl c flag. +.Pp +When bridging two physical ports, it is necessary that both NICS are in +promiscuous mode, otherwise unicast traffic directed to other hosts will +be dropped by the hardware, and bridging will not work. +.Pp +When bridging the hardware rings of a physical port with the corresponding +host rings, it is necessary to turn off the offloads, because netmap does +not prepare the NIC rings with offload information. +Example: +.Bd -literal -offset intent +ifconfig em0 -rxcsum -txcsum -tso4 -tso6 -lro +.Ed +.Pp +Available options: .Bl -tag -width Ds .It Fl i Ar port Name of the netmap port. @@ -71,8 +85,8 @@ Disable zero-copy mode. .El .Sh SEE ALSO .Xr netmap 4 , -.Xr pkt-gen 8 , -.Xr lb 8 +.Xr lb 8 , +.Xr pkt-gen 8 .Sh AUTHORS .An -nosplit .Nm From owner-svn-src-all@freebsd.org Sat Nov 21 18:27:11 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B5D046DA0E for ; Sat, 21 Nov 2020 18:27:11 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound5a.ore.mailhop.org (outbound5a.ore.mailhop.org [44.233.67.66]) (using TLSv1.3 with cipher TLS_AES_256_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 4Cdhhv0jB9z3Glx for ; Sat, 21 Nov 2020 18:27:10 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1605983223; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=W/IzzqJq2Ai8ybSt40O/nU0Eyg04JBl+o2VJd1fI7tgtcdeqKX3Zwk6JJWx8wXSeh1B0Gr23ajg2j aI9Pk+y/G4ss7GeumHLkTJYHTUYBjH6fzjxAc4FdUMPIiN0vEAW1iAG1nc8pOsu/IJFZSc4n9zd1O7 4qjyKiObB0hTbAUIDaakXoOrjxzIiRyKIkIgGJYVQAdLc5XzDoTY2oE3nGo+fC1KyIY8Z6BogVVh8F xt4r1r7FX3sJFFDE+hQjf0woWSQpZGzG/oaMl09Ybkz4FG2IQNzFmg+uEhNiFggG607o62xNeK8ylo BNVVtW5XxnoIqyd9tb0Xig6qDvsm2Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=XnKnsByI6kImSAREX2kWdwoF8pdhd5tASuAzx6AIa1g=; b=mHwuGPF+6UX/wIPLKpAp6gC11VyYg2TyekuWSM5wbq/EP1SqxP4BCkmO91e0Fob8HPw0JB98djMZz 24715XjPm182qyHn/TkfwK/h0Xof+ifYmgeKn5SSRLRhcY0gRLje2mMgEi63r7x7W4MMEhFJ/Pd+jr rTAqgkZk5JLmh4c3IBZRuT0D1FeLyxlZ18Nuk1/5yxDJ1MbMGVW7eND6s+7WsP9MZ27GVwbf/g7j+c hh6dlPpR5MJ+1Ycz+Bk5XXlSwbAhJ8SU4WxkmZhsJ7F3pA+PBCw9S+/tWA1R9L2J0tX8Wtxt+2CUon uG4UtnhPoM9MGGFSbcL2pNMKfOP4QzQ== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=XnKnsByI6kImSAREX2kWdwoF8pdhd5tASuAzx6AIa1g=; b=JcslGc6C3z1Rki4JkzzG/BFSotKWkZmlzWBkTx2lqcazp064C1vTZUzyDnMObtRm6z2/WGoE35uXe ukUc1d5zkLrshWFu0I9l49Yv9U48bQK3cuO45whs3WDImhBNtjNVvrPNVEiFM8kPUgmn1581YOgv9o si61LImRb4jmiQdtPIZofNmVINPdcqg0cPkMQoePQrmHuDjGuQRqwE1DgDRqhyam+ipxaNyFb4aq1d HZKZCBZYdim84eRSmqhO817xQOyxZCZItfth/AJD9Roe3cfXgFqZum3CptBH4qQhXpyGm/wVjOLdap 5dl5cmyLgfCpTNRrjfywU4xeqUn2Y9w== X-MHO-RoutePath: aGlwcGll X-MHO-User: 25af17f3-2c27-11eb-8b38-614106969e8d X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-67-177-211-60.hsd1.co.comcast.net [67.177.211.60]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id 25af17f3-2c27-11eb-8b38-614106969e8d; Sat, 21 Nov 2020 18:27:02 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 0ALIR1mX058399; Sat, 21 Nov 2020 11:27:01 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <6a7cb30702e3391c772b3b9a33a2587d190ff4ef.camel@freebsd.org> Subject: Re: svn commit: r367920 - head/tools/tools/netmap From: Ian Lepore To: Vincenzo Maffione , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Sat, 21 Nov 2020 11:27:00 -0700 In-Reply-To: <202011211820.0ALIKMsI050433@repo.freebsd.org> References: <202011211820.0ALIKMsI050433@repo.freebsd.org> Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Cdhhv0jB9z3Glx X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 18:27:11 -0000 On Sat, 2020-11-21 at 18:20 +0000, Vincenzo Maffione wrote: > Author: vmaffione > Date: Sat Nov 21 18:20:21 2020 > New Revision: 367920 ... > +.Bd -literal -offset intent > s/intent/indent/ ? -- Ian From owner-svn-src-all@freebsd.org Sat Nov 21 18:46:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38A7B46DE11; Sat, 21 Nov 2020 18:46:27 +0000 (UTC) (envelope-from vmaffione@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cdj770sGXz3J1Y; Sat, 21 Nov 2020 18:46:27 +0000 (UTC) (envelope-from vmaffione@freebsd.org) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: vmaffione) by smtp.freebsd.org (Postfix) with ESMTPSA id 0A44A2C426; Sat, 21 Nov 2020 18:46:27 +0000 (UTC) (envelope-from vmaffione@freebsd.org) Received: by mail-pg1-f180.google.com with SMTP id f17so1846210pge.6; Sat, 21 Nov 2020 10:46:26 -0800 (PST) X-Gm-Message-State: AOAM533ZnPs6eYllROQ2oMJM2JX6ZsL9M+hMY1yBq7nosqN+Cawiu7Fb g9HF09p1Q2niSiujzFelhbud4WWoe26ISdVkOk4= X-Google-Smtp-Source: ABdhPJxwYg/2A781sQD6ussRk4aTPobQ9Yna2di2m6F4PKW1heRzL+Za1Ah8mUbwHHXhbIkZ5eNYVcJj8Eqsx4KAirE= X-Received: by 2002:a17:90a:c084:: with SMTP id o4mr8095248pjs.150.1605984386057; Sat, 21 Nov 2020 10:46:26 -0800 (PST) MIME-Version: 1.0 References: <202011211820.0ALIKMsI050433@repo.freebsd.org> <6a7cb30702e3391c772b3b9a33a2587d190ff4ef.camel@freebsd.org> In-Reply-To: <6a7cb30702e3391c772b3b9a33a2587d190ff4ef.camel@freebsd.org> From: Vincenzo Maffione Date: Sat, 21 Nov 2020 19:46:15 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r367920 - head/tools/tools/netmap To: Ian Lepore Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 18:46:27 -0000 ups... Thanks! Cheers, Vincenzo Il giorno sab 21 nov 2020 alle ore 19:27 Ian Lepore ha scritto: > On Sat, 2020-11-21 at 18:20 +0000, Vincenzo Maffione wrote: > > Author: vmaffione > > Date: Sat Nov 21 18:20:21 2020 > > New Revision: 367920 > ... > > +.Bd -literal -offset intent > > > > s/intent/indent/ ? > > -- Ian > > From owner-svn-src-all@freebsd.org Sat Nov 21 18:47:14 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 528F446E259; Sat, 21 Nov 2020 18:47:14 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cdj821x5Dz3JBT; Sat, 21 Nov 2020 18:47:14 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 30B4D4E99; Sat, 21 Nov 2020 18:47:14 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0ALIlEBH069302; Sat, 21 Nov 2020 18:47:14 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0ALIlDbO069301; Sat, 21 Nov 2020 18:47:13 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <202011211847.0ALIlDbO069301@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sat, 21 Nov 2020 18:47:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367921 - head/tools/tools/netmap X-SVN-Group: head X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: head/tools/tools/netmap X-SVN-Commit-Revision: 367921 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 18:47:14 -0000 Author: vmaffione Date: Sat Nov 21 18:47:13 2020 New Revision: 367921 URL: https://svnweb.freebsd.org/changeset/base/367921 Log: netmap: bridge, pkt-gen: fix man page typo Reported by: ian MFC after: 3 days Modified: head/tools/tools/netmap/bridge.8 head/tools/tools/netmap/pkt-gen.8 Modified: head/tools/tools/netmap/bridge.8 ============================================================================== --- head/tools/tools/netmap/bridge.8 Sat Nov 21 18:20:21 2020 (r367920) +++ head/tools/tools/netmap/bridge.8 Sat Nov 21 18:47:13 2020 (r367921) @@ -58,7 +58,7 @@ When bridging the hardware rings of a physical port wi host rings, it is necessary to turn off the offloads, because netmap does not prepare the NIC rings with offload information. Example: -.Bd -literal -offset intent +.Bd -literal -offset indent ifconfig em0 -rxcsum -txcsum -tso4 -tso6 -lro .Ed .Pp Modified: head/tools/tools/netmap/pkt-gen.8 ============================================================================== --- head/tools/tools/netmap/pkt-gen.8 Sat Nov 21 18:20:21 2020 (r367920) +++ head/tools/tools/netmap/pkt-gen.8 Sat Nov 21 18:47:13 2020 (r367921) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 3, 2020 +.Dd November 21, 2020 .Dt PKT-GEN 8 .Os .Sh NAME @@ -287,7 +287,7 @@ Send a stream of fake DNS packets between two hosts wi length of 128 bytes. You must set the destination MAC address for packets to be received by the target host. -.Bd -literal -offset intent +.Bd -literal -offset indent pkt-gen -i netmap:ncxl0 -f tx -s 172.16.0.1:53 -d 172.16.1.3:53 -D 00:07:43:29:2a:e0 .Ed .Sh SEE ALSO From owner-svn-src-all@freebsd.org Sat Nov 21 19:14:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 262CA46E568; Sat, 21 Nov 2020 19:14:12 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cdjl8008Rz3KrF; Sat, 21 Nov 2020 19:14:11 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DC24E5616; Sat, 21 Nov 2020 19:14:11 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0ALJEBqX088221; Sat, 21 Nov 2020 19:14:11 GMT (envelope-from mr@FreeBSD.org) Received: (from mr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0ALJEBFV088220; Sat, 21 Nov 2020 19:14:11 GMT (envelope-from mr@FreeBSD.org) Message-Id: <202011211914.0ALJEBFV088220@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mr set sender to mr@FreeBSD.org using -f From: Michael Reifenberger Date: Sat, 21 Nov 2020 19:14:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367922 - head/usr.bin/systat X-SVN-Group: head X-SVN-Commit-Author: mr X-SVN-Commit-Paths: head/usr.bin/systat X-SVN-Commit-Revision: 367922 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 19:14:12 -0000 Author: mr Date: Sat Nov 21 19:14:11 2020 New Revision: 367922 URL: https://svnweb.freebsd.org/changeset/base/367922 Log: Improve number reading by rounding up to a next unit earlier for memory display. Submitted by: ota@j.email.ne.jp Differential Revision: https://reviews.freebsd.org/D26503 Modified: head/usr.bin/systat/vmstat.c Modified: head/usr.bin/systat/vmstat.c ============================================================================== --- head/usr.bin/systat/vmstat.c Sat Nov 21 18:47:13 2020 (r367921) +++ head/usr.bin/systat/vmstat.c Sat Nov 21 19:14:11 2020 (r367922) @@ -303,12 +303,12 @@ labelkre(void) clear(); mvprintw(STATROW, STATCOL + 6, "users Load"); mvprintw(STATROW + 1, STATCOL + 3, "Mem usage: %%Phy %%Kmem"); - mvprintw(MEMROW, MEMCOL, "Mem: REAL VIRTUAL"); - mvprintw(MEMROW + 1, MEMCOL, " Tot Share Tot Share"); + mvprintw(MEMROW, MEMCOL, "Mem: REAL VIRTUAL"); + mvprintw(MEMROW + 1, MEMCOL, " Tot Share Tot Share"); mvprintw(MEMROW + 2, MEMCOL, "Act"); mvprintw(MEMROW + 3, MEMCOL, "All"); - mvprintw(MEMROW + 1, MEMCOL + 41, "Free"); + mvprintw(MEMROW + 1, MEMCOL + 40, "Free"); mvprintw(PAGEROW, PAGECOL, " VN PAGER SWAP PAGER"); mvprintw(PAGEROW + 1, PAGECOL, " in out in out"); @@ -458,15 +458,15 @@ showkre(void) putfloat(100.0 * s.v_kmem_map_size / kmem_size, STATROW + 1, STATCOL + 22, 2, 0, 1); - sysputpage(wnd, MEMROW + 2, MEMCOL + 4, 7, total.t_arm, 0); - sysputpage(wnd, MEMROW + 2, MEMCOL + 12, 7, total.t_armshr, 0); - sysputpage(wnd, MEMROW + 2, MEMCOL + 20, 8, total.t_avm, 0); - sysputpage(wnd, MEMROW + 2, MEMCOL + 29, 8, total.t_avmshr, 0); - sysputpage(wnd, MEMROW + 3, MEMCOL + 4, 7, total.t_rm, 0); - sysputpage(wnd, MEMROW + 3, MEMCOL + 12, 7, total.t_rmshr, 0); - sysputpage(wnd, MEMROW + 3, MEMCOL + 20, 8, total.t_vm, 0); - sysputpage(wnd, MEMROW + 3, MEMCOL + 29, 8, total.t_vmshr, 0); - sysputpage(wnd, MEMROW + 2, MEMCOL + 38, 7, total.t_free, 0); + sysputpage(wnd, MEMROW + 2, MEMCOL + 4, 6, total.t_arm, 0); + sysputpage(wnd, MEMROW + 2, MEMCOL + 12, 6, total.t_armshr, 0); + sysputpage(wnd, MEMROW + 2, MEMCOL + 20, 6, total.t_avm, 0); + sysputpage(wnd, MEMROW + 2, MEMCOL + 29, 6, total.t_avmshr, 0); + sysputpage(wnd, MEMROW + 3, MEMCOL + 4, 6, total.t_rm, 0); + sysputpage(wnd, MEMROW + 3, MEMCOL + 12, 6, total.t_rmshr, 0); + sysputpage(wnd, MEMROW + 3, MEMCOL + 20, 6, total.t_vm, 0); + sysputpage(wnd, MEMROW + 3, MEMCOL + 29, 6, total.t_vmshr, 0); + sysputpage(wnd, MEMROW + 2, MEMCOL + 38, 6, total.t_free, 0); putint(total.t_rq - 1, PROCSROW + 2, PROCSCOL, 3); putint(total.t_pw, PROCSROW + 2, PROCSCOL + 4, 3); putint(total.t_dw, PROCSROW + 2, PROCSCOL + 8, 3); From owner-svn-src-all@freebsd.org Sat Nov 21 21:43:37 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C28294717CD; Sat, 21 Nov 2020 21:43:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cdn3Y5Bvkz3R92; Sat, 21 Nov 2020 21:43:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A57196EB6; Sat, 21 Nov 2020 21:43:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0ALLhbKq080894; Sat, 21 Nov 2020 21:43:37 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0ALLhaQA080890; Sat, 21 Nov 2020 21:43:36 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202011212143.0ALLhaQA080890@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 21 Nov 2020 21:43:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367923 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 367923 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 21:43:37 -0000 Author: kib Date: Sat Nov 21 21:43:36 2020 New Revision: 367923 URL: https://svnweb.freebsd.org/changeset/base/367923 Log: Stop using eventhandlers for itimers subsystem exec and exit hooks. While there, do some minor cleanup for kclocks. They are only registered from kern_time.c, make registration function static. Remove event hooks, they are not used by both registered kclocks. Add some consts. Perhaps we can stop registering kclocks at all and statically initialize them. Reviewed by: mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27305 Modified: head/sys/kern/kern_exec.c head/sys/kern/kern_exit.c head/sys/kern/kern_time.c head/sys/sys/timers.h Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Sat Nov 21 19:14:11 2020 (r367922) +++ head/sys/kern/kern_exec.c Sat Nov 21 21:43:36 2020 (r367923) @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1049,6 +1050,7 @@ exec_new_vmspace(struct image_params *imgp, struct sys sigfastblock_clear(td); umtx_exec(p); + itimers_exec(p); EVENTHANDLER_DIRECT_INVOKE(process_exec, p, imgp); Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Sat Nov 21 19:14:11 2020 (r367922) +++ head/sys/kern/kern_exit.c Sat Nov 21 21:43:36 2020 (r367923) @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #ifdef KTRACE #include @@ -323,6 +324,8 @@ exit1(struct thread *td, int rval, int signo) msleep(p, &ppeers_lock, PWAIT, "exit1", 0); mtx_unlock(&ppeers_lock); } + + itimers_exit(p); /* * Check if any loadable modules need anything done at process exit. Modified: head/sys/kern/kern_time.c ============================================================================== --- head/sys/kern/kern_time.c Sat Nov 21 19:14:11 2020 (r367922) +++ head/sys/kern/kern_time.c Sat Nov 21 21:43:36 2020 (r367923) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -99,8 +98,6 @@ static void itimer_enter(struct itimer *); static void itimer_leave(struct itimer *); static struct itimer *itimer_find(struct proc *, int); static void itimers_alloc(struct proc *); -static void itimers_event_hook_exec(void *arg, struct proc *p, struct image_params *imgp); -static void itimers_event_hook_exit(void *arg, struct proc *p); static int realtimer_create(struct itimer *); static int realtimer_gettime(struct itimer *, struct itimerspec *); static int realtimer_settime(struct itimer *, int, @@ -109,7 +106,7 @@ static int realtimer_delete(struct itimer *); static void realtimer_clocktime(clockid_t, struct timespec *); static void realtimer_expire(void *); -int register_posix_clock(int, struct kclock *); +static int register_posix_clock(int, const struct kclock *); void itimer_fire(struct itimer *it); int itimespecfix(struct timespec *ts); @@ -1086,12 +1083,11 @@ ppsratecheck(struct timeval *lasttime, int *curpps, in static void itimer_start(void) { - struct kclock rt_clock = { + static const struct kclock rt_clock = { .timer_create = realtimer_create, .timer_delete = realtimer_delete, .timer_settime = realtimer_settime, .timer_gettime = realtimer_gettime, - .event_hook = NULL }; itimer_zone = uma_zcreate("itimer", sizeof(struct itimer), @@ -1101,14 +1097,10 @@ itimer_start(void) p31b_setcfg(CTL_P1003_1B_TIMERS, 200112L); p31b_setcfg(CTL_P1003_1B_DELAYTIMER_MAX, INT_MAX); p31b_setcfg(CTL_P1003_1B_TIMER_MAX, TIMER_MAX); - EVENTHANDLER_REGISTER(process_exit, itimers_event_hook_exit, - (void *)ITIMER_EV_EXIT, EVENTHANDLER_PRI_ANY); - EVENTHANDLER_REGISTER(process_exec, itimers_event_hook_exec, - (void *)ITIMER_EV_EXEC, EVENTHANDLER_PRI_ANY); } -int -register_posix_clock(int clockid, struct kclock *clk) +static int +register_posix_clock(int clockid, const struct kclock *clk) { if ((unsigned)clockid >= MAX_CLOCKS) { printf("%s: invalid clockid\n", __func__); @@ -1714,46 +1706,41 @@ itimers_alloc(struct proc *p) } } -static void -itimers_event_hook_exec(void *arg, struct proc *p, struct image_params *imgp __unused) -{ - itimers_event_hook_exit(arg, p); -} - /* Clean up timers when some process events are being triggered. */ static void -itimers_event_hook_exit(void *arg, struct proc *p) +itimers_event_exit_exec(int start_idx, struct proc *p) { struct itimers *its; struct itimer *it; - int event = (int)(intptr_t)arg; int i; - if (p->p_itimers != NULL) { - its = p->p_itimers; - for (i = 0; i < MAX_CLOCKS; ++i) { - if (posix_clocks[i].event_hook != NULL) - CLOCK_CALL(i, event_hook, (p, i, event)); - } - /* - * According to susv3, XSI interval timers should be inherited - * by new image. - */ - if (event == ITIMER_EV_EXEC) - i = 3; - else if (event == ITIMER_EV_EXIT) - i = 0; - else - panic("unhandled event"); - for (; i < TIMER_MAX; ++i) { - if ((it = its->its_timers[i]) != NULL) - kern_ktimer_delete(curthread, i); - } - if (its->its_timers[0] == NULL && - its->its_timers[1] == NULL && - its->its_timers[2] == NULL) { - free(its, M_SUBPROC); - p->p_itimers = NULL; - } + its = p->p_itimers; + if (its == NULL) + return; + + for (i = start_idx; i < TIMER_MAX; ++i) { + if ((it = its->its_timers[i]) != NULL) + kern_ktimer_delete(curthread, i); } + if (its->its_timers[0] == NULL && its->its_timers[1] == NULL && + its->its_timers[2] == NULL) { + free(its, M_SUBPROC); + p->p_itimers = NULL; + } +} + +void +itimers_exec(struct proc *p) +{ + /* + * According to susv3, XSI interval timers should be inherited + * by new image. + */ + itimers_event_exit_exec(3, p); +} + +void +itimers_exit(struct proc *p) +{ + itimers_event_exit_exec(0, p); } Modified: head/sys/sys/timers.h ============================================================================== --- head/sys/sys/timers.h Sat Nov 21 19:14:11 2020 (r367922) +++ head/sys/sys/timers.h Sat Nov 21 21:43:36 2020 (r367923) @@ -107,13 +107,10 @@ struct kclock { int (*timer_delete)(struct itimer * timer); int (*timer_gettime)(struct itimer * timer, struct itimerspec * cur_value); - void (*event_hook)(struct proc *p, clockid_t clock_id, int event); }; -/* Event values for event_hook() */ -#define ITIMER_EV_EXEC 0 -#define ITIMER_EV_EXIT 1 - +void itimers_exec(struct proc *p); +void itimers_exit(struct proc *p); int itimer_accept(struct proc *p, int tid, ksiginfo_t *ksi); #endif #endif /* !_SYS_TIMERS_H_ */