From nobody Mon Nov 1 02:26: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 C178E1830A7D; Mon, 1 Nov 2021 02:27:06 +0000 (UTC) (envelope-from kpn@neutralgood.org) Received: from gunsight1.neutralgood.org (gunsight1.neutralgood.org [IPv6:2607:f758:2280:1:d6be:d9ff:feac:a1e9]) (using TLSv1.3 with cipher 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 "gunsight1.neutralgood.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjH3s5QxGz3QZZ; Mon, 1 Nov 2021 02:27:05 +0000 (UTC) (envelope-from kpn@neutralgood.org) Received: from gunsight1.NeutralGood.ORG (localhost [127.0.0.1]) by gunsight1.neutralgood.org (8.16.1/8.15.2) with ESMTPS id 1A12Qf0V051124 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 31 Oct 2021 22:26:41 -0400 (EDT) (envelope-from kpn@gunsight1.NeutralGood.ORG) Received: (from kpn@localhost) by gunsight1.NeutralGood.ORG (8.16.1/8.15.2/Submit) id 1A12Qc9J051121; Sun, 31 Oct 2021 22:26:38 -0400 (EDT) (envelope-from kpn) Date: Sun, 31 Oct 2021 22:26:38 -0400 From: "Kevin P. Neal" To: Emmanuel Vadot Cc: Benjamin Kaduk , "Rodney W. Grimes" , "Rodney W. Grimes" , gljennjohn@gmail.com, Gleb Smirnoff , Slawa Olhovchenkov , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 225639e7db68 - main - vt: Disable bell by default Message-ID: References: <20211021192020.6dcb95c1@ernst.home> <202110221704.19MH4FDn075994@gndrsh.dnsmgr.net> <20211022194717.8c94d2fa302339b55882497f@bidouilliste.com> <20211022225540.a4220cfddc96cc1e08cb5235@bidouilliste.com> 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: <20211022225540.a4220cfddc96cc1e08cb5235@bidouilliste.com> X-No-archive: Yes X-Rspamd-Queue-Id: 4HjH3s5QxGz3QZZ X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of kpn@neutralgood.org designates 2607:f758:2280:1:d6be:d9ff:feac:a1e9 as permitted sender) smtp.mailfrom=kpn@neutralgood.org X-Spamd-Result: default: False [-1.77 / 15.00]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.02)[-0.021]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.00)[-0.999]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[neutralgood.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.45)[-0.446]; RCPT_COUNT_SEVEN(0.00)[10]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:13649, ipnet:2607:f758::/32, country:US]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org,gndrsh.dnsmgr.net,zxy.spb.ru] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N On Fri, Oct 22, 2021 at 10:55:40PM +0200, Emmanuel Vadot wrote: > If I knew that this change would have caused that much mails I would > have send a mail to current or whatever before and left the review > opened for more time. Is this exposing an issue with the review process? I don't know the FreeBSD review process, but I do know the LLVM one. Now, LLVM has a different set of people in the project. That means that what works over there might not be a good fit here. I thought I'd mention it just the same. On the LLVM project they don't allow code that is up for review to be pushed without an explicit signoff from one of the reviewers. Period. There's _no_ putting code up for review, waiting, and then going ahead and pushing. If there's no feedback for a while the person asking for the review will add a message every week or two that says just "ping". This often nudges people to get to the review. Not always, and it can take a while to get code through, but that's the process. Changes are allowed without a review if they are "obvious". If someone pushes a change that another committer doesn't feel is obvious then the change is reverted, usually by the person who cares. Personally, I've never had this happen, but my non-review pushes are usually either new tests or fixes to broken builds. -- Kevin P. Neal http://www.pobox.com/~kpn/ "It sounded pretty good, but it's hard to tell how it will work out in practice." -- Dennis Ritchie, ~1977, "Summary of a DEC 32-bit machine" From nobody Mon Nov 1 02:38: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 E9F851836FD2; Mon, 1 Nov 2021 02:38: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 4HjHKV6Kq3z3kR3; Mon, 1 Nov 2021 02:38: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 B923D1242; Mon, 1 Nov 2021 02:38:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A12csHm052790; Mon, 1 Nov 2021 02:38:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A12csuF052789; Mon, 1 Nov 2021 02:38:54 GMT (envelope-from git) Date: Mon, 1 Nov 2021 02:38:54 GMT Message-Id: <202111010238.1A12csuF052789@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: 4f889260c33c - main - sinpi[fl] etc: Fix the ld128 implementations 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: 4f889260c33c163ab28e0e082b4d7e7562d9c647 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4f889260c33c163ab28e0e082b4d7e7562d9c647 commit 4f889260c33c163ab28e0e082b4d7e7562d9c647 Author: Steve Kargl AuthorDate: 2021-10-31 22:26:20 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-01 02:38:19 +0000 sinpi[fl] etc: Fix the ld128 implementations Mark Murray graciously provided access to an aarch64 system to test the ld128 implementations. This patch address * Misuses of copysignl() in sinpil() and tanpil(). * Redo the splitting of argument 'x' into an integer part and remainder. The remainder must satify 0 <= r < 1. * Update the reduction of the integer part to something that can easily be seen as even or odd, e.g., sin(pi*x) = (-1)^n*sin(pi*r) with n <= 2^112 and we an reduce n by subtracting integer powers of 2. * In s_cospil.c, fix typos where 'x' is used where 'ax', the remainder, is required. * In tanpil(), fix the use of an uninitialized variable, ax = fabsl(ax), ax should be x in fabsl(). One item of note, in the limited tested on aarch64, the max ULP for sinpil() and cospil() were less than 1.1 ULP, which is higher that the desired max ULP less than 1. This was traced to the kernel for cosl() in the fundamental interval [0,pi/4]. The coefficients in the minmax polynomial likely need refinement. PR: 218514 MFC after: 1 week --- lib/msun/ld128/s_cospil.c | 31 +++++++++++++++++-------------- lib/msun/ld128/s_sinpil.c | 29 ++++++++++++++++------------- lib/msun/ld128/s_tanpil.c | 23 +++++++++++++---------- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/lib/msun/ld128/s_cospil.c b/lib/msun/ld128/s_cospil.c index b4bc50bb4d89..71acc4485f7b 100644 --- a/lib/msun/ld128/s_cospil.c +++ b/lib/msun/ld128/s_cospil.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2017 Steven G. Kargl + * Copyright (c) 2017-2021 Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,9 +26,6 @@ /* * 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" @@ -54,7 +51,7 @@ cospil(long double x) ax = fabsl(x); - if (ax < 1) { + if (ax <= 1) { if (ax < 0.25) { if (ax < 0x1p-60) { if ((int)x == 0) @@ -75,15 +72,21 @@ cospil(long double x) } if (ax < 0x1p112) { - xf = floorl(ax); - ax -= xf; - if (x < 0.5) { - if (x < 0.25) + /* Split x = n + r with 0 <= r < 1. */ + xf = (ax + 0x1p112L) - 0x1p112L; /* Integer part */ + ax -= xf; /* Remainder */ + if (ax < 0) { + ax += 1; + xf -= 1; + } + + if (ax < 0.5) { + if (ax < 0.25) c = ax == 0 ? 1 : __kernel_cospil(ax); else c = __kernel_sinpil(0.5 - ax); } else { - if (x < 0.75) { + if (ax < 0.75) { if (ax == 0.5) return (0); c = -__kernel_sinpil(ax - 0.5); @@ -91,10 +94,10 @@ cospil(long double x) c = -__kernel_cospil(1 - ax); } - if (xf > 0x1p50) - xf -= 0x1p50; - if (xf > 0x1p30) - xf -= 0x1p30; + if (xf > 0x1p64) + xf -= 0x1p64; + if (xf > 0x1p32) + xf -= 0x1p32; ix = (uint32_t)xf; return (ix & 1 ? -c : c); } diff --git a/lib/msun/ld128/s_sinpil.c b/lib/msun/ld128/s_sinpil.c index 39eed9b007bc..cdfa2bcac3ef 100644 --- a/lib/msun/ld128/s_sinpil.c +++ b/lib/msun/ld128/s_sinpil.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2017 Steven G. Kargl + * Copyright (c) 2017-2021 Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,9 +26,6 @@ /* * 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" @@ -68,7 +65,7 @@ sinpil(long double x) } s = __kernel_sinpil(ax); - return (copysignl(s, x)); + return (x < 0 ? -s : s); } if (ax < 0.5) @@ -77,12 +74,18 @@ sinpil(long double x) s = __kernel_cospil(ax - 0.5); else s = __kernel_sinpil(1 - ax); - return (copysignl(s, x)); + return (x < 0 ? -s : s); } if (ax < 0x1p112) { - xf = floorl(ax); - ax -= xf; + /* Split x = n + r with 0 <= r < 1. */ + xf = (ax + 0x1p112L) - 0x1p112L; /* Integer part */ + ax -= xf; /* Remainder */ + if (ax < 0) { + ax += 1; + xf -= 1; + } + if (ax == 0) { s = 0; } else { @@ -98,14 +101,14 @@ sinpil(long double x) s = __kernel_sinpil(1 - ax); } - if (xf > 0x1p50) - xf -= 0x1p50; - if (xf > 0x1p30) - xf -= 0x1p30; + if (xf > 0x1p64) + xf -= 0x1p64; + if (xf > 0x1p32) + xf -= 0x1p32; ix = (uint32_t)xf; if (ix & 1) s = -s; } - return (copysignl(s, x)); + return (x < 0 ? -s : s); } if (isinf(x) || isnan(x)) diff --git a/lib/msun/ld128/s_tanpil.c b/lib/msun/ld128/s_tanpil.c index 7cbbdc8a5d05..90f4aea5c629 100644 --- a/lib/msun/ld128/s_tanpil.c +++ b/lib/msun/ld128/s_tanpil.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2017 Steven G. Kargl + * Copyright (c) 2017-2021 Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,9 +26,6 @@ /* * 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" @@ -75,7 +72,7 @@ tanpil(long double x) long double ax, hi, lo, xf, t; uint32_t ix; - ax = fabsl(ax); + ax = fabsl(x); if (ax < 1) { if (ax < 0.5) { @@ -94,19 +91,25 @@ tanpil(long double x) return ((ax - ax) / (ax - ax)); else t = -__kernel_tanpil(1 - ax); - return (copysignl(t, x)); + return (x < 0 ? -t : t); } if (ix < 0x1p112) { - xf = floorl(ax); - ax -= xf; + /* Split x = n + r with 0 <= r < 1. */ + xf = (ax + 0x1p112L) - 0x1p112L; /* Integer part */ + ax -= xf; /* Remainder */ + if (ax < 0) { + ax += 1; + xf -= 1; + } + 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)); + return (x < 0 ? -t : t); } /* x = +-inf or nan. */ @@ -114,7 +117,7 @@ tanpil(long double x) return (vzero / vzero); /* - * |x| >= 0x1p53 is always an integer, so return +-0. + * |x| >= 0x1p112 is always an integer, so return +-0. */ return (copysignl(0, x)); } From nobody Mon Nov 1 02:40: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 B13F7183777E for ; Mon, 1 Nov 2021 02:40:48 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) (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 4HjHMh46wbz3kwv for ; Mon, 1 Nov 2021 02:40:48 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-ua1-x931.google.com with SMTP id ay21so8832511uab.12 for ; Sun, 31 Oct 2021 19:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=idIjZiIz+q+FX7mMgYEwOPjThaHYMb0fyNFuIraC/II=; b=ysnsF+evIV3nBz2EsgV0OQdTiuufl2WeaBMxq5BgnZjbwVhI6mlE8wlm8Ke4s4a3c5 M/fpF/XNbGDLAnjg0hImtDwXZduHxfoRTSa4BZapOa4WVVVebtfEjbpF2Ry5eETHFXFX /p58LxIhR7GV8PqoLRSec3FZ2e0korM22VrPhPdreBxujZjvZeJJLv0M2p1jlfGaSbn8 wSXTzhl9JU6xeSRpIFIRC9Emg7aPKMrDQehg7y9Zkbnp6th/87yxURlUVqwhf1YfNYP+ eMciKWJMUVx0t8sBJro+zysOpP+hl4eL8/W4bHkoViexQfQVR9WslP7LYU5DSltfyc0o zmxQ== 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=idIjZiIz+q+FX7mMgYEwOPjThaHYMb0fyNFuIraC/II=; b=WLav7wu7uzWTQmh4WCf+wQeNBA3cSpwWC9aXnxxxPVb7y9jIv3DmZnnCgex2kkP3Oc jrug2uiU/nyDRYUyM0YlVxa0N8raF9TrnBfPGCMfYOJMfPYoJNqlkrRo9vSUeJhurSxs gaW/iMms7X4ZWoIc/SxT68xuPpvASBj3Wl35GQhYVsXHmuNKPxGTPh9YOMEni8n1dJgm tS/ySI3krNgg/zYrHpJxYXXD7PE1axdDKmu6LADLxvqTklkGk2sLxWfjROd8cAj+KnqC 0hxHQjnbk8GXAwMBpvikSfigUPisMjLoG+ankZBHcJ2zqfCQuG8FQAw+S1jM1DbMES0M 9/iQ== X-Gm-Message-State: AOAM5337G53MMEY5D7tGr5vXCzr9i2oU5Iu5GUqq8PE9yqrvUrXkdlP9 jFeQIMy/1lq7Mx8JmDqd8eGk5cH9pJAJ+e9YyCLLPw== X-Google-Smtp-Source: ABdhPJyAyxrkphwijiCWhF294KjHmL+yTBvf26QXxT4OdA4z5+CPX3e4U54U1aYU+FXYpgjZOuTCZk8F4j85NgILlXw= X-Received: by 2002:ab0:3d07:: with SMTP id f7mr4012209uax.11.1635734442241; Sun, 31 Oct 2021 19:40:42 -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: <20211021192020.6dcb95c1@ernst.home> <202110221704.19MH4FDn075994@gndrsh.dnsmgr.net> <20211022194717.8c94d2fa302339b55882497f@bidouilliste.com> <20211022225540.a4220cfddc96cc1e08cb5235@bidouilliste.com> In-Reply-To: From: Warner Losh Date: Sun, 31 Oct 2021 20:40:31 -0600 Message-ID: Subject: Re: git: 225639e7db68 - main - vt: Disable bell by default To: "Kevin P. Neal" Cc: Emmanuel Vadot , Benjamin Kaduk , "Rodney W. Grimes" , "Rodney W. Grimes" , Gary Jennejohn , Gleb Smirnoff , Slawa Olhovchenkov , src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="00000000000060818305cfb11a3d" X-Rspamd-Queue-Id: 4HjHMh46wbz3kwv X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N --00000000000060818305cfb11a3d Content-Type: text/plain; charset="UTF-8" On Sun, Oct 31, 2021 at 8:27 PM Kevin P. Neal wrote: > On Fri, Oct 22, 2021 at 10:55:40PM +0200, Emmanuel Vadot wrote: > > If I knew that this change would have caused that much mails I would > > have send a mail to current or whatever before and left the review > > opened for more time. > > Is this exposing an issue with the review process? I don't know the FreeBSD > review process, but I do know the LLVM one. Now, LLVM has a different set > of people in the project. That means that what works over there might not > be a good fit here. I thought I'd mention it just the same. > > > On the LLVM project they don't allow code that is up for review to be > pushed without an explicit signoff from one of the reviewers. Period. > > There's _no_ putting code up for review, waiting, and then going ahead and > pushing. > > If there's no feedback for a while the person asking for the review will > add a message every week or two that says just "ping". This often nudges > people to get to the review. Not always, and it can take a while to get > code through, but that's the process. > > Changes are allowed without a review if they are "obvious". If someone > pushes a change that another committer doesn't feel is obvious then the > change is reverted, usually by the person who cares. Personally, I've never > had this happen, but my non-review pushes are usually either new tests or > fixes to broken builds. > I clicked approve on this quickly after manu posted it. There was little other comment. Seemed like a boring change. A better review process wouldn't have helped. Dozens of other boring commits have a very similar profile. Warner --00000000000060818305cfb11a3d-- From nobody Mon Nov 1 05:09: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 806A21833702; Mon, 1 Nov 2021 05:09: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 4HjLg83D6Dz3Bmh; Mon, 1 Nov 2021 05:09: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 4E65A36AD; Mon, 1 Nov 2021 05:09: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 1A159ODB054721; Mon, 1 Nov 2021 05:09:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A159OOo054720; Mon, 1 Nov 2021 05:09:24 GMT (envelope-from git) Date: Mon, 1 Nov 2021 05:09:24 GMT Message-Id: <202111010509.1A159OOo054720@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Philip Paeps Subject: git: e528757ca6a9 - main - iicoc: add support for SiFive HiFive Unmatched 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: philip X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e528757ca6a9c03dca7e35b77411b311af166b7f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=e528757ca6a9c03dca7e35b77411b311af166b7f commit e528757ca6a9c03dca7e35b77411b311af166b7f Author: Thomas Skibo AuthorDate: 2021-11-01 04:23:22 +0000 Commit: Philip Paeps CommitDate: 2021-11-01 04:26:49 +0000 iicoc: add support for SiFive HiFive Unmatched Reviewed by: jrtc27, philip MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D32737 --- sys/dev/iicbus/iicoc_fdt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/dev/iicbus/iicoc_fdt.c b/sys/dev/iicbus/iicoc_fdt.c index 699a1738f53b..052174a91134 100644 --- a/sys/dev/iicbus/iicoc_fdt.c +++ b/sys/dev/iicbus/iicoc_fdt.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); static struct ofw_compat_data compat_data[] = { { "opencores,i2c-ocores", 1 }, + { "sifive,fu740-c000-i2c", 1 }, + { "sifive,fu540-c000-i2c", 1 }, + { "sifive,i2c0", 1 }, { NULL, 0 } }; From nobody Mon Nov 1 05:09:25 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 B78B31833624; Mon, 1 Nov 2021 05:09:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjLg94BMHz4vkk; Mon, 1 Nov 2021 05:09:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 701A636B7; Mon, 1 Nov 2021 05:09:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A159PhX054745; Mon, 1 Nov 2021 05:09:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A159Pe2054744; Mon, 1 Nov 2021 05:09:25 GMT (envelope-from git) Date: Mon, 1 Nov 2021 05:09:25 GMT Message-Id: <202111010509.1A159Pe2054744@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Philip Paeps Subject: git: 2a36909a94be - main - iicoc: fix repeated start 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: philip X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2a36909a94be110c34128319536c1c595635aa2e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=2a36909a94be110c34128319536c1c595635aa2e commit 2a36909a94be110c34128319536c1c595635aa2e Author: Thomas Skibo AuthorDate: 2021-11-01 04:29:29 +0000 Commit: Philip Paeps CommitDate: 2021-11-01 04:29:29 +0000 iicoc: fix repeated start Reviewed by: jrtc27, philip MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D32737 --- sys/dev/iicbus/iicoc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/sys/dev/iicbus/iicoc.c b/sys/dev/iicbus/iicoc.c index e243e7128be7..f22878224c32 100644 --- a/sys/dev/iicbus/iicoc.c +++ b/sys/dev/iicbus/iicoc.c @@ -147,8 +147,8 @@ iicoc_init(device_t dev) return ((value & OC_CONTROL_EN) == 0); } -int -iicoc_iicbus_start(device_t dev, u_char slave, int timeout) +static int +iicoc_iicbus_start_common(device_t dev, u_char slave, int timeout, bool repeat) { int error = IIC_EBUSERR; struct iicoc_softc *sc; @@ -158,7 +158,7 @@ iicoc_iicbus_start(device_t dev, u_char slave, int timeout) sc->i2cdev_addr = (slave >> 1); /* Verify the bus is idle */ - if (iicoc_wait_on_status(dev, OC_STATUS_BUSY) < 0) + if (!repeat && iicoc_wait_on_status(dev, OC_STATUS_BUSY) < 0) goto i2c_stx_error; /* Write Slave Address */ @@ -186,6 +186,20 @@ i2c_stx_error: return (error); } +int +iicoc_iicbus_start(device_t dev, u_char slave, int timeout) +{ + + return (iicoc_iicbus_start_common(dev, slave, timeout, false)); +} + +int +iicoc_iicbus_repeated_start(device_t dev, u_char slave, int timeout) +{ + + return (iicoc_iicbus_start_common(dev, slave, timeout, true)); +} + int iicoc_iicbus_stop(device_t dev) { @@ -268,10 +282,3 @@ iicoc_iicbus_reset(device_t dev, u_char speed, u_char addr, u_char *oldadr) mtx_unlock(&sc->sc_mtx); return (error); } - -int -iicoc_iicbus_repeated_start(device_t dev, u_char slave, int timeout) -{ - - return 0; -} From nobody Mon Nov 1 05:09: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 9098218335C8; Mon, 1 Nov 2021 05:09: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 4HjLgB6158z3Bsh; Mon, 1 Nov 2021 05:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B8DB3660; Mon, 1 Nov 2021 05:09: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 1A159Q2c054769; Mon, 1 Nov 2021 05:09:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A159QCA054768; Mon, 1 Nov 2021 05:09:26 GMT (envelope-from git) Date: Mon, 1 Nov 2021 05:09:26 GMT Message-Id: <202111010509.1A159QCA054768@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Philip Paeps Subject: git: 99443830fa7c - main - iicoc: support building as a module 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: philip X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 99443830fa7c121af42a6af5971357f9ab52deff Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=99443830fa7c121af42a6af5971357f9ab52deff commit 99443830fa7c121af42a6af5971357f9ab52deff Author: Thomas Skibo AuthorDate: 2021-11-01 04:31:49 +0000 Commit: Philip Paeps CommitDate: 2021-11-01 04:33:39 +0000 iicoc: support building as a module Only build on RISC-V for now, since we're not aware of any other cores with this IP supported by FreeBSD. Reviewed by: jrtc27, philip MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D32737 --- sys/dev/iicbus/iicoc_fdt.c | 1 + sys/modules/i2c/controllers/Makefile | 3 +++ sys/modules/i2c/controllers/iicoc/Makefile | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/sys/dev/iicbus/iicoc_fdt.c b/sys/dev/iicbus/iicoc_fdt.c index 052174a91134..0bc25044a293 100644 --- a/sys/dev/iicbus/iicoc_fdt.c +++ b/sys/dev/iicbus/iicoc_fdt.c @@ -185,6 +185,7 @@ static driver_t iicoc_driver = { sizeof(struct iicoc_softc), }; +SIMPLEBUS_PNP_INFO(compat_data); DRIVER_MODULE(iicoc, simplebus, iicoc_driver, iicoc_devclass, 0, 0); DRIVER_MODULE(ofw_iicbus, iicoc, ofw_iicbus_driver, ofw_iicbus_devclass, 0, 0); MODULE_DEPEND(iicoc, iicbus, 1, 1, 1); diff --git a/sys/modules/i2c/controllers/Makefile b/sys/modules/i2c/controllers/Makefile index 8773bc09c030..3bae39c3b439 100644 --- a/sys/modules/i2c/controllers/Makefile +++ b/sys/modules/i2c/controllers/Makefile @@ -5,5 +5,8 @@ SUBDIR = alpm amdpm amdsmb ichiic ichsmb intpm ismt nfsmb viapm lpbb pcf .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" SUBDIR += imcsmb .endif +.if ${MACHINE_CPUARCH} == "riscv" +SUBDIR += iicoc +.endif .include diff --git a/sys/modules/i2c/controllers/iicoc/Makefile b/sys/modules/i2c/controllers/iicoc/Makefile new file mode 100644 index 000000000000..f6902f1f864a --- /dev/null +++ b/sys/modules/i2c/controllers/iicoc/Makefile @@ -0,0 +1,7 @@ +.PATH: ${SRCTOP}/sys/dev/iicbus + +KMOD = iicoc +SRCS = device_if.h bus_if.h iicbus_if.h \ + iicoc.c iicoc_fdt.c iicoc_pci.c + +.include From nobody Mon Nov 1 05:21: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 033F0182273E; Mon, 1 Nov 2021 05:21:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjLx46cqpz3HK0; Mon, 1 Nov 2021 05:21: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 C3FD92EEA; Mon, 1 Nov 2021 05:21: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 1A15LSAs079616; Mon, 1 Nov 2021 05:21:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A15LS5q079615; Mon, 1 Nov 2021 05:21:28 GMT (envelope-from git) Date: Mon, 1 Nov 2021 05:21:28 GMT Message-Id: <202111010521.1A15LS5q079615@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Philip Paeps Subject: git: 91feb4f42075 - main - riscv: add iicbus and iicoc to GENERIC 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: philip X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91feb4f42075e2d7c8d6d50cd5faa651ab3a0e7d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=91feb4f42075e2d7c8d6d50cd5faa651ab3a0e7d commit 91feb4f42075e2d7c8d6d50cd5faa651ab3a0e7d Author: Philip Paeps AuthorDate: 2021-11-01 05:16:27 +0000 Commit: Philip Paeps CommitDate: 2021-11-01 05:19:55 +0000 riscv: add iicbus and iicoc to GENERIC The iicoc driver supports the OpenCores I2C IP. This is included in at least the SiFive "Unleashed" and "Unmatched" cores and probably others. Suggested by: jrtc27 --- sys/riscv/conf/GENERIC | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC index a02a30d4834f..4ce1cb6a3cda 100644 --- a/sys/riscv/conf/GENERIC +++ b/sys/riscv/conf/GENERIC @@ -203,6 +203,10 @@ device bpf # Berkeley packet filter options FDT makeoptions MODULES_EXTRA+="dtb/sifive" +# I2C support +device iicbus # Bus support, required for iicoc below. +device iicoc # OpenCores I2C controller support + # SiFive device drivers device fu740_pci_dw device sifive_gpio From nobody Mon Nov 1 06:54: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 0261818119DD; Mon, 1 Nov 2021 06:54:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjP0L6g0Rz4R9v; Mon, 1 Nov 2021 06:54:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C0AE04FA0; Mon, 1 Nov 2021 06:54: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 1A16sQeW000300; Mon, 1 Nov 2021 06:54:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A16sQ2L000299; Mon, 1 Nov 2021 06:54:26 GMT (envelope-from git) Date: Mon, 1 Nov 2021 06:54:26 GMT Message-Id: <202111010654.1A16sQ2L000299@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: e18fbe6f19ed - main - fuser: restore functionality by fixing fsid 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a commit e18fbe6f19ed106f035c7d2aaeade6eb55cc0b5a Author: Andriy Gapon AuthorDate: 2021-11-01 06:40:17 +0000 Commit: Andriy Gapon CommitDate: 2021-11-01 06:45:26 +0000 fuser: restore functionality by fixing fsid type Use types from sys/stat.h for the filesystem and inode numbers for extra safety. PR: 259504 Reported by: Markus Wild MFC after: 1 week --- usr.bin/fstat/fuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/fstat/fuser.c b/usr.bin/fstat/fuser.c index b4225328fc1f..ad4aebf4a2cb 100644 --- a/usr.bin/fstat/fuser.c +++ b/usr.bin/fstat/fuser.c @@ -92,8 +92,8 @@ struct consumer { STAILQ_ENTRY(consumer) next; }; struct reqfile { - uint32_t fsid; - uint64_t fileid; + dev_t fsid; + ino_t fileid; const char *name; STAILQ_HEAD(, consumer) consumers; }; From nobody Mon Nov 1 11:27: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 20D211839866; Mon, 1 Nov 2021 11:27:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjW3F0Mq8z4sWP; Mon, 1 Nov 2021 11:27: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 E210D107E0; Mon, 1 Nov 2021 11:27: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 1A1BRKEM059538; Mon, 1 Nov 2021 11:27:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1BRK3d059537; Mon, 1 Nov 2021 11:27:20 GMT (envelope-from git) Date: Mon, 1 Nov 2021 11:27:20 GMT Message-Id: <202111011127.1A1BRK3d059537@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 62cbc00d2f57 - main - Print the correct register for the arm64 elr 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 62cbc00d2f57785c747632b1a5ba7571281d17c4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=62cbc00d2f57785c747632b1a5ba7571281d17c4 commit 62cbc00d2f57785c747632b1a5ba7571281d17c4 Author: Andrew Turner AuthorDate: 2021-11-01 11:19:57 +0000 Commit: Andrew Turner CommitDate: 2021-11-01 11:19:57 +0000 Print the correct register for the arm64 elr In 7ec86b6609912 ("Also print symbols when printing arm64 registers") a new function was created to print most registers. Unfortunately the Link Register (LR) was being printed when we should have printed the Exception Link Register (ELR). Fix this by adding the missing 'e'. Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/trap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index c1566b7df492..891f1024232a 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -399,7 +399,7 @@ print_registers(struct trapframe *frame) } printf(" sp: %16lx\n", frame->tf_sp); print_gp_register(" lr", frame->tf_lr); - print_gp_register("elr", frame->tf_lr); + print_gp_register("elr", frame->tf_elr); printf("spsr: %8x\n", frame->tf_spsr); } From nobody Mon Nov 1 12:55: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 D5E571832B4E for ; Mon, 1 Nov 2021 12:55:49 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjY1K5Yvjz3sgS for ; Mon, 1 Nov 2021 12:55:49 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f53.google.com with SMTP id d5so12724656wrc.1 for ; Mon, 01 Nov 2021 05:55:49 -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:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=xUf/cYQAZG8Cs4emnNwQA4q5TNsJ5Y3TE0G+zO4oYhE=; b=xDnockvnxzPEqtsidFRxoCBTdmIa34IIJfmxTztJ4EDIawVSPGnBHUtBv5RQtQRRsG mgyBJ92y3RInMtawHC7Opxe8pydqeOVKxppeh/drF7R0zSWyqBziqCGY3U/p7LPzdz7l b4c9g3bjpWJSUi+B/pcvctGcxob7hxLfh4U3+j42G1od8XtXDGxKIa1/jnmyT4306SVx Wsq6HgVVO1HmQVkbn6e+/hphbgUDryzNVFCKet8Rq/MAh5FhxNxWvV2YHVt+JoZ4U87M R0CwD4ccH0XrQJG4xeUHZ9WXru6HXCDVStos0QHQ4+70bFYDdjJNcFpRt7Bz394Vxq6N FRew== X-Gm-Message-State: AOAM533/obSy95xRN7J+RFCpTCjZo6kQqNXftEiwcg5lcHCWViFgbany yY4T3aRszxcO59dVs/ueIl+1L0B1wbSTSw== X-Google-Smtp-Source: ABdhPJzdfx/rTm3McNnh+VV6e/6wDNinB9CU+ESgiW9Ltg10bb7T3F6N50oCC5Itb+Kc965EuBpP0w== X-Received: by 2002:a05:6000:2ca:: with SMTP id o10mr36801406wry.383.1635771343496; Mon, 01 Nov 2021 05:55:43 -0700 (PDT) Received: from smtpclient.apple (global-5-141.nat-2.net.cam.ac.uk. [131.111.5.141]) by smtp.gmail.com with ESMTPSA id j10sm3814696wru.15.2021.11.01.05.55.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Nov 2021 05:55:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 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 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: e528757ca6a9 - main - iicoc: add support for SiFive HiFive Unmatched From: Jessica Clarke In-Reply-To: <202111010509.1A159OOo054720@gitrepo.freebsd.org> Date: Mon, 1 Nov 2021 12:55:42 +0000 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <3DD4AA9B-9985-4DFB-BBC8-E5E34787BA7A@freebsd.org> References: <202111010509.1A159OOo054720@gitrepo.freebsd.org> To: Philip Paeps X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Rspamd-Queue-Id: 4HjY1K5Yvjz3sgS 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 1 Nov 2021, at 05:09, Philip Paeps wrote: >=20 > The branch main has been updated by philip: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3De528757ca6a9c03dca7e35b77411b311= af166b7f >=20 > commit e528757ca6a9c03dca7e35b77411b311af166b7f > Author: Thomas Skibo > AuthorDate: 2021-11-01 04:23:22 +0000 > Commit: Philip Paeps > CommitDate: 2021-11-01 04:26:49 +0000 >=20 > iicoc: add support for SiFive HiFive Unmatched >=20 > Reviewed by: jrtc27, philip > MFC after: 3 days > Differential Revision: https://reviews.freebsd.org/D32737 I didn=E2=80=99t approve the revision, I just left comments on the first version. One of which still stands (not limiting the module to RISC-V). Jess > --- > sys/dev/iicbus/iicoc_fdt.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/sys/dev/iicbus/iicoc_fdt.c b/sys/dev/iicbus/iicoc_fdt.c > index 699a1738f53b..052174a91134 100644 > --- a/sys/dev/iicbus/iicoc_fdt.c > +++ b/sys/dev/iicbus/iicoc_fdt.c > @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); >=20 > static struct ofw_compat_data compat_data[] =3D { > { "opencores,i2c-ocores", 1 }, > + { "sifive,fu740-c000-i2c", 1 }, > + { "sifive,fu540-c000-i2c", 1 }, > + { "sifive,i2c0", 1 }, > { NULL, 0 } > }; >=20 From nobody Mon Nov 1 13:09: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 65F571821797; Mon, 1 Nov 2021 13:09: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 4HjYJj2QB2z4RnN; Mon, 1 Nov 2021 13:09:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 33406121B7; Mon, 1 Nov 2021 13:09:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A1D9993092594; Mon, 1 Nov 2021 13:09:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1D990a092593; Mon, 1 Nov 2021 13:09:09 GMT (envelope-from git) Date: Mon, 1 Nov 2021 13:09:09 GMT Message-Id: <202111011309.1A1D990a092593@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: ac56b22f44d8 - main - src.conf.5: regen 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: ac56b22f44d829eae7d6fb0e84d00d7ad10b1067 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ac56b22f44d829eae7d6fb0e84d00d7ad10b1067 commit ac56b22f44d829eae7d6fb0e84d00d7ad10b1067 Author: Ed Maste AuthorDate: 2021-11-01 13:07:37 +0000 Commit: Ed Maste CommitDate: 2021-11-01 13:08:44 +0000 src.conf.5: regen Pick up changes in option dependencies (WITHOUT_OPENSSL and WITHOUT_CXX) and the addition of WITH_DETECT_TZ_CHANGES and WITH_LLVM_BINUTILS. Sponsored by: The FreeBSD Foundation --- share/man/man5/src.conf.5 | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 60f2f0af02aa..9ba27d393410 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,6 +1,6 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. .\" $FreeBSD$ -.Dd August 7, 2021 +.Dd November 1, 2021 .Dt SRC.CONF 5 .Os .Sh NAME @@ -326,6 +326,35 @@ When set, it enforces these options: .It .Va WITHOUT_LLVM_COV .El +.Pp +When set, these options are also in effect: +.Pp +.Bl -inset -compact +.It Va WITHOUT_LLVM_TARGET_AARCH64 +(unless +.Va WITH_LLVM_TARGET_AARCH64 +is set explicitly) +.It Va WITHOUT_LLVM_TARGET_ALL +(unless +.Va WITH_LLVM_TARGET_ALL +is set explicitly) +.It Va WITHOUT_LLVM_TARGET_ARM +(unless +.Va WITH_LLVM_TARGET_ARM +is set explicitly) +.It Va WITHOUT_LLVM_TARGET_MIPS +(unless +.Va WITH_LLVM_TARGET_MIPS +is set explicitly) +.It Va WITHOUT_LLVM_TARGET_POWERPC +(unless +.Va WITH_LLVM_TARGET_POWERPC +is set explicitly) +.It Va WITHOUT_LLVM_TARGET_RISCV +(unless +.Va WITH_LLVM_TARGET_RISCV +is set explicitly) +.El .It Va WITHOUT_CLANG_BOOTSTRAP Do not build the Clang C/C++ compiler during the bootstrap phase of the build. @@ -393,6 +422,8 @@ When set, it enforces these options: .It .Va WITHOUT_OPENSSL .It +.Va WITHOUT_OPENSSL_KTLS +.It .Va WITHOUT_PKGBOOTSTRAP .It .Va WITHOUT_UNBOUND @@ -452,11 +483,21 @@ When set, it enforces these options: .It .Va WITHOUT_LLVM_COV .It +.Va WITHOUT_OFED +.It +.Va WITHOUT_OFED_EXTRA +.It +.Va WITHOUT_OPENMP +.It +.Va WITHOUT_PMC +.It .Va WITHOUT_TESTS .El .It Va WITHOUT_DEBUG_FILES Avoid building or installing standalone debug files for each executable binary and shared library. +.It Va WITH_DETECT_TZ_CHANGES +Make the time handling code detect changes to the timezone files. .It Va WITHOUT_DIALOG Do not build .Xr dialog 1 , @@ -873,6 +914,8 @@ The system will not have a usable tool chain unless a linker is provided some other way. .It Va WITHOUT_LLVM_ASSERTIONS Disable debugging assertions in LLVM. +.It Va WITH_LLVM_BINUTILS +Install LLVM's binutils (ar, addr2line, nm, etc.) instead of ELF Tool Chain's. .It Va WITHOUT_LLVM_COV Do not build the .Xr llvm-cov 1 @@ -1278,6 +1321,8 @@ When set, it enforces these options: .It .Va WITHOUT_OPENSSH .It +.Va WITHOUT_OPENSSL_KTLS +.It .Va WITHOUT_PKGBOOTSTRAP .It .Va WITHOUT_UNBOUND From nobody Mon Nov 1 13:52:16 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 20822183E408; Mon, 1 Nov 2021 13:52: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 4HjZGT4WbBz4pXp; Mon, 1 Nov 2021 13:52: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 1416B12B20; Mon, 1 Nov 2021 13:52: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 1A1DqGiS066847; Mon, 1 Nov 2021 13:52:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1DqGXN066846; Mon, 1 Nov 2021 13:52:16 GMT (envelope-from git) Date: Mon, 1 Nov 2021 13:52:16 GMT Message-Id: <202111011352.1A1DqGXN066846@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: fab343a7168a - main - uma: Improve M_USE_RESERVE handling in keg_fetch_slab() 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: fab343a7168a2f033073bb5f65b5af17d9092c6f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fab343a7168a2f033073bb5f65b5af17d9092c6f commit fab343a7168a2f033073bb5f65b5af17d9092c6f Author: Mark Johnston AuthorDate: 2021-11-01 13:27:35 +0000 Commit: Mark Johnston CommitDate: 2021-11-01 13:51:18 +0000 uma: Improve M_USE_RESERVE handling in keg_fetch_slab() M_USE_RESERVE is used in a couple of places in the VM to avoid unbounded recursion when the direct map is not available, as is the case on 32-bit platforms or when certain kernel sanitizers (KASAN and KMSAN) are enabled. For example, to allocate KVA, the kernel might allocate a kernel map entry, which might require a new slab, which requires KVA. For these zones, we use uma_prealloc() to populate a reserve of items, and then in certain serialized contexts M_USE_RESERVE can be used to guarantee a successful allocation. uma_prealloc() allocates the requested number of items, distributing them evenly among NUMA domains. Thus, in a first-touch zone, to satisfy an M_USE_RESERVE allocation we might have to check the slab lists of other domains than the current one to provide the semantics expected by consumers. So, try harder to find an item if M_USE_RESERVE is specified and the keg doesn't have anything for current (first-touch) domain. Specifically, fall back to a round-robin slab allocation. This change fixes boot-time panics on NUMA systems with KASAN or KMSAN enabled.[1] Alternately we could have uma_prealloc() allocate the requested number of items for each domain, but for some existing consumers this would be quite wasteful. In general I think keg_fetch_slab() should try harder to find free slabs in other domains before trying to allocate fresh ones, but let's limit this to M_USE_RESERVE for now. Also fix a separate problem that I noticed: in a non-round-robin slab allocation with M_WAITOK, rather than sleeping after a failed slab allocation we simply try again. Call vm_wait_domain() before retrying. Reported by: mjg, tuexen [1] Reviewed by: alc MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32515 --- sys/vm/uma_core.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 35ed473da5ca..de9605a28bb6 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -3914,6 +3914,9 @@ keg_fetch_slab(uma_keg_t keg, uma_zone_t zone, int rdomain, const int flags) int aflags, domain; bool rr; + KASSERT((flags & (M_WAITOK | M_NOVM)) != (M_WAITOK | M_NOVM), + ("%s: invalid flags %#x", __func__, flags)); + restart: /* * Use the keg's policy if upper layers haven't already specified a @@ -3939,17 +3942,29 @@ restart: return (slab); /* - * M_NOVM means don't ask at all! + * M_NOVM is used to break the recursion that can otherwise + * occur if low-level memory management routines use UMA. */ - if (flags & M_NOVM) - break; + if ((flags & M_NOVM) == 0) { + slab = keg_alloc_slab(keg, zone, domain, flags, aflags); + if (slab != NULL) + return (slab); + } - slab = keg_alloc_slab(keg, zone, domain, flags, aflags); - if (slab != NULL) - return (slab); - if (!rr && (flags & M_WAITOK) == 0) - break; - if (rr && vm_domainset_iter_policy(&di, &domain) != 0) { + if (!rr) { + if ((flags & M_USE_RESERVE) != 0) { + /* + * Drain reserves from other domains before + * giving up or sleeping. It may be useful to + * support per-domain reserves eventually. + */ + rdomain = UMA_ANYDOMAIN; + goto restart; + } + if ((flags & M_WAITOK) == 0) + break; + vm_wait_domain(domain); + } else if (vm_domainset_iter_policy(&di, &domain) != 0) { if ((flags & M_WAITOK) != 0) { vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask, 0); goto restart; From nobody Mon Nov 1 13:52: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 1AA6E183E40D; Mon, 1 Nov 2021 13:52: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 4HjZGV3BRwz4pKs; Mon, 1 Nov 2021 13:52: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 339E712D08; Mon, 1 Nov 2021 13:52:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A1DqIvr066871; Mon, 1 Nov 2021 13:52:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1DqIQq066870; Mon, 1 Nov 2021 13:52:18 GMT (envelope-from git) Date: Mon, 1 Nov 2021 13:52:18 GMT Message-Id: <202111011352.1A1DqIQq066870@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: 7585c5db25b7 - main - uma: Fix handling of reserves in zone_import() 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: 7585c5db25b700d19baebd7afd7a1b2e03c29cda Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7585c5db25b700d19baebd7afd7a1b2e03c29cda commit 7585c5db25b700d19baebd7afd7a1b2e03c29cda Author: Mark Johnston AuthorDate: 2021-11-01 13:27:52 +0000 Commit: Mark Johnston CommitDate: 2021-11-01 13:51:43 +0000 uma: Fix handling of reserves in zone_import() Kegs with no items reserved have uk_reserve = 0. So the check keg->uk_reserve >= dom->ud_free_items will be true once all slabs are depleted. Then, rather than go and allocate a fresh slab, we return to the cache layer. The intent was to do this only when the keg actually has a reserve, so modify the check to verify this first. Another approach would be to make uk_reserve signed and set it to -1 until uma_zone_reserve() is called, but this requires a few casts elsewhere. Fixes: 1b2dcc8c54a8 ("uma: Avoid depleting keg reserves when filling a bucket") MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32516 --- sys/vm/uma_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index de9605a28bb6..7b83d81a423d 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -4038,7 +4038,8 @@ zone_import(void *arg, void **bucket, int max, int domain, int flags) dom = &keg->uk_domain[slab->us_domain]; do { bucket[i++] = slab_alloc_item(keg, slab); - if (dom->ud_free_items <= keg->uk_reserve) { + if (keg->uk_reserve > 0 && + dom->ud_free_items <= keg->uk_reserve) { /* * Avoid depleting the reserve after a * successful item allocation, even if From nobody Mon Nov 1 14:49: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 6A370183A1A7; Mon, 1 Nov 2021 14:49: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 4HjbXG2QqQz4cR0; Mon, 1 Nov 2021 14:49: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 33BA31389C; Mon, 1 Nov 2021 14:49:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A1EnIPp035504; Mon, 1 Nov 2021 14:49:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1EnID1035503; Mon, 1 Nov 2021 14:49:18 GMT (envelope-from git) Date: Mon, 1 Nov 2021 14:49:18 GMT Message-Id: <202111011449.1A1EnID1035503@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: 065ef8f7832e - main - Add descriptions for WITH_ASAN and WITH_UBSAN 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: 065ef8f7832e8722ea07213faa5efc2f4d70aa8d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=065ef8f7832e8722ea07213faa5efc2f4d70aa8d commit 065ef8f7832e8722ea07213faa5efc2f4d70aa8d Author: Ed Maste AuthorDate: 2021-11-01 13:03:14 +0000 Commit: Ed Maste CommitDate: 2021-11-01 14:48:56 +0000 Add descriptions for WITH_ASAN and WITH_UBSAN Reviewed by: jrtc27 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32773 --- tools/build/options/WITH_ASAN | 4 ++++ tools/build/options/WITH_UBSAN | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tools/build/options/WITH_ASAN b/tools/build/options/WITH_ASAN new file mode 100644 index 000000000000..2955434fd167 --- /dev/null +++ b/tools/build/options/WITH_ASAN @@ -0,0 +1,4 @@ +Build the base system with Address Sanitizer (ASan) to detect +memory corruption bugs such as buffer overflows or use-after-free. +Requires that Clang be used as the base system compiler +and that the runtime support library is available. diff --git a/tools/build/options/WITH_UBSAN b/tools/build/options/WITH_UBSAN new file mode 100644 index 000000000000..a27f72c713d7 --- /dev/null +++ b/tools/build/options/WITH_UBSAN @@ -0,0 +1,4 @@ +Build the base system with Undefined Behavior Sanitizer (UBSan) to detect +various kinds of undefined behavior at runtime. +Requires that Clang be used as the base system compiler +and that the runtime support library is available From nobody Mon Nov 1 14:49: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 A8142183A305; Mon, 1 Nov 2021 14:49: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 4HjbXH3sq2z4cXn; Mon, 1 Nov 2021 14:49: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 632E21343E; Mon, 1 Nov 2021 14:49: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 1A1EnJ4A035535; Mon, 1 Nov 2021 14:49:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1EnJGv035534; Mon, 1 Nov 2021 14:49:19 GMT (envelope-from git) Date: Mon, 1 Nov 2021 14:49:19 GMT Message-Id: <202111011449.1A1EnJGv035534@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: 0ab89d72aab7 - main - src.conf.5: regen for WITH_ASAN and WITH_UBSAN descriptions 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: 0ab89d72aab7a6904b6990cb21e0a86afb58342f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=0ab89d72aab7a6904b6990cb21e0a86afb58342f commit 0ab89d72aab7a6904b6990cb21e0a86afb58342f Author: Ed Maste AuthorDate: 2021-11-01 13:27:49 +0000 Commit: Ed Maste CommitDate: 2021-11-01 14:48:56 +0000 src.conf.5: regen for WITH_ASAN and WITH_UBSAN descriptions --- share/man/man5/src.conf.5 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 9ba27d393410..61629e32f225 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -106,6 +106,19 @@ Do not build .Xr apm 8 , .Xr apmd 8 and related programs. +.It Va WITH_ASAN +Build the base system with Address Sanitizer (ASan) to detect +memory corruption bugs such as buffer overflows or use-after-free. +Requires that Clang be used as the base system compiler +and that the runtime support library is available. +When set, it enforces these options: +.Pp +.Bl -item -compact +.It +.Va WITH_LLVM_BINUTILS +.It +.Va WITH_LLVM_CXXFILT +.El .It Va WITHOUT_ASSERT_DEBUG Compile programs and libraries without the .Xr assert 3 @@ -1645,6 +1658,11 @@ When set, it enforces these options: .It .Va WITHOUT_LLVM_COV .El +.It Va WITH_UBSAN +Build the base system with Undefined Behavior Sanitizer (UBSan) to detect +various kinds of undefined behavior at runtime. +Requires that Clang be used as the base system compiler +and that the runtime support library is available .It Va WITHOUT_UNBOUND Do not build .Xr unbound 8 From nobody Mon Nov 1 16:35: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 1505E17EFCC5; Mon, 1 Nov 2021 16:35: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 4HjdtZ06B8z3lTc; Mon, 1 Nov 2021 16:35: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 D41B514BBB; Mon, 1 Nov 2021 16:35: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 1A1GZHO8081821; Mon, 1 Nov 2021 16:35:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1GZHtY081820; Mon, 1 Nov 2021 16:35:17 GMT (envelope-from git) Date: Mon, 1 Nov 2021 16:35:17 GMT Message-Id: <202111011635.1A1GZHtY081820@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: dde6071adcf2 - main - devinfo(8): Remove cross-reference to pnpinfo(8) 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: dde6071adcf203b185c185289f687c2bd51532fb 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=dde6071adcf203b185c185289f687c2bd51532fb commit dde6071adcf203b185c185289f687c2bd51532fb Author: Felix Johnson AuthorDate: 2021-11-01 16:29:12 +0000 Commit: Guangyuan Yang CommitDate: 2021-11-01 16:29:12 +0000 devinfo(8): Remove cross-reference to pnpinfo(8) devinfo(8) manpage contains reference to pnpinfo(8) which existed at the time. Remove it. PR: 232587 MFC: 3 days Reported by: Graham Perrin --- usr.sbin/devinfo/devinfo.8 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.sbin/devinfo/devinfo.8 b/usr.sbin/devinfo/devinfo.8 index 72fd73dba82c..091248250830 100644 --- a/usr.sbin/devinfo/devinfo.8 +++ b/usr.sbin/devinfo/devinfo.8 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 21, 2017 +.Dd November 1, 2021 .Dt DEVINFO 8 .Os .Sh NAME @@ -75,7 +75,6 @@ back to the root of the device tree. .Xr devinfo 3 , .Xr iostat 8 , .Xr pciconf 8 , -.Xr pnpinfo 8 , .Xr vmstat 8 , .Xr devclass 9 , .Xr device 9 From nobody Mon Nov 1 17:08: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 F3A551832DF0; Mon, 1 Nov 2021 17:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjfdH6VT6z4Sm2; Mon, 1 Nov 2021 17:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BF0A215354; Mon, 1 Nov 2021 17:08: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 1A1H8pG9024680; Mon, 1 Nov 2021 17:08:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1H8poq024679; Mon, 1 Nov 2021 17:08:51 GMT (envelope-from git) Date: Mon, 1 Nov 2021 17:08:51 GMT Message-Id: <202111011708.1A1H8poq024679@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: 1019354b5416 - main - carp: deal with negative net.inet.carp.demotion 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: 1019354b54161c140d10a8203ff1e849c09c8010 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1019354b54161c140d10a8203ff1e849c09c8010 commit 1019354b54161c140d10a8203ff1e849c09c8010 Author: Marius Halden AuthorDate: 2021-10-31 20:18:42 +0000 Commit: Kristof Provost CommitDate: 2021-11-01 16:08:23 +0000 carp: deal with negative net.inet.carp.demotion Given nodes 1 and 2, where node 1 has an advskew of 0 and node 2 has an advskew of 100, making them master and backup respectively. If net.inet.carp.demotion is set to a negative value on node 1, node 2 might become master while node 1 still retains it master status. Wether or not node 2 becomes master seems to depend on the nodes advskew and what the demotion sysctl was set to on node 1. The reason for node 2 becoming master seems to be that the calculated advskew taking demotion into account is truncated to a single unsigned byte when copied into the carp header for sending, and node 1 stays master since it takes uses the whole non-truncated calculated advskew when deciding wether to stay master. PR: 259528 Reviewed by: donner, glebius MFC after: 3 weeks Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D32759 --- sys/netinet/ip_carp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 9a551a70c3ad..7554becb974e 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -304,7 +304,9 @@ SYSCTL_VNET_PCPUSTAT(_net_inet_carp, OID_AUTO, stats, struct carpstats, #define DEMOTE_ADVSKEW(sc) \ (((sc)->sc_advskew + V_carp_demotion > CARP_MAXSKEW) ? \ - CARP_MAXSKEW : ((sc)->sc_advskew + V_carp_demotion)) + CARP_MAXSKEW : \ + (((sc)->sc_advskew + V_carp_demotion < 0) ? \ + 0 : ((sc)->sc_advskew + V_carp_demotion))) static void carp_input_c(struct mbuf *, struct carp_header *, sa_family_t); static struct carp_softc From nobody Mon Nov 1 17:08: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 47ECB1832F97; Mon, 1 Nov 2021 17:08: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 4HjfdK16Lkz4T4s; Mon, 1 Nov 2021 17:08: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 D9EAB151E4; Mon, 1 Nov 2021 17:08: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 1A1H8qTl024705; Mon, 1 Nov 2021 17:08:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1H8q50024704; Mon, 1 Nov 2021 17:08:52 GMT (envelope-from git) Date: Mon, 1 Nov 2021 17:08:52 GMT Message-Id: <202111011708.1A1H8q50024704@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: 847b0d07c43c - main - carp tests: negative demotion 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: 847b0d07c43c1190f0015c4c93a9e8fd953e3ab5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=847b0d07c43c1190f0015c4c93a9e8fd953e3ab5 commit 847b0d07c43c1190f0015c4c93a9e8fd953e3ab5 Author: Marius Halden AuthorDate: 2021-10-31 20:22:10 +0000 Commit: Kristof Provost CommitDate: 2021-11-01 16:08:23 +0000 carp tests: negative demotion PR: 259528 Reviewed by: donner MFC after: 3 weeks Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D32760 --- tests/sys/netinet/carp.sh | 67 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh index 30ae79c93c8d..267e70ebf0dc 100755 --- a/tests/sys/netinet/carp.sh +++ b/tests/sys/netinet/carp.sh @@ -48,6 +48,15 @@ wait_for_carp() done } +carp_init() +{ + if ! kldstat -q -m carp; then + atf_skip "This test requires carp" + fi + + vnet_init +} + atf_test_case "basic_v4" "cleanup" basic_v4_head() { @@ -57,11 +66,8 @@ basic_v4_head() basic_v4_body() { - if ! kldstat -q -m carp; then - atf_skip "This test requires carp" - fi + carp_init - vnet_init bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) @@ -104,11 +110,8 @@ basic_v6_head() basic_v6_body() { - if ! kldstat -q -m carp; then - atf_skip "This test requires carp" - fi + carp_init - vnet_init bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) @@ -145,8 +148,56 @@ basic_v6_cleanup() vnet_cleanup } +atf_test_case "negative_demotion" "cleanup" +negative_demotion_head() +{ + atf_set descr 'Test PR #259528' + atf_set require.user root +} + +negative_demotion_body() +{ + carp_init + + epair=$(vnet_mkepair) + + vnet_mkjail one ${epair}a + jexec one sysctl net.inet.carp.preempt=1 + jexec one ifconfig ${epair}a 192.0.2.1/24 up + jexec one ifconfig ${epair}a add vhid 1 192.0.2.254/24 \ + advskew 0 pass foobar + + vnet_mkjail two ${epair}b + jexec two sysctl net.inet.carp.preempt=1 + jexec two ifconfig ${epair}b 192.0.2.2/24 up + jexec two ifconfig ${epair}b add vhid 1 192.0.2.254/24 \ + advskew 100 pass foobar + + # Allow things to settle + wait_for_carp one ${epair}a two ${epair}b + + if is_master one ${epair}a && is_master two ${epair}b + then + atf_fail "Two masters!" + fi + + jexec one sysctl net.inet.carp.demotion=-1 + sleep 3 + + if is_master one ${epair}a && is_master two ${epair}b + then + atf_fail "Two masters!" + fi +} + +negative_demotion_cleanup() +{ + vnet_cleanup +} + atf_init_test_cases() { atf_add_test_case "basic_v4" atf_add_test_case "basic_v6" + atf_add_test_case "negative_demotion" } From nobody Mon Nov 1 17:25: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 475E2183B4C8; Mon, 1 Nov 2021 17:25:44 +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 4Hjg0m1cyfz4bXP; Mon, 1 Nov 2021 17:25:44 +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 D409028F7F; Mon, 1 Nov 2021 17:25:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: Xin LI , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202110310610.19V6A6M9016716@gitrepo.freebsd.org> From: John Baldwin Subject: Re: git: f38bef2ce417 - main - Bump __FreeBSD_version following the libdialog shared library version number bump. Message-ID: <21eaa4ed-3ec0-c2e6-7043-e3ebe03db421@FreeBSD.org> Date: Mon, 1 Nov 2021 10:25:41 -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: <202110310610.19V6A6M9016716@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ThisMailContainsUnwantedMimeParts: N On 10/30/21 11:10 PM, Xin LI wrote: > 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. > --- Oops, thanks. -- John Baldwin From nobody Mon Nov 1 18:35: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 16806183D2BF; Mon, 1 Nov 2021 18:35: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 4HjhYc04s1z3FNL; Mon, 1 Nov 2021 18:35: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 D2E1E16541; Mon, 1 Nov 2021 18:35: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 1A1IZlqw044575; Mon, 1 Nov 2021 18:35:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1IZlJ6044574; Mon, 1 Nov 2021 18:35:47 GMT (envelope-from git) Date: Mon, 1 Nov 2021 18:35:47 GMT Message-Id: <202111011835.1A1IZlJ6044574@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: a10482ea7476 - main - ktls: Add simple transmit tests of kernel TLS. 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: a10482ea7476d68d1ab028145ae6d97cef747b49 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a10482ea7476d68d1ab028145ae6d97cef747b49 commit a10482ea7476d68d1ab028145ae6d97cef747b49 Author: John Baldwin AuthorDate: 2021-11-01 18:28:10 +0000 Commit: John Baldwin CommitDate: 2021-11-01 18:28:10 +0000 ktls: Add simple transmit tests of kernel TLS. Note that these tests test the kernel TLS functionality directly. Rather than using OpenSSL to perform negotiation and generate keys, these tests generate random keys send data over a pair of TCP sockets manually decrypting the TLS records generated by the kernel. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32652 --- tests/sys/kern/Makefile | 2 + tests/sys/kern/ktls_test.c | 1033 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1035 insertions(+) diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index 6746812d9b4a..ee9decac518c 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -12,6 +12,7 @@ ATF_TESTS_C+= kern_copyin ATF_TESTS_C+= kern_descrip_test ATF_TESTS_C+= fdgrowtable_test ATF_TESTS_C+= kill_zombie +ATF_TESTS_C+= ktls_test ATF_TESTS_C+= ptrace_test TEST_METADATA.ptrace_test+= timeout="15" ATF_TESTS_C+= reaper @@ -46,6 +47,7 @@ LIBADD.sys_getrandom+= pthread LIBADD.ptrace_test+= pthread LIBADD.unix_seqpacket_test+= pthread LIBADD.kcov+= pthread +LIBADD.ktls_test+= crypto LIBADD.sendfile_helper+= pthread LIBADD.fdgrowtable_test+= util pthread kvm procstat diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c new file mode 100644 index 000000000000..908f7f1818a2 --- /dev/null +++ b/tests/sys/kern/ktls_test.c @@ -0,0 +1,1033 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Netflix Inc. + * Written by: John Baldwin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static void +require_ktls(void) +{ + size_t len; + bool enable; + + len = sizeof(enable); + if (sysctlbyname("kern.ipc.tls.enable", &enable, &len, NULL, 0) == -1) { + if (errno == ENOENT) + atf_tc_skip("kernel does not support TLS offload"); + atf_libc_error(errno, "Failed to read kern.ipc.tls.enable"); + } + + if (!enable) + atf_tc_skip("Kernel TLS is disabled"); +} + +#define ATF_REQUIRE_KTLS() require_ktls() + +static char +rdigit(void) +{ + /* ASCII printable values between 0x20 and 0x7e */ + return (0x20 + random() % (0x7f - 0x20)); +} + +static char * +alloc_buffer(size_t len) +{ + char *buf; + size_t i; + + if (len == 0) + return (NULL); + buf = malloc(len); + for (i = 0; i < len; i++) + buf[i] = rdigit(); + return (buf); +} + +static bool +socketpair_tcp(int *sv) +{ + struct pollfd pfd; + struct sockaddr_in sin; + socklen_t len; + int as, cs, ls; + + ls = socket(PF_INET, SOCK_STREAM, 0); + if (ls == -1) { + warn("socket() for listen"); + return (false); + } + + memset(&sin, 0, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + if (bind(ls, (struct sockaddr *)&sin, sizeof(sin)) == -1) { + warn("bind"); + close(ls); + return (false); + } + + if (listen(ls, 1) == -1) { + warn("listen"); + close(ls); + return (false); + } + + len = sizeof(sin); + if (getsockname(ls, (struct sockaddr *)&sin, &len) == -1) { + warn("getsockname"); + close(ls); + return (false); + } + + cs = socket(PF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); + if (cs == -1) { + warn("socket() for connect"); + close(ls); + return (false); + } + + if (connect(cs, (struct sockaddr *)&sin, sizeof(sin)) == -1) { + if (errno != EINPROGRESS) { + warn("connect"); + close(ls); + close(cs); + return (false); + } + } + + as = accept4(ls, NULL, NULL, SOCK_NONBLOCK); + if (as == -1) { + warn("accept4"); + close(ls); + close(cs); + return (false); + } + + close(ls); + + pfd.fd = cs; + pfd.events = POLLOUT; + pfd.revents = 0; + ATF_REQUIRE(poll(&pfd, 1, INFTIM) == 1); + ATF_REQUIRE(pfd.revents == POLLOUT); + + sv[0] = cs; + sv[1] = as; + return (true); +} + +static void +fd_set_blocking(int fd) +{ + int flags; + + ATF_REQUIRE((flags = fcntl(fd, F_GETFL)) != -1); + flags &= ~O_NONBLOCK; + ATF_REQUIRE(fcntl(fd, F_SETFL, flags) != -1); +} + +static bool +cbc_decrypt(const EVP_CIPHER *cipher, const char *key, const char *iv, + const char *input, char *output, size_t size) +{ + EVP_CIPHER_CTX *ctx; + int outl, total; + + ctx = EVP_CIPHER_CTX_new(); + if (ctx == NULL) { + warnx("EVP_CIPHER_CTX_new failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + return (false); + } + if (EVP_CipherInit_ex(ctx, cipher, NULL, (const u_char *)key, + (const u_char *)iv, 0) != 1) { + warnx("EVP_CipherInit_ex failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + EVP_CIPHER_CTX_set_padding(ctx, 0); + if (EVP_CipherUpdate(ctx, (u_char *)output, &outl, + (const u_char *)input, size) != 1) { + warnx("EVP_CipherUpdate failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + total = outl; + if (EVP_CipherFinal_ex(ctx, (u_char *)output + outl, &outl) != 1) { + warnx("EVP_CipherFinal_ex failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + total += outl; + if ((size_t)total != size) { + warnx("decrypt size mismatch: %zu vs %d", size, total); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + EVP_CIPHER_CTX_free(ctx); + return (true); +} + +static bool +verify_hash(const EVP_MD *md, const void *key, size_t key_len, const void *aad, + size_t aad_len, const void *buffer, size_t len, const void *digest) +{ + HMAC_CTX *ctx; + unsigned char digest2[EVP_MAX_MD_SIZE]; + u_int digest_len; + + ctx = HMAC_CTX_new(); + if (ctx == NULL) { + warnx("HMAC_CTX_new failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + return (false); + } + if (HMAC_Init_ex(ctx, key, key_len, md, NULL) != 1) { + warnx("HMAC_Init_ex failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + HMAC_CTX_free(ctx); + return (false); + } + if (HMAC_Update(ctx, aad, aad_len) != 1) { + warnx("HMAC_Update (aad) failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + HMAC_CTX_free(ctx); + return (false); + } + if (HMAC_Update(ctx, buffer, len) != 1) { + warnx("HMAC_Update (payload) failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + HMAC_CTX_free(ctx); + return (false); + } + if (HMAC_Final(ctx, digest2, &digest_len) != 1) { + warnx("HMAC_Final failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + HMAC_CTX_free(ctx); + return (false); + } + HMAC_CTX_free(ctx); + if (memcmp(digest, digest2, digest_len) != 0) { + warnx("HMAC mismatch"); + return (false); + } + return (true); +} + +static bool +aead_decrypt(const EVP_CIPHER *cipher, const char *key, const char *nonce, + const void *aad, size_t aad_len, const char *input, char *output, + size_t size, const char *tag, size_t tag_len) +{ + EVP_CIPHER_CTX *ctx; + int outl, total; + bool valid; + + ctx = EVP_CIPHER_CTX_new(); + if (ctx == NULL) { + warnx("EVP_CIPHER_CTX_new failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + return (false); + } + if (EVP_DecryptInit_ex(ctx, cipher, NULL, (const u_char *)key, + (const u_char *)nonce) != 1) { + warnx("EVP_DecryptInit_ex failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + EVP_CIPHER_CTX_set_padding(ctx, 0); + if (aad != NULL) { + if (EVP_DecryptUpdate(ctx, NULL, &outl, (const u_char *)aad, + aad_len) != 1) { + warnx("EVP_DecryptUpdate for AAD failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + } + if (EVP_DecryptUpdate(ctx, (u_char *)output, &outl, + (const u_char *)input, size) != 1) { + warnx("EVP_DecryptUpdate failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + total = outl; + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, + __DECONST(char *, tag)) != 1) { + warnx("EVP_CIPHER_CTX_ctrl(EVP_CTRL_AEAD_SET_TAG) failed: %s", + ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + valid = (EVP_DecryptFinal_ex(ctx, (u_char *)output + outl, &outl) == 1); + total += outl; + if ((size_t)total != size) { + warnx("decrypt size mismatch: %zu vs %d", size, total); + EVP_CIPHER_CTX_free(ctx); + return (false); + } + if (!valid) + warnx("tag mismatch"); + EVP_CIPHER_CTX_free(ctx); + return (valid); +} + +static void +build_tls_enable(int cipher_alg, size_t cipher_key_len, int auth_alg, + int minor, uint64_t seqno, struct tls_enable *en) +{ + u_int auth_key_len, iv_len; + + memset(en, 0, sizeof(*en)); + + switch (cipher_alg) { + case CRYPTO_AES_CBC: + if (minor == TLS_MINOR_VER_ZERO) + iv_len = AES_BLOCK_LEN; + else + iv_len = 0; + break; + case CRYPTO_AES_NIST_GCM_16: + if (minor == TLS_MINOR_VER_TWO) + iv_len = TLS_AEAD_GCM_LEN; + else + iv_len = TLS_1_3_GCM_IV_LEN; + break; + case CRYPTO_CHACHA20_POLY1305: + iv_len = TLS_CHACHA20_IV_LEN; + break; + default: + iv_len = 0; + break; + } + switch (auth_alg) { + case CRYPTO_SHA1_HMAC: + auth_key_len = SHA1_HASH_LEN; + break; + case CRYPTO_SHA2_256_HMAC: + auth_key_len = SHA2_256_HASH_LEN; + break; + case CRYPTO_SHA2_384_HMAC: + auth_key_len = SHA2_384_HASH_LEN; + break; + default: + auth_key_len = 0; + break; + } + en->cipher_key = alloc_buffer(cipher_key_len); + en->iv = alloc_buffer(iv_len); + en->auth_key = alloc_buffer(auth_key_len); + en->cipher_algorithm = cipher_alg; + en->cipher_key_len = cipher_key_len; + en->iv_len = iv_len; + en->auth_algorithm = auth_alg; + en->auth_key_len = auth_key_len; + en->tls_vmajor = TLS_MAJOR_VER_ONE; + en->tls_vminor = minor; + be64enc(en->rec_seq, seqno); +} + +static void +free_tls_enable(struct tls_enable *en) +{ + free(__DECONST(void *, en->cipher_key)); + free(__DECONST(void *, en->iv)); + free(__DECONST(void *, en->auth_key)); +} + +static const EVP_CIPHER * +tls_EVP_CIPHER(const struct tls_enable *en) +{ + switch (en->cipher_algorithm) { + case CRYPTO_AES_CBC: + switch (en->cipher_key_len) { + case 128 / 8: + return (EVP_aes_128_cbc()); + case 256 / 8: + return (EVP_aes_256_cbc()); + default: + return (NULL); + } + break; + case CRYPTO_AES_NIST_GCM_16: + switch (en->cipher_key_len) { + case 128 / 8: + return (EVP_aes_128_gcm()); + case 256 / 8: + return (EVP_aes_256_gcm()); + default: + return (NULL); + } + break; + case CRYPTO_CHACHA20_POLY1305: + return (EVP_chacha20_poly1305()); + default: + return (NULL); + } +} + +static const EVP_MD * +tls_EVP_MD(const struct tls_enable *en) +{ + switch (en->auth_algorithm) { + case CRYPTO_SHA1_HMAC: + return (EVP_sha1()); + case CRYPTO_SHA2_256_HMAC: + return (EVP_sha256()); + case CRYPTO_SHA2_384_HMAC: + return (EVP_sha384()); + default: + return (NULL); + } +} + +static size_t +tls_header_len(struct tls_enable *en) +{ + size_t len; + + len = sizeof(struct tls_record_layer); + switch (en->cipher_algorithm) { + case CRYPTO_AES_CBC: + if (en->tls_vminor != TLS_MINOR_VER_ZERO) + len += AES_BLOCK_LEN; + return (len); + case CRYPTO_AES_NIST_GCM_16: + if (en->tls_vminor == TLS_MINOR_VER_TWO) + len += sizeof(uint64_t); + return (len); + case CRYPTO_CHACHA20_POLY1305: + return (len); + default: + return (0); + } +} + +static size_t +tls_mac_len(struct tls_enable *en) +{ + switch (en->cipher_algorithm) { + case CRYPTO_AES_CBC: + switch (en->auth_algorithm) { + case CRYPTO_SHA1_HMAC: + return (SHA1_HASH_LEN); + case CRYPTO_SHA2_256_HMAC: + return (SHA2_256_HASH_LEN); + case CRYPTO_SHA2_384_HMAC: + return (SHA2_384_HASH_LEN); + default: + return (0); + } + case CRYPTO_AES_NIST_GCM_16: + return (AES_GMAC_HASH_LEN); + case CRYPTO_CHACHA20_POLY1305: + return (POLY1305_HASH_LEN); + default: + return (0); + } +} + +/* Includes maximum padding for MTE. */ +static size_t +tls_trailer_len(struct tls_enable *en) +{ + size_t len; + + len = tls_mac_len(en); + if (en->cipher_algorithm == CRYPTO_AES_CBC) + len += AES_BLOCK_LEN; + if (en->tls_vminor == TLS_MINOR_VER_THREE) + len++; + return (len); +} + +/* 'len' is the length of the payload application data. */ +static void +tls_mte_aad(struct tls_enable *en, size_t len, + const struct tls_record_layer *hdr, uint64_t seqno, struct tls_mac_data *ad) +{ + ad->seq = htobe64(seqno); + ad->type = hdr->tls_type; + ad->tls_vmajor = hdr->tls_vmajor; + ad->tls_vminor = hdr->tls_vminor; + ad->tls_length = htons(len); +} + +static void +tls_12_aead_aad(struct tls_enable *en, size_t len, + const struct tls_record_layer *hdr, uint64_t seqno, + struct tls_aead_data *ad) +{ + ad->seq = htobe64(seqno); + ad->type = hdr->tls_type; + ad->tls_vmajor = hdr->tls_vmajor; + ad->tls_vminor = hdr->tls_vminor; + ad->tls_length = htons(len); +} + +static void +tls_13_aad(struct tls_enable *en, const struct tls_record_layer *hdr, + uint64_t seqno, struct tls_aead_data_13 *ad) +{ + ad->type = hdr->tls_type; + ad->tls_vmajor = hdr->tls_vmajor; + ad->tls_vminor = hdr->tls_vminor; + ad->tls_length = hdr->tls_length; +} + +static void +tls_12_gcm_nonce(struct tls_enable *en, const struct tls_record_layer *hdr, + char *nonce) +{ + memcpy(nonce, en->iv, TLS_AEAD_GCM_LEN); + memcpy(nonce + TLS_AEAD_GCM_LEN, hdr + 1, sizeof(uint64_t)); +} + +static void +tls_13_nonce(struct tls_enable *en, uint64_t seqno, char *nonce) +{ + static_assert(TLS_1_3_GCM_IV_LEN == TLS_CHACHA20_IV_LEN, + "TLS 1.3 nonce length mismatch"); + memcpy(nonce, en->iv, TLS_1_3_GCM_IV_LEN); + *(uint64_t *)(nonce + 4) ^= htobe64(seqno); +} + +/* + * Decrypt a TLS record 'len' bytes long at 'src' and store the result at + * 'dst'. If the TLS record header length doesn't match or 'dst' doesn't + * have sufficient room ('avail'), fail the test. + */ +static size_t +decrypt_tls_aes_cbc_mte(struct tls_enable *en, uint64_t seqno, const void *src, + size_t len, void *dst, size_t avail, uint8_t *record_type) +{ + const struct tls_record_layer *hdr; + struct tls_mac_data aad; + const char *iv; + char *buf; + size_t hdr_len, mac_len, payload_len; + int padding; + + hdr = src; + hdr_len = tls_header_len(en); + mac_len = tls_mac_len(en); + ATF_REQUIRE(hdr->tls_vmajor == TLS_MAJOR_VER_ONE); + ATF_REQUIRE(hdr->tls_vminor == en->tls_vminor); + + /* First, decrypt the outer payload into a temporary buffer. */ + payload_len = len - hdr_len; + buf = malloc(payload_len); + if (en->tls_vminor == TLS_MINOR_VER_ZERO) + iv = en->iv; + else + iv = (void *)(hdr + 1); + ATF_REQUIRE(cbc_decrypt(tls_EVP_CIPHER(en), en->cipher_key, iv, + (const u_char *)src + hdr_len, buf, payload_len)); + + /* + * Copy the last encrypted block to use as the IV for the next + * record for TLS 1.0. + */ + if (en->tls_vminor == TLS_MINOR_VER_ZERO) + memcpy(__DECONST(uint8_t *, en->iv), (const u_char *)src + + (len - AES_BLOCK_LEN), AES_BLOCK_LEN); + + /* + * Verify trailing padding and strip. + * + * The kernel always generates the smallest amount of padding. + */ + padding = buf[payload_len - 1] + 1; + ATF_REQUIRE(padding > 0 && padding <= AES_BLOCK_LEN); + ATF_REQUIRE(payload_len >= mac_len + padding); + payload_len -= padding; + + /* Verify HMAC. */ + payload_len -= mac_len; + tls_mte_aad(en, payload_len, hdr, seqno, &aad); + ATF_REQUIRE(verify_hash(tls_EVP_MD(en), en->auth_key, en->auth_key_len, + &aad, sizeof(aad), buf, payload_len, buf + payload_len)); + + ATF_REQUIRE(payload_len <= avail); + memcpy(dst, buf, payload_len); + *record_type = hdr->tls_type; + return (payload_len); +} + +static size_t +decrypt_tls_12_aead(struct tls_enable *en, uint64_t seqno, const void *src, + size_t len, void *dst, uint8_t *record_type) +{ + const struct tls_record_layer *hdr; + struct tls_aead_data aad; + char nonce[12]; + size_t hdr_len, mac_len, payload_len; + + hdr = src; + + hdr_len = tls_header_len(en); + mac_len = tls_mac_len(en); + payload_len = len - (hdr_len + mac_len); + ATF_REQUIRE(hdr->tls_vmajor == TLS_MAJOR_VER_ONE); + ATF_REQUIRE(hdr->tls_vminor == TLS_MINOR_VER_TWO); + + tls_12_aead_aad(en, payload_len, hdr, seqno, &aad); + if (en->cipher_algorithm == CRYPTO_AES_NIST_GCM_16) + tls_12_gcm_nonce(en, hdr, nonce); + else + tls_13_nonce(en, seqno, nonce); + + ATF_REQUIRE(aead_decrypt(tls_EVP_CIPHER(en), en->cipher_key, nonce, + &aad, sizeof(aad), (const char *)src + hdr_len, dst, payload_len, + (const char *)src + hdr_len + payload_len, mac_len)); + + *record_type = hdr->tls_type; + return (payload_len); +} + +static size_t +decrypt_tls_13_aead(struct tls_enable *en, uint64_t seqno, const void *src, + size_t len, void *dst, uint8_t *record_type) +{ + const struct tls_record_layer *hdr; + struct tls_aead_data_13 aad; + char nonce[12]; + char *buf; + size_t hdr_len, mac_len, payload_len; + + hdr = src; + + hdr_len = tls_header_len(en); + mac_len = tls_mac_len(en); + payload_len = len - (hdr_len + mac_len); + ATF_REQUIRE(payload_len >= 1); + ATF_REQUIRE(hdr->tls_type == TLS_RLTYPE_APP); + ATF_REQUIRE(hdr->tls_vmajor == TLS_MAJOR_VER_ONE); + ATF_REQUIRE(hdr->tls_vminor == TLS_MINOR_VER_TWO); + + tls_13_aad(en, hdr, seqno, &aad); + tls_13_nonce(en, seqno, nonce); + + /* + * Have to use a temporary buffer for the output due to the + * record type as the last byte of the trailer. + */ + buf = malloc(payload_len); + + ATF_REQUIRE(aead_decrypt(tls_EVP_CIPHER(en), en->cipher_key, nonce, + &aad, sizeof(aad), (const char *)src + hdr_len, buf, payload_len, + (const char *)src + hdr_len + payload_len, mac_len)); + + /* Trim record type. */ + *record_type = buf[payload_len - 1]; + payload_len--; + + memcpy(dst, buf, payload_len); + free(buf); + + return (payload_len); +} + +static size_t +decrypt_tls_aead(struct tls_enable *en, uint64_t seqno, const void *src, + size_t len, void *dst, size_t avail, uint8_t *record_type) +{ + const struct tls_record_layer *hdr; + size_t payload_len; + + hdr = src; + ATF_REQUIRE(ntohs(hdr->tls_length) + sizeof(*hdr) == len); + + payload_len = len - (tls_header_len(en) + tls_trailer_len(en)); + ATF_REQUIRE(payload_len <= avail); + + if (en->tls_vminor == TLS_MINOR_VER_TWO) { + ATF_REQUIRE(decrypt_tls_12_aead(en, seqno, src, len, dst, + record_type) == payload_len); + } else { + ATF_REQUIRE(decrypt_tls_13_aead(en, seqno, src, len, dst, + record_type) == payload_len); + } + + return (payload_len); +} + +static size_t +decrypt_tls_record(struct tls_enable *en, uint64_t seqno, const void *src, + size_t len, void *dst, size_t avail, uint8_t *record_type) +{ + if (en->cipher_algorithm == CRYPTO_AES_CBC) + return (decrypt_tls_aes_cbc_mte(en, seqno, src, len, dst, avail, + record_type)); + else + return (decrypt_tls_aead(en, seqno, src, len, dst, avail, + record_type)); +} + +static void +test_ktls_transmit_app_data(struct tls_enable *en, uint64_t seqno, size_t len) +{ + struct kevent ev; + struct tls_record_layer *hdr; + char *plaintext, *decrypted, *outbuf; + size_t decrypted_len, outbuf_len, outbuf_cap, record_len, written; + ssize_t rv; + int kq, sockets[2]; + uint8_t record_type; + + plaintext = alloc_buffer(len); + decrypted = malloc(len); + outbuf_cap = tls_header_len(en) + TLS_MAX_MSG_SIZE_V10_2 + + tls_trailer_len(en); + outbuf = malloc(outbuf_cap); + hdr = (struct tls_record_layer *)outbuf; + + ATF_REQUIRE((kq = kqueue()) != -1); + + ATF_REQUIRE_MSG(socketpair_tcp(sockets), "failed to create sockets"); + + ATF_REQUIRE(setsockopt(sockets[1], IPPROTO_TCP, TCP_TXTLS_ENABLE, en, + sizeof(*en)) == 0); + + EV_SET(&ev, sockets[0], EVFILT_READ, EV_ADD, 0, 0, NULL); + ATF_REQUIRE(kevent(kq, &ev, 1, NULL, 0, NULL) == 0); + EV_SET(&ev, sockets[1], EVFILT_WRITE, EV_ADD, 0, 0, NULL); + ATF_REQUIRE(kevent(kq, &ev, 1, NULL, 0, NULL) == 0); + + decrypted_len = 0; + outbuf_len = 0; + written = 0; + + while (decrypted_len != len) { + ATF_REQUIRE(kevent(kq, NULL, 0, &ev, 1, NULL) == 1); + + switch (ev.filter) { + case EVFILT_WRITE: + /* Try to write any remaining data. */ + rv = write(ev.ident, plaintext + written, + len - written); + ATF_REQUIRE_MSG(rv > 0, + "failed to write to socket"); + written += rv; + if (written == len) { + ev.flags = EV_DISABLE; + ATF_REQUIRE(kevent(kq, &ev, 1, NULL, 0, + NULL) == 0); + } + break; + + case EVFILT_READ: + ATF_REQUIRE((ev.flags & EV_EOF) == 0); + + /* + * Try to read data for the next TLS record + * into outbuf. Start by reading the header + * to determine how much additional data to + * read. + */ + if (outbuf_len < sizeof(struct tls_record_layer)) { + rv = read(ev.ident, outbuf + outbuf_len, + sizeof(struct tls_record_layer) - + outbuf_len); + ATF_REQUIRE_MSG(rv > 0, + "failed to read from socket"); + outbuf_len += rv; + } + + if (outbuf_len < sizeof(struct tls_record_layer)) + break; + + record_len = sizeof(struct tls_record_layer) + + ntohs(hdr->tls_length); + assert(record_len <= outbuf_cap); + assert(record_len > outbuf_len); + rv = read(ev.ident, outbuf + outbuf_len, + record_len - outbuf_len); + if (rv == -1 && errno == EAGAIN) + break; + ATF_REQUIRE_MSG(rv > 0, "failed to read from socket"); + + outbuf_len += rv; + if (outbuf_len == record_len) { + decrypted_len += decrypt_tls_record(en, seqno, + outbuf, outbuf_len, + decrypted + decrypted_len, + len - decrypted_len, &record_type); + ATF_REQUIRE(record_type == TLS_RLTYPE_APP); + + seqno++; + outbuf_len = 0; + } + break; + } + } + + ATF_REQUIRE_MSG(written == decrypted_len, + "read %zu decrypted bytes, but wrote %zu", decrypted_len, written); + + ATF_REQUIRE(memcmp(plaintext, decrypted, len) == 0); + + free(outbuf); + free(decrypted); + free(plaintext); + + close(sockets[1]); + close(sockets[0]); + close(kq); +} + +static void +ktls_send_control_message(int fd, uint8_t type, void *data, size_t len) +{ + struct msghdr msg; + struct cmsghdr *cmsg; + char cbuf[CMSG_SPACE(sizeof(type))]; + struct iovec iov; + + memset(&msg, 0, sizeof(msg)); + + msg.msg_control = cbuf; + msg.msg_controllen = sizeof(cbuf); + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_level = IPPROTO_TCP; + cmsg->cmsg_type = TLS_SET_RECORD_TYPE; + cmsg->cmsg_len = CMSG_LEN(sizeof(type)); + *(uint8_t *)CMSG_DATA(cmsg) = type; + + iov.iov_base = data; + iov.iov_len = len; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + + ATF_REQUIRE(sendmsg(fd, &msg, 0) == (ssize_t)len); +} + +static void +test_ktls_transmit_control(struct tls_enable *en, uint64_t seqno, uint8_t type, + size_t len) +{ + struct tls_record_layer *hdr; + char *plaintext, *decrypted, *outbuf; + size_t outbuf_cap, payload_len, record_len; + ssize_t rv; + int sockets[2]; + uint8_t record_type; + + ATF_REQUIRE(len <= TLS_MAX_MSG_SIZE_V10_2); + + plaintext = alloc_buffer(len); + decrypted = malloc(len); + outbuf_cap = tls_header_len(en) + len + tls_trailer_len(en); + outbuf = malloc(outbuf_cap); + hdr = (struct tls_record_layer *)outbuf; + + ATF_REQUIRE_MSG(socketpair_tcp(sockets), "failed to create sockets"); + + ATF_REQUIRE(setsockopt(sockets[1], IPPROTO_TCP, TCP_TXTLS_ENABLE, en, + sizeof(*en)) == 0); + + fd_set_blocking(sockets[0]); + fd_set_blocking(sockets[1]); + + ktls_send_control_message(sockets[1], type, plaintext, len); + + /* + * First read the header to determine how much additional data + * to read. + */ + rv = read(sockets[0], outbuf, sizeof(struct tls_record_layer)); + ATF_REQUIRE(rv == sizeof(struct tls_record_layer)); + payload_len = ntohs(hdr->tls_length); + record_len = payload_len + sizeof(struct tls_record_layer); + assert(record_len <= outbuf_cap); + rv = read(sockets[0], outbuf + sizeof(struct tls_record_layer), + payload_len); + ATF_REQUIRE(rv == (ssize_t)payload_len); + + rv = decrypt_tls_record(en, seqno, outbuf, record_len, decrypted, len, + &record_type); + + ATF_REQUIRE_MSG((ssize_t)len == rv, + "read %zd decrypted bytes, but wrote %zu", rv, len); + ATF_REQUIRE(record_type == type); + + ATF_REQUIRE(memcmp(plaintext, decrypted, len) == 0); + + free(outbuf); + free(decrypted); + free(plaintext); + + close(sockets[1]); + close(sockets[0]); +} + +#define AES_CBC_TESTS(M) \ + M(aes128_cbc_1_0_sha1, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA1_HMAC, TLS_MINOR_VER_ZERO) \ + M(aes256_cbc_1_0_sha1, CRYPTO_AES_CBC, 256 / 8, \ + CRYPTO_SHA1_HMAC, TLS_MINOR_VER_ZERO) \ + M(aes128_cbc_1_1_sha1, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA1_HMAC, TLS_MINOR_VER_ONE) \ + M(aes256_cbc_1_1_sha1, CRYPTO_AES_CBC, 256 / 8, \ + CRYPTO_SHA1_HMAC, TLS_MINOR_VER_ONE) \ + M(aes128_cbc_1_2_sha1, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA1_HMAC, TLS_MINOR_VER_TWO) \ + M(aes256_cbc_1_2_sha1, CRYPTO_AES_CBC, 256 / 8, \ + CRYPTO_SHA1_HMAC, TLS_MINOR_VER_TWO) \ + M(aes128_cbc_1_2_sha256, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_256_HMAC, TLS_MINOR_VER_TWO) \ + M(aes256_cbc_1_2_sha256, CRYPTO_AES_CBC, 256 / 8, \ + CRYPTO_SHA2_256_HMAC, TLS_MINOR_VER_TWO) \ + M(aes128_cbc_1_2_sha384, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_384_HMAC, TLS_MINOR_VER_TWO) \ + M(aes256_cbc_1_2_sha384, CRYPTO_AES_CBC, 256 / 8, \ + CRYPTO_SHA2_384_HMAC, TLS_MINOR_VER_TWO) \ + +#define AES_GCM_TESTS(M) \ *** 97 LINES SKIPPED *** From nobody Mon Nov 1 19:43: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 72EA9183D480; Mon, 1 Nov 2021 19:43:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hjk3f2JYnz3plg; Mon, 1 Nov 2021 19:43:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F701174E1; Mon, 1 Nov 2021 19:43: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 1A1JhQjE037704; Mon, 1 Nov 2021 19:43:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1JhQst037703; Mon, 1 Nov 2021 19:43:26 GMT (envelope-from git) Date: Mon, 1 Nov 2021 19:43:26 GMT Message-Id: <202111011943.1A1JhQst037703@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Zhilin Subject: git: 9400fe9cf8df - main - Add entry in rtwn_usb(4) for TP-Link Archer T2U Plus 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: mizhka X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9400fe9cf8df6744844038db3030ed2fe94e90dd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mizhka: URL: https://cgit.FreeBSD.org/src/commit/?id=9400fe9cf8df6744844038db3030ed2fe94e90dd commit 9400fe9cf8df6744844038db3030ed2fe94e90dd Author: Michael Zhilin AuthorDate: 2021-11-01 19:39:50 +0000 Commit: Michael Zhilin CommitDate: 2021-11-01 19:39:50 +0000 Add entry in rtwn_usb(4) for TP-Link Archer T2U Plus This is missing documentation change of D24142. Submitted by: kjopek@gmail.com Reviewed by: gbe Differential Revision: https://reviews.freebsd.org/D25114 --- share/man/man4/rtwn_usb.4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/man/man4/rtwn_usb.4 b/share/man/man4/rtwn_usb.4 index 86c4c02aafa9..aee135eaf5e4 100644 --- a/share/man/man4/rtwn_usb.4 +++ b/share/man/man4/rtwn_usb.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\"/ -.Dd May 27, 2021 +.Dd November 1, 2021 .Dt RTWN_USB 4 .Os .Sh NAME @@ -49,7 +49,7 @@ kernel configuration file: .Cd "device rtwn_usb" .Cd "device wlan" .Ed -.Sh DESCRIPTION +.SH DESCRIPTION This module provides the USB bus glue needed for the devices supported by the .Xr rtwn 4 @@ -99,6 +99,7 @@ based USB wireless network adapters, including: .It "Realtek RTL8188CUS" Ta RTL8188CUS Ta USB 2.0 .It "Sitecom WLA-7100" Ta RTL8812AU Ta USB 3.0 .It "TP-Link Archer T2U Nano" Ta RTL8821AU Ta USB 2.0 +.It "TP-Link Archer T2U Plus" Ta RTL8821AU Ta USB 2.0 .It "TP-Link Archer T2U v3" Ta RTL8821AU Ta USB 2.0 .It "TP-Link Archer T4U" Ta RTL8812AU Ta USB 3.0 .It "TP-Link Archer T4U v2" Ta RTL8812AU Ta USB 3.0 From nobody Mon Nov 1 19:46: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 8956D183DA1A; Mon, 1 Nov 2021 19:46: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 4Hjk6p3TDSz3qR9; Mon, 1 Nov 2021 19:46: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 51E30177A2; Mon, 1 Nov 2021 19:46: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 1A1JkAbq038024; Mon, 1 Nov 2021 19:46:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1JkAVu038023; Mon, 1 Nov 2021 19:46:10 GMT (envelope-from git) Date: Mon, 1 Nov 2021 19:46:10 GMT Message-Id: <202111011946.1A1JkAVu038023@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: 87152f340549 - main - ssh: disble internal security key support in generated config.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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 87152f34054921632016bc5eb4ab9f836fbaa522 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=87152f34054921632016bc5eb4ab9f836fbaa522 commit 87152f34054921632016bc5eb4ab9f836fbaa522 Author: Ed Maste AuthorDate: 2021-10-27 20:45:35 +0000 Commit: Ed Maste CommitDate: 2021-11-01 19:45:37 +0000 ssh: disble internal security key support in generated config.h We want to set ENABLE_SK_INTERNAL only when building with USB support. We'll leave it off in config.h and enble it via our bespoke build's Makefile.inc. Sponsored by: The FreeBSD Foundation --- crypto/openssh/freebsd-configure.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/openssh/freebsd-configure.sh b/crypto/openssh/freebsd-configure.sh index d89d536bfd6a..8df468e5eb1c 100755 --- a/crypto/openssh/freebsd-configure.sh +++ b/crypto/openssh/freebsd-configure.sh @@ -12,6 +12,7 @@ configure_args=" --with-libedit --with-ssl-engine --without-xauth + --without-security-key-internal " set -e From nobody Mon Nov 1 20:00: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 F16B11844C9A; Mon, 1 Nov 2021 20:00: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 4HjkR56Wckz4R1P; Mon, 1 Nov 2021 20:00: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 C01CB17461; Mon, 1 Nov 2021 20:00: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 1A1K0HOw059386; Mon, 1 Nov 2021 20:00:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1K0Hs4059375; Mon, 1 Nov 2021 20:00:17 GMT (envelope-from git) Date: Mon, 1 Nov 2021 20:00:17 GMT Message-Id: <202111012000.1A1K0Hs4059375@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: edf6dd82e966 - main - pf: fix use-after-free from pf_find_state_all 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: edf6dd82e9662b72c17483de4de5575dd5acd972 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=edf6dd82e9662b72c17483de4de5575dd5acd972 commit edf6dd82e9662b72c17483de4de5575dd5acd972 Author: Mateusz Guzik AuthorDate: 2021-11-01 13:02:43 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-01 19:59:05 +0000 pf: fix use-after-free from pf_find_state_all state was returned without any locks nor references held Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 21 +++++++++++++++++++-- sys/netpfil/pf/pf_ioctl.c | 42 +++++++++++++++++++++++------------------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 61eea329a7f7..d7644b47f700 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1510,6 +1510,9 @@ pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir) return (NULL); } +/* + * Returns with ID hash slot locked on success. + */ struct pf_kstate * pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more) { @@ -1547,14 +1550,17 @@ pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more) second_run: TAILQ_FOREACH(s, &sk->states[idx], key_list[idx]) { if (more == NULL) { + PF_STATE_LOCK(s); PF_HASHROW_UNLOCK(kh); return (s); } if (ret) (*more)++; - else + else { ret = s; + PF_STATE_LOCK(s); + } } if (inout == 1) { inout = 0; @@ -1566,13 +1572,24 @@ second_run: return (ret); } +/* + * FIXME + * This routine is inefficient -- locks the state only to unlock immediately on + * return. + * It is racy -- after the state is unlocked nothing stops other threads from + * removing it. + */ bool pf_find_state_all_exists(struct pf_state_key_cmp *key, u_int dir) { struct pf_kstate *s; s = pf_find_state_all(key, dir, NULL); - return (s != NULL); + if (s != NULL) { + PF_STATE_UNLOCK(s); + return (true); + } + return (false); } /* END state table stuff */ diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index ee265de65b45..1cfedf19e662 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2029,19 +2029,20 @@ pf_label_match(const struct pf_krule *rule, const char *label) static unsigned int pf_kill_matching_state(struct pf_state_key_cmp *key, int dir) { - struct pf_kstate *match; + struct pf_kstate *s; int more = 0; - unsigned int killed = 0; - /* Call with unlocked hashrow */ + s = pf_find_state_all(key, dir, &more); + if (s == NULL) + return (0); - match = pf_find_state_all(key, dir, &more); - if (match && !more) { - pf_unlink_state(match, 0); - killed++; + if (more) { + PF_STATE_UNLOCK(s); + return (0); } - return (killed); + pf_unlink_state(s, PF_ENTER_LOCKED); + return (1); } static int @@ -3159,18 +3160,21 @@ DIOCGETSTATESV2_full: key.port[didx] = pnl->dport; state = pf_find_state_all(&key, direction, &m); - - if (m > 1) - error = E2BIG; /* more than one state */ - else if (state != NULL) { - /* XXXGL: not locked read */ - sk = state->key[sidx]; - PF_ACPY(&pnl->rsaddr, &sk->addr[sidx], sk->af); - pnl->rsport = sk->port[sidx]; - PF_ACPY(&pnl->rdaddr, &sk->addr[didx], sk->af); - pnl->rdport = sk->port[didx]; - } else + if (state == NULL) { error = ENOENT; + } else { + if (m > 1) { + PF_STATE_UNLOCK(state); + error = E2BIG; /* more than one state */ + } else { + sk = state->key[sidx]; + PF_ACPY(&pnl->rsaddr, &sk->addr[sidx], sk->af); + pnl->rsport = sk->port[sidx]; + PF_ACPY(&pnl->rdaddr, &sk->addr[didx], sk->af); + pnl->rdport = sk->port[didx]; + PF_STATE_UNLOCK(state); + } + } } break; } From nobody Mon Nov 1 20:00: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 396221844B70; Mon, 1 Nov 2021 20:00: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 4HjkR70wv4z4Qsf; Mon, 1 Nov 2021 20:00: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 E835D17A90; Mon, 1 Nov 2021 20:00:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A1K0IIc059911; Mon, 1 Nov 2021 20:00:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1K0IBU059903; Mon, 1 Nov 2021 20:00:18 GMT (envelope-from git) Date: Mon, 1 Nov 2021 20:00:18 GMT Message-Id: <202111012000.1A1K0IBU059903@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: 8f3d786cb301 - main - pf: remove the flags argument from pf_unlink_state 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: 8f3d786cb301c49dec189bad80cdc163dd3ca1d7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8f3d786cb301c49dec189bad80cdc163dd3ca1d7 commit 8f3d786cb301c49dec189bad80cdc163dd3ca1d7 Author: Mateusz Guzik AuthorDate: 2021-11-01 13:14:02 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-01 19:59:14 +0000 pf: remove the flags argument from pf_unlink_state All consumers call it with PF_ENTER_LOCKED. Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/net/pfvar.h | 4 +--- sys/netpfil/pf/if_pfsync.c | 6 +++--- sys/netpfil/pf/pf.c | 11 ++++------- sys/netpfil/pf/pf_ioctl.c | 10 +++++----- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 9fa1da8b5c07..e9277dce4963 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1915,9 +1915,7 @@ extern void pf_unload_vnet_purge(void); extern void pf_intr(void *); extern void pf_purge_expired_src_nodes(void); -extern int pf_unlink_state(struct pf_kstate *, u_int); -#define PF_ENTER_LOCKED 0x00000001 -#define PF_RETURN_LOCKED 0x00000002 +extern int pf_unlink_state(struct pf_kstate *); extern int pf_state_insert(struct pfi_kkif *, struct pfi_kkif *, struct pf_state_key *, diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index e959fdbc8553..1aa5e6c0b066 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -759,7 +759,7 @@ relock: LIST_FOREACH(s, &ih->states, entry) { if (s->creatorid == creatorid) { s->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(s, PF_ENTER_LOCKED); + pf_unlink_state(s); goto relock; } } @@ -1118,7 +1118,7 @@ pfsync_in_del(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count) continue; } st->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(st, PF_ENTER_LOCKED); + pf_unlink_state(st); } return (len); @@ -1150,7 +1150,7 @@ pfsync_in_del_c(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count) } st->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(st, PF_ENTER_LOCKED); + pf_unlink_state(st); } return (len); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index d7644b47f700..9595650dbc36 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1995,14 +1995,11 @@ pf_src_tree_remove_state(struct pf_kstate *s) * unlocked, since it needs to go through key hash locking. */ int -pf_unlink_state(struct pf_kstate *s, u_int flags) +pf_unlink_state(struct pf_kstate *s) { struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(s)]; - if ((flags & PF_ENTER_LOCKED) == 0) - PF_HASHROW_LOCK(ih); - else - PF_HASHROW_ASSERT(ih); + PF_HASHROW_ASSERT(ih); if (s->timeout == PFTM_UNLINKED) { /* @@ -2091,7 +2088,7 @@ relock: LIST_FOREACH(s, &ih->states, entry) { if (pf_state_expires(s) <= time_uptime) { V_pf_status.states -= - pf_unlink_state(s, PF_ENTER_LOCKED); + pf_unlink_state(s); goto relock; } s->rule.ptr->rule_ref |= PFRULE_REFS; @@ -4992,7 +4989,7 @@ pf_test_state_tcp(struct pf_kstate **state, int direction, struct pfi_kkif *kif, } /* XXX make sure it's the same direction ?? */ pf_set_protostate(*state, PF_PEER_BOTH, TCPS_CLOSED); - pf_unlink_state(*state, PF_ENTER_LOCKED); + pf_unlink_state(*state); *state = NULL; return (PF_DROP); } diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 1cfedf19e662..727ebb0135f4 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2041,7 +2041,7 @@ pf_kill_matching_state(struct pf_state_key_cmp *key, int dir) return (0); } - pf_unlink_state(s, PF_ENTER_LOCKED); + pf_unlink_state(s); return (1); } @@ -2138,7 +2138,7 @@ relock_DIOCKILLSTATES: match_key.port[1] = s->key[idx]->port[0]; } - pf_unlink_state(s, PF_ENTER_LOCKED); + pf_unlink_state(s); killed++; if (psk->psk_kill_match) @@ -5040,7 +5040,7 @@ relock: s->timeout = PFTM_PURGE; /* Don't send out individual delete messages. */ s->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(s, PF_ENTER_LOCKED); + pf_unlink_state(s); goto relock; } PF_HASHROW_UNLOCK(ih); @@ -5227,7 +5227,7 @@ relock_DIOCCLRSTATES: * delete messages. */ s->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(s, PF_ENTER_LOCKED); + pf_unlink_state(s); killed++; if (kill->psk_kill_match) @@ -5255,7 +5255,7 @@ pf_killstates(struct pf_kstate_kill *kill, unsigned int *killed) kill->psk_pfcmp.creatorid = V_pf_status.hostid; if ((s = pf_find_state_byid(kill->psk_pfcmp.id, kill->psk_pfcmp.creatorid))) { - pf_unlink_state(s, PF_ENTER_LOCKED); + pf_unlink_state(s); *killed = 1; } return; From nobody Mon Nov 1 23:11: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 182E31833452; Mon, 1 Nov 2021 23:11: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 4Hjph00FS2z3mqD; Mon, 1 Nov 2021 23:11: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 DD17E1A504; Mon, 1 Nov 2021 23:11: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 1A1NBhuA014892; Mon, 1 Nov 2021 23:11:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1NBhJh014891; Mon, 1 Nov 2021 23:11:43 GMT (envelope-from git) Date: Mon, 1 Nov 2021 23:11:43 GMT Message-Id: <202111012311.1A1NBhJh014891@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: 8e2796878626 - main - inet: remove tcp_debug from netinet/tcp_debug.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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e2796878626ccc2fc15e4911a16af8a9fa7819a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8e2796878626ccc2fc15e4911a16af8a9fa7819a commit 8e2796878626ccc2fc15e4911a16af8a9fa7819a Author: Mateusz Guzik AuthorDate: 2021-11-01 21:28:54 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-01 23:10:30 +0000 inet: remove tcp_debug from netinet/tcp_debug.h It was a hack only needed for trpt, which can just define it locally. This makes it possible to fix up systat which also includes the file. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netinet/tcp_debug.h | 6 ------ usr.sbin/trpt/trpt.c | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/netinet/tcp_debug.h b/sys/netinet/tcp_debug.h index c44930724b66..0b3c895e9909 100644 --- a/sys/netinet/tcp_debug.h +++ b/sys/netinet/tcp_debug.h @@ -73,10 +73,4 @@ static const char *tanames[] = #define TCP_NDEBUG 100 -#ifndef _KERNEL -/* XXX common variables for broken applications. */ -struct tcp_debug tcp_debug[TCP_NDEBUG]; -int tcp_debx; -#endif - #endif /* !_NETINET_TCP_DEBUG_H_ */ diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c index e8198f7d080e..59727cadaaba 100644 --- a/usr.sbin/trpt/trpt.c +++ b/usr.sbin/trpt/trpt.c @@ -85,6 +85,9 @@ __FBSDID("$FreeBSD$"); #include #include +static struct tcp_debug tcp_debug[TCP_NDEBUG]; +static int tcp_debx; + static struct nlist nl[3]; #define N_TCP_DEBUG 0 #define N_TCP_DEBX 1 From nobody Mon Nov 1 23:11: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 5954F18333A6; Mon, 1 Nov 2021 23:11: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 4Hjph11dR4z3mZ4; Mon, 1 Nov 2021 23:11: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 106DA19FF6; Mon, 1 Nov 2021 23:11: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 1A1NBidA014916; Mon, 1 Nov 2021 23:11:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1NBivv014915; Mon, 1 Nov 2021 23:11:44 GMT (envelope-from git) Date: Mon, 1 Nov 2021 23:11:44 GMT Message-Id: <202111012311.1A1NBivv014915@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: 6d88f9fed6a2 - main - systat: mostly clean up warns 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: 6d88f9fed6a2aa1ffd2c856d246209f24b7dbea0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=6d88f9fed6a2aa1ffd2c856d246209f24b7dbea0 commit 6d88f9fed6a2aa1ffd2c856d246209f24b7dbea0 Author: Mateusz Guzik AuthorDate: 2021-11-01 20:45:42 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-01 23:11:16 +0000 systat: mostly clean up warns Sponsored by: Rubicon Communications, LLC ("Netgate") --- usr.bin/systat/Makefile | 4 ++-- usr.bin/systat/devs.c | 10 +++++----- usr.bin/systat/extern.h | 5 +++++ usr.bin/systat/ifstat.c | 35 +++++++++++++---------------------- usr.bin/systat/main.c | 12 ++++++------ usr.bin/systat/netstat.c | 2 +- usr.bin/systat/proc.c | 30 ++++++++---------------------- usr.bin/systat/sysput.c | 36 +++++++++++++++++++++--------------- usr.bin/systat/vmstat.c | 16 ++++------------ 9 files changed, 65 insertions(+), 85 deletions(-) diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile index 58b6c855d6af..e0575ff0d15a 100644 --- a/usr.bin/systat/Makefile +++ b/usr.bin/systat/Makefile @@ -14,8 +14,8 @@ SRCS+= icmp6.c ip6.c CFLAGS+= -DINET6 .endif -WARNS?= 1 - LIBADD= tinfow ncursesw m devstat kvm util procstat .include + +CFLAGS+= -Wno-cast-align -Wno-cast-qual diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c index 87d04f989ea3..63990bab5f81 100644 --- a/usr.bin/systat/devs.c +++ b/usr.bin/systat/devs.c @@ -86,16 +86,16 @@ typedef enum { struct statinfo cur_dev, last_dev, run_dev; -last_match_type last_type; +static last_match_type last_type; struct device_selection *dev_select; long generation; int num_devices, num_selected; int num_selections; long select_generation; -struct devstat_match *matches = NULL; -int num_matches = 0; -char **specified_devices; -int num_devices_specified = 0; +static struct devstat_match *matches = NULL; +static int num_matches = 0; +static char **specified_devices; +static int num_devices_specified = 0; static int dsmatchselect(const char *args, devstat_select_mode select_mode, int maxshowdevs, struct statinfo *s1); diff --git a/usr.bin/systat/extern.h b/usr.bin/systat/extern.h index 322065f79312..3b5597598b8b 100644 --- a/usr.bin/systat/extern.h +++ b/usr.bin/systat/extern.h @@ -58,6 +58,11 @@ extern int protos; extern int verbose; extern unsigned int delay; +extern int curscale; +extern char *matchline; +extern int showpps; +extern int needsort; + struct in_conninfo; extern struct device_selection *dev_select; diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c index 82e3429dbfda..c97e586ae7a3 100644 --- a/usr.bin/systat/ifstat.c +++ b/usr.bin/systat/ifstat.c @@ -56,15 +56,11 @@ #define C4 60 /* 60-80 */ #define C5 80 /* Used for label positioning. */ -static const int col0 = 0; -static const int col1 = C1; static const int col2 = C2; static const int col3 = C3; static const int col4 = C4; -static const int col5 = C5; -SLIST_HEAD(, if_stat) curlist; -SLIST_HEAD(, if_stat_disp) displist; +static SLIST_HEAD(, if_stat) curlist; struct if_stat { SLIST_ENTRY(if_stat) link; @@ -87,11 +83,6 @@ struct if_stat { u_int match; }; -extern int curscale; -extern char *matchline; -extern int showpps; -extern int needsort; - static int needclear = 0; static bool displayall = false; @@ -217,19 +208,19 @@ showifstat(void) struct if_stat *ifp = NULL; SLIST_FOREACH(ifp, &curlist, link) { - if (ifp->if_ypos < LINES - 3 && ifp->if_ypos != -1) + if (ifp->if_ypos < LINES - 3 && ifp->if_ypos != -1) { if (!ifp->display || ifp->match == 0) { wmove(wnd, ifp->if_ypos, 0); wclrtoeol(wnd); wmove(wnd, ifp->if_ypos + 1, 0); wclrtoeol(wnd); - } - else { + } else { PUTNAME(ifp); PUTRATE(col2, ifp->if_ypos); PUTRATE(col3, ifp->if_ypos); PUTTOTAL(col4, ifp->if_ypos); } + } } return; @@ -390,9 +381,9 @@ format_device_name(struct if_stat *ifp) static int check_match(const char *ifname) { - char *p = matchline, *c, t; + char *p = matchline, *ch, t; int match = 0, mlen; - + if (matchline == NULL) return (0); @@ -400,21 +391,21 @@ check_match(const char *ifname) while (*p == ' ') p ++; - c = p; - while ((mlen = strcspn(c, " ;,")) != 0) { - p = c + mlen; + ch = p; + while ((mlen = strcspn(ch, " ;,")) != 0) { + p = ch + mlen; t = *p; - if (p - c > 0) { + if (p - ch > 0) { *p = '\0'; - if (fnmatch(c, ifname, FNM_CASEFOLD) == 0) { + if (fnmatch(ch, ifname, FNM_CASEFOLD) == 0) { *p = t; return (1); } *p = t; - c = p + strspn(p, " ;,"); + ch = p + strspn(p, " ;,"); } else { - c = p + strspn(p, " ;,"); + ch = p + strspn(p, " ;,"); } } diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c index b84351379f41..3266fa187714 100644 --- a/usr.bin/systat/main.c +++ b/usr.bin/systat/main.c @@ -38,7 +38,7 @@ static const char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #endif #ifndef lint -static const char copyright[] = +static const char copyright[] __unused = "@(#) Copyright (c) 1980, 1992, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif @@ -65,12 +65,11 @@ static const char copyright[] = static int dellave; kvm_t *kd; -sig_t sigtstpdfl; double avenrun[3]; int col; unsigned int delay = 5000000; /* in microseconds */ int verbose = 1; /* to report kvm read errs */ -struct clockinfo clkinfo; +static struct clockinfo clkinfo; double hertz; char c; char *namp; @@ -86,7 +85,7 @@ struct cmdentry { char *cmd; /* Command name */ char *argv; /* Arguments vector for a command */ }; -SLIST_HEAD(, cmdentry) commands; +static SLIST_HEAD(, cmdentry) commands; static void parse_cmd_args (int argc, char **argv) @@ -277,6 +276,7 @@ void display(void) { uint64_t arc_stat; + unsigned int ui; int i, j; /* Get the load average over the last minute. */ @@ -316,8 +316,8 @@ display(void) GETSYSCTL("kstat.zfs.misc.arcstats.dbuf_size", arc_stat); arc[6] += arc_stat; wmove(wload, 0, 0); wclrtoeol(wload); - for (i = 0 ; i < nitems(arc); i++) - sysputuint64(wload, 0, i*8+2, 6, arc[i], 0); + for (ui = 0 ; ui < nitems(arc); ui++) + sysputuint64(wload, 0, ui*8+2, 6, arc[ui], 0); } } (*curcmd->c_refresh)(); diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index a334e03beb5a..8199d0c81586 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -115,7 +115,7 @@ struct netinfo { u_int ni_sndcc; /* snd buffer character count */ }; -TAILQ_HEAD(netinfohead, netinfo) netcb = TAILQ_HEAD_INITIALIZER(netcb); +static TAILQ_HEAD(netinfohead, netinfo) netcb = TAILQ_HEAD_INITIALIZER(netcb); static int aflag = 0; static int nflag = 0; diff --git a/usr.bin/systat/proc.c b/usr.bin/systat/proc.c index 58c3bea64239..deb27fc2f4bb 100644 --- a/usr.bin/systat/proc.c +++ b/usr.bin/systat/proc.c @@ -64,14 +64,14 @@ static struct proc_usage { uint64_t total; uint32_t pages; } **pu = NULL; -static unsigned int nproc; +static 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; + const char *uname; char buf[30]; uint64_t swapbytes; @@ -210,25 +210,11 @@ per_proc_swap_usage(struct kinfo_proc *kipp) } 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) +procshow(int lcol, int hight, uint64_t totalswappages) { int i, y; - for (i = 0, y = col + 1 /* HEADING */; i < hight; i++, y++) + for (i = 0, y = lcol + 1 /* HEADING */; i < hight; i++, y++) display_proc_line(i, y, totalswappages); } @@ -244,7 +230,7 @@ procinit(void) void procgetinfo(void) { - static unsigned int maxnproc = 0; + static int maxnproc = 0; int cnt, i; uint32_t pages; struct kinfo_proc *kipp; @@ -289,12 +275,12 @@ procgetinfo(void) } void -proclabel(int col) +proclabel(int lcol) { - wmove(wnd, col, 0); + wmove(wnd, lcol, 0); wclrtoeol(wnd); - mvwaddstr(wnd, col, 0, + mvwaddstr(wnd, lcol, 0, "Pid Username Command Swap/Total " "Per-Process Per-System"); } diff --git a/usr.bin/systat/sysput.c b/usr.bin/systat/sysput.c index 6e14f9eb752f..bccc00f65165 100644 --- a/usr.bin/systat/sysput.c +++ b/usr.bin/systat/sysput.c @@ -41,36 +41,42 @@ __FBSDID("$FreeBSD$"); #include "extern.h" void -sysputspaces(WINDOW *wd, int row, int col, int width) +sysputspaces(WINDOW *wd, int row, int lcol, int width) { static char str60[] = " " " "; - mvwaddstr(wd, row, col, str60 + sizeof(str60) - width - 1); + mvwaddstr(wd, row, lcol, str60 + sizeof(str60) - width - 1); } void -sysputstrs(WINDOW *wd, int row, int col, int width) +sysputstrs(WINDOW *wd __unused, int row, int lcol, int width) { static char str60[] = "********************" "****************************************"; - mvwaddstr(wnd, row, col, str60 + sizeof(str60) - width - 1); + /* + * XXX wnd instead of wd? + */ + mvwaddstr(wnd, row, lcol, str60 + sizeof(str60) - width - 1); } void -sysputXs(WINDOW *wd, int row, int col, int width) +sysputXs(WINDOW *wd __unused, int row, int lcol, int width) { static char str60[] = "XXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; - mvwaddstr(wnd, row, col, str60 + sizeof(str60) - width - 1); + /* + * XXX wnd instead of wd? + */ + mvwaddstr(wnd, row, lcol, str60 + sizeof(str60) - width - 1); } void -sysputuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags) +sysputuint64(WINDOW *wd, int row, int lcol, int width, uint64_t val, int flags) { - char unit, *ptr, *start, wrtbuf[width + width + 1]; + char unit, *start, wrtbuf[width + width + 1]; int len; unit = 0; @@ -88,25 +94,25 @@ sysputuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags) memset(wrtbuf + len, ' ', width - len); start += len; - mvwaddstr(wd, row, col, start); + mvwaddstr(wd, row, lcol, start); return; error: - sysputstrs(wd, row, col, width); + sysputstrs(wd, row, lcol, width); } void -sysputwuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags) +sysputwuint64(WINDOW *wd, int row, int lcol, int width, uint64_t val, int flags) { if(val == 0) - sysputspaces(wd, row, col, width); + sysputspaces(wd, row, lcol, width); else - sysputuint64(wd, row, col, width, val, flags); + sysputuint64(wd, row, lcol, width, val, flags); } void -sysputpage(WINDOW *wd, int row, int col, int width, uint64_t pages, int flags) +sysputpage(WINDOW *wd, int row, int lcol, int width, uint64_t pages, int flags) { - sysputuint64(wd, row, col, width, ptoa(pages), flags); + sysputuint64(wd, row, lcol, width, ptoa(pages), flags); } diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index e84b79bdd184..57697284a6ab 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -136,7 +136,6 @@ static void copyinfo(struct Info *, struct Info *); static float cputime(int); static void do_putuint64(uint64_t, int, int, int, int); static void getinfo(struct Info *); -static void putuint64(uint64_t, int, int, int); static int ucount(void); static int ncpu; @@ -298,7 +297,7 @@ fetchkre(void) void labelkre(void) { - int i, j; + int i; clear(); mvprintw(STATROW, STATCOL + 6, "users Load"); @@ -634,19 +633,12 @@ putint(int n, int l, int lc, int w) do_putuint64(n, l, lc, w, SI); } -static void -putuint64(uint64_t n, int l, int lc, int w) -{ - - do_putuint64(n, l, lc, w, IEC); -} - static void do_putuint64(uint64_t n, int l, int lc, int w, int div) { int snr; char b[128]; - char buf[128]; + char lbuf[128]; move(l, lc); #ifdef DEBUG @@ -661,9 +653,9 @@ do_putuint64(uint64_t n, int l, int lc, int w, int div) } snr = snprintf(b, sizeof(b), "%*ju", w, (uintmax_t)n); if (snr != w) { - humanize_number(buf, w, n, "", HN_AUTOSCALE, + humanize_number(lbuf, w, n, "", HN_AUTOSCALE, HN_NOSPACE | HN_DECIMAL | div); - snr = snprintf(b, sizeof(b), "%*s", w, buf); + snr = snprintf(b, sizeof(b), "%*s", w, lbuf); } if (snr != w) { while (w-- > 0) From nobody Mon Nov 1 23:59: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 278681820CB1; Mon, 1 Nov 2021 23:59: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 4Hjqkn0Yzgz4WQq; Mon, 1 Nov 2021 23:59: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 E31931AC16; Mon, 1 Nov 2021 23:59: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 1A1NxCfE071902; Mon, 1 Nov 2021 23:59:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1NxCw6071901; Mon, 1 Nov 2021 23:59:12 GMT (envelope-from git) Date: Mon, 1 Nov 2021 23:59:12 GMT Message-Id: <202111012359.1A1NxCw6071901@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: 932c2667d9bc - main - systat: fix stack overflow when running -iostat 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: 932c2667d9bca62ad5f03757775ebe8aa743cfd8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=932c2667d9bca62ad5f03757775ebe8aa743cfd8 commit 932c2667d9bca62ad5f03757775ebe8aa743cfd8 Author: Mateusz Guzik AuthorDate: 2021-11-01 23:55:47 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-01 23:57:27 +0000 systat: fix stack overflow when running -iostat The new buffer is arbitrarily sized to likely "big enough". Sponsored by: Rubicon Communications, LLC ("Netgate") --- usr.bin/systat/iostat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c index 8767a046d81a..e3d577507e08 100644 --- a/usr.bin/systat/iostat.c +++ b/usr.bin/systat/iostat.c @@ -185,7 +185,7 @@ static int numlabels(int row) { int i, _col, regions, ndrives; - char tmpstr[10]; + char tmpstr[32]; #define COLWIDTH 17 #define DRIVESPERLINE ((getmaxx(wnd) - 1 - INSET) / COLWIDTH) @@ -211,7 +211,7 @@ numlabels(int row) if (row > getmaxy(wnd) - 1 - (linesperregion + 1)) break; } - sprintf(tmpstr, "%s%d", dev_select[i].device_name, + snprintf(tmpstr, sizeof(tmpstr), "%s%d", dev_select[i].device_name, dev_select[i].unit_number); mvwaddstr(wnd, row, _col + 4, tmpstr); mvwaddstr(wnd, row + 1, _col, " KB/t tps MB/s "); @@ -226,7 +226,7 @@ static int barlabels(int row) { int i; - char tmpstr[10]; + char tmpstr[32]; mvwaddstr(wnd, row++, INSET, "/0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100"); @@ -235,7 +235,7 @@ barlabels(int row) if (dev_select[i].selected) { if (row > getmaxy(wnd) - 1 - linesperregion) break; - sprintf(tmpstr, "%s%d", dev_select[i].device_name, + snprintf(tmpstr, sizeof(tmpstr), "%s%d", dev_select[i].device_name, dev_select[i].unit_number); mvwprintw(wnd, row++, 0, "%-5.5s MB/s|", tmpstr); From nobody Tue Nov 2 00:24: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 C26C6182BBFA; Tue, 2 Nov 2021 00:24:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HjrJQ6pF5z4d8k; Tue, 2 Nov 2021 00:24: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 94FB01AC7A; Tue, 2 Nov 2021 00:24:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A20OsMm011881; Tue, 2 Nov 2021 00:24:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A20OsCU011880; Tue, 2 Nov 2021 00:24:54 GMT (envelope-from git) Date: Tue, 2 Nov 2021 00:24:54 GMT Message-Id: <202111020024.1A20OsCU011880@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: 5a95a6e8e4d9 - main - nfscl: Use a smaller initial delay time for NFSERR_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: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a95a6e8e4d9e947b3bb4b4755a7242e1ddd72e7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=5a95a6e8e4d9e947b3bb4b4755a7242e1ddd72e7 commit 5a95a6e8e4d9e947b3bb4b4755a7242e1ddd72e7 Author: Rick Macklem AuthorDate: 2021-11-02 00:21:31 +0000 Commit: Rick Macklem CommitDate: 2021-11-02 00:21:31 +0000 nfscl: Use a smaller initial delay time for NFSERR_DELAY For NFS RPCs that receive a NFSERR_DELAY reply, the delay time is initially 1sec and then increases exponentially to NFS_TRYLATERDEL. It was found that this delay time is excessive for some NFSv4 servers, which work well with a 1msec delay. A 1sec delay resulted in very slow performance for Remove and Rename when delegations and pNFS were enabled. This patch decreases the initial delay time to 1msec. Found during a recent IETF NFSv4 working group testing event. MFC after: 2 weeks --- sys/fs/nfs/nfs_commonkrpc.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 423ddb52494f..2235f1077a03 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -107,6 +107,10 @@ static int nfs_reconnects; static int nfs3_jukebox_delay = 10; static int nfs_skip_wcc_data_onerr = 1; static int nfs_dsretries = 2; +static struct timespec nfs_trylater_max = { + .tv_sec = NFS_TRYLATERDEL, + .tv_nsec = 0, +}; SYSCTL_DECL(_vfs_nfs); @@ -584,12 +588,11 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp, u_char *retsum, int toplevel, u_int64_t *xidp, struct nfsclsession *dssep) { uint32_t retseq, retval, slotseq, *tl; - time_t waituntil; int i = 0, j = 0, opcnt, set_sigset = 0, slot; int error = 0, usegssname = 0, secflavour = AUTH_SYS; int freeslot, maxslot, reterr, slotpos, timeo; u_int16_t procnum; - u_int nextconn, trylater_delay = 1; + u_int nextconn; struct nfs_feedback_arg nf; struct timeval timo; AUTH *auth; @@ -602,7 +605,11 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp, struct nfsclsession *sep; uint8_t sessionid[NFSX_V4SESSIONID]; bool nextconn_set; + struct timespec trylater_delay, ts, waituntil; + /* Initially 1msec. */ + trylater_delay.tv_sec = 0; + trylater_delay.tv_nsec = 1000000; sep = dssep; if (xidp != NULL) *xidp = 0; @@ -1144,12 +1151,19 @@ tryagain: (nd->nd_repstat == NFSERR_DELAY && (nd->nd_flag & ND_NFSV4) == 0) || nd->nd_repstat == NFSERR_RESOURCE) { - if (trylater_delay > NFS_TRYLATERDEL) - trylater_delay = NFS_TRYLATERDEL; - waituntil = NFSD_MONOSEC + trylater_delay; - while (NFSD_MONOSEC < waituntil) - (void) nfs_catnap(PZERO, 0, "nfstry"); - trylater_delay *= 2; + /* Clip at NFS_TRYLATERDEL. */ + if (timespeccmp(&trylater_delay, + &nfs_trylater_max, >)) + trylater_delay = nfs_trylater_max; + getnanouptime(&waituntil); + timespecadd(&waituntil, &trylater_delay, + &waituntil); + do { + nfs_catnap(PZERO, 0, "nfstry"); + getnanouptime(&ts); + } while (timespeccmp(&ts, &waituntil, <)); + timespecadd(&trylater_delay, &trylater_delay, + &trylater_delay); /* Double each time. */ if (slot != -1) { mtx_lock(&sep->nfsess_mtx); sep->nfsess_slotseq[slot]++; From nobody Tue Nov 2 01:05: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 DC6F2183F947; Tue, 2 Nov 2021 01:05: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 4HjsCV5rQ5z4sXw; Tue, 2 Nov 2021 01:05: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 A91811BD0A; Tue, 2 Nov 2021 01:05: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 1A215gdY065562; Tue, 2 Nov 2021 01:05:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A215gAs065561; Tue, 2 Nov 2021 01:05:42 GMT (envelope-from git) Date: Tue, 2 Nov 2021 01:05:42 GMT Message-Id: <202111020105.1A215gAs065561@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: 5d03c187731d - main - Document my doc commit bit 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: 5d03c187731db84c55191869bd1e503fafa165bb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=5d03c187731db84c55191869bd1e503fafa165bb commit 5d03c187731db84c55191869bd1e503fafa165bb Author: Ed Maste AuthorDate: 2021-11-02 00:59:52 +0000 Commit: Ed Maste CommitDate: 2021-11-02 01:04:55 +0000 Document my doc commit bit Prodded by: ygy --- share/misc/committers-doc.dot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/misc/committers-doc.dot b/share/misc/committers-doc.dot index 8a256548e758..fe2323b3830b 100644 --- a/share/misc/committers-doc.dot +++ b/share/misc/committers-doc.dot @@ -68,6 +68,7 @@ dexter [label="Michael Dexter\ndexter@FreeBSD.org\n2016/11/15"] dru [label="Dru Lavigne\ndru@FreeBSD.org\n2013/01/22"] eadler [label="Eitan Adler\neadler@FreeBSD.org\n2012/10/15"] ebrandi [label="Edson Brandi\nebrandi@FreeBSD.org\n2012/09/13"] +emaste [label="Ed Maste\nemaste@FreeBSD.org\n2021/08/18"] fernape [label="Fernando Apesteguia\fernape@FreeBSD.org\n2021/02/07"] gabor [label="Gabor Kovesdan\ngabor@FreeBSD.org\n2007/02/02"] ganbold [label="Ganbold Tsagaankhuu\nganbold@FreeBSD.org\n2008/02/26"] @@ -133,6 +134,7 @@ blackend -> ceri brueffer -> joel +carlavilla -> emaste carlavilla -> lwhsu ceri -> brd @@ -214,5 +216,6 @@ trhodes -> jcamou wblock -> jgh wblock -> allanjude +ygy -> emaste ygy -> lwhsu } From nobody Tue Nov 2 01:23: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 4B62F182A0C8; Tue, 2 Nov 2021 01:23:53 +0000 (UTC) (envelope-from philip@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 4HjscT0zHxz3HPH; Tue, 2 Nov 2021 01:23:53 +0000 (UTC) (envelope-from philip@freebsd.org) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com [66.111.4.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: philip/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id EC7B82D597; Tue, 2 Nov 2021 01:23:52 +0000 (UTC) (envelope-from philip@freebsd.org) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailauth.nyi.internal (Postfix) with ESMTP id 978CC27C0054; Mon, 1 Nov 2021 21:23:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 01 Nov 2021 21:23:52 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvdehgedgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffokfgjfhggtgfgsehtqh hmtdertdejnecuhfhrohhmpefrhhhilhhiphcurfgrvghpshcuoehphhhilhhiphesfhhr vggvsghsugdrohhrgheqnecuggftrfgrthhtvghrnhepjeekueehvddvjefhheektdeuue evudduieejvdegieeiffduieffleejgeekjedtnecuffhomhgrihhnpehfrhgvvggsshgu rdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epphhhihhlihhpodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeiiedv iedvgeekqddvfeehudektddtkedqphhhihhlihhppeepfhhrvggvsghsugdrohhrghesth hrohhusghlvgdrihhs X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Nov 2021 21:23:50 -0400 (EDT) From: Philip Paeps To: Jessica Clarke Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: e528757ca6a9 - main - iicoc: add support for SiFive HiFive Unmatched Date: Tue, 02 Nov 2021 09:23:35 +0800 X-Mailer: MailMate (1.14r5842) Message-ID: In-Reply-To: <3DD4AA9B-9985-4DFB-BBC8-E5E34787BA7A@freebsd.org> References: <202111010509.1A159OOo054720@gitrepo.freebsd.org> <3DD4AA9B-9985-4DFB-BBC8-E5E34787BA7A@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; format=flowed Content-Transfer-Encoding: quoted-printable X-ThisMailContainsUnwantedMimeParts: N On 2021-11-01 20:55:42 (+0800), Jessica Clarke wrote: > On 1 Nov 2021, at 05:09, Philip Paeps wrote: >> The branch main has been updated by philip: >> >> URL: = >> https://cgit.FreeBSD.org/src/commit/?id=3De528757ca6a9c03dca7e35b77411= b311af166b7f >> >> commit e528757ca6a9c03dca7e35b77411b311af166b7f >> Author: Thomas Skibo >> AuthorDate: 2021-11-01 04:23:22 +0000 >> Commit: Philip Paeps >> CommitDate: 2021-11-01 04:26:49 +0000 >> >> iicoc: add support for SiFive HiFive Unmatched >> >> Reviewed by: jrtc27, philip >> MFC after: 3 days >> Differential Revision: https://reviews.freebsd.org/D32737 > > I didn=E2=80=99t approve the revision, I just left comments on the firs= t = > version. Oh! I'm sorry. I misread the Phabricator "accepted by riscv group" = tick. I thought that was yours ... turns out it was mine. :-o > One of which still stands (not limiting the module to RISC-V). I agree it would make sense to build the module for all platforms. I'll = make that happen. Sorry for jumping the gun. Philip -- = Philip Paeps Senior Reality Engineer Alternative Enterprises From nobody Tue Nov 2 07:19: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 D17271837450; Tue, 2 Nov 2021 07:19: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 4Hk1Vn5Zm0z4dHg; Tue, 2 Nov 2021 07:19: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 9F55C2094B; Tue, 2 Nov 2021 07:19: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 1A27JTqr058000; Tue, 2 Nov 2021 07:19:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A27JTS3057999; Tue, 2 Nov 2021 07:19:29 GMT (envelope-from git) Date: Tue, 2 Nov 2021 07:19:29 GMT Message-Id: <202111020719.1A27JTS3057999@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: 2fe85640b2a3 - main - efirt(9): Correct efi_var_set definition in the manpage 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: 2fe85640b2a3bf5c377dd180e40cd3d6e1a4f1f4 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=2fe85640b2a3bf5c377dd180e40cd3d6e1a4f1f4 commit 2fe85640b2a3bf5c377dd180e40cd3d6e1a4f1f4 Author: Lakshman AuthorDate: 2021-11-02 07:17:38 +0000 Commit: Guangyuan Yang CommitDate: 2021-11-02 07:17:38 +0000 efirt(9): Correct efi_var_set definition in the manpage PR: 257531 MFC after: 3 days --- share/man/man9/efirt.9 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/man/man9/efirt.9 b/share/man/man9/efirt.9 index fd5aee83656b..cdf0ea21ad8d 100644 --- a/share/man/man9/efirt.9 +++ b/share/man/man9/efirt.9 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 11, 2018 +.Dd November 2, 2021 .Dt EFIRT 9 .Os .Sh NAME @@ -63,8 +63,8 @@ .Ft int .Fn efi_var_nextname "size_t *namesize" "uint16_t *name" "struct uuid *vendor" .Ft int -.Fn efi_var_set "uint16_t *name" "struct uuid *vendor" "uint32_t *attrib" \ - "size_t *datasize" "void *data" +.Fn efi_var_set "uint16_t *name" "struct uuid *vendor" "uint32_t attrib" \ + "size_t datasize" "void *data" .Sh DESCRIPTION All of the following calls will return .Dv ENXIO From nobody Tue Nov 2 07:30: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 6B049183DBD4; Tue, 2 Nov 2021 07:30: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 4Hk1lV2T96z4htb; Tue, 2 Nov 2021 07:30: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 3477D20E21; Tue, 2 Nov 2021 07:30: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 1A27UUs5079346; Tue, 2 Nov 2021 07:30:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A27UUQK079345; Tue, 2 Nov 2021 07:30:30 GMT (envelope-from git) Date: Tue, 2 Nov 2021 07:30:30 GMT Message-Id: <202111020730.1A27UUQK079345@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: a85aa7f9d3bf - main - dpv: Fix synopsis formatting & sort options 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a85aa7f9d3bfd26f5dc07f70cb7ba281bfc69f20 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a85aa7f9d3bfd26f5dc07f70cb7ba281bfc69f20 commit a85aa7f9d3bfd26f5dc07f70cb7ba281bfc69f20 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-11-02 07:05:48 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-11-02 07:30:11 +0000 dpv: Fix synopsis formatting & sort options MFC after: 3 days --- usr.bin/dpv/dpv.1 | 97 +++++++++++++++++++++++++++++++------------------------ usr.bin/dpv/dpv.c | 30 ++++++++--------- 2 files changed, 70 insertions(+), 57 deletions(-) diff --git a/usr.bin/dpv/dpv.1 b/usr.bin/dpv/dpv.1 index 8c0dce79d2d1..d571addfa7c9 100644 --- a/usr.bin/dpv/dpv.1 +++ b/usr.bin/dpv/dpv.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 26, 2016 +.Dd November 2, 2021 .Dt DPV 1 .Os .Sh NAME @@ -33,13 +33,26 @@ .Sh SYNOPSIS .Nm .Op options -.Ar [bytes:]label +.Sm off +.Op Ar bytes Cm \&: +.Ar label +.Sm on .Nm .Op options .Fl m -.Ar [bytes1:]label1 +.Sm off +.Op Ar bytes1 Cm \& : +. Ar label1 +.Sm on .Ar path1 -.Op Ar [bytes2:]label2 path2 ... +.Oo +.Sm off +.Op Ar bytes2 Cm \&: +.Ar label2 +.Sm on +.Ar path2 +.Ar ... +.Oc .Sh DESCRIPTION .Nm provides a dialog progress view, allowing a user to see current throughput rate @@ -95,10 +108,6 @@ When using this is displayed inside the window .Pq at the top followed by a separator line. -.It Fl d -Debug mode. -Print dialog prompt data to standard out and provide additional debugging on -standard error. .It Fl D Do not use the default interface of .Xr dialog 3 , @@ -111,11 +120,15 @@ is taken from the environment variable or simply .Dq Li dialog if unset or NULL. +.It Fl d +Debug mode. +Print dialog prompt data to standard out and provide additional debugging on +standard error. .It Fl h Produce a short syntax usage with brief option descriptions and exit. Output is produced on standard error. -.It Fl i Ar format -Customize the single-file format string used to update the status line. +.It Fl I Ar format +Customize the multi-file format string used to update the status line. Ignored when using either .Ql Fl D or @@ -124,10 +137,10 @@ which lack the ability to display the status line .Pq containing bytes/rate/thread information . Default value is -.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. . -This format is used when handling one file. -.It Fl I Ar format -Customize the multi-file format string used to update the status line. +.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. [%i/%i busy/wait] . +This format is used when handling more than one file. +.It Fl i Ar format +Customize the single-file format string used to update the status line. Ignored when using either .Ql Fl D or @@ -136,24 +149,27 @@ which lack the ability to display the status line .Pq containing bytes/rate/thread information . Default value is -.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. [%i/%i busy/wait] . -This format is used when handling more than one file. +.Dq Li %'10lli bytes read @ %'9.1f bytes/sec. . +This format is used when handling one file. .It Fl k Keep tite. Prevent visually distracting initialization/exit routines for scripts running .Xr dialog 1 several times. -.It Fl l -Line mode. -Read lines from input instead of bytes. .It Fl L Ar size Label size. If negative, shrink to longest label width. +.It Fl l +Line mode. +Read lines from input instead of bytes. .It Fl m Multi-input mode. Instead of reading bytes from standard input, read from a set of paths .Pq one for each label . By default, each path is processed sequentially in the order given. +.It Fl N +No overrun. +If enabled, stop reading known-length inputs when input reaches stated length. .It Fl n Ar num Display at-most .Ar num @@ -162,9 +178,6 @@ If zero, display as many as possible. If negative, only display the main progress indicator. Default is 0. Maximum value is 10. -.It Fl N -No overrun. -If enabled, stop reading known-length inputs when input reaches stated length. .It Fl o Ar file Output data to .Ar file . @@ -176,10 +189,6 @@ in will be replaced with the .Ar label text. -.It Fl p Ar text -Display -.Ar text -above the file progress indicator(s). .It Fl P Ar size Mini-progressbar size. If negative, don't display mini-progressbars @@ -187,6 +196,19 @@ If negative, don't display mini-progressbars If zero, auto-adjust based on number of files to read. When zero and only one file to read, defaults to -1. When zero and more than one file to read, defaults to 17. +.It Fl p Ar text +Display +.Ar text +above the file progress indicator(s). +.It Fl T +Test mode. +Simulate reading a number of bytes, divided evenly across the number of files, +while stepping through each percent value of each file to process. +Appends +.Dq Li [TEST MODE] +to the status line +.Pq to override, use Ql Fl u Ar format . +No data is actually read. .It Fl t Ar title Display .Ar title @@ -201,15 +223,6 @@ and .Ar title are effectively switched .Pq see BUGS section below . -.It Fl T -Test mode. -Simulate reading a number of bytes, divided evenly across the number of files, -while stepping through each percent value of each file to process. -Appends -.Dq Li [TEST MODE] -to the status line -.Pq to override, use Ql Fl u Ar format . -No data is actually read. .It Fl U Ar num Update status line .Ar num @@ -237,6 +250,13 @@ and to bump the dialog width. Prompts wider than the maximum width will wrap .Pq unless using Xr Xdialog 1 ; see BUGS section below . +.It Fl X +Enable X11 mode by using +.Xr Xdialog 1 +instead of +.Xr dialog 1 +or +.Xr dialog 3 . .It Fl x Ar cmd Execute .Ar cmd @@ -259,13 +279,6 @@ in will be replaced with the .Ar label text. -.It Fl X -Enable X11 mode by using -.Xr Xdialog 1 -instead of -.Xr dialog 1 -or -.Xr dialog 3 . .El .Sh ENVIRONMENT The following environment variables are referenced by diff --git a/usr.bin/dpv/dpv.c b/usr.bin/dpv/dpv.c index 440b5ab6de0f..725b24f6bbe9 100644 --- a/usr.bin/dpv/dpv.c +++ b/usr.bin/dpv/dpv.c @@ -496,50 +496,50 @@ usage(void) if (debug) /* No need for usage */ exit(EXIT_FAILURE); - fprintf(stderr, "Usage: %s [options] bytes:label\n", pgm); - fprintf(stderr, " %s [options] -m bytes1:label1 path1 " - "[bytes2:label2 path2 ...]\n", pgm); + fprintf(stderr, "Usage: %s [options] [bytes:]label\n", pgm); + fprintf(stderr, " %s [options] -m [bytes1:]label1 path1 " + "[[bytes2:]label2 path2 ...]\n", pgm); fprintf(stderr, "OPTIONS:\n"); #define OPTFMT "\t%-14s %s\n" fprintf(stderr, OPTFMT, "-a text", "Append text. Displayed below file progress indicators."); fprintf(stderr, OPTFMT, "-b backtitle", "String to be displayed on the backdrop, at top-left."); - fprintf(stderr, OPTFMT, "-d", - "Debug. Write to standard output instead of dialog."); fprintf(stderr, OPTFMT, "-D", "Use dialog(1) instead of dialog(3) [default]."); + fprintf(stderr, OPTFMT, "-d", + "Debug. Write to standard output instead of dialog."); fprintf(stderr, OPTFMT, "-h", "Produce this output on standard error and exit."); - fprintf(stderr, OPTFMT, "-i format", - "Customize status line format. See fdpv(1) for details."); fprintf(stderr, OPTFMT, "-I format", "Customize status line format. See fdpv(1) for details."); + fprintf(stderr, OPTFMT, "-i format", + "Customize status line format. See fdpv(1) for details."); fprintf(stderr, OPTFMT, "-L size", "Label size. Must be a number greater than 0, or -1."); fprintf(stderr, OPTFMT, "-m", "Enable processing of multiple file argiments."); - fprintf(stderr, OPTFMT, "-n num", - "Display at-most num files per screen. Default is -1."); fprintf(stderr, OPTFMT, "-N", "No overrun. Stop reading input at stated length, if any."); + fprintf(stderr, OPTFMT, "-n num", + "Display at-most num files per screen. Default is -1."); fprintf(stderr, OPTFMT, "-o file", "Output data to file. First %s replaced with label text."); - fprintf(stderr, OPTFMT, "-p text", - "Prefix text. Displayed above file progress indicators."); fprintf(stderr, OPTFMT, "-P size", "Mini-progressbar size. Must be a number greater than 3."); - fprintf(stderr, OPTFMT, "-t title", - "Title string to be displayed at top of dialog(1) box."); + fprintf(stderr, OPTFMT, "-p text", + "Prefix text. Displayed above file progress indicators."); fprintf(stderr, OPTFMT, "-T", "Test mode. Don't actually read any data, but fake it."); + fprintf(stderr, OPTFMT, "-t title", + "Title string to be displayed at top of dialog(1) box."); fprintf(stderr, OPTFMT, "-U num", "Update status line num times per-second. Default is 2."); fprintf(stderr, OPTFMT, "-w", "Wide. Width of `-p' and `-a' text bump dialog(1) width."); - fprintf(stderr, OPTFMT, "-x cmd", - "Send data to executed cmd. First %s replaced with label."); fprintf(stderr, OPTFMT, "-X", "X11. Use Xdialog(1) instead of dialog(1)."); + fprintf(stderr, OPTFMT, "-x cmd", + "Send data to executed cmd. First %s replaced with label."); exit(EXIT_FAILURE); } From nobody Tue Nov 2 07:30: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 8EC2E183DBD8; Tue, 2 Nov 2021 07:30: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 4Hk1lW3NVxz4hmF; Tue, 2 Nov 2021 07:30: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 4BAD120BB2; Tue, 2 Nov 2021 07:30: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 1A27UVJS079388; Tue, 2 Nov 2021 07:30:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A27UVKk079381; Tue, 2 Nov 2021 07:30:31 GMT (envelope-from git) Date: Tue, 2 Nov 2021 07:30:31 GMT Message-Id: <202111020730.1A27UVKk079381@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: f7c7a6ac00f1 - main - dpv.1: Fix an example 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f7c7a6ac00f13e2d47d50844dd92071933c33a56 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=f7c7a6ac00f13e2d47d50844dd92071933c33a56 commit f7c7a6ac00f13e2d47d50844dd92071933c33a56 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-11-02 07:11:50 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-11-02 07:30:11 +0000 dpv.1: Fix an example dpv(1) requires a label to be specified. MFC after: 3 days --- usr.bin/dpv/dpv.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/dpv/dpv.1 b/usr.bin/dpv/dpv.1 index d571addfa7c9..dd5829f6829c 100644 --- a/usr.bin/dpv/dpv.1 +++ b/usr.bin/dpv/dpv.1 @@ -374,7 +374,7 @@ dpv -o /dev/ada0 -m label disk-image.img .Pp Zeroing a disk: .Bd -literal -offset indent -dpv -o /dev/md42 < /dev/zero +dpv -o /dev/md42 "Zeroing md42" < /dev/zero .Ed .Sh SEE ALSO .Xr dialog 1 , From nobody Tue Nov 2 07:30: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 5FD1E183DE19; Tue, 2 Nov 2021 07:30: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 4Hk1lX5KLMz4j03; Tue, 2 Nov 2021 07:30: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 706A320BB3; Tue, 2 Nov 2021 07:30: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 1A27UWQD080116; Tue, 2 Nov 2021 07:30:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A27UWC4080115; Tue, 2 Nov 2021 07:30:32 GMT (envelope-from git) Date: Tue, 2 Nov 2021 07:30:32 GMT Message-Id: <202111020730.1A27UWC4080115@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 3693250e8a74 - main - dpv.1: Do not use mdoc macros for Bl width 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3693250e8a746053291849d8442f912336f0bf1b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3693250e8a746053291849d8442f912336f0bf1b commit 3693250e8a746053291849d8442f912336f0bf1b Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-11-02 07:17:19 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-11-02 07:30:11 +0000 dpv.1: Do not use mdoc macros for Bl width Macros do not expand there. MFC after: 3 days --- usr.bin/dpv/dpv.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/dpv/dpv.1 b/usr.bin/dpv/dpv.1 index dd5829f6829c..801389529946 100644 --- a/usr.bin/dpv/dpv.1 +++ b/usr.bin/dpv/dpv.1 @@ -94,7 +94,7 @@ or instead .Pq see Ql Fl X . .Pp The following options are available: -.Bl -tag -width ".Fl b Ar backtitle" +.Bl -tag -width "-b backtitle" .It Fl a Ar text Display .Ar text @@ -323,7 +323,7 @@ If using .Xr Xdialog 1 is required. .Sh FILES -.Bl -tag -width ".Pa $HOME/.dialogrc" -compact +.Bl -tag -width "$HOME/.dialogrc" -compact .It Pa $HOME/.dialogrc .El .Sh EXAMPLES From nobody Tue Nov 2 08:24: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 E64AB182E2A6; Tue, 2 Nov 2021 08:24: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 4Hk2y25zCTz3Dq7; Tue, 2 Nov 2021 08:24: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 9A8B32184C; Tue, 2 Nov 2021 08:24: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 1A28OgZA050548; Tue, 2 Nov 2021 08:24:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A28OgCa050547; Tue, 2 Nov 2021 08:24:42 GMT (envelope-from git) Date: Tue, 2 Nov 2021 08:24:42 GMT Message-Id: <202111020824.1A28OgCa050547@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: 3dd5760aa5f8 - main - if_epair: rework 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: 3dd5760aa5f876f8a3f0735afeebdf9ee414e1f5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=3dd5760aa5f876f8a3f0735afeebdf9ee414e1f5 commit 3dd5760aa5f876f8a3f0735afeebdf9ee414e1f5 Author: Bjoern A. Zeeb AuthorDate: 2021-10-09 14:09:04 +0000 Commit: Kristof Provost CommitDate: 2021-11-02 08:23:46 +0000 if_epair: rework Rework if_epair(4) to no longer use netisr and dpcpu. Instead use mbufq and swi_net. This simplifies the code and seems to make it work better and no longer hang. Work largely by bz@, with minor tweaks by kp@. Reviewed by: bz, kp MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D31077 --- sys/net/if_epair.c | 746 +++++++++++++++++------------------------------------ 1 file changed, 240 insertions(+), 506 deletions(-) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index a62fbfad8771..e46c5271cc0f 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -2,8 +2,8 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2008 The FreeBSD Foundation - * Copyright (c) 2009-2010 Bjoern A. Zeeb * All rights reserved. + * Copyright (c) 2009-2021 Bjoern A. Zeeb * * This software was developed by CK Software GmbH under sponsorship * from the FreeBSD Foundation. @@ -37,17 +37,6 @@ * This is mostly intended to be used to provide connectivity between * different virtual network stack instances. */ -/* - * Things to re-think once we have more experience: - * - ifp->if_reassign function once we can test with vimage. Depending on - * how if_vmove() is going to be improved. - * - Real random etheraddrs that are checked to be uniquish; we would need - * to re-do them in case we move the interface between network stacks - * in a private if_reassign function. - * In case we bridge to a real interface/network or between indepedent - * epairs on multiple stacks/machines, we may need this. - * For now let the user handle that case. - */ #include __FBSDID("$FreeBSD$"); @@ -61,13 +50,15 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include #include #include #include +#include +#include +#include #include #include @@ -80,122 +71,41 @@ __FBSDID("$FreeBSD$"); #include #include -SYSCTL_DECL(_net_link); -static SYSCTL_NODE(_net_link, OID_AUTO, epair, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, - "epair sysctl"); - -#ifdef EPAIR_DEBUG -static int epair_debug = 0; -SYSCTL_INT(_net_link_epair, OID_AUTO, epair_debug, CTLFLAG_RW, - &epair_debug, 0, "if_epair(4) debugging."); -#define DPRINTF(fmt, arg...) \ - if (epair_debug) \ - printf("[%s:%d] " fmt, __func__, __LINE__, ##arg) -#else -#define DPRINTF(fmt, arg...) -#endif - -static void epair_nh_sintr(struct mbuf *); -static struct mbuf *epair_nh_m2cpuid(struct mbuf *, uintptr_t, u_int *); -static void epair_nh_drainedcpu(u_int); - -static void epair_start_locked(struct ifnet *); -static int epair_media_change(struct ifnet *); -static void epair_media_status(struct ifnet *, struct ifmediareq *); - static int epair_clone_match(struct if_clone *, const char *); static int epair_clone_create(struct if_clone *, char *, size_t, caddr_t); static int epair_clone_destroy(struct if_clone *, struct ifnet *); static const char epairname[] = "epair"; -static unsigned int next_index = 0; +#define RXRSIZE 4096 /* Probably overkill by 4-8x. */ -/* Netisr related definitions and sysctl. */ -static struct netisr_handler epair_nh = { - .nh_name = epairname, - .nh_proto = NETISR_EPAIR, - .nh_policy = NETISR_POLICY_CPU, - .nh_handler = epair_nh_sintr, - .nh_m2cpuid = epair_nh_m2cpuid, - .nh_drainedcpu = epair_nh_drainedcpu, -}; +static MALLOC_DEFINE(M_EPAIR, epairname, + "Pair of virtual cross-over connected Ethernet-like interfaces"); -static int -sysctl_epair_netisr_maxqlen(SYSCTL_HANDLER_ARGS) -{ - int error, qlimit; +VNET_DEFINE_STATIC(struct if_clone *, epair_cloner); +#define V_epair_cloner VNET(epair_cloner) - netisr_getqlimit(&epair_nh, &qlimit); - error = sysctl_handle_int(oidp, &qlimit, 0, req); - if (error || !req->newptr) - return (error); - if (qlimit < 1) - return (EINVAL); - return (netisr_setqlimit(&epair_nh, qlimit)); -} -SYSCTL_PROC(_net_link_epair, OID_AUTO, netisr_maxqlen, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, - sysctl_epair_netisr_maxqlen, "I", - "Maximum if_epair(4) netisr \"hw\" queue length"); +static unsigned int next_index = 0; +#define EPAIR_LOCK_INIT() mtx_init(&epair_n_index_mtx, "epairidx", \ + NULL, MTX_DEF) +#define EPAIR_LOCK_DESTROY() mtx_destroy(&epair_n_index_mtx) +#define EPAIR_LOCK() mtx_lock(&epair_n_index_mtx) +#define EPAIR_UNLOCK() mtx_unlock(&epair_n_index_mtx) + +static void *swi_cookie[MAXCPU]; /* swi(9). */ +static STAILQ_HEAD(, epair_softc) swi_sc[MAXCPU]; +static struct mtx epair_n_index_mtx; struct epair_softc { struct ifnet *ifp; /* This ifp. */ struct ifnet *oifp; /* other ifp of pair. */ + void *swi_cookie; /* swi(9). */ + struct buf_ring *rxring[2]; + volatile int ridx; /* 0 || 1 */ struct ifmedia media; /* Media config (fake). */ - u_int refcount; /* # of mbufs in flight. */ - u_int cpuid; /* CPU ID assigned upon creation. */ - void (*if_qflush)(struct ifnet *); - /* Original if_qflush routine. */ + uint32_t cpuidx; + STAILQ_ENTRY(epair_softc) entry; }; -/* - * Per-CPU list of ifps with data in the ifq that needs to be flushed - * to the netisr ``hw'' queue before we allow any further direct queuing - * to the ``hw'' queue. - */ -struct epair_ifp_drain { - STAILQ_ENTRY(epair_ifp_drain) ifp_next; - struct ifnet *ifp; -}; -STAILQ_HEAD(eid_list, epair_ifp_drain); - -#define EPAIR_LOCK_INIT(dpcpu) mtx_init(&(dpcpu)->if_epair_mtx, \ - "if_epair", NULL, MTX_DEF) -#define EPAIR_LOCK_DESTROY(dpcpu) mtx_destroy(&(dpcpu)->if_epair_mtx) -#define EPAIR_LOCK_ASSERT(dpcpu) mtx_assert(&(dpcpu)->if_epair_mtx, \ - MA_OWNED) -#define EPAIR_LOCK(dpcpu) mtx_lock(&(dpcpu)->if_epair_mtx) -#define EPAIR_UNLOCK(dpcpu) mtx_unlock(&(dpcpu)->if_epair_mtx) - -#ifdef INVARIANTS -#define EPAIR_REFCOUNT_INIT(r, v) refcount_init((r), (v)) -#define EPAIR_REFCOUNT_AQUIRE(r) refcount_acquire((r)) -#define EPAIR_REFCOUNT_RELEASE(r) refcount_release((r)) -#define EPAIR_REFCOUNT_ASSERT(a, p) KASSERT(a, p) -#else -#define EPAIR_REFCOUNT_INIT(r, v) -#define EPAIR_REFCOUNT_AQUIRE(r) -#define EPAIR_REFCOUNT_RELEASE(r) -#define EPAIR_REFCOUNT_ASSERT(a, p) -#endif - -static MALLOC_DEFINE(M_EPAIR, epairname, - "Pair of virtual cross-over connected Ethernet-like interfaces"); - -VNET_DEFINE_STATIC(struct if_clone *, epair_cloner); -#define V_epair_cloner VNET(epair_cloner) - -/* - * DPCPU area and functions. - */ -struct epair_dpcpu { - struct mtx if_epair_mtx; /* Per-CPU locking. */ - int epair_drv_flags; /* Per-CPU ``hw'' drv flags. */ - struct eid_list epair_ifp_drain_list; /* Per-CPU list of ifps with - * data in the ifq. */ -}; -DPCPU_DEFINE(struct epair_dpcpu, epair_dpcpu); - static void epair_clear_mbuf(struct mbuf *m) { @@ -210,313 +120,179 @@ epair_clear_mbuf(struct mbuf *m) } static void -epair_dpcpu_init(void) +epair_if_input(struct epair_softc *sc, int ridx) { - struct epair_dpcpu *epair_dpcpu; - struct eid_list *s; - u_int cpuid; - - CPU_FOREACH(cpuid) { - epair_dpcpu = DPCPU_ID_PTR(cpuid, epair_dpcpu); - - /* Initialize per-cpu lock. */ - EPAIR_LOCK_INIT(epair_dpcpu); - - /* Driver flags are per-cpu as are our netisr "hw" queues. */ - epair_dpcpu->epair_drv_flags = 0; - - /* - * Initialize per-cpu drain list. - * Manually do what STAILQ_HEAD_INITIALIZER would do. - */ - s = &epair_dpcpu->epair_ifp_drain_list; - s->stqh_first = NULL; - s->stqh_last = &s->stqh_first; - } -} + struct epoch_tracker et; + struct ifnet *ifp; + struct mbuf *m; -static void -epair_dpcpu_detach(void) -{ - struct epair_dpcpu *epair_dpcpu; - u_int cpuid; + ifp = sc->ifp; + NET_EPOCH_ENTER(et); + do { + m = buf_ring_dequeue_sc(sc->rxring[ridx]); + if (m == NULL) + break; - CPU_FOREACH(cpuid) { - epair_dpcpu = DPCPU_ID_PTR(cpuid, epair_dpcpu); + MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0); + (*ifp->if_input)(ifp, m); - /* Destroy per-cpu lock. */ - EPAIR_LOCK_DESTROY(epair_dpcpu); - } + } while (1); + NET_EPOCH_EXIT(et); } -/* - * Helper functions. - */ -static u_int -cpuid_from_ifp(struct ifnet *ifp) +static void +epair_sintr(struct epair_softc *sc) { - struct epair_softc *sc; + int ridx, nidx; - if (ifp == NULL) - return (0); - sc = ifp->if_softc; + if_ref(sc->ifp); + do { + ridx = sc->ridx; + nidx = (ridx == 0) ? 1 : 0; + } while (!atomic_cmpset_int(&sc->ridx, ridx, nidx)); + epair_if_input(sc, ridx); - return (sc->cpuid); + if_rele(sc->ifp); } -/* - * Netisr handler functions. - */ static void -epair_nh_sintr(struct mbuf *m) -{ - struct ifnet *ifp; - struct epair_softc *sc __unused; - - ifp = m->m_pkthdr.rcvif; - (*ifp->if_input)(ifp, m); - sc = ifp->if_softc; - EPAIR_REFCOUNT_RELEASE(&sc->refcount); - EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, - ("%s: ifp=%p sc->refcount not >= 1: %d", - __func__, ifp, sc->refcount)); - DPRINTF("ifp=%p refcount=%u\n", ifp, sc->refcount); -} - -static struct mbuf * -epair_nh_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid) +epair_intr(void *arg) { + struct epair_softc *sc; + uint32_t cpuidx; + + cpuidx = (uintptr_t)arg; + /* If this is a problem, this is a read-mostly situation. */ + EPAIR_LOCK(); + STAILQ_FOREACH(sc, &swi_sc[cpuidx], entry) { + /* Do this lockless. */ + if (buf_ring_empty(sc->rxring[sc->ridx])) + continue; + epair_sintr(sc); + } + EPAIR_UNLOCK(); - *cpuid = cpuid_from_ifp(m->m_pkthdr.rcvif); - - return (m); + return; } -static void -epair_nh_drainedcpu(u_int cpuid) +static int +epair_menq(struct mbuf *m, struct epair_softc *osc) { - struct epair_dpcpu *epair_dpcpu; - struct epair_ifp_drain *elm, *tvar; - struct ifnet *ifp; + struct ifnet *ifp, *oifp; + int len, ret; + int ridx; + short mflags; + bool was_empty; - epair_dpcpu = DPCPU_ID_PTR(cpuid, epair_dpcpu); - EPAIR_LOCK(epair_dpcpu); /* - * Assume our "hw" queue and possibly ifq will be emptied - * again. In case we will overflow the "hw" queue while - * draining, epair_start_locked will set IFF_DRV_OACTIVE - * again and we will stop and return. + * I know this looks weird. We pass the "other sc" as we need that one + * and can get both ifps from it as well. */ - STAILQ_FOREACH_SAFE(elm, &epair_dpcpu->epair_ifp_drain_list, - ifp_next, tvar) { - ifp = elm->ifp; - epair_dpcpu->epair_drv_flags &= ~IFF_DRV_OACTIVE; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - epair_start_locked(ifp); - - IFQ_LOCK(&ifp->if_snd); - if (IFQ_IS_EMPTY(&ifp->if_snd)) { - struct epair_softc *sc __unused; - - STAILQ_REMOVE(&epair_dpcpu->epair_ifp_drain_list, - elm, epair_ifp_drain, ifp_next); - /* The cached ifp goes off the list. */ - sc = ifp->if_softc; - EPAIR_REFCOUNT_RELEASE(&sc->refcount); - EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, - ("%s: ifp=%p sc->refcount not >= 1: %d", - __func__, ifp, sc->refcount)); - free(elm, M_EPAIR); - } - IFQ_UNLOCK(&ifp->if_snd); + oifp = osc->ifp; + ifp = osc->oifp; - if ((ifp->if_drv_flags & IFF_DRV_OACTIVE) != 0) { - /* Our "hw"q overflew again. */ - epair_dpcpu->epair_drv_flags |= IFF_DRV_OACTIVE; - DPRINTF("hw queue length overflow at %u\n", - epair_nh.nh_qlimit); - break; - } - } - EPAIR_UNLOCK(epair_dpcpu); -} + M_ASSERTPKTHDR(m); + epair_clear_mbuf(m); + if_setrcvif(m, oifp); + M_SETFIB(m, oifp->if_fib); -/* - * Network interface (`if') related functions. - */ -static void -epair_remove_ifp_from_draining(struct ifnet *ifp) -{ - struct epair_dpcpu *epair_dpcpu; - struct epair_ifp_drain *elm, *tvar; - u_int cpuid; - - CPU_FOREACH(cpuid) { - epair_dpcpu = DPCPU_ID_PTR(cpuid, epair_dpcpu); - EPAIR_LOCK(epair_dpcpu); - STAILQ_FOREACH_SAFE(elm, &epair_dpcpu->epair_ifp_drain_list, - ifp_next, tvar) { - if (ifp == elm->ifp) { - struct epair_softc *sc __unused; - - STAILQ_REMOVE( - &epair_dpcpu->epair_ifp_drain_list, elm, - epair_ifp_drain, ifp_next); - /* The cached ifp goes off the list. */ - sc = ifp->if_softc; - EPAIR_REFCOUNT_RELEASE(&sc->refcount); - EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, - ("%s: ifp=%p sc->refcount not >= 1: %d", - __func__, ifp, sc->refcount)); - free(elm, M_EPAIR); - } - } - EPAIR_UNLOCK(epair_dpcpu); - } -} + /* Save values as once the mbuf is queued, it's not ours anymore. */ + len = m->m_pkthdr.len; + mflags = m->m_flags; -static int -epair_add_ifp_for_draining(struct ifnet *ifp) -{ - struct epair_dpcpu *epair_dpcpu; - struct epair_softc *sc; - struct epair_ifp_drain *elm = NULL; + MPASS(m->m_nextpkt == NULL); + MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0); - sc = ifp->if_softc; - epair_dpcpu = DPCPU_ID_PTR(sc->cpuid, epair_dpcpu); - EPAIR_LOCK_ASSERT(epair_dpcpu); - STAILQ_FOREACH(elm, &epair_dpcpu->epair_ifp_drain_list, ifp_next) - if (elm->ifp == ifp) - break; - /* If the ifp is there already, return success. */ - if (elm != NULL) + ridx = atomic_load_int(&osc->ridx); + was_empty = buf_ring_empty(osc->rxring[ridx]); + ret = buf_ring_enqueue(osc->rxring[ridx], m); + if (ret != 0) { + /* Ring is full. */ + m_freem(m); return (0); + } - elm = malloc(sizeof(struct epair_ifp_drain), M_EPAIR, M_NOWAIT|M_ZERO); - if (elm == NULL) - return (ENOMEM); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + /* + * IFQ_HANDOFF_ADJ/ip_handoff() update statistics, + * but as we bypass all this we have to duplicate + * the logic another time. + */ + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); + if (mflags & (M_BCAST|M_MCAST)) + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); + /* Someone else received the packet. */ + if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); - elm->ifp = ifp; - /* Add a reference for the ifp pointer on the list. */ - EPAIR_REFCOUNT_AQUIRE(&sc->refcount); - STAILQ_INSERT_TAIL(&epair_dpcpu->epair_ifp_drain_list, elm, ifp_next); + /* Kick the interrupt handler for the first packet. */ + if (was_empty && osc->swi_cookie != NULL) + swi_sched(osc->swi_cookie, 0); return (0); } static void -epair_start_locked(struct ifnet *ifp) +epair_start(struct ifnet *ifp) { - struct epair_dpcpu *epair_dpcpu; struct mbuf *m; struct epair_softc *sc; struct ifnet *oifp; - int error; - - DPRINTF("ifp=%p\n", ifp); - sc = ifp->if_softc; - epair_dpcpu = DPCPU_ID_PTR(sc->cpuid, epair_dpcpu); - EPAIR_LOCK_ASSERT(epair_dpcpu); - - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) - return; - if ((ifp->if_flags & IFF_UP) == 0) - return; /* * We get packets here from ether_output via if_handoff() * and need to put them into the input queue of the oifp - * and call oifp->if_input() via netisr/epair_sintr(). + * and will put the packet into the receive-queue (rxq) of the + * other interface (oifp) of our pair. */ + sc = ifp->if_softc; oifp = sc->oifp; sc = oifp->if_softc; for (;;) { IFQ_DEQUEUE(&ifp->if_snd, m); if (m == NULL) break; + M_ASSERTPKTHDR(m); BPF_MTAP(ifp, m); - /* - * In case the outgoing interface is not usable, - * drop the packet. - */ - if ((oifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || - (oifp->if_flags & IFF_UP) ==0) { - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + /* In case either interface is not usable drop the packet. */ + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || + (ifp->if_flags & IFF_UP) == 0 || + (oifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || + (oifp->if_flags & IFF_UP) == 0) { m_freem(m); continue; } - 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. - */ - EPAIR_REFCOUNT_AQUIRE(&sc->refcount); - m->m_pkthdr.rcvif = oifp; - CURVNET_SET_QUIET(oifp->if_vnet); - error = netisr_queue(NETISR_EPAIR, m); - CURVNET_RESTORE(); - if (!error) { - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - /* Someone else received the packet. */ - if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); - } else { - /* The packet was freed already. */ - epair_dpcpu->epair_drv_flags |= IFF_DRV_OACTIVE; - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - (void) epair_add_ifp_for_draining(ifp); - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - EPAIR_REFCOUNT_RELEASE(&sc->refcount); - EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, - ("%s: ifp=%p sc->refcount not >= 1: %d", - __func__, oifp, sc->refcount)); - } - } -} -static void -epair_start(struct ifnet *ifp) -{ - struct epair_dpcpu *epair_dpcpu; - - epair_dpcpu = DPCPU_ID_PTR(cpuid_from_ifp(ifp), epair_dpcpu); - EPAIR_LOCK(epair_dpcpu); - epair_start_locked(ifp); - EPAIR_UNLOCK(epair_dpcpu); + (void) epair_menq(m, sc); + } } static int -epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) +epair_transmit(struct ifnet *ifp, struct mbuf *m) { - struct epair_dpcpu *epair_dpcpu; struct epair_softc *sc; struct ifnet *oifp; int error, len; short mflags; - DPRINTF("ifp=%p m=%p\n", ifp, m); - sc = ifp->if_softc; - epair_dpcpu = DPCPU_ID_PTR(sc->cpuid, epair_dpcpu); - EPAIR_LOCK_ASSERT(epair_dpcpu); - if (m == NULL) return (0); + M_ASSERTPKTHDR(m); /* * We are not going to use the interface en/dequeue mechanism * on the TX side. We are called from ether_output_frame() - * and will put the packet into the incoming queue of the - * other interface of our pair via the netsir. + * and will put the packet into the receive-queue (rxq) of the + * other interface (oifp) of our pair. */ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { m_freem(m); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENXIO); } if ((ifp->if_flags & IFF_UP) == 0) { m_freem(m); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENETDOWN); } @@ -526,16 +302,16 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) * In case the outgoing interface is not usable, * drop the packet. */ + sc = ifp->if_softc; oifp = sc->oifp; if ((oifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || - (oifp->if_flags & IFF_UP) ==0) { + (oifp->if_flags & IFF_UP) == 0) { if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); return (0); } len = m->m_pkthdr.len; mflags = m->m_flags; - DPRINTF("packet %s -> %s\n", ifp->if_xname, oifp->if_xname); #ifdef ALTQ /* Support ALTQ via the classic if_start() path. */ @@ -549,99 +325,17 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) if_inc_counter(ifp, IFCOUNTER_OBYTES, len); if (mflags & (M_BCAST|M_MCAST)) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); - - if ((ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) - epair_start_locked(ifp); - else - (void)epair_add_ifp_for_draining(ifp); + epair_start(ifp); } return (error); } IF_UNLOCK(&ifp->if_snd); #endif - if ((epair_dpcpu->epair_drv_flags & IFF_DRV_OACTIVE) != 0) { - /* - * Our hardware queue is full, try to fall back - * queuing to the ifq but do not call ifp->if_start. - * Either we are lucky or the packet is gone. - */ - IFQ_ENQUEUE(&ifp->if_snd, m, error); - if (!error) - (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 - * packet is in transit as we rely on rcvif to stay valid. - */ - EPAIR_REFCOUNT_AQUIRE(&sc->refcount); - m->m_pkthdr.rcvif = oifp; - CURVNET_SET_QUIET(oifp->if_vnet); - error = netisr_queue(NETISR_EPAIR, m); - CURVNET_RESTORE(); - if (!error) { - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - /* - * IFQ_HANDOFF_ADJ/ip_handoff() update statistics, - * but as we bypass all this we have to duplicate - * the logic another time. - */ - if_inc_counter(ifp, IFCOUNTER_OBYTES, len); - if (mflags & (M_BCAST|M_MCAST)) - if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); - /* Someone else received the packet. */ - if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); - } else { - /* The packet was freed already. */ - epair_dpcpu->epair_drv_flags |= IFF_DRV_OACTIVE; - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - EPAIR_REFCOUNT_RELEASE(&sc->refcount); - EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, - ("%s: ifp=%p sc->refcount not >= 1: %d", - __func__, oifp, sc->refcount)); - } - - return (error); -} - -static int -epair_transmit(struct ifnet *ifp, struct mbuf *m) -{ - struct epair_dpcpu *epair_dpcpu; - int error; - - epair_dpcpu = DPCPU_ID_PTR(cpuid_from_ifp(ifp), epair_dpcpu); - EPAIR_LOCK(epair_dpcpu); - error = epair_transmit_locked(ifp, m); - EPAIR_UNLOCK(epair_dpcpu); + error = epair_menq(m, oifp->if_softc); return (error); } -static void -epair_qflush(struct ifnet *ifp) -{ - struct epair_softc *sc; - - sc = ifp->if_softc; - KASSERT(sc != NULL, ("%s: ifp=%p, epair_softc gone? sc=%p\n", - __func__, ifp, sc)); - /* - * Remove this ifp from all backpointer lists. The interface will not - * usable for flushing anyway nor should it have anything to flush - * after if_qflush(). - */ - epair_remove_ifp_from_draining(ifp); - - if (sc->if_qflush) - sc->if_qflush(ifp); -} - static int epair_media_change(struct ifnet *ifp __unused) { @@ -709,8 +403,6 @@ epair_clone_match(struct if_clone *ifc, const char *name) { const char *cp; - DPRINTF("name='%s'\n", name); - /* * Our base name is epair. * Our interfaces will be named epair[ab]. @@ -799,16 +491,16 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) /* Allocate memory for both [ab] interfaces */ sca = malloc(sizeof(struct epair_softc), M_EPAIR, M_WAITOK | M_ZERO); - EPAIR_REFCOUNT_INIT(&sca->refcount, 1); sca->ifp = if_alloc(IFT_ETHER); if (sca->ifp == NULL) { free(sca, M_EPAIR); ifc_free_unit(ifc, unit); return (ENOSPC); } + sca->rxring[0] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK,NULL); + sca->rxring[1] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK, NULL); scb = malloc(sizeof(struct epair_softc), M_EPAIR, M_WAITOK | M_ZERO); - EPAIR_REFCOUNT_INIT(&scb->refcount, 1); scb->ifp = if_alloc(IFT_ETHER); if (scb->ifp == NULL) { free(scb, M_EPAIR); @@ -817,6 +509,8 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifc_free_unit(ifc, unit); return (ENOSPC); } + scb->rxring[0] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK, NULL); + scb->rxring[1] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK, NULL); /* * Cross-reference the interfaces so we will be able to free both. @@ -824,16 +518,49 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) sca->oifp = scb->ifp; scb->oifp = sca->ifp; - /* - * Calculate the cpuid for netisr queueing based on the - * ifIndex of the interfaces. As long as we cannot configure - * this or use cpuset information easily we cannot guarantee - * cache locality but we can at least allow parallelism. - */ - sca->cpuid = - netisr_get_cpuid(sca->ifp->if_index); - scb->cpuid = - netisr_get_cpuid(scb->ifp->if_index); + EPAIR_LOCK(); +#ifdef SMP + /* Get an approximate distribution. */ + hash = next_index % mp_ncpus; +#else + hash = 0; +#endif + if (swi_cookie[hash] == NULL) { + void *cookie; + + EPAIR_UNLOCK(); + error = swi_add(NULL, epairname, + epair_intr, (void *)(uintptr_t)hash, + SWI_NET, INTR_MPSAFE, &cookie); + if (error) { + buf_ring_free(scb->rxring[0], M_EPAIR); + buf_ring_free(scb->rxring[1], M_EPAIR); + if_free(scb->ifp); + free(scb, M_EPAIR); + buf_ring_free(sca->rxring[0], M_EPAIR); + buf_ring_free(sca->rxring[1], M_EPAIR); + if_free(sca->ifp); + free(sca, M_EPAIR); + ifc_free_unit(ifc, unit); + return (ENOSPC); + } + EPAIR_LOCK(); + /* Recheck under lock even though a race is very unlikely. */ + if (swi_cookie[hash] == NULL) { + swi_cookie[hash] = cookie; + } else { + EPAIR_UNLOCK(); + (void) swi_remove(cookie); + EPAIR_LOCK(); + } + } + sca->cpuidx = hash; + STAILQ_INSERT_TAIL(&swi_sc[hash], sca, entry); + sca->swi_cookie = swi_cookie[hash]; + scb->cpuidx = hash; + STAILQ_INSERT_TAIL(&swi_sc[hash], scb, entry); + scb->swi_cookie = swi_cookie[hash]; + EPAIR_UNLOCK(); /* Initialise pseudo media types. */ ifmedia_init(&sca->media, 0, epair_media_change, epair_media_status); @@ -850,6 +577,7 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifp->if_dname = epairname; ifp->if_dunit = unit; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_flags |= IFF_KNOWSEPOCH; ifp->if_capabilities = IFCAP_VLAN_MTU; ifp->if_capenable = IFCAP_VLAN_MTU; ifp->if_start = epair_start; @@ -870,12 +598,14 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) if (hostid == 0) arc4rand(&hostid, sizeof(hostid), 0); + EPAIR_LOCK(); if (ifp->if_index > next_index) next_index = ifp->if_index; else next_index++; key[0] = (uint32_t)next_index; + EPAIR_UNLOCK(); key[1] = (uint32_t)(hostid & 0xffffffff); key[2] = (uint32_t)((hostid >> 32) & 0xfffffffff); hash = jenkins_hash32(key, 3, 0); @@ -884,10 +614,8 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) memcpy(&eaddr[1], &hash, 4); eaddr[5] = 0x0a; ether_ifattach(ifp, eaddr); - sca->if_qflush = ifp->if_qflush; - ifp->if_qflush = epair_qflush; - ifp->if_transmit = epair_transmit; ifp->if_baudrate = IF_Gbps(10); /* arbitrary maximum */ + ifp->if_transmit = epair_transmit; /* Swap the name and finish initialization of interface b. */ *dp = 'b'; @@ -912,27 +640,40 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) strlcpy(name, scb->ifp->if_xname, len); epair_clone_add(ifc, scb); - scb->if_qflush = ifp->if_qflush; - ifp->if_qflush = epair_qflush; - ifp->if_transmit = epair_transmit; ifp->if_baudrate = IF_Gbps(10); /* arbitrary maximum */ + ifp->if_transmit = epair_transmit; /* * Restore name to a as the ifp for this will go into the * cloner list for the initial call. */ strlcpy(name, sca->ifp->if_xname, len); - DPRINTF("name='%s/%db' created sca=%p scb=%p\n", name, unit, sca, scb); /* Tell the world, that we are ready to rock. */ sca->ifp->if_drv_flags |= IFF_DRV_RUNNING; - scb->ifp->if_drv_flags |= IFF_DRV_RUNNING; if_link_state_change(sca->ifp, LINK_STATE_UP); + scb->ifp->if_drv_flags |= IFF_DRV_RUNNING; if_link_state_change(scb->ifp, LINK_STATE_UP); return (0); } +static void +epair_drain_rings(struct epair_softc *sc) +{ + int ridx; + struct mbuf *m; + + for (ridx = 0; ridx < 2; ridx++) { + do { + m = buf_ring_dequeue_sc(sc->rxring[ridx]); + if (m == NULL) + break; + m_freem(m); + } while (1); + } +} + static int epair_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) { @@ -940,8 +681,6 @@ epair_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) struct epair_softc *sca, *scb; int unit, error; - DPRINTF("ifp=%p\n", ifp); - /* * In case we called into if_clone_destroyif() ourselves * again to remove the second interface, the softc will be @@ -955,27 +694,26 @@ epair_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) oifp = sca->oifp; scb = oifp->if_softc; - DPRINTF("ifp=%p oifp=%p\n", ifp, oifp); + /* Frist get the interfaces down and detached. */ if_link_state_change(ifp, LINK_STATE_DOWN); - if_link_state_change(oifp, LINK_STATE_DOWN); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_link_state_change(oifp, LINK_STATE_DOWN); oifp->if_drv_flags &= ~IFF_DRV_RUNNING; - /* - * Get rid of our second half. As the other of the two - * interfaces may reside in a different vnet, we need to - * switch before freeing them. - */ - CURVNET_SET_QUIET(oifp->if_vnet); + ether_ifdetach(ifp); ether_ifdetach(oifp); - /* - * Wait for all packets to be dispatched to if_input. - * The numbers can only go down as the interface is - * detached so there is no need to use atomics. - */ - DPRINTF("scb refcnt=%u\n", scb->refcount); - EPAIR_REFCOUNT_ASSERT(scb->refcount == 1, - ("%s: ifp=%p scb->refcount!=1: %d", __func__, oifp, scb->refcount)); + + /* Second stop interrupt handler. */ + EPAIR_LOCK(); + STAILQ_REMOVE(&swi_sc[sca->cpuidx], sca, epair_softc, entry); + STAILQ_REMOVE(&swi_sc[scb->cpuidx], scb, epair_softc, entry); + EPAIR_UNLOCK(); + sca->swi_cookie = NULL; + scb->swi_cookie = NULL; + + /* Third free any queued packets and all the resources. */ + CURVNET_SET_QUIET(oifp->if_vnet); + epair_drain_rings(scb); oifp->if_softc = NULL; error = if_clone_destroyif(ifc, oifp); if (error) @@ -983,19 +721,19 @@ epair_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) __func__, error); if_free(oifp); ifmedia_removeall(&scb->media); + buf_ring_free(scb->rxring[0], M_EPAIR); + buf_ring_free(scb->rxring[1], M_EPAIR); *** 103 LINES SKIPPED *** From nobody Tue Nov 2 09:07: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 E9B8A1842126; Tue, 2 Nov 2021 09:07:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hk3tt69TQz3jCn; Tue, 2 Nov 2021 09:07:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B591422255; Tue, 2 Nov 2021 09:07:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A2972N3004618; Tue, 2 Nov 2021 09:07:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A297227004617; Tue, 2 Nov 2021 09:07:02 GMT (envelope-from git) Date: Tue, 2 Nov 2021 09:07:02 GMT Message-Id: <202111020907.1A297227004617@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: 6d04e1422e70 - main - cosl(): fix polynomial approximation coefficients for ld128 version 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: 6d04e1422e70ca0a77552782c01c291f90716773 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6d04e1422e70ca0a77552782c01c291f90716773 commit 6d04e1422e70ca0a77552782c01c291f90716773 Author: Steve Kargl AuthorDate: 2021-11-02 08:54:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-02 08:54:10 +0000 cosl(): fix polynomial approximation coefficients for ld128 version As mention previously, the minmax polynomial approximation in the kernel for cosl() seem to have a bad set of coefficients. In testing, cosl() in the interval [0.785, pi/4] for 1 million values and pi/4 written to 37 decimal digits. The old version on an aarch64 system gave % tlibm/tlibm_lmath -l -x 0.78 -X 7.85398163397448309615660845819875721e-1L cos Interval tested for cosl: [0.78,0.785398] count: 1000000 xm = 7.80213913234863919029058821396125599e-01L libm = 7.10763080972549562455058499280609083e-01L mpfr = 7.10763080972549562455058499280608983e-01L ULP = 1.04431 The max ULP exceeds 1, which is not good. So, I rinsed off a 10 year code and recomputed coefficients. The new minmax polynomial now yields % tlibm/tlibm_lmath -l -x 0.78 -X 7.85398163397448309615660845819875721e-1L cos Interval tested for cosl: [0.78,0.785398] count: 1000000 xm = 7.82916198746768272588844890973704219e-01L libm = 7.08859615479571058183956453286628396e-01L mpfr = 7.08859615479571058183956453286628469e-01L ULP = 0.75407 which is very good. PR: 218514 MFC after: 1 week --- lib/msun/ld128/k_cosl.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/msun/ld128/k_cosl.c b/lib/msun/ld128/k_cosl.c index fe57773a1348..422357bf8a6c 100644 --- a/lib/msun/ld128/k_cosl.c +++ b/lib/msun/ld128/k_cosl.c @@ -21,8 +21,8 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" /* - * Domain [-0.7854, 0.7854], range ~[-1.80e-37, 1.79e-37]: - * |cos(x) - c(x))| < 2**-122.0 + * Domain [-0.7854, 0.7854], range ~[-1.17e-39, 1.19e-39]: + * |cos(x) - c(x))| < 2**-129.3 * * 113-bit precision requires more care than 64-bit precision, since * simple methods give a minimax polynomial with coefficient for x^2 @@ -31,21 +31,19 @@ __FBSDID("$FreeBSD$"); */ static const double one = 1.0; - static const long double -C1 = 0.04166666666666666666666666666666658424671L, -C2 = -0.001388888888888888888888888888863490893732L, -C3 = 0.00002480158730158730158730158600795304914210L, -C4 = -0.2755731922398589065255474947078934284324e-6L, -C5 = 0.2087675698786809897659225313136400793948e-8L, -C6 = -0.1147074559772972315817149986812031204775e-10L, -C7 = 0.4779477332386808976875457937252120293400e-13L; - -static const double -C8 = -0.1561920696721507929516718307820958119868e-15, -C9 = 0.4110317413744594971475941557607804508039e-18, -C10 = -0.8896592467191938803288521958313920156409e-21, -C11 = 0.1601061435794535138244346256065192782581e-23; +C1 = 4.16666666666666666666666666666666667e-02L, +C2 = -1.38888888888888888888888888888888834e-03L, +C3 = 2.48015873015873015873015873015446795e-05L, +C4 = -2.75573192239858906525573190949988493e-07L, +C5 = 2.08767569878680989792098886701451072e-09L, +C6 = -1.14707455977297247136657111139971865e-11L, +C7 = 4.77947733238738518870113294139830239e-14L, +C8 = -1.56192069685858079920640872925306403e-16L, +C9 = 4.11031762320473354032038893429515732e-19L, +C10= -8.89679121027589608738005163931958096e-22L, +C11= 1.61171797801314301767074036661901531e-24L, +C12= -2.46748624357670948912574279501044295e-27L; long double __kernel_cosl(long double x, long double y) @@ -54,7 +52,7 @@ __kernel_cosl(long double x, long double y) z = x*x; r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*(C7+ - z*(C8+z*(C9+z*(C10+z*C11)))))))))); + z*(C8+z*(C9+z*(C10+z*(C11+z*C12))))))))))); hz = 0.5*z; w = one-hz; return w + (((one-w)-hz) + (z*r-x*y)); From nobody Tue Nov 2 10:34: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 2CA931822C29; Tue, 2 Nov 2021 10:34: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 4Hk5rG0r9hz4dQn; Tue, 2 Nov 2021 10:34: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 E60D6235CF; Tue, 2 Nov 2021 10:34: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 1A2AYr4j024075; Tue, 2 Nov 2021 10:34:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2AYr2C024074; Tue, 2 Nov 2021 10:34:53 GMT (envelope-from git) Date: Tue, 2 Nov 2021 10:34:53 GMT Message-Id: <202111021034.1A2AYr2C024074@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michal Meloun Subject: git: a670e1c13a52 - main - arm: Fix handling of undefined instruction aborts in THUMB2 mode. 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: mmel X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a670e1c13a522df4fb8c63bb023b88b1d65de797 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=a670e1c13a522df4fb8c63bb023b88b1d65de797 commit a670e1c13a522df4fb8c63bb023b88b1d65de797 Author: Michal Meloun AuthorDate: 2021-10-17 17:36:33 +0000 Commit: Michal Meloun CommitDate: 2021-11-02 10:11:44 +0000 arm: Fix handling of undefined instruction aborts in THUMB2 mode. Correctly recognize NEON/SIMD and VFP instructions in THUMB2 mode and pass these to the appropriate handler. Note that it is not necessary to filter all undefined instruction variant or register combinations, this is a job for given handler. Reported by: Robert Clausecker PR: 259187 MFC after: 2 weks --- sys/arm/arm/undefined.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/sys/arm/arm/undefined.c b/sys/arm/arm/undefined.c index 4e9a5295d338..d95b02e2bbb4 100644 --- a/sys/arm/arm/undefined.c +++ b/sys/arm/arm/undefined.c @@ -90,13 +90,25 @@ __FBSDID("$FreeBSD$"); #define ARM_COPROC_INSN(insn) (((insn) & (1 << 27)) != 0) #define ARM_VFP_INSN(insn) ((((insn) & 0xfe000000) == 0xf2000000) || \ - (((insn) & 0xff100000) == 0xf4000000)) + (((insn) & 0xff100000) == 0xf4000000)) #define ARM_COPROC(insn) (((insn) >> 8) & 0xf) -#define THUMB_32BIT_INSN(insn) ((insn) >= 0xe800) +#define THUMB_32BIT_INSN(insn) ((((insn) & 0xe000) == 0xe000) && \ + (((insn) & 0x1800) != 0)) +/* + * Coprocessor, Advanced SIMD, and + * Floating-point instructions on page A6-251 + * OP1 == 01 OR 11 + * OP2 == 1xxxxxx + */ #define THUMB_COPROC_INSN(insn) (((insn) & (3 << 26)) == (3 << 26)) -#define THUMB_COPROC_UNDEFINED(insn) (((insn) & 0x3e << 20) == 0) -#define THUMB_VFP_INSN(insn) (((insn) & (3 << 24)) == (3 << 24)) +/* + * Advanced SIMD element or structure + * load/store instructions on page A7-275 + * OP1 == 11 + * OP2 == 001xxx0 +*/ +#define THUMB_VFP_INSN(insn) (((insn) & (0x1F1 << 20)) == (0x190 << 20)) #define THUMB_COPROC(insn) (((insn) >> 8) & 0xf) #define COPROC_VFP 10 @@ -278,18 +290,13 @@ undefinedinstruction(struct trapframe *frame) fault_instruction <<= 16; fault_instruction |= *(uint16_t *)(fault_pc + 2); - /* - * Is it a Coprocessor, Advanced SIMD, or - * Floating-point instruction. - */ - if (THUMB_COPROC_INSN(fault_instruction)) { - if (THUMB_COPROC_UNDEFINED(fault_instruction)) { - /* undefined insn */ - } else if (THUMB_VFP_INSN(fault_instruction)) - coprocessor = COPROC_VFP; - else - coprocessor = - THUMB_COPROC(fault_instruction); + /* Coprocessor, Advanced SIMD and Floating-point */ + if (THUMB_COPROC_INSN(fault_instruction)) + coprocessor = THUMB_COPROC(fault_instruction); + else { + /* Advanced SIMD load/store */ + if (THUMB_VFP_INSN(fault_instruction)) + coprocessor = COPROC_VFP; /* SIMD */ } } #else From nobody Tue Nov 2 15:54: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 6DA1D1831ED8; Tue, 2 Nov 2021 15:54:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HkDx12gRcz3sfv; Tue, 2 Nov 2021 15:54:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C66827C6B; Tue, 2 Nov 2021 15:54:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A2FsTCo050904; Tue, 2 Nov 2021 15:54:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2FsTOi050903; Tue, 2 Nov 2021 15:54:29 GMT (envelope-from git) Date: Tue, 2 Nov 2021 15:54:29 GMT Message-Id: <202111021554.1A2FsTOi050903@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 2390a1441eff - main - LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2390a1441effaba0e3d0f2f447f448aaf20428f1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=2390a1441effaba0e3d0f2f447f448aaf20428f1 commit 2390a1441effaba0e3d0f2f447f448aaf20428f1 Author: Hans Petter Selasky AuthorDate: 2021-11-02 15:52:46 +0000 Commit: Hans Petter Selasky CommitDate: 2021-11-02 15:53:34 +0000 LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's. The purpose of this change is to reduce the amount of dmesg(8) noise when VT switching after a panic. Submitted by: Greg V MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30174 Sponsored by: NVIDIA Networking --- sys/compat/linuxkpi/common/include/linux/kernel.h | 25 +++++++++++++---------- sys/compat/linuxkpi/common/src/linux_compat.c | 5 +++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 6cbd95c4ac64..94af8f29c4d7 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -121,28 +121,31 @@ extern const volatile int lkpi_build_bug_on_zero; } \ } while (0) +extern int linuxkpi_warn_dump_stack; #define WARN_ON(cond) ({ \ - bool __ret = (cond); \ - if (__ret) { \ + bool __ret = (cond); \ + if (__ret) { \ printf("WARNING %s failed at %s:%d\n", \ __stringify(cond), __FILE__, __LINE__); \ - linux_dump_stack(); \ - } \ - unlikely(__ret); \ + if (linuxkpi_warn_dump_stack) \ + linux_dump_stack(); \ + } \ + unlikely(__ret); \ }) #define WARN_ON_SMP(cond) WARN_ON(cond) #define WARN_ON_ONCE(cond) ({ \ - static bool __warn_on_once; \ - bool __ret = (cond); \ - if (__ret && !__warn_on_once) { \ + static bool __warn_on_once; \ + bool __ret = (cond); \ + if (__ret && !__warn_on_once) { \ __warn_on_once = 1; \ printf("WARNING %s failed at %s:%d\n", \ __stringify(cond), __FILE__, __LINE__); \ - linux_dump_stack(); \ - } \ - unlikely(__ret); \ + if (linuxkpi_warn_dump_stack) \ + linux_dump_stack(); \ + } \ + unlikely(__ret); \ }) #define oops_in_progress SCHEDULER_STOPPED() diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index a62cf93dbd82..6440f7bdcff4 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -103,6 +103,11 @@ int linuxkpi_debug; SYSCTL_INT(_compat_linuxkpi, OID_AUTO, debug, CTLFLAG_RWTUN, &linuxkpi_debug, 0, "Set to enable pr_debug() prints. Clear to disable."); +int linuxkpi_warn_dump_stack = 0; +SYSCTL_INT(_compat_linuxkpi, OID_AUTO, warn_dump_stack, CTLFLAG_RWTUN, + &linuxkpi_warn_dump_stack, 0, + "Set to enable stack traces from WARN_ON(). Clear to disable."); + static struct timeval lkpi_net_lastlog; static int lkpi_net_curpps; static int lkpi_net_maxpps = 99; From nobody Tue Nov 2 16:50: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 9C713184AB97; Tue, 2 Nov 2021 16:50: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 4HkG9C45L6z4g3n; Tue, 2 Nov 2021 16:50: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 68D584C0; Tue, 2 Nov 2021 16:50: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 1A2Go7CC020620; Tue, 2 Nov 2021 16:50:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2Go7Wm020617; Tue, 2 Nov 2021 16:50:07 GMT (envelope-from git) Date: Tue, 2 Nov 2021 16:50:07 GMT Message-Id: <202111021650.1A2Go7Wm020617@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: d30dc78f798a - main - llvm BPF target: add missed source files 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: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d30dc78f798adebda488d2b8e21290268d2fb501 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=d30dc78f798adebda488d2b8e21290268d2fb501 commit d30dc78f798adebda488d2b8e21290268d2fb501 Author: Dimitry Andric AuthorDate: 2021-11-02 16:49:34 +0000 Commit: Dimitry Andric CommitDate: 2021-11-02 16:49:50 +0000 llvm BPF target: add missed source files Otherwise, linking llvm binaries with this target enabled (which is not the default) will fail with a number of undefined symbol errors: ld: error: undefined symbol: llvm::initializeBPFAdjustOptPass(llvm::PassRegistry&) ld: error: undefined symbol: llvm::initializeBPFCheckAndAdjustIRPass(llvm::PassRegistry&) ld: error: undefined symbol: llvm::createBPFCheckAndAdjustIR() ld: error: undefined symbol: llvm::createBPFAdjustOpt() ld: error: undefined symbol: llvm::BPFAdjustOptPass::run(llvm::Module&, llvm::AnalysisManager&) Reported by: Michael Dexter MFC after: 3 days --- lib/clang/libllvm/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile index bd0aee918ef3..43f6cfa9302d 100644 --- a/lib/clang/libllvm/Makefile +++ b/lib/clang/libllvm/Makefile @@ -1163,7 +1163,9 @@ SRCS_MIN+= Target/ARM/Utils/ARMBaseInfo.cpp .if ${MK_LLVM_TARGET_BPF} != "no" SRCS_MIN+= Target/BPF/AsmParser/BPFAsmParser.cpp SRCS_MIN+= Target/BPF/BPFAbstractMemberAccess.cpp +SRCS_MIN+= Target/BPF/BPFAdjustOpt.cpp SRCS_MIN+= Target/BPF/BPFAsmPrinter.cpp +SRCS_MIN+= Target/BPF/BPFCheckAndAdjustIR.cpp SRCS_MIN+= Target/BPF/BPFFrameLowering.cpp SRCS_MIN+= Target/BPF/BPFISelDAGToDAG.cpp SRCS_MIN+= Target/BPF/BPFISelLowering.cpp From nobody Tue Nov 2 16:53: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 769E3184B2B4; Tue, 2 Nov 2021 16:53:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HkGDt2xgmz4gts; Tue, 2 Nov 2021 16:53:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4544883C; Tue, 2 Nov 2021 16:53:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A2GrIKx031116; Tue, 2 Nov 2021 16:53:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2GrI1H031115; Tue, 2 Nov 2021 16:53:18 GMT (envelope-from git) Date: Tue, 2 Nov 2021 16:53:18 GMT Message-Id: <202111021653.1A2GrI1H031115@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: 1a8f198fa665 - main - epair: remove "All rights reserved" 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: 1a8f198fa66518e6d249fa8aa765ec6e50a4fbab Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=1a8f198fa66518e6d249fa8aa765ec6e50a4fbab commit 1a8f198fa66518e6d249fa8aa765ec6e50a4fbab Author: Bjoern A. Zeeb AuthorDate: 2021-11-02 16:48:07 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-11-02 16:50:26 +0000 epair: remove "All rights reserved" Remove "All rights reserved" from The FreeBSD Foundation owned copyrights on epair code and documentation. Approved by: emaste (FreeBSD Foundation) --- share/man/man4/epair.4 | 1 - sys/net/if_epair.c | 1 - 2 files changed, 2 deletions(-) diff --git a/share/man/man4/epair.4 b/share/man/man4/epair.4 index 3ea706cb02ac..e1018e4b177f 100644 --- a/share/man/man4/epair.4 +++ b/share/man/man4/epair.4 @@ -1,6 +1,5 @@ .\"- .\" Copyright (c) 2008 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This software was developed by CK Software GmbH under sponsorship .\" from the FreeBSD Foundation. diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index e46c5271cc0f..89483db46337 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -2,7 +2,6 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2008 The FreeBSD Foundation - * All rights reserved. * Copyright (c) 2009-2021 Bjoern A. Zeeb * * This software was developed by CK Software GmbH under sponsorship From nobody Tue Nov 2 18:55: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 02F09183FC91; Tue, 2 Nov 2021 18:55:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HkJxR6by9z3vLN; Tue, 2 Nov 2021 18:55: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 C1DAA20E7; Tue, 2 Nov 2021 18:55: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 1A2It7qh091916; Tue, 2 Nov 2021 18:55:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2It7OP091915; Tue, 2 Nov 2021 18:55:07 GMT (envelope-from git) Date: Tue, 2 Nov 2021 18:55:07 GMT Message-Id: <202111021855.1A2It7OP091915@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: 3513df4bcc17 - main - fstyp: fix build WITHOUT_ICONV 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: 3513df4bcc172b2b7b923ba62591490d5df1bf5a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=3513df4bcc172b2b7b923ba62591490d5df1bf5a commit 3513df4bcc172b2b7b923ba62591490d5df1bf5a Author: Ed Maste AuthorDate: 2021-11-02 13:43:56 +0000 Commit: Ed Maste CommitDate: 2021-11-02 18:54:45 +0000 fstyp: fix build WITHOUT_ICONV Reported by: Michael Dexter, Build Option Survey Sponsored by: The FreeBSD Foundation --- usr.sbin/fstyp/exfat.c | 5 +++++ usr.sbin/fstyp/ntfs.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/usr.sbin/fstyp/exfat.c b/usr.sbin/fstyp/exfat.c index 3f10cb6a9e5a..d92d9c828427 100644 --- a/usr.sbin/fstyp/exfat.c +++ b/usr.sbin/fstyp/exfat.c @@ -365,6 +365,11 @@ fstyp_exfat(FILE *fp, char *label, size_t size) #ifdef WITH_ICONV if (show_label) exfat_find_label(fp, ev, bytespersec, label, size); +#else + if (show_label) { + warnx("label not available without iconv support"); + memset(label, 0, size); + } #endif out: diff --git a/usr.sbin/fstyp/ntfs.c b/usr.sbin/fstyp/ntfs.c index 0ce1fa81181a..c286d950dc2b 100644 --- a/usr.sbin/fstyp/ntfs.c +++ b/usr.sbin/fstyp/ntfs.c @@ -179,6 +179,11 @@ fstyp_ntfs(FILE *fp, char *label, size_t size) } ok: +#else + if (show_label) { + warnx("label not available without iconv support"); + memset(label, 0, size); + } #endif /* WITH_ICONV */ free(bf); free(filerecp); From nobody Tue Nov 2 19:18: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 98F9A1849FDC; Tue, 2 Nov 2021 19:18: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 4HkKSQ3wYMz4WpQ; Tue, 2 Nov 2021 19:18: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 667982A0A; Tue, 2 Nov 2021 19:18: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 1A2JIU7q019570; Tue, 2 Nov 2021 19:18:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2JIU9L019569; Tue, 2 Nov 2021 19:18:30 GMT (envelope-from git) Date: Tue, 2 Nov 2021 19:18:30 GMT Message-Id: <202111021918.1A2JIU9L019569@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: 717857819223 - main - crypto: Use a single "crypto" kproc for all of the OCF kthreads. 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: 717857819223d9c0f81eb38abd0df200532e1cdc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=717857819223d9c0f81eb38abd0df200532e1cdc commit 717857819223d9c0f81eb38abd0df200532e1cdc Author: John Baldwin AuthorDate: 2021-11-02 18:26:21 +0000 Commit: John Baldwin CommitDate: 2021-11-02 19:18:05 +0000 crypto: Use a single "crypto" kproc for all of the OCF kthreads. Reported by: julian Reviewed by: markj MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32739 --- sys/opencrypto/crypto.c | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index 85c22fd51ee2..436444869e90 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -168,7 +168,7 @@ struct crypto_ret_worker { uint32_t reorder_ops; /* total ordered sym jobs received */ uint32_t reorder_cur_seq; /* current sym job dispatched */ - struct proc *cryptoretproc; + struct thread *td; }; static struct crypto_ret_worker *crypto_ret_workers = NULL; @@ -204,9 +204,9 @@ SYSCTL_INT(_kern, OID_AUTO, cryptodevallowsoft, CTLFLAG_RWTUN, MALLOC_DEFINE(M_CRYPTO_DATA, "crypto", "crypto session records"); -static void crypto_proc(void); -static struct proc *cryptoproc; -static void crypto_ret_proc(struct crypto_ret_worker *ret_worker); +static void crypto_dispatch_thread(void *arg); +static struct thread *cryptotd; +static void crypto_ret_thread(void *arg); static void crypto_destroy(void); static int crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint); static void crypto_task_invoke(void *ctx, int pending); @@ -296,6 +296,7 @@ static int crypto_init(void) { struct crypto_ret_worker *ret_worker; + struct proc *p; int error; mtx_init(&crypto_drivers_mtx, "crypto", "crypto driver table", @@ -321,8 +322,9 @@ crypto_init(void) taskqueue_start_threads(&crypto_tq, crypto_workers_num, PRI_MIN_KERN, "crypto"); - error = kproc_create((void (*)(void *)) crypto_proc, NULL, - &cryptoproc, 0, 0, "crypto"); + p = NULL; + error = kproc_kthread_add(crypto_dispatch_thread, NULL, &p, &cryptotd, + 0, 0, "crypto", "crypto"); if (error) { printf("crypto_init: cannot start crypto thread; error %d", error); @@ -341,8 +343,9 @@ crypto_init(void) mtx_init(&ret_worker->crypto_ret_mtx, "crypto", "crypto return queues", MTX_DEF); - error = kproc_create((void (*)(void *)) crypto_ret_proc, ret_worker, - &ret_worker->cryptoretproc, 0, 0, "crypto returns %td", CRYPTO_RETW_ID(ret_worker)); + error = kthread_add(crypto_ret_thread, ret_worker, p, + &ret_worker->td, 0, 0, "crypto returns %td", + CRYPTO_RETW_ID(ret_worker)); if (error) { printf("crypto_init: cannot start cryptoret thread; error %d", error); @@ -366,20 +369,16 @@ bad: * for the other half of this song-and-dance. */ static void -crypto_terminate(struct proc **pp, void *q) +crypto_terminate(struct thread **tdp, void *q) { - struct proc *p; + struct thread *td; mtx_assert(&crypto_drivers_mtx, MA_OWNED); - p = *pp; - *pp = NULL; - if (p) { + td = *tdp; + *tdp = NULL; + if (td != NULL) { wakeup_one(q); - PROC_LOCK(p); /* NB: insure we don't miss wakeup */ - CRYPTO_DRIVER_UNLOCK(); /* let crypto_finis progress */ - msleep(p, &p->p_mtx, PWAIT, "crypto_destroy", 0); - PROC_UNLOCK(p); - CRYPTO_DRIVER_LOCK(); + mtx_sleep(td, &crypto_drivers_mtx, PWAIT, "crypto_destroy", 0); } } @@ -442,9 +441,9 @@ crypto_destroy(void) if (crypto_tq != NULL) taskqueue_drain_all(crypto_tq); CRYPTO_DRIVER_LOCK(); - crypto_terminate(&cryptoproc, &crp_q); + crypto_terminate(&cryptotd, &crp_q); FOREACH_CRYPTO_RETW(ret_worker) - crypto_terminate(&ret_worker->cryptoretproc, &ret_worker->crp_ret_q); + crypto_terminate(&ret_worker->td, &ret_worker->crp_ret_q); CRYPTO_DRIVER_UNLOCK(); /* XXX flush queues??? */ @@ -1708,14 +1707,14 @@ crypto_finis(void *chan) CRYPTO_DRIVER_LOCK(); wakeup_one(chan); CRYPTO_DRIVER_UNLOCK(); - kproc_exit(0); + kthread_exit(); } /* * Crypto thread, dispatches crypto requests. */ static void -crypto_proc(void) +crypto_dispatch_thread(void *arg __unused) { struct cryptop *crp, *submit; struct cryptocap *cap; @@ -1804,7 +1803,7 @@ crypto_proc(void) crp_sleep = 1; msleep(&crp_q, &crypto_q_mtx, PWAIT, "crypto_wait", 0); crp_sleep = 0; - if (cryptoproc == NULL) + if (cryptotd == NULL) break; CRYPTOSTAT_INC(cs_intrs); } @@ -1820,8 +1819,9 @@ crypto_proc(void) * callbacks typically are expensive and would slow interrupt handling. */ static void -crypto_ret_proc(struct crypto_ret_worker *ret_worker) +crypto_ret_thread(void *arg) { + struct crypto_ret_worker *ret_worker = arg; struct cryptop *crpt; CRYPTO_RETW_LOCK(ret_worker); @@ -1858,7 +1858,7 @@ crypto_ret_proc(struct crypto_ret_worker *ret_worker) */ msleep(&ret_worker->crp_ret_q, &ret_worker->crypto_ret_mtx, PWAIT, "crypto_ret_wait", 0); - if (ret_worker->cryptoretproc == NULL) + if (ret_worker->td == NULL) break; CRYPTOSTAT_INC(cs_rets); } From nobody Tue Nov 2 19:18: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 E90D51849FE1; Tue, 2 Nov 2021 19:18: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 4HkKSR5RHpz4WjG; Tue, 2 Nov 2021 19:18: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 95E7524F5; Tue, 2 Nov 2021 19:18: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 1A2JIVXC019594; Tue, 2 Nov 2021 19:18:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2JIVBn019593; Tue, 2 Nov 2021 19:18:31 GMT (envelope-from git) Date: Tue, 2 Nov 2021 19:18:31 GMT Message-Id: <202111021918.1A2JIVBn019593@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: 4e057806cf56 - main - crypto: Cleanup mtx_init() calls. 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: 4e057806cf56b238a0a3ef7af140f447d7b67ab5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4e057806cf56b238a0a3ef7af140f447d7b67ab5 commit 4e057806cf56b238a0a3ef7af140f447d7b67ab5 Author: John Baldwin AuthorDate: 2021-11-02 18:27:20 +0000 Commit: John Baldwin CommitDate: 2021-11-02 19:18:05 +0000 crypto: Cleanup mtx_init() calls. Don't pass the same name to multiple mutexes while using unique types for WITNESS. Just use the unique types as the mutex names. Reviewed by: markj MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32740 --- sys/opencrypto/crypto.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index 436444869e90..8c5457a48f65 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -299,11 +299,10 @@ crypto_init(void) struct proc *p; int error; - mtx_init(&crypto_drivers_mtx, "crypto", "crypto driver table", - MTX_DEF|MTX_QUIET); + mtx_init(&crypto_drivers_mtx, "crypto driver table", NULL, MTX_DEF); TAILQ_INIT(&crp_q); - mtx_init(&crypto_q_mtx, "crypto", "crypto op queues", MTX_DEF); + mtx_init(&crypto_q_mtx, "crypto op queues", NULL, MTX_DEF); cryptop_zone = uma_zcreate("cryptop", sizeof(struct cryptop), NULL, NULL, NULL, NULL, @@ -341,7 +340,8 @@ crypto_init(void) ret_worker->reorder_ops = 0; ret_worker->reorder_cur_seq = 0; - mtx_init(&ret_worker->crypto_ret_mtx, "crypto", "crypto return queues", MTX_DEF); + mtx_init(&ret_worker->crypto_ret_mtx, "crypto return queues", + NULL, MTX_DEF); error = kthread_add(crypto_ret_thread, ret_worker, p, &ret_worker->td, 0, 0, "crypto returns %td", From nobody Tue Nov 2 19:49: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 08C86183096B; Tue, 2 Nov 2021 19:49: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 4HkL8c60zLz4htl; Tue, 2 Nov 2021 19:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AD0892E57; Tue, 2 Nov 2021 19:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A2Jnq9L059250; Tue, 2 Nov 2021 19:49:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2JnqBS059249; Tue, 2 Nov 2021 19:49:52 GMT (envelope-from git) Date: Tue, 2 Nov 2021 19:49:52 GMT Message-Id: <202111021949.1A2JnqBS059249@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ruslan Bukin Subject: git: 4bb6991531b5 - main - arm/pmu: add ACPI attachment. 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: br X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4bb6991531b528c89fdadd3316d80b885a7f9bdb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=4bb6991531b528c89fdadd3316d80b885a7f9bdb commit 4bb6991531b528c89fdadd3316d80b885a7f9bdb Author: Ruslan Bukin AuthorDate: 2021-11-02 19:35:29 +0000 Commit: Ruslan Bukin CommitDate: 2021-11-02 19:35:29 +0000 arm/pmu: add ACPI attachment. This makes hwpmc(4) sampling work on ACPI-based AArch64 systems. Tested on ARM Neoverse N1. Submitted by: Greg V Reviewed by: jrtc27, mhorne Differential Revision: https://reviews.freebsd.org/D24423 --- sys/arm/arm/pmu.h | 2 +- sys/arm/arm/pmu_acpi.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++ sys/conf/files.arm64 | 1 + 3 files changed, 197 insertions(+), 1 deletion(-) diff --git a/sys/arm/arm/pmu.h b/sys/arm/arm/pmu.h index bfad6d9da282..657faba28e74 100644 --- a/sys/arm/arm/pmu.h +++ b/sys/arm/arm/pmu.h @@ -33,7 +33,7 @@ #ifndef _ARM_PMU_H_ #define _ARM_PMU_H_ -#define MAX_RLEN 8 +#define MAX_RLEN MAXCPU struct pmu_intr { struct resource *res; diff --git a/sys/arm/arm/pmu_acpi.c b/sys/arm/arm/pmu_acpi.c new file mode 100644 index 000000000000..b1378c24e833 --- /dev/null +++ b/sys/arm/arm/pmu_acpi.c @@ -0,0 +1,195 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Greg V + * Copyright (c) 2021 Ruslan Bukin + * + * 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 "acpi_bus_if.h" +#include "pmu.h" + +struct madt_ctx { + struct pmu_softc *sc; + int error; + int i; +}; + +static void +madt_handler(ACPI_SUBTABLE_HEADER *entry, void *arg) +{ + ACPI_MADT_GENERIC_INTERRUPT *intr; + struct intr_map_data_acpi *ad; + struct intr_map_data *data; + struct madt_ctx *ctx; + struct pmu_softc *sc; + struct pcpu *pcpu; + int rid; + int cpuid; + int i; + + ctx = arg; + sc = ctx->sc; + rid = ctx->i; + cpuid = -1; + + if (ctx->error) + return; + + if (entry->Type != ACPI_MADT_TYPE_GENERIC_INTERRUPT) + return; + intr = (ACPI_MADT_GENERIC_INTERRUPT *)entry; + + for (i = 0; i < MAXCPU; i++) { + pcpu = pcpu_find(i); + if (pcpu != NULL && pcpu->pc_mpidr == intr->ArmMpidr) { + cpuid = i; + break; + } + } + + if (cpuid == -1) { + /* pcpu not found. */ + device_printf(sc->dev, "MADT: could not find pcpu, " + "ArmMpidr %lx\n", intr->ArmMpidr); + ctx->error = ENODEV; + return; + } + + if (bootverbose) + device_printf(sc->dev, "MADT: cpu %d (mpidr %lu) irq %d " + "%s-triggered\n", cpuid, intr->ArmMpidr, + intr->PerformanceInterrupt, + (intr->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ? + "edge" : "level"); + + bus_set_resource(sc->dev, SYS_RES_IRQ, ctx->i, + intr->PerformanceInterrupt, 1); + + sc->irq[ctx->i].res = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, + &rid, RF_ACTIVE | RF_SHAREABLE); + if (sc->irq[ctx->i].res == NULL) { + device_printf(sc->dev, "Failed to allocate IRQ %d\n", ctx->i); + ctx->error = ENXIO; + return; + } + + /* + * BUS_CONFIG_INTR does nothing on arm64, so we manually set trigger + * mode. + */ + data = rman_get_virtual(sc->irq[ctx->i].res); + KASSERT(data->type == INTR_MAP_DATA_ACPI, ("Wrong data type")); + ad = (struct intr_map_data_acpi *)data; + ad->trig = (intr->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ? + INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL; + ad->pol = INTR_POLARITY_HIGH; + + if (!intr_is_per_cpu(sc->irq[ctx->i].res)) + sc->irq[ctx->i].cpuid = cpuid; + + ctx->i++; +} + +static void +pmu_acpi_identify(driver_t *driver, device_t parent) +{ + device_t dev; + + if (acpi_find_table(ACPI_SIG_MADT) == 0) + return; + + dev = BUS_ADD_CHILD(parent, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST, + "pmu", -1); + + if (dev == NULL) + device_printf(parent, "pmu: Unable to add pmu child\n"); +} + +static int +pmu_acpi_probe(device_t dev) +{ + + device_set_desc(dev, "Performance Monitoring Unit"); + + return (BUS_PROBE_NOWILDCARD); +} + +static int +pmu_acpi_attach(device_t dev) +{ + struct pmu_softc *sc; + struct madt_ctx ctx; + ACPI_TABLE_MADT *madt; + int i; + + sc = device_get_softc(dev); + sc->dev = dev; + + madt = acpi_map_table(acpi_find_table(ACPI_SIG_MADT), ACPI_SIG_MADT); + if (madt == NULL) { + device_printf(dev, "Unable to map the MADT table\n"); + return (ENXIO); + } + + /* We have to initialize cpuid to -1. */ + for (i = 0; i < MAX_RLEN; i++) + sc->irq[i].cpuid = -1; + + ctx.sc = sc; + ctx.i = 0; + ctx.error = 0; + acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, + madt_handler, &ctx); + + acpi_unmap_table(madt); + + if (ctx.error) + return (ctx.error); + + return (pmu_attach(dev)); +} + +static device_method_t pmu_acpi_methods[] = { + DEVMETHOD(device_identify, pmu_acpi_identify), + DEVMETHOD(device_probe, pmu_acpi_probe), + DEVMETHOD(device_attach, pmu_acpi_attach), + DEVMETHOD_END, +}; + +DEFINE_CLASS_0(pmu, pmu_acpi_driver, pmu_acpi_methods, + sizeof(struct pmu_softc)); + +static devclass_t pmu_acpi_devclass; + +DRIVER_MODULE(pmu, acpi, pmu_acpi_driver, pmu_acpi_devclass, 0, 0); diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 2d98568b3d9f..b363b800af67 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -22,6 +22,7 @@ arm/arm/gic_acpi.c optional acpi arm/arm/gic_fdt.c optional fdt arm/arm/gic_if.m standard arm/arm/pmu.c standard +arm/arm/pmu_acpi.c optional acpi arm/arm/pmu_fdt.c optional fdt arm64/acpica/acpi_iort.c optional acpi arm64/acpica/acpi_machdep.c optional acpi From nobody Tue Nov 2 23:09: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 D16381842CEE; Tue, 2 Nov 2021 23:09:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HkQb85Z46z4lL8; Tue, 2 Nov 2021 23:09:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9068B5DC8; Tue, 2 Nov 2021 23:09:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A2N9ebv025568; Tue, 2 Nov 2021 23:09:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2N9efq025567; Tue, 2 Nov 2021 23:09:40 GMT (envelope-from git) Date: Tue, 2 Nov 2021 23:09:40 GMT Message-Id: <202111022309.1A2N9efq025567@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: e3ab141fda6a - main - gpart: Move GPT efimedia reporting to a separate routine 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: e3ab141fda6a999d6fcdf050e07174199eea5557 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e3ab141fda6a999d6fcdf050e07174199eea5557 commit e3ab141fda6a999d6fcdf050e07174199eea5557 Author: Warner Losh AuthorDate: 2021-11-02 23:08:37 +0000 Commit: Warner Losh CommitDate: 2021-11-02 23:09:17 +0000 gpart: Move GPT efimedia reporting to a separate routine Move the efimedia reporting to g_part_gpt_efimedia and use that from g_part_gpt_dumpconf to report it. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D32780 --- sys/geom/part/g_part_gpt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index 89a92977dff6..1f6d3dff249d 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -734,6 +734,15 @@ g_part_gpt_destroy(struct g_part_table *basetable, struct g_part_parms *gpp) return (0); } +static void +g_part_gpt_efimedia(struct g_part_gpt_entry *entry, struct sbuf *sb) +{ + sbuf_printf(sb, "HD(%d,GPT,", entry->base.gpe_index); + sbuf_printf_uuid(sb, &entry->ent.ent_uuid); + sbuf_printf(sb, ",%#jx,%#jx)", (intmax_t)entry->base.gpe_start, + (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1)); +} + static void g_part_gpt_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, struct sbuf *sb, const char *indent) @@ -768,10 +777,7 @@ g_part_gpt_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, sbuf_printf_uuid(sb, &entry->ent.ent_uuid); sbuf_cat(sb, "\n"); sbuf_printf(sb, "%s", indent); - sbuf_printf(sb, "HD(%d,GPT,", entry->base.gpe_index); - sbuf_printf_uuid(sb, &entry->ent.ent_uuid); - sbuf_printf(sb, ",%#jx,%#jx)", (intmax_t)entry->base.gpe_start, - (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1)); + g_part_gpt_efimedia(entry, sb); sbuf_cat(sb, "\n"); } else { /* confxml: scheme information */ From nobody Tue Nov 2 23:09: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 0D0361842F89; Tue, 2 Nov 2021 23:09: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 4HkQb96Kxfz4lFg; Tue, 2 Nov 2021 23:09: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 B1D8A5D74; Tue, 2 Nov 2021 23:09: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 1A2N9fq0025592; Tue, 2 Nov 2021 23:09:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A2N9fmP025591; Tue, 2 Nov 2021 23:09:41 GMT (envelope-from git) Date: Tue, 2 Nov 2021 23:09:41 GMT Message-Id: <202111022309.1A2N9fmP025591@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: edfbbfd541ab - main - gpart: Move MBR efimedia reporting to a separate routine 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: edfbbfd541ab9f7ba13b246d86bd0c36757ec660 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=edfbbfd541ab9f7ba13b246d86bd0c36757ec660 commit edfbbfd541ab9f7ba13b246d86bd0c36757ec660 Author: Warner Losh AuthorDate: 2021-11-02 23:08:48 +0000 Commit: Warner Losh CommitDate: 2021-11-02 23:09:17 +0000 gpart: Move MBR efimedia reporting to a separate routine Move the efimedia reporting to g_part_mbr_efimedia and use that from g_part_mbr_dumpconf to report it. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D32781 --- sys/geom/part/g_part_mbr.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c index 750d417bba5d..d5d18e52456d 100644 --- a/sys/geom/part/g_part_mbr.c +++ b/sys/geom/part/g_part_mbr.c @@ -308,13 +308,24 @@ g_part_mbr_destroy(struct g_part_table *basetable, struct g_part_parms *gpp) return (0); } +static void +g_part_mbr_efimedia(struct g_part_mbr_table *table, struct g_part_mbr_entry *entry, + struct sbuf *sb) +{ + uint32_t dsn; + + dsn = le32dec(table->mbr + DOSDSNOFF); + sbuf_printf(sb, "HD(%d,MBR,%#08x,%#jx,%#jx)", + entry->base.gpe_index, dsn, (intmax_t)entry->base.gpe_start, + (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1)); +} + static void g_part_mbr_dumpconf(struct g_part_table *basetable, struct g_part_entry *baseentry, struct sbuf *sb, const char *indent) { struct g_part_mbr_entry *entry; struct g_part_mbr_table *table; - uint32_t dsn; table = (struct g_part_mbr_table *)basetable; entry = (struct g_part_mbr_entry *)baseentry; @@ -327,10 +338,8 @@ g_part_mbr_dumpconf(struct g_part_table *basetable, struct g_part_entry *baseent entry->ent.dp_typ); if (entry->ent.dp_flag & 0x80) sbuf_printf(sb, "%sactive\n", indent); - dsn = le32dec(table->mbr + DOSDSNOFF); - sbuf_printf(sb, "%sHD(%d,MBR,%#08x,%#jx,%#jx)", indent, - entry->base.gpe_index, dsn, (intmax_t)entry->base.gpe_start, - (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1)); + sbuf_printf(sb, "%s", indent); + g_part_mbr_efimedia(table, entry, sb); sbuf_cat(sb, "\n"); } else { /* confxml: scheme information */ From nobody Wed Nov 3 00:31: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 D846B1845146; Wed, 3 Nov 2021 00:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HkSPV5q1tz56Ct; Wed, 3 Nov 2021 00:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A7C1F707F; Wed, 3 Nov 2021 00:31: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 1A30VQN7039566; Wed, 3 Nov 2021 00:31:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A30VQ2X039565; Wed, 3 Nov 2021 00:31:26 GMT (envelope-from git) Date: Wed, 3 Nov 2021 00:31:26 GMT Message-Id: <202111030031.1A30VQ2X039565@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: 331883a2f2e9 - main - nfscl: Check for a forced dismount in nfscl_getref() 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: 331883a2f2e9ae5567085e4cd3a7ae3db2a2b022 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=331883a2f2e9ae5567085e4cd3a7ae3db2a2b022 commit 331883a2f2e9ae5567085e4cd3a7ae3db2a2b022 Author: Rick Macklem AuthorDate: 2021-11-03 00:28:13 +0000 Commit: Rick Macklem CommitDate: 2021-11-03 00:28:13 +0000 nfscl: Check for a forced dismount in nfscl_getref() The nfscl_getref() function is called within nfscl_doiods() when the NFSv4.1/4.2 pNFS client is doing I/O on a DS. As such, nfscl_getref() needs to check for a forced dismount. This patch adds that check. Found during a recent IETF NFSv4 working group testing event. MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clstate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 523cc59039af..22c0da1bcef8 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -4907,6 +4907,7 @@ int nfscl_getref(struct nfsmount *nmp) { struct nfsclclient *clp; + int ret; NFSLOCKCLSTATE(); clp = nfscl_findcl(nmp); @@ -4914,9 +4915,12 @@ nfscl_getref(struct nfsmount *nmp) NFSUNLOCKCLSTATE(); return (0); } - nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, NULL); + nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, nmp->nm_mountp); + ret = 1; + if (NFSCL_FORCEDISM(nmp->nm_mountp)) + ret = 0; NFSUNLOCKCLSTATE(); - return (1); + return (ret); } /* From nobody Wed Nov 3 07:34: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 95CA318387B7; Wed, 3 Nov 2021 07:34: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 4HkdnJ3hhpz4lKP; Wed, 3 Nov 2021 07:34: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 54132145F6; Wed, 3 Nov 2021 07:34: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 1A37YCSL002282; Wed, 3 Nov 2021 07:34:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A37YChn002281; Wed, 3 Nov 2021 07:34:12 GMT (envelope-from git) Date: Wed, 3 Nov 2021 07:34:12 GMT Message-Id: <202111030734.1A37YChn002281@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: 7771f2a0c94f - main - kern: physmem: improve region coalescing logic 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: 7771f2a0c94fc2f7b9ce1565a49e52dba1e7381d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=7771f2a0c94fc2f7b9ce1565a49e52dba1e7381d commit 7771f2a0c94fc2f7b9ce1565a49e52dba1e7381d Author: Kyle Evans AuthorDate: 2021-10-28 04:40:08 +0000 Commit: Kyle Evans CommitDate: 2021-11-03 07:32:46 +0000 kern: physmem: improve region coalescing logic The existing logic didn't take into account newly inserted mappings wholly contained by an existing region (or vice versa), nor did it account for weird overlap scenarios. The latter is probably unlikely to happen, but the former may happen in UEFI: BootServicesData allocated within a large chunk of ConventionalMemory. This situation blows up vm initialization. While we're here, remove the "exact match" logic as it's likely wrong; if an exact match exists with conflicting flags, for instance, then we should probably be doing something else. The new logic takes into account exact matches as part of the overlapping efforts. Reviewed by: kib, mhorne (both earlier version) Differential Revision: https://reviews.freebsd.org/D32701 --- sys/kern/subr_physmem.c | 92 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 6 deletions(-) diff --git a/sys/kern/subr_physmem.c b/sys/kern/subr_physmem.c index ea1ec12dd065..1cff1eb062c6 100644 --- a/sys/kern/subr_physmem.c +++ b/sys/kern/subr_physmem.c @@ -270,6 +270,67 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, size_t maxavail, return (acnt); } +/* + * Check if the region at idx can be merged with the region above it. + */ +static size_t +merge_upper_regions(struct region *regions, size_t rcnt, size_t idx) +{ + struct region *lower, *upper; + vm_paddr_t lend, uend; + size_t i, mergecnt, movecnt; + + lower = ®ions[idx]; + lend = lower->addr + lower->size; + + /* + * Continue merging in upper entries as long as we have entries to + * merge; the new block could have spanned more than one, although one + * is likely the common case. + */ + for (i = idx + 1; i < rcnt; i++) { + upper = ®ions[i]; + if (lend < upper->addr || lower->flags != upper->flags) + break; + + uend = upper->addr + upper->size; + if (uend > lend) { + lower->size += uend - lend; + lend = lower->addr + lower->size; + } + + if (uend >= lend) { + /* + * If we didn't move past the end of the upper region, + * then we don't need to bother checking for another + * merge because it would have been done already. Just + * increment i once more to maintain the invariant that + * i is one past the last entry merged. + */ + i++; + break; + } + } + + /* + * We merged in the entries from [idx + 1, i); physically move the tail + * end at [i, rcnt) if we need to. + */ + mergecnt = i - (idx + 1); + if (mergecnt > 0) { + movecnt = rcnt - i; + if (movecnt == 0) { + /* Merged all the way to the end, just decrease rcnt. */ + rcnt = idx + 1; + } else { + memmove(®ions[idx + 1], ®ions[idx + mergecnt + 1], + movecnt * sizeof(*regions)); + rcnt -= mergecnt; + } + } + return (rcnt); +} + /* * Insertion-sort a new entry into a regions list; sorted by start address. */ @@ -278,19 +339,38 @@ insert_region(struct region *regions, size_t rcnt, vm_paddr_t addr, vm_size_t size, uint32_t flags) { size_t i; + vm_paddr_t nend, rend; struct region *ep, *rp; + nend = addr + size; ep = regions + rcnt; for (i = 0, rp = regions; i < rcnt; ++i, ++rp) { - if (rp->addr == addr && rp->size == size) /* Pure dup. */ - return (rcnt); if (flags == rp->flags) { - if (addr + size == rp->addr) { + rend = rp->addr + rp->size; + if (addr <= rp->addr && nend >= rp->addr) { + /* + * New mapping overlaps at the beginning, shift + * for any difference in the beginning then + * shift if the new mapping extends past. + */ + rp->size += rp->addr - addr; rp->addr = addr; - rp->size += size; + if (nend > rend) { + rp->size += nend - rend; + rcnt = merge_upper_regions(regions, + rcnt, i); + } return (rcnt); - } else if (rp->addr + rp->size == addr) { - rp->size += size; + } else if (addr <= rend && nend > rp->addr) { + /* + * New mapping is either entirely contained + * within or it's overlapping at the end. + */ + if (nend > rend) { + rp->size += nend - rend; + rcnt = merge_upper_regions(regions, + rcnt, i); + } return (rcnt); } } From nobody Wed Nov 3 09:03: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 A8C291818260; Wed, 3 Nov 2021 09:03: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 4HkgmL4MGHz3hGs; Wed, 3 Nov 2021 09:03: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 7640015F2C; Wed, 3 Nov 2021 09:03: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 1A393UZN022397; Wed, 3 Nov 2021 09:03:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A393UCA022396; Wed, 3 Nov 2021 09:03:30 GMT (envelope-from git) Date: Wed, 3 Nov 2021 09:03:30 GMT Message-Id: <202111030903.1A393UCA022396@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: 91be6286e2a7 - main - linprocfs: Fix formatting of Uid and Gid lines 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: 91be6286e2a7ddad6dcf8d653fcd3f2c0b53072f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=91be6286e2a7ddad6dcf8d653fcd3f2c0b53072f commit 91be6286e2a7ddad6dcf8d653fcd3f2c0b53072f Author: Edward Tomasz Napierala AuthorDate: 2021-11-03 08:40:49 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-11-03 08:40:55 +0000 linprocfs: Fix formatting of Uid and Gid lines The separator here should be tabs, not spaces. This fixes a warning from chromium-browser on Bionic: [1022/162248.137612:ERROR:process_info_linux.cc(107)] format error: unrecognized Uid format Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32612 --- sys/compat/linprocfs/linprocfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 18dec7e01aae..66c6d1cf76ac 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1089,12 +1089,12 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) sbuf_printf(sb, "Pid:\t%d\n", p->p_pid); sbuf_printf(sb, "PPid:\t%d\n", kp.ki_ppid ); sbuf_printf(sb, "TracerPid:\t%d\n", kp.ki_tracer ); - sbuf_printf(sb, "Uid:\t%d %d %d %d\n", p->p_ucred->cr_ruid, + sbuf_printf(sb, "Uid:\t%d\t%d\t%d\t%d\n", p->p_ucred->cr_ruid, p->p_ucred->cr_uid, p->p_ucred->cr_svuid, /* FreeBSD doesn't have fsuid */ p->p_ucred->cr_uid); - sbuf_printf(sb, "Gid:\t%d %d %d %d\n", p->p_ucred->cr_rgid, + sbuf_printf(sb, "Gid:\t%d\t%d\t%d\t%d\n", p->p_ucred->cr_rgid, p->p_ucred->cr_gid, p->p_ucred->cr_svgid, /* FreeBSD doesn't have fsgid */ From nobody Wed Nov 3 09:08: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 40F75181C05B; Wed, 3 Nov 2021 09:08: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 4Hkgt40yT8z3kGp; Wed, 3 Nov 2021 09:08: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 00D73158D7; Wed, 3 Nov 2021 09:08: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 1A398ROC022840; Wed, 3 Nov 2021 09:08:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A398Rb8022839; Wed, 3 Nov 2021 09:08:27 GMT (envelope-from git) Date: Wed, 3 Nov 2021 09:08:27 GMT Message-Id: <202111030908.1A398Rb8022839@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: 4dfd612286ec - main - linux: mv sys/i386/linux/linux_ptrace{,_machdep}.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: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4dfd612286ec2ecc7a05f3d4fd65a58f4b05f74c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=4dfd612286ec2ecc7a05f3d4fd65a58f4b05f74c commit 4dfd612286ec2ecc7a05f3d4fd65a58f4b05f74c Author: Edward Tomasz Napierala AuthorDate: 2021-11-03 08:49:41 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-11-03 08:50:17 +0000 linux: mv sys/i386/linux/linux_ptrace{,_machdep}.c In preparation for machine-independent sys/compat/linux/linux_ptrace.c, rename the i386-specific Linux ptrace(2) implementation. No functional changes. Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32757 --- sys/i386/linux/{linux_ptrace.c => linux_ptrace_machdep.c} | 0 sys/modules/linux/Makefile | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/i386/linux/linux_ptrace.c b/sys/i386/linux/linux_ptrace_machdep.c similarity index 100% rename from sys/i386/linux/linux_ptrace.c rename to sys/i386/linux/linux_ptrace_machdep.c diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile index 373ec3dcae91..d2822a20c67a 100644 --- a/sys/modules/linux/Makefile +++ b/sys/modules/linux/Makefile @@ -40,8 +40,8 @@ SRCS+= opt_apic.h OBJS= linux${SFX}_vdso.so .if ${MACHINE_CPUARCH} == "i386" -SRCS+= linux_ptrace.c imgact_linux.c linux_util.c linux_mib.c linux_mmap.c \ - linux_dummy.c linux_emul.c linux_errno.c opt_cpu.h linux.c +SRCS+= linux_ptrace_machdep.c imgact_linux.c linux_util.c linux_mib.c \ + linux_mmap.c linux_dummy.c linux_emul.c linux_errno.c opt_cpu.h linux.c .endif .if ${MACHINE_CPUARCH} == "i386" From nobody Wed Nov 3 09:11: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 B8AE0181C8A2; Wed, 3 Nov 2021 09:11: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 4Hkgy04vVHz3kvn; Wed, 3 Nov 2021 09:11: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 87EC91636E; Wed, 3 Nov 2021 09:11: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 1A39BqhA033778; Wed, 3 Nov 2021 09:11:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A39BqFQ033777; Wed, 3 Nov 2021 09:11:52 GMT (envelope-from git) Date: Wed, 3 Nov 2021 09:11:52 GMT Message-Id: <202111030911.1A39BqFQ033777@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: c91d0e59be10 - main - linux: Make linux_ptrace.c portable 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: c91d0e59be10f9412cbce467b8b038f006bb6f18 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=c91d0e59be10f9412cbce467b8b038f006bb6f18 commit c91d0e59be10f9412cbce467b8b038f006bb6f18 Author: Edward Tomasz Napierala AuthorDate: 2021-11-03 08:54:30 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-11-03 08:54:35 +0000 linux: Make linux_ptrace.c portable Make sys/amd64/linux/linux_ptrace.c machine-independent, in preparation for moving it into sys/compat/linux/. No functional changes. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32756 --- sys/amd64/linux/linux_ptrace.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index 191e6265b39c..2ebf1c2be997 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -108,6 +108,7 @@ __FBSDID("$FreeBSD$"); #define LINUX_PTRACE_PEEKUSER_DS 184 #define LINUX_ARCH_AMD64 0xc000003e +#define LINUX_ARCH_AARCH64 0xc00000b7 static int map_signum(int lsig, int *bsigp) @@ -217,6 +218,7 @@ linux_ptrace_peekuser(struct thread *td, pid_t pid, void *addr, void *data) return (error); switch ((uintptr_t)addr) { +#ifdef __amd64__ case LINUX_PTRACE_PEEKUSER_ORIG_RAX: val = b_reg.r_rax; break; @@ -229,6 +231,7 @@ linux_ptrace_peekuser(struct thread *td, pid_t pid, void *addr, void *data) case LINUX_PTRACE_PEEKUSER_DS: val = b_reg.r_ds; break; +#endif /* __amd64__ */ default: linux_msg(td, "PTRACE_PEEKUSER offset %ld not implemented; " "returning EINVAL", (uintptr_t)addr); @@ -343,20 +346,25 @@ linux_ptrace_getregs(struct thread *td, pid_t pid, void *data) struct ptrace_lwpinfo lwpinfo; struct reg b_reg; struct linux_pt_regset l_regset; +#ifdef __amd64__ struct pcb *pcb; +#endif int error; error = kern_ptrace(td, PT_GETREGS, pid, &b_reg, 0); if (error != 0) return (error); + bsd_to_linux_regset(&b_reg, &l_regset); + +#ifdef __amd64__ 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; +#endif error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { @@ -404,7 +412,9 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) struct reg b_reg; struct linux_pt_regset l_regset; struct iovec iov; +#ifdef __amd64__ struct pcb *pcb; +#endif size_t len; int error; @@ -418,13 +428,16 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) if (error != 0) return (error); + bsd_to_linux_regset(&b_reg, &l_regset); + +#ifdef __amd64__ 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; +#endif error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { @@ -569,9 +582,17 @@ linux_ptrace_get_syscall_info(struct thread *td, pid_t pid, if (error != 0) return (error); +#if defined(__amd64__) si.arch = LINUX_ARCH_AMD64; si.instruction_pointer = b_reg.r_rip; si.stack_pointer = b_reg.r_rsp; +#elif defined(__aarch64__) + si.arch = LINUX_ARCH_AARCH64; + si.instruction_pointer = b_reg.lr; + si.stack_pointer = b_reg.sp; +#else +#error "unknown architecture" +#endif len = MIN(len, sizeof(si)); error = copyout(&si, (void *)data, len); From nobody Wed Nov 3 09:14: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 24CED1828DA5; Wed, 3 Nov 2021 09:14: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 4Hkh1Q0VS1z3n3b; Wed, 3 Nov 2021 09:14: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 E4F8A15EDF; Wed, 3 Nov 2021 09:14: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 1A39EnRu035755; Wed, 3 Nov 2021 09:14:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A39Enne035754; Wed, 3 Nov 2021 09:14:49 GMT (envelope-from git) Date: Wed, 3 Nov 2021 09:14:49 GMT Message-Id: <202111030914.1A39Enne035754@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: e03813c3e1fd - main - development(7): Use a more common architecture for examples 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: e03813c3e1fd6aaac87eac3dd258cccb4238ed91 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=e03813c3e1fd6aaac87eac3dd258cccb4238ed91 commit e03813c3e1fd6aaac87eac3dd258cccb4238ed91 Author: Edward Tomasz Napierala AuthorDate: 2021-10-31 13:27:29 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-11-03 08:59:26 +0000 development(7): Use a more common architecture for examples --- share/man/man7/development.7 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/man/man7/development.7 b/share/man/man7/development.7 index 805e3c948df9..71846b236ec2 100644 --- a/share/man/man7/development.7 +++ b/share/man/man7/development.7 @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 19, 2021 +.Dd November 1, 2021 .Dt DEVELOPMENT 7 .Os .Sh NAME @@ -157,20 +157,20 @@ for another CPU architecture, first prepare your source tree by building the cross-toolchain: .Bd -literal -offset indent cd src -make -sj8 toolchain TARGET_ARCH=armv6 +make -sj8 toolchain TARGET_ARCH=aarch64 .Ed .Pp Afterwards, to build and install a single piece of userspace, use: .Bd -literal -offset indent cd src/bin/ls -make buildenv TARGET_ARCH=armv6 +make buildenv TARGET_ARCH=aarch64 make clean all install DESTDIR=/clients/arm .Ed .Pp Likewise, to quickly rebuild and reinstall the kernel, use: .Bd -literal -offset indent cd src -make buildenv TARGET_ARCH=armv6 +make buildenv TARGET_ARCH=aarch64 make -sj8 kernel KERNFAST=1 DESTDIR=/clients/arm .Ed .Sh SEE ALSO From nobody Wed Nov 3 09:49: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 57D8D1839544; Wed, 3 Nov 2021 09:49: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 4Hkhn96fyqz4SKC; Wed, 3 Nov 2021 09:49: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 BAF3E16A08; Wed, 3 Nov 2021 09:49: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 1A39nHae075910; Wed, 3 Nov 2021 09:49:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A39nHBP075909; Wed, 3 Nov 2021 09:49:17 GMT (envelope-from git) Date: Wed, 3 Nov 2021 09:49:17 GMT Message-Id: <202111030949.1A39nHBP075909@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: 11703705c2f7 - main - pf tests: route_to:icmp_nat_head requires scapy 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: 11703705c2f77498246b9523aae44040bd346c00 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=11703705c2f77498246b9523aae44040bd346c00 commit 11703705c2f77498246b9523aae44040bd346c00 Author: Kristof Provost AuthorDate: 2021-11-03 09:34:20 +0000 Commit: Kristof Provost CommitDate: 2021-11-03 09:35:09 +0000 pf tests: route_to:icmp_nat_head requires scapy Document the requirement so the test is skipped if scapy is not installed. MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/route_to.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/sys/netpfil/pf/route_to.sh b/tests/sys/netpfil/pf/route_to.sh index e7646a5fb7f7..570d1feb36ff 100644 --- a/tests/sys/netpfil/pf/route_to.sh +++ b/tests/sys/netpfil/pf/route_to.sh @@ -257,6 +257,7 @@ icmp_nat_head() { atf_set descr 'Test that ICMP packets are correct for route-to + NAT' atf_set require.user root + atf_set require.progs scapy } icmp_nat_body() From nobody Wed Nov 3 12:24: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 490B4183BA05; Wed, 3 Nov 2021 12:24: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 4HkmDd1JHJz3qjx; Wed, 3 Nov 2021 12:24: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 F1AB91877A; Wed, 3 Nov 2021 12:24: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 1A3COmZg087732; Wed, 3 Nov 2021 12:24:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3COmc0087731; Wed, 3 Nov 2021 12:24:48 GMT (envelope-from git) Date: Wed, 3 Nov 2021 12:24:48 GMT Message-Id: <202111031224.1A3COmc0087731@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: 4a9e95286cac - main - ip_divert: calculate delayed checksum for IPv6 adress family 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: ae X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a9e95286cacce5bf7cd193b43c4a461cf7d69b8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=4a9e95286cacce5bf7cd193b43c4a461cf7d69b8 commit 4a9e95286cacce5bf7cd193b43c4a461cf7d69b8 Author: Andrey V. Elsukov AuthorDate: 2021-11-02 16:59:06 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-11-03 12:20:51 +0000 ip_divert: calculate delayed checksum for IPv6 adress family Before passing an IPv6 packet to application apply delayed checksum calculation. Mbuf flags will be lost when divert listener will return a packet back, so we will not be able to do delayed checksum calculation later. Also an application will get a packet with correct checksum. Reviewed by: donner MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32807 --- sys/netinet/ip_divert.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index e156b77f44c7..3e1200b1ff1c 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -227,6 +227,25 @@ divert_packet(struct mbuf *m, bool incoming) m->m_pkthdr.csum_flags &= ~CSUM_SCTP; } #endif +#ifdef INET6 + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { + m = mb_unmapped_to_ext(m); + if (m == NULL) + return; + in6_delayed_cksum(m, m->m_pkthdr.len - + sizeof(struct ip6_hdr), sizeof(struct ip6_hdr)); + m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; + } +#if defined(SCTP) || defined(SCTP_SUPPORT) + if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { + m = mb_unmapped_to_ext(m); + if (m == NULL) + return; + sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); + m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; + } +#endif +#endif /* INET6 */ bzero(&divsrc, sizeof(divsrc)); divsrc.sin_len = sizeof(divsrc); divsrc.sin_family = AF_INET; From nobody Wed Nov 3 12:50: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 286001845812; Wed, 3 Nov 2021 12:50: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 4HkmpH0cTjz4S3v; Wed, 3 Nov 2021 12:50: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 E936F18ED0; Wed, 3 Nov 2021 12:50: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 1A3CoUqv022949; Wed, 3 Nov 2021 12:50:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3CoU2t022948; Wed, 3 Nov 2021 12:50:30 GMT (envelope-from git) Date: Wed, 3 Nov 2021 12:50:30 GMT Message-Id: <202111031250.1A3CoU2t022948@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: 7acd322ebe20 - main - devfs.rules: Correctly unhide pf in vnet jails 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: 7acd322ebe2072b1d73b1d19c14ab12a300ba8e8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7acd322ebe2072b1d73b1d19c14ab12a300ba8e8 commit 7acd322ebe2072b1d73b1d19c14ab12a300ba8e8 Author: Zhenlei Huang AuthorDate: 2021-11-03 11:46:48 +0000 Commit: Kristof Provost CommitDate: 2021-11-03 11:50:13 +0000 devfs.rules: Correctly unhide pf in vnet jails Revision 9e9be081d8 introduced a new devfs rule devfsrules_jail_vnet. It includes rule devfsrules_jail which include other rules. Unfortunately devfs could not recursively parse the action include and thus devfsrules_jail_vnet will expose all nodes. PR: 255660 Reviewed by: kp Obtained from: Gijs Peskens MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D32814 --- sbin/devfs/devfs.rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbin/devfs/devfs.rules b/sbin/devfs/devfs.rules index 01d8e5194c17..9543e20947d9 100644 --- a/sbin/devfs/devfs.rules +++ b/sbin/devfs/devfs.rules @@ -88,5 +88,8 @@ add path fuse unhide add path zfs unhide [devfsrules_jail_vnet=5] +add include $devfsrules_hide_all +add include $devfsrules_unhide_basic +add include $devfsrules_unhide_login add include $devfsrules_jail add path pf unhide From nobody Wed Nov 3 13:09: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 529C5182F16C; Wed, 3 Nov 2021 13:09: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 4HknDP1k34z4Yd1; Wed, 3 Nov 2021 13:09: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 1CA051932A; Wed, 3 Nov 2021 13:09: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 1A3D9fM5041723; Wed, 3 Nov 2021 13:09:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3D9fxk041722; Wed, 3 Nov 2021 13:09:41 GMT (envelope-from git) Date: Wed, 3 Nov 2021 13:09:41 GMT Message-Id: <202111031309.1A3D9fxk041722@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: a12b16f48f74 - main - date: Clean up synopses 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a12b16f48f747339ccae6dd80cc0c0c4ad5b7846 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a12b16f48f747339ccae6dd80cc0c0c4ad5b7846 commit a12b16f48f747339ccae6dd80cc0c0c4ad5b7846 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-11-03 11:58:09 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-11-03 13:09:36 +0000 date: Clean up synopses MFC after: 3 days --- bin/date/date.1 | 49 +++++++++++++++++++++++++++++++++++-------------- bin/date/date.c | 6 +++--- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/bin/date/date.1 b/bin/date/date.1 index 05b180cceb2b..4e60d34c1f86 100644 --- a/bin/date/date.1 +++ b/bin/date/date.1 @@ -39,34 +39,55 @@ .Nm date .Nd display or set date and time .Sh SYNOPSIS +.\" Display time. .Nm -.Op Fl jnRu -.Op Fl r Ar seconds | Ar filename +.Op Fl nRu +.Op Fl I Ns Op Ar FMT +.Op Fl r Ar filename +.Op Fl r Ar seconds .Oo -.Fl v .Sm off +.Fl v .Op Cm + | - .Ar val Op Cm y | m | w | d | H | M | S .Sm on .Oc .Op Cm + Ns Ar output_fmt +.\" Set time with the default input format. .Nm -.Op Fl ju +.Op Fl jnRu +.Op Fl I Ns Op Ar FMT +.Oo .Sm off -.Op Oo Oo Oo Oo Ar cc Oc Ar yy Oc Ar mm Oc Ar dd Oc Ar HH -.Ar MM Op Ar .ss +.Fl v +.Op Cm + | - +.Ar val Op Cm y | m | w | d | H | M | S +.Sm on +.Oc +.Sm off +.Oo Oo Oo Oo Oo +.Ar cc Oc +.Ar yy Oc +.Ar mm Oc +.Ar dd Oc +.Ar HH +.Oc Ar MM Op Cm \&. Ar ss .Sm on -.Nm -.Op Fl jRu -.Fl f Ar input_fmt new_date .Op Cm + Ns Ar output_fmt +.\" Set time with the user-provided input format. .Nm -.Op Fl jnu +.Op Fl jnRu .Op Fl I Ns Op Ar FMT -.Op Fl f Ar input_fmt -.Op Fl r Ar ... -.Op Fl v Ar ... -.Op Ar new_date +.Oo +.Sm off +.Fl v +.Op Cm + | - +.Ar val Op Cm y | m | w | d | H | M | S +.Sm on +.Oc +.Fl f Ar input_fmt +.Ar new_date +.Op Cm + Ns Ar output_fmt .Sh DESCRIPTION When invoked without arguments, the .Nm diff --git a/bin/date/date.c b/bin/date/date.c index cde299f6de61..87f3dad28bd6 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -383,11 +383,11 @@ static void usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n", - "usage: date [-jnRu] [-r seconds|file] [-v[+|-]val[ymwdHMS]]", + "usage: date [-jnRu] [-I[date|hours|minutes|seconds]] [-f input_fmt]", " " - "[-I[date | hours | minutes | seconds]]", + "[-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]", " " - "[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]" + "[[[[[[cc]yy]mm]dd]HH]MM[.ss] | new_date] [+output_fmt]" ); exit(1); } From nobody Wed Nov 3 13:09: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 43ADB182F488; Wed, 3 Nov 2021 13:09:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HknDN1QDtz4Yqn; Wed, 3 Nov 2021 13:09:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0C225195BC; Wed, 3 Nov 2021 13:09:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3D9deD041699; Wed, 3 Nov 2021 13:09:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3D9d2J041698; Wed, 3 Nov 2021 13:09:39 GMT (envelope-from git) Date: Wed, 3 Nov 2021 13:09:39 GMT Message-Id: <202111031309.1A3D9d2J041698@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 00133d5c5e6a - main - date.1: Fix some style issues and examples 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 00133d5c5e6aae01663eca40993abd5e6137425b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=00133d5c5e6aae01663eca40993abd5e6137425b commit 00133d5c5e6aae01663eca40993abd5e6137425b Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-11-03 10:26:46 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-11-03 13:09:18 +0000 date.1: Fix some style issues and examples - Use Cm instead of Ar or Sq for command modifiers of the -v flag. - Remove unnecessary "Ar ..." from the synopsis. It's not clear what it was referring to. - Add missing arguments to the -f and -v flags. - Stylize the dot before "ss" with Cm in the default format in the -f flag description. - Set LC_ALL=C in the last example so that the output format of date(1) always matches the specified format of the -f flag not matter the locale. - List the -f flag as optional in all usage lines in the synopsis. MFC after: 3 days --- bin/date/date.1 | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/bin/date/date.1 b/bin/date/date.1 index 8f187b311a82..05b180cceb2b 100644 --- a/bin/date/date.1 +++ b/bin/date/date.1 @@ -32,7 +32,7 @@ .\" @(#)date.1 8.3 (Berkeley) 4/28/95 .\" $FreeBSD$ .\" -.Dd June 16, 2021 +.Dd November 3, 2021 .Dt DATE 1 .Os .Sh NAME @@ -46,10 +46,9 @@ .Fl v .Sm off .Op Cm + | - -.Ar val Op Ar ymwdHMS +.Ar val Op Cm y | m | w | d | H | M | S .Sm on .Oc -.Ar ... .Op Cm + Ns Ar output_fmt .Nm .Op Fl ju @@ -90,7 +89,7 @@ the time may not be changed by more than 1 second. .Pp The options are as follows: .Bl -tag -width Ds -.It Fl f +.It Fl f Ar input_fmt Use .Ar input_fmt as the format string to parse the @@ -103,7 +102,7 @@ provided rather than using the default .Ar mm Oc .Ar dd Oc .Ar HH -.Oc Ar MM Op Ar .ss +.Oc Ar MM Op Cm \&. Ar ss .Sm on format. Parsing is done using @@ -114,24 +113,24 @@ Use output format. .Ar FMT may be omitted, in which case the default is -.Sq date . +.Cm date . Valid .Ar FMT values are -.Sq date , -.Sq hours , -.Sq minutes , +.Cm date , +.Cm hours , +.Cm minutes , and -.Sq seconds . +.Cm seconds . The date and time is formatted to the specified precision. When .Ar FMT is -.Sq hours +.Cm hours (or the more precise -.Sq minutes +.Cm minutes or -.Sq seconds ) , +.Cm seconds ) , the .St -iso8601 format includes the timezone. @@ -175,7 +174,13 @@ Print the date and time of the last modification of Display or set the date in .Tn UTC (Coordinated Universal) time. -.It Fl v +.It Xo +.Fl v +.Sm off +.Op Cm + | - +.Ar val Op Cm y | m | w | d | H | M | S +.Sm on +.Xc Adjust (i.e., take the current date and display the result of the adjustment; not actually set the date) the second, minute, hour, month day, week day, month or year according to @@ -199,14 +204,14 @@ and years are in the range 80-38 or 1980-2038. If .Ar val is numeric, one of either -.Ar y , -.Ar m , -.Ar w , -.Ar d , -.Ar H , -.Ar M +.Cm y , +.Cm m , +.Cm w , +.Cm d , +.Cm H , +.Cm M or -.Ar S +.Cm S must be used to specify which part of the date is to be adjusted. .Pp The week day or month may be specified using a name rather than a @@ -420,7 +425,7 @@ will display .Pp Finally the command: .Pp -.Dl "date -j -f ""%a %b %d %T %Z %Y"" ""`date`"" ""+%s""" +.Dl "date -j -f ""%a %b %d %T %Z %Y"" ""`LC_ALL=C date`"" ""+%s""" .Pp can be used to parse the output from .Nm From nobody Wed Nov 3 13:09: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 A80E6182F52B; Wed, 3 Nov 2021 13:09: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 4HknDQ3m8Vz4Yqv; Wed, 3 Nov 2021 13:09: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 4E0BA18FEC; Wed, 3 Nov 2021 13:09: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 1A3D9gaA041747; Wed, 3 Nov 2021 13:09:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3D9gm8041746; Wed, 3 Nov 2021 13:09:42 GMT (envelope-from git) Date: Wed, 3 Nov 2021 13:09:42 GMT Message-Id: <202111031309.1A3D9gm8041746@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: c537bf9d5903 - main - date: Capitalize seconds string in synopses 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c537bf9d5903d0689321f83691341c93b5919172 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c537bf9d5903d0689321f83691341c93b5919172 commit c537bf9d5903d0689321f83691341c93b5919172 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2021-11-03 11:59:49 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-11-03 13:09:36 +0000 date: Capitalize seconds string in synopses This makes it consistent with other date(1) implementations. Also, it feels more consistent since hours and minutes are already represented as HH and MM respectively. MFC after: 3 days --- bin/date/date.1 | 6 +++--- bin/date/date.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/date/date.1 b/bin/date/date.1 index 4e60d34c1f86..0aaae1614327 100644 --- a/bin/date/date.1 +++ b/bin/date/date.1 @@ -71,7 +71,7 @@ .Ar mm Oc .Ar dd Oc .Ar HH -.Oc Ar MM Op Cm \&. Ar ss +.Oc Ar MM Op Cm \&. Ar SS .Sm on .Op Cm + Ns Ar output_fmt .\" Set time with the user-provided input format. @@ -123,7 +123,7 @@ provided rather than using the default .Ar mm Oc .Ar dd Oc .Ar HH -.Oc Ar MM Op Cm \&. Ar ss +.Oc Ar MM Op Cm \&. Ar SS .Sm on format. Parsing is done using @@ -330,7 +330,7 @@ Day, a number from 1 to 31. Hour, a number from 0 to 23. .It Ar MM Minutes, a number from 0 to 59. -.It Ar ss +.It Ar SS Seconds, a number from 0 to 60 (59 plus a potential leap second). .El diff --git a/bin/date/date.c b/bin/date/date.c index 87f3dad28bd6..4dc5df0dccfc 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -387,7 +387,7 @@ usage(void) " " "[-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]", " " - "[[[[[[cc]yy]mm]dd]HH]MM[.ss] | new_date] [+output_fmt]" + "[[[[[[cc]yy]mm]dd]HH]MM[.SS] | new_date] [+output_fmt]" ); exit(1); } From nobody Wed Nov 3 13:10: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 AE5F91830727; Wed, 3 Nov 2021 13:10: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 4HknFV1t3Xz4ZnB; Wed, 3 Nov 2021 13:10: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 BF1B6193B8; Wed, 3 Nov 2021 13:10: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 1A3DAbce050193; Wed, 3 Nov 2021 13:10:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3DAbMr050192; Wed, 3 Nov 2021 13:10:37 GMT (envelope-from git) Date: Wed, 3 Nov 2021 13:10:37 GMT Message-Id: <202111031310.1A3DAbMr050192@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: e4ce23b238a1 - main - fexecve(2): restore the attempts to calculate the executable path 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: e4ce23b238a162f5d36afe8ef49dcd66901138a1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e4ce23b238a162f5d36afe8ef49dcd66901138a1 commit e4ce23b238a162f5d36afe8ef49dcd66901138a1 Author: Konstantin Belousov AuthorDate: 2021-11-03 12:58:03 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-03 13:10:22 +0000 fexecve(2): restore the attempts to calculate the executable path vn_fullpath() call was not converted to pass newtextvp, instead it used imgp->vp which is still NULL there. As result vn_fullpath() always returned EINVAL and execpath was recorded from the value of arg0. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/kern/kern_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 780b917ad21d..c5b450b04240 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -537,7 +537,7 @@ interpret: &newtextvp); if (error) goto exec_fail; - if (vn_fullpath(imgp->vp, &imgp->execpath, + if (vn_fullpath(newtextvp, &imgp->execpath, &imgp->freepath) != 0) imgp->execpath = args->fname; vn_lock(newtextvp, LK_SHARED | LK_RETRY); From nobody Wed Nov 3 13:48: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 A33071844775; Wed, 3 Nov 2021 13:48: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 4Hkp5Q4FZLz4qjT; Wed, 3 Nov 2021 13:48: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 7398019E30; Wed, 3 Nov 2021 13:48: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 1A3DmgbR094720; Wed, 3 Nov 2021 13:48:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3Dmgdr094719; Wed, 3 Nov 2021 13:48:42 GMT (envelope-from git) Date: Wed, 3 Nov 2021 13:48:42 GMT Message-Id: <202111031348.1A3Dmgdr094719@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: b042d10cdc71 - main - ofwfb: fix vga/hdmi console with ASMEDIA during boot on powerpc64(le) 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: alfredo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b042d10cdc71ddd6ef3449261d712b05c648746e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=b042d10cdc71ddd6ef3449261d712b05c648746e commit b042d10cdc71ddd6ef3449261d712b05c648746e Author: Alfredo Dal'Ava Junior AuthorDate: 2021-11-03 16:42:28 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2021-11-03 16:42:28 +0000 ofwfb: fix vga/hdmi console with ASMEDIA during boot on powerpc64(le) On recent OpenBMC firmware, the onboard ASMEDIA video card framebuffer address was removed from device tree for security purposes (value is set to zero to avoid leaking the address). This patch works around the problem by taking framebuffer base address from the "ranges" property of a parent node. Reviewed by: luporl, jhibbits (on IRC) MFC after: 2 weeks Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D30626 --- sys/dev/vt/hw/ofwfb/ofwfb.c | 116 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 110 insertions(+), 6 deletions(-) diff --git a/sys/dev/vt/hw/ofwfb/ofwfb.c b/sys/dev/vt/hw/ofwfb/ofwfb.c index 9dc674c0ebf9..e388356450d6 100644 --- a/sys/dev/vt/hw/ofwfb/ofwfb.c +++ b/sys/dev/vt/hw/ofwfb/ofwfb.c @@ -61,7 +61,8 @@ struct ofwfb_softc { uint32_t vendor_id; }; -#define PCI_VENDOR_ID_NVIDIA 0x10de +#define PCI_VID_NVIDIA 0x10de /* NVIDIA Corporation */ +#define PCI_VID_ASPEED 0x1a03 /* ASPEED Technology, Inc. */ static void ofwfb_initialize(struct vt_device *vd); static vd_probe_t ofwfb_probe; @@ -297,6 +298,104 @@ ofwfb_bitblt_text(struct vt_device *vd, const struct vt_window *vw, #endif } + +/* + * Decode OpenFirmware/IEEE 1275-1994 "ranges" property + * + * XXX: this is similar to ofw_pcib_fill_ranges but cannot use it here because + * it's not possible to allocate memory at the moment this is funcion is + * used. Since there are other similar functions dealing with "ranges" + * property, a proper refactoring is suggested. + */ +static uint64_t +decode_pci_ranges_host_addr(phandle_t pcinode) +{ + struct simplebus_range { + uint64_t bus; + uint64_t host; + uint64_t size; + }; + + struct simplebus_range ranges[4]; + int nranges, host_address_cells; + pcell_t acells, scells; + cell_t base_ranges[64]; + + ssize_t nbase_ranges; + int i, j, k; + + if (!OF_hasprop(pcinode, "ranges")) + return (0); + + if (OF_getencprop(pcinode, "#address-cells", &acells, sizeof(acells)) != + sizeof(acells)) + return (0); + + if (OF_getencprop(pcinode, "#size-cells", &scells, sizeof(scells)) != + sizeof(scells)) + return (0); + + if (OF_searchencprop(OF_parent(pcinode), "#address-cells", + &host_address_cells, sizeof(host_address_cells)) != + sizeof(host_address_cells)) + return (0); + + nbase_ranges = OF_getproplen(pcinode, "ranges"); + nranges = nbase_ranges / sizeof(cell_t) / (acells + host_address_cells + scells); + + /* prevent buffer overflow during iteration */ + if (nranges > sizeof(ranges) / sizeof(ranges[0])) + nranges = sizeof(ranges) / sizeof(ranges[0]); + + /* decode range value and return the first valid address */ + OF_getencprop(pcinode, "ranges", base_ranges, nbase_ranges); + for (i = 0, j = 0; i < nranges; i++) { + ranges[i].bus = 0; + for (k = 0; k < acells; k++) { + ranges[i].bus <<= 32; + ranges[i].bus |= base_ranges[j++]; + } + + ranges[i].host = 0; + for (k = 0; k < host_address_cells; k++) { + ranges[i].host <<= 32; + ranges[i].host |= base_ranges[j++]; + } + ranges[i].size = 0; + for (k = 0; k < scells; k++) { + ranges[i].size <<= 32; + ranges[i].size |= base_ranges[j++]; + } + + if (ranges[i].host != 0) + return (ranges[i].host); + } + + return (0); +} + +static bus_addr_t +find_pci_host_address(phandle_t node) +{ + uint64_t addr; + + /* + * According to IEEE STD 1275, if property "ranges" exists but has a + * zero-length property value, the child address space is identical + * to the parent address space. + */ + while (node) { + if (OF_hasprop(node, "ranges")) { + addr = decode_pci_ranges_host_addr(node); + if (addr != 0) + return ((bus_addr_t)addr); + } + node = OF_parent(node); + } + + return (0); +} + static void ofwfb_initialize(struct vt_device *vd) { @@ -350,7 +449,7 @@ ofwfb_initialize(struct vt_device *vd) * There is no good way to determine the correct option, as this * is independent of endian swapping. */ - if (sc->vendor_id == PCI_VENDOR_ID_NVIDIA) + if (sc->vendor_id == PCI_VID_NVIDIA) sc->argb = 0; else sc->argb = 1; @@ -430,7 +529,6 @@ ofwfb_init(struct vt_device *vd) sizeof(vendor_id)) == sizeof(vendor_id)) sc->vendor_id = vendor_id; - /* Keep track of the OF node */ sc->sc_node = node; @@ -497,12 +595,18 @@ ofwfb_init(struct vt_device *vd) * Grab the physical address of the framebuffer, and then map it * into our memory space. If the MMU is not yet up, it will be * remapped for us when relocation turns on. + * + * The ASPEED driver on recent petitboot versions doesn't expose the + * physical address of framebuffer anymore for security. So it should + * retrieve the address from PCI device properties. */ user_phys = 0; TUNABLE_UINT64_FETCH("hw.ofwfb.physaddr", &user_phys); - fb_phys = (bus_addr_t)user_phys; - if (fb_phys) - sc->fb.fb_pbase = (vm_paddr_t)fb_phys; + + if (user_phys) + sc->fb.fb_pbase = (vm_paddr_t)user_phys; + else if (sc->vendor_id == PCI_VID_ASPEED) + sc->fb.fb_pbase = find_pci_host_address(node); else if (OF_hasprop(node, "address")) { switch (OF_getproplen(node, "address")) { From nobody Wed Nov 3 14:03: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 B2A1C182BDE6; Wed, 3 Nov 2021 14:03: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 4HkpQk4H79z4vqx; Wed, 3 Nov 2021 14:03: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 72CFD19FAC; Wed, 3 Nov 2021 14:03: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 1A3E3g2P021952; Wed, 3 Nov 2021 14:03:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3E3g4T021951; Wed, 3 Nov 2021 14:03:42 GMT (envelope-from git) Date: Wed, 3 Nov 2021 14:03:42 GMT Message-Id: <202111031403.1A3E3g4T021951@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: dbfe5dd3f951 - main - cam_periph: style change 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: dbfe5dd3f95148dd14b95025182da371029c2e90 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=dbfe5dd3f95148dd14b95025182da371029c2e90 commit dbfe5dd3f95148dd14b95025182da371029c2e90 Author: Warner Losh AuthorDate: 2021-11-03 14:03:07 +0000 Commit: Warner Losh CommitDate: 2021-11-03 14:03:07 +0000 cam_periph: style change wrap a long line at 80 columns Sponsored by: Netflix Reviewed by: chs Differential Revision: https://reviews.freebsd.org/D32679 --- sys/cam/cam_periph.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 90ddf261cb12..d8fd41d77be7 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -279,7 +279,8 @@ cam_periph_alloc(periph_ctor_t *periph_ctor, && cur_periph->unit_number < periph->unit_number) cur_periph = TAILQ_NEXT(cur_periph, unit_links); if (cur_periph != NULL) { - KASSERT(cur_periph->unit_number != periph->unit_number, ("duplicate units on periph list")); + KASSERT(cur_periph->unit_number != periph->unit_number, + ("duplicate units on periph list")); TAILQ_INSERT_BEFORE(cur_periph, periph, unit_links); } else { TAILQ_INSERT_TAIL(&(*p_drv)->units, periph, unit_links); From nobody Wed Nov 3 15:22: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 B0EC9182227E; Wed, 3 Nov 2021 15:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hkr9b4hd3z3wR6; Wed, 3 Nov 2021 15:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 81F271B06A; Wed, 3 Nov 2021 15:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3FMR2H028066; Wed, 3 Nov 2021 15:22:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3FMRDv028063; Wed, 3 Nov 2021 15:22:27 GMT (envelope-from git) Date: Wed, 3 Nov 2021 15:22:27 GMT Message-Id: <202111031522.1A3FMRDv028063@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: 8da503495491 - main - ixgbe(4): Fix a few 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: 8da5034954911ecad0ce1e55acd3b50797bc338a 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=8da5034954911ecad0ce1e55acd3b50797bc338a commit 8da5034954911ecad0ce1e55acd3b50797bc338a Author: Gordon Bergling AuthorDate: 2021-11-03 15:16:20 +0000 Commit: Gordon Bergling CommitDate: 2021-11-03 15:16:20 +0000 ixgbe(4): Fix a few typos in source code comments - s/Manageblility/Managebility/ - s/alows/allows/ MFC after: 3 days Obtained from: NetBSD --- sys/dev/ixgbe/ixgbe_type.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/ixgbe/ixgbe_type.h b/sys/dev/ixgbe/ixgbe_type.h index 1eb446184990..769c47a143d8 100644 --- a/sys/dev/ixgbe/ixgbe_type.h +++ b/sys/dev/ixgbe/ixgbe_type.h @@ -1488,7 +1488,7 @@ struct ixgbe_dmac_config { #define IXGBE_CTRL_RST_MASK (IXGBE_CTRL_LNK_RST | IXGBE_CTRL_RST) /* FACTPS */ -#define IXGBE_FACTPS_MNGCG 0x20000000 /* Manageblility Clock Gated */ +#define IXGBE_FACTPS_MNGCG 0x20000000 /* Managebility Clock Gated */ #define IXGBE_FACTPS_LFS 0x40000000 /* LAN Function Select */ /* MHADD Bit Masks */ @@ -2334,7 +2334,7 @@ enum { /* EEPROM Addressing bits based on type (0-small, 1-large) */ #define IXGBE_EEC_ADDR_SIZE 0x00000400 #define IXGBE_EEC_SIZE 0x00007800 /* EEPROM Size */ -#define IXGBE_EERD_MAX_ADDR 0x00003FFF /* EERD alows 14 bits for addr. */ +#define IXGBE_EERD_MAX_ADDR 0x00003FFF /* EERD allows 14 bits for addr. */ #define IXGBE_EEC_SIZE_SHIFT 11 #define IXGBE_EEPROM_WORD_SIZE_SHIFT 6 From nobody Wed Nov 3 15:22: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 0650D1822385; Wed, 3 Nov 2021 15:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hkr9c6MJ0z4QmX; Wed, 3 Nov 2021 15:22:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABC8E1B06B; Wed, 3 Nov 2021 15:22:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3FMS57028092; Wed, 3 Nov 2021 15:22:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3FMSix028091; Wed, 3 Nov 2021 15:22:28 GMT (envelope-from git) Date: Wed, 3 Nov 2021 15:22:28 GMT Message-Id: <202111031522.1A3FMSix028091@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: a506133ac91d - main - mana: Fix a typo in a source code comment 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: a506133ac91da01e901cacae92133f68803bafe1 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=a506133ac91da01e901cacae92133f68803bafe1 commit a506133ac91da01e901cacae92133f68803bafe1 Author: Gordon Bergling AuthorDate: 2021-11-03 15:20:11 +0000 Commit: Gordon Bergling CommitDate: 2021-11-03 15:20:11 +0000 mana: Fix a typo in a source code comment - s/maxium/maximum/ MFC after: 1 week --- sys/dev/mana/mana_en.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c index 7ad69457afc2..e57a2622d09f 100644 --- a/sys/dev/mana/mana_en.c +++ b/sys/dev/mana/mana_en.c @@ -2164,7 +2164,7 @@ mana_create_rxq(struct mana_port_context *apc, uint32_t rxq_idx, rxq->rxq_idx = rxq_idx; /* * Minimum size is MCLBYTES(2048) bytes for a mbuf cluster. - * Now we just allow maxium size of 4096. + * Now we just allow maximum size of 4096. */ rxq->datasize = ALIGN(apc->frame_size, MCLBYTES); if (rxq->datasize > MAX_FRAME_SIZE) From nobody Wed Nov 3 15:22: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 92E9A1822390; Wed, 3 Nov 2021 15:22:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hkr9d6s4Lz4Qmk; Wed, 3 Nov 2021 15:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CA9EB1AFC0; Wed, 3 Nov 2021 15:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3FMTmv028116; Wed, 3 Nov 2021 15:22:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3FMTtt028115; Wed, 3 Nov 2021 15:22:29 GMT (envelope-from git) Date: Wed, 3 Nov 2021 15:22:29 GMT Message-Id: <202111031522.1A3FMTtt028115@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: bb91496a8517 - main - netinet: Fix a common typo 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: bb91496a85176cfc005cf141fe1262c9ad5507d4 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=bb91496a85176cfc005cf141fe1262c9ad5507d4 commit bb91496a85176cfc005cf141fe1262c9ad5507d4 Author: Gordon Bergling AuthorDate: 2021-11-03 15:21:49 +0000 Commit: Gordon Bergling CommitDate: 2021-11-03 15:21:49 +0000 netinet: Fix a common typo in source code comments - s/writting/writing/ MFC after: 3 days --- sys/netinet/sctputil.c | 4 ++-- sys/netinet/tcp_subr.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index cff22394dda3..9283b1288dae 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -7458,7 +7458,7 @@ sctp_over_udp_stop(void) { /* * This function assumes sysctl caller holds sctp_sysctl_info_lock() - * for writting! + * for writing! */ #ifdef INET if (SCTP_BASE_INFO(udp4_tun_socket) != NULL) { @@ -7487,7 +7487,7 @@ sctp_over_udp_start(void) #endif /* * This function assumes sysctl caller holds sctp_sysctl_info_lock() - * for writting! + * for writing! */ port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); if (ntohs(port) == 0) { diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index e12eb5682c14..2075c1d853c3 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -774,7 +774,7 @@ tcp_over_udp_stop(void) { /* * This function assumes sysctl caller holds inp_rinfo_lock() - * for writting! + * for writing! */ #ifdef INET if (V_udp4_tun_socket != NULL) { @@ -803,7 +803,7 @@ tcp_over_udp_start(void) #endif /* * This function assumes sysctl caller holds inp_info_rlock() - * for writting! + * for writing! */ port = V_tcp_udp_tunneling_port; if (ntohs(port) == 0) { From nobody Wed Nov 3 15:22: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 69B4D18228B0; Wed, 3 Nov 2021 15:22:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hkr9z1BKSz4RFr; Wed, 3 Nov 2021 15:22:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D69A41B3EF; Wed, 3 Nov 2021 15:22: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 1A3FMkZb028259; Wed, 3 Nov 2021 15:22:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3FMkce028258; Wed, 3 Nov 2021 15:22:46 GMT (envelope-from git) Date: Wed, 3 Nov 2021 15:22:46 GMT Message-Id: <202111031522.1A3FMkce028258@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: c75c1d2df9b3 - main - vmci: Avoid relying on macro expansion to provide correct syntax 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: c75c1d2df9b3839319f6b5e2fad0b757eebd9c55 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c75c1d2df9b3839319f6b5e2fad0b757eebd9c55 commit c75c1d2df9b3839319f6b5e2fad0b757eebd9c55 Author: Mark Johnston AuthorDate: 2021-11-03 15:19:53 +0000 Commit: Mark Johnston CommitDate: 2021-11-03 15:22:40 +0000 vmci: Avoid relying on macro expansion to provide correct syntax No functional change intended. MFC after: 3 days Sponsored by: The FreeBSD Foundation --- sys/dev/vmware/vmci/vmci_kernel_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/vmware/vmci/vmci_kernel_if.c b/sys/dev/vmware/vmci/vmci_kernel_if.c index de54a8d1ca4f..f66e63f56fc7 100644 --- a/sys/dev/vmware/vmci/vmci_kernel_if.c +++ b/sys/dev/vmware/vmci/vmci_kernel_if.c @@ -70,7 +70,7 @@ void vmci_cleanup_lock(vmci_lock *lock) { - if mtx_initialized(lock) + if (mtx_initialized(lock)) mtx_destroy(lock); } From nobody Wed Nov 3 15:30: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 D1DA6182866E; Wed, 3 Nov 2021 15:30: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 4HkrMD5dbyz4Wqj; Wed, 3 Nov 2021 15:30: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 A19F21B29C; Wed, 3 Nov 2021 15:30: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 1A3FUme0037457; Wed, 3 Nov 2021 15:30:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3FUmUp037456; Wed, 3 Nov 2021 15:30:48 GMT (envelope-from git) Date: Wed, 3 Nov 2021 15:30:48 GMT Message-Id: <202111031530.1A3FUmUp037456@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: 02de91d74023 - main - proc_get_binpath(): return empty string instead of NULL 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: 02de91d740235f186321d7d3e11d09737daba43e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=02de91d740235f186321d7d3e11d09737daba43e commit 02de91d740235f186321d7d3e11d09737daba43e Author: Konstantin Belousov AuthorDate: 2021-11-03 15:11:33 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-03 15:30:10 +0000 proc_get_binpath(): return empty string instead of NULL for strange case where queried process does not have text. Reported by: Michael Butler Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/kern/kern_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2156c5c465ba..d11f651960c0 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2252,7 +2252,7 @@ proc_get_binpath(struct proc *p, char *binname, char **retbuf, vp = p->p_textvp; if (vp == NULL) { PROC_UNLOCK(p); - *retbuf = NULL; + *retbuf = ""; *freebuf = NULL; return (0); } From nobody Wed Nov 3 16:02: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 4CC4718372A1; Wed, 3 Nov 2021 16:02: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 4Hks481ZVvz4hbv; Wed, 3 Nov 2021 16:02: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 15B571B1F0; Wed, 3 Nov 2021 16:02: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 1A3G2mH4082443; Wed, 3 Nov 2021 16:02:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3G2mu7082442; Wed, 3 Nov 2021 16:02:48 GMT (envelope-from git) Date: Wed, 3 Nov 2021 16:02:48 GMT Message-Id: <202111031602.1A3G2mu7082442@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: be10c0a91015 - main - fexecve(2): allow O_PATH file descriptors opened without O_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: be10c0a910155709dc4e521db3349d50e0440018 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=be10c0a910155709dc4e521db3349d50e0440018 commit be10c0a910155709dc4e521db3349d50e0440018 Author: Konstantin Belousov AuthorDate: 2021-11-03 12:51:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-03 16:00:42 +0000 fexecve(2): allow O_PATH file descriptors opened without O_EXEC This improves compatibility with Linux. Noted by: Drew DeVault Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32821 --- lib/libc/sys/open.2 | 3 --- sys/kern/kern_descrip.c | 5 +++-- sys/kern/kern_exec.c | 13 ++++++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index da42c238a151..f6b061079ddf 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -334,9 +334,6 @@ but advisory locking is not allowed .It Xr close 2 .It Xr fstat 2 .It Xr fexecve 2 -requires that -.Dv O_EXEC -was also specified at open time .It Dv SCM_RIGHTS can be passed over a .Xr unix 4 diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index a7e3785bc672..37d978e96de5 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3213,8 +3213,9 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags, error = EBADF; break; case FEXEC: - if ((fp->f_flag & (FREAD | FEXEC)) == 0 || - ((fp->f_flag & FWRITE) != 0)) + if (fp->f_ops != &path_fileops && + ((fp->f_flag & (FREAD | FEXEC)) == 0 || + (fp->f_flag & FWRITE) != 0)) error = EBADF; break; case 0: diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index c5b450b04240..575771346fd1 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -530,13 +530,20 @@ interpret: } } else { AUDIT_ARG_FD(args->fd); + /* - * Descriptors opened only with O_EXEC or O_RDONLY are allowed. + * If the descriptors was not opened with O_PATH, then + * we require that it was opened with O_EXEC or + * O_RDONLY. In either case, exec_check_permissions() + * below checks _current_ file access mode regardless + * of the permissions additionally checked at the + * open(2). */ error = fgetvp_exec(td, args->fd, &cap_fexecve_rights, &newtextvp); - if (error) + if (error != 0) goto exec_fail; + if (vn_fullpath(newtextvp, &imgp->execpath, &imgp->freepath) != 0) imgp->execpath = args->fname; @@ -881,7 +888,7 @@ interpret: /* * Store the vp for use in kern.proc.pathname. This vnode was - * referenced by namei() or fgetvp_exec(). + * referenced by namei() or by fexecve variant of fname handling. */ oldtextvp = p->p_textvp; p->p_textvp = newtextvp; From nobody Wed Nov 3 16:18: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 22D3E183ED4F; Wed, 3 Nov 2021 16:18: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 4HksPq0Vqtz4mRx; Wed, 3 Nov 2021 16:18: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 E0EBE1BE0F; Wed, 3 Nov 2021 16:18: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 1A3GI6fF096553; Wed, 3 Nov 2021 16:18:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3GI6J1096552; Wed, 3 Nov 2021 16:18:06 GMT (envelope-from git) Date: Wed, 3 Nov 2021 16:18:06 GMT Message-Id: <202111031618.1A3GI6J1096552@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: 9d2e51884ef2 - main - gjournal(8): Fix a typo in a source code comment 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: 9d2e51884ef286bab94d48d062cf71f6a74a3f99 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=9d2e51884ef286bab94d48d062cf71f6a74a3f99 commit 9d2e51884ef286bab94d48d062cf71f6a74a3f99 Author: Gordon Bergling AuthorDate: 2021-11-03 16:14:00 +0000 Commit: Gordon Bergling CommitDate: 2021-11-03 16:14:00 +0000 gjournal(8): Fix a typo in a source code comment - s/writting/writing/ MFC after: 3 days --- sys/geom/journal/g_journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 97516ed293e7..e57d58d6f7ca 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -2445,7 +2445,7 @@ g_journal_destroy(struct g_journal_softc *sc) if (cp->acr + cp->acw + cp->ace > 0) g_access(cp, -1, -1, -1); /* - * We keep all consumers open for writting, so if I'll detach + * We keep all consumers open for writing, so if I'll detach * and destroy consumer here, I'll get providers for taste, so * journal will be started again. * Sending an event here, prevents this from happening. From nobody Wed Nov 3 16:18: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 D9549183F091; Wed, 3 Nov 2021 16:18:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HksPr13R6z4mjP; Wed, 3 Nov 2021 16:18: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 0273E1BCDE; Wed, 3 Nov 2021 16:18: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 1A3GI7dc096577; Wed, 3 Nov 2021 16:18:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3GI79b096576; Wed, 3 Nov 2021 16:18:07 GMT (envelope-from git) Date: Wed, 3 Nov 2021 16:18:07 GMT Message-Id: <202111031618.1A3GI79b096576@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: 40a57b00f9a7 - main - ng_pptpgre(4): Fix a typo in a source code comment 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: 40a57b00f9a76f32a271d258acec4075966eec32 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=40a57b00f9a76f32a271d258acec4075966eec32 commit 40a57b00f9a76f32a271d258acec4075966eec32 Author: Gordon Bergling AuthorDate: 2021-11-03 16:15:59 +0000 Commit: Gordon Bergling CommitDate: 2021-11-03 16:15:59 +0000 ng_pptpgre(4): Fix a typo in a source code comment - s/mimimum/minimum/ MFC after: 3 days --- sys/netgraph/ng_pptpgre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netgraph/ng_pptpgre.c b/sys/netgraph/ng_pptpgre.c index 4c3ccebd560f..f6d8a89b9fa3 100644 --- a/sys/netgraph/ng_pptpgre.c +++ b/sys/netgraph/ng_pptpgre.c @@ -128,7 +128,7 @@ typedef u_int64_t pptptime_t; #define PPTP_REORDER_TIMEOUT 1 /* When we receive a packet, we wait to see if there's an outgoing packet - we can piggy-back the ACK off of. These parameters determine the mimimum + we can piggy-back the ACK off of. These parameters determine the minimum and maxmimum length of time we're willing to wait in order to do that. These have no effect unless "enableDelayedAck" is turned on. */ #define PPTP_MIN_ACK_DELAY (PPTP_TIME_SCALE / 500) /* 2 milliseconds */ From nobody Wed Nov 3 16:18: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 EE4E0183ED63; Wed, 3 Nov 2021 16:18: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 4HksPs4mkBz4mSC; Wed, 3 Nov 2021 16:18: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 273D11BAF4; Wed, 3 Nov 2021 16:18: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 1A3GI9kB096601; Wed, 3 Nov 2021 16:18:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3GI9Si096600; Wed, 3 Nov 2021 16:18:09 GMT (envelope-from git) Date: Wed, 3 Nov 2021 16:18:09 GMT Message-Id: <202111031618.1A3GI9Si096600@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: 7b56cb0462c3 - main - ocs_fs: Fix two 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: 7b56cb0462c39cb190fc23e0e1190bdc89c163c8 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=7b56cb0462c39cb190fc23e0e1190bdc89c163c8 commit 7b56cb0462c39cb190fc23e0e1190bdc89c163c8 Author: Gordon Bergling AuthorDate: 2021-11-03 16:17:51 +0000 Commit: Gordon Bergling CommitDate: 2021-11-03 16:17:51 +0000 ocs_fs: Fix two typos in source code comments - s/maxium/maximum/ - s/maxiumum/maximum/ MFC after: 3 days --- sys/dev/ocs_fc/ocs_os.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/ocs_fc/ocs_os.h b/sys/dev/ocs_fc/ocs_os.h index ae10b00cb465..a4efd0186984 100644 --- a/sys/dev/ocs_fc/ocs_os.h +++ b/sys/dev/ocs_fc/ocs_os.h @@ -100,7 +100,7 @@ #define OCS_RSVD_INI_IO 8 #define OCS_MIN_DMA_ALIGNMENT 16 -#define OCS_MAX_DMA_ALLOC (64*1024) /* maxium DMA allocation that is expected to reliably succeed */ +#define OCS_MAX_DMA_ALLOC (64*1024) /* maximum DMA allocation that is expected to reliably succeed */ /* * Macros used to size the CQ hash table. We want to round up to the next @@ -465,7 +465,7 @@ typedef struct ocs_dma_s { * Return maximum supported DMA allocation size, given alignment * requirement. * - * @return maxiumum supported DMA allocation size + * @return maximum supported DMA allocation size */ static inline uint32_t ocs_max_dma_alloc(ocs_os_handle_t os, size_t align) { From nobody Wed Nov 3 16:36: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 2CAF11831694; Wed, 3 Nov 2021 16:36:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HksqM0gh4z4tw9; Wed, 3 Nov 2021 16:36:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EB6CC1BDBE; Wed, 3 Nov 2021 16:36: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 1A3GakMT023014; Wed, 3 Nov 2021 16:36:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3GakDL023013; Wed, 3 Nov 2021 16:36:46 GMT (envelope-from git) Date: Wed, 3 Nov 2021 16:36:46 GMT Message-Id: <202111031636.1A3GakDL023013@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: 175d3380a367 - main - amd64: Deduplicate routines for expanding KASAN/KMSAN shadow maps 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: 175d3380a367954a5825ba7078f3bc948e9aca39 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=175d3380a367954a5825ba7078f3bc948e9aca39 commit 175d3380a367954a5825ba7078f3bc948e9aca39 Author: Mark Johnston AuthorDate: 2021-11-03 16:28:08 +0000 Commit: Mark Johnston CommitDate: 2021-11-03 16:36:02 +0000 amd64: Deduplicate routines for expanding KASAN/KMSAN shadow maps When working on the ports these functions were slightly different, but now there's no reason for them to be separate. No functional change intended. MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/amd64/amd64/pmap.c | 83 ++++++------------------------------------------ sys/amd64/include/pmap.h | 7 ++-- sys/kern/subr_asan.c | 2 +- sys/kern/subr_msan.c | 4 +-- 4 files changed, 15 insertions(+), 81 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 8526cc3031d2..3f1125cfc79f 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -11424,9 +11424,9 @@ pmap_pkru_clear(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) return (error); } -#ifdef KASAN +#if defined(KASAN) || defined(KMSAN) static vm_page_t -pmap_kasan_enter_alloc_4k(void) +pmap_san_enter_alloc_4k(void) { vm_page_t m; @@ -11438,81 +11438,18 @@ pmap_kasan_enter_alloc_4k(void) } static vm_page_t -pmap_kasan_enter_alloc_2m(void) +pmap_san_enter_alloc_2m(void) { return (vm_page_alloc_noobj_contig(VM_ALLOC_WIRED | VM_ALLOC_ZERO, NPTEPG, 0, ~0ul, NBPDR, 0, VM_MEMATTR_DEFAULT)); } /* - * Grow the shadow map by at least one 4KB page at the specified address. Use - * 2MB pages when possible. - */ -void -pmap_kasan_enter(vm_offset_t va) -{ - pdp_entry_t *pdpe; - pd_entry_t *pde; - pt_entry_t *pte; - vm_page_t m; - - mtx_assert(&kernel_map->system_mtx, MA_OWNED); - - pdpe = pmap_pdpe(kernel_pmap, va); - if ((*pdpe & X86_PG_V) == 0) { - m = pmap_kasan_enter_alloc_4k(); - *pdpe = (pdp_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | - X86_PG_V | pg_nx); - } - pde = pmap_pdpe_to_pde(pdpe, va); - if ((*pde & X86_PG_V) == 0) { - m = pmap_kasan_enter_alloc_2m(); - if (m != NULL) { - *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | - X86_PG_PS | X86_PG_V | X86_PG_A | X86_PG_M | pg_nx); - } else { - m = pmap_kasan_enter_alloc_4k(); - *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | - X86_PG_V | pg_nx); - } - } - if ((*pde & X86_PG_PS) != 0) - return; - pte = pmap_pde_to_pte(pde, va); - if ((*pte & X86_PG_V) != 0) - return; - m = pmap_kasan_enter_alloc_4k(); - *pte = (pt_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_V | - X86_PG_M | X86_PG_A | pg_nx); -} -#endif - -#ifdef KMSAN -static vm_page_t -pmap_kmsan_enter_alloc_4k(void) -{ - vm_page_t m; - - m = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED | - VM_ALLOC_ZERO); - if (m == NULL) - panic("%s: no memory to grow shadow map", __func__); - return (m); -} - -static vm_page_t -pmap_kmsan_enter_alloc_2m(void) -{ - return (vm_page_alloc_noobj_contig(VM_ALLOC_ZERO | VM_ALLOC_WIRED, - NPTEPG, 0, ~0ul, NBPDR, 0, VM_MEMATTR_DEFAULT)); -} - -/* - * Grow the shadow or origin maps by at least one 4KB page at the specified - * address. Use 2MB pages when possible. + * Grow a shadow map by at least one 4KB page at the specified address. Use 2MB + * pages when possible. */ void -pmap_kmsan_enter(vm_offset_t va) +pmap_san_enter(vm_offset_t va) { pdp_entry_t *pdpe; pd_entry_t *pde; @@ -11523,18 +11460,18 @@ pmap_kmsan_enter(vm_offset_t va) pdpe = pmap_pdpe(kernel_pmap, va); if ((*pdpe & X86_PG_V) == 0) { - m = pmap_kmsan_enter_alloc_4k(); + m = pmap_san_enter_alloc_4k(); *pdpe = (pdp_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_V | pg_nx); } pde = pmap_pdpe_to_pde(pdpe, va); if ((*pde & X86_PG_V) == 0) { - m = pmap_kmsan_enter_alloc_2m(); + m = pmap_san_enter_alloc_2m(); if (m != NULL) { *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_PS | X86_PG_V | X86_PG_A | X86_PG_M | pg_nx); } else { - m = pmap_kmsan_enter_alloc_4k(); + m = pmap_san_enter_alloc_4k(); *pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_V | pg_nx); } @@ -11544,7 +11481,7 @@ pmap_kmsan_enter(vm_offset_t va) pte = pmap_pde_to_pte(pde, va); if ((*pte & X86_PG_V) != 0) return; - m = pmap_kmsan_enter_alloc_4k(); + m = pmap_san_enter_alloc_4k(); *pte = (pt_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_V | X86_PG_M | X86_PG_A | pg_nx); } diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index bd6a8c006813..1e63ffb68099 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -528,11 +528,8 @@ int pmap_vmspace_copy(pmap_t dst_pmap, pmap_t src_pmap); void pmap_page_array_startup(long count); vm_page_t pmap_page_alloc_below_4g(bool zeroed); -#ifdef KASAN -void pmap_kasan_enter(vm_offset_t); -#endif -#ifdef KMSAN -void pmap_kmsan_enter(vm_offset_t); +#if defined(KASAN) || defined(KMSAN) +void pmap_san_enter(vm_offset_t); #endif #endif /* _KERNEL */ diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c index 5441d7be39a1..19496346ce7e 100644 --- a/sys/kern/subr_asan.c +++ b/sys/kern/subr_asan.c @@ -119,7 +119,7 @@ kasan_shadow_map(vm_offset_t addr, size_t size) ("%s: invalid address range %#lx-%#lx", __func__, sva, eva)); for (i = 0; i < npages; i++) - pmap_kasan_enter(sva + ptoa(i)); + pmap_san_enter(sva + ptoa(i)); } void diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c index 81322da2be6c..10ccc842012a 100644 --- a/sys/kern/subr_msan.c +++ b/sys/kern/subr_msan.c @@ -525,12 +525,12 @@ kmsan_shadow_map(vm_offset_t addr, size_t size) va = kmsan_md_addr_to_shad(addr); for (i = 0; i < npages; i++) { - pmap_kmsan_enter(va + ptoa(i)); + pmap_san_enter(va + ptoa(i)); } va = kmsan_md_addr_to_orig(addr); for (i = 0; i < npages; i++) { - pmap_kmsan_enter(va + ptoa(i)); + pmap_san_enter(va + ptoa(i)); } } From nobody Wed Nov 3 16:36: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 6290618315AF; Wed, 3 Nov 2021 16:36: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 4HksqN1sxqz4tqH; Wed, 3 Nov 2021 16:36: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 1D4771C11E; Wed, 3 Nov 2021 16:36: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 1A3GamPb023038; Wed, 3 Nov 2021 16:36:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3Gale1023037; Wed, 3 Nov 2021 16:36:47 GMT (envelope-from git) Date: Wed, 3 Nov 2021 16:36:47 GMT Message-Id: <202111031636.1A3Gale1023037@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: 2a519c3b14c2 - main - kasan: Disable validation of function parameters passed by value 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: 2a519c3b14c29688e42d11f916655318b13c8409 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2a519c3b14c29688e42d11f916655318b13c8409 commit 2a519c3b14c29688e42d11f916655318b13c8409 Author: Mark Johnston AuthorDate: 2021-11-03 16:28:48 +0000 Commit: Mark Johnston CommitDate: 2021-11-03 16:36:02 +0000 kasan: Disable validation of function parameters passed by value It appears that the emitted code in the caller does not update shadow state for values passed on the stack to the callee, which it seemingly ought to do after pushing values on the stack and prior to the call itself. This leaves open a window where an interrupt handler can cause regions of the stack containing these values to be poisoned, resulting in rare false positive reports. This happens particularly in the amd64 TLB invalidation code, where we liberally pass cpuset_t's around by value. LLVM has a flag to disable validation of accesses of function parameters passed by value. Such validation is itself a relatively new feature. Turn it off for now. Reported by: pho, syzkaller MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- sys/conf/kern.pre.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index 9d9e32027ec7..056963adcb2d 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -100,7 +100,8 @@ SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kasan \ -mllvm -asan-instrument-dynamic-allocas=true \ -mllvm -asan-globals=true \ -mllvm -asan-use-after-scope=true \ - -mllvm -asan-instrumentation-with-call-threshold=0 + -mllvm -asan-instrumentation-with-call-threshold=0 \ + -mllvm -asan-instrument-byval=false .endif KCSAN_ENABLED!= grep KCSAN opt_global.h || true ; echo From nobody Wed Nov 3 17:31: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 73190184A129; Wed, 3 Nov 2021 17:31: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 4Hkv312dKpz3j3q; Wed, 3 Nov 2021 17:31: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 3ABB91C8E4; Wed, 3 Nov 2021 17:31: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 1A3HVvZn002034; Wed, 3 Nov 2021 17:31:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3HVvva002033; Wed, 3 Nov 2021 17:31:57 GMT (envelope-from git) Date: Wed, 3 Nov 2021 17:31:57 GMT Message-Id: <202111031731.1A3HVvva002033@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: b788a226f6a2 - main - Document net.inet.tcp.nolocaltimewait enabled. 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: b788a226f6a274f9cb31014468700d0103974c07 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=b788a226f6a274f9cb31014468700d0103974c07 commit b788a226f6a274f9cb31014468700d0103974c07 Author: Gleb Smirnoff AuthorDate: 2021-11-03 17:31:44 +0000 Commit: Gleb Smirnoff CommitDate: 2021-11-03 17:31:44 +0000 Document net.inet.tcp.nolocaltimewait enabled. --- RELNOTES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELNOTES b/RELNOTES index 0c6c1c2f4ffc..d56e86623fa2 100644 --- a/RELNOTES +++ b/RELNOTES @@ -10,6 +10,11 @@ newline. Entries should be separated by a newline. Changes to this file should not be MFCed. +92b3e07229ba: + net.inet.tcp.nolocaltimewait enabled by default. It prevents + creation of timewait entries for TCP connections that were + terminated locally. + d410b585b6f0: sh(1) is now the default shell for the root user. From nobody Wed Nov 3 17:45: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 9916118205BA; Wed, 3 Nov 2021 17:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HkvLc417cz3n8m; Wed, 3 Nov 2021 17:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5B4341CD53; Wed, 3 Nov 2021 17:45:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3HjSw6016392; Wed, 3 Nov 2021 17:45:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3HjSi8016391; Wed, 3 Nov 2021 17:45:28 GMT (envelope-from git) Date: Wed, 3 Nov 2021 17:45:28 GMT Message-Id: <202111031745.1A3HjSi8016391@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: 3358df297325 - main - udp_input: remove a BSD stack relict 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: 3358df2973251b4de690f197640eca5d794e0194 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=3358df2973251b4de690f197640eca5d794e0194 commit 3358df2973251b4de690f197640eca5d794e0194 Author: Gleb Smirnoff AuthorDate: 2021-10-28 07:07:02 +0000 Commit: Gleb Smirnoff CommitDate: 2021-11-03 17:39:34 +0000 udp_input: remove a BSD stack relict I should had removed it 9 years ago in 8ad458a471ca. That commit left save_ip as a write-only variable. With save_ip removed we got one case when IP header can be modified: the calculation of IP checksum with zeroed out header. This place already has had a header saver char b[9]. However, the b[9] saver didn't cover the ip_sum field, which we explicitly overwrite aliased as (struct ipovly *)->ih_len. This was fine in cb34210012d4e, since checksum doesn't need to be restored if packet is consumed. Now we need to extend up to ip_sum field. In collaboration with: ae Differential revision: https://reviews.freebsd.org/D32719 --- sys/netinet/udp_usrreq.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 46d687690713..7c5a642da040 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -398,7 +398,6 @@ udp_input(struct mbuf **mp, int *offp, int proto) struct inpcb *inp; uint16_t len, ip_len; struct inpcbinfo *pcbinfo; - struct ip save_ip; struct sockaddr_in udp_in[2]; struct mbuf *m; struct m_tag *fwd_tag; @@ -474,15 +473,6 @@ udp_input(struct mbuf **mp, int *offp, int proto) m_adj(m, len - ip_len); } - /* - * Save a copy of the IP header in case we want restore it for - * sending an ICMP error message in response. - */ - if (!V_udp_blackhole) - save_ip = *ip; - else - memset(&save_ip, 0, sizeof(save_ip)); - /* * Checksum extended UDP header and data. */ @@ -499,14 +489,15 @@ udp_input(struct mbuf **mp, int *offp, int proto) m->m_pkthdr.csum_data + proto)); uh_sum ^= 0xffff; } else { - char b[9]; + char b[offsetof(struct ipovly, ih_src)]; + struct ipovly *ipov = (struct ipovly *)ip; - bcopy(((struct ipovly *)ip)->ih_x1, b, 9); - bzero(((struct ipovly *)ip)->ih_x1, 9); - ((struct ipovly *)ip)->ih_len = (proto == IPPROTO_UDP) ? + bcopy(ipov, b, sizeof(b)); + bzero(ipov, sizeof(ipov->ih_x1)); + ipov->ih_len = (proto == IPPROTO_UDP) ? uh->uh_ulen : htons(ip_len); uh_sum = in_cksum(m, len + sizeof (struct ip)); - bcopy(b, ((struct ipovly *)ip)->ih_x1, 9); + bcopy(b, ipov, sizeof(b)); } if (uh_sum) { UDPSTAT_INC(udps_badsum); @@ -714,7 +705,6 @@ udp_input(struct mbuf **mp, int *offp, int proto) goto badunlocked; if (badport_bandlim(BANDLIM_ICMP_UNREACH) < 0) goto badunlocked; - *ip = save_ip; icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); return (IPPROTO_DONE); } From nobody Wed Nov 3 19:11: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 202341832A9F; Wed, 3 Nov 2021 19:11: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 4HkxG70SMxz4lBs; Wed, 3 Nov 2021 19:11: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 E3C7D1E2EF; Wed, 3 Nov 2021 19:11: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 1A3JBgZq033169; Wed, 3 Nov 2021 19:11:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3JBgYC033168; Wed, 3 Nov 2021 19:11:42 GMT (envelope-from git) Date: Wed, 3 Nov 2021 19:11:42 GMT Message-Id: <202111031911.1A3JBgYC033168@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: 6afabf00920f - main - scsi_cd: Improve TOC access validation 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: 6afabf00920fb8d41b8f013090f282c17c117efc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6afabf00920fb8d41b8f013090f282c17c117efc commit 6afabf00920fb8d41b8f013090f282c17c117efc Author: Mark Johnston AuthorDate: 2021-11-03 19:09:17 +0000 Commit: Mark Johnston CommitDate: 2021-11-03 19:09:17 +0000 scsi_cd: Improve TOC access validation 1. During CD probing, we read the TOC header to find the number of entries, then read the TOC itself. The header determines the number of entries, which determines the amount of data to read from the device into the softc in the CD_STATE_MEDIA_TOC_FULL state. We hard-code a limit of 99 tracks (plus one for the lead-out) in the softc, but were not validating that the size reported by the media would fit in this hard-coded limit. Kernel memory corruption could occur if not.[1] Add validation to check this, and refuse to cache the TOC if it would not fit. 2. The CDIOCPLAYTRACKS ioctl uses caller provided track numbers to index into the TOC, but we only validate the starting index. Add validation of the ending index. Also, raise the hard-coded limit from 100 tracks to 170, per a suggestion from Ken. Reported by: C Turt [1] Reviewed by: ken, avg MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32803 --- sys/cam/scsi/scsi_cd.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 3e8187544bff..3cca4bbf243b 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -136,9 +136,13 @@ typedef enum { #define ccb_state ppriv_field0 #define ccb_bp ppriv_ptr1 +/* + * According to the MMC-6 spec, 6.25.3.2.11, the lead-out is reported by + * READ_TOC as logical track 170, so at most 169 tracks may be reported. + */ struct cd_tocdata { struct ioc_toc_header header; - struct cd_toc_entry entries[100]; + struct cd_toc_entry entries[170]; }; struct cd_toc_single { @@ -1596,12 +1600,13 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) } /* Number of TOC entries, plus leadout */ - num_entries = (toch->ending_track - toch->starting_track) + 2; - cdindex = toch->starting_track + num_entries -1; + num_entries = toch->ending_track - toch->starting_track + 2; + cdindex = toch->starting_track + num_entries - 1; if ((done_ccb->ccb_h.ccb_state & CD_CCB_TYPE_MASK) == CD_CCB_MEDIA_TOC_HDR) { - if (num_entries <= 0) { + if (num_entries <= 0 || + num_entries > nitems(softc->toc.entries)) { softc->flags &= ~CD_FLAG_VALID_TOC; bzero(&softc->toc, sizeof(softc->toc)); /* @@ -1838,23 +1843,19 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) */ if (softc->flags & CD_FLAG_VALID_TOC) { union msf_lba *sentry, *eentry; + struct ioc_toc_header *th; int st, et; - if (args->end_track < - softc->toc.header.ending_track + 1) + th = &softc->toc.header; + if (args->end_track < th->ending_track + 1) args->end_track++; - if (args->end_track > - softc->toc.header.ending_track + 1) - args->end_track = - softc->toc.header.ending_track + 1; - st = args->start_track - - softc->toc.header.starting_track; - et = args->end_track - - softc->toc.header.starting_track; - if ((st < 0) - || (et < 0) - || (st > (softc->toc.header.ending_track - - softc->toc.header.starting_track))) { + if (args->end_track > th->ending_track + 1) + args->end_track = th->ending_track + 1; + st = args->start_track - th->starting_track; + et = args->end_track - th->starting_track; + if (st < 0 || et < 0 || + st > th->ending_track - th->starting_track || + et > th->ending_track - th->starting_track) { error = EINVAL; cam_periph_unlock(periph); break; From nobody Wed Nov 3 19:19: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 5DD0E183626F; Wed, 3 Nov 2021 19:19: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 4HkxR529b3z4n44; Wed, 3 Nov 2021 19:19: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 2683E1E3E8; Wed, 3 Nov 2021 19:19: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 1A3JJTcF038477; Wed, 3 Nov 2021 19:19:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3JJT98038476; Wed, 3 Nov 2021 19:19:29 GMT (envelope-from git) Date: Wed, 3 Nov 2021 19:19:29 GMT Message-Id: <202111031919.1A3JJT98038476@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: 441222585968 - main - nfscl: Fix use after free for forced dismount 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: 441222585968517c595ef7f39e5c71a42d238acd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=441222585968517c595ef7f39e5c71a42d238acd commit 441222585968517c595ef7f39e5c71a42d238acd Author: Rick Macklem AuthorDate: 2021-11-03 19:15:40 +0000 Commit: Rick Macklem CommitDate: 2021-11-03 19:15:40 +0000 nfscl: Fix use after free for forced dismount When a forced dismount is done and delegations are being issued by the server (disabled by default for FreeBSD servers), the delegation structure is free'd before the loop calling vflush(). This could result in a use after free of the delegation structure. This patch changes the code so that the delegation structures are not free'd until after the vflush() loop for forced dismounts. Found during a recent IETF NFSv4 working group testing event. MFC after: 2 weeks --- sys/fs/nfs/nfs_var.h | 2 +- sys/fs/nfsclient/nfs_clstate.c | 16 +++++++++++----- sys/fs/nfsclient/nfs_clvfsops.c | 13 +++++++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 7f0ca990540d..7e4136a6ff67 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -596,7 +596,7 @@ void nfscl_lockrelease(struct nfscllockowner *, int, int); void nfscl_fillclid(u_int64_t, char *, u_int8_t *, u_int16_t); void nfscl_filllockowner(void *, u_int8_t *, int); void nfscl_freeopen(struct nfsclopen *, int, bool); -void nfscl_umount(struct nfsmount *, NFSPROC_T *); +void nfscl_umount(struct nfsmount *, NFSPROC_T *, struct nfscldeleghead *); void nfscl_renewthread(struct nfsclclient *, NFSPROC_T *); void nfscl_initiate_recovery(struct nfsclclient *); int nfscl_hasexpired(struct nfsclclient *, u_int32_t, NFSPROC_T *); diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 22c0da1bcef8..42233ea7cf9d 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -119,7 +119,8 @@ static void nfscl_insertlock(struct nfscllockowner *, struct nfscllock *, struct nfscllock *, int); static int nfscl_updatelock(struct nfscllockowner *, struct nfscllock **, struct nfscllock **, int); -static void nfscl_delegreturnall(struct nfsclclient *, NFSPROC_T *); +static void nfscl_delegreturnall(struct nfsclclient *, NFSPROC_T *, + struct nfscldeleghead *); static u_int32_t nfscl_nextcbident(void); static mount_t nfscl_getmnt(int, uint8_t *, u_int32_t, struct nfsclclient **); static struct nfsclclient *nfscl_getclnt(u_int32_t); @@ -1985,7 +1986,7 @@ static int fake_global; /* Used to force visibility of MNTK_UNMOUNTF */ * Called from nfs umount to free up the clientid. */ void -nfscl_umount(struct nfsmount *nmp, NFSPROC_T *p) +nfscl_umount(struct nfsmount *nmp, NFSPROC_T *p, struct nfscldeleghead *dhp) { struct nfsclclient *clp; struct ucred *cred; @@ -2047,7 +2048,7 @@ nfscl_umount(struct nfsmount *nmp, NFSPROC_T *p) * the server throws it away? */ LIST_REMOVE(clp, nfsc_list); - nfscl_delegreturnall(clp, p); + nfscl_delegreturnall(clp, p, dhp); cred = newnfs_getcred(); if (NFSHASNFSV4N(nmp)) { (void)nfsrpc_destroysession(nmp, clp, cred, p); @@ -3438,7 +3439,8 @@ lookformore: * (Must be called with client sleep lock.) */ static void -nfscl_delegreturnall(struct nfsclclient *clp, NFSPROC_T *p) +nfscl_delegreturnall(struct nfsclclient *clp, NFSPROC_T *p, + struct nfscldeleghead *dhp) { struct nfscldeleg *dp, *ndp; struct ucred *cred; @@ -3447,7 +3449,11 @@ nfscl_delegreturnall(struct nfsclclient *clp, NFSPROC_T *p) TAILQ_FOREACH_SAFE(dp, &clp->nfsc_deleg, nfsdl_list, ndp) { nfscl_cleandeleg(dp); (void) nfscl_trydelegreturn(dp, cred, clp->nfsc_nmp, p); - nfscl_freedeleg(&clp->nfsc_deleg, dp, true); + if (dhp != NULL) { + nfscl_freedeleg(&clp->nfsc_deleg, dp, false); + TAILQ_INSERT_HEAD(dhp, dp, nfsdl_list); + } else + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } NFSFREECRED(cred); } diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index d5d9bb395c79..330279b9ef4d 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -1767,8 +1767,11 @@ nfs_unmount(struct mount *mp, int mntflags) struct nfsmount *nmp; int error, flags = 0, i, trycnt = 0; struct nfsclds *dsp, *tdsp; + struct nfscldeleg *dp, *ndp; + struct nfscldeleghead dh; td = curthread; + TAILQ_INIT(&dh); if (mntflags & MNT_FORCE) flags |= FORCECLOSE; @@ -1792,7 +1795,7 @@ nfs_unmount(struct mount *mp, int mntflags) if (error) goto out; /* For a forced close, get rid of the renew thread now */ - nfscl_umount(nmp, td); + nfscl_umount(nmp, td, &dh); } /* We hold 1 extra ref on the root vnode; see comment in mountnfs(). */ do { @@ -1807,7 +1810,7 @@ nfs_unmount(struct mount *mp, int mntflags) * We are now committed to the unmount. */ if ((mntflags & MNT_FORCE) == 0) - nfscl_umount(nmp, td); + nfscl_umount(nmp, td, NULL); else { mtx_lock(&nmp->nm_mtx); nmp->nm_privflag |= NFSMNTP_FORCEDISM; @@ -1849,6 +1852,12 @@ nfs_unmount(struct mount *mp, int mntflags) } free(nmp->nm_tlscertname, M_NEWNFSMNT); free(nmp, M_NEWNFSMNT); + + /* Free up the delegation structures for forced dismounts. */ + TAILQ_FOREACH_SAFE(dp, &dh, nfsdl_list, ndp) { + TAILQ_REMOVE(&dh, dp, nfsdl_list); + free(dp, M_NFSCLDELEG); + } out: return (error); } From nobody Wed Nov 3 19:50: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 A1CFE18455B1; Wed, 3 Nov 2021 19:50: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 4Hky7N4FT6z3Cpw; Wed, 3 Nov 2021 19:50: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 739141EABC; Wed, 3 Nov 2021 19:50: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 1A3JouUU087193; Wed, 3 Nov 2021 19:50:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3JouD2087192; Wed, 3 Nov 2021 19:50:56 GMT (envelope-from git) Date: Wed, 3 Nov 2021 19:50:56 GMT Message-Id: <202111031950.1A3JouD2087192@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: c28e39c3d6d1 - main - Fix a common typo in syctl descriptions 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: c28e39c3d6d10a72800b7f49c23453fcc1bca8cc 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=c28e39c3d6d10a72800b7f49c23453fcc1bca8cc commit c28e39c3d6d10a72800b7f49c23453fcc1bca8cc Author: Gordon Bergling AuthorDate: 2021-11-03 19:49:24 +0000 Commit: Gordon Bergling CommitDate: 2021-11-03 19:49:24 +0000 Fix a common typo in syctl descriptions - s/maxiumum/maximum/ MFC after: 3 days --- sys/netinet/tcp_stacks/bbr.c | 2 +- sys/netinet/tcp_stacks/rack.c | 2 +- sys/vm/vm_glue.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 41f441da99a1..718f4ddc2a56 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -1666,7 +1666,7 @@ bbr_init_sysctls(void) SYSCTL_CHILDREN(bbr_timeout), OID_AUTO, "maxrto", CTLFLAG_RW, &bbr_rto_max_sec, 4, - "Maxiumum RTO in seconds -- should be at least as large as min_rto"); + "Maximum RTO in seconds -- should be at least as large as min_rto"); SYSCTL_ADD_S32(&bbr_sysctl_ctx, SYSCTL_CHILDREN(bbr_timeout), OID_AUTO, "tlp_retry", CTLFLAG_RW, diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 616e079df60c..3d065ef14c86 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -1316,7 +1316,7 @@ rack_init_sysctls(void) SYSCTL_CHILDREN(rack_timers), OID_AUTO, "maxrto", CTLFLAG_RW, &rack_rto_max, 4000000, - "Maxiumum RTO in microseconds -- should be at least as large as min_rto"); + "Maximum RTO in microseconds -- should be at least as large as min_rto"); SYSCTL_ADD_S32(&rack_sysctl_ctx, SYSCTL_CHILDREN(rack_timers), OID_AUTO, "minto", CTLFLAG_RW, diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 5e118a7ad86e..e2f8f861b373 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -494,7 +494,7 @@ static int max_kstack_used; SYSCTL_INT(_debug, OID_AUTO, max_kstack_used, CTLFLAG_RD, &max_kstack_used, 0, - "Maxiumum stack depth used by a thread in kernel"); + "Maximum stack depth used by a thread in kernel"); void intr_prof_stack_use(struct thread *td, struct trapframe *frame) From nobody Wed Nov 3 19:51: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 28DAD1845ADB; Wed, 3 Nov 2021 19:51: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 4Hky8K0VDYz3DB9; Wed, 3 Nov 2021 19:51: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 DA8191E84D; Wed, 3 Nov 2021 19:51: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 1A3JpiXc089748; Wed, 3 Nov 2021 19:51:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3JpiNU089747; Wed, 3 Nov 2021 19:51:44 GMT (envelope-from git) Date: Wed, 3 Nov 2021 19:51:44 GMT Message-Id: <202111031951.1A3JpiNU089747@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: 626bd0970abf - main - ipsec: fix edge case detection in key_do_getnewspi 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: 626bd0970abfdfba596bced3bc8a47adaf11a46d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=626bd0970abfdfba596bced3bc8a47adaf11a46d commit 626bd0970abfdfba596bced3bc8a47adaf11a46d Author: Mateusz Guzik AuthorDate: 2021-11-03 14:00:53 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-03 19:51:40 +0000 ipsec: fix edge case detection in key_do_getnewspi The 'count' variable would end up being -1 post loop, while the following condition would check for 0 instead. PR: 258849 Reported by: Herbie.Robinson@stratus.com Reviewed by: ae Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32826 --- sys/netipsec/key.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 72c598586d8e..48de29305b3c 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -5019,7 +5019,7 @@ static uint32_t key_do_getnewspi(struct sadb_spirange *spirange, struct secasindex *saidx) { uint32_t min, max, newspi, t; - int count = V_key_spi_trycnt; + int tries, limit; /* set spi range to allocate */ if (spirange != NULL) { @@ -5047,21 +5047,22 @@ key_do_getnewspi(struct sadb_spirange *spirange, struct secasindex *saidx) return 0; } - count--; /* taking one cost. */ + tries = 1; newspi = min; } else { /* init SPI */ newspi = 0; + limit = atomic_load_int(&V_key_spi_trycnt); /* when requesting to allocate spi ranged */ - while (count--) { + for (tries = 0; tries < limit; tries++) { /* generate pseudo-random SPI value ranged. */ newspi = min + (key_random() % (max - min + 1)); if (!key_checkspidup(htonl(newspi))) break; } - if (count == 0 || newspi == 0) { + if (tries == limit || newspi == 0) { ipseclog((LOG_DEBUG, "%s: failed to allocate SPI.\n", __func__)); return 0; @@ -5070,7 +5071,7 @@ key_do_getnewspi(struct sadb_spirange *spirange, struct secasindex *saidx) /* statistics */ keystat.getspi_count = - (keystat.getspi_count + V_key_spi_trycnt - count) / 2; + (keystat.getspi_count + tries) / 2; return (htonl(newspi)); } From nobody Wed Nov 3 19:51: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 6C69E1845C97; Wed, 3 Nov 2021 19:51: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 4Hky8L1xj6z3DMh; Wed, 3 Nov 2021 19:51: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 0A69B1E55E; Wed, 3 Nov 2021 19:51: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 1A3JpjCs089775; Wed, 3 Nov 2021 19:51:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3JpjSC089774; Wed, 3 Nov 2021 19:51:45 GMT (envelope-from git) Date: Wed, 3 Nov 2021 19:51:45 GMT Message-Id: <202111031951.1A3JpjSC089774@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: 10ea195fa269 - main - ipsec: add a lock encompassing SPI allocation 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: 10ea195fa269888d362f548279f3d3fa252662d7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=10ea195fa269888d362f548279f3d3fa252662d7 commit 10ea195fa269888d362f548279f3d3fa252662d7 Author: Mateusz Guzik AuthorDate: 2021-11-03 13:10:34 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-03 19:51:40 +0000 ipsec: add a lock encompassing SPI allocation SPIs get allocated and inserted in separate steps. Prior to the change there was nothing preventing 2 differnet threads from ending up with the same one. PR: 258849 Reported by: Herbie.Robinson@stratus.com Reviewed by: ae Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32826 --- sys/netipsec/key.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 48de29305b3c..9a810fa49931 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -216,6 +216,13 @@ VNET_DEFINE_STATIC(struct mtx *, spdcache_lock); #define SPDCACHE_LOCK(a) mtx_lock(&V_spdcache_lock[a]); #define SPDCACHE_UNLOCK(a) mtx_unlock(&V_spdcache_lock[a]); +static struct sx spi_alloc_lock; +#define SPI_ALLOC_LOCK_INIT() sx_init(&spi_alloc_lock, "spialloc") +#define SPI_ALLOC_LOCK_DESTROY() sx_destroy(&spi_alloc_lock) +#define SPI_ALLOC_LOCK() sx_xlock(&spi_alloc_lock) +#define SPI_ALLOC_UNLOCK() sx_unlock(&spi_alloc_lock) +#define SPI_ALLOC_LOCK_ASSERT() sx_assert(&spi_alloc_lock, SA_XLOCKED) + /* SAD */ TAILQ_HEAD(secashead_queue, secashead); LIST_HEAD(secashead_list, secashead); @@ -4902,6 +4909,7 @@ key_getspi(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) KEY_SETSECASIDX(proto, mode, reqid, src0 + 1, dst0 + 1, &saidx); /* SPI allocation */ + SPI_ALLOC_LOCK(); spi = key_do_getnewspi( (struct sadb_spirange *)mhp->ext[SADB_EXT_SPIRANGE], &saidx); if (spi == 0) { @@ -4909,10 +4917,12 @@ key_getspi(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) * Requested SPI or SPI range is not available or * already used. */ + SPI_ALLOC_UNLOCK(); error = EEXIST; goto fail; } sav = key_newsav(mhp, &saidx, spi, &error); + SPI_ALLOC_UNLOCK(); if (sav == NULL) goto fail; @@ -5021,6 +5031,8 @@ key_do_getnewspi(struct sadb_spirange *spirange, struct secasindex *saidx) uint32_t min, max, newspi, t; int tries, limit; + SPI_ALLOC_LOCK_ASSERT(); + /* set spi range to allocate */ if (spirange != NULL) { min = spirange->sadb_spirange_min; @@ -5629,9 +5641,11 @@ key_add(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) * secasindex. * XXXAE: IPComp seems also doesn't use SPI. */ + SPI_ALLOC_LOCK(); if (proto == IPPROTO_TCP) { sav = key_getsav_tcpmd5(&saidx, &spi); if (sav == NULL && spi == 0) { + SPI_ALLOC_UNLOCK(); /* Failed to allocate SPI */ ipseclog((LOG_DEBUG, "%s: SA already exists.\n", __func__)); @@ -5643,12 +5657,14 @@ key_add(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) sav = key_getsavbyspi(spi); } if (sav != NULL) { + SPI_ALLOC_UNLOCK(); key_freesav(&sav); ipseclog((LOG_DEBUG, "%s: SA already exists.\n", __func__)); return key_senderror(so, m, EEXIST); } sav = key_newsav(mhp, &saidx, spi, &error); + SPI_ALLOC_UNLOCK(); if (sav == NULL) return key_senderror(so, m, error); KEYDBG(KEY_STAMP, @@ -6023,10 +6039,12 @@ key_delete(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) return (key_senderror(so, m, EINVAL)); } sa0 = (struct sadb_sa *)mhp->ext[SADB_EXT_SA]; + SPI_ALLOC_LOCK(); if (proto == IPPROTO_TCP) sav = key_getsav_tcpmd5(&saidx, NULL); else sav = key_getsavbyspi(sa0->sadb_sa_spi); + SPI_ALLOC_UNLOCK(); if (sav == NULL) { ipseclog((LOG_DEBUG, "%s: no SA found for SPI %u.\n", __func__, ntohl(sa0->sadb_sa_spi))); @@ -6235,10 +6253,12 @@ key_get(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) } KEY_SETSECASIDX(proto, IPSEC_MODE_ANY, 0, src0 + 1, dst0 + 1, &saidx); + SPI_ALLOC_LOCK(); if (proto == IPPROTO_TCP) sav = key_getsav_tcpmd5(&saidx, NULL); else sav = key_getsavbyspi(sa0->sadb_sa_spi); + SPI_ALLOC_UNLOCK(); if (sav == NULL) { ipseclog((LOG_DEBUG, "%s: no SA found.\n", __func__)); return key_senderror(so, m, ESRCH); @@ -8318,6 +8338,7 @@ key_init(void) SAHTREE_LOCK_INIT(); ACQ_LOCK_INIT(); SPACQ_LOCK_INIT(); + SPI_ALLOC_LOCK_INIT(); #ifndef IPSEC_DEBUG2 callout_init(&key_timer, 1); @@ -8442,6 +8463,7 @@ key_destroy(void) SAHTREE_LOCK_DESTROY(); ACQ_LOCK_DESTROY(); SPACQ_LOCK_DESTROY(); + SPI_ALLOC_LOCK_DESTROY(); } #endif From nobody Wed Nov 3 19:54: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 6A28F1846DBA; Wed, 3 Nov 2021 19:54: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 4HkyCy2WbBz3G3x; Wed, 3 Nov 2021 19:54: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 36A0E1E85C; Wed, 3 Nov 2021 19:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3Jss9b091071; Wed, 3 Nov 2021 19:54:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3JssVx091070; Wed, 3 Nov 2021 19:54:54 GMT (envelope-from git) Date: Wed, 3 Nov 2021 19:54:54 GMT Message-Id: <202111031954.1A3JssVx091070@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: c47a4a237561 - main - arm: Remove unused items 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: c47a4a23756167e40c6a9d1dfd0bf64258620171 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=c47a4a23756167e40c6a9d1dfd0bf64258620171 commit c47a4a23756167e40c6a9d1dfd0bf64258620171 Author: Warner Losh AuthorDate: 2021-11-03 19:53:48 +0000 Commit: Warner Losh CommitDate: 2021-11-03 19:54:36 +0000 arm: Remove unused items Remote detritis copied, apparently, from sparc. utrap has never been used on arm, so it's safe to just remove it. Sponsored by: Netflix --- sys/arm/include/proc.h | 10 +---- sys/arm/include/utrap.h | 112 ------------------------------------------------ 2 files changed, 1 insertion(+), 121 deletions(-) diff --git a/sys/arm/include/proc.h b/sys/arm/include/proc.h index 9566c264731e..641b42280045 100644 --- a/sys/arm/include/proc.h +++ b/sys/arm/include/proc.h @@ -40,13 +40,6 @@ #ifndef _MACHINE_PROC_H_ #define _MACHINE_PROC_H_ -#include - -struct md_utrap { - utrap_entry_t *ut_precise[UT_MAX]; /* must be first */ - int ut_refcnt; -}; - struct mdthread { int md_spinlock_count; /* (k) */ register_t md_saved_cspr; /* (k) */ @@ -58,8 +51,7 @@ struct mdthread { }; struct mdproc { - struct md_utrap *md_utrap; - void *md_sigtramp; + long md_dummy; }; #define KINFO_PROC_SIZE 816 diff --git a/sys/arm/include/utrap.h b/sys/arm/include/utrap.h deleted file mode 100644 index b261d87d566f..000000000000 --- a/sys/arm/include/utrap.h +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_UTRAP_H_ -#define _MACHINE_UTRAP_H_ - -#define UT_INSTRUCTION_EXCEPTION 1 -#define UT_INSTRUCTION_ERROR 2 -#define UT_INSTRUCTION_PROTECTION 3 -#define UT_ILLTRAP_INSTRUCTION 4 -#define UT_ILLEGAL_INSTRUCTION 5 -#define UT_PRIVILEGED_OPCODE 6 -#define UT_FP_DISABLED 7 -#define UT_FP_EXCEPTION_IEEE_754 8 -#define UT_FP_EXCEPTION_OTHER 9 -#define UT_TAG_OFERFLOW 10 -#define UT_DIVISION_BY_ZERO 11 -#define UT_DATA_EXCEPTION 12 -#define UT_DATA_ERROR 13 -#define UT_DATA_PROTECTION 14 -#define UT_MEM_ADDRESS_NOT_ALIGNED 15 -#define UT_PRIVILEGED_ACTION 16 -#define UT_ASYNC_DATA_ERROR 17 -#define UT_TRAP_INSTRUCTION_16 18 -#define UT_TRAP_INSTRUCTION_17 19 -#define UT_TRAP_INSTRUCTION_18 20 -#define UT_TRAP_INSTRUCTION_19 21 -#define UT_TRAP_INSTRUCTION_20 22 -#define UT_TRAP_INSTRUCTION_21 23 -#define UT_TRAP_INSTRUCTION_22 24 -#define UT_TRAP_INSTRUCTION_23 25 -#define UT_TRAP_INSTRUCTION_24 26 -#define UT_TRAP_INSTRUCTION_25 27 -#define UT_TRAP_INSTRUCTION_26 28 -#define UT_TRAP_INSTRUCTION_27 29 -#define UT_TRAP_INSTRUCTION_28 30 -#define UT_TRAP_INSTRUCTION_29 31 -#define UT_TRAP_INSTRUCTION_30 32 -#define UT_TRAP_INSTRUCTION_31 33 -#define UT_INSTRUCTION_MISS 34 -#define UT_DATA_MISS 35 -#define UT_MAX 36 - -#define ST_SUNOS_SYSCALL 0 -#define ST_BREAKPOINT 1 -#define ST_DIVISION_BY_ZERO 2 -#define ST_FLUSH_WINDOWS 3 /* XXX implement! */ -#define ST_CLEAN_WINDOW 4 -#define ST_RANGE_CHECK 5 -#define ST_FIX_ALIGNMENT 6 -#define ST_INTEGER_OVERFLOW 7 -/* 8 is 32-bit ABI syscall (old solaris syscall?) */ -#define ST_BSD_SYSCALL 9 -#define ST_FP_RESTORE 10 -/* 11-15 are available */ -/* 16 is linux 32 bit syscall (but supposed to be reserved, grr) */ -/* 17 is old linux 64 bit syscall (but supposed to be reserved, grr) */ -/* 16-31 are reserved for user applications (utraps) */ -#define ST_GETCC 32 /* XXX implement! */ -#define ST_SETCC 33 /* XXX implement! */ -#define ST_GETPSR 34 /* XXX implement! */ -#define ST_SETPSR 35 /* XXX implement! */ -/* 36-63 are available */ -#define ST_SOLARIS_SYSCALL 64 -#define ST_SYSCALL 65 -#define ST_SYSCALL32 66 -/* 67 is reserved to OS source licensee */ -/* 68 is return from deferred trap (not supported) */ -/* 69-95 are reserved to SPARC international */ -/* 96-108 are available */ -/* 109 is linux 64 bit syscall */ -/* 110 is linux 64 bit getcontext (?) */ -/* 111 is linux 64 bit setcontext (?) */ -/* 112-255 are available */ - -#define UTH_NOCHANGE (-1) - -#ifndef __ASM__ - -typedef int utrap_entry_t; -typedef void *utrap_handler_t; - -#endif - -#endif From nobody Wed Nov 3 20:03: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 37B48184A9ED; Wed, 3 Nov 2021 20:03: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 4HkyPh12z7z3JXS; Wed, 3 Nov 2021 20:03: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 EFCF81ECF1; Wed, 3 Nov 2021 20:03: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 1A3K3JBR004906; Wed, 3 Nov 2021 20:03:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3K3JWl004905; Wed, 3 Nov 2021 20:03:19 GMT (envelope-from git) Date: Wed, 3 Nov 2021 20:03:19 GMT Message-Id: <202111032003.1A3K3JWl004905@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: 3ea9a7cf7b09 - main - blackhole(4): disable for locally originated TCP/UDP packets 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: 3ea9a7cf7b09a355cde3a76824809402b99d0892 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=3ea9a7cf7b09a355cde3a76824809402b99d0892 commit 3ea9a7cf7b09a355cde3a76824809402b99d0892 Author: Gleb Smirnoff AuthorDate: 2021-10-28 15:11:45 +0000 Commit: Gleb Smirnoff CommitDate: 2021-11-03 20:02:44 +0000 blackhole(4): disable for locally originated TCP/UDP packets In most cases blackholing for locally originated packets is undesired, leads to different kind of lags and delays. Provide sysctls to enforce it, e.g. for debugging purposes. Reviewed by: rrs Differential revision: https://reviews.freebsd.org/D32718 --- share/man/man4/blackhole.4 | 12 +++++++++++- sys/netinet/tcp_input.c | 19 +++++++++++++++++-- sys/netinet/udp_usrreq.c | 7 ++++++- sys/netinet/udp_var.h | 2 ++ sys/netinet6/udp6_usrreq.c | 3 ++- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/share/man/man4/blackhole.4 b/share/man/man4/blackhole.4 index 0bd7d03bcb50..17d1286525e4 100644 --- a/share/man/man4/blackhole.4 +++ b/share/man/man4/blackhole.4 @@ -12,7 +12,7 @@ .\" .\" .\" $FreeBSD$ -.Dd September 6, 2015 +.Dd November 3, 2021 .Dt BLACKHOLE 4 .Os .Sh NAME @@ -24,7 +24,9 @@ attempts .Sh SYNOPSIS .Cd sysctl net.inet.sctp.blackhole Ns Op = Ns Brq "0 | 1 | 2" .Cd sysctl net.inet.tcp.blackhole Ns Op = Ns Brq "0 | 1 | 2" +.Cd sysctl net.inet.tcp.blackhole_local Ns Op = Ns Brq "0 | 1" .Cd sysctl net.inet.udp.blackhole Ns Op = Ns Brq "0 | 1" +.Cd sysctl net.inet.udp.blackhole_local Ns Op = Ns Brq "0 | 1" .Sh DESCRIPTION The .Nm @@ -35,6 +37,14 @@ are received on SCTP, TCP, or UDP ports where there is no socket listening. The blackhole behaviour is useful to slow down an attacker who is port-scanning a system in an attempt to detect vulnerable services. It might also slow down an attempted denial of service attack. +.Pp +The blackhole behaviour is disabled by default. +If enabled, the locally originated packets would still be responded to, +unless also +.Va net.inet.tcp.blackhole_local +(for TCP) and/or +.Va net.inet.udp.blackhole_local +(for UDP) are enforced. .Ss SCTP Setting the SCTP blackhole MIB to a numeric value of one will prevent sending an ABORT packet in response to an incoming INIT. diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index a8fe6d9817d0..3ebac68c7c48 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -144,6 +144,12 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(blackhole), 0, "Do not send RST on segments to closed ports"); +VNET_DEFINE(bool, blackhole_local) = false; +#define V_blackhole_local VNET(blackhole_local) +SYSCTL_BOOL(_net_inet_tcp, OID_AUTO, blackhole_local, CTLFLAG_VNET | + CTLFLAG_RW, &VNET_NAME(blackhole_local), false, + "Enforce net.inet.tcp.blackhole for locally originated packets"); + VNET_DEFINE(int, tcp_delack_enabled) = 1; SYSCTL_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_delack_enabled), 0, @@ -935,8 +941,17 @@ findpcb: * When blackholing do not respond with a RST but * completely ignore the segment and drop it. */ - if ((V_blackhole == 1 && (thflags & TH_SYN)) || - V_blackhole == 2) + if (((V_blackhole == 1 && (thflags & TH_SYN)) || + V_blackhole == 2) && (V_blackhole_local || +#ifdef INET6 + isipv6 ? !in6_localaddr(&ip6->ip6_src) : +#endif +#ifdef INET + !in_localip(ip->ip_src) +#else + true +#endif + )) goto dropunlock; rstreason = BANDLIM_RST_CLOSEDPORT; diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 7c5a642da040..a9d534fbc8c0 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -127,6 +127,10 @@ VNET_DEFINE(int, udp_blackhole) = 0; SYSCTL_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(udp_blackhole), 0, "Do not send port unreachables for refused connects"); +VNET_DEFINE(bool, udp_blackhole_local) = false; +SYSCTL_BOOL(_net_inet_udp, OID_AUTO, blackhole_local, CTLFLAG_VNET | + CTLFLAG_RW, &VNET_NAME(udp_blackhole_local), false, + "Enforce net.inet.udp.blackhole for locally originated packets"); u_long udp_sendspace = 9216; /* really max datagram size */ SYSCTL_ULONG(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW, @@ -701,7 +705,8 @@ udp_input(struct mbuf **mp, int *offp, int proto) UDPSTAT_INC(udps_noportbcast); goto badunlocked; } - if (V_udp_blackhole) + if (V_udp_blackhole && (V_udp_blackhole_local || + !in_localip(ip->ip_src))) goto badunlocked; if (badport_bandlim(BANDLIM_ICMP_UNREACH) < 0) goto badunlocked; diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h index 37bc0c846d99..eaafdb299233 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -149,9 +149,11 @@ extern u_long udp_sendspace; extern u_long udp_recvspace; VNET_DECLARE(int, udp_cksum); VNET_DECLARE(int, udp_blackhole); +VNET_DECLARE(bool, udp_blackhole_local); VNET_DECLARE(int, udp_log_in_vain); #define V_udp_cksum VNET(udp_cksum) #define V_udp_blackhole VNET(udp_blackhole) +#define V_udp_blackhole_local VNET(udp_blackhole_local) #define V_udp_log_in_vain VNET(udp_log_in_vain) VNET_DECLARE(int, zero_checksum_port); diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 6ee2abc4ea1b..5939b631a1ab 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -511,7 +511,8 @@ skip_checksum: UDPSTAT_INC(udps_noportmcast); goto badunlocked; } - if (V_udp_blackhole) + if (V_udp_blackhole && (V_udp_blackhole_local || + !in6_localaddr(&ip6->ip6_src))) goto badunlocked; icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); *mp = NULL; From nobody Wed Nov 3 20:29: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 45BA2182E889; Wed, 3 Nov 2021 20:29: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 4Hkz0F1X9Tz3Qy7; Wed, 3 Nov 2021 20:29:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 146971F0B4; Wed, 3 Nov 2021 20:29:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3KTmpW031921; Wed, 3 Nov 2021 20:29:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3KTmGe031920; Wed, 3 Nov 2021 20:29:48 GMT (envelope-from git) Date: Wed, 3 Nov 2021 20:29:48 GMT Message-Id: <202111032029.1A3KTmGe031920@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: ae49051c033a - main - nfscl: Fix forced dismount when "nconnect" is specified 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: ae49051c033a2468af2f1f0079ecaf069b993245 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=ae49051c033a2468af2f1f0079ecaf069b993245 commit ae49051c033a2468af2f1f0079ecaf069b993245 Author: Rick Macklem AuthorDate: 2021-11-03 20:26:38 +0000 Commit: Rick Macklem CommitDate: 2021-11-03 20:26:38 +0000 nfscl: Fix forced dismount when "nconnect" is specified When a forced dismount is done and the "nconnect" mount option was used, the additional connections must be closed. This patch does that. Found during a recent IETF NFSv4 working group testing event. MFC after: 2 weeks --- sys/fs/nfs/nfs_commonkrpc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 2235f1077a03..358d77fe5b30 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -1298,9 +1298,13 @@ newnfs_nmcancelreqs(struct nfsmount *nmp) { struct nfsclds *dsp; struct __rpc_client *cl; + int i; if (nmp->nm_sockreq.nr_client != NULL) CLNT_CLOSE(nmp->nm_sockreq.nr_client); + for (i = 0; i < nmp->nm_aconnect; i++) + if (nmp->nm_aconn[i] != NULL) + CLNT_CLOSE(nmp->nm_aconn[i]); lookformore: NFSLOCKMNT(nmp); TAILQ_FOREACH(dsp, &nmp->nm_sess, nfsclds_list) { From nobody Wed Nov 3 20:55: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 05537183D2D2; Wed, 3 Nov 2021 20:55: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 4HkzYk0zqfz3qSh; Wed, 3 Nov 2021 20:55: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 C8C2B1FA94; Wed, 3 Nov 2021 20:55: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 1A3KtL9n071806; Wed, 3 Nov 2021 20:55:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3KtLQX071805; Wed, 3 Nov 2021 20:55:21 GMT (envelope-from git) Date: Wed, 3 Nov 2021 20:55:21 GMT Message-Id: <202111032055.1A3KtLQX071805@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: 589aed00e36c - main - sched: separate out schedinit_ap() 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: 589aed00e36c22733d3fd9c9016deccf074830b1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=589aed00e36c22733d3fd9c9016deccf074830b1 commit 589aed00e36c22733d3fd9c9016deccf074830b1 Author: Kyle Evans AuthorDate: 2021-11-02 18:06:47 +0000 Commit: Kyle Evans CommitDate: 2021-11-03 20:54:59 +0000 sched: separate out schedinit_ap() schedinit_ap() sets up an AP for a later call to sched_throw(NULL). Currently, ULE sets up some pcpu bits and fixes the idlethread lock with a call to sched_throw(NULL); this results in a window where curthread is setup in platforms' init_secondary(), but it has the wrong td_lock. Typical platform AP startup procedure looks something like: - Setup curthread - ... other stuff, including cpu_initclocks_ap() - Signal smp_started - sched_throw(NULL) to enter the scheduler cpu_initclocks_ap() may have callouts to process (e.g., nvme) and attempt to sched_add() for this AP, but this attempt fails because of the noted violated assumption leading to locking heartburn in sched_setpreempt(). Interrupts are still disabled until cpu_throw() so we're not really at risk of being preempted -- just let the scheduler in on it a little earlier as part of setting up curthread. Reviewed by: alfredo, kib, markj Triage help from: andrew, markj Smoke-tested by: alfredo (ppc), kevans (arm64, x86), mhorne (arm) Differential Revision: https://reviews.freebsd.org/D32797 --- sys/arm/arm/mp_machdep.c | 1 + sys/arm64/arm64/mp_machdep.c | 1 + sys/kern/sched_4bsd.c | 7 +++++++ sys/kern/sched_ule.c | 29 ++++++++++++++++++++++------- sys/mips/mips/mp_machdep.c | 1 + sys/powerpc/aim/mp_cpudep.c | 2 ++ sys/powerpc/booke/mp_cpudep.c | 2 ++ sys/riscv/riscv/mp_machdep.c | 1 + sys/sys/sched.h | 5 +++++ sys/x86/x86/mp_x86.c | 1 + 10 files changed, 43 insertions(+), 7 deletions(-) diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 6368f7b72da9..4089af5929eb 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -182,6 +182,7 @@ init_secondary(int cpu) pc->pc_curthread = pc->pc_idlethread; pc->pc_curpcb = pc->pc_idlethread->td_pcb; set_curthread(pc->pc_idlethread); + schedinit_ap(); #ifdef VFP vfp_init(); #endif diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 15e05ef46262..b42f65b9e399 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -255,6 +255,7 @@ init_secondary(uint64_t cpu) /* Initialize curthread */ KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); pcpup->pc_curthread = pcpup->pc_idlethread; + schedinit_ap(); /* Initialize curpmap to match TTBR0's current setting. */ pmap0 = vmspace_pmap(&vmspace0); diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index ddd65b94f0ff..6ba41eb80dcc 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -678,6 +678,13 @@ schedinit(void) mtx_init(&sched_lock, "sched lock", NULL, MTX_SPIN); } +void +schedinit_ap(void) +{ + + /* Nothing needed. */ +} + int sched_runnable(void) { diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 1b9473b93773..ce7ce4cd2bd8 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -1743,6 +1743,26 @@ schedinit(void) ts0->ts_cpu = curcpu; /* set valid CPU number */ } +/* + * schedinit_ap() is needed prior to calling sched_throw(NULL) to ensure that + * the pcpu requirements are met for any calls in the period between curthread + * initialization and sched_throw(). One can safely add threads to the queue + * before sched_throw(), for instance, as long as the thread lock is setup + * correctly. + * + * TDQ_SELF() relies on the below sched pcpu setting; it may be used only + * after schedinit_ap(). + */ +void +schedinit_ap(void) +{ + +#ifdef SMP + PCPU_SET(sched, DPCPU_PTR(tdq)); +#endif + PCPU_GET(idlethread)->td_lock = TDQ_LOCKPTR(TDQ_SELF()); +} + /* * This is only somewhat accurate since given many processes of the same * priority they will switch when their slices run out, which will be @@ -2973,19 +2993,14 @@ sched_throw(struct thread *td) struct thread *newtd; struct tdq *tdq; + tdq = TDQ_SELF(); if (__predict_false(td == NULL)) { -#ifdef SMP - PCPU_SET(sched, DPCPU_PTR(tdq)); -#endif - /* Correct spinlock nesting and acquire the correct lock. */ - tdq = TDQ_SELF(); TDQ_LOCK(tdq); + /* Correct spinlock nesting. */ spinlock_exit(); PCPU_SET(switchtime, cpu_ticks()); PCPU_SET(switchticks, ticks); - PCPU_GET(idlethread)->td_lock = TDQ_LOCKPTR(tdq); } else { - tdq = TDQ_SELF(); THREAD_LOCK_ASSERT(td, MA_OWNED); THREAD_LOCKPTR_ASSERT(td, TDQ_LOCKPTR(tdq)); tdq_load_rem(tdq, td); diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c index 1a5a023db381..dc089db1d189 100644 --- a/sys/mips/mips/mp_machdep.c +++ b/sys/mips/mips/mp_machdep.c @@ -311,6 +311,7 @@ smp_init_secondary(u_int32_t cpuid) /* Initialize curthread. */ KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); PCPU_SET(curthread, PCPU_GET(idlethread)); + schedinit_ap(); mtx_lock_spin(&ap_boot_mtx); diff --git a/sys/powerpc/aim/mp_cpudep.c b/sys/powerpc/aim/mp_cpudep.c index 33aae520c4b2..a73246487683 100644 --- a/sys/powerpc/aim/mp_cpudep.c +++ b/sys/powerpc/aim/mp_cpudep.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -134,6 +135,7 @@ cpudep_ap_bootstrap(void) #endif pcpup->pc_curpcb = pcpup->pc_curthread->td_pcb; sp = pcpup->pc_curpcb->pcb_sp; + schedinit_ap(); return (sp); } diff --git a/sys/powerpc/booke/mp_cpudep.c b/sys/powerpc/booke/mp_cpudep.c index c07e8c06ce05..709578d8e1b4 100644 --- a/sys/powerpc/booke/mp_cpudep.c +++ b/sys/powerpc/booke/mp_cpudep.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -85,6 +86,7 @@ cpudep_ap_bootstrap() #endif pcpup->pc_curpcb = pcpup->pc_curthread->td_pcb; sp = pcpup->pc_curpcb->pcb_sp; + schedinit_ap(); /* XXX shouldn't the pcb_sp be checked/forced for alignment here?? */ diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index 1dadf19ce51f..57d5606a3b88 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -248,6 +248,7 @@ init_secondary(uint64_t hart) /* Initialize curthread */ KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); pcpup->pc_curthread = pcpup->pc_idlethread; + schedinit_ap(); /* * Identify current CPU. This is necessary to setup diff --git a/sys/sys/sched.h b/sys/sys/sched.h index 64651ffa9c90..8041a2bc12d4 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -226,6 +226,11 @@ SYSINIT(name, SI_SUB_LAST, SI_ORDER_MIDDLE, name ## _add_proc, NULL); * Fixup scheduler state for proc0 and thread0 */ void schedinit(void); + +/* + * Fixup scheduler state for secondary APs + */ +void schedinit_ap(void); #endif /* _KERNEL */ /* POSIX 1003.1b Process Scheduling */ diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index ca1125886619..1fac244cbed7 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -1040,6 +1040,7 @@ init_secondary_tail(void) /* Initialize curthread. */ KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); PCPU_SET(curthread, PCPU_GET(idlethread)); + schedinit_ap(); mtx_lock_spin(&ap_boot_mtx); From nobody Wed Nov 3 21:29: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 3EA39182E38A; Wed, 3 Nov 2021 21:29:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hl0KB12cKz4Zhc; Wed, 3 Nov 2021 21:29:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F20AC20115; Wed, 3 Nov 2021 21:29:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3LTXfr012912; Wed, 3 Nov 2021 21:29:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3LTXJg012911; Wed, 3 Nov 2021 21:29:33 GMT (envelope-from git) Date: Wed, 3 Nov 2021 21:29:33 GMT Message-Id: <202111032129.1A3LTXJg012911@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: 6b67753488cb - main - nfscl: Fix forced dismount from looping on commit 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: 6b67753488cb506f05694c5f6d2e74cf53497c54 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=6b67753488cb506f05694c5f6d2e74cf53497c54 commit 6b67753488cb506f05694c5f6d2e74cf53497c54 Author: Rick Macklem AuthorDate: 2021-11-03 21:25:44 +0000 Commit: Rick Macklem CommitDate: 2021-11-03 21:25:44 +0000 nfscl: Fix forced dismount from looping on commit When a forced dismount is in progress, it is possible to end up looping, retrying commits that fail. This patch fixes the problem by pretending that commits succeeded when a forced dismount is in prgress. MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clbio.c | 2 +- sys/fs/nfsclient/nfs_clvnops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index 250d01d88948..73f559ad82f8 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -1738,7 +1738,7 @@ ncl_doio(struct vnode *vp, struct buf *bp, struct ucred *cr, struct thread *td, off = ((u_quad_t)bp->b_blkno) * DEV_BSIZE + bp->b_dirtyoff; retv = ncl_commit(vp, off, bp->b_dirtyend-bp->b_dirtyoff, bp->b_wcred, td); - if (retv == 0) { + if (NFSCL_FORCEDISM(vp->v_mount) || retv == 0) { bp->b_dirtyoff = bp->b_dirtyend = 0; bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK); bp->b_resid = 0; diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 1685edf5b2de..abccf82e3ff0 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3067,7 +3067,7 @@ again: for (i = 0; i < bvecpos; i++) { bp = bvec[i]; bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK); - if (retv) { + if (!NFSCL_FORCEDISM(vp->v_mount) && retv) { /* * Error, leave B_DELWRI intact */ From nobody Wed Nov 3 22:04:16 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 1ED1A183E12E; Wed, 3 Nov 2021 22:04:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hl15F0KRDz4lmv; Wed, 3 Nov 2021 22:04:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E083E20927; Wed, 3 Nov 2021 22:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3M4G16066311; Wed, 3 Nov 2021 22:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3M4Gjj066310; Wed, 3 Nov 2021 22:04:16 GMT (envelope-from git) Date: Wed, 3 Nov 2021 22:04:16 GMT Message-Id: <202111032204.1A3M4Gjj066310@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: 072d5b98c431 - main - sysbeep: Adjust interface to take a duration as a sbt 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: 072d5b98c4318e20248a6fbea4a5ca7c96992cac Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=072d5b98c4318e20248a6fbea4a5ca7c96992cac commit 072d5b98c4318e20248a6fbea4a5ca7c96992cac Author: Warner Losh AuthorDate: 2021-11-03 21:55:32 +0000 Commit: Warner Losh CommitDate: 2021-11-03 22:03:51 +0000 sysbeep: Adjust interface to take a duration as a sbt Change the 'period' argument to 'duration' and change its type to sbintime_t so we can more easily express different durations. Reviewed by: tsoome, glebius Differential Revision: https://reviews.freebsd.org/D32619 --- sys/dev/mlx/mlx.c | 6 +++--- sys/dev/syscons/syscons.c | 7 ++++++- sys/dev/vt/vt_core.c | 8 ++++---- sys/i386/i386/trap.c | 4 ++-- sys/kern/kern_cons.c | 13 +++++++------ sys/sys/systm.h | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c index bafd0902e09a..f5b023eafc9c 100644 --- a/sys/dev/mlx/mlx.c +++ b/sys/dev/mlx/mlx.c @@ -1083,7 +1083,7 @@ mlx_periodic(void *data) mlx_pause_action(sc); /* pause is running */ sc->mlx_pause.mp_when = 0; - sysbeep(500, hz); + sysbeep(500, SBT_1S); /* * Bus pause still running? @@ -1095,9 +1095,9 @@ mlx_periodic(void *data) if (time_second >= sc->mlx_pause.mp_howlong) { mlx_pause_action(sc); sc->mlx_pause.mp_which = 0; /* pause is complete */ - sysbeep(500, hz); + sysbeep(500, SBT_1S); } else { - sysbeep((time_second % 5) * 100 + 500, hz/8); + sysbeep((time_second % 5) * 100 + 500, SBT_1S / 8); } /* diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 6a389604d3ab..6c349668410d 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -4258,6 +4258,11 @@ sc_respond(scr_stat *scp, const u_char *p, int count, int wakeup) } } +/* + * pitch is the divisor for 1.193182MHz PIT clock. By dividing 1193172 / pitch, + * we convert it back to Hz. + * duration is in ticks of 1/hz. + */ void sc_bell(scr_stat *scp, int pitch, int duration) { @@ -4277,7 +4282,7 @@ sc_bell(scr_stat *scp, int pitch, int duration) } else if (duration != 0 && pitch != 0) { if (scp != scp->sc->cur_scp) pitch *= 2; - sysbeep(1193182 / pitch, duration); + sysbeep(1193182 / pitch, SBT_1S * duration / hz); } } diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 075b23597f68..567cdd2890d5 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -118,8 +118,8 @@ const struct terminal_class vt_termclass = { #define VT_TIMERFREQ 25 /* Bell pitch/duration. */ -#define VT_BELLDURATION ((5 * hz + 99) / 100) -#define VT_BELLPITCH 800 +#define VT_BELLDURATION (SBT_1S / 20) +#define VT_BELLPITCH (1193182 / 800) /* Approx 1491Hz */ #define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \ (vw)->vw_number) @@ -1100,7 +1100,7 @@ vtterm_bell(struct terminal *tm) if (vd->vd_flags & VDF_QUIET_BELL) return; - sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION); + sysbeep(VT_BELLPITCH, VT_BELLDURATION); } static void @@ -1116,7 +1116,7 @@ vtterm_beep(struct terminal *tm, u_int param) return; } - period = ((param >> 16) & 0xffff) * hz / 1000; + period = ((param >> 16) & 0xffff) * SBT_1MS; freq = 1193182 / (param & 0xffff); sysbeep(freq, period); diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 07abac23c9da..d770cf808f5f 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -414,7 +414,7 @@ user_trctrap_out: #endif if (time_second - lastalert > 10) { log(LOG_WARNING, "NMI: power fail\n"); - sysbeep(880, hz); + sysbeep(880, SBT_1S); lastalert = time_second; } return; @@ -671,7 +671,7 @@ kernel_trctrap: #ifdef POWERFAIL_NMI if (time_second - lastalert > 10) { log(LOG_WARNING, "NMI: power fail\n"); - sysbeep(880, hz); + sysbeep(880, SBT_1S); lastalert = time_second; } return; diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c index 780fce00387d..d33811f1e3c8 100644 --- a/sys/kern/kern_cons.c +++ b/sys/kern/kern_cons.c @@ -658,7 +658,7 @@ constty_timeout(void *arg) #ifdef HAS_TIMER_SPKR -static int beeping; +static bool beeping; static struct callout beeping_timer; static void @@ -666,11 +666,11 @@ sysbeepstop(void *chan) { timer_spkr_release(); - beeping = 0; + beeping = false; } int -sysbeep(int pitch, int period) +sysbeep(int pitch, sbintime_t duration) { if (timer_spkr_acquire()) { @@ -681,8 +681,9 @@ sysbeep(int pitch, int period) } timer_spkr_setfreq(pitch); if (!beeping) { - beeping = period; - callout_reset(&beeping_timer, period, sysbeepstop, NULL); + beeping = true; + callout_reset_sbt(&beeping_timer, duration, 0, sysbeepstop, + NULL, C_PREL(5)); } return (0); } @@ -701,7 +702,7 @@ SYSINIT(sysbeep, SI_SUB_SOFTINTR, SI_ORDER_ANY, sysbeep_init, NULL); */ int -sysbeep(int pitch __unused, int period __unused) +sysbeep(int pitch __unused, sbintime_t duration __unused) { return (ENODEV); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 497e09f86488..ffe014eb8b42 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -467,7 +467,7 @@ int SAN_INTERCEPTOR(casueword)(volatile u_long *p, u_long oldval, void realitexpire(void *); -int sysbeep(int hertz, int period); +int sysbeep(int hertz, sbintime_t duration); void hardclock(int cnt, int usermode); void hardclock_sync(int cpu); From nobody Wed Nov 3 22:04: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 818F8183E0D8; Wed, 3 Nov 2021 22:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hl15G1zPsz4lsb; Wed, 3 Nov 2021 22:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1897E20457; Wed, 3 Nov 2021 22:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3M4HGq066335; Wed, 3 Nov 2021 22:04:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3M4HtB066334; Wed, 3 Nov 2021 22:04:17 GMT (envelope-from git) Date: Wed, 3 Nov 2021 22:04:17 GMT Message-Id: <202111032204.1A3M4HtB066334@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: 2533eca1c2b9 - main - vt(4): Connect to teken's TP_SETBELLPD 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: 2533eca1c2b9d561c42d28bcb6f1c1c35562fbcc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=2533eca1c2b9d561c42d28bcb6f1c1c35562fbcc commit 2533eca1c2b9d561c42d28bcb6f1c1c35562fbcc Author: Warner Losh AuthorDate: 2021-11-03 21:55:42 +0000 Commit: Warner Losh CommitDate: 2021-11-03 22:03:51 +0000 vt(4): Connect to teken's TP_SETBELLPD Add the glue needed to listen to TP_SETBELLPD which teken uses to inform its client drivers about the results of parsing \e[=;B. It converts these to a Hz value for the tone/pitch of the bell and a duration in ms. There's some loss of precision because in the escape seuquence is defined to be (1193182 / pitch) Hz and is in 10ms units. Also note that kbdcontrol also parses 'off' but then doesn't send the proper escape sequence, leading me to wonder if that's another bug since teken appears to parse that sequence properly and I've added code here to treat that as the same as quiet or disabled. In general, Hz from 100 to 2000 is good. Outside that range is possible, but even at 100Hz the square wave is starting to sound bad and above 2000Hz the speaker may not respond. Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D32620 --- sys/dev/vt/vt.h | 2 ++ sys/dev/vt/vt_core.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 8a74fd97a4e0..5ba64388bd27 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -308,6 +308,8 @@ struct vt_window { struct vt_mode vw_smode; /* switch mode */ struct callout vw_proc_dead_timer; struct vt_window *vw_switch_to; + int vw_bell_pitch; /* (?) Bell pitch */ + sbintime_t vw_bell_duration; /* (?) Bell duration */ }; #define VT_AUTO 0 /* switching is automatic */ diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 567cdd2890d5..a197c8e8be68 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -257,6 +257,8 @@ static struct vt_window vt_conswindow = { .vw_terminal = &vt_consterm, .vw_kbdmode = K_XLATE, .vw_grabbed = 0, + .vw_bell_pitch = VT_BELLPITCH, + .vw_bell_duration = VT_BELLDURATION, }; struct terminal vt_consterm = { .tm_class = &vt_termclass, @@ -1100,7 +1102,11 @@ vtterm_bell(struct terminal *tm) if (vd->vd_flags & VDF_QUIET_BELL) return; - sysbeep(VT_BELLPITCH, VT_BELLDURATION); + if (vw->vw_bell_pitch == 0 || + vw->vw_bell_duration == 0) + return; + + sysbeep(vw->vw_bell_pitch, vw->vw_bell_duration); } static void @@ -1177,6 +1183,11 @@ vtterm_param(struct terminal *tm, int cmd, unsigned int arg) case TP_MOUSE: vw->vw_mouse_level = arg; break; + case TP_SETBELLPD: + vw->vw_bell_pitch = TP_SETBELLPD_PITCH(arg); + vw->vw_bell_duration = + TICKS_2_MSEC(TP_SETBELLPD_DURATION(arg)) * SBT_1MS; + break; } } From nobody Wed Nov 3 22:04: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 E2421183E13C; Wed, 3 Nov 2021 22:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hl15H3mJ2z4lqT; Wed, 3 Nov 2021 22:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A3B420458; Wed, 3 Nov 2021 22:04:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3M4J6j066365; Wed, 3 Nov 2021 22:04:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3M4JLL066364; Wed, 3 Nov 2021 22:04:19 GMT (envelope-from git) Date: Wed, 3 Nov 2021 22:04:19 GMT Message-Id: <202111032204.1A3M4JLL066364@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: 4ac3d08a9693 - main - vt: Add devctl message for bells 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: 4ac3d08a9693c27c1bd2ddd67b2808ac9e18f4c5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4ac3d08a9693c27c1bd2ddd67b2808ac9e18f4c5 commit 4ac3d08a9693c27c1bd2ddd67b2808ac9e18f4c5 Author: Warner Losh AuthorDate: 2021-11-03 21:55:48 +0000 Commit: Warner Losh CommitDate: 2021-11-03 22:03:51 +0000 vt: Add devctl message for bells Generate VT events when the bell beeps. When coupled with disabling the bell,this allows custom bells to be rung when we'd otherwise beep. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D32656 --- sbin/devd/devd.conf.5 | 9 +++++++++ share/man/man4/vt.4 | 14 ++++++++++++++ sys/dev/vt/vt_core.c | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5 index f6579ac3f20f..887ce5ec9a3d 100644 --- a/sbin/devd/devd.conf.5 +++ b/sbin/devd/devd.conf.5 @@ -604,6 +604,15 @@ Notification of a filesystem being unmounted. .Pp .Bl -column "System" "Subsystem" "1234567" -compact .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" +.It Li VT Ta BELL Ta RING Ta +Notifcation that the console bell has run. +See +.Xr vt 4 +for details. +.El +.Pp +.Bl -column "System" "Subsystem" "1234567" -compact +.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" .It Li ZFS Ta ZFS Ta Ta Events about the ZFS subsystem. See diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4 index 8584706dc1aa..d0672ff9e5a0 100644 --- a/share/man/man4/vt.4 +++ b/share/man/man4/vt.4 @@ -297,6 +297,20 @@ console fonts .It Pa /usr/share/vt/keymaps/*.kbd keyboard layouts .El +.Sh DEVCTL MESSAGES +.Bl -column "System" "Subsystem" "1234567" -compact +.Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" +.It Li VT Ta BELL Ta RING Ta +Notifcation that the console bell has run. +.El +.Pp +.Bl -column "Variable" "Meaning" -compact +.Sy "Variable" Ta Sy "Meaning" +.It Li duration_ms Ta Length of time the bell was requested to ring in milliseconds. +.It Li enabled Ta true or false indicating whether or not the bell was enabled when rung. +.It Li hz Ta Tone that was requested in Hz. +.El +.Pp .Sh EXAMPLES This example changes the default color of normal text to green on a black background, or black on a green background when reversed. diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index a197c8e8be68..38efd1e5501c 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -51,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -1090,12 +1092,35 @@ vt_allocate_keyboard(struct vt_device *vd) return (idx0); } +#define DEVCTL_LEN 64 +static void +vtterm_devctl(bool enabled, int hz, sbintime_t duration) +{ + struct sbuf sb; + char *buf; + + buf = malloc(DEVCTL_LEN, M_VT, M_NOWAIT); + if (buf == NULL) + return; + sbuf_new(&sb, buf, DEVCTL_LEN, SBUF_FIXEDLEN); + sbuf_printf(&sb, "enabled=%s hz=%d duration_ms=%d", + enabled ? "true" : "false", hz, (int)(duration / SBT_1MS)); + sbuf_finish(&sb); + if (sbuf_error(&sb) == 0) + devctl_notify("VT", "BELL", "RING", sbuf_data(&sb)); + sbuf_delete(&sb); + free(buf, M_VT); +} + static void vtterm_bell(struct terminal *tm) { struct vt_window *vw = tm->tm_softc; struct vt_device *vd = vw->vw_device; + vtterm_devctl(vt_enable_bell, vw->vw_bell_pitch, + vw->vw_bell_duration); + if (!vt_enable_bell) return; @@ -1112,10 +1137,8 @@ vtterm_bell(struct terminal *tm) static void vtterm_beep(struct terminal *tm, u_int param) { - u_int freq, period; - - if (!vt_enable_bell) - return; + u_int freq; + sbintime_t period; if ((param == 0) || ((param & 0xffff) == 0)) { vtterm_bell(tm); @@ -1125,6 +1148,11 @@ vtterm_beep(struct terminal *tm, u_int param) period = ((param >> 16) & 0xffff) * SBT_1MS; freq = 1193182 / (param & 0xffff); + vtterm_devctl(vt_enable_bell, freq, period); + + if (!vt_enable_bell) + return; + sysbeep(freq, period); } From nobody Wed Nov 3 22:04: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 27B8F183E1A7; Wed, 3 Nov 2021 22:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hl15J4VpXz4lnQ; Wed, 3 Nov 2021 22:04:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B49920928; Wed, 3 Nov 2021 22:04:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A3M4KAl066390; Wed, 3 Nov 2021 22:04:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3M4K5R066389; Wed, 3 Nov 2021 22:04:20 GMT (envelope-from git) Date: Wed, 3 Nov 2021 22:04:20 GMT Message-Id: <202111032204.1A3M4K5R066389@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: ba48d52ca6c8 - main - vt: Fix frequency calcuation for bell 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: ba48d52ca6c867559156dd916631f9ac47abe80f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ba48d52ca6c867559156dd916631f9ac47abe80f commit ba48d52ca6c867559156dd916631f9ac47abe80f Author: Warner Losh AuthorDate: 2021-11-03 21:55:55 +0000 Commit: Warner Losh CommitDate: 2021-11-03 22:03:51 +0000 vt: Fix frequency calcuation for bell 386BSD provided a MD function sysbeep. This took two arguments (pitch and period). Pitch was jammed into the PIT's divisor directly (which means the argument was expected to sound a tone at '1193182 / pitch' Hz). FreeBSD inherited this interface. In commit e46598588587 (svn 177642, Mar 26 2008), phk changed this function to take a tone to sound in hz. He converted all in-tree instances of 1193182 / hz to just hz (and kept the few misguided folks that passed hz directly unchanged -- this was part of what motivated the change). He converted the places where we pre-computed the 8254 divisor from being pitch to 1193182 / pitch (since that converts the divisor to the frequency and the interfaces that were exposed to userland exposed it in these units in places, continuing the tradition inherited from SCO System V/386 Unix in spots). In 2009, Ed Shouten was contracted by the FreeBSD Foundation to write / finish newcons. This work was done in perforce and was imported into subversion in user/ed/newcons in revision 199072 (https://svnweb.freebsd.org/base?view=revision&revision=199072) which was later imported into FreeBSD by ray@ (Aleksandr Rybalko). From that earliest import into svn import to this date, we ring the bell with: sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION); where VT_BELLPITCH was defined to be 800. This results in a bell frequency of 1491Hz, more or less today. This is similar to the frequency that syscons and pcvt used (1493Hz and 1500Hz respectively). This in turn was inherited from 386BSD, it seems, which used the hard coded value 0x31b which is 795 -> 1500Hz. This '800' was intended to be the bell tone (eg 800Hz) and this interface was one that wasn't converted. The most common terminal prior to the rise of PCs was the VT100, which had an approximately 800Hz bell. Ed Shouten has confirmed that the original intent was 800Hz and changing this was overlooked after the change to -current was made. This restors that original intent and makes the bell less obnoxious in the process. Reviewed by: des, adrian Differential Revision: https://reviews.freebsd.org/D32594 Sponsored by: Netflix --- sys/dev/vt/vt_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 38efd1e5501c..06f5827078ca 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -121,7 +121,7 @@ const struct terminal_class vt_termclass = { /* Bell pitch/duration. */ #define VT_BELLDURATION (SBT_1S / 20) -#define VT_BELLPITCH (1193182 / 800) /* Approx 1491Hz */ +#define VT_BELLPITCH 800 #define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \ (vw)->vw_number) From nobody Wed Nov 3 22:13: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 324DE1843A7E; Wed, 3 Nov 2021 22:13: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 4Hl1Hz0yZwz4r6x; Wed, 3 Nov 2021 22:13: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 019B420C8D; Wed, 3 Nov 2021 22:13: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 1A3MDYhG079540; Wed, 3 Nov 2021 22:13:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3MDYsI079539; Wed, 3 Nov 2021 22:13:34 GMT (envelope-from git) Date: Wed, 3 Nov 2021 22:13:34 GMT Message-Id: <202111032213.1A3MDYsI079539@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: cc48eb70d10d - main - vt: fix typo 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: cc48eb70d10da7310750930a153616f38afe28d6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=cc48eb70d10da7310750930a153616f38afe28d6 commit cc48eb70d10da7310750930a153616f38afe28d6 Author: Warner Losh AuthorDate: 2021-11-03 22:12:55 +0000 Commit: Warner Losh CommitDate: 2021-11-03 22:12:55 +0000 vt: fix typo Notifcation -> Notification --- sbin/devd/devd.conf.5 | 2 +- share/man/man4/vt.4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5 index 887ce5ec9a3d..5c7d129a6054 100644 --- a/sbin/devd/devd.conf.5 +++ b/sbin/devd/devd.conf.5 @@ -605,7 +605,7 @@ Notification of a filesystem being unmounted. .Bl -column "System" "Subsystem" "1234567" -compact .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" .It Li VT Ta BELL Ta RING Ta -Notifcation that the console bell has run. +Notification that the console bell has run. See .Xr vt 4 for details. diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4 index d0672ff9e5a0..1ed344237eb9 100644 --- a/share/man/man4/vt.4 +++ b/share/man/man4/vt.4 @@ -301,7 +301,7 @@ keyboard layouts .Bl -column "System" "Subsystem" "1234567" -compact .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" .It Li VT Ta BELL Ta RING Ta -Notifcation that the console bell has run. +Notification that the console bell has run. .El .Pp .Bl -column "Variable" "Meaning" -compact From nobody Wed Nov 3 22:22: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 CAB65184885B; Wed, 3 Nov 2021 22:22:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hl1VM5MLHz4ttL; Wed, 3 Nov 2021 22:22:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 97F2620CDA; Wed, 3 Nov 2021 22:22: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 1A3MMZkl092428; Wed, 3 Nov 2021 22:22:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3MMZbI092427; Wed, 3 Nov 2021 22:22:35 GMT (envelope-from git) Date: Wed, 3 Nov 2021 22:22:35 GMT Message-Id: <202111032222.1A3MMZbI092427@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: 80f21bb039ce - main - vt: fix git mismerge 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: 80f21bb039cef279e50e1b791b2808b916009bf6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=80f21bb039cef279e50e1b791b2808b916009bf6 commit 80f21bb039cef279e50e1b791b2808b916009bf6 Author: Warner Losh AuthorDate: 2021-11-03 22:20:41 +0000 Commit: Warner Losh CommitDate: 2021-11-03 22:20:41 +0000 vt: fix git mismerge I made a mistaking in merging the final commits for the devctl changes. This adds the 'hushed' variable and has the correct dates for the manuals. Pointy hat to: imp --- sbin/devd/devd.conf.5 | 4 ++-- share/man/man4/vt.4 | 7 ++++--- sys/dev/vt/vt_core.c | 18 +++++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5 index 5c7d129a6054..dd9faa05c869 100644 --- a/sbin/devd/devd.conf.5 +++ b/sbin/devd/devd.conf.5 @@ -40,7 +40,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd June 23, 2021 +.Dd November 3, 2021 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -605,7 +605,7 @@ Notification of a filesystem being unmounted. .Bl -column "System" "Subsystem" "1234567" -compact .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" .It Li VT Ta BELL Ta RING Ta -Notification that the console bell has run. +Notification that the console bell has rung. See .Xr vt 4 for details. diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4 index 1ed344237eb9..c31eae0ec274 100644 --- a/share/man/man4/vt.4 +++ b/share/man/man4/vt.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 4, 2020 +.Dd November 3, 2021 .Dt "VT" 4 .Os .Sh NAME @@ -301,13 +301,14 @@ keyboard layouts .Bl -column "System" "Subsystem" "1234567" -compact .Sy "System" Ta Sy "Subsystem" Ta Sy "Type" Ta Sy "Description" .It Li VT Ta BELL Ta RING Ta -Notification that the console bell has run. +Notification that the console bell has rung. .El .Pp .Bl -column "Variable" "Meaning" -compact .Sy "Variable" Ta Sy "Meaning" .It Li duration_ms Ta Length of time the bell was requested to ring in milliseconds. -.It Li enabled Ta true or false indicating whether or not the bell was enabled when rung. +.It Li enabled Ta true or false indicating whether or not the bell was administratively enabled when rung. +.It Li hushed Ta true or false indicating whether or not the bell was quieted by the user when rung. .It Li hz Ta Tone that was requested in Hz. .El .Pp diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 06f5827078ca..0fab05ff4096 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -121,7 +121,7 @@ const struct terminal_class vt_termclass = { /* Bell pitch/duration. */ #define VT_BELLDURATION (SBT_1S / 20) -#define VT_BELLPITCH 800 +#define VT_BELLPITCH (1193182 / 800) /* Approx 1491Hz */ #define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \ (vw)->vw_number) @@ -1094,7 +1094,7 @@ vt_allocate_keyboard(struct vt_device *vd) #define DEVCTL_LEN 64 static void -vtterm_devctl(bool enabled, int hz, sbintime_t duration) +vtterm_devctl(bool enabled, bool hushed, int hz, sbintime_t duration) { struct sbuf sb; char *buf; @@ -1103,8 +1103,9 @@ vtterm_devctl(bool enabled, int hz, sbintime_t duration) if (buf == NULL) return; sbuf_new(&sb, buf, DEVCTL_LEN, SBUF_FIXEDLEN); - sbuf_printf(&sb, "enabled=%s hz=%d duration_ms=%d", - enabled ? "true" : "false", hz, (int)(duration / SBT_1MS)); + sbuf_printf(&sb, "enabled=%s hushed=%s hz=%d duration_ms=%d", + enabled ? "true" : "false", hushed ? "true" : "false", + hz, (int)(duration / SBT_1MS)); sbuf_finish(&sb); if (sbuf_error(&sb) == 0) devctl_notify("VT", "BELL", "RING", sbuf_data(&sb)); @@ -1118,8 +1119,8 @@ vtterm_bell(struct terminal *tm) struct vt_window *vw = tm->tm_softc; struct vt_device *vd = vw->vw_device; - vtterm_devctl(vt_enable_bell, vw->vw_bell_pitch, - vw->vw_bell_duration); + vtterm_devctl(vt_enable_bell, vd->vd_flags & VDF_QUIET_BELL, + vw->vw_bell_pitch, vw->vw_bell_duration); if (!vt_enable_bell) return; @@ -1139,6 +1140,8 @@ vtterm_beep(struct terminal *tm, u_int param) { u_int freq; sbintime_t period; + struct vt_window *vw = tm->tm_softc; + struct vt_device *vd = vw->vw_device; if ((param == 0) || ((param & 0xffff) == 0)) { vtterm_bell(tm); @@ -1148,7 +1151,8 @@ vtterm_beep(struct terminal *tm, u_int param) period = ((param >> 16) & 0xffff) * SBT_1MS; freq = 1193182 / (param & 0xffff); - vtterm_devctl(vt_enable_bell, freq, period); + vtterm_devctl(vt_enable_bell, vd->vd_flags & VDF_QUIET_BELL, + freq, period); if (!vt_enable_bell) return; From nobody Wed Nov 3 23:38: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 7D36B1841A07; Wed, 3 Nov 2021 23:38: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 4Hl3B134H4z3lv0; Wed, 3 Nov 2021 23:38: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 45D0E21BB7; Wed, 3 Nov 2021 23:38: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 1A3NcXtL086194; Wed, 3 Nov 2021 23:38:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A3NcXe8086193; Wed, 3 Nov 2021 23:38:33 GMT (envelope-from git) Date: Wed, 3 Nov 2021 23:38:33 GMT Message-Id: <202111032338.1A3NcXe8086193@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: 9d63429fa163 - main - ssh: move common Makefile boilerplate to a new ssh.mk 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: 9d63429fa16352f58037ac2aa6ddc734b25e8331 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=9d63429fa16352f58037ac2aa6ddc734b25e8331 commit 9d63429fa16352f58037ac2aa6ddc734b25e8331 Author: Ed Maste AuthorDate: 2021-11-02 18:48:33 +0000 Commit: Ed Maste CommitDate: 2021-11-03 23:38:05 +0000 ssh: move common Makefile boilerplate to a new ssh.mk This moves SSHDIR and ssh_namespace.h handling to a common location, and will simplify future work such as adding U2F support (D32509). Reviewed by: kevans MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32808 --- secure/Makefile.inc | 6 ------ secure/lib/libssh/Makefile | 4 +--- secure/libexec/sftp-server/Makefile | 3 +-- secure/libexec/ssh-keysign/Makefile | 3 +-- secure/libexec/ssh-pkcs11-helper/Makefile | 3 +-- secure/ssh.mk | 6 ++++++ secure/usr.bin/scp/Makefile | 3 +-- secure/usr.bin/sftp/Makefile | 3 +-- secure/usr.bin/ssh-add/Makefile | 3 +-- secure/usr.bin/ssh-agent/Makefile | 3 +-- secure/usr.bin/ssh-keygen/Makefile | 3 +-- secure/usr.bin/ssh-keyscan/Makefile | 3 +-- secure/usr.bin/ssh/Makefile | 4 +--- secure/usr.sbin/sshd/Makefile | 3 +-- 14 files changed, 18 insertions(+), 32 deletions(-) diff --git a/secure/Makefile.inc b/secure/Makefile.inc index 6c298be0223f..5de6eed37faf 100644 --- a/secure/Makefile.inc +++ b/secure/Makefile.inc @@ -1,15 +1,9 @@ # $FreeBSD$ -.include - .if exists(${.CURDIR:H:H}/lib/libcrypt/obj) CRYPTOBJDIR= ${.CURDIR:H:H}/lib/libcrypt/obj .else CRYPTOBJDIR= ${.CURDIR:H:H}/lib/libcrypt .endif -.if ${MK_OPENSSH} != "no" -SSHDIR= ${SRCTOP}/crypto/openssh -.endif - WARNS?= 0 diff --git a/secure/lib/libssh/Makefile b/secure/lib/libssh/Makefile index 49b5319d2b54..f6ea5c211a03 100644 --- a/secure/lib/libssh/Makefile +++ b/secure/lib/libssh/Makefile @@ -1,6 +1,7 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" LIB= ssh PRIVATELIB= true @@ -50,9 +51,6 @@ SRCS+= getrrsetbyname-ldns.c LIBADD+= ldns .endif -CFLAGS+= -I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h - .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no" CFLAGS+= -include krb5_config.h SRCS+= krb5_config.h diff --git a/secure/libexec/sftp-server/Makefile b/secure/libexec/sftp-server/Makefile index 24d675e0cf16..97408d332d34 100644 --- a/secure/libexec/sftp-server/Makefile +++ b/secure/libexec/sftp-server/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= sftp-server SRCS= sftp-server.c sftp-common.c sftp-server-main.c MAN= sftp-server.8 -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh diff --git a/secure/libexec/ssh-keysign/Makefile b/secure/libexec/ssh-keysign/Makefile index e3fc51c66432..72acf1c2d75e 100644 --- a/secure/libexec/ssh-keysign/Makefile +++ b/secure/libexec/ssh-keysign/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= ssh-keysign SRCS= ssh-keysign.c readconf.c uidswap.c MAN= ssh-keysign.8 -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h BINMODE=4555 LIBADD= ssh diff --git a/secure/libexec/ssh-pkcs11-helper/Makefile b/secure/libexec/ssh-pkcs11-helper/Makefile index 19e114be935d..c4ae4f503197 100644 --- a/secure/libexec/ssh-pkcs11-helper/Makefile +++ b/secure/libexec/ssh-pkcs11-helper/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= ssh-pkcs11-helper SRCS= ssh-pkcs11.c ssh-pkcs11-helper.c MAN= ssh-pkcs11-helper.8 -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh diff --git a/secure/ssh.mk b/secure/ssh.mk new file mode 100644 index 000000000000..4ab8cd399ae8 --- /dev/null +++ b/secure/ssh.mk @@ -0,0 +1,6 @@ +# Common Make variables for OpenSSH + +SSHDIR= ${SRCTOP}/crypto/openssh + +CFLAGS+= -I${SSHDIR} -include ssh_namespace.h +SRCS+= ssh_namespace.h diff --git a/secure/usr.bin/scp/Makefile b/secure/usr.bin/scp/Makefile index a4e55c1bf86b..c071f5198902 100644 --- a/secure/usr.bin/scp/Makefile +++ b/secure/usr.bin/scp/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= scp SRCS= scp.c sftp-common.c sftp-client.c sftp-glob.c progressmeter.c PACKAGE= ssh -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh diff --git a/secure/usr.bin/sftp/Makefile b/secure/usr.bin/sftp/Makefile index 249fef233d37..868f7a23bfde 100644 --- a/secure/usr.bin/sftp/Makefile +++ b/secure/usr.bin/sftp/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= sftp SRCS= sftp.c sftp-client.c sftp-common.c sftp-glob.c progressmeter.c PACKAGE= ssh -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh edit diff --git a/secure/usr.bin/ssh-add/Makefile b/secure/usr.bin/ssh-add/Makefile index c76e50a4a91a..162ea60a29d0 100644 --- a/secure/usr.bin/ssh-add/Makefile +++ b/secure/usr.bin/ssh-add/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= ssh-add SRCS+= ssh-add.c ssh-sk-client.c PACKAGE= ssh -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh diff --git a/secure/usr.bin/ssh-agent/Makefile b/secure/usr.bin/ssh-agent/Makefile index 95ccd05811fe..c8139ec376c3 100644 --- a/secure/usr.bin/ssh-agent/Makefile +++ b/secure/usr.bin/ssh-agent/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= ssh-agent SRCS= ssh-agent.c PACKAGE= ssh -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh diff --git a/secure/usr.bin/ssh-keygen/Makefile b/secure/usr.bin/ssh-keygen/Makefile index eec0b23e1b3f..b53b645e8576 100644 --- a/secure/usr.bin/ssh-keygen/Makefile +++ b/secure/usr.bin/ssh-keygen/Makefile @@ -1,13 +1,12 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= ssh-keygen # XXX ssh-sk-client.c in libssh maybe? SRCS= ssh-keygen.c sshsig.c ssh-sk-client.c PACKAGE= ssh -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh diff --git a/secure/usr.bin/ssh-keyscan/Makefile b/secure/usr.bin/ssh-keyscan/Makefile index ade1e4237ff5..130e5f61ec64 100644 --- a/secure/usr.bin/ssh-keyscan/Makefile +++ b/secure/usr.bin/ssh-keyscan/Makefile @@ -1,12 +1,11 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" PROG= ssh-keyscan SRCS= ssh-keyscan.c PACKAGE= ssh -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h LIBADD= ssh diff --git a/secure/usr.bin/ssh/Makefile b/secure/usr.bin/ssh/Makefile index 614cc7627fc5..5528aceed5ee 100644 --- a/secure/usr.bin/ssh/Makefile +++ b/secure/usr.bin/ssh/Makefile @@ -1,6 +1,7 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" CONFS= ssh_config CONFSDIR= /etc/ssh @@ -16,9 +17,6 @@ SRCS= ssh.c readconf.c clientloop.c sshtty.c \ # gss-genr.c really belongs in libssh; see src/secure/lib/libssh/Makefile SRCS+= gss-genr.c -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h - LIBADD= ssh .if ${MK_LDNS} != "no" diff --git a/secure/usr.sbin/sshd/Makefile b/secure/usr.sbin/sshd/Makefile index b374e737a139..a34732f868c7 100644 --- a/secure/usr.sbin/sshd/Makefile +++ b/secure/usr.sbin/sshd/Makefile @@ -1,6 +1,7 @@ # $FreeBSD$ .include +.include "${SRCTOP}/secure/ssh.mk" CONFS= moduli sshd_config CONFSDIR= /etc/ssh @@ -25,8 +26,6 @@ PACKAGE= ssh SRCS+= gss-genr.c MAN= sshd.8 sshd_config.5 -CFLAGS+=-I${SSHDIR} -include ssh_namespace.h -SRCS+= ssh_namespace.h # Don't rebuild based on moduli.c moduli: .MADE From nobody Thu Nov 4 00:32: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 B6EA8183A6A1; Thu, 4 Nov 2021 00:32: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 4Hl4Nb4lKdz4WTb; Thu, 4 Nov 2021 00:32: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 8322022A90; Thu, 4 Nov 2021 00:32:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A40Wllp066175; Thu, 4 Nov 2021 00:32:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A40WlMg066174; Thu, 4 Nov 2021 00:32:47 GMT (envelope-from git) Date: Thu, 4 Nov 2021 00:32:47 GMT Message-Id: <202111040032.1A40WlMg066174@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Allan Jude Subject: git: 34d8fffff313 - main - SIFTR: Fix compilation with -DSIFTR_IPV6 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: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 34d8fffff313d026ed3bb5c0befc8212eaa27d2d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=34d8fffff313d026ed3bb5c0befc8212eaa27d2d commit 34d8fffff313d026ed3bb5c0befc8212eaa27d2d Author: Allan Jude AuthorDate: 2021-11-04 00:31:13 +0000 Commit: Allan Jude CommitDate: 2021-11-04 00:32:17 +0000 SIFTR: Fix compilation with -DSIFTR_IPV6 A few pieces of the SIFTR code that are behind #ifdef SIFTR_IPV6 have not been updated as APIs have changed, etc. Reported by: Alexander Sideropoulos Reviewed by: rscheff, lstewart Sponsored by: NetApp Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D32698 --- sys/netinet/siftr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c index 2a6bf5e71151..00a4f477ad2e 100644 --- a/sys/netinet/siftr.c +++ b/sys/netinet/siftr.c @@ -99,7 +99,7 @@ __FBSDID("$FreeBSD$"); #ifdef SIFTR_IPV6 #include -#include +#include #include #endif /* SIFTR_IPV6 */ @@ -1007,8 +1007,9 @@ ret: } #ifdef SIFTR_IPV6 -static int -siftr_chkpkt6(struct mbuf **m, struct ifnet *ifp, int flags, struct inpcb *inp) +static pfil_return_t +siftr_chkpkt6(struct mbuf **m, struct ifnet *ifp, int flags, + void *ruleset __unused, struct inpcb *inp) { struct pkt_node *pn; struct ip6_hdr *ip6; @@ -1134,7 +1135,7 @@ ret6: VNET_DEFINE_STATIC(pfil_hook_t, siftr_inet_hook); #define V_siftr_inet_hook VNET(siftr_inet_hook) -#ifdef INET6 +#ifdef SIFTR_IPV6 VNET_DEFINE_STATIC(pfil_hook_t, siftr_inet6_hook); #define V_siftr_inet6_hook VNET(siftr_inet6_hook) #endif From nobody Thu Nov 4 00:55: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 24686184427B; Thu, 4 Nov 2021 00:55: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 4Hl4vK0Vzxz4f20; Thu, 4 Nov 2021 00:55: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 E531322BCE; Thu, 4 Nov 2021 00:55: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 1A40tuCv092783; Thu, 4 Nov 2021 00:55:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A40tuiE092782; Thu, 4 Nov 2021 00:55:56 GMT (envelope-from git) Date: Thu, 4 Nov 2021 00:55:56 GMT Message-Id: <202111040055.1A40tuiE092782@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: 7ac82c96fe79 - main - proc_get_binpath(): provide syntaxically correct value for unused NDINIT arg 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: 7ac82c96fe79a6a9dcf595ef4860ed75d3511414 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7ac82c96fe79a6a9dcf595ef4860ed75d3511414 commit 7ac82c96fe79a6a9dcf595ef4860ed75d3511414 Author: Konstantin Belousov AuthorDate: 2021-11-04 00:53:21 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-04 00:55:33 +0000 proc_get_binpath(): provide syntaxically correct value for unused NDINIT arg Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/kern/kern_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index d11f651960c0..21af09265dd2 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2276,7 +2276,7 @@ proc_get_binpath(struct proc *p, char *binname, char **retbuf, * which case we should not report old name. */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, *retbuf, - req->td); + curthread); error = namei(&nd); if (error == 0) { if (nd.ni_vp == vp) From nobody Thu Nov 4 04:14: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 C1578184FB39; Thu, 4 Nov 2021 04:14:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hl9JD52ZMz3ncg; Thu, 4 Nov 2021 04:14:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8CDEC25989; Thu, 4 Nov 2021 04:14:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A44EK14059874; Thu, 4 Nov 2021 04:14:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A44EK4m059873; Thu, 4 Nov 2021 04:14:20 GMT (envelope-from git) Date: Thu, 4 Nov 2021 04:14:20 GMT Message-Id: <202111040414.1A44EK4m059873@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: 15bd9fa3bea7 - main - procfs_doprocfile(): simplify 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: 15bd9fa3bea794054b4a5bd2f4bb71b0ba3aa3ba Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=15bd9fa3bea794054b4a5bd2f4bb71b0ba3aa3ba commit 15bd9fa3bea794054b4a5bd2f4bb71b0ba3aa3ba Author: Konstantin Belousov AuthorDate: 2021-11-04 03:58:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-04 04:13:47 +0000 procfs_doprocfile(): simplify Now that proc_get_binpath() does not return NULL in fullpath on success, directly use sbuf_cat() over the value. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/fs/procfs/procfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c index 697bbfc9877a..38cfb4752279 100644 --- a/sys/fs/procfs/procfs.c +++ b/sys/fs/procfs/procfs.c @@ -77,7 +77,7 @@ procfs_doprocfile(PFS_FILL_ARGS) PROC_LOCK(p); error = proc_get_binpath(p, binpath, &fullpath, &freepath); if (error == 0) - sbuf_printf(sb, "%s", fullpath == NULL ? "" : fullpath); + sbuf_cat(sb, fullpath); free(binpath, M_TEMP); free(freepath, M_TEMP); return (error); From nobody Thu Nov 4 05:09: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 AD19818278BA; Thu, 4 Nov 2021 05:09: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 4HlBX84WX6z4VYg; Thu, 4 Nov 2021 05:09: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 7AC7726482; Thu, 4 Nov 2021 05:09: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 1A459i9x026577; Thu, 4 Nov 2021 05:09:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A459ilB026576; Thu, 4 Nov 2021 05:09:44 GMT (envelope-from git) Date: Thu, 4 Nov 2021 05:09:44 GMT Message-Id: <202111040509.1A459ilB026576@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: 890cae197737 - main - fsck_msdosfs: truncate directory entry when the head pointer is invalid. 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: 890cae197737b463e56d1cc5a3f61f84cb49c807 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=890cae197737b463e56d1cc5a3f61f84cb49c807 commit 890cae197737b463e56d1cc5a3f61f84cb49c807 Author: Xin LI AuthorDate: 2021-11-04 05:09:32 +0000 Commit: Xin LI CommitDate: 2021-11-04 05:09:32 +0000 fsck_msdosfs: truncate directory entry when the head pointer is invalid. As far as we know, there is no FAT implementation that supported hard links, and our msdosfs driver assumed one cluster chain is only referenced by one directory entry and clears it out when the file is deleted. On the other hand, the current code would proceed with checkchain() when the directory entry's head cluster is a valid numbered cluster without checking if it was a valid head node of a cluster chain. So if the cluster do not being a chain (e.g. CLUST_FREE, CLUST_BAD), or was already referenced by another directory entry, this would trigger an assertion in check_chain() at a later time. Fix this by giving the user an option to truncate the directory entry when the head cluster is an invalid cluster, an visited head node, or not a head node. Reported by: NetApp (kevans@) Reviewed by: kevans, emaste (no objection) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D32699 --- sbin/fsck_msdosfs/dir.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c index 471f6cc0335e..dbe4e0c7db2f 100644 --- a/sbin/fsck_msdosfs/dir.c +++ b/sbin/fsck_msdosfs/dir.c @@ -400,8 +400,21 @@ checksize(struct fat_descriptor *fat, u_char *p, struct dosDirEntry *dir) if (dir->head == CLUST_FREE) { physicalSize = 0; } else { - if (!fat_is_valid_cl(fat, dir->head)) - return FSERROR; + if (!fat_is_valid_cl(fat, dir->head) || !fat_is_cl_head(fat, dir->head)) { + pwarn("Directory entry %s of size %u referencing invalid cluster %u\n", + fullpath(dir), dir->size, dir->head); + if (ask(1, "Truncate")) { + p[28] = p[29] = p[30] = p[31] = 0; + p[26] = p[27] = 0; + if (boot->ClustMask == CLUST32_MASK) + p[20] = p[21] = 0; + dir->size = 0; + dir->head = CLUST_FREE; + return FSDIRMOD; + } else { + return FSERROR; + } + } ret = checkchain(fat, dir->head, &chainsize); /* * Upon return, chainsize would hold the chain length From nobody Thu Nov 4 08:02: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 3DE641843447; Thu, 4 Nov 2021 08:02:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlGMY1Dk4z4sH9; Thu, 4 Nov 2021 08:02:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0ADB328898; Thu, 4 Nov 2021 08:02:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A482W4J064502; Thu, 4 Nov 2021 08:02:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A482W2D064501; Thu, 4 Nov 2021 08:02:32 GMT (envelope-from git) Date: Thu, 4 Nov 2021 08:02:32 GMT Message-Id: <202111040802.1A482W2D064501@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 8abfbe5a79b1 - main - beep(1): Initial version of utility to create terminal beep via soundcard. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8abfbe5a79b19bb95430f574d970843607f5809c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=8abfbe5a79b19bb95430f574d970843607f5809c commit 8abfbe5a79b19bb95430f574d970843607f5809c Author: Hans Petter Selasky AuthorDate: 2021-10-26 17:13:00 +0000 Commit: Hans Petter Selasky CommitDate: 2021-11-04 08:00:46 +0000 beep(1): Initial version of utility to create terminal beep via soundcard. Reviewed by: imp@, emaste@ and pstef@ Differential Revision: https://reviews.freebsd.org/D32672 MFC after: 1 week Sponsored by: NVIDIA Networking --- usr.bin/Makefile | 1 + usr.bin/beep/Makefile | 8 ++ usr.bin/beep/beep.1 | 84 +++++++++++++++ usr.bin/beep/beep.c | 275 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 368 insertions(+) diff --git a/usr.bin/Makefile b/usr.bin/Makefile index e8be161db01a..ab93df2abd19 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -10,6 +10,7 @@ SUBDIR= alias \ backlight \ banner \ basename \ + beep \ brandelf \ bsdcat \ bsdiff \ diff --git a/usr.bin/beep/Makefile b/usr.bin/beep/Makefile new file mode 100644 index 000000000000..754656ef059b --- /dev/null +++ b/usr.bin/beep/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +PROG= beep +MAN= beep.1 + +LDFLAGS= -lm + +.include diff --git a/usr.bin/beep/beep.1 b/usr.bin/beep/beep.1 new file mode 100644 index 000000000000..55fe0173272a --- /dev/null +++ b/usr.bin/beep/beep.1 @@ -0,0 +1,84 @@ +.\"- +.\" Copyright (c) 2021 Hans Petter Selasky +.\" +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd November 4, 2021 +.Dt beep 1 +.Os +.Sh NAME +.Nm beep +.Nd play a beep sound +.Sh SYNOPSIS +.Nm +.Op Fl F Ar frequency +.Op Fl D Ar duration_ms +.Op Fl r Ar sample_rate_hz +.Op Fl d Ar oss_device +.Op Fl g Ar gain +.Op Fl B +.Op Fl h +.Sh DESCRIPTION +The +.Nm +utility is used to playback a beep on the soundcard. +.Pp +The options are as follows: +.Bl -tag -width "-f device" +.It Fl F +Sets the center frequency of the beep in Hz. +The default is 440 Hz . +.It Fl D +Sets the duration of the beep in milliseconds. +The default is 150 ms . +.It Fl d +Sets the soundcard to use. +The default is /dev/dsp . +.It Fl r +Sets the soundcard samplerate in Hz. +The default is 48000 Hz. +.It Fl g +Sets the waveform gain, between 0 and 100 inclusively. +The default is 75. +.It Fl B +Runs the +.Nm +utility in the background. +.It Fl h +Display summary of options. +.El +.Sh EXAMPLES +.Pp +Playback default beep sound using /dev/dsp . +.Bl -tag -width Ds -offset indent +.It $ beep +.El +.Sh SEE ALSO +.Xr mixer 3 , +.Xr sound 4 , +.Sh HISTORY +The +.Nm +utility first appeared in FreeBSD 14.0. +.Sh AUTHORS +.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org diff --git a/usr.bin/beep/beep.c b/usr.bin/beep/beep.c new file mode 100644 index 000000000000..151236b4825b --- /dev/null +++ b/usr.bin/beep/beep.c @@ -0,0 +1,275 @@ +/*- + * Copyright (c) 2021 Hans Petter Selasky + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SAMPLE_RATE_DEF 48000 /* hz */ +#define SAMPLE_RATE_MAX 48000 /* hz */ +#define SAMPLE_RATE_MIN 8000 /* hz */ + +#define DURATION_DEF 150 /* ms */ +#define DURATION_MAX 2000 /* ms */ +#define DURATION_MIN 50 /* ms */ + +#define GAIN_DEF 75 +#define GAIN_MAX 100 +#define GAIN_MIN 0 + +#define WAVE_POWER 1.25f + +#define DEFAULT_HZ 440 + +#define DEFAULT_DEVICE _PATH_DEV "dsp" + +static int frequency = DEFAULT_HZ; +static int duration_ms = DURATION_DEF; +static int sample_rate = SAMPLE_RATE_DEF; +static int gain = GAIN_DEF; +static const char *oss_dev = DEFAULT_DEVICE; +static bool background; + +/* + * wave_function_16 + * + * "phase" should be in the range [0.0f .. 1.0f> + * "power" should be in the range <0.0f .. 2.0f> + * + * The return value is in the range [-1.0f .. 1.0f] + */ +static float +wave_function_16(float phase, float power) +{ + uint16_t x = phase * (1U << 16); + float retval; + uint8_t num; + + /* Handle special cases, if any */ + switch (x) { + case 0xffff: + case 0x0000: + return (1.0f); + case 0x3fff: + case 0x4000: + case 0xBfff: + case 0xC000: + return (0.0f); + case 0x7FFF: + case 0x8000: + return (-1.0f); + default: + break; + } + + /* Apply Gray coding */ + for (uint16_t mask = 1U << 15; mask != 1; mask /= 2) { + if (x & mask) + x ^= (mask - 1); + } + + /* Find first set bit */ + for (num = 0; num != 14; num++) { + if (x & (1U << num)) { + num++; + break; + } + } + + /* Initialize return value */ + retval = 0.0; + + /* Compute the rest of the power series */ + for (; num != 14; num++) { + if (x & (1U << num)) { + retval = (1.0f - retval) / 2.0f; + retval = powf(retval, power); + } else { + retval = (1.0f + retval) / 2.0f; + retval = powf(retval, power); + } + } + + /* Check if halfway */ + if (x & (1ULL << 14)) + retval = -retval; + + return (retval); +} + +static void +usage(void) +{ + fprintf(stderr, "Usage: %s [parameters]\n" + "\t" "-F \n" + "\t" "-D \n" + "\t" "-r \n" + "\t" "-d \n" + "\t" "-g \n" + "\t" "-B Run in background\n" + "\t" "-h Show usage\n", + getprogname(), + DEFAULT_HZ, + DURATION_MIN, DURATION_MAX, DURATION_DEF, + SAMPLE_RATE_MIN, SAMPLE_RATE_MAX, SAMPLE_RATE_DEF, + DEFAULT_DEVICE, + GAIN_MIN, GAIN_MAX, GAIN_DEF); + exit(1); +} + +int +main(int argc, char **argv) +{ + int32_t *buffer; + size_t slope; + size_t size; + size_t off; + float a; + float d; + float p; + int c; + int f; + + while ((c = getopt(argc, argv, "BF:D:r:g:d:h")) != -1) { + switch (c) { + case 'F': + frequency = strtol(optarg, NULL, 10); + break; + case 'D': + duration_ms = strtol(optarg, NULL, 10); + if (duration_ms < DURATION_MIN || + duration_ms > DURATION_MAX) + usage(); + break; + case 'r': + sample_rate = strtol(optarg, NULL, 10); + if (sample_rate < SAMPLE_RATE_MIN || + sample_rate > SAMPLE_RATE_MAX) + usage(); + break; + case 'g': + gain = strtol(optarg, NULL, 10); + if (gain < GAIN_MIN || + gain > GAIN_MAX) + usage(); + break; + case 'd': + oss_dev = optarg; + break; + case 'B': + background = true; + break; + default: + usage(); + break; + } + } + + if (background && daemon(0, 0) != 0) + errx(1, "daemon(0,0) failed"); + + f = open(oss_dev, O_WRONLY); + if (f < 0) + errx(1, "Failed to open '%s'", oss_dev); + + c = 1; /* mono */ + if (ioctl(f, SOUND_PCM_WRITE_CHANNELS, &c) != 0) + errx(1, "ioctl SOUND_PCM_WRITE_CHANNELS(1) failed"); + + c = AFMT_S32_NE; + if (ioctl(f, SNDCTL_DSP_SETFMT, &c) != 0) + errx(1, "ioctl SNDCTL_DSP_SETFMT(AFMT_S32_NE) failed"); + + if (ioctl(f, SNDCTL_DSP_SPEED, &sample_rate) != 0) + errx(1, "ioctl SNDCTL_DSP_SPEED(%d) failed", sample_rate); + + c = (2 << 16); + while ((1ULL << (c & 63)) < (size_t)(4 * sample_rate / 50)) + c++; + if (ioctl(f, SNDCTL_DSP_SETFRAGMENT, &c)) + errx(1, "ioctl SNDCTL_DSP_SETFRAGMENT(0x%x) failed", c); + + if (ioctl(f, SNDCTL_DSP_GETODELAY, &c) != 0) + errx(1, "ioctl SNDCTL_DSP_GETODELAY failed"); + + size = ((sample_rate * duration_ms) + 999) / 1000; + buffer = malloc(sizeof(buffer[0]) * size); + if (buffer == NULL) + errx(1, "out of memory"); + + /* compute slope duration in samples */ + slope = (DURATION_MIN * sample_rate) / 2000; + + /* compute base gain */ + a = powf(65536.0f, (float)gain / (float)GAIN_MAX) / 65536.0f; + + /* set initial phase and delta */ + p = 0; + d = (float)frequency / (float)sample_rate; + + /* compute wave */ + for (p = off = 0; off != size; off++, p += d) { + float sample; + + p = p - floorf(p); + sample = a * wave_function_16(p, WAVE_POWER); + + if (off < slope) + sample = sample * off / (float)slope; + else if (off > (size - slope)) + sample = sample * (size - off - 1) / (float)slope; + + buffer[off] = sample * 0x7fffff00; + } + + if (write(f, buffer, size * sizeof(buffer[0])) != + (ssize_t)(size * sizeof(buffer[0]))) + errx(1, "failed writing to DSP device(%s)", oss_dev); + + free(buffer); + + /* wait for data to be written */ + while (ioctl(f, SNDCTL_DSP_GETODELAY, &c) == 0) { + if (c == 0) + break; + usleep(10000); + } + + /* wait for audio to go out */ + usleep(50000); + close(f); + + return (0); +} From nobody Thu Nov 4 08:44: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 770F61835C41; Thu, 4 Nov 2021 08:44: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 4HlHHg2hvFz3QgV; Thu, 4 Nov 2021 08:44: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 3C47228EFA; Thu, 4 Nov 2021 08:44: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 1A48iFxj017449; Thu, 4 Nov 2021 08:44:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A48iF7V017448; Thu, 4 Nov 2021 08:44:15 GMT (envelope-from git) Date: Thu, 4 Nov 2021 08:44:15 GMT Message-Id: <202111040844.1A48iF7V017448@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Li-Wen Hsu Subject: git: 9c0287e0920a - main - release: Remove unused variables in azure 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: lwhsu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9c0287e0920ad7a16c75e62e914cd69c439dba1c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by lwhsu: URL: https://cgit.FreeBSD.org/src/commit/?id=9c0287e0920ad7a16c75e62e914cd69c439dba1c commit 9c0287e0920ad7a16c75e62e914cd69c439dba1c Author: Li-Wen Hsu AuthorDate: 2021-11-04 08:42:38 +0000 Commit: Li-Wen Hsu CommitDate: 2021-11-04 08:42:38 +0000 release: Remove unused variables in azure Makefile Approved by: re (gjb) Sponsored by: The FreeBSD Foundation --- release/Makefile.azure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/Makefile.azure b/release/Makefile.azure index bc6f8859dea9..4e9e33184dfc 100644 --- a/release/Makefile.azure +++ b/release/Makefile.azure @@ -11,7 +11,7 @@ AZURE_UPLOAD_TGTS= azure-check-depends \ CLEANFILES+= ${AZURE_UPLOAD_TGTS} .if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF) -. for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY _LOCATION +. for VAR in _STORAGE _ACCOUNT _KEY AZURE${VAR}!= grep -E '^AZURE${VAR}' ${AZURE_UPLOAD_CONF} | awk -F ' ' '{print $$2}' . endfor .endif @@ -28,7 +28,7 @@ EXPIRY_DATE!= date -v+1m -I -u azure-upload: ${AZURE_UPLOAD_TGTS} azure-check-depends: -.for VAR in _STORAGE _ACCOUNT _RESOURCEGROUP _KEY _LOCATION +.for VAR in _STORAGE _ACCOUNT _KEY . if !defined(AZURE${VAR}) || empty(AZURE${VAR}) @echo "Variable AZURE${VAR} cannot be empty." @false From nobody Thu Nov 4 12:56: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 56586183B40F; Thu, 4 Nov 2021 12:56: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 4HlNtt2047z4l4w; Thu, 4 Nov 2021 12:56: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 230A82C7BF; Thu, 4 Nov 2021 12:56: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 1A4CucvJ049983; Thu, 4 Nov 2021 12:56:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4CucBg049982; Thu, 4 Nov 2021 12:56:38 GMT (envelope-from git) Date: Thu, 4 Nov 2021 12:56:38 GMT Message-Id: <202111041256.1A4CucBg049982@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Allan Jude Subject: git: c441592a0e15 - main - Allow kern.ipc.maxsockets to be set to current value without error 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: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c441592a0e1591591665cd037a8a5e9b54675f99 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=c441592a0e1591591665cd037a8a5e9b54675f99 commit c441592a0e1591591665cd037a8a5e9b54675f99 Author: Allan Jude AuthorDate: 2021-11-04 12:55:33 +0000 Commit: Allan Jude CommitDate: 2021-11-04 12:56:09 +0000 Allow kern.ipc.maxsockets to be set to current value without error Normally setting kern.ipc.maxsockets returns EINVAL if the new value is not greater than the previous value. This can cause spurious error messages when sysctl.conf is processed multiple times, or when automation systems try to ensure the sysctl is set to the correct value. If the value is unchanged, then just do nothing. PR: 243532 Reviewed by: markj MFC after: 3 days Sponsored by: Modirum MDPay Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D32775 --- sys/kern/uipc_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 267a33feac3b..e033b2d77f1d 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -364,7 +364,7 @@ sysctl_maxsockets(SYSCTL_HANDLER_ARGS) newmaxsockets = maxsockets; error = sysctl_handle_int(oidp, &newmaxsockets, 0, req); - if (error == 0 && req->newptr) { + if (error == 0 && req->newptr && newmaxsockets != maxsockets) { if (newmaxsockets > maxsockets && newmaxsockets <= maxfiles) { maxsockets = newmaxsockets; From nobody Thu Nov 4 14:55:01 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 61EB5183B3D1; Thu, 4 Nov 2021 14:55:04 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlRWW44yTz4Y7V; Thu, 4 Nov 2021 14:55:03 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 1A4Et1FE029820; Thu, 4 Nov 2021 07:55:01 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 1A4Et1pX029819; Thu, 4 Nov 2021 07:55:01 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202111041455.1A4Et1pX029819@gndrsh.dnsmgr.net> Subject: Re: git: ba48d52ca6c8 - main - vt: Fix frequency calcuation for bell In-Reply-To: <202111032204.1A3M4K5R066389@gitrepo.freebsd.org> To: Warner Losh Date: Thu, 4 Nov 2021 07:55:01 -0700 (PDT) CC: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] 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: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4HlRWW44yTz4Y7V X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N Thank you Warner for all the legwork on tracking this down and getting a proper bell tone working on FreeBSD-Current. I do not see any MFC plans for this, can you please consider merging this to all supported releases? Oh and RELNOTES: YES? Thanks, Rod > The branch main has been updated by imp: > > URL: https://cgit.FreeBSD.org/src/commit/?id=ba48d52ca6c867559156dd916631f9ac47abe80f > > commit ba48d52ca6c867559156dd916631f9ac47abe80f > Author: Warner Losh > AuthorDate: 2021-11-03 21:55:55 +0000 > Commit: Warner Losh > CommitDate: 2021-11-03 22:03:51 +0000 > > vt: Fix frequency calcuation for bell > > 386BSD provided a MD function sysbeep. This took two arguments (pitch > and period). Pitch was jammed into the PIT's divisor directly (which > means the argument was expected to sound a tone at '1193182 / pitch' > Hz). FreeBSD inherited this interface. > > In commit e46598588587 (svn 177642, Mar 26 2008), phk changed this > function to take a tone to sound in hz. He converted all in-tree > instances of 1193182 / hz to just hz (and kept the few misguided folks > that passed hz directly unchanged -- this was part of what motivated the > change). He converted the places where we pre-computed the 8254 divisor > from being pitch to 1193182 / pitch (since that converts the divisor to > the frequency and the interfaces that were exposed to userland exposed > it in these units in places, continuing the tradition inherited from SCO > System V/386 Unix in spots). > > In 2009, Ed Shouten was contracted by the FreeBSD Foundation to write / > finish newcons. This work was done in perforce and was imported into > subversion in user/ed/newcons in revision 199072 > (https://svnweb.freebsd.org/base?view=revision&revision=199072) which > was later imported into FreeBSD by ray@ (Aleksandr Rybalko). > > From that earliest import into svn import to this date, we ring the bell > with: > sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION); > where VT_BELLPITCH was defined to be 800. This results in a bell > frequency of 1491Hz, more or less today. This is similar to the > frequency that syscons and pcvt used (1493Hz and 1500Hz respectively). > This in turn was inherited from 386BSD, it seems, which used the hard > coded value 0x31b which is 795 -> 1500Hz. > > This '800' was intended to be the bell tone (eg 800Hz) and this > interface was one that wasn't converted. The most common terminal prior > to the rise of PCs was the VT100, which had an approximately 800Hz > bell. Ed Shouten has confirmed that the original intent was 800Hz and > changing this was overlooked after the change to -current was made. > This restors that original intent and makes the bell less obnoxious in > the process. > > Reviewed by: des, adrian > Differential Revision: https://reviews.freebsd.org/D32594 > Sponsored by: Netflix > --- > sys/dev/vt/vt_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c > index 38efd1e5501c..06f5827078ca 100644 > --- a/sys/dev/vt/vt_core.c > +++ b/sys/dev/vt/vt_core.c > @@ -121,7 +121,7 @@ const struct terminal_class vt_termclass = { > > /* Bell pitch/duration. */ > #define VT_BELLDURATION (SBT_1S / 20) > -#define VT_BELLPITCH (1193182 / 800) /* Approx 1491Hz */ > +#define VT_BELLPITCH 800 > > #define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \ > (vw)->vw_number) > -- Rod Grimes rgrimes@freebsd.org From nobody Thu Nov 4 15:16: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 C29471846960; Thu, 4 Nov 2021 15:16:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlRzr57r0z4hNN; Thu, 4 Nov 2021 15:16: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 902402E427; Thu, 4 Nov 2021 15:16: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 1A4FG8Yu037225; Thu, 4 Nov 2021 15:16:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4FG8O8037224; Thu, 4 Nov 2021 15:16:08 GMT (envelope-from git) Date: Thu, 4 Nov 2021 15:16:08 GMT Message-Id: <202111041516.1A4FG8O8037224@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: aa80581c195e - main - Add notes about vt beeping 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: aa80581c195eb3d29caa632213f363041be36c1f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=aa80581c195eb3d29caa632213f363041be36c1f commit aa80581c195eb3d29caa632213f363041be36c1f Author: Warner Losh AuthorDate: 2021-11-04 15:15:38 +0000 Commit: Warner Losh CommitDate: 2021-11-04 15:15:38 +0000 Add notes about vt beeping Sponsored by: Netflix --- RELNOTES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELNOTES b/RELNOTES index d56e86623fa2..44b777e9b7ab 100644 --- a/RELNOTES +++ b/RELNOTES @@ -10,6 +10,11 @@ newline. Entries should be separated by a newline. Changes to this file should not be MFCed. +ba48d52ca6c8,4ac3d08a9693,2533eca1c2b9: + The default bell tone is now 800Hz. It may be set with kbdcontrol + again. There's devd integration for people wishing to use their sound + cards for the beep. + 92b3e07229ba: net.inet.tcp.nolocaltimewait enabled by default. It prevents creation of timewait entries for TCP connections that were From nobody Thu Nov 4 15:17: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 6F78D1848F43 for ; Thu, 4 Nov 2021 15:17:51 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-vk1-xa30.google.com (mail-vk1-xa30.google.com [IPv6:2607:f8b0:4864:20::a30]) (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 4HlS1q1zYBz4jZ2 for ; Thu, 4 Nov 2021 15:17:51 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-vk1-xa30.google.com with SMTP id f126so3192652vke.3 for ; Thu, 04 Nov 2021 08:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LALnhJbIsUnZ9H28sEKaL65MU0snYLeHfJVy3yvBaJ0=; b=NODCVkkrjL70tMzuHS8jTdDzq7jFTX01QdIwkDJbNMDvrzYNLgkWTyWYOEOBskx+sq h7GUwOLKIrrZ+/qBGmeQsNG7KZ3T7UFqZSw+Y5Z3SQ4DfrLuHUsJGu58s662rjEeYvc1 Q7df3HV0IhmJ3EIce7SHCtcjV0os3KeqLq9YLPlRTU6m/cdOqSiqUrBILfivJ27k1Ooq NRRIhXfD/YprAl95geXeazQCiQvzYx4sdW649yVhmxXMILnKbGa7NZRS+bStTAiUQOZ9 PhYBZlqJB65ZWbsc0W21OCv4C71G7Qg8OPIvu2j8F2zrYh2srIFj/ykZcILsGNvgSRWB uMRg== 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=LALnhJbIsUnZ9H28sEKaL65MU0snYLeHfJVy3yvBaJ0=; b=a3y5ydE8pjvS6dW2V6lTZebGzIm54qc/tr1z+84EzJ2zB4V8fgcdQErj6Xgj8TqeT/ zAL1WK+JuVyvMxHwS5LSU8kw16wN1dY3z39PwV2BbPQ8gOaKG9g9czRdk7zzOxXrwAmy 3YXKUEB3su0XvA0+S+D6QGyJJt0TGbmUW0n1adzOhRnq4W55N/j1kZEGFBlTV+K7NLSH gkqVNavH9NABZhazE0uLeenrg0y/9iHxD4QiAQTsIbRRhlW8zBifZGJJkQ4sGfGrpx8N 7ZQFmxnW48pxPhc5N7QKtWnDYIuOwKq9Nc3ZaX6rBlSnfaA0sPsTpE1zNqSwE6nbS4nm vukQ== X-Gm-Message-State: AOAM531kWDoH2ZJwROkk2jy9QyvXiqxDIbx9/davquZ/miKeWgi649SJ tTTlc+vxeS5+DZDuXGEWEopV5XpiKu3fCYMEoFLiOQ== X-Google-Smtp-Source: ABdhPJyUtawuilGtRikN5NT+i+TvQUZaUMkDGXv1jnAJ3+KIrcG2sYF0g7DDEjalMqUW08Koz07blxBSOQPup3DxV20= X-Received: by 2002:a05:6122:20a5:: with SMTP id i37mr13222595vkd.18.1636039070488; Thu, 04 Nov 2021 08:17:50 -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: <202111032204.1A3M4K5R066389@gitrepo.freebsd.org> <202111041455.1A4Et1pX029819@gndrsh.dnsmgr.net> In-Reply-To: <202111041455.1A4Et1pX029819@gndrsh.dnsmgr.net> From: Warner Losh Date: Thu, 4 Nov 2021 09:17:38 -0600 Message-ID: Subject: Re: git: ba48d52ca6c8 - main - vt: Fix frequency calcuation for bell To: "Rodney W. Grimes" Cc: Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000a2ab7805cff80759" X-Rspamd-Queue-Id: 4HlS1q1zYBz4jZ2 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N --000000000000a2ab7805cff80759 Content-Type: text/plain; charset="UTF-8" On Thu, Nov 4, 2021 at 8:55 AM Rodney W. Grimes wrote: > Thank you Warner for all the legwork on tracking this down and > getting a proper bell tone working on FreeBSD-Current. I do not > see any MFC plans for this, can you please consider merging this > to all supported releases? > I'm merging to 13. The merge was easy. I'm unlikely to merge to 12, though, because some of these changes are dependent on changing a system interface that I got conflicts with. If there's a lot of demand I can plow through the conflicts. > Oh and RELNOTES: YES? > Added. > Thanks, > Rod > > > The branch main has been updated by imp: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=ba48d52ca6c867559156dd916631f9ac47abe80f > > > > commit ba48d52ca6c867559156dd916631f9ac47abe80f > > Author: Warner Losh > > AuthorDate: 2021-11-03 21:55:55 +0000 > > Commit: Warner Losh > > CommitDate: 2021-11-03 22:03:51 +0000 > > > > vt: Fix frequency calcuation for bell > > > > 386BSD provided a MD function sysbeep. This took two arguments (pitch > > and period). Pitch was jammed into the PIT's divisor directly (which > > means the argument was expected to sound a tone at '1193182 / pitch' > > Hz). FreeBSD inherited this interface. > > > > In commit e46598588587 (svn 177642, Mar 26 2008), phk changed this > > function to take a tone to sound in hz. He converted all in-tree > > instances of 1193182 / hz to just hz (and kept the few misguided > folks > > that passed hz directly unchanged -- this was part of what motivated > the > > change). He converted the places where we pre-computed the 8254 > divisor > > from being pitch to 1193182 / pitch (since that converts the divisor > to > > the frequency and the interfaces that were exposed to userland > exposed > > it in these units in places, continuing the tradition inherited from > SCO > > System V/386 Unix in spots). > > > > In 2009, Ed Shouten was contracted by the FreeBSD Foundation to > write / > > finish newcons. This work was done in perforce and was imported into > > subversion in user/ed/newcons in revision 199072 > > (https://svnweb.freebsd.org/base?view=revision&revision=199072) > which > > was later imported into FreeBSD by ray@ (Aleksandr Rybalko). > > > > From that earliest import into svn import to this date, we ring the > bell > > with: > > sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION); > > where VT_BELLPITCH was defined to be 800. This results in a bell > > frequency of 1491Hz, more or less today. This is similar to the > > frequency that syscons and pcvt used (1493Hz and 1500Hz > respectively). > > This in turn was inherited from 386BSD, it seems, which used the hard > > coded value 0x31b which is 795 -> 1500Hz. > > > > This '800' was intended to be the bell tone (eg 800Hz) and this > > interface was one that wasn't converted. The most common terminal > prior > > to the rise of PCs was the VT100, which had an approximately 800Hz > > bell. Ed Shouten has confirmed that the original intent was 800Hz and > > changing this was overlooked after the change to -current was made. > > This restors that original intent and makes the bell less obnoxious > in > > the process. > > > > Reviewed by: des, adrian > > Differential Revision: https://reviews.freebsd.org/D32594 > > Sponsored by: Netflix > > --- > > sys/dev/vt/vt_core.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c > > index 38efd1e5501c..06f5827078ca 100644 > > --- a/sys/dev/vt/vt_core.c > > +++ b/sys/dev/vt/vt_core.c > > @@ -121,7 +121,7 @@ const struct terminal_class vt_termclass = { > > > > /* Bell pitch/duration. */ > > #define VT_BELLDURATION (SBT_1S / 20) > > -#define VT_BELLPITCH (1193182 / 800) /* Approx 1491Hz */ > > +#define VT_BELLPITCH 800 > > > > #define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS > + \ > > (vw)->vw_number) > > > > -- > Rod Grimes > rgrimes@freebsd.org > --000000000000a2ab7805cff80759-- From nobody Thu Nov 4 15:54: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 ED3521837935; Thu, 4 Nov 2021 15:54:35 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlSrC54MDz3Cws; Thu, 4 Nov 2021 15:54:35 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1mif4N-0005QR-1C; Thu, 04 Nov 2021 18:54:27 +0300 Date: Thu, 4 Nov 2021 18:54:26 +0300 From: Slawa Olhovchenkov To: Warner Losh Cc: "Rodney W. Grimes" , Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org Subject: Re: git: ba48d52ca6c8 - main - vt: Fix frequency calcuation for bell Message-ID: <20211104155426.GD77338@zxy.spb.ru> References: <202111032204.1A3M4K5R066389@gitrepo.freebsd.org> <202111041455.1A4Et1pX029819@gndrsh.dnsmgr.net> 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: User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-Rspamd-Queue-Id: 4HlSrC54MDz3Cws 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 Thu, Nov 04, 2021 at 09:17:38AM -0600, Warner Losh wrote: > On Thu, Nov 4, 2021 at 8:55 AM Rodney W. Grimes > wrote: > > > Thank you Warner for all the legwork on tracking this down and > > getting a proper bell tone working on FreeBSD-Current. I do not > > see any MFC plans for this, can you please consider merging this > > to all supported releases? > > > > I'm merging to 13. The merge was easy. I'm unlikely to merge to 12, > though, because some of these changes are dependent on changing > a system interface that I got conflicts with. If there's a lot of demand > I can plow through the conflicts. > > > > Oh and RELNOTES: YES? > > > > Added. May be now enable bell by default back? From nobody Thu Nov 4 16:02: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 4EC8F183D9A2; Thu, 4 Nov 2021 16:02:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlT1k1n6dz3HFl; Thu, 4 Nov 2021 16:02:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E5FE2EF9A; Thu, 4 Nov 2021 16:02:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A4G2ovR003621; Thu, 4 Nov 2021 16:02:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2o3b003620; Thu, 4 Nov 2021 16:02:50 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:50 GMT Message-Id: <202111041602.1A4G2o3b003620@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: 6325f105aad2 - main - ipq4018: toggle ps-hold to allow SoC reset 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: 6325f105aad2d6d8ba08efe5aff1c860cc7df198 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=6325f105aad2d6d8ba08efe5aff1c860cc7df198 commit 6325f105aad2d6d8ba08efe5aff1c860cc7df198 Author: Adrian Chadd AuthorDate: 2021-10-20 05:33:27 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:21 +0000 ipq4018: toggle ps-hold to allow SoC reset This is enough to allow this ASUS router to reboot successfully. I tried the watchdog path and although it fires, it isn't rebooting! It's just hanging, likely somewhere in TZ. Tested: * ASUS RT-AC58U router, IPQ4019 Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/qualcomm/ipq4018_machdep.c | 42 ++++++++++++++++++++++++++++++++++++++ sys/arm/qualcomm/ipq4018_reg.h | 3 +++ 2 files changed, 45 insertions(+) diff --git a/sys/arm/qualcomm/ipq4018_machdep.c b/sys/arm/qualcomm/ipq4018_machdep.c index b3f841575ebb..39510c8294ae 100644 --- a/sys/arm/qualcomm/ipq4018_machdep.c +++ b/sys/arm/qualcomm/ipq4018_machdep.c @@ -36,10 +36,12 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include @@ -94,12 +96,52 @@ ipq4018_devmap_init(platform_t plat) * a call to pmap_mapdev() when the bus space code is doing its thing. */ devmap_add_entry(IPQ4018_MEM_UART1_START, IPQ4018_MEM_UART1_SIZE); + + /* + * This covers a bunch of the reset block, which includes the PS-HOLD + * register for dropping power. + */ + devmap_add_entry(IPQ4018_MEM_PSHOLD_START, IPQ4018_MEM_PSHOLD_SIZE); + return (0); } +/* + * This toggles the PS-HOLD register which on most IPQ devices will toggle + * the power control block and reset the SoC. + * + * However, there are apparently some units out there where this is not + * appropriate and instead the watchdog needs to be used. + * + * For now since there's only going to be one or two initial supported boards + * this will be fine. But if this doesn't reboot cleanly, now you know. + */ +static void +ipq4018_cpu_reset_pshold(void) +{ + bus_space_handle_t pshold; + + printf("%s: called\n", __func__); + + bus_space_map(fdtbus_bs_tag, IPQ4018_MEM_PSHOLD_START, + IPQ4018_MEM_PSHOLD_SIZE, 0, &pshold); + bus_space_write_4(fdtbus_bs_tag, pshold, 0, 0); + bus_space_barrier(fdtbus_bs_tag, pshold, 0, 0x4, + BUS_SPACE_BARRIER_WRITE); +} + static void ipq4018_cpu_reset(platform_t plat) { + spinlock_enter(); + dsb(); + + ipq4018_cpu_reset_pshold(); + + /* Spin */ + printf("%s: spinning\n", __func__); + while(1) + ; } /* diff --git a/sys/arm/qualcomm/ipq4018_reg.h b/sys/arm/qualcomm/ipq4018_reg.h index 945d650dcfd6..9c09605eab1a 100644 --- a/sys/arm/qualcomm/ipq4018_reg.h +++ b/sys/arm/qualcomm/ipq4018_reg.h @@ -39,4 +39,7 @@ #define IPQ4018_MEM_UART1_START 0x078af000 #define IPQ4018_MEM_UART1_SIZE 0x00001000 +#define IPQ4018_MEM_PSHOLD_START 0x004ab000 +#define IPQ4018_MEM_PSHOLD_SIZE 0x00001000 + #endif From nobody Thu Nov 4 16:02: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 76EF0183DA27; Thu, 4 Nov 2021 16:02: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 4HlT1l3tswz3HDG; Thu, 4 Nov 2021 16:02: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 4D21D2F0F9; Thu, 4 Nov 2021 16:02: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 1A4G2pxk003654; Thu, 4 Nov 2021 16:02:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2p7J003653; Thu, 4 Nov 2021 16:02:51 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:51 GMT Message-Id: <202111041602.1A4G2p7J003653@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: 1492c8c0d825 - main - qcom_rnd: add initial qualcomm prng 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: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1492c8c0d825d1dcd8a2b2975fe35e4269b0b7de Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=1492c8c0d825d1dcd8a2b2975fe35e4269b0b7de commit 1492c8c0d825d1dcd8a2b2975fe35e4269b0b7de Author: Adrian Chadd AuthorDate: 2021-10-21 03:05:10 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:27 +0000 qcom_rnd: add initial qualcomm prng driver. This is the MVP required to initialise and consume random data from the QCA PRNG hardware found on the IPQ401x. Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/dev/qcom_rnd/qcom_rnd.c | 257 ++++++++++++++++++++++++++++++++++++++++ sys/dev/qcom_rnd/qcom_rnd_reg.h | 43 +++++++ sys/sys/random.h | 1 + 3 files changed, 301 insertions(+) diff --git a/sys/dev/qcom_rnd/qcom_rnd.c b/sys/dev/qcom_rnd/qcom_rnd.c new file mode 100644 index 000000000000..c78438a29ba0 --- /dev/null +++ b/sys/dev/qcom_rnd/qcom_rnd.c @@ -0,0 +1,257 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * 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. + */ + +/* Driver for Qualcomm MSM entropy device. */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +struct qcom_rnd_softc { + device_t dev; + int reg_rid; + struct resource *reg; +}; + +static int qcom_rnd_modevent(module_t, int, void *); + +static int qcom_rnd_probe(device_t); +static int qcom_rnd_attach(device_t); +static int qcom_rnd_detach(device_t); + +static int qcom_rnd_harvest(struct qcom_rnd_softc *, void *, size_t *); +static unsigned qcom_rnd_read(void *, unsigned); + +static struct random_source random_qcom_rnd = { + .rs_ident = "Qualcomm Entropy Adapter", + .rs_source = RANDOM_PURE_QUALCOMM, + .rs_read = qcom_rnd_read, +}; + +/* Kludge for API limitations of random(4). */ +static _Atomic(struct qcom_rnd_softc *) g_qcom_rnd_softc; + +static int +qcom_rnd_modevent(module_t mod, int type, void *unused) +{ + int error; + + switch (type) { + case MOD_LOAD: + case MOD_QUIESCE: + case MOD_UNLOAD: + case MOD_SHUTDOWN: + error = 0; + break; + default: + error = EOPNOTSUPP; + break; + } + + return (error); +} + +static int +qcom_rnd_probe(device_t dev) +{ + if (! ofw_bus_status_okay(dev)) { + return (ENXIO); + } + + if (ofw_bus_is_compatible(dev, "qcom,prng") == 0) { + return (ENXIO); + } + + return (0); +} + +static int +qcom_rnd_attach(device_t dev) +{ + struct qcom_rnd_softc *sc, *exp; + uint32_t reg; + + sc = device_get_softc(dev); + + + /* Found a compatible device! */ + + sc->dev = dev; + + exp = NULL; + if (!atomic_compare_exchange_strong_explicit(&g_qcom_rnd_softc, &exp, + sc, memory_order_release, memory_order_acquire)) { + return (ENXIO); + } + + sc->reg_rid = 0; + sc->reg = bus_alloc_resource_anywhere(dev, SYS_RES_MEMORY, + &sc->reg_rid, 0x140, RF_ACTIVE); + if (sc->reg == NULL) { + device_printf(dev, "Couldn't allocate memory resource!\n"); + return (ENXIO); + } + + device_set_desc(dev, "Qualcomm PRNG"); + + /* + * Check to see whether the PRNG has already been setup or not. + */ + bus_barrier(sc->reg, 0, 0x120, BUS_SPACE_BARRIER_READ); + reg = bus_read_4(sc->reg, QCOM_RND_PRNG_CONFIG); + if (reg & QCOM_RND_PRNG_CONFIG_HW_ENABLE) { + device_printf(dev, "PRNG HW already enabled\n"); + } else { + /* + * Do PRNG setup and then enable it. + */ + reg = bus_read_4(sc->reg, QCOM_RND_PRNG_LFSR_CFG); + reg &= QCOM_RND_PRNG_LFSR_CFG_MASK; + reg |= QCOM_RND_PRNG_LFSR_CFG_CLOCKS; + bus_write_4(sc->reg, QCOM_RND_PRNG_LFSR_CFG, reg); + bus_barrier(sc->reg, 0, 0x120, BUS_SPACE_BARRIER_WRITE); + + reg = bus_read_4(sc->reg, QCOM_RND_PRNG_CONFIG); + reg |= QCOM_RND_PRNG_CONFIG_HW_ENABLE; + bus_write_4(sc->reg, QCOM_RND_PRNG_CONFIG, reg); + bus_barrier(sc->reg, 0, 0x120, BUS_SPACE_BARRIER_WRITE); + } + + random_source_register(&random_qcom_rnd); + return (0); + +} + +static int +qcom_rnd_detach(device_t dev) +{ + struct qcom_rnd_softc *sc; + + sc = device_get_softc(dev); + KASSERT( + atomic_load_explicit(&g_qcom_rnd_softc, memory_order_acquire) == sc, + ("only one global instance at a time")); + + random_source_deregister(&random_qcom_rnd); + if (sc->reg != NULL) { + bus_release_resource(sc->dev, SYS_RES_MEMORY, sc->reg_rid, sc->reg); + } + atomic_store_explicit(&g_qcom_rnd_softc, NULL, memory_order_release); + return (0); +} + +static int +qcom_rnd_harvest(struct qcom_rnd_softc *sc, void *buf, size_t *sz) +{ + /* + * Add data to buf until we either run out of entropy or we + * fill the buffer. + * + * Note - be mindful of the provided buffer size; we're reading + * 4 bytes at a time but we only want to supply up to the max + * buffer size, so don't write past it! + */ + size_t rz = 0; + uint32_t reg; + + while (rz < *sz) { + bus_barrier(sc->reg, 0, 0x120, BUS_SPACE_BARRIER_READ); + reg = bus_read_4(sc->reg, QCOM_RND_PRNG_STATUS); + if ((reg & QCOM_RND_PRNG_STATUS_DATA_AVAIL) == 0) + break; + reg = bus_read_4(sc->reg, QCOM_RND_PRNG_DATA_OUT); + memcpy(((char *) buf) + rz, ®, sizeof(uint32_t)); + rz += sizeof(uint32_t); + } + + if (rz == 0) + return (EAGAIN); + *sz = rz; + return (0); +} + +static unsigned +qcom_rnd_read(void *buf, unsigned usz) +{ + struct qcom_rnd_softc *sc; + size_t sz; + int error; + + sc = g_qcom_rnd_softc; + if (sc == NULL) + return (0); + + sz = usz; + error = qcom_rnd_harvest(sc, buf, &sz); + if (error != 0) + return (0); + + return (sz); +} + +static device_method_t qcom_rnd_methods[] = { + /* Device methods. */ + DEVMETHOD(device_probe, qcom_rnd_probe), + DEVMETHOD(device_attach, qcom_rnd_attach), + DEVMETHOD(device_detach, qcom_rnd_detach), + + DEVMETHOD_END +}; + +static driver_t qcom_rnd_driver = { + "qcom_rnd", + qcom_rnd_methods, + sizeof(struct qcom_rnd_softc) +}; +static devclass_t qcom_rnd_devclass; + +DRIVER_MODULE(qcom_rnd_random, simplebus, qcom_rnd_driver, qcom_rnd_devclass, + qcom_rnd_modevent, 0); +DRIVER_MODULE(qcom_rnd_random, ofwbus, qcom_rnd_driver, qcom_rnd_devclass, + qcom_rnd_modevent, 0); +MODULE_DEPEND(qcom_rnd_random, random_device, 1, 1, 1); +MODULE_VERSION(qcom_rnd_random, 1); diff --git a/sys/dev/qcom_rnd/qcom_rnd_reg.h b/sys/dev/qcom_rnd/qcom_rnd_reg.h new file mode 100644 index 000000000000..64cb0d678b6b --- /dev/null +++ b/sys/dev/qcom_rnd/qcom_rnd_reg.h @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * 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. + */ + +#ifndef __QCOM_RND_REG_H__ +#define __QCOM_RND_REG_H__ + +#define QCOM_RND_PRNG_DATA_OUT 0x0000 + +#define QCOM_RND_PRNG_STATUS 0x0004 +#define QCOM_RND_PRNG_STATUS_DATA_AVAIL (1 << 0) + +#define QCOM_RND_PRNG_LFSR_CFG 0x0100 +#define QCOM_RND_PRNG_LFSR_CFG_MASK 0x0000ffff +#define QCOM_RND_PRNG_LFSR_CFG_CLOCKS 0x0000dddd + +#define QCOM_RND_PRNG_CONFIG 0x0104 +#define QCOM_RND_PRNG_CONFIG_HW_ENABLE (1 << 1) + +#endif /* __QCOM_RND_REG_H__ */ diff --git a/sys/sys/random.h b/sys/sys/random.h index e2c4ab144d2a..cfcf4b30e698 100644 --- a/sys/sys/random.h +++ b/sys/sys/random.h @@ -102,6 +102,7 @@ enum random_entropy_source { RANDOM_PURE_DARN, RANDOM_PURE_TPM, RANDOM_PURE_VMGENID, + RANDOM_PURE_QUALCOMM, ENTROPYSOURCE }; _Static_assert(ENTROPYSOURCE <= 32, From nobody Thu Nov 4 16:02: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 E0CE6183D9BB; Thu, 4 Nov 2021 16:02: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 4HlT1m58QXz3HFx; Thu, 4 Nov 2021 16:02: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 5B1072EF9B; Thu, 4 Nov 2021 16:02: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 1A4G2qIR003678; Thu, 4 Nov 2021 16:02:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2qvY003677; Thu, 4 Nov 2021 16:02:52 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:52 GMT Message-Id: <202111041602.1A4G2qvY003677@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: a516ccc4ae04 - main - ipq4018: add SoC reset and qcom_rnd 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: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a516ccc4ae04975a54882651104c4a0369c3eaba Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=a516ccc4ae04975a54882651104c4a0369c3eaba commit a516ccc4ae04975a54882651104c4a0369c3eaba Author: Adrian Chadd AuthorDate: 2021-10-21 03:08:56 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:30 +0000 ipq4018: add SoC reset and qcom_rnd driver Summary: This is enough to allow this ASUS router to reboot successfully. I tried the watchdog path and although it fires, it isn't rebooting! It's just hanging, likely somewhere in TZ. This is the MVP required to initialise and consume random data from the QCA PRNG hardware found on the IPQ401x. Test Plan: * ASUS RT-AC58U router, IPQ4019 Subscribers: imp, andrew Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/std.qca | 3 +++ sys/arm/qualcomm/std.ipq4018 | 2 ++ 2 files changed, 5 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index cabd5f309121..091de6178094 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -12,6 +12,9 @@ files "../qualcomm/std.ipq4018" device uart device uart_msm # Qualcomm MSM UART driver +# Random +device qcom_rnd + device gic # MMC/SD/SDIO Card slot support diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 9a9801fa6415..823d7e74cb50 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -1,2 +1,4 @@ arm/qualcomm/ipq4018_machdep.c standard arm/qualcomm/ipq4018_mp.c optional smp + +dev/qcom_rnd/qcom_rnd.c optional qcom_rnd From nobody Thu Nov 4 16:02: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 A80E3183DB20; Thu, 4 Nov 2021 16:02: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 4HlT1p0czBz3HDb; Thu, 4 Nov 2021 16:02: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 60B772EA76; Thu, 4 Nov 2021 16:02: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 1A4G2ri1003704; Thu, 4 Nov 2021 16:02:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2rEo003703; Thu, 4 Nov 2021 16:02:53 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:53 GMT Message-Id: <202111041602.1A4G2rEo003703@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: 960e65d23aaa - main - qcom: add initial SCM legacy API 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: 960e65d23aaa55dd00255e95f14c2f6256a4fce3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=960e65d23aaa55dd00255e95f14c2f6256a4fce3 commit 960e65d23aaa55dd00255e95f14c2f6256a4fce3 Author: Adrian Chadd AuthorDate: 2021-10-30 03:34:08 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:33 +0000 qcom: add initial SCM legacy API This is a very simple implementation of Qualcomm's SCM API. It is just the structure/field definitions and the atomic SCM call which doesn't use the structs yet - it uses the field definitions inside registers. I've tested that setting the cold boot address via the atomic API is fine - Linux does the same thing. But not all SCM calls can be done via the legacy API. This is a reimplementation based on the Linux qualcomm SCM legacy code and definitions. Tested: * Qualcomm IPQ4018 AP, as part of other changes for doing SMP bring-up Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/std.qca | 3 + sys/arm/qualcomm/qcom_scm_defs.h | 122 ++++++++++++++++++++++++++ sys/arm/qualcomm/qcom_scm_legacy.c | 88 +++++++++++++++++++ sys/arm/qualcomm/qcom_scm_legacy.h | 41 +++++++++ sys/arm/qualcomm/qcom_scm_legacy_defs.h | 149 ++++++++++++++++++++++++++++++++ sys/arm/qualcomm/std.ipq4018 | 1 + 6 files changed, 404 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 091de6178094..00d627b77b7b 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -25,6 +25,9 @@ device sdhci device generic_timer device mpcore_timer +# PSCI - SMC calls, needed for qualcomm SCM +device psci + options FDT # Disable CP14 work in DDB as TZ won't let us by default diff --git a/sys/arm/qualcomm/qcom_scm_defs.h b/sys/arm/qualcomm/qcom_scm_defs.h new file mode 100644 index 000000000000..f4fe0fd76b52 --- /dev/null +++ b/sys/arm/qualcomm/qcom_scm_defs.h @@ -0,0 +1,122 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * 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 __QCOM_SCM_DEFS_H__ +#define __QCOM_SCM_DEFS_H__ + +/* + * Maximum SCM arguments and return values. + */ +#define MAX_QCOM_SCM_ARGS 10 +#define MAX_QCOM_SCM_RETS 3 + +/* + * SCM argument type definitions. + */ +#define QCOM_SCM_ARGTYPE_VAL 0x00 +#define QCOM_SCM_ARGTYPE_RO 0x01 +#define QCOM_SCM_ARGTYPE_RW 0x02 +#define QCOM_SCM_ARGTYPE_BUFVAL 0x03 + +/* + * SCM calls + arguments. + */ +#define QCOM_SCM_SVC_BOOT 0x01 +#define QCOM_SCM_BOOT_SET_ADDR 0x01 +#define QCOM_SCM_BOOT_TERMINATE_PC 0x02 +#define QCOM_SCM_BOOT_SET_DLOAD_MODE 0x10 +#define QCOM_SCM_BOOT_SET_REMOTE_STATE 0x0a +#define QCOM_SCM_FLUSH_FLAG_MASK 0x3 + +/* Flags for QCOM_SCM_BOOT_SET_ADDR argv[0] */ +/* Note: no COLDBOOT for CPU0, it's already booted */ +#define QCOM_SCM_FLAG_COLDBOOT_CPU1 0x01 +#define QCOM_SCM_FLAG_WARMBOOT_CPU1 0x02 +#define QCOM_SCM_FLAG_WARMBOOT_CPU0 0x04 +#define QCOM_SCM_FLAG_COLDBOOT_CPU2 0x08 +#define QCOM_SCM_FLAG_WARMBOOT_CPU2 0x10 +#define QCOM_SCM_FLAG_COLDBOOT_CPU3 0x20 +#define QCOM_SCM_FLAG_WARMBOOT_CPU3 0x40 + +#define QCOM_SCM_SVC_PIL 0x02 +#define QCOM_SCM_PIL_PAS_INIT_IMAGE 0x01 +#define QCOM_SCM_PIL_PAS_MEM_SETUP 0x02 +#define QCOM_SCM_PIL_PAS_AUTH_AND_RESET 0x05 +#define QCOM_SCM_PIL_PAS_SHUTDOWN 0x06 +#define QCOM_SCM_PIL_PAS_IS_SUPPORTED 0x07 +#define QCOM_SCM_PIL_PAS_MSS_RESET 0x0a + +#define QCOM_SCM_SVC_IO 0x05 +#define QCOM_SCM_IO_READ 0x01 +#define QCOM_SCM_IO_WRITE 0x02 + +/* + * Fetch SCM call availability information. + */ +#define QCOM_SCM_SVC_INFO 0x06 +#define QCOM_SCM_INFO_IS_CALL_AVAIL 0x01 + +#define QCOM_SCM_SVC_MP 0x0c +#define QCOM_SCM_MP_RESTORE_SEC_CFG 0x02 +#define QCOM_SCM_MP_IOMMU_SECURE_PTBL_SIZE 0x03 +#define QCOM_SCM_MP_IOMMU_SECURE_PTBL_INIT 0x04 +#define QCOM_SCM_MP_VIDEO_VAR 0x08 +#define QCOM_SCM_MP_ASSIGN 0x16 + +#define QCOM_SCM_SVC_OCMEM 0x0f +#define QCOM_SCM_OCMEM_LOCK_CMD 0x01 +#define QCOM_SCM_OCMEM_UNLOCK_CMD 0x02 + +#define QCOM_SCM_SVC_ES 0x10 +#define QCOM_SCM_ES_INVALIDATE_ICE_KEY 0x03 +#define QCOM_SCM_ES_CONFIG_SET_ICE_KEY 0x04 + +#define QCOM_SCM_SVC_HDCP 0x11 +#define QCOM_SCM_HDCP_INVOKE 0x01 + +#define QCOM_SCM_SVC_LMH 0x13 +#define QCOM_SCM_LMH_LIMIT_PROFILE_CHANGE 0x01 +#define QCOM_SCM_LMH_LIMIT_DCVSH 0x10 + +#define QCOM_SCM_SVC_SMMU_PROGRAM 0x15 +#define QCOM_SCM_SMMU_CONFIG_ERRATA1 0x03 +#define QCOM_SCM_SMMU_CONFIG_ERRATA1_CLIENT_ALL 0x02 + +/* + * Return values from the SCM calls. + */ +#define QCOM_SCM_RETVAL_V2_EBUSY -12 +#define QCOM_SCM_RETVAL_ENOMEM -5 +#define QCOM_SCM_RETVAL_EOPNOTSUPP -4 +#define QCOM_SCM_RETVAL_EINVAL_ADDR -3 +#define QCOM_SCM_RETVAL_EINVAL_ARG -2 +#define QCOM_SCM_RETVAL_ERROR -1 +#define QCOM_SCM_RETVAL_INTERRUPTED 1 + +#endif /* __QCOM_SCM_DEFS_H__ */ diff --git a/sys/arm/qualcomm/qcom_scm_legacy.c b/sys/arm/qualcomm/qcom_scm_legacy.c new file mode 100644 index 000000000000..d773e095185b --- /dev/null +++ b/sys/arm/qualcomm/qcom_scm_legacy.c @@ -0,0 +1,88 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "opt_platform.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +/* + * Set the cold boot address for (later) a mask of CPUs. + * + * Don't set it for CPU0, that CPU is the boot CPU and is already alive. + * + * For now it sets it on CPU1..3. + * + * This works on the IPQ4019 as tested; the retval is 0x0. + */ +uint32_t +qcom_scm_legacy_mp_set_cold_boot_address(vm_offset_t mp_entry_func) +{ + struct arm_smccc_res res; + int ret; + int context_id; + + uint32_t scm_arg0 = QCOM_SCM_LEGACY_ATOMIC_ID(QCOM_SCM_SVC_BOOT, + QCOM_SCM_BOOT_SET_ADDR, 2); + + uint32_t scm_arg1 = QCOM_SCM_FLAG_COLDBOOT_CPU1 + | QCOM_SCM_FLAG_COLDBOOT_CPU2 + | QCOM_SCM_FLAG_COLDBOOT_CPU3; + uint32_t scm_arg2 = pmap_kextract((vm_offset_t)mp_entry_func); + + ret = arm_smccc_smc(scm_arg0, (uint32_t) &context_id, scm_arg1, + scm_arg2, 0, 0, 0, 0, &res); + + if (ret == 0 && res.a0 == 0) + return (0); + printf("%s: called; error; ret=0x%08x; retval[0]=0x%08x\n", + __func__, ret, res.a0); + + return (0); +} diff --git a/sys/arm/qualcomm/qcom_scm_legacy.h b/sys/arm/qualcomm/qcom_scm_legacy.h new file mode 100644 index 000000000000..a0f9d44062cf --- /dev/null +++ b/sys/arm/qualcomm/qcom_scm_legacy.h @@ -0,0 +1,41 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * 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 __QCOM_SCM_LEGACY_H__ +#define __QCOM_SCM_LEGACY_H__ + +/* + * These functions are specific to the 32 bit legacy SCM interface + * used by the IPQ806x and IPQ401x SoCs. + */ + +extern uint32_t qcom_scm_legacy_mp_set_cold_boot_address( + vm_offset_t mp_entry_func); + +#endif /* __QCOM_SCM_LEGACY_H__ */ diff --git a/sys/arm/qualcomm/qcom_scm_legacy_defs.h b/sys/arm/qualcomm/qcom_scm_legacy_defs.h new file mode 100644 index 000000000000..d34a552d4b80 --- /dev/null +++ b/sys/arm/qualcomm/qcom_scm_legacy_defs.h @@ -0,0 +1,149 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * 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 __QCOM_SCM_LEGACY_DEFS_H__ +#define __QCOM_SCM_LEGACY_DEFS_H__ + +/* + * These definitions are specific to the 32 bit legacy SCM interface + * used by the IPQ806x and IPQ401x SoCs. + */ + +/* + * Mapping of the SCM service/command fields into the a0 argument + * in an SMC instruction call. + * + * This is particular to the legacy SCM interface, and is not the + * same as the non-legacy 32/64 bit FNID mapping layout. + */ +#define QCOM_SCM_LEGACY_SMC_FNID(s, c) (((s) << 10) | ((c) & 0x3ff)) + +/* + * There are two kinds of SCM calls in this legacy path. + * + * The first kind are the normal ones - up to a defined max of arguments, + * a defined max of responses and some identifiers for all of it. + * They can be issues in parallel on different cores, can be interrupted, + * etc. + * + * The second kind are what are termed "atomic" SCM calls - + * up to 5 argument DWORDs, up to 3 response DWORDs, done atomically, + * not interruptable/parallel. + * + * The former use the structures below to represent the request and response + * in memory. The latter use defines and a direct SMC call with the + * arguments in registers. + */ + +struct qcom_scm_legacy_smc_args { + uint32_t args[8]; +}; + +/* + * Atomic SCM call command/response buffer definitions. + */ +#define QCOM_SCM_LEGACY_ATOMIC_MAX_ARGCOUNT 5 +#define QCOM_SCM_LEGACY_CLASS_REGISTER (0x2 << 8) +#define QCOM_SCM_LEGACY_MASK_IRQS (1U << 5) + +/* + * Mapping an SCM service/command/argcount into the a0 register + * for an SMC instruction call. + */ +#define QCOM_SCM_LEGACY_ATOMIC_ID(svc, cmd, n) \ + ((QCOM_SCM_LEGACY_SMC_FNID((svc), cmd) << 12) | \ + QCOM_SCM_LEGACY_CLASS_REGISTER | \ + QCOM_SCM_LEGACY_MASK_IRQS | \ + ((n) & 0xf)) + +/* + * Legacy command/response buffer definitions. + * + * The legacy path contains up to the defined maximum arguments + * but only a single command/response pair per call. + * + * A command and response buffer is laid out in memory as such: + * + * | command header | + * | (buffer payload) | + * | response header | + * | (response payload) | + */ + +/* + * The command header. + * + * len - the length of the total command and response, including + * the headers. + * + * buf_offset - the offset inside the buffer, starting at the + * beginning of this command header, where the command buffer + * is found. The end is the byte before the response_header_offset. + * + * response_header_offset - the offset inside the buffer where + * the response header is found. + * + * id - the QCOM_SCM_LEGACY_SMC_FNID() - service/command ids + */ +struct qcom_scm_legacy_command_header { + uint32_t len; + uint32_t buf_offset; + uint32_t response_header_offset; + uint32_t id; +}; + +/* + * The response header. + * + * This is found immediately after the command header and command + * buffer payload. + * + * len - the total amount of memory available for the response. + * Linux doesn't set this; it always passes in a response + * buffer large enough to store MAX_QCOM_SCM_RETS * DWORD + * bytes. + * + * It's also possible this is set by the firmware. + * + * buf_offset - start of response buffer, relative to the beginning + * of the command header. This also isn't set in Linux before + * calling the SMC instruction, but it is checked afterwards + * to assemble a pointer to the response data. The firmware + * likely sets this. + * + * is_complete - true if complete. Linux loops over DMA sync to + * check if this is complete even after the SMC call returns. + */ +struct qcom_scm_legacy_response_header { + uint32_t len; + uint32_t buf_offset; + uint32_t is_complete; +}; + +#endif /* __QCOM_SCM_LEGACY_DEFS_H__ */ diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 823d7e74cb50..6492dbd06b1b 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -1,4 +1,5 @@ arm/qualcomm/ipq4018_machdep.c standard arm/qualcomm/ipq4018_mp.c optional smp +arm/qualcomm/qcom_scm_legacy.c standard dev/qcom_rnd/qcom_rnd.c optional qcom_rnd From nobody Thu Nov 4 16:02: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 6D63D183D9E2; Thu, 4 Nov 2021 16:02: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 4HlT1q69Ytz3HP8; Thu, 4 Nov 2021 16:02: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 72FF82F181; Thu, 4 Nov 2021 16:02:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A4G2sqM003735; Thu, 4 Nov 2021 16:02:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2sDd003734; Thu, 4 Nov 2021 16:02:54 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:54 GMT Message-Id: <202111041602.1A4G2sDd003734@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: d3514c294207 - main - ipq401x: add MP core start-up path for the CPU regulator/clock gate used 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: d3514c294207bd5cda7f4276ebff5235bb239b8a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=d3514c294207bd5cda7f4276ebff5235bb239b8a commit d3514c294207bd5cda7f4276ebff5235bb239b8a Author: Adrian Chadd AuthorDate: 2021-10-30 04:27:02 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:36 +0000 ipq401x: add MP core start-up path for the CPU regulator/clock gate used This code implements the "kpssv2" flavour of CPU regulator/clock gating in Linux. It's used by at least the ipq4018/4019 to power on and off CPU cores. This is based on the Linux implementation - the register definitions and values are from Linux and I've reverse engineered the sequencing requirements. The MP bring-up is: * set cold boot address via an SCM call - this is the address used by the bootloader/TZ firmware to jump to when the CPUs boot * power down the LDO feeding the CPU core and wait for it to settle * program in the right set of LDO and power tree configuration for the CPU regulator to power up the core. Unfortunately these are magic numbers that I've not found documented anywhere. * (I think) power up the shared L2 cache connect if it isn't. * Clamp the power into the core down; put the core into reset * Unclamp the power rail; release reset; and then set the core to boot. The MP core will then boot the bootloader/TZ firmware and then will wait until an incoming interrupt kicks it to start @ mpentry. Tested: * IPQ4019, 4 CPUs Release APs CPU(3) applied BP hardening: not necessary CPU(1) applied BP hardening: not necessary CPU(2) applied BP hardening: not necessary Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/qualcomm/ipq4018_mp.c | 55 +++++++++ sys/arm/qualcomm/qcom_cpu_kpssv2.c | 211 +++++++++++++++++++++++++++++++++ sys/arm/qualcomm/qcom_cpu_kpssv2.h | 35 ++++++ sys/arm/qualcomm/qcom_cpu_kpssv2_reg.h | 58 +++++++++ sys/arm/qualcomm/std.ipq4018 | 1 + 5 files changed, 360 insertions(+) diff --git a/sys/arm/qualcomm/ipq4018_mp.c b/sys/arm/qualcomm/ipq4018_mp.c index 37b7cc3e097d..a7ebb7d7d6c8 100644 --- a/sys/arm/qualcomm/ipq4018_mp.c +++ b/sys/arm/qualcomm/ipq4018_mp.c @@ -35,27 +35,82 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include #include +#include #include #include +#include #include +#include +#include #include "platform_if.h" void ipq4018_mp_setmaxid(platform_t plat) { + int ncpu; + + /* If we've already set the global vars don't bother to do it again. */ + if (mp_ncpus != 0) + return; + + /* Read current CP15 Cache Size ID Register */ + ncpu = cp15_l2ctlr_get(); + ncpu = CPUV7_L2CTLR_NPROC(ncpu); + + mp_ncpus = ncpu; + mp_maxid = ncpu - 1; + + printf("SMP: ncpu=%d\n", ncpu); +} + +static boolean_t +ipq4018_start_ap(u_int id, phandle_t node, u_int addr_cells, pcell_t *arg) +{ + + /* + * For the IPQ401x we assume the enable method is + * "qcom,kpss-acc-v2". If this path gets turned into + * something more generic for other 32 bit qualcomm + * SoCs then we'll likely want to turn this into a + * switch based on "enable-method". + */ + return qcom_cpu_kpssv2_regulator_start(id, node); } void ipq4018_mp_start_ap(platform_t plat) { + int ret; + + /* + * First step - SCM call to set the cold boot address to mpentry, so + * CPUs hopefully start in the MP path. + */ + ret = qcom_scm_legacy_mp_set_cold_boot_address((vm_offset_t) mpentry); + if (ret != 0) + panic("%s: Couldn't set cold boot address via SCM " + "(error 0x%08x)", __func__, ret); + + /* + * Next step - loop over the CPU nodes and do the per-CPU setup + * required to power on the CPUs themselves. + */ + ofw_cpu_early_foreach(ipq4018_start_ap, true); + + /* + * The next set of IPIs to the CPUs will wake them up and enter + * mpentry. + */ } diff --git a/sys/arm/qualcomm/qcom_cpu_kpssv2.c b/sys/arm/qualcomm/qcom_cpu_kpssv2.c new file mode 100644 index 000000000000..4193f952549b --- /dev/null +++ b/sys/arm/qualcomm/qcom_cpu_kpssv2.c @@ -0,0 +1,211 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "opt_platform.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "platform_if.h" + +/* + * Since DELAY() hangs this early, we need some way to + * delay things to settle. + */ +static inline void +loop_delay(int usec) +{ + int lcount = usec * 100000; + + for (volatile int i = 0; i < lcount; i++) + ; +} + +/* + * This is the KPSSv2 (eg IPQ4018) regulator path for CPU + * and shared L2 cache power-on. + */ +boolean_t +qcom_cpu_kpssv2_regulator_start(u_int id, phandle_t node) +{ + phandle_t acc_phandle, l2_phandle, saw_phandle; + bus_space_tag_t acc_tag, saw_tag; + bus_space_handle_t acc_handle, saw_handle; + bus_size_t acc_sz, saw_sz; + ssize_t sret; + int ret; + uint32_t reg_val; + + /* + * We don't need to power up CPU 0! This will power it + * down first and ... then everything hangs. + */ + if (id == 0) + return true; + + /* + * Walk the qcom,acc and next-level-cache entries to find their + * child phandles and thus regulators. + * + * The qcom,acc is a phandle to a node. + * + * The next-level-cache actually is a phandle through to a qcom,saw + * entry. + */ + sret = OF_getencprop(node, "qcom,acc", (void *) &acc_phandle, + sizeof(acc_phandle)); + if (sret != sizeof(acc_phandle)) + panic("***couldn't get phandle for qcom,acc"); + acc_phandle = OF_node_from_xref(acc_phandle); + + sret = OF_getencprop(node, "next-level-cache", (void *) &l2_phandle, + sizeof(l2_phandle)); + if (sret != sizeof(l2_phandle)) + panic("***couldn't get phandle for next-level-cache"); + l2_phandle = OF_node_from_xref(l2_phandle); + + sret = OF_getencprop(l2_phandle, "qcom,saw", (void *) &saw_phandle, + sizeof(saw_phandle)); + if (sret != sizeof(saw_phandle)) + panic("***couldn't get phandle for qcom,saw"); + l2_phandle = OF_node_from_xref(l2_phandle); + + /* + * Now that we have the phandles referencing the correct locations, + * do some KVA mappings so we can go access the registers. + */ + ret = OF_decode_addr(acc_phandle, 0, &acc_tag, &acc_handle, &acc_sz); + if (ret != 0) + panic("*** couldn't map qcom,acc space (%d)", ret); + ret = OF_decode_addr(saw_phandle, 0, &saw_tag, &saw_handle, &saw_sz); + if (ret != 0) + panic("*** couldn't map next-level-cache -> " + "qcom,saw space (%d)", ret); + + /* + * Power sequencing to ensure the cores are off, then power them on + * and bring them out of reset. + */ + + /* + * BHS: off + * LDO: bypassed, powered off + */ + reg_val = (64 << QCOM_APC_PWR_GATE_CTL_BHS_CNT_SHIFT) + | (0x3f << QCOM_APC_PWR_GATE_CTL_LDO_PWR_DWN_SHIFT) + | QCOM_APC_PWR_GATE_CTL_BHS_EN; + bus_space_write_4(acc_tag, acc_handle, QCOM_APC_PWR_GATE_CTL, reg_val); + mb(); + /* Settle time */ + loop_delay(1); + + /* + * Start up BHS segments. + */ + reg_val |= 0x3f << QCOM_APC_PWR_GATE_CTL_BHS_SEG_SHIFT; + bus_space_write_4(acc_tag, acc_handle, QCOM_APC_PWR_GATE_CTL, reg_val); + mb(); + /* Settle time */ + loop_delay(1); + + /* + * Switch on the LDO bypass; BHS will now supply power. + */ + reg_val |= 0x3f << QCOM_APC_PWR_GATE_CTL_LDO_BYP_SHIFT; + bus_space_write_4(acc_tag, acc_handle, QCOM_APC_PWR_GATE_CTL, reg_val); + + /* + * Shared L2 regulator control. + */ + bus_space_write_4(saw_tag, saw_handle, QCOM_APCS_SAW2_2_VCTL, 0x10003); + mb(); + /* Settle time */ + loop_delay(50); + + /* + * Put the core in reset. + */ + reg_val = QCOM_APCS_CPU_PWR_CTL_COREPOR_RST + | QCOM_APCS_CPU_PWR_CTL_CLAMP; + bus_space_write_4(acc_tag, acc_handle, QCOM_APCS_CPU_PWR_CTL, reg_val); + mb(); + loop_delay(2); + + /* + * Remove power-down clamp. + */ + reg_val &= ~QCOM_APCS_CPU_PWR_CTL_CLAMP; + bus_space_write_4(acc_tag, acc_handle, QCOM_APCS_CPU_PWR_CTL, reg_val); + mb(); + loop_delay(2); + + /* + * Clear core power reset. + */ + reg_val &= ~QCOM_APCS_CPU_PWR_CTL_COREPOR_RST; + bus_space_write_4(acc_tag, acc_handle, QCOM_APCS_CPU_PWR_CTL, reg_val); + mb(); + + /* + * The power is ready, the core is out of reset, signal the core + * to power up. + */ + reg_val |= QCOM_APCS_CPU_PWR_CTL_CORE_PWRD_UP; + bus_space_write_4(acc_tag, acc_handle, QCOM_APCS_CPU_PWR_CTL, reg_val); + mb(); + + /* + * Finished with these KVA mappings, so release them. + */ + bus_space_unmap(acc_tag, acc_handle, acc_sz); + bus_space_unmap(saw_tag, saw_handle, saw_sz); + + return true; +} diff --git a/sys/arm/qualcomm/qcom_cpu_kpssv2.h b/sys/arm/qualcomm/qcom_cpu_kpssv2.h new file mode 100644 index 000000000000..18e4affc208e --- /dev/null +++ b/sys/arm/qualcomm/qcom_cpu_kpssv2.h @@ -0,0 +1,35 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * 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 __QCOM_CPU_KPSSV2_H__ +#define __QCOM_CPU_KPSSV2_H__ + +extern boolean_t qcom_cpu_kpssv2_regulator_start(u_int id, phandle_t node); + +#endif /* __QCOM_CPU_KPSSV2_H__ */ diff --git a/sys/arm/qualcomm/qcom_cpu_kpssv2_reg.h b/sys/arm/qualcomm/qcom_cpu_kpssv2_reg.h new file mode 100644 index 000000000000..b966571e9fdd --- /dev/null +++ b/sys/arm/qualcomm/qcom_cpu_kpssv2_reg.h @@ -0,0 +1,58 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * 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 __QCOM_CPU_KPSSV2_REG_H__ +#define __QCOM_CPU_KPSSV2_REG_H__ + + +/* + * APCS CPU core regulator registers. + */ +#define QCOM_APCS_CPU_PWR_CTL 0x04 +#define QCOM_APCS_CPU_PWR_CTL_PLL_CLAMP (1U << 8) +#define QCOM_APCS_CPU_PWR_CTL_CORE_PWRD_UP (1U << 7) +#define QCOM_APCS_CPU_PWR_CTL_COREPOR_RST (1U << 5) +#define QCOM_APCS_CPU_PWR_CTL_CORE_RST (1U << 4) +#define QCOM_APCS_CPU_PWR_CTL_L2DT_SLP (1U << 3) +#define QCOM_APCS_CPU_PWR_CTL_CLAMP (1U << 0) + +#define QCOM_APC_PWR_GATE_CTL 0x14 +#define QCOM_APC_PWR_GATE_CTL_BHS_CNT_SHIFT 24 +#define QCOM_APC_PWR_GATE_CTL_LDO_PWR_DWN_SHIFT 16 +#define QCOM_APC_PWR_GATE_CTL_LDO_BYP_SHIFT 8 +#define QCOM_APC_PWR_GATE_CTL_BHS_SEG_SHIFT 1 +#define QCOM_APC_PWR_GATE_CTL_BHS_EN (1U << 0) + + +/* + * L2 cache regulator registers. + */ +#define QCOM_APCS_SAW2_2_VCTL 0x1c + +#endif /* __QCOM_CPU_KPSSV2_REG_H__ */ diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 6492dbd06b1b..099fd81b5171 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -1,5 +1,6 @@ arm/qualcomm/ipq4018_machdep.c standard arm/qualcomm/ipq4018_mp.c optional smp arm/qualcomm/qcom_scm_legacy.c standard +arm/qualcomm/qcom_cpu_kpssv2.c optional smp dev/qcom_rnd/qcom_rnd.c optional qcom_rnd From nobody Thu Nov 4 16:02: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 4DD42183DC10; Thu, 4 Nov 2021 16:02: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 4HlT1r48btz3HPL; Thu, 4 Nov 2021 16:02: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 855C42F182; Thu, 4 Nov 2021 16:02: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 1A4G2t5W003768; Thu, 4 Nov 2021 16:02:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2tXq003767; Thu, 4 Nov 2021 16:02:55 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:55 GMT Message-Id: <202111041602.1A4G2tXq003767@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: bc06496744a1 - main - ipq401x: flip on SMP for the ASUS AC1300 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: bc06496744a1a658c1cd9c6488dd23326b52390e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=bc06496744a1a658c1cd9c6488dd23326b52390e commit bc06496744a1a658c1cd9c6488dd23326b52390e Author: Adrian Chadd AuthorDate: 2021-10-30 04:31:50 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:38 +0000 ipq401x: flip on SMP for the ASUS AC1300 This actually enables SMP and yes it boots. Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/ASUS_AC1300 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/arm/conf/ASUS_AC1300 b/sys/arm/conf/ASUS_AC1300 index 73d3d9f37eb7..67ee0b541c2e 100644 --- a/sys/arm/conf/ASUS_AC1300 +++ b/sys/arm/conf/ASUS_AC1300 @@ -38,8 +38,7 @@ makeoptions FDT_DTS_FILE=qcom-ipq4018-rt-ac58u.dts options LINUX_BOOT_ABI options SCHED_ULE -# DEFINITELY not ready for SMP yet! -# options SMP +options SMP options PLATFORM device loop @@ -50,3 +49,4 @@ device gpio device ether device mii device bpf + From nobody Thu Nov 4 16:02: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 19B75183DB5A; Thu, 4 Nov 2021 16:02: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 4HlT1t3MPLz3HPS; Thu, 4 Nov 2021 16:02: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 9B87C2EF4F; Thu, 4 Nov 2021 16:02: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 1A4G2uQN003792; Thu, 4 Nov 2021 16:02:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2ubJ003791; Thu, 4 Nov 2021 16:02:56 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:56 GMT Message-Id: <202111041602.1A4G2ubJ003791@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: b12a863a1e14 - main - ipq4018: add initial reset driver support for the clock/reset controller. 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: b12a863a1e14610f6b145f235aa7452602038f9a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=b12a863a1e14610f6b145f235aa7452602038f9a commit b12a863a1e14610f6b145f235aa7452602038f9a Author: Adrian Chadd AuthorDate: 2021-10-31 03:43:27 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:41 +0000 ipq4018: add initial reset driver support for the clock/reset controller. This implements the "reset controller" side of the clock/reset controller. It's a simple array of registers and bits to set. The register table itself comes from Linux; the rest of the code is a reimplementation. It doesn't yet implement or expose the clock side - I have a lot of reverse engineering to do before that! Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 Obtained from: Linux (registers) --- sys/arm/qualcomm/qcom_gcc_ipq4018.c | 167 +++++++++++++++++++++++++++ sys/arm/qualcomm/qcom_gcc_ipq4018_reset.c | 181 ++++++++++++++++++++++++++++++ sys/arm/qualcomm/qcom_gcc_ipq4018_var.h | 50 +++++++++ sys/arm/qualcomm/std.ipq4018 | 3 + 4 files changed, 401 insertions(+) diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018.c b/sys/arm/qualcomm/qcom_gcc_ipq4018.c new file mode 100644 index 000000000000..3002ae32a597 --- /dev/null +++ b/sys/arm/qualcomm/qcom_gcc_ipq4018.c @@ -0,0 +1,167 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * 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. + */ + +/* Driver for Qualcomm IPQ4018 clock and reset device */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include "hwreset_if.h" + +#include + +#include + + +static int qcom_gcc_ipq4018_modevent(module_t, int, void *); + +static int qcom_gcc_ipq4018_probe(device_t); +static int qcom_gcc_ipq4018_attach(device_t); +static int qcom_gcc_ipq4018_detach(device_t); + +static int +qcom_gcc_ipq4018_modevent(module_t mod, int type, void *unused) +{ + int error; + + switch (type) { + case MOD_LOAD: + case MOD_QUIESCE: + case MOD_UNLOAD: + case MOD_SHUTDOWN: + error = 0; + break; + default: + error = EOPNOTSUPP; + break; + } + + return (error); +} + +static int +qcom_gcc_ipq4018_probe(device_t dev) +{ + if (! ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_is_compatible(dev, "qcom,gcc-ipq4019") == 0) + return (ENXIO); + + return (0); +} + +static int +qcom_gcc_ipq4018_attach(device_t dev) +{ + struct qcom_gcc_ipq4018_softc *sc; + + sc = device_get_softc(dev); + + /* Found a compatible device! */ + sc->dev = dev; + + sc->reg_rid = 0; + sc->reg = bus_alloc_resource_anywhere(dev, SYS_RES_MEMORY, + &sc->reg_rid, 0x60000, RF_ACTIVE); + if (sc->reg == NULL) { + device_printf(dev, "Couldn't allocate memory resource!\n"); + return (ENXIO); + } + + device_set_desc(dev, "Qualcomm IPQ4018 Clock/Reset Controller"); + + mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); + + /* + * Register as a reset provider. + */ + hwreset_register_ofw_provider(dev); + + return (0); +} + +static int +qcom_gcc_ipq4018_detach(device_t dev) +{ + struct qcom_gcc_ipq4018_softc *sc; + + sc = device_get_softc(dev); + + if (sc->reg != NULL) { + bus_release_resource(sc->dev, SYS_RES_MEMORY, + sc->reg_rid, sc->reg); + } + return (0); +} + +static device_method_t qcom_gcc_ipq4018_methods[] = { + /* Device methods. */ + DEVMETHOD(device_probe, qcom_gcc_ipq4018_probe), + DEVMETHOD(device_attach, qcom_gcc_ipq4018_attach), + DEVMETHOD(device_detach, qcom_gcc_ipq4018_detach), + + /* Reset interface */ + DEVMETHOD(hwreset_assert, qcom_gcc_ipq4018_hwreset_assert), + DEVMETHOD(hwreset_is_asserted, qcom_gcc_ipq4018_hwreset_is_asserted), + + DEVMETHOD_END +}; + +static driver_t qcom_gcc_ipq4018_driver = { + "qcom_gcc", + qcom_gcc_ipq4018_methods, + sizeof(struct qcom_gcc_ipq4018_softc) +}; +static devclass_t qcom_gcc_ipq4018_devclass; + +EARLY_DRIVER_MODULE(qcom_gcc_ipq4018, simplebus, qcom_gcc_ipq4018_driver, + qcom_gcc_ipq4018_devclass, qcom_gcc_ipq4018_modevent, 0, + BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); +EARLY_DRIVER_MODULE(qcom_gcc_ipq4018, ofwbus, qcom_gcc_ipq4018_driver, + qcom_gcc_ipq4018_devclass, qcom_gcc_ipq4018_modevent, 0, + BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); +MODULE_VERSION(qcom_gcc_ipq4018_random, 1); diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018_reset.c b/sys/arm/qualcomm/qcom_gcc_ipq4018_reset.c new file mode 100644 index 000000000000..754e7636ff6e --- /dev/null +++ b/sys/arm/qualcomm/qcom_gcc_ipq4018_reset.c @@ -0,0 +1,181 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * 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. + */ + +/* Driver for Qualcomm IPQ4018 clock and reset device */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include "hwreset_if.h" + +#include + +#include + + +static const struct qcom_gcc_ipq4018_reset_entry gcc_ipq4019_reset_list[] = { + [WIFI0_CPU_INIT_RESET] = { 0x1f008, 5 }, + [WIFI0_RADIO_SRIF_RESET] = { 0x1f008, 4 }, + [WIFI0_RADIO_WARM_RESET] = { 0x1f008, 3 }, + [WIFI0_RADIO_COLD_RESET] = { 0x1f008, 2 }, + [WIFI0_CORE_WARM_RESET] = { 0x1f008, 1 }, + [WIFI0_CORE_COLD_RESET] = { 0x1f008, 0 }, + [WIFI1_CPU_INIT_RESET] = { 0x20008, 5 }, + [WIFI1_RADIO_SRIF_RESET] = { 0x20008, 4 }, + [WIFI1_RADIO_WARM_RESET] = { 0x20008, 3 }, + [WIFI1_RADIO_COLD_RESET] = { 0x20008, 2 }, + [WIFI1_CORE_WARM_RESET] = { 0x20008, 1 }, + [WIFI1_CORE_COLD_RESET] = { 0x20008, 0 }, + [USB3_UNIPHY_PHY_ARES] = { 0x1e038, 5 }, + [USB3_HSPHY_POR_ARES] = { 0x1e038, 4 }, + [USB3_HSPHY_S_ARES] = { 0x1e038, 2 }, + [USB2_HSPHY_POR_ARES] = { 0x1e01c, 4 }, + [USB2_HSPHY_S_ARES] = { 0x1e01c, 2 }, + [PCIE_PHY_AHB_ARES] = { 0x1d010, 11 }, + [PCIE_AHB_ARES] = { 0x1d010, 10 }, + [PCIE_PWR_ARES] = { 0x1d010, 9 }, + [PCIE_PIPE_STICKY_ARES] = { 0x1d010, 8 }, + [PCIE_AXI_M_STICKY_ARES] = { 0x1d010, 7 }, + [PCIE_PHY_ARES] = { 0x1d010, 6 }, + [PCIE_PARF_XPU_ARES] = { 0x1d010, 5 }, + [PCIE_AXI_S_XPU_ARES] = { 0x1d010, 4 }, + [PCIE_AXI_M_VMIDMT_ARES] = { 0x1d010, 3 }, + [PCIE_PIPE_ARES] = { 0x1d010, 2 }, + [PCIE_AXI_S_ARES] = { 0x1d010, 1 }, + [PCIE_AXI_M_ARES] = { 0x1d010, 0 }, + [ESS_RESET] = { 0x12008, 0}, + [GCC_BLSP1_BCR] = {0x01000, 0}, + [GCC_BLSP1_QUP1_BCR] = {0x02000, 0}, + [GCC_BLSP1_UART1_BCR] = {0x02038, 0}, + [GCC_BLSP1_QUP2_BCR] = {0x03008, 0}, + [GCC_BLSP1_UART2_BCR] = {0x03028, 0}, + [GCC_BIMC_BCR] = {0x04000, 0}, + [GCC_TLMM_BCR] = {0x05000, 0}, + [GCC_IMEM_BCR] = {0x0E000, 0}, + [GCC_ESS_BCR] = {0x12008, 0}, + [GCC_PRNG_BCR] = {0x13000, 0}, + [GCC_BOOT_ROM_BCR] = {0x13008, 0}, + [GCC_CRYPTO_BCR] = {0x16000, 0}, + [GCC_SDCC1_BCR] = {0x18000, 0}, + [GCC_SEC_CTRL_BCR] = {0x1A000, 0}, + [GCC_AUDIO_BCR] = {0x1B008, 0}, + [GCC_QPIC_BCR] = {0x1C000, 0}, + [GCC_PCIE_BCR] = {0x1D000, 0}, + [GCC_USB2_BCR] = {0x1E008, 0}, + [GCC_USB2_PHY_BCR] = {0x1E018, 0}, + [GCC_USB3_BCR] = {0x1E024, 0}, + [GCC_USB3_PHY_BCR] = {0x1E034, 0}, + [GCC_SYSTEM_NOC_BCR] = {0x21000, 0}, + [GCC_PCNOC_BCR] = {0x2102C, 0}, + [GCC_DCD_BCR] = {0x21038, 0}, + [GCC_SNOC_BUS_TIMEOUT0_BCR] = {0x21064, 0}, + [GCC_SNOC_BUS_TIMEOUT1_BCR] = {0x2106C, 0}, + [GCC_SNOC_BUS_TIMEOUT2_BCR] = {0x21074, 0}, + [GCC_SNOC_BUS_TIMEOUT3_BCR] = {0x2107C, 0}, + [GCC_PCNOC_BUS_TIMEOUT0_BCR] = {0x21084, 0}, + [GCC_PCNOC_BUS_TIMEOUT1_BCR] = {0x2108C, 0}, + [GCC_PCNOC_BUS_TIMEOUT2_BCR] = {0x21094, 0}, + [GCC_PCNOC_BUS_TIMEOUT3_BCR] = {0x2109C, 0}, + [GCC_PCNOC_BUS_TIMEOUT4_BCR] = {0x210A4, 0}, + [GCC_PCNOC_BUS_TIMEOUT5_BCR] = {0x210AC, 0}, + [GCC_PCNOC_BUS_TIMEOUT6_BCR] = {0x210B4, 0}, + [GCC_PCNOC_BUS_TIMEOUT7_BCR] = {0x210BC, 0}, + [GCC_PCNOC_BUS_TIMEOUT8_BCR] = {0x210C4, 0}, + [GCC_PCNOC_BUS_TIMEOUT9_BCR] = {0x210CC, 0}, + [GCC_TCSR_BCR] = {0x22000, 0}, + [GCC_MPM_BCR] = {0x24000, 0}, + [GCC_SPDM_BCR] = {0x25000, 0}, +}; + +int +qcom_gcc_ipq4018_hwreset_assert(device_t dev, intptr_t id, bool reset) +{ + struct qcom_gcc_ipq4018_softc *sc; + uint32_t reg; + + sc = device_get_softc(dev); + + if (id > nitems(gcc_ipq4019_reset_list)) { + device_printf(dev, "%s: invalid id (%d)\n", __func__, id); + return (EINVAL); + } + + device_printf(dev, "%s: called; id=%d, reset=%d\n", __func__, id, reset); + mtx_lock(&sc->mtx); + reg = bus_read_4(sc->reg, gcc_ipq4019_reset_list[id].reg); + if (reset) + reg |= (1U << gcc_ipq4019_reset_list[id].bit); + else + reg &= ~(1U << gcc_ipq4019_reset_list[id].bit); + bus_write_4(sc->reg, gcc_ipq4019_reset_list[id].reg, reg); + mtx_unlock(&sc->mtx); + return (0); +} + +int +qcom_gcc_ipq4018_hwreset_is_asserted(device_t dev, intptr_t id, bool *reset) +{ + struct qcom_gcc_ipq4018_softc *sc; + uint32_t reg; + + sc = device_get_softc(dev); + + if (id > nitems(gcc_ipq4019_reset_list)) { + device_printf(dev, "%s: invalid id (%d)\n", __func__, id); + return (EINVAL); + } + mtx_lock(&sc->mtx); + reg = bus_read_4(sc->reg, gcc_ipq4019_reset_list[id].reg); + if (reg & ((1U << gcc_ipq4019_reset_list[id].bit))) + *reset = true; + else + *reset = false; + mtx_unlock(&sc->mtx); + + device_printf(dev, "called; id=%d\n", id); + return (0); +} + diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018_var.h b/sys/arm/qualcomm/qcom_gcc_ipq4018_var.h new file mode 100644 index 000000000000..3997e1860e43 --- /dev/null +++ b/sys/arm/qualcomm/qcom_gcc_ipq4018_var.h @@ -0,0 +1,50 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Adrian Chadd + * + * 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 __QCOM_GCC_IPQ4018_VAR_H__ +#define __QCOM_GCC_IPQ4018_VAR_H__ + +struct qcom_gcc_ipq4018_reset_entry { + uint32_t reg; + uint32_t bit; +}; + +struct qcom_gcc_ipq4018_softc { + device_t dev; + int reg_rid; + struct resource *reg; + struct mtx mtx; +}; + +extern int qcom_gcc_ipq4018_hwreset_assert(device_t dev, intptr_t id, + bool reset); +extern int qcom_gcc_ipq4018_hwreset_is_asserted(device_t dev, intptr_t id, + bool *reset); + +#endif /* __QCOM_GCC_IPQ4018_VAR_H__ */ diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 099fd81b5171..7e8ac39e7222 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -4,3 +4,6 @@ arm/qualcomm/qcom_scm_legacy.c standard arm/qualcomm/qcom_cpu_kpssv2.c optional smp dev/qcom_rnd/qcom_rnd.c optional qcom_rnd +arm/qualcomm/qcom_gcc_ipq4018.c optional qcom_gcc_ipq4018 +arm/qualcomm/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 + From nobody Thu Nov 4 16:02: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 AD7A0183DC50; Thu, 4 Nov 2021 16:03: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 4HlT1w1bGMz3HRy; Thu, 4 Nov 2021 16:03: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 BEAB42EF9C; Thu, 4 Nov 2021 16:02: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 1A4G2vXJ003816; Thu, 4 Nov 2021 16:02:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G2vMG003815; Thu, 4 Nov 2021 16:02:57 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:02:57 GMT Message-Id: <202111041602.1A4G2vMG003815@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: cfd06987029a - main - ipq4018: add qcom-gcc-ipq4018 and dependencies into the 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: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cfd06987029ac1bf5f6a6be2d87ade7358bd59ca Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=cfd06987029ac1bf5f6a6be2d87ade7358bd59ca commit cfd06987029ac1bf5f6a6be2d87ade7358bd59ca Author: Adrian Chadd AuthorDate: 2021-10-31 03:45:17 +0000 Commit: Adrian Chadd CommitDate: 2021-11-04 16:02:43 +0000 ipq4018: add qcom-gcc-ipq4018 and dependencies into the build * add the extres stuff into the build, I'm going to end up leveraging all of it * include the qcom-gcc-ipq4018 driver which currently implements the hwreset side of the API. Reviewed by: andrew, manu, imp Differential Revision: https://reviews.freebsd.org/D32723 --- sys/arm/conf/std.qca | 12 +++++ sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c | 82 +++++++++++++++++++++++++++++++ sys/arm/qualcomm/std.ipq4018 | 1 + 3 files changed, 95 insertions(+) diff --git a/sys/arm/conf/std.qca b/sys/arm/conf/std.qca index 00d627b77b7b..09cd61078870 100644 --- a/sys/arm/conf/std.qca +++ b/sys/arm/conf/std.qca @@ -12,6 +12,15 @@ files "../qualcomm/std.ipq4018" device uart device uart_msm # Qualcomm MSM UART driver +# EXT_RESOURCES pseudo devices +options EXT_RESOURCES +device clk +device phy +device hwreset +device nvmem +device regulator +device syscon + # Random device qcom_rnd @@ -28,6 +37,9 @@ device mpcore_timer # PSCI - SMC calls, needed for qualcomm SCM device psci +# Clock/Reset provider +device qcom_gcc_ipq4018 + options FDT # Disable CP14 work in DDB as TZ won't let us by default diff --git a/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c b/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c new file mode 100644 index 000000000000..f7f7a6c348ba --- /dev/null +++ b/sys/arm/qualcomm/qcom_gcc_ipq4018_clock.c @@ -0,0 +1,82 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021, Adrian Chadd + * + * 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. + */ + +/* Driver for Qualcomm IPQ4018 clock and reset device */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include + + +/* + * Fixed frequency clock sources: + * + * P_XO - 48MHz + * sleep-clk - is really 32KHz, although older DTS have it as 32.768KHz + */ + +/* + * PLL derived sources: + * + * P_FEPLL125 - 125MHz + * P_FEPLL125DLY - 125MHz + * P_FEPLL200 - 200MHz + * P_FEPLL500 - 500MHz + * P_FEPLLWCSS2G - TBD + * P_FEPLLWCSS5G - TBD + * + * Then there are two DDR PLLs which are treated/configured slightly + * differently: + * + * P_DDRPLLAPSS - TBD + * P_DDRPLLSDCC - TBD + */ + +/* + * Interesting stuff in Linux whilst I reverse engineer + figure it out: + * /sys/kernel/debug/clk + */ diff --git a/sys/arm/qualcomm/std.ipq4018 b/sys/arm/qualcomm/std.ipq4018 index 7e8ac39e7222..913314e92301 100644 --- a/sys/arm/qualcomm/std.ipq4018 +++ b/sys/arm/qualcomm/std.ipq4018 @@ -6,4 +6,5 @@ arm/qualcomm/qcom_cpu_kpssv2.c optional smp dev/qcom_rnd/qcom_rnd.c optional qcom_rnd arm/qualcomm/qcom_gcc_ipq4018.c optional qcom_gcc_ipq4018 arm/qualcomm/qcom_gcc_ipq4018_reset.c optional qcom_gcc_ipq4018 +arm/qualcomm/qcom_gcc_ipq4018_clock.c optional qcom_gcc_ipq4018 From nobody Thu Nov 4 16:05: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 1CBC4183FC7D; Thu, 4 Nov 2021 16:05:42 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlT5153Zcz3LPL; Thu, 4 Nov 2021 16:05:41 +0000 (UTC) (envelope-from danfe@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1636041941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/UHDU30xqs/5RLhpR0Y4IMl6Ktb7yxW5jDl5Ul8J44s=; b=k8rKAykDi5HMmWP0K7xRIbr10iX2MynYsD+76VJgpvIqhAcEhNAniLHDjm79AMvvkfgNpF Ys7mMa4HCTp55vaQ4PL/LlXFnziZdgKeMSWrBOLg6nYe2jwKHByEZhPZAfLB7m+snK+th4 zY62zooqXg64NJoABp4MYaMpluWIJoHyNvd9wF3J7TCkU2y1iB6c8rvX/lgpAicNooIwjz lAFSGVakf4whqlf/LjhFPC+x/0jNAs/ANfWTzYOpY6i0ZWJmqN6qxScNy7MKLlT5Fcm2gP TxT2Au3A0rZkIiPAyDg+8RtIsHI6GlwX0KagO4BGuhJHQXbmYufzCiLIJ8o2ng== Received: by freefall.freebsd.org (Postfix, from userid 1033) id 790D61D18A; Thu, 4 Nov 2021 16:05:41 +0000 (UTC) Date: Thu, 4 Nov 2021 16:05:41 +0000 From: Alexey Dokuchaev To: Slawa Olhovchenkov Cc: Warner Losh , "Rodney W. Grimes" , Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org Subject: Re: git: ba48d52ca6c8 - main - vt: Fix frequency calcuation for bell Message-ID: References: <202111032204.1A3M4K5R066389@gitrepo.freebsd.org> <202111041455.1A4Et1pX029819@gndrsh.dnsmgr.net> <20211104155426.GD77338@zxy.spb.ru> 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: <20211104155426.GD77338@zxy.spb.ru> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1636041941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/UHDU30xqs/5RLhpR0Y4IMl6Ktb7yxW5jDl5Ul8J44s=; b=I2XxOKuZL1/mCR6VwxC02ZSeF2hArgr6tEXNp4nJgq9nmILbCviCil89HTgUw06sCVulWB tI52aLxqAdfkMKBjrXlDgJbKu6kKABGAhXJ2pwd9rcA8mcg6dbldHZ8inyhZmh3nDe9EEK StkDcWc6UNzPGY5Mf371k0kRbS/VdtWu4i5Ns+QYpUSNFvasmPegDUjL6cGKBYeAF6cWv4 lnp2giWMz4E4ssaa63mIGTtoH1I6iJXUYSvjtfL+g1JKQOlx6OvlWGKqHGIv4T/Kcm/vlY u1WcZeuT20cpL1s1RmZS8Y5M1di9ORty1UweTMqiBzeEObieH8ZDEgLZ7KfnXw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1636041941; a=rsa-sha256; cv=none; b=e6Ekff73tyMzOOAfoI/D61MX8/A8O5cJgisz7qqo31lkZ2au/Z+ujp19iJ5y+MtmiHK/Hb z82cCpW5non5ulF0VYJ/tx8KrGWox8GeVzCfoBCn+L9p8ILgo+X1e84acR9V/721KHdIXi PFXUuQVKSVIAw4jTzNqrFwggahpFtGKF99FJdG1fCipiUeqniSjJoJ5ylvoKBJ6Rxv2llE bM8NxKU4GrSmesH+JejCtiZkdLeLPXr/YGkcUWP9QNS1e6OnGurQLg9qZi7Ez45fO3SVMV 14OSZB9Ip/L27R+PrsuuQWRuDMV1i7SwLRL8hJf5MGtgzL3Rwh9TdVEnWtmKcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N On Thu, Nov 04, 2021 at 06:54:26PM +0300, Slawa Olhovchenkov wrote: > On Thu, Nov 04, 2021 at 09:17:38AM -0600, Warner Losh wrote: > > On Thu, Nov 4, 2021 at 8:55 AM Rodney W. Grimes wrote: > > > Thank you Warner for all the legwork on tracking this down and > > > getting a proper bell tone working on FreeBSD-Current. I do not > > > see any MFC plans for this, can you please consider merging this > > > to all supported releases? > > > > I'm merging to 13. The merge was easy. > > Maybe now enable bell by default back? Yes please. ./danfe From nobody Thu Nov 4 16:08: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 5D5C21840EB8; Thu, 4 Nov 2021 16:08: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 4HlT8n29qbz3MQM; Thu, 4 Nov 2021 16:08: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 2C5D32EFA1; Thu, 4 Nov 2021 16:08: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 1A4G8vjx004402; Thu, 4 Nov 2021 16:08:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4G8vGX004401; Thu, 4 Nov 2021 16:08:57 GMT (envelope-from git) Date: Thu, 4 Nov 2021 16:08:57 GMT Message-Id: <202111041608.1A4G8vGX004401@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: 305ef653bcf3 - main - efi: switch boot_services_gone to boot_services_active 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: 305ef653bcf349c7dea83c90add6f2d97910e545 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=305ef653bcf349c7dea83c90add6f2d97910e545 commit 305ef653bcf349c7dea83c90add6f2d97910e545 Author: Warner Losh AuthorDate: 2021-11-04 15:34:20 +0000 Commit: Warner Losh CommitDate: 2021-11-04 16:07:54 +0000 efi: switch boot_services_gone to boot_services_active Turn the presence or absence of boot services into a positive bool (and change its type to bool). Move declaration to efi.h in the global variables section. Sponsored by: Netflix Reviewed by: tsoome, kib Differential Revision: https://reviews.freebsd.org/D31814 --- stand/common/gfx_fb.c | 10 ++++++---- stand/efi/include/efi.h | 2 ++ stand/efi/libefi/efi_console.c | 23 +++++++++++------------ stand/efi/loader/bootinfo.c | 4 +--- stand/efi/loader/copy.c | 4 +--- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index 99968e10d8fe..d13a627e1a74 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -751,14 +751,16 @@ gfxfb_blt(void *BltBuffer, GFXFB_BLT_OPERATION BltOperation, #if defined(EFI) EFI_STATUS status; EFI_GRAPHICS_OUTPUT *gop = gfx_state.tg_private; - extern int boot_services_gone; EFI_TPL tpl; /* - * We assume Blt() does work, if not, we will need to build - * exception list case by case. + * We assume Blt() does work, if not, we will need to build exception + * list case by case. We only have boot services during part of our + * exectution. Once terminate boot services, these operations cannot be + * done as they are provided by protocols that disappear when exit + * boot services. */ - if (gop != NULL && boot_services_gone == 0) { + if (gop != NULL && boot_services_active) { tpl = BS->RaiseTPL(TPL_NOTIFY); switch (BltOperation) { case GfxFbBltVideoFill: diff --git a/stand/efi/include/efi.h b/stand/efi/include/efi.h index fe8d78286529..7e44a5b819fc 100644 --- a/stand/efi/include/efi.h +++ b/stand/efi/include/efi.h @@ -60,11 +60,13 @@ Revision History #include "efitcp.h" #include "efipoint.h" #include "efiuga.h" +#include /* * Global variables */ extern EFI_LOADED_IMAGE *boot_img; +extern bool boot_services_active; /* * FreeBSD UUID diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c index bacc2546e070..a63cba5e3f34 100644 --- a/stand/efi/libefi/efi_console.c +++ b/stand/efi/libefi/efi_console.c @@ -37,14 +37,15 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" -extern int boot_services_gone; extern EFI_GUID gop_guid; + +bool boot_services_active = true; /* boot services active first thing in main */ + static EFI_GUID simple_input_ex_guid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; static SIMPLE_INPUT_INTERFACE *conin; static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *coninex; static bool efi_started; - static int mode; /* Does ConOut have serial console? */ static uint32_t utf8_left; @@ -177,7 +178,7 @@ efi_text_cursor(void *arg, const teken_pos_t *p) teken_gfx_t *state = arg; UINTN col, row; - if (boot_services_gone) + if (!boot_services_active) return; row = p->tp_row; @@ -238,7 +239,7 @@ efi_text_putchar(void *s, const teken_pos_t *p, teken_char_t c, EFI_STATUS status; int idx; - if (boot_services_gone) + if (!boot_services_active) return; idx = p->tp_col + p->tp_row * state->tg_tp.tp_col; @@ -258,7 +259,7 @@ efi_text_fill(void *arg, const teken_rect_t *r, teken_char_t c, teken_gfx_t *state = arg; teken_pos_t p; - if (boot_services_gone) + if (!boot_services_active) return; if (state->tg_cursor_visible) @@ -313,7 +314,7 @@ efi_text_copy(void *arg, const teken_rect_t *r, const teken_pos_t *p) int nrow, ncol, x, y; /* Has to be signed - >= 0 comparison */ bool scroll = false; - if (boot_services_gone) + if (!boot_services_active) return; /* @@ -369,7 +370,7 @@ efi_text_param(void *arg, int cmd, unsigned int value) { teken_gfx_t *state = arg; - if (boot_services_gone) + if (!boot_services_active) return; switch (cmd) { @@ -739,6 +740,8 @@ get_arg(int c) static void efi_term_emu(int c) { + if (!boot_services_active) + return; #ifdef TERM_EMU static int ansi_col[] = { 0, 4, 2, 6, 1, 5, 3, 7 @@ -746,9 +749,6 @@ efi_term_emu(int c) int t, i; EFI_STATUS status; - if (boot_services_gone) - return; - switch (esc) { case 0: switch (c) { @@ -858,8 +858,7 @@ efi_term_emu(int c) break; } #else - if (!boot_services_gone) - efi_cons_rawputchar(c); + efi_cons_rawputchar(c); #endif } diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index 15b5d86f82b6..5213b328d712 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -63,8 +63,6 @@ __FBSDID("$FreeBSD$"); int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs); -int boot_services_gone; - static int bi_getboothowto(char *kargs) { @@ -397,7 +395,7 @@ bi_load_efi_data(struct preloaded_file *kfp, bool exit_bs) break; status = BS->ExitBootServices(IH, efi_mapkey); if (!EFI_ERROR(status)) { - boot_services_gone = 1; + boot_services_active = false; break; } } diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index 2552ae86d966..47e613ccc2f3 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -42,8 +42,6 @@ __FBSDID("$FreeBSD$"); #define M(x) ((x) * 1024 * 1024) #define G(x) (1UL * (x) * 1024 * 1024 * 1024) -extern int boot_services_gone; - #if defined(__i386__) || defined(__amd64__) #include #include @@ -370,7 +368,7 @@ efi_check_space(vm_offset_t end) if (end + staging_slop <= staging_end) return (true); - if (boot_services_gone) { + if (!boot_services_active) { if (end <= staging_end) return (true); panic("efi_check_space: cannot expand staging area " From nobody Thu Nov 4 17:01: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 38FE4183C148; Thu, 4 Nov 2021 17:01: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 4HlVKz0zBXz4RxH; Thu, 4 Nov 2021 17:01: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 01DCF2FBBD; Thu, 4 Nov 2021 17:01: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 1A4H1wCU080136; Thu, 4 Nov 2021 17:01:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4H1wRK080135; Thu, 4 Nov 2021 17:01:58 GMT (envelope-from git) Date: Thu, 4 Nov 2021 17:01:58 GMT Message-Id: <202111041701.1A4H1wRK080135@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: e9a994639b2a - main - ssh: enable FIDO/U2F keys 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: e9a994639b2af232f994ba2ad23ca45a17718d2b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=e9a994639b2af232f994ba2ad23ca45a17718d2b commit e9a994639b2af232f994ba2ad23ca45a17718d2b Author: Ed Maste AuthorDate: 2021-10-07 03:31:17 +0000 Commit: Ed Maste CommitDate: 2021-11-04 17:01:44 +0000 ssh: enable FIDO/U2F keys Description of FIDO/U2F support (from OpenSSH 8.2 release notes, https://www.openssh.com/txt/release-8.2): This release adds support for FIDO/U2F hardware authenticators to OpenSSH. U2F/FIDO are open standards for inexpensive two-factor authentication hardware that are widely used for website authentication. In OpenSSH FIDO devices are supported by new public key types "ecdsa-sk" and "ed25519-sk", along with corresponding certificate types. ssh-keygen(1) may be used to generate a FIDO token-backed key, after which they may be used much like any other key type supported by OpenSSH, so long as the hardware token is attached when the keys are used. FIDO tokens also generally require the user explicitly authorise operations by touching or tapping them. Generating a FIDO key requires the token be attached, and will usually require the user tap the token to confirm the operation: $ ssh-keygen -t ecdsa-sk -f ~/.ssh/id_ecdsa_sk Generating public/private ecdsa-sk key pair. You may need to touch your security key to authorize key generation. Enter file in which to save the key (/home/djm/.ssh/id_ecdsa_sk): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/djm/.ssh/id_ecdsa_sk Your public key has been saved in /home/djm/.ssh/id_ecdsa_sk.pub This will yield a public and private key-pair. The private key file should be useless to an attacker who does not have access to the physical token. After generation, this key may be used like any other supported key in OpenSSH and may be listed in authorized_keys, added to ssh-agent(1), etc. The only additional stipulation is that the FIDO token that the key belongs to must be attached when the key is used. To enable FIDO/U2F support, this change regenerates ssh_namespace.h, adds ssh-sk-helper, and sets ENABLE_SK_INTERNAL (unless building WITHOUT_USB). devd integration is not included in this change, and is under investigation for the base system. In the interim the security/u2f-devd port can be installed to provide appropriate devd rules. Reviewed by: delphij, kevans Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32509 --- crypto/openssh/ssh_namespace.h | 12 ++++++++++++ secure/libexec/Makefile | 2 +- secure/libexec/ssh-sk-helper/Makefile | 16 ++++++++++++++++ secure/ssh.mk | 6 ++++++ tools/build/mk/OptionalObsoleteFiles.inc | 2 ++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/crypto/openssh/ssh_namespace.h b/crypto/openssh/ssh_namespace.h index 2c2060567460..94a391ee5f45 100644 --- a/crypto/openssh/ssh_namespace.h +++ b/crypto/openssh/ssh_namespace.h @@ -87,6 +87,10 @@ #define chacha_encrypt_bytes Fssh_chacha_encrypt_bytes #define chacha_ivsetup Fssh_chacha_ivsetup #define chacha_keysetup Fssh_chacha_keysetup +#define chachapoly_crypt Fssh_chachapoly_crypt +#define chachapoly_free Fssh_chachapoly_free +#define chachapoly_get_length Fssh_chachapoly_get_length +#define chachapoly_new Fssh_chachapoly_new #define chan_ibuf_empty Fssh_chan_ibuf_empty #define chan_is_dead Fssh_chan_is_dead #define chan_mark_dead Fssh_chan_mark_dead @@ -553,8 +557,10 @@ #define ssh_dss_sign Fssh_ssh_dss_sign #define ssh_dss_verify Fssh_ssh_dss_verify #define ssh_ecdsa_sign Fssh_ssh_ecdsa_sign +#define ssh_ecdsa_sk_verify Fssh_ssh_ecdsa_sk_verify #define ssh_ecdsa_verify Fssh_ssh_ecdsa_verify #define ssh_ed25519_sign Fssh_ssh_ed25519_sign +#define ssh_ed25519_sk_verify Fssh_ssh_ed25519_sk_verify #define ssh_ed25519_verify Fssh_ssh_ed25519_verify #define ssh_err Fssh_ssh_err #define ssh_fetch_identitylist Fssh_ssh_fetch_identitylist @@ -871,6 +877,12 @@ #define sshpkt_start Fssh_sshpkt_start #define sshpkt_vfatal Fssh_sshpkt_vfatal #define sshsigdie Fssh_sshsigdie +#define sshsk_add_option Fssh_sshsk_add_option +#define sshsk_enroll Fssh_sshsk_enroll +#define sshsk_key_from_response Fssh_sshsk_key_from_response +#define sshsk_load_resident Fssh_sshsk_load_resident +#define sshsk_open Fssh_sshsk_open +#define sshsk_sign Fssh_sshsk_sign #define start_progress_meter Fssh_start_progress_meter #define stdfd_devnull Fssh_stdfd_devnull #define stop_progress_meter Fssh_stop_progress_meter diff --git a/secure/libexec/Makefile b/secure/libexec/Makefile index 3438b412d5da..f07454db3643 100644 --- a/secure/libexec/Makefile +++ b/secure/libexec/Makefile @@ -4,7 +4,7 @@ SUBDIR= .if ${MK_OPENSSH} != "no" -SUBDIR+=sftp-server ssh-keysign ssh-pkcs11-helper +SUBDIR+=sftp-server ssh-keysign ssh-pkcs11-helper ssh-sk-helper .endif SUBDIR.${MK_TESTS}+= tests diff --git a/secure/libexec/ssh-sk-helper/Makefile b/secure/libexec/ssh-sk-helper/Makefile new file mode 100644 index 000000000000..622b0ac682bd --- /dev/null +++ b/secure/libexec/ssh-sk-helper/Makefile @@ -0,0 +1,16 @@ +.include +.include "${SRCTOP}/secure/ssh.mk" + +PROG= ssh-sk-helper +SRCS= ssh-sk-helper.c ssh-sk.c sk-usbhid.c +MAN= ssh-sk-helper.8 +CFLAGS+=-I${SRCTOP}/contrib/libfido2/src + +LIBADD= ssh crypto z +.if ${MK_USB} != "no" +LIBADD+= fido2 cbor +.endif + +.include + +.PATH: ${SSHDIR} diff --git a/secure/ssh.mk b/secure/ssh.mk index 4ab8cd399ae8..822946253263 100644 --- a/secure/ssh.mk +++ b/secure/ssh.mk @@ -1,6 +1,12 @@ # Common Make variables for OpenSSH +.include + SSHDIR= ${SRCTOP}/crypto/openssh CFLAGS+= -I${SSHDIR} -include ssh_namespace.h SRCS+= ssh_namespace.h + +.if ${MK_USB} != "no" +CFLAGS+= -DENABLE_SK_INTERNAL=1 +.endif diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 91822aac492a..96156a80f2e3 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -7141,6 +7141,7 @@ OLD_FILES+=usr/lib32/libprivatessh_p.a OLD_FILES+=usr/libexec/sftp-server OLD_FILES+=usr/libexec/ssh-keysign OLD_FILES+=usr/libexec/ssh-pkcs11-helper +OLD_FILES+=usr/libexec/ssh-sk-helper OLD_FILES+=usr/sbin/sshd OLD_FILES+=usr/share/man/man1/scp.1.gz OLD_FILES+=usr/share/man/man1/sftp.1.gz @@ -7157,6 +7158,7 @@ OLD_FILES+=usr/share/man/man8/pam_ssh.8.gz OLD_FILES+=usr/share/man/man8/sftp-server.8.gz OLD_FILES+=usr/share/man/man8/ssh-keysign.8.gz OLD_FILES+=usr/share/man/man8/ssh-pkcs11-helper.8.gz +OLD_FILES+=usr/share/man/man8/ssh-sk-helper.8.gz OLD_FILES+=usr/share/man/man8/sshd.8.gz .endif From nobody Thu Nov 4 17:13: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 D94E11841902 for ; Thu, 4 Nov 2021 17:13:20 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ua1-x932.google.com (mail-ua1-x932.google.com [IPv6:2607:f8b0:4864:20::932]) (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 4HlVb44Wdgz4WGq for ; Thu, 4 Nov 2021 17:13:20 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-ua1-x932.google.com with SMTP id e5so12149866uam.11 for ; Thu, 04 Nov 2021 10:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Pur7pSCBUCkSAYliscyD5iYykSOcBsCsq78cgO0rawg=; b=ZbF+eABZvySoS42Vffy1ktSlEucBhvs/fn19i3FnDp1m/acy8tdLK2ljqfV/bPcPWt Y1NsbXpwfOC5C2Z+CviM0b5NCPHiUzHl7XYOxVsM1rKC2NDdRygLgwbWZt95HRDAJ+kc V+g9KRi+HIYp+5MDFGgjIktVPwU6CDnr31Anezd9oau6vBgqBNKcem6wK+Nl6fH71Lke XkIwQ4ObPLeu1bmJV5iqZrS/AL6nAiEu3mbuZYlDulh02GU8//bPpOeOefWaH0oFIK4S Mhz8AVdXEC2uWPRz67eW38kONSOk9tVxZTKI16c2B3dRcEyH69qX12aDSeYgaU/NnvEO 6ytg== 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=Pur7pSCBUCkSAYliscyD5iYykSOcBsCsq78cgO0rawg=; b=7KABiC75rOykHxe3QTylCtdTuf+dKtpZh/UiLFH+gk3t/D+5fdULpcUCcGUFfYfb8j L63ap+Z0WWdPtGO8GGnemCr5JP8WZ//wjSZgp7OFMs4NFqlFNNRu2EDWu1kpEw6f6xFs 4wBDByQ/wlnw68kDqLHIw9q4Eq+tbOb8+/cjmpFOq/85GrURX+1v07tWoHc8HvhO3ynx wySiK5Kt2RcIIEpVOlZaAb1v0OOoZEbz+Sb8VRT9fPyxGoOS+L3TeZu8qkbYYQiyFnYn Ml67nRC8HyjOAPBcKUaYVNhd7yPWLw2j3wZBNGmbrlcUTDlfAR68CaoQNib7XiwEcmsy nTiQ== X-Gm-Message-State: AOAM533aRnTybe1MjilKnIcmtpHMiIKeyNbcD5fqI4WY1euCY0IoefLs 4zVcbBR/L+BOv6PeBPVCN6tlpvxPfZRZAO+S86yIfA== X-Google-Smtp-Source: ABdhPJz39rtufKtXgVk9CAa4SNv/Ik0ExRqEvD2BUMZvEir1T2jKIz9Bgr5Asrly8iInwViaaaLGHWgMFx9qSfqfeQ0= X-Received: by 2002:ab0:3d07:: with SMTP id f7mr38062335uax.11.1636046000133; Thu, 04 Nov 2021 10:13:20 -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: <202111032204.1A3M4K5R066389@gitrepo.freebsd.org> <202111041455.1A4Et1pX029819@gndrsh.dnsmgr.net> <20211104155426.GD77338@zxy.spb.ru> In-Reply-To: From: Warner Losh Date: Thu, 4 Nov 2021 11:13:09 -0600 Message-ID: Subject: Re: git: ba48d52ca6c8 - main - vt: Fix frequency calcuation for bell To: Alexey Dokuchaev Cc: Slawa Olhovchenkov , "Rodney W. Grimes" , Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000acabda05cff9a4db" X-Rspamd-Queue-Id: 4HlVb44Wdgz4WGq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N --000000000000acabda05cff9a4db Content-Type: text/plain; charset="UTF-8" On Thu, Nov 4, 2021 at 10:05 AM Alexey Dokuchaev wrote: > On Thu, Nov 04, 2021 at 06:54:26PM +0300, Slawa Olhovchenkov wrote: > > On Thu, Nov 04, 2021 at 09:17:38AM -0600, Warner Losh wrote: > > > On Thu, Nov 4, 2021 at 8:55 AM Rodney W. Grimes wrote: > > > > Thank you Warner for all the legwork on tracking this down and > > > > getting a proper bell tone working on FreeBSD-Current. I do not > > > > see any MFC plans for this, can you please consider merging this > > > > to all supported releases? > > > > > > I'm merging to 13. The merge was easy. > > > > Maybe now enable bell by default back? > > Yes please. > Given the last shitstorm over this, I'm not touching that issue with a 10' pole. Warner --000000000000acabda05cff9a4db-- From nobody Thu Nov 4 17:54: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 DB508183BDFC; Thu, 4 Nov 2021 17:54: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 4HlWVZ4GN3z4np1; Thu, 4 Nov 2021 17:54: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 739BE889; Thu, 4 Nov 2021 17:54: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 1A4HsUiW050098; Thu, 4 Nov 2021 17:54:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4HsUsu050097; Thu, 4 Nov 2021 17:54:30 GMT (envelope-from git) Date: Thu, 4 Nov 2021 17:54:30 GMT Message-Id: <202111041754.1A4HsUsu050097@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 63378c84b4ec - main - Remove unused ocf_operation structure from stack. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 63378c84b4ec580257683ef9596cf6f8b49d327c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=63378c84b4ec580257683ef9596cf6f8b49d327c commit 63378c84b4ec580257683ef9596cf6f8b49d327c Author: Hans Petter Selasky AuthorDate: 2021-11-04 17:30:57 +0000 Commit: Hans Petter Selasky CommitDate: 2021-11-04 17:52:06 +0000 Remove unused ocf_operation structure from stack. Reviewed by: jhb@ MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/opencrypto/ktls_ocf.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sys/opencrypto/ktls_ocf.c b/sys/opencrypto/ktls_ocf.c index 0096b4189533..3b944e302a8d 100644 --- a/sys/opencrypto/ktls_ocf.c +++ b/sys/opencrypto/ktls_ocf.c @@ -458,15 +458,11 @@ ktls_ocf_tls12_aead_decrypt(struct ktls_session *tls, struct tls_aead_data ad; struct cryptop crp; struct ktls_ocf_session *os; - struct ocf_operation oo; int error; uint16_t tls_comp_len; os = tls->ocf_session; - oo.os = os; - oo.done = false; - crypto_initreq(&crp, os->sid); /* Setup the IV. */ From nobody Thu Nov 4 17:54: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 03E86183C00D; Thu, 4 Nov 2021 17:54: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 4HlWVb5k7Hz4np5; Thu, 4 Nov 2021 17:54: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 9E25F82F; Thu, 4 Nov 2021 17:54: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 1A4HsVOF050122; Thu, 4 Nov 2021 17:54:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4HsVkY050121; Thu, 4 Nov 2021 17:54:31 GMT (envelope-from git) Date: Thu, 4 Nov 2021 17:54:31 GMT Message-Id: <202111041754.1A4HsVkY050121@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 10a62eb109ce - main - Use layer five checksum flags in the mbuf packet header to pass on crypto state. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 10a62eb109ceafce32aa2b18ec835b3b7285c2dd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=10a62eb109ceafce32aa2b18ec835b3b7285c2dd commit 10a62eb109ceafce32aa2b18ec835b3b7285c2dd Author: Hans Petter Selasky AuthorDate: 2021-11-04 17:43:24 +0000 Commit: Hans Petter Selasky CommitDate: 2021-11-04 17:52:06 +0000 Use layer five checksum flags in the mbuf packet header to pass on crypto state. The mbuf protocol flags get cleared between layers, and also it was discovered that M_DECRYPTED conflicts with M_HASFCS when receiving ethernet patckets. Add the proper CSUM_TLS_MASK and CSUM_TLS_DECRYPTED defines, and start using these instead of M_DECRYPTED inside the TCP LRO code. This change is needed by coming TLS RX hardware offload support patches. Suggested by: kib@ Reviewed by: jhb@ MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/netinet/tcp_lro.c | 11 ++++++++++- sys/sys/mbuf.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index cb9681559777..ea23ad75994d 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -395,7 +395,8 @@ tcp_lro_parser(struct mbuf *m, struct lro_parser *po, struct lro_parser *pi, boo htons(m->m_pkthdr.ether_vtag) & htons(EVL_VLID_MASK); } /* Store decrypted flag, if any. */ - if (__predict_false(m->m_flags & M_DECRYPTED)) + if (__predict_false((m->m_pkthdr.csum_flags & + CSUM_TLS_MASK) == CSUM_TLS_DECRYPTED)) po->data.lro_flags |= LRO_FLAG_DECRYPTED; } @@ -833,6 +834,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | CSUM_IP_VALID; le->m_head->m_pkthdr.csum_data = 0xffff; + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; break; case LRO_TYPE_IPV6_TCP: csum = tcp_lro_update_checksum(&le->inner, le, @@ -844,6 +847,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | CSUM_PSEUDO_HDR; le->m_head->m_pkthdr.csum_data = 0xffff; + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; break; case LRO_TYPE_NONE: switch (le->outer.data.lro_type) { @@ -854,6 +859,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | CSUM_IP_VALID; le->m_head->m_pkthdr.csum_data = 0xffff; + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; break; case LRO_TYPE_IPV6_TCP: csum = tcp_lro_update_checksum(&le->outer, le, @@ -862,6 +869,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | CSUM_PSEUDO_HDR; le->m_head->m_pkthdr.csum_data = 0xffff; + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; break; default: break; diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 413854cc9a57..d0f90805fa78 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -721,6 +721,8 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) #define CSUM_UDP_IPV6 CSUM_IP6_UDP #define CSUM_TCP_IPV6 CSUM_IP6_TCP #define CSUM_SCTP_IPV6 CSUM_IP6_SCTP +#define CSUM_TLS_MASK (CSUM_L5_CALC|CSUM_L5_VALID) +#define CSUM_TLS_DECRYPTED CSUM_L5_CALC /* * mbuf types describing the content of the mbuf (including external storage). From nobody Thu Nov 4 17:54: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 2BE61183BF9D; Thu, 4 Nov 2021 17:54: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 4HlWVd1ZcQz4nbK; Thu, 4 Nov 2021 17:54: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 B7FE391C; Thu, 4 Nov 2021 17:54: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 1A4HsWUj050146; Thu, 4 Nov 2021 17:54:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A4HsW5c050145; Thu, 4 Nov 2021 17:54:32 GMT (envelope-from git) Date: Thu, 4 Nov 2021 17:54:32 GMT Message-Id: <202111041754.1A4HsW5c050145@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: dd31400c3c2a - main - Factor out flags preserved during mbuf demote into a separate define. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dd31400c3c2aa941d057e78296c193959a6d9ed3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=dd31400c3c2aa941d057e78296c193959a6d9ed3 commit dd31400c3c2aa941d057e78296c193959a6d9ed3 Author: Hans Petter Selasky AuthorDate: 2021-11-04 17:48:23 +0000 Commit: Hans Petter Selasky CommitDate: 2021-11-04 17:53:49 +0000 Factor out flags preserved during mbuf demote into a separate define. This define will later on be used by coming TLS RX hardware offload patches. No functional change intended. Reviewed by: jhb@ MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/kern/uipc_mbuf.c | 5 +++-- sys/sys/mbuf.h | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index e0793a16d76f..0196023bc601 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -278,13 +278,14 @@ m_demote(struct mbuf *m0, int all, int flags) { struct mbuf *m; + flags |= M_DEMOTEFLAGS; + for (m = all ? m0 : m0->m_next; m != NULL; m = m->m_next) { KASSERT(m->m_nextpkt == NULL, ("%s: m_nextpkt in m %p, m0 %p", __func__, m, m0)); if (m->m_flags & M_PKTHDR) m_demote_pkthdr(m); - m->m_flags = m->m_flags & (M_EXT | M_RDONLY | M_NOFREE | - M_EXTPG | flags); + m->m_flags &= flags; } } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index d0f90805fa78..07a75bd5b47b 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -496,6 +496,12 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG|M_TSTMP| \ M_TSTMP_HPREC|M_TSTMP_LRO|M_PROTOFLAGS) +/* + * Flags preserved during demote. + */ +#define M_DEMOTEFLAGS \ + (M_EXT | M_RDONLY | M_NOFREE | M_EXTPG) + /* * Mbuf flag description for use with printf(9) %b identifier. */ From nobody Thu Nov 4 18:20:16 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 E3B0A17DBB09; Thu, 4 Nov 2021 18:20:20 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlX4N4z76z3Fhr; Thu, 4 Nov 2021 18:20:20 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1mihLU-000633-Qf; Thu, 04 Nov 2021 21:20:16 +0300 Date: Thu, 4 Nov 2021 21:20:16 +0300 From: Slawa Olhovchenkov To: Warner Losh Cc: Alexey Dokuchaev , "Rodney W. Grimes" , Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org Subject: Re: git: ba48d52ca6c8 - main - vt: Fix frequency calcuation for bell Message-ID: <20211104182016.GE77338@zxy.spb.ru> References: <202111032204.1A3M4K5R066389@gitrepo.freebsd.org> <202111041455.1A4Et1pX029819@gndrsh.dnsmgr.net> <20211104155426.GD77338@zxy.spb.ru> 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: User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-Rspamd-Queue-Id: 4HlX4N4z76z3Fhr 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 Thu, Nov 04, 2021 at 11:13:09AM -0600, Warner Losh wrote: > On Thu, Nov 4, 2021 at 10:05 AM Alexey Dokuchaev wrote: > > > On Thu, Nov 04, 2021 at 06:54:26PM +0300, Slawa Olhovchenkov wrote: > > > On Thu, Nov 04, 2021 at 09:17:38AM -0600, Warner Losh wrote: > > > > On Thu, Nov 4, 2021 at 8:55 AM Rodney W. Grimes wrote: > > > > > Thank you Warner for all the legwork on tracking this down and > > > > > getting a proper bell tone working on FreeBSD-Current. I do not > > > > > see any MFC plans for this, can you please consider merging this > > > > > to all supported releases? > > > > > > > > I'm merging to 13. The merge was easy. > > > > > > Maybe now enable bell by default back? > > > > Yes please. > > > > Given the last shitstorm over this, I'm not touching that issue with a 10' > pole. May be option in bsdinstall? From nobody Fri Nov 5 00:09: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 EE19B1847B01; Fri, 5 Nov 2021 00:09: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 4Hlgqj5rgdz4xLF; Fri, 5 Nov 2021 00:09: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 7F01059ED; Fri, 5 Nov 2021 00:09: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 1A509rEo044738; Fri, 5 Nov 2021 00:09:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A509rSV044737; Fri, 5 Nov 2021 00:09:53 GMT (envelope-from git) Date: Fri, 5 Nov 2021 00:09:53 GMT Message-Id: <202111050009.1A509rSV044737@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: 80e5955b085a - main - nfscl: Fix NFSv4.1/4.2 pnfs mounts using nconnect 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: 80e5955b085af20e65ef84066a164936413748e3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=80e5955b085af20e65ef84066a164936413748e3 commit 80e5955b085af20e65ef84066a164936413748e3 Author: Rick Macklem AuthorDate: 2021-11-05 00:06:34 +0000 Commit: Rick Macklem CommitDate: 2021-11-05 00:06:34 +0000 nfscl: Fix NFSv4.1/4.2 pnfs mounts using nconnect When a mount with the "pnfs" and "nconnect" options specified does an I/O operation, it erroneously uses a TCP connection to the MDS when it is meant to be a DS operation and, as such, needs to use a TCP connection to the DS. This patch fixes this. When the "pnfs" and "nconnect" options are specified for a NFSv4.1/4.2 mount, there probably should be N connections established to each DS for I/O RPCs. This is a fair amount of work and may be done in a future commit. This problem was found during a recent IETF NFSv4 working group testing event. MFC after: 2 weeks --- sys/fs/nfs/nfs_commonkrpc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 358d77fe5b30..c1a5fab2a358 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -639,8 +639,17 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp, if (nrp->nr_client == NULL) newnfs_connect(nmp, nrp, cred, td, 0, false, &nrp->nr_client); + /* + * If the "nconnect" mount option was specified and this RPC is + * one that can have a large RPC message and is being done through + * the NFS/MDS server, use an additional connection. (When the RPC is + * being done through the server/MDS, nrp == &nmp->nm_sockreq.) + * The "nconnect" mount option normally has minimal effect when the + * "pnfs" mount option is specified, since only Readdir RPCs are + * normally done through the NFS/MDS server. + */ nextconn_set = false; - if (nmp != NULL && nmp->nm_aconnect > 0 && + if (nmp != NULL && nmp->nm_aconnect > 0 && nrp == &nmp->nm_sockreq && (nd->nd_procnum == NFSPROC_READ || nd->nd_procnum == NFSPROC_READDIR || nd->nd_procnum == NFSPROC_READDIRPLUS || From nobody Fri Nov 5 05:08: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 A514B18383C2; Fri, 5 Nov 2021 05:08:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4HlpSX345Hz3rCR; Fri, 5 Nov 2021 05:08:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 1A558Upt010453 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 5 Nov 2021 07:08:33 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 1A558Upt010453 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 1A558UU1010452; Fri, 5 Nov 2021 07:08:30 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 5 Nov 2021 07:08:30 +0200 From: Konstantin Belousov To: Hans Petter Selasky Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 10a62eb109ce - main - Use layer five checksum flags in the mbuf packet header to pass on crypto state. Message-ID: References: <202111041754.1A4HsVkY050121@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: <202111041754.1A4HsVkY050121@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4HlpSX345Hz3rCR 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 Thu, Nov 04, 2021 at 05:54:31PM +0000, Hans Petter Selasky wrote: > The branch main has been updated by hselasky: > > URL: https://cgit.FreeBSD.org/src/commit/?id=10a62eb109ceafce32aa2b18ec835b3b7285c2dd > > commit 10a62eb109ceafce32aa2b18ec835b3b7285c2dd > Author: Hans Petter Selasky > AuthorDate: 2021-11-04 17:43:24 +0000 > Commit: Hans Petter Selasky > CommitDate: 2021-11-04 17:52:06 +0000 > > Use layer five checksum flags in the mbuf packet header to pass on crypto state. > > The mbuf protocol flags get cleared between layers, and also it was discovered > that M_DECRYPTED conflicts with M_HASFCS when receiving ethernet patckets. > > Add the proper CSUM_TLS_MASK and CSUM_TLS_DECRYPTED defines, and start using > these instead of M_DECRYPTED inside the TCP LRO code. > > This change is needed by coming TLS RX hardware offload support patches. > > Suggested by: kib@ > Reviewed by: jhb@ > MFC after: 1 week > Sponsored by: NVIDIA Networking > --- > sys/netinet/tcp_lro.c | 11 ++++++++++- > sys/sys/mbuf.h | 2 ++ > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c > index cb9681559777..ea23ad75994d 100644 > --- a/sys/netinet/tcp_lro.c > +++ b/sys/netinet/tcp_lro.c > @@ -395,7 +395,8 @@ tcp_lro_parser(struct mbuf *m, struct lro_parser *po, struct lro_parser *pi, boo > htons(m->m_pkthdr.ether_vtag) & htons(EVL_VLID_MASK); > } > /* Store decrypted flag, if any. */ > - if (__predict_false(m->m_flags & M_DECRYPTED)) > + if (__predict_false((m->m_pkthdr.csum_flags & > + CSUM_TLS_MASK) == CSUM_TLS_DECRYPTED)) > po->data.lro_flags |= LRO_FLAG_DECRYPTED; > } > > @@ -833,6 +834,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) > le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | > CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | CSUM_IP_VALID; > le->m_head->m_pkthdr.csum_data = 0xffff; > + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) > + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; > break; > case LRO_TYPE_IPV6_TCP: > csum = tcp_lro_update_checksum(&le->inner, le, > @@ -844,6 +847,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) > le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | > CSUM_PSEUDO_HDR; > le->m_head->m_pkthdr.csum_data = 0xffff; > + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) > + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; > break; > case LRO_TYPE_NONE: > switch (le->outer.data.lro_type) { > @@ -854,6 +859,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) > le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | > CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | CSUM_IP_VALID; > le->m_head->m_pkthdr.csum_data = 0xffff; > + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) > + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; > break; > case LRO_TYPE_IPV6_TCP: > csum = tcp_lro_update_checksum(&le->outer, le, > @@ -862,6 +869,8 @@ tcp_flush_out_entry(struct lro_ctrl *lc, struct lro_entry *le) > le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | > CSUM_PSEUDO_HDR; > le->m_head->m_pkthdr.csum_data = 0xffff; > + if (__predict_false(le->outer.data.lro_flags & LRO_FLAG_DECRYPTED)) > + le->m_head->m_pkthdr.csum_flags |= CSUM_TLS_DECRYPTED; > break; > default: > break; > diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h > index 413854cc9a57..d0f90805fa78 100644 > --- a/sys/sys/mbuf.h > +++ b/sys/sys/mbuf.h > @@ -721,6 +721,8 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) > #define CSUM_UDP_IPV6 CSUM_IP6_UDP > #define CSUM_TCP_IPV6 CSUM_IP6_TCP > #define CSUM_SCTP_IPV6 CSUM_IP6_SCTP > +#define CSUM_TLS_MASK (CSUM_L5_CALC|CSUM_L5_VALID) > +#define CSUM_TLS_DECRYPTED CSUM_L5_CALC It is worth explaining in a comment that selection of the value for CSUM_TLS_DECRYPTED does not reuse previous value, in the sense that correct use of the CSUM_L5 flags from drivers (are there any?) is still correct. We usurp a value for L5 CSUM flags which should not be returned from driver, to mean something new. It also may be worth discussing do we need L5 flags in its present form, and are there any existing consumers that do not abuse there semi-free flags for something else. If no external consumers exist (*) then perhaps officially re-purposing them is better route. We could define them as something extensible or at least context (inpcb etc)-dependent. (*) it seems that there is no in-tree users > > /* > * mbuf types describing the content of the mbuf (including external storage). From nobody Fri Nov 5 09:17: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 CC9B718492E8; Fri, 5 Nov 2021 09:17: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 4Hlvz45QBtz4gxh; Fri, 5 Nov 2021 09:17: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 99A0415236; Fri, 5 Nov 2021 09:17: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 1A59H4kN077862; Fri, 5 Nov 2021 09:17:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A59H4BZ077861; Fri, 5 Nov 2021 09:17:04 GMT (envelope-from git) Date: Fri, 5 Nov 2021 09:17:04 GMT Message-Id: <202111050917.1A59H4BZ077861@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: 76c5eecc3490 - main - pf: Introduce ridentifier 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: 76c5eecc3490d89a9a3492ed2354802b69d69602 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=76c5eecc3490d89a9a3492ed2354802b69d69602 commit 76c5eecc3490d89a9a3492ed2354802b69d69602 Author: Kristof Provost AuthorDate: 2021-10-29 15:40:53 +0000 Commit: Kristof Provost CommitDate: 2021-11-05 08:39:56 +0000 pf: Introduce ridentifier Allow users to set a number on rules which will be exposed as part of the pflog header. The intent behind this is to allow users to correlate rules across updates (remember that pf rules continue to exist and match existing states, even if they're removed from the active ruleset) and pflog. Obtained from: pfSense MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32750 --- contrib/tcpdump/print-pflog.c | 7 ++++++- lib/libpfctl/libpfctl.c | 2 ++ lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/parse.y | 15 ++++++++++++++- sbin/pfctl/pfctl_parser.c | 2 ++ share/man/man4/pflog.4 | 3 ++- share/man/man5/pf.conf.5 | 7 ++++++- sys/net/if_pflog.h | 1 + sys/net/pfvar.h | 1 + sys/netpfil/ipfw/nat64/nat64clat.c | 2 +- sys/netpfil/ipfw/nat64/nat64lsn.c | 2 +- sys/netpfil/ipfw/nat64/nat64stl.c | 2 +- sys/netpfil/pf/if_pflog.c | 3 ++- sys/netpfil/pf/pf_nv.c | 2 ++ 14 files changed, 42 insertions(+), 8 deletions(-) diff --git a/contrib/tcpdump/print-pflog.c b/contrib/tcpdump/print-pflog.c index 38201c55ee3f..49994507e728 100644 --- a/contrib/tcpdump/print-pflog.c +++ b/contrib/tcpdump/print-pflog.c @@ -88,10 +88,12 @@ static const struct tok pf_directions[] = { static void pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr) { - uint32_t rulenr, subrulenr; + uint32_t rulenr, subrulenr, ridentifier; rulenr = EXTRACT_32BITS(&hdr->rulenr); subrulenr = EXTRACT_32BITS(&hdr->subrulenr); + ridentifier = EXTRACT_32BITS(&hdr->ridentifier); + if (subrulenr == (uint32_t)-1) ND_PRINT((ndo, "rule %u/", rulenr)); else @@ -102,6 +104,9 @@ pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr) if (hdr->uid != UID_MAX) ND_PRINT((ndo, " [uid %u]", (unsigned)hdr->uid)); + if (ridentifier != 0) + ND_PRINT((ndo, " [ridentifier %u]", ridentifier)); + ND_PRINT((ndo, ": %s %s on %s: ", tok2str(pf_actions, "unkn(%u)", hdr->action), tok2str(pf_directions, "unkn(%u)", hdr->dir), diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index aaf5998ed0d6..9abfbdce8cf1 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -455,6 +455,7 @@ pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule) assert(labelcount <= PF_RULE_MAX_LABEL_COUNT); for (size_t i = 0; i < labelcount; i++) strlcpy(rule->label[i], labels[i], PF_RULE_LABEL_SIZE); + rule->ridentifier = nvlist_get_number(nvl, "ridentifier"); strlcpy(rule->ifname, nvlist_get_string(nvl, "ifname"), IFNAMSIZ); strlcpy(rule->qname, nvlist_get_string(nvl, "qname"), PF_QNAME_SIZE); strlcpy(rule->pqname, nvlist_get_string(nvl, "pqname"), PF_QNAME_SIZE); @@ -569,6 +570,7 @@ pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, r->label[labelcount]); labelcount++; } + nvlist_add_number(nvlr, "ridentifier", r->ridentifier); nvlist_add_string(nvlr, "ifname", r->ifname); nvlist_add_string(nvlr, "qname", r->qname); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 1f7259ee8d32..71806ed217ee 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -81,6 +81,7 @@ struct pfctl_rule { struct pf_rule_addr dst; union pf_rule_ptr skip[PF_SKIP_COUNT]; char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; + u_int32_t ridentifier; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index e22e60182c73..a21643070028 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -236,6 +236,7 @@ static struct filter_opts { struct node_icmp *icmpspec; u_int32_t tos; u_int32_t prob; + u_int32_t ridentifier; struct { int action; struct node_state_opt *options; @@ -263,6 +264,7 @@ static struct filter_opts { static struct antispoof_opts { char *label[PF_RULE_MAX_LABEL_COUNT]; int labelcount; + u_int32_t ridentifier; u_int rtableid; } antispoof_opts; @@ -471,7 +473,7 @@ int parseport(char *, struct range *r, int); %token BITMASK RANDOM SOURCEHASH ROUNDROBIN STATICPORT PROBABILITY MAPEPORTSET %token ALTQ CBQ CODEL PRIQ HFSC FAIRQ BANDWIDTH TBRSIZE LINKSHARE REALTIME %token UPPERLIMIT QUEUE PRIORITY QLIMIT HOGS BUCKETS RTABLE TARGET INTERVAL -%token DNPIPE DNQUEUE +%token DNPIPE DNQUEUE RIDENTIFIER %token LOAD RULESET_OPTIMIZATION PRIO %token STICKYADDRESS MAXSRCSTATES MAXSRCNODES SOURCETRACK GLOBAL RULE %token MAXSRCCONN MAXSRCCONNRATE OVERLOAD FLUSH SLOPPY @@ -927,6 +929,7 @@ anchorrule : ANCHOR anchorname dir quick interface af proto fromto r.af = $6; r.prob = $9.prob; r.rtableid = $9.rtableid; + r.ridentifier = $9.ridentifier; if ($9.tag) if (strlcpy(r.tagname, $9.tag, @@ -1326,6 +1329,7 @@ antispoof : ANTISPOOF logquick antispoof_ifspc af antispoof_opts { r.logif = $2.logif; r.quick = $2.quick; r.af = $4; + r.ridentifier = $5.ridentifier; if (rule_label(&r, $5.label)) YYERROR; r.rtableid = $5.rtableid; @@ -1378,6 +1382,7 @@ antispoof : ANTISPOOF logquick antispoof_ifspc af antispoof_opts { r.logif = $2.logif; r.quick = $2.quick; r.af = $4; + r.ridentifier = $5.ridentifier; if (rule_label(&r, $5.label)) YYERROR; r.rtableid = $5.rtableid; @@ -1440,6 +1445,9 @@ antispoof_opt : label { } antispoof_opts.label[antispoof_opts.labelcount++] = $1; } + | RIDENTIFIER number { + antispoof_opts.ridentifier = $2; + } | RTABLE NUMBER { if ($2 < 0 || $2 > rt_tableid_max()) { yyerror("invalid rtable id"); @@ -2155,6 +2163,7 @@ pfrule : action dir logquick interface route af proto fromto YYERROR; for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) free($9.label[i]); + r.ridentifier = $9.ridentifier; r.flags = $9.flags.b1; r.flagset = $9.flags.b2; if (($9.flags.b1 & $9.flags.b2) != $9.flags.b1) { @@ -2594,6 +2603,9 @@ filter_opt : USER uids { filter_opts.keep.action = $1.action; filter_opts.keep.options = $1.options; } + | RIDENTIFIER number { + filter_opts.ridentifier = $2; + } | FRAGMENT { filter_opts.fragment = 1; } @@ -5736,6 +5748,7 @@ lookup(char *s) { "return-icmp", RETURNICMP}, { "return-icmp6", RETURNICMP6}, { "return-rst", RETURNRST}, + { "ridentifier", RIDENTIFIER}, { "round-robin", ROUNDROBIN}, { "route", ROUTE}, { "route-to", ROUTETO}, diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 91a3a38ef016..a9bea39a6771 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1019,6 +1019,8 @@ print_rule(struct pfctl_rule *r, const char *anchor_call, int verbose, int numer i = 0; while (r->label[i][0]) printf(" label \"%s\"", r->label[i++]); + if (r->ridentifier) + printf(" ridentifier %u", r->ridentifier); /* Only dnrpipe as we might do (0, 42) to only queue return traffic. */ if (r->dnrpipe) printf(" %s(%d, %d)", diff --git a/share/man/man4/pflog.4 b/share/man/man4/pflog.4 index 300092a9532b..19eb7012bca3 100644 --- a/share/man/man4/pflog.4 +++ b/share/man/man4/pflog.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 18, 2019 +.Dd October 29, 2021 .Dt PFLOG 4 .Os .Sh NAME @@ -84,6 +84,7 @@ struct pfloghdr { pid_t rule_pid; u_int8_t dir; u_int8_t pad[3]; + u_int32_t ridentifier; }; .Ed .Sh EXAMPLES diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5 index 9f69db70d90b..63b8acaef358 100644 --- a/share/man/man5/pf.conf.5 +++ b/share/man/man5/pf.conf.5 @@ -1896,6 +1896,9 @@ pass in inet proto tcp from any to 1.2.3.5 \e The macro expansion for the .Ar label directive occurs only at configuration file parse time, not during runtime. +.It Ar ridentifier Aq Ar number +Add an identifier (number) to the rule, which can be used to correlate the rule +to pflog entries, even after ruleset updates. .It Xo Ar queue Aq Ar queue .No \*(Ba ( Aq Ar queue , .Aq Ar queue ) @@ -3000,7 +3003,8 @@ filteropt = user | group | flags | icmp-type | icmp6-type | "tos" tos | "queue" ( string | "(" string [ [ "," ] string ] ")" ) | "rtable" number | "probability" number"%" | "prio" number | "dnpipe" ( number | "(" number "," number ")" ) | - "dnqueue" ( number | "(" number "," number ")" ) + "dnqueue" ( number | "(" number "," number ")" ) | + "ridentifier" number nat-rule = [ "no" ] "nat" [ "pass" [ "log" [ "(" logopts ")" ] ] ] [ "on" ifspec ] [ af ] @@ -3024,6 +3028,7 @@ rdr-rule = [ "no" ] "rdr" [ "pass" [ "log" [ "(" logopts ")" ] ] ] antispoof-rule = "antispoof" [ "log" ] [ "quick" ] "for" ifspec [ af ] [ "label" string ] + [ "ridentifier" number ] table-rule = "table" "\*(Lt" string "\*(Gt" [ tableopts-list ] tableopts-list = tableopts-list tableopts | tableopts diff --git a/sys/net/if_pflog.h b/sys/net/if_pflog.h index 5ed341a85d86..c77d8da1440a 100644 --- a/sys/net/if_pflog.h +++ b/sys/net/if_pflog.h @@ -50,6 +50,7 @@ struct pfloghdr { pid_t rule_pid; u_int8_t dir; u_int8_t pad[3]; + u_int32_t ridentifier; }; #define PFLOG_HDRLEN sizeof(struct pfloghdr) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index e9277dce4963..a6994e8b1846 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -578,6 +578,7 @@ struct pf_krule { struct pf_rule_addr dst; union pf_krule_ptr skip[PF_SKIP_COUNT]; char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; + uint32_t ridentifier; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; diff --git a/sys/netpfil/ipfw/nat64/nat64clat.c b/sys/netpfil/ipfw/nat64/nat64clat.c index fcc922726d02..c48c68183e08 100644 --- a/sys/netpfil/ipfw/nat64/nat64clat.c +++ b/sys/netpfil/ipfw/nat64/nat64clat.c @@ -71,7 +71,7 @@ nat64clat_log(struct pfloghdr *plog, struct mbuf *m, sa_family_t family, static uint32_t pktid = 0; memset(plog, 0, sizeof(*plog)); - plog->length = PFLOG_REAL_HDRLEN; + plog->length = PFLOG_HDRLEN; plog->af = family; plog->action = PF_NAT; plog->dir = PF_IN; diff --git a/sys/netpfil/ipfw/nat64/nat64lsn.c b/sys/netpfil/ipfw/nat64/nat64lsn.c index bde42eeb18d6..90c27cabdf29 100644 --- a/sys/netpfil/ipfw/nat64/nat64lsn.c +++ b/sys/netpfil/ipfw/nat64/nat64lsn.c @@ -181,7 +181,7 @@ nat64lsn_log(struct pfloghdr *plog, struct mbuf *m, sa_family_t family, { memset(plog, 0, sizeof(*plog)); - plog->length = PFLOG_REAL_HDRLEN; + plog->length = PFLOG_HDRLEN; plog->af = family; plog->action = PF_NAT; plog->dir = PF_IN; diff --git a/sys/netpfil/ipfw/nat64/nat64stl.c b/sys/netpfil/ipfw/nat64/nat64stl.c index 286876e553e3..a3451a107579 100644 --- a/sys/netpfil/ipfw/nat64/nat64stl.c +++ b/sys/netpfil/ipfw/nat64/nat64stl.c @@ -70,7 +70,7 @@ nat64stl_log(struct pfloghdr *plog, struct mbuf *m, sa_family_t family, static uint32_t pktid = 0; memset(plog, 0, sizeof(*plog)); - plog->length = PFLOG_REAL_HDRLEN; + plog->length = PFLOG_HDRLEN; plog->af = family; plog->action = PF_NAT; plog->dir = PF_IN; diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c index 9eb168b9a74f..4853c1301d6f 100644 --- a/sys/netpfil/pf/if_pflog.c +++ b/sys/netpfil/pf/if_pflog.c @@ -215,7 +215,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, return (0); bzero(&hdr, sizeof(hdr)); - hdr.length = PFLOG_REAL_HDRLEN; + hdr.length = PFLOG_HDRLEN; hdr.af = af; hdr.action = rm->action; hdr.reason = reason; @@ -231,6 +231,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, strlcpy(hdr.ruleset, ruleset->anchor->name, sizeof(hdr.ruleset)); } + hdr.ridentifier = htonl(rm->ridentifier); /* * XXXGL: we avoid pf_socket_lookup() when we are holding * state lock, since this leads to unsafe LOR. diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index 933603066e21..143d84416542 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -531,6 +531,7 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule *rule) } } + PFNV_CHK(pf_nvuint32_opt(nvl, "ridentifier", &rule->ridentifier, 0)); PFNV_CHK(pf_nvstring(nvl, "ifname", rule->ifname, sizeof(rule->ifname))); PFNV_CHK(pf_nvstring(nvl, "qname", rule->qname, sizeof(rule->qname))); @@ -696,6 +697,7 @@ pf_krule_to_nvrule(struct pf_krule *rule) nvlist_append_string_array(nvl, "labels", rule->label[i]); } nvlist_add_string(nvl, "label", rule->label[0]); + nvlist_add_number(nvl, "ridentifier", rule->ridentifier); nvlist_add_string(nvl, "ifname", rule->ifname); nvlist_add_string(nvl, "qname", rule->qname); nvlist_add_string(nvl, "pqname", rule->pqname); From nobody Fri Nov 5 09:17:05 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 E9F7D1849345; Fri, 5 Nov 2021 09:17:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hlvz564QFz4gvT; Fri, 5 Nov 2021 09:17:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB85A14D21; Fri, 5 Nov 2021 09:17:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A59H56Q077886; Fri, 5 Nov 2021 09:17:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A59H523077885; Fri, 5 Nov 2021 09:17:05 GMT (envelope-from git) Date: Fri, 5 Nov 2021 09:17:05 GMT Message-Id: <202111050917.1A59H523077885@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: 508161111dc2 - main - pf tests: basic test for ridentifier 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: 508161111dc23cee0a41fa70de865743c694502f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=508161111dc23cee0a41fa70de865743c694502f commit 508161111dc23cee0a41fa70de865743c694502f Author: Kristof Provost AuthorDate: 2021-10-29 15:52:59 +0000 Commit: Kristof Provost CommitDate: 2021-11-05 08:39:56 +0000 pf tests: basic test for ridentifier MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32751 --- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/ridentifier.sh | 108 ++++++++++++++++++++++++++++++++++++ tests/sys/netpfil/pf/utils.subr | 7 +++ 3 files changed, 116 insertions(+) diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 246c267e7d2b..e62f3485d26d 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -22,6 +22,7 @@ ATF_TESTS_SH+= altq \ pfsync \ proxy \ rdr \ + ridentifier \ route_to \ rules_counter \ set_skip \ diff --git a/tests/sys/netpfil/pf/ridentifier.sh b/tests/sys/netpfil/pf/ridentifier.sh new file mode 100644 index 000000000000..da2f40c7ae98 --- /dev/null +++ b/tests/sys/netpfil/pf/ridentifier.sh @@ -0,0 +1,108 @@ +# $FreeBSD$ +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Rubicon Communications, LLC (Netgate) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/utils.subr + +atf_test_case "basic" "cleanup" +basic_head() +{ + atf_set descr 'Test ridentifier keyword' + atf_set require.user root +} + +basic_body() +{ + pft_init + pflog_init + + epair=$(vnet_mkepair) + + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig lo0 up + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz /usr/sbin/inetd -p inetd-alcatraz.pid $(atf_get_srcdir)/echo_inetd.conf + + # Sanity check + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + jexec alcatraz pfctl -e + jexec alcatraz ifconfig pflog0 up + pft_set_rules alcatraz \ + "pass in log" \ + "pass in log proto tcp ridentifier 1234" + + jexec alcatraz tcpdump --immediate-mode -n -e -i pflog0 > tcpdump.log & + sleep 1 + + echo "test" | nc -N 192.0.2.2 7 + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + sleep 1 + jexec alcatraz killall tcpdump + + # Make sure we spotted the ridentifier + atf_check -s exit:0 -o ignore \ + grep 'rule 1/0.*ridentifier 1234' tcpdump.log + # But not on the !TCP traffic + atf_check -s exit:1 -o ignore \ + grep 'rule 0/0.*ridentifier' tcpdump.log + + # Now try with antispoof rules + pft_set_rules alcatraz \ + "pass in log" \ + "antispoof log for ${epair}b ridentifier 4321" + + jexec alcatraz tcpdump --immediate-mode -n -e -i pflog0 > tcpdump.log & + sleep 1 + + # Without explicit rules for lo0 we're going to drop packets to ourself + atf_check -s exit:2 -o ignore -e ignore \ + jexec alcatraz ping -c 1 -t 1 192.0.2.2 + + sleep 1 + jexec alcatraz killall tcpdump + + cat tcpdump.log + + # Make sure we spotted the ridentifier + atf_check -s exit:0 -o ignore \ + grep 'rule 2/0.*ridentifier 4321' tcpdump.log +} + +basic_cleanup() +{ + pft_cleanup + rm -f inetd-alcatraz.pid + rm -f tcpdump.log +} + +atf_init_test_cases() +{ + atf_add_test_case "basic" +} diff --git a/tests/sys/netpfil/pf/utils.subr b/tests/sys/netpfil/pf/utils.subr index d7df2a6747da..c9a404c8012e 100644 --- a/tests/sys/netpfil/pf/utils.subr +++ b/tests/sys/netpfil/pf/utils.subr @@ -46,6 +46,13 @@ pfsynct_init() fi } +pflog_init() +{ + if ! kldstat -q -m pflog; then + atf_skip "This test requires pflog" + fi +} + pft_set_rules() { jname=$1 From nobody Fri Nov 5 09:17: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 D1AFE1849351; Fri, 5 Nov 2021 09:17: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 4Hlvz70gDrz4h5k; Fri, 5 Nov 2021 09:17: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 DC61B14D22; Fri, 5 Nov 2021 09:17: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 1A59H6Ls077917; Fri, 5 Nov 2021 09:17:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A59H6Yb077916; Fri, 5 Nov 2021 09:17:06 GMT (envelope-from git) Date: Fri, 5 Nov 2021 09:17:06 GMT Message-Id: <202111050917.1A59H6Yb077916@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: 7bb3c927f7d9 - main - libpfct: be consistent with u_int vs. uint 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: 7bb3c927f7d9c48b356b4d20907b813f9b83273b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7bb3c927f7d9c48b356b4d20907b813f9b83273b commit 7bb3c927f7d9c48b356b4d20907b813f9b83273b Author: Kristof Provost AuthorDate: 2021-11-05 08:37:56 +0000 Commit: Kristof Provost CommitDate: 2021-11-05 08:39:56 +0000 libpfct: be consistent with u_int vs. uint Always use uint64_t over u_int64_t, for the sake of consistency. No functional change. MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") --- lib/libpfctl/libpfctl.c | 34 ++++++------- lib/libpfctl/libpfctl.h | 128 ++++++++++++++++++++++++------------------------ 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 9abfbdce8cf1..da7c27522fd2 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -61,7 +61,7 @@ static int _pfctl_clear_states(int , const struct pfctl_kill *, static void pf_nvuint_8_array(const nvlist_t *nvl, const char *name, size_t maxelems, - u_int8_t *numbers, size_t *nelems) + uint8_t *numbers, size_t *nelems) { const uint64_t *tmp; size_t elems; @@ -78,7 +78,7 @@ pf_nvuint_8_array(const nvlist_t *nvl, const char *name, size_t maxelems, static void pf_nvuint_16_array(const nvlist_t *nvl, const char *name, size_t maxelems, - u_int16_t *numbers, size_t *nelems) + uint16_t *numbers, size_t *nelems) { const uint64_t *tmp; size_t elems; @@ -95,7 +95,7 @@ pf_nvuint_16_array(const nvlist_t *nvl, const char *name, size_t maxelems, static void pf_nvuint_32_array(const nvlist_t *nvl, const char *name, size_t maxelems, - u_int32_t *numbers, size_t *nelems) + uint32_t *numbers, size_t *nelems) { const uint64_t *tmp; size_t elems; @@ -112,7 +112,7 @@ pf_nvuint_32_array(const nvlist_t *nvl, const char *name, size_t maxelems, static void pf_nvuint_64_array(const nvlist_t *nvl, const char *name, size_t maxelems, - u_int64_t *numbers, size_t *nelems) + uint64_t *numbers, size_t *nelems) { const uint64_t *tmp; size_t elems; @@ -304,7 +304,7 @@ static void pfctl_nv_add_rule_addr(nvlist_t *nvparent, const char *name, const struct pf_rule_addr *addr) { - u_int64_t ports[2]; + uint64_t ports[2]; nvlist_t *nvl = nvlist_create(0); pfctl_nv_add_addr_wrap(nvl, "addr", &addr->addr); @@ -345,7 +345,7 @@ static void pfctl_nv_add_pool(nvlist_t *nvparent, const char *name, const struct pfctl_pool *pool) { - u_int64_t ports[2]; + uint64_t ports[2]; nvlist_t *nvl = nvlist_create(0); nvlist_add_binary(nvl, "key", &pool->key, sizeof(pool->key)); @@ -394,7 +394,7 @@ static void pfctl_nv_add_uid(nvlist_t *nvparent, const char *name, const struct pf_rule_uid *uid) { - u_int64_t uids[2]; + uint64_t uids[2]; nvlist_t *nvl = nvlist_create(0); uids[0] = uid->uid[0]; @@ -542,11 +542,11 @@ pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule) int pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, - const char *anchor_call, u_int32_t ticket, u_int32_t pool_ticket) + const char *anchor_call, uint32_t ticket, uint32_t pool_ticket) { struct pfioc_nv nv; - u_int64_t timeouts[PFTM_MAX]; - u_int64_t set_prio[2]; + uint64_t timeouts[PFTM_MAX]; + uint64_t set_prio[2]; nvlist_t *nvl, *nvlr; size_t labelcount; int ret; @@ -662,15 +662,15 @@ pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, } int -pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, const char *anchor, - u_int32_t ruleset, struct pfctl_rule *rule, char *anchor_call) +pfctl_get_rule(int dev, uint32_t nr, uint32_t ticket, const char *anchor, + uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call) { return (pfctl_get_clear_rule(dev, nr, ticket, anchor, ruleset, rule, anchor_call, false)); } -int pfctl_get_clear_rule(int dev, u_int32_t nr, u_int32_t ticket, - const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, +int pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket, + const char *anchor, uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call, bool clear) { struct pfioc_nv nv; @@ -947,7 +947,7 @@ pfctl_kill_states(int dev, const struct pfctl_kill *kill, unsigned int *killed) } static int -pfctl_get_limit(int dev, const int index, u_int *limit) +pfctl_get_limit(int dev, const int index, uint *limit) { struct pfioc_limit pl; @@ -968,7 +968,7 @@ pfctl_set_syncookies(int dev, const struct pfctl_syncookies *s) struct pfioc_nv nv; nvlist_t *nvl; int ret; - u_int state_limit; + uint state_limit; ret = pfctl_get_limit(dev, PF_LIMIT_STATES, &state_limit); if (ret != 0) @@ -998,7 +998,7 @@ pfctl_get_syncookies(int dev, struct pfctl_syncookies *s) struct pfioc_nv nv; nvlist_t *nvl; int ret; - u_int state_limit; + uint state_limit; bool enabled, adaptive; ret = pfctl_get_limit(dev, PF_LIMIT_STATES, &state_limit); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 71806ed217ee..6b516b0a7649 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -72,8 +72,8 @@ struct pfctl_pool { struct pf_addr counter; struct pf_mape_portset mape; int tblidx; - u_int16_t proxy_port[2]; - u_int8_t opts; + uint16_t proxy_port[2]; + uint8_t opts; }; struct pfctl_rule { @@ -81,7 +81,7 @@ struct pfctl_rule { struct pf_rule_addr dst; union pf_rule_ptr skip[PF_SKIP_COUNT]; char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; - u_int32_t ridentifier; + uint32_t ridentifier; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; @@ -93,9 +93,9 @@ struct pfctl_rule { TAILQ_ENTRY(pfctl_rule) entries; struct pfctl_pool rpool; - u_int64_t evaluations; - u_int64_t packets[2]; - u_int64_t bytes[2]; + uint64_t evaluations; + uint64_t packets[2]; + uint64_t bytes[2]; struct pfi_kif *kif; struct pfctl_anchor *anchor; @@ -104,22 +104,22 @@ struct pfctl_rule { pf_osfp_t os_fingerprint; int rtableid; - u_int32_t timeout[PFTM_MAX]; - u_int32_t max_states; - u_int32_t max_src_nodes; - u_int32_t max_src_states; - u_int32_t max_src_conn; + uint32_t timeout[PFTM_MAX]; + uint32_t max_states; + uint32_t max_src_nodes; + uint32_t max_src_states; + uint32_t max_src_conn; struct { - u_int32_t limit; - u_int32_t seconds; + uint32_t limit; + uint32_t seconds; } max_src_conn_rate; - u_int32_t qid; - u_int32_t pqid; - u_int16_t dnpipe; - u_int16_t dnrpipe; - u_int32_t free_flags; - u_int32_t nr; - u_int32_t prob; + uint32_t qid; + uint32_t pqid; + uint16_t dnpipe; + uint16_t dnrpipe; + uint32_t free_flags; + uint32_t nr; + uint32_t prob; uid_t cuid; pid_t cpid; @@ -127,49 +127,49 @@ struct pfctl_rule { uint64_t states_tot; uint64_t src_nodes; - u_int16_t return_icmp; - u_int16_t return_icmp6; - u_int16_t max_mss; - u_int16_t tag; - u_int16_t match_tag; - u_int16_t scrub_flags; + uint16_t return_icmp; + uint16_t return_icmp6; + uint16_t max_mss; + uint16_t tag; + uint16_t match_tag; + uint16_t scrub_flags; struct pf_rule_uid uid; struct pf_rule_gid gid; - u_int32_t rule_flag; - u_int8_t action; - u_int8_t direction; - u_int8_t log; - u_int8_t logif; - u_int8_t quick; - u_int8_t ifnot; - u_int8_t match_tag_not; - u_int8_t natpass; - - u_int8_t keep_state; + uint32_t rule_flag; + uint8_t action; + uint8_t direction; + uint8_t log; + uint8_t logif; + uint8_t quick; + uint8_t ifnot; + uint8_t match_tag_not; + uint8_t natpass; + + uint8_t keep_state; sa_family_t af; - u_int8_t proto; - u_int8_t type; - u_int8_t code; - u_int8_t flags; - u_int8_t flagset; - u_int8_t min_ttl; - u_int8_t allow_opts; - u_int8_t rt; - u_int8_t return_ttl; - u_int8_t tos; - u_int8_t set_tos; - u_int8_t anchor_relative; - u_int8_t anchor_wildcard; - - u_int8_t flush; - u_int8_t prio; - u_int8_t set_prio[2]; + uint8_t proto; + uint8_t type; + uint8_t code; + uint8_t flags; + uint8_t flagset; + uint8_t min_ttl; + uint8_t allow_opts; + uint8_t rt; + uint8_t return_ttl; + uint8_t tos; + uint8_t set_tos; + uint8_t anchor_relative; + uint8_t anchor_wildcard; + + uint8_t flush; + uint8_t prio; + uint8_t set_prio[2]; struct { struct pf_addr addr; - u_int16_t port; + uint16_t port; } divert; }; @@ -181,13 +181,13 @@ struct pfctl_ruleset { struct { struct pfctl_rulequeue *ptr; struct pfctl_rule **ptr_array; - u_int32_t rcount; - u_int32_t ticket; + uint32_t rcount; + uint32_t ticket; int open; } active, inactive; } rules[PF_RULESET_MAX]; struct pfctl_anchor *anchor; - u_int32_t tticket; + uint32_t tticket; int tables; int topen; }; @@ -291,15 +291,15 @@ struct pfctl_syncookies { struct pfctl_status* pfctl_get_status(int dev); void pfctl_free_status(struct pfctl_status *status); -int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, - const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, +int pfctl_get_rule(int dev, uint32_t nr, uint32_t ticket, + const char *anchor, uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call); -int pfctl_get_clear_rule(int dev, u_int32_t nr, u_int32_t ticket, - const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, +int pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket, + const char *anchor, uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call, bool clear); int pfctl_add_rule(int dev, const struct pfctl_rule *r, - const char *anchor, const char *anchor_call, u_int32_t ticket, - u_int32_t pool_ticket); + const char *anchor, const char *anchor_call, uint32_t ticket, + uint32_t pool_ticket); int pfctl_set_keepcounters(int dev, bool keep); int pfctl_get_states(int dev, struct pfctl_states *states); void pfctl_free_states(struct pfctl_states *states); From nobody Fri Nov 5 09:19: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 3FAE3184C04F; Fri, 5 Nov 2021 09:19: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 4Hlw1g10S8z4kCM; Fri, 5 Nov 2021 09:19: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 02B04150CF; Fri, 5 Nov 2021 09:19: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 1A59JIHV078224; Fri, 5 Nov 2021 09:19:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A59JIGD078223; Fri, 5 Nov 2021 09:19:18 GMT (envelope-from git) Date: Fri, 5 Nov 2021 09:19:18 GMT Message-Id: <202111050919.1A59JIGD078223@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: b8f94506f2d4 - main - sdhci: Provide devmethod for software reset 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: b8f94506f2d4b0ae811f27c244896d044d8780bf Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=b8f94506f2d4b0ae811f27c244896d044d8780bf commit b8f94506f2d4b0ae811f27c244896d044d8780bf Author: Artur Rojek AuthorDate: 2021-11-05 09:14:25 +0000 Commit: Wojciech Macek CommitDate: 2021-11-05 09:18:57 +0000 sdhci: Provide devmethod for software reset Some sdhci controllers require custom software reset logic. Accommodate this need by introducing a new SDHCI_RESET devmethod. Move the existing reset logic into sdhci_generic_reset and use it as a default for the aforementioned method. Obtained from: Semihalf Sponsored by: Alstom Group Differeential revision: https://reviews.freebsd.org/D32704 --- sys/dev/sdhci/sdhci.c | 157 ++++++++++++++++++++++++----------------------- sys/dev/sdhci/sdhci.h | 1 + sys/dev/sdhci/sdhci_if.m | 6 ++ 3 files changed, 87 insertions(+), 77 deletions(-) diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index 4a59a73a7e26..22618ca0a822 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -106,7 +106,6 @@ static void sdhci_init(struct sdhci_slot *slot); static void sdhci_read_block_pio(struct sdhci_slot *slot); static void sdhci_req_done(struct sdhci_slot *slot); static void sdhci_req_wakeup(struct mmc_request *req); -static void sdhci_reset(struct sdhci_slot *slot, uint8_t mask); static void sdhci_retune(void *arg); static void sdhci_set_clock(struct sdhci_slot *slot, uint32_t clock); static void sdhci_set_power(struct sdhci_slot *slot, u_char power); @@ -370,66 +369,6 @@ sdhci_syctl_dumpcaps(SYSCTL_HANDLER_ARGS) return (0); } -static void -sdhci_reset(struct sdhci_slot *slot, uint8_t mask) -{ - int timeout; - uint32_t clock; - - if (slot->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) { - if (!SDHCI_GET_CARD_PRESENT(slot->bus, slot)) - return; - } - - /* Some controllers need this kick or reset won't work. */ - if ((mask & SDHCI_RESET_ALL) == 0 && - (slot->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)) { - /* This is to force an update */ - clock = slot->clock; - slot->clock = 0; - sdhci_set_clock(slot, clock); - } - - if (mask & SDHCI_RESET_ALL) { - slot->clock = 0; - slot->power = 0; - } - - WR1(slot, SDHCI_SOFTWARE_RESET, mask); - - if (slot->quirks & SDHCI_QUIRK_WAITFOR_RESET_ASSERTED) { - /* - * Resets on TI OMAPs and AM335x are incompatible with SDHCI - * specification. The reset bit has internal propagation delay, - * so a fast read after write returns 0 even if reset process is - * in progress. The workaround is to poll for 1 before polling - * for 0. In the worst case, if we miss seeing it asserted the - * time we spent waiting is enough to ensure the reset finishes. - */ - timeout = 10000; - while ((RD1(slot, SDHCI_SOFTWARE_RESET) & mask) != mask) { - if (timeout <= 0) - break; - timeout--; - DELAY(1); - } - } - - /* Wait max 100 ms */ - timeout = 10000; - /* Controller clears the bits when it's done */ - while (RD1(slot, SDHCI_SOFTWARE_RESET) & mask) { - if (timeout <= 0) { - slot_printf(slot, "Reset 0x%x never completed.\n", - mask); - sdhci_dumpregs(slot); - return; - } - timeout--; - DELAY(10); - } -} - static uint32_t sdhci_tuning_intmask(const struct sdhci_slot *slot) { @@ -449,7 +388,7 @@ static void sdhci_init(struct sdhci_slot *slot) { - sdhci_reset(slot, SDHCI_RESET_ALL); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_ALL); /* Enable interrupts. */ slot->intmask = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT | @@ -1256,7 +1195,7 @@ sdhci_cleanup_slot(struct sdhci_slot *slot) device_delete_child(slot->bus, d); SDHCI_LOCK(slot); - sdhci_reset(slot, SDHCI_RESET_ALL); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_ALL); SDHCI_UNLOCK(slot); if (slot->opt & SDHCI_HAVE_DMA) sdhci_dma_free(slot); @@ -1283,7 +1222,7 @@ sdhci_generic_suspend(struct sdhci_slot *slot) callout_drain(&slot->retune_callout); SDHCI_LOCK(slot); slot->opt &= ~SDHCI_TUNING_ENABLED; - sdhci_reset(slot, SDHCI_RESET_ALL); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_ALL); SDHCI_UNLOCK(slot); return (0); @@ -1300,6 +1239,67 @@ sdhci_generic_resume(struct sdhci_slot *slot) return (0); } +void +sdhci_generic_reset(device_t brdev __unused, struct sdhci_slot *slot, + uint8_t mask) +{ + int timeout; + uint32_t clock; + + if (slot->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) { + if (!SDHCI_GET_CARD_PRESENT(slot->bus, slot)) + return; + } + + /* Some controllers need this kick or reset won't work. */ + if ((mask & SDHCI_RESET_ALL) == 0 && + (slot->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)) { + /* This is to force an update */ + clock = slot->clock; + slot->clock = 0; + sdhci_set_clock(slot, clock); + } + + if (mask & SDHCI_RESET_ALL) { + slot->clock = 0; + slot->power = 0; + } + + WR1(slot, SDHCI_SOFTWARE_RESET, mask); + + if (slot->quirks & SDHCI_QUIRK_WAITFOR_RESET_ASSERTED) { + /* + * Resets on TI OMAPs and AM335x are incompatible with SDHCI + * specification. The reset bit has internal propagation delay, + * so a fast read after write returns 0 even if reset process is + * in progress. The workaround is to poll for 1 before polling + * for 0. In the worst case, if we miss seeing it asserted the + * time we spent waiting is enough to ensure the reset finishes. + */ + timeout = 10000; + while ((RD1(slot, SDHCI_SOFTWARE_RESET) & mask) != mask) { + if (timeout <= 0) + break; + timeout--; + DELAY(1); + } + } + + /* Wait max 100 ms */ + timeout = 10000; + /* Controller clears the bits when it's done */ + while (RD1(slot, SDHCI_SOFTWARE_RESET) & mask) { + if (timeout <= 0) { + slot_printf(slot, "Reset 0x%x never completed.\n", + mask); + sdhci_dumpregs(slot); + return; + } + timeout--; + DELAY(10); + } +} + uint32_t sdhci_generic_min_freq(device_t brdev __unused, struct sdhci_slot *slot) { @@ -1391,7 +1391,8 @@ sdhci_generic_update_ios(device_t brdev, device_t reqdev) SDHCI_SET_UHS_TIMING(brdev, slot); /* Some controllers like reset after bus changes. */ if (slot->quirks & SDHCI_QUIRK_RESET_ON_IOS) - sdhci_reset(slot, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, + SDHCI_RESET_CMD | SDHCI_RESET_DATA); SDHCI_UNLOCK(slot); return (0); @@ -1634,7 +1635,7 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset) slot_printf(slot, "Tuning failed, using fixed sampling clock\n"); WR2(slot, SDHCI_HOST_CONTROL2, hostctrl2 & ~(SDHCI_CTRL2_EXEC_TUNING | SDHCI_CTRL2_SAMPLING_CLOCK)); - sdhci_reset(slot, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_CMD | SDHCI_RESET_DATA); return (EIO); } @@ -1703,7 +1704,8 @@ sdhci_timeout(void *arg) if (slot->curcmd != NULL) { slot_printf(slot, "Controller timeout\n"); sdhci_dumpregs(slot); - sdhci_reset(slot, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, + SDHCI_RESET_CMD | SDHCI_RESET_DATA); slot->curcmd->error = MMC_ERR_TIMEOUT; sdhci_req_done(slot); } else { @@ -1881,8 +1883,8 @@ sdhci_finish_command(struct sdhci_slot *slot) if (slot->curcmd->error) { if (slot->curcmd->error == MMC_ERR_BADCRC) slot->retune_req |= SDHCI_RETUNE_REQ_RESET; - sdhci_reset(slot, SDHCI_RESET_CMD); - sdhci_reset(slot, SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_CMD); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_DATA); sdhci_start(slot); return; } @@ -2041,8 +2043,8 @@ sdhci_finish_data(struct sdhci_slot *slot) if (slot->curcmd->error) { if (slot->curcmd->error == MMC_ERR_BADCRC) slot->retune_req |= SDHCI_RETUNE_REQ_RESET; - sdhci_reset(slot, SDHCI_RESET_CMD); - sdhci_reset(slot, SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_CMD); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_DATA); sdhci_start(slot); return; } @@ -2084,8 +2086,8 @@ sdhci_start(struct sdhci_slot *slot) slot_printf(slot, "result: %d\n", mmcio->cmd.error); if (mmcio->cmd.error == 0 && (slot->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST)) { - sdhci_reset(slot, SDHCI_RESET_CMD); - sdhci_reset(slot, SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_CMD); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_DATA); } sdhci_req_done(slot); @@ -2117,8 +2119,8 @@ sdhci_start(struct sdhci_slot *slot) ((slot->curcmd == req->stop && (slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP)) || (slot->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { - sdhci_reset(slot, SDHCI_RESET_CMD); - sdhci_reset(slot, SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_CMD); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_DATA); } sdhci_req_done(slot); @@ -2343,7 +2345,7 @@ sdhci_acmd_irq(struct sdhci_slot *slot, uint16_t acmd_err) return; } slot_printf(slot, "Got AutoCMD12 error 0x%04x\n", acmd_err); - sdhci_reset(slot, SDHCI_RESET_CMD); + SDHCI_RESET(slot->bus, slot, SDHCI_RESET_CMD); } void @@ -2849,7 +2851,8 @@ sdhci_cam_update_ios(struct sdhci_slot *slot) WR1(slot, SDHCI_HOST_CONTROL, slot->hostctrl); /* Some controllers like reset after bus changes. */ if(slot->quirks & SDHCI_QUIRK_RESET_ON_IOS) - sdhci_reset(slot, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + SDHCI_RESET(slot->bus, slot, + SDHCI_RESET_CMD | SDHCI_RESET_DATA); SDHCI_UNLOCK(slot); return (0); diff --git a/sys/dev/sdhci/sdhci.h b/sys/dev/sdhci/sdhci.h index 9d68a14b28a2..4feb272bb359 100644 --- a/sys/dev/sdhci/sdhci.h +++ b/sys/dev/sdhci/sdhci.h @@ -431,6 +431,7 @@ void sdhci_finish_data(struct sdhci_slot *slot); int sdhci_cleanup_slot(struct sdhci_slot *slot); int sdhci_generic_suspend(struct sdhci_slot *slot); int sdhci_generic_resume(struct sdhci_slot *slot); +void sdhci_generic_reset(device_t brdev, struct sdhci_slot *slot, uint8_t mask); int sdhci_generic_update_ios(device_t brdev, device_t reqdev); int sdhci_generic_tune(device_t brdev, device_t reqdev, bool hs400); int sdhci_generic_switch_vccq(device_t brdev, device_t reqdev); diff --git a/sys/dev/sdhci/sdhci_if.m b/sys/dev/sdhci/sdhci_if.m index 93c97a155fb1..c888f35bdaf0 100644 --- a/sys/dev/sdhci/sdhci_if.m +++ b/sys/dev/sdhci/sdhci_if.m @@ -164,3 +164,9 @@ METHOD void set_uhs_timing { device_t brdev; struct sdhci_slot *slot; } DEFAULT null_set_uhs_timing; + +METHOD void reset { + device_t brdev; + struct sdhci_slot *slot; + uint8_t mask; +} DEFAULT sdhci_generic_reset; From nobody Fri Nov 5 09:19: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 C3879184C061; Fri, 5 Nov 2021 09:19: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 4Hlw1h33s1z4k9F; Fri, 5 Nov 2021 09:19: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 3689915247; Fri, 5 Nov 2021 09:19: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 1A59JKkQ078254; Fri, 5 Nov 2021 09:19:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A59JK1T078253; Fri, 5 Nov 2021 09:19:20 GMT (envelope-from git) Date: Fri, 5 Nov 2021 09:19:20 GMT Message-Id: <202111050919.1A59JK1T078253@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: 36b80dba1742 - main - sdhci_fsl_fdt: Add full support for software reset 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: 36b80dba1742acfeecfe8c26516c5cf16fd1346d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=36b80dba1742acfeecfe8c26516c5cf16fd1346d commit 36b80dba1742acfeecfe8c26516c5cf16fd1346d Author: Artur Rojek AuthorDate: 2021-11-05 09:16:30 +0000 Commit: Wojciech Macek CommitDate: 2021-11-05 09:18:57 +0000 sdhci_fsl_fdt: Add full support for software reset When performing software reset, this controller does not clear all the required hw registers. In particular, tuning block is left in enabled state, inhibiting operation of some eMMC cards. The existing solution was to disable the ability to call SDHCI_RESET_ALL. As this issue is now better understood, enable the SDHCI_RESET_ALL flag, provide a custom reset devmethod and clear selected registers by hand. Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D32705 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 5aec394b9192..77af367c5366 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -86,6 +86,9 @@ __FBSDID("$FreeBSD$"); #define SDHCI_FSL_HOST_VERSION 0xfc #define SDHCI_FSL_CAPABILITIES2 0x114 +#define SDHCI_FSL_TBCTL 0x120 +#define SDHCI_FSL_TBCTL_TBEN (1 << 2) + #define SDHCI_FSL_ESDHC_CTRL 0x40c #define SDHCI_FSL_ESDHC_CTRL_SNOOP (1 << 6) #define SDHCI_FSL_ESDHC_CTRL_CLK_DIV2 (1 << 19) @@ -347,9 +350,6 @@ sdhci_fsl_fdt_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, return; case SDHCI_POWER_CONTROL: return; - case SDHCI_SOFTWARE_RESET: - val &= ~SDHCI_RESET_ALL; - /* FALLTHROUGH. */ default: val32 = RD4(sc, off & ~3); val32 &= ~(UINT8_MAX << (off & 3) * 8); @@ -803,6 +803,27 @@ sdhci_fsl_fdt_read_ivar(device_t bus, device_t child, int which, return (sdhci_generic_read_ivar(bus, child, which, result)); } +static void +sdhci_fsl_fdt_reset(device_t dev, struct sdhci_slot *slot, uint8_t mask) +{ + struct sdhci_fsl_fdt_softc *sc; + uint32_t val; + + sdhci_generic_reset(dev, slot, mask); + + if (!(mask & SDHCI_RESET_ALL)) + return; + + sc = device_get_softc(dev); + + /* Some registers have to be cleared by hand. */ + if (slot->version >= SDHCI_SPEC_300) { + val = RD4(sc, SDHCI_FSL_TBCTL); + val &= ~SDHCI_FSL_TBCTL_TBEN; + WR4(sc, SDHCI_FSL_TBCTL, val); + } +} + static const device_method_t sdhci_fsl_fdt_methods[] = { /* Device interface. */ DEVMETHOD(device_probe, sdhci_fsl_fdt_probe), @@ -831,6 +852,7 @@ static const device_method_t sdhci_fsl_fdt_methods[] = { DEVMETHOD(sdhci_write_4, sdhci_fsl_fdt_write_4), DEVMETHOD(sdhci_write_multi_4, sdhci_fsl_fdt_write_multi_4), DEVMETHOD(sdhci_get_card_present, sdhci_fsl_fdt_get_card_present), + DEVMETHOD(sdhci_reset, sdhci_fsl_fdt_reset), DEVMETHOD_END }; From nobody Fri Nov 5 09:19: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 EA34A184C309; Fri, 5 Nov 2021 09:19:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hlw1j3s33z4kJK; Fri, 5 Nov 2021 09:19:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 48B38152EC; Fri, 5 Nov 2021 09:19:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A59JLhX078280; Fri, 5 Nov 2021 09:19:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A59JL4h078279; Fri, 5 Nov 2021 09:19:21 GMT (envelope-from git) Date: Fri, 5 Nov 2021 09:19:21 GMT Message-Id: <202111050919.1A59JL4h078279@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: 8b57ee7e0107 - main - sdhci_fsl_fdt: Provide more accurate clk calculation 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: 8b57ee7e0107695403702cca2b5ac0dfa452b5ee Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=8b57ee7e0107695403702cca2b5ac0dfa452b5ee commit 8b57ee7e0107695403702cca2b5ac0dfa452b5ee Author: Artur Rojek AuthorDate: 2021-11-05 09:17:49 +0000 Commit: Wojciech Macek CommitDate: 2021-11-05 09:18:57 +0000 sdhci_fsl_fdt: Provide more accurate clk calculation SDHCI controllers found in the QorIQ SoCs offer improved accuracy of the clock frequency selection, compared to the SDHCI standard. Frequency selection is performed using two divider registers, named prescaler and divisor, according to the following formula: frequency = base clock / (prescaler * divisor), where prescaler can be bypassed (set to 1) and divisor permitted to take odd values. Rather than depend on clock division precalculated by sdhci core, make use of this property of the divider registers and achieve frequencies closer to the ones requested. Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D32706 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 74 +++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 77af367c5366..06e3afeb4b09 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); #define SDHCI_FSL_WTMK_WR_512B (0 << 15) #define SDHCI_FSL_HOST_VERSION 0xfc +#define SDHCI_FSL_VENDOR_V23 0x13 #define SDHCI_FSL_CAPABILITIES2 0x114 #define SDHCI_FSL_TBCTL 0x120 @@ -110,6 +111,7 @@ struct sdhci_fsl_fdt_softc { uint32_t cmd_and_mode; uint16_t sdclk_bits; struct mmc_helper fdt_helper; + uint8_t vendor_ver; uint32_t (* read)(struct sdhci_fsl_fdt_softc *, bus_size_t); void (* write)(struct sdhci_fsl_fdt_softc *, bus_size_t, uint32_t); @@ -186,10 +188,26 @@ sdhci_fsl_fdt_get_clock(struct sdhci_fsl_fdt_softc *sc) return (val); } +/* + * Calculate clock prescaler and divisor values based on the following formula: + * `frequency = base clock / (prescaler * divisor)`. + */ +#define SDHCI_FSL_FDT_CLK_DIV(sc, base, freq, pre, div) \ + do { \ + (pre) = (sc)->vendor_ver < SDHCI_FSL_VENDOR_V23 ? 2 : 1;\ + while ((freq) < (base) / ((pre) * 16) && (pre) < 256) \ + (pre) <<= 1; \ + /* div/pre can't both be set to 1, according to PM. */ \ + (div) = ((pre) == 1 ? 2 : 1); \ + while ((freq) < (base) / ((pre) * (div)) && (div) < 16) \ + ++(div); \ + } while (0) + static void -fsl_sdhc_fdt_set_clock(struct sdhci_fsl_fdt_softc *sc, uint16_t val) +fsl_sdhc_fdt_set_clock(struct sdhci_fsl_fdt_softc *sc, struct sdhci_slot *slot, + uint16_t val) { - uint32_t div, freq, prescale, val32; + uint32_t prescale, div, val32; sc->sdclk_bits = val & SDHCI_DIVIDERS_MASK; val32 = RD4(sc, SDHCI_CLOCK_CONTROL); @@ -199,23 +217,16 @@ fsl_sdhc_fdt_set_clock(struct sdhci_fsl_fdt_softc *sc, uint16_t val) return; } - div = ((val >> SDHCI_DIVIDER_SHIFT) & SDHCI_DIVIDER_MASK) | - ((val >> SDHCI_DIVIDER_HI_SHIFT) & SDHCI_DIVIDER_HI_MASK) << - SDHCI_DIVIDER_MASK_LEN; - if (div == 0) - freq = sc->maxclk_hz; - else - freq = sc->maxclk_hz / (2 * div); - - for (prescale = 2; freq < sc->baseclk_hz / (prescale * 16); ) - prescale <<= 1; - for (div = 1; freq < sc->baseclk_hz / (prescale * div); ) - ++div; + /* + * Ignore dividers provided by core in `sdhci_set_clock` and calculate + * them anew with higher accuracy. + */ + SDHCI_FSL_FDT_CLK_DIV(sc, sc->baseclk_hz, slot->clock, prescale, div); #ifdef DEBUG device_printf(sc->dev, "Desired SD/MMC freq: %d, actual: %d; base %d prescale %d divisor %d\n", - freq, sc->baseclk_hz / (prescale * div), + slot->clock, sc->baseclk_hz / (prescale * div), sc->baseclk_hz, prescale, div); #endif @@ -370,7 +381,7 @@ sdhci_fsl_fdt_write_2(device_t dev, struct sdhci_slot *slot, bus_size_t off, switch (off) { case SDHCI_CLOCK_CONTROL: - fsl_sdhc_fdt_set_clock(sc, val); + fsl_sdhc_fdt_set_clock(sc, slot, val); return; /* * eSDHC hardware combines command and mode into a single @@ -689,6 +700,9 @@ sdhci_fsl_fdt_attach(device_t dev) buf_order = SDHCI_FSL_PROT_CTRL_BYTE_SWAP; } + sc->vendor_ver = (RD4(sc, SDHCI_FSL_HOST_VERSION) & + SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT; + sdhci_fsl_fdt_of_parse(dev); sc->maxclk_hz = host->f_max ? host->f_max : sc->baseclk_hz; @@ -803,6 +817,32 @@ sdhci_fsl_fdt_read_ivar(device_t bus, device_t child, int which, return (sdhci_generic_read_ivar(bus, child, which, result)); } +static int +sdhci_fsl_fdt_write_ivar(device_t bus, device_t child, int which, + uintptr_t value) +{ + struct sdhci_fsl_fdt_softc *sc; + struct sdhci_slot *slot = device_get_ivars(child); + uint32_t prescale, div; + + /* Don't depend on clock resolution limits from sdhci core. */ + if (which == MMCBR_IVAR_CLOCK) { + if (value == 0) { + slot->host.ios.clock = 0; + return (0); + } + + sc = device_get_softc(bus); + + SDHCI_FSL_FDT_CLK_DIV(sc, sc->baseclk_hz, value, prescale, div); + slot->host.ios.clock = sc->baseclk_hz / (prescale * div); + + return (0); + } + + return (sdhci_generic_write_ivar(bus, child, which, value)); +} + static void sdhci_fsl_fdt_reset(device_t dev, struct sdhci_slot *slot, uint8_t mask) { @@ -832,7 +872,7 @@ static const device_method_t sdhci_fsl_fdt_methods[] = { /* Bus interface. */ DEVMETHOD(bus_read_ivar, sdhci_fsl_fdt_read_ivar), - DEVMETHOD(bus_write_ivar, sdhci_generic_write_ivar), + DEVMETHOD(bus_write_ivar, sdhci_fsl_fdt_write_ivar), /* MMC bridge interface. */ DEVMETHOD(mmcbr_request, sdhci_generic_request), From nobody Fri Nov 5 11:53:01 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 9A4A9182922D; Fri, 5 Nov 2021 11:53: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 4HlzR13cgHz4XjX; Fri, 5 Nov 2021 11:53: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 5861317557; Fri, 5 Nov 2021 11:53: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 1A5Br1VW090498; Fri, 5 Nov 2021 11:53:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5Br1Aq090497; Fri, 5 Nov 2021 11:53:01 GMT (envelope-from git) Date: Fri, 5 Nov 2021 11:53:01 GMT Message-Id: <202111051153.1A5Br1Aq090497@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: 046e2d5db1e8 - main - Implementations of cexpl() 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: 046e2d5db1e8afd2d09ea28e5d2a7550535d4b77 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=046e2d5db1e8afd2d09ea28e5d2a7550535d4b77 commit 046e2d5db1e8afd2d09ea28e5d2a7550535d4b77 Author: Steve Kargl AuthorDate: 2021-11-05 02:04:01 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-05 11:51:42 +0000 Implementations of cexpl() The change implements cexpl() for both ld80 and ld128 architectures. Testing was done on x86_64 and aarch64 systems. Along the way sincos[fl]() use an optimization that reduces the argument to being done one rather than twice. This optimization actually pointed to a bug in the ld128 version of sincosl(), which is now fixed. In addition, the minmax polynomial coefficients for sincosl() have been updated. A concise log of the file-by-file changes follows. * include/complex.h: . Add a prototype for cexpl(). * lib/msun/Makefile: . Add s_cexpl.c to the build. . Setup a link for cexpl.3 to cexp.3. * lib/msun/Symbol.map: . Expose cexpl symbol in libm shared library. * lib/msun/ld128/s_cexpl.c: * Implementation of cexpl() for 128-bit long double architectures. Tested on an aarch64 system. * lib/msun/ld80/s_cexpl.c: * Implementation of cexpl() for Intel 80-bit long double. * lib/msun/man/cexp.3: . Document cexpl(). * lib/msun/man/complex.3: . Add a BUGS section about cpow[fl]. * lib/msun/src/s_cexp.c: . Include float.h for weak references on 53-bit long double targets. . Use sincos() to reduce argument reduction cost. * lib/msun/src/s_cexpf.c: . Use sincosf() to reduce argument reduction cost. * lib/msun/src/k_sincosl.h: . Catch up with the new minmax polynomial coefficients for the kernel for the 128-bit cosl() implementation. . BUG FIX: *cs was used where *sn should have been. This means that sinl() was no computed correctly when iy != 0. * lib/msun/src/s_cosl.c: . Include fpmath.h to get access to IEEEl2bits. . Replace M_PI_4 with pio4, a 64-bit or 113-bit approximation for pi / 4. PR: 216862 MFC after: 1 week --- include/complex.h | 2 + lib/msun/Makefile | 4 +- lib/msun/Symbol.map | 1 + lib/msun/ld128/s_cexpl.c | 94 +++++++++++++++++++++++++++++++++++++++++ lib/msun/ld80/s_cexpl.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++ lib/msun/man/cexp.3 | 17 +++++--- lib/msun/man/complex.3 | 8 +++- lib/msun/src/k_sincosl.h | 29 +++++++------ lib/msun/src/s_cexp.c | 16 +++++-- lib/msun/src/s_cexpf.c | 11 +++-- lib/msun/src/s_cosl.c | 7 +++- 11 files changed, 265 insertions(+), 31 deletions(-) diff --git a/include/complex.h b/include/complex.h index 892bc55e5145..c31c15d9da4b 100644 --- a/include/complex.h +++ b/include/complex.h @@ -98,6 +98,8 @@ double complex ccosh(double complex); float complex ccoshf(float complex); double complex cexp(double complex); float complex cexpf(float complex); +long double complex + cexpl(long double complex); double cimag(double complex) __pure2; float cimagf(float complex) __pure2; long double cimagl(long double complex) __pure2; diff --git a/lib/msun/Makefile b/lib/msun/Makefile index 1d94e371e61f..d7c0e2f88358 100644 --- a/lib/msun/Makefile +++ b/lib/msun/Makefile @@ -117,7 +117,7 @@ COMMON_SRCS+= catrigl.c \ e_lgammal.c e_lgammal_r.c e_powl.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_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c s_cexpl.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 \ @@ -189,7 +189,7 @@ MLINKS+=ccos.3 ccosf.3 ccos.3 csin.3 ccos.3 csinf.3 ccos.3 ctan.3 ccos.3 ctanf.3 MLINKS+=ccosh.3 ccoshf.3 ccosh.3 csinh.3 ccosh.3 csinhf.3 \ ccosh.3 ctanh.3 ccosh.3 ctanhf.3 MLINKS+=ceil.3 ceilf.3 ceil.3 ceill.3 -MLINKS+=cexp.3 cexpf.3 +MLINKS+=cexp.3 cexpf.3 cexp.3 cexpl.3 MLINKS+=cimag.3 cimagf.3 cimag.3 cimagl.3 \ cimag.3 conj.3 cimag.3 conjf.3 cimag.3 conjl.3 \ cimag.3 cproj.3 cimag.3 cprojf.3 cimag.3 cprojl.3 \ diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map index 7229e7ef31fd..8650d56eb9d5 100644 --- a/lib/msun/Symbol.map +++ b/lib/msun/Symbol.map @@ -307,6 +307,7 @@ FBSD_1.5 { /* First added in 14.0-CURRENT */ FBSD_1.7 { + cexpl; cospi; cospif; cospil; diff --git a/lib/msun/ld128/s_cexpl.c b/lib/msun/ld128/s_cexpl.c new file mode 100644 index 000000000000..24f5e3792115 --- /dev/null +++ b/lib/msun/ld128/s_cexpl.c @@ -0,0 +1,94 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 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, 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 "fpmath.h" +#include "math_private.h" +#include "k_expl.h" + +/* XXX cexpl() should be converted to use bits likeo src/s_cexp.c. */ + +static const long double +cexp_ovfl = 2.27892930024498818830197576893019292e+04L, +exp_ovfl = 1.13565234062941439494919310779707649e+04L; + +long double complex +cexpl(long double complex z) +{ + long double c, exp_x, s, x, y; + + x = creall(z); + y = cimagl(z); + + /* cexp(x + I 0) = exp(x) + I 0 */ + if (y == 0) + return (CMPLXL(expl(x), y)); + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if (x == 0) { + sincosl(y, &s, &c); + return (CMPLXL(c, s)); + } + + if (!isfinite(y)) { + if (isfinite(x) || isnan(x)) { + /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ + return (CMPLXL(y - y, y - y)); + } else if (isinf(x) && copysignl(1.L, x) < 0) { + /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ + return (CMPLXL(0.0, 0.0)); + } else { + /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ + return (CMPLXL(x, y - y)); + } + } + + if (x > exp_ovfl && x < cexp_ovfl) { + /* + * x is between exp_ovfl and cexp_ovfl, so we must scale to + * avoid overflow in exp(x). + */ + return (__ldexp_cexpl(z, 0)); + } else { + /* + * Cases covered here: + * - x < exp_ovfl and exp(x) won't overflow (common case) + * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 + * - x = +-Inf (generated by exp()) + * - x = NaN (spurious inexact exception from y) + */ + exp_x = expl(x); + sincosl(y, &s, &c); + return (CMPLXL(exp_x * c, exp_x * s)); + } +} diff --git a/lib/msun/ld80/s_cexpl.c b/lib/msun/ld80/s_cexpl.c new file mode 100644 index 000000000000..5cc35f6d2514 --- /dev/null +++ b/lib/msun/ld80/s_cexpl.c @@ -0,0 +1,107 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2011 David Schultz + * 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. + * + * src/s_cexp.c converted to long double complex by Steven G. Kargl + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#ifdef __i386__ +#include +#endif + +#include "fpmath.h" +#include "math.h" +#include "math_private.h" +#include "k_expl.h" + +long double complex +cexpl (long double complex z) +{ + long double c, exp_x, s, x, y; + uint64_t lx, ly; + uint16_t hx, hy; + + ENTERI(); + + x = creall(z); + y = cimagl(z); + + EXTRACT_LDBL80_WORDS(hy, ly, y); + hy &= 0x7fff; + + /* cexp(x + I 0) = exp(x) + I 0 */ + if ((hy | ly) == 0) + RETURNI(CMPLXL(expl(x), y)); + EXTRACT_LDBL80_WORDS(hx, lx, x); + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if (((hx & 0x7fff) | lx) == 0) { + sincosl(y, &s, &c); + RETURNI(CMPLXL(c, s)); + } + + if (hy >= 0x7fff) { + if ((hx & 0x7fff) < 0x7fff || ((hx & 0x7fff) == 0x7fff && + (lx & 0x7fffffffffffffffULL) != 0)) { + /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ + RETURNI(CMPLXL(y - y, y - y)); + } else if (hx & 0x8000) { + /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ + RETURNI(CMPLXL(0.0, 0.0)); + } else { + /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ + RETURNI(CMPLXL(x, y - y)); + } + } + + /* + * exp_ovfl = 11356.5234062941439497 + * cexp_ovfl = 22755.3287906024445633 + */ + if ((hx == 0x400c && lx > 0xb17217f7d1cf79acULL) || + (hx == 0x400d && lx < 0xb1c6a8573de9768cULL)) { + /* + * x is between exp_ovfl and cexp_ovfl, so we must scale to + * avoid overflow in exp(x). + */ + RETURNI(__ldexp_cexpl(z, 0)); + } else { + /* + * Cases covered here: + * - x < exp_ovfl and exp(x) won't overflow (common case) + * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 + * - x = +-Inf (generated by exp()) + * - x = NaN (spurious inexact exception from y) + */ + exp_x = expl(x); + sincosl(y, &s, &c); + RETURNI(CMPLXL(exp_x * c, exp_x * s)); + } +} diff --git a/lib/msun/man/cexp.3 b/lib/msun/man/cexp.3 index 776e6cee823e..27ab3e9c2098 100644 --- a/lib/msun/man/cexp.3 +++ b/lib/msun/man/cexp.3 @@ -24,12 +24,13 @@ .\" .\" $FreeBSD$ .\" -.Dd March 6, 2011 +.Dd November 3, 2021 .Dt CEXP 3 .Os .Sh NAME .Nm cexp , -.Nm cexpf +.Nm cexpf , +.Nm cexpl .Nd complex exponential functions .Sh LIBRARY .Lb libm @@ -39,11 +40,14 @@ .Fn cexp "double complex z" .Ft float complex .Fn cexpf "float complex z" +.Ft long double complex +.Fn cexpl "long double complex z" .Sh DESCRIPTION The -.Fn cexp +.Fn cexp , +.Fn cexpf , and -.Fn cexpf +.Fn cexpl functions compute the complex exponential of .Fa z , also known as @@ -106,8 +110,9 @@ is not finite, the sign of the result is indeterminate. .Xr math 3 .Sh STANDARDS The -.Fn cexp +.Fn cexp , +.Fn cexpf , and -.Fn cexpf +.Fn cexpl functions conform to .St -isoC-99 . diff --git a/lib/msun/man/complex.3 b/lib/msun/man/complex.3 index f1acfbe6da74..8cc0b7f97c52 100644 --- a/lib/msun/man/complex.3 +++ b/lib/msun/man/complex.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 19, 2018 +.Dd November 3, 2021 .Dt COMPLEX 3 .Os .Sh NAME @@ -121,3 +121,9 @@ The .In complex.h functions described here conform to .St -isoC-99 . +.Sh BUGS +The power functions, +.Fn cpowf, cpow , +and +.Fn cpowl , +are implemented, but the code was neither reviewed nor tested. diff --git a/lib/msun/src/k_sincosl.h b/lib/msun/src/k_sincosl.h index 4d4dc69f7820..6425f14a1ea0 100644 --- a/lib/msun/src/k_sincosl.h +++ b/lib/msun/src/k_sincosl.h @@ -76,13 +76,6 @@ __kernel_sincosl(long double x, long double y, int iy, long double *sn, #elif LDBL_MANT_DIG == 113 /* ld128 version of k_sincosl.c. */ static const long double -C1 = 0.04166666666666666666666666666666658424671L, -C2 = -0.001388888888888888888888888888863490893732L, -C3 = 0.00002480158730158730158730158600795304914210L, -C4 = -0.2755731922398589065255474947078934284324e-6L, -C5 = 0.2087675698786809897659225313136400793948e-8L, -C6 = -0.1147074559772972315817149986812031204775e-10L, -C7 = 0.4779477332386808976875457937252120293400e-13L, S1 = -0.16666666666666666666666666666666666606732416116558L, S2 = 0.0083333333333333333333333333333331135404851288270047L, S3 = -0.00019841269841269841269841269839935785325638310428717L, @@ -93,15 +86,25 @@ S7 = -0.76471637318198151807063387954939213287488216303768e-12L, S8 = 0.28114572543451292625024967174638477283187397621303e-14L; static const double -C8 = -0.1561920696721507929516718307820958119868e-15, -C9 = 0.4110317413744594971475941557607804508039e-18, -C10 = -0.8896592467191938803288521958313920156409e-21, -C11 = 0.1601061435794535138244346256065192782581e-23, S9 = -0.82206352458348947812512122163446202498005154296863e-17, S10 = 0.19572940011906109418080609928334380560135358385256e-19, S11 = -0.38680813379701966970673724299207480965452616911420e-22, S12 = 0.64038150078671872796678569586315881020659912139412e-25; +static const long double +C1 = 4.16666666666666666666666666666666667e-02L, +C2 = -1.38888888888888888888888888888888834e-03L, +C3 = 2.48015873015873015873015873015446795e-05L, +C4 = -2.75573192239858906525573190949988493e-07L, +C5 = 2.08767569878680989792098886701451072e-09L, +C6 = -1.14707455977297247136657111139971865e-11L, +C7 = 4.77947733238738518870113294139830239e-14L, +C8 = -1.56192069685858079920640872925306403e-16L, +C9 = 4.11031762320473354032038893429515732e-19L, +C10= -8.89679121027589608738005163931958096e-22L, +C11= 1.61171797801314301767074036661901531e-24L, +C12= -2.46748624357670948912574279501044295e-27L; + static inline void __kernel_sincosl(long double x, long double y, int iy, long double *sn, long double *cs) @@ -120,12 +123,12 @@ __kernel_sincosl(long double x, long double y, int iy, long double *sn, if (iy == 0) *sn = x + v * (S1 + z * r); else - *cs = x - ((z * (y / 2 - v * r) - y) - v * S1); + *sn = x - ((z * (y / 2 - v * r) - y) - v * S1); hz = z / 2; w = 1 - hz; r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * (C6 + - z * (C7 + z * (C8 + z * (C9 + z * (C10 + z * C11)))))))))); + z * (C7 + z * (C8 + z * (C9 + z * (C10 + z * (C11+z*C12))))))))))); *cs = w + (((1 - w) - hz) + (z * r - x * y)); } diff --git a/lib/msun/src/s_cexp.c b/lib/msun/src/s_cexp.c index 2ef8ba1972ca..a1f853eca4cc 100644 --- a/lib/msun/src/s_cexp.c +++ b/lib/msun/src/s_cexp.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include "math_private.h" @@ -41,7 +42,7 @@ cexp_ovfl = 0x4096b8e4; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ double complex cexp(double complex z) { - double x, y, exp_x; + double c, exp_x, s, x, y; uint32_t hx, hy, lx, ly; x = creal(z); @@ -55,8 +56,10 @@ cexp(double complex z) return (CMPLX(exp(x), y)); EXTRACT_WORDS(hx, lx, x); /* cexp(0 + I y) = cos(y) + I sin(y) */ - if (((hx & 0x7fffffff) | lx) == 0) - return (CMPLX(cos(y), sin(y))); + if (((hx & 0x7fffffff) | lx) == 0) { + sincos(y, &s, &c); + return (CMPLX(c, s)); + } if (hy >= 0x7ff00000) { if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) { @@ -86,6 +89,11 @@ cexp(double complex z) * - x = NaN (spurious inexact exception from y) */ exp_x = exp(x); - return (CMPLX(exp_x * cos(y), exp_x * sin(y))); + sincos(y, &s, &c); + return (CMPLX(exp_x * c, exp_x * s)); } } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(cexp, cexpl); +#endif diff --git a/lib/msun/src/s_cexpf.c b/lib/msun/src/s_cexpf.c index b815c99af89f..d905b74ff4bd 100644 --- a/lib/msun/src/s_cexpf.c +++ b/lib/msun/src/s_cexpf.c @@ -41,7 +41,7 @@ cexp_ovfl = 0x43400074; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ float complex cexpf(float complex z) { - float x, y, exp_x; + float c, exp_x, s, x, y; uint32_t hx, hy; x = crealf(z); @@ -55,8 +55,10 @@ cexpf(float complex z) return (CMPLXF(expf(x), y)); GET_FLOAT_WORD(hx, x); /* cexp(0 + I y) = cos(y) + I sin(y) */ - if ((hx & 0x7fffffff) == 0) - return (CMPLXF(cosf(y), sinf(y))); + if ((hx & 0x7fffffff) == 0) { + sincosf(y, &s, &c); + return (CMPLXF(c, s)); + } if (hy >= 0x7f800000) { if ((hx & 0x7fffffff) != 0x7f800000) { @@ -86,6 +88,7 @@ cexpf(float complex z) * - x = NaN (spurious inexact exception from y) */ exp_x = expf(x); - return (CMPLXF(exp_x * cosf(y), exp_x * sinf(y))); + sincosf(y, &s, &c); + return (CMPLXF(exp_x * c, exp_x * s)); } } diff --git a/lib/msun/src/s_cosl.c b/lib/msun/src/s_cosl.c index 46a2e8620a22..3d066483f227 100644 --- a/lib/msun/src/s_cosl.c +++ b/lib/msun/src/s_cosl.c @@ -39,12 +39,17 @@ __FBSDID("$FreeBSD$"); #include #endif +#include "fpmath.h" #include "math.h" #include "math_private.h" #if LDBL_MANT_DIG == 64 #include "../ld80/e_rem_pio2l.h" +static const union IEEEl2bits +pio4u = LD80C(0xc90fdaa22168c235, -00001, 7.85398163397448309628e-01L); +#define pio4 (pio4u.e) #elif LDBL_MANT_DIG == 113 #include "../ld128/e_rem_pio2l.h" +long double pio4 = 7.85398163397448309615660845819875721e-1L; #else #error "Unsupported long double format" #endif @@ -71,7 +76,7 @@ cosl(long double x) ENTERI(); /* Optimize the case where x is already within range. */ - if (z.e < M_PI_4) + if (z.e < pio4) RETURNI(__kernel_cosl(z.e, 0)); e0 = __ieee754_rem_pio2l(x, y); From nobody Fri Nov 5 12:41: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 6DF4418418F9; Fri, 5 Nov 2021 12:41:15 +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 4Hm0Vg1Yl1z4mdL; Fri, 5 Nov 2021 12:41:15 +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 F02926715; Fri, 5 Nov 2021 12:41:14 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id 5C1B738921; Fri, 5 Nov 2021 13:41:12 +0100 (CET) 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, 05 Nov 2021 13:41:11 +0100 X-Mailer: MailMate (1.13.2r5673) Message-ID: In-Reply-To: <5C3D57AA-5771-42FF-924B-3A09818F869D@FreeBSD.org> References: <202110290552.19T5qOjx061844@gitrepo.freebsd.org> <5C3D57AA-5771-42FF-924B-3A09818F869D@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"; format=flowed Content-Transfer-Encoding: quoted-printable X-ThisMailContainsUnwantedMimeParts: N Hi Kirk, On 29 Oct 2021, at 22:12, Kristof Provost wrote: > 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=3D68bff4a07e3fa6c30a0c0ff6cf5f= 0bef95dcbd72 >> >> 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[] =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 = >> 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 > >> @@ -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 verbose 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 = > specified. > > The set_flags() output is only used if g_func is set, which isn't the = > case in any of the examples in the commit message, so I wonder if that = > case was overlooked. > Have you had a chance to look at this? It=E2=80=99s causing multiple fail= ures = in the geom regression tests. Thanks, Kristof From nobody Fri Nov 5 14:54: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 E7518183462D; Fri, 5 Nov 2021 14:54: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 4Hm3SQ5C22z4YSc; Fri, 5 Nov 2021 14:54: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 8598219C13; Fri, 5 Nov 2021 14:54: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 1A5EsUZi032188; Fri, 5 Nov 2021 14:54:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5EsUpV032187; Fri, 5 Nov 2021 14:54:30 GMT (envelope-from git) Date: Fri, 5 Nov 2021 14:54:30 GMT Message-Id: <202111051454.1A5EsUpV032187@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: 517e52b6c21c - main - awk: Move to using two sets of tests 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: 517e52b6c21ccff22c46df0dcd15c19baee3d86c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=517e52b6c21ccff22c46df0dcd15c19baee3d86c commit 517e52b6c21ccff22c46df0dcd15c19baee3d86c Author: Warner Losh AuthorDate: 2021-11-04 16:09:16 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:53:36 +0000 awk: Move to using two sets of tests Upstream one-true-awk has two sets of tests. These are in addition to NetBSD's tests we're using. The 'bugs-fixed' tests from upstream are ready to use as-is (more or less). However, the 'tests' from upstream are not, so for now we'll just use the netbsd and bugs-fixed tests. They provide an OK workout and are better than nothing, though the tests themselves are for specific esoteric things. The upstream bugs-fixed tests are *ALMOST* a drop in. However, 3 test for errors and the upstream test jig mashes stdout and stderr together, which atf doesn't do, so make a tiny tweak to the upstream tests that I hope to upstream. Plus upstream has ../a.out: instead of awk: in the output. Not sure how to deal with this yet, so I've not proposed anything upstream and have changed the test locally. In addition, the system-status.awk test is not suitable to run in ATF. It wants to force sh to dump core, but kyua doesn't seem to allow that sometimes so the test will fail or pass based on whether or not a core dump can be created. Since it's unstable, remove it. This required moving the netbsd tests to a new direcotry, so update mtree files as well. The change is useless for 'make check' without it. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31376 --- .../one-true-awk/bugs-fixed/missing-precision.err | 2 + .../one-true-awk/bugs-fixed/missing-precision.ok | 2 - contrib/one-true-awk/bugs-fixed/negative-nf.err | 2 + contrib/one-true-awk/bugs-fixed/negative-nf.ok | 2 - contrib/one-true-awk/bugs-fixed/pfile-overflow.ok | 4 -- contrib/one-true-awk/bugs-fixed/system-status.awk | 19 ------ contrib/one-true-awk/bugs-fixed/system-status.bad | 3 - contrib/one-true-awk/bugs-fixed/system-status.ok | 3 - etc/mtree/BSD.tests.dist | 4 ++ usr.bin/awk/tests/Makefile | 31 +-------- usr.bin/awk/tests/bugs-fixed/Makefile | 14 ++++ usr.bin/awk/tests/bugs-fixed/bug_fix_test.sh | 75 ++++++++++++++++++++++ usr.bin/awk/tests/netbsd/Makefile | 36 +++++++++++ 13 files changed, 136 insertions(+), 61 deletions(-) diff --git a/contrib/one-true-awk/bugs-fixed/missing-precision.err b/contrib/one-true-awk/bugs-fixed/missing-precision.err new file mode 100644 index 000000000000..c08632787d9a --- /dev/null +++ b/contrib/one-true-awk/bugs-fixed/missing-precision.err @@ -0,0 +1,2 @@ +awk: not enough args in printf(%*s) + source line number 1 diff --git a/contrib/one-true-awk/bugs-fixed/missing-precision.ok b/contrib/one-true-awk/bugs-fixed/missing-precision.ok deleted file mode 100644 index 75e1e3d00446..000000000000 --- a/contrib/one-true-awk/bugs-fixed/missing-precision.ok +++ /dev/null @@ -1,2 +0,0 @@ -../a.out: not enough args in printf(%*s) - source line number 1 diff --git a/contrib/one-true-awk/bugs-fixed/negative-nf.err b/contrib/one-true-awk/bugs-fixed/negative-nf.err new file mode 100644 index 000000000000..5b941f526dd8 --- /dev/null +++ b/contrib/one-true-awk/bugs-fixed/negative-nf.err @@ -0,0 +1,2 @@ +awk: cannot set NF to a negative value + source line number 1 diff --git a/contrib/one-true-awk/bugs-fixed/negative-nf.ok b/contrib/one-true-awk/bugs-fixed/negative-nf.ok deleted file mode 100644 index de97f8b27def..000000000000 --- a/contrib/one-true-awk/bugs-fixed/negative-nf.ok +++ /dev/null @@ -1,2 +0,0 @@ -../a.out: cannot set NF to a negative value - source line number 1 diff --git a/contrib/one-true-awk/bugs-fixed/pfile-overflow.ok b/contrib/one-true-awk/bugs-fixed/pfile-overflow.ok deleted file mode 100644 index a0de50f9007f..000000000000 --- a/contrib/one-true-awk/bugs-fixed/pfile-overflow.ok +++ /dev/null @@ -1,4 +0,0 @@ -../a.out: syntax error at source line 1 source file pfile-overflow.awk - context is - >>> <<< -../a.out: bailing out at source line 1 source file pfile-overflow.awk diff --git a/contrib/one-true-awk/bugs-fixed/system-status.awk b/contrib/one-true-awk/bugs-fixed/system-status.awk deleted file mode 100644 index 8daf563e6f4f..000000000000 --- a/contrib/one-true-awk/bugs-fixed/system-status.awk +++ /dev/null @@ -1,19 +0,0 @@ -# Unmodified nawk prints the 16 bit exit status divided by 256, but -# does so using floating point arithmetic, yielding strange results. -# -# The fix is to use the various macros defined for wait(2) and to -# use the signal number + 256 for death by signal, or signal number + 512 -# for death by signal with core dump. - -BEGIN { - status = system("exit 42") - print "normal status", status - - status = system("kill -HUP $$") - print "death by signal status", status - - status = system("kill -ABRT $$") - print "death by signal with core dump status", status - - system("rm -f core*") -} diff --git a/contrib/one-true-awk/bugs-fixed/system-status.bad b/contrib/one-true-awk/bugs-fixed/system-status.bad deleted file mode 100644 index a1317dba54a8..000000000000 --- a/contrib/one-true-awk/bugs-fixed/system-status.bad +++ /dev/null @@ -1,3 +0,0 @@ -normal status 42 -death by signal status 0.00390625 -death by signal with core dump status 0.523438 diff --git a/contrib/one-true-awk/bugs-fixed/system-status.ok b/contrib/one-true-awk/bugs-fixed/system-status.ok deleted file mode 100644 index 737828f5ed7a..000000000000 --- a/contrib/one-true-awk/bugs-fixed/system-status.ok +++ /dev/null @@ -1,3 +0,0 @@ -normal status 42 -death by signal status 257 -death by signal with core dump status 518 diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index b21256c8563c..08ad8e41a527 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -873,6 +873,10 @@ apply .. awk + bugs-fixed + .. + netbsd + .. .. basename .. diff --git a/usr.bin/awk/tests/Makefile b/usr.bin/awk/tests/Makefile index 79a0bc14de80..d9bef1bf2365 100644 --- a/usr.bin/awk/tests/Makefile +++ b/usr.bin/awk/tests/Makefile @@ -1,33 +1,8 @@ # $FreeBSD$ -PACKAGE= tests +.include -NETBSD_ATF_TESTS_SH= awk_test - -${PACKAGE}FILES+= d_assign_NF.awk -${PACKAGE}FILES+= d_assign_NF.in -${PACKAGE}FILES+= d_assign_NF.out -${PACKAGE}FILES+= d_big_regexp.awk -${PACKAGE}FILES+= d_big_regexp.in -${PACKAGE}FILES+= d_big_regexp.out -${PACKAGE}FILES+= d_end1.awk -${PACKAGE}FILES+= d_end1.in -${PACKAGE}FILES+= d_end1.out -${PACKAGE}FILES+= d_end2.awk -${PACKAGE}FILES+= d_end2.in -${PACKAGE}FILES+= d_end2.out -${PACKAGE}FILES+= d_period.awk -${PACKAGE}FILES+= d_period.in -${PACKAGE}FILES+= d_period.out -${PACKAGE}FILES+= d_string1.awk -${PACKAGE}FILES+= d_string1.out -${PACKAGE}FILES+= d_tolower.awk -${PACKAGE}FILES+= d_tolower.in -${PACKAGE}FILES+= d_tolower.out -${PACKAGE}FILES+= d_toupper.awk -${PACKAGE}FILES+= d_toupper.in -${PACKAGE}FILES+= d_toupper.out - -.include +TESTS_SUBDIRS+= bugs-fixed +TESTS_SUBDIRS+= netbsd .include diff --git a/usr.bin/awk/tests/bugs-fixed/Makefile b/usr.bin/awk/tests/bugs-fixed/Makefile new file mode 100644 index 000000000000..b53195baa55c --- /dev/null +++ b/usr.bin/awk/tests/bugs-fixed/Makefile @@ -0,0 +1,14 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/usr.bin/awk/${.CURDIR:T} +TESTSRC= ${SRCTOP}/contrib/one-true-awk/bugs-fixed + +ATF_TESTS_SH= bug_fix_test + +.PATH: ${TESTSRC} +# Upstream controls the list of tests, so generate it dynamically +${PACKAGE}FILES!=(cd ${TESTSRC} ; ls *.awk *.ok *.in *.err) + +.include diff --git a/usr.bin/awk/tests/bugs-fixed/bug_fix_test.sh b/usr.bin/awk/tests/bugs-fixed/bug_fix_test.sh new file mode 100644 index 000000000000..a22f112ce4b1 --- /dev/null +++ b/usr.bin/awk/tests/bugs-fixed/bug_fix_test.sh @@ -0,0 +1,75 @@ +# +# Copyright 2014 EMC Corp. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# $FreeBSD$ + +SRCDIR=$(atf_get_srcdir) + +check() +{ + local tc=${1%.awk}; shift + local in_flag out_flag err_flag + + awk=awk + + local out_file="${SRCDIR}/${tc}.ok" + [ -f "${out_file}" ] && out_flag="-o file:${out_file}" + local err_file="${SRCDIR}/${tc}.err" + [ -f "${err_file}" ] && err_flag="-e file:${err_file} -s exit:2" + local in_file="${SRCDIR}/${tc}.in" + [ -f "${in_file}" ] && in_flag="${in_file}" + + (cd ${SRCDIR} ; atf_check ${out_flag} ${err_flag} ${awk} -f "${tc}.awk" ${in_flag}) +} + +add_testcase() +{ + local tc=${1%.awk} + local tc_escaped word + + case "${tc%.*}" in + *-*) + local IFS="-" + for word in ${tc}; do + tc_escaped="${tc_escaped:+${tc_escaped}_}${word}" + done + ;; + *) + tc_escaped=${tc} + ;; + esac + + atf_test_case ${tc_escaped} + eval "${tc_escaped}_body() { check ${tc}; }" + atf_add_test_case ${tc_escaped} +} + +atf_init_test_cases() +{ + for path in $(find -s "${SRCDIR}" -name '*.awk'); do + add_testcase ${path##*/} + done +} diff --git a/usr.bin/awk/tests/netbsd/Makefile b/usr.bin/awk/tests/netbsd/Makefile new file mode 100644 index 000000000000..5fecc4e947a1 --- /dev/null +++ b/usr.bin/awk/tests/netbsd/Makefile @@ -0,0 +1,36 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/usr.bin/awk/${.CURDIR:T} +TESTSRC= ${SRCTOP}/contrib/netbsd-tests/usr.bin/awk + +NETBSD_ATF_TESTS_SH= awk_test + +${PACKAGE}FILES+= d_assign_NF.awk +${PACKAGE}FILES+= d_assign_NF.in +${PACKAGE}FILES+= d_assign_NF.out +${PACKAGE}FILES+= d_big_regexp.awk +${PACKAGE}FILES+= d_big_regexp.in +${PACKAGE}FILES+= d_big_regexp.out +${PACKAGE}FILES+= d_end1.awk +${PACKAGE}FILES+= d_end1.in +${PACKAGE}FILES+= d_end1.out +${PACKAGE}FILES+= d_end2.awk +${PACKAGE}FILES+= d_end2.in +${PACKAGE}FILES+= d_end2.out +${PACKAGE}FILES+= d_period.awk +${PACKAGE}FILES+= d_period.in +${PACKAGE}FILES+= d_period.out +${PACKAGE}FILES+= d_string1.awk +${PACKAGE}FILES+= d_string1.out +${PACKAGE}FILES+= d_tolower.awk +${PACKAGE}FILES+= d_tolower.in +${PACKAGE}FILES+= d_tolower.out +${PACKAGE}FILES+= d_toupper.awk +${PACKAGE}FILES+= d_toupper.in +${PACKAGE}FILES+= d_toupper.out + +.include + +.include From nobody Fri Nov 5 15:25: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 0DFB91836605; Fri, 5 Nov 2021 15:25: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 4Hm48J6yNLz4kgr; Fri, 5 Nov 2021 15:25: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 CA1131A19E; Fri, 5 Nov 2021 15:25: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 1A5FPaXN073195; Fri, 5 Nov 2021 15:25:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPaUn073194; Fri, 5 Nov 2021 15:25:36 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:36 GMT Message-Id: <202111051525.1A5FPaUn073194@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: 00f79c97a4f2 - main - cam_periph: Remove vestigial "scbus" comparison 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: 00f79c97a4f265f8d653a11fdb764cd999b7d0a9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=00f79c97a4f265f8d653a11fdb764cd999b7d0a9 commit 00f79c97a4f265f8d653a11fdb764cd999b7d0a9 Author: Warner Losh AuthorDate: 2021-11-05 14:56:13 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:56:13 +0000 cam_periph: Remove vestigial "scbus" comparison The code in camperiphunit rejects "scbus" as an 'at' location that would allow any other wiring to use that unit number. Yet in camperiphunitnext, if we have a no target and the 'at' location of 'scbus' it would be excluded on the basis that it's a wiring cadidate. This is improper and appears to be a hold-over of the pre-hints / pre-newbus config system, so remove it. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32680 --- sys/cam/cam_periph.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index d8fd41d77be7..990854f992c3 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -568,9 +568,10 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, break; /* - * Don't match entries like "da 4" as a wired down - * device, but do match entries like "da 4 target 5" - * or even "da 4 scbus 1". + * Don't allow the mere presence of any attributes of a device + * means that it is for a wired down entry. Instead, insist that + * one of the matching criteria from camperiphunit be present + * for the device. */ i = 0; dname = periph_name; @@ -580,8 +581,7 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, break; /* if no "target" and no specific scbus, skip */ if (resource_int_value(dname, dunit, "target", &val) && - (resource_string_value(dname, dunit, "at",&strval)|| - strcmp(strval, "scbus") == 0)) + resource_string_value(dname, dunit, "at",&strval)) continue; if (newunit == dunit) break; From nobody Fri Nov 5 15:25: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 D2A11183650D; Fri, 5 Nov 2021 15:25: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 4Hm48L17bwz4kpV; Fri, 5 Nov 2021 15:25: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 F3B261A260; Fri, 5 Nov 2021 15:25: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 1A5FPbfL073219; Fri, 5 Nov 2021 15:25:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPb07073218; Fri, 5 Nov 2021 15:25:37 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:37 GMT Message-Id: <202111051525.1A5FPb07073218@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: bee0133fb937 - main - cam_periph: switch from negative logic to positive logic 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: bee0133fb937e519623324fd1ae7214d59a03aca Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=bee0133fb937e519623324fd1ae7214d59a03aca commit bee0133fb937e519623324fd1ae7214d59a03aca Author: Warner Losh AuthorDate: 2021-11-05 14:56:22 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:56:22 +0000 cam_periph: switch from negative logic to positive logic When scanning the resources that are wired for this driver, skip any that whose number doesn't match newunit. They aren't relevant. Switch to positive logic to break out of the loop (and thus go to the next unit) if we find either a target resource or an at resource. This makes the code easier to read and modify. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32681 --- sys/cam/cam_periph.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 990854f992c3..37a54a2d992b 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -579,11 +579,11 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, r = resource_find_dev(&i, dname, &dunit, NULL, NULL); if (r != 0) break; - /* if no "target" and no specific scbus, skip */ - if (resource_int_value(dname, dunit, "target", &val) && - resource_string_value(dname, dunit, "at",&strval)) + + if (newunit != dunit) continue; - if (newunit == dunit) + if (resource_int_value(dname, dunit, "target", &val) == 0 || + resource_string_value(dname, dunit, "at", &strval) == 0) break; } if (r != 0) From nobody Fri Nov 5 15:25: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 12917183603D; Fri, 5 Nov 2021 15:25: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 4Hm48N4fy0z4kmN; Fri, 5 Nov 2021 15:25: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 4104E19AF7; Fri, 5 Nov 2021 15:25: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 1A5FPd5b073245; Fri, 5 Nov 2021 15:25:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPdnW073244; Fri, 5 Nov 2021 15:25:39 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:39 GMT Message-Id: <202111051525.1A5FPdnW073244@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: 710a519ebbe3 - main - cam_periph: fix bug in camperiphunitnext logic 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: 710a519ebbe34850ee37e688896a761606be5009 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=710a519ebbe34850ee37e688896a761606be5009 commit 710a519ebbe34850ee37e688896a761606be5009 Author: Warner Losh AuthorDate: 2021-11-05 14:56:27 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:56:27 +0000 cam_periph: fix bug in camperiphunitnext logic If we assigned just a lun as a wired unit (something that camperiphunit will accept), we failed to properly skip over that unit when computing a next unit number. Add lun so the code matches the comments that we have to skip all the same criteria that camperiphunit uses to select wired units for a driver. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32682 --- sys/cam/cam_periph.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 37a54a2d992b..8fbc2e3926fa 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -582,7 +582,8 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, if (newunit != dunit) continue; - if (resource_int_value(dname, dunit, "target", &val) == 0 || + if (resource_int_value(dname, dunit, "lun", &val) == 0 || + resource_int_value(dname, dunit, "target", &val) == 0 || resource_string_value(dname, dunit, "at", &strval) == 0) break; } From nobody Fri Nov 5 15:25: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 5EFC81836592; Fri, 5 Nov 2021 15:25: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 4Hm48P5VVwz4kmS; Fri, 5 Nov 2021 15:25: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 619A619D53; Fri, 5 Nov 2021 15:25: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 1A5FPfZ6073295; Fri, 5 Nov 2021 15:25:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPfc3073294; Fri, 5 Nov 2021 15:25:41 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:41 GMT Message-Id: <202111051525.1A5FPfc3073294@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: bd82711aff98 - main - cam: Remove trailing spaces from serial numbers too 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: bd82711aff986b66e9fae60847a79d9db938a467 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=bd82711aff986b66e9fae60847a79d9db938a467 commit bd82711aff986b66e9fae60847a79d9db938a467 Author: Warner Losh AuthorDate: 2021-11-05 14:56:41 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:56:41 +0000 cam: Remove trailing spaces from serial numbers too The SanDisk SD8SB8U1 and likely others pad their serial number with spaces on the end rather than the start (at least when connected to a SAS3008). This makes them difficult to wire unit numbers to with the serial because you have to specify the trailing spaces. Instead, strip out the trailing spaces. We already strip leading spaces both here. In addition, when glabel creates the devfs device nodes, leading and trailing spaces are removed already (so there will be no change there either). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32684 --- sys/cam/scsi/scsi_xpt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 6bcf95506963..77c47d578ae3 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -1615,6 +1615,14 @@ probe_device_check: */ slen = 0; } + /* + * In apparent violation of the spec, some + * devices pad their serial numbers with + * trailing spaces. Remove them. + */ + while (slen > 0 && + serial_buf->serial_num[slen - 1] == ' ') + slen--; memcpy(path->device->serial_num, &serial_buf->serial_num[start], slen); path->device->serial_num_len = slen; From nobody Fri Nov 5 15:25: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 2316A18364A0; Fri, 5 Nov 2021 15:25: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 4Hm48N51zqz4kmP; Fri, 5 Nov 2021 15:25: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 5726119AF8; Fri, 5 Nov 2021 15:25: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 1A5FPee8073269; Fri, 5 Nov 2021 15:25:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPepL073268; Fri, 5 Nov 2021 15:25:40 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:40 GMT Message-Id: <202111051525.1A5FPepL073268@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: 577f9aa266e3 - main - cam_periph: Add ability to wire units to a serial number 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: 577f9aa266e3407a2de9d6bd6d836a9ba984e944 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=577f9aa266e3407a2de9d6bd6d836a9ba984e944 commit 577f9aa266e3407a2de9d6bd6d836a9ba984e944 Author: Warner Losh AuthorDate: 2021-11-05 14:56:33 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:56:33 +0000 cam_periph: Add ability to wire units to a serial number For scsi, ata and nvme, at least, we read a serial number from the device (if the device supports it, some scsi drives do not) and record it during the *_xpt probe device state machine before it posts the AC_FOUND_DEVICE async event. For mmc, no serial number is ever retrieved, so it's always NULL. Add the ability to match this serial number during device wiring. This mechanism is competely optional, and often times using a label and/or some other attribute of the device is easier. However, other times wiring a unit to a serial number simplifies management as most monitoring tools require the *daX device and having it stable from boot to boot helps with data continuity. It can be especially helpful for nvme where no other means exists to reliably tie a ndaX device to an underlying nvme drive and namespace. A similar mechanism exists in Linux to mange device unit numbers with udev. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32683 --- sys/cam/cam_periph.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 8fbc2e3926fa..bb4baaf0888f 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -69,7 +69,8 @@ static u_int camperiphnextunit(struct periph_driver *p_drv, lun_id_t lun); static u_int camperiphunit(struct periph_driver *p_drv, path_id_t pathid, target_id_t target, - lun_id_t lun); + lun_id_t lun, + const char *sn); static void camperiphdone(struct cam_periph *periph, union ccb *done_ccb); static void camperiphfree(struct cam_periph *periph); @@ -273,7 +274,8 @@ cam_periph_alloc(periph_ctor_t *periph_ctor, free(periph, M_CAMPERIPH); return (CAM_REQ_INVALID); } - periph->unit_number = camperiphunit(*p_drv, path_id, target_id, lun_id); + periph->unit_number = camperiphunit(*p_drv, path_id, target_id, lun_id, + path->device->serial_num); cur_periph = TAILQ_FIRST(&(*p_drv)->units); while (cur_periph != NULL && cur_periph->unit_number < periph->unit_number) @@ -582,7 +584,8 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, if (newunit != dunit) continue; - if (resource_int_value(dname, dunit, "lun", &val) == 0 || + if (resource_string_value(dname, dunit, "sn", &strval) == 0 || + resource_int_value(dname, dunit, "lun", &val) == 0 || resource_int_value(dname, dunit, "target", &val) == 0 || resource_string_value(dname, dunit, "at", &strval) == 0) break; @@ -595,7 +598,7 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, static u_int camperiphunit(struct periph_driver *p_drv, path_id_t pathid, - target_id_t target, lun_id_t lun) + target_id_t target, lun_id_t lun, const char *sn) { u_int unit; int wired, i, val, dunit; @@ -624,6 +627,11 @@ camperiphunit(struct periph_driver *p_drv, path_id_t pathid, continue; wired++; } + if (resource_string_value(dname, dunit, "sn", &strval) == 0) { + if (sn == NULL || strcmp(strval, sn) != 0) + continue; + wired++; + } if (wired != 0) { unit = dunit; break; From nobody Fri Nov 5 15:25: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 D60761836046; Fri, 5 Nov 2021 15:25: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 4Hm48R37VTz4l15; Fri, 5 Nov 2021 15:25: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 A43051A324; Fri, 5 Nov 2021 15:25: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 1A5FPg8D073326; Fri, 5 Nov 2021 15:25:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPgwj073325; Fri, 5 Nov 2021 15:25:42 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:42 GMT Message-Id: <202111051525.1A5FPgwj073325@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: d836c48e7110 - main - cam_periph: wired is really a bool, update it to a bool. 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: d836c48e7110f2894885cf84ce8990f7916663cc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d836c48e7110f2894885cf84ce8990f7916663cc commit d836c48e7110f2894885cf84ce8990f7916663cc Author: Warner Losh AuthorDate: 2021-11-05 14:56:48 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:56:48 +0000 cam_periph: wired is really a bool, update it to a bool. Sponsored by: Netflix Reviewed by: scottl Differential Revision: https://reviews.freebsd.org/D32823 --- sys/cam/cam_periph.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index bb4baaf0888f..54fe9a0ef40c 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -64,7 +64,7 @@ __FBSDID("$FreeBSD$"); #include static u_int camperiphnextunit(struct periph_driver *p_drv, - u_int newunit, int wired, + u_int newunit, bool wired, path_id_t pathid, target_id_t target, lun_id_t lun); static u_int camperiphunit(struct periph_driver *p_drv, @@ -539,7 +539,7 @@ cam_periph_unhold(struct cam_periph *periph) * numbers that did not match a wiring entry. */ static u_int -camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, +camperiphnextunit(struct periph_driver *p_drv, u_int newunit, bool wired, path_id_t pathid, target_id_t target, lun_id_t lun) { struct cam_periph *periph; @@ -555,14 +555,14 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, ; if (periph != NULL && periph->unit_number == newunit) { - if (wired != 0) { + if (wired) { xpt_print(periph->path, "Duplicate Wired " "Device entry!\n"); xpt_print(periph->path, "Second device (%s " "device at scbus%d target %d lun %d) will " "not be wired\n", periph_name, pathid, target, lun); - wired = 0; + wired = false; } continue; } @@ -600,8 +600,9 @@ static u_int camperiphunit(struct periph_driver *p_drv, path_id_t pathid, target_id_t target, lun_id_t lun, const char *sn) { + bool wired; u_int unit; - int wired, i, val, dunit; + int i, val, dunit; const char *dname, *strval; char pathbuf[32], *periph_name; @@ -610,29 +611,29 @@ camperiphunit(struct periph_driver *p_drv, path_id_t pathid, unit = 0; i = 0; dname = periph_name; - for (wired = 0; resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0; - wired = 0) { + while (resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0) { + wired = false; if (resource_string_value(dname, dunit, "at", &strval) == 0) { if (strcmp(strval, pathbuf) != 0) continue; - wired++; + wired = true; } if (resource_int_value(dname, dunit, "target", &val) == 0) { if (val != target) continue; - wired++; + wired = true; } if (resource_int_value(dname, dunit, "lun", &val) == 0) { if (val != lun) continue; - wired++; + wired = true; } if (resource_string_value(dname, dunit, "sn", &strval) == 0) { if (sn == NULL || strcmp(strval, sn) != 0) continue; - wired++; + wired = true; } - if (wired != 0) { + if (wired) { unit = dunit; break; } From nobody Fri Nov 5 15:25: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 B036A1836639; Fri, 5 Nov 2021 15:25: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 4Hm48W2Ytqz4kmd; Fri, 5 Nov 2021 15:25: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 A098619F72; Fri, 5 Nov 2021 15:25: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 1A5FPhRT073350; Fri, 5 Nov 2021 15:25:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPh3d073349; Fri, 5 Nov 2021 15:25:43 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:43 GMT Message-Id: <202111051525.1A5FPh3d073349@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: c688a2eb2f24 - main - scsi.4: Remove untrue paragraph 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: c688a2eb2f2481da6a4b57913e3ea261daa73f32 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=c688a2eb2f2481da6a4b57913e3ea261daa73f32 commit c688a2eb2f2481da6a4b57913e3ea261daa73f32 Author: Warner Losh AuthorDate: 2021-11-05 14:56:57 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:56:57 +0000 scsi.4: Remove untrue paragraph Unwired units start with the first avaialble unit that hasn't been wired, not one greater than the largest wired unit. wired units are skipped when assigning unwired units a number. Sponsored by: Netflix Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D32824 --- share/man/man4/scsi.4 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/share/man/man4/scsi.4 b/share/man/man4/scsi.4 index d3f92fd6b8bb..29b8a48cd48d 100644 --- a/share/man/man4/scsi.4 +++ b/share/man/man4/scsi.4 @@ -24,7 +24,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd June 18, 2020 +.Dd November 3, 2021 .Dt CAM 4 .Os .Sh NAME @@ -252,14 +252,6 @@ The namespace id 1 is exported as .Tn nda10 and namespace id 2 is exported as .Tn nda11 . -.Pp -When you have a mixture of wired down and counted devices then the -counting begins with the first non-wired down unit for a particular -type. -That is, if you have a disk wired down as -.Em "device da1" , -then the first non-wired disk shall come on line as -.Em da2 . .Sh ADAPTERS The system allows common device drivers to work through many different types of adapters. From nobody Fri Nov 5 15:25: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 844EF18365C4; Fri, 5 Nov 2021 15: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 4Hm48W6YC4z4kvT; Fri, 5 Nov 2021 15:25: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 EA3C71A0A2; Fri, 5 Nov 2021 15:25:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A5FPi16073374; Fri, 5 Nov 2021 15:25:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5FPiA0073373; Fri, 5 Nov 2021 15:25:44 GMT (envelope-from git) Date: Fri, 5 Nov 2021 15:25:44 GMT Message-Id: <202111051525.1A5FPiA0073373@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: 15d4459cb2d3 - main - scsi.4: Document serial numbers 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: 15d4459cb2d3d2fa8f3831fa5cc99d133cbae48d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=15d4459cb2d3d2fa8f3831fa5cc99d133cbae48d commit 15d4459cb2d3d2fa8f3831fa5cc99d133cbae48d Author: Warner Losh AuthorDate: 2021-11-05 14:57:05 +0000 Commit: Warner Losh CommitDate: 2021-11-05 14:57:05 +0000 scsi.4: Document serial numbers You can wire da, ada and nda device units to serial numbers. sdda cannot be wired like this because SD and MMC cards lack serial numbers (or at the very least CAMMMC does not query or retain them). Sponsored by: Netflix Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D32825 --- share/man/man4/scsi.4 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/share/man/man4/scsi.4 b/share/man/man4/scsi.4 index 29b8a48cd48d..e4c6d9a53eb4 100644 --- a/share/man/man4/scsi.4 +++ b/share/man/man4/scsi.4 @@ -242,16 +242,32 @@ hint.nda.11.target="1" hint.nda.11.unit="2" .Ed .Pp -This assigns the NVMe card living at PCI bus 7 to scbus 10 (in PCIe, -slot and function are rarely used and usually 0). +This assigns the NVMe card living at PCI bus 7 slot 0 function 1 to scbus 10. The target for .Xr nda 4 devices is always 1. The unit is the namespace identifier from the drive. The namespace id 1 is exported as -.Tn nda10 +.Em nda10 and namespace id 2 is exported as -.Tn nda11 . +.Em nda11 . +.Pp +For devices that provide a serial number, units may be wired to that serial +number without regard where the drive is attached: +.Bd -literal -offset indent +hint.nda.3.sn="CY0AN07101120B12P" +hint.da.44.sn="143282400011" +hint.ada.2.sn="A065D591" +.Ed +wires +.Em nda3 , +.Em da44 , +and +.Em ada2 +to drives with the specified serial numbers. +One need not specify an +.Em at +line when serial numbers are used. .Sh ADAPTERS The system allows common device drivers to work through many different types of adapters. From nobody Fri Nov 5 20:46: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 B2066184296E; Fri, 5 Nov 2021 20:46: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 4HmCG74cpjz3JWP; Fri, 5 Nov 2021 20:46: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 7B0AE1E881; Fri, 5 Nov 2021 20:46: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 1A5Kk7uc016583; Fri, 5 Nov 2021 20:46:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5Kk7nl016582; Fri, 5 Nov 2021 20:46:07 GMT (envelope-from git) Date: Fri, 5 Nov 2021 20:46:07 GMT Message-Id: <202111052046.1A5Kk7nl016582@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: 6a8ea6d17498 - main - sched: split sched_ap_entry() out of sched_throw() 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: 6a8ea6d17498f07c702e2acf4072cf4436037a6a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=6a8ea6d17498f07c702e2acf4072cf4436037a6a commit 6a8ea6d17498f07c702e2acf4072cf4436037a6a Author: Kyle Evans AuthorDate: 2021-11-04 00:09:56 +0000 Commit: Kyle Evans CommitDate: 2021-11-05 20:45:51 +0000 sched: split sched_ap_entry() out of sched_throw() sched_throw() can no longer take a NULL thread, APs enter through sched_ap_entry() instead. This completely removes branching in the common case and cleans up both paths. No functional change intended. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D32829 --- sys/arm/arm/mp_machdep.c | 2 +- sys/arm64/arm64/mp_machdep.c | 2 +- sys/kern/sched_4bsd.c | 51 +++++++++++++++++-------- sys/kern/sched_ule.c | 81 ++++++++++++++++++++++++++++------------ sys/mips/mips/mp_machdep.c | 2 +- sys/powerpc/powerpc/mp_machdep.c | 2 +- sys/riscv/riscv/mp_machdep.c | 2 +- sys/sys/sched.h | 1 + sys/x86/x86/mp_x86.c | 2 +- 9 files changed, 100 insertions(+), 45 deletions(-) diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 4089af5929eb..6f772deee2d4 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -217,7 +217,7 @@ init_secondary(int cpu) CTR0(KTR_SMP, "go into scheduler"); /* Enter the scheduler */ - sched_throw(NULL); + sched_ap_entry(); panic("scheduler returned us to %s", __func__); /* NOTREACHED */ diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index b42f65b9e399..4eebfe219934 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -293,7 +293,7 @@ init_secondary(uint64_t cpu) MPASS(PCPU_GET(curpcb) == NULL); /* Enter the scheduler */ - sched_throw(NULL); + sched_ap_entry(); panic("scheduler returned us to init_secondary"); /* NOTREACHED */ diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 6ba41eb80dcc..25f8bfc04d48 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1662,12 +1662,22 @@ sched_idletd(void *dummy) } } +static void +sched_throw_tail(struct thread *td) +{ + + mtx_assert(&sched_lock, MA_OWNED); + KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count")); + cpu_throw(td, choosethread()); /* doesn't return */ +} + /* - * A CPU is entering for the first time or a thread is exiting. + * A CPU is entering for the first time. */ void -sched_throw(struct thread *td) +sched_ap_entry(void) { + /* * Correct spinlock nesting. The idle thread context that we are * borrowing was created so that it would start out with a single @@ -1677,20 +1687,29 @@ sched_throw(struct thread *td) * spinlock_exit() will simply adjust the counts without allowing * spin lock using code to interrupt us. */ - if (td == NULL) { - mtx_lock_spin(&sched_lock); - spinlock_exit(); - PCPU_SET(switchtime, cpu_ticks()); - PCPU_SET(switchticks, ticks); - } else { - lock_profile_release_lock(&sched_lock.lock_object, true); - MPASS(td->td_lock == &sched_lock); - td->td_lastcpu = td->td_oncpu; - td->td_oncpu = NOCPU; - } - mtx_assert(&sched_lock, MA_OWNED); - KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count")); - cpu_throw(td, choosethread()); /* doesn't return */ + mtx_lock_spin(&sched_lock); + spinlock_exit(); + PCPU_SET(switchtime, cpu_ticks()); + PCPU_SET(switchticks, ticks); + + sched_throw_tail(NULL); +} + +/* + * A thread is exiting. + */ +void +sched_throw(struct thread *td) +{ + + MPASS(td != NULL); + MPASS(td->td_lock == &sched_lock); + + lock_profile_release_lock(&sched_lock.lock_object, true); + td->td_lastcpu = td->td_oncpu; + td->td_oncpu = NOCPU; + + sched_throw_tail(td); } void diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index ce7ce4cd2bd8..e311c8da8bac 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -2985,39 +2985,74 @@ sched_idletd(void *dummy) } /* - * A CPU is entering for the first time or a thread is exiting. + * sched_throw_grab() chooses a thread from the queue to switch to + * next. It returns with the tdq lock dropped in a spinlock section to + * keep interrupts disabled until the CPU is running in a proper threaded + * context. */ -void -sched_throw(struct thread *td) +static struct thread * +sched_throw_grab(struct tdq *tdq) { struct thread *newtd; - struct tdq *tdq; - tdq = TDQ_SELF(); - if (__predict_false(td == NULL)) { - TDQ_LOCK(tdq); - /* Correct spinlock nesting. */ - spinlock_exit(); - PCPU_SET(switchtime, cpu_ticks()); - PCPU_SET(switchticks, ticks); - } else { - THREAD_LOCK_ASSERT(td, MA_OWNED); - THREAD_LOCKPTR_ASSERT(td, TDQ_LOCKPTR(tdq)); - tdq_load_rem(tdq, td); - td->td_lastcpu = td->td_oncpu; - td->td_oncpu = NOCPU; - thread_lock_block(td); - } newtd = choosethread(); spinlock_enter(); TDQ_UNLOCK(tdq); KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count %d", curthread->td_md.md_spinlock_count)); + return (newtd); +} + +/* + * A CPU is entering for the first time. + */ +void +sched_ap_entry(void) +{ + struct thread *newtd; + struct tdq *tdq; + + tdq = TDQ_SELF(); + + /* This should have been setup in schedinit_ap(). */ + THREAD_LOCKPTR_ASSERT(curthread, TDQ_LOCKPTR(tdq)); + + TDQ_LOCK(tdq); + /* Correct spinlock nesting. */ + spinlock_exit(); + PCPU_SET(switchtime, cpu_ticks()); + PCPU_SET(switchticks, ticks); + + newtd = sched_throw_grab(tdq); + /* doesn't return */ - if (__predict_false(td == NULL)) - cpu_throw(td, newtd); /* doesn't return */ - else - cpu_switch(td, newtd, TDQ_LOCKPTR(tdq)); + cpu_throw(NULL, newtd); +} + +/* + * A thread is exiting. + */ +void +sched_throw(struct thread *td) +{ + struct thread *newtd; + struct tdq *tdq; + + tdq = TDQ_SELF(); + + MPASS(td != NULL); + THREAD_LOCK_ASSERT(td, MA_OWNED); + THREAD_LOCKPTR_ASSERT(td, TDQ_LOCKPTR(tdq)); + + tdq_load_rem(tdq, td); + td->td_lastcpu = td->td_oncpu; + td->td_oncpu = NOCPU; + thread_lock_block(td); + + newtd = sched_throw_grab(tdq); + + /* doesn't return */ + cpu_switch(td, newtd, TDQ_LOCKPTR(tdq)); } /* diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c index dc089db1d189..2582c2b65e78 100644 --- a/sys/mips/mips/mp_machdep.c +++ b/sys/mips/mips/mp_machdep.c @@ -335,7 +335,7 @@ smp_init_secondary(u_int32_t cpuid) cpu_initclocks_ap(); /* enter the scheduler */ - sched_throw(NULL); + sched_ap_entry(); panic("scheduler returned us to %s", __func__); /* NOTREACHED */ diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index 627cde77adbf..33ef870b8180 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -112,7 +112,7 @@ machdep_ap_bootstrap(void) cpu_initclocks_ap(); /* Announce ourselves awake, and enter the scheduler */ - sched_throw(NULL); + sched_ap_entry(); } void diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index 57d5606a3b88..74647b8fcba4 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -291,7 +291,7 @@ init_secondary(uint64_t hart) MPASS(PCPU_GET(curpcb) == NULL); /* Enter the scheduler */ - sched_throw(NULL); + sched_ap_entry(); panic("scheduler returned us to init_secondary"); /* NOTREACHED */ diff --git a/sys/sys/sched.h b/sys/sys/sched.h index 8041a2bc12d4..a9598767e4cb 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -91,6 +91,7 @@ void sched_nice(struct proc *p, int nice); * Threads are switched in and out, block on resources, have temporary * priorities inherited from their procs, and use up cpu time. */ +void sched_ap_entry(void); void sched_exit_thread(struct thread *td, struct thread *child); u_int sched_estcpu(struct thread *td); void sched_fork_thread(struct thread *td, struct thread *child); diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 1fac244cbed7..7a72c501ff25 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -1099,7 +1099,7 @@ init_secondary_tail(void) */ MPASS(PCPU_GET(curpcb) == NULL); - sched_throw(NULL); + sched_ap_entry(); panic("scheduler returned us to %s", __func__); /* NOTREACHED */ From nobody Fri Nov 5 21:27: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 2C1691856E77; Fri, 5 Nov 2021 21:27: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 4HmD9z0fWDz3nQj; Fri, 5 Nov 2021 21:27: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 EC6111F189; Fri, 5 Nov 2021 21:27: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 1A5LRYGP070855; Fri, 5 Nov 2021 21:27:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5LRYAt070854; Fri, 5 Nov 2021 21:27:34 GMT (envelope-from git) Date: Fri, 5 Nov 2021 21:27:34 GMT Message-Id: <202111052127.1A5LRYAt070854@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: e2157cd0000f - main - Partially revert ac76bc1145dd because it is no longer necessary 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: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e2157cd0000f6dbb6465d7a885f2dcfd4d3596cb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=e2157cd0000f6dbb6465d7a885f2dcfd4d3596cb commit e2157cd0000f6dbb6465d7a885f2dcfd4d3596cb Author: Dimitry Andric AuthorDate: 2021-11-05 21:26:16 +0000 Commit: Dimitry Andric CommitDate: 2021-11-05 21:27:20 +0000 Partially revert ac76bc1145dd because it is no longer necessary In ac76bc1145dd, I added a few volatiles to work around ctrig_test failures with {inf,inf}. This is not necessary anymore now, since in 3b00222f156d we added -fp-exception-behavior=maytrap for clang >= 10 in libm's Makefile. (The flag tells clang to use stricter floating point semantics, which libm depends on.) PR: 244732, 254911 Fixes: ac76bc1145dd MFC after: 3 days --- lib/msun/src/s_ccoshf.c | 2 +- lib/msun/src/s_ctanh.c | 2 +- lib/msun/src/s_ctanhf.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/msun/src/s_ccoshf.c b/lib/msun/src/s_ccoshf.c index e72395c277d5..5d7a09ba5f8d 100644 --- a/lib/msun/src/s_ccoshf.c +++ b/lib/msun/src/s_ccoshf.c @@ -43,7 +43,7 @@ static const float huge = 0x1p127; float complex ccoshf(float complex z) { - volatile float x, y, h; + float x, y, h; int32_t hx, hy, ix, iy; x = crealf(z); diff --git a/lib/msun/src/s_ctanh.c b/lib/msun/src/s_ctanh.c index 93e5ad444501..e5840a1bf67b 100644 --- a/lib/msun/src/s_ctanh.c +++ b/lib/msun/src/s_ctanh.c @@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$"); double complex ctanh(double complex z) { - volatile double x, y; + double x, y; double t, beta, s, rho, denom; uint32_t hx, ix, lx; diff --git a/lib/msun/src/s_ctanhf.c b/lib/msun/src/s_ctanhf.c index 164a2c23df9e..c46f86d2e116 100644 --- a/lib/msun/src/s_ctanhf.c +++ b/lib/msun/src/s_ctanhf.c @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); float complex ctanhf(float complex z) { - volatile float x, y; + float x, y; float t, beta, s, rho, denom; uint32_t hx, ix; From nobody Fri Nov 5 22:36: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 82F99184B600; Fri, 5 Nov 2021 22:36: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 4HmFjM3GCKz4h66; Fri, 5 Nov 2021 22:36: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 4CB421FFB9; Fri, 5 Nov 2021 22:36: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 1A5MaNYW064060; Fri, 5 Nov 2021 22:36:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5MaNEf064059; Fri, 5 Nov 2021 22:36:23 GMT (envelope-from git) Date: Fri, 5 Nov 2021 22:36:23 GMT Message-Id: <202111052236.1A5MaNEf064059@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: f5d5164fb607 - main - nfscl: Fix two more cases for forced dismount 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: f5d5164fb607ab9c51c52ace4ec241f6cac7cc5c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f5d5164fb607ab9c51c52ace4ec241f6cac7cc5c commit f5d5164fb607ab9c51c52ace4ec241f6cac7cc5c Author: Rick Macklem AuthorDate: 2021-11-05 22:33:19 +0000 Commit: Rick Macklem CommitDate: 2021-11-05 22:33:19 +0000 nfscl: Fix two more cases for forced dismount Although I was not able to cause a failure during testing, there are places in nfscl_removedeleg() and nfscl_renamedeleg() where I think a forced dismount could get hung. This patch fixes those. This patch only affects forced dismount and only if the NFSv4 server is issuing delegations to the client. Found by code inspection. MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clstate.c | 54 +++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 42233ea7cf9d..1df8530d0e39 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -4669,6 +4669,7 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) struct nfsclowner *owp; struct nfscllockowner *lp; struct nfsmount *nmp; + struct mount *mp; struct ucred *cred; struct nfsnode *np; int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; @@ -4683,6 +4684,7 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) } NFSUNLOCKMNT(nmp); np = VTONFS(vp); + mp = nmp->nm_mountp; NFSLOCKCLSTATE(); /* * Loop around waiting for: @@ -4709,8 +4711,13 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) igotlock = 0; } dp->nfsdl_rwlock.nfslock_lock |= NFSV4LOCK_WANTED; - (void) nfsmsleep(&dp->nfsdl_rwlock, - NFSCLSTATEMUTEXPTR, PZERO, "nfscld", NULL); + msleep(&dp->nfsdl_rwlock, NFSCLSTATEMUTEXPTR, PZERO, + "nfscld", hz); + if (NFSCL_FORCEDISM(mp)) { + dp->nfsdl_flags &= ~NFSCLDL_DELEGRET; + NFSUNLOCKCLSTATE(); + return (0); + } continue; } needsrecall = 0; @@ -4733,7 +4740,14 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) islept = 0; while (!igotlock) { igotlock = nfsv4_lock(&clp->nfsc_lock, 1, - &islept, NFSCLSTATEMUTEXPTR, NULL); + &islept, NFSCLSTATEMUTEXPTR, mp); + if (NFSCL_FORCEDISM(mp)) { + dp->nfsdl_flags &= ~NFSCLDL_DELEGRET; + if (igotlock) + nfsv4_unlock(&clp->nfsc_lock, 0); + NFSUNLOCKCLSTATE(); + return (0); + } if (islept) break; } @@ -4774,6 +4788,7 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, struct nfsclowner *owp; struct nfscllockowner *lp; struct nfsmount *nmp; + struct mount *mp; struct ucred *cred; struct nfsnode *np; int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; @@ -4789,6 +4804,7 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, return (retcnt); } NFSUNLOCKMNT(nmp); + mp = nmp->nm_mountp; NFSLOCKCLSTATE(); /* * Loop around waiting for: @@ -4816,8 +4832,15 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, igotlock = 0; } dp->nfsdl_rwlock.nfslock_lock |= NFSV4LOCK_WANTED; - (void) nfsmsleep(&dp->nfsdl_rwlock, - NFSCLSTATEMUTEXPTR, PZERO, "nfscld", NULL); + msleep(&dp->nfsdl_rwlock, NFSCLSTATEMUTEXPTR, PZERO, + "nfscld", hz); + if (NFSCL_FORCEDISM(mp)) { + dp->nfsdl_flags &= ~NFSCLDL_DELEGRET; + NFSUNLOCKCLSTATE(); + *gotfdp = 0; + *gottdp = 0; + return (0); + } continue; } needsrecall = 0; @@ -4840,7 +4863,16 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, islept = 0; while (!igotlock) { igotlock = nfsv4_lock(&clp->nfsc_lock, 1, - &islept, NFSCLSTATEMUTEXPTR, NULL); + &islept, NFSCLSTATEMUTEXPTR, mp); + if (NFSCL_FORCEDISM(mp)) { + dp->nfsdl_flags &= ~NFSCLDL_DELEGRET; + if (igotlock) + nfsv4_unlock(&clp->nfsc_lock, 0); + NFSUNLOCKCLSTATE(); + *gotfdp = 0; + *gottdp = 0; + return (0); + } if (islept) break; } @@ -4877,8 +4909,14 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, */ if (dp->nfsdl_rwlock.nfslock_usecnt > 0) { dp->nfsdl_rwlock.nfslock_lock |= NFSV4LOCK_WANTED; - (void) nfsmsleep(&dp->nfsdl_rwlock, - NFSCLSTATEMUTEXPTR, PZERO, "nfscld", NULL); + msleep(&dp->nfsdl_rwlock, NFSCLSTATEMUTEXPTR, PZERO, + "nfscld", hz); + if (NFSCL_FORCEDISM(mp)) { + NFSUNLOCKCLSTATE(); + *gotfdp = 0; + *gottdp = 0; + return (0); + } continue; } LIST_FOREACH(owp, &dp->nfsdl_owner, nfsow_list) { From nobody Fri Nov 5 23:39: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 E46031845D45; Fri, 5 Nov 2021 23:39: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 4HmH6P62rPz3Hqb; Fri, 5 Nov 2021 23:39: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 A576C20770; Fri, 5 Nov 2021 23:39: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 1A5Ndf70044195; Fri, 5 Nov 2021 23:39:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A5Ndf4R044194; Fri, 5 Nov 2021 23:39:41 GMT (envelope-from git) Date: Fri, 5 Nov 2021 23:39:41 GMT Message-Id: <202111052339.1A5Ndf4R044194@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: e900338c0987 - main - Move the ICL_CONN_*LOCK* macros to . 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: e900338c0987603456df8d9a8aeec5c239106d0b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e900338c0987603456df8d9a8aeec5c239106d0b commit e900338c0987603456df8d9a8aeec5c239106d0b Author: John Baldwin AuthorDate: 2021-11-05 23:38:25 +0000 Commit: John Baldwin CommitDate: 2021-11-05 23:38:25 +0000 Move the ICL_CONN_*LOCK* macros to . These macros are not backend-specific but reference a backend-independent field in struct icl_conn. Reviewed by: mav Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32858 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 5 ----- sys/dev/iscsi/icl.h | 5 +++++ sys/dev/iscsi/icl_soft.c | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index cf1032f2a3a2..de8f2547f29a 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -129,11 +129,6 @@ SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, recvspace, CTLFLAG_RWTUN, static volatile u_int icl_cxgbei_ncons; -#define ICL_CONN_LOCK(X) mtx_lock(X->ic_lock) -#define ICL_CONN_UNLOCK(X) mtx_unlock(X->ic_lock) -#define ICL_CONN_LOCK_ASSERT(X) mtx_assert(X->ic_lock, MA_OWNED) -#define ICL_CONN_LOCK_ASSERT_NOT(X) mtx_assert(X->ic_lock, MA_NOTOWNED) - static icl_conn_new_pdu_t icl_cxgbei_conn_new_pdu; static icl_conn_pdu_data_segment_length_t icl_cxgbei_conn_pdu_data_segment_length; diff --git a/sys/dev/iscsi/icl.h b/sys/dev/iscsi/icl.h index 07dcbbf2a0b5..edd43a45ba2e 100644 --- a/sys/dev/iscsi/icl.h +++ b/sys/dev/iscsi/icl.h @@ -120,6 +120,11 @@ struct icl_conn { void *ic_prv0; }; +#define ICL_CONN_LOCK(X) mtx_lock(X->ic_lock) +#define ICL_CONN_UNLOCK(X) mtx_unlock(X->ic_lock) +#define ICL_CONN_LOCK_ASSERT(X) mtx_assert(X->ic_lock, MA_OWNED) +#define ICL_CONN_LOCK_ASSERT_NOT(X) mtx_assert(X->ic_lock, MA_NOTOWNED) + struct icl_drv_limits { int idl_max_recv_data_segment_length; int idl_max_send_data_segment_length; diff --git a/sys/dev/iscsi/icl_soft.c b/sys/dev/iscsi/icl_soft.c index 95c4c87dd6f3..37f3911204c4 100644 --- a/sys/dev/iscsi/icl_soft.c +++ b/sys/dev/iscsi/icl_soft.c @@ -123,11 +123,6 @@ static uma_zone_t icl_soft_pdu_zone; static volatile u_int icl_ncons; -#define ICL_CONN_LOCK(X) mtx_lock(X->ic_lock) -#define ICL_CONN_UNLOCK(X) mtx_unlock(X->ic_lock) -#define ICL_CONN_LOCK_ASSERT(X) mtx_assert(X->ic_lock, MA_OWNED) -#define ICL_CONN_LOCK_ASSERT_NOT(X) mtx_assert(X->ic_lock, MA_NOTOWNED) - STAILQ_HEAD(icl_pdu_stailq, icl_pdu); static icl_conn_new_pdu_t icl_soft_conn_new_pdu; From nobody Sat Nov 6 03:07: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 5520C1834D23; Sat, 6 Nov 2021 03:07:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmMjq21CCz4Wpk; Sat, 6 Nov 2021 03:07:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1A87823653; Sat, 6 Nov 2021 03:07:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A637B6m032567; Sat, 6 Nov 2021 03:07:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A637Bvn032565; Sat, 6 Nov 2021 03:07:11 GMT (envelope-from git) Date: Sat, 6 Nov 2021 03:07:11 GMT Message-Id: <202111060307.1A637Bvn032565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: dc238358f9f4 - main - Add some of Intel Alder Lake device IDs. 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dc238358f9f48ee4c983e2131656edb15636ab9e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=dc238358f9f48ee4c983e2131656edb15636ab9e commit dc238358f9f48ee4c983e2131656edb15636ab9e Author: Alexander Motin AuthorDate: 2021-11-06 03:05:15 +0000 Commit: Alexander Motin CommitDate: 2021-11-06 03:06:59 +0000 Add some of Intel Alder Lake device IDs. MFC after: 1 week --- sys/dev/ahci/ahci_pci.c | 1 + sys/dev/sound/pci/hda/hdac.c | 1 + sys/dev/sound/pci/hda/hdac.h | 3 +++ sys/dev/sound/pci/hda/hdacc.c | 2 ++ sys/dev/usb/controller/xhci_pci.c | 2 ++ 5 files changed, 9 insertions(+) diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c index b60119f3ab64..9e4987e38bfb 100644 --- a/sys/dev/ahci/ahci_pci.c +++ b/sys/dev/ahci/ahci_pci.c @@ -191,6 +191,7 @@ static const struct { {0x23a38086, 0x00, "Intel Coleto Creek", 0}, {0x31e38086, 0x00, "Intel Gemini Lake", 0}, {0x5ae38086, 0x00, "Intel Apollo Lake", 0}, + {0x7ae28086, 0x00, "Intel Alder Lake", 0}, {0x8c028086, 0x00, "Intel Lynx Point", 0}, {0x8c038086, 0x00, "Intel Lynx Point", 0}, {0x8c048086, 0x00, "Intel Lynx Point (RAID)", 0}, diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index cad631f4ee5d..5d3f1d85a2ad 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -112,6 +112,7 @@ static const struct { { HDA_INTEL_CMLKH, "Intel Comet Lake-H", 0, 0 }, { HDA_INTEL_TGLK, "Intel Tiger Lake", 0, 0 }, { HDA_INTEL_GMLK, "Intel Gemini Lake", 0, 0 }, + { HDA_INTEL_ALLK, "Intel Alder Lake", 0, 0 }, { HDA_INTEL_82801F, "Intel 82801F", 0, 0 }, { HDA_INTEL_63XXESB, "Intel 631x/632xESB", 0, 0 }, { HDA_INTEL_82801G, "Intel 82801G", 0, 0 }, diff --git a/sys/dev/sound/pci/hda/hdac.h b/sys/dev/sound/pci/hda/hdac.h index 06ac0371df6b..37744065fdc1 100644 --- a/sys/dev/sound/pci/hda/hdac.h +++ b/sys/dev/sound/pci/hda/hdac.h @@ -71,6 +71,7 @@ #define HDA_INTEL_JLK2 HDA_MODEL_CONSTRUCT(INTEL, 0x4dc8) #define HDA_INTEL_BXTNP HDA_MODEL_CONSTRUCT(INTEL, 0x5a98) #define HDA_INTEL_MACBOOKPRO92 HDA_MODEL_CONSTRUCT(INTEL, 0x7270) +#define HDA_INTEL_ALLK HDA_MODEL_CONSTRUCT(INTEL, 0x7ad0) #define HDA_INTEL_SCH HDA_MODEL_CONSTRUCT(INTEL, 0x811b) #define HDA_INTEL_LPT1 HDA_MODEL_CONSTRUCT(INTEL, 0x8c20) #define HDA_INTEL_LPT2 HDA_MODEL_CONSTRUCT(INTEL, 0x8c21) @@ -575,6 +576,7 @@ #define HDA_CODEC_ALC888 HDA_CODEC_CONSTRUCT(REALTEK, 0x0888) #define HDA_CODEC_ALC889 HDA_CODEC_CONSTRUCT(REALTEK, 0x0889) #define HDA_CODEC_ALC892 HDA_CODEC_CONSTRUCT(REALTEK, 0x0892) +#define HDA_CODEC_ALC897 HDA_CODEC_CONSTRUCT(REALTEK, 0x0897) #define HDA_CODEC_ALC899 HDA_CODEC_CONSTRUCT(REALTEK, 0x0899) #define HDA_CODEC_ALC1150 HDA_CODEC_CONSTRUCT(REALTEK, 0x0900) #define HDA_CODEC_ALCS1200A HDA_CODEC_CONSTRUCT(REALTEK, 0x0b00) @@ -871,6 +873,7 @@ #define HDA_CODEC_INTELGMLK1 HDA_CODEC_CONSTRUCT(INTEL, 0x280d) #define HDA_CODEC_INTELICLK HDA_CODEC_CONSTRUCT(INTEL, 0x280f) #define HDA_CODEC_INTELTGLK HDA_CODEC_CONSTRUCT(INTEL, 0x2812) +#define HDA_CODEC_INTELALLK HDA_CODEC_CONSTRUCT(INTEL, 0x2815) #define HDA_CODEC_INTELJLK HDA_CODEC_CONSTRUCT(INTEL, 0x281a) #define HDA_CODEC_INTELELLK HDA_CODEC_CONSTRUCT(INTEL, 0x281b) #define HDA_CODEC_INTELCT HDA_CODEC_CONSTRUCT(INTEL, 0x2880) diff --git a/sys/dev/sound/pci/hda/hdacc.c b/sys/dev/sound/pci/hda/hdacc.c index e663ffa3dbcf..dba60e5101bd 100644 --- a/sys/dev/sound/pci/hda/hdacc.c +++ b/sys/dev/sound/pci/hda/hdacc.c @@ -147,6 +147,7 @@ static const struct { { HDA_CODEC_ALC888, 0, "Realtek ALC888" }, { HDA_CODEC_ALC889, 0, "Realtek ALC889" }, { HDA_CODEC_ALC892, 0, "Realtek ALC892" }, + { HDA_CODEC_ALC897, 0, "Realtek ALC897" }, { HDA_CODEC_ALC899, 0, "Realtek ALC899" }, { HDA_CODEC_ALC1150, 0, "Realtek ALC1150" }, { HDA_CODEC_ALCS1200A, 0, "Realtek ALCS1200A" }, @@ -392,6 +393,7 @@ static const struct { { HDA_CODEC_INTELGMLK1, 0, "Intel Gemini Lake" }, { HDA_CODEC_INTELICLK, 0, "Intel Ice Lake" }, { HDA_CODEC_INTELTGLK, 0, "Intel Tiger Lake" }, + { HDA_CODEC_INTELALLK, 0, "Intel Alder Lake" }, { HDA_CODEC_SII1390, 0, "Silicon Image SiI1390" }, { HDA_CODEC_SII1392, 0, "Silicon Image SiI1392" }, /* Unknown CODECs */ diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index 615d16ee3740..7ed0420b7664 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -134,6 +134,8 @@ xhci_pci_match(device_t self) return ("Intel Gemini Lake USB 3.0 controller"); case 0x5aa88086: return ("Intel Apollo Lake USB 3.0 controller"); + case 0x7ae08086: + return ("Intel Alder Lake USB 3.2 controller"); case 0x8c318086: return ("Intel Lynx Point USB 3.0 controller"); case 0x8cb18086: From nobody Sat Nov 6 04:40: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 2D3BB183AA71; Sat, 6 Nov 2021 04:40: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 4HmPnS0NhKz3GHn; Sat, 6 Nov 2021 04:40: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 E16E424EEB; Sat, 6 Nov 2021 04:40: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 1A64eRK2059863; Sat, 6 Nov 2021 04:40:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A64eRVa059862; Sat, 6 Nov 2021 04:40:27 GMT (envelope-from git) Date: Sat, 6 Nov 2021 04:40:27 GMT Message-Id: <202111060440.1A64eRVa059862@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: 8363963a8f3f - main - rtld: fix dangerous_ld_env calculation for ld_dynamic_weak 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: 8363963a8f3fc8226b1e3aa627e2fdd09688704e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8363963a8f3fc8226b1e3aa627e2fdd09688704e commit 8363963a8f3fc8226b1e3aa627e2fdd09688704e Author: Konstantin Belousov AuthorDate: 2021-11-06 03:00:52 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-06 04:40:17 +0000 rtld: fix dangerous_ld_env calculation for ld_dynamic_weak Default value for ld_dynamic_weak is true, non-default settings should be activated for the false value. Reported by: obiwac@gmail.com Sponsored by: The FreeBSD Foundation MFC after: 3 days --- libexec/rtld-elf/rtld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 05afe5f42c3e..5a8e4f6bbc96 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -726,7 +726,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) } dangerous_ld_env = libmap_disable || libmap_override != NULL || ld_library_path != NULL || ld_preload != NULL || - ld_elf_hints_path != NULL || ld_loadfltr || ld_dynamic_weak; + ld_elf_hints_path != NULL || ld_loadfltr || !ld_dynamic_weak; ld_tracing = ld_get_env_var(LD_TRACE_LOADED_OBJECTS); ld_utrace = ld_get_env_var(LD_UTRACE); From nobody Sat Nov 6 04:40: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 00F7A183ADF1; Sat, 6 Nov 2021 04:40: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 4HmPnT1Sd1z3GQ5; Sat, 6 Nov 2021 04:40: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 1055424EEC; Sat, 6 Nov 2021 04:40: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 1A64eSa3059887; Sat, 6 Nov 2021 04:40:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A64eSK1059886; Sat, 6 Nov 2021 04:40:28 GMT (envelope-from git) Date: Sat, 6 Nov 2021 04:40:28 GMT Message-Id: <202111060440.1A64eSK1059886@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: c5637b8be8a5 - main - rtld: ignore fstatfs(2) errors when checking MNT_NOEXEC flag 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: c5637b8be8a5b6aaf663a58b0027f7f924d78b04 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c5637b8be8a5b6aaf663a58b0027f7f924d78b04 commit c5637b8be8a5b6aaf663a58b0027f7f924d78b04 Author: Konstantin Belousov AuthorDate: 2021-11-06 03:06:34 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-06 04:40:17 +0000 rtld: ignore fstatfs(2) errors when checking MNT_NOEXEC flag File descriptor we operate on might reference something that is not a file, e.g. shmfd. In this case, we cannot check MNT_NOEXEC in principle. If fstatfs(2) caused some failure on normal filesystem, then typical expectation is that read or mmap of this file would also fail. If not, mmap(2) PROT_EXEC on MNT_NOEXEC filesystem returns EACCES. Reported by: obiwac@gmail.com Sponsored by: The FreeBSD Foundation MFC after: 1 week --- libexec/rtld-elf/rtld.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 5a8e4f6bbc96..db89a878c5f9 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2773,19 +2773,17 @@ do_load_object(int fd, const char *name, char *path, struct stat *sbp, struct statfs fs; /* - * but first, make sure that environment variables haven't been + * First, make sure that environment variables haven't been * used to circumvent the noexec flag on a filesystem. + * We ignore fstatfs(2) failures, since fd might reference + * not a file, e.g. shmfd. */ - if (dangerous_ld_env) { - if (fstatfs(fd, &fs) != 0) { - _rtld_error("Cannot fstatfs \"%s\"", printable_path(path)); - return NULL; - } - if (fs.f_flags & MNT_NOEXEC) { + if (dangerous_ld_env && fstatfs(fd, &fs) == 0 && + (fs.f_flags & MNT_NOEXEC) != 0) { _rtld_error("Cannot execute objects on %s", fs.f_mntonname); - return NULL; - } + return (NULL); } + dbg("loading \"%s\"", printable_path(path)); obj = map_object(fd, printable_path(path), sbp); if (obj == NULL) From nobody Sat Nov 6 04:40: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 BFE3F183AF88; Sat, 6 Nov 2021 04:40: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 4HmPnV2XLvz3GBq; Sat, 6 Nov 2021 04:40: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 3072F24A7A; Sat, 6 Nov 2021 04:40: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 1A64eUwv059911; Sat, 6 Nov 2021 04:40:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A64eUcn059910; Sat, 6 Nov 2021 04:40:30 GMT (envelope-from git) Date: Sat, 6 Nov 2021 04:40:30 GMT Message-Id: <202111060440.1A64eUcn059910@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: 74aec9618fd7 - main - rtld: style adjustments 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: 74aec9618fd709513ef2d319598dd82801c29726 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=74aec9618fd709513ef2d319598dd82801c29726 commit 74aec9618fd709513ef2d319598dd82801c29726 Author: Konstantin Belousov AuthorDate: 2021-11-06 03:20:39 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-06 04:40:18 +0000 rtld: style adjustments Consistently use `return ()'. Fix some spacing issues with types formatting, and around binary ops. Sponsored by: The FreeBSD Foundation MFC after: 1 week --- libexec/rtld-elf/rtld.c | 126 +++++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 61 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index db89a878c5f9..c173c5a6e22e 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -974,7 +974,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) /* Return the exit procedure and the program entry point. */ *exit_proc = rtld_exit_ptr; *objp = obj_main; - return (func_ptr_type) obj_main->entry; + return ((func_ptr_type)obj_main->entry); } void * @@ -1035,7 +1035,7 @@ _rtld_bind(Obj_Entry *obj, Elf_Size reloff) */ target = reloc_jmpslot(where, target, defobj, obj, rel); lock_release(rtld_bind_lock, &lockstate); - return target; + return (target); } /* @@ -1092,8 +1092,10 @@ errmsg_restore(struct dlerror_save *saved_msg) static const char * basename(const char *name) { - const char *p = strrchr(name, '/'); - return p != NULL ? p + 1 : name; + const char *p; + + p = strrchr(name, '/'); + return (p != NULL ? p + 1 : name); } static struct utsname uts; @@ -1696,11 +1698,11 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path) } if (nsegs < 1) { _rtld_error("%s: too few PT_LOAD segments", path); - return NULL; + return (NULL); } obj->entry = entry; - return obj; + return (obj); } void @@ -1761,9 +1763,9 @@ dlcheck(void *handle) if (obj == NULL || obj->refcount == 0 || obj->dl_refcount == 0) { _rtld_error("Invalid shared object handle %p", handle); - return NULL; + return (NULL); } - return obj; + return (obj); } /* @@ -1777,7 +1779,7 @@ donelist_check(DoneList *dlp, const Obj_Entry *obj) for (i = 0; i < dlp->num_used; i++) if (dlp->objs[i] == obj) - return true; + return (true); /* * Our donelist allocation should always be sufficient. But if * our threads locking isn't working properly, more shared objects @@ -1786,7 +1788,7 @@ donelist_check(DoneList *dlp, const Obj_Entry *obj) */ if (dlp->num_used < dlp->num_alloc) dlp->objs[dlp->num_used++] = obj; - return false; + return (false); } /* @@ -1806,7 +1808,7 @@ elf_hash(const char *name) h ^= g >> 24; h &= ~g; } - return h; + return (h); } /* @@ -1975,10 +1977,10 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj, * the cache. */ if (symnum >= refobj->dynsymcount) - return NULL; /* Bad object */ + return (NULL); /* Bad object */ if (cache != NULL && cache[symnum].sym != NULL) { *defobj_out = cache[symnum].obj; - return cache[symnum].sym; + return (cache[symnum].sym); } ref = refobj->symtab + symnum; @@ -2035,7 +2037,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj, _rtld_error("%s: Undefined symbol \"%s%s%s\"", refobj->path, name, ve != NULL ? "@" : "", ve != NULL ? ve->name : ""); } - return def; + return (def); } /* @@ -2736,7 +2738,7 @@ load_object(const char *name, int fd_u, const Obj_Entry *refobj, int flags) _rtld_error("Cannot fstat \"%s\"", printable_path(path)); close(fd); free(path); - return NULL; + return (NULL); } TAILQ_FOREACH(obj, &obj_list, next) { if (obj->marker || obj->doomed) @@ -2748,7 +2750,7 @@ load_object(const char *name, int fd_u, const Obj_Entry *refobj, int flags) object_add_name(obj, name); free(path); close(fd); - return obj; + return (obj); } if (flags & RTLD_LO_NOLOAD) { free(path); @@ -2762,7 +2764,7 @@ load_object(const char *name, int fd_u, const Obj_Entry *refobj, int flags) free(path); close(fd); - return obj; + return (obj); } static Obj_Entry * @@ -2787,7 +2789,7 @@ do_load_object(int fd, const char *name, char *path, struct stat *sbp, dbg("loading \"%s\"", printable_path(path)); obj = map_object(fd, printable_path(path), sbp); if (obj == NULL) - return NULL; + return (NULL); /* * If DT_SONAME is present in the object, digest_dynamic2 already @@ -2847,7 +2849,7 @@ obj_from_addr(const void *addr) if (addr < (void *)(obj->mapbase + obj->mapsize)) return obj; } - return NULL; + return (NULL); } static void @@ -3049,7 +3051,7 @@ objlist_find(Objlist *list, const Obj_Entry *obj) STAILQ_FOREACH(elm, list, link) if (elm->obj == obj) return elm; - return NULL; + return (NULL); } static void @@ -3429,7 +3431,7 @@ search_library_path(const char *name, const char *path, struct try_library_args arg; if (path == NULL) - return NULL; + return (NULL); arg.name = name; arg.namelen = strlen(name); @@ -3530,7 +3532,7 @@ dlclose_locked(void *handle, RtldLockState *lockstate) root = dlcheck(handle); if (root == NULL) - return -1; + return (-1); LD_UTRACE(UTRACE_DLCLOSE_START, handle, NULL, 0, root->dl_refcount, root->path); @@ -3554,7 +3556,7 @@ dlclose_locked(void *handle, RtldLockState *lockstate) unref_dag(root); LD_UTRACE(UTRACE_DLCLOSE_STOP, handle, NULL, 0, 0, NULL); - return 0; + return (0); } char * @@ -3772,7 +3774,7 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags, objlist_clear(&initlist); if (lockstate == &mlockstate) lock_release(rtld_bind_lock, lockstate); - return obj; + return (obj); trace: trace_loaded_objects(obj); if (lockstate == &mlockstate) @@ -3811,7 +3813,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, _rtld_error("Cannot determine caller's shared object"); lock_release(rtld_bind_lock, &lockstate); LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name); - return NULL; + return (NULL); } if (handle == NULL) { /* Just the caller's shared object. */ res = symlook_obj(&req, obj); @@ -3864,7 +3866,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, if ((obj = dlcheck(handle)) == NULL) { lock_release(rtld_bind_lock, &lockstate); LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name); - return NULL; + return (NULL); } donelist_init(&donelist); @@ -3924,14 +3926,14 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, ve != NULL ? ve->name : ""); lock_release(rtld_bind_lock, &lockstate); LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name); - return NULL; + return (NULL); } void * dlsym(void *handle, const char *name) { - return do_dlsym(handle, name, __builtin_return_address(0), NULL, - SYMLOOK_DLSYM); + return (do_dlsym(handle, name, __builtin_return_address(0), NULL, + SYMLOOK_DLSYM)); } dlfunc_t @@ -3956,8 +3958,8 @@ dlvsym(void *handle, const char *name, const char *version) ventry.file = NULL; ventry.hash = elf_hash(version); ventry.flags= 0; - return do_dlsym(handle, name, __builtin_return_address(0), &ventry, - SYMLOOK_DLSYM); + return (do_dlsym(handle, name, __builtin_return_address(0), &ventry, + SYMLOOK_DLSYM)); } int @@ -3992,7 +3994,7 @@ dladdr(const void *addr, Dl_info *info) if (obj == NULL) { _rtld_error("No shared object contains address"); lock_release(rtld_bind_lock, &lockstate); - return 0; + return (0); } info->dli_fname = obj->path; info->dli_fbase = obj->mapbase; @@ -4031,7 +4033,7 @@ dladdr(const void *addr, Dl_info *info) break; } lock_release(rtld_bind_lock, &lockstate); - return 1; + return (1); } int @@ -5258,8 +5260,8 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign) dtv = xcalloc(tls_max_index + 2, sizeof(Elf_Addr)); segbase = (Elf_Addr)(tls + roundup(tls_static_space, ralign)); - ((Elf_Addr*)segbase)[0] = segbase; - ((Elf_Addr*)segbase)[1] = (Elf_Addr) dtv; + ((Elf_Addr *)segbase)[0] = segbase; + ((Elf_Addr *)segbase)[1] = (Elf_Addr) dtv; dtv[0] = tls_dtv_generation; dtv[1] = tls_max_index; @@ -5270,18 +5272,19 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign) */ oldsegbase = (Elf_Addr) oldtls; memcpy((void *)(segbase - tls_static_space), - (const void *)(oldsegbase - tls_static_space), - tls_static_space); + (const void *)(oldsegbase - tls_static_space), + tls_static_space); /* * If any dynamic TLS blocks have been created tls_get_addr(), * move them over. */ - olddtv = ((Elf_Addr**)oldsegbase)[1]; + olddtv = ((Elf_Addr **)oldsegbase)[1]; for (i = 0; i < olddtv[1]; i++) { - if (olddtv[i+2] < oldsegbase - size || olddtv[i+2] > oldsegbase) { - dtv[i+2] = olddtv[i+2]; - olddtv[i+2] = 0; + if (olddtv[i + 2] < oldsegbase - size || + olddtv[i + 2] > oldsegbase) { + dtv[i + 2] = olddtv[i + 2]; + olddtv[i + 2] = 0; } } @@ -5289,23 +5292,23 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign) * We assume that this block was the one we created with * allocate_initial_tls(). */ - free_tls(oldtls, 2*sizeof(Elf_Addr), sizeof(Elf_Addr)); + free_tls(oldtls, 2 * sizeof(Elf_Addr), sizeof(Elf_Addr)); } else { for (obj = objs; obj != NULL; obj = TAILQ_NEXT(obj, next)) { if (obj->marker || obj->tlsoffset == 0) continue; addr = segbase - obj->tlsoffset; - memset((void*)(addr + obj->tlsinitsize), - 0, obj->tlssize - obj->tlsinitsize); + memset((void *)(addr + obj->tlsinitsize), + 0, obj->tlssize - obj->tlsinitsize); if (obj->tlsinit) { - memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize); - obj->static_tls_copied = true; + memcpy((void *)addr, obj->tlsinit, obj->tlsinitsize); + obj->static_tls_copied = true; } dtv[obj->tlsindex + 1] = addr; } } - return (void*) segbase; + return ((void *)segbase); } void @@ -5325,18 +5328,19 @@ free_tls(void *tls, size_t tcbsize __unused, size_t tcbalign) ralign = tls_static_max_align; size = roundup(tls_static_space, ralign); - dtv = ((Elf_Addr**)tls)[1]; + dtv = ((Elf_Addr **)tls)[1]; dtvsize = dtv[1]; - tlsend = (Elf_Addr) tls; + tlsend = (Elf_Addr)tls; tlsstart = tlsend - size; for (i = 0; i < dtvsize; i++) { - if (dtv[i + 2] != 0 && (dtv[i + 2] < tlsstart || dtv[i + 2] > tlsend)) { - free_aligned((void *)dtv[i + 2]); + if (dtv[i + 2] != 0 && (dtv[i + 2] < tlsstart || + dtv[i + 2] > tlsend)) { + free_aligned((void *)dtv[i + 2]); } } free_aligned((void *)tlsstart); - free((void*) dtv); + free((void *)dtv); } #endif /* TLS_VARIANT_II */ @@ -5373,11 +5377,11 @@ allocate_tls_offset(Obj_Entry *obj) size_t off; if (obj->tls_done) - return true; + return (true); if (obj->tlssize == 0) { obj->tls_done = true; - return true; + return (true); } if (tls_last_offset == 0) @@ -5400,7 +5404,7 @@ allocate_tls_offset(Obj_Entry *obj) */ if (tls_static_space != 0) { if (off > tls_static_space) - return false; + return (false); } else if (obj->tlsalign > tls_static_max_align) { tls_static_max_align = obj->tlsalign; } @@ -5409,7 +5413,7 @@ allocate_tls_offset(Obj_Entry *obj) tls_last_size = obj->tlssize; obj->tls_done = true; - return true; + return (true); } void @@ -5490,7 +5494,7 @@ locate_dependency(const Obj_Entry *obj, const char *name) STAILQ_FOREACH(entry, &list_main, link) { if (object_match_name(entry->obj, name)) - return entry->obj; + return (entry->obj); } for (needed = obj->needed; needed != NULL; needed = needed->next) { @@ -5655,7 +5659,7 @@ rtld_verify_object_versions(Obj_Entry *obj) break; vn = (const Elf_Verneed *)((const char *)vn + vn->vn_next); } - return 0; + return (0); } static int @@ -5680,7 +5684,7 @@ rtld_verify_versions(const Objlist *objlist) } if (rc == 0 || ld_tracing != NULL) rc = rtld_verify_object_versions(&obj_rtld); - return rc; + return (rc); } const Ver_Entry * @@ -5694,10 +5698,10 @@ fetch_ventry(const Obj_Entry *obj, unsigned long symnum) _rtld_error("%s: symbol %s has wrong verneed value %d", obj->path, obj->strtab + symnum, vernum); } else if (obj->vertab[vernum].hash != 0) { - return &obj->vertab[vernum]; + return (&obj->vertab[vernum]); } } - return NULL; + return (NULL); } int From nobody Sat Nov 6 04:54: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 A483B184195F; Sat, 6 Nov 2021 04:54:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmQ5H3PM9z3LZK; Sat, 6 Nov 2021 04:54:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5590D24BEB; Sat, 6 Nov 2021 04:54:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A64sBmB077958; Sat, 6 Nov 2021 04:54:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A64sB3B077957; Sat, 6 Nov 2021 04:54:11 GMT (envelope-from git) Date: Sat, 6 Nov 2021 04:54:11 GMT Message-Id: <202111060454.1A64sB3B077957@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 6badb512a94d - main - Prefer CPUID leaf 1Fh for Intel CPU topology detection. 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6badb512a94df667f0df1484fb288ece186305bd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=6badb512a94df667f0df1484fb288ece186305bd commit 6badb512a94df667f0df1484fb288ece186305bd Author: Alexander Motin AuthorDate: 2021-11-06 04:48:37 +0000 Commit: Alexander Motin CommitDate: 2021-11-06 04:53:52 +0000 Prefer CPUID leaf 1Fh for Intel CPU topology detection. Leaf 1Fh is a prefered extended version of 0Bh. It is supported by new Lader Lake CPUs, though does not report anything new so far. MFC after: 2 weeks --- sys/x86/x86/mp_x86.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 7a72c501ff25..3b0e25172d0d 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -380,7 +380,7 @@ topo_probe_intel_0x4(void) /* * Determine topology of processing units for Intel CPUs - * using CPUID Leaf 11, if supported. + * using CPUID Leaf 1Fh or 0Bh, if supported. * See: * - Intel 64 Architecture Processor Topology Enumeration * - Intel 64 and IA-32 ArchitecturesSoftware Developer’s Manual, @@ -390,13 +390,23 @@ topo_probe_intel_0x4(void) static void topo_probe_intel_0xb(void) { - u_int p[4]; + u_int leaf; + u_int p[4] = { 0 }; int bits; int type; int i; - /* Fall back if CPU leaf 11 doesn't really exist. */ - cpuid_count(0x0b, 0, p); + /* Prefer leaf 1Fh (V2 Extended Topology Enumeration). */ + if (cpu_high >= 0x1f) { + leaf = 0x1f; + cpuid_count(leaf, 0, p); + } + /* Fall back to leaf 0Bh (Extended Topology Enumeration). */ + if (p[1] == 0) { + leaf = 0x0b; + cpuid_count(leaf, 0, p); + } + /* Fall back to leaf 04h (Deterministic Cache Parameters). */ if (p[1] == 0) { topo_probe_intel_0x4(); return; @@ -404,7 +414,7 @@ topo_probe_intel_0xb(void) /* We only support three levels for now. */ for (i = 0; ; i++) { - cpuid_count(0x0b, i, p); + cpuid_count(leaf, i, p); bits = p[0] & 0x1f; type = (p[2] >> 8) & 0xff; @@ -412,13 +422,12 @@ topo_probe_intel_0xb(void) if (type == 0) break; - /* TODO: check for duplicate (re-)assignment */ if (type == CPUID_TYPE_SMT) core_id_shift = bits; else if (type == CPUID_TYPE_CORE) pkg_id_shift = bits; - else - printf("unknown CPU level type %d\n", type); + else if (bootverbose) + printf("Topology level type %d shift: %d\n", type, bits); } if (pkg_id_shift < core_id_shift) { From nobody Sat Nov 6 08:11: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 544E71834377; Sat, 6 Nov 2021 08:11: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 4HmVSw0VF5z3Q6q; Sat, 6 Nov 2021 08:11: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 DCD2B2794D; Sat, 6 Nov 2021 08:11: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 1A68BRc6041041; Sat, 6 Nov 2021 08:11:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A68BRPA041040; Sat, 6 Nov 2021 08:11:27 GMT (envelope-from git) Date: Sat, 6 Nov 2021 08:11:27 GMT Message-Id: <202111060811.1A68BRPA041040@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: 849faf4e0ba9 - main - ossl: Add support for AES-CBC cipher 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: 849faf4e0ba9a8b8f24ff34da93a0fd46c14eda9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=849faf4e0ba9a8b8f24ff34da93a0fd46c14eda9 commit 849faf4e0ba9a8b8f24ff34da93a0fd46c14eda9 Author: Kornel Duleba AuthorDate: 2021-11-02 11:53:22 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 08:08:44 +0000 ossl: Add support for AES-CBC cipher AES-CBC OpenSSL assembly is used underneath. The glue layer(ossl_aes.c) is based on CHACHA20 implementation. Contrary to the SHA and CHACHA20, AES OpenSSL assembly logic does not have a fallback implementation in case CPU doesn't support required instructions. Because of that CPU caps are checked during initialization and AES support is advertised only if available. The feature is available on all architectures that ossl supports: i386, amd64, arm64. The biggest advantage of this patch over existing solutions (aesni(4) and armv8crypto(4)) is that it supports SHA, allowing for ETA operations. Sponsored by: Stormshield Obtained from: Semihalf Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D32099 --- share/man/man4/ossl.4 | 4 +- sys/conf/files | 1 + sys/conf/files.amd64 | 1 + sys/conf/files.arm64 | 4 + sys/conf/files.i386 | 1 + sys/crypto/openssl/ossl.c | 94 +++++++++++++++++------ sys/crypto/openssl/ossl.h | 36 ++++++++- sys/crypto/openssl/ossl_aarch64.c | 23 +++++- sys/crypto/openssl/ossl_aarch64.h | 31 ++++++++ sys/crypto/openssl/ossl_aes.c | 153 +++++++++++++++++++++++++++++++++++++ sys/crypto/openssl/ossl_chacha20.c | 18 ++++- sys/crypto/openssl/ossl_cipher.h | 53 +++++++++++++ sys/crypto/openssl/ossl_x86.c | 15 +++- sys/crypto/openssl/ossl_x86.h | 20 +++++ sys/modules/ossl/Makefile | 14 ++++ tests/sys/opencrypto/cryptotest.py | 2 +- 16 files changed, 436 insertions(+), 34 deletions(-) diff --git a/share/man/man4/ossl.4 b/share/man/man4/ossl.4 index 5929e46e9fe3..039ce301ac29 100644 --- a/share/man/man4/ossl.4 +++ b/share/man/man4/ossl.4 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 3, 2021 +.Dd September 24, 2021 .Dt OSSL 4 .Os .Sh NAME @@ -74,6 +74,8 @@ driver includes support for the following algorithms: .Pp .Bl -bullet -compact .It +AES-CBC +.It ChaCha20 .It ChaCha20-Poly1305 (RFC 8439) diff --git a/sys/conf/files b/sys/conf/files index f2663fd1c6c0..9743341f6e45 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -716,6 +716,7 @@ crypto/chacha20/chacha-sw.c optional crypto | ipsec | ipsec_support crypto/des/des_ecb.c optional netsmb crypto/des/des_setkey.c optional netsmb crypto/openssl/ossl.c optional ossl +crypto/openssl/ossl_aes.c optional ossl crypto/openssl/ossl_chacha20.c optional ossl crypto/openssl/ossl_poly1305.c optional ossl crypto/openssl/ossl_sha1.c optional ossl diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 37ff6404cdba..6b51c1a5a55d 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -88,6 +88,7 @@ cddl/dev/dtrace/amd64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/amd64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_amd64.S optional aesni crypto/des/des_enc.c optional netsmb +crypto/openssl/amd64/aesni-x86_64.S optional ossl crypto/openssl/amd64/chacha-x86_64.S optional ossl crypto/openssl/amd64/poly1305-x86_64.S optional ossl crypto/openssl/amd64/sha1-x86_64.S optional ossl diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index b363b800af67..c1f99382863a 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -128,6 +128,8 @@ ghashv8-armx.o optional armv8crypto \ crypto/des/des_enc.c optional netsmb crypto/openssl/ossl_aarch64.c optional ossl +crypto/openssl/aarch64/aesv8-armx.S optional ossl \ + compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} -march=armv8-a+crypto ${.IMPSRC}" crypto/openssl/aarch64/chacha-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/poly1305-armv8.S optional ossl \ @@ -138,6 +140,8 @@ crypto/openssl/aarch64/sha256-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/sha512-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" +crypto/openssl/aarch64/vpaes-armv8.S optional ossl \ + compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" dev/acpica/acpi_bus_if.m optional acpi dev/acpica/acpi_if.m optional acpi diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index e83bcd5a3492..0c681d6a84a0 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -15,6 +15,7 @@ cddl/dev/dtrace/i386/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/i386/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_i386.S optional aesni crypto/des/arch/i386/des_enc.S optional netsmb +crypto/openssl/i386/aesni-x86.S optional ossl crypto/openssl/i386/chacha-x86.S optional ossl crypto/openssl/i386/poly1305-x86.S optional ossl crypto/openssl/i386/sha1-586.S optional ossl diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index ad9b93dd960d..f46b5a966bb1 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -49,24 +49,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "cryptodev_if.h" -struct ossl_softc { - int32_t sc_cid; -}; - -struct ossl_session_hash { - struct ossl_hash_context ictx; - struct ossl_hash_context octx; - struct auth_hash *axf; - u_int mlen; -}; - -struct ossl_session { - struct ossl_session_hash hash; -}; - static MALLOC_DEFINE(M_OSSL, "ossl", "OpenSSL crypto"); static void @@ -92,7 +78,7 @@ ossl_attach(device_t dev) sc = device_get_softc(dev); - ossl_cpuid(); + ossl_cpuid(sc); sc->sc_cid = crypto_get_driverid(dev, sizeof(struct ossl_session), CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_SYNC | CRYPTOCAP_F_ACCEL_SOFTWARE); @@ -143,9 +129,34 @@ ossl_lookup_hash(const struct crypto_session_params *csp) } } +static struct ossl_cipher* +ossl_lookup_cipher(const struct crypto_session_params *csp) +{ + + switch (csp->csp_cipher_alg) { + case CRYPTO_AES_CBC: + switch (csp->csp_cipher_klen * 8) { + case 128: + case 192: + case 256: + break; + default: + return (NULL); + } + return (&ossl_cipher_aes_cbc); + case CRYPTO_CHACHA20: + if (csp->csp_cipher_klen != CHACHA_KEY_SIZE) + return (NULL); + return (&ossl_cipher_chacha20); + default: + return (NULL); + } +} + static int ossl_probesession(device_t dev, const struct crypto_session_params *csp) { + struct ossl_softc *sc = device_get_softc(dev); if ((csp->csp_flags & ~(CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD)) != 0) @@ -156,14 +167,10 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) return (EINVAL); break; case CSP_MODE_CIPHER: - switch (csp->csp_cipher_alg) { - case CRYPTO_CHACHA20: - if (csp->csp_cipher_klen != CHACHA_KEY_SIZE) - return (EINVAL); - break; - default: + if (csp->csp_cipher_alg != CRYPTO_CHACHA20 && !sc->has_aes) + return (EINVAL); + if (ossl_lookup_cipher(csp) == NULL) return (EINVAL); - } break; case CSP_MODE_AEAD: switch (csp->csp_cipher_alg) { @@ -213,20 +220,57 @@ ossl_newsession_hash(struct ossl_session *s, } } +static int +ossl_newsession_cipher(struct ossl_session *s, + const struct crypto_session_params *csp) +{ + struct ossl_cipher *cipher; + int error = 0; + + cipher = ossl_lookup_cipher(csp); + if (cipher == NULL) + return (EINVAL); + + s->cipher.cipher = cipher; + + if (csp->csp_cipher_key == NULL) + return (0); + + fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); + if (cipher->set_encrypt_key != NULL) { + error = cipher->set_encrypt_key(csp->csp_cipher_key, + 8 * csp->csp_cipher_klen, &s->cipher.enc_ctx); + if (error != 0) { + fpu_kern_leave(curthread, NULL); + return (error); + } + } + if (cipher->set_decrypt_key != NULL) + error = cipher->set_decrypt_key(csp->csp_cipher_key, + 8 * csp->csp_cipher_klen, &s->cipher.dec_ctx); + fpu_kern_leave(curthread, NULL); + + return (error); +} + static int ossl_newsession(device_t dev, crypto_session_t cses, const struct crypto_session_params *csp) { struct ossl_session *s; + int error = 0; s = crypto_get_driver_session(cses); switch (csp->csp_mode) { case CSP_MODE_DIGEST: ossl_newsession_hash(s, csp); break; + case CSP_MODE_CIPHER: + error = ossl_newsession_cipher(s, csp); + break; } - return (0); + return (error); } static int @@ -320,7 +364,7 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) error = ossl_process_hash(s, crp, csp); break; case CSP_MODE_CIPHER: - error = ossl_chacha20(crp, csp); + error = s->cipher.cipher->process(&s->cipher, crp, csp); break; case CSP_MODE_AEAD: if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) diff --git a/sys/crypto/openssl/ossl.h b/sys/crypto/openssl/ossl.h index 11793dca037a..4f5353818add 100644 --- a/sys/crypto/openssl/ossl.h +++ b/sys/crypto/openssl/ossl.h @@ -36,20 +36,47 @@ struct cryptop; struct crypto_session_params; +struct ossl_softc; +struct ossl_session; -int ossl_chacha20(struct cryptop *crp, - const struct crypto_session_params *csp); int ossl_chacha20_poly1305_decrypt(struct cryptop *crp, const struct crypto_session_params *csp); int ossl_chacha20_poly1305_encrypt(struct cryptop *crp, const struct crypto_session_params *csp); -void ossl_cpuid(void); +void ossl_cpuid(struct ossl_softc *sc); + +struct ossl_softc { + int32_t sc_cid; + bool has_aes; +}; /* Needs to be big enough to hold any hash context. */ struct ossl_hash_context { uint32_t dummy[61]; } __aligned(32); +struct ossl_cipher_context { + uint32_t dummy[61]; +} __aligned(32); + +struct ossl_session_hash { + struct ossl_hash_context ictx; + struct ossl_hash_context octx; + struct auth_hash *axf; + u_int mlen; +}; + +struct ossl_session_cipher { + struct ossl_cipher_context dec_ctx; + struct ossl_cipher_context enc_ctx; + struct ossl_cipher *cipher; +}; + +struct ossl_session { + struct ossl_session_cipher cipher; + struct ossl_session_hash hash; +}; + extern struct auth_hash ossl_hash_poly1305; extern struct auth_hash ossl_hash_sha1; extern struct auth_hash ossl_hash_sha224; @@ -57,4 +84,7 @@ extern struct auth_hash ossl_hash_sha256; extern struct auth_hash ossl_hash_sha384; extern struct auth_hash ossl_hash_sha512; +extern struct ossl_cipher ossl_cipher_aes_cbc; +extern struct ossl_cipher ossl_cipher_chacha20; + #endif /* !__OSSL_H__ */ diff --git a/sys/crypto/openssl/ossl_aarch64.c b/sys/crypto/openssl/ossl_aarch64.c index 2a45a848808a..e4b87a75a403 100644 --- a/sys/crypto/openssl/ossl_aarch64.c +++ b/sys/crypto/openssl/ossl_aarch64.c @@ -36,6 +36,7 @@ #include #include +#include #include /* @@ -43,8 +44,14 @@ */ unsigned int OPENSSL_armcap_P; +ossl_cipher_setkey_t aes_v8_set_encrypt_key; +ossl_cipher_setkey_t aes_v8_set_decrypt_key; + +ossl_cipher_setkey_t vpaes_set_encrypt_key; +ossl_cipher_setkey_t vpaes_set_decrypt_key; + void -ossl_cpuid(void) +ossl_cpuid(struct ossl_softc *sc) { /* SHA features */ if ((elf_hwcap & HWCAP_SHA1) != 0) @@ -59,4 +66,18 @@ ossl_cpuid(void) OPENSSL_armcap_P |= ARMV8_AES; if ((elf_hwcap & HWCAP_PMULL) != 0) OPENSSL_armcap_P |= ARMV8_PMULL; + + if ((OPENSSL_armcap_P & ARMV8_AES) == 0 && + (OPENSSL_armcap_P & ARMV7_NEON) == 0) { + sc->has_aes = false; + return; + } + sc->has_aes = true; + if (OPENSSL_armcap_P & ARMV8_AES) { + ossl_cipher_aes_cbc.set_encrypt_key = aes_v8_set_encrypt_key; + ossl_cipher_aes_cbc.set_decrypt_key = aes_v8_set_decrypt_key; + } else { + ossl_cipher_aes_cbc.set_encrypt_key = vpaes_set_encrypt_key; + ossl_cipher_aes_cbc.set_decrypt_key = vpaes_set_decrypt_key; + } } diff --git a/sys/crypto/openssl/ossl_aarch64.h b/sys/crypto/openssl/ossl_aarch64.h new file mode 100644 index 000000000000..f933f862d009 --- /dev/null +++ b/sys/crypto/openssl/ossl_aarch64.h @@ -0,0 +1,31 @@ +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef __OSSL_AARCH64__ +#define __OSSL_AARCH64__ + +#include +#include +#include + +/* aesv8-armx.S */ +ossl_cipher_encrypt_t aes_v8_cbc_encrypt; +/* vpaes-armv8.S */ +ossl_cipher_encrypt_t vpaes_cbc_encrypt; + +static void +AES_CBC_ENCRYPT(const unsigned char *in, unsigned char *out, + size_t length, const void *key, unsigned char *iv, int encrypt) +{ + if (OPENSSL_armcap_P & ARMV8_AES) + aes_v8_cbc_encrypt(in, out, length, key, iv, encrypt); + else + vpaes_cbc_encrypt(in, out, length, key, iv, encrypt); +} +#endif diff --git a/sys/crypto/openssl/ossl_aes.c b/sys/crypto/openssl/ossl_aes.c new file mode 100644 index 000000000000..93f16e7dce55 --- /dev/null +++ b/sys/crypto/openssl/ossl_aes.c @@ -0,0 +1,153 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Stormshield. + * 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 + +#if defined(__amd64__) || defined(__i386__) +#include +#elif defined (__aarch64__) +#include +#endif + +static ossl_cipher_process_t ossl_aes_cbc; + +struct ossl_cipher ossl_cipher_aes_cbc = { + .type = CRYPTO_AES_CBC, + .blocksize = AES_BLOCK_LEN, + .ivsize = AES_BLOCK_LEN, + + /* Filled during initialization based on CPU caps. */ + .set_encrypt_key = NULL, + .set_decrypt_key = NULL, + .process = ossl_aes_cbc +}; + +static int +ossl_aes_cbc(struct ossl_session_cipher *s, struct cryptop *crp, + const struct crypto_session_params *csp) +{ + struct crypto_buffer_cursor cc_in, cc_out; + unsigned char block[EALG_MAX_BLOCK_LEN]; + unsigned char iv[EALG_MAX_BLOCK_LEN]; + const unsigned char *in, *inseg; + unsigned char *out, *outseg; + size_t plen, seglen, inlen, outlen; + struct ossl_cipher_context key; + struct ossl_cipher *cipher; + int blocklen, error; + bool encrypt; + + cipher = s->cipher; + encrypt = CRYPTO_OP_IS_ENCRYPT(crp->crp_op); + plen = crp->crp_payload_length; + blocklen = cipher->blocksize; + + if (plen % blocklen) + return (EINVAL); + + if (crp->crp_cipher_key != NULL) { + if (encrypt) + error = cipher->set_encrypt_key(crp->crp_cipher_key, + 8 * csp->csp_cipher_klen, &key); + else + error = cipher->set_decrypt_key(crp->crp_cipher_key, + 8 * csp->csp_cipher_klen, &key); + if (error) + return (error); + } else { + if (encrypt) + key = s->enc_ctx; + else + key = s->dec_ctx; + } + + crypto_read_iv(crp, iv); + + /* Derived from ossl_chacha20.c */ + crypto_cursor_init(&cc_in, &crp->crp_buf); + crypto_cursor_advance(&cc_in, crp->crp_payload_start); + inseg = crypto_cursor_segment(&cc_in, &inlen); + if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { + crypto_cursor_init(&cc_out, &crp->crp_obuf); + crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); + } else { + cc_out = cc_in; + } + outseg = crypto_cursor_segment(&cc_out, &outlen); + + while (plen >= blocklen) { + if (inlen < blocklen) { + crypto_cursor_copydata(&cc_in, blocklen, block); + in = block; + inlen = blocklen; + } else { + in = inseg; + } + if (outlen < blocklen) { + out = block; + outlen = blocklen; + } else { + out = outseg; + } + + /* Figure out how many blocks we can encrypt/decrypt at once. */ + seglen = rounddown(MIN(plen, MIN(inlen, outlen)), blocklen); + + AES_CBC_ENCRYPT(in, out, seglen, &key, iv, encrypt); + + if (out == block) { + crypto_cursor_copyback(&cc_out, blocklen, block); + outseg = crypto_cursor_segment(&cc_out, &outlen); + } else { + crypto_cursor_advance(&cc_out, seglen); + outseg += seglen; + outlen -= seglen; + } + if (in == block) { + inseg = crypto_cursor_segment(&cc_in, &inlen); + } else { + crypto_cursor_advance(&cc_in, seglen); + inseg += seglen; + inlen -= seglen; + } + plen -= seglen; + } + + explicit_bzero(block, sizeof(block)); + explicit_bzero(iv, sizeof(iv)); + explicit_bzero(&key, sizeof(key)); + return (0); +} diff --git a/sys/crypto/openssl/ossl_chacha20.c b/sys/crypto/openssl/ossl_chacha20.c index aa125121e8b4..c21a28470a26 100644 --- a/sys/crypto/openssl/ossl_chacha20.c +++ b/sys/crypto/openssl/ossl_chacha20.c @@ -37,10 +37,24 @@ #include #include +#include #include -int -ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) +static ossl_cipher_process_t ossl_chacha20; + +struct ossl_cipher ossl_cipher_chacha20 = { + .type = CRYPTO_CHACHA20, + .blocksize = CHACHA_BLK_SIZE, + .ivsize = CHACHA_CTR_SIZE, + + .set_encrypt_key = NULL, + .set_decrypt_key = NULL, + .process = ossl_chacha20 +}; + +static int +ossl_chacha20(struct ossl_session_cipher *s, struct cryptop *crp, + const struct crypto_session_params *csp) { _Alignas(8) unsigned int key[CHACHA_KEY_SIZE / 4]; unsigned int counter[CHACHA_CTR_SIZE / 4]; diff --git a/sys/crypto/openssl/ossl_cipher.h b/sys/crypto/openssl/ossl_cipher.h new file mode 100644 index 000000000000..d9e6ec29aafc --- /dev/null +++ b/sys/crypto/openssl/ossl_cipher.h @@ -0,0 +1,53 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Stormshield. + * 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. + */ + +#ifndef __OSSL_CIPHER_H__ +#define __OSSL_CIPHER_H__ + +struct ossl_session_cipher; +struct cryptop; +struct crypto_session_params; + +typedef int (ossl_cipher_setkey_t)(const unsigned char*, int, void*); +typedef int (ossl_cipher_process_t)(struct ossl_session_cipher*, struct cryptop*, + const struct crypto_session_params*); +typedef void (ossl_cipher_encrypt_t)(const unsigned char*, unsigned char*, size_t, + const void*, unsigned char*, int); + +ossl_cipher_encrypt_t ossl_aes_cbc_encrypt; + +struct ossl_cipher { + int type; + uint16_t blocksize; + uint16_t ivsize; + + ossl_cipher_setkey_t *set_encrypt_key; + ossl_cipher_setkey_t *set_decrypt_key; + ossl_cipher_process_t *process; +}; + +#endif diff --git a/sys/crypto/openssl/ossl_x86.c b/sys/crypto/openssl/ossl_x86.c index 60ff6fa0c759..a1e9a995948b 100644 --- a/sys/crypto/openssl/ossl_x86.c +++ b/sys/crypto/openssl/ossl_x86.c @@ -39,6 +39,7 @@ #include #include +#include /* * See OPENSSL_ia32cap(3). @@ -49,9 +50,13 @@ * [3] = 0 */ unsigned int OPENSSL_ia32cap_P[4]; +#define AESNI_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32))) + +ossl_cipher_setkey_t aesni_set_encrypt_key; +ossl_cipher_setkey_t aesni_set_decrypt_key; void -ossl_cpuid(void) +ossl_cpuid(struct ossl_softc *sc) { uint64_t xcr0; u_int regs[4]; @@ -112,4 +117,12 @@ ossl_cpuid(void) OPENSSL_ia32cap_P[1] &= ~(CPUID2_AVX | AMDID2_XOP | CPUID2_FMA); OPENSSL_ia32cap_P[2] &= ~CPUID_STDEXT_AVX2; } + + if (!AESNI_CAPABLE) { + sc->has_aes = false; + return; + } + sc->has_aes = true; + ossl_cipher_aes_cbc.set_encrypt_key = aesni_set_encrypt_key; + ossl_cipher_aes_cbc.set_decrypt_key = aesni_set_decrypt_key; } diff --git a/sys/crypto/openssl/ossl_x86.h b/sys/crypto/openssl/ossl_x86.h new file mode 100644 index 000000000000..12bd5a4eaddb --- /dev/null +++ b/sys/crypto/openssl/ossl_x86.h @@ -0,0 +1,20 @@ +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef __OSSL_X86__ +#define __OSSL_X86__ + +#include +#include + +/* aesni-x86_64.S, aesni-x86.S */ +ossl_cipher_encrypt_t aesni_cbc_encrypt; + +#define AES_CBC_ENCRYPT aesni_cbc_encrypt +#endif diff --git a/sys/modules/ossl/Makefile b/sys/modules/ossl/Makefile index dfd82dcf6e1f..765e70a03edd 100644 --- a/sys/modules/ossl/Makefile +++ b/sys/modules/ossl/Makefile @@ -4,10 +4,12 @@ .PATH: ${SRCTOP}/sys/crypto/openssl/${MACHINE_CPUARCH} KMOD= ossl +OBJS+= ${OBJS.${MACHINE_CPUARCH}} SRCS= bus_if.h \ cryptodev_if.h \ device_if.h \ ossl.c \ + ossl_aes.c \ ossl_chacha20.c \ ossl_poly1305.c \ ossl_sha1.c \ @@ -21,9 +23,11 @@ SRCS.aarch64= \ sha1-armv8.S \ sha256-armv8.S \ sha512-armv8.S \ + vpaes-armv8.S \ ossl_aarch64.c SRCS.amd64= \ + aesni-x86_64.S \ chacha-x86_64.S \ poly1305-x86_64.S \ sha1-x86_64.S \ @@ -32,6 +36,7 @@ SRCS.amd64= \ ossl_x86.c SRCS.i386= \ + aesni-x86.S \ chacha-x86.S \ poly1305-x86.S \ sha1-586.S \ @@ -45,4 +50,13 @@ ${SRCS.aarch64:M*.S:S/S/o/}: ${.TARGET:R}.S ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC} ${CTFCONVERT_CMD} +# Based on modules/armv8crypto/Makefile. +# Clang doesn't recognize "aes*" instructions without -march set. +aesv8-armx.o: aesv8-armx.S + ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} \ + -march=armv8-a+crypto ${.IMPSRC} + ${CTFCONVERT_CMD} + +OBJS.aarch64= aesv8-armx.o + .include diff --git a/tests/sys/opencrypto/cryptotest.py b/tests/sys/opencrypto/cryptotest.py index 74ce62cee33d..447a7854b246 100644 --- a/tests/sys/opencrypto/cryptotest.py +++ b/tests/sys/opencrypto/cryptotest.py @@ -50,7 +50,7 @@ def katg(base, glob): raise unittest.SkipTest("Missing %s test vectors" % (base)) return iglob(os.path.join(katdir, base, glob)) -aesmodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'safexcel0', 'qat0' ] +aesmodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'ossl0', 'safexcel0', 'qat0' ] shamodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'ossl0', 'safexcel0', 'qat0' ] def GenTestCase(cname): From nobody Sat Nov 6 08:11: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 CA6891834726; Sat, 6 Nov 2021 08:11: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 4HmVSx1mt1z3QFb; Sat, 6 Nov 2021 08:11: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 0BD5E27B1F; Sat, 6 Nov 2021 08:11: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 1A68BSrA041065; Sat, 6 Nov 2021 08:11:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A68BSCq041064; Sat, 6 Nov 2021 08:11:28 GMT (envelope-from git) Date: Sat, 6 Nov 2021 08:11:28 GMT Message-Id: <202111060811.1A68BSCq041064@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: 048a71b46e81 - main - ossl: Add support for ETA mode 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: 048a71b46e816de8fb95b553a8ad0e98c0d51e12 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=048a71b46e816de8fb95b553a8ad0e98c0d51e12 commit 048a71b46e816de8fb95b553a8ad0e98c0d51e12 Author: Kornel Duleba AuthorDate: 2021-11-02 11:57:20 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 08:08:44 +0000 ossl: Add support for ETA mode Now that the AES-CBC is supported we can handle ETA requests. Sponsored by: Stormshield Obtained from: Semihalf Reviewed by: jhb(previous version) Differential revision: https://reviews.freebsd.org/D32100 --- sys/crypto/openssl/ossl.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index f46b5a966bb1..f41ff09c371d 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -172,6 +172,13 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) if (ossl_lookup_cipher(csp) == NULL) return (EINVAL); break; + case CSP_MODE_ETA: + if (!sc->has_aes || + csp->csp_cipher_alg == CRYPTO_CHACHA20 || + ossl_lookup_hash(csp) == NULL || + ossl_lookup_cipher(csp) == NULL) + return (EINVAL); + break; case CSP_MODE_AEAD: switch (csp->csp_cipher_alg) { case CRYPTO_CHACHA20_POLY1305: @@ -268,6 +275,10 @@ ossl_newsession(device_t dev, crypto_session_t cses, case CSP_MODE_CIPHER: error = ossl_newsession_cipher(s, csp); break; + case CSP_MODE_ETA: + ossl_newsession_hash(s, csp); + error = ossl_newsession_cipher(s, csp); + break; } return (error); @@ -341,6 +352,25 @@ out: return (error); } +static int +ossl_process_eta(struct ossl_session *s, struct cryptop *crp, + const struct crypto_session_params *csp) +{ + int error; + + if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { + error = s->cipher.cipher->process(&s->cipher, crp, csp); + if (error == 0) + error = ossl_process_hash(s, crp, csp); + } else { + error = ossl_process_hash(s, crp, csp); + if (error == 0) + error = s->cipher.cipher->process(&s->cipher, crp, csp); + } + + return (error); +} + static int ossl_process(device_t dev, struct cryptop *crp, int hint) { @@ -366,6 +396,9 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) case CSP_MODE_CIPHER: error = s->cipher.cipher->process(&s->cipher, crp, csp); break; + case CSP_MODE_ETA: + error = ossl_process_eta(s, crp, csp); + break; case CSP_MODE_AEAD: if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) error = ossl_chacha20_poly1305_encrypt(crp, csp); From nobody Sat Nov 6 08:11: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 F2D021834738; Sat, 6 Nov 2021 08:11: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 4HmVSz0M9qz3QC3; Sat, 6 Nov 2021 08:11: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 2BEE72794E; Sat, 6 Nov 2021 08:11: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 1A68BUJe041089; Sat, 6 Nov 2021 08:11:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A68BUBo041088; Sat, 6 Nov 2021 08:11:30 GMT (envelope-from git) Date: Sat, 6 Nov 2021 08:11:30 GMT Message-Id: <202111060811.1A68BUBo041088@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: b8b7c0dda9a0 - main - qoriq_gpio: Add support for driver inheritance 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: b8b7c0dda9a085902f702f8c89271b852aa898a4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=b8b7c0dda9a085902f702f8c89271b852aa898a4 commit b8b7c0dda9a085902f702f8c89271b852aa898a4 Author: Kornel Duleba AuthorDate: 2021-10-29 14:06:35 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 08:08:45 +0000 qoriq_gpio: Add support for driver inheritance Expose softc and other necessary things in a separate header. This is needed for an armv8 specific driver, that will inherit from this one. Driver mutex was converted to a spin lock, so that it can be later used in interrupt filter context. Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D32587 --- sys/dev/gpio/qoriq_gpio.c | 44 +++++--------------------------- sys/dev/gpio/qoriq_gpio.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 38 deletions(-) diff --git a/sys/dev/gpio/qoriq_gpio.c b/sys/dev/gpio/qoriq_gpio.c index dc4813e07b8e..eb790eb50d29 100644 --- a/sys/dev/gpio/qoriq_gpio.c +++ b/sys/dev/gpio/qoriq_gpio.c @@ -46,40 +46,12 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include "gpio_if.h" -#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) - -#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_DEF) -#define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); - -#define GPIO_GPDIR 0x0 -#define GPIO_GPODR 0x4 -#define GPIO_GPDAT 0x8 -#define GPIO_GPIER 0xc -#define GPIO_GPIMR 0x10 -#define GPIO_GPICR 0x14 -#define GPIO_GPIBE 0x18 - -struct qoriq_gpio_softc { - device_t dev; - device_t busdev; - struct mtx sc_mtx; - struct resource *sc_mem; /* Memory resource */ - struct gpio_pin sc_pins[MAXPIN + 1]; -}; - static device_t qoriq_gpio_get_bus(device_t dev) { @@ -379,9 +351,7 @@ qoriq_gpio_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells, return (err); } -static int qoriq_gpio_detach(device_t dev); - -static int +int qoriq_gpio_attach(device_t dev) { struct qoriq_gpio_softc *sc = device_get_softc(dev); @@ -422,7 +392,7 @@ qoriq_gpio_attach(device_t dev) return (0); } -static int +int qoriq_gpio_detach(device_t dev) { struct qoriq_gpio_softc *sc = device_get_softc(dev); @@ -464,13 +434,11 @@ static device_method_t qoriq_gpio_methods[] = { DEVMETHOD_END }; -static driver_t qoriq_gpio_driver = { - "gpio", - qoriq_gpio_methods, - sizeof(struct qoriq_gpio_softc), -}; static devclass_t qoriq_gpio_devclass; +DEFINE_CLASS_0(gpio, qoriq_gpio_driver, qoriq_gpio_methods, + sizeof(struct qoriq_gpio_softc)); + EARLY_DRIVER_MODULE(qoriq_gpio, simplebus, qoriq_gpio_driver, qoriq_gpio_devclass, NULL, NULL, BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/dev/gpio/qoriq_gpio.h b/sys/dev/gpio/qoriq_gpio.h new file mode 100644 index 000000000000..6b401e1d3f44 --- /dev/null +++ b/sys/dev/gpio/qoriq_gpio.h @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 2020 Alstom Group. + * Copyright (c) 2020 Semihalf. + * Copyright (c) 2015 Justin Hibbits + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#define MAXPIN (31) + +#define BIT(x) (1 << (x)) + +#define VALID_PIN(u) ((u) >= 0 && (u) <= MAXPIN) +#define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \ + 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_INIT(sc) \ + mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->dev), \ + "gpio", MTX_SPIN) +#define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); + +#define GPIO_GPDIR 0x0 +#define GPIO_GPODR 0x4 +#define GPIO_GPDAT 0x8 +#define GPIO_GPIER 0xc +#define GPIO_GPIMR 0x10 +#define GPIO_GPICR 0x14 +#define GPIO_GPIBE 0x18 + +struct qoriq_gpio_softc { + device_t dev; + device_t busdev; + struct mtx sc_mtx; + struct resource *sc_mem; + struct gpio_pin sc_pins[MAXPIN + 1]; +}; + +device_attach_t qoriq_gpio_attach; +device_detach_t qoriq_gpio_detach; + +DECLARE_CLASS(qoriq_gpio_driver); From nobody Sat Nov 6 08:11: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 9D29F18346DB; Sat, 6 Nov 2021 08:11: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 4HmVT01mw1z3QL4; Sat, 6 Nov 2021 08:11: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 55602276FE; Sat, 6 Nov 2021 08:11: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 1A68BVD5041114; Sat, 6 Nov 2021 08:11:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A68BVEF041113; Sat, 6 Nov 2021 08:11:31 GMT (envelope-from git) Date: Sat, 6 Nov 2021 08:11:31 GMT Message-Id: <202111060811.1A68BVEF041113@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: 463b6ba05a69 - main - Introduce qoriq_gpio_pic 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: 463b6ba05a69edbdaaf79425ba9fdc9dc64eae70 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=463b6ba05a69edbdaaf79425ba9fdc9dc64eae70 commit 463b6ba05a69edbdaaf79425ba9fdc9dc64eae70 Author: Kornel Duleba AuthorDate: 2021-11-02 10:30:01 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 08:08:45 +0000 Introduce qoriq_gpio_pic driver It adds the PIC functionality on top of qoriq_gpio driver. We need a separate module since the powerpc PIC API is completely different than on other architectures. 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 --- sys/arm64/qoriq/qoriq_gpio_pic.c | 439 +++++++++++++++++++++++++++++++++++++++ sys/conf/files.arm64 | 1 + sys/dev/gpio/qoriq_gpio.c | 1 - 3 files changed, 440 insertions(+), 1 deletion(-) diff --git a/sys/arm64/qoriq/qoriq_gpio_pic.c b/sys/arm64/qoriq/qoriq_gpio_pic.c new file mode 100644 index 000000000000..c2f462bf7787 --- /dev/null +++ b/sys/arm64/qoriq/qoriq_gpio_pic.c @@ -0,0 +1,439 @@ +/*- + * 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 "gpio_if.h" +#include "pic_if.h" + +struct qoriq_gpio_pic_irqsrc { + struct intr_irqsrc isrc; + int pin; +}; + +struct qoriq_gpio_pic_softc { + struct qoriq_gpio_softc base; + + struct resource *res_irq; + void *irq_cookie; + struct qoriq_gpio_pic_irqsrc isrcs[MAXPIN + 1]; + struct intr_map_data_gpio gdata; +}; + +#define RD4(sc, off) bus_read_4((sc)->base.sc_mem, (off)) +#define WR4(sc, off, data) bus_write_4((sc)->base.sc_mem, (off), (data)) + +static device_probe_t qoriq_gpio_pic_probe; +static device_attach_t qoriq_gpio_pic_attach; +static device_detach_t qoriq_gpio_pic_detach; + +static void +qoriq_gpio_pic_set_intr(struct qoriq_gpio_pic_softc *sc, int pin, bool enable) +{ + uint32_t reg; + + reg = RD4(sc, GPIO_GPIMR); + if (enable) + reg |= BIT(31 - pin); + else + reg &= ~BIT(31 - pin); + WR4(sc, GPIO_GPIMR, reg); +} + +static void +qoriq_gpio_pic_ack_intr(struct qoriq_gpio_pic_softc *sc, int pin) +{ + uint32_t reg; + + reg = BIT(31 - pin); + WR4(sc, GPIO_GPIER, reg); +} + +static int +qoriq_gpio_pic_intr(void *arg) +{ + struct qoriq_gpio_pic_softc *sc; + struct trapframe *tf; + uint32_t status; + int pin; + + sc = (struct qoriq_gpio_pic_softc *)arg; + tf = curthread->td_intr_frame; + + status = RD4(sc, GPIO_GPIER); + status &= RD4(sc, GPIO_GPIMR); + while (status != 0) { + pin = ffs(status) - 1; + status &= ~BIT(pin); + pin = 31 - pin; + + if (intr_isrc_dispatch(&sc->isrcs[pin].isrc, tf) != 0) { + GPIO_LOCK(&sc->base); + qoriq_gpio_pic_set_intr(sc, pin, false); + qoriq_gpio_pic_ack_intr(sc, pin); + GPIO_UNLOCK(&sc->base); + device_printf(sc->base.dev, + "Masking spurious pin interrupt %d\n", + pin); + } + } + + return (FILTER_HANDLED); +} + +static void +qoriq_gpio_pic_disable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_pic_softc *sc; + struct qoriq_gpio_pic_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc; + + GPIO_LOCK(&sc->base); + qoriq_gpio_pic_set_intr(sc, qisrc->pin, false); + GPIO_UNLOCK(&sc->base); +} + +static void +qoriq_gpio_pic_enable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_pic_softc *sc; + struct qoriq_gpio_pic_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc; + + GPIO_LOCK(&sc->base); + qoriq_gpio_pic_set_intr(sc, qisrc->pin, true); + GPIO_UNLOCK(&sc->base); +} + +static struct intr_map_data_gpio* +qoriq_gpio_pic_convert_map_data(struct qoriq_gpio_pic_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_pic_map_intr(device_t dev, struct intr_map_data *data, + struct intr_irqsrc **isrcp) +{ + struct qoriq_gpio_pic_softc *sc; + struct intr_map_data_gpio *gdata; + int pin; + + sc = device_get_softc(dev); + + gdata = qoriq_gpio_pic_convert_map_data(sc, data); + if (gdata == NULL) + return (EINVAL); + + pin = gdata->gpio_pin_num; + if (pin > MAXPIN) + return (EINVAL); + + *isrcp = &sc->isrcs[pin].isrc; + return (0); +} + +static int +qoriq_gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + struct qoriq_gpio_pic_softc *sc; + struct intr_map_data_gpio *gdata; + struct qoriq_gpio_pic_irqsrc *qisrc; + bool falling; + uint32_t reg; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc; + + gdata = qoriq_gpio_pic_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->base); + reg = RD4(sc, GPIO_GPICR); + if (falling) + reg |= BIT(31 - qisrc->pin); + else + reg &= ~BIT(31 - qisrc->pin); + WR4(sc, GPIO_GPICR, reg); + GPIO_UNLOCK(&sc->base); + + return (0); +} + +static int +qoriq_gpio_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + struct qoriq_gpio_pic_softc *sc; + struct qoriq_gpio_pic_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc; + + if (isrc->isrc_handlers > 0) + return (0); + + GPIO_LOCK(&sc->base); + qoriq_gpio_pic_set_intr(sc, qisrc->pin, false); + GPIO_UNLOCK(&sc->base); + return (0); +} + +static void +qoriq_gpio_pic_post_filter(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_pic_softc *sc; + struct qoriq_gpio_pic_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc; + + GPIO_LOCK(&sc->base); + qoriq_gpio_pic_ack_intr(sc, qisrc->pin); + GPIO_UNLOCK(&sc->base); +} + + +static void +qoriq_gpio_pic_post_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_pic_softc *sc; + struct qoriq_gpio_pic_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc; + + GPIO_LOCK(&sc->base); + qoriq_gpio_pic_ack_intr(sc, qisrc->pin); + qoriq_gpio_pic_set_intr(sc, qisrc->pin, true); + GPIO_UNLOCK(&sc->base); +} + +static void +qoriq_gpio_pic_pre_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct qoriq_gpio_pic_softc *sc; + struct qoriq_gpio_pic_irqsrc *qisrc; + + sc = device_get_softc(dev); + qisrc = (struct qoriq_gpio_pic_irqsrc *)isrc; + + GPIO_LOCK(&sc->base); + qoriq_gpio_pic_set_intr(sc, qisrc->pin, false); + GPIO_UNLOCK(&sc->base); + +} +static int +qoriq_gpio_pic_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "fsl,qoriq-gpio")) + return (ENXIO); + + device_set_desc(dev, "Freescale QorIQ GPIO PIC driver"); + + return (BUS_PROBE_DEFAULT); +} + +static int +qoriq_gpio_pic_attach(device_t dev) +{ + struct qoriq_gpio_pic_softc *sc; + int error, rid, i; + const char *name; + intptr_t xref; + + sc = device_get_softc(dev); + + error = qoriq_gpio_attach(dev); + if (error != 0) + return (error); + + rid = 0; + sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE | RF_SHAREABLE); + if (sc->res_irq == NULL) { + device_printf(dev, "Can't allocate interrupt resource.\n"); + error = ENOMEM; + goto fail; + } + + error = bus_setup_intr(dev, sc->res_irq, INTR_TYPE_MISC | INTR_MPSAFE, + qoriq_gpio_pic_intr, NULL, sc, &sc->irq_cookie); + if (error != 0) { + device_printf(dev, "Failed to setup interrupt.\n"); + goto fail; + } + + name = device_get_nameunit(dev); + for (i = 0; i <= MAXPIN; i++) { + sc->isrcs[i].pin = i; + error = intr_isrc_register(&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; + } + + /* ACK and mask all interrupts. */ + WR4(sc, GPIO_GPIER, 0xffffffff); + WR4(sc, GPIO_GPIMR, 0); + + return (0); +fail: + qoriq_gpio_pic_detach(dev); + return (error); +} + +static int +qoriq_gpio_pic_detach(device_t dev) +{ + struct qoriq_gpio_pic_softc *sc; + + sc = device_get_softc(dev); + + if (sc->irq_cookie != NULL) + bus_teardown_intr(dev, sc->res_irq, sc->irq_cookie); + + if (sc->res_irq != NULL) + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(sc->res_irq), sc->res_irq); + + return (qoriq_gpio_detach(dev)); +} + + +static device_method_t qoriq_gpio_pic_methods[] = { + DEVMETHOD(device_probe, qoriq_gpio_pic_probe), + DEVMETHOD(device_attach, qoriq_gpio_pic_attach), + DEVMETHOD(device_detach, qoriq_gpio_pic_detach), + + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + + DEVMETHOD(pic_disable_intr, qoriq_gpio_pic_disable_intr), + DEVMETHOD(pic_enable_intr, qoriq_gpio_pic_enable_intr), + DEVMETHOD(pic_map_intr, qoriq_gpio_pic_map_intr), + DEVMETHOD(pic_setup_intr, qoriq_gpio_pic_setup_intr), + DEVMETHOD(pic_teardown_intr, qoriq_gpio_pic_teardown_intr), + DEVMETHOD(pic_post_filter, qoriq_gpio_pic_post_filter), + DEVMETHOD(pic_post_ithread, qoriq_gpio_pic_post_ithread), + DEVMETHOD(pic_pre_ithread, qoriq_gpio_pic_pre_ithread), + + DEVMETHOD_END +}; + +static devclass_t qoriq_gpio_pic_devclass; + +DEFINE_CLASS_1(gpio, qoriq_gpio_pic_driver, qoriq_gpio_pic_methods, + sizeof(struct qoriq_gpio_pic_softc), qoriq_gpio_driver); +EARLY_DRIVER_MODULE(qoriq_gpio_pic, simplebus, qoriq_gpio_pic_driver, + qoriq_gpio_pic_devclass, NULL, NULL, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index c1f99382863a..e718e9b93847 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -522,6 +522,7 @@ tegra210_xusb.fw optional tegra210_xusb_fw \ # NXP arm/freescale/vybrid/vf_i2c.c optional vf_i2c iicbus SOC_NXP_LS arm64/qoriq/qoriq_dw_pci.c optional pci fdt SOC_NXP_LS +arm64/qoriq/qoriq_gpio_pic.c optional gpio 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 diff --git a/sys/dev/gpio/qoriq_gpio.c b/sys/dev/gpio/qoriq_gpio.c index eb790eb50d29..8300a45aa249 100644 --- a/sys/dev/gpio/qoriq_gpio.c +++ b/sys/dev/gpio/qoriq_gpio.c @@ -233,7 +233,6 @@ qoriq_gpio_pin_toggle(device_t dev, uint32_t pin) } static struct ofw_compat_data gpio_matches[] = { - {"fsl,qoriq-gpio", 1}, {"fsl,pq3-gpio", 1}, {"fsl,mpc8572-gpio", 1}, {0, 0} From nobody Sat Nov 6 08:11: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 E1A1E18346F2; Sat, 6 Nov 2021 08:11: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 4HmVT05rQFz3QCC; Sat, 6 Nov 2021 08:11: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 5E85827B99; Sat, 6 Nov 2021 08:11: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 1A68BWV8041143; Sat, 6 Nov 2021 08:11:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A68BWQD041142; Sat, 6 Nov 2021 08:11:32 GMT (envelope-from git) Date: Sat, 6 Nov 2021 08:11:32 GMT Message-Id: <202111060811.1A68BWQD041142@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: 4b843e7f0319 - main - mii_fdt: Add support for switch PHY node lookup 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: 4b843e7f0319867c412070e7752dbb47f195b322 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=4b843e7f0319867c412070e7752dbb47f195b322 commit 4b843e7f0319867c412070e7752dbb47f195b322 Author: Kornel Duleba AuthorDate: 2021-10-27 08:34:17 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 08:08:45 +0000 mii_fdt: Add support for switch PHY node lookup Previously we would only search for a PHY xref in node of the miibus parent. That didn't work very well with switches. Fix that by searching through "ports" subnode, checking if any of its children have a valid PHY xref. Since switches tend to have multiple ports we also have multiple candidates. Use the PHY address read from mii_attach_args to find the right one. Obtained from: Semihalf Sponsored by: Alstom Group Reviewed by: mw Differential revision: https://reviews.freebsd.org/D32690 --- sys/dev/mii/mii_fdt.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/sys/dev/mii/mii_fdt.c b/sys/dev/mii/mii_fdt.c index 009a523e32ce..18ed9c8e749c 100644 --- a/sys/dev/mii/mii_fdt.c +++ b/sys/dev/mii/mii_fdt.c @@ -99,6 +99,44 @@ mii_fdt_get_phynode(phandle_t macnode) return (-1); } +static phandle_t +mii_fdt_lookup_phy(phandle_t node, int addr) +{ + phandle_t ports, phynode, child; + int reg; + + /* First try to see if we have a direct xref pointing to a PHY. */ + phynode = mii_fdt_get_phynode(node); + if (phynode != -1) + return (phynode); + + /* + * Now handle the "switch" case. + * Search "ports" subnode for nodes that describe a switch port + * including a PHY xref. + * Since we have multiple candidates select one based on PHY address. + */ + ports = ofw_bus_find_child(node, "ports"); + if (ports <= 0) + return (-1); + + for (child = OF_child(ports); child != 0; child = OF_peer(child)) { + if (ofw_bus_node_status_okay(child) == 0) + continue; + + phynode = mii_fdt_get_phynode(child); + if (phynode <= 0) + continue; + + if (OF_getencprop(phynode, "reg", ®, sizeof(reg)) <= 0) + continue; + + if (reg == addr) + return (phynode); + } + return (-1); +} + mii_contype_t mii_fdt_contype_from_name(const char *name) { @@ -145,10 +183,12 @@ mii_fdt_free_config(struct mii_fdt_phy_config *cfg) mii_fdt_phy_config_t * mii_fdt_get_config(device_t phydev) { + struct mii_attach_args *ma; mii_fdt_phy_config_t *cfg; device_t miibus, macdev; pcell_t val; + ma = device_get_ivars(phydev); miibus = device_get_parent(phydev); macdev = device_get_parent(miibus); @@ -167,7 +207,8 @@ mii_fdt_get_config(device_t phydev) * If we can't find our own PHY node, there's nothing more we can fill * in, just return what we've got. */ - if ((cfg->phynode = mii_fdt_get_phynode(cfg->macnode)) == -1) + cfg->phynode = mii_fdt_lookup_phy(cfg->macnode, ma->mii_phyno); + if (cfg->phynode == -1) return (cfg); if (OF_getencprop(cfg->phynode, "max-speed", &val, sizeof(val)) > 0) From nobody Sat Nov 6 08: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 25AEA183E0BD; Sat, 6 Nov 2021 08: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 4HmVrL6lRxz3n9f; Sat, 6 Nov 2021 08:28: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 B907027DC5; Sat, 6 Nov 2021 08:28:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A68SIIe058502; Sat, 6 Nov 2021 08: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 1A68SIDs058501; Sat, 6 Nov 2021 08:28:18 GMT (envelope-from git) Date: Sat, 6 Nov 2021 08:28:18 GMT Message-Id: <202111060828.1A68SIDs058501@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: 3be6e606d787 - main - linux: Fix another amd64-specific piece of linux_ptrace.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: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3be6e606d7870a79baa7a4c5947dffd333defa79 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=3be6e606d7870a79baa7a4c5947dffd333defa79 commit 3be6e606d7870a79baa7a4c5947dffd333defa79 Author: Edward Tomasz Napierala AuthorDate: 2021-11-06 07:56:51 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-11-06 08:28:11 +0000 linux: Fix another amd64-specific piece of linux_ptrace.c This was missed in c91d0e59be1. No functional changes. Sponsored By: EPSRC --- sys/amd64/linux/linux_ptrace.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index 2ebf1c2be997..5910e4ec3d4f 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -41,8 +41,8 @@ __FBSDID("$FreeBSD$"); #include -#include -#include +#include +#include #include #include #include @@ -343,10 +343,10 @@ linux_ptrace_getsiginfo(struct thread *td, pid_t pid, l_ulong data) static int linux_ptrace_getregs(struct thread *td, pid_t pid, void *data) { - struct ptrace_lwpinfo lwpinfo; struct reg b_reg; struct linux_pt_regset l_regset; #ifdef __amd64__ + struct ptrace_lwpinfo lwpinfo; struct pcb *pcb; #endif int error; @@ -364,7 +364,6 @@ linux_ptrace_getregs(struct thread *td, pid_t pid, void *data) l_regset.fs_base = pcb->pcb_fsbase; l_regset.gs_base = pcb->pcb_gsbase; -#endif error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { @@ -385,6 +384,7 @@ linux_ptrace_getregs(struct thread *td, pid_t pid, void *data) */ l_regset.orig_rax = lwpinfo.pl_syscall_code; } +#endif error = copyout(&l_regset, (void *)data, sizeof(l_regset)); return (error); @@ -408,11 +408,11 @@ linux_ptrace_setregs(struct thread *td, pid_t pid, void *data) static int linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) { - struct ptrace_lwpinfo lwpinfo; struct reg b_reg; struct linux_pt_regset l_regset; struct iovec iov; #ifdef __amd64__ + struct ptrace_lwpinfo lwpinfo; struct pcb *pcb; #endif size_t len; @@ -437,7 +437,6 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) l_regset.fs_base = pcb->pcb_fsbase; l_regset.gs_base = pcb->pcb_gsbase; -#endif error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { @@ -459,6 +458,7 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) */ l_regset.orig_rax = lwpinfo.pl_syscall_code; } +#endif len = MIN(iov.iov_len, sizeof(l_regset)); error = copyout(&l_regset, (void *)iov.iov_base, len); From nobody Sat Nov 6 08:35: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 5F92B1841A71; Sat, 6 Nov 2021 08:35: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 4HmW0z2CQPz3qXn; Sat, 6 Nov 2021 08:35: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 27C3B199; Sat, 6 Nov 2021 08:35: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 1A68ZlL0072318; Sat, 6 Nov 2021 08:35:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A68Zl3B072317; Sat, 6 Nov 2021 08:35:47 GMT (envelope-from git) Date: Sat, 6 Nov 2021 08:35:47 GMT Message-Id: <202111060835.1A68Zl3B072317@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: 6f397bc0fbe3 - main - linux: Implement linux_to_bsd_regset() on arm64 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: 6f397bc0fbe378664bbbc7c2296043e3b9673e2a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=6f397bc0fbe378664bbbc7c2296043e3b9673e2a commit 6f397bc0fbe378664bbbc7c2296043e3b9673e2a Author: Edward Tomasz Napierala AuthorDate: 2021-11-06 08:35:04 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-11-06 08:35:04 +0000 linux: Implement linux_to_bsd_regset() on arm64 This will be used by ptrace. Sponsored By: EPSRC --- sys/arm64/linux/linux.h | 2 ++ sys/arm64/linux/linux_machdep.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/sys/arm64/linux/linux.h b/sys/arm64/linux/linux.h index 5e4bf3ae0680..05e5bd189b36 100644 --- a/sys/arm64/linux/linux.h +++ b/sys/arm64/linux/linux.h @@ -324,5 +324,7 @@ 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 /* _ARM64_LINUX_H_ */ diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c index c874f86a5f0c..0bcc05ff06de 100644 --- a/sys/arm64/linux/linux_machdep.c +++ b/sys/arm64/linux/linux_machdep.c @@ -145,3 +145,16 @@ bsd_to_linux_regset(const struct reg *b_reg, struct linux_pt_regset *l_regset) l_regset->pc = b_reg->elr; l_regset->cpsr = b_reg->spsr; } + +void +linux_to_bsd_regset(struct reg *b_reg, const struct linux_pt_regset *l_regset) +{ + + KASSERT(sizeof(l_regset->x) == sizeof(b_reg->x) + sizeof(l_ulong), + ("%s: size mismatch\n", __func__)); + + memcpy(b_reg->x, l_regset->x, sizeof(b_reg->x)); + b_reg->sp = l_regset->sp; + b_reg->elr = l_regset->pc; + b_reg->spsr = l_regset->cpsr; +} From nobody Sat Nov 6 09:43: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 1BDF5184DC85; Sat, 6 Nov 2021 09:43: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 4HmXW30GM5z4grt; Sat, 6 Nov 2021 09:43: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 DCCF3B4C; Sat, 6 Nov 2021 09:43: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 1A69hQCA067784; Sat, 6 Nov 2021 09:43:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A69hQ5G067783; Sat, 6 Nov 2021 09:43:26 GMT (envelope-from git) Date: Sat, 6 Nov 2021 09:43:26 GMT Message-Id: <202111060943.1A69hQ5G067783@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: acdfc0963946 - main - lagg: update capabilites on SIOCSIFMTU 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: acdfc09639467714e4ac2080d346251e266ea4a6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=acdfc09639467714e4ac2080d346251e266ea4a6 commit acdfc09639467714e4ac2080d346251e266ea4a6 Author: Wojciech Macek AuthorDate: 2021-11-06 09:41:43 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 09:43:08 +0000 lagg: update capabilites on SIOCSIFMTU Some NICs might have limited capabilities when Jumbo frames are used. For exampe some neta interfaces only support TX csum offload when the packet size is lower than a value specified in DT. Fix it by re-reading capabilities of children interfaces after MTU has been successfully changed. Found by: Jerome Tomczyk Reviewed by: jhb Obtained from: Semihalf Sponsored by: Stormshield Differential revision: https://reviews.freebsd.org/D32724 --- sys/net/if_lagg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 8f7900277f01..87227136e667 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -1726,7 +1726,9 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) (*lp->lp_ioctl)(lp->lp_ifp, cmd, data); } } + lagg_capabilities(sc); LAGG_XUNLOCK(sc); + VLAN_CAPABILITIES(ifp); break; default: From nobody Sat Nov 6 14:02: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 85EB21843F3F; Sat, 6 Nov 2021 14:02: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 4HmfFj3H8lz3Khb; Sat, 6 Nov 2021 14:02: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 51F05499D; Sat, 6 Nov 2021 14:02: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 1A6E2HFk023179; Sat, 6 Nov 2021 14:02:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6E2HbB023178; Sat, 6 Nov 2021 14:02:17 GMT (envelope-from git) Date: Sat, 6 Nov 2021 14:02:17 GMT Message-Id: <202111061402.1A6E2HbB023178@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 866dd6335a6c - main - unionfs: various locking fixes 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: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 866dd6335a6c74cc7615a8ad8ae2f2b2ec4ece94 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=866dd6335a6c74cc7615a8ad8ae2f2b2ec4ece94 commit 866dd6335a6c74cc7615a8ad8ae2f2b2ec4ece94 Author: Jason A. Harmening AuthorDate: 2021-10-24 17:24:18 +0000 Commit: Jason A. Harmening CommitDate: 2021-11-06 14:08:33 +0000 unionfs: various locking fixes --Clearing cached subdirectories in unionfs_noderem() should be done under the vnode interlock --When preparing to switch the vnode lock in both unionfs_node_update() and unionfs_noderem(), the incoming lock should be acquired before updating the v_vnlock field to point to it. Otherwise we effectively break the locking contract for a brief window. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D32629 --- sys/fs/unionfs/union_subr.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 326483bcc400..7bde71bb17b1 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -439,6 +439,9 @@ unionfs_noderem(struct vnode *vp, struct thread *td) struct vnode *dvp; int count; + if (lockmgr(&(vp->v_lock), LK_EXCLUSIVE, NULL) != 0) + panic("the lock for deletion is unacquirable."); + /* * Use the interlock to protect the clearing of v_data to * prevent faults in unionfs_lock(). @@ -459,6 +462,22 @@ unionfs_noderem(struct vnode *vp, struct thread *td) VOP_ADD_WRITECOUNT(lvp, -vp->v_writecount); } else if (vp->v_writecount < 0) vp->v_writecount = 0; + if (unp->un_hashtbl != NULL) { + /* + * Clear out any cached child vnodes. This should only + * be necessary during forced unmount, when the vnode may + * be reclaimed with a non-zero use count. Otherwise the + * reference held by each child should prevent reclamation. + */ + for (count = 0; count <= UNIONFSHASHMASK; count++) { + hd = unp->un_hashtbl + count; + LIST_FOREACH_SAFE(unp_t1, hd, un_hash, unp_t2) { + LIST_REMOVE(unp_t1, un_hash); + unp_t1->un_hash.le_next = NULL; + unp_t1->un_hash.le_prev = NULL; + } + } + } VI_UNLOCK(vp); if (lvp != NULLVP) @@ -469,9 +488,6 @@ unionfs_noderem(struct vnode *vp, struct thread *td) if (dvp != NULLVP) unionfs_rem_cached_vnode(unp, dvp); - if (lockmgr(vp->v_vnlock, LK_EXCLUSIVE, VI_MTX(vp)) != 0) - panic("the lock for deletion is unacquirable."); - if (lvp != NULLVP) vrele(lvp); if (uvp != NULLVP) @@ -483,14 +499,6 @@ unionfs_noderem(struct vnode *vp, struct thread *td) } if (unp->un_hashtbl != NULL) { - for (count = 0; count <= UNIONFSHASHMASK; count++) { - hd = unp->un_hashtbl + count; - LIST_FOREACH_SAFE(unp_t1, hd, un_hash, unp_t2) { - LIST_REMOVE(unp_t1, un_hash); - unp_t1->un_hash.le_next = NULL; - unp_t1->un_hash.le_prev = NULL; - } - } hashdestroy(unp->un_hashtbl, M_UNIONFSHASH, UNIONFSHASHMASK); } @@ -798,15 +806,16 @@ unionfs_node_update(struct unionfs_node *unp, struct vnode *uvp, dvp = unp->un_dvp; /* - * lock update + * Uppdate the upper vnode's lock state to match the lower vnode, + * and then switch the unionfs vnode's lock to the upper vnode. */ + lockrec = lvp->v_vnlock->lk_recurse; + for (count = 0; count < lockrec; count++) + vn_lock(uvp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY); VI_LOCK(vp); unp->un_uppervp = uvp; vp->v_vnlock = uvp->v_vnlock; VI_UNLOCK(vp); - lockrec = lvp->v_vnlock->lk_recurse; - for (count = 0; count < lockrec; count++) - vn_lock(uvp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY); /* * Re-cache the unionfs vnode against the upper vnode From nobody Sat Nov 6 14:02: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 273631843E7A; Sat, 6 Nov 2021 14:02: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 4HmfFk4qmVz3KfV; Sat, 6 Nov 2021 14:02: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 6F385499F; Sat, 6 Nov 2021 14:02:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6E2IuO023209; Sat, 6 Nov 2021 14:02:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6E2IKS023208; Sat, 6 Nov 2021 14:02:18 GMT (envelope-from git) Date: Sat, 6 Nov 2021 14:02:18 GMT Message-Id: <202111061402.1A6E2IKS023208@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 3ecefc4a61cc - main - unionfs: assorted style fixes 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: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3ecefc4a61cc3df506b38bfdf2dac843859a23a7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=3ecefc4a61cc3df506b38bfdf2dac843859a23a7 commit 3ecefc4a61cc3df506b38bfdf2dac843859a23a7 Author: Jason A. Harmening AuthorDate: 2021-10-24 20:26:49 +0000 Commit: Jason A. Harmening CommitDate: 2021-11-06 14:08:33 +0000 unionfs: assorted style fixes No functional change intended, beyond slightly different panic strings Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D32629 --- sys/fs/unionfs/union.h | 8 +++---- sys/fs/unionfs/union_subr.c | 55 +++++++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/sys/fs/unionfs/union.h b/sys/fs/unionfs/union.h index fe611dea1461..5708998c6043 100644 --- a/sys/fs/unionfs/union.h +++ b/sys/fs/unionfs/union.h @@ -137,15 +137,15 @@ int unionfs_relookup(struct vnode *, struct vnode **, struct componentname *, struct componentname *, struct thread *, char *, int, u_long); int unionfs_relookup_for_create(struct vnode *, struct componentname *, - struct thread *td); + struct thread *); int unionfs_relookup_for_delete(struct vnode *, struct componentname *, struct thread *); int unionfs_relookup_for_rename(struct vnode *, struct componentname *, - struct thread *td); + struct thread *); #ifdef DIAGNOSTIC -struct vnode *unionfs_checklowervp(struct vnode *vp, char *fil, int lno); -struct vnode *unionfs_checkuppervp(struct vnode *vp, char *fil, int lno); +struct vnode *unionfs_checklowervp(struct vnode *, char *, int); +struct vnode *unionfs_checkuppervp(struct vnode *, char *, int); #define UNIONFSVPTOLOWERVP(vp) unionfs_checklowervp((vp), __FILE__, __LINE__) #define UNIONFSVPTOUPPERVP(vp) unionfs_checkuppervp((vp), __FILE__, __LINE__) #else diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 7bde71bb17b1..449e171d52cf 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -153,8 +153,8 @@ unionfs_get_cached_vnode_locked(struct vnode *lookup, struct vnode *dvp) hd = unionfs_get_hashhead(dvp, lookup); LIST_FOREACH(unp, hd, un_hash) { - if ((unp->un_uppervp == lookup) || - (unp->un_lowervp == lookup)) { + if (unp->un_uppervp == lookup || + unp->un_lowervp == lookup) { vp = UNIONFSTOV(unp); VI_LOCK_FLAGS(vp, MTX_DUPOK); vp->v_iflag &= ~VI_OWEINACT; @@ -183,10 +183,10 @@ unionfs_get_cached_vnode(struct vnode *uvp, struct vnode *lvp, { struct vnode *vp; - KASSERT((uvp == NULLVP || uvp->v_type == VDIR), - ("unionfs_get_cached_vnode: v_type != VDIR")); - KASSERT((lvp == NULLVP || lvp->v_type == VDIR), - ("unionfs_get_cached_vnode: v_type != VDIR")); + KASSERT(uvp == NULLVP || uvp->v_type == VDIR, + ("%s: v_type != VDIR", __func__)); + KASSERT(lvp == NULLVP || lvp->v_type == VDIR, + ("%s: v_type != VDIR", __func__)); vp = NULLVP; VI_LOCK(dvp); @@ -209,10 +209,10 @@ unionfs_ins_cached_vnode(struct unionfs_node *uncp, struct unionfs_node_hashhead *hd; struct vnode *vp; - KASSERT((uncp->un_uppervp==NULLVP || uncp->un_uppervp->v_type==VDIR), - ("unionfs_ins_cached_vnode: v_type != VDIR")); - KASSERT((uncp->un_lowervp==NULLVP || uncp->un_lowervp->v_type==VDIR), - ("unionfs_ins_cached_vnode: v_type != VDIR")); + KASSERT(uncp->un_uppervp == NULLVP || uncp->un_uppervp->v_type == VDIR, + ("%s: v_type != VDIR", __func__)); + KASSERT(uncp->un_lowervp == NULLVP || uncp->un_lowervp->v_type == VDIR, + ("%s: v_type != VDIR", __func__)); vp = NULLVP; VI_LOCK(dvp); @@ -236,9 +236,9 @@ unionfs_ins_cached_vnode(struct unionfs_node *uncp, static void unionfs_rem_cached_vnode(struct unionfs_node *unp, struct vnode *dvp) { - KASSERT((unp != NULL), ("unionfs_rem_cached_vnode: null node")); - KASSERT((dvp != NULLVP), - ("unionfs_rem_cached_vnode: null parent vnode")); + KASSERT(unp != NULL, ("%s: null node", __func__)); + KASSERT(dvp != NULLVP, + ("%s: null parent vnode", __func__)); VI_LOCK(dvp); if (unp->un_hash.le_prev != NULL) { @@ -320,7 +320,7 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp, *vpp = NULLVP; if (uppervp == NULLVP && lowervp == NULLVP) - panic("unionfs_nodeget: upper and lower is null"); + panic("%s: upper and lower is null", __func__); vt = (uppervp != NULLVP ? uppervp->v_type : lowervp->v_type); @@ -440,7 +440,7 @@ unionfs_noderem(struct vnode *vp, struct thread *td) int count; if (lockmgr(&(vp->v_lock), LK_EXCLUSIVE, NULL) != 0) - panic("the lock for deletion is unacquirable."); + panic("%s: failed to acquire lock for vnode lock", __func__); /* * Use the interlock to protect the clearing of v_data to @@ -529,8 +529,8 @@ unionfs_get_node_status(struct unionfs_node *unp, struct thread *td, pid = td->td_proc->p_pid; - KASSERT(NULL != unspp, ("null pointer")); - ASSERT_VOP_ELOCKED(UNIONFSTOV(unp), "unionfs_get_node_status"); + KASSERT(NULL != unspp, ("%s: NULL status", __func__)); + ASSERT_VOP_ELOCKED(UNIONFSTOV(unp), __func__); LIST_FOREACH(unsp, &(unp->un_unshead), uns_list) { if (unsp->uns_pid == pid) { @@ -557,8 +557,8 @@ void unionfs_tryrem_node_status(struct unionfs_node *unp, struct unionfs_node_status *unsp) { - KASSERT(NULL != unsp, ("null pointer")); - ASSERT_VOP_ELOCKED(UNIONFSTOV(unp), "unionfs_get_node_status"); + KASSERT(NULL != unsp, ("%s: NULL status", __func__)); + ASSERT_VOP_ELOCKED(UNIONFSTOV(unp), __func__); if (0 < unsp->uns_lower_opencnt || 0 < unsp->uns_upper_opencnt) return; @@ -802,7 +802,7 @@ unionfs_node_update(struct unionfs_node *unp, struct vnode *uvp, vp = UNIONFSTOV(unp); lvp = unp->un_lowervp; - ASSERT_VOP_ELOCKED(lvp, "unionfs_node_update"); + ASSERT_VOP_ELOCKED(lvp, __func__); dvp = unp->un_dvp; /* @@ -991,7 +991,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, unionfs_create_uppervattr_core(ump, &lva, uvap, td); if (unp->un_path == NULL) - panic("unionfs: un_path is null"); + panic("%s: NULL un_path", __func__); nd.ni_cnd.cn_namelen = unp->un_pathlen; nd.ni_cnd.cn_pnbuf = unp->un_path; @@ -1211,7 +1211,7 @@ unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td) */ char buf[256 * 6]; - ASSERT_VOP_ELOCKED(vp, "unionfs_check_rmdir"); + ASSERT_VOP_ELOCKED(vp, __func__); eofflag = 0; uvp = UNIONFSVPTOUPPERVP(vp); @@ -1253,7 +1253,8 @@ unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td) break; if (eofflag == 0 && uio.uio_resid == sizeof(buf)) { #ifdef DIAGNOSTIC - panic("bad readdir response from lower FS."); + panic("%s: bad readdir response from lower FS", + __func__); #endif break; } @@ -1325,12 +1326,12 @@ unionfs_checkuppervp(struct vnode *vp, char *fil, int lno) #ifdef notyet if (vp->v_op != unionfs_vnodeop_p) { - printf("unionfs_checkuppervp: on non-unionfs-node.\n"); + printf("%s: on non-unionfs-node.\n", __func__); #ifdef KDB kdb_enter(KDB_WHY_UNIONFS, "unionfs_checkuppervp: on non-unionfs-node.\n"); #endif - panic("unionfs_checkuppervp"); + panic("%s", __func__); } #endif return (unp->un_uppervp); @@ -1345,12 +1346,12 @@ unionfs_checklowervp(struct vnode *vp, char *fil, int lno) #ifdef notyet if (vp->v_op != unionfs_vnodeop_p) { - printf("unionfs_checklowervp: on non-unionfs-node.\n"); + printf("%s: on non-unionfs-node.\n", __func__); #ifdef KDB kdb_enter(KDB_WHY_UNIONFS, "unionfs_checklowervp: on non-unionfs-node.\n"); #endif - panic("unionfs_checklowervp"); + panic("%s", __func__); } #endif return (unp->un_lowervp); From nobody Sat Nov 6 14:02: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 2B1691843E85; Sat, 6 Nov 2021 14:02:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmfFl5h3lz3KcK; Sat, 6 Nov 2021 14:02: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 979D2493E; Sat, 6 Nov 2021 14:02: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 1A6E2J9S023234; Sat, 6 Nov 2021 14:02:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6E2JUj023233; Sat, 6 Nov 2021 14:02:19 GMT (envelope-from git) Date: Sat, 6 Nov 2021 14:02:19 GMT Message-Id: <202111061402.1A6E2JUj023233@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 66191a76ace5 - main - unionfs: Improve locking assertions 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: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 66191a76ace56af6603b343ad2e9a003e0589d70 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=66191a76ace56af6603b343ad2e9a003e0589d70 commit 66191a76ace56af6603b343ad2e9a003e0589d70 Author: Jason A. Harmening AuthorDate: 2021-10-28 05:31:16 +0000 Commit: Jason A. Harmening CommitDate: 2021-11-06 14:08:33 +0000 unionfs: Improve locking assertions Add an assertion to unionfs_node_update() that the upper vnode is exclusively locked; we already make the same assertion for the lower vnode. Also, assert in unionfs_noderem() that the vnode lock is not recursed and acquire v_lock with LK_NOWAIT. Since v_lock is not the active lock for the vnode at this point, it should not be contended. Finally, remove VDIR assertions from unionfs_get_cached_vnode(). lvp/uvp will be referenced but not locked at this point, so v_type may concurrently change due to vgonel(). The cached unionfs node, if one exists, would only have made it into the cache if lvp/uvp were of type VDIR at the time of insertion; the corresponding VDIR assert in unionfs_ins_cached_vnode() should be safe because lvp/uvp will be locked by that time and will not be used if either is doomed. Noted by: kib Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D32629 --- sys/fs/unionfs/union_subr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 449e171d52cf..0ca209c47502 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -183,11 +183,6 @@ unionfs_get_cached_vnode(struct vnode *uvp, struct vnode *lvp, { struct vnode *vp; - KASSERT(uvp == NULLVP || uvp->v_type == VDIR, - ("%s: v_type != VDIR", __func__)); - KASSERT(lvp == NULLVP || lvp->v_type == VDIR, - ("%s: v_type != VDIR", __func__)); - vp = NULLVP; VI_LOCK(dvp); if (uvp != NULLVP) @@ -209,6 +204,8 @@ unionfs_ins_cached_vnode(struct unionfs_node *uncp, struct unionfs_node_hashhead *hd; struct vnode *vp; + ASSERT_VOP_ELOCKED(uncp->un_uppervp, __func__); + ASSERT_VOP_ELOCKED(uncp->un_lowervp, __func__); KASSERT(uncp->un_uppervp == NULLVP || uncp->un_uppervp->v_type == VDIR, ("%s: v_type != VDIR", __func__)); KASSERT(uncp->un_lowervp == NULLVP || uncp->un_lowervp->v_type == VDIR, @@ -439,7 +436,9 @@ unionfs_noderem(struct vnode *vp, struct thread *td) struct vnode *dvp; int count; - if (lockmgr(&(vp->v_lock), LK_EXCLUSIVE, NULL) != 0) + KASSERT(vp->v_vnlock->lk_recurse == 0, + ("%s: vnode %p locked recursively", __func__, vp)); + if (lockmgr(&vp->v_lock, LK_EXCLUSIVE | LK_NOWAIT, NULL) != 0) panic("%s: failed to acquire lock for vnode lock", __func__); /* @@ -803,6 +802,7 @@ unionfs_node_update(struct unionfs_node *unp, struct vnode *uvp, vp = UNIONFSTOV(unp); lvp = unp->un_lowervp; ASSERT_VOP_ELOCKED(lvp, __func__); + ASSERT_VOP_ELOCKED(uvp, __func__); dvp = unp->un_dvp; /* From nobody Sat Nov 6 14:02: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 6F4641843F58; Sat, 6 Nov 2021 14:02:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmfFn0SJWz3KHq; Sat, 6 Nov 2021 14:02:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 95E3A4657; Sat, 6 Nov 2021 14:02:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6E2KWw023370; Sat, 6 Nov 2021 14:02:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6E2KcX023358; Sat, 6 Nov 2021 14:02:20 GMT (envelope-from git) Date: Sat, 6 Nov 2021 14:02:20 GMT Message-Id: <202111061402.1A6E2KcX023358@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: fb273fe70f8b - main - unionfs: replace zero-length read check with KASSERT 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: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb273fe70f8be66bb946c5a2ea1e53042bbada48 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=fb273fe70f8be66bb946c5a2ea1e53042bbada48 commit fb273fe70f8be66bb946c5a2ea1e53042bbada48 Author: Jason A. Harmening AuthorDate: 2021-10-28 05:31:52 +0000 Commit: Jason A. Harmening CommitDate: 2021-11-06 14:08:34 +0000 unionfs: replace zero-length read check with KASSERT The lower FS VOP_READDIR() shouldn't return an empty read without setting EOF; don't try to handle this case only for non-DIAGNOSTIC builds. Noted by: kib Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D32629 --- sys/fs/unionfs/union_subr.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 0ca209c47502..8269b1e11fa4 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -1251,13 +1251,8 @@ unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td) error = VOP_READDIR(lvp, &uio, cred, &eofflag, NULL, NULL); if (error != 0) break; - if (eofflag == 0 && uio.uio_resid == sizeof(buf)) { -#ifdef DIAGNOSTIC - panic("%s: bad readdir response from lower FS", - __func__); -#endif - break; - } + KASSERT(eofflag != 0 || uio.uio_resid < sizeof(buf), + ("%s: empty read from lower FS", __func__)); edp = (struct dirent*)&buf[sizeof(buf) - uio.uio_resid]; for (dp = (struct dirent*)buf; !error && dp < edp; From nobody Sat Nov 6 14:02: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 C6A671843FE9; Sat, 6 Nov 2021 14:02: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 4HmfFq1yG0z3KlZ; Sat, 6 Nov 2021 14:02: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 C1A764659; Sat, 6 Nov 2021 14:02: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 1A6E2LTS024004; Sat, 6 Nov 2021 14:02:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6E2LbF024003; Sat, 6 Nov 2021 14:02:21 GMT (envelope-from git) Date: Sat, 6 Nov 2021 14:02:21 GMT Message-Id: <202111061402.1A6E2LbF024003@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 5f73b3338ee1 - main - unionfs: Improve vnode validation 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: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5f73b3338ee10ea843da3ae8b241320b8293a35b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=5f73b3338ee10ea843da3ae8b241320b8293a35b commit 5f73b3338ee10ea843da3ae8b241320b8293a35b Author: Jason A. Harmening AuthorDate: 2021-10-28 05:37:48 +0000 Commit: Jason A. Harmening CommitDate: 2021-11-06 14:08:34 +0000 unionfs: Improve vnode validation Instead of validating that a vnode belongs to unionfs only when the caller attempts to extract the upper or lower vnode pointers, do this validation any time the caller tries to extract a unionfs_node from the vnode private data. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D32629 --- sys/fs/unionfs/union.h | 26 ++++++++++++++++---------- sys/fs/unionfs/union_subr.c | 42 ------------------------------------------ 2 files changed, 16 insertions(+), 52 deletions(-) diff --git a/sys/fs/unionfs/union.h b/sys/fs/unionfs/union.h index 5708998c6043..eda24c1b8333 100644 --- a/sys/fs/unionfs/union.h +++ b/sys/fs/unionfs/union.h @@ -108,8 +108,23 @@ struct unionfs_node { #define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */ #define UNIONFS_OPENEXTU 0x02 /* openextattr (upper) */ +extern struct vop_vector unionfs_vnodeops; + +static inline struct unionfs_node * +unionfs_check_vnode(struct vnode *vp, const char *file __unused, + int line __unused) +{ + /* + * unionfs_lock() needs the NULL check here, as it explicitly + * handles the case in which the vnode has been vgonel()'ed. + */ + KASSERT(vp->v_op == &unionfs_vnodeops || vp->v_data == NULL, + ("%s:%d: non-unionfs vnode %p", file, line, vp)); + return ((struct unionfs_node *)vp->v_data); +} + #define MOUNTTOUNIONFSMOUNT(mp) ((struct unionfs_mount *)((mp)->mnt_data)) -#define VTOUNIONFS(vp) ((struct unionfs_node *)(vp)->v_data) +#define VTOUNIONFS(vp) unionfs_check_vnode(vp, __FILE__, __LINE__) #define UNIONFSTOV(xp) ((xp)->un_vnode) int unionfs_init(struct vfsconf *); @@ -143,17 +158,8 @@ int unionfs_relookup_for_delete(struct vnode *, struct componentname *, int unionfs_relookup_for_rename(struct vnode *, struct componentname *, struct thread *); -#ifdef DIAGNOSTIC -struct vnode *unionfs_checklowervp(struct vnode *, char *, int); -struct vnode *unionfs_checkuppervp(struct vnode *, char *, int); -#define UNIONFSVPTOLOWERVP(vp) unionfs_checklowervp((vp), __FILE__, __LINE__) -#define UNIONFSVPTOUPPERVP(vp) unionfs_checkuppervp((vp), __FILE__, __LINE__) -#else #define UNIONFSVPTOLOWERVP(vp) (VTOUNIONFS(vp)->un_lowervp) #define UNIONFSVPTOUPPERVP(vp) (VTOUNIONFS(vp)->un_uppervp) -#endif - -extern struct vop_vector unionfs_vnodeops; #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_UNIONFSNODE); diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 8269b1e11fa4..195d74583443 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -1310,45 +1310,3 @@ unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td) return (error); } -#ifdef DIAGNOSTIC - -struct vnode * -unionfs_checkuppervp(struct vnode *vp, char *fil, int lno) -{ - struct unionfs_node *unp; - - unp = VTOUNIONFS(vp); - -#ifdef notyet - if (vp->v_op != unionfs_vnodeop_p) { - printf("%s: on non-unionfs-node.\n", __func__); -#ifdef KDB - kdb_enter(KDB_WHY_UNIONFS, - "unionfs_checkuppervp: on non-unionfs-node.\n"); -#endif - panic("%s", __func__); - } -#endif - return (unp->un_uppervp); -} - -struct vnode * -unionfs_checklowervp(struct vnode *vp, char *fil, int lno) -{ - struct unionfs_node *unp; - - unp = VTOUNIONFS(vp); - -#ifdef notyet - if (vp->v_op != unionfs_vnodeop_p) { - printf("%s: on non-unionfs-node.\n", __func__); -#ifdef KDB - kdb_enter(KDB_WHY_UNIONFS, - "unionfs_checklowervp: on non-unionfs-node.\n"); -#endif - panic("%s", __func__); - } -#endif - return (unp->un_lowervp); -} -#endif From nobody Sat Nov 6 15:16: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 704FF1846505; Sat, 6 Nov 2021 15:17:05 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmgw10xmZz4X20; Sat, 6 Nov 2021 15:17:05 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 1A6FGudA038008; Sat, 6 Nov 2021 08:16:56 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 1A6FGuAe038007; Sat, 6 Nov 2021 08:16:56 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202111061516.1A6FGuAe038007@gndrsh.dnsmgr.net> Subject: Re: git: 6badb512a94d - main - Prefer CPUID leaf 1Fh for Intel CPU topology detection. In-Reply-To: <202111060454.1A64sB3B077957@gitrepo.freebsd.org> To: Alexander Motin Date: Sat, 6 Nov 2021 08:16:56 -0700 (PDT) CC: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] 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: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4Hmgw10xmZz4X20 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N > The branch main has been updated by mav: > > URL: https://cgit.FreeBSD.org/src/commit/?id=6badb512a94df667f0df1484fb288ece186305bd > > commit 6badb512a94df667f0df1484fb288ece186305bd > Author: Alexander Motin > AuthorDate: 2021-11-06 04:48:37 +0000 > Commit: Alexander Motin > CommitDate: 2021-11-06 04:53:52 +0000 > > Prefer CPUID leaf 1Fh for Intel CPU topology detection. > > Leaf 1Fh is a prefered extended version of 0Bh. It is supported by > new Lader Lake CPUs, though does not report anything new so far. > > MFC after: 2 weeks > --- > sys/x86/x86/mp_x86.c | 25 +++++++++++++++++-------- > 1 file changed, 17 insertions(+), 8 deletions(-) > > diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c > index 7a72c501ff25..3b0e25172d0d 100644 > --- a/sys/x86/x86/mp_x86.c > +++ b/sys/x86/x86/mp_x86.c > @@ -380,7 +380,7 @@ topo_probe_intel_0x4(void) > > /* > * Determine topology of processing units for Intel CPUs > - * using CPUID Leaf 11, if supported. > + * using CPUID Leaf 1Fh or 0Bh, if supported. > * See: > * - Intel 64 Architecture Processor Topology Enumeration > * - Intel 64 and IA-32 ArchitecturesSoftware Developer?s Manual, > @@ -390,13 +390,23 @@ topo_probe_intel_0x4(void) > static void > topo_probe_intel_0xb(void) > { > - u_int p[4]; > + u_int leaf; > + u_int p[4] = { 0 }; > int bits; > int type; > int i; > > - /* Fall back if CPU leaf 11 doesn't really exist. */ > - cpuid_count(0x0b, 0, p); > + /* Prefer leaf 1Fh (V2 Extended Topology Enumeration). */ > + if (cpu_high >= 0x1f) { > + leaf = 0x1f; > + cpuid_count(leaf, 0, p); > + } > + /* Fall back to leaf 0Bh (Extended Topology Enumeration). */ > + if (p[1] == 0) { > + leaf = 0x0b; > + cpuid_count(leaf, 0, p); > + } > + /* Fall back to leaf 04h (Deterministic Cache Parameters). */ > if (p[1] == 0) { > topo_probe_intel_0x4(); > return; > @@ -404,7 +414,7 @@ topo_probe_intel_0xb(void) > > /* We only support three levels for now. */ > for (i = 0; ; i++) { > - cpuid_count(0x0b, i, p); > + cpuid_count(leaf, i, p); > > bits = p[0] & 0x1f; > type = (p[2] >> 8) & 0xff; > @@ -412,13 +422,12 @@ topo_probe_intel_0xb(void) > if (type == 0) > break; > > - /* TODO: check for duplicate (re-)assignment */ > if (type == CPUID_TYPE_SMT) > core_id_shift = bits; > else if (type == CPUID_TYPE_CORE) > pkg_id_shift = bits; > - else > - printf("unknown CPU level type %d\n", type); Why do we loose this potential diagnostic message, and isnt its trailing \n needed to close the probe message? It would need to be come an else of the if (bootverbose) if I am reading things correctly. > + else if (bootverbose) > + printf("Topology level type %d shift: %d\n", type, bits); > } > > if (pkg_id_shift < core_id_shift) { > -- Rod Grimes rgrimes@freebsd.org From nobody Sat Nov 6 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 6EB7317DCE29; Sat, 6 Nov 2021 15:45:38 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmhXy2VGGz4gqw; Sat, 6 Nov 2021 15:45:38 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: by mail-qk1-x72e.google.com with SMTP id c20so1519634qko.10; Sat, 06 Nov 2021 08:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mRGa7237yGXvKFxbS0Vk5p++Rip/FNAm6c5lyxezwPs=; b=F2pGVDSHfoicWYbWuiWc/T0o6VfQBz1svc4M5wMKIeBFAGFY+srnxY+KOgq3uD7de1 ojY9VeV22Tfp+NN2vHq7FXu2FS2aKg2giwneBTVLCzwDamLXUtI6r6zXpQMYrSt1CwR9 4Sd6dX8LH7G6MWdCGeSS5dfdZUXtsvU89kwpzzne9CeZDPZDJl4MXNpBViG4UAKcLEcj OePO+Z8ShdFpJRevhCHyHbZrRY4q7tNdikA+VF5KN5LT1NjfjVTDqo8QTAjbIfDEvC3T LrM29/V9pAz8OvUmFh4KnFMfuFLPFB5ivL9HQYGDe4FDgpIFHbfP80sxX7ZAHvB6nZbS nizA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mRGa7237yGXvKFxbS0Vk5p++Rip/FNAm6c5lyxezwPs=; b=E2xxADtTXUL10J4D1pOp4eldgzl+rnjcq96HaPluHFRnIUGBT1k43SM0EQQT9BMTTf Miltj6EqKkMlk/4KWNFM5udMGKZlbgm4JHRpP7OK7ESn6y4/0xRaGOPwWxNOjEMVhmnd pFePpb+TVtcxNVHhN5nVi6EFT5nJJIP2JLDnd01nwjXmskv5uogWRJpyjGdbdI74QrKK x8Kf8NyIYNDkQxUkbsblLwFnC+1fobXv88KGorrMZ99oquDHU8odYV8f2jb7hqAOm2Rp g7fjBm2fYGRyNtFqvarUmMxTBtG1enVFG5JUYxh34Js3VK2/Iu8uXlPwfKZzG9D7wk9i BzDA== X-Gm-Message-State: AOAM533ivI4U7AQGit9ahYzB87CpgmNCt9AXeA58/6phljgcFLP5qRZr VSHelpd+XbOBPB6lU76tMqm9ajVvjcM= X-Google-Smtp-Source: ABdhPJy7gxh4V39+dDVOu58JYPWrnSGpV3eOvq+LnffQ9/hfhkOinhuFlSwVFFAs9XHjduK9BGoiaA== X-Received: by 2002:a05:620a:4550:: with SMTP id u16mr32559019qkp.112.1636213537576; Sat, 06 Nov 2021 08:45:37 -0700 (PDT) Received: from mavoffice.ixsystems.com ([38.32.73.2]) by smtp.gmail.com with ESMTPSA id v18sm1921868qta.56.2021.11.06.08.45.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Nov 2021 08:45:36 -0700 (PDT) Sender: Alexander Motin Subject: Re: git: 6badb512a94d - main - Prefer CPUID leaf 1Fh for Intel CPU topology detection. To: rgrimes@freebsd.org Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202111061516.1A6FGuAe038007@gndrsh.dnsmgr.net> From: Alexander Motin Message-ID: <2eeb65b1-4f75-9c92-f885-0a9bb2b6cf99@FreeBSD.org> Date: Sat, 6 Nov 2021 11:45:36 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.13.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: <202111061516.1A6FGuAe038007@gndrsh.dnsmgr.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4HmhXy2VGGz4gqw X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N Hi Rodney, On 06.11.2021 11:16, Rodney W. Grimes wrote: >> /* We only support three levels for now. */ >> for (i = 0; ; i++) { >> - cpuid_count(0x0b, i, p); >> + cpuid_count(leaf, i, p); >> >> bits = p[0] & 0x1f; >> type = (p[2] >> 8) & 0xff; >> @@ -412,13 +422,12 @@ topo_probe_intel_0xb(void) >> if (type == 0) >> break; >> >> - /* TODO: check for duplicate (re-)assignment */ >> if (type == CPUID_TYPE_SMT) >> core_id_shift = bits; >> else if (type == CPUID_TYPE_CORE) >> pkg_id_shift = bits; >> - else >> - printf("unknown CPU level type %d\n", type); > > Why do we loose this potential diagnostic message, Because it is not an error and not important for average user. New specifications list addition of such levels as Module, Tile and Die, meaning of which and OS use is unclear at this point. I've actually made the new message more informative under the bootverbose to help later developers when the time of those types come. > and isnt its trailing \n needed to close the probe message? > It would need to be come an else of the if (bootverbose) if > I am reading things correctly. It does not close any probe message, it is a full line, so there is nothing for "else". >> + else if (bootverbose) >> + printf("Topology level type %d shift: %d\n", type, bits); >> } >> >> if (pkg_id_shift < core_id_shift) { >> > -- Alexander Motin From nobody Sat Nov 6 16:46: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 F3FD7184F244; Sat, 6 Nov 2021 16:46: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 4Hmjty6Z7Hz3JMl; Sat, 6 Nov 2021 16:46: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 C252B6BC5; Sat, 6 Nov 2021 16:46:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6GkIoH036878; Sat, 6 Nov 2021 16:46:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6GkIj4036877; Sat, 6 Nov 2021 16:46:18 GMT (envelope-from git) Date: Sat, 6 Nov 2021 16:46:18 GMT Message-Id: <202111061646.1A6GkIj4036877@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: 0dedcdaa1a02 - main - Revert "ossl: Add support for ETA mode" 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: 0dedcdaa1a023d46c8951f03cd2f9df7ae025675 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=0dedcdaa1a023d46c8951f03cd2f9df7ae025675 commit 0dedcdaa1a023d46c8951f03cd2f9df7ae025675 Author: Wojciech Macek AuthorDate: 2021-11-06 16:45:50 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 16:45:50 +0000 Revert "ossl: Add support for ETA mode" This reverts commit 048a71b46e816de8fb95b553a8ad0e98c0d51e12. --- sys/crypto/openssl/ossl.c | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index f41ff09c371d..f46b5a966bb1 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -172,13 +172,6 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) if (ossl_lookup_cipher(csp) == NULL) return (EINVAL); break; - case CSP_MODE_ETA: - if (!sc->has_aes || - csp->csp_cipher_alg == CRYPTO_CHACHA20 || - ossl_lookup_hash(csp) == NULL || - ossl_lookup_cipher(csp) == NULL) - return (EINVAL); - break; case CSP_MODE_AEAD: switch (csp->csp_cipher_alg) { case CRYPTO_CHACHA20_POLY1305: @@ -275,10 +268,6 @@ ossl_newsession(device_t dev, crypto_session_t cses, case CSP_MODE_CIPHER: error = ossl_newsession_cipher(s, csp); break; - case CSP_MODE_ETA: - ossl_newsession_hash(s, csp); - error = ossl_newsession_cipher(s, csp); - break; } return (error); @@ -352,25 +341,6 @@ out: return (error); } -static int -ossl_process_eta(struct ossl_session *s, struct cryptop *crp, - const struct crypto_session_params *csp) -{ - int error; - - if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { - error = s->cipher.cipher->process(&s->cipher, crp, csp); - if (error == 0) - error = ossl_process_hash(s, crp, csp); - } else { - error = ossl_process_hash(s, crp, csp); - if (error == 0) - error = s->cipher.cipher->process(&s->cipher, crp, csp); - } - - return (error); -} - static int ossl_process(device_t dev, struct cryptop *crp, int hint) { @@ -396,9 +366,6 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) case CSP_MODE_CIPHER: error = s->cipher.cipher->process(&s->cipher, crp, csp); break; - case CSP_MODE_ETA: - error = ossl_process_eta(s, crp, csp); - break; case CSP_MODE_AEAD: if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) error = ossl_chacha20_poly1305_encrypt(crp, csp); From nobody Sat Nov 6 16:46: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 48279184F29F; Sat, 6 Nov 2021 16:46: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 4Hmjv00Fw4z3JCL; Sat, 6 Nov 2021 16:46: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 DE1906A3E; Sat, 6 Nov 2021 16:46: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 1A6GkJkq036908; Sat, 6 Nov 2021 16:46:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6GkJtc036907; Sat, 6 Nov 2021 16:46:19 GMT (envelope-from git) Date: Sat, 6 Nov 2021 16:46:19 GMT Message-Id: <202111061646.1A6GkJtc036907@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: 200bc58953f0 - main - Revert "ossl: Add support for AES-CBC cipher" 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: 200bc58953f0f5403d5ae57691f34500afe4c614 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=200bc58953f0f5403d5ae57691f34500afe4c614 commit 200bc58953f0f5403d5ae57691f34500afe4c614 Author: Wojciech Macek AuthorDate: 2021-11-06 16:46:01 +0000 Commit: Wojciech Macek CommitDate: 2021-11-06 16:46:01 +0000 Revert "ossl: Add support for AES-CBC cipher" This reverts commit 849faf4e0ba9a8b8f24ff34da93a0fd46c14eda9. --- share/man/man4/ossl.4 | 4 +- sys/conf/files | 1 - sys/conf/files.amd64 | 1 - sys/conf/files.arm64 | 4 - sys/conf/files.i386 | 1 - sys/crypto/openssl/ossl.c | 94 ++++++----------------- sys/crypto/openssl/ossl.h | 36 +-------- sys/crypto/openssl/ossl_aarch64.c | 23 +----- sys/crypto/openssl/ossl_aarch64.h | 31 -------- sys/crypto/openssl/ossl_aes.c | 153 ------------------------------------- sys/crypto/openssl/ossl_chacha20.c | 18 +---- sys/crypto/openssl/ossl_cipher.h | 53 ------------- sys/crypto/openssl/ossl_x86.c | 15 +--- sys/crypto/openssl/ossl_x86.h | 20 ----- sys/modules/ossl/Makefile | 14 ---- tests/sys/opencrypto/cryptotest.py | 2 +- 16 files changed, 34 insertions(+), 436 deletions(-) diff --git a/share/man/man4/ossl.4 b/share/man/man4/ossl.4 index 039ce301ac29..5929e46e9fe3 100644 --- a/share/man/man4/ossl.4 +++ b/share/man/man4/ossl.4 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 24, 2021 +.Dd March 3, 2021 .Dt OSSL 4 .Os .Sh NAME @@ -74,8 +74,6 @@ driver includes support for the following algorithms: .Pp .Bl -bullet -compact .It -AES-CBC -.It ChaCha20 .It ChaCha20-Poly1305 (RFC 8439) diff --git a/sys/conf/files b/sys/conf/files index 9743341f6e45..f2663fd1c6c0 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -716,7 +716,6 @@ crypto/chacha20/chacha-sw.c optional crypto | ipsec | ipsec_support crypto/des/des_ecb.c optional netsmb crypto/des/des_setkey.c optional netsmb crypto/openssl/ossl.c optional ossl -crypto/openssl/ossl_aes.c optional ossl crypto/openssl/ossl_chacha20.c optional ossl crypto/openssl/ossl_poly1305.c optional ossl crypto/openssl/ossl_sha1.c optional ossl diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 6b51c1a5a55d..37ff6404cdba 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -88,7 +88,6 @@ cddl/dev/dtrace/amd64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/amd64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_amd64.S optional aesni crypto/des/des_enc.c optional netsmb -crypto/openssl/amd64/aesni-x86_64.S optional ossl crypto/openssl/amd64/chacha-x86_64.S optional ossl crypto/openssl/amd64/poly1305-x86_64.S optional ossl crypto/openssl/amd64/sha1-x86_64.S optional ossl diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index e718e9b93847..a0bdaeb475d6 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -128,8 +128,6 @@ ghashv8-armx.o optional armv8crypto \ crypto/des/des_enc.c optional netsmb crypto/openssl/ossl_aarch64.c optional ossl -crypto/openssl/aarch64/aesv8-armx.S optional ossl \ - compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} -march=armv8-a+crypto ${.IMPSRC}" crypto/openssl/aarch64/chacha-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/poly1305-armv8.S optional ossl \ @@ -140,8 +138,6 @@ crypto/openssl/aarch64/sha256-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" crypto/openssl/aarch64/sha512-armv8.S optional ossl \ compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" -crypto/openssl/aarch64/vpaes-armv8.S optional ossl \ - compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC}" dev/acpica/acpi_bus_if.m optional acpi dev/acpica/acpi_if.m optional acpi diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 0c681d6a84a0..e83bcd5a3492 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -15,7 +15,6 @@ cddl/dev/dtrace/i386/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/i386/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_i386.S optional aesni crypto/des/arch/i386/des_enc.S optional netsmb -crypto/openssl/i386/aesni-x86.S optional ossl crypto/openssl/i386/chacha-x86.S optional ossl crypto/openssl/i386/poly1305-x86.S optional ossl crypto/openssl/i386/sha1-586.S optional ossl diff --git a/sys/crypto/openssl/ossl.c b/sys/crypto/openssl/ossl.c index f46b5a966bb1..ad9b93dd960d 100644 --- a/sys/crypto/openssl/ossl.c +++ b/sys/crypto/openssl/ossl.c @@ -49,10 +49,24 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include "cryptodev_if.h" +struct ossl_softc { + int32_t sc_cid; +}; + +struct ossl_session_hash { + struct ossl_hash_context ictx; + struct ossl_hash_context octx; + struct auth_hash *axf; + u_int mlen; +}; + +struct ossl_session { + struct ossl_session_hash hash; +}; + static MALLOC_DEFINE(M_OSSL, "ossl", "OpenSSL crypto"); static void @@ -78,7 +92,7 @@ ossl_attach(device_t dev) sc = device_get_softc(dev); - ossl_cpuid(sc); + ossl_cpuid(); sc->sc_cid = crypto_get_driverid(dev, sizeof(struct ossl_session), CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_SYNC | CRYPTOCAP_F_ACCEL_SOFTWARE); @@ -129,34 +143,9 @@ ossl_lookup_hash(const struct crypto_session_params *csp) } } -static struct ossl_cipher* -ossl_lookup_cipher(const struct crypto_session_params *csp) -{ - - switch (csp->csp_cipher_alg) { - case CRYPTO_AES_CBC: - switch (csp->csp_cipher_klen * 8) { - case 128: - case 192: - case 256: - break; - default: - return (NULL); - } - return (&ossl_cipher_aes_cbc); - case CRYPTO_CHACHA20: - if (csp->csp_cipher_klen != CHACHA_KEY_SIZE) - return (NULL); - return (&ossl_cipher_chacha20); - default: - return (NULL); - } -} - static int ossl_probesession(device_t dev, const struct crypto_session_params *csp) { - struct ossl_softc *sc = device_get_softc(dev); if ((csp->csp_flags & ~(CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD)) != 0) @@ -167,10 +156,14 @@ ossl_probesession(device_t dev, const struct crypto_session_params *csp) return (EINVAL); break; case CSP_MODE_CIPHER: - if (csp->csp_cipher_alg != CRYPTO_CHACHA20 && !sc->has_aes) - return (EINVAL); - if (ossl_lookup_cipher(csp) == NULL) + switch (csp->csp_cipher_alg) { + case CRYPTO_CHACHA20: + if (csp->csp_cipher_klen != CHACHA_KEY_SIZE) + return (EINVAL); + break; + default: return (EINVAL); + } break; case CSP_MODE_AEAD: switch (csp->csp_cipher_alg) { @@ -220,57 +213,20 @@ ossl_newsession_hash(struct ossl_session *s, } } -static int -ossl_newsession_cipher(struct ossl_session *s, - const struct crypto_session_params *csp) -{ - struct ossl_cipher *cipher; - int error = 0; - - cipher = ossl_lookup_cipher(csp); - if (cipher == NULL) - return (EINVAL); - - s->cipher.cipher = cipher; - - if (csp->csp_cipher_key == NULL) - return (0); - - fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); - if (cipher->set_encrypt_key != NULL) { - error = cipher->set_encrypt_key(csp->csp_cipher_key, - 8 * csp->csp_cipher_klen, &s->cipher.enc_ctx); - if (error != 0) { - fpu_kern_leave(curthread, NULL); - return (error); - } - } - if (cipher->set_decrypt_key != NULL) - error = cipher->set_decrypt_key(csp->csp_cipher_key, - 8 * csp->csp_cipher_klen, &s->cipher.dec_ctx); - fpu_kern_leave(curthread, NULL); - - return (error); -} - static int ossl_newsession(device_t dev, crypto_session_t cses, const struct crypto_session_params *csp) { struct ossl_session *s; - int error = 0; s = crypto_get_driver_session(cses); switch (csp->csp_mode) { case CSP_MODE_DIGEST: ossl_newsession_hash(s, csp); break; - case CSP_MODE_CIPHER: - error = ossl_newsession_cipher(s, csp); - break; } - return (error); + return (0); } static int @@ -364,7 +320,7 @@ ossl_process(device_t dev, struct cryptop *crp, int hint) error = ossl_process_hash(s, crp, csp); break; case CSP_MODE_CIPHER: - error = s->cipher.cipher->process(&s->cipher, crp, csp); + error = ossl_chacha20(crp, csp); break; case CSP_MODE_AEAD: if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) diff --git a/sys/crypto/openssl/ossl.h b/sys/crypto/openssl/ossl.h index 4f5353818add..11793dca037a 100644 --- a/sys/crypto/openssl/ossl.h +++ b/sys/crypto/openssl/ossl.h @@ -36,47 +36,20 @@ struct cryptop; struct crypto_session_params; -struct ossl_softc; -struct ossl_session; +int ossl_chacha20(struct cryptop *crp, + const struct crypto_session_params *csp); int ossl_chacha20_poly1305_decrypt(struct cryptop *crp, const struct crypto_session_params *csp); int ossl_chacha20_poly1305_encrypt(struct cryptop *crp, const struct crypto_session_params *csp); -void ossl_cpuid(struct ossl_softc *sc); - -struct ossl_softc { - int32_t sc_cid; - bool has_aes; -}; +void ossl_cpuid(void); /* Needs to be big enough to hold any hash context. */ struct ossl_hash_context { uint32_t dummy[61]; } __aligned(32); -struct ossl_cipher_context { - uint32_t dummy[61]; -} __aligned(32); - -struct ossl_session_hash { - struct ossl_hash_context ictx; - struct ossl_hash_context octx; - struct auth_hash *axf; - u_int mlen; -}; - -struct ossl_session_cipher { - struct ossl_cipher_context dec_ctx; - struct ossl_cipher_context enc_ctx; - struct ossl_cipher *cipher; -}; - -struct ossl_session { - struct ossl_session_cipher cipher; - struct ossl_session_hash hash; -}; - extern struct auth_hash ossl_hash_poly1305; extern struct auth_hash ossl_hash_sha1; extern struct auth_hash ossl_hash_sha224; @@ -84,7 +57,4 @@ extern struct auth_hash ossl_hash_sha256; extern struct auth_hash ossl_hash_sha384; extern struct auth_hash ossl_hash_sha512; -extern struct ossl_cipher ossl_cipher_aes_cbc; -extern struct ossl_cipher ossl_cipher_chacha20; - #endif /* !__OSSL_H__ */ diff --git a/sys/crypto/openssl/ossl_aarch64.c b/sys/crypto/openssl/ossl_aarch64.c index e4b87a75a403..2a45a848808a 100644 --- a/sys/crypto/openssl/ossl_aarch64.c +++ b/sys/crypto/openssl/ossl_aarch64.c @@ -36,7 +36,6 @@ #include #include -#include #include /* @@ -44,14 +43,8 @@ */ unsigned int OPENSSL_armcap_P; -ossl_cipher_setkey_t aes_v8_set_encrypt_key; -ossl_cipher_setkey_t aes_v8_set_decrypt_key; - -ossl_cipher_setkey_t vpaes_set_encrypt_key; -ossl_cipher_setkey_t vpaes_set_decrypt_key; - void -ossl_cpuid(struct ossl_softc *sc) +ossl_cpuid(void) { /* SHA features */ if ((elf_hwcap & HWCAP_SHA1) != 0) @@ -66,18 +59,4 @@ ossl_cpuid(struct ossl_softc *sc) OPENSSL_armcap_P |= ARMV8_AES; if ((elf_hwcap & HWCAP_PMULL) != 0) OPENSSL_armcap_P |= ARMV8_PMULL; - - if ((OPENSSL_armcap_P & ARMV8_AES) == 0 && - (OPENSSL_armcap_P & ARMV7_NEON) == 0) { - sc->has_aes = false; - return; - } - sc->has_aes = true; - if (OPENSSL_armcap_P & ARMV8_AES) { - ossl_cipher_aes_cbc.set_encrypt_key = aes_v8_set_encrypt_key; - ossl_cipher_aes_cbc.set_decrypt_key = aes_v8_set_decrypt_key; - } else { - ossl_cipher_aes_cbc.set_encrypt_key = vpaes_set_encrypt_key; - ossl_cipher_aes_cbc.set_decrypt_key = vpaes_set_decrypt_key; - } } diff --git a/sys/crypto/openssl/ossl_aarch64.h b/sys/crypto/openssl/ossl_aarch64.h deleted file mode 100644 index f933f862d009..000000000000 --- a/sys/crypto/openssl/ossl_aarch64.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef __OSSL_AARCH64__ -#define __OSSL_AARCH64__ - -#include -#include -#include - -/* aesv8-armx.S */ -ossl_cipher_encrypt_t aes_v8_cbc_encrypt; -/* vpaes-armv8.S */ -ossl_cipher_encrypt_t vpaes_cbc_encrypt; - -static void -AES_CBC_ENCRYPT(const unsigned char *in, unsigned char *out, - size_t length, const void *key, unsigned char *iv, int encrypt) -{ - if (OPENSSL_armcap_P & ARMV8_AES) - aes_v8_cbc_encrypt(in, out, length, key, iv, encrypt); - else - vpaes_cbc_encrypt(in, out, length, key, iv, encrypt); -} -#endif diff --git a/sys/crypto/openssl/ossl_aes.c b/sys/crypto/openssl/ossl_aes.c deleted file mode 100644 index 93f16e7dce55..000000000000 --- a/sys/crypto/openssl/ossl_aes.c +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2021 Stormshield. - * 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 - -#if defined(__amd64__) || defined(__i386__) -#include -#elif defined (__aarch64__) -#include -#endif - -static ossl_cipher_process_t ossl_aes_cbc; - -struct ossl_cipher ossl_cipher_aes_cbc = { - .type = CRYPTO_AES_CBC, - .blocksize = AES_BLOCK_LEN, - .ivsize = AES_BLOCK_LEN, - - /* Filled during initialization based on CPU caps. */ - .set_encrypt_key = NULL, - .set_decrypt_key = NULL, - .process = ossl_aes_cbc -}; - -static int -ossl_aes_cbc(struct ossl_session_cipher *s, struct cryptop *crp, - const struct crypto_session_params *csp) -{ - struct crypto_buffer_cursor cc_in, cc_out; - unsigned char block[EALG_MAX_BLOCK_LEN]; - unsigned char iv[EALG_MAX_BLOCK_LEN]; - const unsigned char *in, *inseg; - unsigned char *out, *outseg; - size_t plen, seglen, inlen, outlen; - struct ossl_cipher_context key; - struct ossl_cipher *cipher; - int blocklen, error; - bool encrypt; - - cipher = s->cipher; - encrypt = CRYPTO_OP_IS_ENCRYPT(crp->crp_op); - plen = crp->crp_payload_length; - blocklen = cipher->blocksize; - - if (plen % blocklen) - return (EINVAL); - - if (crp->crp_cipher_key != NULL) { - if (encrypt) - error = cipher->set_encrypt_key(crp->crp_cipher_key, - 8 * csp->csp_cipher_klen, &key); - else - error = cipher->set_decrypt_key(crp->crp_cipher_key, - 8 * csp->csp_cipher_klen, &key); - if (error) - return (error); - } else { - if (encrypt) - key = s->enc_ctx; - else - key = s->dec_ctx; - } - - crypto_read_iv(crp, iv); - - /* Derived from ossl_chacha20.c */ - crypto_cursor_init(&cc_in, &crp->crp_buf); - crypto_cursor_advance(&cc_in, crp->crp_payload_start); - inseg = crypto_cursor_segment(&cc_in, &inlen); - if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { - crypto_cursor_init(&cc_out, &crp->crp_obuf); - crypto_cursor_advance(&cc_out, crp->crp_payload_output_start); - } else { - cc_out = cc_in; - } - outseg = crypto_cursor_segment(&cc_out, &outlen); - - while (plen >= blocklen) { - if (inlen < blocklen) { - crypto_cursor_copydata(&cc_in, blocklen, block); - in = block; - inlen = blocklen; - } else { - in = inseg; - } - if (outlen < blocklen) { - out = block; - outlen = blocklen; - } else { - out = outseg; - } - - /* Figure out how many blocks we can encrypt/decrypt at once. */ - seglen = rounddown(MIN(plen, MIN(inlen, outlen)), blocklen); - - AES_CBC_ENCRYPT(in, out, seglen, &key, iv, encrypt); - - if (out == block) { - crypto_cursor_copyback(&cc_out, blocklen, block); - outseg = crypto_cursor_segment(&cc_out, &outlen); - } else { - crypto_cursor_advance(&cc_out, seglen); - outseg += seglen; - outlen -= seglen; - } - if (in == block) { - inseg = crypto_cursor_segment(&cc_in, &inlen); - } else { - crypto_cursor_advance(&cc_in, seglen); - inseg += seglen; - inlen -= seglen; - } - plen -= seglen; - } - - explicit_bzero(block, sizeof(block)); - explicit_bzero(iv, sizeof(iv)); - explicit_bzero(&key, sizeof(key)); - return (0); -} diff --git a/sys/crypto/openssl/ossl_chacha20.c b/sys/crypto/openssl/ossl_chacha20.c index c21a28470a26..aa125121e8b4 100644 --- a/sys/crypto/openssl/ossl_chacha20.c +++ b/sys/crypto/openssl/ossl_chacha20.c @@ -37,24 +37,10 @@ #include #include -#include #include -static ossl_cipher_process_t ossl_chacha20; - -struct ossl_cipher ossl_cipher_chacha20 = { - .type = CRYPTO_CHACHA20, - .blocksize = CHACHA_BLK_SIZE, - .ivsize = CHACHA_CTR_SIZE, - - .set_encrypt_key = NULL, - .set_decrypt_key = NULL, - .process = ossl_chacha20 -}; - -static int -ossl_chacha20(struct ossl_session_cipher *s, struct cryptop *crp, - const struct crypto_session_params *csp) +int +ossl_chacha20(struct cryptop *crp, const struct crypto_session_params *csp) { _Alignas(8) unsigned int key[CHACHA_KEY_SIZE / 4]; unsigned int counter[CHACHA_CTR_SIZE / 4]; diff --git a/sys/crypto/openssl/ossl_cipher.h b/sys/crypto/openssl/ossl_cipher.h deleted file mode 100644 index d9e6ec29aafc..000000000000 --- a/sys/crypto/openssl/ossl_cipher.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2021 Stormshield. - * 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. - */ - -#ifndef __OSSL_CIPHER_H__ -#define __OSSL_CIPHER_H__ - -struct ossl_session_cipher; -struct cryptop; -struct crypto_session_params; - -typedef int (ossl_cipher_setkey_t)(const unsigned char*, int, void*); -typedef int (ossl_cipher_process_t)(struct ossl_session_cipher*, struct cryptop*, - const struct crypto_session_params*); -typedef void (ossl_cipher_encrypt_t)(const unsigned char*, unsigned char*, size_t, - const void*, unsigned char*, int); - -ossl_cipher_encrypt_t ossl_aes_cbc_encrypt; - -struct ossl_cipher { - int type; - uint16_t blocksize; - uint16_t ivsize; - - ossl_cipher_setkey_t *set_encrypt_key; - ossl_cipher_setkey_t *set_decrypt_key; - ossl_cipher_process_t *process; -}; - -#endif diff --git a/sys/crypto/openssl/ossl_x86.c b/sys/crypto/openssl/ossl_x86.c index a1e9a995948b..60ff6fa0c759 100644 --- a/sys/crypto/openssl/ossl_x86.c +++ b/sys/crypto/openssl/ossl_x86.c @@ -39,7 +39,6 @@ #include #include -#include /* * See OPENSSL_ia32cap(3). @@ -50,13 +49,9 @@ * [3] = 0 */ unsigned int OPENSSL_ia32cap_P[4]; -#define AESNI_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32))) - -ossl_cipher_setkey_t aesni_set_encrypt_key; -ossl_cipher_setkey_t aesni_set_decrypt_key; void -ossl_cpuid(struct ossl_softc *sc) +ossl_cpuid(void) { uint64_t xcr0; u_int regs[4]; @@ -117,12 +112,4 @@ ossl_cpuid(struct ossl_softc *sc) OPENSSL_ia32cap_P[1] &= ~(CPUID2_AVX | AMDID2_XOP | CPUID2_FMA); OPENSSL_ia32cap_P[2] &= ~CPUID_STDEXT_AVX2; } - - if (!AESNI_CAPABLE) { - sc->has_aes = false; - return; - } - sc->has_aes = true; - ossl_cipher_aes_cbc.set_encrypt_key = aesni_set_encrypt_key; - ossl_cipher_aes_cbc.set_decrypt_key = aesni_set_decrypt_key; } diff --git a/sys/crypto/openssl/ossl_x86.h b/sys/crypto/openssl/ossl_x86.h deleted file mode 100644 index 12bd5a4eaddb..000000000000 --- a/sys/crypto/openssl/ossl_x86.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef __OSSL_X86__ -#define __OSSL_X86__ - -#include -#include - -/* aesni-x86_64.S, aesni-x86.S */ -ossl_cipher_encrypt_t aesni_cbc_encrypt; - -#define AES_CBC_ENCRYPT aesni_cbc_encrypt -#endif diff --git a/sys/modules/ossl/Makefile b/sys/modules/ossl/Makefile index 765e70a03edd..dfd82dcf6e1f 100644 --- a/sys/modules/ossl/Makefile +++ b/sys/modules/ossl/Makefile @@ -4,12 +4,10 @@ .PATH: ${SRCTOP}/sys/crypto/openssl/${MACHINE_CPUARCH} KMOD= ossl -OBJS+= ${OBJS.${MACHINE_CPUARCH}} SRCS= bus_if.h \ cryptodev_if.h \ device_if.h \ ossl.c \ - ossl_aes.c \ ossl_chacha20.c \ ossl_poly1305.c \ ossl_sha1.c \ @@ -23,11 +21,9 @@ SRCS.aarch64= \ sha1-armv8.S \ sha256-armv8.S \ sha512-armv8.S \ - vpaes-armv8.S \ ossl_aarch64.c SRCS.amd64= \ - aesni-x86_64.S \ chacha-x86_64.S \ poly1305-x86_64.S \ sha1-x86_64.S \ @@ -36,7 +32,6 @@ SRCS.amd64= \ ossl_x86.c SRCS.i386= \ - aesni-x86.S \ chacha-x86.S \ poly1305-x86.S \ sha1-586.S \ @@ -50,13 +45,4 @@ ${SRCS.aarch64:M*.S:S/S/o/}: ${.TARGET:R}.S ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC} ${CTFCONVERT_CMD} -# Based on modules/armv8crypto/Makefile. -# Clang doesn't recognize "aes*" instructions without -march set. -aesv8-armx.o: aesv8-armx.S - ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} \ - -march=armv8-a+crypto ${.IMPSRC} - ${CTFCONVERT_CMD} - -OBJS.aarch64= aesv8-armx.o - .include diff --git a/tests/sys/opencrypto/cryptotest.py b/tests/sys/opencrypto/cryptotest.py index 447a7854b246..74ce62cee33d 100644 --- a/tests/sys/opencrypto/cryptotest.py +++ b/tests/sys/opencrypto/cryptotest.py @@ -50,7 +50,7 @@ def katg(base, glob): raise unittest.SkipTest("Missing %s test vectors" % (base)) return iglob(os.path.join(katdir, base, glob)) -aesmodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'ossl0', 'safexcel0', 'qat0' ] +aesmodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'safexcel0', 'qat0' ] shamodules = [ 'cryptosoft0', 'aesni0', 'armv8crypto0', 'ccr0', 'ccp0', 'ossl0', 'safexcel0', 'qat0' ] def GenTestCase(cname): From nobody Sat Nov 6 16:59: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 B3E3718376E8 for ; Sat, 6 Nov 2021 16:59:54 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) (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 4HmkBf4BFFz3Ngq for ; Sat, 6 Nov 2021 16:59:54 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qk1-x72f.google.com with SMTP id x23so5010310qkf.7 for ; Sat, 06 Nov 2021 09:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DidsRh1rAlXrRH78UbHf9A5/66Ez2oYJ3SzbowwAdX4=; b=RBCmzyhz1yHhiPR/UTstrNWDJJZZakoYs7lsqQQw2z/jTvjeP79X6SgYGCh+OZe5uN qisBnqbGKiVRSMa4uuKHYjizVkeo9GgiAP9v/lFMiiJLxZ2/HmyIZeJVt3x5/cYjRXk7 hLo6AYH50H3i7Zkgz7DivmalXkLF/wdo5JGwiu1YhYKbWjHAxYfD8hb9EBV2HddPD3LF Wsotf3rIsM4GUFJrBH49TPledEGBP3eJjTCrTLOqK/c7krnskEf1mipTTzbiE002HOc0 VuJtkXtuY/SE8lB6J1Z+DbW6U6hqDgv3kx/iT9YTXSwJ2o7AxgDfmGrklZFAKZMbP582 R6hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DidsRh1rAlXrRH78UbHf9A5/66Ez2oYJ3SzbowwAdX4=; b=2j4hnmptpgwaVBzmkTkeGXQ2pg8OAx0hyXKCviMG4308BIb/hXMigYnShC8GXPM7xS /3ECFRkkcBAGuZjTUtRzgn5TtyQoiK/n/I1MRmY0DrEKNXJNg6z7typy7h+Yw9HJGZ9l htd7+oEFbxYcrfPmrJ7iQaXB85kHnOAtm3bDzpYbxuQQ6WeUnhGFR8OAHZW0V38hZJt7 OgRGqe92Fw0k8nH5Jx6q20TYjVCreAoSfenrNFgXRW/5MTxD9WdcYOaorKN0ljyDuQ2T s9OeWNeVD1DerLhFdVfs7/a7rV00zhUAkR5+TcawiFuzD74TDjr+Jl5aIir6fVnuc3V6 rUzg== X-Gm-Message-State: AOAM532akUdb69jiobO+Fkd8u1Eai+td4cfWtD6+y0QyIF+fcd3sp6/4 YXWTXCQZqo11I2iFgRx9OAbUhw== X-Google-Smtp-Source: ABdhPJwkQa+job+VlJUbhAR0/2KfUtE7frniuI0xu5zATgnMJOpG5Q9L7LhrV9BmkmUq/NGpwGX71Q== X-Received: by 2002:a37:660f:: with SMTP id a15mr25917296qkc.73.1636217987853; Sat, 06 Nov 2021 09:59:47 -0700 (PDT) Received: from mutt-hbsd (pool-100-16-224-136.bltmmd.fios.verizon.net. [100.16.224.136]) by smtp.gmail.com with ESMTPSA id v7sm2548387qki.98.2021.11.06.09.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Nov 2021 09:59:47 -0700 (PDT) Date: Sat, 6 Nov 2021 12:59:46 -0400 From: Shawn Webb To: Wojciech Macek Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 0dedcdaa1a02 - main - Revert "ossl: Add support for ETA mode" Message-ID: <20211106165946.zrj7fonoxbca3cj2@mutt-hbsd> X-Operating-System: FreeBSD mutt-hbsd 14.0-CURRENT-HBSD FreeBSD 14.0-CURRENT-HBSD X-PGP-Key: https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/blob/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc References: <202111061646.1A6GkIj4036877@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-sha256; protocol="application/pgp-signature"; boundary="xlg5tbx6jxdstqa2" Content-Disposition: inline In-Reply-To: <202111061646.1A6GkIj4036877@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4HmkBf4BFFz3Ngq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N --xlg5tbx6jxdstqa2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 06, 2021 at 04:46:18PM +0000, Wojciech Macek wrote: > The branch main has been updated by wma: >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3D0dedcdaa1a023d46c8951f03cd= 2f9df7ae025675 >=20 > commit 0dedcdaa1a023d46c8951f03cd2f9df7ae025675 > Author: Wojciech Macek > AuthorDate: 2021-11-06 16:45:50 +0000 > Commit: Wojciech Macek > CommitDate: 2021-11-06 16:45:50 +0000 >=20 > Revert "ossl: Add support for ETA mode" > =20 > This reverts commit 048a71b46e816de8fb95b553a8ad0e98c0d51e12. Why? --=20 Shawn Webb Cofounder / Security Engineer HardenedBSD https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A= 4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc --xlg5tbx6jxdstqa2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAmGGtH8ACgkQ/y5nonf4 4frimA/+PVCoFFh0I9SL9RCpZyYLXkjvVo+xWJW63j98phx9N92XwTBN1mkA+Q4m xo2Y+jOAspYlQbyiwpiLnVc/YsaDbwFNFywwUMFWRHXk6WwtShNSqrzDw0OxAov/ 02lKS55duHM/XGmMhGUEWrsMzcTWLEo/d8Xxj86M+03UWK1c0O5jlinTwh53h+O3 aLtHB0UeUW4r2dAP/UV7QjHKd7I2WPq0J/QS6kTxRsuIYKhN5uA2JXIESVaPBUeo kif+r5T6zCH+H5xgZ3/wAWPk0bsq2W3ZpryxklIubp6z/o6DRNugCL7a3liDdogt K50bKf9kC0Ow3KR33LnRwimnqIAQCK+zjZUiMqADTywU7iDsK+RzoscYWqii+35j DBJExNqTTGcnmr9kArRs4gl/xpGTWOjQlYU21xJcLxK0x/KLjZRPoza3Y9h3RiK0 vwMmZlS8/IA+JhIq/5ksuy/VddzcYRGYCNcR9rfJTHSUVIJuZs3AsXrIj0ETAorJ asjk8g2smCM7xPkk4/wXVT7G+dNFP15Y90l/hbFDTUF76Pc/Kb6TeNumzxszhy4g IbW5lnRH/WCa61Jp9aXzbGMq3JB1XMUSr+0SrnrYbmmTk1017QO5HWEzmujQPJGj IwV9NSNkoEd5IVlEg5W0i02xHO1u4BHA8Z319Z0usKdCFJ6lm+o= =kU1P -----END PGP SIGNATURE----- --xlg5tbx6jxdstqa2-- From nobody Sat Nov 6 17:15: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 B6AC4183F278; Sat, 6 Nov 2021 17:15:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmkXD4nfZz3jK7; Sat, 6 Nov 2021 17:15: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 7FEBE7171; Sat, 6 Nov 2021 17:15: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 1A6HF80Q077338; Sat, 6 Nov 2021 17:15:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HF8iM077337; Sat, 6 Nov 2021 17:15:08 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:15:08 GMT Message-Id: <202111061715.1A6HF8iM077337@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: a60b30469741 - main - pcf8591: driver for adc/dac with i2c interface 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a60b30469741392e66ec6fd21a8d5c4810a2d407 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=a60b30469741392e66ec6fd21a8d5c4810a2d407 commit a60b30469741392e66ec6fd21a8d5c4810a2d407 Author: Andriy Gapon AuthorDate: 2020-08-17 10:05:11 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:14:50 +0000 pcf8591: driver for adc/dac with i2c interface --- share/man/man4/Makefile | 1 + share/man/man4/pcf8591.4 | 122 ++++++++++++++++++ sys/conf/files | 1 + sys/dev/iicbus/pcf8591.c | 271 +++++++++++++++++++++++++++++++++++++++ sys/modules/i2c/Makefile | 1 + sys/modules/i2c/pcf8591/Makefile | 17 +++ 6 files changed, 413 insertions(+) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 742a758f1ec0..bf7f265e7551 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -420,6 +420,7 @@ MAN= aac.4 \ pccard.4 \ pccbb.4 \ pcf.4 \ + pcf8591.4 \ ${_pchtherm.4} \ pci.4 \ pcib.4 \ diff --git a/share/man/man4/pcf8591.4 b/share/man/man4/pcf8591.4 new file mode 100644 index 000000000000..2876ad057f90 --- /dev/null +++ b/share/man/man4/pcf8591.4 @@ -0,0 +1,122 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2020 Andriy Gapon +.\" +.\" 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: head/share/man/man4/cp2112.4 364144 2020-08-12 09:42:05Z avg $ +.\" +.Dd November 6, 2021 +.Dt PCF8591 4 +.Os +.Sh NAME +.Nm pcf8591 +.Nd driver for the PCF8591 8-bit A/D and D/A converter +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device pcf8591" +.Cd "device iicbus" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +pcf8591_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver supports reading four inputs and setting one output over I2C. +The hardware supports configuring the input lines as: +.Bl -bullet +.It +four single-ended inputs +.It +three differential inputs (one input line is shared between all three inputs) +.It +two single-ended inputs and one differential input +.It +two differential inputs. +.El +.Pp +The +.Nm +driver reports data via +.Xr sysctl 8 +entries in the device's node in the +.Xr sysctl 8 +tree: +.Bl -tag -width inputs.%d +.It Va inputs.%d +The input level of the corresponding input in steps between 0 and 255. +Absolute voltage depends on an actual reference voltage. +.El +.Pp +On an +.Xr FDT 4 +based system the following properties must be set: +.Bl -tag -width "compatible" +.It Va compatible +Must be set to "nxp,pcf8591". +.It Va reg +The I2C address of +.Nm . +It should be in the range from 0x40 to 0x4f (7-bit). +.El +.Pp +The DTS part for a +.Nm +device usually looks like: +.Bd -literal +/ { + + ... + pcf8591adc { + compatible = "nxp,pcf8591"; + reg = <0x48>; + }; +}; +.Ed +.Sh SEE ALSO +.Xr fdt 4 , +.Xr iicbus 4 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +driver and this manual page was written by +.An Andriy Gapon Aq Mt avg@FreeBSD.org . +.Sh BUGS +The +.Nm +driver does not support changing the input configuration. +All input lines are configured as single-ended inputs. +.Pp +The +.Nm +driver does not support setting the output. +It is always disabled (tri-state). diff --git a/sys/conf/files b/sys/conf/files index f2663fd1c6c0..434a783ebbbe 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1855,6 +1855,7 @@ dev/iicbus/mux/iic_gpiomux.c optional iic_gpiomux fdt dev/iicbus/mux/ltc430x.c optional ltc430x dev/iicbus/nxprtc.c optional nxprtc | pcf8563 dev/iicbus/ofw_iicbus.c optional fdt iicbus +dev/iicbus/pcf8591.c optional pcf8591 dev/iicbus/rtc8583.c optional rtc8583 dev/iicbus/rtc/rx8803.c optional rx8803 iicbus fdt dev/iicbus/s35390a.c optional s35390a diff --git a/sys/dev/iicbus/pcf8591.c b/sys/dev/iicbus/pcf8591.c new file mode 100644 index 000000000000..ff769b368d91 --- /dev/null +++ b/sys/dev/iicbus/pcf8591.c @@ -0,0 +1,271 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) Andriy Gapon + * + * 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 "opt_platform.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef FDT +#include +#include +#endif + +/* + * Driver for PCF8591 I2C 8-bit ADC and DAC. + */ +#define CTRL_CH_SELECT_MASK 0x03 +#define CTRL_AUTOINC_EN 0x04 +#define CTRL_CH_CONFIG_MASK 0x30 +#define CTRL_CH_CONFIG_4_SINGLE 0x00 +#define CTRL_CH_CONFIG_3_DIFF 0x10 +#define CTRL_CH_CONFIG_2_SINGLE_1_DIFF 0x20 +#define CTRL_CH_CONFIG_2_DIFF 0x30 +#define CTRL_OUTPUT_EN 0x40 + +struct pcf8591_softc { + device_t sc_dev; + int sc_ch_count; + uint8_t sc_addr; + uint8_t sc_cfg; + uint8_t sc_output; +}; + +#ifdef FDT +static struct ofw_compat_data compat_data[] = { + { "nxp,pcf8591", true }, + { NULL, false } +}; +#endif + +static int +pcf8591_set_config(device_t dev) +{ + + struct iic_msg msg; + uint8_t data[2]; + struct pcf8591_softc *sc; + int error; + + sc = device_get_softc(dev); + data[0] = sc->sc_cfg; + data[1] = sc->sc_output; + msg.slave = sc->sc_addr; + msg.flags = IIC_M_WR; + msg.len = nitems(data); + msg.buf = data; + + error = iicbus_transfer_excl(dev, &msg, 1, IIC_INTRWAIT); + return (error); +} + +static int +pcf8591_get_reading(device_t dev, uint8_t *reading) +{ + struct iic_msg msg; + struct pcf8591_softc *sc; + int error; + + sc = device_get_softc(dev); + + msg.slave = sc->sc_addr; + msg.flags = IIC_M_RD; + msg.len = 1; + msg.buf = reading; + + error = iicbus_transfer_excl(dev, &msg, 1, IIC_INTRWAIT); + return (error); +} + +static int +pcf8591_select_channel(device_t dev, int channel) +{ + struct pcf8591_softc *sc; + int error; + uint8_t unused; + + sc = device_get_softc(dev); + if (channel >= sc->sc_ch_count) + return (EINVAL); + sc->sc_cfg &= ~CTRL_CH_SELECT_MASK; + sc->sc_cfg += channel; + error = pcf8591_set_config(dev); + if (error != 0) + return (error); + + /* + * The next read is still for the old channel, + * so do it and discard. + */ + error = pcf8591_get_reading(dev, &unused); + return (error); +} + +static int +pcf8591_channel_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct pcf8591_softc *sc; + device_t dev; + int error, channel, val; + uint8_t reading; + + dev = arg1; + channel = arg2; + sc = device_get_softc(dev); + + if (req->oldptr != NULL) { + error = pcf8591_select_channel(dev, channel); + if (error != 0) + return (EIO); + error = pcf8591_get_reading(dev, &reading); + if (error != 0) + return (EIO); + val = reading; + } + error = sysctl_handle_int(oidp, &val, 0, req); + return (error); +} + +static void +pcf8591_start(void *arg) +{ + device_t dev; + struct pcf8591_softc *sc; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *tree_node; + struct sysctl_oid_list *tree; + struct sysctl_oid *inputs_node; + struct sysctl_oid_list *inputs; + int error; + + sc = arg; + dev = sc->sc_dev; + + /* + * Set initial -- and, for the time being, fixed -- configuration. + * Channel auto-incrementi is disabled, although it could be more + * performant and precise for bulk channel queries. + * The inputs are configured as four single channels. + * The output is disabled. + */ + sc->sc_cfg = 0; + sc->sc_output = 0; + sc->sc_ch_count = 4; + error = pcf8591_set_config(dev); + + ctx = device_get_sysctl_ctx(dev); + tree_node = device_get_sysctl_tree(dev); + tree = SYSCTL_CHILDREN(tree_node); + + inputs_node = SYSCTL_ADD_NODE(ctx, tree, OID_AUTO, "inputs", + CTLTYPE_NODE, NULL, "Input channels"); + inputs = SYSCTL_CHILDREN(inputs_node); + for (int i = 0; i < sc->sc_ch_count; i++) { + char buf[4]; + + snprintf(buf, sizeof(buf), "%d", i); + SYSCTL_ADD_PROC(ctx, inputs, OID_AUTO, buf, + CTLTYPE_INT | CTLFLAG_RD, dev, i, + pcf8591_channel_sysctl, "I", "Input level from 0 to 255 " + "(relative to Vref)"); + } +} + +static int +pcf8591_probe(device_t dev) +{ +#ifdef FDT + if (!ofw_bus_status_okay(dev)) + return (ENXIO); +#endif + device_set_desc(dev, "PCF8591 8-bit ADC / DAC"); +#ifdef FDT + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data) + return (BUS_PROBE_GENERIC); +#endif + return (BUS_PROBE_NOWILDCARD); +} + +static int +pcf8591_attach(device_t dev) +{ + struct pcf8591_softc *sc; + + sc = device_get_softc(dev); + sc->sc_dev = dev; + sc->sc_addr = iicbus_get_addr(dev); + + /* + * We have to wait until interrupts are enabled. Usually I2C read + * and write only works when the interrupts are available. + */ + config_intrhook_oneshot(pcf8591_start, sc); + return (0); +} + +static int +pcf8591_detach(device_t dev) +{ + return (0); +} + +static device_method_t pcf8591_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcf8591_probe), + DEVMETHOD(device_attach, pcf8591_attach), + DEVMETHOD(device_detach, pcf8591_detach), + + DEVMETHOD_END +}; + +static driver_t pcf8591_driver = { + "pcf8591", + pcf8591_methods, + sizeof(struct pcf8591_softc) +}; + +static devclass_t pcf8591_devclass; + +DRIVER_MODULE(pcf8591, iicbus, pcf8591_driver, pcf8591_devclass, 0, 0); +MODULE_DEPEND(pcf8591, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); +MODULE_VERSION(pcf8591, 1); +#ifdef FDT +IICBUS_FDT_PNP_INFO(compat_data); +#endif diff --git a/sys/modules/i2c/Makefile b/sys/modules/i2c/Makefile index edd92943c6c1..b79e2a98fc7d 100644 --- a/sys/modules/i2c/Makefile +++ b/sys/modules/i2c/Makefile @@ -20,6 +20,7 @@ SUBDIR = \ jedec_dimm \ mux \ nxprtc \ + pcf8591 \ rtc8583 \ s35390a \ smb \ diff --git a/sys/modules/i2c/pcf8591/Makefile b/sys/modules/i2c/pcf8591/Makefile new file mode 100644 index 000000000000..82148867a00f --- /dev/null +++ b/sys/modules/i2c/pcf8591/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/dev/iicbus +KMOD= pcf8591 +SRCS= pcf8591.c + +SRCS+= \ + bus_if.h \ + device_if.h \ + iicbus_if.h \ + opt_platform.h + +.if !empty(OPT_FDT) +SRCS+= ofw_bus_if.h +.endif + +.include From nobody Sat Nov 6 17: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 35D5D1843510; Sat, 6 Nov 2021 17:19:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmkd70qDxz3lhS; Sat, 6 Nov 2021 17:19:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F06566F9E; Sat, 6 Nov 2021 17: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 1A6HJMiD077851; Sat, 6 Nov 2021 17: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 1A6HJM5U077850; Sat, 6 Nov 2021 17:19:22 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:19:22 GMT Message-Id: <202111061719.1A6HJM5U077850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: ff6fe2983550 - main - driver for MAX44009 I2C illuminance sensor 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ff6fe2983550aeab0852e982e7fe5ac4c672c205 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=ff6fe2983550aeab0852e982e7fe5ac4c672c205 commit ff6fe2983550aeab0852e982e7fe5ac4c672c205 Author: Andriy Gapon AuthorDate: 2020-08-20 08:11:31 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:19:04 +0000 driver for MAX44009 I2C illuminance sensor --- share/man/man4/Makefile | 1 + share/man/man4/max44009.4 | 92 ++++++++++++++++++ sys/conf/files | 1 + sys/dev/iicbus/max44009.c | 193 ++++++++++++++++++++++++++++++++++++++ sys/modules/i2c/Makefile | 1 + sys/modules/i2c/max44009/Makefile | 17 ++++ 6 files changed, 305 insertions(+) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index bf7f265e7551..f19e11ba62aa 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -292,6 +292,7 @@ MAN= aac.4 \ mac_stub.4 \ mac_test.4 \ malo.4 \ + max44009.4 \ md.4 \ mdio.4 \ me.4 \ diff --git a/share/man/man4/max44009.4 b/share/man/man4/max44009.4 new file mode 100644 index 000000000000..fa399c52cec3 --- /dev/null +++ b/share/man/man4/max44009.4 @@ -0,0 +1,92 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2020 Andriy Gapon +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 6, 2021 +.Dt MAX44009 4 +.Os +.Sh NAME +.Nm max44009 +.Nd driver for MAX44009 Ambient Light Sensor +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device max44009" +.Cd "device iicbus" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +max44009_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver reports illuminance data from MAX44009 Ambient Light Sensor. +.Pp +The +.Nm +driver reports data via +.Xr sysctl 8 +entry in the device's node in the +.Xr sysctl 8 +tree: +.Bl -tag -width illuminance +.It Va illuminance +The illuminance, in lux units. +.El +.Pp +On an +.Xr FDT 4 +based system the following properties must be set: +.Bl -tag -width "compatible" +.It Va compatible +Must be set to +.Qq maxim,max44009 . +.It Va reg +The I2C address of +.Nm +which can be either 0x4a or 0x4b. +.El +.Sh SEE ALSO +.Xr fdt 4 , +.Xr iicbus 4 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +driver and this manual page was written by +.An Andriy Gapon Aq Mt avg@FreeBSD.org . +.Sh BUGS +The +.Nm +driver does not support illuminance thresholds and the corresponding +interrupt. diff --git a/sys/conf/files b/sys/conf/files index 434a783ebbbe..5229484dc076 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1848,6 +1848,7 @@ dev/iicbus/iicoc_fdt.c optional iicoc ext_resources fdt dev/iicbus/iicoc_pci.c optional iicoc pci dev/iicbus/isl12xx.c optional isl12xx dev/iicbus/lm75.c optional lm75 +dev/iicbus/max44009.c optional max44009 dev/iicbus/mux/pca9547.c optional pca9547 iicmux fdt dev/iicbus/mux/iicmux.c optional iicmux dev/iicbus/mux/iicmux_if.m optional iicmux diff --git a/sys/dev/iicbus/max44009.c b/sys/dev/iicbus/max44009.c new file mode 100644 index 000000000000..739b43ed9055 --- /dev/null +++ b/sys/dev/iicbus/max44009.c @@ -0,0 +1,193 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) Andriy Gapon + * + * 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 "opt_platform.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef FDT +#include +#include +#endif + +/* + * Driver for MAX44009 Ambient Light Sensor with ADC. + */ +#define REG_LUX_HIGH 0x03 +#define REG_LUX_LOW 0x04 + +struct max44009_softc { + device_t sc_dev; + uint8_t sc_addr; +}; + +#ifdef FDT +static const struct ofw_compat_data compat_data[] = { + { "maxim,max44009", true }, + { NULL, false }, +}; +#endif + +static int +max44009_get_reading(device_t dev, u_int *reading) +{ + struct iic_msg msgs[4]; + struct max44009_softc *sc; + u_int val; + uint8_t reghi, reglo, valhi, vallo; + int error; + + sc = device_get_softc(dev); + + reghi = REG_LUX_HIGH; + reglo = REG_LUX_LOW; + msgs[0].slave = sc->sc_addr; + msgs[0].flags = IIC_M_WR | IIC_M_NOSTOP; + msgs[0].len = 1; + msgs[0].buf = ®hi; + msgs[1].slave = sc->sc_addr; + msgs[1].flags = IIC_M_RD | IIC_M_NOSTOP; + msgs[1].len = 1; + msgs[1].buf = &valhi; + msgs[2].slave = sc->sc_addr; + msgs[2].flags = IIC_M_WR | IIC_M_NOSTOP; + msgs[2].len = 1; + msgs[2].buf = ®lo; + msgs[3].slave = sc->sc_addr; + msgs[3].flags = IIC_M_RD; + msgs[3].len = 1; + msgs[3].buf = &vallo; + + error = iicbus_transfer_excl(dev, msgs, nitems(msgs), IIC_INTRWAIT); + if (error != 0) + return (error); + + val = ((valhi & 0x0f) << 4) | (vallo & 0x0f); + val <<= (valhi & 0xf0) >> 4; + val = val * 72 / 100; + *reading = val; + return (0); +} + +static int +max44009_lux_sysctl(SYSCTL_HANDLER_ARGS) +{ + device_t dev; + u_int reading; + int error, val; + + if (req->oldptr != NULL) { + dev = arg1; + error = max44009_get_reading(dev, &reading); + if (error != 0) + return (EIO); + val = reading; + } + error = sysctl_handle_int(oidp, &val, 0, req); + return (error); +} + +static int +max44009_probe(device_t dev) +{ + int rc; + +#ifdef FDT + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data) + rc = BUS_PROBE_GENERIC; + else +#endif + rc = BUS_PROBE_NOWILDCARD; + device_set_desc(dev, "MAX44009 light intensity sensor"); + return (rc); +} + +static int +max44009_attach(device_t dev) +{ + struct max44009_softc *sc; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *tree_node; + struct sysctl_oid_list *tree; + + sc = device_get_softc(dev); + sc->sc_dev = dev; + sc->sc_addr = iicbus_get_addr(dev); + + ctx = device_get_sysctl_ctx(dev); + tree_node = device_get_sysctl_tree(dev); + tree = SYSCTL_CHILDREN(tree_node); + + SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "illuminance", + CTLTYPE_INT | CTLFLAG_RD, dev, 0, + max44009_lux_sysctl, "I", "Light intensity, lux"); + return (0); +} + +static int +max44009_detach(device_t dev) +{ + return (0); +} + +static device_method_t max44009_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, max44009_probe), + DEVMETHOD(device_attach, max44009_attach), + DEVMETHOD(device_detach, max44009_detach), + + DEVMETHOD_END +}; + +static driver_t max44009_driver = { + "max44009", + max44009_methods, + sizeof(struct max44009_softc) +}; + +static devclass_t max44009_devclass; + +DRIVER_MODULE(max44009, iicbus, max44009_driver, max44009_devclass, 0, 0); +MODULE_DEPEND(max44009, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); +MODULE_VERSION(max44009, 1); +IICBUS_FDT_PNP_INFO(compat_data); diff --git a/sys/modules/i2c/Makefile b/sys/modules/i2c/Makefile index b79e2a98fc7d..483eb012bb95 100644 --- a/sys/modules/i2c/Makefile +++ b/sys/modules/i2c/Makefile @@ -18,6 +18,7 @@ SUBDIR = \ isl \ isl12xx \ jedec_dimm \ + max44009 \ mux \ nxprtc \ pcf8591 \ diff --git a/sys/modules/i2c/max44009/Makefile b/sys/modules/i2c/max44009/Makefile new file mode 100644 index 000000000000..1e201c5aaba4 --- /dev/null +++ b/sys/modules/i2c/max44009/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/dev/iicbus +KMOD= max44009 +SRCS= max44009.c + +SRCS+= \ + bus_if.h \ + device_if.h \ + iicbus_if.h \ + opt_platform.h + +.if !empty(OPT_FDT) +SRCS+= ofw_bus_if.h +.endif + +.include From nobody Sat Nov 6 17:21: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 6EC5D1843B63; Sat, 6 Nov 2021 17:21: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 4HmkgD2kvtz3ltJ; Sat, 6 Nov 2021 17:21: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 3A7556EB7; Sat, 6 Nov 2021 17:21: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 1A6HLCok087162; Sat, 6 Nov 2021 17:21:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HLC9c087161; Sat, 6 Nov 2021 17:21:12 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:21:12 GMT Message-Id: <202111061721.1A6HLC9c087161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 832503063e32 - main - gpioled: allow the driver to be disabled via fdt 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 832503063e32a449f8ed6ecf865d01e575559971 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=832503063e32a449f8ed6ecf865d01e575559971 commit 832503063e32a449f8ed6ecf865d01e575559971 Author: Andriy Gapon AuthorDate: 2020-09-25 07:32:47 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:21:05 +0000 gpioled: allow the driver to be disabled via fdt --- sys/dev/gpio/gpioled_fdt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/gpio/gpioled_fdt.c b/sys/dev/gpio/gpioled_fdt.c index 3f627706860a..58bcd0fbd2bb 100644 --- a/sys/dev/gpio/gpioled_fdt.c +++ b/sys/dev/gpio/gpioled_fdt.c @@ -144,6 +144,8 @@ gpioleds_detach_led(struct gpioled *led) static int gpioled_probe(device_t dev) { + if (!ofw_bus_status_okay(dev)) + return (ENXIO); if (!ofw_bus_is_compatible(dev, "gpio-leds")) return (ENXIO); From nobody Sat Nov 6 17:24: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 9B705184614D; Sat, 6 Nov 2021 17:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmkkl1Kqjz3nZk; Sat, 6 Nov 2021 17:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EA64F73BB; Sat, 6 Nov 2021 17:24:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6HOEjA090595; Sat, 6 Nov 2021 17:24:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HOEgo090594; Sat, 6 Nov 2021 17:24:14 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:24:14 GMT Message-Id: <202111061724.1A6HOEgo090594@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 6354154ef520 - main - pcf8574: driver for 8-pin quasi-bidirectional GPIO over I2C 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6354154ef520d359492badf0de9c8ae5d7080ae7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=6354154ef520d359492badf0de9c8ae5d7080ae7 commit 6354154ef520d359492badf0de9c8ae5d7080ae7 Author: Andriy Gapon AuthorDate: 2020-10-01 09:48:56 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:23:27 +0000 pcf8574: driver for 8-pin quasi-bidirectional GPIO over I2C MFC after: 2 weeks --- share/man/man4/Makefile | 1 + share/man/man4/pcf8574.4 | 98 +++++++++ sys/conf/files | 1 + sys/dev/iicbus/gpio/pcf8574.c | 425 +++++++++++++++++++++++++++++++++++++++ sys/modules/i2c/Makefile | 1 + sys/modules/i2c/pcf8574/Makefile | 18 ++ 6 files changed, 544 insertions(+) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index f19e11ba62aa..d3cd58b495f4 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -421,6 +421,7 @@ MAN= aac.4 \ pccard.4 \ pccbb.4 \ pcf.4 \ + pcf8574.4 \ pcf8591.4 \ ${_pchtherm.4} \ pci.4 \ diff --git a/share/man/man4/pcf8574.4 b/share/man/man4/pcf8574.4 new file mode 100644 index 000000000000..9fdf71874063 --- /dev/null +++ b/share/man/man4/pcf8574.4 @@ -0,0 +1,98 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2020 Andriy Gapon +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 6, 2021 +.Dt PCF8574 4 +.Os +.Sh NAME +.Nm pcf8574 +.Nd driver for the PCF8574 8-bit I2C IO expander +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device pcf8574" +.Cd "device gpio" +.Cd "device iicbus" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +pcf8574_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides +.Xr gpiobus 4 +control over 8 GPIO pins. +The pins are quasi-bidirectional. +Only low output can be actively driven. +High output is equivalent to input. +.Pp +On an +.Xr FDT 4 +based system the following properties must be set: +.Bl -tag -width "compatible" +.It Va compatible +Must be set to "nxp,pcf8574". +.It Va reg +The I2C address of +.Nm . +.El +.Pp +The DTS part for a +.Nm +device usually looks like: +.Bd -literal +/ { + + ... + pcf8574@27 { + compatible = "nxp,pcf8574"; + reg = <0x27>; + }; +}; +.Ed +.Sh SEE ALSO +.Xr fdt 4 , +.Xr gpiobus 4 , +.Xr iicbus 4 +.Sh HISTORY +The +.Nm +driver and this manual page was written by +.An Andriy Gapon Aq Mt avg@FreeBSD.org . +.Sh BUGS +The +.Nm +driver does not support the input change interrupt +that the hardware provides. diff --git a/sys/conf/files b/sys/conf/files index 5229484dc076..5fa918b59f62 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1856,6 +1856,7 @@ dev/iicbus/mux/iic_gpiomux.c optional iic_gpiomux fdt dev/iicbus/mux/ltc430x.c optional ltc430x dev/iicbus/nxprtc.c optional nxprtc | pcf8563 dev/iicbus/ofw_iicbus.c optional fdt iicbus +dev/iicbus/pcf8574.c optional pcf8574 dev/iicbus/pcf8591.c optional pcf8591 dev/iicbus/rtc8583.c optional rtc8583 dev/iicbus/rtc/rx8803.c optional rx8803 iicbus fdt diff --git a/sys/dev/iicbus/gpio/pcf8574.c b/sys/dev/iicbus/gpio/pcf8574.c new file mode 100644 index 000000000000..6fa544ac3283 --- /dev/null +++ b/sys/dev/iicbus/gpio/pcf8574.c @@ -0,0 +1,425 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) Andriy Gapon + * + * 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. + * + */ + +/* + * Driver for PCF8574 / PCF8574A 8-bit I/O expander + * with quasi-bidirectional I/O. + * There is no separate mode / configuration register. + * Pins are set and queried via a single register. + * Because of that we have to maintain the state in the driver + * and assume that there is no outside meddling with the device. + * See the datasheet for details. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_platform.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef FDT +#include +#include +#include +#endif + +#include +#include + +#include + +#include "gpio_if.h" + +#define NUM_PINS 8 +#define PIN_CAPS (GPIO_PIN_OUTPUT | GPIO_PIN_INPUT) + +#define dbg_dev_printf(dev, fmt, args...) \ + if (bootverbose) device_printf(dev, fmt, ##args) + +struct pcf8574_softc { + device_t dev; + device_t busdev; + struct sx lock; + uint8_t addr; + uint8_t output_mask; + uint8_t output_state; +}; + +#ifdef FDT +static struct ofw_compat_data compat_data[] = { + { "nxp,pcf8574", 1 }, + { "nxp,pcf8574a", 1 }, + { NULL, 0 } +}; +#endif + +static int +pcf8574_read(struct pcf8574_softc *sc, uint8_t *val) +{ + struct iic_msg msg; + int error; + + msg.slave = sc->addr; + msg.flags = IIC_M_RD; + msg.len = 1; + msg.buf = val; + + error = iicbus_transfer_excl(sc->dev, &msg, 1, IIC_WAIT); + return (iic2errno(error)); +} + +static int +pcf8574_write(struct pcf8574_softc *sc, uint8_t val) +{ + struct iic_msg msg; + int error; + + msg.slave = sc->addr; + msg.flags = IIC_M_WR; + msg.len = 1; + msg.buf = &val; + + error = iicbus_transfer_excl(sc->dev, &msg, 1, IIC_WAIT); + return (iic2errno(error)); +} + +static int +pcf8574_probe(device_t dev) +{ + +#ifdef FDT + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); +#endif + device_set_desc(dev, "PCF8574 I/O expander"); + return (BUS_PROBE_DEFAULT); +} + +static int +pcf8574_attach(device_t dev) +{ + struct pcf8574_softc *sc; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->addr = iicbus_get_addr(dev); + + /* Treat everything as input because there is no way to tell. */ + sc->output_mask = 0; + sc->output_state = 0xff; + + /* Put the device to a safe, known state. */ + (void)pcf8574_write(sc, 0xff); + + sx_init(&sc->lock, "pcf8574"); + sc->busdev = gpiobus_attach_bus(dev); + if (sc->busdev == NULL) { + device_printf(dev, "Could not create busdev child\n"); + sx_destroy(&sc->lock); + return (ENXIO); + } + return (0); +} + +static int +pcf8574_detach(device_t dev) +{ + struct pcf8574_softc *sc; + + sc = device_get_softc(dev); + + if (sc->busdev != NULL) + gpiobus_detach_bus(sc->busdev); + + sx_destroy(&sc->lock); + return (0); +} + +static device_t +pcf8574_get_bus(device_t dev) +{ + struct pcf8574_softc *sc; + + sc = device_get_softc(dev); + return (sc->busdev); +} + +static int +pcf8574_pin_max(device_t dev __unused, int *maxpin) +{ + *maxpin = NUM_PINS - 1; + return (0); +} + +static int +pcf8574_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +{ + + if (pin >= NUM_PINS) + return (EINVAL); + *caps = PIN_CAPS; + return (0); +} + +static int +pcf8574_pin_getflags(device_t dev, uint32_t pin, uint32_t *pflags) +{ + struct pcf8574_softc *sc; + uint8_t val, stale; + int error; + + sc = device_get_softc(dev); + + if (pin >= NUM_PINS) + return (EINVAL); + + sx_xlock(&sc->lock); + error = pcf8574_read(sc, &val); + if (error != 0) { + dbg_dev_printf(dev, "failed to read from device: %d\n", + error); + sx_xunlock(&sc->lock); + return (error); + } + + /* + * Check for pins whose read value is one, but they are configured + * as outputs with low signal. This is an impossible combination, + * so change their view to be inputs. + */ + stale = val & sc->output_mask & ~sc->output_state; + sc->output_mask &= ~stale; + sc->output_state |= stale; + + if ((sc->output_mask & (1 << pin)) != 0) + *pflags = GPIO_PIN_OUTPUT; + else + *pflags = GPIO_PIN_INPUT; + sx_xunlock(&sc->lock); + + return (0); +} + +static int +pcf8574_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + struct pcf8574_softc *sc; + int error; + uint8_t val; + bool update_needed; + + sc = device_get_softc(dev); + + if (pin >= NUM_PINS) + return (EINVAL); + if ((flags & ~PIN_CAPS) != 0) + return (EINVAL); + + sx_xlock(&sc->lock); + if ((flags & GPIO_PIN_OUTPUT) != 0) { + sc->output_mask |= 1 << pin; + update_needed = false; + } else if ((flags & GPIO_PIN_INPUT) != 0) { + sc->output_mask &= ~(1 << pin); + sc->output_state |= 1 << pin; + update_needed = true; + } else { + KASSERT(false, ("both input and output modes requested")); + update_needed = false; + } + + if (update_needed) { + val = sc->output_state | ~sc->output_mask; + error = pcf8574_write(sc, val); + if (error != 0) + dbg_dev_printf(dev, "failed to write to device: %d\n", + error); + } + sx_xunlock(&sc->lock); + + return (0); +} + +static int +pcf8574_pin_getname(device_t dev, uint32_t pin, char *name) +{ + + if (pin >= NUM_PINS) + return (EINVAL); + snprintf(name, GPIOMAXNAME, "P%d", pin); + return (0); +} + +static int +pcf8574_pin_get(device_t dev, uint32_t pin, unsigned int *on) +{ + struct pcf8574_softc *sc; + uint8_t val; + int error; + + sc = device_get_softc(dev); + + sx_xlock(&sc->lock); + if ((sc->output_mask & (1 << pin)) != 0) { + *on = (sc->output_state & (1 << pin)) != 0; + sx_xunlock(&sc->lock); + return (0); + } + + error = pcf8574_read(sc, &val); + if (error != 0) { + dbg_dev_printf(dev, "failed to read from device: %d\n", error); + sx_xunlock(&sc->lock); + return (error); + } + sx_xunlock(&sc->lock); + + *on = (val & (1 << pin)) != 0; + return (0); +} + +static int +pcf8574_pin_set(device_t dev, uint32_t pin, unsigned int on) +{ + struct pcf8574_softc *sc; + uint8_t val; + int error; + + sc = device_get_softc(dev); + + if (pin >= NUM_PINS) + return (EINVAL); + + sx_xlock(&sc->lock); + + if ((sc->output_mask & (1 << pin)) == 0) { + sx_xunlock(&sc->lock); + return (EINVAL); + } + + /* + * Algorithm: + * - set all outputs to their recorded state; + * - set all inputs to the high state; + * - apply the requested change. + */ + val = sc->output_state | ~sc->output_mask; + val &= ~(1 << pin); + val |= (on != 0) << pin; + + error = pcf8574_write(sc, val); + if (error != 0) { + dbg_dev_printf(dev, "failed to write to device: %d\n", error); + sx_xunlock(&sc->lock); + return (error); + } + + /* + * NB: we can record anything as "output" state of input pins. + * By convention and for convenience it will be recorded as 1. + */ + sc->output_state = val; + sx_xunlock(&sc->lock); + return (0); +} + +static int +pcf8574_pin_toggle(device_t dev, uint32_t pin) +{ + struct pcf8574_softc *sc; + uint8_t val; + int error; + + sc = device_get_softc(dev); + + if (pin >= NUM_PINS) + return (EINVAL); + + sx_xlock(&sc->lock); + + if ((sc->output_mask & (1 << pin)) == 0) { + sx_xunlock(&sc->lock); + return (EINVAL); + } + + val = sc->output_state | ~sc->output_mask; + val ^= 1 << pin; + + error = pcf8574_write(sc, val); + if (error != 0) { + dbg_dev_printf(dev, "failed to write to device: %d\n", error); + sx_xunlock(&sc->lock); + return (error); + } + + sc->output_state = val; + sx_xunlock(&sc->lock); + return (0); +} + +static device_method_t pcf8574_methods[] = { + DEVMETHOD(device_probe, pcf8574_probe), + DEVMETHOD(device_attach, pcf8574_attach), + DEVMETHOD(device_detach, pcf8574_detach), + + /* GPIO methods */ + DEVMETHOD(gpio_get_bus, pcf8574_get_bus), + DEVMETHOD(gpio_pin_max, pcf8574_pin_max), + DEVMETHOD(gpio_pin_getcaps, pcf8574_pin_getcaps), + DEVMETHOD(gpio_pin_getflags, pcf8574_pin_getflags), + DEVMETHOD(gpio_pin_setflags, pcf8574_pin_setflags), + DEVMETHOD(gpio_pin_getname, pcf8574_pin_getname), + DEVMETHOD(gpio_pin_get, pcf8574_pin_get), + DEVMETHOD(gpio_pin_set, pcf8574_pin_set), + DEVMETHOD(gpio_pin_toggle, pcf8574_pin_toggle), + + DEVMETHOD_END +}; + +static driver_t pcf8574_driver = { + "gpio", + pcf8574_methods, + sizeof(struct pcf8574_softc) +}; + +static devclass_t pcf8574_devclass; + +DRIVER_MODULE(pcf8574, iicbus, pcf8574_driver, pcf8574_devclass, 0, 0); +MODULE_DEPEND(pcf8574, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); +MODULE_DEPEND(pcf8574, gpiobus, 1, 1, 1); +MODULE_VERSION(pcf8574, 1); +#ifdef FDT +IICBUS_FDT_PNP_INFO(compat_data); +#endif diff --git a/sys/modules/i2c/Makefile b/sys/modules/i2c/Makefile index 483eb012bb95..9fea714975f7 100644 --- a/sys/modules/i2c/Makefile +++ b/sys/modules/i2c/Makefile @@ -21,6 +21,7 @@ SUBDIR = \ max44009 \ mux \ nxprtc \ + pcf8574 \ pcf8591 \ rtc8583 \ s35390a \ diff --git a/sys/modules/i2c/pcf8574/Makefile b/sys/modules/i2c/pcf8574/Makefile new file mode 100644 index 000000000000..7c4fe37297e4 --- /dev/null +++ b/sys/modules/i2c/pcf8574/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/dev/iicbus/gpio/ +KMOD = pcf8574 +SRCS = pcf8574.c + +SRCS+= \ + bus_if.h \ + device_if.h \ + gpio_if.h \ + iicbus_if.h \ + opt_platform.h \ + +.if !empty(OPT_FDT) +SRCS+= ofw_bus_if.h +.endif + +.include From nobody Sat Nov 6 17:25: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 3DEB81847919; Sat, 6 Nov 2021 17:25:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmkm41JgGz3pbX; Sat, 6 Nov 2021 17:25:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0E3FE741C; Sat, 6 Nov 2021 17:25:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6HPNaW090928; Sat, 6 Nov 2021 17:25:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HPN5S090927; Sat, 6 Nov 2021 17:25:23 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:25:23 GMT Message-Id: <202111061725.1A6HPN5S090927@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: a75159eabc90 - main - htu21: allow configuration via hints on FDT-based 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a75159eabc90dc35af68c92f7d5eb72e087f6131 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=a75159eabc90dc35af68c92f7d5eb72e087f6131 commit a75159eabc90dc35af68c92f7d5eb72e087f6131 Author: Andriy Gapon AuthorDate: 2021-11-04 11:56:12 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:24:44 +0000 htu21: allow configuration via hints on FDT-based systems On-board devices should be configured via the FDT and overlays. Hints are primarily useful for external and temporarily attached devices. Adding hints is much easier and faster than writing and compiling an overlay. MFC after: 1 week --- sys/dev/iicbus/htu21.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/dev/iicbus/htu21.c b/sys/dev/iicbus/htu21.c index 5c59ebe8f54a..aa8507bf7437 100644 --- a/sys/dev/iicbus/htu21.c +++ b/sys/dev/iicbus/htu21.c @@ -458,11 +458,17 @@ static int htu21_probe(device_t dev) { uint8_t addr; + int rc; #ifdef FDT - if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) + if (!ofw_bus_status_okay(dev)) return (ENXIO); + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data) + rc = BUS_PROBE_GENERIC; + else #endif + rc = BUS_PROBE_NOWILDCARD; + addr = iicbus_get_addr(dev); if (addr != (HTU21_ADDR << 1)) { device_printf(dev, "non-standard slave address 0x%02x\n", @@ -470,7 +476,7 @@ htu21_probe(device_t dev) } device_set_desc(dev, "HTU21 temperature and humidity sensor"); - return (BUS_PROBE_GENERIC); + return (rc); } static int @@ -516,6 +522,4 @@ static devclass_t htu21_devclass; DRIVER_MODULE(htu21, iicbus, htu21_driver, htu21_devclass, 0, 0); MODULE_DEPEND(htu21, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); MODULE_VERSION(htu21, 1); -#ifdef FDT IICBUS_FDT_PNP_INFO(compat_data); -#endif From nobody Sat Nov 6 17:29: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 777601847F56; Sat, 6 Nov 2021 17:29: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 4Hmkrp2xmCz3q6c; Sat, 6 Nov 2021 17:29: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 4569D73C1; Sat, 6 Nov 2021 17:29: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 1A6HTUNY091435; Sat, 6 Nov 2021 17:29:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HTUY0091434; Sat, 6 Nov 2021 17:29:30 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:29:30 GMT Message-Id: <202111061729.1A6HTUY0091434@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: c01a46d4acab - main - camcontrol: dump received data for MMC command even if it is 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c01a46d4acab923961dfb7e4605b9ca6e775e616 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=c01a46d4acab923961dfb7e4605b9ca6e775e616 commit c01a46d4acab923961dfb7e4605b9ca6e775e616 Author: Andriy Gapon AuthorDate: 2021-11-06 10:23:55 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:25:57 +0000 camcontrol: dump received data for MMC command even if it is unknown For example, EXT_CSD can be read like this: # camcontrol mmcsdcmd 2:0:0 -c 8 -a 0 -f 0x35 -l 512 CMD 8 arg 0 flags 35 MMCIO: error 0, 00000900 00000000 00000000 00000000 No command-specific decoder for CMD 8 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 0010 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |9...............| ... 0100 00 00 00 00 00 00 00 00 01 08 00 01 02 02 00 00 |................| ... 01e0 00 00 00 00 00 00 00 00 00 81 c7 00 00 01 03 07 |................| 01f0 05 00 03 01 3f 3f 01 01 01 00 00 00 00 00 00 00 |....??..........| MFC after: 2 weeks --- sbin/camcontrol/camcontrol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index e560eb349f79..facabbe2ecdc 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -8140,6 +8140,8 @@ mmcsdcmd(struct cam_device *device, int argc, char **argv, char *combinedopt, break; default: printf("No command-specific decoder for CMD %d\n", mmc_opcode); + if (mmc_data_len > 0) + hexdump(mmc_data, mmc_data_len, NULL, 0); } } mmccmd_bailout: From nobody Sat Nov 6 17:33:25 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 7C4A2184BABD for ; Sat, 6 Nov 2021 17:33:37 +0000 (UTC) (envelope-from wma@semihalf.com) Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) (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 4HmkxY2T4kz3sLG for ; Sat, 6 Nov 2021 17:33:37 +0000 (UTC) (envelope-from wma@semihalf.com) Received: by mail-yb1-xb2b.google.com with SMTP id v64so31411881ybi.5 for ; Sat, 06 Nov 2021 10:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=majW1KXXaPsF+NjDDTZdwnlp1r/RoWVnziUW3gy36U0=; b=uIN3CtbMMKSfp0bfMKDZjxT58EmTQg7lf4mNPGOf0RoraT+bTP2wYf4LYGeqEJRxi3 8ALR9Mo24nfj1OG+9txo5E5JK02BwSrbgKTDnMJhuMyXzdLxk2SwswhExK2UUX/q/dsS g36bN7nPEgxpWMh/+ipYE9H11nTVnJeMPSyXYjnwZhtjsBQq/coiPqvvEbF11VNQfg45 +qEhBxmIyVdAo+eNvybCMDoXJcISmX8vTr3fySDSzIYdyryxdfyTFDaC4/5nsoYHnXld Y+1VqidRANsjtL5K6hmmdGBtvlo9z5NwTxuaoi9WBJg95QUaidmw/70I/XjRxhijfYxU pFlw== 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=majW1KXXaPsF+NjDDTZdwnlp1r/RoWVnziUW3gy36U0=; b=rm+SMv6IMy3C5dytRPLZLnFZmW3QRzDOdHZRf+N3TwRjECf7h/ff0BvwIm3TPoMuuV tbFJVt2CE6l+YGNXH0UiJNpUQ44DkRbVsgVloKvbKJa6I/d+svtqqNzMkkhyp5jTeLzD FvFruT0qX3z8ipzHKtqhYkG1iYvk/Inm7A2MXur+v2ffr50ar2U70u1OKlhcaiMd5POD fo0fn9aLu2xRs4KPMdUzcqB6laZ8ql0NPS2jwXi7c83e+5tALhv2itnUX7u+FfSlg4oL B+jOUqZQLljUtQlBaeM6Z+IBmtifhvpBo6k4tXDRKkR9RzCbOoU50klHWfo4tvOOV7r8 +LSw== X-Gm-Message-State: AOAM532IN5R+GBbwecMR48XieCKaSY+ohABnSaGPaDDvdmG/1cwBaHIu zgZ4vE6ftAte04pQn+NODhaRrzi+5QACv/Cym72e1g== X-Google-Smtp-Source: ABdhPJwe/2J6gS9bUcsuBdDc5iz6dqPEdwSrLDjuRONpmEHlcryi5Nk78S3SYx3RbHshQDlKeOYxLOpcwSEkx+nChy0= X-Received: by 2002:a25:b213:: with SMTP id i19mr52891425ybj.393.1636220016855; Sat, 06 Nov 2021 10:33:36 -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: <202111061646.1A6GkIj4036877@gitrepo.freebsd.org> <20211106165946.zrj7fonoxbca3cj2@mutt-hbsd> In-Reply-To: <20211106165946.zrj7fonoxbca3cj2@mutt-hbsd> From: Wojciech Macek Date: Sat, 6 Nov 2021 18:33:25 +0100 Message-ID: Subject: Re: git: 0dedcdaa1a02 - main - Revert "ossl: Add support for ETA mode" To: Shawn Webb Cc: Wojciech Macek , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000e1216d05d0222833" X-Rspamd-Queue-Id: 4HmkxY2T4kz3sLG X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N --000000000000e1216d05d0222833 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It breaks linker for arm64-LINT kernel. Will fix and push it back next week= . sob., 6 lis 2021, 17:59 u=C5=BCytkownik Shawn Webb napisa=C5=82: > On Sat, Nov 06, 2021 at 04:46:18PM +0000, Wojciech Macek wrote: > > The branch main has been updated by wma: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=3D0dedcdaa1a023d46c8951f03cd2f9df= 7ae025675 > > > > commit 0dedcdaa1a023d46c8951f03cd2f9df7ae025675 > > Author: Wojciech Macek > > AuthorDate: 2021-11-06 16:45:50 +0000 > > Commit: Wojciech Macek > > CommitDate: 2021-11-06 16:45:50 +0000 > > > > Revert "ossl: Add support for ETA mode" > > > > This reverts commit 048a71b46e816de8fb95b553a8ad0e98c0d51e12. > > Why? > > -- > Shawn Webb > Cofounder / Security Engineer > HardenedBSD > > > https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/0= 3A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc > --000000000000e1216d05d0222833-- From nobody Sat Nov 6 17:41: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 AD525184F489; Sat, 6 Nov 2021 17:41: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 4Hml6k4Zh1z3vM9; Sat, 6 Nov 2021 17:41: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 7E020775B; Sat, 6 Nov 2021 17:41: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 1A6HfYS9017301; Sat, 6 Nov 2021 17:41:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HfYMn017300; Sat, 6 Nov 2021 17:41:34 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:41:34 GMT Message-Id: <202111061741.1A6HfYMn017300@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 43b031a371eb - main - htu21: don't needlessly bother hardware when measurements are not needed 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 43b031a371eb90c15c390c26202f5f58d09300ef Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=43b031a371eb90c15c390c26202f5f58d09300ef commit 43b031a371eb90c15c390c26202f5f58d09300ef Author: Andriy Gapon AuthorDate: 2021-11-06 16:47:32 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:39:52 +0000 htu21: don't needlessly bother hardware when measurements are not needed sysctl(8) first queries a sysctl to get a size of its value even if the sysctl is of a fixed size, e.g. it has an integer type. Only after that sysctl(8) queries an actual value of the sysctl. Previosuly the driver would needlessly read a sensor in the first step. MFC after: 1 week --- sys/dev/iicbus/htu21.c | 88 +++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/sys/dev/iicbus/htu21.c b/sys/dev/iicbus/htu21.c index aa8507bf7437..6b834354d73f 100644 --- a/sys/dev/iicbus/htu21.c +++ b/sys/dev/iicbus/htu21.c @@ -192,21 +192,24 @@ htu21_temp_sysctl(SYSCTL_HANDLER_ARGS) dev = arg1; sc = device_get_softc(dev); - if (sc->sc_hold) - error = htu21_get_measurement(dev, HTU21_GET_TEMP, - raw_data, nitems(raw_data)); - else - error = htu21_get_measurement_nohold(dev, HTU21_GET_TEMP_NH, - raw_data, nitems(raw_data)); - - if (error != 0) { - return (EIO); - } else if (!check_crc_16(raw_data, raw_data[2])) { - temp = -1; - sc->sc_errcount++; - } else { - temp = (((uint16_t)raw_data[0]) << 8) | (raw_data[1] & 0xfc); - temp = ((temp * 17572) >> 16 ) + 27315 - 4685; + if (req->oldptr != NULL) { + if (sc->sc_hold) + error = htu21_get_measurement(dev, HTU21_GET_TEMP, + raw_data, nitems(raw_data)); + else + error = htu21_get_measurement_nohold(dev, + HTU21_GET_TEMP_NH, raw_data, nitems(raw_data)); + + if (error != 0) { + return (EIO); + } else if (!check_crc_16(raw_data, raw_data[2])) { + temp = -1; + sc->sc_errcount++; + } else { + temp = (((uint16_t)raw_data[0]) << 8) | + (raw_data[1] & 0xfc); + temp = ((temp * 17572) >> 16 ) + 27315 - 4685; + } } error = sysctl_handle_int(oidp, &temp, 0, req); @@ -224,21 +227,24 @@ htu21_rh_sysctl(SYSCTL_HANDLER_ARGS) dev = arg1; sc = device_get_softc(dev); - if (sc->sc_hold) - error = htu21_get_measurement(dev, HTU21_GET_HUM, - raw_data, nitems(raw_data)); - else - error = htu21_get_measurement_nohold(dev, HTU21_GET_HUM_NH, - raw_data, nitems(raw_data)); - - if (error != 0) { - return (EIO); - } else if (!check_crc_16(raw_data, raw_data[2])) { - rh = -1; - sc->sc_errcount++; - } else { - rh = (((uint16_t)raw_data[0]) << 8) | (raw_data[1] & 0xfc); - rh = ((rh * 12500) >> 16 ) - 600; + if (req->oldptr != NULL) { + if (sc->sc_hold) + error = htu21_get_measurement(dev, HTU21_GET_HUM, + raw_data, nitems(raw_data)); + else + error = htu21_get_measurement_nohold(dev, + HTU21_GET_HUM_NH, raw_data, nitems(raw_data)); + + if (error != 0) { + return (EIO); + } else if (!check_crc_16(raw_data, raw_data[2])) { + rh = -1; + sc->sc_errcount++; + } else { + rh = (((uint16_t)raw_data[0]) << 8) | + (raw_data[1] & 0xfc); + rh = ((rh * 12500) >> 16 ) - 600; + } } error = sysctl_handle_int(oidp, &rh, 0, req); @@ -302,11 +308,12 @@ htu21_heater_sysctl(SYSCTL_HANDLER_ARGS) dev = arg1; sc = device_get_softc(dev); - error = htu21_get_cfg(dev, &cfg); - if (error != 0) - return (EIO); - - heater = (cfg & 0x04) != 0; + if (req->oldptr != NULL) { + error = htu21_get_cfg(dev, &cfg); + if (error != 0) + return (EIO); + heater = (cfg & 0x04) != 0; + } error = sysctl_handle_int(oidp, &heater, 0, req); if (error != 0 || req->newptr == NULL) return (error); @@ -328,11 +335,12 @@ htu21_power_sysctl(SYSCTL_HANDLER_ARGS) dev = arg1; sc = device_get_softc(dev); - error = htu21_get_cfg(dev, &cfg); - if (error != 0) - return (EIO); - - power = (cfg & 0x40) == 0; + if (req->oldptr != NULL) { + error = htu21_get_cfg(dev, &cfg); + if (error != 0) + return (EIO); + power = (cfg & 0x40) == 0; + } error = sysctl_handle_int(oidp, &power, 0, req); return (error); } From nobody Sat Nov 6 17:46: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 86ABB1852767; Sat, 6 Nov 2021 17:46: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 4HmlD13PRgz4RYh; Sat, 6 Nov 2021 17:46: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 5581D6FF3; Sat, 6 Nov 2021 17:46: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 1A6Hk9Qs017751; Sat, 6 Nov 2021 17:46:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6Hk9Bc017750; Sat, 6 Nov 2021 17:46:09 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:46:09 GMT Message-Id: <202111061746.1A6Hk9Bc017750@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 24f567bb0e50 - main - files.arm64: fix sort order for aw_i2s.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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 24f567bb0e5060adb21bed24b00effec4f37f034 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=24f567bb0e5060adb21bed24b00effec4f37f034 commit 24f567bb0e5060adb21bed24b00effec4f37f034 Author: Andriy Gapon AuthorDate: 2021-09-24 17:26:07 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:45:49 +0000 files.arm64: fix sort order for aw_i2s.c --- sys/conf/files.arm64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index a0bdaeb475d6..4e96cd7a76f6 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -322,8 +322,8 @@ arm/allwinner/a64/sun50i_a64_acodec.c optional fdt sound a64_codec arm/allwinner/sunxi_dma_if.m optional a31_dmac arm/allwinner/aw_cir.c optional evdev aw_cir fdt arm/allwinner/aw_dwc3.c optional aw_dwc3 fdt -arm/allwinner/aw_i2s.c optional fdt sound aw_i2s arm/allwinner/aw_gpio.c optional gpio aw_gpio fdt +arm/allwinner/aw_i2s.c optional fdt sound aw_i2s arm/allwinner/aw_mmc.c optional mmc aw_mmc fdt | mmccam aw_mmc fdt arm/allwinner/aw_nmi.c optional aw_nmi fdt \ compile-with "${NORMAL_C} -I$S/contrib/device-tree/include" From nobody Sat Nov 6 17:49: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 7A09C1852D29; Sat, 6 Nov 2021 17:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmlJJ2yPPz4SDw; Sat, 6 Nov 2021 17:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 450E47880; Sat, 6 Nov 2021 17:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6HnqAo018143; Sat, 6 Nov 2021 17:49:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HnqCP018142; Sat, 6 Nov 2021 17:49:52 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:49:52 GMT Message-Id: <202111061749.1A6HnqCP018142@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: aa917184a9c0 - main - add rk3328_codec and rk_i2s from gonzoua/socaudio 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aa917184a9c04b41e055e13b1ab158dfacca4c66 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=aa917184a9c04b41e055e13b1ab158dfacca4c66 commit aa917184a9c04b41e055e13b1ab158dfacca4c66 Author: Oleksandr Tymoshenko AuthorDate: 2021-06-04 12:18:06 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:47:10 +0000 add rk3328_codec and rk_i2s from gonzoua/socaudio Not sure why these haven't been committed with the rest of the SoC Audio project. They work sufficiently well for me. Discussed with: manu MFC after: 1 month --- sys/arm64/rockchip/rk3328_codec.c | 593 ++++++++++++++++++++++++++++++++++ sys/arm64/rockchip/rk_i2s.c | 657 ++++++++++++++++++++++++++++++++++++++ sys/conf/files.arm64 | 2 + 3 files changed, 1252 insertions(+) diff --git a/sys/arm64/rockchip/rk3328_codec.c b/sys/arm64/rockchip/rk3328_codec.c new file mode 100644 index 000000000000..940b3b8bb9e8 --- /dev/null +++ b/sys/arm64/rockchip/rk3328_codec.c @@ -0,0 +1,593 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Oleksandr Tymoshenko + * Copyright (c) 2018 Jared McNeill + * + * 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. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "syscon_if.h" + +#include "opt_snd.h" +#include +#include +#include "audio_dai_if.h" +#include "mixer_if.h" + +#define RKCODEC_MIXER_DEVS (1 << SOUND_MIXER_VOLUME) + +#define GRF_SOC_CON2 0x0408 +#define SOC_CON2_I2S_ACODEC_EN (1 << 14) +#define SOC_CON2_I2S_ACODEC_EN_MASK ((1 << 14) << 16) +#define GRF_SOC_CON10 0x0428 +#define SOC_CON10_GPIOMUT (1 << 1) +#define SOC_CON10_GPIOMUT_MASK ((1 << 1) << 16) +#define SOC_CON10_GPIOMUT_EN (1 << 0) +#define SOC_CON10_GPIOMUT_EN_MASK ((1 << 0) << 16) + +#define CODEC_RESET 0x00 +#define RESET_DIG_CORE_RST (1 << 1) +#define RESET_SYS_RST (1 << 0) +#define CODEC_DAC_INIT_CTRL1 0x0c +#define DAC_INIT_CTRL1_DIRECTION_IN (0 << 5) +#define DAC_INIT_CTRL1_DIRECTION_OUT (1 << 5) +#define DAC_INIT_CTRL1_DAC_I2S_MODE_SLAVE (0 << 4) +#define DAC_INIT_CTRL1_DAC_I2S_MODE_MASTER (1 << 4) +#define DAC_INIT_CTRL1_MODE_MASK (3 << 4) +#define CODEC_DAC_INIT_CTRL2 0x10 +#define DAC_INIT_CTRL2_DAC_VDL_16BITS (0 << 5) +#define DAC_INIT_CTRL2_DAC_VDL_20BITS (1 << 5) +#define DAC_INIT_CTRL2_DAC_VDL_24BITS (2 << 5) +#define DAC_INIT_CTRL2_DAC_VDL_32BITS (3 << 5) +#define DAC_INIT_CTRL2_DAC_VDL_MASK (3 << 5) +#define DAC_INIT_CTRL2_DAC_MODE_RJM (0 << 3) +#define DAC_INIT_CTRL2_DAC_MODE_LJM (1 << 3) +#define DAC_INIT_CTRL2_DAC_MODE_I2S (2 << 3) +#define DAC_INIT_CTRL2_DAC_MODE_PCM (3 << 3) +#define DAC_INIT_CTRL2_DAC_MODE_MASK (3 << 3) +#define CODEC_DAC_INIT_CTRL3 0x14 +#define DAC_INIT_CTRL3_WL_16BITS (0 << 2) +#define DAC_INIT_CTRL3_WL_20BITS (1 << 2) +#define DAC_INIT_CTRL3_WL_24BITS (2 << 2) +#define DAC_INIT_CTRL3_WL_32BITS (3 << 2) +#define DAC_INIT_CTRL3_WL_MASK (3 << 2) +#define DAC_INIT_CTRL3_RST_MASK (1 << 1) +#define DAC_INIT_CTRL3_RST_DIS (1 << 1) +#define DAC_INIT_CTRL3_DAC_BCP_REVERSAL (1 << 0) +#define DAC_INIT_CTRL3_DAC_BCP_NORMAL (0 << 0) +#define DAC_INIT_CTRL3_DAC_BCP_MASK (1 << 0) +#define CODEC_DAC_PRECHARGE_CTRL 0x88 +#define DAC_PRECHARGE_CTRL_DAC_CHARGE_PRECHARGE (1 << 7) +#define DAC_PRECHARGE_CTRL_DAC_CHARGE_CURRENT_I (1 << 0) +#define DAC_PRECHARGE_CTRL_DAC_CHARGE_CURRENT_ALL (0x7f) +#define CODEC_DAC_PWR_CTRL 0x8c +#define DAC_PWR_CTRL_DAC_PWR (1 << 6) +#define DAC_PWR_CTRL_DACL_PATH_REFV (1 << 5) +#define DAC_PWR_CTRL_HPOUTL_ZERO_CROSSING (1 << 4) +#define DAC_PWR_CTRL_DACR_PATH_REFV (1 << 1) +#define DAC_PWR_CTRL_HPOUTR_ZERO_CROSSING (1 << 0) +#define CODEC_DAC_CLK_CTRL 0x90 +#define DAC_CLK_CTRL_DACL_REFV_ON (1 << 7) +#define DAC_CLK_CTRL_DACL_CLK_ON (1 << 6) +#define DAC_CLK_CTRL_DACL_ON (1 << 5) +#define DAC_CLK_CTRL_DACL_INIT_ON (1 << 4) +#define DAC_CLK_CTRL_DACR_REFV_ON (1 << 3) +#define DAC_CLK_CTRL_DACR_CLK_ON (1 << 2) +#define DAC_CLK_CTRL_DACR_ON (1 << 1) +#define DAC_CLK_CTRL_DACR_INIT_ON (1 << 0) +#define CODEC_HPMIX_CTRL 0x94 +#define HPMIX_CTRL_HPMIXL_EN (1 << 6) +#define HPMIX_CTRL_HPMIXL_INIT_EN (1 << 5) +#define HPMIX_CTRL_HPMIXL_INIT2_EN (1 << 4) +#define HPMIX_CTRL_HPMIXR_EN (1 << 2) +#define HPMIX_CTRL_HPMIXR_INIT_EN (1 << 1) +#define HPMIX_CTRL_HPMIXR_INIT2_EN (1 << 0) +#define CODEC_DAC_SELECT 0x98 +#define DAC_SELECT_DACL_SELECT (1 << 4) +#define DAC_SELECT_DACR_SELECT (1 << 0) +#define CODEC_HPOUT_CTRL 0x9c +#define HPOUT_CTRL_HPOUTL_EN (1 << 7) +#define HPOUT_CTRL_HPOUTL_INIT_EN (1 << 6) +#define HPOUT_CTRL_HPOUTL_UNMUTE (1 << 5) +#define HPOUT_CTRL_HPOUTR_EN (1 << 4) +#define HPOUT_CTRL_HPOUTR_INIT_EN (1 << 3) +#define HPOUT_CTRL_HPOUTR_UNMUTE (1 << 2) +#define CODEC_HPOUTL_GAIN_CTRL 0xa0 +#define CODEC_HPOUTR_GAIN_CTRL 0xa4 +#define CODEC_HPOUT_POP_CTRL 0xa8 +#define HPOUT_POP_CTRL_HPOUTR_POP (1 << 5) +#define HPOUT_POP_CTRL_HPOUTR_POP_XCHARGE (1 << 4) +#define HPOUT_POP_CTRL_HPOUTL_POP (1 << 1) +#define HPOUT_POP_CTRL_HPOUTL_POP_XCHARGE (1 << 0) + +#define DEFAULT_RATE (48000 * 256) + +static struct ofw_compat_data compat_data[] = { + { "rockchip,rk3328-codec", 1}, + { NULL, 0 } +}; + +struct rkcodec_softc { + device_t dev; + struct resource *res; + struct mtx mtx; + clk_t mclk; + clk_t pclk; + struct syscon *grf; + u_int regaddr; /* address for the sysctl */ +}; + +#define RKCODEC_LOCK(sc) mtx_lock(&(sc)->mtx) +#define RKCODEC_UNLOCK(sc) mtx_unlock(&(sc)->mtx) +#define RKCODEC_READ(sc, reg) bus_read_4((sc)->res, (reg)) +#define RKCODEC_WRITE(sc, reg, val) bus_write_4((sc)->res, (reg), (val)) + +static int rkcodec_probe(device_t dev); +static int rkcodec_attach(device_t dev); +static int rkcodec_detach(device_t dev); + +static void +rkcodec_set_power(struct rkcodec_softc *sc, bool poweron) +{ + uint32_t val; + val = RKCODEC_READ(sc, CODEC_DAC_PRECHARGE_CTRL); + if (poweron) + val |= DAC_PRECHARGE_CTRL_DAC_CHARGE_PRECHARGE; + else + val &= ~(DAC_PRECHARGE_CTRL_DAC_CHARGE_PRECHARGE); + RKCODEC_WRITE(sc, CODEC_DAC_PRECHARGE_CTRL, val); + DELAY(10); + if (poweron) + val |= DAC_PRECHARGE_CTRL_DAC_CHARGE_CURRENT_ALL; + else + val &= ~(DAC_PRECHARGE_CTRL_DAC_CHARGE_CURRENT_ALL); + RKCODEC_WRITE(sc, CODEC_DAC_PRECHARGE_CTRL, val); + +} + +static void +rkcodec_set_mute(struct rkcodec_softc *sc, bool muted) +{ + uint32_t val; + val = SOC_CON10_GPIOMUT_MASK; + if (!muted) + val |= SOC_CON10_GPIOMUT; + SYSCON_WRITE_4(sc->grf, GRF_SOC_CON10, val); +} + +static void +rkcodec_reset(struct rkcodec_softc *sc) +{ + + RKCODEC_WRITE(sc, CODEC_RESET, 0); + DELAY(10); + RKCODEC_WRITE(sc, CODEC_RESET, RESET_DIG_CORE_RST | RESET_SYS_RST); +} + +static int +rkcodec_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) + return (ENXIO); + + device_set_desc(dev, "Rockchip RK3328 CODEC"); + return (BUS_PROBE_DEFAULT); +} + +static int +rkcodec_attach(device_t dev) +{ + struct rkcodec_softc *sc; + int error, rid; + phandle_t node; + uint32_t val; + + sc = device_get_softc(dev); + sc->dev = dev; + + mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); + + rid = 0; + sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (!sc->res) { + device_printf(dev, "could not allocate resource for device\n"); + error = ENXIO; + goto fail; + } + + node = ofw_bus_get_node(dev); + if (syscon_get_by_ofw_property(dev, node, + "rockchip,grf", &sc->grf) != 0) { + device_printf(dev, "cannot get rockchip,grf handle\n"); + return (ENXIO); + } + + val = SOC_CON2_I2S_ACODEC_EN_MASK | (SOC_CON2_I2S_ACODEC_EN << 16); + SYSCON_WRITE_4(sc->grf, GRF_SOC_CON2, val); + + val = 0 | (SOC_CON10_GPIOMUT_EN << 16); + SYSCON_WRITE_4(sc->grf, GRF_SOC_CON10, val); + + error = clk_get_by_ofw_name(dev, 0, "pclk", &sc->pclk); + if (error != 0) { + device_printf(dev, "could not get pclk clock\n"); + goto fail; + } + + error = clk_get_by_ofw_name(dev, 0, "mclk", &sc->mclk); + if (error != 0) { + device_printf(dev, "could not get mclk clock\n"); + goto fail; + } + + error = clk_enable(sc->pclk); + if (error != 0) { + device_printf(sc->dev, "could not enable pclk clock\n"); + goto fail; + } + + error = clk_enable(sc->mclk); + if (error != 0) { + device_printf(sc->dev, "could not enable mclk clock\n"); + goto fail; + } + +#if 0 + error = clk_set_freq(sc->mclk, DEFAULT_RATE, 0); + if (error != 0) { + device_printf(sc->dev, "could not set frequency for mclk clock\n"); + goto fail; + } +#endif + + /* TODO: handle mute-gpios */ + + rkcodec_reset(sc); + rkcodec_set_power(sc, true); + + val = RKCODEC_READ(sc, CODEC_DAC_PWR_CTRL); + val |= DAC_PWR_CTRL_DAC_PWR; + RKCODEC_WRITE(sc, CODEC_DAC_PWR_CTRL, val); + + val |= DAC_PWR_CTRL_DACL_PATH_REFV | + DAC_PWR_CTRL_DACR_PATH_REFV; + RKCODEC_WRITE(sc, CODEC_DAC_PWR_CTRL, val); + + val |= DAC_PWR_CTRL_HPOUTL_ZERO_CROSSING | + DAC_PWR_CTRL_HPOUTR_ZERO_CROSSING; + RKCODEC_WRITE(sc, CODEC_DAC_PWR_CTRL, val); + + val = RKCODEC_READ(sc, CODEC_HPOUT_POP_CTRL); + val |= HPOUT_POP_CTRL_HPOUTR_POP | HPOUT_POP_CTRL_HPOUTL_POP; + val &= ~(HPOUT_POP_CTRL_HPOUTR_POP_XCHARGE | HPOUT_POP_CTRL_HPOUTL_POP_XCHARGE); + RKCODEC_WRITE(sc, CODEC_HPOUT_POP_CTRL, val); + + val = RKCODEC_READ(sc, CODEC_HPMIX_CTRL); + val |= HPMIX_CTRL_HPMIXL_EN | HPMIX_CTRL_HPMIXR_EN; + RKCODEC_WRITE(sc, CODEC_HPMIX_CTRL, val); + + val |= HPMIX_CTRL_HPMIXL_INIT_EN | HPMIX_CTRL_HPMIXR_INIT_EN; + RKCODEC_WRITE(sc, CODEC_HPMIX_CTRL, val); + + val = RKCODEC_READ(sc, CODEC_HPOUT_CTRL); + val |= HPOUT_CTRL_HPOUTL_EN | HPOUT_CTRL_HPOUTR_EN; + RKCODEC_WRITE(sc, CODEC_HPOUT_CTRL, val); + + val |= HPOUT_CTRL_HPOUTL_INIT_EN | HPOUT_CTRL_HPOUTR_INIT_EN; + RKCODEC_WRITE(sc, CODEC_HPOUT_CTRL, val); + + val = RKCODEC_READ(sc, CODEC_DAC_CLK_CTRL); + val |= DAC_CLK_CTRL_DACL_REFV_ON | DAC_CLK_CTRL_DACR_REFV_ON; + RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + + val |= DAC_CLK_CTRL_DACL_CLK_ON | DAC_CLK_CTRL_DACR_CLK_ON; + RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + + val |= DAC_CLK_CTRL_DACL_ON | DAC_CLK_CTRL_DACR_ON; + RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + + val |= DAC_CLK_CTRL_DACL_INIT_ON | DAC_CLK_CTRL_DACR_INIT_ON; + RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + + val = RKCODEC_READ(sc, CODEC_DAC_SELECT); + val |= DAC_SELECT_DACL_SELECT | DAC_SELECT_DACR_SELECT; + RKCODEC_WRITE(sc, CODEC_DAC_SELECT, val); + + val = RKCODEC_READ(sc, CODEC_HPMIX_CTRL); + val |= HPMIX_CTRL_HPMIXL_INIT2_EN | HPMIX_CTRL_HPMIXR_INIT2_EN; + RKCODEC_WRITE(sc, CODEC_HPMIX_CTRL, val); + + val = RKCODEC_READ(sc, CODEC_HPOUT_CTRL); + val |= HPOUT_CTRL_HPOUTL_UNMUTE | HPOUT_CTRL_HPOUTR_UNMUTE; + RKCODEC_WRITE(sc, CODEC_HPOUT_CTRL, val); + + RKCODEC_WRITE(sc, CODEC_HPOUTL_GAIN_CTRL, 0x1f); + RKCODEC_WRITE(sc, CODEC_HPOUTR_GAIN_CTRL, 0x1f); + + rkcodec_set_mute(sc, false); + + node = ofw_bus_get_node(dev); + OF_device_register_xref(OF_xref_from_node(node), dev); + + return (0); + +fail: + rkcodec_detach(dev); + return (error); +} + +static int +rkcodec_detach(device_t dev) +{ + struct rkcodec_softc *sc; + + sc = device_get_softc(dev); + + if (sc->res) + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res); + mtx_destroy(&sc->mtx); + + return (0); +} + +static int +rkcodec_mixer_init(struct snd_mixer *m) +{ + + mix_setdevs(m, RKCODEC_MIXER_DEVS); + + return (0); +} + +static int +rkcodec_mixer_uninit(struct snd_mixer *m) +{ + + return (0); +} + +static int +rkcodec_mixer_reinit(struct snd_mixer *m) +{ + + return (0); +} + +static int +rkcodec_mixer_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right) +{ + struct rkcodec_softc *sc; + struct mtx *mixer_lock; + uint8_t do_unlock; + + sc = device_get_softc(mix_getdevinfo(m)); + mixer_lock = mixer_get_lock(m); + + if (mtx_owned(mixer_lock)) { + do_unlock = 0; + } else { + do_unlock = 1; + mtx_lock(mixer_lock); + } + + right = left; + + RKCODEC_LOCK(sc); + switch(dev) { + case SOUND_MIXER_VOLUME: + printf("[%s] %s:%d\n", __func__, __FILE__, __LINE__); + break; + + case SOUND_MIXER_MIC: + printf("[%s] %s:%d\n", __func__, __FILE__, __LINE__); + break; + default: + break; + } + RKCODEC_UNLOCK(sc); + + if (do_unlock) { + mtx_unlock(mixer_lock); + } + + return (left | (right << 8)); +} + +static unsigned +rkcodec_mixer_setrecsrc(struct snd_mixer *m, unsigned src) +{ + + return (0); +} + +static kobj_method_t rkcodec_mixer_methods[] = { + KOBJMETHOD(mixer_init, rkcodec_mixer_init), + KOBJMETHOD(mixer_uninit, rkcodec_mixer_uninit), + KOBJMETHOD(mixer_reinit, rkcodec_mixer_reinit), + KOBJMETHOD(mixer_set, rkcodec_mixer_set), + KOBJMETHOD(mixer_setrecsrc, rkcodec_mixer_setrecsrc), + KOBJMETHOD_END +}; + +MIXER_DECLARE(rkcodec_mixer); + +static int +rkcodec_dai_init(device_t dev, uint32_t format) +{ + struct rkcodec_softc *sc; + int fmt, pol, clk; + uint32_t ctrl1, ctrl2, ctrl3; + + sc = device_get_softc(dev); + + fmt = AUDIO_DAI_FORMAT_FORMAT(format); + pol = AUDIO_DAI_FORMAT_POLARITY(format); + clk = AUDIO_DAI_FORMAT_CLOCK(format); + + ctrl1 = RKCODEC_READ(sc, CODEC_DAC_INIT_CTRL1); + ctrl2 = RKCODEC_READ(sc, CODEC_DAC_INIT_CTRL2); + ctrl3 = RKCODEC_READ(sc, CODEC_DAC_INIT_CTRL3); + + ctrl3 &= ~(DAC_INIT_CTRL3_DAC_BCP_MASK); + switch (pol) { + case AUDIO_DAI_POLARITY_IB_NF: + ctrl3 |= DAC_INIT_CTRL3_DAC_BCP_REVERSAL; + break; + case AUDIO_DAI_POLARITY_NB_NF: + ctrl3 |= DAC_INIT_CTRL3_DAC_BCP_NORMAL; + break; + default: + return (EINVAL); + } + + ctrl1 &= ~(DAC_INIT_CTRL1_MODE_MASK); + switch (clk) { + case AUDIO_DAI_CLOCK_CBM_CFM: + ctrl1 |= DAC_INIT_CTRL1_DIRECTION_OUT | + DAC_INIT_CTRL1_DAC_I2S_MODE_SLAVE; + break; + case AUDIO_DAI_CLOCK_CBS_CFS: + ctrl1 |= DAC_INIT_CTRL1_DIRECTION_IN | + DAC_INIT_CTRL1_DAC_I2S_MODE_SLAVE; + break; + default: + return (EINVAL); + } + + ctrl2 &= ~(DAC_INIT_CTRL2_DAC_VDL_MASK | DAC_INIT_CTRL2_DAC_MODE_MASK); + ctrl2 |= DAC_INIT_CTRL2_DAC_VDL_16BITS; + ctrl3 &= ~(DAC_INIT_CTRL3_WL_MASK); + ctrl3 |= DAC_INIT_CTRL3_WL_32BITS; + switch (fmt) { + case AUDIO_DAI_FORMAT_I2S: + ctrl2 |= DAC_INIT_CTRL2_DAC_MODE_I2S; + break; + case AUDIO_DAI_FORMAT_LJ: + ctrl2 |= DAC_INIT_CTRL2_DAC_MODE_LJM; + break; + case AUDIO_DAI_FORMAT_RJ: + ctrl2 |= DAC_INIT_CTRL2_DAC_MODE_RJM; + break; + default: + return EINVAL; + } + + ctrl3 &= ~(DAC_INIT_CTRL3_RST_MASK); + ctrl3 |= DAC_INIT_CTRL3_RST_DIS; + + RKCODEC_WRITE(sc, CODEC_DAC_INIT_CTRL1, ctrl1); + RKCODEC_WRITE(sc, CODEC_DAC_INIT_CTRL2, ctrl2); + RKCODEC_WRITE(sc, CODEC_DAC_INIT_CTRL3, ctrl3); + + return (0); +} + +static int +rkcodec_dai_trigger(device_t dev, int go, int pcm_dir) +{ + // struct rkcodec_softc *sc = device_get_softc(dev); + + if ((pcm_dir != PCMDIR_PLAY) && (pcm_dir != PCMDIR_REC)) + return (EINVAL); + + switch (go) { + case PCMTRIG_START: + if (pcm_dir == PCMDIR_PLAY) { + printf("[%s] %s:%d\n", __func__, __FILE__, __LINE__); + } + else if (pcm_dir == PCMDIR_REC) { + printf("[%s] %s:%d\n", __func__, __FILE__, __LINE__); + } + break; + + case PCMTRIG_STOP: + case PCMTRIG_ABORT: + if (pcm_dir == PCMDIR_PLAY) { + printf("[%s] %s:%d\n", __func__, __FILE__, __LINE__); + } + else if (pcm_dir == PCMDIR_REC) { + printf("[%s] %s:%d\n", __func__, __FILE__, __LINE__); + } + break; + } + + return (0); +} + +static int +rkcodec_dai_setup_mixer(device_t dev, device_t pcmdev) +{ + + mixer_init(pcmdev, &rkcodec_mixer_class, dev); + + return (0); +} + +static device_method_t rkcodec_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, rkcodec_probe), + DEVMETHOD(device_attach, rkcodec_attach), + DEVMETHOD(device_detach, rkcodec_detach), + + DEVMETHOD(audio_dai_init, rkcodec_dai_init), + DEVMETHOD(audio_dai_setup_mixer, rkcodec_dai_setup_mixer), + DEVMETHOD(audio_dai_trigger, rkcodec_dai_trigger), + + DEVMETHOD_END +}; + +static driver_t rkcodec_driver = { + "rk3328codec", + rkcodec_methods, + sizeof(struct rkcodec_softc), +}; + +static devclass_t rkcodec_devclass; + +DRIVER_MODULE(rkcodec, simplebus, rkcodec_driver, rkcodec_devclass, 0, 0); +SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm64/rockchip/rk_i2s.c b/sys/arm64/rockchip/rk_i2s.c new file mode 100644 index 000000000000..8f53d8581d5c --- /dev/null +++ b/sys/arm64/rockchip/rk_i2s.c @@ -0,0 +1,657 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Oleksandr Tymoshenko + * + * 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. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "syscon_if.h" + +#include "opt_snd.h" +#include +#include +#include "audio_dai_if.h" + +#define AUDIO_BUFFER_SIZE 48000 * 4 + +#define I2S_TXCR 0x0000 +#define I2S_CSR_2 (0 << 15) +#define I2S_CSR_4 (1 << 15) +#define I2S_CSR_6 (2 << 15) +#define I2S_CSR_8 (3 << 15) +#define I2S_TXCR_IBM_NORMAL (0 << 9) +#define I2S_TXCR_IBM_LJ (1 << 9) +#define I2S_TXCR_IBM_RJ (2 << 9) +#define I2S_TXCR_PBM_NODELAY (0 << 7) +#define I2S_TXCR_PBM_1 (1 << 7) +#define I2S_TXCR_PBM_2 (2 << 7) +#define I2S_TXCR_PBM_3 (3 << 7) +#define I2S_TXCR_TFS_I2S (0 << 5) +#define I2S_TXCR_TFS_PCM (1 << 5) +#define I2S_TXCR_VDW_16 (0xf << 0) +#define I2S_RXCR 0x0004 +#define I2S_RXCR_IBM_NORMAL (0 << 9) +#define I2S_RXCR_IBM_LJ (1 << 9) +#define I2S_RXCR_IBM_RJ (2 << 9) +#define I2S_RXCR_PBM_NODELAY (0 << 7) +#define I2S_RXCR_PBM_1 (1 << 7) +#define I2S_RXCR_PBM_2 (2 << 7) +#define I2S_RXCR_PBM_3 (3 << 7) +#define I2S_RXCR_TFS_I2S (0 << 5) +#define I2S_RXCR_TFS_PCM (1 << 5) +#define I2S_RXCR_VDW_16 (0xf << 0) +#define I2S_CKR 0x0008 +#define I2S_CKR_MSS_MASK (1 << 27) +#define I2S_CKR_MSS_MASTER (0 << 27) +#define I2S_CKR_MSS_SLAVE (1 << 27) +#define I2S_CKR_CKP (1 << 26) +#define I2S_CKR_MDIV(n) (((n) - 1) << 16) +#define I2S_CKR_MDIV_MASK (0xff << 16) +#define I2S_CKR_RSD(n) (((n) - 1) << 8) +#define I2S_CKR_RSD_MASK (0xff << 8) +#define I2S_CKR_TSD(n) (((n) - 1) << 0) +#define I2S_CKR_TSD_MASK (0xff << 0) +#define I2S_TXFIFOLR 0x000c +#define TXFIFO0LR_MASK 0x3f +#define I2S_DMACR 0x0010 +#define I2S_DMACR_RDE_ENABLE (1 << 24) +#define I2S_DMACR_RDL(n) ((n) << 16) +#define I2S_DMACR_TDE_ENABLE (1 << 8) +#define I2S_DMACR_TDL(n) ((n) << 0) +#define I2S_INTCR 0x0014 +#define I2S_INTCR_RFT(n) (((n) - 1) << 20) +#define I2S_INTCR_TFT(n) (((n) - 1) << 4) +#define I2S_INTCR_RXFIE (1 << 16) +#define I2S_INTCR_TXUIC (1 << 2) +#define I2S_INTCR_TXEIE (1 << 0) +#define I2S_INTSR 0x0018 +#define I2S_INTSR_RXFI (1 << 16) +#define I2S_INTSR_TXUI (1 << 1) +#define I2S_INTSR_TXEI (1 << 0) +#define I2S_XFER 0x001c +#define I2S_XFER_RXS_START (1 << 1) +#define I2S_XFER_TXS_START (1 << 0) +#define I2S_CLR 0x0020 +#define I2S_CLR_RXC (1 << 1) +#define I2S_CLR_TXC (1 << 0) +#define I2S_TXDR 0x0024 +#define I2S_RXDR 0x0028 +#define I2S_RXFIFOLR 0x002c +#define RXFIFO0LR_MASK 0x3f + +/* syscon */ +#define GRF_SOC_CON8 0xe220 +#define I2S_IO_DIRECTION_MASK 7 +#define I2S_IO_DIRECTION_SHIFT 11 +#define I2S_IO_8CH_OUT_2CH_IN 0 +#define I2S_IO_6CH_OUT_4CH_IN 4 +#define I2S_IO_4CH_OUT_6CH_IN 6 +#define I2S_IO_2CH_OUT_8CH_IN 7 + +#define DIV_ROUND_CLOSEST(n,d) (((n) + (d) / 2) / (d)) + +#define RK_I2S_SAMPLING_RATE 48000 +#define FIFO_SIZE 32 + +static struct ofw_compat_data compat_data[] = { + { "rockchip,rk3066-i2s", 1 }, + { "rockchip,rk3399-i2s", 1 }, + { NULL, 0 } +}; + +static struct resource_spec rk_i2s_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE }, + { -1, 0 } +}; + +struct rk_i2s_softc { + device_t dev; + struct resource *res[2]; + struct mtx mtx; + clk_t clk; + clk_t hclk; + void * intrhand; + struct syscon *grf; + /* pointers to playback/capture buffers */ + uint32_t play_ptr; + uint32_t rec_ptr; +}; + +#define RK_I2S_LOCK(sc) mtx_lock(&(sc)->mtx) +#define RK_I2S_UNLOCK(sc) mtx_unlock(&(sc)->mtx) +#define RK_I2S_READ_4(sc, reg) bus_read_4((sc)->res[0], (reg)) +#define RK_I2S_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val)) + +static int rk_i2s_probe(device_t dev); +static int rk_i2s_attach(device_t dev); +static int rk_i2s_detach(device_t dev); + +static uint32_t sc_fmt[] = { + SND_FORMAT(AFMT_S16_LE, 2, 0), + 0 +}; +static struct pcmchan_caps rk_i2s_caps = {RK_I2S_SAMPLING_RATE, RK_I2S_SAMPLING_RATE, sc_fmt, 0}; + + +static int +rk_i2s_init(struct rk_i2s_softc *sc) +{ + uint32_t val; + int error; + + clk_set_freq(sc->clk, RK_I2S_SAMPLING_RATE * 256, + CLK_SET_ROUND_DOWN); + error = clk_enable(sc->clk); + if (error != 0) { + device_printf(sc->dev, "cannot enable i2s_clk clock\n"); + return (ENXIO); + } + + val = I2S_INTCR_TFT(FIFO_SIZE/2); + val |= I2S_INTCR_RFT(FIFO_SIZE/2); + RK_I2S_WRITE_4(sc, I2S_INTCR, val); + + if (sc->grf) { + val = (I2S_IO_2CH_OUT_8CH_IN << I2S_IO_DIRECTION_SHIFT); + val |= (I2S_IO_DIRECTION_MASK << I2S_IO_DIRECTION_SHIFT) << 16; + SYSCON_WRITE_4(sc->grf, GRF_SOC_CON8, val); + + #if 0 + // HACK: enable IO domain + val = (1 << 1); + val |= (1 << 1) << 16; + SYSCON_WRITE_4(sc->grf, 0xe640, val); + #endif + } + + RK_I2S_WRITE_4(sc, I2S_XFER, 0); + + return (0); +} + +static int +rk_i2s_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) + return (ENXIO); + + device_set_desc(dev, "Rockchip I2S"); + return (BUS_PROBE_DEFAULT); +} + +static int +rk_i2s_attach(device_t dev) +{ + struct rk_i2s_softc *sc; + int error; + phandle_t node; + + sc = device_get_softc(dev); + sc->dev = dev; + + mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); + + if (bus_alloc_resources(dev, rk_i2s_spec, sc->res) != 0) { + device_printf(dev, "cannot allocate resources for device\n"); + error = ENXIO; + goto fail; + } + + error = clk_get_by_ofw_name(dev, 0, "i2s_hclk", &sc->hclk); + if (error != 0) { + device_printf(dev, "cannot get i2s_hclk clock\n"); + goto fail; + } + + error = clk_get_by_ofw_name(dev, 0, "i2s_clk", &sc->clk); + if (error != 0) { + device_printf(dev, "cannot get i2s_clk clock\n"); + goto fail; + } + + /* Activate the module clock. */ + error = clk_enable(sc->hclk); + if (error != 0) { + device_printf(dev, "cannot enable i2s_hclk clock\n"); + goto fail; + } + + node = ofw_bus_get_node(dev); + if (OF_hasprop(node, "rockchip,grf") && + syscon_get_by_ofw_property(dev, node, + "rockchip,grf", &sc->grf) != 0) { + device_printf(dev, "cannot get grf driver handle\n"); + return (ENXIO); + } + + rk_i2s_init(sc); + + OF_device_register_xref(OF_xref_from_node(node), dev); + + return (0); + +fail: + rk_i2s_detach(dev); + return (error); +} + +static int +rk_i2s_detach(device_t dev) +{ + struct rk_i2s_softc *i2s; + + i2s = device_get_softc(dev); + + if (i2s->hclk != NULL) + clk_release(i2s->hclk); + if (i2s->clk) + clk_release(i2s->clk); + + if (i2s->intrhand != NULL) + bus_teardown_intr(i2s->dev, i2s->res[1], i2s->intrhand); + + bus_release_resources(dev, rk_i2s_spec, i2s->res); + mtx_destroy(&i2s->mtx); + + return (0); +} + +static int +rk_i2s_dai_init(device_t dev, uint32_t format) +{ + uint32_t val, txcr, rxcr; + struct rk_i2s_softc *sc; + int fmt, pol, clk; + + sc = device_get_softc(dev); + + fmt = AUDIO_DAI_FORMAT_FORMAT(format); + pol = AUDIO_DAI_FORMAT_POLARITY(format); + clk = AUDIO_DAI_FORMAT_CLOCK(format); + + /* Set format */ + val = RK_I2S_READ_4(sc, I2S_CKR); + + val &= ~(I2S_CKR_MSS_MASK); + switch (clk) { + case AUDIO_DAI_CLOCK_CBM_CFM: + val |= I2S_CKR_MSS_MASTER; + break; + case AUDIO_DAI_CLOCK_CBS_CFS: + val |= I2S_CKR_MSS_SLAVE; + break; + default: + return (EINVAL); + } + + switch (pol) { + case AUDIO_DAI_POLARITY_IB_NF: + val |= I2S_CKR_CKP; + break; + case AUDIO_DAI_POLARITY_NB_NF: + val &= ~I2S_CKR_CKP; + break; + default: + return (EINVAL); + } + + RK_I2S_WRITE_4(sc, I2S_CKR, val); + + txcr = I2S_TXCR_VDW_16 | I2S_CSR_2; + rxcr = I2S_RXCR_VDW_16 | I2S_CSR_2; + + switch (fmt) { + case AUDIO_DAI_FORMAT_I2S: + txcr |= I2S_TXCR_IBM_NORMAL; + rxcr |= I2S_RXCR_IBM_NORMAL; + break; + case AUDIO_DAI_FORMAT_LJ: + txcr |= I2S_TXCR_IBM_LJ; + rxcr |= I2S_RXCR_IBM_LJ; + break; + case AUDIO_DAI_FORMAT_RJ: *** 314 LINES SKIPPED *** From nobody Sat Nov 6 17:52: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 0945A185596B; Sat, 6 Nov 2021 17:52: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 4HmlM76Zb9z4V6P; Sat, 6 Nov 2021 17:52: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 C3505781F; Sat, 6 Nov 2021 17:52: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 1A6HqJvT030367; Sat, 6 Nov 2021 17:52:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HqJbV030366; Sat, 6 Nov 2021 17:52:19 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:52:19 GMT Message-Id: <202111061752.1A6HqJbV030366@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 8c9bdaf227b1 - main - rk3328_codec: fix a problem with the enable value 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8c9bdaf227b1b83279ff76446e5fc226e19088d0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=8c9bdaf227b1b83279ff76446e5fc226e19088d0 commit 8c9bdaf227b1b83279ff76446e5fc226e19088d0 Author: Andriy Gapon AuthorDate: 2021-06-09 07:51:00 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:51:14 +0000 rk3328_codec: fix a problem with the enable value The previous value contained only the mask bit ("twice"), but not the value bit. While here, make a couple of lines a little bit prettier. MFC after: 1 month --- sys/arm64/rockchip/rk3328_codec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/arm64/rockchip/rk3328_codec.c b/sys/arm64/rockchip/rk3328_codec.c index 940b3b8bb9e8..c2ffe1e8089f 100644 --- a/sys/arm64/rockchip/rk3328_codec.c +++ b/sys/arm64/rockchip/rk3328_codec.c @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #define SOC_CON10_GPIOMUT (1 << 1) #define SOC_CON10_GPIOMUT_MASK ((1 << 1) << 16) #define SOC_CON10_GPIOMUT_EN (1 << 0) -#define SOC_CON10_GPIOMUT_EN_MASK ((1 << 0) << 16) +#define SOC_CON10_GPIOMUT_EN_MASK ((1 << 0) << 16) #define CODEC_RESET 0x00 #define RESET_DIG_CORE_RST (1 << 1) @@ -247,10 +247,10 @@ rkcodec_attach(device_t dev) return (ENXIO); } - val = SOC_CON2_I2S_ACODEC_EN_MASK | (SOC_CON2_I2S_ACODEC_EN << 16); + val = SOC_CON2_I2S_ACODEC_EN | SOC_CON2_I2S_ACODEC_EN_MASK; SYSCON_WRITE_4(sc->grf, GRF_SOC_CON2, val); - val = 0 | (SOC_CON10_GPIOMUT_EN << 16); + val = 0 | SOC_CON10_GPIOMUT_EN_MASK; SYSCON_WRITE_4(sc->grf, GRF_SOC_CON10, val); error = clk_get_by_ofw_name(dev, 0, "pclk", &sc->pclk); From nobody Sat Nov 6 17:52: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 980CE18559E6; Sat, 6 Nov 2021 17:52:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmlM926Fvz4VFg; Sat, 6 Nov 2021 17:52: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 05B3B7A11; Sat, 6 Nov 2021 17:52: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 1A6HqK5J030391; Sat, 6 Nov 2021 17:52:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HqKR6030390; Sat, 6 Nov 2021 17:52:20 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:52:20 GMT Message-Id: <202111061752.1A6HqKR6030390@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 5d1a2edeec2e - main - rk_i2s: modify GRF_SOC_CON8 only for rk3399 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d1a2edeec2eb8221b42a7c887f9b2b8e0a17423 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=5d1a2edeec2eb8221b42a7c887f9b2b8e0a17423 commit 5d1a2edeec2eb8221b42a7c887f9b2b8e0a17423 Author: Andriy Gapon AuthorDate: 2021-06-09 08:02:36 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:51:36 +0000 rk_i2s: modify GRF_SOC_CON8 only for rk3399 The register definition has nothing to do with, e.g., rk3328. MFC after: 1 month --- sys/arm64/rockchip/rk_i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm64/rockchip/rk_i2s.c b/sys/arm64/rockchip/rk_i2s.c index 8f53d8581d5c..52f80789a795 100644 --- a/sys/arm64/rockchip/rk_i2s.c +++ b/sys/arm64/rockchip/rk_i2s.c @@ -195,7 +195,7 @@ rk_i2s_init(struct rk_i2s_softc *sc) val |= I2S_INTCR_RFT(FIFO_SIZE/2); RK_I2S_WRITE_4(sc, I2S_INTCR, val); - if (sc->grf) { + if (sc->grf && ofw_bus_is_compatible(sc->dev, "rockchip,rk3399-i2s")) { val = (I2S_IO_2CH_OUT_8CH_IN << I2S_IO_DIRECTION_SHIFT); val |= (I2S_IO_DIRECTION_MASK << I2S_IO_DIRECTION_SHIFT) << 16; SYSCON_WRITE_4(sc->grf, GRF_SOC_CON8, val); From nobody Sat Nov 6 17:52: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 02E741855859; Sat, 6 Nov 2021 17:52: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 4HmlMB3zvPz4VCc; Sat, 6 Nov 2021 17:52: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 1BA22777C; Sat, 6 Nov 2021 17:52: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 1A6HqMrK030422; Sat, 6 Nov 2021 17:52:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HqMXV030420; Sat, 6 Nov 2021 17:52:22 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:52:22 GMT Message-Id: <202111061752.1A6HqMXV030420@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 69d202f22400 - main - rk3328_codec: bump delays in set_power and set_mute 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 69d202f22400c5b64331fbbcd37b66df8d265c64 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=69d202f22400c5b64331fbbcd37b66df8d265c64 commit 69d202f22400c5b64331fbbcd37b66df8d265c64 Author: Andriy Gapon AuthorDate: 2021-06-09 08:58:42 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:51:44 +0000 rk3328_codec: bump delays in set_power and set_mute According to Linux they should be 10 ms, not 10 us. Also, add a read before the second write in set_power. MFC after: 1 month --- sys/arm64/rockchip/rk3328_codec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/arm64/rockchip/rk3328_codec.c b/sys/arm64/rockchip/rk3328_codec.c index c2ffe1e8089f..22f36389e1c6 100644 --- a/sys/arm64/rockchip/rk3328_codec.c +++ b/sys/arm64/rockchip/rk3328_codec.c @@ -178,7 +178,10 @@ rkcodec_set_power(struct rkcodec_softc *sc, bool poweron) else val &= ~(DAC_PRECHARGE_CTRL_DAC_CHARGE_PRECHARGE); RKCODEC_WRITE(sc, CODEC_DAC_PRECHARGE_CTRL, val); - DELAY(10); + + DELAY(10000); + + val = RKCODEC_READ(sc, CODEC_DAC_PRECHARGE_CTRL); if (poweron) val |= DAC_PRECHARGE_CTRL_DAC_CHARGE_CURRENT_ALL; else @@ -202,7 +205,7 @@ rkcodec_reset(struct rkcodec_softc *sc) { RKCODEC_WRITE(sc, CODEC_RESET, 0); - DELAY(10); + DELAY(10000); RKCODEC_WRITE(sc, CODEC_RESET, RESET_DIG_CORE_RST | RESET_SYS_RST); } From nobody Sat Nov 6 17:52: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 2D0251855CC3; Sat, 6 Nov 2021 17:52:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmlMD38fmz4V6l; Sat, 6 Nov 2021 17: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 443B377E6; Sat, 6 Nov 2021 17:52: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 1A6HqNEH030446; Sat, 6 Nov 2021 17:52:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6HqNgg030445; Sat, 6 Nov 2021 17:52:23 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:52:23 GMT Message-Id: <202111061752.1A6HqNgg030445@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 507fdedd83cd - main - rk3328_codec: add delays between register writes in the initial setup 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 507fdedd83cd7aca7f1b208e93e9128d7da02b11 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=507fdedd83cd7aca7f1b208e93e9128d7da02b11 commit 507fdedd83cd7aca7f1b208e93e9128d7da02b11 Author: Andriy Gapon AuthorDate: 2021-06-09 09:10:50 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:51:50 +0000 rk3328_codec: add delays between register writes in the initial setup MFC after: 1 month --- sys/arm64/rockchip/rk3328_codec.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/arm64/rockchip/rk3328_codec.c b/sys/arm64/rockchip/rk3328_codec.c index 22f36389e1c6..b00a61f58054 100644 --- a/sys/arm64/rockchip/rk3328_codec.c +++ b/sys/arm64/rockchip/rk3328_codec.c @@ -296,61 +296,77 @@ rkcodec_attach(device_t dev) val = RKCODEC_READ(sc, CODEC_DAC_PWR_CTRL); val |= DAC_PWR_CTRL_DAC_PWR; RKCODEC_WRITE(sc, CODEC_DAC_PWR_CTRL, val); + DELAY(1000); val |= DAC_PWR_CTRL_DACL_PATH_REFV | DAC_PWR_CTRL_DACR_PATH_REFV; RKCODEC_WRITE(sc, CODEC_DAC_PWR_CTRL, val); + DELAY(1000); val |= DAC_PWR_CTRL_HPOUTL_ZERO_CROSSING | DAC_PWR_CTRL_HPOUTR_ZERO_CROSSING; RKCODEC_WRITE(sc, CODEC_DAC_PWR_CTRL, val); + DELAY(1000); val = RKCODEC_READ(sc, CODEC_HPOUT_POP_CTRL); val |= HPOUT_POP_CTRL_HPOUTR_POP | HPOUT_POP_CTRL_HPOUTL_POP; val &= ~(HPOUT_POP_CTRL_HPOUTR_POP_XCHARGE | HPOUT_POP_CTRL_HPOUTL_POP_XCHARGE); RKCODEC_WRITE(sc, CODEC_HPOUT_POP_CTRL, val); + DELAY(1000); val = RKCODEC_READ(sc, CODEC_HPMIX_CTRL); val |= HPMIX_CTRL_HPMIXL_EN | HPMIX_CTRL_HPMIXR_EN; RKCODEC_WRITE(sc, CODEC_HPMIX_CTRL, val); + DELAY(1000); val |= HPMIX_CTRL_HPMIXL_INIT_EN | HPMIX_CTRL_HPMIXR_INIT_EN; RKCODEC_WRITE(sc, CODEC_HPMIX_CTRL, val); + DELAY(1000); val = RKCODEC_READ(sc, CODEC_HPOUT_CTRL); val |= HPOUT_CTRL_HPOUTL_EN | HPOUT_CTRL_HPOUTR_EN; RKCODEC_WRITE(sc, CODEC_HPOUT_CTRL, val); + DELAY(1000); val |= HPOUT_CTRL_HPOUTL_INIT_EN | HPOUT_CTRL_HPOUTR_INIT_EN; RKCODEC_WRITE(sc, CODEC_HPOUT_CTRL, val); + DELAY(1000); val = RKCODEC_READ(sc, CODEC_DAC_CLK_CTRL); val |= DAC_CLK_CTRL_DACL_REFV_ON | DAC_CLK_CTRL_DACR_REFV_ON; RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + DELAY(1000); val |= DAC_CLK_CTRL_DACL_CLK_ON | DAC_CLK_CTRL_DACR_CLK_ON; RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + DELAY(1000); val |= DAC_CLK_CTRL_DACL_ON | DAC_CLK_CTRL_DACR_ON; RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + DELAY(1000); val |= DAC_CLK_CTRL_DACL_INIT_ON | DAC_CLK_CTRL_DACR_INIT_ON; RKCODEC_WRITE(sc, CODEC_DAC_CLK_CTRL, val); + DELAY(1000); val = RKCODEC_READ(sc, CODEC_DAC_SELECT); val |= DAC_SELECT_DACL_SELECT | DAC_SELECT_DACR_SELECT; RKCODEC_WRITE(sc, CODEC_DAC_SELECT, val); + DELAY(1000); val = RKCODEC_READ(sc, CODEC_HPMIX_CTRL); val |= HPMIX_CTRL_HPMIXL_INIT2_EN | HPMIX_CTRL_HPMIXR_INIT2_EN; RKCODEC_WRITE(sc, CODEC_HPMIX_CTRL, val); + DELAY(1000); val = RKCODEC_READ(sc, CODEC_HPOUT_CTRL); val |= HPOUT_CTRL_HPOUTL_UNMUTE | HPOUT_CTRL_HPOUTR_UNMUTE; RKCODEC_WRITE(sc, CODEC_HPOUT_CTRL, val); + DELAY(1000); RKCODEC_WRITE(sc, CODEC_HPOUTL_GAIN_CTRL, 0x1f); RKCODEC_WRITE(sc, CODEC_HPOUTR_GAIN_CTRL, 0x1f); + DELAY(1000); rkcodec_set_mute(sc, false); From nobody Sat Nov 6 17: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 410671855E81; Sat, 6 Nov 2021 17:52:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmlMF4Tlkz4VCw; Sat, 6 Nov 2021 17:52:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63CFE77E7; Sat, 6 Nov 2021 17: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 1A6HqOaP030470; Sat, 6 Nov 2021 17: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 1A6HqOJM030469; Sat, 6 Nov 2021 17:52:24 GMT (envelope-from git) Date: Sat, 6 Nov 2021 17:52:24 GMT Message-Id: <202111061752.1A6HqOJM030469@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 2d1de2d55320 - main - rk3328_codec: set output gain to the value found in 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2d1de2d55320fdc218a82ccb5116ab61aeb20fca Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=2d1de2d55320fdc218a82ccb5116ab61aeb20fca commit 2d1de2d55320fdc218a82ccb5116ab61aeb20fca Author: Andriy Gapon AuthorDate: 2021-06-09 08:50:55 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:52:00 +0000 rk3328_codec: set output gain to the value found in linux According to Linux code the new value should correspond to 0dB gain while the original value corresponded to 6dB gain which may be uncomfortable for some output types. MFC after: 1 month --- sys/arm64/rockchip/rk3328_codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/arm64/rockchip/rk3328_codec.c b/sys/arm64/rockchip/rk3328_codec.c index b00a61f58054..2a5f652fa8c2 100644 --- a/sys/arm64/rockchip/rk3328_codec.c +++ b/sys/arm64/rockchip/rk3328_codec.c @@ -364,8 +364,8 @@ rkcodec_attach(device_t dev) RKCODEC_WRITE(sc, CODEC_HPOUT_CTRL, val); DELAY(1000); - RKCODEC_WRITE(sc, CODEC_HPOUTL_GAIN_CTRL, 0x1f); - RKCODEC_WRITE(sc, CODEC_HPOUTR_GAIN_CTRL, 0x1f); + RKCODEC_WRITE(sc, CODEC_HPOUTL_GAIN_CTRL, 0x18); + RKCODEC_WRITE(sc, CODEC_HPOUTR_GAIN_CTRL, 0x18); DELAY(1000); rkcodec_set_mute(sc, false); From nobody Sat Nov 6 18:00: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 1476E1833163; Sat, 6 Nov 2021 18:00:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmlY507Hhz4ZTR; Sat, 6 Nov 2021 18:00:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D84A97828; Sat, 6 Nov 2021 18:00:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6I0u9A044311; Sat, 6 Nov 2021 18:00:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6I0uQh044310; Sat, 6 Nov 2021 18:00:56 GMT (envelope-from git) Date: Sat, 6 Nov 2021 18:00:56 GMT Message-Id: <202111061800.1A6I0uQh044310@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: cc0b35259aed - main - rk805: add system poweroff support 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cc0b35259aed73747721718415fa1854108a276a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=cc0b35259aed73747721718415fa1854108a276a commit cc0b35259aed73747721718415fa1854108a276a Author: Andriy Gapon AuthorDate: 2021-11-06 17:58:43 +0000 Commit: Andriy Gapon CommitDate: 2021-11-06 17:58:43 +0000 rk805: add system poweroff support On my Rock64 neither EFI nor PSCI shutdown actually power off the board. RK805 does the job. Reviewed by: manu, peterj Differential Revision: https://reviews.freebsd.org/D30786 --- sys/arm64/rockchip/rk805.c | 36 ++++++++++++++++++++++++++++++++++++ sys/arm64/rockchip/rk805reg.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/sys/arm64/rockchip/rk805.c b/sys/arm64/rockchip/rk805.c index a2ee53b35a07..d3bda29ae362 100644 --- a/sys/arm64/rockchip/rk805.c +++ b/sys/arm64/rockchip/rk805.c @@ -31,8 +31,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include @@ -844,6 +846,29 @@ rk805_settime(device_t dev, struct timespec *ts) return (error); } +static void +rk805_poweroff(void *arg, int howto) +{ + device_t dev = arg; + int error; + uint8_t val; + + if ((howto & RB_POWEROFF) == 0) + return; + + device_printf(dev, "Powering off...\n"); + error = rk805_read(dev, RK805_DEV_CTRL, &val, 1); + if (error == 0) { + val |= RK805_DEV_CTRL_OFF; + error = rk805_write(dev, RK805_DEV_CTRL, &val, 1); + + /* Wait a bit for the command to take effect. */ + if (error == 0) + DELAY(100); + } + device_printf(dev, "Power off failed\n"); +} + static int rk805_attach(device_t dev) { @@ -907,6 +932,17 @@ rk805_attach(device_t dev) } } + if (OF_hasprop(ofw_bus_get_node(dev), + "rockchip,system-power-controller")) { + /* + * The priority is chosen to override PSCI and EFI shutdown + * methods as those two just hang without powering off on Rock64 + * at least. + */ + EVENTHANDLER_REGISTER(shutdown_final, rk805_poweroff, dev, + SHUTDOWN_PRI_LAST - 2); + } + return (0); } diff --git a/sys/arm64/rockchip/rk805reg.h b/sys/arm64/rockchip/rk805reg.h index b1f4481a5b68..61c6f49abd2c 100644 --- a/sys/arm64/rockchip/rk805reg.h +++ b/sys/arm64/rockchip/rk805reg.h @@ -93,6 +93,10 @@ #define RK808_LDO8_ON_VSEL 0x49 #define RK808_LDO8_SLEEP_VSEL 0x4A +#define RK805_DEV_CTRL 0x4B +#define RK805_DEV_CTRL_OFF (1 << 0) +#define RK805_DEV_CTRL_SLP (1 << 1) + enum rk805_regulator { RK805_DCDC1 = 0, RK805_DCDC2, From nobody Sat Nov 6 20:30: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 31E16183979B; Sat, 6 Nov 2021 20:30: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 4Hmpsw0qYJz3Mcw; Sat, 6 Nov 2021 20:30: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 F1C5611A21; Sat, 6 Nov 2021 20:30: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 1A6KUhoX039747; Sat, 6 Nov 2021 20:30:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6KUht7039746; Sat, 6 Nov 2021 20:30:43 GMT (envelope-from git) Date: Sat, 6 Nov 2021 20:30:43 GMT Message-Id: <202111062030.1A6KUht7039746@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: f0c9847a6c47 - main - vfs: Add "ioflag" and "cred" arguments to VOP_ALLOCATE 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: f0c9847a6c477430d6fff647b12e9e9e2b461f2a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f0c9847a6c477430d6fff647b12e9e9e2b461f2a commit f0c9847a6c477430d6fff647b12e9e9e2b461f2a Author: Rick Macklem AuthorDate: 2021-11-06 20:26:43 +0000 Commit: Rick Macklem CommitDate: 2021-11-06 20:26:43 +0000 vfs: Add "ioflag" and "cred" arguments to VOP_ALLOCATE When the NFSv4.2 server does a VOP_ALLOCATE(), it needs the operation to be done for the RPC's credential and not td_ucred. It also needs the writing to be done synchronously. This patch adds "ioflag" and "cred" arguments to VOP_ALLOCATE() and modifies vop_stdallocate() to use these arguments. The VOP_ALLOCATE.9 man page will be patched separately. Reviewed by: khng, kib Differential Revision: https://reviews.freebsd.org/D32865 --- sys/fs/nfsclient/nfs_clvnops.c | 2 +- sys/fs/nfsserver/nfs_nfsdport.c | 2 +- sys/kern/vfs_default.c | 10 +++++----- sys/kern/vfs_vnops.c | 3 ++- sys/kern/vnode_if.src | 2 ++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index abccf82e3ff0..d4545cf2d840 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3731,7 +3731,7 @@ nfs_allocate(struct vop_allocate_args *ap) if ((uint64_t)alen > nfs_maxalloclen) alen = nfs_maxalloclen; error = nfsrpc_allocate(vp, *ap->a_offset, alen, - &nfsva, &attrflag, td->td_ucred, td, NULL); + &nfsva, &attrflag, ap->a_cred, td, NULL); } if (error == 0) { *ap->a_offset += alen; diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 5fa6853446ae..806f4a8545b8 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -6598,7 +6598,7 @@ nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, */ do { olen = len; - error = VOP_ALLOCATE(vp, &off, &len); + error = VOP_ALLOCATE(vp, &off, &len, IO_SYNC, cred); if (error == 0 && len > 0 && olen > len) maybe_yield(); } while (error == 0 && len > 0 && olen > len); diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d66443e6d6f0..02fae41e3404 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -963,7 +963,7 @@ vop_stdallocate(struct vop_allocate_args *ap) len = *ap->a_len; offset = *ap->a_offset; - error = VOP_GETATTR(vp, vap, td->td_ucred); + error = VOP_GETATTR(vp, vap, ap->a_cred); if (error != 0) goto out; fsize = vap->va_size; @@ -1000,12 +1000,12 @@ vop_stdallocate(struct vop_allocate_args *ap) */ VATTR_NULL(vap); vap->va_size = offset + len; - error = VOP_SETATTR(vp, vap, td->td_ucred); + error = VOP_SETATTR(vp, vap, ap->a_cred); if (error != 0) goto out; VATTR_NULL(vap); vap->va_size = fsize; - error = VOP_SETATTR(vp, vap, td->td_ucred); + error = VOP_SETATTR(vp, vap, ap->a_cred); if (error != 0) goto out; } @@ -1031,7 +1031,7 @@ vop_stdallocate(struct vop_allocate_args *ap) auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_READ; auio.uio_td = td; - error = VOP_READ(vp, &auio, 0, td->td_ucred); + error = VOP_READ(vp, &auio, ap->a_ioflag, ap->a_cred); if (error != 0) break; if (auio.uio_resid > 0) { @@ -1052,7 +1052,7 @@ vop_stdallocate(struct vop_allocate_args *ap) auio.uio_rw = UIO_WRITE; auio.uio_td = td; - error = VOP_WRITE(vp, &auio, 0, td->td_ucred); + error = VOP_WRITE(vp, &auio, ap->a_ioflag, ap->a_cred); if (error != 0) break; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index d6c472995489..79d422aacfef 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3466,7 +3466,8 @@ vn_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td) error = mac_vnode_check_write(td->td_ucred, fp->f_cred, vp); if (error == 0) #endif - error = VOP_ALLOCATE(vp, &offset, &len); + error = VOP_ALLOCATE(vp, &offset, &len, 0, + td->td_ucred); VOP_UNLOCK(vp); vn_finished_write(mp); diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index d10758019b87..276382738504 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -702,6 +702,8 @@ vop_allocate { IN struct vnode *vp; INOUT off_t *offset; INOUT off_t *len; + IN int ioflag; + IN struct ucred *cred; }; From nobody Sat Nov 6 20:38: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 4AAED183D8C2; Sat, 6 Nov 2021 20:38:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmq2S1VJMz3Q7v; Sat, 6 Nov 2021 20:38: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 0CE7C11CC2; Sat, 6 Nov 2021 20:38: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 1A6Kc76a044441; Sat, 6 Nov 2021 20:38:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6Kc7G6044440; Sat, 6 Nov 2021 20:38:07 GMT (envelope-from git) Date: Sat, 6 Nov 2021 20:38:07 GMT Message-Id: <202111062038.1A6Kc7G6044440@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: 0c276dee030b - main - param.h: Bump __FreeBSD_version for commit f0c9847a6c47 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: 0c276dee030b241e12e1ceb1b2ab619004f08ce1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=0c276dee030b241e12e1ceb1b2ab619004f08ce1 commit 0c276dee030b241e12e1ceb1b2ab619004f08ce1 Author: Rick Macklem AuthorDate: 2021-11-06 20:34:56 +0000 Commit: Rick Macklem CommitDate: 2021-11-06 20:34:56 +0000 param.h: Bump __FreeBSD_version for commit f0c9847a6c47 Commit f0c9847a6c47 changed the arguments for VOP_ALLOCATE. Bump __FreeBSD_version to 1400041. --- 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 f4beaf0ec408..61774a80e2f9 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 1400040 +#define __FreeBSD_version 1400041 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Sat Nov 6 20:43: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 C055F183F60F; Sat, 6 Nov 2021 20:43:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmq9B52SDz3h0G; Sat, 6 Nov 2021 20:43:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8DE1D11D56; Sat, 6 Nov 2021 20:43:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6Khwnv058031; Sat, 6 Nov 2021 20:43:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6KhwlB058030; Sat, 6 Nov 2021 20:43:58 GMT (envelope-from git) Date: Sat, 6 Nov 2021 20:43:58 GMT Message-Id: <202111062043.1A6KhwlB058030@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: 25b0021d401b - main - UPDATING: Add entry for commit f0c9847a6c47 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: 25b0021d401bdbc28980255f69dfadbd64e58564 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=25b0021d401bdbc28980255f69dfadbd64e58564 commit 25b0021d401bdbc28980255f69dfadbd64e58564 Author: Rick Macklem AuthorDate: 2021-11-06 20:40:50 +0000 Commit: Rick Macklem CommitDate: 2021-11-06 20:40:50 +0000 UPDATING: Add entry for commit f0c9847a6c47 --- UPDATING | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UPDATING b/UPDATING index 765722b62617..bd79cda17aa3 100644 --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 14.x IS SLOW: world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20211106: + Commit f0c9847a6c47 changed the arguments for VOP_ALLOCATE. + The NFS modules must be rebuilt from sources and any out + of tree file systems that implement their own VOP_ALLOCATE + may need to be modified. + 20211022: The synchronous PPP kernel driver sppp(4) has been removed. The cp(4) and ce(4) drivers are now always compiled with netgraph(4) From nobody Sat Nov 6 22:25: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 3CE641856126; Sat, 6 Nov 2021 22:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HmsQC1CBDz4lR3; Sat, 6 Nov 2021 22:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 056B31354C; Sat, 6 Nov 2021 22:25:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A6MPMZW091595; Sat, 6 Nov 2021 22:25:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A6MPMbu091594; Sat, 6 Nov 2021 22:25:22 GMT (envelope-from git) Date: Sat, 6 Nov 2021 22:25:22 GMT Message-Id: <202111062225.1A6MPMbu091594@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: 3fe0a5d2f6e3 - main - Awk: Add error 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3fe0a5d2f6e3b13320732f21aa51141333ef92b9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3fe0a5d2f6e3b13320732f21aa51141333ef92b9 commit 3fe0a5d2f6e3b13320732f21aa51141333ef92b9 Author: Warner Losh AuthorDate: 2021-11-06 22:24:36 +0000 Commit: Warner Losh CommitDate: 2021-11-06 22:24:36 +0000 Awk: Add error file Add the expected output on stderr file. Sponsored by: Netflix --- contrib/one-true-awk/bugs-fixed/pfile-overflow.err | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/one-true-awk/bugs-fixed/pfile-overflow.err b/contrib/one-true-awk/bugs-fixed/pfile-overflow.err new file mode 100644 index 000000000000..d2507df70e0c --- /dev/null +++ b/contrib/one-true-awk/bugs-fixed/pfile-overflow.err @@ -0,0 +1,4 @@ +awk: syntax error at source line 1 source file pfile-overflow.awk + context is + >>> <<< +awk: bailing out at source line 1 source file pfile-overflow.awk From nobody Sun Nov 7 01:53: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 28A1B1854D50; Sun, 7 Nov 2021 01:53:52 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hmy2l6psmz4v2p; Sun, 7 Nov 2021 01:53:51 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id jTsPm4JcFps7PjXNXmRA2l; Sun, 07 Nov 2021 01:53:51 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id jXNVm2Gkc1ykvjXNWmXCjB; Sun, 07 Nov 2021 01:53:51 +0000 X-Authority-Analysis: v=2.4 cv=DLqcXgBb c=1 sm=1 tr=0 ts=618731af a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=kj9zAlcOel0A:10 a=vIxV3rELxO4A:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=EkcXrb_YAAAA:8 a=ypVJL4-jAAAA:8 a=7wxGZsl52zzSAFj4mXEA:9 a=JOWeiY5itpwPQvuQ8dm/GawRuwE=:19 a=sSj7MGH7lQmzwXWU:21 a=CjuIK1q_8ugA:10 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 a=LK5xJRSDVpKd5WXXoEvA:22 a=khIbc0fXALFIcTpOSxgJ:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 2C97B6DE; Sat, 6 Nov 2021 18:53:48 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 1A71rl5H004446; Sat, 6 Nov 2021 18:53:47 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202111070153.1A71rl5H004446@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: Wojciech Macek cc: Shawn Webb , Wojciech Macek , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 0dedcdaa1a02 - main - Revert "ossl: Add support for ETA mode" In-reply-to: References: <202111061646.1A6GkIj4036877@gitrepo.freebsd.org> <20211106165946.zrj7fonoxbca3cj2@mutt-hbsd> Comments: In-reply-to Wojciech Macek message dated "Sat, 06 Nov 2021 18:33:25 +0100." 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 Date: Sat, 06 Nov 2021 18:53:47 -0700 X-CMAE-Envelope: MS4xfDLT9x1qZz0KDFTaoU9CDL+BsqEbl3mPMGxvMK/iu7H3vLZShDjRoolnOWppGK653+BjG4x5Tt5ZkoPpAYpd6MWodracObc/vKmct7+TFAHWuLfbtY1o zDUVZOPp5erORcu2dERKsAZNL/tcpz8+jJM389tpsMlJp8PgsmGiFRvDPYD/f2GSrPDw2m4SeOdUO0ZODy2b8xkSVmz5Tv3DWlM8DRCSNF5rfs088Z+KK7Hr eVyCAIGmoA6ZObMZs1uTV88G4JtzGfOCfgnAtdlmgGzCtkiqZWX8X2VPhJVtWQSrsCdYK/BcugqAhN8cQ52uM8HZZqQZZGa5AWHPz/Dmy1NC79yoDFuSfwFj 9XkOu7u9lBtM0+Zf/YfNidSviLbFW2NEZ9NgHvAJ8/Gb1XH9eRA= X-Rspamd-Queue-Id: 4Hmy2l6psmz4v2p X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N This should have been documented in the commit log message. Now people reading the log months from now will be left wondering. -- 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. In message , Wojciech Macek writes: > --000000000000e1216d05d0222833 > Content-Type: text/plain; charset="UTF-8" > Content-Transfer-Encoding: quoted-printable > > It breaks linker for arm64-LINT kernel. Will fix and push it back next week= > . > > sob., 6 lis 2021, 17:59 u=C5=BCytkownik Shawn Webb org> > napisa=C5=82: > > > On Sat, Nov 06, 2021 at 04:46:18PM +0000, Wojciech Macek wrote: > > > The branch main has been updated by wma: > > > > > > URL: > > https://cgit.FreeBSD.org/src/commit/?id=3D0dedcdaa1a023d46c8951f03cd2f9df= > 7ae025675 > > > > > > commit 0dedcdaa1a023d46c8951f03cd2f9df7ae025675 > > > Author: Wojciech Macek > > > AuthorDate: 2021-11-06 16:45:50 +0000 > > > Commit: Wojciech Macek > > > CommitDate: 2021-11-06 16:45:50 +0000 > > > > > > Revert "ossl: Add support for ETA mode" > > > > > > This reverts commit 048a71b46e816de8fb95b553a8ad0e98c0d51e12. > > > > Why? > > > > -- > > Shawn Webb > > Cofounder / Security Engineer > > HardenedBSD > > > > > > https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/0= > 3A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc > > > > --000000000000e1216d05d0222833 > Content-Type: text/html; charset="UTF-8" > Content-Transfer-Encoding: quoted-printable > >
It breaks linker for arm64-LINT kernel. Will fix and push= > it back next week.

ass=3D"gmail_attr">sob., 6 lis 2021, 17:59 u=C5=BCytkownik Shawn Webb <<= > a href=3D"mailto:shawn.webb@hardenedbsd.org">shawn.webb@hardenedbsd.org= > > napisa=C5=82:
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Nov 06, = > 2021 at 04:46:18PM +0000, Wojciech Macek wrote:
> > The branch main has been updated by wma:
> >
> > URL: 3d46c8951f03cd2f9df7ae025675" rel=3D"noreferrer noreferrer" target=3D"_blan= > k">https://cgit.FreeBSD.org/src/commit/?id=3D0dedcdaa1a023d46c8951f03cd2f9d= > f7ae025675
> >
> > commit 0dedcdaa1a023d46c8951f03cd2f9df7ae025675
> > Author:=C2=A0 =C2=A0 =C2=A0Wojciech Macek <wma@FreeBSD.org>
> > AuthorDate: 2021-11-06 16:45:50 +0000
> > Commit:=C2=A0 =C2=A0 =C2=A0Wojciech Macek <wma@FreeBSD.org>
> > CommitDate: 2021-11-06 16:45:50 +0000
> >
> >=C2=A0 =C2=A0 =C2=A0Revert "ossl: Add support for ETA mode" r> > >=C2=A0 =C2=A0 =C2=A0
> >=C2=A0 =C2=A0 =C2=A0This reverts commit 048a71b46e816de8fb95b553a8ad0e9= > 8c0d51e12.
>
> Why?
>
> --
> Shawn Webb
> Cofounder / Security Engineer
> HardenedBSD
>
> wn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc" rel=3D"noreferrer= > noreferrer" target=3D"_blank">https://git.hardenedbsd.org/hardenedbsd/pubk= > eys/-/raw/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.as= > c
>
> > --000000000000e1216d05d0222833-- > From nobody Sun Nov 7 02:44: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 EDBBB1846F07; Sun, 7 Nov 2021 02:44: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 4Hmz9f6P19z3QWM; Sun, 7 Nov 2021 02:44: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 B819F167A6; Sun, 7 Nov 2021 02:44:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A72isoi037337; Sun, 7 Nov 2021 02:44:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A72isYX037336; Sun, 7 Nov 2021 02:44:54 GMT (envelope-from git) Date: Sun, 7 Nov 2021 02:44:54 GMT Message-Id: <202111070244.1A72isYX037336@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: ec071430a782 - main - powerd(8): Add rc.conf(5) to see also 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: ec071430a7822997619fe6d99853d8f49ea10b20 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=ec071430a7822997619fe6d99853d8f49ea10b20 commit ec071430a7822997619fe6d99853d8f49ea10b20 Author: Felix Johnson AuthorDate: 2021-11-07 02:39:23 +0000 Commit: Guangyuan Yang CommitDate: 2021-11-07 02:43:30 +0000 powerd(8): Add rc.conf(5) to see also powerd_flags is mentioned in rc.conf(5) and can be set there and pass to powerd. PR: 258320 MFC after: 3 days Reported by: Michael --- usr.sbin/powerd/powerd.8 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/powerd/powerd.8 b/usr.sbin/powerd/powerd.8 index eb0d84292207..9c5133f536d7 100644 --- a/usr.sbin/powerd/powerd.8 +++ b/usr.sbin/powerd/powerd.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 3, 2020 +.Dd November 6, 2021 .Dt POWERD 8 .Os .Sh NAME @@ -143,7 +143,8 @@ The default PID file. .Sh SEE ALSO .Xr acpi 4 , .Xr apm 4 , -.Xr cpufreq 4 +.Xr cpufreq 4 , +.Xr rc.conf 5 .Sh HISTORY The .Nm From nobody Sun Nov 7 09:19: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 0E4FC183C657; Sun, 7 Nov 2021 09:19: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 4Hn7xP6xShz3hdb; Sun, 7 Nov 2021 09:19: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 C97A61BC8A; Sun, 7 Nov 2021 09:19: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 1A79JrZf056688; Sun, 7 Nov 2021 09:19:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A79JrgM056687; Sun, 7 Nov 2021 09:19:53 GMT (envelope-from git) Date: Sun, 7 Nov 2021 09:19:53 GMT Message-Id: <202111070919.1A79JrgM056687@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: a90ff3c4bc90 - main - linux: Add ptrace(2) support on arm64 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: a90ff3c4bc901947a040717f39d5b3b8778047fe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=a90ff3c4bc901947a040717f39d5b3b8778047fe commit a90ff3c4bc901947a040717f39d5b3b8778047fe Author: Edward Tomasz Napierala AuthorDate: 2021-11-07 08:22:41 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-11-07 08:39:24 +0000 linux: Add ptrace(2) support on arm64 This moves linux_ptrace.c from sys/amd64/linux/ to sys/compat/linux/, making it possible to use it on architectures other than amd64. It also enables Linux ptrace(2) on arm64. Relnotes: yes Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D32868 --- sys/arm64/linux/linux_ptrace.c | 56 ------------------------------ sys/compat/linux/linux_misc.c | 2 +- sys/compat/linux/linux_misc.h | 2 +- sys/{amd64 => compat}/linux/linux_ptrace.c | 0 4 files changed, 2 insertions(+), 58 deletions(-) diff --git a/sys/arm64/linux/linux_ptrace.c b/sys/arm64/linux/linux_ptrace.c deleted file mode 100644 index a7d53470a12d..000000000000 --- a/sys/arm64/linux/linux_ptrace.c +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (C) 2018 Turing Robotic Industries Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include -#include - -/* DTrace init */ -LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); - -/* DTrace probes */ -LIN_SDT_PROBE_DEFINE0(ptrace, linux_ptrace, todo); - -int -linux_ptrace(struct thread *td, struct linux_ptrace_args *uap) -{ - - /* LINUXTODO: implement arm64 linux_ptrace */ - LIN_SDT_PROBE0(ptrace, linux_ptrace, todo); - return (EDOOFUS); -} diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 559eb6463da0..5ae4051aaf38 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1024,7 +1024,7 @@ linux_common_wait(struct thread *td, int pid, int *statusp, } else if (WIFSTOPPED(tmpstat)) { tmpstat = (tmpstat & 0xffff00ff) | (bsd_to_linux_signal(WSTOPSIG(tmpstat)) << 8); -#if defined(__amd64__) && !defined(COMPAT_LINUX32) +#if defined(__aarch64__) || (defined(__amd64__) && !defined(COMPAT_LINUX32)) if (WSTOPSIG(status) == SIGTRAP) { tmpstat = linux_ptrace_status(td, siginfo.si_pid, tmpstat); diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index ceb140d3da75..bf8f3dd2f0cd 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -153,7 +153,7 @@ extern int stclohz; /* Linux syslog flags */ #define LINUX_SYSLOG_ACTION_READ_ALL 3 -#if defined(__amd64__) && !defined(COMPAT_LINUX32) +#if defined(__aarch64__) || (defined(__amd64__) && !defined(COMPAT_LINUX32)) int linux_ptrace_status(struct thread *td, int pid, int status); #endif void linux_to_bsd_waitopts(int options, int *bsdopts); diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/compat/linux/linux_ptrace.c similarity index 100% rename from sys/amd64/linux/linux_ptrace.c rename to sys/compat/linux/linux_ptrace.c From nobody Sun Nov 7 13:04: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 699001841EDF; Sun, 7 Nov 2021 13:04: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 4HnDx62Vx4z3tFg; Sun, 7 Nov 2021 13:04: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 35DCD1ED08; Sun, 7 Nov 2021 13:04: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 1A7D4wjv061878; Sun, 7 Nov 2021 13:04:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A7D4wSj061877; Sun, 7 Nov 2021 13:04:58 GMT (envelope-from git) Date: Sun, 7 Nov 2021 13:04:58 GMT Message-Id: <202111071304.1A7D4wSj061877@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: 3d6ed119e3fe - main - usb_audio: Fix a typo in a source code comment 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: 3d6ed119e3fe123b7e18adf8672c45ab81068527 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=3d6ed119e3fe123b7e18adf8672c45ab81068527 commit 3d6ed119e3fe123b7e18adf8672c45ab81068527 Author: Gordon Bergling AuthorDate: 2021-11-07 13:04:26 +0000 Commit: Gordon Bergling CommitDate: 2021-11-07 13:04:26 +0000 usb_audio: Fix a typo in a source code comment - s/maxium/maximum/ MFC after: 3 days --- sys/dev/sound/usb/uaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 538e4180f6de..3a7d4189b9ef 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -1588,7 +1588,7 @@ uaudio20_check_rate(struct usb_device *udev, uint8_t iface_no, { struct usb_device_request req; usb_error_t error; -#define UAUDIO20_MAX_RATES 32 /* we support at maxium 32 rates */ +#define UAUDIO20_MAX_RATES 32 /* we support at maximum 32 rates */ uint8_t data[2 + UAUDIO20_MAX_RATES * 12]; uint16_t actlen; uint16_t rates; From nobody Sun Nov 7 13:08: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 5B0E1184299D; Sun, 7 Nov 2021 13:08: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 4HnF1026v2z3tQr; Sun, 7 Nov 2021 13:08: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 257221ECF4; Sun, 7 Nov 2021 13:08: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 1A7D8KZn062209; Sun, 7 Nov 2021 13:08:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A7D8K6j062208; Sun, 7 Nov 2021 13:08:20 GMT (envelope-from git) Date: Sun, 7 Nov 2021 13:08:20 GMT Message-Id: <202111071308.1A7D8K6j062208@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: 2b0f6ad444c0 - main - efi(8): Fix a typo in a source code comment 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: 2b0f6ad444c0ec82facf55c0ee4806c2ba217daa 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=2b0f6ad444c0ec82facf55c0ee4806c2ba217daa commit 2b0f6ad444c0ec82facf55c0ee4806c2ba217daa Author: Gordon Bergling AuthorDate: 2021-11-07 13:07:24 +0000 Commit: Gordon Bergling CommitDate: 2021-11-07 13:07:24 +0000 efi(8): Fix a typo in a source code comment - s/writting/writing/ MFC after: 3 days --- stand/efi/include/efiuga.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stand/efi/include/efiuga.h b/stand/efi/include/efiuga.h index 28c738e7fbc4..00464b7cb4c0 100644 --- a/stand/efi/include/efiuga.h +++ b/stand/efi/include/efiuga.h @@ -139,7 +139,7 @@ typedef enum { @retval EFI_SUCCESS - The Blt operation completed. @retval EFI_INVALID_PARAMETER - BltOperation is not valid. - @retval EFI_DEVICE_ERROR - A hardware error occurred writting to the video buffer. + @retval EFI_DEVICE_ERROR - A hardware error occurred writing to the video buffer. --*/ typedef From nobody Sun Nov 7 13:13: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 6534518463BC; Sun, 7 Nov 2021 13:13: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 4HnF6g2H3nz3wRL; Sun, 7 Nov 2021 13:13: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 2C1051EAB3; Sun, 7 Nov 2021 13:13: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 1A7DDFtj074935; Sun, 7 Nov 2021 13:13:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A7DDFlV074934; Sun, 7 Nov 2021 13:13:15 GMT (envelope-from git) Date: Sun, 7 Nov 2021 13:13:15 GMT Message-Id: <202111071313.1A7DDFlV074934@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: e9c7c6f5a021 - main - e1000: Fix a typo in a source code comment 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: e9c7c6f5a021a02c5af2fa446d31cf3756b58d62 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=e9c7c6f5a021a02c5af2fa446d31cf3756b58d62 commit e9c7c6f5a021a02c5af2fa446d31cf3756b58d62 Author: Gordon Bergling AuthorDate: 2021-11-07 13:12:23 +0000 Commit: Gordon Bergling CommitDate: 2021-11-07 13:12:23 +0000 e1000: Fix a typo in a source code comment - s/overwritting/overwriting/ MFC after: 3 days --- sys/dev/e1000/e1000_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/e1000/e1000_phy.c b/sys/dev/e1000/e1000_phy.c index 872a5267bfdb..5c346b2163de 100644 --- a/sys/dev/e1000/e1000_phy.c +++ b/sys/dev/e1000/e1000_phy.c @@ -474,7 +474,7 @@ s32 e1000_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data) DEBUGFUNC("e1000_write_phy_reg_i2c"); - /* Prevent overwritting SFP I2C EEPROM which is at A0 address.*/ + /* Prevent overwriting SFP I2C EEPROM which is at A0 address.*/ if ((hw->phy.addr == 0) || (hw->phy.addr > 7)) { DEBUGOUT1("PHY I2C Address %d is out of range.\n", hw->phy.addr); From nobody Sun Nov 7 15:19: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 34074183F013; Sun, 7 Nov 2021 15:19: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 4HnHwj0nvpz3L6w; Sun, 7 Nov 2021 15:19: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 EF9D020060; Sun, 7 Nov 2021 15:19: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 1A7FJmqj034547; Sun, 7 Nov 2021 15:19:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A7FJmf9034546; Sun, 7 Nov 2021 15:19:48 GMT (envelope-from git) Date: Sun, 7 Nov 2021 15:19:48 GMT Message-Id: <202111071519.1A7FJmf9034546@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mariusz Zaborski Subject: git: 597b02675751 - main - libc: add clearenv 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: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 597b02675751e48dd04777f1e91fee382bf3a966 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=597b02675751e48dd04777f1e91fee382bf3a966 commit 597b02675751e48dd04777f1e91fee382bf3a966 Author: Mariusz Zaborski AuthorDate: 2021-11-07 15:15:28 +0000 Commit: Mariusz Zaborski CommitDate: 2021-11-07 15:20:15 +0000 libc: add clearenv function The clearenv(3) function allows us to clear all environment variable in one shot. This may be useful for security programs that want to control the environment or what variables are passed to new spawned programs. Reviewed by: scf, markj (secteam), 0mp (manpages) Differential Revision: https://reviews.freebsd.org/D28223 --- include/stdlib.h | 2 + lib/libc/stdlib/Makefile.inc | 3 +- lib/libc/stdlib/Symbol.map | 4 + lib/libc/stdlib/getenv.3 | 20 +++- lib/libc/stdlib/getenv.c | 25 +++++ lib/libc/tests/stdlib/Makefile | 1 + lib/libc/tests/stdlib/clearenv_test.c | 176 ++++++++++++++++++++++++++++++++++ 7 files changed, 228 insertions(+), 3 deletions(-) diff --git a/include/stdlib.h b/include/stdlib.h index ca96c06b83b7..bf1a612190ee 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -283,6 +283,8 @@ int cgetset(const char *); int cgetstr(char *, const char *, char **); int cgetustr(char *, const char *, char **); +int clearenv(void); + int daemon(int, int); int daemonfd(int, int); char *devname(__dev_t, __mode_t); diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index 361761e73fdd..a658fd78e862 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -46,7 +46,8 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 \ MLINKS+=a64l.3 l64a.3 a64l.3 l64a_r.3 MLINKS+=atol.3 atoll.3 MLINKS+=exit.3 _Exit.3 -MLINKS+=getenv.3 putenv.3 getenv.3 setenv.3 getenv.3 unsetenv.3 +MLINKS+=getenv.3 clearenv.3 getenv.3 putenv.3 getenv.3 setenv.3 \ + getenv.3 unsetenv.3 MLINKS+=getopt_long.3 getopt_long_only.3 MLINKS+=hcreate.3 hdestroy.3 hcreate.3 hsearch.3 MLINKS+=hcreate.3 hcreate_r.3 hcreate.3 hdestroy_r.3 hcreate.3 hsearch_r.3 diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map index 2be23390e333..6524c6097b96 100644 --- a/lib/libc/stdlib/Symbol.map +++ b/lib/libc/stdlib/Symbol.map @@ -128,6 +128,10 @@ FBSD_1.6 { srand; }; +FBSD_1.7 { + clearenv; +}; + FBSDprivate_1.0 { __system; _system; diff --git a/lib/libc/stdlib/getenv.3 b/lib/libc/stdlib/getenv.3 index e662b86d214b..5566d7b01dcd 100644 --- a/lib/libc/stdlib/getenv.3 +++ b/lib/libc/stdlib/getenv.3 @@ -32,10 +32,11 @@ .\" @(#)getenv.3 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd June 20, 2007 +.Dd November 7, 2021 .Dt GETENV 3 .Os .Sh NAME +.Nm clearenv , .Nm getenv , .Nm putenv , .Nm setenv , @@ -45,6 +46,8 @@ .Lb libc .Sh SYNOPSIS .In stdlib.h +.Ft int +.Fn clearenv "void" .Ft char * .Fn getenv "const char *name" .Ft int @@ -59,6 +62,14 @@ host .Em environment list . .Pp The +.Fn clearenv +function clears all environment variables. +New variables can be added using +.Fn setenv +and +.Fn putenv . +.Pp +The .Fn getenv function obtains the current value of the environment variable, .Fa name . @@ -128,7 +139,7 @@ is not in the current environment, .Dv NULL is returned. .Pp -.Rv -std setenv putenv unsetenv +.Rv -std clearenv setenv putenv unsetenv .Sh ERRORS .Bl -tag -width Er .It Bq Er EINVAL @@ -211,6 +222,11 @@ This was changed to use as the memory location of the ``name=value'' pair to follow the .Tn POSIX specification. +.Pp +The +.Fn clearenv +was added in +.Fx 14 . .Sh BUGS Successive calls to .Fn setenv diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index 5d445e18d93b..bf79cb6b0d79 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -691,3 +691,28 @@ unsetenv(const char *name) return (0); } + +/* + * Unset all variable by flagging them as inactive. No variable is + * ever freed. + */ +int +clearenv(void) +{ + int ndx; + + /* Initialize environment. */ + if (__merge_environ() == -1 || (envVars == NULL && __build_env() == -1)) + return (-1); + + /* Remove from the end to not shuffle memory too much. */ + for (ndx = envVarsTotal - 1; ndx >= 0; ndx--) { + envVars[ndx].active = false; + if (envVars[ndx].putenv) + __remove_putenv(ndx); + } + + __rebuild_environ(0); + + return (0); +} diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index bd85efcb1b95..ffba83443a9e 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -2,6 +2,7 @@ .include +ATF_TESTS_C+= clearenv_test ATF_TESTS_C+= dynthr_test ATF_TESTS_C+= heapsort_test ATF_TESTS_C+= mergesort_test diff --git a/lib/libc/tests/stdlib/clearenv_test.c b/lib/libc/tests/stdlib/clearenv_test.c new file mode 100644 index 000000000000..0c705bfece1e --- /dev/null +++ b/lib/libc/tests/stdlib/clearenv_test.c @@ -0,0 +1,176 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (C) 2021 Mariusz Zaborski + * + * 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. + */ + +/* + * Test for clearenv(3) routine. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include + +#define TEST_VARIABLE "TEST_VAR" +#define TEST_SYSTEM_VARIABLE "PWD" + +extern char **environ; + +void +create_multiple_variables(int num) +{ + char name[64]; + char value[64]; + int i; + + for (i = 0; i < num; i++) { + snprintf(name, sizeof(name), "%s_%d", TEST_VARIABLE, i); + snprintf(value, sizeof(value), "%d", i); + ATF_CHECK(getenv(name) == NULL); + ATF_CHECK(setenv(name, value, 0) != -1); + ATF_CHECK_STREQ(getenv(name), value); + } +} + +void +check_if_nulled_variables(int num) +{ + char name[64]; + int i; + + for (i = 0; i < num; i++) { + snprintf(name, sizeof(name), "%s_%d", TEST_VARIABLE, i); + ATF_CHECK(getenv(name) == NULL); + } +} + +ATF_TC_WITHOUT_HEAD(clearenv__single_var_test); +ATF_TC_BODY(clearenv__single_var_test, tc) +{ + + ATF_CHECK(setenv(TEST_VARIABLE, "true", 0) != -1); + ATF_CHECK_STREQ(getenv(TEST_VARIABLE), "true"); + ATF_CHECK(clearenv() == 0); + ATF_CHECK(getenv(TEST_VARIABLE) == NULL); +} + +ATF_TC_WITHOUT_HEAD(clearenv__multiple_vars_test); +ATF_TC_BODY(clearenv__multiple_vars_test, tc) +{ + + create_multiple_variables(10); + ATF_CHECK(clearenv() == 0); + check_if_nulled_variables(10); +} + +ATF_TC_WITHOUT_HEAD(clearenv__recreated_vars_test); +ATF_TC_BODY(clearenv__recreated_vars_test, tc) +{ + + create_multiple_variables(10); + ATF_CHECK(clearenv() == 0); + check_if_nulled_variables(10); + create_multiple_variables(10); +} + +ATF_TC_WITHOUT_HEAD(clearenv__system_var_test); +ATF_TC_BODY(clearenv__system_var_test, tc) +{ + + ATF_CHECK(getenv(TEST_SYSTEM_VARIABLE) != NULL); + ATF_CHECK(clearenv() == 0); + ATF_CHECK(getenv(TEST_SYSTEM_VARIABLE) == NULL); +} + +ATF_TC_WITHOUT_HEAD(clearenv__recreated_system_var_test); +ATF_TC_BODY(clearenv__recreated_system_var_test, tc) +{ + + ATF_CHECK(getenv(TEST_SYSTEM_VARIABLE) != NULL); + ATF_CHECK(clearenv() == 0); + ATF_CHECK(getenv(TEST_SYSTEM_VARIABLE) == NULL); + ATF_CHECK(setenv(TEST_SYSTEM_VARIABLE, "test", 0) != -1); + ATF_CHECK_STREQ(getenv(TEST_SYSTEM_VARIABLE), "test"); +} + +ATF_TC_WITHOUT_HEAD(clearenv__double_clear_vars); +ATF_TC_BODY(clearenv__double_clear_vars, tc) +{ + + create_multiple_variables(10); + ATF_CHECK(clearenv() == 0); + check_if_nulled_variables(10); + ATF_CHECK(clearenv() == 0); + check_if_nulled_variables(10); + create_multiple_variables(10); +} + +ATF_TC_WITHOUT_HEAD(clearenv__environ_null); +ATF_TC_BODY(clearenv__environ_null, tc) +{ + + ATF_CHECK(clearenv() == 0); + ATF_CHECK(environ == NULL); +} + +ATF_TC_WITHOUT_HEAD(clearenv__putenv_vars); +ATF_TC_BODY(clearenv__putenv_vars, tc) +{ + char buf[64], ref[64]; + + snprintf(buf, sizeof(buf), "%s=1", TEST_VARIABLE); + strcpy(ref, buf); + + ATF_CHECK(getenv(TEST_VARIABLE) == NULL); + ATF_CHECK(putenv(buf) != -1); + ATF_CHECK(strcmp(getenv(TEST_VARIABLE), "1") == 0); + + ATF_CHECK(clearenv() == 0); + + ATF_CHECK(getenv(TEST_VARIABLE) == NULL); + ATF_CHECK(strcmp(buf, ref) == 0); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, clearenv__single_var_test); + ATF_TP_ADD_TC(tp, clearenv__multiple_vars_test); + ATF_TP_ADD_TC(tp, clearenv__recreated_vars_test); + + ATF_TP_ADD_TC(tp, clearenv__system_var_test); + ATF_TP_ADD_TC(tp, clearenv__recreated_system_var_test); + + ATF_TP_ADD_TC(tp, clearenv__double_clear_vars); + ATF_TP_ADD_TC(tp, clearenv__environ_null); + + ATF_TP_ADD_TC(tp, clearenv__putenv_vars); + + return (atf_no_error()); +} From nobody Sun Nov 7 19:46: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 040CE1835AAA; Sun, 7 Nov 2021 19:46: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 4HnPr56jyDz4Zh5; Sun, 7 Nov 2021 19:46: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 C4A0F23ECE; Sun, 7 Nov 2021 19:46: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 1A7JkD5M093252; Sun, 7 Nov 2021 19:46:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A7JkDrS093251; Sun, 7 Nov 2021 19:46:13 GMT (envelope-from git) Date: Sun, 7 Nov 2021 19:46:13 GMT Message-Id: <202111071946.1A7JkDrS093251@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: a7e014eee5d4 - main - nfsd: Fix the NFSv4 pNFS MDS server for DS NFSERR_NOSPC 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: a7e014eee5d47d6eb13bc98c71e65d00a6de8ed3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=a7e014eee5d47d6eb13bc98c71e65d00a6de8ed3 commit a7e014eee5d47d6eb13bc98c71e65d00a6de8ed3 Author: Rick Macklem AuthorDate: 2021-11-07 19:43:03 +0000 Commit: Rick Macklem CommitDate: 2021-11-07 19:43:03 +0000 nfsd: Fix the NFSv4 pNFS MDS server for DS NFSERR_NOSPC If a pNFS server's DS runs out of disk space, it replies NFSERR_NOSPC to the client doing writing. For the Linux client, it then sends a LayoutError RPC to the server to tell it about the error and keeps retrying, doing repeated LayoutGet and Write RPCs to the DS. The Linux client is "stuck" until disk space on the DS is free'd up. For a mirrored server configuration, the first mirror that ran out of space was taken offline. This does not make much sense, since the other mirror(s) will run out of space soon and the fix is a manual cleanup up disk space. This patch changes the pNFS server to not disable a mirror for the mirrored case when this occurs. Further work is needed, since the Linux client expects the MDS to reply NFSERR_NOSPC to LayoutGets once the DS is out of space. Without this further change, the above mentioned looping occurs. Found during a recent IEFT NFSv4 working group testing event. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdserv.c | 7 ++++--- sys/fs/nfsserver/nfs_nfsdstate.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index fca1df3a716a..4d92cb61614d 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -5046,10 +5046,11 @@ nfsrvd_layouterror(struct nfsrv_descript *nd, __unused int isdgram, opnum = fxdr_unsigned(int, *tl); NFSD_DEBUG(4, "nfsrvd_layouterr op=%d stat=%d\n", opnum, stat); /* - * Except for NFSERR_ACCES and NFSERR_STALE errors, - * disable the mirror. + * Except for NFSERR_ACCES, NFSERR_STALE and NFSERR_NOSPC + * errors, disable the mirror. */ - if (stat != NFSERR_ACCES && stat != NFSERR_STALE) + if (stat != NFSERR_ACCES && stat != NFSERR_STALE && + stat != NFSERR_NOSPC) nfsrv_delds(devid, curthread); } nfsmout: diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 750eda2027ec..797b9b0a466e 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -7009,10 +7009,11 @@ nfsrv_flexlayouterr(struct nfsrv_descript *nd, uint32_t *layp, int maxcnt, NFSD_DEBUG(4, "flexlayouterr op=%d stat=%d\n", opnum, stat); /* - * Except for NFSERR_ACCES and NFSERR_STALE errors, - * disable the mirror. + * Except for NFSERR_ACCES, NFSERR_STALE and + * NFSERR_NOSPC errors, disable the mirror. */ - if (stat != NFSERR_ACCES && stat != NFSERR_STALE) + if (stat != NFSERR_ACCES && stat != NFSERR_STALE && + stat != NFSERR_NOSPC) nfsrv_delds(devid, p); } }