From nobody Mon Oct 25 16:13:28 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CF7121826335; Mon, 25 Oct 2021 16:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdKkd30zCz3mWH; Mon, 25 Oct 2021 16:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 03FD83BF9; Mon, 25 Oct 2021 16:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PGDSTr097840; Mon, 25 Oct 2021 16:13:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PGDSuD097839; Mon, 25 Oct 2021 16:13:28 GMT (envelope-from git) Date: Mon, 25 Oct 2021 16:13:28 GMT Message-Id: <202110251613.19PGDSuD097839@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: b382b78503b5 - main - LinuxKPI: add kstrtou8() and kstrtou8_from_user() to kernel.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b382b78503b56ad6b787b995b46418db27adaa61 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=b382b78503b56ad6b787b995b46418db27adaa61 commit b382b78503b56ad6b787b995b46418db27adaa61 Author: Bjoern A. Zeeb AuthorDate: 2021-10-22 11:04:36 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 16:10:48 +0000 LinuxKPI: add kstrtou8() and kstrtou8_from_user() to kernel.h Analogous to the other sized version of kstrto[u]() and kstrtobool_from_user() add the "u8" versions needed by a driver. MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32598 --- sys/compat/linuxkpi/common/include/linux/kernel.h | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 852603f75f8b..6cbd95c4ac64 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -393,6 +393,24 @@ kstrtouint(const char *cp, unsigned int base, unsigned int *res) return (0); } +static inline int +kstrtou8(const char *cp, unsigned int base, u8 *res) +{ + char *end; + unsigned long temp; + + *res = temp = strtoul(cp, &end, base); + + /* skip newline character, if any */ + if (*end == '\n') + end++; + if (*cp == 0 || *end != 0) + return (-EINVAL); + if (temp != (u8)temp) + return (-ERANGE); + return (0); +} + static inline int kstrtou16(const char *cp, unsigned int base, u16 *res) { @@ -484,6 +502,21 @@ kstrtobool_from_user(const char __user *s, size_t count, bool *res) return (kstrtobool(buf, res)); } +static inline int +kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, + u8 *p) +{ + char buf[8] = {}; + + if (count > (sizeof(buf) - 1)) + count = (sizeof(buf) - 1); + + if (copy_from_user(buf, s, count)) + return (-EFAULT); + + return (kstrtou8(buf, base, p)); +} + #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) From nobody Mon Oct 25 16:14:52 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B9E38182774F; Mon, 25 Oct 2021 16:14:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdKmF3bDBz3p1T; Mon, 25 Oct 2021 16:14:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 115663BFC; Mon, 25 Oct 2021 16:14:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PGEq4t098157; Mon, 25 Oct 2021 16:14:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PGEqKj098156; Mon, 25 Oct 2021 16:14:52 GMT (envelope-from git) Date: Mon, 25 Oct 2021 16:14:52 GMT Message-Id: <202110251614.19PGEqKj098156@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: a5e2a27dca4b - main - LinuxKPI: add strreplace() to string.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a5e2a27dca4bd5f4795b42ac598d4fff1c3a6eae Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=a5e2a27dca4bd5f4795b42ac598d4fff1c3a6eae commit a5e2a27dca4bd5f4795b42ac598d4fff1c3a6eae Author: Bjoern A. Zeeb AuthorDate: 2021-10-22 11:00:36 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 16:12:10 +0000 LinuxKPI: add strreplace() to string.h Add strreplace() needed by a driver. MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32597 --- sys/compat/linuxkpi/common/include/linux/string.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index 659a48d93596..a757464bf02b 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -167,6 +167,19 @@ str_has_prefix(const char *str, const char *prefix) return (strncmp(str, prefix, len) == 0 ? len : 0); } +static inline char * +strreplace(char *str, char old, char new) +{ + char *p; + + p = strchrnul(str, old); + while (p != NULL && *p != '\0') { + *p = new; + p = strchrnul(str, old); + } + return (p); +} + static inline ssize_t strscpy(char* dst, const char* src, size_t len) { From nobody Mon Oct 25 17:28:52 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CD383180D83C; Mon, 25 Oct 2021 17:28:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdMPc5N2lz3GrV; Mon, 25 Oct 2021 17:28:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 94EA74EB2; Mon, 25 Oct 2021 17:28:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PHSqF6091292; Mon, 25 Oct 2021 17:28:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PHSqfn091291; Mon, 25 Oct 2021 17:28:52 GMT (envelope-from git) Date: Mon, 25 Oct 2021 17:28:52 GMT Message-Id: <202110251728.19PHSqfn091291@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 9ef7df022a46 - main - hyperv: Register hyperv_timecounter later during boot List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9ef7df022a467776aa616b92fe5783e4261e84c6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9ef7df022a467776aa616b92fe5783e4261e84c6 commit 9ef7df022a467776aa616b92fe5783e4261e84c6 Author: Mark Johnston AuthorDate: 2021-10-25 17:08:38 +0000 Commit: Mark Johnston CommitDate: 2021-10-25 17:25:01 +0000 hyperv: Register hyperv_timecounter later during boot Previously the MSR-based timecounter was registered during SI_SUB_HYPERVISOR, i.e., very early during boot, and before SI_SUB_LOCK. After commit 621fd9dcb2d8 this triggers a panic since the timecounter list lock is not yet initialized. The hyperv timecounter does not need to be registered so early, so defer that to SI_SUB_DRIVERS, at the same time the hyperv TSC timecounter is registered. Reported by: whu Approved by: whu Fixes: 621fd9dcb2d8 ("timecounter: Lock the timecounter list") MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/dev/hyperv/vmbus/hyperv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/hyperv/vmbus/hyperv.c b/sys/dev/hyperv/vmbus/hyperv.c index 5bb38fde8241..2c413664cd07 100644 --- a/sys/dev/hyperv/vmbus/hyperv.c +++ b/sys/dev/hyperv/vmbus/hyperv.c @@ -247,6 +247,13 @@ hyperv_init(void *dummy __unused) /* Set guest id */ wrmsr(MSR_HV_GUEST_OS_ID, MSR_HV_GUESTID_FREEBSD); +} +SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init, + NULL); + +static void +hyperv_tc_init(void *arg __unused) +{ if (hyperv_features & CPUID_HV_MSR_TIME_REFCNT) { /* Register Hyper-V timecounter */ tc_init(&hyperv_timecounter); @@ -258,8 +265,7 @@ hyperv_init(void *dummy __unused) hyperv_tc64 = hyperv_tc64_rdmsr; } } -SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init, - NULL); +SYSINIT(hyperv_tc_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, hyperv_tc_init, NULL); static void hypercall_memfree(void) From nobody Mon Oct 25 17:34:07 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BA8FF1810A96; Mon, 25 Oct 2021 17:34:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdMWg4yHPz3JRb; Mon, 25 Oct 2021 17:34:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 89B0E50AF; Mon, 25 Oct 2021 17:34:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PHY7sS004348; Mon, 25 Oct 2021 17:34:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PHY7Ix004347; Mon, 25 Oct 2021 17:34:07 GMT (envelope-from git) Date: Mon, 25 Oct 2021 17:34:07 GMT Message-Id: <202110251734.19PHY7Ix004347@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 1b610624fdc8 - main - vm_object_list: split sysctl handler in separate function List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1b610624fdc851f54871f7ee4d67642f5879096f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1b610624fdc851f54871f7ee4d67642f5879096f commit 1b610624fdc851f54871f7ee4d67642f5879096f Author: Konstantin Belousov AuthorDate: 2021-07-13 10:23:25 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-25 17:34:01 +0000 vm_object_list: split sysctl handler in separate function Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31163 --- sys/vm/vm_object.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 9bd3f416ff94..533d1e37318e 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2471,7 +2471,7 @@ vm_object_busy_wait(vm_object_t obj, const char *wmesg) } static int -sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) +vm_object_list_handler(struct sysctl_req *req) { struct kinfo_vmobject *kvo; char *fullpath, *freepath; @@ -2588,6 +2588,13 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) free(kvo, M_TEMP); return (error); } + +static int +sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) +{ + return (vm_object_list_handler(req)); +} + SYSCTL_PROC(_vm, OID_AUTO, objects, CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_object_list, "S,kinfo_vmobject", "List of VM objects"); From nobody Mon Oct 25 17:34:08 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 107471810971; Mon, 25 Oct 2021 17:34:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdMWh6c3Lz3JP2; Mon, 25 Oct 2021 17:34:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AF28350B0; Mon, 25 Oct 2021 17:34:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PHY8PH004372; Mon, 25 Oct 2021 17:34:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PHY8OD004371; Mon, 25 Oct 2021 17:34:08 GMT (envelope-from git) Date: Mon, 25 Oct 2021 17:34:08 GMT Message-Id: <202110251734.19PHY8OD004371@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 42812ccc969f - main - Add vm.swap_objects sysctl List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 42812ccc969f174b3e5827c1c320b1738a1e0985 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=42812ccc969f174b3e5827c1c320b1738a1e0985 commit 42812ccc969f174b3e5827c1c320b1738a1e0985 Author: Konstantin Belousov AuthorDate: 2021-07-13 10:27:36 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-25 17:34:01 +0000 Add vm.swap_objects sysctl Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31163 --- sys/vm/vm_object.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 533d1e37318e..addcf5f2c686 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2471,7 +2471,7 @@ vm_object_busy_wait(vm_object_t obj, const char *wmesg) } static int -vm_object_list_handler(struct sysctl_req *req) +vm_object_list_handler(struct sysctl_req *req, bool swap_only) { struct kinfo_vmobject *kvo; char *fullpath, *freepath; @@ -2509,10 +2509,12 @@ vm_object_list_handler(struct sysctl_req *req) */ mtx_lock(&vm_object_list_mtx); TAILQ_FOREACH(obj, &vm_object_list, object_list) { - if (obj->type == OBJT_DEAD) + if (obj->type == OBJT_DEAD || + (swap_only && (obj->flags & (OBJ_ANON | OBJ_SWAP)) == 0)) continue; VM_OBJECT_RLOCK(obj); - if (obj->type == OBJT_DEAD) { + if (obj->type == OBJT_DEAD || + (swap_only && (obj->flags & (OBJ_ANON | OBJ_SWAP)) == 0)) { VM_OBJECT_RUNLOCK(obj); continue; } @@ -2592,13 +2594,31 @@ vm_object_list_handler(struct sysctl_req *req) static int sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) { - return (vm_object_list_handler(req)); + return (vm_object_list_handler(req, false)); } SYSCTL_PROC(_vm, OID_AUTO, objects, CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_object_list, "S,kinfo_vmobject", "List of VM objects"); +static int +sysctl_vm_object_list_swap(SYSCTL_HANDLER_ARGS) +{ + return (vm_object_list_handler(req, true)); +} + +/* + * This sysctl returns list of the anonymous or swap objects. Intent + * is to provide stripped optimized list useful to analyze swap use. + * Since technically non-swap (default) objects participate in the + * shadow chains, and are converted to swap type as needed by swap + * pager, we must report them. + */ +SYSCTL_PROC(_vm, OID_AUTO, swap_objects, + CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, 0, + sysctl_vm_object_list_swap, "S,kinfo_vmobject", + "List of swap VM objects"); + #include "opt_ddb.h" #ifdef DDB #include From nobody Mon Oct 25 17:34:09 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6E5AB1810977; Mon, 25 Oct 2021 17:34:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdMWk02Jmz3Jm4; Mon, 25 Oct 2021 17:34:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C966451F6; Mon, 25 Oct 2021 17:34:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PHY92o004396; Mon, 25 Oct 2021 17:34:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PHY9Oc004395; Mon, 25 Oct 2021 17:34:09 GMT (envelope-from git) Date: Mon, 25 Oct 2021 17:34:09 GMT Message-Id: <202110251734.19PHY9Oc004395@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7738118e9a29 - main - vm.objects_swap: disable reporting some information List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7738118e9a298a205b37c256245fd8449acccb0c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7738118e9a298a205b37c256245fd8449acccb0c commit 7738118e9a298a205b37c256245fd8449acccb0c Author: Konstantin Belousov AuthorDate: 2021-07-13 10:34:31 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-25 17:34:01 +0000 vm.objects_swap: disable reporting some information For making the call faster, do not count active/inactive object queues, and do not report vnode info if any (for tmpfs). Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31163 --- sys/vm/vm_object.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index addcf5f2c686..9462e8753afb 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2526,20 +2526,22 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) kvo->kvo_memattr = obj->memattr; kvo->kvo_active = 0; kvo->kvo_inactive = 0; - TAILQ_FOREACH(m, &obj->memq, listq) { - /* - * A page may belong to the object but be - * dequeued and set to PQ_NONE while the - * object lock is not held. This makes the - * reads of m->queue below racy, and we do not - * count pages set to PQ_NONE. However, this - * sysctl is only meant to give an - * approximation of the system anyway. - */ - if (m->a.queue == PQ_ACTIVE) - kvo->kvo_active++; - else if (m->a.queue == PQ_INACTIVE) - kvo->kvo_inactive++; + if (!swap_only) { + TAILQ_FOREACH(m, &obj->memq, listq) { + /* + * A page may belong to the object but be + * dequeued and set to PQ_NONE while the + * object lock is not held. This makes the + * reads of m->queue below racy, and we do not + * count pages set to PQ_NONE. However, this + * sysctl is only meant to give an + * approximation of the system anyway. + */ + if (m->a.queue == PQ_ACTIVE) + kvo->kvo_active++; + else if (m->a.queue == PQ_INACTIVE) + kvo->kvo_inactive++; + } } kvo->kvo_vn_fileid = 0; @@ -2547,7 +2549,8 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) kvo->kvo_vn_fsid_freebsd11 = 0; freepath = NULL; fullpath = ""; - kvo->kvo_type = vm_object_kvme_type(obj, &vp); + vp = NULL; + kvo->kvo_type = vm_object_kvme_type(obj, swap_only ? NULL : &vp); if (vp != NULL) { vref(vp); } else if ((obj->flags & OBJ_ANON) != 0) { From nobody Mon Oct 25 17:34:10 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AAA521810D81; Mon, 25 Oct 2021 17:34:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdMWl1yxXz3JRt; Mon, 25 Oct 2021 17:34:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 059EC50B1; Mon, 25 Oct 2021 17:34:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PHYA9x004420; Mon, 25 Oct 2021 17:34:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PHYAOb004419; Mon, 25 Oct 2021 17:34:10 GMT (envelope-from git) Date: Mon, 25 Oct 2021 17:34:10 GMT Message-Id: <202110251734.19PHYAOb004419@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 350fc36b4cf8 - main - sysctl vm.objects: yield if hog List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 350fc36b4cf896cbfce657a6dab600b26367a34a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=350fc36b4cf896cbfce657a6dab600b26367a34a commit 350fc36b4cf896cbfce657a6dab600b26367a34a Author: Konstantin Belousov AuthorDate: 2021-05-07 22:13:29 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-25 17:34:02 +0000 sysctl vm.objects: yield if hog Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31163 --- sys/vm/vm_object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 9462e8753afb..5bbe7faed50b 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2585,6 +2585,7 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) kvo->kvo_structsize = roundup(kvo->kvo_structsize, sizeof(uint64_t)); error = SYSCTL_OUT(req, kvo, kvo->kvo_structsize); + maybe_yield(); mtx_lock(&vm_object_list_mtx); if (error) break; From nobody Mon Oct 25 17:47:56 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 967C918179D3; Mon, 25 Oct 2021 17:47:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdMqc3sXmz3PDk; Mon, 25 Oct 2021 17:47:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64E865490; Mon, 25 Oct 2021 17:47:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PHluLe017806; Mon, 25 Oct 2021 17:47:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PHlugL017805; Mon, 25 Oct 2021 17:47:56 GMT (envelope-from git) Date: Mon, 25 Oct 2021 17:47:56 GMT Message-Id: <202110251747.19PHlugL017805@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 40ddde6ef9f3 - main - rtld: Print currently configured search path for libraries for -v List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 40ddde6ef9f38fd238fd1d84d77750f96c96a157 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=40ddde6ef9f38fd238fd1d84d77750f96c96a157 commit 40ddde6ef9f38fd238fd1d84d77750f96c96a157 Author: Konstantin Belousov AuthorDate: 2021-10-25 16:16:37 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-25 17:41:53 +0000 rtld: Print currently configured search path for libraries for -v Sponsored by: The FreeBSD Foundation MFC after: 1 week --- libexec/rtld-elf/rtld.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 8b1f84c6901a..05afe5f42c3e 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -466,6 +466,13 @@ rtld_init_env_vars(char **env) rtld_init_env_vars_for_prefix(env, ld_env_prefix); } +static void +set_ld_elf_hints_path(void) +{ + if (ld_elf_hints_path == NULL || strlen(ld_elf_hints_path) == 0) + ld_elf_hints_path = ld_elf_hints_default; +} + /* * Main entry point for dynamic linking. The first argument is the * stack pointer. The stack is expected to be laid out as described @@ -723,9 +730,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) ld_tracing = ld_get_env_var(LD_TRACE_LOADED_OBJECTS); ld_utrace = ld_get_env_var(LD_UTRACE); - if ((ld_elf_hints_path == NULL) || strlen(ld_elf_hints_path) == 0) - ld_elf_hints_path = ld_elf_hints_default; - + set_ld_elf_hints_path(); if (ld_debug != NULL && *ld_debug != '\0') debug = 1; dbg("%s is initialized, base address = %p", __progname, @@ -5972,16 +5977,23 @@ parse_args(char* argv[], int argc, bool *use_pathp, int *fdp, mib[1] = HW_MACHINE; sz = sizeof(machine); sysctl(mib, nitems(mib), machine, &sz, NULL, 0); + ld_elf_hints_path = ld_get_env_var( + LD_ELF_HINTS_PATH); + set_ld_elf_hints_path(); rtld_printf( "FreeBSD ld-elf.so.1 %s\n" "FreeBSD_version %d\n" "Default lib path %s\n" + "Hints lib path %s\n" "Env prefix %s\n" + "Default hint file %s\n" "Hint file %s\n" "libmap file %s\n", machine, __FreeBSD_version, ld_standard_library_path, + gethints(false), ld_env_prefix, ld_elf_hints_default, + ld_elf_hints_path, ld_path_libmap_conf); _exit(0); } else { From nobody Mon Oct 25 18:17:57 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 338801824C89; Mon, 25 Oct 2021 18:17:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdNVF334Tz3ngl; Mon, 25 Oct 2021 18:17:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 490A652EF; Mon, 25 Oct 2021 18:17:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PIHvQB058431; Mon, 25 Oct 2021 18:17:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PIHvuF058430; Mon, 25 Oct 2021 18:17:57 GMT (envelope-from git) Date: Mon, 25 Oct 2021 18:17:57 GMT Message-Id: <202110251817.19PIHvuF058430@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: d89c820b0da1 - main - Remove div_ctlinput(). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d89c820b0da17992d4ccd8a075c1b81382cef1a9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=d89c820b0da17992d4ccd8a075c1b81382cef1a9 commit d89c820b0da17992d4ccd8a075c1b81382cef1a9 Author: Gleb Smirnoff AuthorDate: 2021-10-22 23:21:10 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-25 18:16:49 +0000 Remove div_ctlinput(). This function does nothing since 97d8d152c28b. It was introduced in 252f24a2cf40 with a sidenote "may not be needed". Reviewed by: donner Differential Revision: https://reviews.freebsd.org/D32608 --- sys/netinet/ip_divert.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 4141386a6a2d..c30550b1c4db 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -687,18 +687,6 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, return div_output(so, m, (struct sockaddr_in *)nam, control); } -static void -div_ctlinput(int cmd, struct sockaddr *sa, void *vip) -{ - struct in_addr faddr; - - faddr = ((struct sockaddr_in *)sa)->sin_addr; - if (sa->sa_family != AF_INET || faddr.s_addr == INADDR_ANY) - return; - if (PRC_IS_REDIRECT(cmd)) - return; -} - static int div_pcblist(SYSCTL_HANDLER_ARGS) { @@ -791,7 +779,6 @@ struct protosw div_protosw = { .pr_protocol = IPPROTO_DIVERT, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = div_input, - .pr_ctlinput = div_ctlinput, .pr_ctloutput = ip_ctloutput, .pr_init = div_init, .pr_usrreqs = &div_usrreqs From nobody Mon Oct 25 18:17:58 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C46621824BC8; Mon, 25 Oct 2021 18:17:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdNVG4jYXz3npp; Mon, 25 Oct 2021 18:17:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 747E45AA5; Mon, 25 Oct 2021 18:17:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PIHwYN058455; Mon, 25 Oct 2021 18:17:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PIHwcN058454; Mon, 25 Oct 2021 18:17:58 GMT (envelope-from git) Date: Mon, 25 Oct 2021 18:17:58 GMT Message-Id: <202110251817.19PIHwcN058454@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: f2d266f3b081 - main - Don't run ip_ctloutput() for divert socket. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f2d266f3b0815a364289320385f94c3f87dc3c40 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=f2d266f3b0815a364289320385f94c3f87dc3c40 commit f2d266f3b0815a364289320385f94c3f87dc3c40 Author: Gleb Smirnoff AuthorDate: 2021-10-22 23:24:56 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-25 18:16:59 +0000 Don't run ip_ctloutput() for divert socket. It was here since divert(4) was introduced, probably just came with a protocol definition boilerplate. There is no useful socket option that can be set or get for a divert socket. Reviewed by: donner Differential Revision: https://reviews.freebsd.org/D32608 --- sys/netinet/ip_divert.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index c30550b1c4db..e156b77f44c7 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -779,7 +779,6 @@ struct protosw div_protosw = { .pr_protocol = IPPROTO_DIVERT, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = div_input, - .pr_ctloutput = ip_ctloutput, .pr_init = div_init, .pr_usrreqs = &div_usrreqs }; From nobody Mon Oct 25 18:43:07 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8DC08182D2BA; Mon, 25 Oct 2021 18:43:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdP3H3X6Wz3vLk; Mon, 25 Oct 2021 18:43:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 58BFD5CB3; Mon, 25 Oct 2021 18:43:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PIh7Pv097565; Mon, 25 Oct 2021 18:43:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PIh7Va097564; Mon, 25 Oct 2021 18:43:07 GMT (envelope-from git) Date: Mon, 25 Oct 2021 18:43:07 GMT Message-Id: <202110251843.19PIh7Va097564@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: e2493f4912ca - main - arm: fix a typo in nvidia/drm2/tegra_bo.c List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e2493f4912cabd1d04be88fd17139a64bf2a2622 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e2493f4912cabd1d04be88fd17139a64bf2a2622 commit e2493f4912cabd1d04be88fd17139a64bf2a2622 Author: Mateusz Guzik AuthorDate: 2021-10-25 18:42:10 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-25 18:42:10 +0000 arm: fix a typo in nvidia/drm2/tegra_bo.c Unbreaks building TEGRA124 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/arm/nvidia/drm2/tegra_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm/nvidia/drm2/tegra_bo.c b/sys/arm/nvidia/drm2/tegra_bo.c index be5177973f4f..ba614d014564 100644 --- a/sys/arm/nvidia/drm2/tegra_bo.c +++ b/sys/arm/nvidia/drm2/tegra_bo.c @@ -105,7 +105,7 @@ tegra_bo_alloc_contig(size_t npages, u_long alignment, vm_memattr_t memattr, boundary = 0; tries = 0; retry: - m = vm_page_alloc_noobj_contig(VM_ALLOC_WIRE | VM_ALLOC_ZERO, npages, + m = vm_page_alloc_noobj_contig(VM_ALLOC_WIRED | VM_ALLOC_ZERO, npages, low, high, alignment, boundary, memattr); if (m == NULL) { if (tries < 3) { From nobody Mon Oct 25 20:07:41 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0083A1827FC3; Mon, 25 Oct 2021 20:07:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdQws6Sr6z4mMK; Mon, 25 Oct 2021 20:07:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEF2A6D57; Mon, 25 Oct 2021 20:07:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PK7f2N004926; Mon, 25 Oct 2021 20:07:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PK7fHU004925; Mon, 25 Oct 2021 20:07:41 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:07:41 GMT Message-Id: <202110252007.19PK7fHU004925@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: ea14af2d3c40 - main - Inline critical enter/exit for "tied" kernel modules List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ea14af2d3c407c42ac36f73fc6d5a1db0433b436 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ea14af2d3c407c42ac36f73fc6d5a1db0433b436 commit ea14af2d3c407c42ac36f73fc6d5a1db0433b436 Author: Mateusz Guzik AuthorDate: 2021-10-25 17:29:46 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-25 20:07:06 +0000 Inline critical enter/exit for "tied" kernel modules Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/sys/systm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 17c110a957c9..497e09f86488 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -273,7 +273,7 @@ void tablefull(const char *); extern int (*lkpi_alloc_current)(struct thread *, int); int linux_alloc_current_noop(struct thread *, int); -#if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || defined(GENOFFSET) +#if (defined(KLD_MODULE) && !defined(KLD_TIED)) || defined(KTR_CRITICAL) || !defined(_KERNEL) || defined(GENOFFSET) #define critical_enter() critical_enter_KBI() #define critical_exit() critical_exit_KBI() #else From nobody Mon Oct 25 20:15:06 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8F8FA180BB2C; Mon, 25 Oct 2021 20:15:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdR5Q2LjLz4pn3; Mon, 25 Oct 2021 20:15:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 303B56CD4; Mon, 25 Oct 2021 20:15:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKF6u3017713; Mon, 25 Oct 2021 20:15:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKF6Hk017712; Mon, 25 Oct 2021 20:15:06 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:15:06 GMT Message-Id: <202110252015.19PKF6Hk017712@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 9d593d5a76f2 - main - mlx4: rename conflicting netdev_priv() to mlx4_netdev_priv() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9d593d5a76f22a315d7c6ab99e5e76003ec2b3f5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=9d593d5a76f22a315d7c6ab99e5e76003ec2b3f5 commit 9d593d5a76f22a315d7c6ab99e5e76003ec2b3f5 Author: Bjoern A. Zeeb AuthorDate: 2021-10-25 16:18:11 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 20:12:32 +0000 mlx4: rename conflicting netdev_priv() to mlx4_netdev_priv() netdev_priv() is a LinuxKPI function which was used with the old ifnet linux/netdevice.h implementation which was not adaptable to modern Linux drviers unless rewriting them for ifnet in first place which defeats the purpose. Rename the netdev_priv() calls in mlx4 to mlx4_netdev_priv() returning the ifnet softc to avoid conflicting symbol names with different implementations in the future. MFC after: 3 days Reviewed by: hselasky, kib Differential Revision: https://reviews.freebsd.org/D32640 --- sys/dev/mlx4/mlx4_en/en.h | 13 ++++++++++--- sys/dev/mlx4/mlx4_en/mlx4_en_main.c | 2 +- sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c | 34 +++++++++++++++++----------------- sys/dev/mlx4/mlx4_en/mlx4_en_port.c | 8 ++++---- sys/dev/mlx4/mlx4_en/mlx4_en_rx.c | 6 +++--- sys/dev/mlx4/mlx4_en/mlx4_en_tx.c | 16 ++++++++-------- sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c | 2 +- 7 files changed, 44 insertions(+), 37 deletions(-) diff --git a/sys/dev/mlx4/mlx4_en/en.h b/sys/dev/mlx4/mlx4_en/en.h index 4a8b4fbd5fd4..440b9a340221 100644 --- a/sys/dev/mlx4/mlx4_en/en.h +++ b/sys/dev/mlx4/mlx4_en/en.h @@ -39,13 +39,20 @@ #include #include #include -#include #include #include #ifdef CONFIG_MLX4_EN_DCB #include #endif +#include +#include + +#include +#include +#include +#include + #include #include #include @@ -655,7 +662,7 @@ struct mlx4_mac_entry { }; static inline void * -netdev_priv(const struct ifnet *dev) +mlx4_netdev_priv(const struct ifnet *dev) { return (dev->if_softc); } @@ -710,7 +717,7 @@ static inline bool mlx4_en_cq_lock_poll(struct mlx4_en_cq *cq) spin_lock_bh(&cq->poll_lock); if ((cq->state & MLX4_CQ_LOCKED)) { struct ifnet *dev = cq->dev; - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_rx_ring *rx_ring = priv->rx_ring[cq->ring]; cq->state |= MLX4_EN_CQ_STATE_POLL_YIELD; diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_main.c b/sys/dev/mlx4/mlx4_en/mlx4_en_main.c index fe3adfe9c162..e328fb228982 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_main.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_main.c @@ -119,7 +119,7 @@ static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr, case MLX4_DEV_EVENT_PORT_DOWN: if (!mdev->pndev[port]) return; - priv = netdev_priv(mdev->pndev[port]); + priv = mlx4_netdev_priv(mdev->pndev[port]); /* To prevent races, we poll the link state in a separate task rather than changing it here */ priv->link_state = event; diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c index 672affcce623..14289cb20e13 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c @@ -65,7 +65,7 @@ static int mlx4_en_low_latency_recv(struct napi_struct *napi) { struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi); struct ifnet *dev = cq->dev; - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_rx_ring *rx_ring = priv->rx_ring[cq->ring]; int done; @@ -291,7 +291,7 @@ static int mlx4_en_filter_rfs(struct ifnet *net_dev, const struct sk_buff *skb, u16 rxq_index, u32 flow_id) { - struct mlx4_en_priv *priv = netdev_priv(net_dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(net_dev); struct mlx4_en_filter *filter; const struct iphdr *ip; const __be16 *ports; @@ -402,7 +402,7 @@ static void mlx4_en_filter_rfs_expire(struct mlx4_en_priv *priv) static void mlx4_en_vlan_rx_add_vid(void *arg, struct ifnet *dev, u16 vid) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; int err; int idx; @@ -429,7 +429,7 @@ static void mlx4_en_vlan_rx_add_vid(void *arg, struct ifnet *dev, u16 vid) static void mlx4_en_vlan_rx_kill_vid(void *arg, struct ifnet *dev, u16 vid) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; int err; @@ -608,7 +608,7 @@ static void mlx4_en_put_qp(struct mlx4_en_priv *priv) static void mlx4_en_clear_uclist(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_addr_list *tmp, *uc_to_del; list_for_each_entry_safe(uc_to_del, tmp, &priv->uc_list, list) { @@ -637,7 +637,7 @@ static u_int mlx4_copy_addr(void *arg, struct sockaddr_dl *sdl, u_int cnt) static void mlx4_en_cache_uclist(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); mlx4_en_clear_uclist(dev); if_foreach_lladdr(dev, mlx4_copy_addr, priv); @@ -645,7 +645,7 @@ static void mlx4_en_cache_uclist(struct ifnet *dev) static void mlx4_en_clear_mclist(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_addr_list *tmp, *mc_to_del; list_for_each_entry_safe(mc_to_del, tmp, &priv->mc_list, list) { @@ -673,7 +673,7 @@ static u_int mlx4_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int count) static void mlx4_en_cache_mclist(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); mlx4_en_clear_mclist(dev); if_foreach_llmaddr(dev, mlx4_copy_maddr, priv); @@ -730,7 +730,7 @@ static void update_addr_list_flags(struct mlx4_en_priv *priv, static void mlx4_en_set_rx_mode(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); if (!priv->port_up) return; @@ -1260,7 +1260,7 @@ static void mlx4_en_linkstate(struct work_struct *work) int mlx4_en_start_port(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_cq *cq; struct mlx4_en_tx_ring *tx_ring; @@ -1453,7 +1453,7 @@ cq_err: void mlx4_en_stop_port(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_addr_list *addr_list, *tmp; int i; @@ -1603,7 +1603,7 @@ reset: static void mlx4_en_clear_stats(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; int i; @@ -1762,7 +1762,7 @@ struct en_port_attribute en_port_attr_##_name = __ATTR(_name, _mode, _show, _sto void mlx4_en_destroy_netdev(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); @@ -1817,7 +1817,7 @@ void mlx4_en_destroy_netdev(struct ifnet *dev) static int mlx4_en_change_mtu(struct ifnet *dev, int new_mtu) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; int err = 0; @@ -2353,7 +2353,7 @@ out: static int mlx4_en_set_ring_size(struct ifnet *dev, int rx_size, int tx_size) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; int port_up = 0; int err = 0; @@ -2427,7 +2427,7 @@ static int mlx4_en_set_tx_ring_size(SYSCTL_HANDLER_ARGS) static int mlx4_en_get_module_info(struct ifnet *dev, struct ethtool_modinfo *modinfo) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; int ret; u8 data[4]; @@ -2475,7 +2475,7 @@ static int mlx4_en_get_module_eeprom(struct ifnet *dev, struct ethtool_eeprom *ee, u8 *data) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; int offset = ee->offset; int i = 0, ret; diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_port.c b/sys/dev/mlx4/mlx4_en/mlx4_en_port.c index 9a0edac109f4..2e19130b9e96 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_port.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_port.c @@ -74,7 +74,7 @@ int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv) int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port) { struct mlx4_en_query_port_context *qport_context; - struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]); + struct mlx4_en_priv *priv = mlx4_netdev_priv(mdev->pndev[port]); struct mlx4_en_port_state *state = &priv->port_state; struct mlx4_cmd_mailbox *mailbox; int err; @@ -151,7 +151,7 @@ static u64 en_stats_adder(__be64 *start, __be64 *next, int num) static void mlx4_en_fold_software_stats(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; u64 packets, bytes; int i; @@ -188,7 +188,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset) struct mlx4_en_stat_out_mbox *mlx4_en_stats; struct mlx4_en_stat_out_flow_control_mbox *flowstats; struct ifnet *dev = mdev->pndev[port]; - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_vport_stats *vport_stats = &priv->vport_stats; struct mlx4_cmd_mailbox *mailbox; u64 in_mod = reset << 8 | port; @@ -436,7 +436,7 @@ out: int mlx4_en_get_vport_stats(struct mlx4_en_dev *mdev, u8 port) { - struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]); + struct mlx4_en_priv *priv = mlx4_netdev_priv(mdev->pndev[port]); struct mlx4_counter tmp_vport_stats; struct mlx4_en_vf_stats *vf_stats = &priv->vf_stats; int err, i, counter_index; diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c b/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c index 8e7c410d1c55..56e8711c6599 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c @@ -340,7 +340,7 @@ void mlx4_en_set_num_rx_rings(struct mlx4_en_dev *mdev) void mlx4_en_calc_rx_buf(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); int eff_mtu = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN + MLX4_NET_IP_ALIGN; @@ -737,7 +737,7 @@ mlx4_en_rss_hash(__be16 status, int udp_rss) #define CQE_FACTOR_INDEX(index, factor) (((index) << (factor)) + (factor)) int mlx4_en_process_rx_cq(struct ifnet *dev, struct mlx4_en_cq *cq, int budget) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_cqe *cqe; struct mlx4_en_rx_ring *ring = priv->rx_ring[cq->ring]; struct mlx4_en_rx_mbuf *mb_list; @@ -880,7 +880,7 @@ static int mlx4_en_poll_rx_cq(struct mlx4_en_cq *cq, int budget) void mlx4_en_rx_irq(struct mlx4_cq *mcq) { struct mlx4_en_cq *cq = container_of(mcq, struct mlx4_en_cq, mcq); - struct mlx4_en_priv *priv = netdev_priv(cq->dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(cq->dev); int done; // Shoot one within the irq context diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c index f3a41a15f8b6..34af99ae0340 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c @@ -310,7 +310,7 @@ done: int mlx4_en_free_tx_buf(struct ifnet *dev, struct mlx4_en_tx_ring *ring) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); int cnt = 0; /* Skip last polled descriptor */ @@ -347,7 +347,7 @@ mlx4_en_tx_ring_is_full(struct mlx4_en_tx_ring *ring) static int mlx4_en_process_tx_cq(struct ifnet *dev, struct mlx4_en_cq *cq) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_cq *mcq = &cq->mcq; struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring]; struct mlx4_cqe *cqe; @@ -423,7 +423,7 @@ static int mlx4_en_process_tx_cq(struct ifnet *dev, void mlx4_en_tx_irq(struct mlx4_cq *mcq) { struct mlx4_en_cq *cq = container_of(mcq, struct mlx4_en_cq, mcq); - struct mlx4_en_priv *priv = netdev_priv(cq->dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(cq->dev); struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring]; if (priv->port_up == 0 || !spin_trylock(&ring->comp_lock)) @@ -436,7 +436,7 @@ void mlx4_en_tx_irq(struct mlx4_cq *mcq) void mlx4_en_poll_tx_cq(unsigned long data) { struct mlx4_en_cq *cq = (struct mlx4_en_cq *) data; - struct mlx4_en_priv *priv = netdev_priv(cq->dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(cq->dev); struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring]; u32 inflight; @@ -606,7 +606,7 @@ SYSINIT(hashrandom_init, SI_SUB_RANDOM, SI_ORDER_ANY, &hashrandom_init, NULL); u16 mlx4_en_select_queue(struct ifnet *dev, struct mbuf *mb) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); u32 rings_p_up = priv->num_tx_rings_p_up; u32 up = 0; u32 queue_index; @@ -929,7 +929,7 @@ tx_drop: static int mlx4_en_transmit_locked(struct ifnet *ifp, int tx_ind, struct mbuf *mb) { - struct mlx4_en_priv *priv = netdev_priv(ifp); + struct mlx4_en_priv *priv = mlx4_netdev_priv(ifp); struct mlx4_en_tx_ring *ring = priv->tx_ring[tx_ind]; int err = 0; @@ -954,7 +954,7 @@ mlx4_en_transmit_locked(struct ifnet *ifp, int tx_ind, struct mbuf *mb) int mlx4_en_transmit(struct ifnet *dev, struct mbuf *m) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); struct mlx4_en_tx_ring *ring; int i, err = 0; @@ -994,7 +994,7 @@ mlx4_en_transmit(struct ifnet *dev, struct mbuf *m) void mlx4_en_qflush(struct ifnet *dev) { - struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_priv *priv = mlx4_netdev_priv(dev); if (priv->port_up == 0) return; diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c index f9ac3121199a..b8a61c87f827 100644 --- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c +++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c @@ -148,7 +148,7 @@ static struct ifnet *mlx4_ib_get_netdev(struct ib_device *device, u8 port_num) if (upper) { struct ifnet *active; - active = bond_option_active_slave_get_rcu(netdev_priv(upper)); + active = bond_option_active_slave_get_rcu(mlx4_netdev_priv(upper)); if (active) dev = active; } From nobody Mon Oct 25 20:17:17 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A6230180C5BC; Mon, 25 Oct 2021 20:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdR7x48zkz4qHp; Mon, 25 Oct 2021 20:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6C7506CD5; Mon, 25 Oct 2021 20:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKHH5E017998; Mon, 25 Oct 2021 20:17:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKHHjg017997; Mon, 25 Oct 2021 20:17:17 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:17:17 GMT Message-Id: <202110252017.19PKHHjg017997@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 41dee251ee9e - main - LinuxKPI: add simple_open() to fs.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 41dee251ee9ead2e5c7a33b1457db5742c584354 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=41dee251ee9ead2e5c7a33b1457db5742c584354 commit 41dee251ee9ead2e5c7a33b1457db5742c584354 Author: Bjoern A. Zeeb AuthorDate: 2021-10-25 16:44:18 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 20:14:42 +0000 LinuxKPI: add simple_open() to fs.h Add a dummy simple_open() to fs.h as we have for other (unsupported) functions. This is needed by a wireless driver. MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32642 --- sys/compat/linuxkpi/common/include/linux/fs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/fs.h b/sys/compat/linuxkpi/common/include/linux/fs.h index eaf806b6732c..f1892352d598 100644 --- a/sys/compat/linuxkpi/common/include/linux/fs.h +++ b/sys/compat/linuxkpi/common/include/linux/fs.h @@ -245,6 +245,12 @@ nonseekable_open(struct inode *inode, struct file *filp) return 0; } +static inline int +simple_open(struct inode *inode, struct file *filp) +{ + return 0; +} + extern unsigned int linux_iminor(struct inode *); #define iminor(...) linux_iminor(__VA_ARGS__) From nobody Mon Oct 25 20:18:57 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AC0A3180E28C; Mon, 25 Oct 2021 20:18:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdR9s4SM3z4rBK; Mon, 25 Oct 2021 20:18:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7040D6CD8; Mon, 25 Oct 2021 20:18:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKIvrC018215; Mon, 25 Oct 2021 20:18:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKIvO4018214; Mon, 25 Oct 2021 20:18:57 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:18:57 GMT Message-Id: <202110252018.19PKIvO4018214@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 490f9d8f0e7c - main - LinuxKPI: add netdev_features.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 490f9d8f0e7ce8c5b268fcd0806c5e00214eb5a7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=490f9d8f0e7ce8c5b268fcd0806c5e00214eb5a7 commit 490f9d8f0e7ce8c5b268fcd0806c5e00214eb5a7 Author: Bjoern A. Zeeb AuthorDate: 2021-10-25 16:50:27 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 20:16:23 +0000 LinuxKPI: add netdev_features.h Add netdev_features.h as a spearate file from the future netdevice.h implementation to avoid include problems with a future skbuff.h. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32643 --- .../common/include/linux/netdev_features.h | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/netdev_features.h b/sys/compat/linuxkpi/common/include/linux/netdev_features.h new file mode 100644 index 000000000000..a4901f4d48c3 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/netdev_features.h @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2020-2021 The FreeBSD Foundation + * + * Portions of this software were developed by Björn Zeeb + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ +#ifndef __LKPI_LINUX_NETDEV_FEATURES_H_ +#define __LKPI_LINUX_NETDEV_FEATURES_H_ + +#include +#include + +typedef uint32_t netdev_features_t; + +#define NETIF_F_HIGHDMA BIT(0) +#define NETIF_F_SG BIT(1) +#define NETIF_F_IP_CSUM BIT(2) +#define NETIF_F_IPV6_CSUM BIT(3) +#define NETIF_F_TSO BIT(4) +#define NETIF_F_TSO6 BIT(5) +#define NETIF_F_RXCSUM BIT(6) + +#define NETIF_F_CSUM_MASK (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM) + +#endif /* __LKPI_LINUX_NETDEV_FEATURES_H_ */ From nobody Mon Oct 25 20:20:23 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2B89D180FEA5; Mon, 25 Oct 2021 20:20:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdRCX0pCBz4s6q; Mon, 25 Oct 2021 20:20:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E4EFE7489; Mon, 25 Oct 2021 20:20:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKKN3r026629; Mon, 25 Oct 2021 20:20:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKKNb5026628; Mon, 25 Oct 2021 20:20:23 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:20:23 GMT Message-Id: <202110252020.19PKKNb5026628@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: ed5600f5329f - main - LinuxKPI: pci.h make pci_dev argument const for pci_{read,write}_config*() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed5600f5329fad8b167bed0a5ae8a5f60d12258e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=ed5600f5329fad8b167bed0a5ae8a5f60d12258e commit ed5600f5329fad8b167bed0a5ae8a5f60d12258e Author: Bjoern A. Zeeb AuthorDate: 2021-10-25 17:06:09 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 20:17:56 +0000 LinuxKPI: pci.h make pci_dev argument const for pci_{read,write}_config*() Make the struct pci_dev argument to the pci_{read,write}_config*() functions "const" to match the Linux definition as some drivers try to pass in a const argument which we currently fail to honor. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32644 --- sys/compat/linuxkpi/common/include/linux/pci.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 2bac82de2af5..5903a402c52e 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -692,7 +692,7 @@ pci_disable_link_state(struct pci_dev *pdev, uint32_t flags) } static inline int -pci_read_config_byte(struct pci_dev *pdev, int where, u8 *val) +pci_read_config_byte(const struct pci_dev *pdev, int where, u8 *val) { *val = (u8)pci_read_config(pdev->dev.bsddev, where, 1); @@ -700,7 +700,7 @@ pci_read_config_byte(struct pci_dev *pdev, int where, u8 *val) } static inline int -pci_read_config_word(struct pci_dev *pdev, int where, u16 *val) +pci_read_config_word(const struct pci_dev *pdev, int where, u16 *val) { *val = (u16)pci_read_config(pdev->dev.bsddev, where, 2); @@ -708,7 +708,7 @@ pci_read_config_word(struct pci_dev *pdev, int where, u16 *val) } static inline int -pci_read_config_dword(struct pci_dev *pdev, int where, u32 *val) +pci_read_config_dword(const struct pci_dev *pdev, int where, u32 *val) { *val = (u32)pci_read_config(pdev->dev.bsddev, where, 4); @@ -716,7 +716,7 @@ pci_read_config_dword(struct pci_dev *pdev, int where, u32 *val) } static inline int -pci_write_config_byte(struct pci_dev *pdev, int where, u8 val) +pci_write_config_byte(const struct pci_dev *pdev, int where, u8 val) { pci_write_config(pdev->dev.bsddev, where, val, 1); @@ -724,7 +724,7 @@ pci_write_config_byte(struct pci_dev *pdev, int where, u8 val) } static inline int -pci_write_config_word(struct pci_dev *pdev, int where, u16 val) +pci_write_config_word(const struct pci_dev *pdev, int where, u16 val) { pci_write_config(pdev->dev.bsddev, where, val, 2); @@ -732,7 +732,7 @@ pci_write_config_word(struct pci_dev *pdev, int where, u16 val) } static inline int -pci_write_config_dword(struct pci_dev *pdev, int where, u32 val) +pci_write_config_dword(const struct pci_dev *pdev, int where, u32 val) { pci_write_config(pdev->dev.bsddev, where, val, 4); From nobody Mon Oct 25 20:22:02 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1E10418104FA; Mon, 25 Oct 2021 20:22:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdRFR0PHHz4srX; Mon, 25 Oct 2021 20:22:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E19B07344; Mon, 25 Oct 2021 20:22:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKM2Am030751; Mon, 25 Oct 2021 20:22:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKM21e030750; Mon, 25 Oct 2021 20:22:02 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:22:02 GMT Message-Id: <202110252022.19PKM21e030750@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: cf899348420c - main - LinuxKPI: pci.h / linux_pci.c rename pci_driver field List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf899348420ce8839e32ddc30247b5d1c2b384f4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=cf899348420ce8839e32ddc30247b5d1c2b384f4 commit cf899348420ce8839e32ddc30247b5d1c2b384f4 Author: Bjoern A. Zeeb AuthorDate: 2021-10-25 17:15:01 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 20:19:24 +0000 LinuxKPI: pci.h / linux_pci.c rename pci_driver field Rename the struct pci_driver {} field got the list_head from links to node as a driver is actually initialsing this to {} which seems questionable but it will at least make us match the Linux structure field name. MFC after: 3 days Reviewed by: manu, hselasky Differential Revision: https://reviews.freebsd.org/D32645 --- sys/compat/linuxkpi/common/include/linux/pci.h | 2 +- sys/compat/linuxkpi/common/src/linux_pci.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 5903a402c52e..1b4f55c2a2e5 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -193,7 +193,7 @@ typedef int pci_power_t; struct pci_dev; struct pci_driver { - struct list_head links; + struct list_head node; char *name; const struct pci_device_id *id_table; int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index 780ba38d18dd..db94bc08239e 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -242,7 +242,7 @@ linux_pci_find(device_t dev, const struct pci_device_id **idp) subdevice = pci_get_subdevice(dev); spin_lock(&pci_lock); - list_for_each_entry(pdrv, &pci_drivers, links) { + list_for_each_entry(pdrv, &pci_drivers, node) { for (id = pdrv->id_table; id->vendor != 0; id++) { if (vendor == id->vendor && (PCI_ANY_ID == id->device || device == id->device) && @@ -640,7 +640,7 @@ _linux_pci_register_driver(struct pci_driver *pdrv, devclass_t dc) linux_set_current(curthread); spin_lock(&pci_lock); - list_add(&pdrv->links, &pci_drivers); + list_add(&pdrv->node, &pci_drivers); spin_unlock(&pci_lock); pdrv->bsddriver.name = pdrv->name; pdrv->bsddriver.methods = pci_methods; @@ -734,7 +734,7 @@ linux_pci_unregister_driver(struct pci_driver *pdrv) bus = devclass_find("pci"); spin_lock(&pci_lock); - list_del(&pdrv->links); + list_del(&pdrv->node); spin_unlock(&pci_lock); mtx_lock(&Giant); if (bus != NULL) @@ -750,7 +750,7 @@ linux_pci_unregister_drm_driver(struct pci_driver *pdrv) bus = devclass_find("vgapci"); spin_lock(&pci_lock); - list_del(&pdrv->links); + list_del(&pdrv->node); spin_unlock(&pci_lock); mtx_lock(&Giant); if (bus != NULL) From nobody Mon Oct 25 20:23:28 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 56A4B1810E10; Mon, 25 Oct 2021 20:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdRH51zmsz4tQx; Mon, 25 Oct 2021 20:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 195567570; Mon, 25 Oct 2021 20:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKNTBP031789; Mon, 25 Oct 2021 20:23:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKNSRO031788; Mon, 25 Oct 2021 20:23:28 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:23:28 GMT Message-Id: <202110252023.19PKNSRO031788@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 548ada00e54a - main - LinuxKPI: add bcd.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 548ada00e54a9e7745d041b1ec7f68f3bd493365 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=548ada00e54a9e7745d041b1ec7f68f3bd493365 commit 548ada00e54a9e7745d041b1ec7f68f3bd493365 Author: Bjoern A. Zeeb AuthorDate: 2021-10-25 18:14:08 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 20:20:53 +0000 LinuxKPI: add bcd.h Add bcd2bin() as linuxkpi_bcd2bin(). Libkern does provide a bcd2bin() which cannot be used leaving us with a conflict (see comment in file). Fortunately this is only seen in one driver so far and it seems easier to drop this in and change a single line in the driver than to add this inline in the driver. MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32647 --- sys/compat/linuxkpi/common/include/linux/bcd.h | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/bcd.h b/sys/compat/linuxkpi/common/include/linux/bcd.h new file mode 100644 index 000000000000..57fcb4c6bd98 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/bcd.h @@ -0,0 +1,53 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Bjoern A. Zeeb + * + * 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 _LINUXKPI_LINUX_BCD_H +#define _LINUXKPI_LINUX_BCD_H + +#include + +/* + * We could use libkern, but we need the argument truncating. + * + * This leaves us with a duplicate symbol with conflicting types + * so we cannot simply re-define as libkern.h gets included in + * too many places directly or indirectly. This means for now + * drivers will have to be adjusted to call linuxkpi_bcd2bin(). + */ +static inline uint8_t linuxkpi_bcd2bin(uint8_t x) +{ + + return (x & 0x0f) + (x >> 4) * 10; +} + +#if 0 +#define bcd2bin(_x) linuxkpi_bcd2bin(_x) +#endif + +#endif /* _LINUXKPI_LINUX_BCD_H */ From nobody Mon Oct 25 20:25:49 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E7FBE1812A0B; Mon, 25 Oct 2021 20:25:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdRKn6DkDz4vKc; Mon, 25 Oct 2021 20:25:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B70BD7358; Mon, 25 Oct 2021 20:25:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKPnSP032074; Mon, 25 Oct 2021 20:25:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKPnps032073; Mon, 25 Oct 2021 20:25:49 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:25:49 GMT Message-Id: <202110252025.19PKPnps032073@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: fc79cf4fea72 - main - iscsid: set max_recv_data_segment_length to what we advertise List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc79cf4fea7221fa62d480648f05e30f7df73f92 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=fc79cf4fea7221fa62d480648f05e30f7df73f92 commit fc79cf4fea7221fa62d480648f05e30f7df73f92 Author: Ed Maste AuthorDate: 2021-10-21 15:09:58 +0000 Commit: Ed Maste CommitDate: 2021-10-25 20:25:15 +0000 iscsid: set max_recv_data_segment_length to what we advertise Previously we updated the conection's conn_max_recv_data_segment_length only when we received a response containing MaxRecvDataSegmentLength from the target. If the target did not send MaxRecvDataSegmentLength then we left conn_max_recv_data_segment_length at the default (i.e., 8192). A target could then send more data than that defult (up to our advertised maximum), and we would drop the connection. RFC 7143 specifies that MaxRecvDataSegmentLength is Declarative, not negotiated. Just set conn_max_recv_data_segment_length to our advertised value in login_negotiate(). PR: 259355 Reviewed by: mav MFC after: 1 week Fixes: a15fbc904a4d ("Alike to r312190 decouple iSCSI...") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32605 --- usr.sbin/iscsid/login.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/iscsid/login.c b/usr.sbin/iscsid/login.c index 864695dcbdb5..3f0020ef140b 100644 --- a/usr.sbin/iscsid/login.c +++ b/usr.sbin/iscsid/login.c @@ -403,9 +403,6 @@ login_negotiate_key(struct connection *conn, const char *name, tmp = isl->isl_max_send_data_segment_length; } conn->conn_max_send_data_segment_length = tmp; - /* We received target's limit, that means it accepted our's. */ - conn->conn_max_recv_data_segment_length = - isl->isl_max_recv_data_segment_length; } else if (strcmp(name, "MaxBurstLength") == 0) { tmp = strtoul(value, NULL, 10); if (tmp <= 0) @@ -538,6 +535,9 @@ login_negotiate(struct connection *conn) isl->isl_max_recv_data_segment_length); } + conn->conn_max_recv_data_segment_length = + isl->isl_max_recv_data_segment_length; + keys_add(request_keys, "DefaultTime2Wait", "0"); keys_add(request_keys, "DefaultTime2Retain", "0"); keys_add(request_keys, "ErrorRecoveryLevel", "0"); From nobody Mon Oct 25 20:28:13 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 18DAE181442F; Mon, 25 Oct 2021 20:28:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdRNZ0FBdz3C3f; Mon, 25 Oct 2021 20:28:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCA546CF8; Mon, 25 Oct 2021 20:28:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKSDb3032414; Mon, 25 Oct 2021 20:28:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKSDBB032413; Mon, 25 Oct 2021 20:28:13 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:28:13 GMT Message-Id: <202110252028.19PKSDBB032413@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: c5eec7b57c39 - main - LinuxKPI: module.h add MODULE_SUPPORTED_DEVICE() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c5eec7b57c39b1dc4a63fea115a93d8d1628ff08 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=c5eec7b57c39b1dc4a63fea115a93d8d1628ff08 commit c5eec7b57c39b1dc4a63fea115a93d8d1628ff08 Author: Bjoern A. Zeeb AuthorDate: 2021-10-25 16:39:56 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-25 20:26:01 +0000 LinuxKPI: module.h add MODULE_SUPPORTED_DEVICE() Add a dummy MODULE_SUPPORTED_DEVICE define as we do for other MODULE_* macros. This is needed by a wireless driver. MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D32641 --- sys/compat/linuxkpi/common/include/linux/module.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/compat/linuxkpi/common/include/linux/module.h b/sys/compat/linuxkpi/common/include/linux/module.h index cd5366bc52d0..2a4fdc5a11a9 100644 --- a/sys/compat/linuxkpi/common/include/linux/module.h +++ b/sys/compat/linuxkpi/common/include/linux/module.h @@ -50,6 +50,7 @@ #define MODULE_LICENSE(name) #define MODULE_INFO(tag, info) #define MODULE_FIRMWARE(firmware) +#define MODULE_SUPPORTED_DEVICE(name) #define THIS_MODULE ((struct module *)0) From nobody Mon Oct 25 20:53:58 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 40BFD181EA4D; Mon, 25 Oct 2021 20:53:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdRyH1PfXz3KRC; Mon, 25 Oct 2021 20:53:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 06F707E1E; Mon, 25 Oct 2021 20:53:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PKrwxw071058; Mon, 25 Oct 2021 20:53:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PKrwZD071057; Mon, 25 Oct 2021 20:53:58 GMT (envelope-from git) Date: Mon, 25 Oct 2021 20:53:58 GMT Message-Id: <202110252053.19PKrwZD071057@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: b15b0535968e - main - tcp: allow new reno functions to be called from other CC modules List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b15b0535968e6c09694c922d0d173956085426d3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=b15b0535968e6c09694c922d0d173956085426d3 commit b15b0535968e6c09694c922d0d173956085426d3 Author: Michael Tuexen AuthorDate: 2021-10-25 20:48:36 +0000 Commit: Michael Tuexen CommitDate: 2021-10-25 20:53:49 +0000 tcp: allow new reno functions to be called from other CC modules Some new reno functions use the internal data, but are also called from functions of other CC modules. Ensure that in this case, the internal data is not accessed. Reported by: syzbot+1d219ea351caa5109d4b@syzkaller.appspotmail.com Reported by: syzbot+b08144f8cad9c67258c5@syzkaller.appspotmail.com Reviewed by: rrs Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D32649 --- sys/netinet/cc/cc_newreno.c | 47 ++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/sys/netinet/cc/cc_newreno.c b/sys/netinet/cc/cc_newreno.c index 23d2b273f6aa..b7ffd28d1270 100644 --- a/sys/netinet/cc/cc_newreno.c +++ b/sys/netinet/cc/cc_newreno.c @@ -167,12 +167,11 @@ newreno_log_hystart_event(struct cc_var *ccv, struct newreno *nreno, uint8_t mod } } -static int +static int newreno_cb_init(struct cc_var *ccv) { struct newreno *nreno; - ccv->cc_data = NULL; ccv->cc_data = malloc(sizeof(struct newreno), M_NEWRENO, M_NOWAIT); if (ccv->cc_data == NULL) return (ENOMEM); @@ -210,7 +209,13 @@ newreno_ack_received(struct cc_var *ccv, uint16_t type) { struct newreno *nreno; - nreno = (struct newreno *)ccv->cc_data; + /* + * Other TCP congestion controls use newreno_ack_received(), but + * with their own private cc_data. Make sure the cc_data is used + * correctly. + */ + nreno = (CC_ALGO(ccv->ccvc.tcp) == &newreno_cc_algo) ? ccv->cc_data : NULL; + if (type == CC_ACK && !IN_RECOVERY(CCV(ccv, t_flags)) && (ccv->flags & CCF_CWND_LIMITED)) { u_int cw = CCV(ccv, snd_cwnd); @@ -244,7 +249,8 @@ newreno_ack_received(struct cc_var *ccv, uint16_t type) * avoid capping cwnd. */ if (cw > CCV(ccv, snd_ssthresh)) { - if (nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS) { + if ((nreno != NULL) && + (nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS)) { /* * We have slipped into CA with * CSS active. Deactivate all. @@ -278,7 +284,8 @@ newreno_ack_received(struct cc_var *ccv, uint16_t type) abc_val = ccv->labc; else abc_val = V_tcp_abc_l_var; - if ((nreno->newreno_flags & CC_NEWRENO_HYSTART_ALLOWED) && + if ((nreno != NULL) && + (nreno->newreno_flags & CC_NEWRENO_HYSTART_ALLOWED) && (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) && ((nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS) == 0)) { /* @@ -316,7 +323,8 @@ newreno_ack_received(struct cc_var *ccv, uint16_t type) incr = min(ccv->bytes_this_ack, CCV(ccv, t_maxseg)); /* Only if Hystart is enabled will the flag get set */ - if (nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS) { + if ((nreno != NULL) && + (nreno->newreno_flags & CC_NEWRENO_HYSTART_IN_CSS)) { incr /= hystart_css_growth_div; newreno_log_hystart_event(ccv, nreno, 3, incr); } @@ -334,7 +342,12 @@ newreno_after_idle(struct cc_var *ccv) struct newreno *nreno; uint32_t rw; - nreno = (struct newreno *)ccv->cc_data; + /* + * Other TCP congestion controls use newreno_after_idle(), but + * with their own private cc_data. Make sure the cc_data is used + * correctly. + */ + nreno = (CC_ALGO(ccv->ccvc.tcp) == &newreno_cc_algo) ? ccv->cc_data : NULL; /* * If we've been idle for more than one retransmit timeout the old * congestion window is no longer current and we have to reduce it to @@ -358,7 +371,8 @@ newreno_after_idle(struct cc_var *ccv) CCV(ccv, snd_cwnd)-(CCV(ccv, snd_cwnd)>>2)); CCV(ccv, snd_cwnd) = min(rw, CCV(ccv, snd_cwnd)); - if ((nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) == 0) { + if ((nreno != NULL) && + (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) == 0) { if (CCV(ccv, snd_cwnd) <= (hystart_lowcwnd * tcp_fixed_maxseg(ccv->ccvc.tcp))) { /* * Re-enable hystart if our cwnd has fallen below @@ -382,9 +396,14 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type) cwin = CCV(ccv, snd_cwnd); mss = tcp_fixed_maxseg(ccv->ccvc.tcp); - nreno = (struct newreno *) ccv->cc_data; - beta = nreno->beta; - beta_ecn = nreno->beta_ecn; + /* + * Other TCP congestion controls use newreno_cong_signal(), but + * with their own private cc_data. Make sure the cc_data is used + * correctly. + */ + nreno = (CC_ALGO(ccv->ccvc.tcp) == &newreno_cc_algo) ? ccv->cc_data : NULL; + beta = (nreno == NULL) ? V_newreno_beta : nreno->beta;; + beta_ecn = (nreno == NULL) ? V_newreno_beta_ecn : nreno->beta_ecn; /* * Note that we only change the backoff for ECN if the * global sysctl V_cc_do_abe is set the stack itself @@ -407,7 +426,8 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type) switch (type) { case CC_NDUPACK: - if (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) { + if ((nreno != NULL) && + (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED)) { /* Make sure the flags are all off we had a loss */ nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_ENABLED; nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; @@ -425,7 +445,8 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type) } break; case CC_ECN: - if (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED) { + if ((nreno != NULL) && + (nreno->newreno_flags & CC_NEWRENO_HYSTART_ENABLED)) { /* Make sure the flags are all off we had a loss */ nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_ENABLED; nreno->newreno_flags &= ~CC_NEWRENO_HYSTART_IN_CSS; From nobody Mon Oct 25 21:02:31 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5733E1821862 for ; Mon, 25 Oct 2021 21:02:40 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2m.ore.mailhop.org (outbound2m.ore.mailhop.org [54.149.155.156]) (using TLSv1.3 with cipher TLS_AES_256_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 4HdS8J0TV0z3M3k for ; Mon, 25 Oct 2021 21:02:39 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1635195753; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=uXgCpctblJz5O3W5CKiOVswP2ku0zTtbVfgJHjWcjHuHSoW0KEeyZqs7LBUoFYEUU6UWAcLCT+4/+ ZBT33hy+7CZWCRKYWyPnh4mne3lnzXkIUpUdncKKRYswREgH9QtHo4yYNOzE1IDVjiLF6jJ3nAmT7q zudaH3IFT6unssKIWSkR1DaOwABGYrx0S0KBTaXsZOr17it/DtPo+7fGJi5Qe5K7Wrg/PLneWO+IdW mlhzK6sfEgGHQtj+fPa9Vwuc7oBIpB/JKDOv+zmhIB5el97hyefg3EvCat8j16EgeZXvTaJewHiKqD uEz8M7efEUyflgOO88bJwd+oPsucIqQ== 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=/rvx8eP5CN/8a8fmEuL4XbEUhiQRbJALZauTtSc9xE8=; b=M0Yp1swrnnwVia9nqMZDzPvdcRDwl/GZ1HOuccAQQHskvoowy4xLd0x3jcyVcndmtrM8Nzxlzdnz/ Z2cGdpS+B8yN9vNVq4FRQigYsG1BmdHDvzjGQp5GVnTSO0qtIwN5V8GxBeAvwXyr1l7Aa69Vqgsj92 UDCx9bxQAFwujvhpkvLtbHEd2YbTpegbpvr453v/qhTkUy7UWGkSSptwXDuSiUw3FniAG9DEjHHh9g KgELGssSvTXKDWGPxwAbjujLu672UzFBY0RgJfh5IS3HKZxLCRYKnVl9yX267yHuhOzYMttph6nGTl zEDL1YVrXOl15kbEcCxKa7FbmPXOc9g== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=24.8.225.114; 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=/rvx8eP5CN/8a8fmEuL4XbEUhiQRbJALZauTtSc9xE8=; b=WnSRGQGPJxoFVnNOEmDroU0JLinoeW0LMB3Qk6967b98JVYHkkVFDIm2O9Y0OdHJPWMCAGQ7I5vbo Go2YY0yk3miyKmsioh1tbFamuhVMK3j1YAYGU7AR4+gSwsuACToQ7qrakjfhbFb2IhYVC6dFcBVeis W4ipq3jDYaN3FyRh+cl57VcQWvGbpfjPN1zlp399PUXjrI3NQxf+farnY4bxGQNY4wE2cCqFHCawty EP8FuPzEKf4nRJgtB/XlFM6oSFpNlCYc+TLs4HIWcRCpwN4THSIKuoROXyQ7fug77vr3aQ5KMVmJkG qd2NJryMlEd5mD2exUnDM4FwXWDqiHQ== X-Originating-IP: 24.8.225.114 X-MHO-RoutePath: aGlwcGll X-MHO-User: de912d67-35d6-11ec-a67c-89389772cfc7 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-24-8-225-114.hsd1.co.comcast.net [24.8.225.114]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id de912d67-35d6-11ec-a67c-89389772cfc7; Mon, 25 Oct 2021 21:02:32 +0000 (UTC) Received: from [172.22.42.84] (rev2.hippie.lan [172.22.42.84]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 19PL2Vx6097716; Mon, 25 Oct 2021 15:02:31 -0600 (MDT) (envelope-from ian@freebsd.org) X-Authentication-Warning: paranoia.hippie.lan: Host rev2.hippie.lan [172.22.42.84] claimed to be [172.22.42.84] Message-ID: <832a2403091df094d6f7ab471aef0694adebb939.camel@freebsd.org> Subject: Re: git: 548ada00e54a - main - LinuxKPI: add bcd.h From: Ian Lepore To: "Bjoern A. Zeeb" , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Date: Mon, 25 Oct 2021 15:02:31 -0600 In-Reply-To: <202110252023.19PKNSRO031788@gitrepo.freebsd.org> References: <202110252023.19PKNSRO031788@gitrepo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.3 FreeBSD GNOME Team List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4HdS8J0TV0z3M3k X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, 2021-10-25 at 20:23 +0000, Bjoern A. Zeeb wrote: > The branch main has been updated by bz: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=548ada00e54a9e7745d041b1ec7f68f3bd493365 > > commit 548ada00e54a9e7745d041b1ec7f68f3bd493365 > Author:     Bjoern A. Zeeb > AuthorDate: 2021-10-25 18:14:08 +0000 > Commit:     Bjoern A. Zeeb > CommitDate: 2021-10-25 20:20:53 +0000 > >     LinuxKPI: add bcd.h >     >     Add bcd2bin() as linuxkpi_bcd2bin().  Libkern does provide a > bcd2bin() > > [...] > + * We could use libkern, but we need the argument truncating. > + * What does that mean, "we need the argument truncating"? It looks to me like the only functional difference between the linux implementation and ours is that for invalid bcd data (nybble values in the range 0xA - 0xF) the linux version returns a crazy result and our lookup table returns 0. I doubt our code relies on that. -- Ian From nobody Mon Oct 25 21:17:11 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B67591827084; Mon, 25 Oct 2021 21:17:17 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdST94g2Wz3QRH; Mon, 25 Oct 2021 21:17:17 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:13b:39f::9f:25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.sbone.de", Issuer "SBone.DE" (not verified)) (Authenticated sender: bz/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 66AF88D4D; Mon, 25 Oct 2021 21:17:17 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 8633F8D4A216; Mon, 25 Oct 2021 21:17:14 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 90F05E70849; Mon, 25 Oct 2021 21:17:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id tn_T4aZK_bRj; Mon, 25 Oct 2021 21:17:12 +0000 (UTC) Received: from nv.sbone.de (nv.sbone.de [IPv6:fde9:577b:c1a9:31::2013:138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 3D0FDE70847; Mon, 25 Oct 2021 21:17:12 +0000 (UTC) Date: Mon, 25 Oct 2021 21:17:11 +0000 (UTC) From: "Bjoern A. Zeeb" To: Ian Lepore cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 548ada00e54a - main - LinuxKPI: add bcd.h In-Reply-To: <832a2403091df094d6f7ab471aef0694adebb939.camel@freebsd.org> Message-ID: References: <202110252023.19PKNSRO031788@gitrepo.freebsd.org> <832a2403091df094d6f7ab471aef0694adebb939.camel@freebsd.org> X-OpenPGP-Key-Id: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-1355922163-1635196632=:68830" X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-1355922163-1635196632=:68830 Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Mon, 25 Oct 2021, Ian Lepore wrote: > On Mon, 2021-10-25 at 20:23 +0000, Bjoern A. Zeeb wrote: >> The branch main has been updated by bz: >> >> URL: >> https://cgit.FreeBSD.org/src/commit/?id=548ada00e54a9e7745d041b1ec7f68f3bd493365 >> >> commit 548ada00e54a9e7745d041b1ec7f68f3bd493365 >> Author:     Bjoern A. Zeeb >> AuthorDate: 2021-10-25 18:14:08 +0000 >> Commit:     Bjoern A. Zeeb >> CommitDate: 2021-10-25 20:20:53 +0000 >> >>     LinuxKPI: add bcd.h >>     >>     Add bcd2bin() as linuxkpi_bcd2bin().  Libkern does provide a >> bcd2bin() >> >> [...] >> + * We could use libkern, but we need the argument truncating. >> + * > > > What does that mean, "we need the argument truncating"? This one takes an uint8_t as argument. If my memory serves me correctly the Linux driver code through macros passes in larger values 0xabcdxx which are truncated by the argument type. We take an int and then have a KASSERT() which doesn't work so well for these larger values. /bz -- Bjoern A. Zeeb r15:7 --0-1355922163-1635196632=:68830-- From nobody Mon Oct 25 21:26:51 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ED39182BDC8 for ; Mon, 25 Oct 2021 21:27:00 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (using TLSv1.3 with cipher TLS_AES_256_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 4HdShM6zLNz3jqw for ; Mon, 25 Oct 2021 21:26:59 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1635197213; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=tnQk8L4OsEtC1u9QHDICCqQSuaOPEn9uYE3S9QeBXW27laPSYkeZ2AEFBxJUTq4RyaYJjB8tcC8qR CJjaENjZGSlwUN/5rc+Q+uI5QVvAJW1SYYDsBJ4XuQB98PyNdNg4kn4WzNfpUfo06vf4iPCfsl9uJk LSodOkS4Z25u4QRx+/NQ2gmbwH2nWZzwGdRpIGyHmK7Vvuw3m/qiQP1pRUeFgK4WwinOWOKT4lNaDi YsyPsmB1Qa6I2OGe89BVB3iaU6/Jgu4gV9EVD2UgBWBNwP6nOZG+rPWy5FFFPXCuCRyYHw297wv845 m78qfLgz9lIxEjyuEUEsJ2DSjzb6Cug== 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=QV21owQ4ug0Hov0jVReRoF7b4Mgbce/2wFhgiHODKH4=; b=ByOEcmPIlNLOL00dildn31m36oMHA9zAlqERQiR+ZR/3iFab+jMhcOoJXbS2GB5VuAU715Osf4zvt AxMIzbpuAcciMuwdq4vlyBaaetcUShThl/89HP9ZWWXEjnjJCdoBXFoY4o6qArpWksi9reETxEX/Vu +gjR1Oo6a9eQL2yU6Cb/80Co2eMEZMLBQjy2pKsR2zlqMgtoW2hVhWakXj61+BOuY/p2x/nCoD/EC9 ILbPZBf00GAHMYLfklsZi7BCcyBHM00otVw678n9VpHRlZthSzezp58ZdMzgtsTRsvuIvj8qhRGw4g gybQVVHceRy79tQA6vWCBejk/W6/X6w== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=24.8.225.114; 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=QV21owQ4ug0Hov0jVReRoF7b4Mgbce/2wFhgiHODKH4=; b=EwTBLu0Qx+f6P/TYrePDetIBMp4OuIbZkYCj1jIXZN8SWGXkLAX82ajDqCGY311X8Gpn6rYEPKyeX WMCPdCpP0ifSg1md60292YBXQ9+IY+QBUD43uZ7FeZaRrw0j+850GmaFYBC1VJ/UOVcYoEdt+Z8au6 i/XLacL7GJ+pAG73agweZ2iw9qr82APpo6+Ee7V/buuAJegNYceBu6/qWgMwH+e50D0vQn8uRnsak6 qaBlHXnS6P2mCM3VCxfIky4uoB/oCkE2rmYjoF1deqV56+elgPIg6KhJcFa3Vfly2env+lTg3TYMfP yvDApul/Fv+3gxhadx0pjoaPBktLNew== X-Originating-IP: 24.8.225.114 X-MHO-RoutePath: aGlwcGll X-MHO-User: 44e8e02d-35da-11ec-9f98-bf9d68d023b6 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-24-8-225-114.hsd1.co.comcast.net [24.8.225.114]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id 44e8e02d-35da-11ec-9f98-bf9d68d023b6; Mon, 25 Oct 2021 21:26:52 +0000 (UTC) Received: from [172.22.42.84] (rev2.hippie.lan [172.22.42.84]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 19PLQpHV097789; Mon, 25 Oct 2021 15:26:51 -0600 (MDT) (envelope-from ian@freebsd.org) X-Authentication-Warning: paranoia.hippie.lan: Host rev2.hippie.lan [172.22.42.84] claimed to be [172.22.42.84] Message-ID: <845d99d8f7c189418b36a832017518c493af729b.camel@freebsd.org> Subject: Re: git: 548ada00e54a - main - LinuxKPI: add bcd.h From: Ian Lepore To: "Bjoern A. Zeeb" Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Date: Mon, 25 Oct 2021 15:26:51 -0600 In-Reply-To: References: <202110252023.19PKNSRO031788@gitrepo.freebsd.org> <832a2403091df094d6f7ab471aef0694adebb939.camel@freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.3 FreeBSD GNOME Team List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4HdShM6zLNz3jqw X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, 2021-10-25 at 21:17 +0000, Bjoern A. Zeeb wrote: > On Mon, 25 Oct 2021, Ian Lepore wrote: > > > On Mon, 2021-10-25 at 20:23 +0000, Bjoern A. Zeeb wrote: > > > The branch main has been updated by bz: > > > > > > URL: > > > https://cgit.FreeBSD.org/src/commit/?id=548ada00e54a9e7745d041b1ec7f68f3bd493365 > > > > > > commit 548ada00e54a9e7745d041b1ec7f68f3bd493365 > > > Author:     Bjoern A. Zeeb > > > AuthorDate: 2021-10-25 18:14:08 +0000 > > > Commit:     Bjoern A. Zeeb > > > CommitDate: 2021-10-25 20:20:53 +0000 > > > > > >     LinuxKPI: add bcd.h > > >     > > >     Add bcd2bin() as linuxkpi_bcd2bin().  Libkern does provide a > > > bcd2bin() > > > > > > [...] > > > + * We could use libkern, but we need the argument truncating. > > > + * > > > > > > What does that mean, "we need the argument truncating"? > > This one takes an uint8_t as argument. > > If my memory serves me correctly the Linux driver code through > macros passes in larger values 0xabcdxx which are truncated by > the argument type. > > We take an int and then have a KASSERT() which doesn't work so well > for these larger values. > > /bz > > -- > Bjoern A. Zeeb                                                     > r15:7 I had forgotten that we added a KASSERT a few years ago. But we don't expect linux to be relying on getting bad answers in response to bad inputs, do we? I wonder why we can't just change the prototype of our inline function from int to uint8_t and remove the >= 0 part from the assert? -- Ian From nobody Mon Oct 25 21:29:21 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 08607182C0EC; Mon, 25 Oct 2021 21:29:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdSl56rJdz3kCf; Mon, 25 Oct 2021 21:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CB6BE104C1; Mon, 25 Oct 2021 21:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19PLTLMP011818; Mon, 25 Oct 2021 21:29:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19PLTLt5011817; Mon, 25 Oct 2021 21:29:21 GMT (envelope-from git) Date: Mon, 25 Oct 2021 21:29:21 GMT Message-Id: <202110252129.19PLTLt5011817@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 179219ea046f - main - strip/objcopy: handle empty file as unknown List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 179219ea046f46927d6478d43431e8b541703539 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=179219ea046f46927d6478d43431e8b541703539 commit 179219ea046f46927d6478d43431e8b541703539 Author: Ed Maste AuthorDate: 2021-10-25 21:25:26 +0000 Commit: Ed Maste CommitDate: 2021-10-25 21:28:41 +0000 strip/objcopy: handle empty file as unknown Previously strip reported a somewhat cryptic error for empty files: strip: elf_begin() failed: Invalid argument Add a special case to treat empty files as with an unknown file format. This is consistent with llvm-strip. GNU strip produces no output which does not seem like useful behaviour (but it does exit with status 1). Reported by: andrew Reviewed by: markj MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32648 --- contrib/elftoolchain/elfcopy/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/elftoolchain/elfcopy/main.c b/contrib/elftoolchain/elfcopy/main.c index 964d3358de60..264e702ef5af 100644 --- a/contrib/elftoolchain/elfcopy/main.c +++ b/contrib/elftoolchain/elfcopy/main.c @@ -738,6 +738,8 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst) if ((ecp->ein = elf_begin(ifd, ELF_C_READ, NULL)) == NULL) { cleanup_tempfile(tempfile); + if (fstat(ifd, &sb) == 0 && sb.st_size == 0) + errx(EXIT_FAILURE, "file format not recognized"); errx(EXIT_FAILURE, "elf_begin() failed: %s", elf_errmsg(-1)); } From nobody Mon Oct 25 21:33:14 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8EFF2182EF76; Mon, 25 Oct 2021 21:33:21 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdSqj3NlQz3mt3; Mon, 25 Oct 2021 21:33:21 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mx1.sbone.de (cross.sbone.de [195.201.62.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.sbone.de", Issuer "SBone.DE" (not verified)) (Authenticated sender: bz/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 27D21917C; Mon, 25 Oct 2021 21:33:21 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id EF5408D4A179; Mon, 25 Oct 2021 21:33:18 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 3D538E70848; Mon, 25 Oct 2021 21:33:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id IRb4mHUZiMb1; Mon, 25 Oct 2021 21:33:16 +0000 (UTC) Received: from nv.sbone.de (nv.sbone.de [IPv6:fde9:577b:c1a9:31::2013:138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id D569DE70847; Mon, 25 Oct 2021 21:33:15 +0000 (UTC) Date: Mon, 25 Oct 2021 21:33:14 +0000 (UTC) From: "Bjoern A. Zeeb" To: Ian Lepore cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 548ada00e54a - main - LinuxKPI: add bcd.h In-Reply-To: <845d99d8f7c189418b36a832017518c493af729b.camel@freebsd.org> Message-ID: References: <202110252023.19PKNSRO031788@gitrepo.freebsd.org> <832a2403091df094d6f7ab471aef0694adebb939.camel@freebsd.org> <845d99d8f7c189418b36a832017518c493af729b.camel@freebsd.org> X-OpenPGP-Key-Id: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-1547604112-1635197595=:68830" X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-1547604112-1635197595=:68830 Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Mon, 25 Oct 2021, Ian Lepore wrote: > On Mon, 2021-10-25 at 21:17 +0000, Bjoern A. Zeeb wrote: >> On Mon, 25 Oct 2021, Ian Lepore wrote: >> >>> On Mon, 2021-10-25 at 20:23 +0000, Bjoern A. Zeeb wrote: >>>> The branch main has been updated by bz: >>>> >>>> URL: >>>> https://cgit.FreeBSD.org/src/commit/?id=548ada00e54a9e7745d041b1ec7f68f3bd493365 >>>> >>>> commit 548ada00e54a9e7745d041b1ec7f68f3bd493365 >>>> Author:     Bjoern A. Zeeb >>>> AuthorDate: 2021-10-25 18:14:08 +0000 >>>> Commit:     Bjoern A. Zeeb >>>> CommitDate: 2021-10-25 20:20:53 +0000 >>>> >>>>     LinuxKPI: add bcd.h >>>>     >>>>     Add bcd2bin() as linuxkpi_bcd2bin().  Libkern does provide a >>>> bcd2bin() >>>> >>>> [...] >>>> + * We could use libkern, but we need the argument truncating. >>>> + * >>> >>> >>> What does that mean, "we need the argument truncating"? >> >> This one takes an uint8_t as argument. >> >> If my memory serves me correctly the Linux driver code through >> macros passes in larger values 0xabcdxx which are truncated by >> the argument type. >> >> We take an int and then have a KASSERT() which doesn't work so well >> for these larger values. >> >> /bz >> >> -- >> Bjoern A. Zeeb                                                     >> r15:7 > > I had forgotten that we added a KASSERT a few years ago. But we don't > expect linux to be relying on getting bad answers in response to bad > inputs, do we? > > I wonder why we can't just change the prototype of our inline function > from int to uint8_t and remove the >= 0 part from the assert? I wonder why the int arguments were there the first time now that you made me look again. Be my guest to change it and I'll happily reduce this file to the #include line. /bz -- Bjoern A. Zeeb r15:7 --0-1547604112-1635197595=:68830-- From nobody Tue Oct 26 02:06:33 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5C799181B905; Tue, 26 Oct 2021 02:06:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdZtx21dpz3GZF; Tue, 26 Oct 2021 02:06:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 26A6314226; Tue, 26 Oct 2021 02:06:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19Q26XNG000728; Tue, 26 Oct 2021 02:06:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19Q26XZm000727; Tue, 26 Oct 2021 02:06:33 GMT (envelope-from git) Date: Tue, 26 Oct 2021 02:06:33 GMT Message-Id: <202110260206.19Q26XZm000727@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: dce5f3abed71 - main - [LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl] List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dce5f3abed7181cc533ca5ed3de44517775e78dd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=dce5f3abed7181cc533ca5ed3de44517775e78dd commit dce5f3abed7181cc533ca5ed3de44517775e78dd Author: Steve Kargl AuthorDate: 2021-10-25 13:13:52 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-25 23:50:20 +0000 [LIBM] implementations of sinpi[fl], cospi[fl], and tanpi[fl] Both IEEE-754 2008 and ISO/IEC TS 18661-4 define the half-cycle trignometric functions cospi, sinpi, and tanpi. The attached patch implements cospi[fl], sinpi[fl], and tanpi[fl]. Limited testing on the cospi and sinpi reveal a max ULP less than 0.89; while tanpi is more problematic with a max ULP less than 2.01 in the interval [0,0.5]. The algorithms used in these functions are documented in {ks}_cospi.c, {ks}_sinpi.c, and s_tanpi.c. Note. I no longer have access to a system with ld128 and adequate support to compile and test the ld128 implementations of these functions. Given the almost complete lack of input from others on improvements to libm, I doubt that anyone cares. If someone does care, the ld128 files contain a number of FIXME comments, and in particular, while the polynomial coefficients are given I did not update the polynomial algorithms to properly use the coefficients. PR: 218514 MFC after: 2 weeks --- lib/msun/Makefile | 14 +++- lib/msun/Symbol.map | 13 ++++ lib/msun/ld128/k_cospil.h | 42 +++++++++++ lib/msun/ld128/k_sinpil.h | 42 +++++++++++ lib/msun/ld128/s_cospil.c | 109 ++++++++++++++++++++++++++++ lib/msun/ld128/s_sinpil.c | 118 +++++++++++++++++++++++++++++++ lib/msun/ld128/s_tanpil.c | 120 +++++++++++++++++++++++++++++++ lib/msun/ld80/k_cospil.h | 42 +++++++++++ lib/msun/ld80/k_sinpil.h | 42 +++++++++++ lib/msun/ld80/s_cospil.c | 129 +++++++++++++++++++++++++++++++++ lib/msun/ld80/s_sinpil.c | 140 ++++++++++++++++++++++++++++++++++++ lib/msun/ld80/s_tanpil.c | 139 ++++++++++++++++++++++++++++++++++++ lib/msun/man/cospi.3 | 111 +++++++++++++++++++++++++++++ lib/msun/man/sinpi.3 | 102 +++++++++++++++++++++++++++ lib/msun/man/tanpi.3 | 106 ++++++++++++++++++++++++++++ lib/msun/src/k_cospi.h | 44 ++++++++++++ lib/msun/src/k_sinpi.h | 43 +++++++++++ lib/msun/src/math.h | 9 +++ lib/msun/src/s_cospi.c | 151 +++++++++++++++++++++++++++++++++++++++ lib/msun/src/s_cospif.c | 109 ++++++++++++++++++++++++++++ lib/msun/src/s_sinpi.c | 168 +++++++++++++++++++++++++++++++++++++++++++ lib/msun/src/s_sinpif.c | 122 ++++++++++++++++++++++++++++++++ lib/msun/src/s_tanpi.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++ lib/msun/src/s_tanpif.c | 114 ++++++++++++++++++++++++++++++ 24 files changed, 2203 insertions(+), 2 deletions(-) diff --git a/lib/msun/Makefile b/lib/msun/Makefile index 7107aad56aa7..dcee5572f949 100644 --- a/lib/msun/Makefile +++ b/lib/msun/Makefile @@ -126,6 +126,12 @@ COMMON_SRCS+= catrigl.c \ # See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=130067 .if ${COMPILER_TYPE} == "gcc" CFLAGS.e_powl.c+= -Wno-error=overflow + +# IEEE-754 2008 and ISO/IEC TS 18661-4 half-cycle trignometric functions +COMMON_SRCS+= s_cospi.c s_cospif.c s_cospil.c \ + s_sinpi.c s_sinpif.c s_sinpil.c \ + s_tanpi.c s_tanpif.c s_tanpil.c + .endif .endif @@ -154,7 +160,8 @@ INCS+= fenv.h math.h MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \ ceil.3 cacos.3 ccos.3 ccosh.3 cexp.3 \ - cimag.3 clog.3 copysign.3 cos.3 cosh.3 cpow.3 csqrt.3 erf.3 \ + cimag.3 clog.3 copysign.3 cos.3 cosh.3 cospi.3 \ + cpow.3 csqrt.3 erf.3 \ exp.3 fabs.3 fdim.3 \ feclearexcept.3 feenableexcept.3 fegetenv.3 \ fegetround.3 fenv.3 floor.3 \ @@ -162,7 +169,7 @@ MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \ lgamma.3 log.3 lrint.3 lround.3 math.3 nan.3 \ nextafter.3 remainder.3 rint.3 \ round.3 scalbn.3 signbit.3 sin.3 sincos.3 \ - sinh.3 sqrt.3 tan.3 tanh.3 trunc.3 \ + sinh.3 sinpi.3 sqrt.3 tan.3 tanh.3 tanpi.3 trunc.3 \ complex.3 MLINKS+=acos.3 acosf.3 acos.3 acosl.3 @@ -192,6 +199,7 @@ MLINKS+=clog.3 clogf.3 clog.3 clogl.3 MLINKS+=copysign.3 copysignf.3 copysign.3 copysignl.3 MLINKS+=cos.3 cosf.3 cos.3 cosl.3 MLINKS+=cosh.3 coshf.3 cosh.3 coshl.3 +MLINKS+=cospi.3 cospif.3 cospi.3 cospil.3 MLINKS+=cpow.3 cpowf.3 cpow.3 cpowl.3 MLINKS+=csqrt.3 csqrtf.3 csqrt.3 csqrtl.3 MLINKS+=erf.3 erfc.3 erf.3 erff.3 erf.3 erfcf.3 erf.3 erfl.3 erf.3 erfcl.3 @@ -244,10 +252,12 @@ MLINKS+=scalbn.3 scalbnf.3 scalbn.3 scalbnl.3 MLINKS+=sin.3 sinf.3 sin.3 sinl.3 MLINKS+=sincos.3 sincosf.3 sin.3 sincosl.3 MLINKS+=sinh.3 sinhf.3 sinh.3 sinhl.3 +MLINKS+=sinpi.3 sinpif.3 sinpi.3 sinpil.3 MLINKS+=sqrt.3 cbrt.3 sqrt.3 cbrtf.3 sqrt.3 cbrtl.3 sqrt.3 sqrtf.3 \ sqrt.3 sqrtl.3 MLINKS+=tan.3 tanf.3 tan.3 tanl.3 MLINKS+=tanh.3 tanhf.3 tanh.3 tanhl.3 +MLINKS+=tanpi.3 tanpif.3 tanpi.3 tanpil.3 MLINKS+=trunc.3 truncf.3 trunc.3 truncl.3 .include diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map index 51deded732f0..7229e7ef31fd 100644 --- a/lib/msun/Symbol.map +++ b/lib/msun/Symbol.map @@ -304,3 +304,16 @@ FBSD_1.5 { sincosf; sincosl; }; + +/* First added in 14.0-CURRENT */ +FBSD_1.7 { + cospi; + cospif; + cospil; + sinpi; + sinpif; + sinpil; + tanpi; + tanpif; + tanpil; +}; diff --git a/lib/msun/ld128/k_cospil.h b/lib/msun/ld128/k_cospil.h new file mode 100644 index 000000000000..592f19229532 --- /dev/null +++ b/lib/msun/ld128/k_cospil.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/k_cospi.c for implementation details. + */ + +static inline long double +__kernel_cospil(long double x) +{ + long double hi, lo; + + hi = (double)x; + lo = x - hi; + lo = lo * (pi_lo + pi_hi) + hi * pi_lo; + hi *= pi_hi; + _2sumF(hi, lo); + return (__kernel_cosl(hi, lo)); +} diff --git a/lib/msun/ld128/k_sinpil.h b/lib/msun/ld128/k_sinpil.h new file mode 100644 index 000000000000..fa4e7d6336d7 --- /dev/null +++ b/lib/msun/ld128/k_sinpil.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/k_sinpi.c for implementation details. + */ + +static inline long double +__kernel_sinpil(long double x) +{ + long double hi, lo; + + hi = (double)x; + lo = x - hi; + lo = lo * (pi_lo + pi_hi) + hi * pi_lo; + hi *= pi_hi; + _2sumF(hi, lo); + return (__kernel_sinl(hi, lo, 1)); +} diff --git a/lib/msun/ld128/s_cospil.c b/lib/msun/ld128/s_cospil.c new file mode 100644 index 000000000000..b4bc50bb4d89 --- /dev/null +++ b/lib/msun/ld128/s_cospil.c @@ -0,0 +1,109 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/s_cospi.c for implementation details. + * + * FIXME: This has not been compiled nor has it been tested for accuracy. + * FIXME: This should use bit twiddling. + */ + +#include "math.h" +#include "math_private.h" + +/* + * pi_hi contains the leading 56 bits of a 169 bit approximation for pi. + */ +static const long double +pi_hi = 3.14159265358979322702026593105983920e+00L, +pi_lo = 1.14423774522196636802434264184180742e-17L; + +#include "k_cospil.h" +#include "k_sinpil.h" + +volatile static const double vzero = 0; + +long double +cospil(long double x) +{ + long double ax, c, xf; + uint32_t ix; + + ax = fabsl(x); + + if (ax < 1) { + if (ax < 0.25) { + if (ax < 0x1p-60) { + if ((int)x == 0) + return (1); + } + return (__kernel_cospil(ax)); + } + + if (ax < 0.5) + c = __kernel_sinpil(0.5 - ax); + else if (ax < 0.75) { + if (ax == 0.5) + return (0); + c = -__kernel_sinpil(ax - 0.5); + } else + c = -__kernel_cospil(1 - ax); + return (c); + } + + if (ax < 0x1p112) { + xf = floorl(ax); + ax -= xf; + if (x < 0.5) { + if (x < 0.25) + c = ax == 0 ? 1 : __kernel_cospil(ax); + else + c = __kernel_sinpil(0.5 - ax); + } else { + if (x < 0.75) { + if (ax == 0.5) + return (0); + c = -__kernel_sinpil(ax - 0.5); + } else + c = -__kernel_cospil(1 - ax); + } + + if (xf > 0x1p50) + xf -= 0x1p50; + if (xf > 0x1p30) + xf -= 0x1p30; + ix = (uint32_t)xf; + return (ix & 1 ? -c : c); + } + + if (isinf(x) || isnan(x)) + return (vzero / vzero); + + /* + * |x| >= 0x1p112 is always an even integer, so return 1. + */ + return (1); +} diff --git a/lib/msun/ld128/s_sinpil.c b/lib/msun/ld128/s_sinpil.c new file mode 100644 index 000000000000..39eed9b007bc --- /dev/null +++ b/lib/msun/ld128/s_sinpil.c @@ -0,0 +1,118 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/s_sinpi.c for implementation details. + * + * FIXME: This has not been compiled nor has it been tested for accuracy. + * FIXME: This should use bit twiddling. + */ + +#include "math.h" +#include "math_private.h" + +/* + * pi_hi contains the leading 56 bits of a 169 bit approximation for pi. + */ +static const long double +pi_hi = 3.14159265358979322702026593105983920e+00L, +pi_lo = 1.14423774522196636802434264184180742e-17L; + +#include "k_cospil.h" +#include "k_sinpil.h" + +volatile static const double vzero = 0; + +long double +sinpil(long double x) +{ + long double ax, hi, lo, s, xf, xhi, xlo; + uint32_t ix; + + ax = fabsl(x); + + if (ax < 1) { + if (ax < 0.25) { + if (ax < 0x1p-60) { + if (x == 0) + return (x); + hi = (double)x; + hi *= 0x1p113L; + lo = x * 0x1p113L - hi; + s = (pi_lo + pi_hi) * lo + pi_lo * lo + + pi_hi * hi; + return (s * 0x1p-113L); + } + + s = __kernel_sinpil(ax); + return (copysignl(s, x)); + } + + if (ax < 0.5) + s = __kernel_cospil(0.5 - ax); + else if (ax < 0.75) + s = __kernel_cospil(ax - 0.5); + else + s = __kernel_sinpil(1 - ax); + return (copysignl(s, x)); + } + + if (ax < 0x1p112) { + xf = floorl(ax); + ax -= xf; + if (ax == 0) { + s = 0; + } else { + if (ax < 0.5) { + if (ax <= 0.25) + s = __kernel_sinpil(ax); + else + s = __kernel_cospil(0.5 - ax); + } else { + if (ax < 0.75) + s = __kernel_cospil(ax - 0.5); + else + s = __kernel_sinpil(1 - ax); + } + + if (xf > 0x1p50) + xf -= 0x1p50; + if (xf > 0x1p30) + xf -= 0x1p30; + ix = (uint32_t)xf; + if (ix & 1) s = -s; + } + return (copysignl(s, x)); + } + + if (isinf(x) || isnan(x)) + return (vzero / vzero); + + /* + * |x| >= 0x1p112 is always an integer, so return +-0. + */ + return (copysignl(0, x)); +} diff --git a/lib/msun/ld128/s_tanpil.c b/lib/msun/ld128/s_tanpil.c new file mode 100644 index 000000000000..33a61cf3115d --- /dev/null +++ b/lib/msun/ld128/s_tanpil.c @@ -0,0 +1,120 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/s_tanpi.c for implementation details. + * + * FIXME: This has not been compiled nor has it been tested for accuracy. + * FIXME: This should use bit twiddling. + */ + +#include "math.h" +#include "math_private.h" + +/* + * pi_hi contains the leading 56 bits of a 169 bit approximation for pi. + */ +static const long double +pi_hi = 3.14159265358979322702026593105983920e+00L, +pi_lo = 1.14423774522196636802434264184180742e-17L; + +static inline long double +__kernel_tanpi(long double x) +{ + long double hi, lo, t; + + if (x < 0.25) { + hi = (double)x; + lo = x - hi; + lo = lo * (pi_lo + pi_hi) + hi * pi_lo; + hi *= pi_hi; + _2sumF(hi, lo); + t = __kernel_tanl(hi, lo, -1); + } else if (x > 0.25) { + x = 0.5 - x; + hi = (double)x; + lo = x - hi; + lo = lo * (pi_lo + pi_hi) + hi * pi_lo; + hi *= pi_hi; + _2sumF(hi, lo); + t = - __kernel_tanl(hi, lo, 1); + } else + t = 1; + + return (t); +} + +volatile static const double vzero = 0; + +long double +tanpil(long double x) +{ + long double ax, hi, lo, xf; + uint32_t ix; + + ax = fabsl(ax); + + if (ax < 1) { + if (ax < 0.5) { + if (ax < 0x1p-60) { + if (x == 0) + return (x); + hi = (double)x; + hi *= 0x1p113L + lo = x * 0x1p113L - hi; + t = (pi_lo + pi_hi) * lo + pi_lo * lo + + pi_hi * hi; + return (t * 0x1p-113L); + } + t = __kernel_tanpil(ax); + } else if (ax == 0.5) + return ((ax - ax) / (ax - ax)); + else + t = -__kernel_tanpil(1 - ax); + return (copysignl(t, x)); + } + + if (ix < 0x1p112) { + xf = floorl(ax); + ax -= xf; + if (ax < 0.5) + t = ax == 0 ? 0 : __kernel_tanpil(ax); + else if (ax == 0.5) + return ((ax - ax) / (ax - ax)); + else + t = -__kernel_tanpil(1 - ax); + return (copysignl(t, x)); + } + + /* x = +-inf or nan. */ + if (isinf(x) || isnan(x)) + return (vzero / vzero); + + /* + * |x| >= 0x1p53 is always an integer, so return +-0. + */ + return (copysignl(0, x)); +} diff --git a/lib/msun/ld80/k_cospil.h b/lib/msun/ld80/k_cospil.h new file mode 100644 index 000000000000..6e13ef02aea2 --- /dev/null +++ b/lib/msun/ld80/k_cospil.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/k_cospi.c for implementation details. + */ + +static inline long double +__kernel_cospil(long double x) +{ + long double hi, lo; + + hi = (float)x; + lo = x - hi; + lo = lo * (pi_lo + pi_hi) + hi * pi_lo; + hi *= pi_hi; + _2sumF(hi, lo); + return (__kernel_cosl(hi, lo)); +} diff --git a/lib/msun/ld80/k_sinpil.h b/lib/msun/ld80/k_sinpil.h new file mode 100644 index 000000000000..00241b932e9e --- /dev/null +++ b/lib/msun/ld80/k_sinpil.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/k_sinpi.c for implementation details. + */ + +static inline long double +__kernel_sinpil(long double x) +{ + long double hi, lo; + + hi = (float)x; + lo = x - hi; + lo = lo * (pi_lo + pi_hi) + hi * pi_lo; + hi *= pi_hi; + _2sumF(hi, lo); + return (__kernel_sinl(hi, lo, 1)); +} diff --git a/lib/msun/ld80/s_cospil.c b/lib/msun/ld80/s_cospil.c new file mode 100644 index 000000000000..199479e9eaf9 --- /dev/null +++ b/lib/msun/ld80/s_cospil.c @@ -0,0 +1,129 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/s_cospi.c for implementation details. + */ + +#ifdef __i386__ +#include +#endif +#include + +#include "fpmath.h" +#include "math.h" +#include "math_private.h" + +static const double +pi_hi = 3.1415926814079285e+00, /* 0x400921fb 0x58000000 */ +pi_lo =-2.7818135228334233e-08; /* 0xbe5dde97 0x3dcb3b3a */ + +#include "k_cospil.h" +#include "k_sinpil.h" + +volatile static const double vzero = 0; + +long double +cospil(long double x) +{ + long double ax, c; + uint64_t lx, m; + uint32_t j0; + uint16_t hx, ix; + + EXTRACT_LDBL80_WORDS(hx, lx, x); + ix = hx & 0x7fff; + INSERT_LDBL80_WORDS(ax, ix, lx); + + ENTERI(); + + if (ix < 0x3fff) { /* |x| < 1 */ + if (ix < 0x3ffd) { /* |x| < 0.25 */ + if (ix < 0x3fdd) { /* |x| < 0x1p-34 */ + if ((int)x == 0) + RETURNI(1); + } + RETURNI(__kernel_cospil(ax)); + } + + if (ix < 0x3ffe) /* |x| < 0.5 */ + c = __kernel_sinpil(0.5 - ax); + else if (lx < 0xc000000000000000ull) { /* |x| < 0.75 */ + if (ax == 0.5) + RETURNI(0); + c = -__kernel_sinpil(ax - 0.5); + } else + c = -__kernel_cospil(1 - ax); + RETURNI(c); + } + + if (ix < 0x403e) { /* 1 <= |x| < 0x1p63 */ + /* Determine integer part of ax. */ + j0 = ix - 0x3fff + 1; + if (j0 < 32) { + lx = (lx >> 32) << 32; + lx &= ~(((lx << 32)-1) >> j0); + } else { + m = (uint64_t)-1 >> (j0 + 1); + if (lx & m) lx &= ~m; + } + INSERT_LDBL80_WORDS(x, ix, lx); + + ax -= x; + EXTRACT_LDBL80_WORDS(ix, lx, ax); + + if (ix < 0x3ffe) { /* |x| < 0.5 */ + if (ix < 0x3ffd) /* |x| < 0.25 */ + c = ix == 0 ? 1 : __kernel_cospil(ax); + else + c = __kernel_sinpil(0.5 - ax); + + } else { + if (lx < 0xc000000000000000ull) { /* |x| < 0.75 */ + if (ax == 0.5) + RETURNI(0); + c = -__kernel_sinpil(ax - 0.5); + } else + c = -__kernel_cospil(1 - ax); + } + + if (j0 > 40) + x -= 0x1p40; + if (j0 > 30) + x -= 0x1p30; + j0 = (uint32_t)x; + + RETURNI(j0 & 1 ? -c : c); + } + + if (ix >= 0x7fff) + RETURNI(vzero / vzero); + + /* + * |x| >= 0x1p63 is always an even integer, so return 1. + */ + RETURNI(1); +} diff --git a/lib/msun/ld80/s_sinpil.c b/lib/msun/ld80/s_sinpil.c new file mode 100644 index 000000000000..4cefa92352e1 --- /dev/null +++ b/lib/msun/ld80/s_sinpil.c @@ -0,0 +1,140 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * See ../src/s_sinpi.c for implementation details. + */ + +#ifdef __i386__ +#include +#endif +#include + +#include "fpmath.h" +#include "math.h" +#include "math_private.h" + +static const union IEEEl2bits +pi_hi_u = LD80C(0xc90fdaa200000000, 1, 3.14159265346825122833e+00L), +pi_lo_u = LD80C(0x85a308d313198a2e, -33, 1.21542010130123852029e-10L); +#define pi_hi (pi_hi_u.e) +#define pi_lo (pi_lo_u.e) + +#include "k_cospil.h" +#include "k_sinpil.h" + +volatile static const double vzero = 0; + +long double +sinpil(long double x) +{ + long double ax, hi, lo, s; + uint64_t lx, m; + uint32_t j0; + uint16_t hx, ix; + + EXTRACT_LDBL80_WORDS(hx, lx, x); + ix = hx & 0x7fff; + INSERT_LDBL80_WORDS(ax, ix, lx); + + ENTERI(); + + if (ix < 0x3fff) { /* |x| < 1 */ + if (ix < 0x3ffd) { /* |x| < 0.25 */ + if (ix < 0x3fdd) { /* |x| < 0x1p-34 */ + if (x == 0) + RETURNI(x); + INSERT_LDBL80_WORDS(hi, hx, + lx & 0xffffffff00000000ull); + hi *= 0x1p63L; + lo = x * 0x1p63L - hi; + s = (pi_lo + pi_hi) * lo + pi_lo * hi + + pi_hi * hi; + RETURNI(s * 0x1p-63L); + } + s = __kernel_sinpil(ax); + RETURNI((hx & 0x8000) ? -s : s); + } + + if (ix < 0x3ffe) /* |x| < 0.5 */ + s = __kernel_cospil(0.5 - ax); + else if (lx < 0xc000000000000000ull) /* |x| < 0.75 */ + s = __kernel_cospil(ax - 0.5); + else + s = __kernel_sinpil(1 - ax); + RETURNI((hx & 0x8000) ? -s : s); + } + + if (ix < 0x403e) { /* 1 <= |x| < 0x1p63 */ + /* Determine integer part of ax. */ + j0 = ix - 0x3fff + 1; + if (j0 < 32) { + lx = (lx >> 32) << 32; + lx &= ~(((lx << 32)-1) >> j0); + } else { + m = (uint64_t)-1 >> (j0 + 1); + if (lx & m) lx &= ~m; + } + INSERT_LDBL80_WORDS(x, ix, lx); + + ax -= x; + EXTRACT_LDBL80_WORDS(ix, lx, ax); + + if (ix == 0) { + s = 0; + } else { + if (ix < 0x3ffe) { /* |x| < 0.5 */ + if (ix < 0x3ffd) /* |x| < 0.25 */ + s = __kernel_sinpil(ax); + else + s = __kernel_cospil(0.5 - ax); + } else { + /* |x| < 0.75 */ + if (lx < 0xc000000000000000ull) + s = __kernel_cospil(ax - 0.5); + else + s = __kernel_sinpil(1 - ax); + } + + if (j0 > 40) + x -= 0x1p40; + if (j0 > 30) + x -= 0x1p30; + j0 = (uint32_t)x; + if (j0 & 1) s = -s; + } + RETURNI((hx & 0x8000) ? -s : s); + } + + /* x = +-inf or nan. */ + if (ix >= 0x7fff) + RETURNI(vzero / vzero); + + /* + * |x| >= 0x1p63 is always an integer, so return +-0. + */ + RETURNI(copysignl(0, x)); +} diff --git a/lib/msun/ld80/s_tanpil.c b/lib/msun/ld80/s_tanpil.c new file mode 100644 index 000000000000..02451e562025 --- /dev/null +++ b/lib/msun/ld80/s_tanpil.c @@ -0,0 +1,139 @@ +/*- + * Copyright (c) 2017 Steven G. Kargl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: *** 1464 LINES SKIPPED *** From nobody Tue Oct 26 02:14:40 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3CAB318202E4; Tue, 26 Oct 2021 02:14:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hdb4J6FCTz3KcH; Tue, 26 Oct 2021 02:14:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6C3C14512; Tue, 26 Oct 2021 02:14:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19Q2Eeo6013631; Tue, 26 Oct 2021 02:14:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19Q2EeYR013630; Tue, 26 Oct 2021 02:14:40 GMT (envelope-from git) Date: Tue, 26 Oct 2021 02:14:40 GMT Message-Id: <202110260214.19Q2EeYR013630@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 23024f004a4c - main - nfscl: Add a missing delegation lock release List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 23024f004a4c5659bfcb0b08fac2211ae925ee58 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=23024f004a4c5659bfcb0b08fac2211ae925ee58 commit 23024f004a4c5659bfcb0b08fac2211ae925ee58 Author: Rick Macklem AuthorDate: 2021-10-26 02:09:14 +0000 Commit: Rick Macklem CommitDate: 2021-10-26 02:11:45 +0000 nfscl: Add a missing delegation lock release There was a case in nfscl_doiods() where the function would return without releasing the delegation shared lock, if it was aquired by the call to nfscl_getstateid(). This patch adds that release. I have never observed a failure due to this missing release, so I do not know if it ever happens in practice. However, since the pNFS client is not yet heavily used, it might be the case. Found by code inspection during a recent NFSv4 IETF working group testing event. MFC after: 2 week --- sys/fs/nfsclient/nfs_clrpcops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 35ce9be88405..dec70dc2ac06 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -6045,6 +6045,8 @@ nfscl_doiods(vnode_t vp, struct uio *uiop, int *iomode, int *must_commit, if (layp == NULL || rflp == NULL) { if (recalled != 0) { NFSFREECRED(newcred); + if (lckp != NULL) + nfscl_lockderef(lckp); nfscl_relref(nmp); return (EIO); } From nobody Tue Oct 26 09:59:39 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7976218360BE; Tue, 26 Oct 2021 09:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdnNq2v7Mz3MMx; Tue, 26 Oct 2021 09:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 452451AAAE; Tue, 26 Oct 2021 09:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19Q9xd9g026017; Tue, 26 Oct 2021 09:59:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19Q9xd0Y026016; Tue, 26 Oct 2021 09:59:39 GMT (envelope-from git) Date: Tue, 26 Oct 2021 09:59:39 GMT Message-Id: <202110260959.19Q9xd0Y026016@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: cbc3ecb7ef08 - main - stress2: Added two syzkaller reproducers List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cbc3ecb7ef08a2978d42b384a49d3456b0ba0a32 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=cbc3ecb7ef08a2978d42b384a49d3456b0ba0a32 commit cbc3ecb7ef08a2978d42b384a49d3456b0ba0a32 Author: Peter Holm AuthorDate: 2021-10-26 09:59:04 +0000 Commit: Peter Holm CommitDate: 2021-10-26 09:59:04 +0000 stress2: Added two syzkaller reproducers --- tools/test/stress2/misc/all.exclude | 2 + tools/test/stress2/misc/syzkaller46.sh | 118 ++++++++++ tools/test/stress2/misc/syzkaller47.sh | 404 +++++++++++++++++++++++++++++++++ 3 files changed, 524 insertions(+) diff --git a/tools/test/stress2/misc/all.exclude b/tools/test/stress2/misc/all.exclude index 7ee33f258f87..dfd936abde70 100644 --- a/tools/test/stress2/misc/all.exclude +++ b/tools/test/stress2/misc/all.exclude @@ -70,6 +70,8 @@ syzkaller40.sh WiP 20210607 syzkaller41.sh WiP 20210607 syzkaller42.sh WiP 20210613 syzkaller43.sh WiP 20210906 +syzkaller46.sh WiP 20211026 +syzkaller47.sh WiP 20211026 truss3.sh WiP 20200915 unionfs.sh insmntque: non-locked vp: xx is not exclusive locked... 20130909 unionfs2.sh insmntque: mp-safe fs and non-locked vp is not ... 20111219 diff --git a/tools/test/stress2/misc/syzkaller46.sh b/tools/test/stress2/misc/syzkaller46.sh new file mode 100755 index 000000000000..db1c9c27b221 --- /dev/null +++ b/tools/test/stress2/misc/syzkaller46.sh @@ -0,0 +1,118 @@ +#!/bin/sh + +# Fatal trap 12: page fault while in kernel mode +# cpuid = 4; apic id = 04 +# fault virtual address = 0x28 +# fault code = supervisor read data, page not present +# instruction pointer = 0x20:0xffffffff81549dea +# stack pointer = 0x28:0xfffffe01d8689480 +# frame pointer = 0x28:0xfffffe01d8689490 +# code segment = base 0x0, limit 0xfffff, type 0x1b +# = DPL 0, pres 1, long 1, def32 0, gran 1 +# processor eflags = interrupt enabled, resume, IOPL = 0 +# current process = 3050 (syzkaller46) +# trap number = 12 +# panic: page fault +# cpuid = 4 +# time = 1635158869 +# KDB: stack backtrace: +# db_trace_self_wrapper() at db_trace_self_wrapper+0xa5/frame 0xfffffe01d8688cb0 +# kdb_backtrace() at kdb_backtrace+0xc9/frame 0xfffffe01d8688e10 +# vpanic() at vpanic+0x248/frame 0xfffffe01d8688ef0 +# panic() at panic+0xb5/frame 0xfffffe01d8688fb0 +# trap_fatal() at trap_fatal+0x52e/frame 0xfffffe01d86890b0 +# trap_pfault() at trap_pfault+0x132/frame 0xfffffe01d86891d0 +# trap() at trap+0x53f/frame 0xfffffe01d86893b0 +# calltrap() at calltrap+0x8/frame 0xfffffe01d86893b0 +# --- trap 0xc, rip = 0xffffffff81549dea, rsp = 0xfffffe01d8689480, rbp = 0xfffffe01d8689490 --- +# filt_bpfwrite() filt_bpfwrite+0x4a/frame 0xfffffe01d8689490 +# kqueue_register() at kqueue_register+0xea3/frame 0xfffffe01d86895d0 +# kqueue_kevent() at kqueue_kevent+0x26a/frame 0xfffffe01d86899c0 +# kern_kevent_fp() at kern_kevent_fp+0xd2/frame 0xfffffe01d8689a10 +# kern_kevent() at kern_kevent+0x138/frame 0xfffffe01d8689b10 +# kern_kevent_generic() at kern_kevent_gene6/frame 0xfffffesys_kevent() at sys_kevent+0x1e1/frame 0xfffffe01d8689d30 +# amd64_syscall() at amd64_syscall+0x31e/frame 0xfffffe01d8689f30 +# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe01d8689f30 +# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x8003adafa, rsp = 0x7fffffffe648, rbp = 0x7fffffffe670 --- +# KDB: enter: panic +# [ thread pid 3050 tid 100263 ] +# Stopped at kdb_enter+0x37: movq $0,0x2638c4e(%rip) +# db> x/s version +# version: FreeBSD 14.0-CURRENT #0 main-n250242-eab5358b9080-dirty: Mon Oct 25 11:32:45 CEST 2021 +# pho@mercat1.netperf.freebsd.org +# db> + + +[ `uname -p` != "amd64" ] && exit 0 +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg +cat > /tmp/syzkaller46.c < +#include +#include +#include +#include +#include +#include +#include +#include +#include + +uint64_t r[1] = {0xffffffffffffffff}; + +int main(void) +{ + syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul); + intptr_t res = 0; + memcpy((void*)0x20000040, "/dev/bpf\000", 9); + syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000040ul, 0ul, 0ul); + res = syscall(SYS_kqueue); + if (res != -1) + r[0] = res; + *(uint64_t*)0x20000480 = 0x284; + *(uint16_t*)0x20000488 = 0xfff8; + *(uint16_t*)0x2000048a = 0x10; + *(uint32_t*)0x2000048c = 1; + *(uint64_t*)0x20000490 = 0x401; + *(uint64_t*)0x20000498 = 5; + *(uint64_t*)0x200004a0 = 5; + *(uint64_t*)0x200004a8 = 0x24000000; + *(uint64_t*)0x200004b0 = 0x100000000; + *(uint64_t*)0x200004b8 = 0x3f; + *(uint64_t*)0x200004c0 = 3; + *(uint16_t*)0x200004c8 = 0xfffe; + *(uint16_t*)0x200004ca = 1; + *(uint32_t*)0x200004cc = 1; + *(uint64_t*)0x200004d0 = 1; + *(uint64_t*)0x200004d8 = 3; + *(uint64_t*)0x200004e0 = 9; + *(uint64_t*)0x200004e8 = 0x3ff; + *(uint64_t*)0x200004f0 = 0x100000001; + *(uint64_t*)0x200004f8 = 3; + *(uint64_t*)0x20000500 = 5; + *(uint16_t*)0x20000508 = 0xfffe; + *(uint16_t*)0x2000050a = 0x42; + *(uint32_t*)0x2000050c = 2; + *(uint64_t*)0x20000510 = 5; + *(uint64_t*)0x20000518 = 0x7f; + *(uint64_t*)0x20000520 = 9; + *(uint64_t*)0x20000528 = 0x600000000; + *(uint64_t*)0x20000530 = 0x1f; + *(uint64_t*)0x20000538 = 7; + syscall(SYS_kevent, r[0], 0x20000480ul, 3ul, 0x200001c0ul, 0xaul, 0ul); + return 0; +} +EOF +mycc -o /tmp/syzkaller46 -Wall -Wextra -O0 /tmp/syzkaller46.c -lpthread || exit 1 + +(cd /tmp; ./syzkaller46) + +rm -rf /tmp/syzkaller46 /tmp/syzkaller46.c /tmp/syzkaller.* +exit 0 diff --git a/tools/test/stress2/misc/syzkaller47.sh b/tools/test/stress2/misc/syzkaller47.sh new file mode 100755 index 000000000000..76561282a86b --- /dev/null +++ b/tools/test/stress2/misc/syzkaller47.sh @@ -0,0 +1,404 @@ +#!/bin/sh + +# panic: ASan: Invalid access, 32-byte read at 0xfffffe01f76145a0, UseAfterScope(f8) +# cpuid = 3 +# time = 1635158022 +# KDB: stack backtrace: +# db_trace_self_wrapper() at db_trace_self_wrapper+0xa5/frame 0xfffffe01f7614170 +# kdb_backtrace() at kdb_backtrace+0xc9/frame 0xfffffe01f76142d0 +# vpanic() at vpanic+0x248/frame 0xfffffe01f76143b0 +# panic() at panic+0xb5/frame 0xfffffe01f7614480 +# __asan_storeN() at __asan_storeN/frame 0xfffffe01f7614550 +# smp_masked_invlpg_range() at smp_masked_invlpg_range+0xb2/frame 0xfffffe01f7614630 +# pmap_invalidate_range() at pmap_invalidate_range+0x22b/frame 0xfffffe01f7614730 +# vm_thread_stack_create() at vm_thread_stack_create+0xf5/frame 0xfffffe01f7614910 +# kstack_import() at kstack_import+0xcache_alloc() at cache_alloc+0x556/frame 0xfffffe01f7614a10 +# cache_alloc_retry() at cache_alloc_retry+0x30/frame 0xfffffe01f7614a80 +# vm_thread_new() at vm_thread_new+0x61/frame 0xfffffe01f7614ab0 +# thread_alloc() at thread_alloc+0x5f/frame 0xfffffe01f7614af0 +# thread_create() at thread_create+0x1b3/frame 0xfffffe01f7614bf0 +# sys_thr_new() at sys_thr_new+0x15a/framd30 +# amd64_syscall() at amd64_syscall+0x31e/frame 0xfffffe01f7614f30 +# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe01f7614f30 +# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x8003afafa, rsp = 0x7fffdfffdf58, rbp = 0x7fffdfffdf70 --- +# KDB: enter: panic +# [ thread pid 69407 tid 100937 ] +# Stopped at kdb_enter+0x37: movq $0,0x2638c4e(%rip) +# db> x/s version +# version: FreeBSD 14.0-CURRENT #0 main-n250242-eab5358b9080-dirty: Mon Oct 25 11:32:45 CEST 2021 +# pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO-KASAN +# db> + +[ `uname -p` != "amd64" ] && exit 0 +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ "`sysctl -in kern.features.kasan`" != "1" ] && exit 0 + +. ../default.cfg +cat > /tmp/syzkaller47.c < + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static __thread int skip_segv; +static __thread jmp_buf segv_env; + +static void segv_handler(int sig, siginfo_t* info, void* ctx __unused) +{ + uintptr_t addr = (uintptr_t)info->si_addr; + const uintptr_t prog_start = 1 << 20; + const uintptr_t prog_end = 100 << 20; + int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; + int valid = addr < prog_start || addr > prog_end; + if (sig == SIGBUS) + valid = 1; + if (skip && valid) { + _longjmp(segv_env, 1); + } + exit(sig); +} + +static void install_segv_handler(void) +{ + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_sigaction = segv_handler; + sa.sa_flags = SA_NODEFER | SA_SIGINFO; + sigaction(SIGSEGV, &sa, NULL); + sigaction(SIGBUS, &sa, NULL); +} + +#define NONFAILING(...) \ + ({ \ + int ok = 1; \ + __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ + if (_setjmp(segv_env) == 0) { \ + __VA_ARGS__; \ + } else \ + ok = 0; \ + __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ + ok; \ + }) + +static void kill_and_wait(int pid, int* status) +{ + kill(pid, SIGKILL); + while (waitpid(-1, status, 0) != pid) { + } +} + +static void sleep_ms(uint64_t ms) +{ + usleep(ms * 1000); +} + +static uint64_t current_time_ms(void) +{ + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts)) + exit(1); + return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; +} + +static void use_temporary_dir(void) +{ + char tmpdir_template[] = "./syzkaller.XXXXXX"; + char* tmpdir = mkdtemp(tmpdir_template); + if (!tmpdir) + exit(1); + if (chmod(tmpdir, 0777)) + exit(1); + if (chdir(tmpdir)) + exit(1); +} + +static void __attribute__((noinline)) remove_dir(const char* dir) +{ + DIR* dp = opendir(dir); + if (dp == NULL) { + if (errno == EACCES) { + if (rmdir(dir)) + exit(1); + return; + } + exit(1); + } + struct dirent* ep = 0; + while ((ep = readdir(dp))) { + if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) + continue; + char filename[FILENAME_MAX]; + snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); + struct stat st; + if (lstat(filename, &st)) + exit(1); + if (S_ISDIR(st.st_mode)) { + remove_dir(filename); + continue; + } + if (unlink(filename)) + exit(1); + } + closedir(dp); + if (rmdir(dir)) + exit(1); +} + +static void thread_start(void* (*fn)(void*), void* arg) +{ + pthread_t th; + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setstacksize(&attr, 128 << 10); + int i = 0; + for (; i < 100; i++) { + if (pthread_create(&th, &attr, fn, arg) == 0) { + pthread_attr_destroy(&attr); + return; + } + if (errno == EAGAIN) { + usleep(50); + continue; + } + break; + } + exit(1); +} + +typedef struct { + pthread_mutex_t mu; + pthread_cond_t cv; + int state; +} event_t; + +static void event_init(event_t* ev) +{ + if (pthread_mutex_init(&ev->mu, 0)) + exit(1); + if (pthread_cond_init(&ev->cv, 0)) + exit(1); + ev->state = 0; +} + +static void event_reset(event_t* ev) +{ + ev->state = 0; +} + +static void event_set(event_t* ev) +{ + pthread_mutex_lock(&ev->mu); + if (ev->state) + exit(1); + ev->state = 1; + pthread_mutex_unlock(&ev->mu); + pthread_cond_broadcast(&ev->cv); +} + +static void event_wait(event_t* ev) +{ + pthread_mutex_lock(&ev->mu); + while (!ev->state) + pthread_cond_wait(&ev->cv, &ev->mu); + pthread_mutex_unlock(&ev->mu); +} + +static int event_isset(event_t* ev) +{ + pthread_mutex_lock(&ev->mu); + int res = ev->state; + pthread_mutex_unlock(&ev->mu); + return res; +} + +static int event_timedwait(event_t* ev, uint64_t timeout) +{ + uint64_t start = current_time_ms(); + uint64_t now = start; + pthread_mutex_lock(&ev->mu); + for (;;) { + if (ev->state) + break; + uint64_t remain = timeout - (now - start); + struct timespec ts; + ts.tv_sec = remain / 1000; + ts.tv_nsec = (remain % 1000) * 1000 * 1000; + pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); + now = current_time_ms(); + if (now - start > timeout) + break; + } + int res = ev->state; + pthread_mutex_unlock(&ev->mu); + return res; +} + +static void sandbox_common() +{ + struct rlimit rlim; + rlim.rlim_cur = rlim.rlim_max = 128 << 20; + setrlimit(RLIMIT_AS, &rlim); + rlim.rlim_cur = rlim.rlim_max = 8 << 20; + setrlimit(RLIMIT_MEMLOCK, &rlim); + rlim.rlim_cur = rlim.rlim_max = 1 << 20; + setrlimit(RLIMIT_FSIZE, &rlim); + rlim.rlim_cur = rlim.rlim_max = 1 << 20; + setrlimit(RLIMIT_STACK, &rlim); + rlim.rlim_cur = rlim.rlim_max = 0; + setrlimit(RLIMIT_CORE, &rlim); + rlim.rlim_cur = rlim.rlim_max = 256; + setrlimit(RLIMIT_NOFILE, &rlim); +} + +static void loop(); + +static int do_sandbox_none(void) +{ + sandbox_common(); + loop(); + return 0; +} + +struct thread_t { + int created, call; + event_t ready, done; +}; + +static struct thread_t threads[16]; +static void execute_call(int call); +static int running; + +static void* thr(void* arg) +{ + struct thread_t* th = (struct thread_t*)arg; + for (;;) { + event_wait(&th->ready); + event_reset(&th->ready); + execute_call(th->call); + __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); + event_set(&th->done); + } + return 0; +} + +static void execute_one(void) +{ + int i, call, thread; + int collide = 0; +again: + for (call = 0; call < 2; call++) { + for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); + thread++) { + struct thread_t* th = &threads[thread]; + if (!th->created) { + th->created = 1; + event_init(&th->ready); + event_init(&th->done); + event_set(&th->done); + thread_start(thr, th); + } + if (!event_isset(&th->done)) + continue; + event_reset(&th->done); + th->call = call; + __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); + event_set(&th->ready); + if (collide && (call % 2) == 0) + break; + event_timedwait(&th->done, 50); + break; + } + } + for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) + sleep_ms(1); + if (!collide) { + collide = 1; + goto again; + } +} + +static void execute_one(void); + +#define WAIT_FLAGS 0 + +static void loop(void) +{ + int iter = 0; + for (;; iter++) { + char cwdbuf[32]; + sprintf(cwdbuf, "./%d", iter); + if (mkdir(cwdbuf, 0777)) + exit(1); + int pid = fork(); + if (pid < 0) + exit(1); + if (pid == 0) { + if (chdir(cwdbuf)) + exit(1); + execute_one(); + exit(0); + } + int status = 0; + uint64_t start = current_time_ms(); + for (;;) { + if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) + break; + sleep_ms(1); + if (current_time_ms() - start < 5000) + continue; + kill_and_wait(pid, &status); + break; + } + remove_dir(cwdbuf); + } +} + +void execute_call(int call) +{ + switch (call) { + case 0: + syscall(SYS_rfork, 0x4030ul); + break; + case 1: + syscall(SYS_thr_new, 0ul, 0ul); + break; + } +} +int main(void) +{ + syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul); + install_segv_handler(); + use_temporary_dir(); + do_sandbox_none(); + return 0; +} +EOF +mycc -o /tmp/syzkaller47 -Wall -Wextra -O0 /tmp/syzkaller47.c -lpthread || exit 1 + +(cd /tmp; timeout 2m ./syzkaller47) + +rm -rf /tmp/syzkaller47 /tmp/syzkaller47.c /tmp/syzkaller.* +exit 0 From nobody Tue Oct 26 12:35:45 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 20388182BBEC; Tue, 26 Oct 2021 12:35:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hdrrx6hhwz4m4c; Tue, 26 Oct 2021 12:35:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C5DB61CD5D; Tue, 26 Oct 2021 12:35:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QCZjA8038801; Tue, 26 Oct 2021 12:35:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QCZje7038800; Tue, 26 Oct 2021 12:35:45 GMT (envelope-from git) Date: Tue, 26 Oct 2021 12:35:45 GMT Message-Id: <202110261235.19QCZje7038800@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wei Hu Subject: git: 1833cf137365 - main - Mana: move mana polling from EQ to CQ List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: whu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1833cf1373655de0446d3c5504aecbff99e2b6cf Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=1833cf1373655de0446d3c5504aecbff99e2b6cf commit 1833cf1373655de0446d3c5504aecbff99e2b6cf Author: Wei Hu AuthorDate: 2021-10-26 12:25:22 +0000 Commit: Wei Hu CommitDate: 2021-10-26 12:25:22 +0000 Mana: move mana polling from EQ to CQ -Each CQ start task queue to poll when completion happens. This means every rx and tx queue has its own cleanup task thread to poll the completion. - Arm EQ everytime no matter it is mana or hwc. CQ arming depends on the budget. - Fix a warning in mana_poll_tx_cq() when cqe_read is 0. - Move cqe_poll from EQ to CQ struct. - Support EQ sharing up to 8 vPorts. - Ease linkdown message from mana_info to mana_dbg. Tested by: whu MFC after: 2 weeks Sponsored by: Microsoft --- sys/dev/mana/gdma.h | 16 +-- sys/dev/mana/gdma_main.c | 107 +------------------- sys/dev/mana/hw_channel.c | 2 +- sys/dev/mana/mana.h | 29 ++++-- sys/dev/mana/mana_en.c | 253 ++++++++++++++++++++++++++++++---------------- 5 files changed, 193 insertions(+), 214 deletions(-) diff --git a/sys/dev/mana/gdma.h b/sys/dev/mana/gdma.h index 097b2b65e545..8b225800ccdb 100644 --- a/sys/dev/mana/gdma.h +++ b/sys/dev/mana/gdma.h @@ -291,8 +291,6 @@ struct gdma_event { struct gdma_queue; -#define CQE_POLLING_BUFFER 512 - typedef void gdma_eq_callback(void *context, struct gdma_queue *q, struct gdma_event *e); @@ -339,14 +337,6 @@ struct gdma_queue { unsigned int msix_index; uint32_t log2_throttle_limit; - - struct task cleanup_task; - struct taskqueue *cleanup_tq; - int cpu; - bool do_not_ring_db; - - int work_done; - int budget; } eq; struct { @@ -371,9 +361,6 @@ struct gdma_queue_spec { void *context; unsigned long log2_throttle_limit; - - /* Only used by the MANA device. */ - struct ifnet *ndev; } eq; struct { @@ -388,7 +375,6 @@ struct gdma_queue_spec { struct mana_eq { struct gdma_queue *eq; - struct gdma_comp cqe_poll[CQE_POLLING_BUFFER]; }; struct gdma_irq_context { @@ -473,7 +459,7 @@ void mana_gd_destroy_queue(struct gdma_context *gc, struct gdma_queue *queue); int mana_gd_poll_cq(struct gdma_queue *cq, struct gdma_comp *comp, int num_cqe); -void mana_gd_arm_cq(struct gdma_queue *cq); +void mana_gd_ring_cq(struct gdma_queue *cq, uint8_t arm_bit); struct gdma_wqe { uint32_t reserved :24; diff --git a/sys/dev/mana/gdma_main.c b/sys/dev/mana/gdma_main.c index 910992ce17a4..211e47368cc5 100644 --- a/sys/dev/mana/gdma_main.c +++ b/sys/dev/mana/gdma_main.c @@ -422,7 +422,7 @@ mana_gd_wq_ring_doorbell(struct gdma_context *gc, struct gdma_queue *queue) } void -mana_gd_arm_cq(struct gdma_queue *cq) +mana_gd_ring_cq(struct gdma_queue *cq, uint8_t arm_bit) { struct gdma_context *gc = cq->gdma_dev->gdma_context; @@ -431,7 +431,7 @@ mana_gd_arm_cq(struct gdma_queue *cq) uint32_t head = cq->head % (num_cqe << GDMA_CQE_OWNER_BITS); mana_gd_ring_doorbell(gc, cq->gdma_dev->doorbell, cq->type, cq->id, - head, SET_ARM_BIT); + head, arm_bit); } static void @@ -508,7 +508,6 @@ mana_gd_process_eq_events(void *arg) struct gdma_context *gc; uint32_t head, num_eqe; struct gdma_eqe *eqe; - unsigned int arm_bit; int i, j; gc = eq->gdma_dev->gdma_context; @@ -565,66 +564,17 @@ mana_gd_process_eq_events(void *arg) bus_dmamap_sync(eq->mem_info.dma_tag, eq->mem_info.dma_map, BUS_DMASYNC_PREREAD); - /* Always rearm the EQ for HWC. */ - if (mana_gd_is_hwc(eq->gdma_dev)) { - arm_bit = SET_ARM_BIT; - } else if (eq->eq.work_done < eq->eq.budget && - eq->eq.do_not_ring_db == false) { - arm_bit = SET_ARM_BIT; - } else { - arm_bit = 0; - } - head = eq->head % (num_eqe << GDMA_EQE_OWNER_BITS); mana_gd_ring_doorbell(gc, eq->gdma_dev->doorbell, eq->type, eq->id, - head, arm_bit); -} - -#define MANA_POLL_BUDGET 8 -#define MANA_RX_BUDGET 256 - -static void -mana_poll(void *arg, int pending) -{ - struct gdma_queue *eq = arg; - int i; - - eq->eq.work_done = 0; - eq->eq.budget = MANA_RX_BUDGET; - - for (i = 0; i < MANA_POLL_BUDGET; i++) { - /* - * If this is the last loop, set the budget big enough - * so it will arm the EQ any way. - */ - if (i == (MANA_POLL_BUDGET - 1)) - eq->eq.budget = CQE_POLLING_BUFFER + 1; - - mana_gd_process_eq_events(eq); - - if (eq->eq.work_done < eq->eq.budget) - break; - - eq->eq.work_done = 0; - } -} - -static void -mana_gd_schedule_task(void *arg) -{ - struct gdma_queue *eq = arg; - - taskqueue_enqueue(eq->eq.cleanup_tq, &eq->eq.cleanup_task); + head, SET_ARM_BIT); } static int mana_gd_register_irq(struct gdma_queue *queue, const struct gdma_queue_spec *spec) { - static int mana_last_bind_cpu = -1; struct gdma_dev *gd = queue->gdma_dev; - bool is_mana = mana_gd_is_mana(gd); struct gdma_irq_context *gic; struct gdma_context *gc; struct gdma_resource *r; @@ -659,39 +609,6 @@ mana_gd_register_irq(struct gdma_queue *queue, gic = &gc->irq_contexts[msi_index]; - if (is_mana) { - struct mana_port_context *apc = if_getsoftc(spec->eq.ndev); - queue->eq.do_not_ring_db = false; - - NET_TASK_INIT(&queue->eq.cleanup_task, 0, mana_poll, queue); - queue->eq.cleanup_tq = - taskqueue_create_fast("mana eq cleanup", - M_WAITOK, taskqueue_thread_enqueue, - &queue->eq.cleanup_tq); - - if (mana_last_bind_cpu < 0) - mana_last_bind_cpu = CPU_FIRST(); - queue->eq.cpu = mana_last_bind_cpu; - mana_last_bind_cpu = CPU_NEXT(mana_last_bind_cpu); - - /* XXX Name is not optimal. However we have to start - * the task here. Otherwise, test eq will have no - * handler. - */ - if (apc->bind_cleanup_thread_cpu) { - cpuset_t cpu_mask; - CPU_SETOF(queue->eq.cpu, &cpu_mask); - taskqueue_start_threads_cpuset(&queue->eq.cleanup_tq, - 1, PI_NET, &cpu_mask, - "mana eq poll msix %u on cpu %d", - msi_index, queue->eq.cpu); - } else { - - taskqueue_start_threads(&queue->eq.cleanup_tq, 1, - PI_NET, "mana eq poll on msix %u", msi_index); - } - } - if (unlikely(gic->handler || gic->arg)) { device_printf(gc->dev, "interrupt handler or arg already assigned, " @@ -700,10 +617,7 @@ mana_gd_register_irq(struct gdma_queue *queue, gic->arg = queue; - if (is_mana) - gic->handler = mana_gd_schedule_task; - else - gic->handler = mana_gd_process_eq_events; + gic->handler = mana_gd_process_eq_events; mana_dbg(NULL, "registered msix index %d vector %d irq %ju\n", msi_index, gic->msix_e.vector, rman_get_start(gic->res)); @@ -810,15 +724,6 @@ mana_gd_destroy_eq(struct gdma_context *gc, bool flush_evenets, mana_gd_deregiser_irq(queue); - if (mana_gd_is_mana(queue->gdma_dev)) { - while (taskqueue_cancel(queue->eq.cleanup_tq, - &queue->eq.cleanup_task, NULL)) - taskqueue_drain(queue->eq.cleanup_tq, - &queue->eq.cleanup_task); - - taskqueue_free(queue->eq.cleanup_tq); - } - if (queue->eq.disable_needed) mana_gd_disable_queue(queue); } @@ -1602,10 +1507,8 @@ mana_gd_setup_irqs(device_t dev) if (max_queues_per_port > MANA_MAX_NUM_QUEUES) max_queues_per_port = MANA_MAX_NUM_QUEUES; - max_irqs = max_queues_per_port * MAX_PORTS_IN_MANA_DEV; - /* Need 1 interrupt for the Hardware communication Channel (HWC) */ - max_irqs++; + max_irqs = max_queues_per_port + 1; nvec = max_irqs; rc = pci_alloc_msix(dev, &nvec); diff --git a/sys/dev/mana/hw_channel.c b/sys/dev/mana/hw_channel.c index 1949f1d2e049..c24e62970f69 100644 --- a/sys/dev/mana/hw_channel.c +++ b/sys/dev/mana/hw_channel.c @@ -377,7 +377,7 @@ mana_hwc_comp_event(void *ctx, struct gdma_queue *q_self) bus_dmamap_sync(q_self->mem_info.dma_tag, q_self->mem_info.dma_map, BUS_DMASYNC_POSTREAD); - mana_gd_arm_cq(q_self); + mana_gd_ring_cq(q_self, SET_ARM_BIT); } static void diff --git a/sys/dev/mana/mana.h b/sys/dev/mana/mana.h index 683ab67a6abd..da551102c246 100644 --- a/sys/dev/mana/mana.h +++ b/sys/dev/mana/mana.h @@ -115,11 +115,7 @@ enum TRI_STATE { #define EQ_SIZE (8 * PAGE_SIZE) #define LOG2_EQ_THROTTLE 3 -#if 1 /* XXX */ -#define MAX_PORTS_IN_MANA_DEV 1 -#else -#define MAX_PORTS_IN_MANA_DEV 16 -#endif +#define MAX_PORTS_IN_MANA_DEV 8 struct mana_send_buf_info { struct mbuf *mbuf; @@ -351,6 +347,8 @@ struct mana_tx_comp_oob { struct mana_rxq; +#define CQE_POLLING_BUFFER 512 + struct mana_cq { struct gdma_queue *gdma_cq; @@ -370,8 +368,18 @@ struct mana_cq { */ struct mana_txq *txq; - /* Pointer to a buffer which the CQ handler can copy the CQE's into. */ - struct gdma_comp *gdma_comp_buf; + /* Taskqueue and related structs */ + struct task cleanup_task; + struct taskqueue *cleanup_tq; + int cpu; + bool do_not_ring_db; + + /* Budget for one cleanup task */ + int work_done; + int budget; + + /* Buffer which the CQ handler can copy the CQE's into. */ + struct gdma_comp gdma_comp_buf[CQE_POLLING_BUFFER]; }; #define GDMA_MAX_RQE_SGES 15 @@ -451,6 +459,8 @@ struct mana_context { uint16_t num_ports; + struct mana_eq *eqs; + struct ifnet *ports[MAX_PORTS_IN_MANA_DEV]; }; @@ -467,8 +477,6 @@ struct mana_port_context { uint8_t mac_addr[ETHER_ADDR_LEN]; - struct mana_eq *eqs; - enum TRI_STATE rss_state; mana_handle_t default_rxobj; @@ -503,7 +511,10 @@ struct mana_port_context { bool port_st_save; /* Saved port state */ bool enable_tx_altq; + bool bind_cleanup_thread_cpu; + int last_tx_cq_bind_cpu; + int last_rx_cq_bind_cpu; struct mana_port_stats port_stats; diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c index 5b680f146476..7ad69457afc2 100644 --- a/sys/dev/mana/mana_en.c +++ b/sys/dev/mana/mana_en.c @@ -108,7 +108,7 @@ mana_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr) if (!apc->port_is_up) { MANA_APC_LOCK_UNLOCK(apc); - mana_info(NULL, "Port %u link is down\n", apc->port_idx); + mana_dbg(NULL, "Port %u link is down\n", apc->port_idx); return; } @@ -142,19 +142,6 @@ mana_get_counter(struct ifnet *ifp, ift_counter cnt) } } -static void -mana_drain_eq_task(struct gdma_queue *queue) -{ - if (!queue || !queue->eq.cleanup_tq) - return; - - while (taskqueue_cancel(queue->eq.cleanup_tq, - &queue->eq.cleanup_task, NULL)) { - taskqueue_drain(queue->eq.cleanup_tq, - &queue->eq.cleanup_task); - } -} - static void mana_qflush(struct ifnet *ifp) { @@ -439,13 +426,11 @@ mana_xmit(struct mana_txq *txq) struct mana_tx_package pkg = {}; struct mana_stats *tx_stats; struct gdma_queue *gdma_sq; - struct gdma_queue *gdma_eq; struct mana_cq *cq; int err, len; gdma_sq = txq->gdma_sq; cq = &apc->tx_qp[txq->idx].tx_cq; - gdma_eq = cq->gdma_cq->cq.parent; tx_stats = &txq->stats; packets = 0; @@ -476,8 +461,7 @@ mana_xmit(struct mana_txq *txq) drbr_putback(ndev, txq->txq_br, mbuf); - taskqueue_enqueue(gdma_eq->eq.cleanup_tq, - &gdma_eq->eq.cleanup_task); + taskqueue_enqueue(cq->cleanup_tq, &cq->cleanup_task); break; } @@ -1183,67 +1167,57 @@ mana_destroy_wq_obj(struct mana_port_context *apc, uint32_t wq_type, } static void -mana_init_cqe_poll_buf(struct gdma_comp *cqe_poll_buf) -{ - int i; - - for (i = 0; i < CQE_POLLING_BUFFER; i++) - memset(&cqe_poll_buf[i], 0, sizeof(struct gdma_comp)); -} - -static void -mana_destroy_eq(struct gdma_context *gc, struct mana_port_context *apc) +mana_destroy_eq(struct mana_context *ac) { + struct gdma_context *gc = ac->gdma_dev->gdma_context; struct gdma_queue *eq; int i; - if (!apc->eqs) + if (!ac->eqs) return; - for (i = 0; i < apc->num_queues; i++) { - eq = apc->eqs[i].eq; + for (i = 0; i < gc->max_num_queues; i++) { + eq = ac->eqs[i].eq; if (!eq) continue; mana_gd_destroy_queue(gc, eq); } - free(apc->eqs, M_DEVBUF); - apc->eqs = NULL; + free(ac->eqs, M_DEVBUF); + ac->eqs = NULL; } static int -mana_create_eq(struct mana_port_context *apc) +mana_create_eq(struct mana_context *ac) { - struct gdma_dev *gd = apc->ac->gdma_dev; + struct gdma_dev *gd = ac->gdma_dev; + struct gdma_context *gc = gd->gdma_context; struct gdma_queue_spec spec = {}; int err; int i; - apc->eqs = mallocarray(apc->num_queues, sizeof(struct mana_eq), + ac->eqs = mallocarray(gc->max_num_queues, sizeof(struct mana_eq), M_DEVBUF, M_WAITOK | M_ZERO); - if (!apc->eqs) + if (!ac->eqs) return ENOMEM; spec.type = GDMA_EQ; spec.monitor_avl_buf = false; spec.queue_size = EQ_SIZE; spec.eq.callback = NULL; - spec.eq.context = apc->eqs; + spec.eq.context = ac->eqs; spec.eq.log2_throttle_limit = LOG2_EQ_THROTTLE; - spec.eq.ndev = apc->ndev; - - for (i = 0; i < apc->num_queues; i++) { - mana_init_cqe_poll_buf(apc->eqs[i].cqe_poll); - err = mana_gd_create_mana_eq(gd, &spec, &apc->eqs[i].eq); + for (i = 0; i < gc->max_num_queues; i++) { + err = mana_gd_create_mana_eq(gd, &spec, &ac->eqs[i].eq); if (err) goto out; } return 0; out: - mana_destroy_eq(gd->gdma_context, apc); + mana_destroy_eq(ac); return err; } @@ -1294,6 +1268,9 @@ mana_poll_tx_cq(struct mana_cq *cq) comp_read = mana_gd_poll_cq(cq->gdma_cq, completions, CQE_POLLING_BUFFER); + if (comp_read < 1) + return; + next_to_complete = txq->next_to_complete; for (i = 0; i < comp_read; i++) { @@ -1360,7 +1337,7 @@ mana_poll_tx_cq(struct mana_cq *cq) txq_idx, next_to_complete, txq->next_to_use, txq->pending_sends, pkt_transmitted, sa_drop, i, comp_read); - continue; + break; } wqe_info = &tx_info->wqe_inf; @@ -1430,6 +1407,8 @@ mana_poll_tx_cq(struct mana_cq *cq) mana_err(NULL, "WARNING: TX %d pending_sends error: %d\n", txq->idx, txq->pending_sends); + + cq->work_done = pkt_transmitted; } static void @@ -1468,13 +1447,11 @@ mana_rx_mbuf(struct mbuf *mbuf, struct mana_rxcomp_oob *cqe, uint32_t pkt_len = cqe->ppi[0].pkt_len; uint16_t rxq_idx = rxq->rxq_idx; struct mana_port_context *apc; - struct gdma_queue *eq; bool do_lro = false; bool do_if_input; apc = if_getsoftc(ndev); - eq = apc->eqs[rxq_idx].eq; - eq->eq.work_done++; + rxq->rx_cq.work_done++; if (!mbuf) { return; @@ -1688,6 +1665,7 @@ static void mana_cq_handler(void *context, struct gdma_queue *gdma_queue) { struct mana_cq *cq = context; + uint8_t arm_bit; KASSERT(cq->gdma_cq == gdma_queue, ("cq do not match %p, %p", cq->gdma_cq, gdma_queue)); @@ -1698,7 +1676,54 @@ mana_cq_handler(void *context, struct gdma_queue *gdma_queue) mana_poll_tx_cq(cq); } - mana_gd_arm_cq(gdma_queue); + if (cq->work_done < cq->budget && cq->do_not_ring_db == false) + arm_bit = SET_ARM_BIT; + else + arm_bit = 0; + + mana_gd_ring_cq(gdma_queue, arm_bit); +} + +#define MANA_POLL_BUDGET 8 +#define MANA_RX_BUDGET 256 +#define MANA_TX_BUDGET MAX_SEND_BUFFERS_PER_QUEUE + +static void +mana_poll(void *arg, int pending) +{ + struct mana_cq *cq = arg; + int i; + + cq->work_done = 0; + if (cq->type == MANA_CQ_TYPE_RX) { + cq->budget = MANA_RX_BUDGET; + } else { + cq->budget = MANA_TX_BUDGET; + } + + for (i = 0; i < MANA_POLL_BUDGET; i++) { + /* + * If this is the last loop, set the budget big enough + * so it will arm the CQ any way. + */ + if (i == (MANA_POLL_BUDGET - 1)) + cq->budget = CQE_POLLING_BUFFER + 1; + + mana_cq_handler(cq, cq->gdma_cq); + + if (cq->work_done < cq->budget) + break; + + cq->work_done = 0; + } +} + +static void +mana_schedule_task(void *arg, struct gdma_queue *gdma_queue) +{ + struct mana_cq *cq = arg; + + taskqueue_enqueue(cq->cleanup_tq, &cq->cleanup_task); } static void @@ -1709,6 +1734,17 @@ mana_deinit_cq(struct mana_port_context *apc, struct mana_cq *cq) if (!cq->gdma_cq) return; + /* Drain cleanup taskqueue */ + if (cq->cleanup_tq) { + while (taskqueue_cancel(cq->cleanup_tq, + &cq->cleanup_task, NULL)) { + taskqueue_drain(cq->cleanup_tq, + &cq->cleanup_task); + } + + taskqueue_free(cq->cleanup_tq); + } + mana_gd_destroy_queue(gd->gdma_context, cq->gdma_cq); } @@ -1798,7 +1834,8 @@ mana_destroy_txq(struct mana_port_context *apc) static int mana_create_txq(struct mana_port_context *apc, struct ifnet *net) { - struct gdma_dev *gd = apc->ac->gdma_dev; + struct mana_context *ac = apc->ac; + struct gdma_dev *gd = ac->gdma_dev; struct mana_obj_spec wq_spec; struct mana_obj_spec cq_spec; struct gdma_queue_spec spec; @@ -1850,7 +1887,6 @@ mana_create_txq(struct mana_port_context *apc, struct ifnet *net) /* Create SQ's CQ */ cq = &apc->tx_qp[i].tx_cq; - cq->gdma_comp_buf = apc->eqs[i].cqe_poll; cq->type = MANA_CQ_TYPE_TX; cq->txq = txq; @@ -1859,8 +1895,8 @@ mana_create_txq(struct mana_port_context *apc, struct ifnet *net) spec.type = GDMA_CQ; spec.monitor_avl_buf = false; spec.queue_size = cq_size; - spec.cq.callback = mana_cq_handler; - spec.cq.parent_eq = apc->eqs[i].eq; + spec.cq.callback = mana_schedule_task; + spec.cq.parent_eq = ac->eqs[i].eq; spec.cq.context = cq; err = mana_gd_create_mana_wq_cq(gd, &spec, &cq->gdma_cq); if (err) @@ -1942,12 +1978,39 @@ mana_create_txq(struct mana_port_context *apc, struct ifnet *net) goto out; } taskqueue_start_threads(&txq->enqueue_tq, 1, PI_NET, - "mana txq %d", i); + "mana txq p%u-tx%d", apc->port_idx, i); mana_alloc_counters((counter_u64_t *)&txq->stats, sizeof(txq->stats)); - mana_gd_arm_cq(cq->gdma_cq); + /* Allocate and start the cleanup task on CQ */ + cq->do_not_ring_db = false; + + NET_TASK_INIT(&cq->cleanup_task, 0, mana_poll, cq); + cq->cleanup_tq = + taskqueue_create_fast("mana tx cq cleanup", + M_WAITOK, taskqueue_thread_enqueue, + &cq->cleanup_tq); + + if (apc->last_tx_cq_bind_cpu < 0) + apc->last_tx_cq_bind_cpu = CPU_FIRST(); + cq->cpu = apc->last_tx_cq_bind_cpu; + apc->last_tx_cq_bind_cpu = CPU_NEXT(apc->last_tx_cq_bind_cpu); + + if (apc->bind_cleanup_thread_cpu) { + cpuset_t cpu_mask; + CPU_SETOF(cq->cpu, &cpu_mask); + taskqueue_start_threads_cpuset(&cq->cleanup_tq, + 1, PI_NET, &cpu_mask, + "mana cq p%u-tx%u-cpu%d", + apc->port_idx, txq->idx, cq->cpu); + } else { + taskqueue_start_threads(&cq->cleanup_tq, 1, + PI_NET, "mana cq p%u-tx%u", + apc->port_idx, txq->idx); + } + + mana_gd_ring_cq(cq->gdma_cq, SET_ARM_BIT); } return 0; @@ -2144,7 +2207,6 @@ mana_create_rxq(struct mana_port_context *apc, uint32_t rxq_idx, /* Create RQ's CQ */ cq = &rxq->rx_cq; - cq->gdma_comp_buf = eq->cqe_poll; cq->type = MANA_CQ_TYPE_RX; cq->rxq = rxq; @@ -2152,7 +2214,7 @@ mana_create_rxq(struct mana_port_context *apc, uint32_t rxq_idx, spec.type = GDMA_CQ; spec.monitor_avl_buf = false; spec.queue_size = cq_size; - spec.cq.callback = mana_cq_handler; + spec.cq.callback = mana_schedule_task; spec.cq.parent_eq = eq->eq; spec.cq.context = cq; err = mana_gd_create_mana_wq_cq(gd, &spec, &cq->gdma_cq); @@ -2192,7 +2254,34 @@ mana_create_rxq(struct mana_port_context *apc, uint32_t rxq_idx, gc->cq_table[cq->gdma_id] = cq->gdma_cq; - mana_gd_arm_cq(cq->gdma_cq); + /* Allocate and start the cleanup task on CQ */ + cq->do_not_ring_db = false; + + NET_TASK_INIT(&cq->cleanup_task, 0, mana_poll, cq); + cq->cleanup_tq = + taskqueue_create_fast("mana rx cq cleanup", + M_WAITOK, taskqueue_thread_enqueue, + &cq->cleanup_tq); + + if (apc->last_rx_cq_bind_cpu < 0) + apc->last_rx_cq_bind_cpu = CPU_FIRST(); + cq->cpu = apc->last_rx_cq_bind_cpu; + apc->last_rx_cq_bind_cpu = CPU_NEXT(apc->last_rx_cq_bind_cpu); + + if (apc->bind_cleanup_thread_cpu) { + cpuset_t cpu_mask; + CPU_SETOF(cq->cpu, &cpu_mask); + taskqueue_start_threads_cpuset(&cq->cleanup_tq, + 1, PI_NET, &cpu_mask, + "mana cq p%u-rx%u-cpu%d", + apc->port_idx, rxq->rxq_idx, cq->cpu); + } else { + taskqueue_start_threads(&cq->cleanup_tq, 1, + PI_NET, "mana cq p%u-rx%u", + apc->port_idx, rxq->rxq_idx); + } + + mana_gd_ring_cq(cq->gdma_cq, SET_ARM_BIT); out: if (!err) return rxq; @@ -2210,12 +2299,13 @@ out: static int mana_add_rx_queues(struct mana_port_context *apc, struct ifnet *ndev) { + struct mana_context *ac = apc->ac; struct mana_rxq *rxq; int err = 0; int i; for (i = 0; i < apc->num_queues; i++) { - rxq = mana_create_rxq(apc, i, &apc->eqs[i], ndev); + rxq = mana_create_rxq(apc, i, &ac->eqs[i], ndev); if (!rxq) { err = ENOMEM; goto out; @@ -2234,20 +2324,12 @@ mana_destroy_vport(struct mana_port_context *apc) { struct mana_rxq *rxq; uint32_t rxq_idx; - struct mana_cq *rx_cq; - struct gdma_queue *cq, *eq; for (rxq_idx = 0; rxq_idx < apc->num_queues; rxq_idx++) { rxq = apc->rxqs[rxq_idx]; if (!rxq) continue; - rx_cq = &rxq->rx_cq; - if ((cq = rx_cq->gdma_cq) != NULL) { - eq = cq->cq.parent; - mana_drain_eq_task(eq); - } - mana_destroy_rxq(apc, rxq, true); apc->rxqs[rxq_idx] = NULL; } @@ -2336,16 +2418,11 @@ int mana_alloc_queues(struct ifnet *ndev) { struct mana_port_context *apc = if_getsoftc(ndev); - struct gdma_dev *gd = apc->ac->gdma_dev; int err; - err = mana_create_eq(apc); - if (err) - return err; - err = mana_create_vport(apc, ndev); if (err) - goto destroy_eq; + return err; err = mana_add_rx_queues(apc, ndev); if (err) @@ -2363,8 +2440,6 @@ mana_alloc_queues(struct ifnet *ndev) destroy_vport: mana_destroy_vport(apc); -destroy_eq: - mana_destroy_eq(gd->gdma_context, apc); return err; } @@ -2430,16 +2505,13 @@ mana_dealloc_queues(struct ifnet *ndev) txq = &apc->tx_qp[i].txq; struct mana_cq *tx_cq = &apc->tx_qp[i].tx_cq; - struct gdma_queue *eq = NULL; - if (tx_cq->gdma_cq) - eq = tx_cq->gdma_cq->cq.parent; - if (eq) { - /* Stop EQ interrupt */ - eq->eq.do_not_ring_db = true; - /* Schedule a cleanup task */ - taskqueue_enqueue(eq->eq.cleanup_tq, - &eq->eq.cleanup_task); - } + struct mana_cq *rx_cq = &(apc->rxqs[i]->rx_cq); + + tx_cq->do_not_ring_db = true; + rx_cq->do_not_ring_db = true; + + /* Schedule a cleanup task */ + taskqueue_enqueue(tx_cq->cleanup_tq, &tx_cq->cleanup_task); while (atomic_read(&txq->pending_sends) > 0) usleep_range(1000, 2000); @@ -2461,8 +2533,6 @@ mana_dealloc_queues(struct ifnet *ndev) mana_destroy_vport(apc); - mana_destroy_eq(apc->ac->gdma_dev->gdma_context, apc); - return 0; } @@ -2550,6 +2620,8 @@ mana_probe_port(struct mana_context *ac, int port_idx, apc->port_handle = INVALID_MANA_HANDLE; apc->port_idx = port_idx; apc->frame_size = DEFAULT_FRAME_SIZE; + apc->last_tx_cq_bind_cpu = -1; + apc->last_rx_cq_bind_cpu = -1; MANA_APC_LOCK_INIT(apc); @@ -2637,6 +2709,10 @@ int mana_probe(struct gdma_dev *gd) ac->num_ports = 1; gd->driver_data = ac; + err = mana_create_eq(ac); + if (err) + goto out; + err = mana_query_device_cfg(ac, MANA_MAJOR_VERSION, MANA_MINOR_VERSION, MANA_MICRO_VERSION, &ac->num_ports); if (err) @@ -2682,6 +2758,9 @@ mana_remove(struct gdma_dev *gd) if_free(ndev); } + + mana_destroy_eq(ac); + out: mana_gd_deregister_device(gd); gd->driver_data = NULL; From nobody Tue Oct 26 12:50:36 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5ED1B1832D07; Tue, 26 Oct 2021 12:50:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdsB51qJCz4qsL; Tue, 26 Oct 2021 12:50:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 14E461CD75; Tue, 26 Oct 2021 12:50:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QCoaNQ060560; Tue, 26 Oct 2021 12:50:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QCoa7f060559; Tue, 26 Oct 2021 12:50:36 GMT (envelope-from git) Date: Tue, 26 Oct 2021 12:50:36 GMT Message-Id: <202110261250.19QCoa7f060559@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f2069331e582 - main - libutil: add kinfo_getswapvmobject(3) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f2069331e5821f4c2b65d82af2809946a34158d2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f2069331e5821f4c2b65d82af2809946a34158d2 commit f2069331e5821f4c2b65d82af2809946a34158d2 Author: Konstantin Belousov AuthorDate: 2021-10-26 08:40:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-26 12:50:29 +0000 libutil: add kinfo_getswapvmobject(3) which is the wrapper around the vm.swap_objects sysctl, same as kinfo_getvmobject(3) wraps vm.objects. Submitted by: Yoshihiro Ota MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29754 --- lib/libutil/kinfo_getvmobject.c | 20 ++++++++++++++++---- lib/libutil/libutil.h | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/libutil/kinfo_getvmobject.c b/lib/libutil/kinfo_getvmobject.c index de55650a518b..4bf666fd7f3b 100644 --- a/lib/libutil/kinfo_getvmobject.c +++ b/lib/libutil/kinfo_getvmobject.c @@ -36,8 +36,8 @@ __FBSDID("$FreeBSD$"); #include "libutil.h" -struct kinfo_vmobject * -kinfo_getvmobject(int *cntp) +static struct kinfo_vmobject * +kinfo_getvmobject_impl(int *cntp, const char *vmobjsysctl) { char *buf, *bp, *ep; struct kinfo_vmobject *kvo, *list, *kp; @@ -46,14 +46,14 @@ kinfo_getvmobject(int *cntp) buf = NULL; for (i = 0; i < 3; i++) { - if (sysctlbyname("vm.objects", NULL, &len, NULL, 0) < 0) { + if (sysctlbyname(vmobjsysctl, NULL, &len, NULL, 0) < 0) { free(buf); return (NULL); } buf = reallocf(buf, len); if (buf == NULL) return (NULL); - if (sysctlbyname("vm.objects", buf, &len, NULL, 0) == 0) + if (sysctlbyname(vmobjsysctl, buf, &len, NULL, 0) == 0) goto unpack; if (errno != ENOMEM) { free(buf); @@ -94,3 +94,15 @@ unpack: *cntp = cnt; return (list); } + +struct kinfo_vmobject * +kinfo_getvmobject(int *cntp) +{ + return (kinfo_getvmobject_impl(cntp, "vm.objects")); +} + +struct kinfo_vmobject * +kinfo_getswapvmobject(int *cntp) +{ + return (kinfo_getvmobject_impl(cntp, "vm.swap_objects")); +} diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index bb96b2caa502..17c44de0fce7 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -109,6 +109,8 @@ struct kinfo_vmentry * kinfo_getvmmap(pid_t _pid, int *_cntp); struct kinfo_vmobject * kinfo_getvmobject(int *_cntp); +struct kinfo_vmobject * + kinfo_getswapvmobject(int *_cntp); struct kinfo_proc * kinfo_getallproc(int *_cntp); struct kinfo_proc * From nobody Tue Oct 26 12:50:38 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 78DB01832CC7; Tue, 26 Oct 2021 12:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdsB62S1Fz4qqK; Tue, 26 Oct 2021 12:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2395A1CF15; Tue, 26 Oct 2021 12:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QCoceL060584; Tue, 26 Oct 2021 12:50:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QCoc3Z060583; Tue, 26 Oct 2021 12:50:38 GMT (envelope-from git) Date: Tue, 26 Oct 2021 12:50:38 GMT Message-Id: <202110261250.19QCoc3Z060583@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 57e5da2c9800 - main - Augment systat(1) -swap to display large swap space processes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 57e5da2c98003e5ab77a337e9fbe22ab7e512ba7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=57e5da2c98003e5ab77a337e9fbe22ab7e512ba7 commit 57e5da2c98003e5ab77a337e9fbe22ab7e512ba7 Author: Konstantin Belousov AuthorDate: 2021-10-26 08:43:08 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-26 12:50:29 +0000 Augment systat(1) -swap to display large swap space processes This change updates the systat(1) -swap display to use libprocstat to obtain and display per-process swap space usage infomation following its existing swap devise/file statistics. It also incorporates the disk I/O information from the -vmstat display. The new screen looks like below with 'systat -swap': /0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10 Load Average | Device/Path Size Used |0% /10 /20 /30 /40 / 60\ 70\ 80\ 90\ 100| ada0s1b 2048M 2034M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX zvol/sys/tempora 1024M 1015M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX zvol/sys/swap 1024M 1014M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Total 4096M 4063M XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Pid Username Command Swap/Total Per-Process Per-System 24153 hiro seamonkey 98M / 1G 7% 2% 23677 hiro xfce4-pane 28M / 81M 34% XXX 0% 23629 hiro xfce4-sess 25M / 118M 21% XX 0% 23681 hiro xfdesktop 20M / 58M 34% XXX 0% 23678 hiro thunar 15M / 43M 36% XXX 0% 23658 hiro at-spi-bus 14M / 23M 63% XXXXXX 0% 23660 hiro gvfsd 12M / 21M 56% XXXXX 0% Disks ada0 ada1 ada2 cd0 pass0 pass1 pass2 pass3 KB/t 8.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tps 0 0 0 0 1 0 0 0 MB/s 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 %busy 0 0 0 0 0 0 0 0 Submitted by: Yoshihiro Ota MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29754 --- usr.bin/systat/Makefile | 4 +- usr.bin/systat/proc.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++ usr.bin/systat/swap.c | 24 ++-- usr.bin/systat/sysput.c | 24 +--- usr.bin/systat/systat.1 | 30 ++++- usr.bin/systat/systat.h | 6 + 6 files changed, 361 insertions(+), 36 deletions(-) diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile index 01cd36877101..58b6c855d6af 100644 --- a/usr.bin/systat/Makefile +++ b/usr.bin/systat/Makefile @@ -5,7 +5,7 @@ PROG= systat SRCS= cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c sysput.c \ - netcmds.c netstat.c pigs.c swap.c icmp.c \ + netcmds.c netstat.c pigs.c proc.c swap.c icmp.c \ mode.c ip.c sctp.c tcp.c zarc.c \ vmstat.c convtbl.c ifcmds.c ifstat.c @@ -16,6 +16,6 @@ CFLAGS+= -DINET6 WARNS?= 1 -LIBADD= tinfow ncursesw m devstat kvm util +LIBADD= tinfow ncursesw m devstat kvm util procstat .include diff --git a/usr.bin/systat/proc.c b/usr.bin/systat/proc.c new file mode 100644 index 000000000000..58c3bea64239 --- /dev/null +++ b/usr.bin/systat/proc.c @@ -0,0 +1,309 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Yoshihiro Ota + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "systat.h" +#include "extern.h" + +/* + * vm objects of swappable types + */ +static struct swapvm { + uint64_t kvo_me; + uint32_t swapped; /* in pages */ + uint64_t next; + pid_t pid; /* to avoid double counting */ +} *swobj = NULL; +static int nswobj = 0; + +static struct procstat *prstat = NULL; +/* + *procstat_getvmmap() is an expensive call and the number of processes running + * may also be high. So, maintain an array of pointers for ease of expanding + * an array and also swapping pointers are faster than struct. + */ +static struct proc_usage { + pid_t pid; + uid_t uid; + char command[COMMLEN + 1]; + uint64_t total; + uint32_t pages; +} **pu = NULL; +static unsigned int nproc; +static int proc_compar(const void *, const void *); + +static void +display_proc_line(int idx, int y, uint64_t totalswappages) +{ + int offset = 0, rate; + const char *uname, *pname; + char buf[30]; + uint64_t swapbytes; + + wmove(wnd, y, 0); + wclrtoeol(wnd); + if (idx >= nproc) + return; + + uname = user_from_uid(pu[idx]->uid, 0); + swapbytes = ptoa(pu[idx]->pages); + + snprintf(buf, sizeof(buf), "%6d %-10s %-10.10s", pu[idx]->pid, uname, + pu[idx]->command); + offset = 6 + 1 + 10 + 1 + 10 + 1; + mvwaddstr(wnd, y, 0, buf); + sysputuint64(wnd, y, offset, 4, swapbytes, 0); + offset += 4; + mvwaddstr(wnd, y, offset, " / "); + offset += 3; + sysputuint64(wnd, y, offset, 4, pu[idx]->total, 0); + offset += 4; + + rate = pu[idx]->total > 1 ? 100 * swapbytes / pu[idx]->total : 0; + snprintf(buf, sizeof(buf), "%3d%%", rate); + mvwaddstr(wnd, y, offset, buf); + if (rate > 100) /* avoid running over the screen */ + rate = 100; + sysputXs(wnd, y, offset + 5, rate / 10); + + rate = 100 * pu[idx]->pages / totalswappages; + snprintf(buf, sizeof(buf), "%3d%%", rate); + mvwaddstr(wnd, y, offset + 16, buf); + if (rate > 100) /* avoid running over the screen */ + rate = 100; + sysputXs(wnd, y, offset + 21, rate / 10); +} + +static int +swobj_search(const void *a, const void *b) +{ + const uint64_t *aa = a; + const struct swapvm *bb = b; + + if (*aa == bb->kvo_me) + return (0); + return (*aa > bb->kvo_me ? -1 : 1); +} + +static int +swobj_sort(const void *a, const void *b) +{ + + return ((((const struct swapvm *) a)->kvo_me > + ((const struct swapvm *) b)->kvo_me) ? -1 : 1); +} + +static bool +get_swap_vmobjects(void) +{ + static int maxnobj; + int cnt, i, next_i, last_nswobj; + struct kinfo_vmobject *kvo; + + next_i = nswobj = 0; + kvo = kinfo_getswapvmobject(&cnt); + if (kvo == NULL) { + error("kinfo_getswapvmobject()"); + return (false); + } + do { + for (i = next_i; i < cnt; i++) { + if (kvo[i].kvo_type != KVME_TYPE_DEFAULT && + kvo[i].kvo_type != KVME_TYPE_SWAP) + continue; + if (nswobj < maxnobj) { + swobj[nswobj].kvo_me = kvo[i].kvo_me; + swobj[nswobj].swapped = kvo[i].kvo_swapped; + swobj[nswobj].next = kvo[i].kvo_backing_obj; + swobj[nswobj].pid = 0; + next_i = i + 1; + } + nswobj++; + } + if (nswobj <= maxnobj) + break; + /* allocate memory and fill skipped elements */ + last_nswobj = maxnobj; + maxnobj = nswobj; + nswobj = last_nswobj; + /* allocate more memory and fill missed ones */ + if ((swobj = reallocf(swobj, maxnobj * sizeof(*swobj))) == + NULL) { + error("Out of memory"); + die(0); + } + } while (i <= cnt); /* extra safety guard */ + free(kvo); + if (nswobj > 1) + qsort(swobj, nswobj, sizeof(swobj[0]), swobj_sort); + return (nswobj > 0); +} + +/* This returns the number of swap pages a process uses. */ +static uint32_t +per_proc_swap_usage(struct kinfo_proc *kipp) +{ + int i, cnt; + uint32_t pages = 0; + uint64_t vmobj; + struct kinfo_vmentry *freep, *kve; + struct swapvm *vm; + + freep = procstat_getvmmap(prstat, kipp, &cnt); + if (freep == NULL) + return (pages); + + for (i = 0; i < cnt; i++) { + kve = &freep[i]; + if (kve->kve_type == KVME_TYPE_DEFAULT || + kve->kve_type == KVME_TYPE_SWAP) { + vmobj = kve->kve_obj; + do { + vm = bsearch(&vmobj, swobj, nswobj, + sizeof(swobj[0]), swobj_search); + if (vm != NULL && vm->pid != kipp->ki_pid) { + pages += vm->swapped; + vmobj = vm->next; + vm->pid = kipp->ki_pid; + } else + break; + } while (vmobj != 0); + } + } + free(freep); + return (pages); +} + +void +closeproc(WINDOW *w) +{ + + if (prstat != NULL) + procstat_close(prstat); + prstat = NULL; + if (w == NULL) + return; + wclear(w); + wrefresh(w); + delwin(w); +} + +void +procshow(int col, int hight, uint64_t totalswappages) +{ + int i, y; + + for (i = 0, y = col + 1 /* HEADING */; i < hight; i++, y++) + display_proc_line(i, y, totalswappages); +} + +int +procinit(void) +{ + + if (prstat == NULL) + prstat = procstat_open_sysctl(); + return (prstat != NULL); +} + +void +procgetinfo(void) +{ + static unsigned int maxnproc = 0; + int cnt, i; + uint32_t pages; + struct kinfo_proc *kipp; + + nproc = 0; + if ( ! get_swap_vmobjects() ) /* call failed or nothing is paged-out */ + return; + + kipp = procstat_getprocs(prstat, KERN_PROC_PROC, 0, &cnt); + if (kipp == NULL) { + error("procstat_getprocs()"); + return; + } + if (maxnproc < cnt) { + if ((pu = realloc(pu, cnt * sizeof(*pu))) == NULL) { + error("Out of memory"); + die(0); + } + memset(&pu[maxnproc], 0, (cnt - maxnproc) * sizeof(pu[0])); + maxnproc = cnt; + } + + for (i = 0; i < cnt; i++) { + pages = per_proc_swap_usage(&kipp[i]); + if (pages == 0) + continue; + if (pu[nproc] == NULL && + (pu[nproc] = malloc(sizeof(**pu))) == NULL) { + error("Out of memory"); + die(0); + } + strlcpy(pu[nproc]->command, kipp[i].ki_comm, + sizeof(pu[nproc]->command)); + pu[nproc]->pid = kipp[i].ki_pid; + pu[nproc]->uid = kipp[i].ki_uid; + pu[nproc]->pages = pages; + pu[nproc]->total = kipp[i].ki_size; + nproc++; + } + if (nproc > 1) + qsort(pu, nproc, sizeof(*pu), proc_compar); +} + +void +proclabel(int col) +{ + + wmove(wnd, col, 0); + wclrtoeol(wnd); + mvwaddstr(wnd, col, 0, + "Pid Username Command Swap/Total " + "Per-Process Per-System"); +} + +int +proc_compar(const void *a, const void *b) +{ + const struct proc_usage *aa = *((const struct proc_usage **)a); + const struct proc_usage *bb = *((const struct proc_usage **)b); + + return (aa->pages > bb->pages ? -1 : 1); +} diff --git a/usr.bin/systat/swap.c b/usr.bin/systat/swap.c index 6052ca0d877b..19374918ff68 100644 --- a/usr.bin/systat/swap.c +++ b/usr.bin/systat/swap.c @@ -103,6 +103,7 @@ initswap(void) } pathlen = 80 - 50 /* % */ - 5 /* Used */ - 5 /* Size */ - 3 /* space */; dsinit(12); + procinit(); once = 1; return (1); @@ -125,14 +126,13 @@ fetchswap(void) cur_dev.dinfo = tmp_dinfo; last_dev.snap_time = cur_dev.snap_time; - dsgetinfo( &cur_dev ); + dsgetinfo(&cur_dev); + procgetinfo(); } void labelswap(void) { - const char *name; - int i; werase(wnd); @@ -146,18 +146,13 @@ labelswap(void) mvwprintw(wnd, 0, 0, "%*s%5s %5s %s", -pathlen, "Device/Path", "Size", "Used", "|0% /10 /20 /30 /40 / 60\\ 70\\ 80\\ 90\\ 100|"); - - for (i = 0; i <= kvnsw; ++i) { - name = i == kvnsw ? "Total" : kvmsw[i].ksw_devname; - mvwprintw(wnd, 1 + i, 0, "%-*.*s", pathlen, pathlen - 1, name); - } } void showswap(void) { - int count; - int i; + const char *name; + int count, i; if (kvnsw != okvnsw) labelswap(); @@ -167,7 +162,10 @@ showswap(void) if (kvnsw <= 0) return; - for (i = 0; i <= kvnsw; ++i) { + for (i = (kvnsw == 1 ? 0 : kvnsw); i >= 0; i--) { + name = i == kvnsw ? "Total" : kvmsw[i].ksw_devname; + mvwprintw(wnd, 1 + i, 0, "%-*.*s", pathlen, pathlen - 1, name); + sysputpage(wnd, i + 1, pathlen, 5, kvmsw[i].ksw_total, 0); sysputpage(wnd, i + 1, pathlen + 5 + 1, 5, kvmsw[i].ksw_used, 0); @@ -178,4 +176,8 @@ showswap(void) } wclrtoeol(wnd); } + count = kvnsw == 1 ? 2 : 3; + proclabel(kvnsw + count); + procshow(kvnsw + count, LINES - 5 - kvnsw + 3 - DISKHIGHT + 1, + kvmsw[kvnsw].ksw_total); } diff --git a/usr.bin/systat/sysput.c b/usr.bin/systat/sysput.c index e089c5c2ff55..6e14f9eb752f 100644 --- a/usr.bin/systat/sysput.c +++ b/usr.bin/systat/sysput.c @@ -31,10 +31,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include +#include #include +#include +#include #include "systat.h" #include "extern.h" @@ -103,26 +104,9 @@ sysputwuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags) sysputuint64(wd, row, col, width, val, flags); } -static int -calc_page_shift() -{ - u_int page_size; - int shifts; - - shifts = 0; - GETSYSCTL("vm.stats.vm.v_page_size", page_size); - for(; page_size > 1; page_size >>= 1) - shifts++; - return shifts; -} - void sysputpage(WINDOW *wd, int row, int col, int width, uint64_t pages, int flags) { - static int shifts = 0; - if (shifts == 0) - shifts = calc_page_shift(); - pages <<= shifts; - sysputuint64(wd, row, col, width, pages, flags); + sysputuint64(wd, row, col, width, ptoa(pages), flags); } diff --git a/usr.bin/systat/systat.1 b/usr.bin/systat/systat.1 index 5ad8078a85a4..1f6ddaeafb1a 100644 --- a/usr.bin/systat/systat.1 +++ b/usr.bin/systat/systat.1 @@ -279,9 +279,11 @@ not display kilobytes per transaction). .El .It Ic swap Show information about swap space usage on all the -swap areas compiled into the kernel. -The first column is the device name of the partition. -The next column is the total space available in the partition. +swap areas compiled into the kernel and processes that are swapped out +as well as a summary of disk activity. +.Pp +The swap areas are displayed first with their name, sizes and +usage percentage. The .Ar Used column indicates the total blocks used so far; @@ -289,6 +291,28 @@ the graph shows the percentage of space in use on each partition. If there are more than one swap partition in use, a total line is also shown. Areas known to the kernel, but not in use are shown as not available. +.Pp +Below the swap space statistics, +processes are listed in order of higher swap area usage. +Pid, username, a part of command line, the total use of swap space +in bytes, the size of process, as well as per-process swap usage percentage and +per-system swap space percentage are shown per process. +.Pp +At the bottom left is the disk usage display. +It reports the number of +kilobytes per transaction, transactions per second, megabytes +per second and the percentage of the time the disk was busy averaged +over the refresh period of the display (by default, five seconds). +The system keeps statistics on most every storage device. +In general, up +to seven devices are displayed. +The devices displayed by default are the +first devices in the kernel's device list. +See +.Xr devstat 3 +and +.Xr devstat 9 +for details on the devstat system. .It Ic vmstat Take over the entire display and show a (rather crowded) compendium of statistics related to virtual memory usage, process scheduling, diff --git a/usr.bin/systat/systat.h b/usr.bin/systat/systat.h index 92233e058172..4ced36c32932 100644 --- a/usr.bin/systat/systat.h +++ b/usr.bin/systat/systat.h @@ -32,6 +32,7 @@ * $FreeBSD$ */ +#include #include struct cmdtab { @@ -72,3 +73,8 @@ extern int use_kvm; extern void putint(int, int, int, int); extern void putfloat(double, int, int, int, int, int); extern void putlongdouble(long double, int, int, int, int, int); + +int procinit(void); +void procgetinfo(void); +void proclabel(int col); +void procshow(int col, int hight, uint64_t totalswappages); From nobody Tue Oct 26 13:57:33 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9CC321826148; Tue, 26 Oct 2021 13:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdtgK3tR3z3QVP; Tue, 26 Oct 2021 13:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64BC41D56D; Tue, 26 Oct 2021 13:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QDvXIe045060; Tue, 26 Oct 2021 13:57:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QDvX43045059; Tue, 26 Oct 2021 13:57:33 GMT (envelope-from git) Date: Tue, 26 Oct 2021 13:57:33 GMT Message-Id: <202110261357.19QDvX43045059@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: c0cf36bc0210 - main - ncurses: rework static linker script generation List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c0cf36bc0210c4d74f626b944b4c7036cb01df5d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=c0cf36bc0210c4d74f626b944b4c7036cb01df5d commit c0cf36bc0210c4d74f626b944b4c7036cb01df5d Author: Baptiste Daroussin AuthorDate: 2021-10-26 10:02:00 +0000 Commit: Baptiste Daroussin CommitDate: 2021-10-26 13:57:29 +0000 ncurses: rework static linker script generation Rework the generation of the linker script to make it in par with ldscript, this also forces the regeneration of the .aldscript in the obj dir which might in the past have ended up empty. Tested by: manu --- lib/ncurses/ncurses/Makefile | 19 +++++++++---------- lib/ncurses/ncurses/libncursesw.aldscript | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile index 951e8a4ea63f..af733d3ac613 100644 --- a/lib/ncurses/ncurses/Makefile +++ b/lib/ncurses/ncurses/Makefile @@ -170,13 +170,12 @@ SYMLINKS+= libncursesw_p.a ${LIBDIR}/libcurses_p.a LIBADD+= tinfow SHLIB_LDSCRIPT= libncursesw.ldscript STATIC_LDSCRIPT= libncursesw.aldscript -CLEANFILES+= ${STATIC_LDSCRIPT} +CLEANFILES+= libncursesw.a -libncursesw.aldscript: - @${ECHO} "INPUT(-lncursesw_real -ltinfow)" >$@ - -libncurses.ldscript: - @${ECHO} "INPUT(${SHLIB_NAME} AS NEEDED(-ltinfow))" >$@ +libncursesw.a: ${.CURDIR}/${STATIC_LDSCRIPT} + sed -e 's,@@LIB@@,${LIB},g' \ + -e 's,@@STATICLIB_SUFFIX@@,${_STATICLIB_SUFFIX},g' \ + ${.ALLSRC} > ${.TARGET} lib_gen.c: MKlib_gen.sh ${.OBJDIR:H}/tinfo/curses.h ncurses_dll.h LC_ALL=C sh ${NCURSES_DIR}/ncurses/base/MKlib_gen.sh "${CPP:N${CCACHE_BIN}} ${CFLAGS}" \ @@ -185,13 +184,13 @@ lib_gen.c: MKlib_gen.sh ${.OBJDIR:H}/tinfo/curses.h ncurses_dll.h expanded.c: MKexpanded.sh sh ${NCURSES_DIR}/ncurses/tty/MKexpanded.sh "${CC:N${CCACHE_BIN}} -E" ${CFLAGS} >expanded.c -all: ${STATIC_LDSCRIPT} +all: ${STATIC_LDSCRIPT} libncursesw.a -install-aldscript: ${STATIC_LDSCRIPT} +install-libncursesw.a: libncursesw.a ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${_INSTALLFLAGS} ${STATIC_LDSCRIPT} ${DESTDIR}${_LIBDIR}/lib${LIB}.a + ${_INSTALLFLAGS} libncursesw.a ${DESTDIR}${_LIBDIR}/lib${LIB}.a -realinstall: install-aldscript +realinstall: install-libncursesw.a .include diff --git a/lib/ncurses/ncurses/libncursesw.aldscript b/lib/ncurses/ncurses/libncursesw.aldscript new file mode 100644 index 000000000000..337995f095c8 --- /dev/null +++ b/lib/ncurses/ncurses/libncursesw.aldscript @@ -0,0 +1 @@ +INPUT(-l@@LIB@@@@STATICLIB_SUFFIX@@ -ltinfow) From nobody Tue Oct 26 14:01:02 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A8FBD182646A; Tue, 26 Oct 2021 14:01:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdtlL4NZqz3R3F; Tue, 26 Oct 2021 14:01:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 766871DD40; Tue, 26 Oct 2021 14:01:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QE12Ut056862; Tue, 26 Oct 2021 14:01:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QE12HX056861; Tue, 26 Oct 2021 14:01:02 GMT (envelope-from git) Date: Tue, 26 Oct 2021 14:01:02 GMT Message-Id: <202110261401.19QE12HX056861@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 426682b05a4c - main - bpf: Fix the write filter for detached descriptors List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 426682b05a4cf700c20d503516bfa07c043fecf8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=426682b05a4cf700c20d503516bfa07c043fecf8 commit 426682b05a4cf700c20d503516bfa07c043fecf8 Author: Mark Johnston AuthorDate: 2021-10-26 13:57:27 +0000 Commit: Mark Johnston CommitDate: 2021-10-26 14:00:39 +0000 bpf: Fix the write filter for detached descriptors A BPF descriptor only has an associated interface descriptor once it is attached to an interface, e.g., with BIOCSETIF. Avoid dereferencing a NULL pointer in filt_bpfwrite() if the BPF descriptor is not attached. Reviewed by: ae Reported by: syzbot+ae45d5166afe15a5a21d@syzkaller.appspotmail.com Fixes: ded77e0237a8 ("Allow the BPF to be select for write.") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32561 --- lib/libc/sys/kqueue.2 | 4 ++-- sys/net/bpf.c | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index 68929e973dc0..afa1dc5dcb4a 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -390,8 +390,8 @@ For eventfds, will contain the maximum value that can be added to the counter without blocking. .Pp -For BPF devices, the filter always indicates that it is possible to -write and +For BPF devices, when the descriptor is attached to an interface the filter +always indicates that it is possible to write and .Va data will contain the MTU size of the underlying interface. .It Dv EVFILT_EMPTY diff --git a/sys/net/bpf.c b/sys/net/bpf.c index ce7aba5a9bcd..b229dd81b127 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -763,6 +763,10 @@ bpf_attachd(struct bpf_d *d, struct bpf_if *bp) CK_LIST_INSERT_HEAD(&bp->bif_dlist, d, bd_next); reset_d(d); + + /* Trigger EVFILT_WRITE events. */ + bpf_wakeup(d); + BPFD_UNLOCK(d); bpf_bpfd_cnt++; @@ -2229,11 +2233,16 @@ static int filt_bpfwrite(struct knote *kn, long hint) { struct bpf_d *d = (struct bpf_d *)kn->kn_hook; - BPFD_LOCK_ASSERT(d); - kn->kn_data = d->bd_bif->bif_ifp->if_mtu; + BPFD_LOCK_ASSERT(d); - return (1); + if (d->bd_bif == NULL) { + kn->kn_data = 0; + return (0); + } else { + kn->kn_data = d->bd_bif->bif_ifp->if_mtu; + return (1); + } } #define BPF_TSTAMP_NONE 0 From nobody Tue Oct 26 14:50:22 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 14F84181D8B8; Tue, 26 Oct 2021 14:50:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdvrG749Zz4RxP; Tue, 26 Oct 2021 14:50:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D3DED1EA8B; Tue, 26 Oct 2021 14:50:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QEoMXN020434; Tue, 26 Oct 2021 14:50:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QEoMqo020433; Tue, 26 Oct 2021 14:50:22 GMT (envelope-from git) Date: Tue, 26 Oct 2021 14:50:22 GMT Message-Id: <202110261450.19QEoMqo020433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: fcfa64801a4f - main - sh: Set PATH envvar after setting HOME in dotfile List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fcfa64801a4fe836ff481465ea068e791aa4ce6a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=fcfa64801a4fe836ff481465ea068e791aa4ce6a commit fcfa64801a4fe836ff481465ea068e791aa4ce6a Author: Ka Ho Ng AuthorDate: 2021-10-26 14:48:57 +0000 Commit: Ka Ho Ng CommitDate: 2021-10-26 14:50:09 +0000 sh: Set PATH envvar after setting HOME in dotfile In single-user mode, all env vars are absent, so exptilde() would not be able to expand ~ correctly. Place the lines setting PATH below HOME, so exptilde() would work as expected. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: jilles, emaste Differential Revision: https://reviews.freebsd.org/D27003 --- bin/sh/dot.profile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/sh/dot.profile b/bin/sh/dot.profile index fd0c43fdb927..e296a360bcc7 100644 --- a/bin/sh/dot.profile +++ b/bin/sh/dot.profile @@ -1,9 +1,9 @@ # $FreeBSD$ # -PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin -export PATH HOME=/root export HOME +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin +export PATH TERM=${TERM:-xterm} export TERM PAGER=less From nobody Tue Oct 26 15:00:22 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DDD131821852; Tue, 26 Oct 2021 15:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hdw3p5xkwz4V5f; Tue, 26 Oct 2021 15:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABF551E762; Tue, 26 Oct 2021 15:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QF0MRi035040; Tue, 26 Oct 2021 15:00:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QF0MVn035039; Tue, 26 Oct 2021 15:00:22 GMT (envelope-from git) Date: Tue, 26 Oct 2021 15:00:22 GMT Message-Id: <202110261500.19QF0MVn035039@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wolfram Schneider Subject: git: 8019068d7c30 - main - /etc/periodic/weekly/310.locate must read /etc/locate.rc List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wosch X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8019068d7c30e45ad392669a6577e5f1db56421d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=8019068d7c30e45ad392669a6577e5f1db56421d commit 8019068d7c30e45ad392669a6577e5f1db56421d Author: Wolfram Schneider AuthorDate: 2021-10-26 14:59:39 +0000 Commit: Wolfram Schneider CommitDate: 2021-10-26 14:59:39 +0000 /etc/periodic/weekly/310.locate must read /etc/locate.rc PR: 160225 Reported by: Hiroaki Abe Reviewed by: se Approved by: se Differential Revision: https://reviews.freebsd.org/D32646 --- usr.sbin/periodic/etc/weekly/310.locate | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/periodic/etc/weekly/310.locate b/usr.sbin/periodic/etc/weekly/310.locate index 4079f5e8287e..b7481965444a 100755 --- a/usr.sbin/periodic/etc/weekly/310.locate +++ b/usr.sbin/periodic/etc/weekly/310.locate @@ -16,7 +16,9 @@ case "$weekly_locate_enable" in echo "" echo "Rebuilding locate database:" - locdb=/var/db/locate.database + . /etc/locate.rc + : ${FCODES:="/var/db/locate.database"} + locdb="$FCODES" touch $locdb && rc=0 || rc=3 chown nobody $locdb || rc=3 From nobody Tue Oct 26 15:32:08 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C5173182F501 for ; Tue, 26 Oct 2021 15:32:11 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2p.ore.mailhop.org (outbound2p.ore.mailhop.org [54.187.218.212]) (using TLSv1.3 with cipher TLS_AES_256_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 4HdwmW3wCFz4gVQ for ; Tue, 26 Oct 2021 15:32:11 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1635262330; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=uB19c58GPvwrmlIny4Er4C8JZG/nM/nTzZzLSQ2JaIF8OGA4DNR0Wt0id7r0IIbDxj4sAuLqUnbG2 PTYLboRzFM5yNVE960aUG6ZGmj781Zh489FYaBmz5QEzEJDpRM47TM1zfUPc0YoM/JHgAsHWn6OXNF x3xNrzeGAlzMlwZPlf/sB5seL/AYUvZRJM86xH/t+BRPnclPaTmN0D4jB7azta9B7jdDLBCOQZYtjX Z62SDJDTUTjjPVnX59+aC/d0VT2LTmUldw6IaN7kUvY0V95YrHDrcd5I7YhieBn0mPjkI5ASPlfSV1 QMmZlVoJMTL78lAb7PcsqTFNhIUSlSw== 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=kHp+/AgMnjXQKao+/n8p1lIkkn2C5jObzK8/isesJuo=; b=e1dZrXkmyEZIEPRhorrBsbj8bAyYAlEwWvTAdeHLwP0w8YflZDXVMtngVDIoDW8PJpdICJFBt1ogV LhKQrwHdoFKlVVbQBeltvP5hKZPlFlDkcy91ottZVgZhy3FDc4/l8goOaEi5MB6NNN7w7XmHXNJAl5 iRAvlCVmSLJs4fC+6KIG/1FTtFMomG0mi+Jkdl4xCUo89HP7eQDIbaBh0Qp8aeyqcdkmmzBspnovRH MdJzOs8sux5lbt3DJM7stwGvXozILDQc7xED85wXnODXiQqoUQAv8mTOLB3IfPDwIdwU+j2IPbB4VM pQ59K9odqFiWosqgrnQOiWNr3DLMOIw== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=24.8.225.114; 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=kHp+/AgMnjXQKao+/n8p1lIkkn2C5jObzK8/isesJuo=; b=ws1jSO2sG+gmllyuGgLcACAqIkOUCf5qAdWkh/br7sbtsYeVv14tip6EfwnZOQ0tM8ZWIgSjJuxcd RZgPLNThWVL83f1+/R4G6kN9iHFuapdvdglspm+p/borfh2Ok30ar1FF2u2SF6nI7lNBk0/Dcx5Muz LMIuWZJDggo/b9UyhuLOeXsJoOPTxQ5PJxYKg6fVa2Qtc6kodCA3t+RW9+a9kbVphyvrJEq21qv6Jx hKVsraK6DfrZNjA7DWpz+tplhqa75rjUIkhpX4xVXb/30/tcoH0X51HdwKnujAdj5ATShYlC2hZzup 8zdUSx7tAUeSw+G8DfBGpsTCaPhw7jQ== X-Originating-IP: 24.8.225.114 X-MHO-RoutePath: aGlwcGll X-MHO-User: e1bebaea-3671-11ec-a67c-89389772cfc7 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-24-8-225-114.hsd1.co.comcast.net [24.8.225.114]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id e1bebaea-3671-11ec-a67c-89389772cfc7; Tue, 26 Oct 2021 15:32:09 +0000 (UTC) Received: from [172.22.42.84] (rev2.hippie.lan [172.22.42.84]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 19QFW86v001129; Tue, 26 Oct 2021 09:32:08 -0600 (MDT) (envelope-from ian@freebsd.org) X-Authentication-Warning: paranoia.hippie.lan: Host rev2.hippie.lan [172.22.42.84] claimed to be [172.22.42.84] Message-ID: <57f6f877de121954935225fba9874a39b6b768c4.camel@freebsd.org> Subject: Re: git: fcfa64801a4f - main - sh: Set PATH envvar after setting HOME in dotfile From: Ian Lepore To: Ka Ho Ng , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Date: Tue, 26 Oct 2021 09:32:08 -0600 In-Reply-To: <202110261450.19QEoMqo020433@gitrepo.freebsd.org> References: <202110261450.19QEoMqo020433@gitrepo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.3 FreeBSD GNOME Team List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4HdwmW3wCFz4gVQ X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Tue, 2021-10-26 at 14:50 +0000, Ka Ho Ng wrote: > The branch main has been updated by khng: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=fcfa64801a4fe836ff481465ea068e791aa4ce6a > > commit fcfa64801a4fe836ff481465ea068e791aa4ce6a > Author:     Ka Ho Ng > AuthorDate: 2021-10-26 14:48:57 +0000 > Commit:     Ka Ho Ng > CommitDate: 2021-10-26 14:50:09 +0000 > >     sh: Set PATH envvar after setting HOME in dotfile >     >     In single-user mode, all env vars are absent, so exptilde() would > not be >     able to expand ~ correctly. >     Place the lines setting PATH below HOME, so exptilde() would work > as >     expected. >     >     Sponsored by:   The FreeBSD Foundation >     MFC after:      3 days >     Reviewed by:    jilles, emaste >     Differential Revision:  https://reviews.freebsd.org/D27003 > --- >  bin/sh/dot.profile | 4 ++-- >  1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/bin/sh/dot.profile b/bin/sh/dot.profile > index fd0c43fdb927..e296a360bcc7 100644 > --- a/bin/sh/dot.profile > +++ b/bin/sh/dot.profile > @@ -1,9 +1,9 @@ >  # $FreeBSD$ >  # > - > PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bi > n > -export PATH >  HOME=/root >  export HOME > +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/ > bin > +export PATH >  TERM=${TERM:-xterm} >  export TERM >  PAGER=less I've always been curious whether there's a reason we seem to favor VAR=value export VAR over the more compact form export VAR=value -- Ian From nobody Tue Oct 26 15:40:54 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6F6AD1812A6A; Tue, 26 Oct 2021 15:41:04 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta001.cacentral1.a.cloudfilter.net (omta001.cacentral1.a.cloudfilter.net [3.97.99.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hdwym1zvGz4jll; Tue, 26 Oct 2021 15:41:04 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from shw-obgw-4002a.ext.cloudfilter.net ([10.228.9.250]) by cmsmtp with ESMTP id fNMTmGwXdczbLfOZOmFtuX; Tue, 26 Oct 2021 15:40:58 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id fOZMm63FfgxGifOZNmMH7l; Tue, 26 Oct 2021 15:40:58 +0000 X-Authority-Analysis: v=2.4 cv=SqLzVNC0 c=1 sm=1 tr=0 ts=6178218a a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=8nJEP1OIZ-IA:10 a=8gfv0ekSlNoA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=YsaGJC6E6cbuPZDk6JEA:9 a=wPNLvfGTeEIA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 27C97235; Tue, 26 Oct 2021 08:40:54 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 19QFesnX010998; Tue, 26 Oct 2021 08:40:54 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202110261540.19QFesnX010998@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: Ian Lepore cc: Ka Ho Ng , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: fcfa64801a4f - main - sh: Set PATH envvar after setting HOME in dotfile In-reply-to: <57f6f877de121954935225fba9874a39b6b768c4.camel@freebsd.org> References: <202110261450.19QEoMqo020433@gitrepo.freebsd.org> <57f6f877de121954935225fba9874a39b6b768c4.camel@freebsd.org> Comments: In-reply-to Ian Lepore message dated "Tue, 26 Oct 2021 09:32:08 -0600." List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Tue, 26 Oct 2021 08:40:54 -0700 X-CMAE-Envelope: MS4xfFFkl28w9kA0LCDIT6qctugGNREApuFoXq2GA8GVKAI7u4VBlVF6CIHNdsPXnOKEFPr7nzeuzyz6Xx6ki6h1jpb9pbqUO4rW6v+dBMDH8slTyE/Fi8Z9 P0v+nH7oKlCP9HYhnkdO3swIn5lTNLcdWHDOCgWWhDyF8gYqbLGQCrdYIDYNat0PZYzZmhoMsqHWsoE/MwHTwLzfN/z+hjRXhg1EfvSqXYg6wI6HXngOVL5J JceVpbUk7KPRh9esZC198szdpk7xaEwZBUpjw1Ml7VoDMk89ARAH3uwriQx19Fa/vMxQ9W3xnxVDBvNdM4gfZZGGVupZDi34r/8jtlyvmYzKw1BLvHJNFSBV K/JfwC2I X-Rspamd-Queue-Id: 4Hdwym1zvGz4jll X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N In message <57f6f877de121954935225fba9874a39b6b768c4.camel@freebsd.org>, Ian Le pore writes: > On Tue, 2021-10-26 at 14:50 +0000, Ka Ho Ng wrote: > > The branch main has been updated by khng: > > > > URL: > > https://cgit.FreeBSD.org/src/commit/?id=fcfa64801a4fe836ff481465ea068e791aa > 4ce6a > > > > commit fcfa64801a4fe836ff481465ea068e791aa4ce6a > > Author:     Ka Ho Ng > > AuthorDate: 2021-10-26 14:48:57 +0000 > > Commit:     Ka Ho Ng > > CommitDate: 2021-10-26 14:50:09 +0000 > > > >     sh: Set PATH envvar after setting HOME in dotfile > >     > >     In single-user mode, all env vars are absent, so exptilde() would > > not be > >     able to expand ~ correctly. > >     Place the lines setting PATH below HOME, so exptilde() would work > > as > >     expected. > >     > >     Sponsored by:   The FreeBSD Foundation > >     MFC after:      3 days > >     Reviewed by:    jilles, emaste > >     Differential Revision:  https://reviews.freebsd.org/D27003 > > --- > >  bin/sh/dot.profile | 4 ++-- > >  1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/bin/sh/dot.profile b/bin/sh/dot.profile > > index fd0c43fdb927..e296a360bcc7 100644 > > --- a/bin/sh/dot.profile > > +++ b/bin/sh/dot.profile > > @@ -1,9 +1,9 @@ > >  # $FreeBSD$ > >  # > > - > > PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bi > > n > > -export PATH > >  HOME=/root > >  export HOME > > +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/ > > bin > > +export PATH > >  TERM=${TERM:-xterm} > >  export TERM > >  PAGER=less > > I've always been curious whether there's a reason we seem to favor > > VAR=value > export VAR > > over the more compact form > > export VAR=value Older Bourne shells don't support export VAR=value. This gives the user greater flexibility to choose an older shell as their login shell. -- 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 nobody Tue Oct 26 16:24:50 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9E1CE1826106; Tue, 26 Oct 2021 16:24:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HdxxG41bQz3CsM; Tue, 26 Oct 2021 16:24:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 69C491FD4A; Tue, 26 Oct 2021 16:24:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QGOo4s045533; Tue, 26 Oct 2021 16:24:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QGOo3F045532; Tue, 26 Oct 2021 16:24:50 GMT (envelope-from git) Date: Tue, 26 Oct 2021 16:24:50 GMT Message-Id: <202110261624.19QGOo3F045532@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: bb4c691299c5 - main - lualoader: fix the autoboot_delay countdown message List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb4c691299c5d699cea29e18fef96bda1cef13da Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=bb4c691299c5d699cea29e18fef96bda1cef13da commit bb4c691299c5d699cea29e18fef96bda1cef13da Author: Katsuyuki Miyoshi AuthorDate: 2021-10-26 16:21:34 +0000 Commit: Kyle Evans CommitDate: 2021-10-26 16:24:29 +0000 lualoader: fix the autoboot_delay countdown message When the timer drops from double to single digits, a spare 'e' is left on the end of the line as we don't overwrite it. Include an extra space at the end to account for this and overwrite the leftover character. PR: 259429 MFC after: 3 days Reviewed by: emaste --- stand/lua/menu.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua index d1e1ee012834..f1a4f07a8d73 100644 --- a/stand/lua/menu.lua +++ b/stand/lua/menu.lua @@ -522,7 +522,7 @@ function menu.autoboot(delay) last = time screen.setcursor(x, y) print("Autoboot in " .. time .. - " seconds. [Space] to pause") + " seconds. [Space] to pause ") screen.defcursor() end if io.ischar() then From nobody Tue Oct 26 17:19:46 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B3BD71812D53; Tue, 26 Oct 2021 17:19:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hdz8f4nCLz3jCr; Tue, 26 Oct 2021 17:19:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 85943206FD; Tue, 26 Oct 2021 17:19:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QHJkQv012218; Tue, 26 Oct 2021 17:19:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QHJkmN012217; Tue, 26 Oct 2021 17:19:46 GMT (envelope-from git) Date: Tue, 26 Oct 2021 17:19:46 GMT Message-Id: <202110261719.19QHJkmN012217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: 12752978d32b - main - tcp: The rack stack can incorrectly have an overflow when calculating a burst delay. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 12752978d32b440f7cc79a9dfb539b5bf42620af Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=12752978d32b440f7cc79a9dfb539b5bf42620af commit 12752978d32b440f7cc79a9dfb539b5bf42620af Author: Randall Stewart AuthorDate: 2021-10-26 17:17:58 +0000 Commit: Randall Stewart CommitDate: 2021-10-26 17:17:58 +0000 tcp: The rack stack can incorrectly have an overflow when calculating a burst delay. If the congestion window is very large the fact that we multiply it by 1000 (for microseconds) can cause the uint32_t to overflow and we incorrectly calculate a very small divisor. This will then cause the burst timer to be very large when it should be 0. Instead lets make the three variables uint64_t and avoid the issue. Reviewed by: Michael Tuexen Sponsored by: Netflix Inc. Differential Revision: https://reviews.freebsd.org/D32668 --- sys/netinet/tcp_stacks/rack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 059c7d26d81e..eee7db6e7a4c 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -14909,6 +14909,7 @@ pace_to_fill_cwnd(struct tcp_rack *rack, int32_t slot, uint32_t len, uint32_t se static int32_t rack_get_pacing_delay(struct tcp_rack *rack, struct tcpcb *tp, uint32_t len, struct rack_sendmap *rsm, uint32_t segsiz) { + uint64_t srtt; int32_t slot = 0; int can_start_hw_pacing = 1; int err; @@ -14921,7 +14922,7 @@ rack_get_pacing_delay(struct tcp_rack *rack, struct tcpcb *tp, uint32_t len, str * quicker then possible. But thats ok we don't want * the peer to have a gap in data sending. */ - uint32_t srtt, cwnd, tr_perms = 0; + uint64_t cwnd, tr_perms = 0; int32_t reduce = 0; old_method: @@ -14971,7 +14972,7 @@ rack_get_pacing_delay(struct tcp_rack *rack, struct tcpcb *tp, uint32_t len, str rack_log_pacing_delay_calc(rack, len, slot, tr_perms, reduce, 0, 7, __LINE__, NULL, 0); } else { uint64_t bw_est, res, lentim, rate_wanted; - uint32_t orig_val, srtt, segs, oh; + uint32_t orig_val, segs, oh; int capped = 0; int prev_fill; @@ -15196,7 +15197,7 @@ done_w_hdwr: srtt = rack->rc_tp->t_srtt; else srtt = RACK_INITIAL_RTO * HPTS_USEC_IN_MSEC; /* its in ms convert */ - if (srtt < slot) { + if (srtt < (uint64_t)slot) { rack_log_pacing_delay_calc(rack, srtt, slot, rate_wanted, bw_est, lentim, 99, __LINE__, NULL, 0); slot = srtt; } From nobody Tue Oct 26 20:17:55 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E1EA518120D4; Tue, 26 Oct 2021 20:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf36C62WCz3DR9; Tue, 26 Oct 2021 20:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AEBFE228FA; Tue, 26 Oct 2021 20:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QKHtMY051756; Tue, 26 Oct 2021 20:17:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QKHta1051755; Tue, 26 Oct 2021 20:17:55 GMT (envelope-from git) Date: Tue, 26 Oct 2021 20:17:55 GMT Message-Id: <202110262017.19QKHta1051755@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 48cb3fee2586 - main - Retire obsolete iscsi_initiator(4) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 48cb3fee25862a6adc10fe0b2c2dc15c7fd7fd9e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=48cb3fee25862a6adc10fe0b2c2dc15c7fd7fd9e commit 48cb3fee25862a6adc10fe0b2c2dc15c7fd7fd9e Author: Ed Maste AuthorDate: 2021-10-26 17:24:30 +0000 Commit: Ed Maste CommitDate: 2021-10-26 20:17:35 +0000 Retire obsolete iscsi_initiator(4) The new iSCSI initiator iscsi(4) was introduced with FreeBSD 10.0, and the old intiator was marked obsolete shortly thereafter (in commit d32789d95cfbf, MFC'd to stable/10 in ba54910169c4). Remove it now. Reviewed by: jhb, mav Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32673 --- ObsoleteFiles.inc | 5 + sbin/Makefile | 1 - sbin/iscontrol/Makefile | 14 - sbin/iscontrol/Makefile.depend | 21 - sbin/iscontrol/auth_subr.c | 206 ----- sbin/iscontrol/config.c | 382 --------- sbin/iscontrol/fsm.c | 759 ------------------ sbin/iscontrol/iscontrol.8 | 141 ---- sbin/iscontrol/iscontrol.c | 264 ------- sbin/iscontrol/iscontrol.h | 167 ---- sbin/iscontrol/login.c | 442 ----------- sbin/iscontrol/misc.c | 228 ------ sbin/iscontrol/pdu.c | 178 ----- share/man/man4/Makefile | 1 - share/man/man4/iscsi_initiator.4 | 118 --- sys/conf/NOTES | 1 - sys/conf/files | 6 - sys/dev/iscsi_initiator/isc_cam.c | 351 -------- sys/dev/iscsi_initiator/isc_sm.c | 750 ------------------ sys/dev/iscsi_initiator/isc_soc.c | 680 ---------------- sys/dev/iscsi_initiator/isc_subr.c | 184 ----- sys/dev/iscsi_initiator/iscsi.c | 880 --------------------- sys/dev/iscsi_initiator/iscsi.h | 502 ------------ sys/dev/iscsi_initiator/iscsi_subr.c | 603 -------------- sys/dev/iscsi_initiator/iscsivar.h | 571 ------------- sys/modules/Makefile | 1 - sys/modules/iscsi_initiator/Makefile | 14 - targets/pseudo/userland/Makefile.depend | 1 - tools/build/mk/OptionalObsoleteFiles.inc | 3 - .../kerneldoc/subsys/Doxyfile-dev_iscsi_initiator | 21 - usr.bin/iscsictl/iscsi.conf.5 | 5 +- usr.bin/iscsictl/iscsictl.8 | 15 - 32 files changed, 6 insertions(+), 7509 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index b6a2d299bc8c..c60629197386 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -40,6 +40,11 @@ # xargs -n1 | sort | uniq -d; # done +# 20211026: retire obsolete iscsi initiator +OLD_FILES+=sbin/iscontrol +OLD_FILES+=usr/share/man/man4/iscsi_initiator.4.gz +OLD_FILES+=usr/share/man/man8/iscontrol.8.gz + # 20211022 OLD_FILES+=sbin/spppcontrol .if ${TARGET_ARCH} == "i386" diff --git a/sbin/Makefile b/sbin/Makefile index b4da58680458..7eb497e3e3dd 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -76,7 +76,6 @@ SUBDIR.${MK_INET6}+= rtsol SUBDIR.${MK_IPFILTER}+= ipf SUBDIR.${MK_IPFW}+= ipfw SUBDIR.${MK_IPFW}+= natd -SUBDIR.${MK_ISCSI}+= iscontrol SUBDIR.${MK_NVME}+= nvmecontrol SUBDIR.${MK_OPENSSL}+= decryptcore SUBDIR.${MK_PF}+= pfctl diff --git a/sbin/iscontrol/Makefile b/sbin/iscontrol/Makefile deleted file mode 100644 index 613444a468f4..000000000000 --- a/sbin/iscontrol/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -PACKAGE=iscsilegacy -SRCS= iscontrol.c pdu.c fsm.c config.c login.c auth_subr.c misc.c -PROG= iscontrol -LIBADD= cam md -S= ${SRCTOP}/sys - -WARNS?= 3 -CFLAGS+= -I$S - -MAN= iscontrol.8 - -.include diff --git a/sbin/iscontrol/Makefile.depend b/sbin/iscontrol/Makefile.depend deleted file mode 100644 index c800a3df77c3..000000000000 --- a/sbin/iscontrol/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcam \ - lib/libcompiler_rt \ - lib/libmd \ - lib/libsbuf \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/sbin/iscontrol/auth_subr.c b/sbin/iscontrol/auth_subr.c deleted file mode 100644 index a4c17ba20868..000000000000 --- a/sbin/iscontrol/auth_subr.c +++ /dev/null @@ -1,206 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005-2010 Daniel Braniss - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* - | $Id: auth_subr.c,v 2.2 2007/06/01 08:09:37 danny Exp $ - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include "iscontrol.h" - -static int -chapMD5(char id, char *cp, char *chapSecret, unsigned char *digest) -{ - MD5_CTX ctx; - char *tmp; - int len; - - debug_called(3); - - MD5Init(&ctx); - - MD5Update(&ctx, &id, 1); - - if((len = str2bin(chapSecret, &tmp)) == 0) { - // print error - return -1; - } - MD5Update(&ctx, tmp, len); - free(tmp); - - if((len = str2bin(cp, &tmp)) == 0) { - // print error - return -1; - } - MD5Update(&ctx, tmp, len); - free(tmp); - - MD5Final(digest, &ctx); - - - return 0; -} - -static int -chapSHA1(char id, char *cp, char *chapSecret, unsigned char *digest) -{ - SHA1_CTX ctx; - char *tmp; - int len; - - debug_called(3); - - SHA1_Init(&ctx); - - SHA1_Update(&ctx, &id, 1); - - if((len = str2bin(chapSecret, &tmp)) == 0) { - // print error - return -1; - } - SHA1_Update(&ctx, tmp, len); - free(tmp); - - if((len = str2bin(cp, &tmp)) == 0) { - // print error - return -1; - } - SHA1_Update(&ctx, tmp, len); - free(tmp); - - SHA1_Final(digest, &ctx); - - return 0; - -} -/* - | the input text format can be anything that the rfc3270 defines - | (see section 5.1 and str2bin) - | digest length for md5 is 128bits, and for sha1 is 160bits. - | digest is an ASCII string which represents the bits in - | hexadecimal or base64 according to the challenge(cp) format - */ -char * -chapDigest(char *ap, char id, char *cp, char *chapSecret) -{ - int len; - unsigned char digest[20]; - char encoding[3]; - - debug_called(3); - - len = 0; - if(strcmp(ap, "5") == 0 && chapMD5(id, cp, chapSecret, digest) == 0) - len = 16; - else - if(strcmp(ap, "7") == 0 && chapSHA1(id, cp, chapSecret, digest) == 0) - len = 20; - - if(len) { - sprintf(encoding, "%.2s", cp); - return bin2str(encoding, digest, len); - } - - return NULL; -} - -char * -genChapChallenge(char *encoding, uint len) -{ - int fd; - unsigned char tmp[1024]; - - if(len > sizeof(tmp)) - return NULL; - - if((fd = open("/dev/random", O_RDONLY)) != -1) { - read(fd, tmp, len); - close(fd); - return bin2str(encoding, tmp, len); - } - perror("/dev/random"); - // make up something ... - return NULL; -} - -#ifdef TEST_AUTH -static void -puke(char *str, unsigned char *dg, int len) -{ - printf("%3d] %s\n 0x", len, str); - while(len-- > 0) - printf("%02x", *dg++); - printf("\n"); -} - -main(int cc, char **vv) -{ - char *p, *ap, *ip, *cp, *chapSecret, *digest; - int len; - -#if 0 - ap = "5"; - chapSecret = "0xa5aff013dd839b1edd31ee73a1df0b1b"; -// chapSecret = "abcdefghijklmnop"; - len = str2bin(chapSecret, &cp); - puke(chapSecret, cp, len); - - ip = "238"; - cp = "0xbd456029"; - - - if((digest = chapDigest(ap, ip, cp, chapSecret)) != NULL) { - len = str2bin(digest, &cp); - puke(digest, cp, len); - } -#else - printf("%d] %s\n", 24, genChallenge("0X", 24)); -#endif -} -#endif diff --git a/sbin/iscontrol/config.c b/sbin/iscontrol/config.c deleted file mode 100644 index 2fe44512f311..000000000000 --- a/sbin/iscontrol/config.c +++ /dev/null @@ -1,382 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005-2009 Daniel Braniss - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/* - | $Id: config.c,v 2.1 2006/11/12 08:06:51 danny Exp danny $ - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "iscontrol.h" - -/* - | ints - */ -#define OPT_port 1 -#define OPT_tags 2 - -#define OPT_maxConnections 3 -#define OPT_maxRecvDataSegmentLength 4 -#define OPT_maxXmitDataSegmentLength 5 -#define OPT_maxBurstLength 6 -#define OPT_firstBurstLength 7 -#define OPT_defaultTime2Wait 8 -#define OPT_defaultTime2Retain 9 -#define OPT_maxOutstandingR2T 10 -#define OPT_errorRecoveryLevel 11 -#define OPT_targetPortalGroupTag 12 -#define OPT_headerDigest 13 -#define OPT_dataDigest 14 -/* - | Booleans - */ -#define OPT_initialR2T 16 -#define OPT_immediateData 17 -#define OPT_dataPDUInOrder 18 -#define OPT_dataSequenceInOrder 19 -/* - | strings - */ -#define OPT_sessionType 15 - -#define OPT_targetAddress 21 -#define OPT_targetAlias 22 -#define OPT_targetName 23 -#define OPT_initiatorName 24 -#define OPT_initiatorAlias 25 -#define OPT_authMethod 26 - -#define OPT_chapSecret 27 -#define OPT_chapIName 28 -#define OPT_chapDigest 29 -#define OPT_tgtChapName 30 -#define OPT_tgtChapSecret 31 -#define OPT_tgtChallengeLen 32 -/* - | private - */ -#define OPT_maxluns 33 -#define OPT_iqn 34 -#define OPT_sockbufsize 35 - -/* - | sentinel - */ -#define OPT_end 0 - -#define _OFF(v) ((int)&((isc_opt_t *)NULL)->v) -#define _E(u, s, v) {.usage=u, .scope=s, .name=#v, .tokenID=OPT_##v} - -textkey_t keyMap[] = { - _E(U_PR, S_PR, port), - _E(U_PR, S_PR, tags), - _E(U_PR, S_PR, maxluns), - _E(U_PR, S_PR, sockbufsize), - - _E(U_PR, S_PR, iqn), - _E(U_PR, S_PR, chapSecret), - _E(U_PR, S_PR, chapIName), - _E(U_PR, S_PR, chapDigest), - _E(U_PR, S_PR, tgtChapName), - _E(U_PR, S_PR, tgtChapSecret), - _E(U_PR, S_PR, tgtChallengeLen), - - _E(U_IO, S_CO, headerDigest), - _E(U_IO, S_CO, dataDigest), - - _E(U_IO, S_CO, authMethod), - - _E(U_LO, S_SW, maxConnections), - _E(U_IO, S_SW, targetName), - - _E(U_IO, S_SW, initiatorName), - _E(U_ALL,S_SW, targetAlias), - _E(U_ALL,S_SW, initiatorAlias), - _E(U_ALL,S_SW, targetAddress), - - _E(U_ALL,S_SW, targetPortalGroupTag), - - _E(U_LO, S_SW, initialR2T), - _E(U_LO, S_SW, immediateData), - - _E(U_ALL,S_CO, maxRecvDataSegmentLength), - _E(U_ALL,S_CO, maxXmitDataSegmentLength), - - _E(U_LO, S_SW, maxBurstLength), - _E(U_LO, S_SW, firstBurstLength), - _E(U_LO, S_SW, defaultTime2Wait), - _E(U_LO, S_SW, defaultTime2Retain), - - _E(U_LO, S_SW, maxOutstandingR2T), - _E(U_LO, S_SW, dataPDUInOrder), - _E(U_LO, S_SW, dataSequenceInOrder), - - _E(U_LO, S_SW, errorRecoveryLevel), - - _E(U_LO, S_SW, sessionType), - - _E(0, 0, end) -}; - -#define _OPT_INT(w) strtol((char *)w, NULL, 0) -#define _OPT_STR(w) (char *)(w) - -static __inline int -_OPT_BOOL(char *w) -{ - if(isalpha((unsigned char)*w)) - return strcasecmp(w, "TRUE") == 0; - else - return _OPT_INT(w); -} - -#define _CASE(k, v) case OPT_##k: op->k = v; break -static void -setOption(isc_opt_t *op, int which, void *rval) -{ - switch(which) { - _CASE(port, _OPT_INT(rval)); - _CASE(tags, _OPT_INT(rval)); - _CASE(maxluns, _OPT_INT(rval)); - _CASE(iqn, _OPT_STR(rval)); - _CASE(sockbufsize, _OPT_INT(rval)); - - _CASE(maxConnections, _OPT_INT(rval)); - _CASE(maxRecvDataSegmentLength, _OPT_INT(rval)); - _CASE(maxXmitDataSegmentLength, _OPT_INT(rval)); - _CASE(maxBurstLength, _OPT_INT(rval)); - _CASE(firstBurstLength, _OPT_INT(rval)); - _CASE(defaultTime2Wait, _OPT_INT(rval)); - _CASE(defaultTime2Retain, _OPT_INT(rval)); - _CASE(maxOutstandingR2T, _OPT_INT(rval)); - _CASE(errorRecoveryLevel, _OPT_INT(rval)); - _CASE(targetPortalGroupTag, _OPT_INT(rval)); - _CASE(headerDigest, _OPT_STR(rval)); - _CASE(dataDigest, _OPT_STR(rval)); - - _CASE(targetAddress, _OPT_STR(rval)); - _CASE(targetAlias, _OPT_STR(rval)); - _CASE(targetName, _OPT_STR(rval)); - _CASE(initiatorName, _OPT_STR(rval)); - _CASE(initiatorAlias, _OPT_STR(rval)); - _CASE(authMethod, _OPT_STR(rval)); - _CASE(chapSecret, _OPT_STR(rval)); - _CASE(chapIName, _OPT_STR(rval)); - _CASE(chapDigest, _OPT_STR(rval)); - - _CASE(tgtChapName, _OPT_STR(rval)); - _CASE(tgtChapSecret, _OPT_STR(rval)); - - _CASE(initialR2T, _OPT_BOOL(rval)); - _CASE(immediateData, _OPT_BOOL(rval)); - _CASE(dataPDUInOrder, _OPT_BOOL(rval)); - _CASE(dataSequenceInOrder, _OPT_BOOL(rval)); - } -} - -static char * -get_line(FILE *fd) -{ - static char *sp, line[BUFSIZ]; - char *lp, *p; - - do { - if(sp == NULL) - sp = fgets(line, sizeof line, fd); - - if((lp = sp) == NULL) - break; - if((p = strchr(lp, '\n')) != NULL) - *p = 0; - if((p = strchr(lp, '#')) != NULL) - *p = 0; - if((p = strchr(lp, ';')) != NULL) { - *p++ = 0; - sp = p; - } else - sp = NULL; - if(*lp) - return lp; - } while (feof(fd) == 0); - return NULL; -} - -static int -getConfig(FILE *fd, char *key, char **Ar, int *nargs) -{ - char *lp, *p, **ar; - int state, len, n; - - ar = Ar; - if(key) - len = strlen(key); - else - len = 0; - state = 0; - while((lp = get_line(fd)) != NULL) { - for(; isspace((unsigned char)*lp); lp++) - ; - switch(state) { - case 0: - if((p = strchr(lp, '{')) != NULL) { - while((--p > lp) && *p && isspace((unsigned char)*p)); - n = p - lp; - if(len && strncmp(lp, key, MAX(n, len)) == 0) - state = 2; - else - state = 1; - continue; - } - break; - - case 1: - if(*lp == '}') - state = 0; - continue; - - case 2: - if(*lp == '}') - goto done; - - break; - } - - - for(p = &lp[strlen(lp)-1]; isspace((unsigned char)*p); p--) - *p = 0; - if((*nargs)-- > 0) - *ar++ = strdup(lp); - } - - done: - if(*nargs > 0) - *ar = 0; - *nargs = ar - Ar; - return ar - Ar; -} - -static textkey_t * -keyLookup(char *key) -{ - textkey_t *tk; - - for(tk = keyMap; tk->name && strcmp(tk->name, "end"); tk++) { - if(strcasecmp(key, tk->name) == 0) - return tk; - } - return NULL; -} - -static void -puke(isc_opt_t *op) -{ - printf("%24s = %d\n", "port", op->port); - printf("%24s = %d\n", "tags", op->tags); - printf("%24s = %d\n", "maxluns", op->maxluns); - printf("%24s = %s\n", "iqn", op->iqn); - - printf("%24s = %d\n", "maxConnections", op->maxConnections); - printf("%24s = %d\n", "maxRecvDataSegmentLength", op->maxRecvDataSegmentLength); - printf("%24s = %d\n", "maxXmitDataSegmentLength", op->maxRecvDataSegmentLength); - printf("%24s = %d\n", "maxBurstLength", op->maxBurstLength); - printf("%24s = %d\n", "firstBurstLength", op->firstBurstLength); - printf("%24s = %d\n", "defaultTime2Wait", op->defaultTime2Wait); - printf("%24s = %d\n", "defaultTime2Retain", op->defaultTime2Retain); - printf("%24s = %d\n", "maxOutstandingR2T", op->maxOutstandingR2T); - printf("%24s = %d\n", "errorRecoveryLevel", op->errorRecoveryLevel); - printf("%24s = %d\n", "targetPortalGroupTag", op->targetPortalGroupTag); - - printf("%24s = %s\n", "headerDigest", op->headerDigest); - printf("%24s = %s\n", "dataDigest", op->dataDigest); - - printf("%24s = %d\n", "initialR2T", op->initialR2T); - printf("%24s = %d\n", "immediateData", op->immediateData); - printf("%24s = %d\n", "dataPDUInOrder", op->dataPDUInOrder); - printf("%24s = %d\n", "dataSequenceInOrder", op->dataSequenceInOrder); - - printf("%24s = %s\n", "sessionType", op->sessionType); - printf("%24s = %s\n", "targetAddress", op->targetAddress); - printf("%24s = %s\n", "targetAlias", op->targetAlias); - printf("%24s = %s\n", "targetName", op->targetName); - printf("%24s = %s\n", "initiatorName", op->initiatorName); - printf("%24s = %s\n", "initiatorAlias", op->initiatorAlias); - printf("%24s = %s\n", "authMethod", op->authMethod); - printf("%24s = %s\n", "chapSecret", op->chapSecret); - printf("%24s = %s\n", "chapIName", op->chapIName); - printf("%24s = %s\n", "tgtChapName", op->tgtChapName); - printf("%24s = %s\n", "tgtChapSecret", op->tgtChapSecret); - printf("%24s = %d\n", "tgttgtChallengeLen", op->tgtChallengeLen); -} - -void -parseArgs(int nargs, char **args, isc_opt_t *op) -{ - char **ar; - char *p, *v; - textkey_t *tk; - - for(ar = args; nargs > 0; nargs--, ar++) { - p = strchr(*ar, '='); - if(p == NULL) - continue; - *p = 0; - v = p + 1; - while(isspace((unsigned char)*--p)) - *p = 0; - while(isspace((unsigned char)*v)) - v++; - if((tk = keyLookup(*ar)) == NULL) - continue; - setOption(op, tk->tokenID, v); - } -} - -void -parseConfig(FILE *fd, char *key, isc_opt_t *op) -{ - char *Ar[256]; - int cc; - - cc = 256; - if(getConfig(fd, key, Ar, &cc)) - parseArgs(cc, Ar, op); - if(vflag) - puke(op); -} diff --git a/sbin/iscontrol/fsm.c b/sbin/iscontrol/fsm.c deleted file mode 100644 index 8efbe6667b16..000000000000 --- a/sbin/iscontrol/fsm.c +++ /dev/null @@ -1,759 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005-2010 Daniel Braniss - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* - | $Id: fsm.c,v 2.8 2007/05/19 16:34:21 danny Exp danny $ - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "iscontrol.h" - -typedef enum { - T1 = 1, - T2, /*T3,*/ T4, T5, /*T6,*/ T7, T8, T9, - T10, T11, T12, T13, T14, T15, T16, T18 -} trans_t; - -/* - | now supports IPV6 - | thanks to: - | Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan - | ume@mahoroba.org ume@{,jp.}FreeBSD.org - | http://www.imasy.org/~ume/ - */ -static trans_t -tcpConnect(isess_t *sess) -{ - isc_opt_t *op = sess->op; - int val, sv_errno, soc; - struct addrinfo *res, *res0, hints; - char pbuf[10]; - - debug_called(3); - if(sess->flags & (SESS_RECONNECT|SESS_REDIRECT)) { - syslog(LOG_INFO, "%s", (sess->flags & SESS_RECONNECT) - ? "Reconnect": "Redirected"); - - debug(1, "%s", (sess->flags & SESS_RECONNECT) ? "Reconnect": "Redirected"); - shutdown(sess->soc, SHUT_RDWR); - //close(sess->soc); - sess->soc = -1; - - sess->flags &= ~SESS_CONNECTED; - if(sess->flags & SESS_REDIRECT) { - sess->redirect_cnt++; - sess->flags |= SESS_RECONNECT; - } else - sleep(2); // XXX: actually should be ? -#ifdef notyet - { - time_t sec; - // make sure we are not in a loop - // XXX: this code has to be tested - sec = time(0) - sess->reconnect_time; - if(sec > (5*60)) { - // if we've been connected for more that 5 minutes - // then just reconnect - sess->reconnect_time = sec; - sess->reconnect_cnt1 = 0; - } - else { - // - sess->reconnect_cnt1++; - if((sec / sess->reconnect_cnt1) < 2) { - // if less that 2 seconds from the last reconnect - // we are most probably looping - syslog(LOG_CRIT, "too many reconnects %d", sess->reconnect_cnt1); - return 0; - } - } - } -#endif - sess->reconnect_cnt++; - } - - snprintf(pbuf, sizeof(pbuf), "%d", op->port); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - debug(1, "targetAddress=%s port=%d", op->targetAddress, op->port); - if((val = getaddrinfo(op->targetAddress, pbuf, &hints, &res0)) != 0) { - fprintf(stderr, "getaddrinfo(%s): %s\n", op->targetAddress, gai_strerror(val)); - return 0; - } - sess->flags &= ~SESS_CONNECTED; - sv_errno = 0; - soc = -1; - for(res = res0; res; res = res->ai_next) { - soc = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (soc == -1) - continue; - - // from Patrick.Guelat@imp.ch: - // iscontrol can be called without waiting for the socket entry to time out - val = 1; - if(setsockopt(soc, SOL_SOCKET, SO_REUSEADDR, &val, (socklen_t)sizeof(val)) < 0) { - fprintf(stderr, "Cannot set socket SO_REUSEADDR %d: %s\n\n", - errno, strerror(errno)); - } - - if(connect(soc, res->ai_addr, res->ai_addrlen) == 0) - break; - sv_errno = errno; - close(soc); - soc = -1; - } - freeaddrinfo(res0); - if(soc != -1) { - sess->soc = soc; - -#if 0 - struct timeval timeout; - - val = 1; - if(setsockopt(sess->soc, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val)) < 0) - fprintf(stderr, "Cannot set socket KEEPALIVE option err=%d %s\n", - errno, strerror(errno)); - - if(setsockopt(sess->soc, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) < 0) - fprintf(stderr, "Cannot set socket NO delay option err=%d %s\n", - errno, strerror(errno)); - - timeout.tv_sec = 10; - timeout.tv_usec = 0; - if((setsockopt(sess->soc, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) - || (setsockopt(sess->soc, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)) { - fprintf(stderr, "Cannot set socket timeout to %ld err=%d %s\n", - timeout.tv_sec, errno, strerror(errno)); - } -#endif -#ifdef CURIOUS - { - int len = sizeof(val); - if(getsockopt(sess->soc, SOL_SOCKET, SO_SNDBUF, &val, &len) == 0) - fprintf(stderr, "was: SO_SNDBUF=%dK\n", val/1024); - } -#endif - if(sess->op->sockbufsize) { - val = sess->op->sockbufsize * 1024; - if((setsockopt(sess->soc, SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) < 0) - || (setsockopt(sess->soc, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) < 0)) { - fprintf(stderr, "Cannot set socket sndbuf & rcvbuf to %d err=%d %s\n", - val, errno, strerror(errno)); - return 0; - } - } - sess->flags |= SESS_CONNECTED; - return T1; - } - - fprintf(stderr, "errno=%d\n", sv_errno); - perror("connect"); - switch(sv_errno) { - case ECONNREFUSED: - case EHOSTUNREACH: - case ENETUNREACH: - case ETIMEDOUT: - if((sess->flags & SESS_REDIRECT) == 0) { - if(strcmp(op->targetAddress, sess->target.address) != 0) { - syslog(LOG_INFO, "reconnecting to original target address"); - free(op->targetAddress); - op->targetAddress = sess->target.address; - op->port = sess->target.port; - op->targetPortalGroupTag = sess->target.pgt; - return T1; - } - } - sleep(5); // for now ... - return T1; - default: - return 0; // terminal error - } -} - -int -setOptions(isess_t *sess, int flag) -{ - isc_opt_t oop; - char *sep; - - debug_called(3); - - bzero(&oop, sizeof(isc_opt_t)); - - if((flag & SESS_FULLFEATURE) == 0) { - oop.initiatorName = sess->op->initiatorName; - oop.targetAddress = sess->op->targetAddress; - if(sess->op->targetName != 0) - oop.targetName = sess->op->targetName; - - oop.maxRecvDataSegmentLength = sess->op->maxRecvDataSegmentLength; - oop.maxXmitDataSegmentLength = sess->op->maxXmitDataSegmentLength; // XXX: - oop.maxBurstLength = sess->op->maxBurstLength; - oop.maxluns = sess->op->maxluns; - } - else { - /* - | turn on digestion only after login - */ - if(sess->op->headerDigest != NULL) { - sep = strchr(sess->op->headerDigest, ','); - if(sep == NULL) *** 6836 LINES SKIPPED *** From nobody Tue Oct 26 20:54:12 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C1AAC1823AD4; Tue, 26 Oct 2021 20:54:38 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vtr.rulingia.com (vtr.rulingia.com [IPv6:2001:19f0:5801:ebe:5400:1ff:fe53:30fd]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "vtr.rulingia.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf3wY0LSDz3QBM; Tue, 26 Oct 2021 20:54:36 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from server.rulingia.com (2001-44b8-31fc-0d00-ecde-7ed7-1c2c-43e2.static.ipv6.internode.on.net [IPv6:2001:44b8:31fc:d00:ecde:7ed7:1c2c:43e2]) by vtr.rulingia.com (8.16.1/8.16.1) with ESMTPS id 19QKsILs042564 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Wed, 27 Oct 2021 07:54:24 +1100 (AEDT) (envelope-from peter@rulingia.com) DKIM-Filter: OpenDKIM Filter v2.10.3 vtr.rulingia.com 19QKsILs042564 X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.16.1/8.16.1) with ESMTPS id 19QKsCI0010924 (version=TLSv1.3 cipher=AEAD-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 27 Oct 2021 07:54:12 +1100 (AEDT) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.16.1/8.16.1/Submit) id 19QKsCai010923; Wed, 27 Oct 2021 07:54:12 +1100 (AEDT) (envelope-from peter) Date: Wed, 27 Oct 2021 07:54:12 +1100 From: Peter Jeremy To: Ed Maste Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 7b1e19ad78c6 - main - Add libfido2 to the build Message-ID: References: <202110230000.19N00JIK052888@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oyfAo94szTeP6IyR" Content-Disposition: inline In-Reply-To: <202110230000.19N00JIK052888@gitrepo.freebsd.org> X-PGP-Key: http://www.rulingia.com/keys/peter.pgp X-Rspamd-Queue-Id: 4Hf3wY0LSDz3QBM X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=pass (policy=quarantine) header.from=rulingia.com; spf=pass (mx1.freebsd.org: domain of peter@rulingia.com designates 2001:19f0:5801:ebe:5400:1ff:fe53:30fd as permitted sender) smtp.mailfrom=peter@rulingia.com X-Spamd-Result: default: False [-3.90 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FREEFALL_USER(0.00)[peter]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_SPAM_SHORT(1.00)[1.000]; RCVD_COUNT_THREE(0.00)[3]; MID_RHS_MATCH_FROMTLD(0.00)[]; DMARC_POLICY_ALLOW(-0.50)[rulingia.com,quarantine]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:20473, ipnet:2001:19f0:5800::/38, country:US]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N --oyfAo94szTeP6IyR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-Oct-23 00:00:19 +0000, Ed Maste wrote: >The branch main has been updated by emaste: > >URL: https://cgit.FreeBSD.org/src/commit/?id=3D7b1e19ad78c6a3f84f81cb1a16a= 39500f0337062 > >commit 7b1e19ad78c6a3f84f81cb1a16a39500f0337062 >Author: Ed Maste >AuthorDate: 2021-10-07 01:52:05 +0000 >Commit: Ed Maste >CommitDate: 2021-10-22 23:57:57 +0000 > > Add libfido2 to the build This triggered build failures on two of my hosts: The first problem is that libfido2 is always built but has hard dependencies on and . The latter two headers are optionally installed based on "WITHOUT_USB". I worked around it by removing WITHOUT_USB but I'm not sure of the best general solution here - making libfido2 optional would make the SSH integration more complex. The second problem showed up in a META_MODE parallel build as: "install: libprivatefido2.a: No such file or directory" with the following meta data: =2EERROR_TARGET=3D'_libinstall' =2EERROR_META_FILE=3D'/usr/obj/usr/src/arm64.aarch64/lib/libfido2/_libinsta= ll.meta' =2EMAKE.LEVEL=3D'5' =2ECURDIR=3D'/usr/src/lib/libfido2' =2EOBJDIR=3D'/usr/obj/usr/src/arm64.aarch64/lib/libfido2' =2ETARGETS=3D'install' DESTDIR=3D'/usr/obj/usr/src/arm64.aarch64/tmp' A retry succeeded so this may indicate a dependency tracking issue. I haven't dug into this further yet. --=20 Peter Jeremy --oyfAo94szTeP6IyR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEE7rKYbDBnHnTmXCJ+FqWXoOSiCzQFAmF4au5fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEVF QjI5ODZDMzA2NzFFNzRFNjVDMjI3RTE2QTU5N0EwRTRBMjBCMzQACgkQFqWXoOSi CzTQfA/+OWd/r3hn5kXuBWlP26yWh/T01WZrGSrG6pcfYV8EOwD//7V3CL+WiHYm CBZM9x53KvUpLY1AgTm6w6CB+n70xPuirk7mqTgE9gOofCOiFTXVRPuM57V0N5RH zwz2ZnC4+L5xIi1OE69b3PlNhjj90eN1D6SBk/o+c9lsezoXFKvqP11sCgFk2zN9 EO+xv06BnqUQo3lfTTpH8OBJMSBLnhOdlCRPgbNGGEtgkXqnbeYXgMsbWRm7St6C 5OJ7fC+lE9V9w8b3jAkhtLAFjyejmnm3iviBYOOIUqpuFMw41tK+Y9zs71bIritj U9X3vM14OFoRnVgF7O/wVYXMZjUoLgbasTn4WY2H0JNh8y0CVOQcxQG4yeK/142c 47/QFUckaz7bMhLHJkva91jSQv2l148/L76DbuMDQ9n7kjiLYgcZLXeG0vBP5Ohe mxz4XDWKACU5eg5XSU1QeKsMty+l2UtkTBehoID09yZBRUWjic+uw8eIhdTeQ+K2 d5n30kqu0alDoTuW/Zzvpg8fzlMFryTmX8n80s83Jf9Xm+5vE1kckBwCPmYWdRwV GC7Bq3t6Y8lbu1kXCU4WBP31Y7HVxZNSeZHLhYG5ApnqFXgOAL99/nW0J/+gZhkT EXQZCn2YicGCMIYVqKjXgzjOaUMsf4RZiXEcOG8Oqp2An/vfiKo= =hNLR -----END PGP SIGNATURE----- --oyfAo94szTeP6IyR-- From nobody Tue Oct 26 21:04:44 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E9A211826F28; Tue, 26 Oct 2021 21:05:05 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.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 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf48d6Gnmz3hyV; Tue, 26 Oct 2021 21:05:05 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-io1-f49.google.com with SMTP id d63so1041877iof.4; Tue, 26 Oct 2021 14:05:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=g7kvhccdP2pszWsa7QmhJmxmHSn/69lLW598mHcdB3w=; b=jpW+nqnIluqrKMvqkXK6MsMIT6mPEQqW+rh0+AMfCPfAbP0lPUwBGRgAZOMxd2yU/P ez8nhPNWEJGN6U75spc6/R6KYr7d6ciXyrgWrdp4olx5t/w2BAo9kNAcp9BQx+OeNtfO baOs0v5Q4K0wKxDm6OFqjmjcRzGBm9UfaBgytrvA6b9Z/W/FikDnNJeea4OgiCGAM8xy +wM8Qend6nGAwgQHxTc1zqZcRDFmffGhJk4OM4iRFe2WtM7r9JoDx3yYs+yGvC7BluAw 6qUqhsy7qXcSVbiar+Vqllj4YvdeGhnIxSitrw2SxaX4VGmrlVsPm/lPZqCyNcVOI1HF Sb2Q== X-Gm-Message-State: AOAM533R2u9nc7/RRos47eXNZwxnfm+dj0lYnk8lG/uCIg20cyQW8u2q +GYN10ONyIQkR60HS640aiPYPUhiuMLFBHxzkesD6AZ8 X-Google-Smtp-Source: ABdhPJynHa4LF7ziXvq12wJRldnQhHkFZ0RdLzBEmHijvrzJN7PAM2xBIAj9uA7Vozcxtm1hIyEte1mxdPVUyltAHdg= X-Received: by 2002:a05:6638:2410:: with SMTP id z16mr17507615jat.76.1635282298340; Tue, 26 Oct 2021 14:04:58 -0700 (PDT) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 References: <202110230000.19N00JIK052888@gitrepo.freebsd.org> In-Reply-To: From: Ed Maste Date: Tue, 26 Oct 2021 17:04:44 -0400 Message-ID: Subject: Re: git: 7b1e19ad78c6 - main - Add libfido2 to the build To: Peter Jeremy Cc: src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Hf48d6Gnmz3hyV X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Tue, 26 Oct 2021 at 16:54, Peter Jeremy wrote: > > This triggered build failures on two of my hosts: > > The first problem is that libfido2 is always built but has hard > dependencies on and . The latter > two headers are optionally installed based on "WITHOUT_USB". I worked > around it by removing WITHOUT_USB but I'm not sure of the best general > solution here - making libfido2 optional would make the SSH integration > more complex. Thanks for the report. I think we can always build ssh-sk-helper, but have it use internal support only when MK_USB is true. This should simplify the integration. From nobody Tue Oct 26 21:20:04 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A7F52182C7F1; Tue, 26 Oct 2021 21:20:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf4Tw4S8jz3mt5; Tue, 26 Oct 2021 21:20:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 79C6123C50; Tue, 26 Oct 2021 21:20:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QLK4sX034047; Tue, 26 Oct 2021 21:20:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QLK4nX034044; Tue, 26 Oct 2021 21:20:04 GMT (envelope-from git) Date: Tue, 26 Oct 2021 21:20:04 GMT Message-Id: <202110262120.19QLK4nX034044@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 93942379cced - main - Avoid building libfido2 if WITHOUT_USB List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 93942379cced89ad4ac653f262ac8277a8550853 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=93942379cced89ad4ac653f262ac8277a8550853 commit 93942379cced89ad4ac653f262ac8277a8550853 Author: Ed Maste AuthorDate: 2021-10-26 21:15:54 +0000 Commit: Ed Maste CommitDate: 2021-10-26 21:17:56 +0000 Avoid building libfido2 if WITHOUT_USB libfido2 requires USB, so disable it if not available. Reported by: peterj Fixes: 7b1e19ad78c6 ("Add libfido2 to the build") Sponsored by: The FreeBSD Foundation --- lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Makefile b/lib/Makefile index 81ace36ba990..3f30917173af 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -215,7 +215,7 @@ SUBDIR.${MK_BHYVE}+= libvmmapi .if ${MACHINE_ARCH} != "powerpc" SUBDIR.${MK_OPENMP}+= libomp .endif -.if !defined(COMPAT_32BIT) +.if !defined(COMPAT_32BIT) && ${MK_USB} != "no" SUBDIR.${MK_OPENSSH}+= libcbor libfido2 .endif SUBDIR.${MK_OPENSSL}+= libmp From nobody Tue Oct 26 21:55:52 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0C6F2181BA90; Tue, 26 Oct 2021 21:55:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf5HD6sWtz4RPm; Tue, 26 Oct 2021 21:55:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEB6B24144; Tue, 26 Oct 2021 21:55:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QLtquT084074; Tue, 26 Oct 2021 21:55:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QLtqeS084073; Tue, 26 Oct 2021 21:55:52 GMT (envelope-from git) Date: Tue, 26 Oct 2021 21:55:52 GMT Message-Id: <202110262155.19QLtqeS084073@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: cdbc4a074bec - main - Further refine the ExpDataSN checks for SCSI Response PDUs. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cdbc4a074bec094dc7f1dfde0773a9417d118ffa Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cdbc4a074bec094dc7f1dfde0773a9417d118ffa commit cdbc4a074bec094dc7f1dfde0773a9417d118ffa Author: John Baldwin AuthorDate: 2021-10-26 21:50:05 +0000 Commit: John Baldwin CommitDate: 2021-10-26 21:50:05 +0000 Further refine the ExpDataSN checks for SCSI Response PDUs. According to 11.4.8 in RFC 7143, ExpDataSN MUST be 0 if the response code is not Command Completed, but we were requiring it to always be the count of DataIn PDUs regardless of the response code. In addition, at least one target (OCI Oracle iSCSI block device) returns an ExpDataSN of 0 when returning a valid completion with an error status (Check Condition) in response to a SCSI Inquiry. As a workaround for this target, only warn without resetting the connection for a 0 ExpDataSN for responses with a non-zero error status. PR: 259152 Reported by: dch Reviewed by: dch, mav, emaste Fixes: 4f0f5bf99591 iscsi: Validate DataSN values in Data-In PDUs in the initiator. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32650 --- sys/dev/iscsi/iscsi.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index eba365f7ad3e..9f49db2ad935 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -892,15 +892,39 @@ iscsi_pdu_handle_scsi_response(struct icl_pdu *response) } ccb = io->io_ccb; - if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { - ISCSI_SESSION_WARN(is, - "ExpDataSN mismatch in SCSI Response (%u vs %u)", - ntohl(bhssr->bhssr_expdatasn), io->io_datasn); - icl_pdu_free(response); - iscsi_session_reconnect(is); - ISCSI_SESSION_UNLOCK(is); - return; + if (bhssr->bhssr_response == BHSSR_RESPONSE_COMMAND_COMPLETED) { + if (ntohl(bhssr->bhssr_expdatasn) != io->io_datasn) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs %u)", + ntohl(bhssr->bhssr_expdatasn), io->io_datasn); + + /* + * XXX: Permit an ExpDataSN of zero for errors. + * + * This doesn't conform to RFC 7143, but some + * targets seem to do this. + */ + if (bhssr->bhssr_status != 0 && + bhssr->bhssr_expdatasn == htonl(0)) + goto skip_expdatasn; + + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } + } else { + if (bhssr->bhssr_expdatasn != htonl(0)) { + ISCSI_SESSION_WARN(is, + "ExpDataSN mismatch in SCSI Response (%u vs 0)", + ntohl(bhssr->bhssr_expdatasn)); + icl_pdu_free(response); + iscsi_session_reconnect(is); + ISCSI_SESSION_UNLOCK(is); + return; + } } +skip_expdatasn: /* * With iSER, after getting good response we can be sure From nobody Tue Oct 26 21:55:53 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 56F99181B95E; Tue, 26 Oct 2021 21:55:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf5HG0VZ0z4R0f; Tue, 26 Oct 2021 21:55:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DAC4F24067; Tue, 26 Oct 2021 21:55:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QLtr5L084098; Tue, 26 Oct 2021 21:55:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QLtrSm084097; Tue, 26 Oct 2021 21:55:53 GMT (envelope-from git) Date: Tue, 26 Oct 2021 21:55:53 GMT Message-Id: <202110262155.19QLtrSm084097@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 7ef7b252adc0 - main - ctld: Always declare MaxRecvDataSegmentLength. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7ef7b252adc0152e5f726d00640124c5de0909a9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7ef7b252adc0152e5f726d00640124c5de0909a9 commit 7ef7b252adc0152e5f726d00640124c5de0909a9 Author: John Baldwin AuthorDate: 2021-10-26 21:52:40 +0000 Commit: John Baldwin CommitDate: 2021-10-26 21:52:40 +0000 ctld: Always declare MaxRecvDataSegmentLength. This key is Declarative and should always be sent even if the initiator did not send it's own limit. This is similar to the fix in fc79cf4fea72 but for the target side. However, unlike that fix, failure to send the key simply results in reduced performance. PR: 259439 Reviewed by: mav, emaste Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32651 --- usr.sbin/ctld/login.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr.sbin/ctld/login.c b/usr.sbin/ctld/login.c index f219a3044586..63b2cfd51d92 100644 --- a/usr.sbin/ctld/login.c +++ b/usr.sbin/ctld/login.c @@ -565,10 +565,6 @@ login_negotiate_key(struct pdu *request, const char *name, tmp = conn->conn_max_send_data_segment_limit; } conn->conn_max_send_data_segment_length = tmp; - conn->conn_max_recv_data_segment_length = - conn->conn_max_recv_data_segment_limit; - keys_add_int(response_keys, name, - conn->conn_max_recv_data_segment_length); } else if (strcmp(name, "MaxBurstLength") == 0) { tmp = strtoul(value, NULL, 10); if (tmp <= 0) { @@ -796,6 +792,11 @@ login_negotiate(struct connection *conn, struct pdu *request) log_errx(1, "initiator sent FirstBurstLength > MaxBurstLength"); } + conn->conn_max_recv_data_segment_length = + conn->conn_max_recv_data_segment_limit; + keys_add_int(response_keys, "MaxRecvDataSegmentLength", + conn->conn_max_recv_data_segment_length); + log_debugx("operational parameter negotiation done; " "transitioning to Full Feature Phase"); From nobody Tue Oct 26 22:34:33 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 39EC3182B72F; Tue, 26 Oct 2021 22:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf67t1BT1z4d7d; Tue, 26 Oct 2021 22:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0595424BB2; Tue, 26 Oct 2021 22:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QMYXGN038128; Tue, 26 Oct 2021 22:34:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QMYXRu038127; Tue, 26 Oct 2021 22:34:33 GMT (envelope-from git) Date: Tue, 26 Oct 2021 22:34:33 GMT Message-Id: <202110262234.19QMYXRu038127@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 6312d144613f - main - lib/msun/ld128/s_tanpil.c: make it compile. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6312d144613f97bf59703c442ee4871be1450c46 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6312d144613f97bf59703c442ee4871be1450c46 commit 6312d144613f97bf59703c442ee4871be1450c46 Author: Konstantin Belousov AuthorDate: 2021-10-26 21:14:35 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-26 22:34:12 +0000 lib/msun/ld128/s_tanpil.c: make it compile. Declare local, add missed ';'. Name function properly. Fixes: dce5f3abed7181cc533ca5ed Reviewed by: kargl Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/msun/ld128/s_tanpil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/msun/ld128/s_tanpil.c b/lib/msun/ld128/s_tanpil.c index 33a61cf3115d..7cbbdc8a5d05 100644 --- a/lib/msun/ld128/s_tanpil.c +++ b/lib/msun/ld128/s_tanpil.c @@ -42,7 +42,7 @@ pi_hi = 3.14159265358979322702026593105983920e+00L, pi_lo = 1.14423774522196636802434264184180742e-17L; static inline long double -__kernel_tanpi(long double x) +__kernel_tanpil(long double x) { long double hi, lo, t; @@ -72,7 +72,7 @@ volatile static const double vzero = 0; long double tanpil(long double x) { - long double ax, hi, lo, xf; + long double ax, hi, lo, xf, t; uint32_t ix; ax = fabsl(ax); @@ -83,7 +83,7 @@ tanpil(long double x) if (x == 0) return (x); hi = (double)x; - hi *= 0x1p113L + hi *= 0x1p113L; lo = x * 0x1p113L - hi; t = (pi_lo + pi_hi) * lo + pi_lo * lo + pi_hi * hi; From nobody Tue Oct 26 22:34:35 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 961D1182B6B1; Tue, 26 Oct 2021 22:34:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hf67v280Fz4dHG; Tue, 26 Oct 2021 22:34:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 275E92477B; Tue, 26 Oct 2021 22:34:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19QMYZiL038152; Tue, 26 Oct 2021 22:34:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19QMYZA5038151; Tue, 26 Oct 2021 22:34:35 GMT (envelope-from git) Date: Tue, 26 Oct 2021 22:34:35 GMT Message-Id: <202110262234.19QMYZA5038151@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ca3d8cb087cd - main - lib/msun: Move the files to appropriate locations in the Makefile List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ca3d8cb087cd5b40369478b1693f3e4038b5fa23 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ca3d8cb087cd5b40369478b1693f3e4038b5fa23 commit ca3d8cb087cd5b40369478b1693f3e4038b5fa23 Author: Steve Kargl AuthorDate: 2021-10-26 20:53:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-26 22:34:12 +0000 lib/msun: Move the files to appropriate locations in the Makefile Fixes: dce5f3abed7181cc533ca5ed PR: 218514 MFC after: 1 week --- lib/msun/Makefile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/msun/Makefile b/lib/msun/Makefile index dcee5572f949..1d94e371e61f 100644 --- a/lib/msun/Makefile +++ b/lib/msun/Makefile @@ -89,6 +89,11 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \ s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_tgammaf.c s_trunc.c s_truncf.c \ w_cabs.c w_cabsf.c w_drem.c w_dremf.c +# IEEE-754 2008 and ISO/IEC TS 18661-4 half-cycle trignometric functions +COMMON_SRCS+= s_cospi.c s_cospif.c \ + s_sinpi.c s_sinpif.c \ + s_tanpi.c s_tanpif.c + # Location of fpmath.h and _fpmath.h .if exists(${LIBCSRCDIR}/${MACHINE_ARCH}) LIBC_ARCH=${MACHINE_ARCH} @@ -113,12 +118,12 @@ COMMON_SRCS+= catrigl.c \ e_remainderl.c e_sinhl.c e_sqrtl.c \ invtrig.c k_cosl.c k_sinl.c k_tanl.c \ s_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c \ - s_clogl.c s_cosl.c s_cprojl.c \ + s_clogl.c s_cosl.c s_cospil.c s_cprojl.c \ s_csqrtl.c s_erfl.c s_exp2l.c s_expl.c s_floorl.c s_fmal.c \ s_fmaxl.c s_fminl.c s_frexpl.c s_logbl.c s_logl.c s_nanl.c \ s_nextafterl.c s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c \ - s_scalbnl.c s_sinl.c s_sincosl.c \ - s_tanhl.c s_tanl.c s_truncl.c w_cabsl.c + s_scalbnl.c s_sinl.c s_sincosl.c s_sinpil.c \ + s_tanhl.c s_tanl.c s_tanpil.c s_truncl.c w_cabsl.c # Work around this warning from gcc: # lib/msun/ld80/e_powl.c:275:1: error: floating constant exceeds range of # 'long double' [-Werror=overflow] @@ -126,12 +131,6 @@ COMMON_SRCS+= catrigl.c \ # See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=130067 .if ${COMPILER_TYPE} == "gcc" CFLAGS.e_powl.c+= -Wno-error=overflow - -# IEEE-754 2008 and ISO/IEC TS 18661-4 half-cycle trignometric functions -COMMON_SRCS+= s_cospi.c s_cospif.c s_cospil.c \ - s_sinpi.c s_sinpif.c s_sinpil.c \ - s_tanpi.c s_tanpif.c s_tanpil.c - .endif .endif From nobody Wed Oct 27 03:29:44 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5193918120BB; Wed, 27 Oct 2021 03:29:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfDhT0m6tz505M; Wed, 27 Oct 2021 03:29:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF5A39BA; Wed, 27 Oct 2021 03:29:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19R3TijE025233; Wed, 27 Oct 2021 03:29:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19R3Tiq7025232; Wed, 27 Oct 2021 03:29:44 GMT (envelope-from git) Date: Wed, 27 Oct 2021 03:29:44 GMT Message-Id: <202110270329.19R3Tiq7025232@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 355c15130aef - main - iwm: update if_iwmreg.h to the latest (as of today) openbsd changes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 355c15130aef13484821051a655da9b9066e1015 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=355c15130aef13484821051a655da9b9066e1015 commit 355c15130aef13484821051a655da9b9066e1015 Author: Adrian Chadd AuthorDate: 2021-10-24 15:47:04 +0000 Commit: Adrian Chadd CommitDate: 2021-10-27 03:28:54 +0000 iwm: update if_iwmreg.h to the latest (as of today) openbsd changes Summary: This updates the if_iwmreg.h definitions to; OpenBSD: if_iwmreg.h,v 1.65 2021/10/11 09:03:22 stsp Exp A few things haven't been fully converted, namely: * I left a couple things as enums for now just to reduce the other diffs needed; but they're the same values * The IWM_SCD_QUEUE_* macros have different offsets which I didn't update in case they broke things / changed based on later firmware. But they also may be real bugfixes which are needed for later chips. It'll need more testing before flipping this on. The c file updates are: * Use the newer names for things if the name changed but the semantics didn't * Explicitly use the earlier firmware structs which maintain compat with the current firmware and code. The newer ones are in here and they'll get converted when more openbsd code is merged into this tree. * Use the older iwm rate table for now, which has entries for legacy rates, HT and VHT. Our code works with that right now, updating it to openbsd's err, "different" version can be done at a later date when HT/VHT support is added. Notably, a bunch of definitions were deleted that weren't used. They're not used either in the openbsd/dfbsd drivers so I think it's safe to delete them in the long run. Test Plan: 7260 hw 0x140 Subscribers: imp Differential Revision: https://reviews.freebsd.org/D32627 Reviewed by: md5 Obtained From: OpenBSD --- sys/dev/iwm/if_iwm.c | 112 +- sys/dev/iwm/if_iwm_binding.c | 2 +- sys/dev/iwm/if_iwm_phy_db.c | 37 +- sys/dev/iwm/if_iwm_scan.c | 10 +- sys/dev/iwm/if_iwmreg.h | 3522 ++++++++++++++++++++++++------------------ sys/dev/iwm/if_iwmvar.h | 2 +- 6 files changed, 2030 insertions(+), 1655 deletions(-) diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index f994e8e75307..3e34c3cac98e 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -1914,98 +1914,6 @@ iwm_nvm_read_section(struct iwm_softc *sc, /* iwlwifi/iwl-nvm-parse.c */ -/* NVM offsets (in words) definitions */ -enum iwm_nvm_offsets { - /* NVM HW-Section offset (in words) definitions */ - IWM_HW_ADDR = 0x15, - -/* NVM SW-Section offset (in words) definitions */ - IWM_NVM_SW_SECTION = 0x1C0, - IWM_NVM_VERSION = 0, - IWM_RADIO_CFG = 1, - IWM_SKU = 2, - IWM_N_HW_ADDRS = 3, - IWM_NVM_CHANNELS = 0x1E0 - IWM_NVM_SW_SECTION, - -/* NVM calibration section offset (in words) definitions */ - IWM_NVM_CALIB_SECTION = 0x2B8, - IWM_XTAL_CALIB = 0x316 - IWM_NVM_CALIB_SECTION -}; - -enum iwm_8000_nvm_offsets { - /* NVM HW-Section offset (in words) definitions */ - IWM_HW_ADDR0_WFPM_8000 = 0x12, - IWM_HW_ADDR1_WFPM_8000 = 0x16, - IWM_HW_ADDR0_PCIE_8000 = 0x8A, - IWM_HW_ADDR1_PCIE_8000 = 0x8E, - IWM_MAC_ADDRESS_OVERRIDE_8000 = 1, - - /* NVM SW-Section offset (in words) definitions */ - IWM_NVM_SW_SECTION_8000 = 0x1C0, - IWM_NVM_VERSION_8000 = 0, - IWM_RADIO_CFG_8000 = 0, - IWM_SKU_8000 = 2, - IWM_N_HW_ADDRS_8000 = 3, - - /* NVM REGULATORY -Section offset (in words) definitions */ - IWM_NVM_CHANNELS_8000 = 0, - IWM_NVM_LAR_OFFSET_8000_OLD = 0x4C7, - IWM_NVM_LAR_OFFSET_8000 = 0x507, - IWM_NVM_LAR_ENABLED_8000 = 0x7, - - /* NVM calibration section offset (in words) definitions */ - IWM_NVM_CALIB_SECTION_8000 = 0x2B8, - IWM_XTAL_CALIB_8000 = 0x316 - IWM_NVM_CALIB_SECTION_8000 -}; - -/* SKU Capabilities (actual values from NVM definition) */ -enum nvm_sku_bits { - IWM_NVM_SKU_CAP_BAND_24GHZ = (1 << 0), - IWM_NVM_SKU_CAP_BAND_52GHZ = (1 << 1), - IWM_NVM_SKU_CAP_11N_ENABLE = (1 << 2), - IWM_NVM_SKU_CAP_11AC_ENABLE = (1 << 3), -}; - -/* radio config bits (actual values from NVM definition) */ -#define IWM_NVM_RF_CFG_DASH_MSK(x) (x & 0x3) /* bits 0-1 */ -#define IWM_NVM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ -#define IWM_NVM_RF_CFG_TYPE_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ -#define IWM_NVM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ -#define IWM_NVM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ -#define IWM_NVM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ - -#define IWM_NVM_RF_CFG_FLAVOR_MSK_8000(x) (x & 0xF) -#define IWM_NVM_RF_CFG_DASH_MSK_8000(x) ((x >> 4) & 0xF) -#define IWM_NVM_RF_CFG_STEP_MSK_8000(x) ((x >> 8) & 0xF) -#define IWM_NVM_RF_CFG_TYPE_MSK_8000(x) ((x >> 12) & 0xFFF) -#define IWM_NVM_RF_CFG_TX_ANT_MSK_8000(x) ((x >> 24) & 0xF) -#define IWM_NVM_RF_CFG_RX_ANT_MSK_8000(x) ((x >> 28) & 0xF) - -/** - * enum iwm_nvm_channel_flags - channel flags in NVM - * @IWM_NVM_CHANNEL_VALID: channel is usable for this SKU/geo - * @IWM_NVM_CHANNEL_IBSS: usable as an IBSS channel - * @IWM_NVM_CHANNEL_ACTIVE: active scanning allowed - * @IWM_NVM_CHANNEL_RADAR: radar detection required - * XXX cannot find this (DFS) flag in iwm-nvm-parse.c - * @IWM_NVM_CHANNEL_DFS: dynamic freq selection candidate - * @IWM_NVM_CHANNEL_WIDE: 20 MHz channel okay (?) - * @IWM_NVM_CHANNEL_40MHZ: 40 MHz channel okay (?) - * @IWM_NVM_CHANNEL_80MHZ: 80 MHz channel okay (?) - * @IWM_NVM_CHANNEL_160MHZ: 160 MHz channel okay (?) - */ -enum iwm_nvm_channel_flags { - IWM_NVM_CHANNEL_VALID = (1 << 0), - IWM_NVM_CHANNEL_IBSS = (1 << 1), - IWM_NVM_CHANNEL_ACTIVE = (1 << 3), - IWM_NVM_CHANNEL_RADAR = (1 << 4), - IWM_NVM_CHANNEL_DFS = (1 << 7), - IWM_NVM_CHANNEL_WIDE = (1 << 8), - IWM_NVM_CHANNEL_40MHZ = (1 << 9), - IWM_NVM_CHANNEL_80MHZ = (1 << 10), - IWM_NVM_CHANNEL_160MHZ = (1 << 11), -}; - /* * Translate EEPROM flags to net80211. */ @@ -2220,7 +2128,7 @@ iwm_set_radio_cfg(const struct iwm_softc *sc, struct iwm_nvm_data *data, data->radio_cfg_type = IWM_NVM_RF_CFG_TYPE_MSK_8000(radio_cfg); data->radio_cfg_step = IWM_NVM_RF_CFG_STEP_MSK_8000(radio_cfg); data->radio_cfg_dash = IWM_NVM_RF_CFG_DASH_MSK_8000(radio_cfg); - data->radio_cfg_pnum = IWM_NVM_RF_CFG_FLAVOR_MSK_8000(radio_cfg); + data->radio_cfg_pnum = IWM_NVM_RF_CFG_PNUM_MSK_8000(radio_cfg); data->valid_tx_ant = IWM_NVM_RF_CFG_TX_ANT_MSK_8000(radio_cfg); data->valid_rx_ant = IWM_NVM_RF_CFG_RX_ANT_MSK_8000(radio_cfg); } @@ -2383,7 +2291,7 @@ iwm_parse_nvm_sections(struct iwm_softc *sc, struct iwm_nvm_section *sections) static int iwm_nvm_init(struct iwm_softc *sc) { - struct iwm_nvm_section nvm_sections[IWM_NVM_MAX_NUM_SECTIONS]; + struct iwm_nvm_section nvm_sections[IWM_NVM_NUM_OF_SECTIONS]; int i, ret, section; uint32_t size_read = 0; uint8_t *nvm_buffer, *temp; @@ -2391,7 +2299,7 @@ iwm_nvm_init(struct iwm_softc *sc) memset(nvm_sections, 0, sizeof(nvm_sections)); - if (sc->cfg->nvm_hw_section_num >= IWM_NVM_MAX_NUM_SECTIONS) + if (sc->cfg->nvm_hw_section_num >= IWM_NVM_NUM_OF_SECTIONS) return EINVAL; /* load NVM values from nic */ @@ -2401,7 +2309,7 @@ iwm_nvm_init(struct iwm_softc *sc) nvm_buffer = malloc(sc->cfg->eeprom_size, M_DEVBUF, M_NOWAIT | M_ZERO); if (!nvm_buffer) return ENOMEM; - for (section = 0; section < IWM_NVM_MAX_NUM_SECTIONS; section++) { + for (section = 0; section < IWM_NVM_NUM_OF_SECTIONS; section++) { /* we override the constness for initial read */ ret = iwm_nvm_read_section(sc, section, nvm_buffer, &len, size_read); @@ -2428,7 +2336,7 @@ iwm_nvm_init(struct iwm_softc *sc) IWM_DPRINTF(sc, IWM_DEBUG_EEPROM | IWM_DEBUG_RESET, "nvm version = %x\n", sc->nvm_data->nvm_version); - for (i = 0; i < IWM_NVM_MAX_NUM_SECTIONS; i++) { + for (i = 0; i < IWM_NVM_NUM_OF_SECTIONS; i++) { if (nvm_sections[i].data != NULL) free(nvm_sections[i].data, M_DEVBUF); } @@ -3181,7 +3089,7 @@ iwm_get_noise(struct iwm_softc *sc, static void iwm_handle_rx_statistics(struct iwm_softc *sc, struct iwm_rx_packet *pkt) { - struct iwm_notif_statistics_v10 *stats = (void *)&pkt->data; + struct iwm_notif_statistics *stats = (void *)&pkt->data; memcpy(&sc->sc_stats, stats, sizeof(sc->sc_stats)); sc->sc_noise = iwm_get_noise(sc, &stats->rx.general); @@ -3897,7 +3805,7 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac) if (hdrlen & 3) { /* First segment length must be a multiple of 4. */ flags |= IWM_TX_CMD_FLG_MH_PAD; - tx->offload_assist |= htole16(1 << IWM_TX_CMD_OFFLD_PAD); + tx->offload_assist |= htole16(IWM_TX_CMD_OFFLD_PAD); pad = 4 - (hdrlen & 3); } else { tx->offload_assist = 0; @@ -4059,7 +3967,7 @@ int iwm_flush_tx_path(struct iwm_softc *sc, uint32_t tfd_msk, uint32_t flags) { int ret; - struct iwm_tx_path_flush_cmd flush_cmd = { + struct iwm_tx_path_flush_cmd_v1 flush_cmd = { .queues_ctl = htole32(tfd_msk), .flush_ctl = htole16(IWM_DUMP_TX_FIFO_FLUSH), }; @@ -4079,7 +3987,7 @@ iwm_flush_tx_path(struct iwm_softc *sc, uint32_t tfd_msk, uint32_t flags) static int iwm_update_quotas(struct iwm_softc *sc, struct iwm_vap *ivp) { - struct iwm_time_quota_cmd cmd; + struct iwm_time_quota_cmd_v1 cmd; int i, idx, ret, num_active_macs, quota, quota_rem; int colors[IWM_MAX_BINDINGS] = { -1, -1, -1, -1, }; int n_ifs[IWM_MAX_BINDINGS] = {0, }; @@ -4711,7 +4619,7 @@ iwm_send_update_mcc_cmd(struct iwm_softc *sc, const char *alpha2) #ifdef IWM_DEBUG struct iwm_rx_packet *pkt; struct iwm_mcc_update_resp_v1 *mcc_resp_v1 = NULL; - struct iwm_mcc_update_resp *mcc_resp; + struct iwm_mcc_update_resp_v2 *mcc_resp; int n_channels; uint16_t mcc; #endif diff --git a/sys/dev/iwm/if_iwm_binding.c b/sys/dev/iwm/if_iwm_binding.c index 28207c998d77..6b0b19b7515c 100644 --- a/sys/dev/iwm/if_iwm_binding.c +++ b/sys/dev/iwm/if_iwm_binding.c @@ -159,7 +159,7 @@ static int iwm_binding_cmd(struct iwm_softc *sc, uint32_t action, struct iwm_iface_iterator_data *data) { - struct iwm_binding_cmd cmd; + struct iwm_binding_cmd_v1 cmd; struct iwm_phy_ctxt *phyctxt = data->phyctxt; int i, ret; uint32_t status; diff --git a/sys/dev/iwm/if_iwm_phy_db.c b/sys/dev/iwm/if_iwm_phy_db.c index 40a0a05adb15..08ded1121d03 100644 --- a/sys/dev/iwm/if_iwm_phy_db.c +++ b/sys/dev/iwm/if_iwm_phy_db.c @@ -186,41 +186,6 @@ struct iwm_phy_db { struct iwm_softc *sc; }; -enum iwm_phy_db_section_type { - IWM_PHY_DB_CFG = 1, - IWM_PHY_DB_CALIB_NCH, - IWM_PHY_DB_UNUSED, - IWM_PHY_DB_CALIB_CHG_PAPD, - IWM_PHY_DB_CALIB_CHG_TXP, - IWM_PHY_DB_MAX -}; - -#define PHY_DB_CMD 0x6c - -/* - * phy db - configure operational ucode - */ -struct iwm_phy_db_cmd { - uint16_t type; - uint16_t length; - uint8_t data[]; -} __packed; - -/* for parsing of tx power channel group data that comes from the firmware*/ -struct iwm_phy_db_chg_txp { - uint32_t space; - uint16_t max_channel_idx; -} __packed; - -/* - * phy db - Receive phy db chunk after calibrations - */ -struct iwm_calib_res_notif_phy_db { - uint16_t type; - uint16_t length; - uint8_t data[]; -} __packed; - struct iwm_phy_db * iwm_phy_db_init(struct iwm_softc *sc) { @@ -477,7 +442,7 @@ iwm_send_phy_db_cmd(struct iwm_phy_db *phy_db, uint16_t type, { struct iwm_phy_db_cmd phy_db_cmd; struct iwm_host_cmd cmd = { - .id = PHY_DB_CMD, + .id = IWM_PHY_DB_CMD, }; IWM_DPRINTF(phy_db->sc, IWM_DEBUG_RESET, diff --git a/sys/dev/iwm/if_iwm_scan.c b/sys/dev/iwm/if_iwm_scan.c index cdf7985d9a97..efba76ad502a 100644 --- a/sys/dev/iwm/if_iwm_scan.c +++ b/sys/dev/iwm/if_iwm_scan.c @@ -379,7 +379,7 @@ iwm_umac_scan_fill_channels(struct iwm_softc *sc, } static int -iwm_fill_probe_req(struct iwm_softc *sc, struct iwm_scan_probe_req *preq) +iwm_fill_probe_req(struct iwm_softc *sc, struct iwm_scan_probe_req_v1 *preq) { struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); @@ -594,12 +594,12 @@ iwm_scan_size(struct iwm_softc *sc) return base_size + sizeof(struct iwm_scan_channel_cfg_umac) * sc->sc_fw.ucode_capa.n_scan_channels + - sizeof(struct iwm_scan_req_umac_tail); + sizeof(struct iwm_scan_req_umac_tail_v1); } else { return sizeof(struct iwm_scan_req_lmac) + sizeof(struct iwm_scan_channel_cfg_lmac) * sc->sc_fw.ucode_capa.n_scan_channels + - sizeof(struct iwm_scan_probe_req); + sizeof(struct iwm_scan_probe_req_v1); } } @@ -614,7 +614,7 @@ iwm_umac_scan(struct iwm_softc *sc) }; struct ieee80211_scan_state *ss = sc->sc_ic.ic_scan; struct iwm_scan_req_umac *req; - struct iwm_scan_req_umac_tail *tail; + struct iwm_scan_req_umac_tail_v1 *tail; size_t req_len; uint16_t general_flags; uint8_t channel_flags, i, nssid; @@ -799,7 +799,7 @@ iwm_lmac_scan(struct iwm_softc *sc) (struct iwm_scan_channel_cfg_lmac *)req->data, nssid); ret = iwm_fill_probe_req(sc, - (struct iwm_scan_probe_req *)(req->data + + (struct iwm_scan_probe_req_v1 *)(req->data + (sizeof(struct iwm_scan_channel_cfg_lmac) * sc->sc_fw.ucode_capa.n_scan_channels))); if (ret) { diff --git a/sys/dev/iwm/if_iwmreg.h b/sys/dev/iwm/if_iwmreg.h index 310b2d53a82e..c3c51a25c4b0 100644 --- a/sys/dev/iwm/if_iwmreg.h +++ b/sys/dev/iwm/if_iwmreg.h @@ -1,5 +1,4 @@ -/* $OpenBSD: if_iwmreg.h,v 1.4 2015/06/15 08:06:11 stsp Exp $ */ -/* $FreeBSD$ */ +/* $OpenBSD: if_iwmreg.h,v 1.65 2021/10/11 09:03:22 stsp Exp $ */ /****************************************************************************** * @@ -63,6 +62,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ + #ifndef __IF_IWM_REG_H__ #define __IF_IWM_REG_H__ @@ -193,7 +193,7 @@ /* interrupt flags in INTA, set by uCode or hardware (e.g. dma), * acknowledged (reset) by host writing "1" to flagged bits. */ -#define IWM_CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ +#define IWM_CSR_INT_BIT_FH_RX (1U << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ #define IWM_CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ #define IWM_CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ #define IWM_CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ @@ -216,7 +216,7 @@ IWM_CSR_INT_BIT_RX_PERIODIC) /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */ -#define IWM_CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ +#define IWM_CSR_FH_INT_BIT_ERR (1U << 31) /* Error */ #define IWM_CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ #define IWM_CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ #define IWM_CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ @@ -306,7 +306,6 @@ enum { IWM_SILICON_C_STEP, }; - #define IWM_CSR_HW_REV_TYPE_MSK (0x000FFF0) #define IWM_CSR_HW_REV_TYPE_5300 (0x0000020) #define IWM_CSR_HW_REV_TYPE_5350 (0x0000030) @@ -417,30 +416,131 @@ enum { #define IWM_CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000) /* DRAM INT TABLE */ -#define IWM_CSR_DRAM_INT_TBL_ENABLE (1 << 31) +#define IWM_CSR_DRAM_INT_TBL_ENABLE (1U << 31) #define IWM_CSR_DRAM_INIT_TBL_WRITE_POINTER (1 << 28) #define IWM_CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27) /* SECURE boot registers */ #define IWM_CSR_SECURE_BOOT_CONFIG_ADDR (0x100) -enum iwm_secure_boot_config_reg { - IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_BURNED_IN_OTP = 0x00000001, - IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_NOT_REQ = 0x00000002, -}; - +#define IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_BURNED_IN_OTP 0x00000001 +#define IWM_CSR_SECURE_BOOT_CONFIG_INSPECTOR_NOT_REQ 0x00000002 #define IWM_CSR_SECURE_BOOT_CPU1_STATUS_ADDR (0x100) #define IWM_CSR_SECURE_BOOT_CPU2_STATUS_ADDR (0x100) -enum iwm_secure_boot_status_reg { - IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_STATUS = 0x00000003, - IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_COMPLETED = 0x00000002, - IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_SUCCESS = 0x00000004, - IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_FAIL = 0x00000008, - IWM_CSR_SECURE_BOOT_CPU_STATUS_SIGN_VERF_FAIL = 0x00000010, -}; +#define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_STATUS 0x00000003 +#define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_COMPLETED 0x00000002 +#define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_SUCCESS 0x00000004 +#define IWM_CSR_SECURE_BOOT_CPU_STATUS_VERF_FAIL 0x00000008 +#define IWM_CSR_SECURE_BOOT_CPU_STATUS_SIGN_VERF_FAIL 0x00000010 #define IWM_FH_UCODE_LOAD_STATUS 0x1af0 + #define IWM_FH_MEM_TB_MAX_LENGTH 0x20000 +/* 9000 rx series registers */ + +#define IWM_RFH_Q0_FRBDCB_BA_LSB 0xA08000 /* 64 bit address */ +#define IWM_RFH_Q_FRBDCB_BA_LSB(q) (IWM_RFH_Q0_FRBDCB_BA_LSB + (q) * 8) +/* Write index table */ +#define IWM_RFH_Q0_FRBDCB_WIDX 0xA08080 +#define IWM_RFH_Q_FRBDCB_WIDX(q) (IWM_RFH_Q0_FRBDCB_WIDX + (q) * 4) +/* Write index table - shadow registers */ +#define IWM_RFH_Q0_FRBDCB_WIDX_TRG 0x1C80 +#define IWM_RFH_Q_FRBDCB_WIDX_TRG(q) (IWM_RFH_Q0_FRBDCB_WIDX_TRG + (q) * 4) +/* Read index table */ +#define IWM_RFH_Q0_FRBDCB_RIDX 0xA080C0 +#define IWM_RFH_Q_FRBDCB_RIDX(q) (IWM_RFH_Q0_FRBDCB_RIDX + (q) * 4) +/* Used list table */ +#define IWM_RFH_Q0_URBDCB_BA_LSB 0xA08100 /* 64 bit address */ +#define IWM_RFH_Q_URBDCB_BA_LSB(q) (IWM_RFH_Q0_URBDCB_BA_LSB + (q) * 8) +/* Write index table */ +#define IWM_RFH_Q0_URBDCB_WIDX 0xA08180 +#define IWM_RFH_Q_URBDCB_WIDX(q) (IWM_RFH_Q0_URBDCB_WIDX + (q) * 4) +#define IWM_RFH_Q0_URBDCB_VAID 0xA081C0 +#define IWM_RFH_Q_URBDCB_VAID(q) (IWM_RFH_Q0_URBDCB_VAID + (q) * 4) +/* stts */ +#define IWM_RFH_Q0_URBD_STTS_WPTR_LSB 0xA08200 /*64 bits address */ +#define IWM_RFH_Q_URBD_STTS_WPTR_LSB(q) (IWM_RFH_Q0_URBD_STTS_WPTR_LSB + (q) * 8) + +#define IWM_RFH_Q0_ORB_WPTR_LSB 0xA08280 +#define IWM_RFH_Q_ORB_WPTR_LSB(q) (IWM_RFH_Q0_ORB_WPTR_LSB + (q) * 8) +#define IWM_RFH_RBDBUF_RBD0_LSB 0xA08300 +#define IWM_RFH_RBDBUF_RBD_LSB(q) (IWM_RFH_RBDBUF_RBD0_LSB + (q) * 8) + +/** + * RFH Status Register + * + * Bit fields: + * + * Bit 29: RBD_FETCH_IDLE + * This status flag is set by the RFH when there is no active RBD fetch from + * DRAM. + * Once the RFH RBD controller starts fetching (or when there is a pending + * RBD read response from DRAM), this flag is immediately turned off. + * + * Bit 30: SRAM_DMA_IDLE + * This status flag is set by the RFH when there is no active transaction from + * SRAM to DRAM. + * Once the SRAM to DRAM DMA is active, this flag is immediately turned off. + * + * Bit 31: RXF_DMA_IDLE + * This status flag is set by the RFH when there is no active transaction from + * RXF to DRAM. + * Once the RXF-to-DRAM DMA is active, this flag is immediately turned off. + */ +#define IWM_RFH_GEN_STATUS 0xA09808 +#define IWM_RFH_GEN_STATUS_GEN3 0xA07824 +#define IWM_RBD_FETCH_IDLE (1 << 29) +#define IWM_SRAM_DMA_IDLE (1 << 30) +#define IWM_RXF_DMA_IDLE (1U << 31) + +/* DMA configuration */ +#define IWM_RFH_RXF_DMA_CFG 0xA09820 +#define IWM_RFH_RXF_DMA_CFG_GEN3 0xA07880 +/* RB size */ +#define IWM_RFH_RXF_DMA_RB_SIZE_MASK (0x000F0000) /* bits 16-19 */ +#define IWM_RFH_RXF_DMA_RB_SIZE_POS 16 +#define IWM_RFH_RXF_DMA_RB_SIZE_1K (0x1 << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_2K (0x2 << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_4K (0x4 << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_8K (0x8 << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_12K (0x9 << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_16K (0xA << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_20K (0xB << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_24K (0xC << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_28K (0xD << IWM_RFH_RXF_DMA_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RB_SIZE_32K (0xE << IWM_RFH_RXF_DMA_RB_SIZE_POS) +/* RB Circular Buffer size:defines the table sizes in RBD units */ +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_MASK (0x00F00000) /* bits 20-23 */ +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_POS 20 +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_8 (0x3 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_16 (0x4 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_32 (0x5 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_64 (0x7 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_128 (0x7 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_256 (0x8 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_512 (0x9 << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_1024 (0xA << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_RBDCB_SIZE_2048 (0xB << IWM_RFH_RXF_DMA_RBDCB_SIZE_POS) +#define IWM_RFH_RXF_DMA_MIN_RB_SIZE_MASK (0x03000000) /* bit 24-25 */ +#define IWM_RFH_RXF_DMA_MIN_RB_SIZE_POS 24 +#define IWM_RFH_RXF_DMA_MIN_RB_4_8 (3 << IWM_RFH_RXF_DMA_MIN_RB_SIZE_POS) +#define IWM_RFH_RXF_DMA_DROP_TOO_LARGE_MASK (0x04000000) /* bit 26 */ +#define IWM_RFH_RXF_DMA_SINGLE_FRAME_MASK (0x20000000) /* bit 29 */ +#define IWM_RFH_DMA_EN_MASK (0xC0000000) /* bits 30-31*/ +#define IWM_RFH_DMA_EN_ENABLE_VAL (1U << 31) + +#define IWM_RFH_RXF_RXQ_ACTIVE 0xA0980C + +#define IWM_RFH_GEN_CFG 0xA09800 +#define IWM_RFH_GEN_CFG_SERVICE_DMA_SNOOP (1 << 0) +#define IWM_RFH_GEN_CFG_RFH_DMA_SNOOP (1 << 1) +#define IWM_RFH_GEN_CFG_RB_CHUNK_SIZE_128 0x00000010 +#define IWM_RFH_GEN_CFG_RB_CHUNK_SIZE_64 0x00000000 +/* the driver assumes everywhere that the default RXQ is 0 */ +#define IWM_RFH_GEN_CFG_DEFAULT_RXQ_NUM 0xF00 + +/* end of 9000 rx series registers */ + #define IWM_LMPM_SECURE_UCODE_LOAD_CPU1_HDR_ADDR 0x1e78 #define IWM_LMPM_SECURE_UCODE_LOAD_CPU2_HDR_ADDR 0x1e7c @@ -457,10 +557,6 @@ enum iwm_secure_boot_status_reg { #define IWM_LMPM_CHICK 0xa01ff8 #define IWM_LMPM_CHICK_EXTENDED_ADDR_SPACE 0x01 -#define IWM_UREG_CHICK 0xa05c00 -#define IWM_UREG_CHICK_MSI_ENABLE 0x01000000 -#define IWM_UREG_CHICK_MSIX_ENABLE 0x02000000 - #define IWM_FH_TCSR_0_REG0 (0x1D00) /* @@ -530,6 +626,8 @@ enum iwm_secure_boot_status_reg { #define IWM_AUX_MISC_MASTER1_SMPHR_STATUS 0xa20800 #define IWM_RSA_ENABLE 0xa24b08 #define IWM_PREG_AUX_BUS_WPROT_0 0xa04cc0 +#define IWM_PREG_PRPH_WPROT_9000 0xa04ce0 +#define IWM_PREG_PRPH_WPROT_22000 0xa04d00 #define IWM_SB_CFG_OVERRIDE_ADDR 0xa26c78 #define IWM_SB_CFG_OVERRIDE_ENABLE 0x8000 #define IWM_SB_CFG_BASE_OVERRIDE 0xa20000 @@ -537,6 +635,14 @@ enum iwm_secure_boot_status_reg { #define IWM_SB_CPU_1_STATUS 0xa01e30 #define IWM_SB_CPU_2_STATUS 0Xa01e34 +#define IWM_UREG_CHICK 0xa05c00 +#define IWM_UREG_CHICK_MSI_ENABLE (1 << 24) +#define IWM_UREG_CHICK_MSIX_ENABLE (1 << 25) + +#define IWM_HPM_DEBUG 0xa03440 +#define IWM_HPM_PERSISTENCE_BIT (1 << 12) +#define IWM_PREG_WFPM_ACCESS (1 << 12) + /* Used to enable DBGM */ #define IWM_HBUS_TARG_TEST_REG (IWM_HBUS_BASE+0x05c) @@ -562,25 +668,51 @@ enum iwm_secure_boot_status_reg { #define IWM_HOST_INT_TIMEOUT_MAX (0xFF) #define IWM_HOST_INT_TIMEOUT_DEF (0x40) #define IWM_HOST_INT_TIMEOUT_MIN (0x0) -#define IWM_HOST_INT_OPER_MODE (1 << 31) +#define IWM_HOST_INT_OPER_MODE (1U << 31) /***************************************************************************** * 7000/3000 series SHR DTS addresses * *****************************************************************************/ /* Diode Results Register Structure: */ -enum iwm_dtd_diode_reg { - IWM_DTS_DIODE_REG_DIG_VAL = 0x000000FF, /* bits [7:0] */ - IWM_DTS_DIODE_REG_VREF_LOW = 0x0000FF00, /* bits [15:8] */ - IWM_DTS_DIODE_REG_VREF_HIGH = 0x00FF0000, /* bits [23:16] */ - IWM_DTS_DIODE_REG_VREF_ID = 0x03000000, /* bits [25:24] */ - IWM_DTS_DIODE_REG_PASS_ONCE = 0x80000000, /* bits [31:31] */ - IWM_DTS_DIODE_REG_FLAGS_MSK = 0xFF000000, /* bits [31:24] */ +#define IWM_DTS_DIODE_REG_DIG_VAL 0x000000FF /* bits [7:0] */ +#define IWM_DTS_DIODE_REG_VREF_LOW 0x0000FF00 /* bits [15:8] */ +#define IWM_DTS_DIODE_REG_VREF_HIGH 0x00FF0000 /* bits [23:16] */ +#define IWM_DTS_DIODE_REG_VREF_ID 0x03000000 /* bits [25:24] */ +#define IWM_DTS_DIODE_REG_PASS_ONCE 0x80000000 /* bits [31:31] */ +#define IWM_DTS_DIODE_REG_FLAGS_MSK 0xFF000000 /* bits [31:24] */ /* Those are the masks INSIDE the flags bit-field: */ - IWM_DTS_DIODE_REG_FLAGS_VREFS_ID_POS = 0, - IWM_DTS_DIODE_REG_FLAGS_VREFS_ID = 0x00000003, /* bits [1:0] */ - IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE_POS = 7, - IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE = 0x00000080, /* bits [7:7] */ +#define IWM_DTS_DIODE_REG_FLAGS_VREFS_ID_POS 0 +#define IWM_DTS_DIODE_REG_FLAGS_VREFS_ID 0x00000003 /* bits [1:0] */ +#define IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE_POS 7 +#define IWM_DTS_DIODE_REG_FLAGS_PASS_ONCE 0x00000080 /* bits [7:7] */ + +/***************************************************************************** + * MSIX related registers * + *****************************************************************************/ + +#define IWM_CSR_MSIX_BASE (0x2000) +#define IWM_CSR_MSIX_FH_INT_CAUSES_AD (IWM_CSR_MSIX_BASE + 0x800) +#define IWM_CSR_MSIX_FH_INT_MASK_AD (IWM_CSR_MSIX_BASE + 0x804) +#define IWM_CSR_MSIX_HW_INT_CAUSES_AD (IWM_CSR_MSIX_BASE + 0x808) +#define IWM_CSR_MSIX_HW_INT_MASK_AD (IWM_CSR_MSIX_BASE + 0x80C) +#define IWM_CSR_MSIX_AUTOMASK_ST_AD (IWM_CSR_MSIX_BASE + 0x810) +#define IWM_CSR_MSIX_RX_IVAR_AD_REG (IWM_CSR_MSIX_BASE + 0x880) +#define IWM_CSR_MSIX_IVAR_AD_REG (IWM_CSR_MSIX_BASE + 0x890) +#define IWM_CSR_MSIX_PENDING_PBA_AD (IWM_CSR_MSIX_BASE + 0x1000) +#define IWM_CSR_MSIX_RX_IVAR(cause) (IWM_CSR_MSIX_RX_IVAR_AD_REG + (cause)) +#define IWM_CSR_MSIX_IVAR(cause) (IWM_CSR_MSIX_IVAR_AD_REG + (cause)) + +/* + * Causes for the FH register interrupts + */ +enum msix_fh_int_causes { + IWM_MSIX_FH_INT_CAUSES_Q0 = (1 << 0), + IWM_MSIX_FH_INT_CAUSES_Q1 = (1 << 1), + IWM_MSIX_FH_INT_CAUSES_D2S_CH0_NUM = (1 << 16), + IWM_MSIX_FH_INT_CAUSES_D2S_CH1_NUM = (1 << 17), + IWM_MSIX_FH_INT_CAUSES_S2D = (1 << 19), + IWM_MSIX_FH_INT_CAUSES_FH_ERR = (1 << 21), }; /* @@ -591,13 +723,58 @@ enum iwm_dtd_diode_reg { * BEGIN iwl-fw.h */ +/* + * Causes for the HW register interrupts + */ +enum msix_hw_int_causes { + IWM_MSIX_HW_INT_CAUSES_REG_ALIVE = (1 << 0), + IWM_MSIX_HW_INT_CAUSES_REG_WAKEUP = (1 << 1), + IWM_MSIX_HW_INT_CAUSES_REG_IPC = (1 << 1), + IWM_MSIX_HW_INT_CAUSES_REG_IML = (1 << 2), + IWM_MSIX_HW_INT_CAUSES_REG_SW_ERR_V2 = (1 << 5), + IWM_MSIX_HW_INT_CAUSES_REG_CT_KILL = (1 << 6), + IWM_MSIX_HW_INT_CAUSES_REG_RF_KILL = (1 << 7), + IWM_MSIX_HW_INT_CAUSES_REG_PERIODIC = (1 << 8), + IWM_MSIX_HW_INT_CAUSES_REG_SW_ERR = (1 << 25), + IWM_MSIX_HW_INT_CAUSES_REG_SCD = (1 << 26), + IWM_MSIX_HW_INT_CAUSES_REG_FH_TX = (1 << 27), + IWM_MSIX_HW_INT_CAUSES_REG_HW_ERR = (1 << 29), + IWM_MSIX_HW_INT_CAUSES_REG_HAP = (1 << 30), +}; + +/* + * Registers to map causes to vectors + */ +enum msix_ivar_for_cause { + IWM_MSIX_IVAR_CAUSE_D2S_CH0_NUM = 0x0, + IWM_MSIX_IVAR_CAUSE_D2S_CH1_NUM = 0x1, + IWM_MSIX_IVAR_CAUSE_S2D = 0x3, + IWM_MSIX_IVAR_CAUSE_FH_ERR = 0x5, + IWM_MSIX_IVAR_CAUSE_REG_ALIVE = 0x10, + IWM_MSIX_IVAR_CAUSE_REG_WAKEUP = 0x11, + IWM_MSIX_IVAR_CAUSE_REG_IML = 0x12, + IWM_MSIX_IVAR_CAUSE_REG_CT_KILL = 0x16, + IWM_MSIX_IVAR_CAUSE_REG_RF_KILL = 0x17, + IWM_MSIX_IVAR_CAUSE_REG_PERIODIC = 0x18, + IWM_MSIX_IVAR_CAUSE_REG_SW_ERR = 0x29, + IWM_MSIX_IVAR_CAUSE_REG_SCD = 0x2a, + IWM_MSIX_IVAR_CAUSE_REG_FH_TX = 0x2b, + IWM_MSIX_IVAR_CAUSE_REG_HW_ERR = 0x2d, + IWM_MSIX_IVAR_CAUSE_REG_HAP = 0x2e, +}; + +#define IWM_MSIX_AUTO_CLEAR_CAUSE (0 << 7) +#define IWM_MSIX_NON_AUTO_CLEAR_CAUSE (1 << 7) + /** - * enum iwm_ucode_tlv_flag - ucode API flags + * uCode API flags * @IWM_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously * was a separate TLV but moved here to save space. * @IWM_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID, * treats good CRC threshold as a boolean * @IWM_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). + * @IWM_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. + * @IWM_UCODE_TLV_FLAGS_DW_BC_TABLE: The SCD byte count table is in DWORDS * @IWM_UCODE_TLV_FLAGS_UAPSD: This uCode image supports uAPSD * @IWM_UCODE_TLV_FLAGS_SHORT_BL: 16 entries of black list instead of 64 in scan * offload profile config command. @@ -607,39 +784,48 @@ enum iwm_dtd_diode_reg { * from the probe request template. * @IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL: new NS offload (small version) * @IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE: new NS offload (large version) + * @IWM_UCODE_TLV_FLAGS_P2P_PS: P2P client power save is supported (only on a + * single bound interface). * @IWM_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD * @IWM_UCODE_TLV_FLAGS_EBS_SUPPORT: this uCode image supports EBS. * @IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save * @IWM_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering. + * @IWM_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients + * */ -enum iwm_ucode_tlv_flag { - IWM_UCODE_TLV_FLAGS_PAN = (1 << 0), - IWM_UCODE_TLV_FLAGS_NEWSCAN = (1 << 1), - IWM_UCODE_TLV_FLAGS_MFP = (1 << 2), - IWM_UCODE_TLV_FLAGS_SHORT_BL = (1 << 7), - IWM_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS = (1 << 10), - IWM_UCODE_TLV_FLAGS_NO_BASIC_SSID = (1 << 12), - IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL = (1 << 15), - IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE = (1 << 16), - IWM_UCODE_TLV_FLAGS_UAPSD_SUPPORT = (1 << 24), - IWM_UCODE_TLV_FLAGS_EBS_SUPPORT = (1 << 25), - IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD = (1 << 26), - IWM_UCODE_TLV_FLAGS_BCAST_FILTERING = (1 << 29), -}; +#define IWM_UCODE_TLV_FLAGS_PAN (1 << 0) +#define IWM_UCODE_TLV_FLAGS_NEWSCAN (1 << 1) +#define IWM_UCODE_TLV_FLAGS_MFP (1 << 2) +#define IWM_UCODE_TLV_FLAGS_P2P (1 << 3) +#define IWM_UCODE_TLV_FLAGS_DW_BC_TABLE (1 << 4) +#define IWM_UCODE_TLV_FLAGS_SHORT_BL (1 << 7) +#define IWM_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS (1 << 10) +#define IWM_UCODE_TLV_FLAGS_NO_BASIC_SSID (1 << 12) +#define IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL (1 << 15) +#define IWM_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE (1 << 16) +#define IWM_UCODE_TLV_FLAGS_P2P_PS (1 << 21) +#define IWM_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM (1 << 22) +#define IWM_UCODE_TLV_FLAGS_BSS_P2P_PS_SCM (1 << 23) +#define IWM_UCODE_TLV_FLAGS_UAPSD_SUPPORT (1 << 24) +#define IWM_UCODE_TLV_FLAGS_EBS_SUPPORT (1 << 25) +#define IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD (1 << 26) +#define IWM_UCODE_TLV_FLAGS_BCAST_FILTERING (1 << 29) +#define IWM_UCODE_TLV_FLAGS_GO_UAPSD (1 << 30) +#define IWM_UCODE_TLV_FLAGS_LTE_COEX (1U << 31) #define IWM_UCODE_TLV_FLAG_BITS \ - "\020\1PAN\2NEWSCAN\3MFP\4P2P\5DW_BC_TABLE\6NEWBT_COEX\7PM_CMD\10SHORT_BL\11RX_ENERG \ -Y\12TIME_EVENT_V2\13D3_6_IPV6\14BF_UPDATED\15NO_BASIC_SSID\17D3_CONTINUITY\20NEW_NSOFF \ -L_S\21NEW_NSOFFL_L\22SCHED_SCAN\24STA_KEY_CMD\25DEVICE_PS_CMD\26P2P_PS\27P2P_PS_DCM\30 \ -P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40LTE_COEX" + "\020\1PAN\2NEWSCAN\3MFP\4P2P\5DW_BC_TABLE\6NEWBT_COEX\7PM_CMD\10SHORT_BL\11RX_ENERGY\12TIME_EVENT_V2\13D3_6_IPV6\14BF_UPDATED\15NO_BASIC_SSID\17D3_CONTINUITY\20NEW_NSOFFL_S\21NEW_NSOFFL_L\22SCHED_SCAN\24STA_KEY_CMD\25DEVICE_PS_CMD\26P2P_PS\27P2P_PS_DCM\30P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40LTE_COEX" /** - * enum iwm_ucode_tlv_api - ucode api + * uCode TLV api * @IWM_UCODE_TLV_API_FRAGMENTED_SCAN: This ucode supports active dwell time * longer than the passive one, which is essential for fragmented scan. * @IWM_UCODE_TLV_API_WIFI_MCC_UPDATE: ucode supports MCC updates with source. + * @IWM_UCODE_TLV_API_WIDE_CMD_HDR: ucode supports wide command header * @IWM_UCODE_TLV_API_LQ_SS_PARAMS: Configure STBC/BFER via LQ CMD ss_params * @IWM_UCODE_TLV_API_NEW_VERSION: new versioning format + * @IWM_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size + * (command version 3) that supports per-chain limits * @IWM_UCODE_TLV_API_SCAN_TSF_REPORT: Scan start time reported in scan * iteration complete notification, and the timestamp reported for RX * received during scan, are reported in TSF of the mac specified in the @@ -647,71 +833,35 @@ P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40L * @IWM_UCODE_TLV_API_TKIP_MIC_KEYS: This ucode supports version 2 of * ADD_MODIFY_STA_KEY_API_S_VER_2. * @IWM_UCODE_TLV_API_STA_TYPE: This ucode supports station type assignement. - * @IWM_UCODE_TLV_API_NAN2_VER2: This ucode supports NAN API version 2 + * @IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY: scan APIs use 8-level priority + * instead of 3. * @IWM_UCODE_TLV_API_NEW_RX_STATS: should new RX STATISTICS API be used - * @IWM_UCODE_TLV_API_QUOTA_LOW_LATENCY: Quota command includes a field - * indicating low latency direction. - * @IWM_UCODE_TLV_API_DEPRECATE_TTAK: RX status flag TTAK ok (bit 7) is - * deprecated. - * @IWM_UCODE_TLV_API_ADAPTIVE_DWELL_V2: This ucode supports version 8 - * of scan request: SCAN_REQUEST_CMD_UMAC_API_S_VER_8 - * @IWM_UCODE_TLV_API_FRAG_EBS: This ucode supports fragmented EBS - * @IWM_UCODE_TLV_API_REDUCE_TX_POWER: This ucode supports v5 of - * the REDUCE_TX_POWER_CMD. - * @IWM_UCODE_TLV_API_SHORT_BEACON_NOTIF: This ucode supports the short - * version of the beacon notification. - * @IWM_UCODE_TLV_API_BEACON_FILTER_V4: This ucode supports v4 of - * BEACON_FILTER_CONFIG_API_S_VER_4. - * @IWM_UCODE_TLV_API_REGULATORY_NVM_INFO: This ucode supports v4 of - * REGULATORY_NVM_GET_INFO_RSP_API_S. - * @IWM_UCODE_TLV_API_FTM_NEW_RANGE_REQ: This ucode supports v7 of - * LOCATION_RANGE_REQ_CMD_API_S and v6 of LOCATION_RANGE_RESP_NTFY_API_S. - * @IWM_UCODE_TLV_API_SCAN_OFFLOAD_CHANS: This ucode supports v2 of - * SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S and v3 of - * SCAN_OFFLOAD_PROFILES_QUERY_RSP_S. - * @IWM_UCODE_TLV_API_MBSSID_HE: This ucode supports v2 of - * STA_CONTEXT_DOT11AX_API_S - * @IWM_UCODE_TLV_CAPA_SAR_TABLE_VER: This ucode supports different sar - * version tables. * * @IWM_NUM_UCODE_TLV_API: number of bits used */ -enum iwm_ucode_tlv_api { - IWM_UCODE_TLV_API_FRAGMENTED_SCAN = 8, - IWM_UCODE_TLV_API_WIFI_MCC_UPDATE = 9, - IWM_UCODE_TLV_API_LQ_SS_PARAMS = 18, - IWM_UCODE_TLV_API_NEW_VERSION = 20, - IWM_UCODE_TLV_API_SCAN_TSF_REPORT = 28, - IWM_UCODE_TLV_API_TKIP_MIC_KEYS = 29, - IWM_UCODE_TLV_API_STA_TYPE = 30, - IWM_UCODE_TLV_API_NAN2_VER2 = 31, - IWM_UCODE_TLV_API_ADAPTIVE_DWELL = 32, - IWM_UCODE_TLV_API_OCE = 33, - IWM_UCODE_TLV_API_NEW_BEACON_TEMPLATE = 34, - IWM_UCODE_TLV_API_NEW_RX_STATS = 35, - IWM_UCODE_TLV_API_WOWLAN_KEY_MATERIAL = 36, - IWM_UCODE_TLV_API_QUOTA_LOW_LATENCY = 38, - IWM_UCODE_TLV_API_DEPRECATE_TTAK = 41, - IWM_UCODE_TLV_API_ADAPTIVE_DWELL_V2 = 42, - IWM_UCODE_TLV_API_FRAG_EBS = 44, - IWM_UCODE_TLV_API_REDUCE_TX_POWER = 45, - IWM_UCODE_TLV_API_SHORT_BEACON_NOTIF = 46, - IWM_UCODE_TLV_API_BEACON_FILTER_V4 = 47, - IWM_UCODE_TLV_API_REGULATORY_NVM_INFO = 48, - IWM_UCODE_TLV_API_FTM_NEW_RANGE_REQ = 49, - IWM_UCODE_TLV_API_SCAN_OFFLOAD_CHANS = 50, - IWM_UCODE_TLV_API_MBSSID_HE = 52, - IWM_UCODE_TLV_API_WOWLAN_TCP_SYN_WAKE = 53, - IWM_UCODE_TLV_API_FTM_RTT_ACCURACY = 54, - IWM_UCODE_TLV_API_SAR_TABLE_VER = 55, - IWM_UCODE_TLV_API_ADWELL_HB_DEF_N_AP = 57, - IWM_UCODE_TLV_API_SCAN_EXT_CHAN_VER = 58, - - IWM_NUM_UCODE_TLV_API = 128, -}; - -/** - * enum iwm_ucode_tlv_capa - ucode capabilities +#define IWM_UCODE_TLV_API_FRAGMENTED_SCAN 8 +#define IWM_UCODE_TLV_API_WIFI_MCC_UPDATE 9 +#define IWM_UCODE_TLV_API_WIDE_CMD_HDR 14 +#define IWM_UCODE_TLV_API_LQ_SS_PARAMS 18 +#define IWM_UCODE_TLV_API_NEW_VERSION 20 +#define IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY 24 +#define IWM_UCODE_TLV_API_TX_POWER_CHAIN 27 +#define IWM_UCODE_TLV_API_SCAN_TSF_REPORT 28 +#define IWM_UCODE_TLV_API_TKIP_MIC_KEYS 29 +#define IWM_UCODE_TLV_API_STA_TYPE 30 +#define IWM_UCODE_TLV_API_NAN2_VER2 31 +#define IWM_UCODE_TLV_API_ADAPTIVE_DWELL 32 +#define IWM_UCODE_TLV_API_NEW_RX_STATS 35 +#define IWM_UCODE_TLV_API_QUOTA_LOW_LATENCY 38 +#define IWM_UCODE_TLV_API_ADAPTIVE_DWELL_V2 42 +#define IWM_UCODE_TLV_API_SCAN_EXT_CHAN_VER 58 +#define IWM_NUM_UCODE_TLV_API 128 + +#define IWM_UCODE_TLV_API_BITS \ + "\020\10FRAGMENTED_SCAN\11WIFI_MCC_UPDATE\16WIDE_CMD_HDR\22LQ_SS_PARAMS\30EXT_SCAN_PRIO\33TX_POWER_CHAIN\35TKIP_MIC_KEYS" + +/** + * uCode capabilities * @IWM_UCODE_TLV_CAPA_D0I3_SUPPORT: supports D0i3 * @IWM_UCODE_TLV_CAPA_LAR_SUPPORT: supports Location Aware Regulatory * @IWM_UCODE_TLV_CAPA_UMAC_SCAN: supports UMAC scan. @@ -763,55 +913,57 @@ enum iwm_ucode_tlv_api { * @IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG: support getting more shared * memory addresses from the firmware. * @IWM_UCODE_TLV_CAPA_LQM_SUPPORT: supports Link Quality Measurement - * @IWM_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger - * command size (command version 4) that supports toggling ACK TX - * power reduction. + * @IWM_UCODE_TLV_CAPA_LMAC_UPLOAD: supports upload mode in lmac (1=supported, + * 0=no support) * * @IWM_NUM_UCODE_TLV_CAPA: number of bits used */ -enum iwm_ucode_tlv_capa { - IWM_UCODE_TLV_CAPA_D0I3_SUPPORT = 0, - IWM_UCODE_TLV_CAPA_LAR_SUPPORT = 1, - IWM_UCODE_TLV_CAPA_UMAC_SCAN = 2, - IWM_UCODE_TLV_CAPA_BEAMFORMER = 3, - IWM_UCODE_TLV_CAPA_TOF_SUPPORT = 5, - IWM_UCODE_TLV_CAPA_TDLS_SUPPORT = 6, - IWM_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT = 8, - IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT = 9, - IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT = 10, - IWM_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT = 11, - IWM_UCODE_TLV_CAPA_DQA_SUPPORT = 12, - IWM_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH = 13, - IWM_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG = 17, - IWM_UCODE_TLV_CAPA_HOTSPOT_SUPPORT = 18, - IWM_UCODE_TLV_CAPA_DC2DC_CONFIG_SUPPORT = 19, - IWM_UCODE_TLV_CAPA_2G_COEX_SUPPORT = 20, - IWM_UCODE_TLV_CAPA_CSUM_SUPPORT = 21, - IWM_UCODE_TLV_CAPA_RADIO_BEACON_STATS = 22, - IWM_UCODE_TLV_CAPA_P2P_STANDALONE_UAPSD = 26, - IWM_UCODE_TLV_CAPA_BT_COEX_PLCR = 28, - IWM_UCODE_TLV_CAPA_LAR_MULTI_MCC = 29, - IWM_UCODE_TLV_CAPA_BT_COEX_RRC = 30, - IWM_UCODE_TLV_CAPA_GSCAN_SUPPORT = 31, - IWM_UCODE_TLV_CAPA_NAN_SUPPORT = 34, - IWM_UCODE_TLV_CAPA_UMAC_UPLOAD = 35, - IWM_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE = 64, - IWM_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS = 65, - IWM_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT = 67, - IWM_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT = 68, - IWM_UCODE_TLV_CAPA_BEACON_ANT_SELECTION = 71, - IWM_UCODE_TLV_CAPA_BEACON_STORING = 72, - IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2 = 73, - IWM_UCODE_TLV_CAPA_CT_KILL_BY_FW = 74, - IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT = 75, - IWM_UCODE_TLV_CAPA_CTDP_SUPPORT = 76, - IWM_UCODE_TLV_CAPA_USNIFFER_UNIFIED = 77, - IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG = 80, - IWM_UCODE_TLV_CAPA_LQM_SUPPORT = 81, - IWM_UCODE_TLV_CAPA_TX_POWER_ACK = 84, - - IWM_NUM_UCODE_TLV_CAPA = 128 -}; +#define IWM_UCODE_TLV_CAPA_D0I3_SUPPORT 0 +#define IWM_UCODE_TLV_CAPA_LAR_SUPPORT 1 +#define IWM_UCODE_TLV_CAPA_UMAC_SCAN 2 +#define IWM_UCODE_TLV_CAPA_BEAMFORMER 3 +#define IWM_UCODE_TLV_CAPA_TOF_SUPPORT 5 +#define IWM_UCODE_TLV_CAPA_TDLS_SUPPORT 6 +#define IWM_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT 8 +#define IWM_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT 9 +#define IWM_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT 10 +#define IWM_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT 11 +#define IWM_UCODE_TLV_CAPA_DQA_SUPPORT 12 +#define IWM_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH 13 +#define IWM_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG 17 +#define IWM_UCODE_TLV_CAPA_HOTSPOT_SUPPORT 18 +#define IWM_UCODE_TLV_CAPA_DC2DC_CONFIG_SUPPORT 19 +#define IWM_UCODE_TLV_CAPA_2G_COEX_SUPPORT 20 +#define IWM_UCODE_TLV_CAPA_CSUM_SUPPORT 21 +#define IWM_UCODE_TLV_CAPA_RADIO_BEACON_STATS 22 +#define IWM_UCODE_TLV_CAPA_P2P_STANDALONE_UAPSD 26 +#define IWM_UCODE_TLV_CAPA_BT_COEX_PLCR 28 +#define IWM_UCODE_TLV_CAPA_LAR_MULTI_MCC 29 +#define IWM_UCODE_TLV_CAPA_BT_COEX_RRC 30 +#define IWM_UCODE_TLV_CAPA_GSCAN_SUPPORT 31 +#define IWM_UCODE_TLV_CAPA_NAN_SUPPORT 34 +#define IWM_UCODE_TLV_CAPA_UMAC_UPLOAD 35 +#define IWM_UCODE_TLV_CAPA_SOC_LATENCY_SUPPORT 37 +#define IWM_UCODE_TLV_CAPA_BINDING_CDB_SUPPORT 39 +#define IWM_UCODE_TLV_CAPA_CDB_SUPPORT 40 +#define IWM_UCODE_TLV_CAPA_DYNAMIC_QUOTA 44 +#define IWM_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS 48 +#define IWM_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE 64 +#define IWM_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS 65 +#define IWM_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT 67 +#define IWM_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT 68 +#define IWM_UCODE_TLV_CAPA_BEACON_ANT_SELECTION 71 +#define IWM_UCODE_TLV_CAPA_BEACON_STORING 72 +#define IWM_UCODE_TLV_CAPA_LAR_SUPPORT_V2 73 +#define IWM_UCODE_TLV_CAPA_CT_KILL_BY_FW 74 +#define IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT 75 +#define IWM_UCODE_TLV_CAPA_CTDP_SUPPORT 76 +#define IWM_UCODE_TLV_CAPA_USNIFFER_UNIFIED 77 +#define IWM_UCODE_TLV_CAPA_LMAC_UPLOAD 79 +#define IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG 80 +#define IWM_UCODE_TLV_CAPA_LQM_SUPPORT 81 + +#define IWM_NUM_UCODE_TLV_CAPA 128 /* The default calibrate table size if not specified by firmware file */ #define IWM_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 @@ -821,17 +973,6 @@ enum iwm_ucode_tlv_capa { /* The default max probe length if not specified by the firmware file */ #define IWM_DEFAULT_MAX_PROBE_LENGTH 200 *** 4208 LINES SKIPPED *** From nobody Wed Oct 27 03:29:45 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 456B71812111; Wed, 27 Oct 2021 03:29:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfDhV1Ll1z507J; Wed, 27 Oct 2021 03:29:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A524C92; Wed, 27 Oct 2021 03:29:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19R3Tj3N025257; Wed, 27 Oct 2021 03:29:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19R3TjaX025256; Wed, 27 Oct 2021 03:29:45 GMT (envelope-from git) Date: Wed, 27 Oct 2021 03:29:45 GMT Message-Id: <202110270329.19R3TjaX025256@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: d524e370c4db - main - iwm: Update SCD register accesses List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d524e370c4dbabf607546aec6e4bcc8d64758851 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d524e370c4dbabf607546aec6e4bcc8d64758851 commit d524e370c4dbabf607546aec6e4bcc8d64758851 Author: Adrian Chadd AuthorDate: 2021-10-25 04:29:53 +0000 Commit: Adrian Chadd CommitDate: 2021-10-27 03:28:55 +0000 iwm: Update SCD register accesses This brings it inline with what's in openbsd. I tested it locally with 2G and 5G association; it seems to work. Tested: Intel 7260 AC, hw 0x140, STA mode, 2G/5G Differential Revision: https://reviews.freebsd.org/D32627 Subscribers: imp Obtainde from: OpenBSD --- sys/dev/iwm/if_iwmreg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/iwm/if_iwmreg.h b/sys/dev/iwm/if_iwmreg.h index c3c51a25c4b0..ee5c5ec07b21 100644 --- a/sys/dev/iwm/if_iwmreg.h +++ b/sys/dev/iwm/if_iwmreg.h @@ -1410,14 +1410,14 @@ static inline unsigned int IWM_SCD_QUEUE_RDPTR(unsigned int chnl) { if (chnl < 20) return IWM_SCD_BASE + 0x68 + chnl * 4; - return IWM_SCD_BASE + 0x2B4 + (chnl - 20) * 4; + return IWM_SCD_BASE + 0x2B4 + chnl * 4; } static inline unsigned int IWM_SCD_QUEUE_STATUS_BITS(unsigned int chnl) { if (chnl < 20) return IWM_SCD_BASE + 0x10c + chnl * 4; - return IWM_SCD_BASE + 0x384 + (chnl - 20) * 4; + return IWM_SCD_BASE + 0x334 + chnl * 4; } /*********************** END TX SCHEDULER *************************************/ From nobody Wed Oct 27 04:15:58 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id ADD231825BB7; Wed, 27 Oct 2021 04:15:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfFjp2fl7z3CQ2; Wed, 27 Oct 2021 04:15:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37891180B; Wed, 27 Oct 2021 04:15:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19R4FwjE091531; Wed, 27 Oct 2021 04:15:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19R4FwBQ091530; Wed, 27 Oct 2021 04:15:58 GMT (envelope-from git) Date: Wed, 27 Oct 2021 04:15:58 GMT Message-Id: <202110270415.19R4FwBQ091530@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 80abcfbdfe1a - main - bxe(4): Fix a few common typos in source code comments List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80abcfbdfe1af72318c2c0b1690013f43e875267 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=80abcfbdfe1af72318c2c0b1690013f43e875267 commit 80abcfbdfe1af72318c2c0b1690013f43e875267 Author: Gordon Bergling AuthorDate: 2021-10-27 04:15:06 +0000 Commit: Gordon Bergling CommitDate: 2021-10-27 04:15:06 +0000 bxe(4): Fix a few common typos in source code comments - s/controled/controlled/ - s/allignment/alignment/ MFC after: 3 days --- sys/dev/bxe/bxe_elink.c | 4 ++-- sys/dev/bxe/ecore_hsi.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/bxe/bxe_elink.c b/sys/dev/bxe/bxe_elink.c index bdd8affdb437..dd77e9301ab0 100644 --- a/sys/dev/bxe/bxe_elink.c +++ b/sys/dev/bxe/bxe_elink.c @@ -4418,7 +4418,7 @@ static uint8_t elink_ext_phy_resolve_fc(struct elink_phy *phy, uint8_t ret = 0; vars->flow_ctrl = ELINK_FLOW_CTRL_NONE; if (phy->req_flow_ctrl != ELINK_FLOW_CTRL_AUTO) { - /* Update the advertised flow-controled of LD/LP in AN */ + /* Update the advertised flow-controlled of LD/LP in AN */ if (phy->req_line_speed == ELINK_SPEED_AUTO_NEG) elink_ext_phy_update_adv_fc(phy, params, vars); /* But set the flow-control result as the requested one */ @@ -6262,7 +6262,7 @@ static void elink_flow_ctrl_resolve(struct elink_phy *phy, /* Resolve from gp_status in case of AN complete and not sgmii */ if (phy->req_flow_ctrl != ELINK_FLOW_CTRL_AUTO) { - /* Update the advertised flow-controled of LD/LP in AN */ + /* Update the advertised flow-controlled of LD/LP in AN */ if (phy->req_line_speed == ELINK_SPEED_AUTO_NEG) elink_update_adv_fc(phy, params, vars, gp_status); /* But set the flow-control result as the requested one */ diff --git a/sys/dev/bxe/ecore_hsi.h b/sys/dev/bxe/ecore_hsi.h index 5048ff5dfc78..22f0767e6b0f 100644 --- a/sys/dev/bxe/ecore_hsi.h +++ b/sys/dev/bxe/ecore_hsi.h @@ -9448,7 +9448,7 @@ struct iscsi_cq_db struct iscsi_cq_db_prod_pnd_cmpltn_cnt_arr cq_u_prod_pend_comp_ctr_arr /* Ustorm CQ producer and pending completion counter array, updated by Ustorm */; struct iscsi_cq_db_pnd_comp_itt_arr cq_c_pend_comp_itt_arr /* Cstorm CQ pending completion ITT array, updated by Cstorm */; struct iscsi_cq_db_sqn_2_notify_arr cq_drv_sqn_2_notify_arr /* Cstorm CQ sequence to notify array, updated by driver */; - uint32_t reserved[4] /* 16 byte allignment */; + uint32_t reserved[4] /* 16 byte alignment */; }; From nobody Wed Oct 27 04:16:34 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AB91C1825FBE; Wed, 27 Oct 2021 04:16:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfFkV3L6xz3CrV; Wed, 27 Oct 2021 04:16:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5279A1665; Wed, 27 Oct 2021 04:16:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19R4GYk1091686; Wed, 27 Oct 2021 04:16:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19R4GYpE091685; Wed, 27 Oct 2021 04:16:34 GMT (envelope-from git) Date: Wed, 27 Oct 2021 04:16:34 GMT Message-Id: <202110270416.19R4GYpE091685@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 70de1003da6f - main - jail(8): Fix a few common typos in source code comments List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 70de1003da6f6e78e32f92bd98c9f18f965e6663 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=70de1003da6f6e78e32f92bd98c9f18f965e6663 commit 70de1003da6f6e78e32f92bd98c9f18f965e6663 Author: Gordon Bergling AuthorDate: 2021-10-27 04:16:06 +0000 Commit: Gordon Bergling CommitDate: 2021-10-27 04:16:06 +0000 jail(8): Fix a few common typos in source code comments - s/phyiscal/physical/ MFC after: 3 days --- sys/kern/kern_jail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index c13aa73538a5..e9019eda4d6c 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -3618,7 +3618,7 @@ prison_priv_check(struct ucred *cred, int priv) /* * As in the non-jail case, non-root users are expected to be - * able to read kernel/phyiscal memory (provided /dev/[k]mem + * able to read kernel/physical memory (provided /dev/[k]mem * exists in the jail and they have permission to access it). */ case PRIV_KMEM_READ: From nobody Wed Oct 27 09:27:45 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CF8AF18140C7; Wed, 27 Oct 2021 09:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfNdY5bpdz3tKm; Wed, 27 Oct 2021 09:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C4C058CC; Wed, 27 Oct 2021 09:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19R9Rjd5004096; Wed, 27 Oct 2021 09:27:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19R9Rjic004095; Wed, 27 Oct 2021 09:27:45 GMT (envelope-from git) Date: Wed, 27 Oct 2021 09:27:45 GMT Message-Id: <202110270927.19R9Rjic004095@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexey Dokuchaev Subject: git: ccfdf335d697 - main - crunchgen: use realpath(3) instead of ``pwd -P'' List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: danfe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ccfdf335d6976bb0e3436b808418d14f3d150a3d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by danfe (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=ccfdf335d6976bb0e3436b808418d14f3d150a3d commit ccfdf335d6976bb0e3436b808418d14f3d150a3d Author: Alexey Dokuchaev AuthorDate: 2020-10-11 08:23:00 +0000 Commit: Alexey Dokuchaev CommitDate: 2021-10-27 09:26:00 +0000 crunchgen: use realpath(3) instead of ``pwd -P'' r366466 (9c7bd4f198e1) fixed a subtle bug by stripping the trailing '\n' appended to the output of popen("cd %s && pwd -P", p->srcdir). Replace this cumbersome implementation with a single realpath(3) call which avoids spawning a shell, reading from the stream with fgets(3), and final strdup(3). Reviewed by: arichardson, kevans Approved by: imp Differential Revision: https://reviews.freebsd.org/D26734 --- usr.sbin/crunch/crunchgen/crunchgen.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index 94792c5ec50b..89d549b18b4e 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -639,7 +639,6 @@ fillin_program(prog_t *p) { char path[MAXPATHLEN]; char line[MAXLINELEN]; - FILE *f; snprintf(line, MAXLINELEN, "filling in parms for %s", p->name); status(line); @@ -654,22 +653,9 @@ fillin_program(prog_t *p) /* Determine the actual srcdir (maybe symlinked). */ if (p->srcdir) { - snprintf(line, MAXLINELEN, "cd %s && pwd -P", p->srcdir); - f = popen(line,"r"); - if (!f) - errx(1, "Can't execute: %s\n", line); - - path[0] = '\0'; - fgets(path, sizeof path, f); - if (pclose(f)) - errx(1, "Can't execute: %s\n", line); - - if (!*path) - errx(1, "Can't perform pwd on: %s\n", p->srcdir); - - /* Chop off trailing newline. */ - path[strlen(path) - 1] = '\0'; - p->realsrcdir = strdup(path); + p->realsrcdir = realpath(p->srcdir, NULL); + if (p->realsrcdir == NULL) + errx(1, "Can't resolve path: %s\n", p->srcdir); } /* Unless the option to make object files was specified the From nobody Wed Oct 27 15:19:10 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D154E1812307; Wed, 27 Oct 2021 15:19:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfXR25TqWz3Cq6; Wed, 27 Oct 2021 15:19:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 987D912915; Wed, 27 Oct 2021 15:19:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RFJAYG070567; Wed, 27 Oct 2021 15:19:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFJA2g070566; Wed, 27 Oct 2021 15:19:10 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:19:10 GMT Message-Id: <202110271519.19RFJA2g070566@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 71f31d784e18 - main - rmslock: Update td_locks during lock and unlock operations List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71f31d784e1816a155cafbccf4b28291200097aa Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71f31d784e1816a155cafbccf4b28291200097aa commit 71f31d784e1816a155cafbccf4b28291200097aa Author: Mark Johnston AuthorDate: 2021-10-27 15:18:13 +0000 Commit: Mark Johnston CommitDate: 2021-10-27 15:18:13 +0000 rmslock: Update td_locks during lock and unlock operations Reviewed by: mjg MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32692 --- sys/kern/kern_rmlock.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 7230a00e357b..f9b5559a648c 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -1017,6 +1017,7 @@ rms_rlock_fallback(struct rmslock *rms) rms_int_readers_inc(rms, rms_int_pcpu(rms)); mtx_unlock(&rms->mtx); critical_exit(); + TD_LOCKS_INC(curthread); } void @@ -1040,6 +1041,7 @@ rms_rlock(struct rmslock *rms) atomic_interrupt_fence(); rms_int_influx_exit(rms, pcpu); critical_exit(); + TD_LOCKS_INC(curthread); } int @@ -1063,6 +1065,7 @@ rms_try_rlock(struct rmslock *rms) atomic_interrupt_fence(); rms_int_influx_exit(rms, pcpu); critical_exit(); + TD_LOCKS_INC(curthread); return (1); } @@ -1082,6 +1085,7 @@ rms_runlock_fallback(struct rmslock *rms) if (rms->readers == 0) wakeup_one(&rms->writers); mtx_unlock(&rms->mtx); + TD_LOCKS_DEC(curthread); } void @@ -1102,6 +1106,7 @@ rms_runlock(struct rmslock *rms) atomic_interrupt_fence(); rms_int_influx_exit(rms, pcpu); critical_exit(); + TD_LOCKS_DEC(curthread); } struct rmslock_ipi { @@ -1219,6 +1224,7 @@ out_grab: rms_assert_no_pcpu_readers(rms); mtx_unlock(&rms->mtx); MPASS(rms->readers == 0); + TD_LOCKS_INC(curthread); } void @@ -1239,6 +1245,7 @@ rms_wunlock(struct rmslock *rms) rms->owner = RMS_NOOWNER; } mtx_unlock(&rms->mtx); + TD_LOCKS_DEC(curthread); } void From nobody Wed Oct 27 15:22:56 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E17AA1813DDA; Wed, 27 Oct 2021 15:22:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfXWN4fHWz3Dpr; Wed, 27 Oct 2021 15:22:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 643ED129C7; Wed, 27 Oct 2021 15:22:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RFMuMa084000; Wed, 27 Oct 2021 15:22:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFMuX4083999; Wed, 27 Oct 2021 15:22:56 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:22:56 GMT Message-Id: <202110271522.19RFMuX4083999@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: e28330832be4 - main - tcp: socket option to get stack alias name List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e28330832be41d2ef012dda1dafef25895ab2c6b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=e28330832be41d2ef012dda1dafef25895ab2c6b commit e28330832be41d2ef012dda1dafef25895ab2c6b Author: Peter Lei AuthorDate: 2021-10-26 03:08:54 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-27 15:21:59 +0000 tcp: socket option to get stack alias name TCP stack sysctl nodes are currently inserted using the stack name alias. Allow the user to get the current stack's alias to allow for programatic sysctl access. Obtained from: Netflix --- sys/netinet/tcp.h | 1 + sys/netinet/tcp_subr.c | 31 +++++++++++++++++++++++++++++++ sys/netinet/tcp_usrreq.c | 15 +++++++++++---- sys/netinet/tcp_var.h | 1 + 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp.h b/sys/netinet/tcp.h index e7c47e85bb7b..6dc7403aae28 100644 --- a/sys/netinet/tcp.h +++ b/sys/netinet/tcp.h @@ -210,6 +210,7 @@ struct tcphdr { #define TCP_PCAP_OUT 2048 /* number of output packets to keep */ #define TCP_PCAP_IN 4096 /* number of input packets to keep */ #define TCP_FUNCTION_BLK 8192 /* Set the tcp function pointers to the specified stack */ +#define TCP_FUNCTION_ALIAS 8193 /* Get the current tcp function pointer name alias */ /* Options for Rack and BBR */ #define TCP_REUSPORT_LB_NUMA 1026 /* set listen socket numa domain */ #define TCP_RACK_MBUF_QUEUE 1050 /* Do we allow mbuf queuing if supported */ diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 9d66086a383b..2752773a95fc 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -473,6 +473,37 @@ find_and_ref_tcp_fb(struct tcp_function_block *blk) return(rblk); } +/* Find a matching alias for the given tcp_function_block. */ +int +find_tcp_function_alias(struct tcp_function_block *blk, + struct tcp_function_set *fs) +{ + struct tcp_function *f; + int found; + + found = 0; + rw_rlock(&tcp_function_lock); + TAILQ_FOREACH(f, &t_functions, tf_next) { + if ((f->tf_fb == blk) && + (strncmp(f->tf_name, blk->tfb_tcp_block_name, + TCP_FUNCTION_NAME_LEN_MAX) != 0)) { + /* Matching function block with different name. */ + strncpy(fs->function_set_name, f->tf_name, + TCP_FUNCTION_NAME_LEN_MAX); + found = 1; + break; + } + } + /* Null terminate the string appropriately. */ + if (found) { + fs->function_set_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0'; + } else { + fs->function_set_name[0] = '\0'; + } + rw_runlock(&tcp_function_lock); + return (found); +} + static struct tcp_function_block * find_and_ref_tcp_default_fb(void) { diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index e9f7fa541461..f004d54b4657 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1894,10 +1894,17 @@ err_out: INP_WUNLOCK(inp); return (error); } else if ((sopt->sopt_dir == SOPT_GET) && - (sopt->sopt_name == TCP_FUNCTION_BLK)) { - strncpy(fsn.function_set_name, tp->t_fb->tfb_tcp_block_name, - TCP_FUNCTION_NAME_LEN_MAX); - fsn.function_set_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0'; + ((sopt->sopt_name == TCP_FUNCTION_BLK) || + (sopt->sopt_name == TCP_FUNCTION_ALIAS))) { + if (sopt->sopt_name == TCP_FUNCTION_ALIAS) { + memset(&fsn, 0, sizeof(fsn)); + find_tcp_function_alias(tp->t_fb, &fsn); + } else { + strncpy(fsn.function_set_name, + tp->t_fb->tfb_tcp_block_name, + TCP_FUNCTION_NAME_LEN_MAX); + fsn.function_set_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0'; + } fsn.pcbcnt = tp->t_fb->tfb_refcnt; INP_WUNLOCK(inp); error = sooptcopyout(sopt, &fsn, sizeof fsn); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index d5b2963ef4dc..2775fb392a1a 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1020,6 +1020,7 @@ int register_tcp_functions_as_name(struct tcp_function_block *blk, int deregister_tcp_functions(struct tcp_function_block *blk, bool quiesce, bool force); struct tcp_function_block *find_and_ref_tcp_functions(struct tcp_function_set *fs); +int find_tcp_function_alias(struct tcp_function_block *blk, struct tcp_function_set *fs); void tcp_switch_back_to_default(struct tcpcb *tp); struct tcp_function_block * find_and_ref_tcp_fb(struct tcp_function_block *fs); From nobody Wed Oct 27 15:22:57 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D946B1813F35; Wed, 27 Oct 2021 15:22:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfXWP5Nlrz3DZJ; Wed, 27 Oct 2021 15:22:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8C36D126E9; Wed, 27 Oct 2021 15:22:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RFMvEM084024; Wed, 27 Oct 2021 15:22:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFMvHK084023; Wed, 27 Oct 2021 15:22:57 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:22:57 GMT Message-Id: <202110271522.19RFMvHK084023@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: fc4d53cc2ef3 - main - Split tcp_ctloutput() into set/get parts. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc4d53cc2ef3345ad36c874010c4abc2317a61f8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=fc4d53cc2ef3345ad36c874010c4abc2317a61f8 commit fc4d53cc2ef3345ad36c874010c4abc2317a61f8 Author: Gleb Smirnoff AuthorDate: 2021-10-26 03:38:31 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-27 15:21:59 +0000 Split tcp_ctloutput() into set/get parts. Reviewed by: rrs Differential Revision: https://reviews.freebsd.org/D32655 --- sys/netinet/tcp_usrreq.c | 125 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 90 insertions(+), 35 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index f004d54b4657..0fca9b88e6f3 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1729,22 +1729,18 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti) } while(0) #define INP_WLOCK_RECHECK(inp) INP_WLOCK_RECHECK_CLEANUP((inp), /* noop */) -int -tcp_ctloutput(struct socket *so, struct sockopt *sopt) +static int +tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) { - int error; - struct inpcb *inp; - struct tcpcb *tp; - struct tcp_function_block *blk; - struct tcp_function_set fsn; + struct tcpcb *tp = intotcpcb(inp); + int error = 0; + + MPASS(sopt->sopt_dir == SOPT_SET); - error = 0; - inp = sotoinpcb(so); - KASSERT(inp != NULL, ("tcp_ctloutput: inp == NULL")); if (sopt->sopt_level != IPPROTO_TCP) { #ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) { - error = ip6_ctloutput(so, sopt); + error = ip6_ctloutput(inp->inp_socket, sopt); /* * In case of the IPV6_USE_MIN_MTU socket option, * the INC_IPV6MINMTU flag to announce a corresponding @@ -1755,7 +1751,6 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt) * be fragmented at the IPv6 layer. */ if ((error == 0) && - (sopt->sopt_dir == SOPT_SET) && (sopt->sopt_level == IPPROTO_IPV6) && (sopt->sopt_name == IPV6_USE_MIN_MTU)) { INP_WLOCK(inp); @@ -1788,29 +1783,29 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt) #endif #ifdef INET { - error = ip_ctloutput(so, sopt); + error = ip_ctloutput(inp->inp_socket, sopt); } #endif return (error); - } - INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { - INP_WUNLOCK(inp); - return (ECONNRESET); - } - tp = intotcpcb(inp); - /* - * Protect the TCP option TCP_FUNCTION_BLK so - * that a sub-function can *never* overwrite this. - */ - if ((sopt->sopt_dir == SOPT_SET) && - (sopt->sopt_name == TCP_FUNCTION_BLK)) { - INP_WUNLOCK(inp); - error = sooptcopyin(sopt, &fsn, sizeof fsn, - sizeof fsn); + } else if (sopt->sopt_name == TCP_FUNCTION_BLK) { + /* + * Protect the TCP option TCP_FUNCTION_BLK so + * that a sub-function can *never* overwrite this. + */ + struct tcp_function_set fsn; + struct tcp_function_block *blk; + + error = sooptcopyin(sopt, &fsn, sizeof fsn, sizeof fsn); if (error) return (error); - INP_WLOCK_RECHECK(inp); + + INP_WLOCK(inp); + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + INP_WUNLOCK(inp); + return (ECONNRESET); + } + tp = intotcpcb(inp); + blk = find_and_ref_tcp_functions(&fsn); if (blk == NULL) { INP_WUNLOCK(inp); @@ -1875,7 +1870,7 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt) if((*tp->t_fb->tfb_tcp_fb_init)(tp) != 0) { /* Fall back failed, drop the connection */ INP_WUNLOCK(inp); - soabort(so); + soabort(inp->inp_socket); return(error); } } @@ -1893,9 +1888,50 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt) err_out: INP_WUNLOCK(inp); return (error); - } else if ((sopt->sopt_dir == SOPT_GET) && - ((sopt->sopt_name == TCP_FUNCTION_BLK) || + } + + INP_WLOCK(inp); + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + INP_WUNLOCK(inp); + return (ECONNRESET); + } + tp = intotcpcb(inp); + + /* Pass in the INP locked, caller must unlock it. */ + return (tp->t_fb->tfb_tcp_ctloutput(inp->inp_socket, sopt, inp, tp)); +} + +static int +tcp_ctloutput_get(struct inpcb *inp, struct sockopt *sopt) +{ + int error = 0; + struct tcpcb *tp; + + MPASS(sopt->sopt_dir == SOPT_GET); + + if (sopt->sopt_level != IPPROTO_TCP) { +#ifdef INET6 + if (inp->inp_vflag & INP_IPV6PROTO) + error = ip6_ctloutput(inp->inp_socket, sopt); +#endif /* INET6 */ +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET + error = ip_ctloutput(inp->inp_socket, sopt); +#endif + return (error); + } + INP_WLOCK(inp); + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + INP_WUNLOCK(inp); + return (ECONNRESET); + } + tp = intotcpcb(inp); + if (((sopt->sopt_name == TCP_FUNCTION_BLK) || (sopt->sopt_name == TCP_FUNCTION_ALIAS))) { + struct tcp_function_set fsn; + if (sopt->sopt_name == TCP_FUNCTION_ALIAS) { memset(&fsn, 0, sizeof(fsn)); find_tcp_function_alias(tp->t_fb, &fsn); @@ -1910,8 +1946,27 @@ err_out: error = sooptcopyout(sopt, &fsn, sizeof fsn); return (error); } - /* Pass in the INP locked, called must unlock it */ - return (tp->t_fb->tfb_tcp_ctloutput(so, sopt, inp, tp)); + + /* Pass in the INP locked, caller must unlock it. */ + return (tp->t_fb->tfb_tcp_ctloutput(inp->inp_socket, sopt, inp, tp)); +} + +int +tcp_ctloutput(struct socket *so, struct sockopt *sopt) +{ + int error; + struct inpcb *inp; + + error = 0; + inp = sotoinpcb(so); + KASSERT(inp != NULL, ("tcp_ctloutput: inp == NULL")); + + if (sopt->sopt_dir == SOPT_SET) + return (tcp_ctloutput_set(inp, sopt)); + else if (sopt->sopt_dir == SOPT_GET) + return (tcp_ctloutput_get(inp, sopt)); + else + panic("%s: sopt_dir $%d", __func__, sopt->sopt_dir); } /* From nobody Wed Oct 27 15:22:58 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A10B11813DFD; Wed, 27 Oct 2021 15:22:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfXWR29sNz3F2P; Wed, 27 Oct 2021 15:22:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AA9BA12B3A; Wed, 27 Oct 2021 15:22:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RFMwYD084048; Wed, 27 Oct 2021 15:22:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFMwUx084047; Wed, 27 Oct 2021 15:22:58 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:22:58 GMT Message-Id: <202110271522.19RFMwUx084047@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: de156263a598 - main - Several IP level socket options may affect TCP. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: de156263a598a0277b7bbc13ef8bdc6f4541b604 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=de156263a598a0277b7bbc13ef8bdc6f4541b604 commit de156263a598a0277b7bbc13ef8bdc6f4541b604 Author: Gleb Smirnoff AuthorDate: 2021-10-26 03:40:12 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-27 15:21:59 +0000 Several IP level socket options may affect TCP. After handling them in IP level ctloutput, pass them down to TCP ctloutput. We already have a hack to handle IPV6_USE_MIN_MTU. Leave it in place for now, but comment out how it should be handled. For IPv4 we are interested in IP_TOS and IP_TTL. Reviewed by: rrs Differential Revision: https://reviews.freebsd.org/D32655 --- sys/netinet/tcp_usrreq.c | 75 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 0fca9b88e6f3..b6e345bd454c 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1739,20 +1739,44 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) if (sopt->sopt_level != IPPROTO_TCP) { #ifdef INET6 - if (inp->inp_vflag & INP_IPV6PROTO) { + if (inp->inp_vflag & INP_IPV6PROTO) error = ip6_ctloutput(inp->inp_socket, sopt); - /* - * In case of the IPV6_USE_MIN_MTU socket option, - * the INC_IPV6MINMTU flag to announce a corresponding - * MSS during the initial handshake. - * If the TCP connection is not in the front states, - * just reduce the MSS being used. - * This avoids the sending of TCP segments which will - * be fragmented at the IPv6 layer. - */ - if ((error == 0) && - (sopt->sopt_level == IPPROTO_IPV6) && - (sopt->sopt_name == IPV6_USE_MIN_MTU)) { +#endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET + error = ip_ctloutput(inp->inp_socket, sopt); +#endif + /* + * When an IP-level socket option affects TCP, pass control + * down to stack tfb_tcp_ctloutput, otherwise return what + * IP level returned. + */ + switch (sopt->sopt_level) { +#ifdef INET6 + case IPPROTO_IPV6: + if ((inp->inp_vflag & INP_IPV6PROTO) == 0) + return (error); + switch (sopt->sopt_name) { + case IPV6_TCLASS: + /* Notify tcp stacks that care (e.g. RACK). */ + break; + case IPV6_USE_MIN_MTU: + /* + * XXXGL: this handling should belong to + * stack specific tfb_tcp_ctloutput, we + * should just break here. + * + * In case of the IPV6_USE_MIN_MTU socket + * option, the INC_IPV6MINMTU flag to announce + * a corresponding MSS during the initial + * handshake. If the TCP connection is not in + * the front states, just reduce the MSS being + * used. This avoids the sending of TCP + * segments which will be fragmented at the + * IPv6 layer. + */ INP_WLOCK(inp); if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED))) { @@ -1775,18 +1799,27 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) } } INP_WUNLOCK(inp); + /* FALLTHROUGH */ + default: + return (error); } - } -#endif /* INET6 */ -#if defined(INET6) && defined(INET) - else + break; #endif #ifdef INET - { - error = ip_ctloutput(inp->inp_socket, sopt); - } + case IPPROTO_IP: + switch (sopt->sopt_name) { + case IP_TOS: + case IP_TTL: + /* Notify tcp stacks that care (e.g. RACK). */ + break; + default: + return (error); + } + break; #endif - return (error); + default: + return (error); + } } else if (sopt->sopt_name == TCP_FUNCTION_BLK) { /* * Protect the TCP option TCP_FUNCTION_BLK so From nobody Wed Oct 27 15:22:59 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6F1891813E79; Wed, 27 Oct 2021 15:23:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfXWS6XPBz3F4n; Wed, 27 Oct 2021 15:23:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D804E12762; Wed, 27 Oct 2021 15:22:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RFMxiO084072; Wed, 27 Oct 2021 15:22:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFMxUI084071; Wed, 27 Oct 2021 15:22:59 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:22:59 GMT Message-Id: <202110271522.19RFMxUI084071@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: f581a26e46b8 - main - Factor out tcp6_use_min_mtu() to handle IPV6_USE_MIN_MTU by TCP. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f581a26e46b896657fd502672c134da115057839 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=f581a26e46b896657fd502672c134da115057839 commit f581a26e46b896657fd502672c134da115057839 Author: Gleb Smirnoff AuthorDate: 2021-10-26 03:53:07 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-27 15:22:00 +0000 Factor out tcp6_use_min_mtu() to handle IPV6_USE_MIN_MTU by TCP. Pass control for IP/IP6 level options from generic tcp_ctloutput_set() down to per-stack ctloutput. Call tcp6_use_min_mtu() from tcp stack tcp_default_ctloutput(). Reviewed by: rrs Differential Revision: https://reviews.freebsd.org/D32655 --- sys/netinet/tcp_stacks/bbr.c | 6 +++++ sys/netinet/tcp_stacks/rack.c | 19 ++++++++++++++ sys/netinet/tcp_subr.c | 35 +++++++++++++++++++++++++ sys/netinet/tcp_usrreq.c | 60 +++++++++++++++++-------------------------- sys/netinet/tcp_var.h | 1 + 5 files changed, 84 insertions(+), 37 deletions(-) diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 3c4cf0f54d97..41f441da99a1 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -14253,6 +14253,12 @@ bbr_set_sockopt(struct socket *so, struct sockopt *sopt, struct epoch_tracker et; int32_t error = 0, optval; + switch (sopt->sopt_level) { + case IPPROTO_IPV6: + case IPPROTO_IP: + return (tcp_default_ctloutput(so, sopt, inp, tp)); + } + switch (sopt->sopt_name) { case TCP_RACK_PACE_MAX_SEG: case TCP_RACK_MIN_TO: diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index eee7db6e7a4c..3e3997f8e18e 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -20248,6 +20248,25 @@ rack_set_sockopt(struct socket *so, struct sockopt *sopt, uint64_t loptval; int32_t error = 0, optval; + switch (sopt->sopt_level) { +#ifdef INET6 + case IPPROTO_IPV6: + MPASS(inp->inp_vflag & INP_IPV6PROTO); + switch (sopt->sopt_name) { + case IPV6_USE_MIN_MTU: + tcp6_use_min_mtu(tp); + /* FALLTHROUGH */ + } + INP_WUNLOCK(inp); + return (0); +#endif +#ifdef INET + case IPPROTO_IP: + INP_WUNLOCK(inp); + return (0); +#endif + } + switch (sopt->sopt_name) { case TCP_RACK_TLP_REDUCE: /* URL:tlp_reduce */ /* Pacing related ones */ diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 2752773a95fc..e12eb5682c14 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -3559,6 +3559,41 @@ tcp_maxmtu6(struct in_conninfo *inc, struct tcp_ifcap *cap) return (maxmtu); } + +/* + * Handle setsockopt(IPV6_USE_MIN_MTU) by a TCP stack. + * + * XXXGL: we are updating inpcb here with INC_IPV6MINMTU flag. + * The right place to do that is ip6_setpktopt() that has just been + * executed. By the way it just filled ip6po_minmtu for us. + */ +void +tcp6_use_min_mtu(struct tcpcb *tp) +{ + struct inpcb *inp = tp->t_inpcb; + + INP_WLOCK_ASSERT(inp); + /* + * In case of the IPV6_USE_MIN_MTU socket + * option, the INC_IPV6MINMTU flag to announce + * a corresponding MSS during the initial + * handshake. If the TCP connection is not in + * the front states, just reduce the MSS being + * used. This avoids the sending of TCP + * segments which will be fragmented at the + * IPv6 layer. + */ + inp->inp_inc.inc_flags |= INC_IPV6MINMTU; + if ((tp->t_state >= TCPS_SYN_SENT) && + (inp->inp_inc.inc_flags & INC_ISIPV6)) { + struct ip6_pktopts *opt; + + opt = inp->in6p_outputopts; + if (opt != NULL && opt->ip6po_minmtu == IP6PO_MINMTU_ALL && + tp->t_maxseg > TCP6_MSS) + tp->t_maxseg = TCP6_MSS; + } +} #endif /* INET6 */ /* diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index b6e345bd454c..7e703af5aa67 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1763,43 +1763,8 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) /* Notify tcp stacks that care (e.g. RACK). */ break; case IPV6_USE_MIN_MTU: - /* - * XXXGL: this handling should belong to - * stack specific tfb_tcp_ctloutput, we - * should just break here. - * - * In case of the IPV6_USE_MIN_MTU socket - * option, the INC_IPV6MINMTU flag to announce - * a corresponding MSS during the initial - * handshake. If the TCP connection is not in - * the front states, just reduce the MSS being - * used. This avoids the sending of TCP - * segments which will be fragmented at the - * IPv6 layer. - */ - INP_WLOCK(inp); - if ((inp->inp_flags & - (INP_TIMEWAIT | INP_DROPPED))) { - INP_WUNLOCK(inp); - return (ECONNRESET); - } - inp->inp_inc.inc_flags |= INC_IPV6MINMTU; - tp = intotcpcb(inp); - if ((tp->t_state >= TCPS_SYN_SENT) && - (inp->inp_inc.inc_flags & INC_ISIPV6)) { - struct ip6_pktopts *opt; - - opt = inp->in6p_outputopts; - if ((opt != NULL) && - (opt->ip6po_minmtu == - IP6PO_MINMTU_ALL)) { - if (tp->t_maxseg > TCP6_MSS) { - tp->t_maxseg = TCP6_MSS; - } - } - } - INP_WUNLOCK(inp); - /* FALLTHROUGH */ + /* Update t_maxseg accordingly. */ + break; default: return (error); } @@ -2058,6 +2023,27 @@ tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp #endif size_t len; + INP_WLOCK_ASSERT(inp); + + switch (sopt->sopt_level) { +#ifdef INET6 + case IPPROTO_IPV6: + MPASS(inp->inp_vflag & INP_IPV6PROTO); + switch (sopt->sopt_name) { + case IPV6_USE_MIN_MTU: + tcp6_use_min_mtu(tp); + /* FALLTHROUGH */ + } + INP_WUNLOCK(inp); + return (0); +#endif +#ifdef INET + case IPPROTO_IP: + INP_WUNLOCK(inp); + return (0); +#endif + } + /* * For TCP_CCALGOOPT forward the control to CC module, for both * SOPT_SET and SOPT_GET. diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 2775fb392a1a..1511da3c70fd 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1053,6 +1053,7 @@ extern uint32_t tcp_ack_war_cnt; uint32_t tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *); uint32_t tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *); +void tcp6_use_min_mtu(struct tcpcb *); u_int tcp_maxseg(const struct tcpcb *); u_int tcp_fixed_maxseg(const struct tcpcb *); void tcp_mss_update(struct tcpcb *, int, int, struct hc_metrics_lite *, From nobody Wed Oct 27 15:23:00 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 10FDA181405A; Wed, 27 Oct 2021 15:23:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfXWV0FhJz3F7G; Wed, 27 Oct 2021 15:23:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 07ACA128AB; Wed, 27 Oct 2021 15:23:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RFN0bf084102; Wed, 27 Oct 2021 15:23:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFN0dS084101; Wed, 27 Oct 2021 15:23:00 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:23:00 GMT Message-Id: <202110271523.19RFN0dS084101@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 5d3bf5b1d27f - main - rack: Update the fast send block on setsockopt(2) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d3bf5b1d27f4b2bd85f40e26987af83353616f0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=5d3bf5b1d27f4b2bd85f40e26987af83353616f0 commit 5d3bf5b1d27f4b2bd85f40e26987af83353616f0 Author: Gleb Smirnoff AuthorDate: 2021-10-26 03:54:26 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-27 15:22:00 +0000 rack: Update the fast send block on setsockopt(2) Rack caches TCP/IP header for fast send, so it doesn't call tcpip_fillheaders(). After certain socket option changes, namely IPV6_TCLASS, IP_TOS and IP_TTL it needs to update its fast block to be in sync with the inpcb. Reviewed by: rrs Differential Revision: https://reviews.freebsd.org/D32655 --- sys/netinet/tcp_stacks/rack.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 3e3997f8e18e..a92e43205f09 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -20245,6 +20245,12 @@ static int rack_set_sockopt(struct socket *so, struct sockopt *sopt, struct inpcb *inp, struct tcpcb *tp, struct tcp_rack *rack) { +#ifdef INET6 + struct ip6_hdr *ip6 = (struct ip6_hdr *)rack->r_ctl.fsb.tcp_ip_hdr; +#endif +#ifdef INET + struct ip *ip = (struct ip *)rack->r_ctl.fsb.tcp_ip_hdr; +#endif uint64_t loptval; int32_t error = 0, optval; @@ -20255,13 +20261,34 @@ rack_set_sockopt(struct socket *so, struct sockopt *sopt, switch (sopt->sopt_name) { case IPV6_USE_MIN_MTU: tcp6_use_min_mtu(tp); - /* FALLTHROUGH */ + break; + case IPV6_TCLASS: + /* + * The DSCP codepoint has changed, update the fsb. + */ + ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) | + (rack->rc_inp->inp_flow & IPV6_FLOWINFO_MASK); + break; } INP_WUNLOCK(inp); return (0); #endif #ifdef INET case IPPROTO_IP: + switch (sopt->sopt_name) { + case IP_TOS: + /* + * The DSCP codepoint has changed, update the fsb. + */ + ip->ip_tos = rack->rc_inp->inp_ip_tos; + break; + case IP_TTL: + /* + * The TTL has changed, update the fsb. + */ + ip->ip_ttl = rack->rc_inp->inp_ip_ttl; + break; + } INP_WUNLOCK(inp); return (0); #endif From nobody Wed Oct 27 15:47:26 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1E04A181FCA6; Wed, 27 Oct 2021 15:47:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfY3g0NZYz3NGp; Wed, 27 Oct 2021 15:47:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E1DE2128E7; Wed, 27 Oct 2021 15:47:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RFlQP9010511; Wed, 27 Oct 2021 15:47:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFlQDe010510; Wed, 27 Oct 2021 15:47:26 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:47:26 GMT Message-Id: <202110271547.19RFlQDe010510@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: aa15f7df644a - main - arm: Remove obsolete comments List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aa15f7df644a5ec0eff84f077920432d5dc81d97 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=aa15f7df644a5ec0eff84f077920432d5dc81d97 commit aa15f7df644a5ec0eff84f077920432d5dc81d97 Author: Warner Losh AuthorDate: 2021-10-27 15:44:41 +0000 Commit: Warner Losh CommitDate: 2021-10-27 15:44:58 +0000 arm: Remove obsolete comments FreeBSD has never supported arm26, so remove comments about what trapframes look like for that platform. Noticed by: kevans Sponsored by: Netflix --- sys/arm/include/frame.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/arm/include/frame.h b/sys/arm/include/frame.h index 8866e8ab0a33..39daeb5e9932 100644 --- a/sys/arm/include/frame.h +++ b/sys/arm/include/frame.h @@ -61,7 +61,7 @@ */ struct trapframe { - register_t tf_spsr; /* Zero on arm26 */ + register_t tf_spsr; register_t tf_r0; register_t tf_r1; register_t tf_r2; @@ -77,8 +77,8 @@ struct trapframe { register_t tf_r12; register_t tf_usr_sp; register_t tf_usr_lr; - register_t tf_svc_sp; /* Not used on arm26 */ - register_t tf_svc_lr; /* Not used on arm26 */ + register_t tf_svc_sp; + register_t tf_svc_lr; register_t tf_pc; register_t tf_pad; }; From nobody Wed Oct 27 16:31:21 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 09BE31811686; Wed, 27 Oct 2021 16:31:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfZ2K6xVjz3r1n; Wed, 27 Oct 2021 16:31:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C42E2138D3; Wed, 27 Oct 2021 16:31:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RGVLhf073155; Wed, 27 Oct 2021 16:31:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RGVL1N073154; Wed, 27 Oct 2021 16:31:21 GMT (envelope-from git) Date: Wed, 27 Oct 2021 16:31:21 GMT Message-Id: <202110271631.19RGVL1N073154@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 2f7f8995367b - main - libdialog: Bump shared library version to 10. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2f7f8995367b3fe1a9e2bf34be6f0684963eed02 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=2f7f8995367b3fe1a9e2bf34be6f0684963eed02 commit 2f7f8995367b3fe1a9e2bf34be6f0684963eed02 Author: John Baldwin AuthorDate: 2021-10-27 16:30:24 +0000 Commit: John Baldwin CommitDate: 2021-10-27 16:30:24 +0000 libdialog: Bump shared library version to 10. The upgrade to libdialog 1.3 included changes to the ABI. Bump libdpv to 3 since it links against libdialog. Reported by: Mark Millard Reviewed by: bapt Fixes: a96ef4501919 dialog: import dialog 1.3-20210117 Differential Revision: https://reviews.freebsd.org/D32675 --- ObsoleteFiles.inc | 6 ++++++ gnu/lib/libdialog/Makefile | 2 +- lib/libdpv/Makefile | 2 +- tools/build/mk/OptionalObsoleteFiles.inc | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index c60629197386..43c977e3cff5 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -40,6 +40,12 @@ # xargs -n1 | sort | uniq -d; # done +# 20211027: libdialog shlib bumped to version 10 for dialog 1.3 +OLD_LIBS+=usr/lib/libdialog.so.9 +OLD_LIBS+=usr/lib/libdpv.so.2 +OLD_LIBS+=usr/lib32/libdialog.so.9 +OLD_LIBS+=usr/lib32/libdpv.so.2 + # 20211026: retire obsolete iscsi initiator OLD_FILES+=sbin/iscontrol OLD_FILES+=usr/share/man/man4/iscsi_initiator.4.gz diff --git a/gnu/lib/libdialog/Makefile b/gnu/lib/libdialog/Makefile index 6de2460c62a5..73373b1d5827 100644 --- a/gnu/lib/libdialog/Makefile +++ b/gnu/lib/libdialog/Makefile @@ -3,7 +3,7 @@ DIALOG= ${SRCTOP}/contrib/dialog LIB= dialog -SHLIB_MAJOR= 9 +SHLIB_MAJOR= 10 SRCS= argv.c arrows.c buildlist.c buttons.c calendar.c checklist.c \ columns.c dlg_keys.c editbox.c fselect.c formbox.c guage.c \ help.c inputbox.c inputstr.c menubox.c mixedform.c \ diff --git a/lib/libdpv/Makefile b/lib/libdpv/Makefile index 5b432602ff7b..43cc6bce07c7 100644 --- a/lib/libdpv/Makefile +++ b/lib/libdpv/Makefile @@ -2,7 +2,7 @@ PACKAGE= dpv LIB= dpv -SHLIB_MAJOR= 2 +SHLIB_MAJOR= 3 INCS= dpv.h MAN= dpv.3 MLINKS= dpv.3 dpv_free.3 diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index a8b0329104c4..91822aac492a 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -1663,11 +1663,11 @@ OLD_FILES+=usr/bin/dialog OLD_FILES+=usr/bin/dpv OLD_FILES+=usr/lib/libdialog.a OLD_FILES+=usr/lib/libdialog.so -OLD_FILES+=usr/lib/libdialog.so.8 +OLD_FILES+=usr/lib/libdialog.so.10 OLD_FILES+=usr/lib/libdialog_p.a OLD_FILES+=usr/lib/libdpv.a OLD_FILES+=usr/lib/libdpv.so -OLD_FILES+=usr/lib/libdpv.so.1 +OLD_FILES+=usr/lib/libdpv.so.3 OLD_FILES+=usr/lib/libdpv_p.a OLD_FILES+=usr/sbin/bsdconfig OLD_FILES+=usr/share/man/man1/dialog.1.gz From nobody Wed Oct 27 17:38:45 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6B4C7182DA63; Wed, 27 Oct 2021 17:38:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfbX52Zbmz4fhw; Wed, 27 Oct 2021 17:38:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3895F143C5; Wed, 27 Oct 2021 17:38:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RHcjwU057688; Wed, 27 Oct 2021 17:38:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RHcju5057687; Wed, 27 Oct 2021 17:38:45 GMT (envelope-from git) Date: Wed, 27 Oct 2021 17:38:45 GMT Message-Id: <202110271738.19RHcju5057687@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 29863d1effe2 - main - xhci: Rework 64-byte context support to avoid pointer abuse List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 29863d1effe20da3cc75ae10bd52d96edafe9e59 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=29863d1effe20da3cc75ae10bd52d96edafe9e59 commit 29863d1effe20da3cc75ae10bd52d96edafe9e59 Author: Jessica Clarke AuthorDate: 2021-10-24 18:48:46 +0000 Commit: Jessica Clarke CommitDate: 2021-10-27 17:38:37 +0000 xhci: Rework 64-byte context support to avoid pointer abuse Currently, to support 64-byte contexts, xhci_ctx_[gs]et_le(32|64) take a pointer to the field within a 32-byte context and, if 64-byte contexts are in use, compute where the 64-byte context field is and use that instead by deriving a pointer from the 32-byte field pointer. This is done by exploiting a combination of 64-byte contexts being the same layout as their 32-byte counterparts, just with 32 bytes of padding at the end, and that all individual contexts are either in a device context or an input context which itself is page-aligned. By masking out the low 4 bits (which is the offset of the field within the 32-byte contxt) of the offset within the page, the offset of the invididual context within the containing device/input context can be determined, which is itself 32 times the number of preceding contexts. Thus, adding this value to the pointer again gets 64 times the number of preceding contexts plus the field offset, which gives the offset of the 64-byte context plus the field offset, which is the address of the field in the 64-byte context. However, this involves a fair amount of lying to the compiler when constructing these intermediate pointers, and is rather difficult to reason about. In particular, this is problematic for CHERI, where we compile the kernel with subobject bounds enabled; that is, unless annotated to opt out (e.g. for C struct inheritance reasons where you need to be able to downcast, or containerof idioms), a pointer to a member of a struct is a capability whose bounds only cover that field, and any attempt to dereference outside those bounds will fault, protecting against intra-object buffer overflows. Thus the pointer given to xhci_ctx_[gs]et_le(32|64) is a capability whose bounds only cover the field in the 32-byte context, and computing the pointer to the 64-byte context field takes the address out of bounds, resulting in a fault when later dereferenced. This can be cleaned up by using a different abstraction. Instead of doing the 32-byte to 64-byte conversion on access to the field, we can do the conversion when getting a pointer to the context itself, and define proper 64-byte versions of contexts in order to let the compiler do all the necessary arithmetic rather than do it manually ourselves. This provides a cleaner implementation, works for CHERI and may even be slightly more performant as it avoids the need to mess with masking pointers (which cannot in the general case be optimised by compilers to be reused across accesses to different fields within the same context, since it does not know that the contexts are over-aligned compared with the C ABI requirements). Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D32554 --- sys/dev/usb/controller/xhci.c | 160 +++++++++++++++--------------------------- sys/dev/usb/controller/xhci.h | 26 +++++++ 2 files changed, 81 insertions(+), 105 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index e9d15eabc20a..0b0d9a7dc7be 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -88,6 +88,11 @@ #define XHCI_BUS2SC(bus) \ __containerof(bus, struct xhci_softc, sc_bus) +#define XHCI_GET_CTX(sc, which, field, ptr) \ + ((sc)->sc_ctx_is_64_byte ? \ + &((struct which##64 *)(ptr))->field.ctx : \ + &((struct which *)(ptr))->field) + static SYSCTL_NODE(_hw_usb, OID_AUTO, xhci, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "USB XHCI"); @@ -163,12 +168,6 @@ static usb_error_t xhci_configure_mask(struct usb_device *, static usb_error_t xhci_cmd_evaluate_ctx(struct xhci_softc *, uint64_t, uint8_t); static void xhci_endpoint_doorbell(struct usb_xfer *); -static void xhci_ctx_set_le32(struct xhci_softc *sc, volatile uint32_t *ptr, uint32_t val); -static uint32_t xhci_ctx_get_le32(struct xhci_softc *sc, volatile uint32_t *ptr); -static void xhci_ctx_set_le64(struct xhci_softc *sc, volatile uint64_t *ptr, uint64_t val); -#ifdef USB_DEBUG -static uint64_t xhci_ctx_get_le64(struct xhci_softc *sc, volatile uint64_t *ptr); -#endif static const struct usb_bus_methods xhci_bus_methods; @@ -183,26 +182,26 @@ xhci_dump_trb(struct xhci_trb *trb) } static void -xhci_dump_endpoint(struct xhci_softc *sc, struct xhci_endp_ctx *pep) +xhci_dump_endpoint(struct xhci_endp_ctx *pep) { DPRINTFN(5, "pep = %p\n", pep); - DPRINTFN(5, "dwEpCtx0=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx0)); - DPRINTFN(5, "dwEpCtx1=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx1)); - DPRINTFN(5, "qwEpCtx2=0x%016llx\n", (long long)xhci_ctx_get_le64(sc, &pep->qwEpCtx2)); - DPRINTFN(5, "dwEpCtx4=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx4)); - DPRINTFN(5, "dwEpCtx5=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx5)); - DPRINTFN(5, "dwEpCtx6=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx6)); - DPRINTFN(5, "dwEpCtx7=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx7)); + DPRINTFN(5, "dwEpCtx0=0x%08x\n", le32toh(pep->dwEpCtx0)); + DPRINTFN(5, "dwEpCtx1=0x%08x\n", le32toh(pep->dwEpCtx1)); + DPRINTFN(5, "qwEpCtx2=0x%016llx\n", (long long)le64toh(pep->qwEpCtx2)); + DPRINTFN(5, "dwEpCtx4=0x%08x\n", le32toh(pep->dwEpCtx4)); + DPRINTFN(5, "dwEpCtx5=0x%08x\n", le32toh(pep->dwEpCtx5)); + DPRINTFN(5, "dwEpCtx6=0x%08x\n", le32toh(pep->dwEpCtx6)); + DPRINTFN(5, "dwEpCtx7=0x%08x\n", le32toh(pep->dwEpCtx7)); } static void -xhci_dump_device(struct xhci_softc *sc, struct xhci_slot_ctx *psl) +xhci_dump_device(struct xhci_slot_ctx *psl) { DPRINTFN(5, "psl = %p\n", psl); - DPRINTFN(5, "dwSctx0=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx0)); - DPRINTFN(5, "dwSctx1=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx1)); - DPRINTFN(5, "dwSctx2=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx2)); - DPRINTFN(5, "dwSctx3=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx3)); + DPRINTFN(5, "dwSctx0=0x%08x\n", le32toh(psl->dwSctx0)); + DPRINTFN(5, "dwSctx1=0x%08x\n", le32toh(psl->dwSctx1)); + DPRINTFN(5, "dwSctx2=0x%08x\n", le32toh(psl->dwSctx2)); + DPRINTFN(5, "dwSctx3=0x%08x\n", le32toh(psl->dwSctx3)); } #endif @@ -234,60 +233,6 @@ xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) } } -static void -xhci_ctx_set_le32(struct xhci_softc *sc, volatile uint32_t *ptr, uint32_t val) -{ - if (sc->sc_ctx_is_64_byte) { - uint32_t offset; - /* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */ - /* all contexts are initially 32-bytes */ - offset = ((uintptr_t)ptr) & ((XHCI_PAGE_SIZE - 1) & ~(31U)); - ptr = (volatile uint32_t *)(((volatile uint8_t *)ptr) + offset); - } - *ptr = htole32(val); -} - -static uint32_t -xhci_ctx_get_le32(struct xhci_softc *sc, volatile uint32_t *ptr) -{ - if (sc->sc_ctx_is_64_byte) { - uint32_t offset; - /* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */ - /* all contexts are initially 32-bytes */ - offset = ((uintptr_t)ptr) & ((XHCI_PAGE_SIZE - 1) & ~(31U)); - ptr = (volatile uint32_t *)(((volatile uint8_t *)ptr) + offset); - } - return (le32toh(*ptr)); -} - -static void -xhci_ctx_set_le64(struct xhci_softc *sc, volatile uint64_t *ptr, uint64_t val) -{ - if (sc->sc_ctx_is_64_byte) { - uint32_t offset; - /* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */ - /* all contexts are initially 32-bytes */ - offset = ((uintptr_t)ptr) & ((XHCI_PAGE_SIZE - 1) & ~(31U)); - ptr = (volatile uint64_t *)(((volatile uint8_t *)ptr) + offset); - } - *ptr = htole64(val); -} - -#ifdef USB_DEBUG -static uint64_t -xhci_ctx_get_le64(struct xhci_softc *sc, volatile uint64_t *ptr) -{ - if (sc->sc_ctx_is_64_byte) { - uint32_t offset; - /* exploit the fact that our structures are XHCI_PAGE_SIZE aligned */ - /* all contexts are initially 32-bytes */ - offset = ((uintptr_t)ptr) & ((XHCI_PAGE_SIZE - 1) & ~(31U)); - ptr = (volatile uint64_t *)(((volatile uint8_t *)ptr) + offset); - } - return (le64toh(*ptr)); -} -#endif - static int xhci_reset_command_queue_locked(struct xhci_softc *sc) { @@ -1397,7 +1342,7 @@ xhci_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t address) struct usb_page_search buf_dev; struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); struct xhci_hw_dev *hdev; - struct xhci_dev_ctx *pdev; + struct xhci_slot_ctx *slot; struct xhci_endpoint_ext *pepext; uint32_t temp; uint16_t mps; @@ -1490,10 +1435,11 @@ xhci_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t address) /* update device address to new value */ usbd_get_page(&hdev->device_pc, 0, &buf_dev); - pdev = buf_dev.buffer; + slot = XHCI_GET_CTX(sc, xhci_dev_ctx, ctx_slot, + buf_dev.buffer); usb_pc_cpu_invalidate(&hdev->device_pc); - temp = xhci_ctx_get_le32(sc, &pdev->ctx_slot.dwSctx3); + temp = le32toh(slot->dwSctx3); udev->address = XHCI_SCTX_3_DEV_ADDR_GET(temp); /* update device state to new value */ @@ -2298,7 +2244,8 @@ xhci_configure_mask(struct usb_device *udev, uint32_t mask, uint8_t drop) { struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); struct usb_page_search buf_inp; - struct xhci_input_dev_ctx *pinp; + struct xhci_input_ctx *input; + struct xhci_slot_ctx *slot; uint32_t temp; uint8_t index; uint8_t x; @@ -2307,22 +2254,23 @@ xhci_configure_mask(struct usb_device *udev, uint32_t mask, uint8_t drop) usbd_get_page(&sc->sc_hw.devs[index].input_pc, 0, &buf_inp); - pinp = buf_inp.buffer; + input = XHCI_GET_CTX(sc, xhci_input_dev_ctx, ctx_input, + buf_inp.buffer); + slot = XHCI_GET_CTX(sc, xhci_input_dev_ctx, ctx_slot, buf_inp.buffer); if (drop) { mask &= XHCI_INCTX_NON_CTRL_MASK; - xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx0, mask); - xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx1, 0); + input->dwInCtx0 = htole32(mask); + input->dwInCtx1 = htole32(0); } else { /* * Some hardware requires that we drop the endpoint * context before adding it again: */ - xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx0, - mask & XHCI_INCTX_NON_CTRL_MASK); + input->dwInCtx0 = htole32(mask & XHCI_INCTX_NON_CTRL_MASK); /* Add new endpoint context */ - xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx1, mask); + input->dwInCtx1 = htole32(mask); /* find most significant set bit */ for (x = 31; x != 1; x--) { @@ -2340,10 +2288,10 @@ xhci_configure_mask(struct usb_device *udev, uint32_t mask, uint8_t drop) x = sc->sc_hw.devs[index].context_num; /* update number of contexts */ - temp = xhci_ctx_get_le32(sc, &pinp->ctx_slot.dwSctx0); + temp = le32toh(slot->dwSctx0); temp &= ~XHCI_SCTX_0_CTX_NUM_SET(31); temp |= XHCI_SCTX_0_CTX_NUM_SET(x + 1); - xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); + slot->dwSctx0 = htole32(temp); } usb_pc_cpu_flush(&sc->sc_hw.devs[index].input_pc); return (0); @@ -2358,7 +2306,7 @@ xhci_configure_endpoint(struct usb_device *udev, { struct usb_page_search buf_inp; struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); - struct xhci_input_dev_ctx *pinp; + struct xhci_endp_ctx *endp; uint64_t ring_addr = pepext->physaddr; uint32_t temp; uint8_t index; @@ -2369,8 +2317,6 @@ xhci_configure_endpoint(struct usb_device *udev, usbd_get_page(&sc->sc_hw.devs[index].input_pc, 0, &buf_inp); - pinp = buf_inp.buffer; - epno = edesc->bEndpointAddress; type = edesc->bmAttributes & UE_XFERTYPE; @@ -2390,6 +2336,9 @@ xhci_configure_endpoint(struct usb_device *udev, if (mult == 0) return (USB_ERR_BAD_BUFSIZE); + endp = XHCI_GET_CTX(sc, xhci_input_dev_ctx, ctx_ep[epno - 1], + buf_inp.buffer); + /* store endpoint mode */ pepext->trb_ep_mode = ep_mode; /* store bMaxPacketSize for control endpoints */ @@ -2445,7 +2394,7 @@ xhci_configure_endpoint(struct usb_device *udev, break; } - xhci_ctx_set_le32(sc, &pinp->ctx_ep[epno - 1].dwEpCtx0, temp); + endp->dwEpCtx0 = htole32(temp); temp = XHCI_EPCTX_1_HID_SET(0) | @@ -2480,8 +2429,8 @@ xhci_configure_endpoint(struct usb_device *udev, if (epno & 1) temp |= XHCI_EPCTX_1_EPTYPE_SET(4); - xhci_ctx_set_le32(sc, &pinp->ctx_ep[epno - 1].dwEpCtx1, temp); - xhci_ctx_set_le64(sc, &pinp->ctx_ep[epno - 1].qwEpCtx2, ring_addr); + endp->dwEpCtx1 = htole32(temp); + endp->qwEpCtx2 = htole64(ring_addr); switch (edesc->bmAttributes & UE_XFERTYPE) { case UE_INTERRUPT: @@ -2498,10 +2447,10 @@ xhci_configure_endpoint(struct usb_device *udev, break; } - xhci_ctx_set_le32(sc, &pinp->ctx_ep[epno - 1].dwEpCtx4, temp); + endp->dwEpCtx4 = htole32(temp); #ifdef USB_DEBUG - xhci_dump_endpoint(sc, &pinp->ctx_ep[epno - 1]); + xhci_dump_endpoint(endp); #endif usb_pc_cpu_flush(&sc->sc_hw.devs[index].input_pc); @@ -2557,7 +2506,7 @@ xhci_configure_device(struct usb_device *udev) struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); struct usb_page_search buf_inp; struct usb_page_cache *pcinp; - struct xhci_input_dev_ctx *pinp; + struct xhci_slot_ctx *slot; struct usb_device *hubdev; uint32_t temp; uint32_t route; @@ -2574,7 +2523,7 @@ xhci_configure_device(struct usb_device *udev) usbd_get_page(pcinp, 0, &buf_inp); - pinp = buf_inp.buffer; + slot = XHCI_GET_CTX(sc, xhci_input_dev_ctx, ctx_slot, buf_inp.buffer); rh_port = 0; route = 0; @@ -2649,7 +2598,7 @@ xhci_configure_device(struct usb_device *udev) if (is_hub) temp |= XHCI_SCTX_0_HUB_SET(1); - xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); + slot->dwSctx0 = htole32(temp); temp = XHCI_SCTX_1_RH_PORT_SET(rh_port); @@ -2658,7 +2607,7 @@ xhci_configure_device(struct usb_device *udev) sc->sc_hw.devs[index].nports); } - xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx1, temp); + slot->dwSctx1 = htole32(temp); temp = XHCI_SCTX_2_IRQ_TARGET_SET(0); @@ -2684,7 +2633,7 @@ xhci_configure_device(struct usb_device *udev) break; } - xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx2, temp); + slot->dwSctx2 = htole32(temp); /* * These fields should be initialized to zero, according to @@ -2693,10 +2642,10 @@ xhci_configure_device(struct usb_device *udev) temp = XHCI_SCTX_3_DEV_ADDR_SET(0) | XHCI_SCTX_3_SLOT_STATE_SET(0); - xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx3, temp); + slot->dwSctx3 = htole32(temp); #ifdef USB_DEBUG - xhci_dump_device(sc, &pinp->ctx_slot); + xhci_dump_device(slot); #endif usb_pc_cpu_flush(pcinp); @@ -2725,7 +2674,7 @@ xhci_alloc_device_ext(struct usb_device *udev) pc->tag_parent = sc->sc_bus.dma_parent_tag; if (usb_pc_alloc_mem(pc, pg, sc->sc_ctx_is_64_byte ? - (2 * sizeof(struct xhci_dev_ctx)) : + sizeof(struct xhci_dev_ctx64) : sizeof(struct xhci_dev_ctx), XHCI_PAGE_SIZE)) goto error; @@ -2738,7 +2687,7 @@ xhci_alloc_device_ext(struct usb_device *udev) pc->tag_parent = sc->sc_bus.dma_parent_tag; if (usb_pc_alloc_mem(pc, pg, sc->sc_ctx_is_64_byte ? - (2 * sizeof(struct xhci_input_dev_ctx)) : + sizeof(struct xhci_input_dev_ctx64) : sizeof(struct xhci_input_dev_ctx), XHCI_PAGE_SIZE)) { goto error; } @@ -3785,7 +3734,7 @@ xhci_get_endpoint_state(struct usb_device *udev, uint8_t epno) struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); struct usb_page_search buf_dev; struct xhci_hw_dev *hdev; - struct xhci_dev_ctx *pdev; + struct xhci_endp_ctx *endp; uint32_t temp; MPASS(epno != 0); @@ -3793,10 +3742,11 @@ xhci_get_endpoint_state(struct usb_device *udev, uint8_t epno) hdev = &sc->sc_hw.devs[udev->controller_slot_id]; usbd_get_page(&hdev->device_pc, 0, &buf_dev); - pdev = buf_dev.buffer; + endp = XHCI_GET_CTX(sc, xhci_dev_ctx, ctx_ep[epno - 1], + buf_dev.buffer); usb_pc_cpu_invalidate(&hdev->device_pc); - temp = xhci_ctx_get_le32(sc, &pdev->ctx_ep[epno - 1].dwEpCtx0); + temp = le32toh(endp->dwEpCtx0); return (XHCI_EPCTX_0_EPSTATE_GET(temp)); } diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index 802207208569..ff7ec23ca5f2 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -111,6 +111,11 @@ struct xhci_slot_ctx { volatile uint32_t dwSctx7; }; +struct xhci_slot_ctx64 { + struct xhci_slot_ctx ctx; + volatile uint8_t padding[32]; +}; + struct xhci_endp_ctx { volatile uint32_t dwEpCtx0; #define XHCI_EPCTX_0_EPSTATE_SET(x) ((x) & 0x7) @@ -156,6 +161,11 @@ struct xhci_endp_ctx { volatile uint32_t dwEpCtx7; }; +struct xhci_endp_ctx64 { + struct xhci_endp_ctx ctx; + volatile uint8_t padding[32]; +}; + struct xhci_input_ctx { #define XHCI_INCTX_NON_CTRL_MASK 0xFFFFFFFCU volatile uint32_t dwInCtx0; @@ -170,17 +180,33 @@ struct xhci_input_ctx { volatile uint32_t dwInCtx7; }; +struct xhci_input_ctx64 { + struct xhci_input_ctx ctx; + volatile uint8_t padding[32]; +}; + struct xhci_input_dev_ctx { struct xhci_input_ctx ctx_input; struct xhci_slot_ctx ctx_slot; struct xhci_endp_ctx ctx_ep[XHCI_MAX_ENDPOINTS - 1]; }; +struct xhci_input_dev_ctx64 { + struct xhci_input_ctx64 ctx_input; + struct xhci_slot_ctx64 ctx_slot; + struct xhci_endp_ctx64 ctx_ep[XHCI_MAX_ENDPOINTS - 1]; +}; + struct xhci_dev_ctx { struct xhci_slot_ctx ctx_slot; struct xhci_endp_ctx ctx_ep[XHCI_MAX_ENDPOINTS - 1]; } __aligned(XHCI_DEV_CTX_ALIGN); +struct xhci_dev_ctx64 { + struct xhci_slot_ctx64 ctx_slot; + struct xhci_endp_ctx64 ctx_ep[XHCI_MAX_ENDPOINTS - 1]; +} __aligned(XHCI_DEV_CTX_ALIGN); + struct xhci_stream_ctx { volatile uint64_t qwSctx0; #define XHCI_SCTX_0_DCS_GET(x) ((x) & 0x1) From nobody Wed Oct 27 17:38:46 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 220AA182DCBD; Wed, 27 Oct 2021 17:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfbX65NZjz4fnR; Wed, 27 Oct 2021 17:38:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 67398143C6; Wed, 27 Oct 2021 17:38:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RHckt7057712; Wed, 27 Oct 2021 17:38:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RHckeP057711; Wed, 27 Oct 2021 17:38:46 GMT (envelope-from git) Date: Wed, 27 Oct 2021 17:38:46 GMT Message-Id: <202110271738.19RHckeP057711@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: f350bc1dd368 - main - ada: Fix intra-object buffer overread of identify strings List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f350bc1dd368a3024ba9ef2a9e8431fc1edd8094 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=f350bc1dd368a3024ba9ef2a9e8431fc1edd8094 commit f350bc1dd368a3024ba9ef2a9e8431fc1edd8094 Author: Jessica Clarke AuthorDate: 2021-10-24 18:48:59 +0000 Commit: Jessica Clarke CommitDate: 2021-10-27 17:38:37 +0000 ada: Fix intra-object buffer overread of identify strings In the ATA/ATAPI spec these are space-padded fixed-length strings with no NUL-terminator (and byte swapped). When performing the identify we call ata_param_fixup to swap the bytes back to be in order, strip any leading/trailing spaces and coalesce consecutive spaces, padding with NULs. However, if the input has no padding spaces, the fixed-up strings are still not NUL-terminated. This causes two issues. The first is that strlcpy will truncate the string by replacing the final byte with a NUL. The second is that strlcpy will keep reading src until it finds a NUL in order to calculate the return value, which is defined as the length of src (so that callers can then compare it with the dsize input to see if the input string was truncated), thereby reading past the end of the buffer and into whatever adjacent fields are in the structure. In practice there's a NUL byte somewhere in the structure, but on CHERI with subobject bounds enabled in the compiler this overread will be detected and trap as a bounds violation. Note this matches ata_xpt's aprobedone, which does a bcopy to a malloc'ed buffer and manually NUL-terminates it for the CAM path's device's serial_num. Found by: CHERI Reviewed by: imp, scottl Differential Revision: https://reviews.freebsd.org/D32567 --- sys/cam/ata/ata_da.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 72bbbfe8ab1f..c05a9fa49d1c 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -3424,6 +3424,7 @@ adasetgeom(struct ada_softc *softc, struct ccb_getdev *cgd) u_int64_t lbasize48; u_int32_t lbasize; u_int maxio, d_flags; + size_t tmpsize; dp->secsize = ata_logical_sector_size(&cgd->ident_data); if ((cgd->ident_data.atavalid & ATA_FLAG_54_58) && @@ -3487,10 +3488,25 @@ adasetgeom(struct ada_softc *softc, struct ccb_getdev *cgd) softc->flags |= ADA_FLAG_UNMAPPEDIO; } softc->disk->d_flags = d_flags; - strlcpy(softc->disk->d_descr, cgd->ident_data.model, - MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model))); - strlcpy(softc->disk->d_ident, cgd->ident_data.serial, - MIN(sizeof(softc->disk->d_ident), sizeof(cgd->ident_data.serial))); + + /* + * ata_param_fixup will strip trailing padding spaces and add a NUL, + * but if the field has no padding (as is common for serial numbers) + * there will still be no NUL terminator. We cannot use strlcpy, since + * it keeps reading src until it finds a NUL in order to compute the + * return value (and will truncate the final character due to having a + * single dsize rather than separate ssize and dsize), and strncpy does + * not add a NUL to the destination if it reaches the character limit. + */ + tmpsize = MIN(sizeof(softc->disk->d_descr) - 1, + sizeof(cgd->ident_data.model)); + memcpy(softc->disk->d_descr, cgd->ident_data.model, tmpsize); + softc->disk->d_descr[tmpsize] = '\0'; + + tmpsize = MIN(sizeof(softc->disk->d_ident) - 1, + sizeof(cgd->ident_data.serial)); + memcpy(softc->disk->d_ident, cgd->ident_data.serial, tmpsize); + softc->disk->d_ident[tmpsize] = '\0'; softc->disk->d_sectorsize = softc->params.secsize; softc->disk->d_mediasize = (off_t)softc->params.sectors * From nobody Wed Oct 27 17:38:47 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DC3BD182DBE2; Wed, 27 Oct 2021 17:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfbX75DH8z4fnZ; Wed, 27 Oct 2021 17:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 808971484F; Wed, 27 Oct 2021 17:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RHcljt057736; Wed, 27 Oct 2021 17:38:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RHclQ6057735; Wed, 27 Oct 2021 17:38:47 GMT (envelope-from git) Date: Wed, 27 Oct 2021 17:38:47 GMT Message-Id: <202110271738.19RHclQ6057735@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 34fb1c133c5b - main - Fix intra-object buffer overread for labeled msdosfs volumes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 34fb1c133c5b8616f14f1d740d99747b427f5571 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=34fb1c133c5b8616f14f1d740d99747b427f5571 commit 34fb1c133c5b8616f14f1d740d99747b427f5571 Author: Jessica Clarke AuthorDate: 2021-10-24 18:49:21 +0000 Commit: Jessica Clarke CommitDate: 2021-10-27 17:38:37 +0000 Fix intra-object buffer overread for labeled msdosfs volumes Volume labels, like directory entries, are padded with spaces and so have no NUL terminator. Whilst the MIN for the dsize argument to strlcpy ensures that the copy does not overflow the destination, strlcpy is defined to return the number of characters in the source string, regardless of the provided dsize, and so keeps reading until it finds a NUL, which likely exists somewhere within the following fields, but On CHERI with the subobject bounds enabled in the compiler this buffer overread will be detected and trap with a bounds violation. Found by: CHERI Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D32579 --- sys/geom/label/g_label_msdosfs.c | 20 +++++++++++++------- usr.sbin/fstyp/msdosfs.c | 20 +++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/sys/geom/label/g_label_msdosfs.c b/sys/geom/label/g_label_msdosfs.c index d6ccb8b334ee..2ba35ff80f51 100644 --- a/sys/geom/label/g_label_msdosfs.c +++ b/sys/geom/label/g_label_msdosfs.c @@ -50,6 +50,7 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size) FAT32_BSBPB *pfat32_bsbpb; FAT_DES *pfat_entry; uint8_t *sector0, *sector; + size_t copysize; g_topology_assert_not(); pp = cp->provider; @@ -111,8 +112,9 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size) pp->name); goto error; } - strlcpy(label, pfat_bsbpb->BS_VolLab, - MIN(size, sizeof(pfat_bsbpb->BS_VolLab) + 1)); + copysize = MIN(size - 1, sizeof(pfat_bsbpb->BS_VolLab)); + memcpy(label, pfat_bsbpb->BS_VolLab, copysize); + label[copysize] = '\0'; } else if (UINT32BYTES(pfat32_bsbpb->BPB_FATSz32) != 0) { uint32_t fat_FirstDataSector, fat_BytesPerSector, offset; @@ -133,8 +135,10 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size) */ if (strncmp(pfat32_bsbpb->BS_VolLab, LABEL_NO_NAME, sizeof(pfat32_bsbpb->BS_VolLab)) != 0) { - strlcpy(label, pfat32_bsbpb->BS_VolLab, - MIN(size, sizeof(pfat32_bsbpb->BS_VolLab) + 1)); + copysize = MIN(size - 1, + sizeof(pfat32_bsbpb->BS_VolLab) + 1); + memcpy(label, pfat32_bsbpb->BS_VolLab, copysize); + label[copysize] = '\0'; goto endofchecks; } @@ -184,9 +188,11 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size) */ if (pfat_entry->DIR_Attr & FAT_DES_ATTR_VOLUME_ID) { - strlcpy(label, pfat_entry->DIR_Name, - MIN(size, - sizeof(pfat_entry->DIR_Name) + 1)); + copysize = MIN(size - 1, + sizeof(pfat_entry->DIR_Name)); + memcpy(label, pfat_entry->DIR_Name, + copysize); + label[copysize] = '\0'; goto endofchecks; } } while((uint8_t *)(++pfat_entry) < diff --git a/usr.sbin/fstyp/msdosfs.c b/usr.sbin/fstyp/msdosfs.c index 3d86802f6a2e..ce745869edba 100644 --- a/usr.sbin/fstyp/msdosfs.c +++ b/usr.sbin/fstyp/msdosfs.c @@ -48,6 +48,7 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size) FAT32_BSBPB *pfat32_bsbpb; FAT_DES *pfat_entry; uint8_t *sector0, *sector; + size_t copysize; sector0 = NULL; sector = NULL; @@ -83,8 +84,9 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size) sizeof(pfat_bsbpb->BS_VolLab)) == 0) { goto endofchecks; } - strlcpy(label, pfat_bsbpb->BS_VolLab, - MIN(size, sizeof(pfat_bsbpb->BS_VolLab) + 1)); + copysize = MIN(size - 1, sizeof(pfat_bsbpb->BS_VolLab)); + memcpy(label, pfat_bsbpb->BS_VolLab, copysize); + label[copysize] = '\0'; } else if (UINT32BYTES(pfat32_bsbpb->BPB_FATSz32) != 0) { uint32_t fat_FirstDataSector, fat_BytesPerSector, offset; @@ -101,8 +103,10 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size) */ if (strncmp(pfat32_bsbpb->BS_VolLab, LABEL_NO_NAME, sizeof(pfat32_bsbpb->BS_VolLab)) != 0) { - strlcpy(label, pfat32_bsbpb->BS_VolLab, - MIN(size, sizeof(pfat32_bsbpb->BS_VolLab) + 1)); + copysize = MIN(size - 1, + sizeof(pfat32_bsbpb->BS_VolLab) + 1); + memcpy(label, pfat32_bsbpb->BS_VolLab, copysize); + label[copysize] = '\0'; goto endofchecks; } @@ -146,9 +150,11 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size) */ if (pfat_entry->DIR_Attr & FAT_DES_ATTR_VOLUME_ID) { - strlcpy(label, pfat_entry->DIR_Name, - MIN(size, - sizeof(pfat_entry->DIR_Name) + 1)); + copysize = MIN(size - 1, + sizeof(pfat_entry->DIR_Name)); + memcpy(label, pfat_entry->DIR_Name, + copysize); + label[copysize] = '\0'; goto endofchecks; } } while((uint8_t *)(++pfat_entry) < From nobody Wed Oct 27 18:28:18 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A728C181B681; Wed, 27 Oct 2021 18:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfcdH3RrKz4vJd; Wed, 27 Oct 2021 18:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0C78515031; Wed, 27 Oct 2021 18:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RISI8n024776; Wed, 27 Oct 2021 18:28:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RISIoR024775; Wed, 27 Oct 2021 18:28:18 GMT (envelope-from git) Date: Wed, 27 Oct 2021 18:28:18 GMT Message-Id: <202110271828.19RISIoR024775@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 628c3b307fb2 - main - cache: only let non-dir descriptors through when doing EMPTYPATH lookups List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 628c3b307fb29e9812008b8a0b3ccb73e0f0ecfa Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=628c3b307fb29e9812008b8a0b3ccb73e0f0ecfa commit 628c3b307fb29e9812008b8a0b3ccb73e0f0ecfa Author: Mateusz Guzik AuthorDate: 2021-10-27 18:17:59 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-27 18:27:47 +0000 cache: only let non-dir descriptors through when doing EMPTYPATH lookups Otherwise things like realpath against a file and '.' end up with an illegal state of having a regular vnode for the parent. Reported by: syzbot+9aa5439dd9c708aeb1a8@syzkaller.appspotmail.com --- sys/kern/vfs_cache.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 656f446b7394..99f7314822f0 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -4245,19 +4245,28 @@ cache_can_fplookup(struct cache_fpl *fpl) return (true); } -static int +static int __noinline cache_fplookup_dirfd(struct cache_fpl *fpl, struct vnode **vpp) { struct nameidata *ndp; + struct componentname *cnp; int error; bool fsearch; ndp = fpl->ndp; + cnp = fpl->cnp; + error = fgetvp_lookup_smr(ndp->ni_dirfd, ndp, vpp, &fsearch); if (__predict_false(error != 0)) { return (cache_fpl_aborted(fpl)); } fpl->fsearch = fsearch; + if ((*vpp)->v_type != VDIR) { + if (!((cnp->cn_flags & EMPTYPATH) != 0 && cnp->cn_pnbuf[0] == '\0')) { + cache_fpl_smr_exit(fpl); + return (cache_fpl_handled_error(fpl, ENOTDIR)); + } + } return (0); } From nobody Wed Oct 27 19:34:02 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0BF231813BED; Wed, 27 Oct 2021 19:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hff566r2vz3R8C; Wed, 27 Oct 2021 19:34:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CA99715E3D; Wed, 27 Oct 2021 19:34:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19RJY2lY017184; Wed, 27 Oct 2021 19:34:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RJY2x7017183; Wed, 27 Oct 2021 19:34:02 GMT (envelope-from git) Date: Wed, 27 Oct 2021 19:34:02 GMT Message-Id: <202110271934.19RJY2x7017183@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jilles Tjoelker Subject: git: 72f750dc7c73 - main - sh: Fix heredoc at certain places in case and for List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jilles X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72f750dc7c7324c3999e4d6cfbb2758694893cdd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jilles: URL: https://cgit.FreeBSD.org/src/commit/?id=72f750dc7c7324c3999e4d6cfbb2758694893cdd commit 72f750dc7c7324c3999e4d6cfbb2758694893cdd Author: Jilles Tjoelker AuthorDate: 2021-10-14 20:53:42 +0000 Commit: Jilles Tjoelker CommitDate: 2021-10-27 19:05:19 +0000 sh: Fix heredoc at certain places in case and for After an unescaped newline, there may be a here-document. Some places in case and for did not check for one. Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D32628 --- bin/sh/parser.c | 16 +++++++++------- bin/sh/tests/parser/Makefile | 3 +++ bin/sh/tests/parser/heredoc14.0 | 8 ++++++++ bin/sh/tests/parser/heredoc15.0 | 9 +++++++++ bin/sh/tests/parser/heredoc16.0 | 8 ++++++++ 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 297d19d4d9b6..e75798800edf 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -480,9 +480,9 @@ command(void) n1 = (union node *)stalloc(sizeof (struct nfor)); n1->type = NFOR; n1->nfor.var = wordtext; - while (readtoken() == TNL) - ; - if (lasttoken == TWORD && ! quoteflag && equal(wordtext, "in")) { + checkkwd = CHKNL; + if (readtoken() == TWORD && !quoteflag && + equal(wordtext, "in")) { app = ≈ while (readtoken() == TWORD) { n2 = makename(); @@ -491,7 +491,9 @@ command(void) } *app = NULL; n1->nfor.args = ap; - if (lasttoken != TNL && lasttoken != TSEMI) + if (lasttoken == TNL) + tokpushback++; + else if (lasttoken != TSEMI) synexpect(-1); } else { static char argvars[5] = { @@ -507,7 +509,7 @@ command(void) * Newline or semicolon here is optional (but note * that the original Bourne shell only allowed NL). */ - if (lasttoken != TNL && lasttoken != TSEMI) + if (lasttoken != TSEMI) tokpushback++; } checkkwd = CHKNL | CHKKWD | CHKALIAS; @@ -526,8 +528,8 @@ command(void) n1->type = NCASE; consumetoken(TWORD); n1->ncase.expr = makename(); - while (readtoken() == TNL); - if (lasttoken != TWORD || ! equal(wordtext, "in")) + checkkwd = CHKNL; + if (readtoken() != TWORD || ! equal(wordtext, "in")) synerror("expecting \"in\""); cpp = &n1->ncase.cases; checkkwd = CHKNL | CHKKWD, readtoken(); diff --git a/bin/sh/tests/parser/Makefile b/bin/sh/tests/parser/Makefile index f3a15badeb52..3239f5bccd84 100644 --- a/bin/sh/tests/parser/Makefile +++ b/bin/sh/tests/parser/Makefile @@ -65,6 +65,9 @@ ${PACKAGE}FILES+= heredoc10.0 ${PACKAGE}FILES+= heredoc11.0 ${PACKAGE}FILES+= heredoc12.0 ${PACKAGE}FILES+= heredoc13.0 +${PACKAGE}FILES+= heredoc14.0 +${PACKAGE}FILES+= heredoc15.0 +${PACKAGE}FILES+= heredoc16.0 ${PACKAGE}FILES+= line-cont1.0 ${PACKAGE}FILES+= line-cont2.0 ${PACKAGE}FILES+= line-cont3.0 diff --git a/bin/sh/tests/parser/heredoc14.0 b/bin/sh/tests/parser/heredoc14.0 new file mode 100644 index 000000000000..036be53dc0c9 --- /dev/null +++ b/bin/sh/tests/parser/heredoc14.0 @@ -0,0 +1,8 @@ +# +read x < To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4827bf76bce8 - main - ktls: Fix assertion for TLS 1.0 CBC when using non-zero starting seqno. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4827bf76bce8814b9d9a0d883467a3d2366e59a2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4827bf76bce8814b9d9a0d883467a3d2366e59a2 commit 4827bf76bce8814b9d9a0d883467a3d2366e59a2 Author: John Baldwin AuthorDate: 2021-10-27 23:35:56 +0000 Commit: John Baldwin CommitDate: 2021-10-27 23:35:56 +0000 ktls: Fix assertion for TLS 1.0 CBC when using non-zero starting seqno. The starting sequence number used to verify that TLS 1.0 CBC records are encrypted in-order in the OCF layer was always set to 0 and not to the initial sequence number from the struct tls_enable. In practice, OpenSSL always starts TLS transmit offload with a sequence number of zero, so this only matters for tests that use a random starting sequence number. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32676 --- sys/opencrypto/ktls_ocf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/opencrypto/ktls_ocf.c b/sys/opencrypto/ktls_ocf.c index 0753f4bafb1a..0096b4189533 100644 --- a/sys/opencrypto/ktls_ocf.c +++ b/sys/opencrypto/ktls_ocf.c @@ -761,6 +761,9 @@ ktls_ocf_try(struct socket *so, struct ktls_session *tls, int direction) if (tls->params.tls_vminor == TLS_MINOR_VER_ZERO) { os->implicit_iv = true; memcpy(os->iv, tls->params.iv, AES_BLOCK_LEN); +#ifdef INVARIANTS + os->next_seqno = tls->next_seqno; +#endif } } From nobody Thu Oct 28 00:01:38 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 317241811F3E; Thu, 28 Oct 2021 00:01:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hfm1t697Hz3wV2; Thu, 28 Oct 2021 00:01:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A2D7F19B23; Thu, 28 Oct 2021 00:01:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S01cih075419; Thu, 28 Oct 2021 00:01:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S01cNU075418; Thu, 28 Oct 2021 00:01:38 GMT (envelope-from git) Date: Thu, 28 Oct 2021 00:01:38 GMT Message-Id: <202110280001.19S01cNU075418@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 63d24336fd1a - main - Fix off-by-one error in msdosfs FAT32 volume label copying List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 63d24336fd1aad81a4bdefb11d8c487cee5f88a0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=63d24336fd1aad81a4bdefb11d8c487cee5f88a0 commit 63d24336fd1aad81a4bdefb11d8c487cee5f88a0 Author: Jessica Clarke AuthorDate: 2021-10-28 00:01:00 +0000 Commit: Jessica Clarke CommitDate: 2021-10-28 00:01:00 +0000 Fix off-by-one error in msdosfs FAT32 volume label copying I dropped the + 1 from the other two instances in each file but failed to do so for this one, resulting in a more egregious buffer overread than the one I was fixing (since the read character ended up in the output if there was space). Reported by: Jenkins Fixes: 34fb1c133c5b ("Fix intra-object buffer overread for labeled msdosfs volumes") --- sys/geom/label/g_label_msdosfs.c | 2 +- usr.sbin/fstyp/msdosfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/geom/label/g_label_msdosfs.c b/sys/geom/label/g_label_msdosfs.c index 2ba35ff80f51..06d5f2a8e0f0 100644 --- a/sys/geom/label/g_label_msdosfs.c +++ b/sys/geom/label/g_label_msdosfs.c @@ -136,7 +136,7 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size) if (strncmp(pfat32_bsbpb->BS_VolLab, LABEL_NO_NAME, sizeof(pfat32_bsbpb->BS_VolLab)) != 0) { copysize = MIN(size - 1, - sizeof(pfat32_bsbpb->BS_VolLab) + 1); + sizeof(pfat32_bsbpb->BS_VolLab)); memcpy(label, pfat32_bsbpb->BS_VolLab, copysize); label[copysize] = '\0'; goto endofchecks; diff --git a/usr.sbin/fstyp/msdosfs.c b/usr.sbin/fstyp/msdosfs.c index ce745869edba..47d2383fbc8f 100644 --- a/usr.sbin/fstyp/msdosfs.c +++ b/usr.sbin/fstyp/msdosfs.c @@ -104,7 +104,7 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size) if (strncmp(pfat32_bsbpb->BS_VolLab, LABEL_NO_NAME, sizeof(pfat32_bsbpb->BS_VolLab)) != 0) { copysize = MIN(size - 1, - sizeof(pfat32_bsbpb->BS_VolLab) + 1); + sizeof(pfat32_bsbpb->BS_VolLab)); memcpy(label, pfat32_bsbpb->BS_VolLab, copysize); label[copysize] = '\0'; goto endofchecks; From nobody Thu Oct 28 02:00:28 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 28AE91828F88; Thu, 28 Oct 2021 02:00:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hfpg10jDjz3MyF; Thu, 28 Oct 2021 02:00:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EC9B41B09F; Thu, 28 Oct 2021 02:00:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S20Swe032149; Thu, 28 Oct 2021 02:00:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S20S1h032148; Thu, 28 Oct 2021 02:00:28 GMT (envelope-from git) Date: Thu, 28 Oct 2021 02:00:28 GMT Message-Id: <202110280200.19S20S1h032148@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 840680e601f1 - main - Wrap mutex(9), rwlock(9) and sx(9) macros into __extension__ ({}) instead of do {} while (0). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 840680e601f15b25abed3fad31399a9ce838f13a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=840680e601f15b25abed3fad31399a9ce838f13a commit 840680e601f15b25abed3fad31399a9ce838f13a Author: Gleb Smirnoff AuthorDate: 2021-10-27 17:33:01 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-28 01:58:36 +0000 Wrap mutex(9), rwlock(9) and sx(9) macros into __extension__ ({}) instead of do {} while (0). This makes them real void expressions, and they can be used anywhere where a void function call can be used, for example in a conditional operator. Reviewed by: kib, mjg Differential revision: https://reviews.freebsd.org/D32696 --- sys/sys/mutex.h | 28 ++++++++++++++++------------ sys/sys/rwlock.h | 15 +++++++++------ sys/sys/sx.h | 5 +++-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index f35cdd7413a6..04e2c823541a 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -236,14 +236,15 @@ void _thread_lock(struct thread *); */ /* Lock a normal mutex. */ -#define __mtx_lock(mp, tid, opts, file, line) do { \ +#define __mtx_lock(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ uintptr_t _v = MTX_UNOWNED; \ \ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(adaptive__acquire) ||\ !_mtx_obtain_lock_fetch((mp), &_v, _tid))) \ _mtx_lock_sleep((mp), _v, (opts), (file), (line)); \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) /* * Lock a spin mutex. For spinlocks, we handle recursion inline (it @@ -252,7 +253,7 @@ void _thread_lock(struct thread *); * inlining this code is not too big a deal. */ #ifdef SMP -#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ +#define __mtx_lock_spin(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ uintptr_t _v = MTX_UNOWNED; \ \ @@ -260,7 +261,8 @@ void _thread_lock(struct thread *); if (__predict_false(LOCKSTAT_PROFILE_ENABLED(spin__acquire) || \ !_mtx_obtain_lock_fetch((mp), &_v, _tid))) \ _mtx_lock_spin((mp), _v, (opts), (file), (line)); \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) #define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ int _ret; \ @@ -277,7 +279,7 @@ void _thread_lock(struct thread *); _ret; \ }) #else /* SMP */ -#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ +#define __mtx_lock_spin(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ \ spinlock_enter(); \ @@ -287,7 +289,8 @@ void _thread_lock(struct thread *); KASSERT((mp)->mtx_lock == MTX_UNOWNED, ("corrupt spinlock")); \ (mp)->mtx_lock = _tid; \ } \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) #define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ int _ret; \ @@ -305,13 +308,14 @@ void _thread_lock(struct thread *); #endif /* SMP */ /* Unlock a normal mutex. */ -#define __mtx_unlock(mp, tid, opts, file, line) do { \ +#define __mtx_unlock(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _v = (uintptr_t)(tid); \ \ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(adaptive__release) ||\ !_mtx_release_lock_fetch((mp), &_v))) \ _mtx_unlock_sleep((mp), _v, (opts), (file), (line)); \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) /* * Unlock a spin mutex. For spinlocks, we can handle everything @@ -324,7 +328,7 @@ void _thread_lock(struct thread *); * releasing a spin lock. This includes the recursion cases. */ #ifdef SMP -#define __mtx_unlock_spin(mp) do { \ +#define __mtx_unlock_spin(mp) __extension__ ({ \ if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ @@ -332,9 +336,9 @@ void _thread_lock(struct thread *); _mtx_release_lock_quick((mp)); \ } \ spinlock_exit(); \ -} while (0) +}) #else /* SMP */ -#define __mtx_unlock_spin(mp) do { \ +#define __mtx_unlock_spin(mp) __extension__ ({ \ if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ @@ -342,7 +346,7 @@ void _thread_lock(struct thread *); (mp)->mtx_lock = MTX_UNOWNED; \ } \ spinlock_exit(); \ -} while (0) +}) #endif /* SMP */ /* diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h index 4e7768595737..99e885e07aaf 100644 --- a/sys/sys/rwlock.h +++ b/sys/sys/rwlock.h @@ -103,23 +103,25 @@ */ /* Acquire a write lock. */ -#define __rw_wlock(rw, tid, file, line) do { \ +#define __rw_wlock(rw, tid, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ uintptr_t _v = RW_UNLOCKED; \ \ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(rw__acquire) || \ !_rw_write_lock_fetch((rw), &_v, _tid))) \ _rw_wlock_hard((rw), _v, (file), (line)); \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) /* Release a write lock. */ -#define __rw_wunlock(rw, tid, file, line) do { \ +#define __rw_wunlock(rw, tid, file, line) __extension__ ({ \ uintptr_t _v = (uintptr_t)(tid); \ \ if (__predict_false(LOCKSTAT_PROFILE_ENABLED(rw__release) || \ !_rw_write_unlock_fetch((rw), &_v))) \ _rw_wunlock_hard((rw), _v, (file), (line)); \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) /* * Function prototypes. Routines that start with _ are not part of the @@ -231,12 +233,13 @@ void __rw_assert(const volatile uintptr_t *c, int what, const char *file, #define rw_try_upgrade(rw) _rw_try_upgrade((rw), LOCK_FILE, LOCK_LINE) #define rw_try_wlock(rw) _rw_try_wlock((rw), LOCK_FILE, LOCK_LINE) #define rw_downgrade(rw) _rw_downgrade((rw), LOCK_FILE, LOCK_LINE) -#define rw_unlock(rw) do { \ +#define rw_unlock(rw) __extension__ ({ \ if (rw_wowned(rw)) \ rw_wunlock(rw); \ else \ rw_runlock(rw); \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) #define rw_sleep(chan, rw, pri, wmesg, timo) \ _sleep((chan), &(rw)->lock_object, (pri), (wmesg), \ tick_sbt * (timo), 0, C_HARDCLOCK) diff --git a/sys/sys/sx.h b/sys/sys/sx.h index 1e6b9f3f8a46..bd164a96558b 100644 --- a/sys/sys/sx.h +++ b/sys/sys/sx.h @@ -253,12 +253,13 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) (((sx)->sx_lock & ~(SX_LOCK_FLAGMASK & ~SX_LOCK_SHARED)) == \ (uintptr_t)curthread) -#define sx_unlock_(sx, file, line) do { \ +#define sx_unlock_(sx, file, line) __extension__ ({ \ if (sx_xlocked(sx)) \ sx_xunlock_(sx, file, line); \ else \ sx_sunlock_(sx, file, line); \ -} while (0) + (void)0; /* ensure void type for expression */ \ +}) #define sx_unlock(sx) sx_unlock_((sx), LOCK_FILE, LOCK_LINE) From nobody Thu Oct 28 05:12:36 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DDBDF182F495; Thu, 28 Oct 2021 05:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hftwh5gvjz3FcW; Thu, 28 Oct 2021 05:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A2C3A1DE2A; Thu, 28 Oct 2021 05:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S5Cadh089296; Thu, 28 Oct 2021 05:12:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S5Cacu089295; Thu, 28 Oct 2021 05:12:36 GMT (envelope-from git) Date: Thu, 28 Oct 2021 05:12:36 GMT Message-Id: <202110280512.19S5Cacu089295@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: fb3854845f50 - main - mroute: fix memory leak List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb3854845f500155982355a39d1d32ccc9a44c16 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=fb3854845f500155982355a39d1d32ccc9a44c16 commit fb3854845f500155982355a39d1d32ccc9a44c16 Author: Wojciech Macek AuthorDate: 2021-10-28 04:41:15 +0000 Commit: Wojciech Macek CommitDate: 2021-10-28 05:12:16 +0000 mroute: fix memory leak Add MFC to linked list to store incoming packets before MCAST JOIN was captured. Sponsored by: Stormshield Obtained from: Semihalf MFC after: 2 weeks --- sys/netinet/ip_mroute.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index efb34af60d9c..c992743a503e 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1466,6 +1466,9 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m, timevalclear(&rt->mfc_last_assert); buf_ring_enqueue(rt->mfc_stall_ring, rte); + + /* Add RT to hashtable as it didn't exist before */ + LIST_INSERT_HEAD(&V_mfchashtbl[hash], rt, mfc_hash); } else { /* determine if queue has overflowed */ if (buf_ring_full(rt->mfc_stall_ring)) { From nobody Thu Oct 28 05:12:37 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 435A1182F2D3; Thu, 28 Oct 2021 05:12:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hftwk0kZTz3FJK; Thu, 28 Oct 2021 05:12:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E1F621DC49; Thu, 28 Oct 2021 05:12:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S5CbdG089320; Thu, 28 Oct 2021 05:12:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S5Cbpj089319; Thu, 28 Oct 2021 05:12:37 GMT (envelope-from git) Date: Thu, 28 Oct 2021 05:12:37 GMT Message-Id: <202110280512.19S5Cbpj089319@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 8a727c3df89a - main - mroute: add missing WUNLOCK List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a727c3df89acd02050b849a916e49ae447c1d9d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=8a727c3df89acd02050b849a916e49ae447c1d9d commit 8a727c3df89acd02050b849a916e49ae447c1d9d Author: Wojciech Macek AuthorDate: 2021-10-28 04:59:37 +0000 Commit: Wojciech Macek CommitDate: 2021-10-28 05:12:23 +0000 mroute: add missing WUNLOCK Add missing WNLOCK as in all other error cases. Reported by: Stormshield Obtained from: Semihalf --- sys/netinet/ip_mroute.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index c992743a503e..02738616d56e 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -713,8 +713,10 @@ ip_mrouter_init(struct socket *so, int version) mtx_init(&V_bw_upcalls_ring_mtx, "mroute upcall buf_ring mtx", NULL, MTX_DEF); V_bw_upcalls_ring = buf_ring_alloc(BW_UPCALLS_MAX, M_MRTABLE, M_NOWAIT, &V_bw_upcalls_ring_mtx); - if (!V_bw_upcalls_ring) + if (!V_bw_upcalls_ring) { + MRW_WUNLOCK(); return (ENOMEM); + } /* Create upcall thread */ upcall_thread_shutdown = 0; From nobody Thu Oct 28 08:50:38 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 14F72181FADB; Thu, 28 Oct 2021 08:50:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfzmH074Fz4xJW; Thu, 28 Oct 2021 08:50:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D99D120C0C; Thu, 28 Oct 2021 08:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S8ocJL079494; Thu, 28 Oct 2021 08:50:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S8ocCH079483; Thu, 28 Oct 2021 08:50:38 GMT (envelope-from git) Date: Thu, 28 Oct 2021 08:50:38 GMT Message-Id: <202110280850.19S8ocCH079483@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 62d2dcafb7f3 - main - if_epair: delete mbuf tags List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 62d2dcafb7f33fe8f47e9d5dd519d665f7af140e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=62d2dcafb7f33fe8f47e9d5dd519d665f7af140e commit 62d2dcafb7f33fe8f47e9d5dd519d665f7af140e Author: Kristof Provost AuthorDate: 2021-10-26 07:57:56 +0000 Commit: Kristof Provost CommitDate: 2021-10-28 08:41:16 +0000 if_epair: delete mbuf tags Remove all (non-persistent) tags when we transmit a packet. Real network interfaces do not carry any tags either, and leaving tags attached can produce unexpected results. Reviewed by: bz, glebius MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32663 --- sys/net/if_epair.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 7f62cdb427ff..a62fbfad8771 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -196,6 +196,19 @@ struct epair_dpcpu { }; DPCPU_DEFINE(struct epair_dpcpu, epair_dpcpu); +static void +epair_clear_mbuf(struct mbuf *m) +{ + /* Remove any CSUM_SND_TAG as ether_input will barf. */ + if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) { + m_snd_tag_rele(m->m_pkthdr.snd_tag); + m->m_pkthdr.snd_tag = NULL; + m->m_pkthdr.csum_flags &= ~CSUM_SND_TAG; + } + + m_tag_delete_nonpersistent(m); +} + static void epair_dpcpu_init(void) { @@ -435,6 +448,8 @@ epair_start_locked(struct ifnet *ifp) } DPRINTF("packet %s -> %s\n", ifp->if_xname, oifp->if_xname); + epair_clear_mbuf(m); + /* * Add a reference so the interface cannot go while the * packet is in transit as we rely on rcvif to stay valid. @@ -556,6 +571,9 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) (void)epair_add_ifp_for_draining(ifp); return (error); } + + epair_clear_mbuf(m); + sc = oifp->if_softc; /* * Add a reference so the interface cannot go while the From nobody Thu Oct 28 08:50:39 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7AA49181FC95; Thu, 28 Oct 2021 08:50:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfzmJ1wQGz4xJd; Thu, 28 Oct 2021 08:50:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 11DF7208EE; Thu, 28 Oct 2021 08:50:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S8odKS079756; Thu, 28 Oct 2021 08:50:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S8od1g079755; Thu, 28 Oct 2021 08:50:39 GMT (envelope-from git) Date: Thu, 28 Oct 2021 08:50:39 GMT Message-Id: <202110280850.19S8od1g079755@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 7fe0c3f8d330 - main - mbuf: PACKET_TAG_PF should not be persistent List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7fe0c3f8d3303b67e55e3abcd66cbd4a9eaa1a0d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7fe0c3f8d3303b67e55e3abcd66cbd4a9eaa1a0d commit 7fe0c3f8d3303b67e55e3abcd66cbd4a9eaa1a0d Author: Kristof Provost AuthorDate: 2021-10-26 07:51:33 +0000 Commit: Kristof Provost CommitDate: 2021-10-28 08:41:17 +0000 mbuf: PACKET_TAG_PF should not be persistent We should clear firewall tags on loopback, icmp reflection, or if_epair transmission. Left over tags can produce unexpected behaviour, especially on if_epair where a and b interfaces can be in different vnets, and have different firewall policies set. MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32664 --- sys/sys/mbuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 9c196f30b319..413854cc9a57 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1351,7 +1351,7 @@ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */ #define PACKET_TAG_DIVERT 17 /* divert info */ #define PACKET_TAG_IPFORWARD 18 /* ipforward info */ #define PACKET_TAG_MACLABEL (19 | MTAG_PERSISTENT) /* MAC label */ -#define PACKET_TAG_PF (21 | MTAG_PERSISTENT) /* PF/ALTQ information */ +#define PACKET_TAG_PF 21 /* PF/ALTQ information */ #define PACKET_TAG_RTSOCKFAM 25 /* rtsock sa family */ #define PACKET_TAG_IPOPTIONS 27 /* Saved IP options */ #define PACKET_TAG_CARP 28 /* CARP info */ From nobody Thu Oct 28 08:50:41 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8D870181FD12; Thu, 28 Oct 2021 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfzmK2hFzz4x9Z; Thu, 28 Oct 2021 08:50:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2A17A2084E; Thu, 28 Oct 2021 08:50:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S8ofa2079782; Thu, 28 Oct 2021 08:50:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S8oflX079781; Thu, 28 Oct 2021 08:50:41 GMT (envelope-from git) Date: Thu, 28 Oct 2021 08:50:41 GMT Message-Id: <202110280850.19S8oflX079781@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: e5c4987e3fc1 - main - pf: fix dummynet + NAT List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e5c4987e3fc1997264f4c3a10d3047a9379b9b15 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e5c4987e3fc1997264f4c3a10d3047a9379b9b15 commit e5c4987e3fc1997264f4c3a10d3047a9379b9b15 Author: Kristof Provost AuthorDate: 2021-10-26 07:59:42 +0000 Commit: Kristof Provost CommitDate: 2021-10-28 08:41:17 +0000 pf: fix dummynet + NAT Dummynet differs from ALTQ in that ALTQ schedules packets after they leave pf. Dummynet schedules them after they leave pf, but then re-injects them. We currently deal with this by ensuring we don't re-schedule a packet we get from dummynet, but this produces unexpected results when combined with NAT, as dummynet processing is done after the NAT transformation. In other words, the second time the packet is handed to pf it may have a different source and destination address. Simplify this by moving dummynet processing to after all other pf processing, and not re-processing (but always passing) packets from dummynet. This fixes NAT of dummynet delayed packets, and also reduces processing overhead (because we only do state/rule lookup for each dummynet packet once, rather than twice). MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32665 --- sys/netpfil/pf/pf.c | 73 +++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index bb7667a3e270..61eea329a7f7 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6456,6 +6456,13 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb * } pd.pf_mtag->flags |= PF_PACKET_LOOPED; m_tag_delete(m, ipfwtag); + if (rr->info & IPFW_IS_DUMMYNET) { + /* Dummynet re-injects packets after they've + * completed their delay. We've already + * processed them, so pass unconditionally. */ + PF_RULES_RUNLOCK(); + return (PF_PASS); + } } if (pd.pf_mtag && pd.pf_mtag->flags & PF_FASTFWD_OURS_PRESENT) { m->m_flags |= M_FASTFWD_OURS; @@ -6704,47 +6711,6 @@ done: } #endif /* ALTQ */ - if (s && (s->dnpipe || s->dnrpipe)) { - pd.act.dnpipe = s->dnpipe; - pd.act.dnrpipe = s->dnrpipe; - pd.act.flags = s->state_flags; - } else if (r->dnpipe || r->dnrpipe) { - pd.act.dnpipe = r->dnpipe; - pd.act.dnrpipe = r->dnrpipe; - pd.act.flags = r->free_flags; - } - if ((pd.act.dnpipe || pd.act.dnrpipe) && !PACKET_LOOPED(&pd)) { - if (ip_dn_io_ptr == NULL) { - action = PF_DROP; - REASON_SET(&reason, PFRES_MEMORY); - } else { - struct ip_fw_args dnflow; - - if (pd.pf_mtag == NULL && - ((pd.pf_mtag = pf_get_mtag(m)) == NULL)) { - action = PF_DROP; - REASON_SET(&reason, PFRES_MEMORY); - if (s) - PF_STATE_UNLOCK(s); - return (action); - } - - if (pf_pdesc_to_dnflow(dir, &pd, r, s, &dnflow)) { - ip_dn_io_ptr(m0, &dnflow); - - if (*m0 == NULL) { - if (s) - PF_STATE_UNLOCK(s); - return (action); - } else { - /* This is dummynet fast io processing */ - m_tag_delete(*m0, m_tag_first(*m0)); - pd.pf_mtag->flags &= ~PF_PACKET_LOOPED; - } - } - } - } - /* * connections redirected to loopback should not match sockets * bound specifically to loopback due to security implications, @@ -6885,6 +6851,31 @@ done: pf_route(m0, r, dir, kif->pfik_ifp, s, &pd, inp); return (action); } + /* Dummynet processing. */ + if (s && (s->dnpipe || s->dnrpipe)) { + pd.act.dnpipe = s->dnpipe; + pd.act.dnrpipe = s->dnrpipe; + pd.act.flags = s->state_flags; + } else if (r->dnpipe || r->dnrpipe) { + pd.act.dnpipe = r->dnpipe; + pd.act.dnrpipe = r->dnrpipe; + pd.act.flags = r->free_flags; + } + if (pd.act.dnpipe || pd.act.dnrpipe) { + if (ip_dn_io_ptr == NULL) { + m_freem(*m0); + *m0 = NULL; + REASON_SET(&reason, PFRES_MEMORY); + } else { + struct ip_fw_args dnflow; + + if (pf_pdesc_to_dnflow(dir, &pd, r, s, &dnflow)) { + ip_dn_io_ptr(m0, &dnflow); + if (*m0 == NULL) + action = PF_DROP; + } + } + } break; } From nobody Thu Oct 28 08:50:42 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 74A52181FBE1; Thu, 28 Oct 2021 08:50:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfzmL4HCCz4xK2; Thu, 28 Oct 2021 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 479EC20C0D; Thu, 28 Oct 2021 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S8ogu1079811; Thu, 28 Oct 2021 08:50:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S8oggf079810; Thu, 28 Oct 2021 08:50:42 GMT (envelope-from git) Date: Thu, 28 Oct 2021 08:50:42 GMT Message-Id: <202110280850.19S8oggf079810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 4ee0f6d87452 - main - netpfil tests: dummynet+NAT test for pf List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4ee0f6d87452d156a588ea23b016203dcc7ec6ad Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4ee0f6d87452d156a588ea23b016203dcc7ec6ad commit 4ee0f6d87452d156a588ea23b016203dcc7ec6ad Author: Kristof Provost AuthorDate: 2021-10-26 08:56:30 +0000 Commit: Kristof Provost CommitDate: 2021-10-28 08:41:17 +0000 netpfil tests: dummynet+NAT test for pf Ensure that NAT still works as expected when combined with dummynet. MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32666 --- tests/sys/netpfil/common/dummynet.sh | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/sys/netpfil/common/dummynet.sh b/tests/sys/netpfil/common/dummynet.sh index 644b36516b5a..448bb79a46f9 100644 --- a/tests/sys/netpfil/common/dummynet.sh +++ b/tests/sys/netpfil/common/dummynet.sh @@ -329,6 +329,50 @@ queue_v6_cleanup() firewall_cleanup $1 } +nat_head() +{ + atf_set descr 'Basic dummynet + NAT test' + atf_set require.user root +} + +nat_body() +{ + fw=$1 + firewall_init $fw + dummynet_init $fw + nat_init $fw + + epair=$(vnet_mkepair) + epair_two=$(vnet_mkepair) + + ifconfig ${epair}a 192.0.2.2/24 up + route add -net 198.51.100.0/24 192.0.2.1 + + vnet_mkjail gw ${epair}b ${epair_two}a + jexec gw ifconfig ${epair}b 192.0.2.1/24 up + jexec gw ifconfig ${epair_two}a 198.51.100.1/24 up + jexec gw sysctl net.inet.ip.forwarding=1 + + vnet_mkjail srv ${epair_two}b + jexec srv ifconfig ${epair_two}b 198.51.100.2/24 up + + jexec gw dnctl pipe 1 config bw 300Byte/s + + firewall_config gw $fw \ + "pf" \ + "nat on ${epair_two}a inet from 192.0.2.0/24 to any -> (${epair_two}a)" \ + "pass dnpipe 1" + + # We've deliberately not set a route to 192.0.2.0/24 on srv, so the + # only way it can respond to this is if NAT is applied correctly. + atf_check -s exit:0 -o ignore ping -c 1 198.51.100.2 +} + +nat_cleanup() +{ + firewall_cleanup $1 +} + setup_tests \ pipe \ ipfw \ @@ -341,4 +385,6 @@ setup_tests \ pf \ queue_v6 \ ipfw \ + pf \ + nat \ pf From nobody Thu Oct 28 13:51:35 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AB9EF182DD04; Thu, 28 Oct 2021 13:51:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hg6RW4QL9z3GN9; Thu, 28 Oct 2021 13:51:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7906C24E49; Thu, 28 Oct 2021 13:51:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SDpZY0080530; Thu, 28 Oct 2021 13:51:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SDpZiK080528; Thu, 28 Oct 2021 13:51:35 GMT (envelope-from git) Date: Thu, 28 Oct 2021 13:51:35 GMT Message-Id: <202110281351.19SDpZiK080528@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 1a4d5f13ba19 - main - ident: replace sbuf(9) with open_memstream(3) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1a4d5f13ba19308f9909ef712c5d7eebaf1f9806 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=1a4d5f13ba19308f9909ef712c5d7eebaf1f9806 commit 1a4d5f13ba19308f9909ef712c5d7eebaf1f9806 Author: Baptiste Daroussin AuthorDate: 2021-10-28 13:39:24 +0000 Commit: Baptiste Daroussin CommitDate: 2021-10-28 13:51:23 +0000 ident: replace sbuf(9) with open_memstream(3) This change makes ident only dependant on libc functions This makes our ident(1) more portable, also the fact that we only depend on libc which is maintained with excellent backward compatibility means that if one day ident is removed from base, someone using FreeBSD 22 will be able to fetch ident from FreeBSD 14 to run ident against FreeBSD 1.0 binary MFC After: 1 week --- usr.bin/ident/Makefile | 2 -- usr.bin/ident/ident.c | 35 +++++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/usr.bin/ident/Makefile b/usr.bin/ident/Makefile index e0a3a80f7b09..0e0734081607 100644 --- a/usr.bin/ident/Makefile +++ b/usr.bin/ident/Makefile @@ -4,8 +4,6 @@ PROG= ident -LIBADD= sbuf - HAS_TESTS= SUBDIR.${MK_TESTS}+= tests diff --git a/usr.bin/ident/ident.c b/usr.bin/ident/ident.c index aa9612d2fce1..14ff8ec8f335 100644 --- a/usr.bin/ident/ident.c +++ b/usr.bin/ident/ident.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Baptiste Daroussin + * Copyright (c) 2015-2021 Baptiste Daroussin * Copyright (c) 2015 Xin LI * * Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -58,10 +59,17 @@ scan(FILE *fp, const char *name, bool quiet) bool hasid = false; bool subversion = false; analyzer_states state = INIT; - struct sbuf *id = sbuf_new_auto(); + FILE* buffp; + char *buf; + size_t sz; locale_t l; l = newlocale(LC_ALL_MASK, "C", NULL); + sz = 0; + buf = NULL; + buffp = open_memstream(&buf, &sz); + if (buffp == NULL) + err(EXIT_FAILURE, "open_memstream()"); if (name != NULL) printf("%s:\n", name); @@ -80,9 +88,11 @@ scan(FILE *fp, const char *name, bool quiet) case DELIM_SEEN: if (isalpha_l(c, l)) { /* Transit to KEYWORD if we see letter */ - sbuf_clear(id); - sbuf_putc(id, '$'); - sbuf_putc(id, c); + if (buf != NULL) + memset(buf, 0, sz); + rewind(buffp); + fputc('$', buffp); + fputc(c, buffp); state = KEYWORD; continue; @@ -95,7 +105,7 @@ scan(FILE *fp, const char *name, bool quiet) } break; case KEYWORD: - sbuf_putc(id, c); + fputc(c, buffp); if (isalpha_l(c, l)) { /* @@ -125,7 +135,7 @@ scan(FILE *fp, const char *name, bool quiet) break; case PUNC_SEEN: case PUNC_SEEN_SVN: - sbuf_putc(id, c); + fputc(c, buffp); switch (c) { case ':': @@ -159,13 +169,13 @@ scan(FILE *fp, const char *name, bool quiet) } break; case TEXT: - sbuf_putc(id, c); + fputc(c, buffp); if (iscntrl_l(c, l)) { /* Control characters are not allowed in this state */ state = INIT; } else if (c == '$') { - sbuf_finish(id); + fflush(buffp); /* * valid ident should end with a space. * @@ -175,9 +185,9 @@ scan(FILE *fp, const char *name, bool quiet) * subversion mode. No length check is enforced * because GNU RCS ident(1) does not do it either. */ - c = sbuf_data(id)[sbuf_len(id) - 2]; + c = buf[strlen(buf) -2 ]; if (c == ' ' || (subversion && c == '#')) { - printf(" %s\n", sbuf_data(id)); + printf(" %s\n", buf); hasid = true; } state = INIT; @@ -186,7 +196,8 @@ scan(FILE *fp, const char *name, bool quiet) break; } } - sbuf_delete(id); + fclose(buffp); + free(buf); freelocale(l); if (!hasid) { From nobody Thu Oct 28 15:45:36 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 53AA11836F3E; Thu, 28 Oct 2021 15:45: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hg8z56XCBz4hb1; Thu, 28 Oct 2021 15:45:37 +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 3C8E19133; Thu, 28 Oct 2021 15:45:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: git: 62d2dcafb7f3 - main - if_epair: delete mbuf tags To: Kristof Provost , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202110280850.19S8ocCH079483@gitrepo.freebsd.org> From: John Baldwin Message-ID: <451456f3-6a1f-78b3-4c34-01c6cf681cd0@FreeBSD.org> Date: Thu, 28 Oct 2021 08:45:36 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 In-Reply-To: <202110280850.19S8ocCH079483@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N On 10/28/21 1:50 AM, Kristof Provost wrote: > The branch main has been updated by kp: > > URL: https://cgit.FreeBSD.org/src/commit/?id=62d2dcafb7f33fe8f47e9d5dd519d665f7af140e > > commit 62d2dcafb7f33fe8f47e9d5dd519d665f7af140e > Author: Kristof Provost > AuthorDate: 2021-10-26 07:57:56 +0000 > Commit: Kristof Provost > CommitDate: 2021-10-28 08:41:16 +0000 > > if_epair: delete mbuf tags > > Remove all (non-persistent) tags when we transmit a packet. Real network > interfaces do not carry any tags either, and leaving tags attached can > produce unexpected results. > > Reviewed by: bz, glebius > MFC after: 3 weeks > Sponsored by: Rubicon Communications, LLC ("Netgate") > Differential Revision: https://reviews.freebsd.org/D32663 Wireguard has similar functionality FWIW, so it might be worth exposing a generic "mb_free_tags". Wireguard also tries to reset some other state like the status of checksum offload since it is moving mbufs between an ifnet and a socket. Not sure if epair also needs to clear all the same things? -- John Baldwin From nobody Thu Oct 28 16:22:32 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D6E5F18277F0; Thu, 28 Oct 2021 16:22:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hg9nm5r6xz4vNH; Thu, 28 Oct 2021 16:22:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.codepro.be", Issuer "R3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 8FC539C1D; Thu, 28 Oct 2021 16:22:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id 2783A2978F; Thu, 28 Oct 2021 18:22:33 +0200 (CEST) From: Kristof Provost To: John Baldwin Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 62d2dcafb7f3 - main - if_epair: delete mbuf tags Date: Thu, 28 Oct 2021 18:22:32 +0200 X-Mailer: MailMate (1.14r5818) Message-ID: In-Reply-To: <451456f3-6a1f-78b3-4c34-01c6cf681cd0@FreeBSD.org> References: <202110280850.19S8ocCH079483@gitrepo.freebsd.org> <451456f3-6a1f-78b3-4c34-01c6cf681cd0@FreeBSD.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ThisMailContainsUnwantedMimeParts: N On 28 Oct 2021, at 17:45, John Baldwin wrote: > On 10/28/21 1:50 AM, Kristof Provost wrote: >> The branch main has been updated by kp: >> >> URL: https://cgit.FreeBSD.org/src/commit/?id=3D62d2dcafb7f33fe8f47e9d5= dd519d665f7af140e >> >> commit 62d2dcafb7f33fe8f47e9d5dd519d665f7af140e >> Author: Kristof Provost >> AuthorDate: 2021-10-26 07:57:56 +0000 >> Commit: Kristof Provost >> CommitDate: 2021-10-28 08:41:16 +0000 >> >> if_epair: delete mbuf tags >> Remove all (non-persistent) tags when we transmit a packet. R= eal network >> interfaces do not carry any tags either, and leaving tags attache= d can >> produce unexpected results. >> Reviewed by: bz, glebius >> MFC after: 3 weeks >> Sponsored by: Rubicon Communications, LLC ("Netgate") >> Differential Revision: https://reviews.freebsd.org/D32663 > > Wireguard has similar functionality FWIW, so it might be worth exposing= a generic > "mb_free_tags". Wireguard also tries to reset some other state like th= e status > of checksum offload since it is moving mbufs between an ifnet and a soc= ket. Not > sure if epair also needs to clear all the same things? > Something like https://reviews.freebsd.org/D32710 ? I stuck with the =E2=80=98clear=E2=80=99 terminology to distinguish it fr= om the existing free functions, and because the use case is slightly diff= erent. Kristof From nobody Thu Oct 28 17:50:36 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D32AA1827007; Thu, 28 Oct 2021 17:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgClJ5hDKz4SWM; Thu, 28 Oct 2021 17:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A36A227CD8; Thu, 28 Oct 2021 17:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SHoa9K097625; Thu, 28 Oct 2021 17:50:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SHoaNk097624; Thu, 28 Oct 2021 17:50:36 GMT (envelope-from git) Date: Thu, 28 Oct 2021 17:50:36 GMT Message-Id: <202110281750.19SHoaNk097624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 143dba3a9142 - main - kern_exec.c: style List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 143dba3a914294c2f4de80a46ffd04cd8b25246f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=143dba3a914294c2f4de80a46ffd04cd8b25246f commit 143dba3a914294c2f4de80a46ffd04cd8b25246f Author: Konstantin Belousov AuthorDate: 2021-10-22 23:49:30 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 17:49:10 +0000 kern_exec.c: style Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611 --- sys/kern/kern_exec.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index a8f07bf39564..eb785c9f71d5 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -241,9 +241,9 @@ static const struct execsw **execsw; #ifndef _SYS_SYSPROTO_H_ struct execve_args { - char *fname; + char *fname; char **argv; - char **envv; + char **envv; }; #endif @@ -509,7 +509,8 @@ interpret: /* * Descriptors opened only with O_EXEC or O_RDONLY are allowed. */ - error = fgetvp_exec(td, args->fd, &cap_fexecve_rights, &newtextvp); + error = fgetvp_exec(td, args->fd, &cap_fexecve_rights, + &newtextvp); if (error) goto exec_fail; vn_lock(newtextvp, LK_SHARED | LK_RETRY); @@ -628,7 +629,8 @@ interpret: imgp->execpath = args->fname; else { VOP_UNLOCK(imgp->vp); - if (vn_fullpath(imgp->vp, &imgp->execpath, &imgp->freepath) != 0) + if (vn_fullpath(imgp->vp, &imgp->execpath, + &imgp->freepath) != 0) imgp->execpath = args->fname; vn_lock(imgp->vp, LK_SHARED | LK_RETRY); } @@ -1040,7 +1042,7 @@ exec_map_first_page(struct image_params *imgp) #endif error = vm_page_grab_valid_unlocked(&m, object, 0, VM_ALLOC_COUNT(VM_INITIAL_PAGEIN) | - VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY | VM_ALLOC_WIRED); + VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY | VM_ALLOC_WIRED); if (error != VM_PAGER_OK) return (EIO); @@ -1985,7 +1987,8 @@ sbuf_drain_core_output(void *arg, const char *data, int len) if (locked) PROC_UNLOCK(p); if (cp->comp != NULL) - error = compressor_write(cp->comp, __DECONST(char *, data), len); + error = compressor_write(cp->comp, __DECONST(char *, data), + len); else error = core_write(cp, __DECONST(void *, data), len, cp->offset, UIO_SYSSPACE, NULL); From nobody Thu Oct 28 17:50:37 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 507381826EB2; Thu, 28 Oct 2021 17:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgClL0WJ1z4Spc; Thu, 28 Oct 2021 17:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D259E27CD9; Thu, 28 Oct 2021 17:50:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SHobf0097649; Thu, 28 Oct 2021 17:50:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SHobrH097648; Thu, 28 Oct 2021 17:50:37 GMT (envelope-from git) Date: Thu, 28 Oct 2021 17:50:37 GMT Message-Id: <202110281750.19SHobrH097648@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9d58243fbc4a - main - do_execve(): switch boolean locals to use bool type List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9d58243fbc4a1931aba618f8f5f6872779656c42 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9d58243fbc4a1931aba618f8f5f6872779656c42 commit 9d58243fbc4a1931aba618f8f5f6872779656c42 Author: Konstantin Belousov AuthorDate: 2021-10-23 14:47:28 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 17:49:16 +0000 do_execve(): switch boolean locals to use bool type Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611 --- sys/kern/kern_exec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index eb785c9f71d5..e86d19e9eed1 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -421,10 +421,10 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, struct ktr_io_params *kiop; #endif struct vnode *oldtextvp = NULL, *newtextvp; - int credential_changing; + bool credential_changing; #ifdef MAC struct label *interpvplabel = NULL; - int will_transition; + bool will_transition; #endif #ifdef HWPMC_HOOKS struct pmckern_procexec pe; @@ -558,14 +558,14 @@ interpret: * XXXMAC: For the time being, use NOSUID to also prohibit * transitions on the file system. */ - credential_changing = 0; + credential_changing = false; credential_changing |= (attr.va_mode & S_ISUID) && oldcred->cr_uid != attr.va_uid; credential_changing |= (attr.va_mode & S_ISGID) && oldcred->cr_gid != attr.va_gid; #ifdef MAC will_transition = mac_vnode_execve_will_transition(oldcred, imgp->vp, - interpvplabel, imgp); + interpvplabel, imgp) != 0; credential_changing |= will_transition; #endif From nobody Thu Oct 28 17:50:38 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BA25E182701C; Thu, 28 Oct 2021 17:50:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgClM1gxqz4ShT; Thu, 28 Oct 2021 17:50:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EB74027E4F; Thu, 28 Oct 2021 17:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SHocKJ097673; Thu, 28 Oct 2021 17:50:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SHocdK097672; Thu, 28 Oct 2021 17:50:38 GMT (envelope-from git) Date: Thu, 28 Oct 2021 17:50:38 GMT Message-Id: <202110281750.19SHocdK097672@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 15bf81f354a4 - main - struct image_params: use bool type for boolean members List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 15bf81f354a428723d7e9ea61ea215d4195aa050 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=15bf81f354a428723d7e9ea61ea215d4195aa050 commit 15bf81f354a428723d7e9ea61ea215d4195aa050 Author: Konstantin Belousov AuthorDate: 2021-10-23 15:05:56 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 17:49:21 +0000 struct image_params: use bool type for boolean members Also re-align comments, and group booleans and char members together. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611 --- sys/kern/kern_exec.c | 6 +++--- sys/sys/imgact.h | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index e86d19e9eed1..5cc5a1205901 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -687,7 +687,7 @@ interpret: #endif if (imgp->opened) { VOP_CLOSE(newtextvp, FREAD, td->td_ucred, td); - imgp->opened = 0; + imgp->opened = false; } vput(newtextvp); vm_object_deallocate(imgp->object); @@ -1091,7 +1091,7 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv) vm_prot_t stack_prot; u_long ssiz; - imgp->vmspace_destroyed = 1; + imgp->vmspace_destroyed = true; imgp->sysent = sv; if (p->p_sysent->sv_onexec_old != NULL) @@ -1791,7 +1791,7 @@ exec_check_permissions(struct image_params *imgp) */ error = VOP_OPEN(vp, FREAD, td->td_ucred, td, NULL); if (error == 0) - imgp->opened = 1; + imgp->opened = true; return (error); } diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h index ef4de48c3e6d..0e99737a84a7 100644 --- a/sys/sys/imgact.h +++ b/sys/sys/imgact.h @@ -58,21 +58,16 @@ struct image_args { }; struct image_params { - struct proc *proc; /* our process struct */ + struct proc *proc; /* our process */ struct label *execlabel; /* optional exec label */ - struct vnode *vp; /* pointer to vnode of file to exec */ + struct vnode *vp; /* pointer to vnode of file to exec */ struct vm_object *object; /* The vm object for this vp */ - struct vattr *attr; /* attributes of file */ - const char *image_header; /* head of file to exec */ - unsigned long entry_addr; /* entry address of target executable */ - unsigned long reloc_base; /* load address of image */ - char vmspace_destroyed; /* flag - we've blown away original vm space */ -#define IMGACT_SHELL 0x1 -#define IMGACT_BINMISC 0x2 - unsigned char interpreted; /* mask of interpreters that have run */ - char opened; /* flag - we have opened executable vnode */ - char *interpreter_name; /* name of the interpreter */ - void *auxargs; /* ELF Auxinfo structure pointer */ + struct vattr *attr; /* attributes of file */ + const char *image_header; /* header of file to exec */ + unsigned long entry_addr; /* entry address of target executable */ + unsigned long reloc_base; /* load address of image */ + char *interpreter_name; /* name of the interpreter */ + void *auxargs; /* ELF Auxinfo structure pointer */ struct sf_buf *firstpage; /* first page that we mapped */ void *ps_strings; /* pointer to ps_string (user space) */ struct image_args *args; /* system call arguments */ @@ -90,7 +85,12 @@ struct image_params { u_long stack_sz; u_long eff_stack_sz; struct ucred *newcred; /* new credentials if changing */ +#define IMGACT_SHELL 0x1 +#define IMGACT_BINMISC 0x2 + unsigned char interpreted; /* mask of interpreters that have run */ bool credential_setid; /* true if becoming setid */ + bool vmspace_destroyed; /* we've blown away original vm space */ + bool opened; /* we have opened executable vnode */ bool textset; u_int map_flags; }; From nobody Thu Oct 28 17:50:40 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BCC861826CFF; Thu, 28 Oct 2021 17:50:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgClN57H6z4Shb; Thu, 28 Oct 2021 17:50:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 25E4D27BCA; Thu, 28 Oct 2021 17:50:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SHoelc097697; Thu, 28 Oct 2021 17:50:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SHoecR097696; Thu, 28 Oct 2021 17:50:40 GMT (envelope-from git) Date: Thu, 28 Oct 2021 17:50:40 GMT Message-Id: <202110281750.19SHoecR097696@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9a0bee9f6a77 - main - Make vn_fullpath_hardlink() externally callable List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a0bee9f6a77a85e4dfb27c9a33d4e210d05b469 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9a0bee9f6a77a85e4dfb27c9a33d4e210d05b469 commit 9a0bee9f6a77a85e4dfb27c9a33d4e210d05b469 Author: Konstantin Belousov AuthorDate: 2021-10-23 00:23:17 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 17:49:26 +0000 Make vn_fullpath_hardlink() externally callable Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611 --- sys/kern/vfs_cache.c | 28 +++++++++++++--------------- sys/sys/vnode.h | 3 +++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 99f7314822f0..006f16587021 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -579,8 +579,6 @@ DEBUGNODE_ULONG(vnodes_cel_3_failures, cache_lock_vnodes_cel_3_failures, "Number of times 3-way vnode locking failed"); static void cache_zap_locked(struct namecache *ncp); -static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, - char **freebuf, size_t *buflen); static int vn_fullpath_any_smr(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, size_t *buflen, size_t addend); static int vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, @@ -3132,7 +3130,8 @@ kern___realpathat(struct thread *td, int fd, const char *path, char *buf, pathseg, path, fd, &cap_fstat_rights, td); if ((error = namei(&nd)) != 0) return (error); - error = vn_fullpath_hardlink(&nd, &retbuf, &freebuf, &size); + error = vn_fullpath_hardlink(nd.ni_vp, nd.ni_dvp, nd.ni_cnd.cn_nameptr, + nd.ni_cnd.cn_namelen, &retbuf, &freebuf, &size); if (error == 0) { error = copyout(retbuf, buf, size); free(freebuf, M_TEMP); @@ -3593,8 +3592,9 @@ vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, /* * Resolve an arbitrary vnode to a pathname (taking care of hardlinks). * - * Since the namecache does not track hardlinks, the caller is expected to first - * look up the target vnode with SAVENAME | WANTPARENT flags passed to namei. + * Since the namecache does not track hardlinks, the caller is + * expected to first look up the target vnode with SAVENAME | + * WANTPARENT flags passed to namei to get dvp and vp. * * Then we have 2 cases: * - if the found vnode is a directory, the path can be constructed just by @@ -3602,14 +3602,13 @@ vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, * - otherwise we populate the buffer with the saved name and start resolving * from the parent */ -static int -vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, - size_t *buflen) +int +vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp, + const char *hrdl_name, size_t hrdl_name_length, + char **retbuf, char **freebuf, size_t *buflen) { char *buf, *tmpbuf; struct pwd *pwd; - struct componentname *cnp; - struct vnode *vp; size_t addend; int error; enum vtype type; @@ -3622,7 +3621,7 @@ vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, buf = malloc(*buflen, M_TEMP, M_WAITOK); addend = 0; - vp = ndp->ni_vp; + /* * Check for VBAD to work around the vp_crossmp bug in lookup(). * @@ -3648,8 +3647,7 @@ vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, goto out_bad; } if (type != VDIR) { - cnp = &ndp->ni_cnd; - addend = cnp->cn_namelen + 2; + addend = hrdl_name_length + 2; if (*buflen < addend) { error = ENOMEM; goto out_bad; @@ -3657,9 +3655,9 @@ vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, *buflen -= addend; tmpbuf = buf + *buflen; tmpbuf[0] = '/'; - memcpy(&tmpbuf[1], cnp->cn_nameptr, cnp->cn_namelen); + memcpy(&tmpbuf[1], hrdl_name, hrdl_name_length); tmpbuf[addend - 1] = '\0'; - vp = ndp->ni_dvp; + vp = dvp; } vfs_smr_enter(); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index a9b57dd4c25d..18bba17011e8 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -697,6 +697,9 @@ int vn_vptocnp(struct vnode **vp, char *buf, size_t *buflen); int vn_getcwd(char *buf, char **retbuf, size_t *buflen); int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf); int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf); +int vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp, + const char *hdrl_name, size_t hrdl_name_length, char **retbuf, + char **freebuf, size_t *buflen); struct vnode * vn_dir_dd_ino(struct vnode *vp); int vn_commname(struct vnode *vn, char *buf, u_int buflen); From nobody Thu Oct 28 17:50:42 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CD1C71827052; Thu, 28 Oct 2021 17:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgClQ4Dg4z4SmS; Thu, 28 Oct 2021 17:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 627D242; Thu, 28 Oct 2021 17:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SHogdE097752; Thu, 28 Oct 2021 17:50:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SHogaM097751; Thu, 28 Oct 2021 17:50:42 GMT (envelope-from git) Date: Thu, 28 Oct 2021 17:50:42 GMT Message-Id: <202110281750.19SHogaM097751@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 351d5f7fc516 - main - exec: store parent directory and hardlink name of the binary in struct proc List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 351d5f7fc5161ededeaa226ee3f21a438ee4a632 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=351d5f7fc5161ededeaa226ee3f21a438ee4a632 commit 351d5f7fc5161ededeaa226ee3f21a438ee4a632 Author: Konstantin Belousov AuthorDate: 2021-10-23 18:44:22 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 17:49:56 +0000 exec: store parent directory and hardlink name of the binary in struct proc While doing it, also move all the code to resolve pathnames and obtain text vp and dvp, into single place. Besides simplifying the code, it avoids spurious vnode relocks and validates the explanation why a transient text reference on the script vnode is not harmful. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611 --- sys/kern/kern_exec.c | 108 ++++++++++++++++++++++++++++--------------------- sys/kern/kern_exit.c | 10 ++++- sys/kern/kern_fork.c | 12 +++++- sys/kern/kern_thread.c | 6 +-- sys/sys/proc.h | 2 + 5 files changed, 85 insertions(+), 53 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index d61a9d5b0b1c..52119036e95b 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -420,7 +420,9 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, #ifdef KTRACE struct ktr_io_params *kiop; #endif - struct vnode *oldtextvp = NULL, *newtextvp; + struct vnode *oldtextvp, *newtextvp; + struct vnode *oldtextdvp, *newtextdvp; + char *oldbinname, *newbinname; bool credential_changing; #ifdef MAC struct label *interpvplabel = NULL; @@ -436,6 +438,9 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, static const char fexecv_proc_title[] = "(fexecv)"; imgp = &image_params; + oldtextvp = oldtextdvp = NULL; + newtextvp = newtextdvp = NULL; + newbinname = oldbinname = NULL; #ifdef KTRACE kiop = NULL; #endif @@ -471,19 +476,6 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, goto exec_fail; #endif - /* - * Translate the file name. namei() returns a vnode pointer - * in ni_vp among other things. - * - * XXXAUDIT: It would be desirable to also audit the name of the - * interpreter if this is an interpreted binary. - */ - if (args->fname != NULL) { - NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | LOCKSHARED | FOLLOW | - SAVENAME | AUDITVNODE1 | WANTPARENT, - UIO_SYSSPACE, args->fname, td); - } - SDT_PROBE1(proc, , , exec, args->fname); interpret: @@ -500,12 +492,42 @@ interpret: goto exec_fail; } #endif + + /* + * Translate the file name. namei() returns a vnode + * pointer in ni_vp among other things. + */ + NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | LOCKSHARED | FOLLOW | + SAVENAME | AUDITVNODE1 | WANTPARENT, UIO_SYSSPACE, + args->fname, td); + error = namei(&nd); if (error) goto exec_fail; newtextvp = nd.ni_vp; + newtextdvp = nd.ni_dvp; + nd.ni_dvp = NULL; + newbinname = malloc(nd.ni_cnd.cn_namelen + 1, M_PARGS, + M_WAITOK); + memcpy(newbinname, nd.ni_cnd.cn_nameptr, nd.ni_cnd.cn_namelen); + newbinname[nd.ni_cnd.cn_namelen] = '\0'; imgp->vp = newtextvp; + + /* + * Do the best to calculate the full path to the image file. + */ + if (args->fname[0] == '/') { + imgp->execpath = args->fname; + } else { + VOP_UNLOCK(imgp->vp); + freepath_size = MAXPATHLEN; + if (vn_fullpath_hardlink(newtextvp, newtextdvp, + newbinname, nd.ni_cnd.cn_namelen, &imgp->execpath, + &imgp->freepath, &freepath_size) != 0) + imgp->execpath = args->fname; + vn_lock(imgp->vp, LK_SHARED | LK_RETRY); + } } else { AUDIT_ARG_FD(args->fd); /* @@ -515,6 +537,9 @@ interpret: &newtextvp); if (error) goto exec_fail; + if (vn_fullpath(imgp->vp, &imgp->execpath, + &imgp->freepath) != 0) + imgp->execpath = args->fname; vn_lock(newtextvp, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(newtextvp); imgp->vp = newtextvp; @@ -624,28 +649,6 @@ interpret: } /* The new credentials are installed into the process later. */ - /* - * Do the best to calculate the full path to the image file. - */ - if (args->fname != NULL) { - if (args->fname[0] == '/') { - imgp->execpath = args->fname; - } else { - VOP_UNLOCK(imgp->vp); - freepath_size = MAXPATHLEN; - if (vn_fullpath_hardlink(&nd, &imgp->execpath, - &imgp->freepath, &freepath_size) != 0) - imgp->execpath = args->fname; - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - } - } else { - VOP_UNLOCK(imgp->vp); - if (vn_fullpath(imgp->vp, &imgp->execpath, - &imgp->freepath) != 0) - imgp->execpath = args->fname; - vn_lock(imgp->vp, LK_SHARED | LK_RETRY); - } - /* * If the current process has a special image activator it * wants to try first, call it. For example, emulating shell @@ -699,10 +702,15 @@ interpret: imgp->opened = false; } vput(newtextvp); + imgp->vp = newtextvp = NULL; if (args->fname != NULL) { - if (nd.ni_dvp != NULL) - vrele(nd.ni_dvp); + if (newtextdvp != NULL) { + vrele(newtextdvp); + newtextdvp = NULL; + } NDFREE(&nd, NDF_ONLY_PNBUF); + free(newbinname, M_PARGS); + newbinname = NULL; } vm_object_deallocate(imgp->object); imgp->object = NULL; @@ -712,9 +720,6 @@ interpret: imgp->freepath = NULL; /* set new name to that of the interpreter */ args->fname = imgp->interpreter_name; - NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | LOCKSHARED | FOLLOW | - SAVENAME | WANTPARENT, - UIO_SYSSPACE, imgp->interpreter_name, td); goto interpret; } @@ -875,11 +880,17 @@ interpret: } /* - * Store the vp for use in procfs. This vnode was referenced by namei - * or fgetvp_exec. + * Store the vp for use in kern.proc.pathname. This vnode was + * referenced by namei() or fgetvp_exec(). */ oldtextvp = p->p_textvp; p->p_textvp = newtextvp; + oldtextdvp = p->p_textdvp; + p->p_textdvp = newtextdvp; + newtextdvp = NULL; + oldbinname = p->p_binname; + p->p_binname = newbinname; + newbinname = NULL; #ifdef KDTRACE_HOOKS /* @@ -953,11 +964,11 @@ exec_fail_dealloc: vput(imgp->vp); else VOP_UNLOCK(imgp->vp); - if (args->fname != NULL) { - if (nd.ni_dvp != NULL) - vrele(nd.ni_dvp); + if (args->fname != NULL) NDFREE(&nd, NDF_ONLY_PNBUF); - } + if (newtextdvp != NULL) + vrele(newtextdvp); + free(newbinname, M_PARGS); } if (imgp->object != NULL) @@ -996,6 +1007,9 @@ exec_fail: */ if (oldtextvp != NULL) vrele(oldtextvp); + if (oldtextdvp != NULL) + vrele(oldtextdvp); + free(oldbinname, M_PARGS); #ifdef KTRACE ktr_io_params_free(kiop); #endif diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 79f1d5bd63e5..44203435fa68 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -424,12 +424,20 @@ exit1(struct thread *td, int rval, int signo) ktrprocexit(td); #endif /* - * Release reference to text vnode + * Release reference to text vnode etc */ if (p->p_textvp != NULL) { vrele(p->p_textvp); p->p_textvp = NULL; } + if (p->p_textdvp != NULL) { + vrele(p->p_textdvp); + p->p_textdvp = NULL; + } + if (p->p_binname != NULL) { + free(p->p_binname, M_PARGS); + p->p_binname = NULL; + } /* * Release our limits structure. diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index e8c34a31e6a1..5b518a0183d8 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -528,6 +528,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * } p2->p_textvp = p1->p_textvp; + p2->p_textdvp = p1->p_textdvp; p2->p_fd = fd; p2->p_fdtol = fdtol; p2->p_pd = pd; @@ -549,9 +550,16 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * PROC_UNLOCK(p1); PROC_UNLOCK(p2); - /* Bump references to the text vnode (for procfs). */ - if (p2->p_textvp) + /* + * Bump references to the text vnode and directory, and copy + * the hardlink name. + */ + if (p2->p_textvp != NULL) vrefact(p2->p_textvp); + if (p2->p_textdvp != NULL) + vrefact(p2->p_textdvp); + p2->p_binname = p1->p_binname == NULL ? NULL : + strdup(p1->p_binname, M_PARGS); /* * Set up linkage for kernel based threading. diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 65c5cc65c87e..71e3c501dddf 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -97,11 +97,11 @@ _Static_assert(offsetof(struct proc, p_flag) == 0xb8, "struct proc KBI p_flag"); _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) == 0x3c8, "struct proc KBI p_filemon"); -_Static_assert(offsetof(struct proc, p_comm) == 0x3d0, +_Static_assert(offsetof(struct proc, p_comm) == 0x3e0, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x4c8, "struct proc KBI p_emuldata"); #endif #ifdef __i386__ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index e83f98646451..177efd5257af 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -666,6 +666,8 @@ struct proc { int p_traceflag; /* (o) Kernel trace points. */ struct ktr_io_params *p_ktrioparms; /* (c + o) Params for ktrace. */ struct vnode *p_textvp; /* (b) Vnode of executable. */ + struct vnode *p_textdvp; /* (b) Dir containing textvp. */ + char *p_binname; /* (b) Binary hardlink name. */ u_int p_lock; /* (c) Proclock (prevent swap) count. */ struct sigiolst p_sigiolst; /* (c) List of sigio sources. */ int p_sigparent; /* (c) Signal to parent on exit. */ From nobody Thu Oct 28 17:50:41 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 524101827047; Thu, 28 Oct 2021 17:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgClP5Tpqz4SSp; Thu, 28 Oct 2021 17:50:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3EF4F88; Thu, 28 Oct 2021 17:50:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SHofdT097721; Thu, 28 Oct 2021 17:50:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SHofm3097720; Thu, 28 Oct 2021 17:50:41 GMT (envelope-from git) Date: Thu, 28 Oct 2021 17:50:41 GMT Message-Id: <202110281750.19SHofm3097720@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0c10648fbb75 - main - exec: provide right hardlink name in AT_EXECPATH List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0c10648fbb758bb76fd29330b7fe1bc519252325 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0c10648fbb758bb76fd29330b7fe1bc519252325 commit 0c10648fbb758bb76fd29330b7fe1bc519252325 Author: Konstantin Belousov AuthorDate: 2021-10-23 00:24:08 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 17:49:31 +0000 exec: provide right hardlink name in AT_EXECPATH For this, use vn_fullpath_hardlink() to resolve executable name for execve(2). This should provide the right hardlink name, used for execution, instead of random hardlink pointing to this binary. Also this should make the AT_EXECNAME reliable for execve(2), since kernel only needs to resolve parent directory path, which should always succeed (except pathological cases like unlinking a directory). PR: 248184 Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611 --- sys/kern/kern_exec.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 5cc5a1205901..d61a9d5b0b1c 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -432,6 +432,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, int error, i, orig_osrel; uint32_t orig_fctl0; Elf_Brandinfo *orig_brandinfo; + size_t freepath_size; static const char fexecv_proc_title[] = "(fexecv)"; imgp = &image_params; @@ -479,7 +480,8 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, */ if (args->fname != NULL) { NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | LOCKSHARED | FOLLOW | - SAVENAME | AUDITVNODE1, UIO_SYSSPACE, args->fname, td); + SAVENAME | AUDITVNODE1 | WANTPARENT, + UIO_SYSSPACE, args->fname, td); } SDT_PROBE1(proc, , , exec, args->fname); @@ -625,9 +627,18 @@ interpret: /* * Do the best to calculate the full path to the image file. */ - if (args->fname != NULL && args->fname[0] == '/') - imgp->execpath = args->fname; - else { + if (args->fname != NULL) { + if (args->fname[0] == '/') { + imgp->execpath = args->fname; + } else { + VOP_UNLOCK(imgp->vp); + freepath_size = MAXPATHLEN; + if (vn_fullpath_hardlink(&nd, &imgp->execpath, + &imgp->freepath, &freepath_size) != 0) + imgp->execpath = args->fname; + vn_lock(imgp->vp, LK_SHARED | LK_RETRY); + } + } else { VOP_UNLOCK(imgp->vp); if (vn_fullpath(imgp->vp, &imgp->execpath, &imgp->freepath) != 0) @@ -680,8 +691,6 @@ interpret: VOP_UNSET_TEXT_CHECKED(newtextvp); imgp->textset = false; /* free name buffer and old vnode */ - if (args->fname != NULL) - NDFREE(&nd, NDF_ONLY_PNBUF); #ifdef MAC mac_execve_interpreter_enter(newtextvp, &interpvplabel); #endif @@ -690,6 +699,11 @@ interpret: imgp->opened = false; } vput(newtextvp); + if (args->fname != NULL) { + if (nd.ni_dvp != NULL) + vrele(nd.ni_dvp); + NDFREE(&nd, NDF_ONLY_PNBUF); + } vm_object_deallocate(imgp->object); imgp->object = NULL; execve_nosetid(imgp); @@ -697,9 +711,10 @@ interpret: free(imgp->freepath, M_TEMP); imgp->freepath = NULL; /* set new name to that of the interpreter */ - NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | LOCKSHARED | FOLLOW | - SAVENAME, UIO_SYSSPACE, imgp->interpreter_name, td); args->fname = imgp->interpreter_name; + NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | LOCKSHARED | FOLLOW | + SAVENAME | WANTPARENT, + UIO_SYSSPACE, imgp->interpreter_name, td); goto interpret; } @@ -930,8 +945,6 @@ exec_fail_dealloc: exec_unmap_first_page(imgp); if (imgp->vp != NULL) { - if (args->fname) - NDFREE(&nd, NDF_ONLY_PNBUF); if (imgp->opened) VOP_CLOSE(imgp->vp, FREAD, td->td_ucred, td); if (imgp->textset) @@ -940,6 +953,11 @@ exec_fail_dealloc: vput(imgp->vp); else VOP_UNLOCK(imgp->vp); + if (args->fname != NULL) { + if (nd.ni_dvp != NULL) + vrele(nd.ni_dvp); + NDFREE(&nd, NDF_ONLY_PNBUF); + } } if (imgp->object != NULL) From nobody Thu Oct 28 17:50:43 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EADB5182719C; Thu, 28 Oct 2021 17:50:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgClS2VLBz4Svd; Thu, 28 Oct 2021 17:50:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E8EC27C67; Thu, 28 Oct 2021 17:50:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SHohkE097777; Thu, 28 Oct 2021 17:50:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SHohAD097776; Thu, 28 Oct 2021 17:50:43 GMT (envelope-from git) Date: Thu, 28 Oct 2021 17:50:43 GMT Message-Id: <202110281750.19SHohAD097776@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ee92c8a842d6 - main - sysctl kern.proc.procname: report right hardlink name List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ee92c8a842d61ffda8d111e1b0e398085c5bfb3a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ee92c8a842d61ffda8d111e1b0e398085c5bfb3a commit ee92c8a842d61ffda8d111e1b0e398085c5bfb3a Author: Konstantin Belousov AuthorDate: 2021-10-23 19:01:37 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 17:50:02 +0000 sysctl kern.proc.procname: report right hardlink name PR: 248184 Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32611 --- sys/kern/kern_proc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2649d1d3a58f..c4c01da1faea 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2233,32 +2235,74 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS) pid_t *pidp = (pid_t *)arg1; unsigned int arglen = arg2; struct proc *p; - struct vnode *vp; - char *retbuf, *freebuf; + struct vnode *vp, *dvp; + char *retbuf, *freebuf, *binname; + struct nameidata nd; + size_t freepath_size; int error; + bool do_fullpath; if (arglen != 1) return (EINVAL); + binname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); + binname[0] = '\0'; if (*pidp == -1) { /* -1 means this process */ p = req->td->td_proc; } else { error = pget(*pidp, PGET_CANSEE, &p); - if (error != 0) + if (error != 0) { + free(binname, M_TEMP); return (error); + } } vp = p->p_textvp; if (vp == NULL) { if (*pidp != -1) PROC_UNLOCK(p); + free(binname, M_TEMP); return (0); } vref(vp); + dvp = p->p_textdvp; + if (dvp != NULL) + vref(dvp); + if (p->p_binname != NULL) + strlcpy(binname, p->p_binname, MAXPATHLEN); if (*pidp != -1) PROC_UNLOCK(p); - error = vn_fullpath(vp, &retbuf, &freebuf); + do_fullpath = true; + freebuf = NULL; + if (dvp != NULL && binname[0] != '\0') { + freepath_size = MAXPATHLEN; + if (vn_fullpath_hardlink(vp, dvp, binname, strlen(binname), + &retbuf, &freebuf, &freepath_size) == 0) { + /* + * Recheck the looked up path. The binary + * might have been renamed or replaced, in + * which case we should not report old name. + */ + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, retbuf, + req->td); + error = namei(&nd); + if (error == 0) { + if (nd.ni_vp == vp) + do_fullpath = false; + vrele(nd.ni_vp); + NDFREE(&nd, NDF_ONLY_PNBUF); + } + } + } + if (do_fullpath) { + free(freebuf, M_TEMP); + freebuf = NULL; + error = vn_fullpath(vp, &retbuf, &freebuf); + } vrele(vp); - if (error) + if (dvp != NULL) + vrele(dvp); + free(binname, M_TEMP); + if (error != 0) return (error); error = SYSCTL_OUT(req, retbuf, strlen(retbuf) + 1); free(freebuf, M_TEMP); From nobody Thu Oct 28 18:20:51 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 61B871834E8B; Thu, 28 Oct 2021 18:20:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgDQC1x0Kz4gkT; Thu, 28 Oct 2021 18:20:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2325F4FD; Thu, 28 Oct 2021 18:20:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SIKpow040837; Thu, 28 Oct 2021 18:20:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SIKpYD040836; Thu, 28 Oct 2021 18:20:51 GMT (envelope-from git) Date: Thu, 28 Oct 2021 18:20:51 GMT Message-Id: <202110281820.19SIKpYD040836@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Guangyuan Yang Subject: git: 191c624d9519 - main - config(5): Update upper limit for maxusers on 64-bit systems List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 191c624d9519a2767801de390b192ee7a96b41cd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ygy (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=191c624d9519a2767801de390b192ee7a96b41cd commit 191c624d9519a2767801de390b192ee7a96b41cd Author: Felix Johnson AuthorDate: 2021-10-28 18:15:08 +0000 Commit: Guangyuan Yang CommitDate: 2021-10-28 18:15:08 +0000 config(5): Update upper limit for maxusers on 64-bit systems The limit of 384 maxusers for auto configuration was only imposed on 32-bit systems. Document that maxusers scales above 384 based on memory for 64-bit systems. PR: 204938 MFC after: 3 days Reported by: David Höppner <0xffea@gmail.com> --- usr.sbin/config/config.5 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/config/config.5 b/usr.sbin/config/config.5 index 433194f3b22b..134e321831d8 100644 --- a/usr.sbin/config/config.5 +++ b/usr.sbin/config/config.5 @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 9, 2020 +.Dd October 28, 2021 .Dt CONFIG 5 .Os .Sh NAME @@ -329,7 +329,9 @@ A value of 0 indicates that the kernel should configure its data structures according to the size of available physical memory. If auto configuration is requested, the kernel will set -this tunable to a value between 32 and 384. +this tunable to a value between 32 and 384 for 32-bit systems, +or scale the value higher based on available memory for 64-bit +systems. .Pp As explained in .Xr tuning 7 , From nobody Thu Oct 28 19:00:46 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5850718258EC; Thu, 28 Oct 2021 19:00:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgFJG21vVz4rWw; Thu, 28 Oct 2021 19:00:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 256D9FF0; Thu, 28 Oct 2021 19:00:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SJ0kJp091815; Thu, 28 Oct 2021 19:00:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SJ0kwX091814; Thu, 28 Oct 2021 19:00:46 GMT (envelope-from git) Date: Thu, 28 Oct 2021 19:00:46 GMT Message-Id: <202110281900.19SJ0kwX091814@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 4d675b80f00f - main - i386: fix struct proc layout asserts after 351d5f7fc5161ede List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4d675b80f00ffd85cce8e65dcd9ef787bb8a8019 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4d675b80f00ffd85cce8e65dcd9ef787bb8a8019 commit 4d675b80f00ffd85cce8e65dcd9ef787bb8a8019 Author: Konstantin Belousov AuthorDate: 2021-10-28 18:31:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 18:56:21 +0000 i386: fix struct proc layout asserts after 351d5f7fc5161ede Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/kern_thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 71e3c501dddf..7b0ff604b086 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -117,11 +117,11 @@ _Static_assert(offsetof(struct proc, p_flag) == 0x6c, "struct proc KBI p_flag"); _Static_assert(offsetof(struct proc, p_pid) == 0x78, "struct proc KBI p_pid"); -_Static_assert(offsetof(struct proc, p_filemon) == 0x268, +_Static_assert(offsetof(struct proc, p_filemon) == 0x270, "struct proc KBI p_filemon"); -_Static_assert(offsetof(struct proc, p_comm) == 0x27c, +_Static_assert(offsetof(struct proc, p_comm) == 0x284, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x308, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x310, "struct proc KBI p_emuldata"); #endif From nobody Thu Oct 28 19:02:10 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 873451825EE6; Thu, 28 Oct 2021 19:02:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgFKt3Sm8z4sCc; Thu, 28 Oct 2021 19:02:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 57AA19F9; Thu, 28 Oct 2021 19:02:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SJ2AQ6095321; Thu, 28 Oct 2021 19:02:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SJ2A0f095320; Thu, 28 Oct 2021 19:02:10 GMT (envelope-from git) Date: Thu, 28 Oct 2021 19:02:10 GMT Message-Id: <202110281902.19SJ2A0f095320@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: e93b5adb6bb8 - main - amd64 pmap: account for the top-level pages List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e93b5adb6bb83d487eaa4211ac26e116db748c63 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e93b5adb6bb83d487eaa4211ac26e116db748c63 commit e93b5adb6bb83d487eaa4211ac26e116db748c63 Author: Konstantin Belousov AuthorDate: 2021-10-20 01:03:43 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 19:01:58 +0000 amd64 pmap: account for the top-level pages both for kernel and user page tables, the later exist in the PTI case. Reviewed by: markj Tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32569 --- sys/amd64/amd64/pmap.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 66d7ac6669da..1c4e8b3354fc 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -1495,6 +1495,15 @@ pmap_resident_count_adj(pmap_t pmap, int count) pmap->pm_stats.resident_count += count; } +static __inline void +pmap_pt_page_count_pinit(pmap_t pmap, int count) +{ + KASSERT(pmap->pm_stats.resident_count + count >= 0, + ("pmap %p resident count underflow %ld %d", pmap, + pmap->pm_stats.resident_count, count)); + pmap->pm_stats.resident_count += count; +} + static __inline void pmap_pt_page_count_adj(pmap_t pmap, int count) { @@ -4344,13 +4353,24 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags) vm_paddr_t pmltop_phys; int i; + bzero(&pmap->pm_stats, sizeof pmap->pm_stats); + /* - * Allocate the page directory page. Pass NULL instead of a pointer to - * the pmap here to avoid recording this page in the resident count, as - * optimizations in pmap_remove() depend on this. + * Allocate the page directory page. Pass NULL instead of a + * pointer to the pmap here to avoid calling + * pmap_resident_count_adj() through pmap_pt_page_count_adj(), + * since that requires pmap lock. Instead do the accounting + * manually. + * + * Note that final call to pmap_remove() optimization that + * checks for zero resident_count is basically disabled by + * accounting for top-level page. But the optimization was + * not effective since we started using non-managed mapping of + * the shared page. */ pmltop_pg = pmap_alloc_pt_page(NULL, 0, VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_WAITOK); + pmap_pt_page_count_pinit(pmap, 1); pmltop_phys = VM_PAGE_TO_PHYS(pmltop_pg); pmap->pm_pmltop = (pml5_entry_t *)PHYS_TO_DMAP(pmltop_phys); @@ -4380,11 +4400,13 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags) pmap_pinit_pml4(pmltop_pg); if ((curproc->p_md.md_flags & P_MD_KPTI) != 0) { /* - * As with pmltop_pg, pass NULL instead of a pointer to - * the pmap to ensure that the PTI page isn't counted. + * As with pmltop_pg, pass NULL instead of a + * pointer to the pmap to ensure that the PTI + * page counted explicitly. */ pmltop_pgu = pmap_alloc_pt_page(NULL, 0, VM_ALLOC_WIRED | VM_ALLOC_WAITOK); + pmap_pt_page_count_pinit(pmap, 1); pmap->pm_pmltopu = (pml4_entry_t *)PHYS_TO_DMAP( VM_PAGE_TO_PHYS(pmltop_pgu)); if (pmap_is_la57(pmap)) @@ -4407,7 +4429,6 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags) vm_radix_init(&pmap->pm_root); CPU_ZERO(&pmap->pm_active); TAILQ_INIT(&pmap->pm_pvchunk); - bzero(&pmap->pm_stats, sizeof pmap->pm_stats); pmap->pm_flags = flags; pmap->pm_eptgen = 0; @@ -4799,9 +4820,6 @@ pmap_release(pmap_t pmap) vm_page_t m; int i; - KASSERT(pmap->pm_stats.resident_count == 0, - ("pmap_release: pmap %p resident count %ld != 0", - pmap, pmap->pm_stats.resident_count)); KASSERT(vm_radix_is_empty(&pmap->pm_root), ("pmap_release: pmap %p has reserved page table page(s)", pmap)); @@ -4834,15 +4852,21 @@ pmap_release(pmap_t pmap) } pmap_free_pt_page(NULL, m, true); + pmap_pt_page_count_pinit(pmap, -1); if (pmap->pm_pmltopu != NULL) { m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pmap-> pm_pmltopu)); pmap_free_pt_page(NULL, m, false); + pmap_pt_page_count_pinit(pmap, -1); } if (pmap->pm_type == PT_X86 && (cpu_stdext_feature2 & CPUID_STDEXT2_PKU) != 0) rangeset_fini(&pmap->pm_pkru); + + KASSERT(pmap->pm_stats.resident_count == 0, + ("pmap_release: pmap %p resident count %ld != 0", + pmap, pmap->pm_stats.resident_count)); } static int From nobody Thu Oct 28 19:02:11 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 082671826240; Thu, 28 Oct 2021 19:02:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgFKv5j0yz4sCk; Thu, 28 Oct 2021 19:02:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8DD641016; Thu, 28 Oct 2021 19:02:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SJ2BKP095345; Thu, 28 Oct 2021 19:02:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SJ2BRQ095344; Thu, 28 Oct 2021 19:02:11 GMT (envelope-from git) Date: Thu, 28 Oct 2021 19:02:11 GMT Message-Id: <202110281902.19SJ2BRQ095344@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0b3bc7288984 - main - amd64 pmap: adjust the empty pmap optimization in pmap_remove() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0b3bc7288984c17da00d9f8c29f116d56bf44d35 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0b3bc7288984c17da00d9f8c29f116d56bf44d35 commit 0b3bc7288984c17da00d9f8c29f116d56bf44d35 Author: Konstantin Belousov AuthorDate: 2021-10-20 20:30:34 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 19:01:58 +0000 amd64 pmap: adjust the empty pmap optimization in pmap_remove() to match the added accounting of the top-level page table pages. Reviewed by: markj Tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32569 --- sys/amd64/amd64/pmap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 1c4e8b3354fc..8526cc3031d2 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -6278,9 +6278,14 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) PG_V = pmap_valid_bit(pmap); /* + * If there are no resident pages besides the top level page + * table page(s), there is nothing to do. Kernel pmap always + * accounts whole preloaded area as resident, which makes its + * resident count > 2. * Perform an unsynchronized read. This is, however, safe. */ - if (pmap->pm_stats.resident_count == 0) + if (pmap->pm_stats.resident_count <= 1 + (pmap->pm_pmltopu != NULL ? + 1 : 0)) return; anyvalid = 0; From nobody Thu Oct 28 19:02:12 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1B1E31825FFA; Thu, 28 Oct 2021 19:02:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgFKw5dGWz4s9Q; Thu, 28 Oct 2021 19:02:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9F3851129; Thu, 28 Oct 2021 19:02:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SJ2CxT095371; Thu, 28 Oct 2021 19:02:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SJ2CGx095370; Thu, 28 Oct 2021 19:02:12 GMT (envelope-from git) Date: Thu, 28 Oct 2021 19:02:12 GMT Message-Id: <202110281902.19SJ2CGx095370@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 1c69690319c5 - main - Unmap shared page manually before doing vm_map_remove() on exit or exec List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1c69690319c5bb7deae6ce1add6ea25bb40b3b91 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1c69690319c5bb7deae6ce1add6ea25bb40b3b91 commit 1c69690319c5bb7deae6ce1add6ea25bb40b3b91 Author: Konstantin Belousov AuthorDate: 2021-10-20 20:32:59 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 19:01:59 +0000 Unmap shared page manually before doing vm_map_remove() on exit or exec This allows the pmap_remove(min, max) call to see empty pmap and exploit empty pmap optimization. Reviewed by: markj Tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32569 --- sys/kern/kern_exec.c | 25 +++++++++++++++++++++++++ sys/kern/kern_exit.c | 1 + sys/sys/sysent.h | 1 + 3 files changed, 27 insertions(+) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 52119036e95b..780b917ad21d 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1104,6 +1104,30 @@ exec_onexec_old(struct thread *td) umtx_exec(td->td_proc); } +/* + * This is an optimization which removes the unmanaged shared page + * mapping. In combination with pmap_remove_pages(), which cleans all + * managed mappings in the process' vmspace pmap, no work will be left + * for pmap_remove(min, max). + */ +void +exec_free_abi_mappings(struct proc *p) +{ + struct vmspace *vmspace; + struct sysentvec *sv; + + vmspace = p->p_vmspace; + if (refcount_load(&vmspace->vm_refcnt) != 1) + return; + + sv = p->p_sysent; + if (sv->sv_shared_page_obj == NULL) + return; + + pmap_remove(vmspace_pmap(vmspace), sv->sv_shared_page_base, + sv->sv_shared_page_base + sv->sv_shared_page_len); +} + /* * Destroy old address space, and allocate a new stack. * The new stack is only sgrowsiz large because it is grown @@ -1146,6 +1170,7 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv) vm_map_min(map) == sv_minuser && vm_map_max(map) == sv->sv_maxuser && cpu_exec_vmspace_reuse(p, map)) { + exec_free_abi_mappings(p); shmexit(vmspace); pmap_remove_pages(vmspace_pmap(vmspace)); vm_map_remove(map, vm_map_min(map), vm_map_max(map)); diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 44203435fa68..14be2425511d 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -417,6 +417,7 @@ exit1(struct thread *td, int rval, int signo) mtx_unlock(&ppeers_lock); } + exec_free_abi_mappings(p); vmspace_exit(td); (void)acct_process(td); diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index ea96c87a79af..fc678d49750a 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -324,6 +324,7 @@ void exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2); void exec_inittk(void); void exit_onexit(struct proc *p); +void exec_free_abi_mappings(struct proc *p); void exec_onexec_old(struct thread *td); #define INIT_SYSENTVEC(name, sv) \ From nobody Thu Oct 28 21:06:23 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6C6B2183A9E8; Thu, 28 Oct 2021 21:06:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgJ5D18TCz4WGy; Thu, 28 Oct 2021 21:06:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EE57529B3; Thu, 28 Oct 2021 21:06:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SL6NRW056451; Thu, 28 Oct 2021 21:06:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SL6Nrx056450; Thu, 28 Oct 2021 21:06:23 GMT (envelope-from git) Date: Thu, 28 Oct 2021 21:06:23 GMT Message-Id: <202110282106.19SL6Nrx056450@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: a901f2af587f - main - libradius: fix WITHOUT_OPENSSL build List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a901f2af587f9cb068e2fca6b62f324bdde471d8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=a901f2af587f9cb068e2fca6b62f324bdde471d8 commit a901f2af587f9cb068e2fca6b62f324bdde471d8 Author: Ed Maste AuthorDate: 2021-10-28 20:27:10 +0000 Commit: Ed Maste CommitDate: 2021-10-28 21:05:53 +0000 libradius: fix WITHOUT_OPENSSL build int alen is used only with SSL. Reported by: Michael Dexter, Build Option Survey MFC after: 3 days Fixes: 8d5c7813061d ("libradius: Fix input validation bugs") Sponsored by: The FreeBSD Foundation --- lib/libradius/radlib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c index ce0c0ccf453a..dd65eda285cb 100644 --- a/lib/libradius/radlib.c +++ b/lib/libradius/radlib.c @@ -286,8 +286,9 @@ is_valid_request(struct rad_handle *h) MD5_CTX ctx; unsigned char md5[MD5_DIGEST_LENGTH]; const struct rad_server *srvp; - int alen, len; + int len; #ifdef WITH_SSL + int alen; HMAC_CTX *hctx; u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE]; u_int md_len; From nobody Thu Oct 28 21:31:30 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B80C9181B19C; Thu, 28 Oct 2021 21:31:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgJfB4vz4z4clg; Thu, 28 Oct 2021 21:31:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 887892F2B; Thu, 28 Oct 2021 21:31:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SLVUgP093028; Thu, 28 Oct 2021 21:31:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SLVUe8093027; Thu, 28 Oct 2021 21:31:30 GMT (envelope-from git) Date: Thu, 28 Oct 2021 21:31:30 GMT Message-Id: <202110282131.19SLVUe8093027@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ae750fbac723 - main - kern_tc.c: Scaling/large delta recalculation List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae750fbac72387c05c8e13623c2465b20497b4be Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ae750fbac72387c05c8e13623c2465b20497b4be commit ae750fbac72387c05c8e13623c2465b20497b4be Author: Sebastian Huber AuthorDate: 2021-10-28 08:22:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-28 21:31:14 +0000 kern_tc.c: Scaling/large delta recalculation This change is a slight performance optimization for systems with a slow 64-bit division. The th->th_scale and th->th_large_delta values only depend on the timecounter frequency and the th->th_adjustment. The timecounter frequency of a timehand only changes when a new timecounter is activated for the timehand. The th->th_adjustment is only changed by the NTP second update. The NTP second update is not done for every call of tc_windup(). Move the code block to recalculate the scaling factor and the large delta of a timehand to the new helper function recalculate_scaling_factor_and_large_delta(). Call recalculate_scaling_factor_and_large_delta() when a new timecounter is activated and a NTP second update occurred. MFC after: 1 week --- sys/kern/kern_tc.c | 88 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 38 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 9a928ca37aff..f7bd116dabe2 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1310,6 +1310,40 @@ tc_setclock(struct timespec *ts) } } +/* + * Recalculate the scaling factor. We want the number of 1/2^64 + * fractions of a second per period of the hardware counter, taking + * into account the th_adjustment factor which the NTP PLL/adjtime(2) + * processing provides us with. + * + * The th_adjustment is nanoseconds per second with 32 bit binary + * fraction and we want 64 bit binary fraction of second: + * + * x = a * 2^32 / 10^9 = a * 4.294967296 + * + * The range of th_adjustment is +/- 5000PPM so inside a 64bit int + * we can only multiply by about 850 without overflowing, that + * leaves no suitably precise fractions for multiply before divide. + * + * Divide before multiply with a fraction of 2199/512 results in a + * systematic undercompensation of 10PPM of th_adjustment. On a + * 5000PPM adjustment this is a 0.05PPM error. This is acceptable. + * + * We happily sacrifice the lowest of the 64 bits of our result + * to the goddess of code clarity. + */ +static void +recalculate_scaling_factor_and_large_delta(struct timehands *th) +{ + uint64_t scale; + + scale = (uint64_t)1 << 63; + scale += (th->th_adjustment / 1024) * 2199; + scale /= th->th_counter->tc_frequency; + th->th_scale = scale * 2; + th->th_large_delta = MIN(((uint64_t)1 << 63) / scale, UINT_MAX); +} + /* * Initialize the next struct timehands in the ring and make * it the active timehands. Along the way we might switch to a different @@ -1320,7 +1354,6 @@ tc_windup(struct bintime *new_boottimebin) { struct bintime bt; struct timehands *th, *tho; - uint64_t scale; u_int delta, ncount, ogen; int i; time_t t; @@ -1382,7 +1415,7 @@ tc_windup(struct bintime *new_boottimebin) tho->th_counter->tc_poll_pps(tho->th_counter); /* - * Deal with NTP second processing. The for loop normally + * Deal with NTP second processing. The loop normally * iterates at most once, but in extreme situations it might * keep NTP sane if timeouts are not run for several seconds. * At boot, the time step can be large when the TOD hardware @@ -1393,14 +1426,21 @@ tc_windup(struct bintime *new_boottimebin) bt = th->th_offset; bintime_add(&bt, &th->th_boottime); i = bt.sec - tho->th_microtime.tv_sec; - if (i > LARGE_STEP) - i = 2; - for (; i > 0; i--) { - t = bt.sec; - ntp_update_second(&th->th_adjustment, &bt.sec); - if (bt.sec != t) - th->th_boottime.sec += bt.sec - t; + if (i > 0) { + if (i > LARGE_STEP) + i = 2; + + do { + t = bt.sec; + ntp_update_second(&th->th_adjustment, &bt.sec); + if (bt.sec != t) + th->th_boottime.sec += bt.sec - t; + --i; + } while (i > 0); + + recalculate_scaling_factor_and_large_delta(th); } + /* Update the UTC timestamps used by the get*() functions. */ th->th_bintime = bt; bintime2timeval(&bt, &th->th_microtime); @@ -1418,40 +1458,12 @@ tc_windup(struct bintime *new_boottimebin) th->th_offset_count = ncount; tc_min_ticktock_freq = max(1, timecounter->tc_frequency / (((uint64_t)timecounter->tc_counter_mask + 1) / 3)); + recalculate_scaling_factor_and_large_delta(th); #ifdef FFCLOCK ffclock_change_tc(th); #endif } - /*- - * Recalculate the scaling factor. We want the number of 1/2^64 - * fractions of a second per period of the hardware counter, taking - * into account the th_adjustment factor which the NTP PLL/adjtime(2) - * processing provides us with. - * - * The th_adjustment is nanoseconds per second with 32 bit binary - * fraction and we want 64 bit binary fraction of second: - * - * x = a * 2^32 / 10^9 = a * 4.294967296 - * - * The range of th_adjustment is +/- 5000PPM so inside a 64bit int - * we can only multiply by about 850 without overflowing, that - * leaves no suitably precise fractions for multiply before divide. - * - * Divide before multiply with a fraction of 2199/512 results in a - * systematic undercompensation of 10PPM of th_adjustment. On a - * 5000PPM adjustment this is a 0.05PPM error. This is acceptable. - * - * We happily sacrifice the lowest of the 64 bits of our result - * to the goddess of code clarity. - * - */ - scale = (uint64_t)1 << 63; - scale += (th->th_adjustment / 1024) * 2199; - scale /= th->th_counter->tc_frequency; - th->th_scale = scale * 2; - th->th_large_delta = MIN(((uint64_t)1 << 63) / scale, UINT_MAX); - /* * Now that the struct timehands is again consistent, set the new * generation number, making sure to not make it zero. From nobody Thu Oct 28 22:35:50 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 761D318368E5; Thu, 28 Oct 2021 22:35:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgL4Q2vk3z3Bwj; Thu, 28 Oct 2021 22:35:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 440B93C7B; Thu, 28 Oct 2021 22:35:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SMZomJ076018; Thu, 28 Oct 2021 22:35:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SMZoAL076017; Thu, 28 Oct 2021 22:35:50 GMT (envelope-from git) Date: Thu, 28 Oct 2021 22:35:50 GMT Message-Id: <202110282235.19SMZoAL076017@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 92b3e07229ba - main - Enable net.inet.tcp.nolocaltimewait. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 92b3e07229baab17cbe258ff1081e66bb7913b31 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=92b3e07229baab17cbe258ff1081e66bb7913b31 commit 92b3e07229baab17cbe258ff1081e66bb7913b31 Author: Gleb Smirnoff AuthorDate: 2021-10-28 22:34:00 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-28 22:34:00 +0000 Enable net.inet.tcp.nolocaltimewait. This feature has been used for many years at large sites and didn't show any pitfalls. --- sys/netinet/tcp_timewait.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 5d4de222b802..9d397d62424f 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -176,10 +176,10 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, maxtcptw, &maxtcptw, 0, sysctl_maxtcptw, "IU", "Maximum number of compressed TCP TIME_WAIT entries"); -VNET_DEFINE_STATIC(int, nolocaltimewait) = 0; +VNET_DEFINE_STATIC(bool, nolocaltimewait) = true; #define V_nolocaltimewait VNET(nolocaltimewait) -SYSCTL_INT(_net_inet_tcp, OID_AUTO, nolocaltimewait, CTLFLAG_VNET | CTLFLAG_RW, - &VNET_NAME(nolocaltimewait), 0, +SYSCTL_BOOL(_net_inet_tcp, OID_AUTO, nolocaltimewait, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(nolocaltimewait), true, "Do not create compressed TCP TIME_WAIT entries for local connections"); void From nobody Thu Oct 28 23:06:23 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5CC5A1824DAE; Thu, 28 Oct 2021 23:06:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgLlg27Xdz3MlQ; Thu, 28 Oct 2021 23:06:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 269644468; Thu, 28 Oct 2021 23:06:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19SN6NUa016478; Thu, 28 Oct 2021 23:06:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19SN6NWd016477; Thu, 28 Oct 2021 23:06:23 GMT (envelope-from git) Date: Thu, 28 Oct 2021 23:06:23 GMT Message-Id: <202110282306.19SN6NWd016477@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 6940d0e4703e - main - Force WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6940d0e4703e72b8ea445541567d0ef64c2bb94b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=6940d0e4703e72b8ea445541567d0ef64c2bb94b commit 6940d0e4703e72b8ea445541567d0ef64c2bb94b Author: Ed Maste AuthorDate: 2021-10-28 21:07:34 +0000 Commit: Ed Maste CommitDate: 2021-10-28 23:04:14 +0000 Force WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL Discussed with: jhb MFC after: 1 week Reported by: Michael Dexter, Build Option Survey Sponsored by: The FreeBSD Foundation --- share/mk/src.opts.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index ff894d3b3517..3d8f7b071904 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -418,6 +418,7 @@ MK_NLS_CATALOGS:= no .if ${MK_OPENSSL} == "no" MK_DMAGENT:= no MK_OPENSSH:= no +MK_OPENSSL_KTLS:= no MK_KERBEROS:= no MK_KERBEROS_SUPPORT:= no MK_LDNS:= no From nobody Fri Oct 29 00:15:46 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 090C1183E1D3; Fri, 29 Oct 2021 00:15:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgNHk6pn0z3tyv; Fri, 29 Oct 2021 00:15:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C728A5436; Fri, 29 Oct 2021 00:15:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T0Fkfr009434; Fri, 29 Oct 2021 00:15:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T0FkCG009433; Fri, 29 Oct 2021 00:15:46 GMT (envelope-from git) Date: Fri, 29 Oct 2021 00:15:46 GMT Message-Id: <202110290015.19T0FkCG009433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 3bfc837685b8 - main - sinpi,cospi,tanpi: float.h needed for week reference List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3bfc837685b8128067b946b31dfe2120dae0d003 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3bfc837685b8128067b946b31dfe2120dae0d003 commit 3bfc837685b8128067b946b31dfe2120dae0d003 Author: Steve Kargl AuthorDate: 2021-10-28 22:53:13 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-29 00:15:19 +0000 sinpi,cospi,tanpi: float.h needed for week reference The patch fixes the omission of '#include ', which is needed for the weak reference on systems with LDBL_MANT_DIG == DBL_MANT_DIG. PR: 218514 MFC after: 1 week --- lib/msun/src/s_cospi.c | 1 + lib/msun/src/s_sinpi.c | 1 + lib/msun/src/s_tanpi.c | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/msun/src/s_cospi.c b/lib/msun/src/s_cospi.c index 92a5f467c97f..860219efd3e4 100644 --- a/lib/msun/src/s_cospi.c +++ b/lib/msun/src/s_cospi.c @@ -60,6 +60,7 @@ * cospi(nan) = nan. Raises the "invalid" floating-point exception. */ +#include #include "math.h" #include "math_private.h" diff --git a/lib/msun/src/s_sinpi.c b/lib/msun/src/s_sinpi.c index b9731112a7eb..858459a5fcb4 100644 --- a/lib/msun/src/s_sinpi.c +++ b/lib/msun/src/s_sinpi.c @@ -63,6 +63,7 @@ * sinpi(nan) = nan. Raises the "invalid" floating-point exception. */ +#include #include "math.h" #include "math_private.h" diff --git a/lib/msun/src/s_tanpi.c b/lib/msun/src/s_tanpi.c index e01917c94c15..01d4c74367fd 100644 --- a/lib/msun/src/s_tanpi.c +++ b/lib/msun/src/s_tanpi.c @@ -63,6 +63,7 @@ * tanpi(nan) = NaN. Raises the "invalid" floating-point exception. */ +#include #include "math.h" #include "math_private.h" From nobody Fri Oct 29 02:39:29 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C4FE1182E440; Fri, 29 Oct 2021 02:39:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgRTY4RzPz3F60; Fri, 29 Oct 2021 02:39:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74DFE729D; Fri, 29 Oct 2021 02:39:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T2dTfW095898; Fri, 29 Oct 2021 02:39:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T2dTP7095897; Fri, 29 Oct 2021 02:39:29 GMT (envelope-from git) Date: Fri, 29 Oct 2021 02:39:29 GMT Message-Id: <202110290239.19T2dTP7095897@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Cy Schubert Subject: git: a30e8044aa47 - main - wpa: Fix WITHOUT_CRYPT build List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a30e8044aa4753858c189f3384dae2b2f25a150b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=a30e8044aa4753858c189f3384dae2b2f25a150b commit a30e8044aa4753858c189f3384dae2b2f25a150b Author: Cy Schubert AuthorDate: 2021-10-28 23:55:48 +0000 Commit: Cy Schubert CommitDate: 2021-10-29 02:38:12 +0000 wpa: Fix WITHOUT_CRYPT build PASN requires CRYPT and when built WITHOUT_CRYPT buildworld fails. Only enable PASN when MK_CRYPT is enabled (default). PR: 259517 Reported by: emaste Fixes: c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5 MFC after: 1 week --- usr.sbin/wpa/Makefile.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr.sbin/wpa/Makefile.inc b/usr.sbin/wpa/Makefile.inc index 915b5312f02f..e43a6f539d92 100644 --- a/usr.sbin/wpa/Makefile.inc +++ b/usr.sbin/wpa/Makefile.inc @@ -56,7 +56,6 @@ CFLAGS+=-DCONFIG_TDLS CFLAGS+=-DCONFIG_TERMINATE_ONLASTIF CFLAGS+=-DCONFIG_TLS=openssl CFLAGS+=-DCONFIG_MATCH_IFACE -CFLAGS+=-DCONFIG_PASN CFLAGS+=-DCONFIG_PTKSA_CACHE CFLAGS+=-DEAP_SERVER CFLAGS+=-DEAP_SERVER_GTC @@ -91,6 +90,10 @@ NEED_AES_ENCBLOCK=y NEED_AES_OMAC1=y .endif +.if ${MK_CRYPT} != "no" +CFLAGS+=-DCONFIG_PASN +.endif + .if !empty(CFLAGS:M*-DEAP_AKA) NEED_SIM_COMMON=y NEED_AES_CBC=y From nobody Fri Oct 29 05:52:24 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 61A07182FAA9; Fri, 29 Oct 2021 05:52:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgWm82Htsz4lGF; Fri, 29 Oct 2021 05:52:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 241CB11BEE; Fri, 29 Oct 2021 05:52:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T5qOFU061845; Fri, 29 Oct 2021 05:52:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T5qOjx061844; Fri, 29 Oct 2021 05:52:24 GMT (envelope-from git) Date: Fri, 29 Oct 2021 05:52:24 GMT Message-Id: <202110290552.19T5qOjx061844@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 68bff4a07e3f - main - Allow GEOM utilities to specify a -v option. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 68bff4a07e3fa6c30a0c0ff6cf5f0bef95dcbd72 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=68bff4a07e3fa6c30a0c0ff6cf5f0bef95dcbd72 commit 68bff4a07e3fa6c30a0c0ff6cf5f0bef95dcbd72 Author: Kirk McKusick AuthorDate: 2021-10-29 05:49:48 +0000 Commit: Kirk McKusick CommitDate: 2021-10-29 05:50:50 +0000 Allow GEOM utilities to specify a -v option. Geom utilities (geli(8), glabel(8), gmirror(8), gpart(8), gmirror(8), gmountver(8), etc) all use the geom(8) utility as their back end to process their commands and pass them into the kernel. Creating a new utility requires no more than filling out a template describing the commands and arguments that the utility supports. Consider the specification for the very simple gmountver(8) utility: struct g_command class_commands[] = { { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, { G_OPT_SENTINEL }, "[-v] prov ..." }, { "destroy", G_FLAG_VERBOSE, NULL, { { 'f', "force", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, "[-fv] name" }, G_CMD_SENTINEL }; It has just two commands of its own: "create" and "destroy" along with the four standard commands "list", "status", "load", and "unload" provided by the base geom(8) utility. The base geom(8) utility allows each command to use the G_FLAG_VERBOSE flag to specify that a command should accept the -v flag and when the -v flag is given the utility prints "Done." if the command completes successfully. In the above example, both of the commands set the G_FLAG_VERBOSE, so have the -v option available. In addition the "destroy" command accepts the -f boolean flag to force the destruction. If the "destroy" command wanted to also print out verbose information, it would need to explicitly declare its intent by adding a line: { 'v', "verbose", NULL, G_TYPE_BOOL }, Before this change, the geom utility would silently ignore the above line in the configuration file, so it was impossible for the utility to know that the -v flag had been set on the command. With this change a geom command can explicitly specify a -v option with a line as given above and handle it as it would any other option. If both a -v option and G_FLAG_VERBOSE are specified for a command then both types of verbose information will be output when that command is run with -v. MFC after: 1 week Sponsored by: Netflix --- sbin/geom/core/geom.c | 19 ++++++++++++------- sbin/geom/core/geom.h | 13 +++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c index 58b33a067700..2e0d8683df49 100644 --- a/sbin/geom/core/geom.c +++ b/sbin/geom/core/geom.c @@ -314,7 +314,7 @@ parse_arguments(struct g_command *cmd, struct gctl_req *req, int *argc, struct g_option *opt; char opts[64]; unsigned i; - int ch; + int ch, vcount; *opts = '\0'; if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0) @@ -336,17 +336,22 @@ parse_arguments(struct g_command *cmd, struct gctl_req *req, int *argc, /* * Add specified arguments. */ + vcount = 0; while ((ch = getopt(*argc, *argv, opts)) != -1) { /* Standard (not passed to kernel) options. */ - switch (ch) { - case 'v': + if (ch == 'v' && (cmd->gc_flags & G_FLAG_VERBOSE) != 0) verbose = 1; - continue; - } /* Options passed to kernel. */ opt = find_option(cmd, ch); - if (opt == NULL) + if (opt == NULL) { + if (ch == 'v' && (cmd->gc_flags & G_FLAG_VERBOSE) != 0){ + if (++vcount < 2) + continue; + else + warnx("Option 'v' specified twice."); + } usage(); + } if (!G_OPT_ISMULTI(opt) && G_OPT_ISDONE(opt)) { warnx("Option '%c' specified twice.", opt->go_char); usage(); @@ -440,7 +445,7 @@ set_flags(struct g_command *cmd) { unsigned flags = 0; - if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0 && verbose) + if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0) flags |= G_FLAG_VERBOSE; return (flags); diff --git a/sbin/geom/core/geom.h b/sbin/geom/core/geom.h index 89c5828c6429..38a99032f692 100644 --- a/sbin/geom/core/geom.h +++ b/sbin/geom/core/geom.h @@ -32,6 +32,19 @@ #define _GEOM_H_ #define G_LIB_VERSION 5 +/* + * The G_FLAG_VERBOSE flag on a command specification means that the + * comand will accept a -v option and the GEOM framework will print + * out status information after the command when it is run with -v. + * Additionally a GEOM command can explicitly specify a -v option and + * handle it as it would any other option. If both a -v option and + * G_FLAG_VERBOSE are specified for a command then both types of verbose + * information will be output when that command is run with -v. + * + * When the G_FLAG_LOADKLD is specified for a command, the GEOM kernel + * module will be loaded when that command is run if it has not yet been + * loaded. This flag is typically specified for the `create' command. + */ #define G_FLAG_NONE 0x0000 #define G_FLAG_VERBOSE 0x0001 #define G_FLAG_LOADKLD 0x0002 From nobody Fri Oct 29 07:19:22 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6F01E18321F6; Fri, 29 Oct 2021 07:19:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgYhV2X2cz3QGw; Fri, 29 Oct 2021 07:19:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 367AB12E54; Fri, 29 Oct 2021 07:19:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T7JMBK069052; Fri, 29 Oct 2021 07:19:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T7JM26069051; Fri, 29 Oct 2021 07:19:22 GMT (envelope-from git) Date: Fri, 29 Oct 2021 07:19:22 GMT Message-Id: <202110290719.19T7JM26069051@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: aeda85278255 - main - tcp: Rack at times can miscalculate the RTT from what it thinks is a persists probe respone. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aeda8527825525cfd75bfbcae7bc895cee17f04b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=aeda8527825525cfd75bfbcae7bc895cee17f04b commit aeda8527825525cfd75bfbcae7bc895cee17f04b Author: Randall Stewart AuthorDate: 2021-10-29 07:17:43 +0000 Commit: Randall Stewart CommitDate: 2021-10-29 07:17:43 +0000 tcp: Rack at times can miscalculate the RTT from what it thinks is a persists probe respone. Turns out that if a peer sends in a window update right after rack fires off a persists probe, we can mis-interpret the window update and calculate a bogus RTT (very short). We still process the window update and send the data but we incorrectly generate an RTT. We should be only doing the RTT stuff if the rwnd is still small and has not changed. Reviewed by: Michael Tuexen Sponsored by: Netflix Inc. Differential Revision: https://reviews.freebsd.org/D32717 --- sys/netinet/tcp_stacks/rack.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index a92e43205f09..04252511ad18 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -5363,8 +5363,6 @@ rack_get_persists_timer_val(struct tcpcb *tp, struct tcp_rack *rack) t = (tp->t_srtt + (tp->t_rttvar << 2)); RACK_TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift], rack_persist_min, rack_persist_max, rack->r_ctl.timer_slop); - if (tp->t_rxtshift < TCP_MAXRXTSHIFT) - tp->t_rxtshift++; rack->r_ctl.rc_hpts_flags |= PACE_TMR_PERSIT; ret_val = (uint32_t)tt; return (ret_val); @@ -14448,11 +14446,20 @@ rack_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, * at least use timestamps if available to validate). */ rack->forced_ack = 0; - us_rtt = us_cts - rack->r_ctl.forced_ack_ts; - if (us_rtt == 0) - us_rtt = 1; - rack_apply_updated_usrtt(rack, us_rtt, us_cts); - tcp_rack_xmit_timer(rack, us_rtt, 0, us_rtt, 3, NULL, 1); + if (tiwin == tp->snd_wnd) { + /* + * Only apply the RTT update if this is + * a response to our window probe. And that + * means the rwnd sent must match the current + * snd_wnd. If it does not, then we got a + * window update ack instead. + */ + us_rtt = us_cts - rack->r_ctl.forced_ack_ts; + if (us_rtt == 0) + us_rtt = 1; + rack_apply_updated_usrtt(rack, us_rtt, us_cts); + tcp_rack_xmit_timer(rack, us_rtt, 0, us_rtt, 3, NULL, 1); + } } /* * This is the one exception case where we set the rack state From nobody Fri Oct 29 07:52:55 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5C11C183E506; Fri, 29 Oct 2021 07:52:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgZRC25nLz3nhM; Fri, 29 Oct 2021 07:52:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 28575130FE; Fri, 29 Oct 2021 07:52:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T7qtld021099; Fri, 29 Oct 2021 07:52:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T7qtkm021098; Fri, 29 Oct 2021 07:52:55 GMT (envelope-from git) Date: Fri, 29 Oct 2021 07:52:55 GMT Message-Id: <202110290752.19T7qtkm021098@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: ccfa9ac5ac12 - main - NXP: Add ls1028a SPI clock driver List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ccfa9ac5ac128fa59291fb99dcae27e890c58cbc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=ccfa9ac5ac128fa59291fb99dcae27e890c58cbc commit ccfa9ac5ac128fa59291fb99dcae27e890c58cbc Author: Wojciech Macek AuthorDate: 2021-10-22 08:12:09 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 07:52:20 +0000 NXP: Add ls1028a SPI clock driver Provide driver for LS1028A and LX2160 SPI clock modules. Obtained from: Semihalf Sponsored by: Alstom Differential revision: https://reviews.freebsd.org/D32689 --- sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c | 310 ++++++++++++++++++++++++++++++ sys/conf/files.arm64 | 1 + 2 files changed, 311 insertions(+) diff --git a/sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c b/sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c new file mode 100644 index 000000000000..5ecefa197ad3 --- /dev/null +++ b/sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c @@ -0,0 +1,310 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Alstom Group. + * Copyright (c) 2021 Semihalf. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include "clkdev_if.h" +#include "syscon_if.h" + + +struct ls1028a_flexspi_clk_softc { + device_t dev; + struct clkdom *clkdom; + uint64_t reg_offset; + struct syscon *syscon; + struct clk_div_def clk_def; + struct mtx mtx; +}; + +static struct clk_div_table ls1028a_flexspi_div_tbl[] = { + { .value = 0, .divider = 1, }, + { .value = 1, .divider = 2, }, + { .value = 2, .divider = 3, }, + { .value = 3, .divider = 4, }, + { .value = 4, .divider = 5, }, + { .value = 5, .divider = 6, }, + { .value = 6, .divider = 7, }, + { .value = 7, .divider = 8, }, + { .value = 11, .divider = 12, }, + { .value = 15, .divider = 16, }, + { .value = 16, .divider = 20, }, + { .value = 17, .divider = 24, }, + { .value = 18, .divider = 28, }, + { .value = 19, .divider = 32, }, + { .value = 20, .divider = 80, }, + {} +}; +static struct clk_div_table lx2160a_flexspi_div_tbl[] = { + { .value = 1, .divider = 2, }, + { .value = 3, .divider = 4, }, + { .value = 5, .divider = 6, }, + { .value = 7, .divider = 8, }, + { .value = 11, .divider = 12, }, + { .value = 15, .divider = 16, }, + { .value = 16, .divider = 20, }, + { .value = 17, .divider = 24, }, + { .value = 18, .divider = 28, }, + { .value = 19, .divider = 32, }, + { .value = 20, .divider = 80, }, + {} +}; + +static struct ofw_compat_data compat_data[] = { + { "fsl,ls1028a-flexspi-clk", (uintptr_t)ls1028a_flexspi_div_tbl }, + { "fsl,lx2160a-flexspi-clk", (uintptr_t)lx2160a_flexspi_div_tbl }, + { NULL, 0 } +}; + +static int +ls1028a_flexspi_clk_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) { + device_set_desc(dev, "NXP FlexSPI clock driver"); + return (BUS_PROBE_DEFAULT); + } + + return (ENXIO); +} + +static int +ls1028a_flexspi_clk_attach(device_t dev) +{ + struct ls1028a_flexspi_clk_softc *sc; + const char *oclkname = NULL; + const char *pclkname[1]; + uint32_t acells; + uint32_t scells; + pcell_t cells[4]; + phandle_t node; + uint64_t reg_size; + int ret; + clk_t clk; + + sc = device_get_softc(dev); + sc->dev = dev; + node = ofw_bus_get_node(dev); + + /* Parse address-cells and size-cells from the parent node as a fallback */ + if (OF_getencprop(node, "#address-cells", &acells, + sizeof(acells)) == -1) { + if (OF_getencprop(OF_parent(node), "#address-cells", &acells, + sizeof(acells)) == -1) { + acells = 2; + } + } + if (OF_getencprop(node, "#size-cells", &scells, + sizeof(scells)) == -1) { + if (OF_getencprop(OF_parent(node), "#size-cells", &scells, + sizeof(scells)) == -1) { + scells = 1; + } + } + ret = OF_getencprop(node, "reg", cells, (acells + scells) * sizeof(pcell_t)); + if (ret < 0) { + device_printf(dev, "ERROR: failed to read REG property\n"); + return (ENOMEM); + } + sc->reg_offset = (uint64_t)cells[0]; + if (acells == 2) + sc->reg_offset = (sc->reg_offset << 32) | (uint64_t)cells[1]; + reg_size = (uint64_t)cells[acells]; + if (scells == 2) + reg_size = (reg_size << 32) | (uint64_t)cells[acells + 1]; + + if (reg_size != 4) { + device_printf(dev, "ERROR, expected only single register\n"); + return (EINVAL); + } + if (sc->reg_offset >> 32UL) { + device_printf(dev, "ERROR, only 32-bit address offset is supported\n"); + return (EINVAL); + } + + /* Get syscon handle */ + ret = SYSCON_GET_HANDLE(dev, &sc->syscon); + if ((ret != 0) || (sc->syscon == NULL)) { + device_printf(dev, "ERROR: failed to get syscon\n"); + return (EFAULT); + } + + /* Initialize access mutex */ + mtx_init(&sc->mtx, "FSL clock mtx", NULL, MTX_DEF); + + /* Get clock names */ + ret = clk_get_by_ofw_index(dev, node, 0, &clk); + if (ret) { + device_printf(dev, "ERROR: failed to get parent clock\n"); + return (EINVAL); + } + pclkname[0] = clk_get_name(clk); + ret = clk_parse_ofw_clk_name(dev, node, &oclkname); + if (ret) { + device_printf(dev, "ERROR: failed to get output clock name\n"); + return (EINVAL); + } + +#ifdef DEBUG + device_printf(dev, "INFO: pclkname %s, oclkname %s\n", pclkname[0], oclkname); +#endif + + /* Fixup CLK structure */ + sc->clk_def.clkdef.name = oclkname; + sc->clk_def.clkdef.parent_names = (const char **)pclkname; + sc->clk_def.offset = (uint32_t)sc->reg_offset; + sc->clk_def.clkdef.id = 1; + sc->clk_def.clkdef.parent_cnt = 1; + sc->clk_def.clkdef.flags = 0; + sc->clk_def.div_flags = CLK_DIV_WITH_TABLE; + sc->clk_def.i_shift = 0; + sc->clk_def.i_width = 5; + sc->clk_def.div_table = (struct clk_div_table*)ofw_bus_search_compatible(dev, compat_data)->ocd_data; + + /* Create clock */ + sc->clkdom = clkdom_create(dev); + if (sc->clkdom == NULL) + panic("clkdom == NULL"); + ret = clknode_div_register(sc->clkdom, &sc->clk_def); + if (ret) { + device_printf(dev, "ERROR: unable to register clock\n"); + return (EINVAL); + } + clkdom_finit(sc->clkdom); + + if (bootverbose) + clkdom_dump(sc->clkdom); + + return (0); +} + +static int +ls1028a_flexspi_clk_detach(device_t dev) +{ + + /* Clock detaching is not supported */ + return (EACCES); +} + +static int +ls1028a_flexspi_clk_read_4(device_t dev, bus_addr_t addr, uint32_t *val) +{ + struct ls1028a_flexspi_clk_softc *sc; + sc = device_get_softc(dev); + + *val = SYSCON_READ_4(sc->syscon, addr); + + return (0); +} + +static int +ls1028a_flexspi_clk_write_4(device_t dev, bus_addr_t addr, uint32_t val) +{ + struct ls1028a_flexspi_clk_softc *sc; + int ret; + + sc = device_get_softc(dev); + + ret = SYSCON_WRITE_4(sc->syscon, addr, val); + + return (ret); +} + +static int +ls1028a_flexspi_clk_modify_4(device_t dev, bus_addr_t addr, uint32_t clr, uint32_t set) +{ + struct ls1028a_flexspi_clk_softc *sc; + int ret; + + sc = device_get_softc(dev); + + ret = SYSCON_MODIFY_4(sc->syscon, addr, clr, set); + + return (ret); +} + +static void +ls1028a_flexspi_clk_device_lock(device_t dev) +{ + struct ls1028a_flexspi_clk_softc *sc; + sc = device_get_softc(dev); + + mtx_lock(&sc->mtx); +} + +static void +ls1028a_flexspi_clk_device_unlock(device_t dev) +{ + struct ls1028a_flexspi_clk_softc *sc; + + sc = device_get_softc(dev); + + mtx_unlock(&sc->mtx); +} + +static device_method_t ls1028a_flexspi_clk_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ls1028a_flexspi_clk_probe), + DEVMETHOD(device_attach, ls1028a_flexspi_clk_attach), + DEVMETHOD(device_detach, ls1028a_flexspi_clk_detach), + + DEVMETHOD(clkdev_read_4, ls1028a_flexspi_clk_read_4), + DEVMETHOD(clkdev_write_4, ls1028a_flexspi_clk_write_4), + DEVMETHOD(clkdev_modify_4, ls1028a_flexspi_clk_modify_4), + DEVMETHOD(clkdev_device_lock, ls1028a_flexspi_clk_device_lock), + DEVMETHOD(clkdev_device_unlock, ls1028a_flexspi_clk_device_unlock), + + DEVMETHOD_END +}; + +static devclass_t ls1028a_flexspi_clk_devclass; +static DEFINE_CLASS_0(fspi_clk, ls1028a_flexspi_clk_driver, ls1028a_flexspi_clk_methods, + sizeof(struct ls1028a_flexspi_clk_softc)); +EARLY_DRIVER_MODULE(ls1028a_flexspi_clk, simple_mfd, ls1028a_flexspi_clk_driver, + ls1028a_flexspi_clk_devclass, NULL, NULL, BUS_PASS_TIMER); diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 5fdf2d6ee648..3a41554eaea7 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -521,6 +521,7 @@ arm64/qoriq/qoriq_dw_pci.c optional pci fdt SOC_NXP_LS arm64/qoriq/qoriq_therm.c optional pci fdt SOC_NXP_LS arm64/qoriq/qoriq_therm_if.m optional pci fdt SOC_NXP_LS arm64/qoriq/clk/ls1028a_clkgen.c optional clk SOC_NXP_LS +arm64/qoriq/clk/ls1028a_flexspi_clk.c optional clk SOC_NXP_LS arm64/qoriq/clk/ls1046a_clkgen.c optional clk SOC_NXP_LS arm64/qoriq/clk/lx2160a_clkgen.c optional clk SOC_NXP_LS arm64/qoriq/clk/qoriq_clk_pll.c optional clk SOC_NXP_LS From nobody Fri Oct 29 08:31:39 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 85CDD1826847; Fri, 29 Oct 2021 08:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgbHv3MjSz4SpZ; Fri, 29 Oct 2021 08:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 53F831401A; Fri, 29 Oct 2021 08:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T8Vdil073735; Fri, 29 Oct 2021 08:31:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T8Vdcl073734; Fri, 29 Oct 2021 08:31:39 GMT (envelope-from git) Date: Fri, 29 Oct 2021 08:31:39 GMT Message-Id: <202110290831.19T8Vdcl073734@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 3c02da8096b1 - main - dmar: Don't try to reserve PCI regions for non-existing devices List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3c02da8096b142ef243da8da667c3a5a7d591105 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=3c02da8096b142ef243da8da667c3a5a7d591105 commit 3c02da8096b142ef243da8da667c3a5a7d591105 Author: Kornel Duleba AuthorDate: 2021-10-21 12:46:51 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 08:08:25 +0000 dmar: Don't try to reserve PCI regions for non-existing devices In some cases we might have to create DMAR context before the corresponding device has been enumerated by the PCI bus. In that case we get called with NULL dev, because of that trying to reserve PCI regions causes a NULL pointer dereference in pci_find_pcie_root_port. Sponsored by: Stormshield Obtained from: Semihalf MFC after: 2 weeks Reviewed by: kib, rlibby Differential revision: https://reviews.freebsd.org/D32589 --- sys/x86/iommu/intel_ctx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index 34730306000b..7aedbf159ac7 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -561,7 +561,7 @@ dmar_get_ctx_for_dev1(struct dmar_unit *dmar, device_t dev, uint16_t rid, error = domain_init_rmrr(domain1, dev, bus, slot, func, dev_domain, dev_busno, dev_path, dev_path_len); - if (error == 0) + if (error == 0 && dev != NULL) error = dmar_reserve_pci_regions(domain1, dev); if (error != 0) { dmar_domain_destroy(domain1); From nobody Fri Oct 29 08:31:40 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D6D171826578; Fri, 29 Oct 2021 08:31:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgbHw58sCz4SRv; Fri, 29 Oct 2021 08:31:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7AA7114204; Fri, 29 Oct 2021 08:31:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T8Vex2073761; Fri, 29 Oct 2021 08:31:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T8Vew6073760; Fri, 29 Oct 2021 08:31:40 GMT (envelope-from git) Date: Fri, 29 Oct 2021 08:31:40 GMT Message-Id: <202110290831.19T8Vew6073760@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 06e6ca6dd350 - main - dmar: Disable protected memory regions after initialization List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 06e6ca6dd3508866b584942a6a40739e09453cc6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=06e6ca6dd3508866b584942a6a40739e09453cc6 commit 06e6ca6dd3508866b584942a6a40739e09453cc6 Author: Kornel Duleba AuthorDate: 2021-10-21 14:02:26 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 08:08:25 +0000 dmar: Disable protected memory regions after initialization Some BIOSes protect memory region they reside in by using DMAR to prevent devices from doing any DMA transactions to that part of RAM. AMI refers to this as "DMA Control Guarantee". Disable the protection when address translation is enabled. I stumbled upon this while investigation a failing coredump on a device which has this feature enabled. Sponsored by: Stormshield Obtained from: Semihalf Reviewed by: kib Differential revision: https://reviews.freebsd.org/D32591 --- sys/x86/iommu/intel_ctx.c | 4 ++++ sys/x86/iommu/intel_dmar.h | 1 + sys/x86/iommu/intel_drv.c | 4 ++++ sys/x86/iommu/intel_utils.c | 27 +++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index 7aedbf159ac7..815dc6146b00 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -631,6 +631,10 @@ dmar_get_ctx_for_dev1(struct dmar_unit *dmar, device_t dev, uint16_t rid, * to avoid unneeded command. */ if (enable && !rmrr_init && (dmar->hw_gcmd & DMAR_GCMD_TE) == 0) { + error = dmar_disable_protected_regions(dmar); + if (error != 0) + printf("dmar%d: Failed to disable protected regions\n", + dmar->iommu.unit); error = dmar_enable_translation(dmar); if (error == 0) { if (bootverbose) { diff --git a/sys/x86/iommu/intel_dmar.h b/sys/x86/iommu/intel_dmar.h index 0ad94dbf4123..b34505a4e5d0 100644 --- a/sys/x86/iommu/intel_dmar.h +++ b/sys/x86/iommu/intel_dmar.h @@ -227,6 +227,7 @@ int dmar_flush_write_bufs(struct dmar_unit *unit); void dmar_flush_pte_to_ram(struct dmar_unit *unit, dmar_pte_t *dst); void dmar_flush_ctx_to_ram(struct dmar_unit *unit, dmar_ctx_entry_t *dst); void dmar_flush_root_to_ram(struct dmar_unit *unit, dmar_root_entry_t *dst); +int dmar_disable_protected_regions(struct dmar_unit *unit); int dmar_enable_translation(struct dmar_unit *unit); int dmar_disable_translation(struct dmar_unit *unit); int dmar_load_irt_ptr(struct dmar_unit *unit); diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 0b470d7bbf7a..66849dd43053 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -1065,6 +1065,10 @@ dmar_instantiate_rmrr_ctxs(struct iommu_unit *unit) KASSERT((dmar->hw_gcmd & DMAR_GCMD_TE) == 0, ("dmar%d: RMRR not handled but translation is already enabled", dmar->iommu.unit)); + error = dmar_disable_protected_regions(dmar); + if (error != 0) + printf("dmar%d: Failed to disable protected regions\n", + dmar->iommu.unit); error = dmar_enable_translation(dmar); if (bootverbose) { if (error == 0) { diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c index 152c7cac3a7d..4511cceb6444 100644 --- a/sys/x86/iommu/intel_utils.c +++ b/sys/x86/iommu/intel_utils.c @@ -489,6 +489,33 @@ dmar_flush_write_bufs(struct dmar_unit *unit) return (error); } +/* + * Some BIOSes protect memory region they reside in by using DMAR to + * prevent devices from doing any DMA transactions to that part of RAM. + * AMI refers to this as "DMA Control Guarantee". + * We need to disable this when address translation is enabled. + */ +int +dmar_disable_protected_regions(struct dmar_unit *unit) +{ + uint32_t reg; + int error; + + DMAR_ASSERT_LOCKED(unit); + + /* Check if we support the feature. */ + if ((unit->hw_cap & (DMAR_CAP_PLMR | DMAR_CAP_PHMR)) == 0) + return (0); + + reg = dmar_read4(unit, DMAR_PMEN_REG); + reg &= ~DMAR_PMEN_EPM; + dmar_write4(unit, DMAR_PMEN_REG, reg); + DMAR_WAIT_UNTIL(((dmar_read4(unit, DMAR_PMEN_REG) & DMAR_PMEN_PRS) + != 0)); + + return (error); +} + int dmar_enable_translation(struct dmar_unit *unit) { From nobody Fri Oct 29 08:31:41 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5CF831826659; Fri, 29 Oct 2021 08:31:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgbHx742Hz4SmT; Fri, 29 Oct 2021 08:31:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ADB2A140F6; Fri, 29 Oct 2021 08:31:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T8Vfa2073800; Fri, 29 Oct 2021 08:31:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T8VfNl073799; Fri, 29 Oct 2021 08:31:41 GMT (envelope-from git) Date: Fri, 29 Oct 2021 08:31:41 GMT Message-Id: <202110290831.19T8VfNl073799@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 29cf6a79acb7 - main - felix: Use internal MDIO regs for PHY communication List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 29cf6a79acb7c28586ce39473e9ea1f2f1cd1ed4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=29cf6a79acb7c28586ce39473e9ea1f2f1cd1ed4 commit 29cf6a79acb7c28586ce39473e9ea1f2f1cd1ed4 Author: Kornel Duleba AuthorDate: 2021-10-26 08:36:35 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 08:08:26 +0000 felix: Use internal MDIO regs for PHY communication Previously we would use an external MDIO device found on the PCI bus. Switch to using MDIO mapped in a separate BAR of the switch device. It is much easier this way since we don't have to depend on another driver anymore. Obtained from: Semihalf Sponsored by: Alstom Group --- sys/dev/etherswitch/felix/felix.c | 70 +++++++++++++++-------------------- sys/dev/etherswitch/felix/felix_reg.h | 2 + sys/dev/etherswitch/felix/felix_var.h | 2 + sys/modules/felix/Makefile | 3 +- 4 files changed, 35 insertions(+), 42 deletions(-) diff --git a/sys/dev/etherswitch/felix/felix.c b/sys/dev/etherswitch/felix/felix.c index 1cd1e0e29ca7..f57a6e1daa0c 100644 --- a/sys/dev/etherswitch/felix/felix.c +++ b/sys/dev/etherswitch/felix/felix.c @@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -124,6 +126,10 @@ static device_method_t felix_methods[] = { DEVMETHOD(etherswitch_setvgroup, felix_setvgroup), DEVMETHOD(etherswitch_getvgroup, felix_getvgroup), + /* miibus interface */ + DEVMETHOD(miibus_readreg, felix_readphy), + DEVMETHOD(miibus_writereg, felix_writephy), + DEVMETHOD_END }; @@ -131,15 +137,16 @@ static devclass_t felix_devclass; DEFINE_CLASS_0(felix, felix_driver, felix_methods, sizeof(struct felix_softc)); -DRIVER_MODULE(felix, pci, felix_driver, felix_devclass, NULL, NULL); +DRIVER_MODULE_ORDERED(felix, pci, felix_driver, felix_devclass, + NULL, NULL, SI_ORDER_ANY); +DRIVER_MODULE(miibus, felix, miibus_driver, miibus_devclass, + NULL, NULL); DRIVER_MODULE(etherswitch, felix, etherswitch_driver, etherswitch_devclass, NULL, NULL); MODULE_VERSION(felix, 1); MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, felix, felix_pci_ids, nitems(felix_pci_ids) - 1); -MODULE_DEPEND(felix, enetc_mdio, 1, 1, 1); - static int felix_probe(device_t dev) { @@ -324,7 +331,6 @@ felix_attach(device_t dev) phandle_t child, ports, node; int error, port, rid; felix_softc_t sc; - device_t mdio_dev; uint32_t phy_addr; ssize_t size; @@ -333,12 +339,21 @@ felix_attach(device_t dev) sc->info.es_vlan_caps = ETHERSWITCH_VLAN_DOT1Q; strlcpy(sc->info.es_name, "Felix TSN Switch", sizeof(sc->info.es_name)); + rid = PCIR_BAR(FELIX_BAR_MDIO); + sc->mdio = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->mdio == NULL) { + device_printf(dev, "Failed to allocate MDIO registers.\n"); + return (ENXIO); + } + rid = PCIR_BAR(FELIX_BAR_REGS); sc->regs = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->regs == NULL) { device_printf(dev, "Failed to allocate registers BAR.\n"); - return (ENXIO); + error = ENXIO; + goto out_fail; } mtx_init(&sc->mtx, "felix lock", NULL, MTX_DEF); @@ -396,25 +411,9 @@ felix_attach(device_t dev) goto out_fail; } - node = OF_parent(node); - if (node <= 0) { - device_printf(sc->dev, - "Failed to obtain MDIO node.\n"); - error = ENXIO; - goto out_fail; - } - - mdio_dev = OF_device_from_xref(node); - if (mdio_dev == NULL) { - device_printf(sc->dev, - "Failed to obtain MDIO driver handle.\n"); - error = ENXIO; - goto out_fail; - } - sc->ports[port].phyaddr = phy_addr; sc->ports[port].miibus = NULL; - error = mii_attach(mdio_dev, &sc->ports[port].miibus, sc->ports[port].ifp, + error = mii_attach(dev, &sc->ports[port].miibus, sc->ports[port].ifp, felix_ifmedia_upd, felix_ifmedia_sts, BMSR_DEFCAPMASK, phy_addr, MII_OFFSET_ANY, 0); if (error != 0) @@ -447,7 +446,6 @@ static int felix_detach(device_t dev) { felix_softc_t sc; - device_t mdio_dev; int error; int i; @@ -468,10 +466,8 @@ felix_detach(device_t dev) felix_setup(sc); for (i = 0; i < sc->info.es_nports; i++) { - if (sc->ports[i].miibus != NULL) { - mdio_dev = device_get_parent(sc->ports[i].miibus); - device_delete_child(mdio_dev, sc->ports[i].miibus); - } + if (sc->ports[i].miibus != NULL) + device_delete_child(dev, sc->ports[i].miibus); if (sc->ports[i].ifp != NULL) if_free(sc->ports[i].ifp); if (sc->ports[i].ifname != NULL) @@ -482,6 +478,10 @@ felix_detach(device_t dev) error = bus_release_resource(sc->dev, SYS_RES_MEMORY, rman_get_rid(sc->regs), sc->regs); + if (sc->mdio != NULL) + error = bus_release_resource(sc->dev, SYS_RES_MEMORY, + rman_get_rid(sc->mdio), sc->mdio); + return (error); } @@ -759,32 +759,20 @@ static int felix_readphy(device_t dev, int phy, int reg) { felix_softc_t sc; - device_t mdio_dev; - int port; sc = device_get_softc(dev); - port = felix_phyforport(sc, phy); - if (port < 0) - return (UINT32_MAX); /* Can't return errors here. */ - mdio_dev = device_get_parent(sc->ports[port].miibus); - return (MIIBUS_READREG(mdio_dev, phy, reg)); + return (enetc_mdio_read(sc->mdio, FELIX_MDIO_BASE, phy, reg)); } static int felix_writephy(device_t dev, int phy, int reg, int data) { felix_softc_t sc; - device_t mdio_dev; - int port; sc = device_get_softc(dev); - port = felix_phyforport(sc, phy); - if (port < 0) - return (ENXIO); - mdio_dev = device_get_parent(sc->ports[port].miibus); - return (MIIBUS_WRITEREG(mdio_dev, phy, reg, data)); + return (enetc_mdio_write(sc->mdio, FELIX_MDIO_BASE, phy, reg, data)); } static int diff --git a/sys/dev/etherswitch/felix/felix_reg.h b/sys/dev/etherswitch/felix/felix_reg.h index 3474da72a456..eae3ebc135eb 100644 --- a/sys/dev/etherswitch/felix/felix_reg.h +++ b/sys/dev/etherswitch/felix/felix_reg.h @@ -31,6 +31,8 @@ #define BIT(x) (1UL << (x)) +#define FELIX_MDIO_BASE 0x1C00 + #define FELIX_DEVCPU_GCB_RST 0x70004 #define FELIX_DEVCPU_GCB_RST_EN BIT(0) diff --git a/sys/dev/etherswitch/felix/felix_var.h b/sys/dev/etherswitch/felix/felix_var.h index 1bdbc35e6116..d891419793b7 100644 --- a/sys/dev/etherswitch/felix/felix_var.h +++ b/sys/dev/etherswitch/felix/felix_var.h @@ -38,6 +38,7 @@ #define PCI_VENDOR_FREESCALE 0x1957 #define FELIX_DEV_ID 0xEEF0 +#define FELIX_BAR_MDIO 0 #define FELIX_BAR_REGS 4 #define FELIX_LOCK(_sc) mtx_lock(&(_sc)->mtx) @@ -92,6 +93,7 @@ struct felix_port { typedef struct felix_softc { device_t dev; struct resource *regs; + struct resource *mdio; etherswitch_info_t info; struct callout tick_callout; diff --git a/sys/modules/felix/Makefile b/sys/modules/felix/Makefile index 8f30a0e72a45..4bbca5046e0a 100644 --- a/sys/modules/felix/Makefile +++ b/sys/modules/felix/Makefile @@ -27,9 +27,10 @@ # .PATH: ${SRCTOP}/sys/dev/etherswitch/felix +.PATH: ${SRCTOP}/sys/dev/enetc KMOD = felix -SRCS = felix.c +SRCS = felix.c enetc_mdio.c SRCS += bus_if.h device_if.h etherswitch_if.h miibus_if.h ofw_bus_if.h pci_if.h .include From nobody Fri Oct 29 08:31:42 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A47DF1826663; Fri, 29 Oct 2021 08:31:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgbHz28RYz4SVj; Fri, 29 Oct 2021 08:31:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BBA1813F79; Fri, 29 Oct 2021 08:31:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T8VgRf073824; Fri, 29 Oct 2021 08:31:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T8Vgn1073823; Fri, 29 Oct 2021 08:31:42 GMT (envelope-from git) Date: Fri, 29 Oct 2021 08:31:42 GMT Message-Id: <202110290831.19T8Vgn1073823@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 8c5fead10590 - main - Remove enetc_mdio driver List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8c5fead105905ffb8cdcf255c08a63ee440b223e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=8c5fead105905ffb8cdcf255c08a63ee440b223e commit 8c5fead105905ffb8cdcf255c08a63ee440b223e Author: Kornel Duleba AuthorDate: 2021-10-26 08:41:09 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 08:08:26 +0000 Remove enetc_mdio driver It was previously used by felix(4) for PHY communication. Since that is not the case anymore this driver is now left unused. Obtained from: Semihalf Sponsored by: Alstom Group --- sys/conf/files.arm64 | 3 +- sys/dev/enetc/enetc_mdio_pci.c | 191 ---------------------------------------- sys/modules/Makefile | 2 - sys/modules/enetc_mdio/Makefile | 8 -- 4 files changed, 1 insertion(+), 203 deletions(-) diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 3a41554eaea7..2d98568b3d9f 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -176,8 +176,7 @@ dev/cpufreq/cpufreq_dt.c optional cpufreq fdt dev/dwc/if_dwc.c optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 | fdt dwc_socfpga soc_intel_stratix10 dev/dwc/if_dwc_if.m optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 | fdt dwc_socfpga soc_intel_stratix10 -dev/enetc/enetc_mdio.c optional enetc soc_nxp_ls | enetc_mdio soc_nxp_ls -dev/enetc/enetc_mdio_pci.c optional enetc_mdio pci soc_nxp_ls +dev/enetc/enetc_mdio.c optional enetc soc_nxp_ls dev/enetc/if_enetc.c optional enetc iflib pci fdt soc_nxp_ls dev/etherswitch/felix/felix.c optional enetc etherswitch fdt felix pci soc_nxp_ls diff --git a/sys/dev/enetc/enetc_mdio_pci.c b/sys/dev/enetc/enetc_mdio_pci.c deleted file mode 100644 index 517efa9b9598..000000000000 --- a/sys/dev/enetc/enetc_mdio_pci.c +++ /dev/null @@ -1,191 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2021 Alstom Group. - * Copyright (c) 2021 Semihalf. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "miibus_if.h" - -#define ENETC_MDIO_DEV_ID 0xee01 -#define ENETC_MDIO_DEV_NAME "FSL PCIe IE Central MDIO" - -static struct entec_mdio_pci_id { - uint16_t vendor; - uint16_t device; - const char *desc; -} enetc_mdio_pci_ids[] = { - {PCI_VENDOR_FREESCALE, ENETC_MDIO_DEV_ID, ENETC_MDIO_DEV_NAME}, -}; -MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, enetc_mdio_pci, - enetc_mdio_pci_ids, nitems(enetc_mdio_pci_ids)); - -struct enetc_mdio_pci_softc { - device_t sc_dev; - struct mtx sc_lock; - struct resource *sc_regs; -}; - -static device_attach_t enetc_mdio_pci_attach; -static device_detach_t enetc_mdio_pci_detach; -static device_probe_t enetc_mdio_pci_probe; - -static int -enetc_mdio_pci_readreg(device_t dev, int phy, int reg) -{ - struct enetc_mdio_pci_softc *sc; - uint32_t ret; - - sc = device_get_softc(dev); - - mtx_lock(&sc->sc_lock); - ret = enetc_mdio_read(sc->sc_regs, ENETC_EMDIO_BASE, phy, reg); - mtx_unlock(&sc->sc_lock); - - return (ret); -} - -static int -enetc_mdio_pci_writereg(device_t dev, int phy, int reg, int data) -{ - struct enetc_mdio_pci_softc *sc; - int err; - - sc = device_get_softc(dev); - - mtx_lock(&sc->sc_lock); - err = enetc_mdio_write(sc->sc_regs, ENETC_EMDIO_BASE, phy, reg, data); - mtx_unlock(&sc->sc_lock); - if (err != 0) - return (err); - - return (0); -} - -static int -enetc_mdio_pci_probe(device_t dev) -{ - struct entec_mdio_pci_id *id; - - for (id = enetc_mdio_pci_ids; id->vendor != 0; ++id) { - if (pci_get_device(dev) != id->device || - pci_get_vendor(dev) != id->vendor) - continue; - - device_set_desc(dev, id->desc); - - return (BUS_PROBE_DEFAULT); - } - - return (ENXIO); -} - -static int -enetc_mdio_pci_attach(device_t dev) -{ - struct enetc_mdio_pci_softc *sc; - int rid; - - sc = device_get_softc(dev); - sc->sc_dev = dev; - - /* Init locks */ - mtx_init(&sc->sc_lock, device_get_nameunit(dev), "MDIO lock", MTX_DEF); - - rid = PCIR_BAR(0); - sc->sc_regs = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->sc_regs == NULL) { - device_printf(dev, "can't allocate resources for PCI MDIO \n"); - return (ENXIO); - } - - OF_device_register_xref(ofw_bus_get_node(dev), dev); - - return (0); -} - -static int -enetc_mdio_pci_detach(device_t dev) -{ - struct enetc_mdio_pci_softc *sc; - - sc = device_get_softc(dev); - - bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0), sc->sc_regs); - mtx_destroy(&sc->sc_lock); - - return (0); -} - -static device_method_t enetc_mdio_pci_methods[] ={ - DEVMETHOD(device_probe, enetc_mdio_pci_probe), - DEVMETHOD(device_attach, enetc_mdio_pci_attach), - DEVMETHOD(device_detach, enetc_mdio_pci_detach), - - DEVMETHOD(miibus_readreg, enetc_mdio_pci_readreg), - DEVMETHOD(miibus_writereg, enetc_mdio_pci_writereg), - - DEVMETHOD_END -}; - -static driver_t enetc_mdio_pci_driver = { - "enetc_mdio", - enetc_mdio_pci_methods, - sizeof(struct enetc_mdio_pci_softc), -}; - -static devclass_t enetc_mdio_pci_devclass; - -DRIVER_MODULE(enetc_mdio, pci, enetc_mdio_pci_driver, - enetc_mdio_pci_devclass, 0, 0); -DRIVER_MODULE(miibus, enetc_mdio, miibus_driver, miibus_devclass, - 0, 0); -MODULE_VERSION(enetc_mdio, 1); diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 6cfeba3f45a7..724dcb694d97 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -110,7 +110,6 @@ SUBDIR= \ ${_em} \ ${_ena} \ ${_enetc} \ - ${_enetc_mdio} \ esp \ ${_et} \ evdev \ @@ -615,7 +614,6 @@ _armv8crypto= armv8crypto _dwwdt= dwwdt _em= em _enetc= enetc -_enetc_mdio= enetc_mdio _felix= felix _rockchip= rockchip .endif diff --git a/sys/modules/enetc_mdio/Makefile b/sys/modules/enetc_mdio/Makefile deleted file mode 100644 index f448fc526705..000000000000 --- a/sys/modules/enetc_mdio/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -#$FreeBSD$ - -.PATH: ${SRCTOP}/sys/dev/enetc - -KMOD = enetc_mdio -SRCS = enetc_mdio_pci.c enetc_mdio.c - -.include From nobody Fri Oct 29 08:31:44 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 560CD1826A79; Fri, 29 Oct 2021 08:31:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgbJ13VqGz4Ssf; Fri, 29 Oct 2021 08:31:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 152F913F9D; Fri, 29 Oct 2021 08:31:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T8ViFt073873; Fri, 29 Oct 2021 08:31:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T8Vi7W073872; Fri, 29 Oct 2021 08:31:44 GMT (envelope-from git) Date: Fri, 29 Oct 2021 08:31:44 GMT Message-Id: <202110290831.19T8Vi7W073872@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 027a58aab2ce - main - qoriq_gpio: Implement interrupt controller functionality List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 027a58aab2cee5589a3a639afb77ecbb607f8fee Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=027a58aab2cee5589a3a639afb77ecbb607f8fee commit 027a58aab2cee5589a3a639afb77ecbb607f8fee Author: Kornel Duleba AuthorDate: 2021-09-28 15:09:41 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 08:08:26 +0000 qoriq_gpio: Implement interrupt controller functionality The pic_* interface was used. Only edge interrupts are supported by this controller. Driver mutex had to be converted to a spin lock so that it can be used in the interrupt filter context. Two types of intr_map_data are supported - INTR_MAP_DATA_GPIO and INTR_MAP_DATA_FDT. This way interrupts can be allocated using the userspace gpio interrupt allocation method, as well as directly from simplebus. The latter can be used by devices that have its irq routed to a GPIO pin. Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D32587 --- sys/dev/gpio/qoriq_gpio.c | 352 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 339 insertions(+), 13 deletions(-) diff --git a/sys/dev/gpio/qoriq_gpio.c b/sys/dev/gpio/qoriq_gpio.c index dc4813e07b8e..0a78adbecb0f 100644 --- a/sys/dev/gpio/qoriq_gpio.c +++ b/sys/dev/gpio/qoriq_gpio.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -49,19 +50,25 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include "gpio_if.h" +#include "pic_if.h" +#define BIT(x) (1 << (x)) #define MAXPIN (31) #define VALID_PIN(u) ((u) >= 0 && (u) <= MAXPIN) #define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \ - GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL) + GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL | \ + GPIO_INTR_EDGE_FALLING | GPIO_INTR_EDGE_BOTH | \ + GPIO_PIN_PULLUP) -#define GPIO_LOCK(sc) mtx_lock(&(sc)->sc_mtx) -#define GPIO_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) +#define GPIO_LOCK(sc) mtx_lock_spin(&(sc)->sc_mtx) +#define GPIO_UNLOCK(sc) mtx_unlock_spin(&(sc)->sc_mtx) #define GPIO_LOCK_INIT(sc) \ mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->dev), \ - "gpio", MTX_DEF) + "gpio", MTX_SPIN) #define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); #define GPIO_GPDIR 0x0 @@ -72,12 +79,21 @@ __FBSDID("$FreeBSD$"); #define GPIO_GPICR 0x14 #define GPIO_GPIBE 0x18 +struct qoriq_gpio_irqsrc { + struct intr_irqsrc isrc; + int pin; +}; + struct qoriq_gpio_softc { device_t dev; device_t busdev; struct mtx sc_mtx; struct resource *sc_mem; /* Memory resource */ + struct resource *sc_intr; + void *intr_cookie; struct gpio_pin sc_pins[MAXPIN + 1]; + struct qoriq_gpio_irqsrc sc_isrcs[MAXPIN + 1]; + struct intr_map_data_gpio gdata; }; static device_t @@ -260,6 +276,254 @@ qoriq_gpio_pin_toggle(device_t dev, uint32_t pin) return (0); } +static void +qoriq_gpio_set_intr(struct qoriq_gpio_softc *sc, int pin, bool enable) +{ + uint32_t reg; + + reg = bus_read_4(sc->sc_mem, GPIO_GPIMR); + if (enable) + reg |= BIT(31 - pin); + else + reg &= ~BIT(31 - pin); + bus_write_4(sc->sc_mem, GPIO_GPIMR, reg); +} + +static void +qoriq_gpio_ack_intr(struct qoriq_gpio_softc *sc, int pin) +{ + uint32_t reg; + + reg = BIT(31 - pin); + bus_write_4(sc->sc_mem, GPIO_GPIER, reg); +} + +static int +qoriq_gpio_intr(void *arg) +{ + struct qoriq_gpio_softc *sc; + struct trapframe *tf; + uint32_t status; + int pin; + + sc = (struct qoriq_gpio_softc *)arg; + tf = curthread->td_intr_frame; + + status = bus_read_4(sc->sc_mem, GPIO_GPIER); + status &= bus_read_4(sc->sc_mem, GPIO_GPIMR); + while (status != 0) { + pin = ffs(status) - 1; + status &= ~BIT(pin); + pin = 31 - pin; + + if (intr_isrc_dispatch(&sc->sc_isrcs[pin].isrc, tf) != 0) { + GPIO_LOCK(sc); + qoriq_gpio_set_intr(sc, pin, false); + qoriq_gpio_ack_intr(sc, pin); + GPIO_UNLOCK(sc); + device_printf(sc->dev, + "Masking spurious pin interrupt %d\n", + pin); + } + } + + return (FILTER_HANDLED); +} + +static void +qoriq_gpio_disable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_softc *sc; + struct qoriq_gpio_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_irqsrc *)isrc; + + GPIO_LOCK(sc); + qoriq_gpio_set_intr(sc, qisrc->pin, false); + GPIO_UNLOCK(sc); +} + +static void +qoriq_gpio_enable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_softc *sc; + struct qoriq_gpio_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_irqsrc *)isrc; + + GPIO_LOCK(sc); + qoriq_gpio_set_intr(sc, qisrc->pin, true); + GPIO_UNLOCK(sc); +} + +static struct intr_map_data_gpio* +qoriq_gpio_convert_map_data(struct qoriq_gpio_softc *sc, struct intr_map_data *data) +{ + struct intr_map_data_gpio *gdata; + struct intr_map_data_fdt *daf; + + switch (data->type) { + case INTR_MAP_DATA_GPIO: + gdata = (struct intr_map_data_gpio *)data; + break; + case INTR_MAP_DATA_FDT: + daf = (struct intr_map_data_fdt *)data; + if (daf->ncells != 2) + return (NULL); + + gdata = &sc->gdata; + gdata->gpio_pin_num = daf->cells[0]; + switch (daf->cells[1]) { + case IRQ_TYPE_LEVEL_LOW: + gdata->gpio_intr_mode = GPIO_INTR_LEVEL_LOW; + break; + case IRQ_TYPE_LEVEL_HIGH: + gdata->gpio_intr_mode = GPIO_INTR_LEVEL_HIGH; + break; + case IRQ_TYPE_EDGE_RISING: + gdata->gpio_intr_mode = GPIO_INTR_EDGE_RISING; + break; + case IRQ_TYPE_EDGE_FALLING: + gdata->gpio_intr_mode = GPIO_INTR_EDGE_FALLING; + break; + case IRQ_TYPE_EDGE_BOTH: + gdata->gpio_intr_mode = GPIO_INTR_EDGE_BOTH; + break; + default: + return (NULL); + } + break; + default: + return (NULL); + } + + return (gdata); +} + + +static int +qoriq_gpio_map_intr(device_t dev, struct intr_map_data *data, + struct intr_irqsrc **isrcp) +{ + struct qoriq_gpio_softc *sc; + struct intr_map_data_gpio *gdata; + int pin; + + sc = device_get_softc(dev); + + gdata = qoriq_gpio_convert_map_data(sc, data); + if (gdata == NULL) + return (EINVAL); + + pin = gdata->gpio_pin_num; + if (pin > MAXPIN) + return (EINVAL); + + *isrcp = &sc->sc_isrcs[pin].isrc; + return (0); +} + +static int +qoriq_gpio_setup_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + struct qoriq_gpio_softc *sc; + struct intr_map_data_gpio *gdata; + struct qoriq_gpio_irqsrc *qisrc; + bool falling; + uint32_t reg; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_irqsrc *)isrc; + + gdata = qoriq_gpio_convert_map_data(sc, data); + if (gdata == NULL) + return (EINVAL); + + if (gdata->gpio_intr_mode & GPIO_INTR_EDGE_BOTH) + falling = false; + else if (gdata->gpio_intr_mode & GPIO_INTR_EDGE_FALLING) + falling = true; + else + return (EOPNOTSUPP); + + GPIO_LOCK(sc); + reg = bus_read_4(sc->sc_mem, GPIO_GPICR); + if (falling) + reg |= BIT(31 - qisrc->pin); + else + reg &= ~BIT(31 - qisrc->pin); + bus_write_4(sc->sc_mem, GPIO_GPICR, reg); + GPIO_UNLOCK(sc); + + return (0); +} + +static int +qoriq_gpio_teardown_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + struct qoriq_gpio_softc *sc; + struct qoriq_gpio_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_irqsrc *)isrc; + + if (isrc->isrc_handlers > 0) + return (0); + + GPIO_LOCK(sc); + qoriq_gpio_set_intr(sc, qisrc->pin, false); + GPIO_UNLOCK(sc); + return (0); +} + +static void +qoriq_gpio_post_filter(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_softc *sc; + struct qoriq_gpio_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_irqsrc *)isrc; + + GPIO_LOCK(sc); + qoriq_gpio_ack_intr(sc, qisrc->pin); + GPIO_UNLOCK(sc); +} + + +static void +qoriq_gpio_post_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_softc *sc; + struct qoriq_gpio_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_irqsrc *)isrc; + + GPIO_LOCK(sc); + qoriq_gpio_ack_intr(sc, qisrc->pin); + qoriq_gpio_set_intr(sc, qisrc->pin, true); + GPIO_UNLOCK(sc); +} + +static void +qoriq_gpio_pre_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_softc *sc; + struct qoriq_gpio_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_irqsrc *)isrc; + + GPIO_LOCK(sc); + qoriq_gpio_set_intr(sc, qisrc->pin, false); + GPIO_UNLOCK(sc); +} + static struct ofw_compat_data gpio_matches[] = { {"fsl,qoriq-gpio", 1}, {"fsl,pq3-gpio", 1}, @@ -385,7 +649,9 @@ static int qoriq_gpio_attach(device_t dev) { struct qoriq_gpio_softc *sc = device_get_softc(dev); - int i, rid; + int i, rid, error; + const char *name; + intptr_t xref; sc->dev = dev; @@ -397,17 +663,46 @@ qoriq_gpio_attach(device_t dev) SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->sc_mem == NULL) { device_printf(dev, "Can't allocate memory for device output port"); - qoriq_gpio_detach(dev); - return (ENOMEM); + error = ENOMEM; + goto fail; + } + + rid = 0; + sc->sc_intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE | RF_SHAREABLE); + if (sc->sc_intr == NULL) { + device_printf(dev, "Can't allocate interrupt resource.\n"); + error = ENOMEM; + goto fail; + } + + error = bus_setup_intr(dev, sc->sc_intr, INTR_TYPE_MISC | INTR_MPSAFE, + qoriq_gpio_intr, NULL, sc, &sc->intr_cookie); + if (error != 0) { + device_printf(dev, "Failed to setup interrupt.\n"); + goto fail; } - for (i = 0; i <= MAXPIN; i++) + name = device_get_nameunit(dev); + for (i = 0; i <= MAXPIN; i++) { sc->sc_pins[i].gp_caps = DEFAULT_CAPS; + sc->sc_isrcs[i].pin = i; + error = intr_isrc_register(&sc->sc_isrcs[i].isrc, + dev, 0, "%s,%u", name, i); + if (error != 0) + goto fail; + } + + xref = OF_xref_from_node(ofw_bus_get_node(dev)); + if (intr_pic_register(dev, xref) == NULL) { + error = ENXIO; + goto fail; + } sc->busdev = gpiobus_attach_bus(dev); if (sc->busdev == NULL) { - qoriq_gpio_detach(dev); - return (ENOMEM); + error = ENXIO; + goto fail; } /* * Enable the GPIO Input Buffer for all GPIOs. @@ -419,7 +714,13 @@ qoriq_gpio_attach(device_t dev) OF_device_register_xref(OF_xref_from_node(ofw_bus_get_node(dev)), dev); + bus_write_4(sc->sc_mem, GPIO_GPIER, 0xffffffff); + bus_write_4(sc->sc_mem, GPIO_GPIMR, 0); + return (0); +fail: + qoriq_gpio_detach(dev); + return (error); } static int @@ -435,6 +736,13 @@ qoriq_gpio_detach(device_t dev) rman_get_rid(sc->sc_mem), sc->sc_mem); } + if (sc->intr_cookie != NULL) + bus_teardown_intr(dev, sc->sc_intr, sc->intr_cookie); + + if (sc->sc_intr != NULL) + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(sc->sc_intr), sc->sc_intr); + GPIO_LOCK_DESTROY(sc); return (0); @@ -446,6 +754,11 @@ static device_method_t qoriq_gpio_methods[] = { DEVMETHOD(device_attach, qoriq_gpio_attach), DEVMETHOD(device_detach, qoriq_gpio_detach), + /* Bus interface */ + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + /* GPIO protocol */ DEVMETHOD(gpio_get_bus, qoriq_gpio_get_bus), DEVMETHOD(gpio_pin_max, qoriq_gpio_pin_max), @@ -461,6 +774,16 @@ static device_method_t qoriq_gpio_methods[] = { DEVMETHOD(gpio_pin_access_32, qoriq_gpio_pin_access_32), DEVMETHOD(gpio_pin_config_32, qoriq_gpio_pin_config_32), + /* Interrupt controller */ + DEVMETHOD(pic_disable_intr, qoriq_gpio_disable_intr), + DEVMETHOD(pic_enable_intr, qoriq_gpio_enable_intr), + DEVMETHOD(pic_map_intr, qoriq_gpio_map_intr), + DEVMETHOD(pic_setup_intr, qoriq_gpio_setup_intr), + DEVMETHOD(pic_teardown_intr, qoriq_gpio_teardown_intr), + DEVMETHOD(pic_post_filter, qoriq_gpio_post_filter), + DEVMETHOD(pic_post_ithread, qoriq_gpio_post_ithread), + DEVMETHOD(pic_pre_ithread, qoriq_gpio_pre_ithread), + DEVMETHOD_END }; @@ -471,6 +794,9 @@ static driver_t qoriq_gpio_driver = { }; static devclass_t qoriq_gpio_devclass; -EARLY_DRIVER_MODULE(qoriq_gpio, simplebus, qoriq_gpio_driver, - qoriq_gpio_devclass, NULL, NULL, - BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); +/* + * This needs to be loaded after interrupts are available and + * before consumers need it. + */ +EARLY_DRIVER_MODULE(qoriq_gpio, simplebus, qoriq_gpio_driver, qoriq_gpio_devclass, + NULL, NULL, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); From nobody Fri Oct 29 08:31:43 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4E17D18268BE; Fri, 29 Oct 2021 08:31:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgbJ13Swyz4SSM; Fri, 29 Oct 2021 08:31:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E63D614195; Fri, 29 Oct 2021 08:31:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T8Vhuo073849; Fri, 29 Oct 2021 08:31:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T8Vh5A073848; Fri, 29 Oct 2021 08:31:43 GMT (envelope-from git) Date: Fri, 29 Oct 2021 08:31:43 GMT Message-Id: <202110290831.19T8Vh5A073848@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: d88aecce69c8 - main - felix: Add a sysctl to control timer routine frequency List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d88aecce69c82e9312c4e5e4e9eab4c56284925f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=d88aecce69c82e9312c4e5e4e9eab4c56284925f commit d88aecce69c82e9312c4e5e4e9eab4c56284925f Author: Kornel Duleba AuthorDate: 2021-10-25 13:18:27 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 08:08:26 +0000 felix: Add a sysctl to control timer routine frequency Driver polls status of all PHYs connected to the switch in a fixed interval. Add a sysctl that allows to control frequency of that. The value is expressed in ticks and defaults to "hz", or 1 second. Obtained from: Semihalf Sponsored by: Alstom Group --- sys/dev/etherswitch/felix/felix.c | 38 ++++++++++++++++++++++++++++++++++- sys/dev/etherswitch/felix/felix_var.h | 2 ++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/sys/dev/etherswitch/felix/felix.c b/sys/dev/etherswitch/felix/felix.c index f57a6e1daa0c..a80f4f8d15ae 100644 --- a/sys/dev/etherswitch/felix/felix.c +++ b/sys/dev/etherswitch/felix/felix.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -325,6 +326,33 @@ felix_setup(felix_softc_t sc) return (0); } +static int +felix_timer_rate(SYSCTL_HANDLER_ARGS) +{ + felix_softc_t sc; + int error, value, old; + + sc = arg1; + + old = value = sc->timer_ticks; + error = sysctl_handle_int(oidp, &value, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + + if (value < 0) + return (EINVAL); + + if (value == old) + return (0); + + FELIX_LOCK(sc); + sc->timer_ticks = value; + callout_reset(&sc->tick_callout, sc->timer_ticks, felix_tick, sc); + FELIX_UNLOCK(sc); + + return (0); +} + static int felix_attach(device_t dev) { @@ -426,6 +454,13 @@ felix_attach(device_t dev) if (error != 0) goto out_fail; + sc->timer_ticks = hz; /* Default to 1s. */ + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "timer_ticks", CTLTYPE_INT | CTLFLAG_RW, + sc, 0, felix_timer_rate, "I", + "Number of ticks between timer invocations"); + /* The tick routine has to be called with the lock held. */ FELIX_LOCK(sc); felix_tick(sc); @@ -922,7 +957,8 @@ felix_tick(void *arg) MPASS(mii != NULL); mii_tick(mii); } - callout_reset(&sc->tick_callout, hz, felix_tick, sc); + if (sc->timer_ticks != 0) + callout_reset(&sc->tick_callout, sc->timer_ticks, felix_tick, sc); } static int diff --git a/sys/dev/etherswitch/felix/felix_var.h b/sys/dev/etherswitch/felix/felix_var.h index d891419793b7..15f43ec6a3d2 100644 --- a/sys/dev/etherswitch/felix/felix_var.h +++ b/sys/dev/etherswitch/felix/felix_var.h @@ -102,6 +102,8 @@ typedef struct felix_softc { int vlan_mode; int vlans[FELIX_NUM_VLANS]; + + uint32_t timer_ticks; } *felix_softc_t; #endif From nobody Fri Oct 29 09:00:10 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 07BC01832796; Fri, 29 Oct 2021 09:00:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgbwp6vBzz4d0W; Fri, 29 Oct 2021 09:00:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CD21014369; Fri, 29 Oct 2021 09:00:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T90A8b005686; Fri, 29 Oct 2021 09:00:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T90AlT005679; Fri, 29 Oct 2021 09:00:10 GMT (envelope-from git) Date: Fri, 29 Oct 2021 09:00:10 GMT Message-Id: <202110290900.19T90AlT005679@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: f5639a06b80c - main - mvneta: fix encap property List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f5639a06b80caf363a28f9b99e0ee697bb32b555 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=f5639a06b80caf363a28f9b99e0ee697bb32b555 commit f5639a06b80caf363a28f9b99e0ee697bb32b555 Author: Wojciech Macek AuthorDate: 2021-10-29 08:56:57 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 08:56:57 +0000 mvneta: fix encap property Fix MVNETA encap property. --- sys/dev/neta/if_mvneta_fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/neta/if_mvneta_fdt.c b/sys/dev/neta/if_mvneta_fdt.c index 85948adb69d4..102ee1f1c884 100644 --- a/sys/dev/neta/if_mvneta_fdt.c +++ b/sys/dev/neta/if_mvneta_fdt.c @@ -133,7 +133,7 @@ mvneta_fdt_attach(device_t dev) } if (ofw_bus_has_prop(dev, "tx-csum-limit")) { - err = OF_getprop(ofw_bus_get_node(dev), "tx-csum-limit", + err = OF_getencprop(ofw_bus_get_node(dev), "tx-csum-limit", &tx_csum_limit, sizeof(tx_csum_limit)); if (err <= 0) { device_printf(dev, From nobody Fri Oct 29 09:05:13 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EDE1F1835318; Fri, 29 Oct 2021 09:05:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgc2d6Pl7z4fgD; Fri, 29 Oct 2021 09:05:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BBF8414889; Fri, 29 Oct 2021 09:05:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19T95D9p015616; Fri, 29 Oct 2021 09:05:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19T95Dhi015615; Fri, 29 Oct 2021 09:05:13 GMT (envelope-from git) Date: Fri, 29 Oct 2021 09:05:13 GMT Message-Id: <202110290905.19T95Dhi015615@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 97a74bbe38eb - main - stress2: Added a regression test List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 97a74bbe38ebdf682e583d8b92f49e137fa2b7c4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=97a74bbe38ebdf682e583d8b92f49e137fa2b7c4 commit 97a74bbe38ebdf682e583d8b92f49e137fa2b7c4 Author: Peter Holm AuthorDate: 2021-10-29 09:04:49 +0000 Commit: Peter Holm CommitDate: 2021-10-29 09:04:49 +0000 stress2: Added a regression test --- tools/test/stress2/misc/execpath.sh | 105 ++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tools/test/stress2/misc/execpath.sh b/tools/test/stress2/misc/execpath.sh new file mode 100755 index 000000000000..4323e3b7d505 --- /dev/null +++ b/tools/test/stress2/misc/execpath.sh @@ -0,0 +1,105 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# Bug 248184 - readlink("/proc/curproc/file") returns arbitrary correct name for programs with more than one link (name) +# Test scenario for D32611 "exec: provide right hardlink name in AT_EXECPATH" + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +dir=/tmp +odir=`pwd` +cd $dir +sed '1,/^EOF/d' < $odir/$0 > $dir/execpath.c +mycc -o execpath -Wall -Wextra -O0 -g execpath.c || exit 1 +rm -f execpath.c +cd $odir + +set -e +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 2g -u $mdstart +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint +set +e + +cd $mntpoint +mkdir d1 d2 +cp /bin/sleep . +ln sleep d1/sleep +ln sleep d2/sleep +s=0 +for p in $mntpoint/sleep $mntpoint/d1/sleep $mntpoint/d2/sleep; do + (cd `dirname $p`; ./`basename $p` 10) & + /bin/sleep .2 + path=`procstat binary $! | awk "/$!/ {print \\$NF}"` + kill $! + wait + [ "$path" != "$p" ] && { s=1; echo "fail path=$path : prog=$p"; } +done +mv /tmp/execpath d1 +ln d1/execpath d2/execpath + +r=`./d1/execpath` +echo $r | grep -q "/d1/" || { s=1; echo "fail: $r. Expected d1 @ 1"; } +r=`./d2/execpath` +echo $r | grep -q "/d2/" || { s=1; echo "fail: $r. Expected d2 @ 2"; } +r=`(cd d1; ./execpath)` +echo $r | grep -q "/d1/" || { s=1; echo "fail: $r. Expected d1 @ 3"; } +r=`(cd d2; ./execpath)` +echo $r | grep -q "/d2/" || { s=1; echo "fail: $r. Expected d2 @ 4"; } + +cd $odir + +for i in `jot 6`; do + mount | grep -q "on $mntpoint " || break + umount $mntpoint && break || sleep 10 + [ $i -eq 6 ] && + { echo FATAL; fstat -mf $mntpoint; exit 1; } +done +mdconfig -d -u $mdstart +exit $s + +EOF +/* Test scenario by Tobias Kortkamp */ + +#include +#include +#include + +int +main(void) +{ + char pathname[PATH_MAX]; + + elf_aux_info(AT_EXECPATH, pathname, PATH_MAX); + puts(pathname); + return 0; +} From nobody Fri Oct 29 10:06:18 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 494E8182D199; Fri, 29 Oct 2021 10:06:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgdP71WZ0z4tvv; Fri, 29 Oct 2021 10:06:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 14B3A15338; Fri, 29 Oct 2021 10:06:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TA6IrD096797; Fri, 29 Oct 2021 10:06:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TA6ILG096796; Fri, 29 Oct 2021 10:06:18 GMT (envelope-from git) Date: Fri, 29 Oct 2021 10:06:18 GMT Message-Id: <202110291006.19TA6ILG096796@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 680920237bdd - main - Revert "qoriq_gpio: Implement interrupt controller functionality" List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 680920237bddaa38da55d2a67e8daf080a38b1dc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=680920237bddaa38da55d2a67e8daf080a38b1dc commit 680920237bddaa38da55d2a67e8daf080a38b1dc Author: Wojciech Macek AuthorDate: 2021-10-29 10:05:55 +0000 Commit: Wojciech Macek CommitDate: 2021-10-29 10:05:55 +0000 Revert "qoriq_gpio: Implement interrupt controller functionality" This reverts commit 027a58aab2cee5589a3a639afb77ecbb607f8fee. --- sys/dev/gpio/qoriq_gpio.c | 352 ++-------------------------------------------- 1 file changed, 13 insertions(+), 339 deletions(-) diff --git a/sys/dev/gpio/qoriq_gpio.c b/sys/dev/gpio/qoriq_gpio.c index 0a78adbecb0f..dc4813e07b8e 100644 --- a/sys/dev/gpio/qoriq_gpio.c +++ b/sys/dev/gpio/qoriq_gpio.c @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -50,25 +49,19 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #include "gpio_if.h" -#include "pic_if.h" -#define BIT(x) (1 << (x)) #define MAXPIN (31) #define VALID_PIN(u) ((u) >= 0 && (u) <= MAXPIN) #define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \ - GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL | \ - GPIO_INTR_EDGE_FALLING | GPIO_INTR_EDGE_BOTH | \ - GPIO_PIN_PULLUP) + GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL) -#define GPIO_LOCK(sc) mtx_lock_spin(&(sc)->sc_mtx) -#define GPIO_UNLOCK(sc) mtx_unlock_spin(&(sc)->sc_mtx) +#define GPIO_LOCK(sc) mtx_lock(&(sc)->sc_mtx) +#define GPIO_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) #define GPIO_LOCK_INIT(sc) \ mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->dev), \ - "gpio", MTX_SPIN) + "gpio", MTX_DEF) #define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); #define GPIO_GPDIR 0x0 @@ -79,21 +72,12 @@ __FBSDID("$FreeBSD$"); #define GPIO_GPICR 0x14 #define GPIO_GPIBE 0x18 -struct qoriq_gpio_irqsrc { - struct intr_irqsrc isrc; - int pin; -}; - struct qoriq_gpio_softc { device_t dev; device_t busdev; struct mtx sc_mtx; struct resource *sc_mem; /* Memory resource */ - struct resource *sc_intr; - void *intr_cookie; struct gpio_pin sc_pins[MAXPIN + 1]; - struct qoriq_gpio_irqsrc sc_isrcs[MAXPIN + 1]; - struct intr_map_data_gpio gdata; }; static device_t @@ -276,254 +260,6 @@ qoriq_gpio_pin_toggle(device_t dev, uint32_t pin) return (0); } -static void -qoriq_gpio_set_intr(struct qoriq_gpio_softc *sc, int pin, bool enable) -{ - uint32_t reg; - - reg = bus_read_4(sc->sc_mem, GPIO_GPIMR); - if (enable) - reg |= BIT(31 - pin); - else - reg &= ~BIT(31 - pin); - bus_write_4(sc->sc_mem, GPIO_GPIMR, reg); -} - -static void -qoriq_gpio_ack_intr(struct qoriq_gpio_softc *sc, int pin) -{ - uint32_t reg; - - reg = BIT(31 - pin); - bus_write_4(sc->sc_mem, GPIO_GPIER, reg); -} - -static int -qoriq_gpio_intr(void *arg) -{ - struct qoriq_gpio_softc *sc; - struct trapframe *tf; - uint32_t status; - int pin; - - sc = (struct qoriq_gpio_softc *)arg; - tf = curthread->td_intr_frame; - - status = bus_read_4(sc->sc_mem, GPIO_GPIER); - status &= bus_read_4(sc->sc_mem, GPIO_GPIMR); - while (status != 0) { - pin = ffs(status) - 1; - status &= ~BIT(pin); - pin = 31 - pin; - - if (intr_isrc_dispatch(&sc->sc_isrcs[pin].isrc, tf) != 0) { - GPIO_LOCK(sc); - qoriq_gpio_set_intr(sc, pin, false); - qoriq_gpio_ack_intr(sc, pin); - GPIO_UNLOCK(sc); - device_printf(sc->dev, - "Masking spurious pin interrupt %d\n", - pin); - } - } - - return (FILTER_HANDLED); -} - -static void -qoriq_gpio_disable_intr(device_t dev, struct intr_irqsrc *isrc) -{ - struct qoriq_gpio_softc *sc; - struct qoriq_gpio_irqsrc *qisrc; - - sc = device_get_softc(dev); - qisrc = (struct qoriq_gpio_irqsrc *)isrc; - - GPIO_LOCK(sc); - qoriq_gpio_set_intr(sc, qisrc->pin, false); - GPIO_UNLOCK(sc); -} - -static void -qoriq_gpio_enable_intr(device_t dev, struct intr_irqsrc *isrc) -{ - struct qoriq_gpio_softc *sc; - struct qoriq_gpio_irqsrc *qisrc; - - sc = device_get_softc(dev); - qisrc = (struct qoriq_gpio_irqsrc *)isrc; - - GPIO_LOCK(sc); - qoriq_gpio_set_intr(sc, qisrc->pin, true); - GPIO_UNLOCK(sc); -} - -static struct intr_map_data_gpio* -qoriq_gpio_convert_map_data(struct qoriq_gpio_softc *sc, struct intr_map_data *data) -{ - struct intr_map_data_gpio *gdata; - struct intr_map_data_fdt *daf; - - switch (data->type) { - case INTR_MAP_DATA_GPIO: - gdata = (struct intr_map_data_gpio *)data; - break; - case INTR_MAP_DATA_FDT: - daf = (struct intr_map_data_fdt *)data; - if (daf->ncells != 2) - return (NULL); - - gdata = &sc->gdata; - gdata->gpio_pin_num = daf->cells[0]; - switch (daf->cells[1]) { - case IRQ_TYPE_LEVEL_LOW: - gdata->gpio_intr_mode = GPIO_INTR_LEVEL_LOW; - break; - case IRQ_TYPE_LEVEL_HIGH: - gdata->gpio_intr_mode = GPIO_INTR_LEVEL_HIGH; - break; - case IRQ_TYPE_EDGE_RISING: - gdata->gpio_intr_mode = GPIO_INTR_EDGE_RISING; - break; - case IRQ_TYPE_EDGE_FALLING: - gdata->gpio_intr_mode = GPIO_INTR_EDGE_FALLING; - break; - case IRQ_TYPE_EDGE_BOTH: - gdata->gpio_intr_mode = GPIO_INTR_EDGE_BOTH; - break; - default: - return (NULL); - } - break; - default: - return (NULL); - } - - return (gdata); -} - - -static int -qoriq_gpio_map_intr(device_t dev, struct intr_map_data *data, - struct intr_irqsrc **isrcp) -{ - struct qoriq_gpio_softc *sc; - struct intr_map_data_gpio *gdata; - int pin; - - sc = device_get_softc(dev); - - gdata = qoriq_gpio_convert_map_data(sc, data); - if (gdata == NULL) - return (EINVAL); - - pin = gdata->gpio_pin_num; - if (pin > MAXPIN) - return (EINVAL); - - *isrcp = &sc->sc_isrcs[pin].isrc; - return (0); -} - -static int -qoriq_gpio_setup_intr(device_t dev, struct intr_irqsrc *isrc, - struct resource *res, struct intr_map_data *data) -{ - struct qoriq_gpio_softc *sc; - struct intr_map_data_gpio *gdata; - struct qoriq_gpio_irqsrc *qisrc; - bool falling; - uint32_t reg; - - sc = device_get_softc(dev); - qisrc = (struct qoriq_gpio_irqsrc *)isrc; - - gdata = qoriq_gpio_convert_map_data(sc, data); - if (gdata == NULL) - return (EINVAL); - - if (gdata->gpio_intr_mode & GPIO_INTR_EDGE_BOTH) - falling = false; - else if (gdata->gpio_intr_mode & GPIO_INTR_EDGE_FALLING) - falling = true; - else - return (EOPNOTSUPP); - - GPIO_LOCK(sc); - reg = bus_read_4(sc->sc_mem, GPIO_GPICR); - if (falling) - reg |= BIT(31 - qisrc->pin); - else - reg &= ~BIT(31 - qisrc->pin); - bus_write_4(sc->sc_mem, GPIO_GPICR, reg); - GPIO_UNLOCK(sc); - - return (0); -} - -static int -qoriq_gpio_teardown_intr(device_t dev, struct intr_irqsrc *isrc, - struct resource *res, struct intr_map_data *data) -{ - struct qoriq_gpio_softc *sc; - struct qoriq_gpio_irqsrc *qisrc; - - sc = device_get_softc(dev); - qisrc = (struct qoriq_gpio_irqsrc *)isrc; - - if (isrc->isrc_handlers > 0) - return (0); - - GPIO_LOCK(sc); - qoriq_gpio_set_intr(sc, qisrc->pin, false); - GPIO_UNLOCK(sc); - return (0); -} - -static void -qoriq_gpio_post_filter(device_t dev, struct intr_irqsrc *isrc) -{ - struct qoriq_gpio_softc *sc; - struct qoriq_gpio_irqsrc *qisrc; - - sc = device_get_softc(dev); - qisrc = (struct qoriq_gpio_irqsrc *)isrc; - - GPIO_LOCK(sc); - qoriq_gpio_ack_intr(sc, qisrc->pin); - GPIO_UNLOCK(sc); -} - - -static void -qoriq_gpio_post_ithread(device_t dev, struct intr_irqsrc *isrc) -{ - struct qoriq_gpio_softc *sc; - struct qoriq_gpio_irqsrc *qisrc; - - sc = device_get_softc(dev); - qisrc = (struct qoriq_gpio_irqsrc *)isrc; - - GPIO_LOCK(sc); - qoriq_gpio_ack_intr(sc, qisrc->pin); - qoriq_gpio_set_intr(sc, qisrc->pin, true); - GPIO_UNLOCK(sc); -} - -static void -qoriq_gpio_pre_ithread(device_t dev, struct intr_irqsrc *isrc) -{ - struct qoriq_gpio_softc *sc; - struct qoriq_gpio_irqsrc *qisrc; - - sc = device_get_softc(dev); - qisrc = (struct qoriq_gpio_irqsrc *)isrc; - - GPIO_LOCK(sc); - qoriq_gpio_set_intr(sc, qisrc->pin, false); - GPIO_UNLOCK(sc); -} - static struct ofw_compat_data gpio_matches[] = { {"fsl,qoriq-gpio", 1}, {"fsl,pq3-gpio", 1}, @@ -649,9 +385,7 @@ static int qoriq_gpio_attach(device_t dev) { struct qoriq_gpio_softc *sc = device_get_softc(dev); - int i, rid, error; - const char *name; - intptr_t xref; + int i, rid; sc->dev = dev; @@ -663,46 +397,17 @@ qoriq_gpio_attach(device_t dev) SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->sc_mem == NULL) { device_printf(dev, "Can't allocate memory for device output port"); - error = ENOMEM; - goto fail; - } - - rid = 0; - sc->sc_intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE | RF_SHAREABLE); - if (sc->sc_intr == NULL) { - device_printf(dev, "Can't allocate interrupt resource.\n"); - error = ENOMEM; - goto fail; - } - - error = bus_setup_intr(dev, sc->sc_intr, INTR_TYPE_MISC | INTR_MPSAFE, - qoriq_gpio_intr, NULL, sc, &sc->intr_cookie); - if (error != 0) { - device_printf(dev, "Failed to setup interrupt.\n"); - goto fail; + qoriq_gpio_detach(dev); + return (ENOMEM); } - name = device_get_nameunit(dev); - for (i = 0; i <= MAXPIN; i++) { + for (i = 0; i <= MAXPIN; i++) sc->sc_pins[i].gp_caps = DEFAULT_CAPS; - sc->sc_isrcs[i].pin = i; - error = intr_isrc_register(&sc->sc_isrcs[i].isrc, - dev, 0, "%s,%u", name, i); - if (error != 0) - goto fail; - } - - xref = OF_xref_from_node(ofw_bus_get_node(dev)); - if (intr_pic_register(dev, xref) == NULL) { - error = ENXIO; - goto fail; - } sc->busdev = gpiobus_attach_bus(dev); if (sc->busdev == NULL) { - error = ENXIO; - goto fail; + qoriq_gpio_detach(dev); + return (ENOMEM); } /* * Enable the GPIO Input Buffer for all GPIOs. @@ -714,13 +419,7 @@ qoriq_gpio_attach(device_t dev) OF_device_register_xref(OF_xref_from_node(ofw_bus_get_node(dev)), dev); - bus_write_4(sc->sc_mem, GPIO_GPIER, 0xffffffff); - bus_write_4(sc->sc_mem, GPIO_GPIMR, 0); - return (0); -fail: - qoriq_gpio_detach(dev); - return (error); } static int @@ -736,13 +435,6 @@ qoriq_gpio_detach(device_t dev) rman_get_rid(sc->sc_mem), sc->sc_mem); } - if (sc->intr_cookie != NULL) - bus_teardown_intr(dev, sc->sc_intr, sc->intr_cookie); - - if (sc->sc_intr != NULL) - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->sc_intr), sc->sc_intr); - GPIO_LOCK_DESTROY(sc); return (0); @@ -754,11 +446,6 @@ static device_method_t qoriq_gpio_methods[] = { DEVMETHOD(device_attach, qoriq_gpio_attach), DEVMETHOD(device_detach, qoriq_gpio_detach), - /* Bus interface */ - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - /* GPIO protocol */ DEVMETHOD(gpio_get_bus, qoriq_gpio_get_bus), DEVMETHOD(gpio_pin_max, qoriq_gpio_pin_max), @@ -774,16 +461,6 @@ static device_method_t qoriq_gpio_methods[] = { DEVMETHOD(gpio_pin_access_32, qoriq_gpio_pin_access_32), DEVMETHOD(gpio_pin_config_32, qoriq_gpio_pin_config_32), - /* Interrupt controller */ - DEVMETHOD(pic_disable_intr, qoriq_gpio_disable_intr), - DEVMETHOD(pic_enable_intr, qoriq_gpio_enable_intr), - DEVMETHOD(pic_map_intr, qoriq_gpio_map_intr), - DEVMETHOD(pic_setup_intr, qoriq_gpio_setup_intr), - DEVMETHOD(pic_teardown_intr, qoriq_gpio_teardown_intr), - DEVMETHOD(pic_post_filter, qoriq_gpio_post_filter), - DEVMETHOD(pic_post_ithread, qoriq_gpio_post_ithread), - DEVMETHOD(pic_pre_ithread, qoriq_gpio_pre_ithread), - DEVMETHOD_END }; @@ -794,9 +471,6 @@ static driver_t qoriq_gpio_driver = { }; static devclass_t qoriq_gpio_devclass; -/* - * This needs to be loaded after interrupts are available and - * before consumers need it. - */ -EARLY_DRIVER_MODULE(qoriq_gpio, simplebus, qoriq_gpio_driver, qoriq_gpio_devclass, - NULL, NULL, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); +EARLY_DRIVER_MODULE(qoriq_gpio, simplebus, qoriq_gpio_driver, + qoriq_gpio_devclass, NULL, NULL, + BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); From nobody Fri Oct 29 13:56:15 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 355ED18203E6; Fri, 29 Oct 2021 13:56:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgkVS0btMz4tTh; Fri, 29 Oct 2021 13:56:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E4ACE1837D; Fri, 29 Oct 2021 13:56:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TDuFtd001325; Fri, 29 Oct 2021 13:56:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TDuFgx001324; Fri, 29 Oct 2021 13:56:15 GMT (envelope-from git) Date: Fri, 29 Oct 2021 13:56:15 GMT Message-Id: <202110291356.19TDuFgx001324@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 6547153e4618 - main - linux: Fix ptrace panic with ERESTART List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6547153e4618c3b57e5f76062de006a04ecbd64b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=6547153e4618c3b57e5f76062de006a04ecbd64b commit 6547153e4618c3b57e5f76062de006a04ecbd64b Author: Edward Tomasz Napierala AuthorDate: 2021-10-29 13:21:21 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-10-29 13:55:59 +0000 linux: Fix ptrace panic with ERESTART Translate ERESTART into Linux "internal" errno ERESTARTSYS. This fixes the erestartsys.gen.test from strace(1). Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32623 --- sys/amd64/linux/linux_ptrace.c | 4 ++++ sys/compat/linux/linux_errno.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index b7d0838fb054..d16e875ba5cf 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -639,6 +640,9 @@ linux_ptrace_get_syscall_info(struct thread *td, pid_t pid, * the ptracing process fall back to another method. */ si.op = LINUX_PTRACE_SYSCALL_INFO_NONE; + } else if (sr.sr_error == ERESTART) { + si.exit.rval = -LINUX_ERESTARTSYS; + si.exit.is_error = 1; } else { si.exit.rval = bsd_to_linux_errno(sr.sr_error); si.exit.is_error = 1; diff --git a/sys/compat/linux/linux_errno.h b/sys/compat/linux/linux_errno.h index 46e6f46e202b..0eae6684ce44 100644 --- a/sys/compat/linux/linux_errno.h +++ b/sys/compat/linux/linux_errno.h @@ -182,4 +182,10 @@ #define LINUX_ELAST LINUX_EHWPOISON +/* + * This is a special "internal" errno that must never be returned + * to a Linux process, but might be observed via ptrace(2). + */ +#define LINUX_ERESTARTSYS 512 + #endif /* _LINUX_ERRNO_H_ */ From nobody Fri Oct 29 14:06:02 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BF96718238E0; Fri, 29 Oct 2021 14:06:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgkjk52J4z4wYD; Fri, 29 Oct 2021 14:06:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8D10C180E9; Fri, 29 Oct 2021 14:06:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TE628a015950; Fri, 29 Oct 2021 14:06:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TE622d015949; Fri, 29 Oct 2021 14:06:02 GMT (envelope-from git) Date: Fri, 29 Oct 2021 14:06:02 GMT Message-Id: <202110291406.19TE622d015949@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: ad09e2c8cfbc - main - Don't build sanitizer runtimes under WITHOUT_CXX List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ad09e2c8cfbc2cf6f2b8826c121d6de8b3bfe96d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ad09e2c8cfbc2cf6f2b8826c121d6de8b3bfe96d commit ad09e2c8cfbc2cf6f2b8826c121d6de8b3bfe96d Author: Ed Maste AuthorDate: 2021-10-29 00:49:12 +0000 Commit: Ed Maste CommitDate: 2021-10-29 14:05:49 +0000 Don't build sanitizer runtimes under WITHOUT_CXX In the past we built the sanitizer runtimes when building Clang (and using Clang as the compiler) but 7676b388adbc changed this to be conditional only on using Clang, to make the runtimes available for external Clang. They fail to build when WITHOUT_CXX is set though, so add MK_CXX as part of the condition. Reported by: Michael Dexter, Build Option Survey Reviewed by: imp, jrtc27 Fixes: 7676b388adbc ("Always build the sanitizer runtimes...") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32731 --- lib/Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 3f30917173af..93761cc06b21 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -176,10 +176,9 @@ SUBDIR.${MK_KERBEROS_SUPPORT}+= libcom_err SUBDIR.${MK_LDNS}+= libldns SUBDIR.${MK_STATS}+= libstats -# The libraries under libclang_rt can only be built by clang, and only make -# sense to build when clang is enabled at all. Furthermore, they can only be -# built for certain architectures. -.if ${COMPILER_TYPE} == "clang" && \ +# The libraries under libclang_rt can only be built by clang and when we enable +# C++ support. Furthermore, they can only be built for certain architectures. +.if ${COMPILER_TYPE} == "clang" && ${MK_CXX} != "no" && \ (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386" || \ ${MACHINE_CPUARCH} == "powerpc") From nobody Fri Oct 29 14:10:32 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0D5701826675; Fri, 29 Oct 2021 14:10:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgkpw6mW8z4xvN; Fri, 29 Oct 2021 14:10:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C8B641855F; Fri, 29 Oct 2021 14:10:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TEAWFa024581; Fri, 29 Oct 2021 14:10:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TEAWfa024580; Fri, 29 Oct 2021 14:10:32 GMT (envelope-from git) Date: Fri, 29 Oct 2021 14:10:32 GMT Message-Id: <202110291410.19TEAWfa024580@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 0e1c864898c1 - main - src.opts.mk: Add WITHOUT_CXX dependencies List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0e1c864898c1803835b1be0d59342ca761051db8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=0e1c864898c1803835b1be0d59342ca761051db8 commit 0e1c864898c1803835b1be0d59342ca761051db8 Author: Ed Maste AuthorDate: 2021-10-29 01:43:33 +0000 Commit: Ed Maste CommitDate: 2021-10-29 14:06:27 +0000 src.opts.mk: Add WITHOUT_CXX dependencies OFED, OPENMP, and PMC depend on C++ support. Force them off when building WITHOUT_CXX. Reported by: Michael Dexter, Build Option Survey Reviewed by: imp, jrtc27 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32730 --- share/mk/src.opts.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 3d8f7b071904..4b9a9953f8ee 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -393,6 +393,9 @@ MK_KERBEROS_SUPPORT:= no .if ${MK_CXX} == "no" MK_CLANG:= no MK_GOOGLETEST:= no +MK_OFED:= no +MK_OPENMP:= no +MK_PMC:= no MK_TESTS:= no .endif From nobody Fri Oct 29 14:10:33 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 845F518267CB; Fri, 29 Oct 2021 14:10:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgkpy1RD0z4y4j; Fri, 29 Oct 2021 14:10:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0045E18637; Fri, 29 Oct 2021 14:10:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TEAX53024605; Fri, 29 Oct 2021 14:10:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TEAXDh024604; Fri, 29 Oct 2021 14:10:33 GMT (envelope-from git) Date: Fri, 29 Oct 2021 14:10:33 GMT Message-Id: <202110291410.19TEAXDh024604@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 6ce99625ca7a - main - Do not build libatf-c++ when WITHOUT_CXX List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6ce99625ca7acecaa64723f0440007eb3f60f53d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=6ce99625ca7acecaa64723f0440007eb3f60f53d commit 6ce99625ca7acecaa64723f0440007eb3f60f53d Author: Ed Maste AuthorDate: 2021-10-29 03:01:21 +0000 Commit: Ed Maste CommitDate: 2021-10-29 14:08:24 +0000 Do not build libatf-c++ when WITHOUT_CXX libatf-c++ requires C++ support. From jrtc27: bit slightly odd this isn't gated by MK_TESTS (which itself depends on MK_CXX), but this makes sense given the current behaviour. Reported by: Michael Dexter, Build Option Survey Reviewed by: imp, jrtc27 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32732 --- lib/atf/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/atf/Makefile b/lib/atf/Makefile index baadf535b424..05c7973fdc02 100644 --- a/lib/atf/Makefile +++ b/lib/atf/Makefile @@ -27,8 +27,8 @@ .include -SUBDIR= libatf-c \ - libatf-c++ \ +SUBDIR= libatf-c +SUBDIR.${MK_CXX}+= libatf-c++ SUBDIR.${MK_TESTS}+= tests From nobody Fri Oct 29 14:28:19 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id ED201182CAE5; Fri, 29 Oct 2021 14:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HglCR6SHdz53V5; Fri, 29 Oct 2021 14:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB45018A2A; Fri, 29 Oct 2021 14:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TESJCR042184; Fri, 29 Oct 2021 14:28:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TESJgh042183; Fri, 29 Oct 2021 14:28:19 GMT (envelope-from git) Date: Fri, 29 Oct 2021 14:28:19 GMT Message-Id: <202110291428.19TESJgh042183@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: c8c93b151678 - main - linux: Also translate the signal if the code is CLD_KILLED List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c8c93b151678b57d86cd50509c9cbb863bbe9e57 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=c8c93b151678b57d86cd50509c9cbb863bbe9e57 commit c8c93b151678b57d86cd50509c9cbb863bbe9e57 Author: Edward Tomasz Napierala AuthorDate: 2021-10-29 13:56:43 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-10-29 14:28:00 +0000 linux: Also translate the signal if the code is CLD_KILLED This fixes ./waitid.gen.test from the strace(1) test suite. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32617 --- sys/compat/linux/linux_signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index 0c71d510e0f2..786bcab2bf5e 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -688,7 +688,7 @@ siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, l_int sig) lsi->lsi_pid = si->si_pid; lsi->lsi_uid = si->si_uid; - if (si->si_code == CLD_STOPPED) + if (si->si_code == CLD_STOPPED || si->si_code == CLD_KILLED) lsi->lsi_status = bsd_to_linux_signal(si->si_status); else if (si->si_code == CLD_CONTINUED) lsi->lsi_status = bsd_to_linux_signal(SIGCONT); From nobody Fri Oct 29 15:04:33 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CE689183B8F2; Fri, 29 Oct 2021 15:04:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgm1F5Wgzz3FN6; Fri, 29 Oct 2021 15:04:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 99EE419516; Fri, 29 Oct 2021 15:04:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TF4XEE095347; Fri, 29 Oct 2021 15:04:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TF4XpF095346; Fri, 29 Oct 2021 15:04:33 GMT (envelope-from git) Date: Fri, 29 Oct 2021 15:04:33 GMT Message-Id: <202110291504.19TF4XpF095346@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: f939dccfd770 - main - linux: Make PTRACE_GETREGSET return proper buffer size List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f939dccfd770df2f9070cd30aa52105b7afe1bde Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=f939dccfd770df2f9070cd30aa52105b7afe1bde commit f939dccfd770df2f9070cd30aa52105b7afe1bde Author: Edward Tomasz Napierala AuthorDate: 2021-10-29 14:28:56 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-10-29 14:31:33 +0000 linux: Make PTRACE_GETREGSET return proper buffer size This fixes Chrome warning: [1022/152319.328632:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68 Reviewed By: emaste Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32616 --- sys/amd64/linux/linux_ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index d16e875ba5cf..275450d63b2d 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -540,7 +540,7 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) return (error); } - iov.iov_len -= len; + iov.iov_len = len; error = copyout(&iov, (void *)data, sizeof(iov)); if (error != 0) { linux_msg(td, "iov copyout error %d", error); From nobody Fri Oct 29 16:34:40 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1E08718371BB; Fri, 29 Oct 2021 16:34:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgp1F0LfQz3tXX; Fri, 29 Oct 2021 16:34:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DFDE51A74E; Fri, 29 Oct 2021 16:34:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TGYeLN015353; Fri, 29 Oct 2021 16:34:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TGYeDc015352; Fri, 29 Oct 2021 16:34:40 GMT (envelope-from git) Date: Fri, 29 Oct 2021 16:34:40 GMT Message-Id: <202110291634.19TGYeDc015352@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: ad0379660d0c - main - linux: make PTRACE_GETREGS return correct struct List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ad0379660d0c77aaf0ca6ec19472b7bb173c5794 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=ad0379660d0c77aaf0ca6ec19472b7bb173c5794 commit ad0379660d0c77aaf0ca6ec19472b7bb173c5794 Author: Edward Tomasz Napierala AuthorDate: 2021-10-29 15:18:13 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-10-29 15:18:28 +0000 linux: make PTRACE_GETREGS return correct struct Previously it returned a shorter struct. I can't find any modern software that uses it, but tests/ptrace from strace(1) repo complained. Differential Revision: https://reviews.freebsd.org/D32601 --- sys/amd64/linux/linux_ptrace.c | 62 ++++++++++++------------------------------ 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index 275450d63b2d..0f06f2aa9c5c 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -214,38 +214,6 @@ struct syscall_info { }; }; -/* - * Translate amd64 ptrace registers between Linux and FreeBSD formats. - * The translation is pretty straighforward, for all registers but - * orig_rax on Linux side and r_trapno and r_err in FreeBSD. - */ -static void -map_regs_to_linux(struct reg *b_reg, struct linux_pt_reg *l_reg) -{ - - l_reg->r15 = b_reg->r_r15; - l_reg->r14 = b_reg->r_r14; - l_reg->r13 = b_reg->r_r13; - l_reg->r12 = b_reg->r_r12; - l_reg->rbp = b_reg->r_rbp; - l_reg->rbx = b_reg->r_rbx; - l_reg->r11 = b_reg->r_r11; - l_reg->r10 = b_reg->r_r10; - l_reg->r9 = b_reg->r_r9; - l_reg->r8 = b_reg->r_r8; - l_reg->rax = b_reg->r_rax; - l_reg->rcx = b_reg->r_rcx; - l_reg->rdx = b_reg->r_rdx; - l_reg->rsi = b_reg->r_rsi; - l_reg->rdi = b_reg->r_rdi; - l_reg->orig_rax = b_reg->r_rax; - l_reg->rip = b_reg->r_rip; - l_reg->cs = b_reg->r_cs; - l_reg->eflags = b_reg->r_rflags; - l_reg->rsp = b_reg->r_rsp; - l_reg->ss = b_reg->r_ss; -} - static void map_regs_from_linux(struct reg *b_reg, struct linux_pt_reg *l_reg) { @@ -434,14 +402,21 @@ linux_ptrace_getregs(struct thread *td, pid_t pid, void *data) { struct ptrace_lwpinfo lwpinfo; struct reg b_reg; - struct linux_pt_reg l_reg; + struct linux_pt_regset l_regset; + struct pcb *pcb; int error; error = kern_ptrace(td, PT_GETREGS, pid, &b_reg, 0); if (error != 0) return (error); - map_regs_to_linux(&b_reg, &l_reg); + pcb = td->td_pcb; + if (td == curthread) + update_pcb_bases(pcb); + + bsd_to_linux_regset(&b_reg, &l_regset); + l_regset.fs_base = pcb->pcb_fsbase; + l_regset.gs_base = pcb->pcb_gsbase; error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { @@ -450,21 +425,20 @@ linux_ptrace_getregs(struct thread *td, pid_t pid, void *data) } if (lwpinfo.pl_flags & PL_FLAG_SCE) { /* - * The strace(1) utility depends on RAX being set to -ENOSYS - * on syscall entry; otherwise it loops printing those: - * - * [ Process PID=928 runs in 64 bit mode. ] - * [ Process PID=928 runs in x32 mode. ] + * Undo the mangling done in exception.S:fast_syscall_common(). */ - l_reg.rax = -38; /* -ENOSYS */ - + l_regset.r10 = l_regset.rcx; + } + if (lwpinfo.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)) { /* - * Undo the mangling done in exception.S:fast_syscall_common(). + * In Linux, the syscall number - passed to the syscall + * as rax - is preserved in orig_rax; rax gets overwritten + * with syscall return value. */ - l_reg.r10 = l_reg.rcx; + l_regset.orig_rax = lwpinfo.pl_syscall_code; } - error = copyout(&l_reg, (void *)data, sizeof(l_reg)); + error = copyout(&l_regset, (void *)data, sizeof(l_regset)); return (error); } From nobody Fri Oct 29 17:27:54 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 59ACA182F845; Fri, 29 Oct 2021 17:27:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HgqBg4Vhpz4gZK; Fri, 29 Oct 2021 17:27:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 338F11AEB5; Fri, 29 Oct 2021 17:27:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19THRt8J083487; Fri, 29 Oct 2021 17:27:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19THRsBj083486; Fri, 29 Oct 2021 17:27:54 GMT (envelope-from git) Date: Fri, 29 Oct 2021 17:27:54 GMT Message-Id: <202110291727.19THRsBj083486@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Houchard Subject: git: 74e9b5f29ad0 - main - Merge commit 'ce929fe84f9c453263af379f3b255ff8eca01d48' List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cognet X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 74e9b5f29ad0056bbe11a30c91dfa0705fa19cd5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cognet: URL: https://cgit.FreeBSD.org/src/commit/?id=74e9b5f29ad0056bbe11a30c91dfa0705fa19cd5 commit 74e9b5f29ad0056bbe11a30c91dfa0705fa19cd5 Merge: ad0379660d0c ce929fe84f9c Author: Olivier Houchard AuthorDate: 2021-10-29 17:18:03 +0000 Commit: Olivier Houchard CommitDate: 2021-10-29 17:18:03 +0000 Merge commit 'ce929fe84f9c453263af379f3b255ff8eca01d48' Import CK as of commit 2265c7846f4ce667f5216456afe2779b23c3e5f7. sys/contrib/ck/include/ck_backoff.h | 2 +- sys/contrib/ck/include/ck_cc.h | 2 + sys/contrib/ck/include/ck_ec.h | 945 ++++++++++++++++++++++++ sys/contrib/ck/include/ck_fifo.h | 2 +- sys/contrib/ck/include/ck_hs.h | 8 + sys/contrib/ck/include/ck_pr.h | 15 +- sys/contrib/ck/include/ck_queue.h | 20 +- sys/contrib/ck/include/ck_ring.h | 672 +++++++++++++---- sys/contrib/ck/include/gcc/aarch64/ck_pr.h | 12 +- sys/contrib/ck/include/gcc/aarch64/ck_pr_llsc.h | 106 +-- sys/contrib/ck/include/gcc/aarch64/ck_pr_lse.h | 37 +- sys/contrib/ck/include/gcc/ck_cc.h | 9 + sys/contrib/ck/include/gcc/x86/ck_pr.h | 109 +-- sys/contrib/ck/include/gcc/x86_64/ck_pr.h | 87 ++- sys/contrib/ck/include/spinlock/fas.h | 9 +- sys/contrib/ck/src/ck_ec.c | 425 +++++++++++ sys/contrib/ck/src/ck_ec_timeutil.h | 150 ++++ sys/contrib/ck/src/ck_hs.c | 7 +- sys/contrib/ck/src/ck_ht.c | 3 - 19 files changed, 2272 insertions(+), 348 deletions(-) diff --cc sys/contrib/ck/include/ck_ec.h index 000000000000,cd2a36813a79..cd2a36813a79 mode 000000,100644..100644 --- a/sys/contrib/ck/include/ck_ec.h +++ b/sys/contrib/ck/include/ck_ec.h diff --cc sys/contrib/ck/src/ck_ec.c index 000000000000,9b24e762947c..9b24e762947c mode 000000,100644..100644 --- a/sys/contrib/ck/src/ck_ec.c +++ b/sys/contrib/ck/src/ck_ec.c diff --cc sys/contrib/ck/src/ck_ec_timeutil.h index 000000000000,50cfb67bf4a4..50cfb67bf4a4 mode 000000,100644..100644 --- a/sys/contrib/ck/src/ck_ec_timeutil.h +++ b/sys/contrib/ck/src/ck_ec_timeutil.h From nobody Fri Oct 29 18:31:31 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4C6D61821A84; Fri, 29 Oct 2021 18:31:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgrc31l1Lz3Gms; Fri, 29 Oct 2021 18:31:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1BF571BDBE; Fri, 29 Oct 2021 18:31:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TIVVgq075299; Fri, 29 Oct 2021 18:31:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TIVVVx075290; Fri, 29 Oct 2021 18:31:31 GMT (envelope-from git) Date: Fri, 29 Oct 2021 18:31:31 GMT Message-Id: <202110291831.19TIVVVx075290@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e9bfb50d5e7a - main - sort: Fix random sort List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e9bfb50d5e7aa5d673a5a35318820320c4190d33 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e9bfb50d5e7aa5d673a5a35318820320c4190d33 commit e9bfb50d5e7aa5d673a5a35318820320c4190d33 Author: Mark Johnston AuthorDate: 2021-10-29 18:25:42 +0000 Commit: Mark Johnston CommitDate: 2021-10-29 18:29:50 +0000 sort: Fix random sort bwsrawdata() is supposed to return the string buffer. PR: 259451 Reported by: sigsys@gmail.com Fixes: d053fb22f6d3 ("usr.bin/sort: Avoid UBSan errors") MFC after: 3 days Sponsored by: The FreeBSD Foundation --- usr.bin/sort/bwstring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/sort/bwstring.c b/usr.bin/sort/bwstring.c index c31cb859cb37..2f2737e94314 100644 --- a/usr.bin/sort/bwstring.c +++ b/usr.bin/sort/bwstring.c @@ -152,7 +152,7 @@ bwsprintf(FILE *f, struct bwstring *bws, const char *prefix, const char *suffix) const void* bwsrawdata(const struct bwstring *bws) { - return (&(bws->wdata)); + return (bws->wdata.str); } size_t bwsrawlen(const struct bwstring *bws) From nobody Fri Oct 29 18:31:32 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 70CDB1821835; Fri, 29 Oct 2021 18:31:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgrc42V7rz3Gpr; Fri, 29 Oct 2021 18:31:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 35BAA1C157; Fri, 29 Oct 2021 18:31:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TIVWTH075461; Fri, 29 Oct 2021 18:31:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TIVWPe075460; Fri, 29 Oct 2021 18:31:32 GMT (envelope-from git) Date: Fri, 29 Oct 2021 18:31:32 GMT Message-Id: <202110291831.19TIVWPe075460@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 26f76aea2d27 - main - timecounter: Load the currently selected tc once in tc_windup() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 26f76aea2d276aacb69a1f9d78558d6107155aed Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=26f76aea2d276aacb69a1f9d78558d6107155aed commit 26f76aea2d276aacb69a1f9d78558d6107155aed Author: Mark Johnston AuthorDate: 2021-10-29 18:29:22 +0000 Commit: Mark Johnston CommitDate: 2021-10-29 18:30:15 +0000 timecounter: Load the currently selected tc once in tc_windup() Reported by: Sebastian Huber Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32729 --- sys/kern/kern_tc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index f7bd116dabe2..f760d8ab34e3 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1353,6 +1353,7 @@ static void tc_windup(struct bintime *new_boottimebin) { struct bintime bt; + struct timecounter *tc; struct timehands *th, *tho; u_int delta, ncount, ogen; int i; @@ -1381,9 +1382,10 @@ tc_windup(struct bintime *new_boottimebin) * changing timecounters, a counter value from the new timecounter. * Update the offset fields accordingly. */ + tc = atomic_load_ptr(&timecounter); delta = tc_delta(th); - if (th->th_counter != timecounter) - ncount = timecounter->tc_get_timecount(timecounter); + if (th->th_counter != tc) + ncount = tc->tc_get_timecount(tc); else ncount = 0; #ifdef FFCLOCK @@ -1447,17 +1449,17 @@ tc_windup(struct bintime *new_boottimebin) bintime2timespec(&bt, &th->th_nanotime); /* Now is a good time to change timecounters. */ - if (th->th_counter != timecounter) { + if (th->th_counter != tc) { #ifndef __arm__ - if ((timecounter->tc_flags & TC_FLAGS_C2STOP) != 0) + if ((tc->tc_flags & TC_FLAGS_C2STOP) != 0) cpu_disable_c2_sleep++; if ((th->th_counter->tc_flags & TC_FLAGS_C2STOP) != 0) cpu_disable_c2_sleep--; #endif - th->th_counter = timecounter; + th->th_counter = tc; th->th_offset_count = ncount; - tc_min_ticktock_freq = max(1, timecounter->tc_frequency / - (((uint64_t)timecounter->tc_counter_mask + 1) / 3)); + tc_min_ticktock_freq = max(1, tc->tc_frequency / + (((uint64_t)tc->tc_counter_mask + 1) / 3)); recalculate_scaling_factor_and_large_delta(th); #ifdef FFCLOCK ffclock_change_tc(th); From nobody Fri Oct 29 20:12:30 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 53A95182BF44; Fri, 29 Oct 2021 20:12:37 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgtrj22Yjz4XJm; Fri, 29 Oct 2021 20:12:37 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.codepro.be", Issuer "R3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 1217D27814; Fri, 29 Oct 2021 20:12:37 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id 885DC2C5AF; Fri, 29 Oct 2021 22:12:34 +0200 (CEST) From: Kristof Provost To: Kirk McKusick Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 68bff4a07e3f - main - Allow GEOM utilities to specify a -v option. Date: Fri, 29 Oct 2021 22:12:30 +0200 X-Mailer: MailMate (1.14r5818) Message-ID: <5C3D57AA-5771-42FF-924B-3A09818F869D@FreeBSD.org> In-Reply-To: <202110290552.19T5qOjx061844@gitrepo.freebsd.org> References: <202110290552.19T5qOjx061844@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-ThisMailContainsUnwantedMimeParts: N On 29 Oct 2021, at 7:52, Kirk McKusick wrote: > The branch main has been updated by mckusick: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D68bff4a07e3fa6c30a0c0ff6= cf5f0bef95dcbd72 > > commit 68bff4a07e3fa6c30a0c0ff6cf5f0bef95dcbd72 > Author: Kirk McKusick > AuthorDate: 2021-10-29 05:49:48 +0000 > Commit: Kirk McKusick > CommitDate: 2021-10-29 05:50:50 +0000 > > Allow GEOM utilities to specify a -v option. > > Geom utilities (geli(8), glabel(8), gmirror(8), gpart(8), gmirror(8= ), > gmountver(8), etc) all use the geom(8) utility as their back end > to process their commands and pass them into the kernel. Creating > a new utility requires no more than filling out a template describi= ng > the commands and arguments that the utility supports. Consider the > specification for the very simple gmountver(8) utility: > > struct g_command class_commands[] =3D { > { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, > { > G_OPT_SENTINEL > }, > "[-v] prov ..." > }, > { "destroy", G_FLAG_VERBOSE, NULL, > { > { 'f', "force", NULL, G_TYPE_BOOL }, > G_OPT_SENTINEL > }, > "[-fv] name" > }, > G_CMD_SENTINEL > }; > > It has just two commands of its own: "create" and "destroy" along > with the four standard commands "list", "status", "load", and > "unload" provided by the base geom(8) utility. The base geom(8) > utility allows each command to use the G_FLAG_VERBOSE flag to speci= fy > that a command should accept the -v flag and when the -v flag is > given the utility prints "Done." if the command completes successfu= lly. > In the above example, both of the commands set the G_FLAG_VERBOSE, > so have the -v option available. In addition the "destroy" command > accepts the -f boolean flag to force the destruction. > > If the "destroy" command wanted to also print out verbose informati= on, > it would need to explicitly declare its intent by adding a line: > > { 'v', "verbose", NULL, G_TYPE_BOOL }, > > Before this change, the geom utility would silently ignore the abov= e > line in the configuration file, so it was impossible for the utilit= y > to know that the -v flag had been set on the command. With this > change a geom command can explicitly specify a -v option with a > line as given above and handle it as it would any other option. If > both a -v option and G_FLAG_VERBOSE are specified for a command > then both types of verbose information will be output when that > command is run with -v. > > MFC after: 1 week > Sponsored by: Netflix > --- > sbin/geom/core/geom.c | 19 ++++++++++++------- > sbin/geom/core/geom.h | 13 +++++++++++++ > 2 files changed, 25 insertions(+), 7 deletions(-) > > diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c > index 58b33a067700..2e0d8683df49 100644 > --- a/sbin/geom/core/geom.c > +++ b/sbin/geom/core/geom.c > @@ -440,7 +445,7 @@ set_flags(struct g_command *cmd) > { > unsigned flags =3D 0; > > - if ((cmd->gc_flags & G_FLAG_VERBOSE) !=3D 0 && verbose) > + if ((cmd->gc_flags & G_FLAG_VERBOSE) !=3D 0) > flags |=3D G_FLAG_VERBOSE; > > return (flags); Given https://reviews.freebsd.org/D32736 I wonder if the removal of the v= erbose check here was correct. If I'm reading this code right we now always set the verbose flag for any= subcommand that supports it (i.e. has G_FLAG_VERBOSE set). That leads to commands such as glabel always acting as if '-v' was specif= ied. The set_flags() output is only used if g_func is set, which isn't the cas= e in any of the examples in the commit message, so I wonder if that case = was overlooked. Best regards, Kristof From nobody Fri Oct 29 21:39:17 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 174F6182DF75; Fri, 29 Oct 2021 21:39:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hgwmj75cLz4tTd; Fri, 29 Oct 2021 21:39:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CFFB91E79C; Fri, 29 Oct 2021 21:39:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19TLdHlX017759; Fri, 29 Oct 2021 21:39:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19TLdH30017758; Fri, 29 Oct 2021 21:39:17 GMT (envelope-from git) Date: Fri, 29 Oct 2021 21:39:17 GMT Message-Id: <202110292139.19TLdH30017758@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: 141a53cd58cd - main - tcp: Rack might retransmit forever. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 141a53cd58cdf0681f800bb98ed5718f32ea7909 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=141a53cd58cdf0681f800bb98ed5718f32ea7909 commit 141a53cd58cdf0681f800bb98ed5718f32ea7909 Author: Randall Stewart AuthorDate: 2021-10-29 21:37:49 +0000 Commit: Randall Stewart CommitDate: 2021-10-29 21:37:49 +0000 tcp: Rack might retransmit forever. If we get a Sacked peer with an MTU change we can retransmit forever if the last bytes are sacked and the client goes away (think power off). Then we never see the end condition and continually retransmit. Reviewed by: Michael Tuexen Sponsored by: Netflix Inc. Differential Revision: https://reviews.freebsd.org/D32671 --- sys/netinet/tcp_stacks/rack.c | 66 ++++++++++++++++++++++++++++++--------- sys/netinet/tcp_stacks/tcp_rack.h | 38 +++++++++++----------- 2 files changed, 71 insertions(+), 33 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 04252511ad18..616e079df60c 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -2422,7 +2422,8 @@ rack_log_rtt_upd(struct tcpcb *tp, struct tcp_rack *rack, uint32_t t, uint32_t l log.u_bbr.pkt_epoch = rsm->r_start; log.u_bbr.lost = rsm->r_end; log.u_bbr.cwnd_gain = rsm->r_rtr_cnt; - log.u_bbr.pacing_gain = rsm->r_flags; + /* We loose any upper of the 24 bits */ + log.u_bbr.pacing_gain = (uint16_t)rsm->r_flags; } else { /* Its a SYN */ log.u_bbr.pkt_epoch = rack->rc_tp->iss; @@ -6670,6 +6671,7 @@ rack_remxt_tmr(struct tcpcb *tp) if (rsm->r_flags & RACK_ACKED) rsm->r_flags |= RACK_WAS_ACKED; rsm->r_flags &= ~(RACK_ACKED | RACK_SACK_PASSED | RACK_WAS_SACKPASS); + rsm->r_flags |= RACK_MUST_RXT; } /* Clear the count (we just un-acked them) */ rack->r_ctl.rc_last_timeout_snduna = tp->snd_una; @@ -7257,7 +7259,6 @@ rack_update_rsm(struct tcpcb *tp, struct tcp_rack *rack, struct rack_sendmap *rsm, uint64_t ts, uint16_t add_flag) { int32_t idx; - uint16_t stripped_flags; rsm->r_rtr_cnt++; rack_log_retran_reason(rack, rsm, __LINE__, 0, 2); @@ -7278,7 +7279,6 @@ rack_update_rsm(struct tcpcb *tp, struct tcp_rack *rack, */ rsm->r_fas = ctf_flight_size(rack->rc_tp, rack->r_ctl.rc_sacked); - stripped_flags = rsm->r_flags & ~(RACK_SENT_SP|RACK_SENT_FP); if (rsm->r_flags & RACK_ACKED) { /* Problably MTU discovery messing with us */ rsm->r_flags &= ~RACK_ACKED; @@ -16112,12 +16112,25 @@ rack_fast_rsm_output(struct tcpcb *tp, struct tcp_rack *rack, struct rack_sendma rack_start_hpts_timer(rack, tp, cts, slot, len, 0); if (rack->r_must_retran) { rack->r_ctl.rc_out_at_rto -= (rsm->r_end - rsm->r_start); - if (SEQ_GEQ(rsm->r_end, rack->r_ctl.rc_snd_max_at_rto)) { + if ((SEQ_GEQ(rsm->r_end, rack->r_ctl.rc_snd_max_at_rto)) || + ((rsm->r_flags & RACK_MUST_RXT) == 0)) { /* - * We have retransmitted all we need. + * We have retransmitted all we need. If + * RACK_MUST_RXT is not set then we need to + * not retransmit this guy. */ rack->r_must_retran = 0; rack->r_ctl.rc_out_at_rto = 0; + if ((rsm->r_flags & RACK_MUST_RXT) == 0) { + /* Not one we should rxt */ + goto failed; + } else { + /* Clear the flag */ + rsm->r_flags &= ~RACK_MUST_RXT; + } + } else { + /* Remove the flag */ + rsm->r_flags &= ~RACK_MUST_RXT; } } #ifdef TCP_ACCOUNTING @@ -17004,8 +17017,8 @@ again: if (rack->r_must_retran && (rsm == NULL)) { /* - * Non-Sack and we had a RTO or MTU change, we - * need to retransmit until we reach + * Non-Sack and we had a RTO or Sack/non-Sack and a + * MTU change, we need to retransmit until we reach * the former snd_max (rack->r_ctl.rc_snd_max_at_rto). */ if (SEQ_GT(tp->snd_max, tp->snd_una)) { @@ -17028,12 +17041,24 @@ again: sb = &so->so_snd; goto just_return_nolock; } - sack_rxmit = 1; - len = rsm->r_end - rsm->r_start; - sendalot = 0; - sb_offset = rsm->r_start - tp->snd_una; - if (len >= segsiz) - len = segsiz; + if ((rsm->r_flags & RACK_MUST_RXT) == 0) { + /* It does not have the flag, we are done */ + rack->r_must_retran = 0; + rack->r_ctl.rc_out_at_rto = 0; + } else { + sack_rxmit = 1; + len = rsm->r_end - rsm->r_start; + sendalot = 0; + sb_offset = rsm->r_start - tp->snd_una; + if (len >= segsiz) + len = segsiz; + /* + * Delay removing the flag RACK_MUST_RXT so + * that the fastpath for retransmit will + * work with this rsm. + */ + + } } else { /* We must be done if there is nothing outstanding */ rack->r_must_retran = 0; @@ -17080,6 +17105,15 @@ again: if (ret == 0) return (0); } + if (rsm && (rsm->r_flags & RACK_MUST_RXT)) { + /* + * Clear the flag in prep for the send + * note that if we can't get an mbuf + * and fail, we won't retransmit this + * rsm but that should be ok (its rare). + */ + rsm->r_flags &= ~RACK_MUST_RXT; + } so = inp->inp_socket; sb = &so->so_snd; if (do_a_prefetch == 0) { @@ -19313,6 +19347,7 @@ rack_mtu_change(struct tcpcb *tp) * The MSS may have changed */ struct tcp_rack *rack; + struct rack_sendmap *rsm; rack = (struct tcp_rack *)tp->t_fb_ptr; if (rack->r_ctl.rc_pace_min_segs != ctf_fixed_maxseg(tp)) { @@ -19329,7 +19364,10 @@ rack_mtu_change(struct tcpcb *tp) rack->r_ctl.rc_sacked); rack->r_ctl.rc_snd_max_at_rto = tp->snd_max; rack->r_must_retran = 1; - + /* Mark all inflight to needing to be rxt'd */ + TAILQ_FOREACH(rsm, &rack->r_ctl.rc_tmap, r_tnext) { + rsm->r_flags |= RACK_MUST_RXT; + } } sack_filter_clear(&rack->r_ctl.rack_sf, tp->snd_una); /* We don't use snd_nxt to retransmit */ diff --git a/sys/netinet/tcp_stacks/tcp_rack.h b/sys/netinet/tcp_stacks/tcp_rack.h index 0ada2116dc6f..0893237e92f9 100644 --- a/sys/netinet/tcp_stacks/tcp_rack.h +++ b/sys/netinet/tcp_stacks/tcp_rack.h @@ -28,22 +28,23 @@ #ifndef _NETINET_TCP_RACK_H_ #define _NETINET_TCP_RACK_H_ -#define RACK_ACKED 0x0001/* The remote endpoint acked this */ -#define RACK_TO_REXT 0x0002/* A timeout occured on this sendmap entry */ -#define RACK_DEFERRED 0x0004/* We can't use this for RTT calc - not used */ -#define RACK_OVERMAX 0x0008/* We have more retran's then we can fit */ -#define RACK_SACK_PASSED 0x0010/* A sack was done above this block */ -#define RACK_WAS_SACKPASS 0x0020/* We retransmitted due to SACK pass */ -#define RACK_HAS_FIN 0x0040/* segment is sent with fin */ -#define RACK_TLP 0x0080/* segment sent as tail-loss-probe */ -#define RACK_RWND_COLLAPSED 0x0100/* The peer collapsed the rwnd on the segment */ -#define RACK_APP_LIMITED 0x0200/* We went app limited after this send */ -#define RACK_WAS_ACKED 0x0400/* a RTO undid the ack, but it already had a rtt calc done */ -#define RACK_HAS_SYN 0x0800/* SYN is on this guy */ -#define RACK_SENT_W_DSACK 0x1000/* Sent with a dsack */ -#define RACK_SENT_SP 0x2000/* sent in slow path */ -#define RACK_SENT_FP 0x4000/* sent in fast path */ -#define RACK_HAD_PUSH 0x8000/* Push was sent on original send */ +#define RACK_ACKED 0x000001/* The remote endpoint acked this */ +#define RACK_TO_REXT 0x000002/* A timeout occured on this sendmap entry */ +#define RACK_DEFERRED 0x000004/* We can't use this for RTT calc - not used */ +#define RACK_OVERMAX 0x000008/* We have more retran's then we can fit */ +#define RACK_SACK_PASSED 0x000010/* A sack was done above this block */ +#define RACK_WAS_SACKPASS 0x000020/* We retransmitted due to SACK pass */ +#define RACK_HAS_FIN 0x000040/* segment is sent with fin */ +#define RACK_TLP 0x000080/* segment sent as tail-loss-probe */ +#define RACK_RWND_COLLAPSED 0x000100/* The peer collapsed the rwnd on the segment */ +#define RACK_APP_LIMITED 0x000200/* We went app limited after this send */ +#define RACK_WAS_ACKED 0x000400/* a RTO undid the ack, but it already had a rtt calc done */ +#define RACK_HAS_SYN 0x000800/* SYN is on this guy */ +#define RACK_SENT_W_DSACK 0x001000/* Sent with a dsack */ +#define RACK_SENT_SP 0x002000/* sent in slow path */ +#define RACK_SENT_FP 0x004000/* sent in fast path */ +#define RACK_HAD_PUSH 0x008000/* Push was sent on original send */ +#define RACK_MUST_RXT 0x010000/* We must retransmit this rsm (non-sack/mtu chg)*/ #define RACK_NUM_OF_RETRANS 3 #define RACK_INITIAL_RTO 1000000 /* 1 second in microseconds */ @@ -55,9 +56,8 @@ struct rack_sendmap { uint32_t r_start; /* Sequence number of the segment */ uint32_t r_end; /* End seq, this is 1 beyond actually */ uint32_t r_rtr_bytes; /* How many bytes have been retransmitted */ - uint16_t r_rtr_cnt; /* Retran count, index this -1 to get time - * sent */ - uint16_t r_flags; /* Flags as defined above */ + uint32_t r_flags : 24, /* Flags as defined above */ + r_rtr_cnt : 8; /* Retran count, index this -1 to get time */ struct mbuf *m; uint32_t soff; uint32_t orig_m_len; From nobody Sat Oct 30 00:25:12 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7969D18323D1; Sat, 30 Oct 2021 00:25:24 +0000 (UTC) (envelope-from koobs.freebsd@gmail.com) Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hh0SM4mLTz3CVS; Sat, 30 Oct 2021 00:25:23 +0000 (UTC) (envelope-from koobs.freebsd@gmail.com) Received: by mail-pj1-x102d.google.com with SMTP id ls14-20020a17090b350e00b001a00e2251c8so8425356pjb.4; Fri, 29 Oct 2021 17:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:reply-to:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=L9p63o0ivQwCQ2C4acrBRBMiTFQl4oYFhCvE0qTGaKw=; b=ZC+VUU1wRSSOHmB/L7sDlWzEd0v7/an5RZOj1/U1WAmRE/BrgQ0myvYeJoxC4gIa7N MCkQqP73qDtNsYR+otpot5iCguho1TNf2dmdBqoYWT87khBlifx1X/x8aJamSzWKaHc6 Z/xHI03NdaFq71dfpUGRBKdxqfHP/Obr8fIDuQ3uVaye70kjxzHXHhc4XKJ+D8Y/TCNx e43iIAC8iXKQjdbgYQvR9TYjpdJLSxNny2TF1WY7TtrR2enq/GWXTV301Xazrs3DmQUc uYTQSKTqIfg6em1Oc/cyKZ7wXfbM6R9JYMtKzkMRjoioQJSDFh/bUBka3+J41xIsRVFs Orlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :reply-to:subject:content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=L9p63o0ivQwCQ2C4acrBRBMiTFQl4oYFhCvE0qTGaKw=; b=KJaFh1QySN9EoRbYh+yw5FxqutXpk5Y/fIIhRrTHfseBuV58MVK7hONAVp7ntfsJK7 NF41WWabcyFqczOERY9R4jnMjPGUQ/q3eGKWQbtluZ9FTgoZBQS8f7z9OoKabLxj+Fat F72+MHYnIvuJ7F61B2/Txe6VvYZqrtF/UhGo9BUPqpZnd7jruqxh0v+C76Wn8GyQCZaS Laly0Q846g0tU/ulH06f9zmULB86d3XIqsKqkYZ55qZNA2DHkfvMOD8H5JQ+eWDFpypE 1cfVHnDSW57NFtburq7059lDWnLdMzoJoNDwZWkLrZ/0dYI0mqwL46WMvhyGcc4uZ1Op EQkw== X-Gm-Message-State: AOAM530ssT/FQ/acyv0rA/BAToelSW18AckqUYdfgT0L/Sv0z6gkQ/SU kIMt1VAo/TTNoUTnkh+QujHfGBVhUPM= X-Google-Smtp-Source: ABdhPJzAUWy/j9iwkpnMy/sRVa1jvRj619E36uLypFg+bJiltBmK7+bAD/h9WBMgqGuHD/Y0d4CqrQ== X-Received: by 2002:a17:902:db02:b0:141:b1dd:111 with SMTP id m2-20020a170902db0200b00141b1dd0111mr5382261plx.44.1635553517053; Fri, 29 Oct 2021 17:25:17 -0700 (PDT) Received: from ?IPV6:2403:5807:1b:1:29fd:8863:3b42:c493? (2403-5807-1b-1-29fd-8863-3b42-c493.ip6.aussiebb.net. [2403:5807:1b:1:29fd:8863:3b42:c493]) by smtp.gmail.com with ESMTPSA id c1sm4926775pfv.54.2021.10.29.17.25.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 17:25:16 -0700 (PDT) Sender: Kubilay Kocak Message-ID: Date: Sat, 30 Oct 2021 11:25:12 +1100 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Thunderbird/95.0a1 Reply-To: koobs@FreeBSD.org Subject: Re: git: 92b3e07229ba - main - Enable net.inet.tcp.nolocaltimewait. Content-Language: en-US To: Gleb Smirnoff , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202110282235.19SMZoAL076017@gitrepo.freebsd.org> From: Kubilay Kocak In-Reply-To: <202110282235.19SMZoAL076017@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Hh0SM4mLTz3CVS X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=ZC+VUU1w; dmarc=none; spf=pass (mx1.freebsd.org: domain of koobsfreebsd@gmail.com designates 2607:f8b0:4864:20::102d as permitted sender) smtp.mailfrom=koobsfreebsd@gmail.com X-Spamd-Result: default: False [-3.20 / 15.00]; HAS_REPLYTO(0.00)[koobs@FreeBSD.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[koobs@FreeBSD.org,koobsfreebsd@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_NEQ_ENVFROM(0.00)[koobs@FreeBSD.org,koobsfreebsd@gmail.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; 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]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::102d:from]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 29/10/2021 9:35 am, Gleb Smirnoff wrote: > The branch main has been updated by glebius: > > URL: https://cgit.FreeBSD.org/src/commit/?id=92b3e07229baab17cbe258ff1081e66bb7913b31 > > commit 92b3e07229baab17cbe258ff1081e66bb7913b31 > Author: Gleb Smirnoff > AuthorDate: 2021-10-28 22:34:00 +0000 > Commit: Gleb Smirnoff > CommitDate: 2021-10-28 22:34:00 +0000 > > Enable net.inet.tcp.nolocaltimewait. > > This feature has been used for many years at large sites and > didn't show any pitfalls. > --- > sys/netinet/tcp_timewait.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c > index 5d4de222b802..9d397d62424f 100644 > --- a/sys/netinet/tcp_timewait.c > +++ b/sys/netinet/tcp_timewait.c > @@ -176,10 +176,10 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, maxtcptw, > &maxtcptw, 0, sysctl_maxtcptw, "IU", > "Maximum number of compressed TCP TIME_WAIT entries"); > > -VNET_DEFINE_STATIC(int, nolocaltimewait) = 0; > +VNET_DEFINE_STATIC(bool, nolocaltimewait) = true; > #define V_nolocaltimewait VNET(nolocaltimewait) > -SYSCTL_INT(_net_inet_tcp, OID_AUTO, nolocaltimewait, CTLFLAG_VNET | CTLFLAG_RW, > - &VNET_NAME(nolocaltimewait), 0, > +SYSCTL_BOOL(_net_inet_tcp, OID_AUTO, nolocaltimewait, CTLFLAG_VNET | CTLFLAG_RW, > + &VNET_NAME(nolocaltimewait), true, > "Do not create compressed TCP TIME_WAIT entries for local connections"); > > void > RELNOTES: ? From nobody Sat Oct 30 03:38:17 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2E63E1836B6A; Sat, 30 Oct 2021 03:38:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hh4ky0qbdz4mBS; Sat, 30 Oct 2021 03:38:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F034A23078; Sat, 30 Oct 2021 03:38:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19U3cHHK098091; Sat, 30 Oct 2021 03:38:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19U3cHmi098090; Sat, 30 Oct 2021 03:38:17 GMT (envelope-from git) Date: Sat, 30 Oct 2021 03:38:17 GMT Message-Id: <202110300338.19U3cHmi098090@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: dc6dd769de63 - main - nfscl: Use NFSMNTP_DELEGISSUED in two more functions List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dc6dd769de63c4eceb8899205a5d780d9f278fd2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=dc6dd769de63c4eceb8899205a5d780d9f278fd2 commit dc6dd769de63c4eceb8899205a5d780d9f278fd2 Author: Rick Macklem AuthorDate: 2021-10-30 03:35:02 +0000 Commit: Rick Macklem CommitDate: 2021-10-30 03:35:02 +0000 nfscl: Use NFSMNTP_DELEGISSUED in two more functions Commit 5e5ca4c8fc53 added a NFSMNTP_DELEGISSUED flag to indicate when a delegation has been issued to the mount. For the common case where an NFSv4 server is not issuing delegations, this flag can be checked to avoid acquisition of the NFSCLSTATEMUTEX. This patch adds checks for NFSMNTP_DELEGISSUED being set to two more functions. This change appears to be performance neutral for a small number of opens, but should reduce lock contention for a large number of opens for the common case where server is not issuing delegations. MFC after: 2 week --- sys/fs/nfsclient/nfs_clstate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 36f8bbd6b51f..549d2f8ff538 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -4565,6 +4565,12 @@ nfscl_mustflush(vnode_t vp) nmp = VFSTONFS(vp->v_mount); if (!NFSHASNFSV4(nmp)) return (1); + NFSLOCKMNT(nmp); + if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) { + NFSUNLOCKMNT(nmp); + return (1); + } + NFSUNLOCKMNT(nmp); NFSLOCKCLSTATE(); clp = nfscl_findcl(nmp); if (clp == NULL) { @@ -4748,6 +4754,12 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, *gottdp = 0; if (NFSHASPNFS(nmp)) return (retcnt); + NFSLOCKMNT(nmp); + if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) { + NFSUNLOCKMNT(nmp); + return (retcnt); + } + NFSUNLOCKMNT(nmp); NFSLOCKCLSTATE(); /* * Loop around waiting for: From nobody Sat Oct 30 07:09:48 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DA41E18186B7; Sat, 30 Oct 2021 07:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hh9R05qqqz4flv; Sat, 30 Oct 2021 07:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A951E262E0; Sat, 30 Oct 2021 07:09:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19U79mll078040; Sat, 30 Oct 2021 07:09:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19U79mDS078039; Sat, 30 Oct 2021 07:09:48 GMT (envelope-from git) Date: Sat, 30 Oct 2021 07:09:48 GMT Message-Id: <202110300709.19U79mDS078039@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Stefan E=C3=9Fer?= Subject: git: 20f8331aca89 - main - usr.bin/stat: honour locale for "-t %+" List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 20f8331aca892ff812510609b3bc4e747b201197 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=20f8331aca892ff812510609b3bc4e747b201197 commit 20f8331aca892ff812510609b3bc4e747b201197 Author: Stefan Eßer AuthorDate: 2021-10-30 07:00:34 +0000 Commit: Stefan Eßer CommitDate: 2021-10-30 07:00:34 +0000 usr.bin/stat: honour locale for "-t %+" The man page states that "-t %+" prints time information in the same format as date with no format specifier. This was not the case, the format used was always that of date for the POSIX locale. The fix suggested by the reporter leads to output that matches the documentation. Reported by: Jamie Landeg-Jones MFC after: 3 days --- usr.bin/stat/stat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.bin/stat/stat.c b/usr.bin/stat/stat.c index e504333c3329..9d94399a6333 100644 --- a/usr.bin/stat/stat.c +++ b/usr.bin/stat/stat.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -763,6 +764,7 @@ format1(const struct stat *st, ts.tv_sec = 0; tm = localtime(&ts.tv_sec); } + (void)setlocale(LC_TIME, ""); (void)strftime(path, sizeof(path), timefmt, tm); sdata = path; formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | From nobody Sat Oct 30 09:12:59 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 10C7F182B926; Sat, 30 Oct 2021 09:13:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhD9800Qyz3mD0; Sat, 30 Oct 2021 09:13:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D489A27A6E; Sat, 30 Oct 2021 09:12:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19U9CxWF050815; Sat, 30 Oct 2021 09:12:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19U9Cx5H050814; Sat, 30 Oct 2021 09:12:59 GMT (envelope-from git) Date: Sat, 30 Oct 2021 09:12:59 GMT Message-Id: <202110300912.19U9Cx5H050814@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 8bbc0600cc21 - main - linux: Add additional ptracestop only if the debugger is Linux List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=8bbc0600cc21bbfdc3b8e67199eec4220952b7e3 commit 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3 Author: Edward Tomasz Napierala AuthorDate: 2021-10-30 08:53:55 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-10-30 08:54:17 +0000 linux: Add additional ptracestop only if the debugger is Linux In 6e66030c4c0, additional ptracestop was added in order to implement PTRACE_EVENT_EXEC. Make it only apply to cases where the debugger is a Linux processes; native FreeBSD debuggers can trace Linux processes too, but they don't expect that additonal ptracestop. Fixes: 6e66030c4c0 Reported By: kib Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32726 --- sys/kern/subr_syscall.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index fab67a68b0a3..dacd82f4c466 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -260,9 +260,15 @@ syscallret(struct thread *td) * the exec event now and then clear TDB_EXEC so that * the next stop is reported as a syscall exit by * linux_ptrace_status(). + * + * We are accessing p->p_pptr without any additional + * locks here: it cannot change while p is kept locked; + * while the debugger could in theory change its ABI + * while tracing another process, the outcome of such + * a race wouln't be deterministic anyway. */ - if ((td->td_dbgflags & TDB_EXEC) != 0 && - SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX) { + if (traced && (td->td_dbgflags & TDB_EXEC) != 0 && + SV_PROC_ABI(p->p_pptr) == SV_ABI_LINUX) { ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~TDB_EXEC; } From nobody Sat Oct 30 10:14:28 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E4800181C402; Sat, 30 Oct 2021 10:14:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhFX45k6lz4X3q; Sat, 30 Oct 2021 10:14:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9FAEAB44; Sat, 30 Oct 2021 10:14:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19UAESA5030601; Sat, 30 Oct 2021 10:14:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19UAESZK030600; Sat, 30 Oct 2021 10:14:28 GMT (envelope-from git) Date: Sat, 30 Oct 2021 10:14:28 GMT Message-Id: <202110301014.19UAESZK030600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: f0d9a6a781f3 - main - linux: make PTRACE_SETREGS use a correct struct List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f0d9a6a781f331440baf9a846e773e44a297d59c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=f0d9a6a781f331440baf9a846e773e44a297d59c commit f0d9a6a781f331440baf9a846e773e44a297d59c Author: Edward Tomasz Napierala AuthorDate: 2021-10-30 09:13:32 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-10-30 09:13:37 +0000 linux: make PTRACE_SETREGS use a correct struct Note that this is largely untested at this point, as was the previous version; I'm committing this mostly to get rid of `struct linux_pt_reg`. Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32735 --- sys/amd64/linux/linux.h | 3 ++ sys/amd64/linux/linux_machdep.c | 31 +++++++++++++++++++ sys/amd64/linux/linux_ptrace.c | 66 ++--------------------------------------- 3 files changed, 37 insertions(+), 63 deletions(-) diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h index 519b6bd200ac..16fe3793eae7 100644 --- a/sys/amd64/linux/linux.h +++ b/sys/amd64/linux/linux.h @@ -461,5 +461,8 @@ struct reg; void bsd_to_linux_regset(const struct reg *b_reg, struct linux_pt_regset *l_regset); +void linux_to_bsd_regset(struct reg *b_reg, + const struct linux_pt_regset *l_regset); + #endif /* !_AMD64_LINUX_H_ */ diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c index c34d98e86d0b..e2346f68da3a 100644 --- a/sys/amd64/linux/linux_machdep.c +++ b/sys/amd64/linux/linux_machdep.c @@ -330,3 +330,34 @@ bsd_to_linux_regset(const struct reg *b_reg, struct linux_pt_regset *l_regset) l_regset->fs = b_reg->r_fs; l_regset->gs = b_reg->r_gs; } + +void +linux_to_bsd_regset(struct reg *b_reg, const struct linux_pt_regset *l_regset) +{ + + b_reg->r_r15 = l_regset->r15; + b_reg->r_r14 = l_regset->r14; + b_reg->r_r13 = l_regset->r13; + b_reg->r_r12 = l_regset->r12; + b_reg->r_rbp = l_regset->rbp; + b_reg->r_rbx = l_regset->rbx; + b_reg->r_r11 = l_regset->r11; + b_reg->r_r10 = l_regset->r10; + b_reg->r_r9 = l_regset->r9; + b_reg->r_r8 = l_regset->r8; + b_reg->r_rax = l_regset->rax; + b_reg->r_rcx = l_regset->rcx; + b_reg->r_rdx = l_regset->rdx; + b_reg->r_rsi = l_regset->rsi; + b_reg->r_rdi = l_regset->rdi; + b_reg->r_rax = l_regset->orig_rax; + b_reg->r_rip = l_regset->rip; + b_reg->r_cs = l_regset->cs; + b_reg->r_rflags = l_regset->eflags; + b_reg->r_rsp = l_regset->rsp; + b_reg->r_ss = l_regset->ss; + b_reg->r_ds = l_regset->ds; + b_reg->r_es = l_regset->es; + b_reg->r_fs = l_regset->fs; + b_reg->r_gs = l_regset->gs; +} diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index 0f06f2aa9c5c..191e6265b39c 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -168,30 +168,6 @@ linux_ptrace_status(struct thread *td, pid_t pid, int status) return (status); } -struct linux_pt_reg { - l_ulong r15; - l_ulong r14; - l_ulong r13; - l_ulong r12; - l_ulong rbp; - l_ulong rbx; - l_ulong r11; - l_ulong r10; - l_ulong r9; - l_ulong r8; - l_ulong rax; - l_ulong rcx; - l_ulong rdx; - l_ulong rsi; - l_ulong rdi; - l_ulong orig_rax; - l_ulong rip; - l_ulong cs; - l_ulong eflags; - l_ulong rsp; - l_ulong ss; -}; - struct syscall_info { uint8_t op; uint32_t arch; @@ -214,42 +190,6 @@ struct syscall_info { }; }; -static void -map_regs_from_linux(struct reg *b_reg, struct linux_pt_reg *l_reg) -{ - b_reg->r_r15 = l_reg->r15; - b_reg->r_r14 = l_reg->r14; - b_reg->r_r13 = l_reg->r13; - b_reg->r_r12 = l_reg->r12; - b_reg->r_r11 = l_reg->r11; - b_reg->r_r10 = l_reg->r10; - b_reg->r_r9 = l_reg->r9; - b_reg->r_r8 = l_reg->r8; - b_reg->r_rdi = l_reg->rdi; - b_reg->r_rsi = l_reg->rsi; - b_reg->r_rbp = l_reg->rbp; - b_reg->r_rbx = l_reg->rbx; - b_reg->r_rdx = l_reg->rdx; - b_reg->r_rcx = l_reg->rcx; - b_reg->r_rax = l_reg->rax; - - /* - * XXX: Are zeroes the right thing to put here? - */ - b_reg->r_trapno = 0; - b_reg->r_fs = 0; - b_reg->r_gs = 0; - b_reg->r_err = 0; - b_reg->r_es = 0; - b_reg->r_ds = 0; - - b_reg->r_rip = l_reg->rip; - b_reg->r_cs = l_reg->cs; - b_reg->r_rflags = l_reg->eflags; - b_reg->r_rsp = l_reg->rsp; - b_reg->r_ss = l_reg->ss; -} - static int linux_ptrace_peek(struct thread *td, pid_t pid, void *addr, void *data) { @@ -446,13 +386,13 @@ static int linux_ptrace_setregs(struct thread *td, pid_t pid, void *data) { struct reg b_reg; - struct linux_pt_reg l_reg; + struct linux_pt_regset l_regset; int error; - error = copyin(data, &l_reg, sizeof(l_reg)); + error = copyin(data, &l_regset, sizeof(l_regset)); if (error != 0) return (error); - map_regs_from_linux(&b_reg, &l_reg); + linux_to_bsd_regset(&b_reg, &l_regset); error = kern_ptrace(td, PT_SETREGS, pid, &b_reg, 0); return (error); } From nobody Sat Oct 30 23:40:04 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7F0DE181DE97; Sat, 30 Oct 2021 23:40:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhbPc3851z4d6l; Sat, 30 Oct 2021 23:40:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C55E1354B; Sat, 30 Oct 2021 23:40:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19UNe4AN096133; Sat, 30 Oct 2021 23:40:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19UNe4wL096128; Sat, 30 Oct 2021 23:40:04 GMT (envelope-from git) Date: Sat, 30 Oct 2021 23:40:04 GMT Message-Id: <202110302340.19UNe4wL096128@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 2be417843a04 - main - PR#259071 provides a test program that fails for the NFS client. Testing with it, there appears to be a race between Lookup and VOPs like Setattr-of-size, where Lookup ends up loading stale attributes (including what might be the wrong file size) into the NFS vnode's attribute cache. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2be417843a04f25e631e99d5188eb2652b13d80d Auto-Submitted: auto-generated X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=2be417843a04f25e631e99d5188eb2652b13d80d commit 2be417843a04f25e631e99d5188eb2652b13d80d Author: Rick Macklem AuthorDate: 2021-10-30 23:35:02 +0000 Commit: Rick Macklem CommitDate: 2021-10-30 23:35:02 +0000 PR#259071 provides a test program that fails for the NFS client. Testing with it, there appears to be a race between Lookup and VOPs like Setattr-of-size, where Lookup ends up loading stale attributes (including what might be the wrong file size) into the NFS vnode's attribute cache. The race occurs when the modifying VOP (which holds a lock on the vnode), blocks the acquisition of the vnode in Lookup, after the RPC (with now potentially stale attributes). Here's what seems to happen: Child Parent does stat(), which does VOP_LOOKUP(), doing the Lookup RPC with the directory vnode locked, acquiring file attributes valid at this point in time blocks waiting for locked file does ftruncate(), which vnode does VOP_SETATTR() of Size, changing the file's size while holding an exclusive lock on the file's vnode releases the vnode lock acquires file vnode and fills in now stale attributes including the old wrong Size does a read() which returns wrong data size This patch fixes the problem by saving a timestamp in the NFS vnode in the VOPs that modify the file (Setattr-of-size, Allocate). Then lookup/readdirplus compares that timestamp with the time just before starting the RPC after it has acquired the file's vnode. If the modifying RPC occurred during the Lookup, the attributes in the RPC reply are discarded, since they might be stale. With this patch the test program works as expected. Note that the test program does not fail on a July stable/12, although this race is in the NFS client code. I suspect a fairly recent change to the name caching code exposed this bug. PR: 259071 Reviewed by: asomers MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D32635 --- sys/fs/nfsclient/nfs_clrpcops.c | 29 +++++++++++++-- sys/fs/nfsclient/nfs_clvnops.c | 78 +++++++++++++++++++++++++++++++++++++---- sys/fs/nfsclient/nfsnode.h | 1 + 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index dec70dc2ac06..f74493debd7c 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -3630,7 +3630,8 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, nfsattrbit_t attrbits, dattrbits; size_t tresid; u_int32_t *tl2 = NULL, rderr; - struct timespec dctime; + struct timespec dctime, ts; + bool attr_ok; KASSERT(uiop->uio_iovcnt == 1 && (uiop->uio_resid & (DIRBLKSIZ - 1)) == 0, @@ -3815,6 +3816,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, *tl = txdr_unsigned(NFSV4OP_GETATTR); (void) nfsrv_putattrbit(nd, &dattrbits); } + nanouptime(&ts); error = nfscl_request(nd, vp, p, cred, stuff); if (error) return (error); @@ -3972,6 +3974,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, ncookie.lval[1]; if (nfhp != NULL) { + attr_ok = true; if (NFSRV_CMPFH(nfhp->nfh_fh, nfhp->nfh_len, dnp->n_fhp->nfh_fh, dnp->n_fhp->nfh_len)) { VREF(vp); @@ -4001,12 +4004,32 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, if (!error) { newvp = NFSTOV(np); unlocknewvp = 1; + /* + * If n_localmodtime >= time before RPC, + * then a file modification operation, + * such as VOP_SETATTR() of size, has + * occurred while the Lookup RPC and + * acquisition of the vnode happened. As + * such, the attributes might be stale, + * with possibly an incorrect size. + */ + NFSLOCKNODE(np); + if (timespecisset( + &np->n_localmodtime) && + timespeccmp(&np->n_localmodtime, + &ts, >=)) { + NFSCL_DEBUG(4, "nfsrpc_readdirplus:" + " localmod stale attributes\n"); + attr_ok = false; + } + NFSUNLOCKNODE(np); } } nfhp = NULL; if (newvp != NULLVP) { - error = nfscl_loadattrcache(&newvp, - &nfsva, NULL, NULL, 0, 0); + if (attr_ok) + error = nfscl_loadattrcache(&newvp, + &nfsva, NULL, NULL, 0, 0); if (error) { if (unlocknewvp) vput(newvp); diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 4a1ab9552a15..e8c713086717 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -1014,6 +1014,7 @@ nfs_setattr(struct vop_setattr_args *ap) struct vattr *vap = ap->a_vap; int error = 0; u_quad_t tsize; + struct timespec ts; #ifndef nolint tsize = (u_quad_t)0; @@ -1108,11 +1109,18 @@ nfs_setattr(struct vop_setattr_args *ap) NFSUNLOCKNODE(np); } error = nfs_setattrrpc(vp, vap, ap->a_cred, td); - if (error && vap->va_size != VNOVAL) { - NFSLOCKNODE(np); - np->n_size = np->n_vattr.na_size = tsize; - vnode_pager_setsize(vp, tsize); - NFSUNLOCKNODE(np); + if (vap->va_size != VNOVAL) { + if (error == 0) { + nanouptime(&ts); + NFSLOCKNODE(np); + np->n_localmodtime = ts; + NFSUNLOCKNODE(np); + } else { + NFSLOCKNODE(np); + np->n_size = np->n_vattr.na_size = tsize; + vnode_pager_setsize(vp, tsize); + NFSUNLOCKNODE(np); + } } return (error); } @@ -1169,7 +1177,7 @@ nfs_lookup(struct vop_lookup_args *ap) struct nfsfh *nfhp; struct nfsvattr dnfsva, nfsva; struct vattr vattr; - struct timespec nctime; + struct timespec nctime, ts; uint32_t openmode; *vpp = NULLVP; @@ -1293,6 +1301,7 @@ nfs_lookup(struct vop_lookup_args *ap) newvp = NULLVP; NFSINCRGLOBAL(nfsstatsv1.lookupcache_misses); + nanouptime(&ts); error = nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_cred, td, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL, openmode); @@ -1359,6 +1368,22 @@ nfs_lookup(struct vop_lookup_args *ap) if (error) return (error); newvp = NFSTOV(np); + /* + * If n_localmodtime >= time before RPC, then + * a file modification operation, such as + * VOP_SETATTR() of size, has occurred while + * the Lookup RPC and acquisition of the vnode + * happened. As such, the attributes might + * be stale, with possibly an incorrect size. + */ + NFSLOCKNODE(np); + if (timespecisset(&np->n_localmodtime) && + timespeccmp(&np->n_localmodtime, &ts, >=)) { + NFSCL_DEBUG(4, "nfs_lookup: rename localmod " + "stale attributes\n"); + attrflag = 0; + } + NFSUNLOCKNODE(np); if (attrflag) (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 0, 1); @@ -1418,6 +1443,22 @@ nfs_lookup(struct vop_lookup_args *ap) if (error) return (error); newvp = NFSTOV(np); + /* + * If n_localmodtime >= time before RPC, then + * a file modification operation, such as + * VOP_SETATTR() of size, has occurred while + * the Lookup RPC and acquisition of the vnode + * happened. As such, the attributes might + * be stale, with possibly an incorrect size. + */ + NFSLOCKNODE(np); + if (timespecisset(&np->n_localmodtime) && + timespeccmp(&np->n_localmodtime, &ts, >=)) { + NFSCL_DEBUG(4, "nfs_lookup: localmod " + "stale attributes\n"); + attrflag = 0; + } + NFSUNLOCKNODE(np); if (attrflag) (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 0, 1); @@ -2635,7 +2676,9 @@ nfs_lookitup(struct vnode *dvp, char *name, int len, struct ucred *cred, struct componentname cn; int error = 0, attrflag, dattrflag; u_int hash; + struct timespec ts; + nanouptime(&ts); error = nfsrpc_lookup(dvp, name, len, cred, td, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL, 0); if (dattrflag) @@ -2696,6 +2739,22 @@ printf("replace=%s\n",nnn); if (error) return (error); newvp = NFSTOV(np); + /* + * If n_localmodtime >= time before RPC, then + * a file modification operation, such as + * VOP_SETATTR() of size, has occurred while + * the Lookup RPC and acquisition of the vnode + * happened. As such, the attributes might + * be stale, with possibly an incorrect size. + */ + NFSLOCKNODE(np); + if (timespecisset(&np->n_localmodtime) && + timespeccmp(&np->n_localmodtime, &ts, >=)) { + NFSCL_DEBUG(4, "nfs_lookitup: localmod " + "stale attributes\n"); + attrflag = 0; + } + NFSUNLOCKNODE(np); } if (!attrflag && *npp == NULL) { if (newvp == dvp) @@ -3643,11 +3702,14 @@ nfs_allocate(struct vop_allocate_args *ap) struct thread *td = curthread; struct nfsvattr nfsva; struct nfsmount *nmp; + struct nfsnode *np; off_t alen; int attrflag, error, ret; + struct timespec ts; attrflag = 0; nmp = VFSTONFS(vp->v_mount); + np = VTONFS(vp); mtx_lock(&nmp->nm_mtx); if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && (nmp->nm_privflag & NFSMNTP_NOALLOCATE) == 0) { @@ -3667,6 +3729,10 @@ nfs_allocate(struct vop_allocate_args *ap) if (error == 0) { *ap->a_offset += alen; *ap->a_len -= alen; + nanouptime(&ts); + NFSLOCKNODE(np); + np->n_localmodtime = ts; + NFSUNLOCKNODE(np); } else if (error == NFSERR_NOTSUPP) { mtx_lock(&nmp->nm_mtx); nmp->nm_privflag |= NFSMNTP_NOALLOCATE; diff --git a/sys/fs/nfsclient/nfsnode.h b/sys/fs/nfsclient/nfsnode.h index b34e362a8522..833737654f6b 100644 --- a/sys/fs/nfsclient/nfsnode.h +++ b/sys/fs/nfsclient/nfsnode.h @@ -129,6 +129,7 @@ struct nfsnode { struct nfsv4node *n_v4; /* extra V4 stuff */ struct ucred *n_writecred; /* Cred. for putpages */ struct nfsclopen *n_openstateid; /* Cached open stateid */ + struct timespec n_localmodtime; /* Last local modify */ }; #define n_atim n_un1.nf_atim From nobody Sat Oct 30 23:49:27 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5ED991822389; Sat, 30 Oct 2021 23:49:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhbcR2C6Lz4h00; Sat, 30 Oct 2021 23:49:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C0AF1382B; Sat, 30 Oct 2021 23:49:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19UNnRUq007668; Sat, 30 Oct 2021 23:49:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19UNnRWS007667; Sat, 30 Oct 2021 23:49:27 GMT (envelope-from git) Date: Sat, 30 Oct 2021 23:49:27 GMT Message-Id: <202110302349.19UNnRWS007667@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: ab87c39c257e - main - nfscl: Set n_localmodtime in Deallocate List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ab87c39c257e7130677867f8e5c11a3ec53fa1bc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=ab87c39c257e7130677867f8e5c11a3ec53fa1bc commit ab87c39c257e7130677867f8e5c11a3ec53fa1bc Author: Rick Macklem AuthorDate: 2021-10-30 23:46:14 +0000 Commit: Rick Macklem CommitDate: 2021-10-30 23:46:14 +0000 nfscl: Set n_localmodtime in Deallocate Commit 2be417843a04 added n_localmodtime, which is used by Lookup and ReaddirPlus to check to see if the file attributes in an RPC reply might be stale. This patch sets n_localmodtime in Deallocate. Done as a separate commit, since Deallocate is not in stable/13. PR: 259071 Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D32635 --- sys/fs/nfsclient/nfs_clvnops.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index e8c713086717..f63eadf26a91 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3767,6 +3767,7 @@ nfs_deallocate(struct vop_deallocate_args *ap) off_t tlen, mlen; int attrflag, error, ret; bool clipped; + struct timespec ts; error = 0; attrflag = 0; @@ -3809,6 +3810,10 @@ nfs_deallocate(struct vop_deallocate_args *ap) if (error == 0) { NFSCL_DEBUG(4, "dealloc: attrflag=%d na_size=%ju\n", attrflag, (uintmax_t)nfsva.na_size); + nanouptime(&ts); + NFSLOCKNODE(np); + np->n_localmodtime = ts; + NFSUNLOCKNODE(np); if (attrflag != 0) { if ((uint64_t)*ap->a_offset < nfsva.na_size) *ap->a_offset += omin((off_t) From nobody Sun Oct 31 00:12:15 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CBF55182BDA7; Sun, 31 Oct 2021 00:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hhc6l5RqPz4pq7; Sun, 31 Oct 2021 00:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B8F1141B0; Sun, 31 Oct 2021 00:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19V0CF2E046963; Sun, 31 Oct 2021 00:12:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19V0CFrF046962; Sun, 31 Oct 2021 00:12:15 GMT (envelope-from git) Date: Sun, 31 Oct 2021 00:12:15 GMT Message-Id: <202110310012.19V0CFrF046962@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 50dcff0816e5 - main - nfscl: Add setting n_localmodtime to the Write RPC code List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 50dcff0816e5e4aa94f51ce27da5121e49902996 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=50dcff0816e5e4aa94f51ce27da5121e49902996 commit 50dcff0816e5e4aa94f51ce27da5121e49902996 Author: Rick Macklem AuthorDate: 2021-10-31 00:08:28 +0000 Commit: Rick Macklem CommitDate: 2021-10-31 00:08:28 +0000 nfscl: Add setting n_localmodtime to the Write RPC code Similar to commit 2be417843a, I believe there could be a race between the NFS client VOP_LOOKUP() and file Writing that could result in stale file attributes being loaded into the NFS vnode by VOP_LOOKUP(). I have not been able to reproduce a failure due to this race, but I believe that there are two possibilities: The Lookup RPC happens while VOP_WRITE() is being executed and loads stale file attributes after VOP_WRITE() returns when it has already completed the Write/Commit RPC(s). --> For this case, setting the local modify timestamp at the end of VOP_WRITE() should ensure that stale file attributes are not loaded. The Lookup RPC occurs after VOP_WRITE() has returned, while asynchronous Write/Commit RPCs are in progress and then is blocked by the vnode held by VOP_OPEN/VOP_CLOSE/VOP_FSYNC which will flush writes via ncl_flush() or ncl_vinvalbuf(), clearing the NMODIFIED flag (which indicates Writes-in-progress). The VOP_LOOKUP() then acquires the NFS vnode lock and fills in stale file attributes. --> Setting the local modify timestamp in ncl_flsuh() and ncl_vinvalbuf() when they clear NMODIFIED should ensure that stale file attributes are not loaded. This patch does the above. PR: 259071 Reviewed by: asomers MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D32677 --- sys/fs/nfsclient/nfs_clbio.c | 18 +++++++++++++++--- sys/fs/nfsclient/nfs_clvnops.c | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index 10a76f0a4b83..250d01d88948 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -907,6 +907,7 @@ ncl_write(struct vop_write_args *ap) int bp_cached, n, on, error = 0, error1, save2, wouldcommit; size_t orig_resid, local_resid; off_t orig_size, tmp_off; + struct timespec ts; KASSERT(uio->uio_rw == UIO_WRITE, ("ncl_write mode")); KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread, @@ -1284,7 +1285,12 @@ again: break; } while (uio->uio_resid > 0 && n > 0); - if (error != 0) { + if (error == 0) { + nanouptime(&ts); + NFSLOCKNODE(np); + np->n_localmodtime = ts; + NFSUNLOCKNODE(np); + } else { if (ioflag & IO_UNIT) { VATTR_NULL(&vattr); vattr.va_size = orig_size; @@ -1356,6 +1362,7 @@ ncl_vinvalbuf(struct vnode *vp, int flags, struct thread *td, int intrflg) struct nfsmount *nmp = VFSTONFS(vp->v_mount); int error = 0, slpflag, slptimeo; bool old_lock; + struct timespec ts; ASSERT_VOP_LOCKED(vp, "ncl_vinvalbuf"); @@ -1400,16 +1407,21 @@ ncl_vinvalbuf(struct vnode *vp, int flags, struct thread *td, int intrflg) } if (NFSHASPNFS(nmp)) { nfscl_layoutcommit(vp, td); + nanouptime(&ts); /* * Invalidate the attribute cache, since writes to a DS * won't update the size attribute. */ NFSLOCKNODE(np); np->n_attrstamp = 0; - } else + } else { + nanouptime(&ts); NFSLOCKNODE(np); - if (np->n_directio_asyncwr == 0) + } + if (np->n_directio_asyncwr == 0 && (np->n_flag & NMODIFIED) != 0) { + np->n_localmodtime = ts; np->n_flag &= ~NMODIFIED; + } NFSUNLOCKNODE(np); out: ncl_excl_finish(vp, old_lock); diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index f63eadf26a91..1685edf5b2de 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -2914,6 +2914,7 @@ ncl_flush(struct vnode *vp, int waitfor, struct thread *td, #endif struct buf *bvec_on_stack[NFS_COMMITBVECSIZ]; u_int bvecsize = 0, bveccount; + struct timespec ts; if (called_from_renewthread != 0) slptimeo = hz; @@ -3234,6 +3235,12 @@ done: vn_printf(vp, "ncl_flush failed"); error = called_from_renewthread != 0 ? EIO : EBUSY; } + if (error == 0) { + nanouptime(&ts); + NFSLOCKNODE(np); + np->n_localmodtime = ts; + NFSUNLOCKNODE(np); + } return (error); } From nobody Sun Oct 31 01:05:20 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E7C5C181AB56; Sun, 31 Oct 2021 01:05:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhdJ06DcSz3N6G; Sun, 31 Oct 2021 01:05:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B5EE514E8E; Sun, 31 Oct 2021 01:05:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19V15KFC015480; Sun, 31 Oct 2021 01:05:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19V15K6k015479; Sun, 31 Oct 2021 01:05:20 GMT (envelope-from git) Date: Sun, 31 Oct 2021 01:05:20 GMT Message-Id: <202110310105.19V15K6k015479@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b4c7d45c8490 - main - sys/proc.h: put proc_add_orphan() into proper place List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b4c7d45c849071b31936fec6ec43f3d4df3ef3d8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b4c7d45c849071b31936fec6ec43f3d4df3ef3d8 commit b4c7d45c849071b31936fec6ec43f3d4df3ef3d8 Author: Konstantin Belousov AuthorDate: 2021-10-29 22:02:32 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-31 01:05:14 +0000 sys/proc.h: put proc_add_orphan() into proper place Noted by: markj Reviewed by: emaste, markjd Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32738 --- sys/sys/proc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 177efd5257af..6bc9c82bb698 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1127,6 +1127,7 @@ int p_canwait(struct thread *td, struct proc *p); struct pargs *pargs_alloc(int len); void pargs_drop(struct pargs *pa); void pargs_hold(struct pargs *pa); +void proc_add_orphan(struct proc *child, struct proc *parent); int proc_getargv(struct thread *td, struct proc *p, struct sbuf *sb); int proc_getauxv(struct thread *td, struct proc *p, struct sbuf *sb); int proc_getenvv(struct thread *td, struct proc *p, struct sbuf *sb); @@ -1137,7 +1138,6 @@ void proc_linkup(struct proc *p, struct thread *td); struct proc *proc_realparent(struct proc *child); void proc_reap(struct thread *td, struct proc *p, int *status, int options); void proc_reparent(struct proc *child, struct proc *newparent, bool set_oppid); -void proc_add_orphan(struct proc *child, struct proc *parent); void proc_set_traced(struct proc *p, bool stop); void proc_wkilled(struct proc *p); struct pstats *pstats_alloc(void); From nobody Sun Oct 31 01:05:21 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 62C02181AE98; Sun, 31 Oct 2021 01:05:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhdJ21TJlz3NB1; Sun, 31 Oct 2021 01:05:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F35FB14CBD; Sun, 31 Oct 2021 01:05:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19V15Lhc015506; Sun, 31 Oct 2021 01:05:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19V15Lnw015505; Sun, 31 Oct 2021 01:05:21 GMT (envelope-from git) Date: Sun, 31 Oct 2021 01:05:21 GMT Message-Id: <202110310105.19V15Lnw015505@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f34fc6ba06a1 - main - Extract proc_get_binpath() from sysctl_kern_proc_pathname() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f34fc6ba06a10e0f2a505ec0dd2f2fab2a79e53d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f34fc6ba06a10e0f2a505ec0dd2f2fab2a79e53d commit f34fc6ba06a10e0f2a505ec0dd2f2fab2a79e53d Author: Konstantin Belousov AuthorDate: 2021-10-29 01:42:59 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-31 01:05:14 +0000 Extract proc_get_binpath() from sysctl_kern_proc_pathname() Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32738 --- sys/kern/kern_proc.c | 89 +++++++++++++++++++++++++++++++++------------------- sys/sys/proc.h | 2 ++ 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index c4c01da1faea..2156c5c465ba 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2226,41 +2226,34 @@ sysctl_kern_proc_auxv(SYSCTL_HANDLER_ARGS) } /* - * This sysctl allows a process to retrieve the path of the executable for - * itself or another process. + * Look up the canonical executable path running in the specified process. + * It tries to return the same hardlink name as was used for execve(2). + * This allows the programs that modify their behavior based on their progname, + * to operate correctly. + * + * Result is returned in retbuf, it must not be freed, similar to vn_fullpath() + * calling conventions. + * binname is a pointer to temporary string buffer of length MAXPATHLEN, + * allocated and freed by caller. + * freebuf should be freed by caller, from the M_TEMP malloc type. */ -static int -sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS) +int +proc_get_binpath(struct proc *p, char *binname, char **retbuf, + char **freebuf) { - pid_t *pidp = (pid_t *)arg1; - unsigned int arglen = arg2; - struct proc *p; - struct vnode *vp, *dvp; - char *retbuf, *freebuf, *binname; struct nameidata nd; + struct vnode *vp, *dvp; size_t freepath_size; int error; bool do_fullpath; - if (arglen != 1) - return (EINVAL); - binname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); - binname[0] = '\0'; - if (*pidp == -1) { /* -1 means this process */ - p = req->td->td_proc; - } else { - error = pget(*pidp, PGET_CANSEE, &p); - if (error != 0) { - free(binname, M_TEMP); - return (error); - } - } + PROC_LOCK_ASSERT(p, MA_OWNED); vp = p->p_textvp; if (vp == NULL) { - if (*pidp != -1) - PROC_UNLOCK(p); - free(binname, M_TEMP); + PROC_UNLOCK(p); + *retbuf = NULL; + *freebuf = NULL; return (0); } vref(vp); @@ -2269,20 +2262,20 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS) vref(dvp); if (p->p_binname != NULL) strlcpy(binname, p->p_binname, MAXPATHLEN); - if (*pidp != -1) - PROC_UNLOCK(p); + PROC_UNLOCK(p); + do_fullpath = true; - freebuf = NULL; + *freebuf = NULL; if (dvp != NULL && binname[0] != '\0') { freepath_size = MAXPATHLEN; if (vn_fullpath_hardlink(vp, dvp, binname, strlen(binname), - &retbuf, &freebuf, &freepath_size) == 0) { + retbuf, freebuf, &freepath_size) == 0) { /* * Recheck the looked up path. The binary * might have been renamed or replaced, in * which case we should not report old name. */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, retbuf, + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, *retbuf, req->td); error = namei(&nd); if (error == 0) { @@ -2294,13 +2287,43 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS) } } if (do_fullpath) { - free(freebuf, M_TEMP); - freebuf = NULL; - error = vn_fullpath(vp, &retbuf, &freebuf); + free(*freebuf, M_TEMP); + *freebuf = NULL; + error = vn_fullpath(vp, retbuf, freebuf); } vrele(vp); if (dvp != NULL) vrele(dvp); + return (error); +} + +/* + * This sysctl allows a process to retrieve the path of the executable for + * itself or another process. + */ +static int +sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS) +{ + pid_t *pidp = (pid_t *)arg1; + unsigned int arglen = arg2; + struct proc *p; + char *retbuf, *freebuf, *binname; + int error; + + if (arglen != 1) + return (EINVAL); + binname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); + binname[0] = '\0'; + if (*pidp == -1) { /* -1 means this process */ + error = 0; + p = req->td->td_proc; + PROC_LOCK(p); + } else { + error = pget(*pidp, PGET_CANSEE, &p); + } + + if (error == 0) + error = proc_get_binpath(p, binname, &retbuf, &freebuf); free(binname, M_TEMP); if (error != 0) return (error); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 6bc9c82bb698..de19bfc9cc3b 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1128,6 +1128,8 @@ struct pargs *pargs_alloc(int len); void pargs_drop(struct pargs *pa); void pargs_hold(struct pargs *pa); void proc_add_orphan(struct proc *child, struct proc *parent); +int proc_get_binpath(struct proc *p, char *binname, char **fullpath, + char **freepath); int proc_getargv(struct thread *td, struct proc *p, struct sbuf *sb); int proc_getauxv(struct thread *td, struct proc *p, struct sbuf *sb); int proc_getenvv(struct thread *td, struct proc *p, struct sbuf *sb); From nobody Sun Oct 31 01:05:22 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 774E8181AEA5; Sun, 31 Oct 2021 01:05:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhdJ31b7Pz3NB4; Sun, 31 Oct 2021 01:05:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0C9F714E4B; Sun, 31 Oct 2021 01:05:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19V15MQt015531; Sun, 31 Oct 2021 01:05:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19V15Mlv015530; Sun, 31 Oct 2021 01:05:22 GMT (envelope-from git) Date: Sun, 31 Oct 2021 01:05:22 GMT Message-Id: <202110310105.19V15Mlv015530@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: e5248548f95f - main - procfs: return right hardlink from /proc/curproc/file List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e5248548f95ff1c89667847e0d945dea38adeca7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e5248548f95ff1c89667847e0d945dea38adeca7 commit e5248548f95ff1c89667847e0d945dea38adeca7 Author: Konstantin Belousov AuthorDate: 2021-10-29 01:43:32 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-31 01:05:14 +0000 procfs: return right hardlink from /proc/curproc/file Use proc_get_binpath() to get the hardlink right. PR: 248184 Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32738 --- sys/fs/procfs/procfs.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c index c492533c52bb..697bbfc9877a 100644 --- a/sys/fs/procfs/procfs.c +++ b/sys/fs/procfs/procfs.c @@ -69,22 +69,17 @@ int procfs_doprocfile(PFS_FILL_ARGS) { - char *fullpath; - char *freepath; - struct vnode *textvp; + char *fullpath, *freepath, *binpath; int error; freepath = NULL; + binpath = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); PROC_LOCK(p); - textvp = p->p_textvp; - vhold(textvp); - PROC_UNLOCK(p); - error = vn_fullpath(textvp, &fullpath, &freepath); - vdrop(textvp); + error = proc_get_binpath(p, binpath, &fullpath, &freepath); if (error == 0) - sbuf_printf(sb, "%s", fullpath); - if (freepath != NULL) - free(freepath, M_TEMP); + sbuf_printf(sb, "%s", fullpath == NULL ? "" : fullpath); + free(binpath, M_TEMP); + free(freepath, M_TEMP); return (error); } From nobody Sun Oct 31 01:45:38 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E057A182D294; Sun, 31 Oct 2021 01:45:46 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HhfBf3TdTz3q0M; Sun, 31 Oct 2021 01:45:46 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.16.1/8.16.1) with ESMTPS id 19V1jcVL035253 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 30 Oct 2021 18:45:38 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 19V1jcdl035252; Sat, 30 Oct 2021 18:45:38 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Sat, 30 Oct 2021 18:45:38 -0700 From: Gleb Smirnoff To: Kubilay Kocak Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 92b3e07229ba - main - Enable net.inet.tcp.nolocaltimewait. Message-ID: References: <202110282235.19SMZoAL076017@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4HhfBf3TdTz3q0M 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:27348, ipnet:162.251.186.0/24, country:US] X-ThisMailContainsUnwantedMimeParts: N On Sat, Oct 30, 2021 at 11:25:12AM +1100, Kubilay Kocak wrote: K> On 29/10/2021 9:35 am, Gleb Smirnoff wrote: K> > The branch main has been updated by glebius: K> > K> > URL: https://cgit.FreeBSD.org/src/commit/?id=92b3e07229baab17cbe258ff1081e66bb7913b31 K> > K> > commit 92b3e07229baab17cbe258ff1081e66bb7913b31 K> > Author: Gleb Smirnoff K> > AuthorDate: 2021-10-28 22:34:00 +0000 K> > Commit: Gleb Smirnoff K> > CommitDate: 2021-10-28 22:34:00 +0000 K> > K> > Enable net.inet.tcp.nolocaltimewait. K> > K> > This feature has been used for many years at large sites and K> > didn't show any pitfalls. K> K> RELNOTES: ? Probably would be useful. Thanks! -- Gleb Smirnoff From nobody Sun Oct 31 06:10:06 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AE9C5182B2AE; Sun, 31 Oct 2021 06:10:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hhm3f70nPz3t4Z; Sun, 31 Oct 2021 06:10:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BF35C18C25; Sun, 31 Oct 2021 06:10:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19V6A6dA016719; Sun, 31 Oct 2021 06:10:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19V6A6M9016716; Sun, 31 Oct 2021 06:10:06 GMT (envelope-from git) Date: Sun, 31 Oct 2021 06:10:06 GMT Message-Id: <202110310610.19V6A6M9016716@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Xin LI Subject: git: f38bef2ce417 - main - Bump __FreeBSD_version following the libdialog shared library version number bump. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f38bef2ce417d6270f32b4ed17cec84bfd95d548 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=f38bef2ce417d6270f32b4ed17cec84bfd95d548 commit f38bef2ce417d6270f32b4ed17cec84bfd95d548 Author: Xin LI AuthorDate: 2021-10-31 06:09:29 +0000 Commit: Xin LI CommitDate: 2021-10-31 06:09:29 +0000 Bump __FreeBSD_version following the libdialog shared library version number bump. --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 42e200de2eae..f4beaf0ec408 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400039 +#define __FreeBSD_version 1400040 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Sun Oct 31 19:12:14 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 318F018220B1; Sun, 31 Oct 2021 19:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hj5Q70WD8z3QsF; Sun, 31 Oct 2021 19:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E611B2350C; Sun, 31 Oct 2021 19:12:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19VJCE62065424; Sun, 31 Oct 2021 19:12:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19VJCEvt065423; Sun, 31 Oct 2021 19:12:14 GMT (envelope-from git) Date: Sun, 31 Oct 2021 19:12:14 GMT Message-Id: <202110311912.19VJCEvt065423@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 917181dddf66 - main - net80211: add a driver-private pointer to struct ieee80211_node List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 917181dddf66a02958cf0a28e0c7c69e13e21af0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=917181dddf66a02958cf0a28e0c7c69e13e21af0 commit 917181dddf66a02958cf0a28e0c7c69e13e21af0 Author: Bjoern A. Zeeb AuthorDate: 2021-10-31 19:08:28 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-10-31 19:08:28 +0000 net80211: add a driver-private pointer to struct ieee80211_node Add a void *ni_drv_data field to struct ieee80211_node that drivers can use to backtrack to their internal state from a net80211 node. Sponsored by: The FreeBSD Foundation MFC after: 1 week X-Differential Revision: https://reviews.freebsd.org/D30654 (abandoned) --- sys/net80211/ieee80211_node.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index 07144fa0adb3..0e885440687c 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -260,6 +260,8 @@ struct ieee80211_node { /* U-APSD */ uint8_t ni_uapsd; /* U-APSD per-node flags matching WMM STA QoS Info field */ + void *ni_drv_data; /* driver specific */ + uint64_t ni_spare[3]; }; MALLOC_DECLARE(M_80211_NODE); From nobody Sun Oct 31 20:41:52 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0F5781823569; Sun, 31 Oct 2021 20:41:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hj7PX6w15z4bnF; Sun, 31 Oct 2021 20:41:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CEB1724843; Sun, 31 Oct 2021 20:41:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19VKfq9I085623; Sun, 31 Oct 2021 20:41:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19VKfqP5085622; Sun, 31 Oct 2021 20:41:52 GMT (envelope-from git) Date: Sun, 31 Oct 2021 20:41:52 GMT Message-Id: <202110312041.19VKfqP5085622@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 627d5d19664f - main - geli: eli data -> eli_data for consistency with other geom classes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 627d5d19664f8a7fc4c9c952ac4b15f8c9f29e95 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=627d5d19664f8a7fc4c9c952ac4b15f8c9f29e95 commit 627d5d19664f8a7fc4c9c952ac4b15f8c9f29e95 Author: Mateusz Guzik AuthorDate: 2021-10-31 20:36:51 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-31 20:36:51 +0000 geli: eli data -> eli_data for consistency with other geom classes PR: 259392 Reported by: dewayne@heuristicsystems.com.au MFC after: 1 week --- sys/geom/eli/g_eli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index c2fdb70980c0..095d5cd2c274 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); FEATURE(geom_eli, "GEOM crypto module"); -MALLOC_DEFINE(M_ELI, "eli data", "GEOM_ELI Data"); +MALLOC_DEFINE(M_ELI, "eli_data", "GEOM_ELI Data"); SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, eli, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, From nobody Sun Oct 31 23:35:24 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 988B21830E58; Sun, 31 Oct 2021 23:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjCFm3rj5z3pHL; Sun, 31 Oct 2021 23:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C41B26C23; Sun, 31 Oct 2021 23:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19VNZOE5012012; Sun, 31 Oct 2021 23:35:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19VNZO2M012011; Sun, 31 Oct 2021 23:35:24 GMT (envelope-from git) Date: Sun, 31 Oct 2021 23:35:24 GMT Message-Id: <202110312335.19VNZO2M012011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: d5d2ce1c8550 - main - nfscl: Do pNFS layout return_on_close synchronously List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d5d2ce1c8550a41e7374893ccd864c172461221f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=d5d2ce1c8550a41e7374893ccd864c172461221f commit d5d2ce1c8550a41e7374893ccd864c172461221f Author: Rick Macklem AuthorDate: 2021-10-31 23:31:31 +0000 Commit: Rick Macklem CommitDate: 2021-10-31 23:31:31 +0000 nfscl: Do pNFS layout return_on_close synchronously For pNFS servers that specify that Layouts are to be returned upon close, they may expect that LayoutReturn to happen before the associated Close. This patch modifies the NFSv4.1/4.2 pNFS client so that this is done. This only affects a pNFS mount against a non-FreeBSD NFSv4.1/4.2 server that specifies return_on_close in LayoutGet replies. Found during a recent IETF NFSv4 working group testing event. MFC after: 2 weeks --- sys/fs/nfs/nfsclstate.h | 1 + sys/fs/nfsclient/nfs_clstate.c | 63 ++++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/sys/fs/nfs/nfsclstate.h b/sys/fs/nfs/nfsclstate.h index 898a7de391dc..03400a2cdea5 100644 --- a/sys/fs/nfs/nfsclstate.h +++ b/sys/fs/nfs/nfsclstate.h @@ -273,6 +273,7 @@ struct nfscllayout { #define NFSLY_RETONCLOSE 0x0080 #define NFSLY_WRITTEN 0x0100 /* Has been used to write to a DS. */ #define NFSLY_FLEXFILE 0x0200 +#define NFSLY_RETURNED 0x0400 /* * Flex file layout mirror specific stuff for nfsclflayout. diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 549d2f8ff538..523cc59039af 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -127,7 +127,7 @@ static struct nfsclclient *nfscl_getclntsess(uint8_t *); static struct nfscldeleg *nfscl_finddeleg(struct nfsclclient *, u_int8_t *, int); static void nfscl_retoncloselayout(vnode_t, struct nfsclclient *, uint8_t *, - int, struct nfsclrecalllayout **); + int, struct nfsclrecalllayout **, struct nfscllayout **); static void nfscl_reldevinfo_locked(struct nfscldevinfo *); static struct nfscllayout *nfscl_findlayout(struct nfsclclient *, u_int8_t *, int); @@ -2934,7 +2934,8 @@ tryagain2: while (lyp != NULL) { nlyp = TAILQ_PREV(lyp, nfscllayouthead, nfsly_list); if (lyp->nfsly_timestamp < NFSD_MONOSEC && - (lyp->nfsly_flags & NFSLY_RECALL) == 0 && + (lyp->nfsly_flags & (NFSLY_RECALL | + NFSLY_RETONCLOSE)) == 0 && lyp->nfsly_lock.nfslock_usecnt == 0 && lyp->nfsly_lock.nfslock_lock == 0) { NFSCL_DEBUG(4, "ret stale lay=%d\n", @@ -2969,7 +2970,13 @@ tryagain2: TAILQ_REMOVE(&rlh, lyp, nfsly_list); NFSCL_DEBUG(4, "ret layout\n"); nfscl_layoutreturn(clp->nfsc_nmp, lyp, cred, p); - nfscl_freelayout(lyp); + if ((lyp->nfsly_flags & NFSLY_RETONCLOSE) != 0) { + NFSLOCKCLSTATE(); + lyp->nfsly_flags |= NFSLY_RETURNED; + wakeup(lyp); + NFSUNLOCKCLSTATE(); + } else + nfscl_freelayout(lyp); } /* @@ -3334,6 +3341,7 @@ nfscl_doclose(vnode_t vp, struct nfsclclient **clpp, NFSPROC_T *p) struct nfscldeleg *dp; struct nfsfh *nfhp; struct nfsclrecalllayout *recallp; + struct nfscllayout *lyp; int error; error = nfscl_getcl(vp->v_mount, NULL, NULL, false, true, &clp); @@ -3363,7 +3371,8 @@ nfscl_doclose(vnode_t vp, struct nfsclclient **clpp, NFSPROC_T *p) } /* Return any layouts marked return on close. */ - nfscl_retoncloselayout(vp, clp, nfhp->nfh_fh, nfhp->nfh_len, &recallp); + nfscl_retoncloselayout(vp, clp, nfhp->nfh_fh, nfhp->nfh_len, &recallp, + &lyp); /* Now process the opens against the server. */ LIST_INIT(&delayed); @@ -3394,6 +3403,20 @@ lookformore: } } nfscl_clrelease(clp); + + /* Now, wait for any layout that is returned upon close. */ + if (lyp != NULL) { + while ((lyp->nfsly_flags & NFSLY_RETURNED) == 0) { + if (NFSCL_FORCEDISM(nmp->nm_mountp)) { + lyp = NULL; + break; + } + msleep(lyp, NFSCLSTATEMUTEXPTR, PZERO, "nfslroc", hz); + } + if (lyp != NULL) + nfscl_freelayout(lyp); + } + NFSUNLOCKCLSTATE(); /* * recallp has been set NULL by nfscl_retoncloselayout() if it was @@ -5233,28 +5256,34 @@ nfscl_getlayout(struct nfsclclient *clp, uint8_t *fhp, int fhlen, */ static void nfscl_retoncloselayout(vnode_t vp, struct nfsclclient *clp, uint8_t *fhp, - int fhlen, struct nfsclrecalllayout **recallpp) + int fhlen, struct nfsclrecalllayout **recallpp, struct nfscllayout **lypp) { struct nfscllayout *lyp; uint32_t iomode; + *lypp = NULL; if (vp->v_type != VREG || !NFSHASPNFS(VFSTONFS(vp->v_mount)) || nfscl_enablecallb == 0 || nfs_numnfscbd == 0 || (VTONFS(vp)->n_flag & NNOLAYOUT) != 0) return; lyp = nfscl_findlayout(clp, fhp, fhlen); - if (lyp != NULL && (lyp->nfsly_flags & (NFSLY_RETONCLOSE | - NFSLY_RECALL)) == NFSLY_RETONCLOSE) { - iomode = 0; - if (!LIST_EMPTY(&lyp->nfsly_flayread)) - iomode |= NFSLAYOUTIOMODE_READ; - if (!LIST_EMPTY(&lyp->nfsly_flayrw)) - iomode |= NFSLAYOUTIOMODE_RW; - (void)nfscl_layoutrecall(NFSLAYOUTRETURN_FILE, lyp, iomode, - 0, UINT64_MAX, lyp->nfsly_stateid.seqid, 0, 0, NULL, - *recallpp); - NFSCL_DEBUG(4, "retoncls recall iomode=%d\n", iomode); - *recallpp = NULL; + if (lyp != NULL && (lyp->nfsly_flags & NFSLY_RETONCLOSE) != 0) { + if ((lyp->nfsly_flags & NFSLY_RECALL) == 0) { + iomode = 0; + if (!LIST_EMPTY(&lyp->nfsly_flayread)) + iomode |= NFSLAYOUTIOMODE_READ; + if (!LIST_EMPTY(&lyp->nfsly_flayrw)) + iomode |= NFSLAYOUTIOMODE_RW; + nfscl_layoutrecall(NFSLAYOUTRETURN_FILE, lyp, iomode, + 0, UINT64_MAX, lyp->nfsly_stateid.seqid, 0, 0, NULL, + *recallpp); + NFSCL_DEBUG(4, "retoncls recall iomode=%d\n", iomode); + *recallpp = NULL; + } + + /* Now, wake up renew thread to do LayoutReturn. */ + wakeup(clp); + *lypp = lyp; } }